Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
"test:examples": "vitest run examples --coverage",
"types": "svelte-check",
"types:legacy": "svelte-check --tsconfig tsconfig.legacy.json",
"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
10 changes: 5 additions & 5 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
* 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 } from './validate-options.js'
import * as MountLegacy from './mount-legacy.js'
import * as MountModern from './mount-modern.svelte.js'
import { createValidateOptions } 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)

export { mount, unmount, updateProps, validateOptions }
export { UnknownSvelteOptionsError } from './validate-options.js'
export { UnknownSvelteOptionsError } from './prepare.js'
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 @@ -15,8 +15,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 @@ -32,15 +32,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 @@ -50,10 +50,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
1 change: 1 addition & 0 deletions tests/render-runes.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('types', () => {

expectTypeOf(result).toExtend<{
container: HTMLElement
baseElement: HTMLElement
component: { hello: string }
debug: (el?: HTMLElement) => void
rerender: (props: { name?: string; count?: number }) => Promise<void>
Expand Down
1 change: 1 addition & 0 deletions tests/render.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('types', () => {

expectTypeOf(result).toExtend<{
container: HTMLElement
baseElement: HTMLElement
component: { hello: string }
debug: (el?: HTMLElement) => void
rerender: (props: { name?: string; count?: number }) => Promise<void>
Expand Down
Loading