Skip to content

Commit f8780c6

Browse files
committed
refactor(core): rename internal core modules for clarity
1 parent 9517f83 commit f8780c6

File tree

9 files changed

+17
-13
lines changed

9 files changed

+17
-13
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
"test:examples": "vitest run examples --coverage",
6767
"types": "svelte-check",
6868
"types:legacy": "svelte-check --tsconfig tsconfig.legacy.json",
69-
"build": "tsc -p tsconfig.build.json && cp src/component-types.d.ts types",
69+
"build": "npm-run-all build:*",
70+
"build:tsc": "tsc -p tsconfig.build.json",
71+
"build:copy-dts": "cp src/core/types.d.ts types/core",
7072
"contributors:add": "all-contributors add",
7173
"contributors:generate": "all-contributors generate",
7274
"preview-release": "./scripts/preview-release",

src/core/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
* Will switch to legacy, class-based mounting logic
66
* if it looks like we're in a Svelte <= 4 environment.
77
*/
8-
import * as LegacyCore from './legacy.js'
9-
import * as ModernCore from './modern.svelte.js'
10-
import { createValidateOptions } from './validate-options.js'
8+
import * as MountLegacy from './mount-legacy.js'
9+
import * as MountModern from './mount-modern.svelte.js'
10+
import { createValidateOptions } from './prepare.js'
1111

1212
const { mount, unmount, updateProps, allowedOptions } =
13-
ModernCore.IS_MODERN_SVELTE ? ModernCore : LegacyCore
13+
MountModern.IS_MODERN_SVELTE ? MountModern : MountLegacy
1414

1515
/** Validate component options. */
1616
const validateOptions = createValidateOptions(allowedOptions)
1717

1818
export { mount, unmount, updateProps, validateOptions }
19-
export { UnknownSvelteOptionsError } from './validate-options.js'
19+
export { UnknownSvelteOptionsError } from './prepare.js'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/pure.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const componentCache = new Set()
1515
/**
1616
* Customize how Svelte renders the component.
1717
*
18-
* @template {import('./component-types.js').Component} C
19-
* @typedef {import('./component-types.js').Props<C> | Partial<import('./component-types.js').MountOptions<C>>} SvelteComponentOptions
18+
* @template {import('./core/types.js').Component} C
19+
* @typedef {import('./core/types.js').Props<C> | Partial<import('./core/types.js').MountOptions<C>>} SvelteComponentOptions
2020
*/
2121

2222
/**
@@ -32,15 +32,15 @@ const componentCache = new Set()
3232
/**
3333
* The rendered component and bound testing functions.
3434
*
35-
* @template {import('./component-types.js').Component} C
35+
* @template {import('./core/types.js').Component} C
3636
* @template {import('@testing-library/dom').Queries} [Q=typeof import('@testing-library/dom').queries]
3737
*
3838
* @typedef {{
3939
* container: HTMLElement
4040
* baseElement: HTMLElement
41-
* component: import('./component-types.js').Exports<C>
41+
* component: import('./core/types.js').Exports<C>
4242
* debug: (el?: HTMLElement | DocumentFragment) => void
43-
* rerender: (props: Partial<import('./component-types.js').Props<C>>) => Promise<void>
43+
* rerender: (props: Partial<import('./core/types.js').Props<C>>) => Promise<void>
4444
* unmount: () => void
4545
* } & {
4646
* [P in keyof Q]: import('@testing-library/dom').BoundFunction<Q[P]>
@@ -50,10 +50,10 @@ const componentCache = new Set()
5050
/**
5151
* Render a component into the document.
5252
*
53-
* @template {import('./component-types.js').Component} C
53+
* @template {import('./core/types.js').Component} C
5454
* @template {import('@testing-library/dom').Queries} [Q=typeof import('@testing-library/dom').queries]
5555
*
56-
* @param {import('./component-types.js').ComponentType<C>} Component - The component to render.
56+
* @param {import('./core/types.js').ComponentType<C>} Component - The component to render.
5757
* @param {SvelteComponentOptions<C>} options - Customize how Svelte renders the component.
5858
* @param {RenderOptions<Q>} renderOptions - Customize how Testing Library sets up the document and binds queries.
5959
* @returns {RenderResult<C, Q>} The rendered component and bound testing functions.

tests/render-runes.test-d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ describe('types', () => {
3131

3232
expectTypeOf(result).toExtend<{
3333
container: HTMLElement
34+
baseElement: HTMLElement
3435
component: { hello: string }
3536
debug: (el?: HTMLElement) => void
3637
rerender: (props: { name?: string; count?: number }) => Promise<void>

tests/render.test-d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ describe('types', () => {
3939

4040
expectTypeOf(result).toExtend<{
4141
container: HTMLElement
42+
baseElement: HTMLElement
4243
component: { hello: string }
4344
debug: (el?: HTMLElement) => void
4445
rerender: (props: { name?: string; count?: number }) => Promise<void>

0 commit comments

Comments
 (0)