From 15bdadb2aeeaa23fc6f31b0380fe5cabb23f7a51 Mon Sep 17 00:00:00 2001 From: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Date: Thu, 8 Jun 2023 05:07:45 +0545 Subject: [PATCH 01/33] chore: playground (#8648) * initialize playground * pnpm up * tidy up git ignore * remove fluff * format * rm readme * fix jsconfig error * add skip-worktree instructions * reload hack * simplify * use rollup * ughh * add flag for SSR * ... * simplify further * configure launch.json * add debugger info to readme * remove vm modules flag * use replaceAll instead of replace * tidy up * fix: make it run * add watch to launch config --- .gitignore | 3 +- .vscode/launch.json | 27 ++++++ packages/playground/.gitignore | 3 + packages/playground/README.md | 7 ++ packages/playground/jsconfig.json | 33 +++++++ packages/playground/package.json | 14 +++ packages/playground/src/App.svelte | 3 + packages/playground/src/entry-client.js | 24 +++++ packages/playground/src/entry-server.js | 6 ++ packages/playground/src/lib/Counter.svelte | 10 +++ packages/playground/src/template.html | 13 +++ packages/playground/start.js | 100 +++++++++++++++++++++ pnpm-lock.yaml | 30 +++++++ 13 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 packages/playground/.gitignore create mode 100644 packages/playground/README.md create mode 100644 packages/playground/jsconfig.json create mode 100644 packages/playground/package.json create mode 100644 packages/playground/src/App.svelte create mode 100644 packages/playground/src/entry-client.js create mode 100644 packages/playground/src/entry-server.js create mode 100644 packages/playground/src/lib/Counter.svelte create mode 100644 packages/playground/src/template.html create mode 100644 packages/playground/start.js diff --git a/.gitignore b/.gitignore index 8a4d1d070e8f..cc2e05ea5f5e 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 000000000000..2e22a5ab9b7e --- /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/packages/playground/.gitignore b/packages/playground/.gitignore new file mode 100644 index 000000000000..0212d8b6cea4 --- /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 000000000000..6ac0393720cc --- /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 000000000000..ba142a7d31d6 --- /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 000000000000..9c1f03db2050 --- /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 000000000000..ab87de6d9679 --- /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 000000000000..e62bbf2eb783 --- /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 000000000000..7402e1e9add2 --- /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 000000000000..e45f90310979 --- /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 000000000000..2cc688066ff3 --- /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 000000000000..4144ba97acfd --- /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/pnpm-lock.yaml b/pnpm-lock.yaml index dcf32989356c..cbec4fcac6dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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': @@ -3012,6 +3024,12 @@ packages: mime-db: 1.52.0 dev: true + /mime@3.0.0: + resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==} + engines: {node: '>=10.0.0'} + hasBin: true + dev: true + /min-indent@1.0.1: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} @@ -3143,6 +3161,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'} @@ -3560,6 +3583,13 @@ packages: glob: 7.2.3 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'} From 1046daba6a9c9b51ef4f25ed6c8f9fba59a92946 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 8 Jun 2023 09:48:11 -0400 Subject: [PATCH 02/33] Generate type declarations with `dts-buddy` (#8702) * use dts-buddy * remove debug output * remove existing type generation script * fix package.json * update gitignore * bump dts-buddy * remove unused action entry point * add svelte/compiler and svelte/types/compiler/preprocess modules * bump dts-buddy * annoying * changeset * bump dts-buddy * get rid of .d.ts files * another one * Update packages/svelte/package.json Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> --------- Co-authored-by: Rich Harris Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> --- .changeset/green-sheep-learn.md | 5 + packages/svelte/.gitignore | 9 - packages/svelte/generate-types.js | 162 ------------------ packages/svelte/package.json | 25 +-- packages/svelte/rollup.config.js | 17 -- packages/svelte/scripts/generate-dts.js | 16 ++ packages/svelte/src/compiler/public.d.ts | 1 + packages/svelte/src/runtime/action/index.js | 1 - .../svelte/src/runtime/animate/public.d.ts | 2 + .../svelte/src/runtime/internal/public.d.ts | 2 + .../svelte/src/runtime/motion/public.d.ts | 2 + packages/svelte/src/runtime/public.d.ts | 2 + packages/svelte/src/runtime/store/public.d.ts | 2 + .../svelte/src/runtime/transition/public.d.ts | 2 + pnpm-lock.yaml | 43 ++++- 15 files changed, 84 insertions(+), 207 deletions(-) create mode 100644 .changeset/green-sheep-learn.md delete mode 100644 packages/svelte/generate-types.js create mode 100644 packages/svelte/scripts/generate-dts.js delete mode 100644 packages/svelte/src/runtime/action/index.js diff --git a/.changeset/green-sheep-learn.md b/.changeset/green-sheep-learn.md new file mode 100644 index 000000000000..b60047414408 --- /dev/null +++ b/.changeset/green-sheep-learn.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +Generate type declarations with dts-buddy diff --git a/packages/svelte/.gitignore b/packages/svelte/.gitignore index 4b6e38265237..13a9e4099990 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/generate-types.js b/packages/svelte/generate-types.js deleted file mode 100644 index 707bf746fd89..000000000000 --- 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 ade672ce3594..7267a91afb28 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -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,18 @@ "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", + "build": "rollup -c && pnpm types", "prepare": "pnpm build", "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", + "types": "node ./scripts/generate-dts.js", "lint": "eslint \"{src,test}/**/*.{ts,js}\" --cache" }, "repository": { @@ -126,6 +126,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 927f8e949545..1bba3c607ecc 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 000000000000..2139118de240 --- /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 32d712afa2b2..202582789d63 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 cb0ff5c3b541..000000000000 --- 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 8c8e5565eaef..8a6cf5ebf659 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 6eab766077b6..64a9a04675e1 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 372d31636fda..bedbac8d22a1 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 8cfa2e6bf8af..3024ba3a38e8 100644 --- a/packages/svelte/src/runtime/public.d.ts +++ b/packages/svelte/src/runtime/public.d.ts @@ -5,3 +5,5 @@ export type { ComponentProps, ComponentEvents } from './internal/public.js'; + +export * from './index.js'; diff --git a/packages/svelte/src/runtime/store/public.d.ts b/packages/svelte/src/runtime/store/public.d.ts index b7368137ac7e..9655a1567471 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 0b158f9c2ec7..454840ad79c6 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/pnpm-lock.yaml b/pnpm-lock.yaml index cbec4fcac6dd..e85c9eecf576 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -120,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 @@ -644,21 +647,24 @@ 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==} engines: {node: '>=6.0.0'} - dev: false /@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==} - dev: false /@jridgewell/sourcemap-codec@1.4.15: resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} @@ -668,7 +674,6 @@ packages: dependencies: '@jridgewell/resolve-uri': 3.1.0 '@jridgewell/sourcemap-codec': 1.4.14 - dev: false /@manypkg/find-root@1.1.0: resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} @@ -1666,6 +1671,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@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true @@ -2900,7 +2920,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==} @@ -3075,6 +3094,11 @@ packages: ufo: 1.1.2 dev: true + /mri@1.2.0: + resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} + engines: {node: '>=4'} + dev: true + /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: true @@ -3608,6 +3632,13 @@ packages: queue-microtask: 1.2.3 dev: true + /sade@1.8.1: + resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} + engines: {node: '>=6'} + dependencies: + mri: 1.2.0 + dev: true + /safe-regex-test@1.0.0: resolution: {integrity: sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==} dependencies: From 0b15bb69287473b84e5a59368c1b644f45db183f Mon Sep 17 00:00:00 2001 From: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Date: Thu, 8 Jun 2023 19:42:15 +0545 Subject: [PATCH 03/33] fix: export ComponentType (#8694) * fix: export ComponentType * ughh * changeset --- .changeset/beige-boxes-rhyme.md | 5 +++++ packages/svelte/src/runtime/public.d.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/beige-boxes-rhyme.md diff --git a/.changeset/beige-boxes-rhyme.md b/.changeset/beige-boxes-rhyme.md new file mode 100644 index 000000000000..6f06ceac6f1e --- /dev/null +++ b/.changeset/beige-boxes-rhyme.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: export ComponentType from `svelte` entrypoint diff --git a/packages/svelte/src/runtime/public.d.ts b/packages/svelte/src/runtime/public.d.ts index 3024ba3a38e8..47bd1e8371d9 100644 --- a/packages/svelte/src/runtime/public.d.ts +++ b/packages/svelte/src/runtime/public.d.ts @@ -2,8 +2,9 @@ import './ambient.js'; export type { ComponentConstructorOptions, + ComponentEvents, ComponentProps, - ComponentEvents + ComponentType } from './internal/public.js'; export * from './index.js'; From 264da48887ff14b556047b8a3a2e0f2d2f3ee14a Mon Sep 17 00:00:00 2001 From: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Date: Thu, 8 Jun 2023 20:47:10 +0545 Subject: [PATCH 04/33] fix: derived types (#8700) * fix: derived store types * changeset --- .changeset/gentle-pumas-chew.md | 5 +++++ packages/svelte/src/runtime/store/index.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/gentle-pumas-chew.md diff --git a/.changeset/gentle-pumas-chew.md b/.changeset/gentle-pumas-chew.md new file mode 100644 index 000000000000..949837bbff61 --- /dev/null +++ b/.changeset/gentle-pumas-chew.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: derived store types diff --git a/packages/svelte/src/runtime/store/index.js b/packages/svelte/src/runtime/store/index.js index c0c20a885b86..3950e5ff4e6c 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} */ From 5963b6fd845fc48e4903f5b623e3ceb366aedcd2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 8 Jun 2023 11:03:52 -0400 Subject: [PATCH 05/33] Version Packages (next) (#8709) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 9 +++++++-- packages/svelte/CHANGELOG.md | 10 ++++++++++ packages/svelte/package.json | 2 +- packages/svelte/src/shared/version.js | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 7c25128a63ce..5bd51f5e8d73 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/packages/svelte/CHANGELOG.md b/packages/svelte/CHANGELOG.md index c42b1fa419f0..e3e082780678 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/package.json b/packages/svelte/package.json index 7267a91afb28..f3a539c075fb 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", diff --git a/packages/svelte/src/shared/version.js b/packages/svelte/src/shared/version.js index 80a6d82b3c96..45744232e4b2 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'; From 3d6dbdc3b67bf2a8559b0521b5ffd17524678094 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 8 Jun 2023 11:32:50 -0400 Subject: [PATCH 06/33] update type generation script --- .changeset/beige-boxes-rhyme.md | 5 + .changeset/gentle-pumas-chew.md | 5 + .changeset/green-sheep-learn.md | 5 + .changeset/pre.json | 9 +- .gitignore | 3 +- .vscode/launch.json | 27 ++ packages/playground/.gitignore | 3 + packages/playground/README.md | 7 + packages/playground/jsconfig.json | 33 +++ packages/playground/package.json | 14 + packages/playground/src/App.svelte | 3 + packages/playground/src/entry-client.js | 24 ++ packages/playground/src/entry-server.js | 6 + packages/playground/src/lib/Counter.svelte | 10 + packages/playground/src/template.html | 13 + packages/playground/start.js | 100 +++++++ packages/svelte/.gitignore | 9 - packages/svelte/CHANGELOG.md | 10 + packages/svelte/generate-types.js | 162 ----------- packages/svelte/package.json | 27 +- packages/svelte/rollup.config.js | 17 -- packages/svelte/scripts/generate-dts.js | 16 ++ packages/svelte/src/compiler/public.d.ts | 1 + packages/svelte/src/runtime/action/index.js | 1 - .../svelte/src/runtime/animate/public.d.ts | 2 + .../svelte/src/runtime/internal/public.d.ts | 2 + .../svelte/src/runtime/motion/public.d.ts | 2 + packages/svelte/src/runtime/public.d.ts | 5 +- packages/svelte/src/runtime/store/index.js | 4 +- packages/svelte/src/runtime/store/public.d.ts | 2 + .../svelte/src/runtime/transition/public.d.ts | 2 + packages/svelte/src/shared/version.js | 2 +- pnpm-lock.yaml | 151 ++++++++++- sites/svelte.dev/scripts/type-gen/index.js | 251 +++++------------- 34 files changed, 529 insertions(+), 404 deletions(-) create mode 100644 .changeset/beige-boxes-rhyme.md create mode 100644 .changeset/gentle-pumas-chew.md create mode 100644 .changeset/green-sheep-learn.md create mode 100644 .vscode/launch.json create mode 100644 packages/playground/.gitignore create mode 100644 packages/playground/README.md create mode 100644 packages/playground/jsconfig.json create mode 100644 packages/playground/package.json create mode 100644 packages/playground/src/App.svelte create mode 100644 packages/playground/src/entry-client.js create mode 100644 packages/playground/src/entry-server.js create mode 100644 packages/playground/src/lib/Counter.svelte create mode 100644 packages/playground/src/template.html create mode 100644 packages/playground/start.js delete mode 100644 packages/svelte/generate-types.js create mode 100644 packages/svelte/scripts/generate-dts.js delete mode 100644 packages/svelte/src/runtime/action/index.js diff --git a/.changeset/beige-boxes-rhyme.md b/.changeset/beige-boxes-rhyme.md new file mode 100644 index 000000000000..6f06ceac6f1e --- /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 000000000000..949837bbff61 --- /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 000000000000..b60047414408 --- /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 7c25128a63ce..5bd51f5e8d73 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/.gitignore b/.gitignore index 8a4d1d070e8f..cc2e05ea5f5e 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 000000000000..2e22a5ab9b7e --- /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/packages/playground/.gitignore b/packages/playground/.gitignore new file mode 100644 index 000000000000..0212d8b6cea4 --- /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 000000000000..6ac0393720cc --- /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 000000000000..ba142a7d31d6 --- /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 000000000000..9c1f03db2050 --- /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 000000000000..ab87de6d9679 --- /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 000000000000..e62bbf2eb783 --- /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 000000000000..7402e1e9add2 --- /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 000000000000..e45f90310979 --- /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 000000000000..2cc688066ff3 --- /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 000000000000..4144ba97acfd --- /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 4b6e38265237..13a9e4099990 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 ef78702e8895..c25d36684157 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 707bf746fd89..000000000000 --- 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 ade672ce3594..f3a539c075fb 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,18 @@ "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", + "build": "rollup -c && pnpm types", "prepare": "pnpm build", "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", + "types": "node ./scripts/generate-dts.js", "lint": "eslint \"{src,test}/**/*.{ts,js}\" --cache" }, "repository": { @@ -126,6 +126,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 927f8e949545..1bba3c607ecc 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 000000000000..2139118de240 --- /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 32d712afa2b2..202582789d63 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 cb0ff5c3b541..000000000000 --- 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 8c8e5565eaef..8a6cf5ebf659 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 6eab766077b6..64a9a04675e1 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 372d31636fda..bedbac8d22a1 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 8cfa2e6bf8af..47bd1e8371d9 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 c0c20a885b86..3950e5ff4e6c 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 b7368137ac7e..9655a1567471 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 0b158f9c2ec7..454840ad79c6 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 80a6d82b3c96..45744232e4b2 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 2c4d34f9da0d..32d0c7d72fc9 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: diff --git a/sites/svelte.dev/scripts/type-gen/index.js b/sites/svelte.dev/scripts/type-gen/index.js index 300b637ffb3d..d5a5ff722954 100644 --- a/sites/svelte.dev/scripts/type-gen/index.js +++ b/sites/svelte.dev/scripts/type-gen/index.js @@ -1,17 +1,16 @@ -// @ts-check import fs from 'fs'; -import prettier from 'prettier'; +import path from 'path'; import ts from 'typescript'; -import { get_bundled_types } from './compile-types.js'; +import prettier from 'prettier'; +import { fileURLToPath } from 'url'; -/** @typedef {{ - * name: string; - * comment: string; - * markdown?: string; - * snippet: string; - * deprecated: string | null; - * children: Extracted[] } - * } Extracted */ +/** @typedef {{ name: string; comment: string; markdown: string; }} Extracted */ + +function mkdirp(dir) { + try { + fs.mkdirSync(dir, { recursive: true }); + } catch {} +} /** @type {Array<{ name: string; comment: string; exports: Extracted[]; types: Extracted[]; exempt?: boolean; }>} */ const modules = []; @@ -51,41 +50,29 @@ function get_types(code, statements) { let start = statement.pos; let comment = ''; - /** @type {string | null} */ - let deprecated_notice = null; // @ts-ignore i think typescript is bad at typescript if (statement.jsDoc) { // @ts-ignore - const jsDoc = statement.jsDoc[0]; - - comment = jsDoc.comment; - - if (jsDoc?.tags?.[0]?.tagName?.escapedText === 'deprecated') { - deprecated_notice = jsDoc.tags[0].comment; - } - + comment = statement.jsDoc[0].comment; // @ts-ignore - start = jsDoc.end; + start = statement.jsDoc[0].end; } const i = code.indexOf('export', start); start = i + 6; - /** @type {Extracted[]} */ - let children = []; + /** @type {string[]} */ + const children = []; let snippet_unformatted = code.slice(start, statement.end).trim(); - if (ts.isInterfaceDeclaration(statement) || ts.isClassDeclaration(statement)) { + if (ts.isInterfaceDeclaration(statement)) { if (statement.members.length > 0) { for (const member of statement.members) { - // @ts-ignore children.push(munge_type_element(member)); } - children = children.filter(Boolean); - // collapse `interface Foo {/* lots of stuff*/}` into `interface Foo {…}` const first = statement.members.at(0); const last = statement.members.at(-1); @@ -119,13 +106,7 @@ function get_types(code, statements) { ? exports : types; - collection.push({ - name, - comment, - snippet, - children, - deprecated: deprecated_notice - }); + collection.push({ name, comment, snippet, children }); } } @@ -143,9 +124,7 @@ function munge_type_element(member, depth = 1) { // @ts-ignore const doc = member.jsDoc?.[0]; - if (/do not use!/i.test(doc?.comment)) return; - - /** @type {string[]} */ + /** @type {string} */ const children = []; const name = member.name?.escapedText; @@ -177,14 +156,6 @@ function munge_type_element(member, depth = 1) { const type = tag.tagName.escapedText; switch (tag.tagName.escapedText) { - case 'private': - bullets.push(`- private ${tag.comment}`); - break; - - case 'readonly': - bullets.push(`- readonly ${tag.comment}`); - break; - case 'param': bullets.push(`- \`${tag.name.getText()}\` ${tag.comment}`); break; @@ -197,10 +168,6 @@ function munge_type_element(member, depth = 1) { bullets.push(`- returns ${tag.comment}`); break; - case 'deprecated': - bullets.push(`- deprecated ${tag.comment}`); - break; - default: console.log(`unhandled JSDoc tag: ${type}`); // TODO indicate deprecated stuff } @@ -219,164 +186,70 @@ function munge_type_element(member, depth = 1) { }; } -const bundled_types = await get_bundled_types(); - -{ - const module = bundled_types.get('svelte'); - - if (!module) throw new Error('Could not find svelte'); - - modules.push({ - name: 'svelte', - comment: '', - ...get_types(module.code, module.ts_source_file.statements) - }); -} - -{ - const module = bundled_types.get('svelte/compiler'); - - if (!module) throw new Error('Could not find svelte/compiler'); - - modules.push({ - name: 'svelte/compiler', - comment: '', - ...get_types(module.code, module.ts_source_file.statements) - }); -} - -{ - const module = bundled_types.get('svelte/action'); - - if (!module) throw new Error('Could not find svelte/action'); - - modules.push({ - name: 'svelte/action', - comment: '', - ...get_types(module.code, module.ts_source_file.statements) - }); -} - -{ - const module = bundled_types.get('svelte/animate'); - - if (!module) throw new Error('Could not find svelte/animate'); - - modules.push({ - name: 'svelte/animate', - comment: '', - ...get_types(module.code, module.ts_source_file.statements) - }); -} - -{ - const module = bundled_types.get('svelte/easing'); - - if (!module) throw new Error('Could not find svelte/easing'); - - modules.push({ - name: 'svelte/easing', - comment: '', - ...get_types(module.code, module.ts_source_file.statements) - }); +/** + * Type declarations include fully qualified URLs so that they become links when + * you hover over names in an editor with TypeScript enabled. We need to remove + * the origin so that they become root-relative, so that they work in preview + * deployments and when developing locally + * @param {string} str + */ +function strip_origin(str) { + return str.replace(/https:\/\/svelte\.dev/g, ''); } -{ - const module = bundled_types.get('svelte/motion'); +/** + * @param {string} file + */ +function read_d_ts_file(file) { + const resolved = path.resolve('../../packages/svelte', file); - if (!module) throw new Error('Could not find svelte/motion'); + // We can't use JSDoc comments inside JSDoc, so we would get ts(7031) errors if + // we didn't ignore this error specifically for `/// file:` code examples + const str = fs.readFileSync(resolved, 'utf-8'); - modules.push({ - name: 'svelte/motion', - comment: '', - ...get_types(module.code, module.ts_source_file.statements) + return str.replace(/(\s*\*\s*)```js([\s\S]+?)```/g, (match, prefix, code) => { + return `${prefix}\`\`\`js${prefix}// @errors: 7031${code}\`\`\``; }); } { - const module = bundled_types.get('svelte/store'); + const code = read_d_ts_file('types/index.d.ts'); + const node = ts.createSourceFile('index.d.ts', code, ts.ScriptTarget.Latest, true); - if (!module) throw new Error('Could not find svelte/store'); + for (const statement of node.statements) { + if (ts.isModuleDeclaration(statement)) { + // @ts-ignore + const name = statement.name.text || statement.name.escapedText; - modules.push({ - name: 'svelte/store', - comment: '', - ...get_types(module.code, module.ts_source_file.statements) - }); -} - -{ - const module = bundled_types.get('svelte/transition'); + if (name === '*.svelte' || name === 'svelte/types/compiler/preprocess') { + continue; + } - if (!module) throw new Error('Could not find svelte/transition'); + // @ts-ignore + const comment = strip_origin(statement.jsDoc?.[0].comment ?? ''); - modules.push({ - name: 'svelte/transition', - comment: '', - ...get_types(module.code, module.ts_source_file.statements) - }); + modules.push({ + name, + comment, + // @ts-ignore + ...get_types(code, statement.body?.statements) + }); + } + } } modules.sort((a, b) => (a.name < b.name ? -1 : 1)); -// Fix the duplicate/messed up types -// !NOTE: This relies on mutation of `modules` -$: { - const module_with_SvelteComponent = modules.find((m) => - m.types.filter((t) => t.name === 'SvelteComponent') - ); - - if (!module_with_SvelteComponent) break $; - - const svelte_comp_part = module_with_SvelteComponent?.types.find( - (t) => t.name === 'SvelteComponent' - ); - - if (!svelte_comp_part) break $; - - const internal_module = bundled_types.get('svelte/internal'); - if (!internal_module) break $; - - const internal_types = get_types(internal_module.code, internal_module.ts_source_file.statements); - - const svelte_comp_dev_internal = internal_types.types.find( - (t) => t.name === 'SvelteComponentDev' - ); - - if (!svelte_comp_dev_internal) break $; - - svelte_comp_part.children = svelte_comp_dev_internal.children; - svelte_comp_part.comment = svelte_comp_dev_internal.comment; - svelte_comp_part.snippet = svelte_comp_dev_internal.snippet; -} - -// Remove $$_attributes from ActionReturn -$: { - const module_with_ActionReturn = modules.find((m) => - m.types.find((t) => t?.name === 'ActionReturn') - ); - - const new_children = - module_with_ActionReturn?.types[1].children.filter((c) => c.name !== '$$_attributes') || []; - - if (!module_with_ActionReturn) break $; - - module_with_ActionReturn.types[1].children = new_children; -} - -try { - fs.mkdirSync(new URL('../../src/lib/generated', import.meta.url), { recursive: true }); -} catch {} - +mkdirp('docs'); fs.writeFileSync( - new URL('../../src/lib/generated/type-info.js', import.meta.url), + 'src/lib/generated/type-info.js', ` -/* This file is generated by running \`pnpm generate\` - in the sites/svelte.dev directory — do not edit it */ -export const modules = /** @type {import('../generated/types').Modules} */ (${JSON.stringify( - modules, +/* This file is generated by running \`node scripts/type-gen.js\` + in the packages/kit directory — do not edit it */ +export const modules = ${JSON.stringify( + modules.filter((m) => !m.name.startsWith('_')), null, ' ' - )}); + )}; `.trim() ); From 7a46f2ece00af617387c00df144aca339e3c3b22 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 8 Jun 2023 11:55:58 -0400 Subject: [PATCH 07/33] remove unused stuff --- .../scripts/type-gen/compile-types.js | 127 -- .../scripts/type-gen/dts-sources/action.d.ts | 1 - .../scripts/type-gen/dts-sources/animate.d.ts | 1 - .../type-gen/dts-sources/compiler.d.ts | 1 - .../scripts/type-gen/dts-sources/easing.d.ts | 1 - .../scripts/type-gen/dts-sources/index.d.ts | 1 - .../type-gen/dts-sources/internal.d.ts | 1 - .../scripts/type-gen/dts-sources/motion.d.ts | 1 - .../scripts/type-gen/dts-sources/store.d.ts | 1 - .../type-gen/dts-sources/transition.d.ts | 1 - type-info.js | 1269 +++++++++++++++++ 11 files changed, 1269 insertions(+), 136 deletions(-) delete mode 100644 sites/svelte.dev/scripts/type-gen/compile-types.js delete mode 100644 sites/svelte.dev/scripts/type-gen/dts-sources/action.d.ts delete mode 100644 sites/svelte.dev/scripts/type-gen/dts-sources/animate.d.ts delete mode 100644 sites/svelte.dev/scripts/type-gen/dts-sources/compiler.d.ts delete mode 100644 sites/svelte.dev/scripts/type-gen/dts-sources/easing.d.ts delete mode 100644 sites/svelte.dev/scripts/type-gen/dts-sources/index.d.ts delete mode 100644 sites/svelte.dev/scripts/type-gen/dts-sources/internal.d.ts delete mode 100644 sites/svelte.dev/scripts/type-gen/dts-sources/motion.d.ts delete mode 100644 sites/svelte.dev/scripts/type-gen/dts-sources/store.d.ts delete mode 100644 sites/svelte.dev/scripts/type-gen/dts-sources/transition.d.ts create mode 100644 type-info.js diff --git a/sites/svelte.dev/scripts/type-gen/compile-types.js b/sites/svelte.dev/scripts/type-gen/compile-types.js deleted file mode 100644 index 14a1a3c66fd2..000000000000 --- a/sites/svelte.dev/scripts/type-gen/compile-types.js +++ /dev/null @@ -1,127 +0,0 @@ -// @ts-check -import MagicString from 'magic-string'; -import fs from 'node:fs'; -import { rollup } from 'rollup'; -import dts from 'rollup-plugin-dts'; -import { VERSION } from 'svelte/compiler'; -import { Project, SyntaxKind } from 'ts-morph'; -import ts from 'typescript'; - -export async function get_bundled_types() { - const dtsSources = fs.readdirSync(new URL('./dts-sources', import.meta.url)); - - /** @type {Map} */ - const codes = new Map(); - - for (const file of dtsSources) { - const bundle = await rollup({ - input: new URL(`./dts-sources/${file}`, import.meta.url).pathname, - plugins: [dts({ respectExternal: true })] - }); - - const moduleName = (file === 'index.d.ts' ? 'svelte' : `svelte/${file}`).replace('.d.ts', ''); - const code = await bundle.generate({ format: 'esm' }).then(({ output }) => output[0].code); - const inlined_export_declaration_code = inlineExportDeclarations(code); - - codes.set(moduleName, { - code: inlined_export_declaration_code, - ts_source_file: ts.createSourceFile( - 'index.d.ts', - inlined_export_declaration_code, - ts.ScriptTarget.ESNext, - true, - ts.ScriptKind.TS - ) - }); - - // !IMPORTANT: This is for debugging purposes only. - // !Do not remove until Svelte d.ts files are stable during v4/v5 - write_to_node_modules('before', file, code); - write_to_node_modules('after', file, inlined_export_declaration_code); - } - - return codes; -} - -/** - * @param {string} str - */ -function inlineExportDeclarations(str) { - const project = new Project(); - const source_file = project.createSourceFile('index.d.ts', str, { overwrite: true }); - - // There's only gonna be one because of the output of dts-plugin - const exportDeclaration = source_file.getExportDeclarations()[0]; - const exportedSymbols = exportDeclaration - .getNamedExports() - .map((e) => e.getAliasNode()?.getText() ?? e.getNameNode().getText()); - - // console.log(exportedSymbols); - if (exportedSymbols.length === 0) return str; - - const aliasedExportedSymbols = new Map(); - const namedExports = exportDeclaration.getNamedExports(); - - namedExports.forEach((namedExport) => { - if (namedExport.getAliasNode()) { - const alias = namedExport.getAliasNode()?.getText(); - const originalName = namedExport.getNameNode().getText(); - aliasedExportedSymbols.set(alias, originalName); - } - }); - - for (const [exported, og] of aliasedExportedSymbols) { - source_file.forEachDescendant((node) => { - if (node.getKind() === ts.SyntaxKind.Identifier && node.getText() === og) { - node.replaceWithText(exported); - } - }); - } - - { - // Get the symbols and their declarations - const exportedSymbols = exportDeclaration - .getNamedExports() - .map((exp) => exp.getSymbolOrThrow()); - - /** @type {import('ts-morph').ExportSpecifier[]} */ - // @ts-ignore - const exportedDeclarations = exportedSymbols.flatMap((symbol) => symbol.getDeclarations()); - - // Add 'export' keyword to the declarations - exportedDeclarations.forEach((declaration) => { - if (!declaration.getFirstDescendantByKind(SyntaxKind.ExportKeyword)) { - for (const target of declaration.getLocalTargetDeclarations()) { - if (target.isKind(SyntaxKind.VariableDeclaration)) { - target.getVariableStatement()?.setIsExported(true); - } else { - // @ts-ignore - target.setIsExported(true); - } - } - } - }); - } - - exportDeclaration.remove(); - - // In case it is export declare VERSION = '__VERSION__', replace it with svelte's real version - const stringified = source_file.getFullText().replace('__VERSION__', VERSION); - - return stringified; -} - -/** - * @param {'before' | 'after'} label - * @param {string} filename - * @param {string} code - */ -function write_to_node_modules(label, filename, code) { - const folder = new URL(`../../node_modules/.type-gen/${label}`, import.meta.url).pathname; - - try { - fs.mkdirSync(folder, { recursive: true }); - } catch {} - - fs.writeFileSync(`${folder}/${filename}`, code); -} diff --git a/sites/svelte.dev/scripts/type-gen/dts-sources/action.d.ts b/sites/svelte.dev/scripts/type-gen/dts-sources/action.d.ts deleted file mode 100644 index 917ea7b5a87c..000000000000 --- a/sites/svelte.dev/scripts/type-gen/dts-sources/action.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type * from 'svelte/action'; diff --git a/sites/svelte.dev/scripts/type-gen/dts-sources/animate.d.ts b/sites/svelte.dev/scripts/type-gen/dts-sources/animate.d.ts deleted file mode 100644 index 51a59e8429c2..000000000000 --- a/sites/svelte.dev/scripts/type-gen/dts-sources/animate.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type * from 'svelte/animate'; diff --git a/sites/svelte.dev/scripts/type-gen/dts-sources/compiler.d.ts b/sites/svelte.dev/scripts/type-gen/dts-sources/compiler.d.ts deleted file mode 100644 index f8deff9afb96..000000000000 --- a/sites/svelte.dev/scripts/type-gen/dts-sources/compiler.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type * from 'svelte/compiler'; diff --git a/sites/svelte.dev/scripts/type-gen/dts-sources/easing.d.ts b/sites/svelte.dev/scripts/type-gen/dts-sources/easing.d.ts deleted file mode 100644 index b882e429c313..000000000000 --- a/sites/svelte.dev/scripts/type-gen/dts-sources/easing.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type * from 'svelte/easing'; diff --git a/sites/svelte.dev/scripts/type-gen/dts-sources/index.d.ts b/sites/svelte.dev/scripts/type-gen/dts-sources/index.d.ts deleted file mode 100644 index 2988db0db1b2..000000000000 --- a/sites/svelte.dev/scripts/type-gen/dts-sources/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type * from 'svelte'; diff --git a/sites/svelte.dev/scripts/type-gen/dts-sources/internal.d.ts b/sites/svelte.dev/scripts/type-gen/dts-sources/internal.d.ts deleted file mode 100644 index 10f0475eea69..000000000000 --- a/sites/svelte.dev/scripts/type-gen/dts-sources/internal.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type * from 'svelte/internal'; diff --git a/sites/svelte.dev/scripts/type-gen/dts-sources/motion.d.ts b/sites/svelte.dev/scripts/type-gen/dts-sources/motion.d.ts deleted file mode 100644 index 7eaf31100004..000000000000 --- a/sites/svelte.dev/scripts/type-gen/dts-sources/motion.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type * from 'svelte/motion'; diff --git a/sites/svelte.dev/scripts/type-gen/dts-sources/store.d.ts b/sites/svelte.dev/scripts/type-gen/dts-sources/store.d.ts deleted file mode 100644 index f2b41123a1f7..000000000000 --- a/sites/svelte.dev/scripts/type-gen/dts-sources/store.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type * from 'svelte/store'; diff --git a/sites/svelte.dev/scripts/type-gen/dts-sources/transition.d.ts b/sites/svelte.dev/scripts/type-gen/dts-sources/transition.d.ts deleted file mode 100644 index 516c9b6ee9b7..000000000000 --- a/sites/svelte.dev/scripts/type-gen/dts-sources/transition.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type * from 'svelte/transition'; diff --git a/type-info.js b/type-info.js new file mode 100644 index 000000000000..11189c5f9aee --- /dev/null +++ b/type-info.js @@ -0,0 +1,1269 @@ +/* This file is generated by running `pnpm generate` + in the sites/svelte.dev directory — do not edit it */ +export const modules = /** @type {import('../generated/types').Modules} */ ([ + { + "name": "svelte", + "comment": "", + "types": [ + { + "name": "ComponentConstructorOptions", + "comment": "", + "snippet": "interface ComponentConstructorOptions<\n\tProps extends Record = Record\n> {/*…*/}", + "children": [ + { + "name": "target", + "snippet": "target: Element | ShadowRoot;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "anchor", + "snippet": "anchor?: Element;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "props", + "snippet": "props?: Props;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "context", + "snippet": "context?: Map;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "hydrate", + "snippet": "hydrate?: boolean;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "intro", + "snippet": "intro?: boolean;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "$$inline", + "snippet": "$$inline?: boolean;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "ComponentProps", + "comment": "Convenience type to get the props the given component expects. Example:\n```html\n\n```", + "snippet": "declare type ComponentProps =\n\tComponent extends SvelteComponentTyped ? Props : never;", + "children": [], + "deprecated": null + }, + { + "name": "ComponentType", + "comment": "Convenience type to get the type of a Svelte component. Useful for example in combination with\ndynamic components using ``.\n\nExample:\n```html\n\n\n\n\n```", + "snippet": "declare type ComponentType<\n\tComponent extends SvelteComponentTyped = SvelteComponentTyped\n> = new (\n\toptions: ComponentConstructorOptions<\n\t\tComponent extends SvelteComponentTyped\n\t\t\t? Props\n\t\t\t: Record\n\t>\n) => Component;", + "children": [], + "deprecated": null + }, + { + "name": "SvelteComponent", + "comment": "", + "snippet": "interface SvelteComponentDev {/*…*/}", + "children": [ + { + "name": "$set", + "snippet": "$set(props?: Props): void;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "$on", + "snippet": "$on(event: string, callback: (event: any) => void): () => void;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "$destroy", + "snippet": "$destroy(): void;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "snippet": "[accessor: string]: any;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "SvelteComponent", + "comment": "", + "snippet": "interface SvelteComponent {/*…*/}", + "children": [ + { + "name": "$set", + "snippet": "$set(props?: Props): void;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "$on", + "snippet": "$on(event: string, callback: (event: any) => void): () => void;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "$destroy", + "snippet": "$destroy(): void;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "snippet": "[accessor: string]: any;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "SvelteComponentTyped", + "comment": "", + "snippet": "interface SvelteComponentTyped<\n\tProps extends Record = any,\n\tEvents extends Record = any,\n\tSlots extends Record = any\n> {/*…*/}", + "children": [ + { + "name": "$set", + "snippet": "$set(props?: Partial): void;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "$on", + "snippet": "$on>(type: K, callback: (e: Events[K]) => void): () => void;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "$destroy", + "snippet": "$destroy(): void;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "snippet": "[accessor: string]: any;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "SvelteComponentTyped", + "comment": "Base class to create strongly typed Svelte components.\nThis only exists for typing purposes and should be used in `.d.ts` files.\n\n### Example:\n\nYou have component library on npm called `component-library`, from which\nyou export a component called `MyComponent`. For Svelte+TypeScript users,\nyou want to provide typings. Therefore you create a `index.d.ts`:\n```ts\nimport { SvelteComponentTyped } from \"svelte\";\nexport class MyComponent extends SvelteComponentTyped<{foo: string}> {}\n```\nTyping this makes it possible for IDEs like VS Code with the Svelte extension\nto provide intellisense and to use the component like this in a Svelte file\nwith TypeScript:\n```svelte\n\n\n```\n\n#### Why not make this part of `SvelteComponent(Dev)`?\nBecause\n```ts\nclass ASubclassOfSvelteComponent extends SvelteComponent<{foo: string}> {}\nconst component: typeof SvelteComponent = ASubclassOfSvelteComponent;\n```\nwill throw a type error, so we need to separate the more strictly typed class.", + "snippet": "declare class SvelteComponentTyped<\n\tProps extends Record = any,\n\tEvents extends Record = any,\n\tSlots extends Record = any\n> extends SvelteComponent {/*…*/}", + "children": [ + { + "name": "$$prop_def", + "snippet": "$$prop_def: Props;", + "comment": "", + "bullets": [ + "- private For type checking capabilities only.\nDoes not exist at runtime.\n### DO NOT USE!" + ], + "children": [] + }, + { + "name": "$$events_def", + "snippet": "$$events_def: Events;", + "comment": "", + "bullets": [ + "- private For type checking capabilities only.\nDoes not exist at runtime.\n### DO NOT USE!" + ], + "children": [] + }, + { + "name": "$$slot_def", + "snippet": "$$slot_def: Slots;", + "comment": "", + "bullets": [ + "- private For type checking capabilities only.\nDoes not exist at runtime.\n### DO NOT USE!" + ], + "children": [] + }, + { + "snippet": "constructor(options: ComponentConstructorOptions);", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + } + ], + "exports": [ + { + "name": "afterUpdate", + "comment": "", + "snippet": "declare function afterUpdate(fn: () => any): void;", + "children": [], + "deprecated": null + }, + { + "name": "beforeUpdate", + "comment": "", + "snippet": "declare function beforeUpdate(fn: () => any): void;", + "children": [], + "deprecated": null + }, + { + "name": "createEventDispatcher", + "comment": "", + "snippet": "declare function createEventDispatcher(): <\n\tEventKey extends Extract\n>(\n\ttype: EventKey,\n\tdetail?: EventMap[EventKey],\n\toptions?: DispatchOptions\n) => boolean;", + "children": [], + "deprecated": null + }, + { + "name": "getAllContexts", + "comment": "", + "snippet": "declare function getAllContexts = Map>(): T;", + "children": [], + "deprecated": null + }, + { + "name": "getContext", + "comment": "", + "snippet": "declare function getContext(key: any): T;", + "children": [], + "deprecated": null + }, + { + "name": "hasContext", + "comment": "", + "snippet": "declare function hasContext(key: any): boolean;", + "children": [], + "deprecated": null + }, + { + "name": "onDestroy", + "comment": "", + "snippet": "declare function onDestroy(fn: () => any): void;", + "children": [], + "deprecated": null + }, + { + "name": "onMount", + "comment": "", + "snippet": "declare function onMount(fn: () => any): void;", + "children": [], + "deprecated": null + }, + { + "name": "setContext", + "comment": "", + "snippet": "declare function setContext(key: any, context: T): T;", + "children": [], + "deprecated": null + }, + { + "name": "tick", + "comment": "", + "snippet": "declare function tick(): Promise;", + "children": [], + "deprecated": null + } + ] + }, + { + "name": "svelte/action", + "comment": "", + "types": [ + { + "name": "Action", + "comment": "Actions are functions that are called when an element is created.\nYou can use this interface to type such actions.\nThe following example defines an action that only works on `
` elements\nand optionally accepts a parameter which it has a default value for:\n```ts\nexport const myAction: Action = (node, param = { someProperty: true }) => {\n // ...\n}\n```\nYou can return an object with methods `update` and `destroy` from the function.\nSee interface `ActionReturn` for more details.\n\nDocs: https://svelte.dev/docs#template-syntax-element-directives-use-action", + "snippet": "interface Action {/*…*/}", + "children": [ + { + "snippet": "(node: Node, parameter?: Parameter): void | ActionReturn;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "ActionReturn", + "comment": "Actions can return an object containing the two properties defined in this interface. Both are optional.\n- update: An action can have a parameter. This method will be called whenever that parameter changes,\n immediately after Svelte has applied updates to the markup.\n- destroy: Method that is called after the element is unmounted\n\nExample usage:\n```ts\nexport function myAction(node: HTMLElement, parameter: Parameter): ActionReturn {\n // ...\n return {\n update: (updatedParameter) => {...},\n destroy: () => {...}\n };\n}\n```\n\nDocs: https://svelte.dev/docs#template-syntax-element-directives-use-action", + "snippet": "interface ActionReturn {/*…*/}", + "children": [ + { + "name": "update", + "snippet": "update?: (parameter: Parameter) => void;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "destroy", + "snippet": "destroy?: () => void;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + } + ], + "exports": [] + }, + { + "name": "svelte/animate", + "comment": "", + "types": [ + { + "name": "AnimationConfig", + "comment": "", + "snippet": "interface AnimationConfig {/*…*/}", + "children": [ + { + "name": "delay", + "snippet": "delay?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "duration", + "snippet": "duration?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "easing", + "snippet": "easing?: (t: number) => number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "css", + "snippet": "css?: (t: number, u: number) => string;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "tick", + "snippet": "tick?: (t: number, u: number) => void;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "FlipParams", + "comment": "", + "snippet": "interface FlipParams {/*…*/}", + "children": [ + { + "name": "delay", + "snippet": "delay?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "duration", + "snippet": "duration?: number | ((len: number) => number);", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "easing", + "snippet": "easing?: (t: number) => number;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + } + ], + "exports": [ + { + "name": "flip", + "comment": "", + "snippet": "declare function flip(\n\tnode: Element,\n\t{\n\t\tfrom,\n\t\tto\n\t}: {\n\t\tfrom: DOMRect;\n\t\tto: DOMRect;\n\t},\n\tparams?: FlipParams\n): AnimationConfig;", + "children": [], + "deprecated": null + } + ] + }, + { + "name": "svelte/compiler", + "comment": "", + "types": [], + "exports": [ + { + "name": "VERSION", + "comment": "", + "snippet": "declare const VERSION = '4.0.0-next.0';", + "children": [], + "deprecated": null + }, + { + "name": "compile", + "comment": "", + "snippet": "declare function compile(\n\tsource: string,\n\toptions?: CompileOptions\n): {\n\tjs: any;\n\tcss: any;\n\tast: Ast;\n\twarnings: Warning[];\n\tvars: Var[];\n\tstats: {\n\t\ttimings: {\n\t\t\ttotal: number;\n\t\t};\n\t};\n};", + "children": [], + "deprecated": null + }, + { + "name": "parse", + "comment": "", + "snippet": "declare function parse(template: string, options?: ParserOptions): Ast;", + "children": [], + "deprecated": null + }, + { + "name": "preprocess", + "comment": "", + "snippet": "declare function preprocess(\n\tsource: string,\n\tpreprocessor: PreprocessorGroup | PreprocessorGroup[],\n\toptions?: {\n\t\tfilename?: string;\n\t}\n): Promise;", + "children": [], + "deprecated": null + }, + { + "name": "walk", + "snippet": "declare function walk(\n\tast: Node,\n\t{\n\t\tenter,\n\t\tleave\n\t}: {\n\t\tenter?: SyncHandler;\n\t\tleave?: SyncHandler;\n\t}\n): Node | null;", + "children": [], + "deprecated": null + } + ] + }, + { + "name": "svelte/easing", + "comment": "", + "types": [], + "exports": [ + { + "name": "backIn", + "comment": "", + "snippet": "declare function backIn(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "backInOut", + "comment": "", + "snippet": "declare function backInOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "backOut", + "comment": "", + "snippet": "declare function backOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "bounceIn", + "comment": "", + "snippet": "declare function bounceIn(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "bounceInOut", + "comment": "", + "snippet": "declare function bounceInOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "bounceOut", + "comment": "", + "snippet": "declare function bounceOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "circIn", + "comment": "", + "snippet": "declare function circIn(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "circInOut", + "comment": "", + "snippet": "declare function circInOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "circOut", + "comment": "", + "snippet": "declare function circOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "cubicIn", + "comment": "", + "snippet": "declare function cubicIn(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "cubicInOut", + "comment": "", + "snippet": "declare function cubicInOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "cubicOut", + "comment": "", + "snippet": "declare function cubicOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "elasticIn", + "comment": "", + "snippet": "declare function elasticIn(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "elasticInOut", + "comment": "", + "snippet": "declare function elasticInOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "elasticOut", + "comment": "", + "snippet": "declare function elasticOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "expoIn", + "comment": "", + "snippet": "declare function expoIn(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "expoInOut", + "comment": "", + "snippet": "declare function expoInOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "expoOut", + "comment": "", + "snippet": "declare function expoOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "linear", + "comment": "", + "snippet": "declare const linear: (x: any) => any;", + "children": [], + "deprecated": null + }, + { + "name": "quadIn", + "comment": "", + "snippet": "declare function quadIn(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "quadInOut", + "comment": "", + "snippet": "declare function quadInOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "quadOut", + "comment": "", + "snippet": "declare function quadOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "quartIn", + "comment": "", + "snippet": "declare function quartIn(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "quartInOut", + "comment": "", + "snippet": "declare function quartInOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "quartOut", + "comment": "", + "snippet": "declare function quartOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "quintIn", + "comment": "", + "snippet": "declare function quintIn(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "quintInOut", + "comment": "", + "snippet": "declare function quintInOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "quintOut", + "comment": "", + "snippet": "declare function quintOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "sineIn", + "comment": "", + "snippet": "declare function sineIn(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "sineInOut", + "comment": "", + "snippet": "declare function sineInOut(t: number): number;", + "children": [], + "deprecated": null + }, + { + "name": "sineOut", + "comment": "", + "snippet": "declare function sineOut(t: number): number;", + "children": [], + "deprecated": null + } + ] + }, + { + "name": "svelte/motion", + "comment": "", + "types": [ + { + "name": "Spring", + "comment": "", + "snippet": "interface Spring extends Readable {/*…*/}", + "children": [ + { + "name": "set", + "snippet": "set: (new_value: T, opts?: SpringUpdateOpts) => Promise;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "update", + "snippet": "update: (fn: Updater$1, opts?: SpringUpdateOpts) => Promise;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "precision", + "snippet": "precision: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "damping", + "snippet": "damping: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "stiffness", + "snippet": "stiffness: number;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "Tweened", + "comment": "", + "snippet": "interface Tweened extends Readable {/*…*/}", + "children": [ + { + "name": "set", + "snippet": "set(value: T, opts?: Options): Promise;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "update", + "snippet": "update(updater: Updater, opts?: Options): Promise;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + } + ], + "exports": [ + { + "name": "spring", + "comment": "", + "snippet": "declare function spring(value?: T, opts?: SpringOpts): Spring;", + "children": [], + "deprecated": null + }, + { + "name": "tweened", + "comment": "", + "snippet": "declare function tweened(value?: T, defaults?: Options): Tweened;", + "children": [], + "deprecated": null + } + ] + }, + { + "name": "svelte/store", + "comment": "", + "types": [ + { + "name": "Readable", + "comment": "Readable interface for subscribing.", + "snippet": "interface Readable {/*…*/}", + "children": [ + { + "name": "subscribe", + "snippet": "subscribe(this: void, run: Subscriber, invalidate?: Invalidator): Unsubscriber;", + "comment": "Subscribe on value changes.", + "bullets": [ + "- `run` subscription callback", + "- `invalidate` cleanup callback" + ], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "StartStopNotifier", + "comment": "Start and stop notification callbacks.", + "snippet": "declare type StartStopNotifier = (set: Subscriber) => Unsubscriber | void;", + "children": [], + "deprecated": null + }, + { + "name": "Subscriber", + "comment": "Callback to inform of a value updates.", + "snippet": "declare type Subscriber = (value: T) => void;", + "children": [], + "deprecated": null + }, + { + "name": "Unsubscriber", + "comment": "Unsubscribes from value updates.", + "snippet": "declare type Unsubscriber = () => void;", + "children": [], + "deprecated": null + }, + { + "name": "Updater", + "comment": "Callback to update a value.", + "snippet": "declare type Updater = (value: T) => T;", + "children": [], + "deprecated": null + }, + { + "name": "Writable", + "comment": "Writable interface for both updating and subscribing.", + "snippet": "interface Writable extends Readable {/*…*/}", + "children": [ + { + "name": "set", + "snippet": "set(this: void, value: T): void;", + "comment": "Set value and inform subscribers.", + "bullets": [ + "- `value` to set" + ], + "children": [] + }, + { + "name": "update", + "snippet": "update(this: void, updater: Updater): void;", + "comment": "Update value using callback and inform subscribers.", + "bullets": [ + "- `updater` callback" + ], + "children": [] + } + ], + "deprecated": null + } + ], + "exports": [ + { + "name": "derived", + "comment": "Derived value store by synchronizing one or more readable stores and\napplying an aggregation function over its input values.", + "snippet": "declare function derived(\n\tstores: S,\n\tfn: (values: StoresValues, set: (value: T) => void) => Unsubscriber | void,\n\tinitial_value?: T\n): Readable;", + "children": [], + "deprecated": null + }, + { + "name": "derived", + "comment": "Derived value store by synchronizing one or more readable stores and\napplying an aggregation function over its input values.", + "snippet": "declare function derived(\n\tstores: S,\n\tfn: (values: StoresValues) => T,\n\tinitial_value?: T\n): Readable;", + "children": [], + "deprecated": null + }, + { + "name": "derived", + "comment": "Derived value store by synchronizing one or more readable stores and\napplying an aggregation function over its input values.", + "snippet": "declare function derived(\n\tstores: S,\n\tfn: (values: StoresValues) => T\n): Readable;", + "children": [], + "deprecated": null + }, + { + "name": "get", + "comment": "", + "snippet": "declare function get(store: Readable): T;", + "children": [], + "deprecated": null + }, + { + "name": "readable", + "comment": "Creates a `Readable` store that allows reading by subscription.", + "snippet": "declare function readable(\n\tvalue?: T,\n\tstart?: StartStopNotifier\n): Readable;", + "children": [], + "deprecated": null + }, + { + "name": "writable", + "comment": "Create a `Writable` store that allows both updating and reading by subscription.", + "snippet": "declare function writable(\n\tvalue?: T,\n\tstart?: StartStopNotifier\n): Writable;", + "children": [], + "deprecated": null + } + ] + }, + { + "name": "svelte/transition", + "comment": "", + "types": [ + { + "name": "BlurParams", + "comment": "", + "snippet": "interface BlurParams {/*…*/}", + "children": [ + { + "name": "delay", + "snippet": "delay?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "duration", + "snippet": "duration?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "easing", + "snippet": "easing?: EasingFunction;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "amount", + "snippet": "amount?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "opacity", + "snippet": "opacity?: number;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "CrossfadeParams", + "comment": "", + "snippet": "interface CrossfadeParams {/*…*/}", + "children": [ + { + "name": "delay", + "snippet": "delay?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "duration", + "snippet": "duration?: number | ((len: number) => number);", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "easing", + "snippet": "easing?: EasingFunction;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "DrawParams", + "comment": "", + "snippet": "interface DrawParams {/*…*/}", + "children": [ + { + "name": "delay", + "snippet": "delay?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "speed", + "snippet": "speed?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "duration", + "snippet": "duration?: number | ((len: number) => number);", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "easing", + "snippet": "easing?: EasingFunction;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "EasingFunction", + "comment": "", + "snippet": "declare type EasingFunction = (t: number) => number;", + "children": [], + "deprecated": null + }, + { + "name": "FadeParams", + "comment": "", + "snippet": "interface FadeParams {/*…*/}", + "children": [ + { + "name": "delay", + "snippet": "delay?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "duration", + "snippet": "duration?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "easing", + "snippet": "easing?: EasingFunction;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "FlyParams", + "comment": "", + "snippet": "interface FlyParams {/*…*/}", + "children": [ + { + "name": "delay", + "snippet": "delay?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "duration", + "snippet": "duration?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "easing", + "snippet": "easing?: EasingFunction;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "x", + "snippet": "x?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "y", + "snippet": "y?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "opacity", + "snippet": "opacity?: number;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "ScaleParams", + "comment": "", + "snippet": "interface ScaleParams {/*…*/}", + "children": [ + { + "name": "delay", + "snippet": "delay?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "duration", + "snippet": "duration?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "easing", + "snippet": "easing?: EasingFunction;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "start", + "snippet": "start?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "opacity", + "snippet": "opacity?: number;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "SlideParams", + "comment": "", + "snippet": "interface SlideParams {/*…*/}", + "children": [ + { + "name": "delay", + "snippet": "delay?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "duration", + "snippet": "duration?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "easing", + "snippet": "easing?: EasingFunction;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + }, + { + "name": "TransitionConfig", + "comment": "", + "snippet": "interface TransitionConfig {/*…*/}", + "children": [ + { + "name": "delay", + "snippet": "delay?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "duration", + "snippet": "duration?: number;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "easing", + "snippet": "easing?: EasingFunction;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "css", + "snippet": "css?: (t: number, u: number) => string;", + "comment": "", + "bullets": [], + "children": [] + }, + { + "name": "tick", + "snippet": "tick?: (t: number, u: number) => void;", + "comment": "", + "bullets": [], + "children": [] + } + ], + "deprecated": null + } + ], + "exports": [ + { + "name": "blur", + "comment": "", + "snippet": "declare function blur(\n\tnode: Element,\n\t{ delay, duration, easing, amount, opacity }?: BlurParams\n): TransitionConfig;", + "children": [], + "deprecated": null + }, + { + "name": "crossfade", + "comment": "", + "snippet": "declare function crossfade({\n\tfallback,\n\t...defaults\n}: CrossfadeParams & {\n\tfallback?: (\n\t\tnode: Element,\n\t\tparams: CrossfadeParams,\n\t\tintro: boolean\n\t) => TransitionConfig;\n}): [\n\t(\n\t\tnode: Element,\n\t\tparams: CrossfadeParams & {\n\t\t\tkey: any;\n\t\t}\n\t) => () => TransitionConfig,\n\t(\n\t\tnode: Element,\n\t\tparams: CrossfadeParams & {\n\t\t\tkey: any;\n\t\t}\n\t) => () => TransitionConfig\n];", + "children": [], + "deprecated": null + }, + { + "name": "draw", + "comment": "", + "snippet": "declare function draw(\n\tnode: SVGElement & {\n\t\tgetTotalLength(): number;\n\t},\n\t{ delay, speed, duration, easing }?: DrawParams\n): TransitionConfig;", + "children": [], + "deprecated": null + }, + { + "name": "fade", + "comment": "", + "snippet": "declare function fade(\n\tnode: Element,\n\t{ delay, duration, easing }?: FadeParams\n): TransitionConfig;", + "children": [], + "deprecated": null + }, + { + "name": "fly", + "comment": "", + "snippet": "declare function fly(\n\tnode: Element,\n\t{ delay, duration, easing, x, y, opacity }?: FlyParams\n): TransitionConfig;", + "children": [], + "deprecated": null + }, + { + "name": "scale", + "comment": "", + "snippet": "declare function scale(\n\tnode: Element,\n\t{ delay, duration, easing, start, opacity }?: ScaleParams\n): TransitionConfig;", + "children": [], + "deprecated": null + }, + { + "name": "slide", + "comment": "", + "snippet": "declare function slide(\n\tnode: Element,\n\t{ delay, duration, easing }?: SlideParams\n): TransitionConfig;", + "children": [], + "deprecated": null + } + ] + } +]); \ No newline at end of file From ba58327f4b077fdff62a7df4bf98d088abffaccb Mon Sep 17 00:00:00 2001 From: Dominik G Date: Thu, 8 Jun 2023 22:32:15 +0200 Subject: [PATCH 08/33] fix: changeset publish script isn't called release anymore (#8711) --- .github/workflows/release.yml | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8f3bad81072e..d311bff110c2 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/package.json b/package.json index 1fc9c0d3cfb3..a2f035b7d951 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", From 0c6f17274ee76de64f39cf7d2e9448901569b41d Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 8 Jun 2023 14:43:33 -0700 Subject: [PATCH 09/33] chore: remove prepare script (#8713) --- packages/svelte/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/svelte/package.json b/packages/svelte/package.json index f3a539c075fb..5d2c63c44cf9 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -75,7 +75,6 @@ "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 types", - "prepare": "pnpm build", "generate:version": "node ./scripts/generate-version.js", "dev": "rollup -cw", "posttest": "agadoo src/internal/index.js", From 8bd90219ec458fd8b7e99eeb5776895ab8e773a5 Mon Sep 17 00:00:00 2001 From: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Date: Fri, 9 Jun 2023 08:17:06 +0545 Subject: [PATCH 10/33] chore: fix release workflow (#8716) --- packages/svelte/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/svelte/package.json b/packages/svelte/package.json index 5d2c63c44cf9..f3dfc00c8566 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -78,7 +78,7 @@ "generate:version": "node ./scripts/generate-version.js", "dev": "rollup -cw", "posttest": "agadoo src/internal/index.js", - "prepublishOnly": "pnpm lint && pnpm build && pnpm test", + "prepublishOnly": "pnpm build", "types": "node ./scripts/generate-dts.js", "lint": "eslint \"{src,test}/**/*.{ts,js}\" --cache" }, From b8f7bf6bd0c155db7bcf7ebfbdb506e1b58ce0ea Mon Sep 17 00:00:00 2001 From: Puru Vijay Date: Sat, 10 Jun 2023 16:49:18 +0530 Subject: [PATCH 11/33] More readable, Fix $$_attributes --- packages/svelte/src/runtime/internal/dev.js | 2 +- sites/svelte.dev/scripts/type-gen/index.js | 133 +- type-info.js | 1269 ------------------- 3 files changed, 108 insertions(+), 1296 deletions(-) delete mode 100644 type-info.js diff --git a/packages/svelte/src/runtime/internal/dev.js b/packages/svelte/src/runtime/internal/dev.js index 8069141015f1..049fced285bd 100644 --- a/packages/svelte/src/runtime/internal/dev.js +++ b/packages/svelte/src/runtime/internal/dev.js @@ -274,7 +274,7 @@ export function construct_svelte_component_dev(component, props) { * * Can be used to create strongly typed Svelte components. * - * ### Example: + * #### Example: * * You have component library on npm called `component-library`, from which * you export a component called `MyComponent`. For Svelte+TypeScript users, diff --git a/sites/svelte.dev/scripts/type-gen/index.js b/sites/svelte.dev/scripts/type-gen/index.js index d5a5ff722954..e33b210c48e8 100644 --- a/sites/svelte.dev/scripts/type-gen/index.js +++ b/sites/svelte.dev/scripts/type-gen/index.js @@ -1,16 +1,17 @@ -import fs from 'fs'; -import path from 'path'; -import ts from 'typescript'; +// @ts-check +import fs from 'node:fs'; +import path from 'node:path'; import prettier from 'prettier'; -import { fileURLToPath } from 'url'; - -/** @typedef {{ name: string; comment: string; markdown: string; }} Extracted */ +import ts from 'typescript'; -function mkdirp(dir) { - try { - fs.mkdirSync(dir, { recursive: true }); - } catch {} -} +/** @typedef {{ + * name: string; + * comment: string; + * markdown?: string; + * snippet: string; + * deprecated: string | null; + * children: Extracted[] } + * } Extracted */ /** @type {Array<{ name: string; comment: string; exports: Extracted[]; types: Extracted[]; exempt?: boolean; }>} */ const modules = []; @@ -50,29 +51,41 @@ function get_types(code, statements) { let start = statement.pos; let comment = ''; + /** @type {string | null} */ + let deprecated_notice = null; // @ts-ignore i think typescript is bad at typescript if (statement.jsDoc) { // @ts-ignore - comment = statement.jsDoc[0].comment; + const jsDoc = statement.jsDoc[0]; + + comment = jsDoc.comment; + + if (jsDoc?.tags?.[0]?.tagName?.escapedText === 'deprecated') { + deprecated_notice = jsDoc.tags[0].comment; + } + // @ts-ignore - start = statement.jsDoc[0].end; + start = jsDoc.end; } const i = code.indexOf('export', start); start = i + 6; - /** @type {string[]} */ - const children = []; + /** @type {Extracted[]} */ + let children = []; let snippet_unformatted = code.slice(start, statement.end).trim(); - if (ts.isInterfaceDeclaration(statement)) { + if (ts.isInterfaceDeclaration(statement) || ts.isClassDeclaration(statement)) { if (statement.members.length > 0) { for (const member of statement.members) { + // @ts-ignore children.push(munge_type_element(member)); } + children = children.filter(Boolean); + // collapse `interface Foo {/* lots of stuff*/}` into `interface Foo {…}` const first = statement.members.at(0); const last = statement.members.at(-1); @@ -93,7 +106,7 @@ function get_types(code, statements) { const snippet = prettier .format(snippet_unformatted, { parser: 'typescript', - printWidth: 80, + printWidth: 60, useTabs: true, singleQuote: true, trailingComma: 'none' @@ -106,7 +119,13 @@ function get_types(code, statements) { ? exports : types; - collection.push({ name, comment, snippet, children }); + collection.push({ + name, + comment, + snippet, + children, + deprecated: deprecated_notice + }); } } @@ -124,7 +143,9 @@ function munge_type_element(member, depth = 1) { // @ts-ignore const doc = member.jsDoc?.[0]; - /** @type {string} */ + if (/do not use!/i.test(doc?.comment)) return; + + /** @type {string[]} */ const children = []; const name = member.name?.escapedText; @@ -156,6 +177,14 @@ function munge_type_element(member, depth = 1) { const type = tag.tagName.escapedText; switch (tag.tagName.escapedText) { + case 'private': + bullets.push(`- private ${tag.comment}`); + break; + + case 'readonly': + bullets.push(`- readonly ${tag.comment}`); + break; + case 'param': bullets.push(`- \`${tag.name.getText()}\` ${tag.comment}`); break; @@ -168,6 +197,10 @@ function munge_type_element(member, depth = 1) { bullets.push(`- returns ${tag.comment}`); break; + case 'deprecated': + bullets.push(`- deprecated ${tag.comment}`); + break; + default: console.log(`unhandled JSDoc tag: ${type}`); // TODO indicate deprecated stuff } @@ -240,16 +273,64 @@ function read_d_ts_file(file) { modules.sort((a, b) => (a.name < b.name ? -1 : 1)); -mkdirp('docs'); +// // Fix the duplicate/messed up types +// // !NOTE: This relies on mutation of `modules` +// $: { +// const module_with_SvelteComponent = modules.find((m) => +// m.types.filter((t) => t.name === 'SvelteComponent') +// ); + +// if (!module_with_SvelteComponent) break $; + +// const svelte_comp_part = module_with_SvelteComponent?.types.find( +// (t) => t.name === 'SvelteComponent' +// ); + +// if (!svelte_comp_part) break $; + +// const internal_module = bundled_types.get('svelte/internal'); +// if (!internal_module) break $; + +// const internal_types = get_types(internal_module.code, internal_module.ts_source_file.statements); + +// const svelte_comp_dev_internal = internal_types.types.find( +// (t) => t.name === 'SvelteComponentDev' +// ); + +// if (!svelte_comp_dev_internal) break $; + +// svelte_comp_part.children = svelte_comp_dev_internal.children; +// svelte_comp_part.comment = svelte_comp_dev_internal.comment; +// svelte_comp_part.snippet = svelte_comp_dev_internal.snippet; +// } + +// Remove $$_attributes from ActionReturn +$: { + const module_with_ActionReturn = modules.find((m) => + m.types.find((t) => t?.name === 'ActionReturn') + ); + + const new_children = + module_with_ActionReturn?.types[1].children.filter((c) => c.name !== '$$_attributes') || []; + + if (!module_with_ActionReturn) break $; + + module_with_ActionReturn.types[1].children = new_children; +} + +try { + fs.mkdirSync(new URL('../../src/lib/generated', import.meta.url), { recursive: true }); +} catch {} + fs.writeFileSync( - 'src/lib/generated/type-info.js', + new URL('../../src/lib/generated/type-info.js', import.meta.url), ` -/* This file is generated by running \`node scripts/type-gen.js\` - in the packages/kit directory — do not edit it */ -export const modules = ${JSON.stringify( - modules.filter((m) => !m.name.startsWith('_')), +/* This file is generated by running \`pnpm generate\` + in the sites/svelte.dev directory — do not edit it */ +export const modules = /** @type {import('../generated/types').Modules} */ (${JSON.stringify( + modules, null, ' ' - )}; + )}); `.trim() ); diff --git a/type-info.js b/type-info.js deleted file mode 100644 index 11189c5f9aee..000000000000 --- a/type-info.js +++ /dev/null @@ -1,1269 +0,0 @@ -/* This file is generated by running `pnpm generate` - in the sites/svelte.dev directory — do not edit it */ -export const modules = /** @type {import('../generated/types').Modules} */ ([ - { - "name": "svelte", - "comment": "", - "types": [ - { - "name": "ComponentConstructorOptions", - "comment": "", - "snippet": "interface ComponentConstructorOptions<\n\tProps extends Record = Record\n> {/*…*/}", - "children": [ - { - "name": "target", - "snippet": "target: Element | ShadowRoot;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "anchor", - "snippet": "anchor?: Element;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "props", - "snippet": "props?: Props;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "context", - "snippet": "context?: Map;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "hydrate", - "snippet": "hydrate?: boolean;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "intro", - "snippet": "intro?: boolean;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "$$inline", - "snippet": "$$inline?: boolean;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "ComponentProps", - "comment": "Convenience type to get the props the given component expects. Example:\n```html\n\n```", - "snippet": "declare type ComponentProps =\n\tComponent extends SvelteComponentTyped ? Props : never;", - "children": [], - "deprecated": null - }, - { - "name": "ComponentType", - "comment": "Convenience type to get the type of a Svelte component. Useful for example in combination with\ndynamic components using ``.\n\nExample:\n```html\n\n\n\n\n```", - "snippet": "declare type ComponentType<\n\tComponent extends SvelteComponentTyped = SvelteComponentTyped\n> = new (\n\toptions: ComponentConstructorOptions<\n\t\tComponent extends SvelteComponentTyped\n\t\t\t? Props\n\t\t\t: Record\n\t>\n) => Component;", - "children": [], - "deprecated": null - }, - { - "name": "SvelteComponent", - "comment": "", - "snippet": "interface SvelteComponentDev {/*…*/}", - "children": [ - { - "name": "$set", - "snippet": "$set(props?: Props): void;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "$on", - "snippet": "$on(event: string, callback: (event: any) => void): () => void;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "$destroy", - "snippet": "$destroy(): void;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "snippet": "[accessor: string]: any;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "SvelteComponent", - "comment": "", - "snippet": "interface SvelteComponent {/*…*/}", - "children": [ - { - "name": "$set", - "snippet": "$set(props?: Props): void;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "$on", - "snippet": "$on(event: string, callback: (event: any) => void): () => void;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "$destroy", - "snippet": "$destroy(): void;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "snippet": "[accessor: string]: any;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "SvelteComponentTyped", - "comment": "", - "snippet": "interface SvelteComponentTyped<\n\tProps extends Record = any,\n\tEvents extends Record = any,\n\tSlots extends Record = any\n> {/*…*/}", - "children": [ - { - "name": "$set", - "snippet": "$set(props?: Partial): void;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "$on", - "snippet": "$on>(type: K, callback: (e: Events[K]) => void): () => void;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "$destroy", - "snippet": "$destroy(): void;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "snippet": "[accessor: string]: any;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "SvelteComponentTyped", - "comment": "Base class to create strongly typed Svelte components.\nThis only exists for typing purposes and should be used in `.d.ts` files.\n\n### Example:\n\nYou have component library on npm called `component-library`, from which\nyou export a component called `MyComponent`. For Svelte+TypeScript users,\nyou want to provide typings. Therefore you create a `index.d.ts`:\n```ts\nimport { SvelteComponentTyped } from \"svelte\";\nexport class MyComponent extends SvelteComponentTyped<{foo: string}> {}\n```\nTyping this makes it possible for IDEs like VS Code with the Svelte extension\nto provide intellisense and to use the component like this in a Svelte file\nwith TypeScript:\n```svelte\n\n\n```\n\n#### Why not make this part of `SvelteComponent(Dev)`?\nBecause\n```ts\nclass ASubclassOfSvelteComponent extends SvelteComponent<{foo: string}> {}\nconst component: typeof SvelteComponent = ASubclassOfSvelteComponent;\n```\nwill throw a type error, so we need to separate the more strictly typed class.", - "snippet": "declare class SvelteComponentTyped<\n\tProps extends Record = any,\n\tEvents extends Record = any,\n\tSlots extends Record = any\n> extends SvelteComponent {/*…*/}", - "children": [ - { - "name": "$$prop_def", - "snippet": "$$prop_def: Props;", - "comment": "", - "bullets": [ - "- private For type checking capabilities only.\nDoes not exist at runtime.\n### DO NOT USE!" - ], - "children": [] - }, - { - "name": "$$events_def", - "snippet": "$$events_def: Events;", - "comment": "", - "bullets": [ - "- private For type checking capabilities only.\nDoes not exist at runtime.\n### DO NOT USE!" - ], - "children": [] - }, - { - "name": "$$slot_def", - "snippet": "$$slot_def: Slots;", - "comment": "", - "bullets": [ - "- private For type checking capabilities only.\nDoes not exist at runtime.\n### DO NOT USE!" - ], - "children": [] - }, - { - "snippet": "constructor(options: ComponentConstructorOptions);", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - } - ], - "exports": [ - { - "name": "afterUpdate", - "comment": "", - "snippet": "declare function afterUpdate(fn: () => any): void;", - "children": [], - "deprecated": null - }, - { - "name": "beforeUpdate", - "comment": "", - "snippet": "declare function beforeUpdate(fn: () => any): void;", - "children": [], - "deprecated": null - }, - { - "name": "createEventDispatcher", - "comment": "", - "snippet": "declare function createEventDispatcher(): <\n\tEventKey extends Extract\n>(\n\ttype: EventKey,\n\tdetail?: EventMap[EventKey],\n\toptions?: DispatchOptions\n) => boolean;", - "children": [], - "deprecated": null - }, - { - "name": "getAllContexts", - "comment": "", - "snippet": "declare function getAllContexts = Map>(): T;", - "children": [], - "deprecated": null - }, - { - "name": "getContext", - "comment": "", - "snippet": "declare function getContext(key: any): T;", - "children": [], - "deprecated": null - }, - { - "name": "hasContext", - "comment": "", - "snippet": "declare function hasContext(key: any): boolean;", - "children": [], - "deprecated": null - }, - { - "name": "onDestroy", - "comment": "", - "snippet": "declare function onDestroy(fn: () => any): void;", - "children": [], - "deprecated": null - }, - { - "name": "onMount", - "comment": "", - "snippet": "declare function onMount(fn: () => any): void;", - "children": [], - "deprecated": null - }, - { - "name": "setContext", - "comment": "", - "snippet": "declare function setContext(key: any, context: T): T;", - "children": [], - "deprecated": null - }, - { - "name": "tick", - "comment": "", - "snippet": "declare function tick(): Promise;", - "children": [], - "deprecated": null - } - ] - }, - { - "name": "svelte/action", - "comment": "", - "types": [ - { - "name": "Action", - "comment": "Actions are functions that are called when an element is created.\nYou can use this interface to type such actions.\nThe following example defines an action that only works on `
` elements\nand optionally accepts a parameter which it has a default value for:\n```ts\nexport const myAction: Action = (node, param = { someProperty: true }) => {\n // ...\n}\n```\nYou can return an object with methods `update` and `destroy` from the function.\nSee interface `ActionReturn` for more details.\n\nDocs: https://svelte.dev/docs#template-syntax-element-directives-use-action", - "snippet": "interface Action {/*…*/}", - "children": [ - { - "snippet": "(node: Node, parameter?: Parameter): void | ActionReturn;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "ActionReturn", - "comment": "Actions can return an object containing the two properties defined in this interface. Both are optional.\n- update: An action can have a parameter. This method will be called whenever that parameter changes,\n immediately after Svelte has applied updates to the markup.\n- destroy: Method that is called after the element is unmounted\n\nExample usage:\n```ts\nexport function myAction(node: HTMLElement, parameter: Parameter): ActionReturn {\n // ...\n return {\n update: (updatedParameter) => {...},\n destroy: () => {...}\n };\n}\n```\n\nDocs: https://svelte.dev/docs#template-syntax-element-directives-use-action", - "snippet": "interface ActionReturn {/*…*/}", - "children": [ - { - "name": "update", - "snippet": "update?: (parameter: Parameter) => void;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "destroy", - "snippet": "destroy?: () => void;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - } - ], - "exports": [] - }, - { - "name": "svelte/animate", - "comment": "", - "types": [ - { - "name": "AnimationConfig", - "comment": "", - "snippet": "interface AnimationConfig {/*…*/}", - "children": [ - { - "name": "delay", - "snippet": "delay?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "duration", - "snippet": "duration?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "easing", - "snippet": "easing?: (t: number) => number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "css", - "snippet": "css?: (t: number, u: number) => string;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "tick", - "snippet": "tick?: (t: number, u: number) => void;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "FlipParams", - "comment": "", - "snippet": "interface FlipParams {/*…*/}", - "children": [ - { - "name": "delay", - "snippet": "delay?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "duration", - "snippet": "duration?: number | ((len: number) => number);", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "easing", - "snippet": "easing?: (t: number) => number;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - } - ], - "exports": [ - { - "name": "flip", - "comment": "", - "snippet": "declare function flip(\n\tnode: Element,\n\t{\n\t\tfrom,\n\t\tto\n\t}: {\n\t\tfrom: DOMRect;\n\t\tto: DOMRect;\n\t},\n\tparams?: FlipParams\n): AnimationConfig;", - "children": [], - "deprecated": null - } - ] - }, - { - "name": "svelte/compiler", - "comment": "", - "types": [], - "exports": [ - { - "name": "VERSION", - "comment": "", - "snippet": "declare const VERSION = '4.0.0-next.0';", - "children": [], - "deprecated": null - }, - { - "name": "compile", - "comment": "", - "snippet": "declare function compile(\n\tsource: string,\n\toptions?: CompileOptions\n): {\n\tjs: any;\n\tcss: any;\n\tast: Ast;\n\twarnings: Warning[];\n\tvars: Var[];\n\tstats: {\n\t\ttimings: {\n\t\t\ttotal: number;\n\t\t};\n\t};\n};", - "children": [], - "deprecated": null - }, - { - "name": "parse", - "comment": "", - "snippet": "declare function parse(template: string, options?: ParserOptions): Ast;", - "children": [], - "deprecated": null - }, - { - "name": "preprocess", - "comment": "", - "snippet": "declare function preprocess(\n\tsource: string,\n\tpreprocessor: PreprocessorGroup | PreprocessorGroup[],\n\toptions?: {\n\t\tfilename?: string;\n\t}\n): Promise;", - "children": [], - "deprecated": null - }, - { - "name": "walk", - "snippet": "declare function walk(\n\tast: Node,\n\t{\n\t\tenter,\n\t\tleave\n\t}: {\n\t\tenter?: SyncHandler;\n\t\tleave?: SyncHandler;\n\t}\n): Node | null;", - "children": [], - "deprecated": null - } - ] - }, - { - "name": "svelte/easing", - "comment": "", - "types": [], - "exports": [ - { - "name": "backIn", - "comment": "", - "snippet": "declare function backIn(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "backInOut", - "comment": "", - "snippet": "declare function backInOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "backOut", - "comment": "", - "snippet": "declare function backOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "bounceIn", - "comment": "", - "snippet": "declare function bounceIn(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "bounceInOut", - "comment": "", - "snippet": "declare function bounceInOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "bounceOut", - "comment": "", - "snippet": "declare function bounceOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "circIn", - "comment": "", - "snippet": "declare function circIn(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "circInOut", - "comment": "", - "snippet": "declare function circInOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "circOut", - "comment": "", - "snippet": "declare function circOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "cubicIn", - "comment": "", - "snippet": "declare function cubicIn(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "cubicInOut", - "comment": "", - "snippet": "declare function cubicInOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "cubicOut", - "comment": "", - "snippet": "declare function cubicOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "elasticIn", - "comment": "", - "snippet": "declare function elasticIn(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "elasticInOut", - "comment": "", - "snippet": "declare function elasticInOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "elasticOut", - "comment": "", - "snippet": "declare function elasticOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "expoIn", - "comment": "", - "snippet": "declare function expoIn(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "expoInOut", - "comment": "", - "snippet": "declare function expoInOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "expoOut", - "comment": "", - "snippet": "declare function expoOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "linear", - "comment": "", - "snippet": "declare const linear: (x: any) => any;", - "children": [], - "deprecated": null - }, - { - "name": "quadIn", - "comment": "", - "snippet": "declare function quadIn(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "quadInOut", - "comment": "", - "snippet": "declare function quadInOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "quadOut", - "comment": "", - "snippet": "declare function quadOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "quartIn", - "comment": "", - "snippet": "declare function quartIn(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "quartInOut", - "comment": "", - "snippet": "declare function quartInOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "quartOut", - "comment": "", - "snippet": "declare function quartOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "quintIn", - "comment": "", - "snippet": "declare function quintIn(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "quintInOut", - "comment": "", - "snippet": "declare function quintInOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "quintOut", - "comment": "", - "snippet": "declare function quintOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "sineIn", - "comment": "", - "snippet": "declare function sineIn(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "sineInOut", - "comment": "", - "snippet": "declare function sineInOut(t: number): number;", - "children": [], - "deprecated": null - }, - { - "name": "sineOut", - "comment": "", - "snippet": "declare function sineOut(t: number): number;", - "children": [], - "deprecated": null - } - ] - }, - { - "name": "svelte/motion", - "comment": "", - "types": [ - { - "name": "Spring", - "comment": "", - "snippet": "interface Spring extends Readable {/*…*/}", - "children": [ - { - "name": "set", - "snippet": "set: (new_value: T, opts?: SpringUpdateOpts) => Promise;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "update", - "snippet": "update: (fn: Updater$1, opts?: SpringUpdateOpts) => Promise;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "precision", - "snippet": "precision: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "damping", - "snippet": "damping: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "stiffness", - "snippet": "stiffness: number;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "Tweened", - "comment": "", - "snippet": "interface Tweened extends Readable {/*…*/}", - "children": [ - { - "name": "set", - "snippet": "set(value: T, opts?: Options): Promise;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "update", - "snippet": "update(updater: Updater, opts?: Options): Promise;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - } - ], - "exports": [ - { - "name": "spring", - "comment": "", - "snippet": "declare function spring(value?: T, opts?: SpringOpts): Spring;", - "children": [], - "deprecated": null - }, - { - "name": "tweened", - "comment": "", - "snippet": "declare function tweened(value?: T, defaults?: Options): Tweened;", - "children": [], - "deprecated": null - } - ] - }, - { - "name": "svelte/store", - "comment": "", - "types": [ - { - "name": "Readable", - "comment": "Readable interface for subscribing.", - "snippet": "interface Readable {/*…*/}", - "children": [ - { - "name": "subscribe", - "snippet": "subscribe(this: void, run: Subscriber, invalidate?: Invalidator): Unsubscriber;", - "comment": "Subscribe on value changes.", - "bullets": [ - "- `run` subscription callback", - "- `invalidate` cleanup callback" - ], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "StartStopNotifier", - "comment": "Start and stop notification callbacks.", - "snippet": "declare type StartStopNotifier = (set: Subscriber) => Unsubscriber | void;", - "children": [], - "deprecated": null - }, - { - "name": "Subscriber", - "comment": "Callback to inform of a value updates.", - "snippet": "declare type Subscriber = (value: T) => void;", - "children": [], - "deprecated": null - }, - { - "name": "Unsubscriber", - "comment": "Unsubscribes from value updates.", - "snippet": "declare type Unsubscriber = () => void;", - "children": [], - "deprecated": null - }, - { - "name": "Updater", - "comment": "Callback to update a value.", - "snippet": "declare type Updater = (value: T) => T;", - "children": [], - "deprecated": null - }, - { - "name": "Writable", - "comment": "Writable interface for both updating and subscribing.", - "snippet": "interface Writable extends Readable {/*…*/}", - "children": [ - { - "name": "set", - "snippet": "set(this: void, value: T): void;", - "comment": "Set value and inform subscribers.", - "bullets": [ - "- `value` to set" - ], - "children": [] - }, - { - "name": "update", - "snippet": "update(this: void, updater: Updater): void;", - "comment": "Update value using callback and inform subscribers.", - "bullets": [ - "- `updater` callback" - ], - "children": [] - } - ], - "deprecated": null - } - ], - "exports": [ - { - "name": "derived", - "comment": "Derived value store by synchronizing one or more readable stores and\napplying an aggregation function over its input values.", - "snippet": "declare function derived(\n\tstores: S,\n\tfn: (values: StoresValues, set: (value: T) => void) => Unsubscriber | void,\n\tinitial_value?: T\n): Readable;", - "children": [], - "deprecated": null - }, - { - "name": "derived", - "comment": "Derived value store by synchronizing one or more readable stores and\napplying an aggregation function over its input values.", - "snippet": "declare function derived(\n\tstores: S,\n\tfn: (values: StoresValues) => T,\n\tinitial_value?: T\n): Readable;", - "children": [], - "deprecated": null - }, - { - "name": "derived", - "comment": "Derived value store by synchronizing one or more readable stores and\napplying an aggregation function over its input values.", - "snippet": "declare function derived(\n\tstores: S,\n\tfn: (values: StoresValues) => T\n): Readable;", - "children": [], - "deprecated": null - }, - { - "name": "get", - "comment": "", - "snippet": "declare function get(store: Readable): T;", - "children": [], - "deprecated": null - }, - { - "name": "readable", - "comment": "Creates a `Readable` store that allows reading by subscription.", - "snippet": "declare function readable(\n\tvalue?: T,\n\tstart?: StartStopNotifier\n): Readable;", - "children": [], - "deprecated": null - }, - { - "name": "writable", - "comment": "Create a `Writable` store that allows both updating and reading by subscription.", - "snippet": "declare function writable(\n\tvalue?: T,\n\tstart?: StartStopNotifier\n): Writable;", - "children": [], - "deprecated": null - } - ] - }, - { - "name": "svelte/transition", - "comment": "", - "types": [ - { - "name": "BlurParams", - "comment": "", - "snippet": "interface BlurParams {/*…*/}", - "children": [ - { - "name": "delay", - "snippet": "delay?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "duration", - "snippet": "duration?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "easing", - "snippet": "easing?: EasingFunction;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "amount", - "snippet": "amount?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "opacity", - "snippet": "opacity?: number;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "CrossfadeParams", - "comment": "", - "snippet": "interface CrossfadeParams {/*…*/}", - "children": [ - { - "name": "delay", - "snippet": "delay?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "duration", - "snippet": "duration?: number | ((len: number) => number);", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "easing", - "snippet": "easing?: EasingFunction;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "DrawParams", - "comment": "", - "snippet": "interface DrawParams {/*…*/}", - "children": [ - { - "name": "delay", - "snippet": "delay?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "speed", - "snippet": "speed?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "duration", - "snippet": "duration?: number | ((len: number) => number);", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "easing", - "snippet": "easing?: EasingFunction;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "EasingFunction", - "comment": "", - "snippet": "declare type EasingFunction = (t: number) => number;", - "children": [], - "deprecated": null - }, - { - "name": "FadeParams", - "comment": "", - "snippet": "interface FadeParams {/*…*/}", - "children": [ - { - "name": "delay", - "snippet": "delay?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "duration", - "snippet": "duration?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "easing", - "snippet": "easing?: EasingFunction;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "FlyParams", - "comment": "", - "snippet": "interface FlyParams {/*…*/}", - "children": [ - { - "name": "delay", - "snippet": "delay?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "duration", - "snippet": "duration?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "easing", - "snippet": "easing?: EasingFunction;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "x", - "snippet": "x?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "y", - "snippet": "y?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "opacity", - "snippet": "opacity?: number;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "ScaleParams", - "comment": "", - "snippet": "interface ScaleParams {/*…*/}", - "children": [ - { - "name": "delay", - "snippet": "delay?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "duration", - "snippet": "duration?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "easing", - "snippet": "easing?: EasingFunction;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "start", - "snippet": "start?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "opacity", - "snippet": "opacity?: number;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "SlideParams", - "comment": "", - "snippet": "interface SlideParams {/*…*/}", - "children": [ - { - "name": "delay", - "snippet": "delay?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "duration", - "snippet": "duration?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "easing", - "snippet": "easing?: EasingFunction;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - }, - { - "name": "TransitionConfig", - "comment": "", - "snippet": "interface TransitionConfig {/*…*/}", - "children": [ - { - "name": "delay", - "snippet": "delay?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "duration", - "snippet": "duration?: number;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "easing", - "snippet": "easing?: EasingFunction;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "css", - "snippet": "css?: (t: number, u: number) => string;", - "comment": "", - "bullets": [], - "children": [] - }, - { - "name": "tick", - "snippet": "tick?: (t: number, u: number) => void;", - "comment": "", - "bullets": [], - "children": [] - } - ], - "deprecated": null - } - ], - "exports": [ - { - "name": "blur", - "comment": "", - "snippet": "declare function blur(\n\tnode: Element,\n\t{ delay, duration, easing, amount, opacity }?: BlurParams\n): TransitionConfig;", - "children": [], - "deprecated": null - }, - { - "name": "crossfade", - "comment": "", - "snippet": "declare function crossfade({\n\tfallback,\n\t...defaults\n}: CrossfadeParams & {\n\tfallback?: (\n\t\tnode: Element,\n\t\tparams: CrossfadeParams,\n\t\tintro: boolean\n\t) => TransitionConfig;\n}): [\n\t(\n\t\tnode: Element,\n\t\tparams: CrossfadeParams & {\n\t\t\tkey: any;\n\t\t}\n\t) => () => TransitionConfig,\n\t(\n\t\tnode: Element,\n\t\tparams: CrossfadeParams & {\n\t\t\tkey: any;\n\t\t}\n\t) => () => TransitionConfig\n];", - "children": [], - "deprecated": null - }, - { - "name": "draw", - "comment": "", - "snippet": "declare function draw(\n\tnode: SVGElement & {\n\t\tgetTotalLength(): number;\n\t},\n\t{ delay, speed, duration, easing }?: DrawParams\n): TransitionConfig;", - "children": [], - "deprecated": null - }, - { - "name": "fade", - "comment": "", - "snippet": "declare function fade(\n\tnode: Element,\n\t{ delay, duration, easing }?: FadeParams\n): TransitionConfig;", - "children": [], - "deprecated": null - }, - { - "name": "fly", - "comment": "", - "snippet": "declare function fly(\n\tnode: Element,\n\t{ delay, duration, easing, x, y, opacity }?: FlyParams\n): TransitionConfig;", - "children": [], - "deprecated": null - }, - { - "name": "scale", - "comment": "", - "snippet": "declare function scale(\n\tnode: Element,\n\t{ delay, duration, easing, start, opacity }?: ScaleParams\n): TransitionConfig;", - "children": [], - "deprecated": null - }, - { - "name": "slide", - "comment": "", - "snippet": "declare function slide(\n\tnode: Element,\n\t{ delay, duration, easing }?: SlideParams\n): TransitionConfig;", - "children": [], - "deprecated": null - } - ] - } -]); \ No newline at end of file From d6f0b7bd5bacbe3ab2aae8dc43a6313cbf42b99a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 11:30:48 -0400 Subject: [PATCH 12/33] Fix types (#8727) * put comment in right place * bump dts-buddy --------- Co-authored-by: Rich Harris --- packages/svelte/package.json | 2 +- packages/svelte/src/runtime/internal/utils.js | 1 + packages/svelte/src/runtime/store/index.js | 6 ------ pnpm-lock.yaml | 18 ++++++++++++++---- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/svelte/package.json b/packages/svelte/package.json index f3dfc00c8566..e957e2249761 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -125,7 +125,7 @@ "@types/node": "^14.14.31", "@typescript-eslint/eslint-plugin": "^5.58.0", "agadoo": "^3.0.0", - "dts-buddy": "^0.1.2", + "dts-buddy": "^0.1.4", "esbuild": "^0.17.19", "happy-dom": "^9.18.3", "jsdom": "^21.1.1", diff --git a/packages/svelte/src/runtime/internal/utils.js b/packages/svelte/src/runtime/internal/utils.js index c279b8d4bf12..7d97f6db4298 100644 --- a/packages/svelte/src/runtime/internal/utils.js +++ b/packages/svelte/src/runtime/internal/utils.js @@ -106,6 +106,7 @@ export function subscribe(store, ...callbacks) { } /** + * Get the current value from a store by subscribing and immediately unsubscribing. * @template T * @param {import('../store/public.js').Readable} store * @returns {T} diff --git a/packages/svelte/src/runtime/store/index.js b/packages/svelte/src/runtime/store/index.js index 3950e5ff4e6c..105f1ac4041b 100644 --- a/packages/svelte/src/runtime/store/index.js +++ b/packages/svelte/src/runtime/store/index.js @@ -189,10 +189,4 @@ export function readonly(store) { }; } -/** - * Get the current value from a store by subscribing and immediately unsubscribing. - * @template T - * @param {import('./public.js').Readable} store readable - * @returns {T} - */ export { get_store_value as get }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e85c9eecf576..906fb17a45f7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -121,8 +121,8 @@ importers: specifier: ^3.0.0 version: 3.0.0 dts-buddy: - specifier: ^0.1.2 - version: 0.1.2 + specifier: ^0.1.4 + version: 0.1.4 esbuild: specifier: ^0.17.19 version: 0.17.19 @@ -1671,8 +1671,8 @@ packages: engines: {node: '>=12'} dev: true - /dts-buddy@0.1.2: - resolution: {integrity: sha512-CLDbDXtcrNjuWLYljJuCL4l//mvDZzjtFkmr4yGyCAk58szuzmjzoWKG+7NBFWeeajOiISu/IG96QNMb0CPtdw==} + /dts-buddy@0.1.4: + resolution: {integrity: sha512-kwWFPmpCFgQRW9U1zdg8ZAIx/KcyhPgvrP9k/apMGNl/LzmL1+PEWevJ6cBBwTW6zckfw9sHHziFK47IoBGX7g==} hasBin: true dependencies: '@jridgewell/source-map': 0.3.3 @@ -1683,6 +1683,7 @@ packages: magic-string: 0.30.0 sade: 1.8.1 tiny-glob: 0.2.9 + ts-api-utils: 0.0.46(typescript@5.0.4) typescript: 5.0.4 dev: true @@ -3995,6 +3996,15 @@ packages: engines: {node: '>=8'} dev: true + /ts-api-utils@0.0.46(typescript@5.0.4): + resolution: {integrity: sha512-YKJeSx39n0mMk+hrpyHKyTgxA3s7Pz/j1cXYR+t8HcwwZupzOR5xDGKnOEw3gmLaUeFUQt3FJD39AH9Ajn/mdA==} + engines: {node: '>=16.13.0'} + peerDependencies: + typescript: '>=4.2.0' + dependencies: + typescript: 5.0.4 + dev: true + /tsconfig-paths@3.14.2: resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==} dependencies: From 564bdffd4f998b7d6a9cfd766d678dbd81bc2b43 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 11:49:12 -0400 Subject: [PATCH 13/33] build types --- sites/svelte.dev/vercel.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sites/svelte.dev/vercel.json b/sites/svelte.dev/vercel.json index 038bee163d0f..f7c95d1edab3 100644 --- a/sites/svelte.dev/vercel.json +++ b/sites/svelte.dev/vercel.json @@ -2,5 +2,6 @@ "$schema": "http://openapi.vercel.sh/vercel.json", "github": { "silent": true - } -} + }, + "buildCommand": "cd ../../packages/svelte && pnpm prepublishOnly && cd ../../sites/svelte.dev && pnpm build" +} \ No newline at end of file From 9dc3498dd3adc072786abc37ba5484cfa5784ec1 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 12:26:35 -0400 Subject: [PATCH 14/33] add svelte/compiler types --- documentation/docs/04-compiler-and-api/01-svelte-compiler.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/documentation/docs/04-compiler-and-api/01-svelte-compiler.md b/documentation/docs/04-compiler-and-api/01-svelte-compiler.md index b590321fabbb..b7d3b9030745 100644 --- a/documentation/docs/04-compiler-and-api/01-svelte-compiler.md +++ b/documentation/docs/04-compiler-and-api/01-svelte-compiler.md @@ -398,3 +398,7 @@ The current version, as set in package.json. import { VERSION } from 'svelte/compiler'; console.log(`running svelte version ${VERSION}`); ``` + +## Types + +> TYPES: svelte/compiler From be4e4abeaf01ff5eef8d6d169da18ab856ab4152 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 12:28:40 -0400 Subject: [PATCH 15/33] remove prepare script --- sites/svelte.dev/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sites/svelte.dev/package.json b/sites/svelte.dev/package.json index 0f15b3741bc9..9f7fbad51872 100644 --- a/sites/svelte.dev/package.json +++ b/sites/svelte.dev/package.json @@ -4,7 +4,6 @@ "description": "Docs and examples for Svelte", "type": "module", "scripts": { - "prepare": "pnpm generate", "dev": "node scripts/update.js && vite dev", "build": "node scripts/update.js && pnpm run generate && vite build", "generate": "node scripts/type-gen/index.js && node scripts/generate_examples.js", @@ -60,4 +59,4 @@ "vite": "^4.3.9", "vite-imagetools": "^5.0.4" } -} +} \ No newline at end of file From 8e0c1ad596dd5a17b1e37cda9ff0b41b506e4abd Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 12:43:44 -0400 Subject: [PATCH 16/33] fix --- documentation/docs/04-compiler-and-api/01-svelte-compiler.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/docs/04-compiler-and-api/01-svelte-compiler.md b/documentation/docs/04-compiler-and-api/01-svelte-compiler.md index b7d3b9030745..f46183251c1b 100644 --- a/documentation/docs/04-compiler-and-api/01-svelte-compiler.md +++ b/documentation/docs/04-compiler-and-api/01-svelte-compiler.md @@ -310,6 +310,7 @@ Multiple preprocessors can be used together. The output of the first becomes the > In Svelte 3, all `markup` functions ran first, then all `script` and then all `style` preprocessors. This order was changed in Svelte 4. ```js +// @errors: 2322 // @filename: ambient.d.ts declare global { var source: string; From c3173133912b9b4f35755c7b75388560b0bf8680 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 12:56:05 -0400 Subject: [PATCH 17/33] typo --- .../02-client-side-component-api.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/documentation/docs/04-compiler-and-api/02-client-side-component-api.md b/documentation/docs/04-compiler-and-api/02-client-side-component-api.md index 48f13cdcb51e..08d03ec09a77 100644 --- a/documentation/docs/04-compiler-and-api/02-client-side-component-api.md +++ b/documentation/docs/04-compiler-and-api/02-client-side-component-api.md @@ -5,7 +5,7 @@ title: 'Client-side component API' ## Creating a component ```ts -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare global { @@ -21,7 +21,7 @@ const component = new Component(options); A client-side component — that is, a component compiled with `generate: 'dom'` (or the `generate` option left unspecified) is a JavaScript class. ```ts -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare module './App.svelte' { @@ -63,7 +63,7 @@ Whereas children of `target` are normally left alone, `hydrate: true` will cause The existing DOM doesn't need to match the component — Svelte will 'repair' the DOM as it goes. ```ts -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare module './App.svelte' { @@ -85,7 +85,7 @@ const app = new App({ ## `$set` ```ts -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare global { @@ -106,7 +106,7 @@ Programmatically sets props on an instance. `component.$set({ x: 1 })` is equiva Calling this method schedules an update for the next microtask — the DOM is _not_ updated synchronously. ```ts -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare global { @@ -124,7 +124,7 @@ component.$set({ answer: 42 }); ## `$on` ```ts -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare global { @@ -146,7 +146,7 @@ Causes the `callback` function to be called whenever the component dispatches an A function is returned that will remove the event listener when called. ```ts -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare global { @@ -168,7 +168,7 @@ off(); ## `$destroy` ```js -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare global { @@ -188,7 +188,7 @@ Removes a component from the DOM and triggers any `onDestroy` handlers. ## Component props ```js -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare global { @@ -204,7 +204,7 @@ component.prop; ``` ```js -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare global { @@ -225,7 +225,7 @@ If a component is compiled with `accessors: true`, each instance will have gette By default, `accessors` is `false`, unless you're compiling as a custom element. ```js -// @filename: ambiend.d.ts +// @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; declare global { From d17be5ad2fc40ab15881773709945f6114439c8e Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 13:16:22 -0400 Subject: [PATCH 18/33] squelch errors --- documentation/docs/03-runtime/02-svelte-store.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/03-runtime/02-svelte-store.md b/documentation/docs/03-runtime/02-svelte-store.md index 35ca93e1839b..203f040fba09 100644 --- a/documentation/docs/03-runtime/02-svelte-store.md +++ b/documentation/docs/03-runtime/02-svelte-store.md @@ -124,7 +124,7 @@ declare global { export {}; // @filename: index.ts -// @errors: 18046 +// @errors: 18046 2769 7006 // ---cut--- import { derived } from 'svelte/store'; From c1c8085e70b4980d5b0074f18ac2ecc628152e6d Mon Sep 17 00:00:00 2001 From: Puru Vijay Date: Tue, 13 Jun 2023 22:54:38 +0530 Subject: [PATCH 19/33] Add svelte and kit to twoslash's types field --- sites/svelte.dev/src/lib/server/markdown/renderer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sites/svelte.dev/src/lib/server/markdown/renderer.js b/sites/svelte.dev/src/lib/server/markdown/renderer.js index 330f5dde7812..3ffca37257e1 100644 --- a/sites/svelte.dev/src/lib/server/markdown/renderer.js +++ b/sites/svelte.dev/src/lib/server/markdown/renderer.js @@ -873,7 +873,8 @@ function syntax_highlight({ source, filename, language, highlighter, twoslashBan defaultCompilerOptions: { allowJs: true, checkJs: true, - target: ts.ScriptTarget.ES2022 + target: ts.ScriptTarget.ES2022, + types: ['svelte', '@sveltejs/kit'] } }); From 0f1e42af1fb171140148119058b5e9b14cfd4ede Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 13:30:24 -0400 Subject: [PATCH 20/33] squelch more stuff --- .../docs/04-compiler-and-api/02-client-side-component-api.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/documentation/docs/04-compiler-and-api/02-client-side-component-api.md b/documentation/docs/04-compiler-and-api/02-client-side-component-api.md index 08d03ec09a77..fd4889274ca9 100644 --- a/documentation/docs/04-compiler-and-api/02-client-side-component-api.md +++ b/documentation/docs/04-compiler-and-api/02-client-side-component-api.md @@ -5,6 +5,7 @@ title: 'Client-side component API' ## Creating a component ```ts +// @errors: 2554 // @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; @@ -21,6 +22,7 @@ const component = new Component(options); A client-side component — that is, a component compiled with `generate: 'dom'` (or the `generate` option left unspecified) is a JavaScript class. ```ts +// @errors: 2554 // @filename: ambient.d.ts import { SvelteComponent, ComponentConstructorOptions } from 'svelte'; @@ -72,7 +74,7 @@ declare module './App.svelte' { } // @filename: index.ts -// @errors: 2322 +// @errors: 2322 2554 // ---cut--- import App from './App.svelte'; From 2e197923e420db3943b75220e7cb2a503b655e93 Mon Sep 17 00:00:00 2001 From: Puru Vijay Date: Tue, 13 Jun 2023 23:02:18 +0530 Subject: [PATCH 21/33] Add errors to account for new types --- .../04-compiler-and-api/02-client-side-component-api.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/documentation/docs/04-compiler-and-api/02-client-side-component-api.md b/documentation/docs/04-compiler-and-api/02-client-side-component-api.md index 08d03ec09a77..c36033dc0f76 100644 --- a/documentation/docs/04-compiler-and-api/02-client-side-component-api.md +++ b/documentation/docs/04-compiler-and-api/02-client-side-component-api.md @@ -14,6 +14,7 @@ declare global { } // @filename: index.ts +// @errors: 2554 // ---cut--- const component = new Component(options); ``` @@ -30,6 +31,7 @@ declare module './App.svelte' { } // @filename: index.ts +// @errors: 2554 // ---cut--- import App from './App.svelte'; @@ -72,7 +74,7 @@ declare module './App.svelte' { } // @filename: index.ts -// @errors: 2322 +// @errors: 2322 2554 // ---cut--- import App from './App.svelte'; @@ -199,6 +201,7 @@ declare global { export {} // @filename: index.ts +// @errors: 2339 // ---cut--- component.prop; ``` @@ -216,6 +219,7 @@ declare global { export {} // @filename: index.ts +// @errors: 2339 // ---cut--- component.prop = value; ``` @@ -237,6 +241,7 @@ declare global { export {} // @filename: index.ts +// @errors: 2339 // ---cut--- console.log(component.count); component.count += 1; From 82422c3d8ffe0dbf13bd5cf7d2850f49a2d23e8c Mon Sep 17 00:00:00 2001 From: Puru Vijay Date: Tue, 13 Jun 2023 23:15:20 +0530 Subject: [PATCH 22/33] Remove deps --- pnpm-lock.yaml | 58 ++--------------------------------- sites/svelte.dev/package.json | 5 +-- 2 files changed, 3 insertions(+), 60 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 393b8a942f75..a4ca90425725 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -229,12 +229,6 @@ importers: prettier-plugin-svelte: specifier: ^2.10.1 version: 2.10.1(prettier@2.8.8)(svelte@packages+svelte) - rollup: - specifier: ^3.23.0 - version: 3.23.0 - rollup-plugin-dts: - specifier: ^5.3.0 - version: 5.3.0(rollup@3.23.0)(typescript@5.0.4) sass: specifier: ^1.62.1 version: 1.62.1 @@ -265,9 +259,6 @@ importers: tiny-glob: specifier: ^0.2.9 version: 0.2.9 - ts-morph: - specifier: ^18.0.0 - version: 18.0.0 typescript: specifier: ^5.0.4 version: 5.0.4 @@ -276,7 +267,7 @@ importers: version: 4.3.9(@types/node@20.2.5)(sass@1.62.1) vite-imagetools: specifier: ^5.0.4 - version: 5.0.4(rollup@3.23.0) + version: 5.0.4 packages: @@ -1919,15 +1910,6 @@ packages: engines: {node: '>= 10'} dev: true - /@ts-morph/common@0.19.0: - resolution: {integrity: sha512-Unz/WHmd4pGax91rdIKWi51wnVUW11QttMEPpBiBgIewnc9UQIX7UDLxr5vRlqeByXCwhkF6VabSsI0raWcyAQ==} - dependencies: - fast-glob: 3.2.12 - minimatch: 7.4.6 - mkdirp: 2.1.6 - path-browserify: 1.0.1 - dev: true - /@types/aria-query@5.0.1: resolution: {integrity: sha512-XTIieEY+gvJ39ChLcB4If5zHtPxt3Syj5rgZR+e1ctpmK8NjPf0zFqsz4JpLJT0xla9GFDKjy8Cpu331nrmE1Q==} dev: true @@ -2714,10 +2696,6 @@ packages: engines: {node: '>=0.8'} dev: true - /code-block-writer@12.0.0: - resolution: {integrity: sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==} - dev: true - /code-red@1.0.0: resolution: {integrity: sha512-x5fNWOBu7Ii38br3iVPuwQcDQM0f2h8ipvqw4qTLlOzYlrFQRz954qR0hPZ8asV5KG/igXNY8CRG6xtDUoKOJQ==} dependencies: @@ -4959,13 +4937,6 @@ packages: brace-expansion: 2.0.1 dev: true - /minimatch@7.4.6: - resolution: {integrity: sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==} - engines: {node: '>=10'} - dependencies: - brace-expansion: 2.0.1 - dev: true - /minimist-options@4.1.0: resolution: {integrity: sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==} engines: {node: '>= 6'} @@ -5362,10 +5333,6 @@ packages: entities: 4.5.0 dev: true - /path-browserify@1.0.1: - resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} - dev: true - /path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -5829,20 +5796,6 @@ packages: glob: 7.2.3 dev: true - /rollup-plugin-dts@5.3.0(rollup@3.23.0)(typescript@5.0.4): - resolution: {integrity: sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==} - engines: {node: '>=v14'} - peerDependencies: - rollup: ^3.0.0 - typescript: ^4.1 || ^5.0 - dependencies: - magic-string: 0.30.0 - rollup: 3.23.0 - typescript: 5.0.4 - optionalDependencies: - '@babel/code-frame': 7.21.4 - dev: true - /rollup-plugin-serve@2.0.2: resolution: {integrity: sha512-ALqyTbPhlf7FZ5RzlbDvMYvbKuCHWginJkTo6dMsbgji/a78IbsXox+pC83HENdkTRz8OXrTj+aShp3+3ratpg==} dependencies: @@ -6575,13 +6528,6 @@ packages: typescript: 5.0.4 dev: true - /ts-morph@18.0.0: - resolution: {integrity: sha512-Kg5u0mk19PIIe4islUI/HWRvm9bC1lHejK4S0oh1zaZ77TMZAEmQC0sHQYiu2RgCQFZKXz1fMVi/7nOOeirznA==} - dependencies: - '@ts-morph/common': 0.19.0 - code-block-writer: 12.0.0 - dev: true - /tsconfig-paths@3.14.2: resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==} dependencies: @@ -6780,7 +6726,7 @@ packages: spdx-expression-parse: 3.0.1 dev: true - /vite-imagetools@5.0.4(rollup@3.23.0): + /vite-imagetools@5.0.4: resolution: {integrity: sha512-EIRstqWlmoQipsucFCioqCYpfp+rG5v8gpKDFvFJBxEKEAEBPnxW+swmE5dfoRQkwMKkYwmBWeXYsnMaDohUtg==} engines: {node: '>=12.0.0'} dependencies: diff --git a/sites/svelte.dev/package.json b/sites/svelte.dev/package.json index 9f7fbad51872..b82157e105c9 100644 --- a/sites/svelte.dev/package.json +++ b/sites/svelte.dev/package.json @@ -42,8 +42,6 @@ "node-fetch": "^3.3.1", "prettier": "^2.8.8", "prettier-plugin-svelte": "^2.10.1", - "rollup": "^3.23.0", - "rollup-plugin-dts": "^5.3.0", "sass": "^1.62.1", "satori": "^0.9.1", "satori-html": "^0.3.2", @@ -54,9 +52,8 @@ "svelte-check": "^3.4.3", "svelte-preprocess": "^5.0.4", "tiny-glob": "^0.2.9", - "ts-morph": "^18.0.0", "typescript": "^5.0.4", "vite": "^4.3.9", "vite-imagetools": "^5.0.4" } -} \ No newline at end of file +} From a02ba7ba787dd638dc3551e1ef6006e1762c35b8 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 14:28:43 -0400 Subject: [PATCH 23/33] formatting tweak --- packages/svelte/src/runtime/action/public.d.ts | 12 ++++++------ sites/svelte.dev/scripts/type-gen/index.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/svelte/src/runtime/action/public.d.ts b/packages/svelte/src/runtime/action/public.d.ts index b36a8d82cee9..da34bd9ddbcf 100644 --- a/packages/svelte/src/runtime/action/public.d.ts +++ b/packages/svelte/src/runtime/action/public.d.ts @@ -12,15 +12,15 @@ * ```ts * interface Attributes { * newprop?: string; - * 'on:event': (e: CustomEvent) => void; + * 'on:event': (e: CustomEvent) => void; * } * * export function myAction(node: HTMLElement, parameter: Parameter): ActionReturn { - * // ... - * return { - * update: (updatedParameter) => {...}, - * destroy: () => {...} - * }; + * // ... + * return { + * update: (updatedParameter) => {...}, + * destroy: () => {...} + * }; * } * ``` * diff --git a/sites/svelte.dev/scripts/type-gen/index.js b/sites/svelte.dev/scripts/type-gen/index.js index e33b210c48e8..113c52cf468a 100644 --- a/sites/svelte.dev/scripts/type-gen/index.js +++ b/sites/svelte.dev/scripts/type-gen/index.js @@ -151,7 +151,7 @@ function munge_type_element(member, depth = 1) { const name = member.name?.escapedText; let snippet = member.getText(); - for (let i = 0; i < depth; i += 1) { + for (let i = -1; i < depth; i += 1) { snippet = snippet.replace(/^\t/gm, ''); } From 1bb7f7443424a140e8668cc7b76f4c6cdf64c0fb Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 14:34:36 -0400 Subject: [PATCH 24/33] fix linting, maybe --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a2f035b7d951..f801b74ccd39 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "test": "pnpm test -r --filter=./packages/*", "build": "pnpm -r build", - "check": "pnpm -r check", + "check": "pnpm -r build --filter=./packages/* && pnpm -r check", "lint": "pnpm -r lint", "format": "pnpm -r format", "changeset:version": "changeset version && pnpm -r generate:version && git add --all", @@ -30,4 +30,4 @@ "prettier-plugin-svelte": "^2.10.0" }, "packageManager": "pnpm@8.6.0" -} +} \ No newline at end of file From 4635d4a669fe49e54233859a39006b70f433dcfe Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 14:41:16 -0400 Subject: [PATCH 25/33] the hell --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f801b74ccd39..8c741d8f0b74 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "test": "pnpm test -r --filter=./packages/*", "build": "pnpm -r build", - "check": "pnpm -r build --filter=./packages/* && pnpm -r check", + "check": "cd packages/svelte && pnpm build && cd ../../ && pnpm -r check", "lint": "pnpm -r lint", "format": "pnpm -r format", "changeset:version": "changeset version && pnpm -r generate:version && git add --all", From a7971e0a7302afca29307703a3e87517a4ce1bd8 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 13 Jun 2023 14:47:02 -0400 Subject: [PATCH 26/33] gah --- sites/svelte.dev/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sites/svelte.dev/package.json b/sites/svelte.dev/package.json index b82157e105c9..c7b93119e34c 100644 --- a/sites/svelte.dev/package.json +++ b/sites/svelte.dev/package.json @@ -10,7 +10,7 @@ "update": "node scripts/update.js --force=true", "preview": "vite preview", "start": "node build", - "check": "node scripts/update.js && svelte-kit sync && svelte-check", + "check": "node scripts/update.js && pnpm generate && svelte-kit sync && svelte-check", "check:watch": "svelte-kit sync && svelte-check --watch", "format": "pnpm run check:format -- --write", "check:format": "prettier --check . --ignore-path .gitignore --plugin-search-dir=." @@ -56,4 +56,4 @@ "vite": "^4.3.9", "vite-imagetools": "^5.0.4" } -} +} \ No newline at end of file From 1a1452873ec5a03f843d6096a0af11575c3db0c6 Mon Sep 17 00:00:00 2001 From: Puru Vijay Date: Wed, 14 Jun 2023 00:23:07 +0530 Subject: [PATCH 27/33] Fix types a bit --- documentation/docs/03-runtime/07-svelte-action.md | 3 ++- sites/svelte.dev/scripts/type-gen/index.js | 6 +++--- sites/svelte.dev/src/lib/server/docs/index.js | 2 +- sites/svelte.dev/src/lib/server/markdown/renderer.js | 2 ++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/documentation/docs/03-runtime/07-svelte-action.md b/documentation/docs/03-runtime/07-svelte-action.md index 77d2d83e0e2b..d7e8d0b4e063 100644 --- a/documentation/docs/03-runtime/07-svelte-action.md +++ b/documentation/docs/03-runtime/07-svelte-action.md @@ -58,7 +58,8 @@ Sometimes actions emit custom events and apply custom attributes to the element