diff --git a/.changeset/beige-boxes-rhyme.md b/.changeset/beige-boxes-rhyme.md new file mode 100644 index 000000000..6f06ceac6 --- /dev/null +++ b/.changeset/beige-boxes-rhyme.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: export ComponentType from `svelte` entrypoint diff --git a/.changeset/gentle-pumas-chew.md b/.changeset/gentle-pumas-chew.md new file mode 100644 index 000000000..949837bbf --- /dev/null +++ b/.changeset/gentle-pumas-chew.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: derived store types diff --git a/.changeset/green-sheep-learn.md b/.changeset/green-sheep-learn.md new file mode 100644 index 000000000..b60047414 --- /dev/null +++ b/.changeset/green-sheep-learn.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +Generate type declarations with dts-buddy diff --git a/.changeset/pre.json b/.changeset/pre.json index 7c25128a6..5bd51f5e8 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -2,7 +2,12 @@ "mode": "pre", "tag": "next", "initialVersions": { - "svelte": "4.0.0-next.1" + "svelte": "4.0.0-next.1", + "playground": "0.0.0" }, - "changesets": [] + "changesets": [ + "beige-boxes-rhyme", + "gentle-pumas-chew", + "green-sheep-learn" + ] } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8f3bad810..d311bff11 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,6 +35,7 @@ jobs: uses: changesets/action@v1 with: version: pnpm changeset:version + publish: pnpm changeset:publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index 8a4d1d070..cc2e05ea5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea .DS_Store -.vscode +.vscode/* +!.vscode/launch.json node_modules .eslintcache diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..2e22a5ab9 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,27 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "launch", + "name": "Playground: Browser", + "url": "http://localhost:10001" + }, + { + "type": "node", + "request": "launch", + "runtimeArgs": ["--watch"], + "name": "Playground: Server", + "outputCapture": "std", + "program": "start.js", + "cwd": "${workspaceFolder}/packages/playground", + "cascadeTerminateToConfigurations": ["Playground: Browser"] + } + ], + "compounds": [ + { + "name": "Playground: Full", + "configurations": ["Playground: Server", "Playground: Browser"] + } + ] +} diff --git a/package.json b/package.json index 1fc9c0d3c..a2f035b7d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "lint": "pnpm -r lint", "format": "pnpm -r format", "changeset:version": "changeset version && pnpm -r generate:version && git add --all", - "release": "changeset release" + "changeset:publish": "changeset publish" }, "repository": { "type": "git", diff --git a/packages/playground/.gitignore b/packages/playground/.gitignore new file mode 100644 index 000000000..0212d8b6c --- /dev/null +++ b/packages/playground/.gitignore @@ -0,0 +1,3 @@ +dist +dist-ssr +*.local diff --git a/packages/playground/README.md b/packages/playground/README.md new file mode 100644 index 000000000..6ac039372 --- /dev/null +++ b/packages/playground/README.md @@ -0,0 +1,7 @@ +You may use this package to experiment with your changes to Svelte. + +To prevent any changes you make in this directory from being accidentally committed, run `git update-index --skip-worktree ./**/*.*` in this directory. + +If you would actually like to make some changes to the files here for everyone then run `git update-index --no-skip-worktree ./**/*.*` before committing. + +If you're using VS Code, you can use the "Playground: Full" launch configuration to run the playground and attach the debugger to both the compiler and the browser. diff --git a/packages/playground/jsconfig.json b/packages/playground/jsconfig.json new file mode 100644 index 000000000..ba142a7d3 --- /dev/null +++ b/packages/playground/jsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "moduleResolution": "Node", + "target": "ESNext", + "module": "ESNext", + /** + * svelte-preprocess cannot figure out whether you have + * a value or a type, so tell TypeScript to enforce using + * `import type` instead of `import` for Types. + */ + "verbatimModuleSyntax": true, + "isolatedModules": true, + "resolveJsonModule": true, + /** + * To have warnings / errors of the Svelte compiler at the + * correct position, enable source maps by default. + */ + "sourceMap": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + /** + * Typecheck JS in `.svelte` and `.js` files by default. + * Disable this if you'd like to use dynamic types. + */ + "checkJs": true + }, + /** + * Use global.d.ts instead of compilerOptions.types + * to avoid limiting type declarations. + */ + "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"] +} diff --git a/packages/playground/package.json b/packages/playground/package.json new file mode 100644 index 000000000..9c1f03db2 --- /dev/null +++ b/packages/playground/package.json @@ -0,0 +1,14 @@ +{ + "name": "playground", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "node --watch start.js" + }, + "devDependencies": { + "rollup": "^3.20.2", + "rollup-plugin-serve": "^2.0.2", + "svelte": "workspace:*" + } +} diff --git a/packages/playground/src/App.svelte b/packages/playground/src/App.svelte new file mode 100644 index 000000000..ab87de6d9 --- /dev/null +++ b/packages/playground/src/App.svelte @@ -0,0 +1,3 @@ +
+ Hello world! +
\ No newline at end of file diff --git a/packages/playground/src/entry-client.js b/packages/playground/src/entry-client.js new file mode 100644 index 000000000..e62bbf2eb --- /dev/null +++ b/packages/playground/src/entry-client.js @@ -0,0 +1,24 @@ +import App from './App.svelte'; + +new App({ + target: document.getElementById('app'), + hydrate: true +}); + +function get_version() { + return fetch('/version.json').then((r) => r.json()); +} + +let prev = await get_version(); + +// Mom: We have live reloading at home +// Live reloading at home: +while (true) { + await new Promise((r) => setTimeout(r, 2500)); + try { + const version = await get_version(); + if (prev !== version) { + window.location.reload(); + } + } catch {} +} diff --git a/packages/playground/src/entry-server.js b/packages/playground/src/entry-server.js new file mode 100644 index 000000000..7402e1e9a --- /dev/null +++ b/packages/playground/src/entry-server.js @@ -0,0 +1,6 @@ +import App from './App.svelte'; + +export function render() { + // @ts-ignore + return App.render(); +} diff --git a/packages/playground/src/lib/Counter.svelte b/packages/playground/src/lib/Counter.svelte new file mode 100644 index 000000000..e45f90310 --- /dev/null +++ b/packages/playground/src/lib/Counter.svelte @@ -0,0 +1,10 @@ + + + diff --git a/packages/playground/src/template.html b/packages/playground/src/template.html new file mode 100644 index 000000000..2cc688066 --- /dev/null +++ b/packages/playground/src/template.html @@ -0,0 +1,13 @@ + + + + + + <!--app-title--> + + + +
+ + + diff --git a/packages/playground/start.js b/packages/playground/start.js new file mode 100644 index 000000000..4144ba97a --- /dev/null +++ b/packages/playground/start.js @@ -0,0 +1,100 @@ +import { readFileSync, writeFileSync } from 'node:fs'; +import path from 'node:path'; +import { watch } from 'rollup'; +import serve from 'rollup-plugin-serve'; +import * as svelte from '../svelte/src/compiler/index.js'; + +const __dirname = new URL('.', import.meta.url).pathname; + +/** @returns {import('rollup').Plugin}*/ +function create_plugin(ssr = false) { + return { + name: 'custom-svelte-ssr-' + ssr, + resolveId(id) { + if (id === 'svelte') { + return path.resolve( + __dirname, + ssr ? '../svelte/src/runtime/ssr.js' : '../svelte/src/runtime/index.js' + ); + } else if (id.startsWith('svelte/')) { + return path.resolve(__dirname, `../svelte/src/runtime/${id.slice(7)}/index.js`); + } + }, + transform(code, id) { + code = code.replaceAll('import.meta.env.SSR', ssr); + + if (!id.endsWith('.svelte')) { + return { + code, + map: null + }; + } + + const compiled = svelte.compile(code, { + filename: id, + generate: ssr ? 'ssr' : 'dom', + hydratable: true, + css: 'injected' + }); + + return compiled.js; + } + }; +} + +const client_plugin = create_plugin(); +const ssr_plugin = create_plugin(true); + +const watcher = watch([ + { + input: 'src/entry-client.js', + output: { + dir: 'dist', + format: 'esm', + sourcemap: true + }, + plugins: [client_plugin, serve('dist')] + }, + { + input: 'src/entry-server.js', + output: { + dir: 'dist-ssr', + format: 'iife', + indent: false + }, + plugins: [ + ssr_plugin, + { + async generateBundle(_, bundle) { + const result = bundle['entry-server.js']; + const mod = (0, eval)(result.code); + const { html } = mod.render(); + + writeFileSync( + 'dist/index.html', + readFileSync('src/template.html', 'utf-8') + .replace('', html) + .replace('', svelte.VERSION) + ); + writeFileSync('dist/version.json', Date.now().toString()); + } + } + ], + onwarn(warning, handler) { + if (warning.code === 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT') return; + handler(warning); + } + } +]); + +watcher + .on('change', (id) => { + console.log(`changed ${id}`); + }) + .on('event', (event) => { + if (event.code === 'ERROR') { + console.error(event.error); + } else if (event.code === 'BUNDLE_END') { + console.log(`Generated ${event.output} in ${event.duration}ms`); + } + }); diff --git a/packages/svelte/.gitignore b/packages/svelte/.gitignore index 4b6e38265..13a9e4099 100644 --- a/packages/svelte/.gitignore +++ b/packages/svelte/.gitignore @@ -1,15 +1,6 @@ *.map /src/compiler/compile/internal_exports.js -/compiler.d.ts /compiler.cjs -/index.d.ts -/action.d.ts -/internal.d.ts -/store.d.ts -/easing.d.ts -/motion.d.ts -/transition.d.ts -/animate.d.ts /scratch/ /test/*/samples/_ /test/runtime/shards diff --git a/packages/svelte/CHANGELOG.md b/packages/svelte/CHANGELOG.md index ef78702e8..c25d36684 100644 --- a/packages/svelte/CHANGELOG.md +++ b/packages/svelte/CHANGELOG.md @@ -1,5 +1,15 @@ # svelte +## 4.0.0-next.1 + +### Patch Changes + +- fix: export ComponentType from `svelte` entrypoint ([#8694](https://github.com/sveltejs/svelte/pull/8694)) + +- fix: derived store types ([#8700](https://github.com/sveltejs/svelte/pull/8700)) + +- Generate type declarations with dts-buddy ([#8702](https://github.com/sveltejs/svelte/pull/8702)) + ## 4.0.0-next.0 ### Major Changes diff --git a/packages/svelte/generate-types.js b/packages/svelte/generate-types.js deleted file mode 100644 index 707bf746f..000000000 --- a/packages/svelte/generate-types.js +++ /dev/null @@ -1,162 +0,0 @@ -// This script generates the TypeScript definitions - -import { execSync } from 'child_process'; -import { readFileSync, writeFileSync, readdirSync, existsSync, copyFileSync, statSync } from 'fs'; - -execSync('tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly', { stdio: 'inherit' }); - -function modify(path, modifyFn) { - const content = readFileSync(path, 'utf8'); - writeFileSync(path, modifyFn(content)); -} - -function adjust(input) { - // Remove typedef jsdoc (duplicated in the type definition) - input = input.replace(/\/\*\*\n(\r)? \* @typedef .+?\*\//gs, ''); - input = input.replace(/\/\*\* @typedef .+?\*\//gs, ''); - - // Extract the import paths and types - const import_regex = /import\(("|')(.+?)("|')\)\.(\w+)/g; - let import_match; - const import_map = new Map(); - - while ((import_match = import_regex.exec(input)) !== null) { - const imports = import_map.get(import_match[2]) || new Map(); - let name = import_match[4]; - if ([...imports.keys()].includes(name)) continue; - - let i = 1; - if (name === 'default') { - name = import_match[2].split('/').pop().split('.').shift().replace(/[^a-z0-9]/gi, '_'); - } - while ([...import_map].some(([path, names]) => path !== import_match[2] && names.has(name))) { - name = `${name}${i++}`; - } - - imports.set(import_match[4], name); - import_map.set(import_match[2], imports); - } - - // Replace inline imports with their type names - const transformed = input.replace(import_regex, (_match, _quote, path, _quote2, name) => { - return import_map.get(path).get(name); - }); - - // Remove/adjust @template, @param and @returns lines - // TODO rethink if we really need to do this for @param and @returns, doesn't show up in hover so unnecessary - const lines = transformed.split("\n"); - - let filtered_lines = []; - let removing = null; - let openCount = 1; - let closedCount = 0; - - for (let line of lines) { - let start_removing = false; - if (line.trim().startsWith("* @template")) { - removing = "template"; - start_removing = true; - } - - if (line.trim().startsWith("* @param {")) { - openCount = 1; - closedCount = 0; - removing = "param"; - start_removing = true; - } - - if (line.trim().startsWith("* @returns {")) { - openCount = 1; - closedCount = 0; - removing = "returns"; - start_removing = true; - } - - if (removing === "returns" || removing === "param") { - let i = start_removing ? line.indexOf('{') + 1 : 0; - for (; i < line.length; i++) { - if (line[i] === "{") openCount++; - if (line[i] === "}") closedCount++; - if (openCount === closedCount) break; - } - if (openCount === closedCount) { - line = start_removing ? (line.slice(0, line.indexOf('{')) + line.slice(i + 1)) : (` * @${removing} ` + line.slice(i + 1)); - removing = null; - } - } - - if (removing && !start_removing && (line.trim().startsWith("* @") || line.trim().startsWith("*/"))) { - removing = null; - } - - if (!removing) { - filtered_lines.push(line); - } - } - - // Replace generic type names with their plain versions - const renamed_generics = filtered_lines.map(line => { - return line.replace(/(\W|\s)([A-Z][\w\d$]*)_\d+(\W|\s)/g, "$1$2$3"); - }); - - // Generate the import statement for the types used - const import_statements = Array.from(import_map.entries()) - .map(([path, names]) => { - const default_name = names.get('default'); - names.delete('default'); - const default_import = default_name ? (default_name + (names.size ? ', ' : ' ')) : ''; - const named_imports = names.size ? `{ ${[...names.values()].join(', ')} } ` : ''; - return `import ${default_import}${named_imports}from '${path}';` - }) - .join("\n"); - - return [import_statements, ...renamed_generics].join("\n"); -} - -let did_replace = false; - -function walk(dir) { - const files = readdirSync(dir); - const _dir = dir.slice('types/'.length) - - for (const file of files) { - const path = `${dir}/${file}`; - if (file.endsWith('.d.ts')) { - modify(path, content => { - content = adjust(content); - - if (file === 'index.d.ts' && existsSync(`src/${_dir}/public.d.ts`)) { - copyFileSync(`src/${_dir}/public.d.ts`, `${dir}/public.d.ts`); - content = "export * from './public.js';\n" + content; - } - - if (file === 'Component.d.ts' && dir.includes('runtime')) { - if (!content.includes('$set(props: Partial): void;\n}')) { - throw new Error('Component.js was modified in a way that automatic patching of d.ts file no longer works. Please adjust it'); - } else { - content = content.replace('$set(props: Partial): void;\n}', '$set(props: Partial): void;\n [accessor:string]: any;\n}'); - did_replace = true; - } - } - - return content; - }); - } else if (statSync(path).isDirectory()) { - if (existsSync(`src/${_dir}/${file}/private.d.ts`)) { - copyFileSync(`src/${_dir}/${file}/private.d.ts`, `${path}/private.d.ts`); - } - if (existsSync(`src/${_dir}/${file}/interfaces.d.ts`)) { - copyFileSync(`src/${_dir}/${file}/interfaces.d.ts`, `${path}/interfaces.d.ts`); - } - walk(path); - } - } -} - -walk('types'); - -if (!did_replace) { - throw new Error('Component.js file in runtime does no longer exist so that automatic patching of the d.ts file no longer works. Please adjust it'); -} - -copyFileSync(`src/runtime/ambient.d.ts`, `types/runtime/ambient.d.ts`); diff --git a/packages/svelte/package.json b/packages/svelte/package.json index ade672ce3..f3dfc00c8 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "4.0.0-next.0", + "version": "4.0.0-next.1", "description": "Cybernetically enhanced web apps", "type": "module", "module": "src/runtime/index.js", @@ -24,42 +24,42 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./types/runtime/index.d.ts", + "types": "./types/index.d.ts", "browser": { "import": "./src/runtime/index.js" }, "import": "./src/runtime/ssr.js" }, "./compiler": { - "types": "./types/compiler/index.d.ts", + "types": "./types/index.d.ts", "import": "./src/compiler/index.js", "require": "./compiler.cjs" }, "./action": { - "types": "./types/runtime/action/index.d.ts" + "types": "./types/index.d.ts" }, "./animate": { - "types": "./types/runtime/animate/index.d.ts", + "types": "./types/index.d.ts", "import": "./src/runtime/animate/index.js" }, "./easing": { - "types": "./types/runtime/easing/index.d.ts", + "types": "./types/index.d.ts", "import": "./src/runtime/easing/index.js" }, "./internal": { - "types": "./types/runtime/internal/index.d.ts", + "types": "./types/index.d.ts", "import": "./src/runtime/internal/index.js" }, "./motion": { - "types": "./types/runtime/motion/index.d.ts", + "types": "./types/index.d.ts", "import": "./src/runtime/motion/index.js" }, "./store": { - "types": "./types/runtime/store/index.d.ts", + "types": "./types/index.d.ts", "import": "./src/runtime/store/index.js" }, "./transition": { - "types": "./types/runtime/transition/index.d.ts", + "types": "./types/index.d.ts", "import": "./src/runtime/transition/index.js" }, "./elements": { @@ -69,18 +69,17 @@ "engines": { "node": ">=16" }, - "types": "types/runtime/index.d.ts", + "types": "types/index.d.ts", "scripts": { "format": "prettier . --cache --plugin-search-dir=. --write", "check": "prettier . --cache --plugin-search-dir=. --check", "test": "vitest run && echo \"manually check that there are no type errors in test/types by opening the files in there\"", - "build": "rollup -c && pnpm tsd", - "prepare": "pnpm build", + "build": "rollup -c && pnpm types", "generate:version": "node ./scripts/generate-version.js", "dev": "rollup -cw", "posttest": "agadoo src/internal/index.js", - "prepublishOnly": "pnpm lint && pnpm build && pnpm test", - "tsd": "node ./generate-types.js", + "prepublishOnly": "pnpm build", + "types": "node ./scripts/generate-dts.js", "lint": "eslint \"{src,test}/**/*.{ts,js}\" --cache" }, "repository": { @@ -126,6 +125,7 @@ "@types/node": "^14.14.31", "@typescript-eslint/eslint-plugin": "^5.58.0", "agadoo": "^3.0.0", + "dts-buddy": "^0.1.2", "esbuild": "^0.17.19", "happy-dom": "^9.18.3", "jsdom": "^21.1.1", diff --git a/packages/svelte/rollup.config.js b/packages/svelte/rollup.config.js index 927f8e949..1bba3c607 100644 --- a/packages/svelte/rollup.config.js +++ b/packages/svelte/rollup.config.js @@ -17,23 +17,6 @@ fs.writeFileSync( `export default new Set(${JSON.stringify(Object.keys(internal))});` ); -// Generate d.ts files for runtime entrypoints so that TS can find it also without `"moduleResolution": "bundler"` -fs.readdirSync('src/runtime', { withFileTypes: true }) - .filter((dirent) => dirent.isDirectory()) - .forEach((dirent) => - fs.writeFileSync( - `${dirent.name}.d.ts`, - `export * from './types/runtime/${dirent.name}/index.js';` - ) - ); - -fs.writeFileSync('./index.d.ts', `export * from './types/runtime/index.js';`); - -fs.writeFileSync( - './compiler.d.ts', - `export { compile, parse, preprocess, walk, VERSION } from './types/compiler/index.js';` -); - /** * @type {import("rollup").RollupOptions[]} */ diff --git a/packages/svelte/scripts/generate-dts.js b/packages/svelte/scripts/generate-dts.js new file mode 100644 index 000000000..2139118de --- /dev/null +++ b/packages/svelte/scripts/generate-dts.js @@ -0,0 +1,16 @@ +import { createBundle } from 'dts-buddy'; + +await createBundle({ + output: 'types/index.d.ts', + modules: { + svelte: 'src/runtime/public.d.ts', + 'svelte/compiler': 'src/compiler/public.d.ts', + 'svelte/types/compiler/preprocess': 'src/compiler/preprocess/public.d.ts', + 'svelte/action': 'src/runtime/action/public.d.ts', + 'svelte/animate': 'src/runtime/animate/public.d.ts', + 'svelte/easing': 'src/runtime/easing/index.js', + 'svelte/motion': 'src/runtime/motion/public.d.ts', + 'svelte/store': 'src/runtime/store/public.d.ts', + 'svelte/transition': 'src/runtime/transition/public.d.ts' + } +}); diff --git a/packages/svelte/src/compiler/public.d.ts b/packages/svelte/src/compiler/public.d.ts index 32d712afa..202582789 100644 --- a/packages/svelte/src/compiler/public.d.ts +++ b/packages/svelte/src/compiler/public.d.ts @@ -1,2 +1,3 @@ export { CompileOptions, EnableSourcemap, CssHashGetter } from './interfaces'; export * from './preprocess/public.js'; +export * from './index.js'; diff --git a/packages/svelte/src/runtime/action/index.js b/packages/svelte/src/runtime/action/index.js deleted file mode 100644 index cb0ff5c3b..000000000 --- a/packages/svelte/src/runtime/action/index.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/svelte/src/runtime/animate/public.d.ts b/packages/svelte/src/runtime/animate/public.d.ts index 8c8e5565e..8a6cf5ebf 100644 --- a/packages/svelte/src/runtime/animate/public.d.ts +++ b/packages/svelte/src/runtime/animate/public.d.ts @@ -12,3 +12,5 @@ export interface FlipParams { duration?: number | ((len: number) => number); easing?: (t: number) => number; } + +export * from './index.js'; diff --git a/packages/svelte/src/runtime/internal/public.d.ts b/packages/svelte/src/runtime/internal/public.d.ts index 6eab76607..64a9a0467 100644 --- a/packages/svelte/src/runtime/internal/public.d.ts +++ b/packages/svelte/src/runtime/internal/public.d.ts @@ -91,3 +91,5 @@ export interface EventDispatcher> { : [type: Type, parameter: EventMap[Type], options?: DispatchOptions] ): boolean; } + +export * from './index.js'; diff --git a/packages/svelte/src/runtime/motion/public.d.ts b/packages/svelte/src/runtime/motion/public.d.ts index 372d31636..bedbac8d2 100644 --- a/packages/svelte/src/runtime/motion/public.d.ts +++ b/packages/svelte/src/runtime/motion/public.d.ts @@ -13,3 +13,5 @@ export interface Tweened extends Readable { set(value: T, opts?: TweenedOptions): Promise; update(updater: Updater, opts?: TweenedOptions): Promise; } + +export * from './index.js'; diff --git a/packages/svelte/src/runtime/public.d.ts b/packages/svelte/src/runtime/public.d.ts index 8cfa2e6bf..47bd1e837 100644 --- a/packages/svelte/src/runtime/public.d.ts +++ b/packages/svelte/src/runtime/public.d.ts @@ -2,6 +2,9 @@ import './ambient.js'; export type { ComponentConstructorOptions, + ComponentEvents, ComponentProps, - ComponentEvents + ComponentType } from './internal/public.js'; + +export * from './index.js'; diff --git a/packages/svelte/src/runtime/store/index.js b/packages/svelte/src/runtime/store/index.js index c0c20a885..3950e5ff4 100644 --- a/packages/svelte/src/runtime/store/index.js +++ b/packages/svelte/src/runtime/store/index.js @@ -97,7 +97,7 @@ export function writable(value, start = noop) { * @template T * @overload * @param {S} stores - input stores - * @param {(values: import('./public.js').StoresValues, set: (value: T) => void, update: (fn: import('./public.js').Updater) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values + * @param {(values: import('./private.js').StoresValues, set: (value: T) => void, update: (fn: import('./public.js').Updater) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values * @param {T} [initial_value] - initial value * @returns {import('./public.js').Readable} */ @@ -110,7 +110,7 @@ export function writable(value, start = noop) { * @template T * @overload * @param {S} stores - input stores - * @param {(values: import('./public.js').StoresValues) => T} fn - function callback that aggregates the values + * @param {(values: import('./private.js').StoresValues) => T} fn - function callback that aggregates the values * @param {T} [initial_value] - initial value * @returns {import('./public.js').Readable} */ diff --git a/packages/svelte/src/runtime/store/public.d.ts b/packages/svelte/src/runtime/store/public.d.ts index b7368137a..9655a1567 100644 --- a/packages/svelte/src/runtime/store/public.d.ts +++ b/packages/svelte/src/runtime/store/public.d.ts @@ -47,3 +47,5 @@ export interface Writable extends Readable { */ update(this: void, updater: Updater): void; } + +export * from './index.js'; diff --git a/packages/svelte/src/runtime/transition/public.d.ts b/packages/svelte/src/runtime/transition/public.d.ts index 0b158f9c2..454840ad7 100644 --- a/packages/svelte/src/runtime/transition/public.d.ts +++ b/packages/svelte/src/runtime/transition/public.d.ts @@ -58,3 +58,5 @@ export interface CrossfadeParams { duration?: number | ((len: number) => number); easing?: EasingFunction; } + +export * from './index.js'; diff --git a/packages/svelte/src/shared/version.js b/packages/svelte/src/shared/version.js index 80a6d82b3..45744232e 100644 --- a/packages/svelte/src/shared/version.js +++ b/packages/svelte/src/shared/version.js @@ -1,4 +1,4 @@ // generated during release, do not modify /** @type {string} */ -export const VERSION = '4.0.0-next.0'; +export const VERSION = '4.0.0-next.1'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2c4d34f9d..32d0c7d72 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,7 +19,7 @@ importers: version: 8.40.0 eslint-plugin-import: specifier: ^2.27.5 - version: 2.27.5(@typescript-eslint/parser@5.59.8)(eslint@8.41.0) + version: 2.27.5(eslint@8.40.0) eslint-plugin-svelte: specifier: ^2.28.0 version: 2.28.0(eslint@8.40.0)(svelte@3.59.1) @@ -36,6 +36,18 @@ importers: specifier: ^2.10.0 version: 2.10.0(prettier@2.8.8)(svelte@3.59.1) + packages/playground: + devDependencies: + rollup: + specifier: ^3.20.2 + version: 3.23.0 + rollup-plugin-serve: + specifier: ^2.0.2 + version: 2.0.2 + svelte: + specifier: workspace:* + version: link:../svelte + packages/svelte: dependencies: '@ampproject/remapping': @@ -108,6 +120,9 @@ importers: agadoo: specifier: ^3.0.0 version: 3.0.0 + dts-buddy: + specifier: ^0.1.2 + version: 0.1.2 esbuild: specifier: ^0.17.19 version: 0.17.19 @@ -1220,7 +1235,6 @@ packages: '@jridgewell/set-array': 1.1.2 '@jridgewell/sourcemap-codec': 1.4.15 '@jridgewell/trace-mapping': 0.3.18 - dev: false /@jridgewell/resolve-uri@3.1.0: resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} @@ -1229,7 +1243,13 @@ packages: /@jridgewell/set-array@1.1.2: resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} engines: {node: '>=6.0.0'} - dev: false + + /@jridgewell/source-map@0.3.3: + resolution: {integrity: sha512-b+fsZXeLYi9fEULmfBrhxn4IrPlINf8fiNarzTof004v3lFdntdwa9PF7vFJqm3mg7s+ScJMxXaE3Acp1irZcg==} + dependencies: + '@jridgewell/gen-mapping': 0.3.3 + '@jridgewell/trace-mapping': 0.3.18 + dev: true /@jridgewell/sourcemap-codec@1.4.14: resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} @@ -3095,6 +3115,21 @@ packages: engines: {node: '>=12'} dev: true + /dts-buddy@0.1.2: + resolution: {integrity: sha512-CLDbDXtcrNjuWLYljJuCL4l//mvDZzjtFkmr4yGyCAk58szuzmjzoWKG+7NBFWeeajOiISu/IG96QNMb0CPtdw==} + hasBin: true + dependencies: + '@jridgewell/source-map': 0.3.3 + '@jridgewell/sourcemap-codec': 1.4.15 + globrex: 0.1.2 + kleur: 4.1.5 + locate-character: 2.0.5 + magic-string: 0.30.0 + sade: 1.8.1 + tiny-glob: 0.2.9 + typescript: 5.0.4 + dev: true + /emoji-regex@10.2.1: resolution: {integrity: sha512-97g6QgOk8zlDRdgq1WxwgTMgEWGVAQvB5Fdpgc1MkNy56la5SKP9GsMXKDOdqwn90/41a8yPwIGk1Y6WVbeMQA==} dev: true @@ -3339,6 +3374,34 @@ packages: - supports-color dev: true + /eslint-module-utils@2.7.4(eslint-import-resolver-node@0.3.7)(eslint@8.40.0): + resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==} + engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint: '*' + eslint-import-resolver-node: '*' + eslint-import-resolver-typescript: '*' + eslint-import-resolver-webpack: '*' + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + eslint: + optional: true + eslint-import-resolver-node: + optional: true + eslint-import-resolver-typescript: + optional: true + eslint-import-resolver-webpack: + optional: true + dependencies: + debug: 3.2.7 + eslint: 8.40.0 + eslint-import-resolver-node: 0.3.7 + transitivePeerDependencies: + - supports-color + dev: true + /eslint-plugin-es@3.0.1(eslint@8.41.0): resolution: {integrity: sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==} engines: {node: '>=8.10.0'} @@ -3383,6 +3446,38 @@ packages: - supports-color dev: true + /eslint-plugin-import@2.27.5(eslint@8.40.0): + resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==} + engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + dependencies: + array-includes: 3.1.6 + array.prototype.flat: 1.3.1 + array.prototype.flatmap: 1.3.1 + debug: 3.2.7 + doctrine: 2.1.0 + eslint: 8.40.0 + eslint-import-resolver-node: 0.3.7 + eslint-module-utils: 2.7.4(eslint-import-resolver-node@0.3.7)(eslint@8.40.0) + has: 1.0.3 + is-core-module: 2.12.0 + is-glob: 4.0.3 + minimatch: 3.1.2 + object.values: 1.1.6 + resolve: 1.22.2 + semver: 6.3.0 + tsconfig-paths: 3.14.2 + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color + dev: true + /eslint-plugin-node@11.1.0(eslint@8.41.0): resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==} engines: {node: '>=8.10.0'} @@ -4670,7 +4765,6 @@ packages: /locate-character@2.0.5: resolution: {integrity: sha512-n2GmejDXtOPBAZdIiEFy5dJ5N38xBCXLNOtw2WpB9kGh6pnrEuKlwYI+Tkpofc4wDtVXHtoAOJaMRlYG/oYaxg==} - dev: false /locate-path@5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} @@ -5107,6 +5201,11 @@ packages: wrappy: 1.0.2 dev: true + /opener@1.5.2: + resolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==} + hasBin: true + dev: true + /optionator@0.8.3: resolution: {integrity: sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==} engines: {node: '>= 0.8.0'} @@ -5730,6 +5829,13 @@ packages: '@babel/code-frame': 7.21.4 dev: true + /rollup-plugin-serve@2.0.2: + resolution: {integrity: sha512-ALqyTbPhlf7FZ5RzlbDvMYvbKuCHWginJkTo6dMsbgji/a78IbsXox+pC83HENdkTRz8OXrTj+aShp3+3ratpg==} + dependencies: + mime: 3.0.0 + opener: 1.5.2 + dev: true + /rollup@3.23.0: resolution: {integrity: sha512-h31UlwEi7FHihLe1zbk+3Q7z1k/84rb9BSwmBSr/XjOCEaBJ2YyedQDuM0t/kfOS0IxM+vk1/zI9XxYj9V+NJQ==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} @@ -6671,7 +6777,7 @@ packages: mlly: 1.2.1 pathe: 1.1.0 picocolors: 1.0.0 - vite: 4.3.9(@types/node@20.2.5)(sass@1.62.1) + vite: 4.3.9(@types/node@14.14.31) transitivePeerDependencies: - '@types/node' - less @@ -6682,6 +6788,39 @@ packages: - terser dev: true + /vite@4.3.9(@types/node@14.14.31): + resolution: {integrity: sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==} + engines: {node: ^14.18.0 || >=16.0.0} + hasBin: true + peerDependencies: + '@types/node': '>= 14' + less: '*' + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + '@types/node': 14.14.31 + esbuild: 0.17.19 + postcss: 8.4.24 + rollup: 3.23.0 + optionalDependencies: + fsevents: 2.3.2 + dev: true + /vite@4.3.9(@types/node@20.2.5)(sass@1.62.1): resolution: {integrity: sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==} engines: {node: ^14.18.0 || >=16.0.0} @@ -6781,7 +6920,7 @@ packages: strip-literal: 1.0.1 tinybench: 2.5.0 tinypool: 0.5.0 - vite: 4.3.9(@types/node@20.2.5)(sass@1.62.1) + vite: 4.3.9(@types/node@14.14.31) vite-node: 0.31.1(@types/node@14.14.31) why-is-node-running: 2.2.2 transitivePeerDependencies: