From 1546669b7b99c885bbe2629b6cd7cf1d6142eb57 Mon Sep 17 00:00:00 2001 From: Michael Cousins Date: Fri, 25 Oct 2024 07:52:51 -0400 Subject: [PATCH] refactor(core): rename internal core modules for clarity --- package.json | 4 +++- src/core/index.js | 11 ++++------- src/core/{legacy.js => mount-legacy.js} | 0 .../{modern.svelte.js => mount-modern.svelte.js} | 0 src/core/{validate-options.js => prepare.js} | 0 src/{component-types.d.ts => core/types.d.ts} | 0 src/pure.js | 14 +++++++------- 7 files changed, 14 insertions(+), 15 deletions(-) rename src/core/{legacy.js => mount-legacy.js} (100%) rename src/core/{modern.svelte.js => mount-modern.svelte.js} (100%) rename src/core/{validate-options.js => prepare.js} (100%) rename src/{component-types.d.ts => core/types.d.ts} (100%) diff --git a/package.json b/package.json index cada7e0..0848923 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,9 @@ "types": "svelte-check", "types:legacy": "svelte-check --tsconfig tsconfig.legacy.json", "validate": "npm-run-all test:vitest:* test:jest types build", - "build": "tsc -p tsconfig.build.json && cp src/component-types.d.ts types", + "build": "npm-run-all build:*", + "build:tsc": "tsc -p tsconfig.build.json", + "build:copy-dts": "cp src/core/types.d.ts types/core", "contributors:add": "all-contributors add", "contributors:generate": "all-contributors generate", "preview-release": "./scripts/preview-release", diff --git a/src/core/index.js b/src/core/index.js index f4a40aa..1c638e8 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -5,15 +5,12 @@ * Will switch to legacy, class-based mounting logic * if it looks like we're in a Svelte <= 4 environment. */ -import * as LegacyCore from './legacy.js' -import * as ModernCore from './modern.svelte.js' -import { - createValidateOptions, - UnknownSvelteOptionsError, -} from './validate-options.js' +import * as MountLegacy from './mount-legacy.js' +import * as MountModern from './mount-modern.svelte.js' +import { createValidateOptions, UnknownSvelteOptionsError } from './prepare.js' const { mount, unmount, updateProps, allowedOptions } = - ModernCore.IS_MODERN_SVELTE ? ModernCore : LegacyCore + MountModern.IS_MODERN_SVELTE ? MountModern : MountLegacy /** Validate component options. */ const validateOptions = createValidateOptions(allowedOptions) diff --git a/src/core/legacy.js b/src/core/mount-legacy.js similarity index 100% rename from src/core/legacy.js rename to src/core/mount-legacy.js diff --git a/src/core/modern.svelte.js b/src/core/mount-modern.svelte.js similarity index 100% rename from src/core/modern.svelte.js rename to src/core/mount-modern.svelte.js diff --git a/src/core/validate-options.js b/src/core/prepare.js similarity index 100% rename from src/core/validate-options.js rename to src/core/prepare.js diff --git a/src/component-types.d.ts b/src/core/types.d.ts similarity index 100% rename from src/component-types.d.ts rename to src/core/types.d.ts diff --git a/src/pure.js b/src/pure.js index 875f87c..35a10fa 100644 --- a/src/pure.js +++ b/src/pure.js @@ -13,8 +13,8 @@ const componentCache = new Set() /** * Customize how Svelte renders the component. * - * @template {import('./component-types.js').Component} C - * @typedef {import('./component-types.js').Props | Partial>} SvelteComponentOptions + * @template {import('./core/types.js').Component} C + * @typedef {import('./core/types.js').Props | Partial>} SvelteComponentOptions */ /** @@ -30,15 +30,15 @@ const componentCache = new Set() /** * The rendered component and bound testing functions. * - * @template {import('./component-types.js').Component} C + * @template {import('./core/types.js').Component} C * @template {import('@testing-library/dom').Queries} [Q=typeof import('@testing-library/dom').queries] * * @typedef {{ * container: HTMLElement * baseElement: HTMLElement - * component: import('./component-types.js').Exports + * component: import('./core/types.js').Exports * debug: (el?: HTMLElement | DocumentFragment) => void - * rerender: (props: Partial>) => Promise + * rerender: (props: Partial>) => Promise * unmount: () => void * } & { * [P in keyof Q]: import('@testing-library/dom').BoundFunction @@ -48,10 +48,10 @@ const componentCache = new Set() /** * Render a component into the document. * - * @template {import('./component-types.js').Component} C + * @template {import('./core/types.js').Component} C * @template {import('@testing-library/dom').Queries} [Q=typeof import('@testing-library/dom').queries] * - * @param {import('./component-types.js').ComponentType} Component - The component to render. + * @param {import('./core/types.js').ComponentType} Component - The component to render. * @param {SvelteComponentOptions} options - Customize how Svelte renders the component. * @param {RenderOptions} renderOptions - Customize how Testing Library sets up the document and binds queries. * @returns {RenderResult} The rendered component and bound testing functions.