Skip to content

Commit

Permalink
refactor(core): rename internal core modules for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous committed Dec 9, 2024
1 parent 7f86754 commit 1546669
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 4 additions & 7 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions src/pure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<C> | Partial<import('./component-types.js').MountOptions<C>>} SvelteComponentOptions
* @template {import('./core/types.js').Component} C
* @typedef {import('./core/types.js').Props<C> | Partial<import('./core/types.js').MountOptions<C>>} SvelteComponentOptions
*/

/**
Expand All @@ -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<C>
* component: import('./core/types.js').Exports<C>
* debug: (el?: HTMLElement | DocumentFragment) => void
* rerender: (props: Partial<import('./component-types.js').Props<C>>) => Promise<void>
* rerender: (props: Partial<import('./core/types.js').Props<C>>) => Promise<void>
* unmount: () => void
* } & {
* [P in keyof Q]: import('@testing-library/dom').BoundFunction<Q[P]>
Expand All @@ -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<C>} Component - The component to render.
* @param {import('./core/types.js').ComponentType<C>} Component - The component to render.
* @param {SvelteComponentOptions<C>} options - Customize how Svelte renders the component.
* @param {RenderOptions<Q>} renderOptions - Customize how Testing Library sets up the document and binds queries.
* @returns {RenderResult<C, Q>} The rendered component and bound testing functions.
Expand Down

0 comments on commit 1546669

Please sign in to comment.