diff --git a/src/lib/Fallback/Fallback.svelte.test.ts b/src/lib/Fallback/Fallback.svelte.test.ts index 8aa725c..9fba6de 100644 --- a/src/lib/Fallback/Fallback.svelte.test.ts +++ b/src/lib/Fallback/Fallback.svelte.test.ts @@ -1,4 +1,4 @@ -import { init } from "$lib/index.js"; +import { init } from "$lib/init.js"; import { describe, test, expect, beforeAll, afterAll, beforeEach } from "vitest"; import { render } from "@testing-library/svelte"; import Fallback from "./Fallback.svelte"; diff --git a/src/lib/Link/Link.svelte.test.ts b/src/lib/Link/Link.svelte.test.ts index 9b2fe0e..07c441c 100644 --- a/src/lib/Link/Link.svelte.test.ts +++ b/src/lib/Link/Link.svelte.test.ts @@ -1,4 +1,5 @@ -import { init, location } from "$lib/index.js"; +import { init } from "$lib/init.js"; +import { location } from "$lib/core/Location.js"; import { describe, test, expect, beforeAll, afterAll, beforeEach, vi } from "vitest"; import { render, fireEvent } from "@testing-library/svelte"; import Link from "./Link.svelte"; @@ -8,26 +9,26 @@ import { flushSync } from "svelte"; function basicLinkTests(setup: ReturnType) { const linkText = "Test Link"; const content = createTestSnippet(linkText); - + beforeEach(() => { // Fresh router instance for each test setup.init(); }); - + afterAll(() => { // Clean disposal after all tests setup.dispose(); }); - + test("Should render an anchor tag with correct href.", async () => { // Arrange. const { hash, context } = setup; const href = "/test/path"; // Act. - const { container } = render(Link, { - props: { hash, href, children: content }, - context + const { container } = render(Link, { + props: { hash, href, children: content }, + context }); const anchor = container.querySelector('a'); @@ -35,16 +36,16 @@ function basicLinkTests(setup: ReturnType) { expect(anchor).toBeDefined(); expect(anchor?.getAttribute('href')).toBeTruthy(); }); - + test("Should render link text content.", async () => { // Arrange. const { hash, context } = setup; const href = "/test/path"; // Act. - const { findByText } = render(Link, { - props: { hash, href, children: content }, - context + const { findByText } = render(Link, { + props: { hash, href, children: content }, + context }); // Assert. @@ -55,12 +56,12 @@ function basicLinkTests(setup: ReturnType) { // Arrange. const { hash, context } = setup; const href = "/test/path"; - const { container } = render(Link, { - props: { hash, href, children: content }, - context + const { container } = render(Link, { + props: { hash, href, children: content }, + context }); const anchor = container.querySelector('a'); - + // Act. const clickEvent = new MouseEvent('click', { bubbles: true }); const preventDefaultSpy = vi.spyOn(clickEvent, 'preventDefault'); @@ -75,12 +76,12 @@ function basicLinkTests(setup: ReturnType) { const { hash, context } = setup; const href = "/test/path"; const goToSpy = vi.spyOn(location, 'goTo'); - const { container } = render(Link, { - props: { hash, href, children: content }, - context + const { container } = render(Link, { + props: { hash, href, children: content }, + context }); const anchor = container.querySelector('a'); - + // Act. await fireEvent.click(anchor!); @@ -92,11 +93,11 @@ function basicLinkTests(setup: ReturnType) { function hrefCalculationTests(setup: ReturnType) { const linkText = "Test Link"; const content = createTestSnippet(linkText); - + beforeEach(() => { setup.init(); }); - + afterAll(() => { setup.dispose(); }); @@ -107,9 +108,9 @@ function hrefCalculationTests(setup: ReturnType) { const href = "/test/path"; // Act. - const { container } = render(Link, { - props: { hash, href, children: content }, - context + const { container } = render(Link, { + props: { hash, href, children: content }, + context }); const anchor = container.querySelector('a'); @@ -121,11 +122,11 @@ function hrefCalculationTests(setup: ReturnType) { // Arrange. const { hash, context } = setup; const href = "/test/path?new=value"; - + // Act. - const { container } = render(Link, { - props: { hash, href, preserveQuery: true, children: content }, - context + const { container } = render(Link, { + props: { hash, href, preserveQuery: true, children: content }, + context }); const anchor = container.querySelector('a'); @@ -137,7 +138,7 @@ function hrefCalculationTests(setup: ReturnType) { // Arrange. const { hash, router, context } = setup; const href = "/test/path"; - + // Set base path on router if (router) { Object.defineProperty(router, 'basePath', { @@ -147,9 +148,9 @@ function hrefCalculationTests(setup: ReturnType) { } // Act. - const { container } = render(Link, { - props: { hash, href, prependBasePath: true, children: content }, - context + const { container } = render(Link, { + props: { hash, href, prependBasePath: true, children: content }, + context }); const anchor = container.querySelector('a'); @@ -161,11 +162,11 @@ function hrefCalculationTests(setup: ReturnType) { function activeStateTests(setup: ReturnType) { const linkText = "Test Link"; const content = createTestSnippet(linkText); - + beforeEach(() => { setup.init(); }); - + afterAll(() => { setup.dispose(); }); @@ -175,7 +176,7 @@ function activeStateTests(setup: ReturnType) { const { hash, router, context } = setup; const href = "/test/path"; const activeKey = "test-route"; - + // Mock active route status if (router) { Object.defineProperty(router, 'routeStatus', { @@ -185,14 +186,14 @@ function activeStateTests(setup: ReturnType) { } // Act. - const { container } = render(Link, { - props: { - hash, - href, + const { container } = render(Link, { + props: { + hash, + href, activeState: { key: activeKey, class: "active-link" }, - children: content - }, - context + children: content + }, + context }); const anchor = container.querySelector('a'); @@ -205,7 +206,7 @@ function activeStateTests(setup: ReturnType) { const { hash, router, context } = setup; const href = "/test/path"; const activeKey = "test-route"; - + // Mock active route status if (router) { Object.defineProperty(router, 'routeStatus', { @@ -215,14 +216,14 @@ function activeStateTests(setup: ReturnType) { } // Act. - const { container } = render(Link, { - props: { - hash, - href, + const { container } = render(Link, { + props: { + hash, + href, activeState: { key: activeKey, style: "color: red;" }, - children: content - }, - context + children: content + }, + context }); const anchor = container.querySelector('a'); @@ -235,7 +236,7 @@ function activeStateTests(setup: ReturnType) { const { hash, router, context } = setup; const href = "/test/path"; const activeKey = "test-route"; - + // Mock active route status if (router) { Object.defineProperty(router, 'routeStatus', { @@ -245,14 +246,14 @@ function activeStateTests(setup: ReturnType) { } // Act. - const { container } = render(Link, { - props: { - hash, - href, + const { container } = render(Link, { + props: { + hash, + href, activeState: { key: activeKey, ariaCurrent: "page" }, - children: content - }, - context + children: content + }, + context }); const anchor = container.querySelector('a'); @@ -265,7 +266,7 @@ function activeStateTests(setup: ReturnType) { const { hash, router, context } = setup; const href = "/test/path"; const activeKey = "test-route"; - + // Mock inactive route status if (router) { Object.defineProperty(router, 'routeStatus', { @@ -275,14 +276,14 @@ function activeStateTests(setup: ReturnType) { } // Act. - const { container } = render(Link, { - props: { - hash, - href, + const { container } = render(Link, { + props: { + hash, + href, activeState: { key: activeKey, class: "active-link" }, - children: content - }, - context + children: content + }, + context }); const anchor = container.querySelector('a'); @@ -295,11 +296,11 @@ function activeStateTests(setup: ReturnType) { function stateHandlingTests(setup: ReturnType) { const linkText = "Test Link"; const content = createTestSnippet(linkText); - + beforeEach(() => { setup.init(); }); - + afterAll(() => { setup.dispose(); }); @@ -310,10 +311,10 @@ function stateHandlingTests(setup: ReturnType) { const href = "/test/path"; const stateObj = { data: "test-state" }; const goToSpy = vi.spyOn(location, 'goTo'); - - const { container } = render(Link, { - props: { hash, href, state: stateObj, children: content }, - context + + const { container } = render(Link, { + props: { hash, href, state: stateObj, children: content }, + context }); const anchor = container.querySelector('a'); @@ -322,11 +323,11 @@ function stateHandlingTests(setup: ReturnType) { // Assert. expect(goToSpy).toHaveBeenCalledWith( - expect.any(String), + expect.any(String), expect.objectContaining({ state: expect.objectContaining({ // State structure varies by routing universe - [hash === false ? 'path' : 'hash']: hash === false + [hash === false ? 'path' : 'hash']: hash === false ? expect.objectContaining(stateObj) : expect.any(Object) }) @@ -341,10 +342,10 @@ function stateHandlingTests(setup: ReturnType) { const stateObj = { data: "function-state" }; const stateFn = vi.fn(() => stateObj); const goToSpy = vi.spyOn(location, 'goTo'); - - const { container } = render(Link, { - props: { hash, href, state: stateFn, children: content }, - context + + const { container } = render(Link, { + props: { hash, href, state: stateFn, children: content }, + context }); const anchor = container.querySelector('a'); @@ -354,11 +355,11 @@ function stateHandlingTests(setup: ReturnType) { // Assert. expect(stateFn).toHaveBeenCalled(); expect(goToSpy).toHaveBeenCalledWith( - expect.any(String), + expect.any(String), expect.objectContaining({ state: expect.objectContaining({ // State structure varies by routing universe - [hash === false ? 'path' : 'hash']: hash === false + [hash === false ? 'path' : 'hash']: hash === false ? expect.objectContaining(stateObj) : expect.any(Object) }) @@ -371,10 +372,10 @@ function stateHandlingTests(setup: ReturnType) { const { hash, context } = setup; const href = "/test/path"; const goToSpy = vi.spyOn(location, 'goTo'); - - const { container } = render(Link, { - props: { hash, href, replace: true, children: content }, - context + + const { container } = render(Link, { + props: { hash, href, replace: true, children: content }, + context }); const anchor = container.querySelector('a'); @@ -383,7 +384,7 @@ function stateHandlingTests(setup: ReturnType) { // Assert. expect(goToSpy).toHaveBeenCalledWith( - expect.any(String), + expect.any(String), expect.objectContaining({ replace: true }) ); }); @@ -392,11 +393,11 @@ function stateHandlingTests(setup: ReturnType) { function reactivityTests(setup: ReturnType) { const linkText = "Test Link"; const content = createTestSnippet(linkText); - + beforeEach(() => { setup.init(); }); - + afterAll(() => { setup.dispose(); }); @@ -407,10 +408,10 @@ function reactivityTests(setup: ReturnType) { const { hash, context } = setup; const initialHref = "/initial/path"; const updatedHref = "/updated/path"; - - const { container, rerender } = render(Link, { - props: { hash, href: initialHref, children: content }, - context + + const { container, rerender } = render(Link, { + props: { hash, href: initialHref, children: content }, + context }); const anchor = container.querySelector('a'); const initialHrefValue = anchor?.getAttribute('href'); @@ -429,10 +430,10 @@ function reactivityTests(setup: ReturnType) { // Arrange. const { hash, context } = setup; let href = $state("/initial/path"); - - const { container } = render(Link, { - props: { hash, get href() { return href; }, children: content }, - context + + const { container } = render(Link, { + props: { hash, get href() { return href; }, children: content }, + context }); const anchor = container.querySelector('a'); const initialHrefValue = anchor?.getAttribute('href'); @@ -452,7 +453,7 @@ function reactivityTests(setup: ReturnType) { const { hash, router, context } = setup; const href = "/test/path"; const activeKey = "test-route"; - + // Mock active route status if (router) { Object.defineProperty(router, 'routeStatus', { @@ -463,10 +464,10 @@ function reactivityTests(setup: ReturnType) { const initialActiveState = { key: activeKey, class: "initial-active" }; const updatedActiveState = { key: activeKey, class: "updated-active" }; - - const { container, rerender } = render(Link, { - props: { hash, href, activeState: initialActiveState, children: content }, - context + + const { container, rerender } = render(Link, { + props: { hash, href, activeState: initialActiveState, children: content }, + context }); const anchor = container.querySelector('a'); expect(anchor?.className).toContain('initial-active'); @@ -484,7 +485,7 @@ function reactivityTests(setup: ReturnType) { const { hash, router, context } = setup; const href = "/test/path"; const activeKey = "test-route"; - + // Mock active route status if (router) { Object.defineProperty(router, 'routeStatus', { @@ -494,15 +495,15 @@ function reactivityTests(setup: ReturnType) { } let activeClass = $state("initial-active"); - - const { container } = render(Link, { - props: { - hash, - href, + + const { container } = render(Link, { + props: { + hash, + href, get activeState() { return { key: activeKey, class: activeClass }; }, - children: content - }, - context + children: content + }, + context }); const anchor = container.querySelector('a'); expect(anchor?.className).toContain('initial-active'); @@ -523,10 +524,10 @@ function reactivityTests(setup: ReturnType) { const initialState = { data: "initial" }; const updatedState = { data: "updated" }; const goToSpy = vi.spyOn(location, 'goTo'); - - const { container, rerender } = render(Link, { - props: { hash, href, state: initialState, children: content }, - context + + const { container, rerender } = render(Link, { + props: { hash, href, state: initialState, children: content }, + context }); const anchor = container.querySelector('a'); @@ -536,10 +537,10 @@ function reactivityTests(setup: ReturnType) { // Assert. expect(goToSpy).toHaveBeenCalledWith( - expect.any(String), + expect.any(String), expect.objectContaining({ state: expect.objectContaining({ - [hash === false ? 'path' : 'hash']: hash === false + [hash === false ? 'path' : 'hash']: hash === false ? expect.objectContaining(updatedState) : expect.any(Object) }) @@ -553,15 +554,15 @@ function reactivityTests(setup: ReturnType) { const href = "/test/path"; let stateData = $state({ data: "initial" }); const goToSpy = vi.spyOn(location, 'goTo'); - - const { container } = render(Link, { - props: { - hash, - href, + + const { container } = render(Link, { + props: { + hash, + href, get state() { return stateData; }, - children: content - }, - context + children: content + }, + context }); const anchor = container.querySelector('a'); @@ -572,10 +573,10 @@ function reactivityTests(setup: ReturnType) { // Assert. expect(goToSpy).toHaveBeenCalledWith( - expect.any(String), + expect.any(String), expect.objectContaining({ state: expect.objectContaining({ - [hash === false ? 'path' : 'hash']: hash === false + [hash === false ? 'path' : 'hash']: hash === false ? expect.objectContaining({ data: "updated" }) : expect.any(Object) }) @@ -587,10 +588,10 @@ function reactivityTests(setup: ReturnType) { // Arrange. const { hash, context } = setup; const href = "/test/path"; - - const { container, rerender } = render(Link, { - props: { hash, href, preserveQuery: false, children: content }, - context + + const { container, rerender } = render(Link, { + props: { hash, href, preserveQuery: false, children: content }, + context }); const anchor = container.querySelector('a'); const initialHref = anchor?.getAttribute('href'); @@ -610,15 +611,15 @@ function reactivityTests(setup: ReturnType) { const baseHref = "/test/path"; let preserveQuery = $state(false); let href = $state(baseHref); - - const { container } = render(Link, { - props: { - hash, + + const { container } = render(Link, { + props: { + hash, get href() { return href; }, get preserveQuery() { return preserveQuery; }, - children: content - }, - context + children: content + }, + context }); const anchor = container.querySelector('a'); const initialHref = anchor?.getAttribute('href'); @@ -639,34 +640,34 @@ ROUTING_UNIVERSES.forEach(ru => { describe(`Link - ${ru.text}`, () => { const setup = createRouterTestSetup(ru.hash); let cleanup: () => void; - + beforeAll(() => { cleanup = init({ implicitMode: ru.implicitMode, hashMode: ru.hashMode, }); }); - + afterAll(() => { cleanup(); }); - + describe("Basic Link Functionality", () => { basicLinkTests(setup); }); - + describe("HREF Calculation", () => { hrefCalculationTests(setup); }); - + describe("Active State Handling", () => { activeStateTests(setup); }); - + describe("State Handling", () => { stateHandlingTests(setup); }); - + describe("Reactivity", () => { reactivityTests(setup); }); diff --git a/src/lib/LinkContext/LinkContext.svelte.test.ts b/src/lib/LinkContext/LinkContext.svelte.test.ts index 95827bd..4d17d87 100644 --- a/src/lib/LinkContext/LinkContext.svelte.test.ts +++ b/src/lib/LinkContext/LinkContext.svelte.test.ts @@ -1,12 +1,11 @@ import { describe, test, expect, beforeEach, vi, beforeAll, afterAll } from "vitest"; import { render } from "@testing-library/svelte"; import LinkContext from "./LinkContext.svelte"; -import Link from "../Link/Link.svelte"; import { createTestSnippet, createRouterTestSetup, ROUTING_UNIVERSES } from "../../testing/test-utils.js"; import { flushSync } from "svelte"; import TestLinkContextNested from "../../testing/TestLinkContextNested.svelte"; import TestLinkContextWithLink from "../../testing/TestLinkContextWithLink.svelte"; -import { init } from "$lib/index.js"; +import { init } from "$lib/init.js"; function defaultPropsTests() { const content = createTestSnippet("Link Context Content"); diff --git a/src/lib/Route/Route.svelte.test.ts b/src/lib/Route/Route.svelte.test.ts index ad8f7f8..f5a7a73 100644 --- a/src/lib/Route/Route.svelte.test.ts +++ b/src/lib/Route/Route.svelte.test.ts @@ -1,10 +1,9 @@ import { describe, test, expect, beforeEach, vi, beforeAll, afterAll } from "vitest"; import { render } from "@testing-library/svelte"; import Route from "./Route.svelte"; -import Router, { getRouterContext } from "../Router/Router.svelte"; import { createTestSnippet, createRouterTestSetup, ROUTING_UNIVERSES } from "../../testing/test-utils.js"; -import { flushSync } from "svelte"; -import { init, location } from "$lib/index.js"; +import { init } from "$lib/init.js"; +import { location } from "$lib/core/Location.js"; import TestRouteWithRouter from "../../testing/TestRouteWithRouter.svelte"; function basicRouteTests(setup: ReturnType) { diff --git a/src/lib/Router/Router.svelte.test.ts b/src/lib/Router/Router.svelte.test.ts index a85cf7c..7643d59 100644 --- a/src/lib/Router/Router.svelte.test.ts +++ b/src/lib/Router/Router.svelte.test.ts @@ -1,11 +1,10 @@ import { describe, test, expect, beforeEach, vi, beforeAll, afterAll } from "vitest"; import { render } from "@testing-library/svelte"; -import { getContext } from "svelte"; -import Router, { getRouterContext, getRouterContextKey } from "./Router.svelte"; +import Router, { getRouterContextKey } from "./Router.svelte"; import { RouterEngine } from "$lib/core/RouterEngine.svelte.js"; import { createTestSnippet, createRouterTestSetup, ROUTING_UNIVERSES } from "../../testing/test-utils.js"; import { flushSync } from "svelte"; -import { init } from "$lib/index.js"; +import { init } from "$lib/init.js"; function basicRouterTests(setup: ReturnType) { beforeEach(() => { diff --git a/src/lib/core/InterceptedHistoryApi.svelte.test.ts b/src/lib/core/InterceptedHistoryApi.svelte.test.ts index e1ce7db..3667eeb 100644 --- a/src/lib/core/InterceptedHistoryApi.svelte.test.ts +++ b/src/lib/core/InterceptedHistoryApi.svelte.test.ts @@ -1,6 +1,6 @@ import { describe, test, expect, beforeEach, afterEach, vi } from "vitest"; import { InterceptedHistoryApi } from "./InterceptedHistoryApi.svelte.js"; -import type { State, BeforeNavigateEvent, NavigationCancelledEvent } from "$lib/types.js"; +import type { State, BeforeNavigateEvent } from "../types.js"; import { setupBrowserMocks } from "../../testing/test-utils.js"; describe("InterceptedHistoryApi", () => { diff --git a/src/lib/core/InterceptedHistoryApi.svelte.ts b/src/lib/core/InterceptedHistoryApi.svelte.ts index d14b505..e25be86 100644 --- a/src/lib/core/InterceptedHistoryApi.svelte.ts +++ b/src/lib/core/InterceptedHistoryApi.svelte.ts @@ -1,4 +1,4 @@ -import type { BeforeNavigateEvent, NavigationCancelledEvent, NavigationEvent, State, FullModeHistoryApi, Events } from "$lib/types.js"; +import type { BeforeNavigateEvent, NavigationCancelledEvent, NavigationEvent, State, FullModeHistoryApi, Events } from "../types.js"; import { isConformantState } from "./isConformantState.js"; import { StockHistoryApi } from "./StockHistoryApi.svelte.js"; import { logger } from "./Logger.js"; diff --git a/src/lib/core/Location.test.ts b/src/lib/core/Location.test.ts index 791bf02..55ed051 100644 --- a/src/lib/core/Location.test.ts +++ b/src/lib/core/Location.test.ts @@ -1,4 +1,4 @@ -import { location, setLocation } from "$lib/core/Location.js"; +import { location, setLocation } from "./Location.js"; import { describe, test, expect, afterEach } from "vitest"; import { LocationLite } from "./LocationLite.svelte.js"; diff --git a/src/lib/core/Location.ts b/src/lib/core/Location.ts index 1afb7f5..e1ab2ab 100644 --- a/src/lib/core/Location.ts +++ b/src/lib/core/Location.ts @@ -1,4 +1,4 @@ -import type { Location, State } from "$lib/types.js"; +import type { Location } from "../types.js"; /** * Internal symbol for accessing complete state from Location implementations. diff --git a/src/lib/core/LocationFull.test.ts b/src/lib/core/LocationFull.test.ts index 9927709..f457dc9 100644 --- a/src/lib/core/LocationFull.test.ts +++ b/src/lib/core/LocationFull.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; import { LocationFull } from "./LocationFull.js"; -import type { State, Location, FullModeHistoryApi } from "$lib/types.js"; +import type { State, Location, FullModeHistoryApi } from "../types.js"; import { setupBrowserMocks, ALL_HASHES } from "../../testing/test-utils.js"; import { SvelteURL } from "svelte/reactivity"; diff --git a/src/lib/core/LocationFull.ts b/src/lib/core/LocationFull.ts index 27e7c13..b7c357f 100644 --- a/src/lib/core/LocationFull.ts +++ b/src/lib/core/LocationFull.ts @@ -1,4 +1,4 @@ -import type { BeforeNavigateEvent, NavigationCancelledEvent, FullModeHistoryApi, Events } from "$lib/types.js"; +import type { BeforeNavigateEvent, NavigationCancelledEvent, FullModeHistoryApi, Events } from "../types.js"; import { LocationLite } from "./LocationLite.svelte.js"; import { InterceptedHistoryApi } from "./InterceptedHistoryApi.svelte.js"; diff --git a/src/lib/core/LocationLite.svelte.test.ts b/src/lib/core/LocationLite.svelte.test.ts index 3334ea6..c816158 100644 --- a/src/lib/core/LocationLite.svelte.test.ts +++ b/src/lib/core/LocationLite.svelte.test.ts @@ -1,7 +1,7 @@ import { describe, test, expect, beforeEach, afterEach, vi } from "vitest"; import { LocationLite } from "./LocationLite.svelte.js"; -import type { Hash, HistoryApi, Location } from "$lib/types.js"; -import { setupBrowserMocks, ROUTING_UNIVERSES, ALL_HASHES } from "../../testing/test-utils.js"; +import type { Hash, HistoryApi } from "../types.js"; +import { setupBrowserMocks, ALL_HASHES } from "../../testing/test-utils.js"; import { SvelteURL } from "svelte/reactivity"; describe("LocationLite", () => { diff --git a/src/lib/core/LocationState.svelte.test.ts b/src/lib/core/LocationState.svelte.test.ts index 2c42112..f19e3db 100644 --- a/src/lib/core/LocationState.svelte.test.ts +++ b/src/lib/core/LocationState.svelte.test.ts @@ -1,6 +1,6 @@ import { describe, test, expect, beforeEach, vi } from 'vitest'; import { LocationState } from './LocationState.svelte.js'; -import type { State } from '$lib/types.js'; +import type { State } from '../types.js'; import { logger } from './Logger.js'; // Mock logger.warn to capture warnings diff --git a/src/lib/core/LocationState.svelte.ts b/src/lib/core/LocationState.svelte.ts index 1bcdee5..abfb289 100644 --- a/src/lib/core/LocationState.svelte.ts +++ b/src/lib/core/LocationState.svelte.ts @@ -1,7 +1,7 @@ import { SvelteURL } from "svelte/reactivity"; import { isConformantState } from "./isConformantState.js"; import { logger } from "./Logger.js"; -import type { State } from "$lib/types.js"; +import type { State } from "../types.js"; /** * Helper class used to manage the reactive data of Location implementations. diff --git a/src/lib/core/Logger.test.ts b/src/lib/core/Logger.test.ts index 0d7d3a4..1fa5deb 100644 --- a/src/lib/core/Logger.test.ts +++ b/src/lib/core/Logger.test.ts @@ -1,6 +1,6 @@ import { describe, test, expect, beforeEach, afterEach, vi } from "vitest"; import { logger, resetLogger, setLogger } from "./Logger.js"; -import type { ILogger } from "$lib/types.js"; +import type { ILogger } from "../types.js"; describe("logger", () => { test("Should default to offLogger when the library hasn't been initialized.", () => { diff --git a/src/lib/core/Logger.ts b/src/lib/core/Logger.ts index bb07ec9..8aeecf4 100644 --- a/src/lib/core/Logger.ts +++ b/src/lib/core/Logger.ts @@ -1,4 +1,4 @@ -import type { ILogger } from "$lib/types.js"; +import type { ILogger } from "../types.js"; const stockLogger: ILogger = globalThis.console; diff --git a/src/lib/core/RouterEngine.svelte.test.ts b/src/lib/core/RouterEngine.svelte.test.ts index b2787b5..48b75da 100644 --- a/src/lib/core/RouterEngine.svelte.test.ts +++ b/src/lib/core/RouterEngine.svelte.test.ts @@ -1,9 +1,9 @@ import { describe, test, expect, beforeAll, afterAll, afterEach, vi, beforeEach } from "vitest"; import { routePatternsKey, RouterEngine } from "./RouterEngine.svelte.js"; -import { init, type RouteInfo } from "$lib/index.js"; +import { init } from "../init.js"; import { registerRouter } from "./trace.svelte.js"; import { location } from "./Location.js"; -import type { State } from "$lib/types.js"; +import type { State, RouteInfo } from "../types.js"; import { setupBrowserMocks, addRoutes, ROUTING_UNIVERSES, ALL_HASHES } from "../../testing/test-utils.js"; describe("RouterEngine", () => { diff --git a/src/lib/core/RouterEngine.svelte.ts b/src/lib/core/RouterEngine.svelte.ts index b33acc8..7ea7002 100644 --- a/src/lib/core/RouterEngine.svelte.ts +++ b/src/lib/core/RouterEngine.svelte.ts @@ -1,4 +1,4 @@ -import type { AndUntyped, Hash, PatternRouteInfo, RegexRouteInfo, RouteInfo, RouteStatus } from "$lib/types.js"; +import type { AndUntyped, Hash, PatternRouteInfo, RegexRouteInfo, RouteInfo, RouteStatus } from "../types.js"; import { traceOptions, registerRouter, unregisterRouter } from "./trace.svelte.js"; import { location } from "./Location.js"; import { routingOptions } from "./options.js"; diff --git a/src/lib/core/StockHistoryApi.svelte.ts b/src/lib/core/StockHistoryApi.svelte.ts index 1dc52e0..de5943f 100644 --- a/src/lib/core/StockHistoryApi.svelte.ts +++ b/src/lib/core/StockHistoryApi.svelte.ts @@ -1,5 +1,5 @@ import { on } from "svelte/events"; -import type { HistoryApi, State } from "$lib/types.js"; +import type { HistoryApi, State } from "../types.js"; import { LocationState } from "./LocationState.svelte.js"; /** diff --git a/src/lib/core/calculateHref.test.ts b/src/lib/core/calculateHref.test.ts index b199d05..dcf4a23 100644 --- a/src/lib/core/calculateHref.test.ts +++ b/src/lib/core/calculateHref.test.ts @@ -1,6 +1,7 @@ import { describe, test, expect, beforeAll, afterAll, beforeEach } from "vitest"; import { calculateHref, type CalculateHrefOptions } from "./calculateHref.js"; -import { init, location } from "$lib/index.js"; +import { init } from "../init.js"; +import { location } from "./Location.js"; import { ROUTING_UNIVERSES, ALL_HASHES } from "../../testing/test-utils.js"; describe("calculateHref", () => { diff --git a/src/lib/core/calculateHref.ts b/src/lib/core/calculateHref.ts index 24c1dd7..05b5e91 100644 --- a/src/lib/core/calculateHref.ts +++ b/src/lib/core/calculateHref.ts @@ -1,4 +1,4 @@ -import type { Hash, PreserveQuery } from "$lib/types.js"; +import type { Hash, PreserveQuery } from "../types.js"; import { dissectHrefs } from "./dissectHrefs.js"; import { location } from "./Location.js"; import { mergeQueryParams } from "./preserveQuery.js"; diff --git a/src/lib/core/calculateState.test.ts b/src/lib/core/calculateState.test.ts index 4d3ff05..175f9fc 100644 --- a/src/lib/core/calculateState.test.ts +++ b/src/lib/core/calculateState.test.ts @@ -1,4 +1,4 @@ -import { init, location } from '$lib/index.js'; +import { init } from '../init.js'; import { describe, test, expect, beforeAll, afterAll, beforeEach } from 'vitest'; import { calculateState } from './calculateState.js'; import { ROUTING_UNIVERSES, ALL_HASHES, setupBrowserMocks } from '../../testing/test-utils.js'; diff --git a/src/lib/core/calculateState.ts b/src/lib/core/calculateState.ts index 1416a43..8b3379e 100644 --- a/src/lib/core/calculateState.ts +++ b/src/lib/core/calculateState.ts @@ -1,4 +1,4 @@ -import type { Hash, Location, State } from "$lib/types.js"; +import type { Hash, Location, State } from "../types.js"; import { location } from "./Location.js"; import { getCompleteStateKey } from "./Location.js"; import { resolveHashValue } from "./resolveHashValue.js"; diff --git a/src/lib/core/initCore.test.ts b/src/lib/core/initCore.test.ts index 2a46ec3..89f47b3 100644 --- a/src/lib/core/initCore.test.ts +++ b/src/lib/core/initCore.test.ts @@ -1,5 +1,5 @@ -import type { BeforeNavigateEvent, GoToOptions, Hash, Location, NavigationCancelledEvent } from "$lib/types.js"; -import { describe, test, expect, beforeEach, afterEach, vi } from 'vitest'; +import type { Location } from "../types.js"; +import { describe, test, expect, afterEach, vi } from 'vitest'; import { initCore } from './initCore.js'; import { SvelteURL } from "svelte/reactivity"; import { location } from "./Location.js"; diff --git a/src/lib/core/initCore.ts b/src/lib/core/initCore.ts index 9bfdc72..92116fa 100644 --- a/src/lib/core/initCore.ts +++ b/src/lib/core/initCore.ts @@ -1,4 +1,4 @@ -import type { InitOptions, Location } from "$lib/types.js"; +import type { InitOptions, Location } from "../types.js"; import { setLocation } from "./Location.js"; import { resetLogger, setLogger } from "./Logger.js"; import { resetRoutingOptions, setRoutingOptions } from "./options.js"; diff --git a/src/lib/core/isConformantState.ts b/src/lib/core/isConformantState.ts index c1bcb4f..9401ac8 100644 --- a/src/lib/core/isConformantState.ts +++ b/src/lib/core/isConformantState.ts @@ -1,4 +1,4 @@ -import type { State } from "$lib/types.js"; +import type { State } from "../types.js"; /** * Tests the given state data to see if it conforms to the expected `State` structure. diff --git a/src/lib/core/options.ts b/src/lib/core/options.ts index b8e7ec5..eea135b 100644 --- a/src/lib/core/options.ts +++ b/src/lib/core/options.ts @@ -1,4 +1,4 @@ -import type { RoutingOptions } from "$lib/types.js"; +import type { RoutingOptions } from "../types.js"; /** * Default routing options used for rollback. diff --git a/src/lib/core/preserveQuery.test.ts b/src/lib/core/preserveQuery.test.ts index 0acb7df..fa1c1c4 100644 --- a/src/lib/core/preserveQuery.test.ts +++ b/src/lib/core/preserveQuery.test.ts @@ -1,6 +1,7 @@ import { describe, test, expect, beforeAll, afterAll, beforeEach } from 'vitest'; import { preserveQueryInUrl, mergeQueryParams } from './preserveQuery.js'; -import { init, location } from '$lib/index.js'; +import { init } from '../init.js'; +import { location } from './Location.js'; describe('preserveQuery utilities', () => { let cleanup: Function; diff --git a/src/lib/core/preserveQuery.ts b/src/lib/core/preserveQuery.ts index ee5f232..1305591 100644 --- a/src/lib/core/preserveQuery.ts +++ b/src/lib/core/preserveQuery.ts @@ -1,4 +1,4 @@ -import type { PreserveQuery } from "$lib/types.js"; +import type { PreserveQuery } from "../types.js"; import { location } from "./Location.js"; /** diff --git a/src/lib/core/trace.svelte.ts b/src/lib/core/trace.svelte.ts index b80c4fc..6725022 100644 --- a/src/lib/core/trace.svelte.ts +++ b/src/lib/core/trace.svelte.ts @@ -1,4 +1,4 @@ -import type { TraceOptions } from "$lib/types.js"; +import type { TraceOptions } from "../types.js"; import type { RouterEngine } from "./RouterEngine.svelte.js"; /** diff --git a/src/lib/core/trace.test.ts b/src/lib/core/trace.test.ts index a0c37f0..e66089e 100644 --- a/src/lib/core/trace.test.ts +++ b/src/lib/core/trace.test.ts @@ -1,7 +1,7 @@ import { afterAll, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { getAllChildRouters, registerRouter, resetTraceOptions, setTraceOptions, traceOptions } from "./trace.svelte.js"; import { RouterEngine } from "./RouterEngine.svelte.js"; -import { init } from "$lib/index.js"; +import { init } from "../init.js"; vi.mock(import('./trace.svelte.js'), async (importActual) => { const actual = await importActual(); diff --git a/src/lib/index.ts b/src/lib/index.ts index f52d824..06db8f4 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,13 +1,13 @@ -export * from "$lib/init.js"; -export * from "$lib/Link/Link.svelte"; -export { default as Link } from "$lib/Link/Link.svelte"; -export { default as LinkContext } from "$lib/LinkContext/LinkContext.svelte"; -export * from "$lib/Route/Route.svelte"; -export { default as Route } from "$lib/Route/Route.svelte"; -export { getRouterContext, setRouterContext } from "$lib/Router/Router.svelte"; -export { default as Router } from "$lib/Router/Router.svelte"; -export * from "$lib/Fallback/Fallback.svelte"; -export { default as Fallback } from "$lib/Fallback/Fallback.svelte"; +export * from "./init.js"; +export * from "./Link/Link.svelte"; +export { default as Link } from "./Link/Link.svelte"; +export { default as LinkContext } from "./LinkContext/LinkContext.svelte"; +export * from "./Route/Route.svelte"; +export { default as Route } from "./Route/Route.svelte"; +export { getRouterContext, setRouterContext } from "./Router/Router.svelte"; +export { default as Router } from "./Router/Router.svelte"; +export * from "./Fallback/Fallback.svelte"; +export { default as Fallback } from "./Fallback/Fallback.svelte"; export type * from "./types.js"; export { location } from "./core/Location.js"; export * from './RouterTrace/RouterTrace.svelte'; diff --git a/src/lib/init.test.ts b/src/lib/init.test.ts index 5b2faff..b82eb01 100644 --- a/src/lib/init.test.ts +++ b/src/lib/init.test.ts @@ -1,6 +1,6 @@ import { describe, test, expect, afterEach } from "vitest"; import { init, initFull } from "./init.js"; -import { location } from "$lib/core/Location.js"; +import { location } from "./core/Location.js"; import { LocationLite } from "./core/LocationLite.svelte.js"; import { LocationFull } from "./core/LocationFull.js";