From de2859c0d0e4dece235c4d7297e82ecae34ad431 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 17 Dec 2024 18:50:18 -0500 Subject: [PATCH 1/8] bump esrap, start fixing stuff --- packages/svelte/package.json | 2 +- .../phases/1-parse/remove_typescript_nodes.js | 19 +- .../samples/typescript/main.svelte | 2 +- pnpm-lock.yaml | 190 +++++++++++++----- 4 files changed, 151 insertions(+), 62 deletions(-) diff --git a/packages/svelte/package.json b/packages/svelte/package.json index a6eb2f4a8acd..eca51f3998f1 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -147,7 +147,7 @@ "aria-query": "^5.3.1", "axobject-query": "^4.1.0", "esm-env": "^1.2.1", - "esrap": "^1.2.3", + "esrap": "^1.3.0", "is-reference": "^3.0.3", "locate-character": "^3.0.0", "magic-string": "^0.30.11", diff --git a/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js b/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js index b968e95213a2..fa4bf166453d 100644 --- a/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js +++ b/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js @@ -17,6 +17,14 @@ function remove_this_param(node, context) { /** @type {Visitors} */ const visitors = { + _(node, context) { + // TODO there may come a time when we decide to preserve type annotations. + // until that day comes, we just delete them so they don't confuse esrap + delete node.typeAnnotation; + delete node.typeParameters; + + context.next(); + }, Decorator(node) { e.typescript_invalid_feature(node, 'decorators (related TSC proposal is not stage 4 yet)'); }, @@ -78,23 +86,12 @@ const visitors = { TSNonNullExpression(node, context) { return context.visit(node.expression); }, - TSTypeAnnotation() { - // This isn't correct, strictly speaking, and could result in invalid ASTs (like an empty statement within function parameters), - // but esrap, our printing tool, just ignores these AST nodes at invalid positions, so it's fine - return b.empty; - }, TSInterfaceDeclaration() { return b.empty; }, TSTypeAliasDeclaration() { return b.empty; }, - TSTypeParameterDeclaration() { - return b.empty; - }, - TSTypeParameterInstantiation() { - return b.empty; - }, TSEnumDeclaration(node) { e.typescript_invalid_feature(node, 'enums'); }, diff --git a/packages/svelte/tests/runtime-runes/samples/typescript/main.svelte b/packages/svelte/tests/runtime-runes/samples/typescript/main.svelte index 3b98dafa0597..cc3135060111 100644 --- a/packages/svelte/tests/runtime-runes/samples/typescript/main.svelte +++ b/packages/svelte/tests/runtime-runes/samples/typescript/main.svelte @@ -24,7 +24,7 @@ declare module 'foobar' {} namespace SomeNamespace { - export type Foo = true + export type Foo = true; } export function overload(a: boolean): boolean; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 250a03744e79..b5becc375a55 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -84,8 +84,8 @@ importers: specifier: ^1.2.1 version: 1.2.1 esrap: - specifier: ^1.2.3 - version: 1.2.3 + specifier: ^1.3.0 + version: 1.3.0 is-reference: specifier: ^3.0.3 version: 3.0.3 @@ -405,10 +405,20 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + '@eslint-community/eslint-utils@4.4.1': + resolution: {integrity: sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + '@eslint-community/regexpp@4.11.0': resolution: {integrity: sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + '@eslint-community/regexpp@4.12.1': + resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + '@eslint/config-array@0.18.0': resolution: {integrity: sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -775,6 +785,11 @@ packages: engines: {node: '>=0.4.0'} hasBin: true + acorn@8.14.0: + resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} + engines: {node: '>=0.4.0'} + hasBin: true + agent-base@7.1.1: resolution: {integrity: sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==} engines: {node: '>= 14'} @@ -838,8 +853,8 @@ packages: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} - binary-extensions@2.2.0: - resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} + binary-extensions@2.3.0: + resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} brace-expansion@1.1.11: @@ -852,6 +867,10 @@ packages: resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} engines: {node: '>=8'} + braces@3.0.3: + resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} + engines: {node: '>=8'} + buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} @@ -882,8 +901,8 @@ packages: resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} engines: {node: '>= 16'} - chokidar@3.5.3: - resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} + chokidar@3.6.0: + resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} ci-info@3.9.0: @@ -908,7 +927,7 @@ packages: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} concat-map@0.0.1: - resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} cross-spawn@5.1.0: resolution: {integrity: sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==} @@ -942,6 +961,15 @@ packages: supports-color: optional: true + debug@4.4.0: + resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + decimal.js@10.4.3: resolution: {integrity: sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==} @@ -1111,8 +1139,8 @@ packages: resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} engines: {node: '>=0.10'} - esrap@1.2.3: - resolution: {integrity: sha512-ZlQmCCK+n7SGoqo7DnfKaP1sJZa49P01/dXzmjCASSo04p72w8EksT2NMK8CEX8DhKsfJXANioIw8VyHNsBfvQ==} + esrap@1.3.0: + resolution: {integrity: sha512-LPT4X5Ur2sGnkQscwgWXRPVDuQrbuJbrStLmVXVXd+lGQ/HoYmcAa47t0Egzw1bYHwhF0w+6DTkxL1Xctp10XQ==} esrecurse@4.3.0: resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} @@ -1175,6 +1203,10 @@ packages: resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} engines: {node: '>=8'} + fill-range@7.1.1: + resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} + engines: {node: '>=8'} + find-up@4.1.0: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} engines: {node: '>=8'} @@ -1230,8 +1262,8 @@ packages: resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} engines: {node: '>=16'} - get-tsconfig@4.7.6: - resolution: {integrity: sha512-ZAqrLlu18NbDdRaHq+AKXzAmqIUPswPWKUchfytdAjiRFnCe5ojG2bstg6mRiZabkKfCoL/e98pbBELIV/YCeA==} + get-tsconfig@4.8.1: + resolution: {integrity: sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==} glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} @@ -1249,6 +1281,10 @@ packages: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} + globals@15.13.0: + resolution: {integrity: sha512-49TewVEz0UxZjr1WYYsWpPrhyC/B/pA8Bq0fUmet2n+eR7yn0IvNzNaoBwnK6mdkzcN+se7Ez9zUgULTz2QH4g==} + engines: {node: '>=18'} + globals@15.9.0: resolution: {integrity: sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==} engines: {node: '>=18'} @@ -1311,8 +1347,8 @@ packages: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} - immutable@4.3.4: - resolution: {integrity: sha512-fsXeu4J4i6WNWSikpI88v/PcVflZz+6kMhUfIwc5SY+poQRPnaf5V7qds6SUyUN3cVxEzuCab7QIoLOQ+DQ1wA==} + immutable@4.3.7: + resolution: {integrity: sha512-1hqclzwYwjRDFLjcFxOM5AYkkG0rpFPpr1RLPMEuGczoS7YA8gLhy8SWXYRAA/XwfEHpfo3cw5JGioS32fnMRw==} import-fresh@3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} @@ -1598,11 +1634,19 @@ packages: ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + nanoid@3.3.8: + resolution: {integrity: sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} @@ -1722,6 +1766,9 @@ packages: picocolors@1.1.0: resolution: {integrity: sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==} + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} @@ -1780,6 +1827,10 @@ packages: resolution: {integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==} engines: {node: ^10 || ^12 || >=14} + postcss@8.4.49: + resolution: {integrity: sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==} + engines: {node: ^10 || ^12 || >=14} + prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -1989,11 +2040,11 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} - svelte-eslint-parser@0.41.0: - resolution: {integrity: sha512-L6f4hOL+AbgfBIB52Z310pg1d2QjRqm7wy3kI1W6hhdhX5bvu7+f0R6w4ykp5HoDdzq+vGhIJmsisaiJDGmVfA==} + svelte-eslint-parser@0.43.0: + resolution: {integrity: sha512-GpU52uPKKcVnh8tKN5P4UZpJ/fUDndmq7wfsvoVXsyP+aY0anol7Yqo01fyrlaWGMFfm4av5DyrjlaXdLRJvGA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: - svelte: ^3.37.0 || ^4.0.0 || ^5.0.0-next.191 + svelte: ^3.37.0 || ^4.0.0 || ^5.0.0 peerDependenciesMeta: svelte: optional: true @@ -2538,8 +2589,15 @@ snapshots: eslint: 9.9.1 eslint-visitor-keys: 3.4.3 + '@eslint-community/eslint-utils@4.4.1(eslint@9.9.1)': + dependencies: + eslint: 9.9.1 + eslint-visitor-keys: 3.4.3 + '@eslint-community/regexpp@4.11.0': {} + '@eslint-community/regexpp@4.12.1': {} + '@eslint/config-array@0.18.0': dependencies: '@eslint/object-schema': 2.1.4 @@ -2733,7 +2791,7 @@ snapshots: '@stylistic/eslint-plugin-js@1.8.0(eslint@9.9.1)': dependencies: '@types/eslint': 8.56.12 - acorn: 8.12.1 + acorn: 8.14.0 escape-string-regexp: 4.0.0 eslint: 9.9.1 eslint-visitor-keys: 3.4.3 @@ -2938,12 +2996,18 @@ snapshots: dependencies: acorn: 8.12.1 + acorn-jsx@5.3.2(acorn@8.14.0): + dependencies: + acorn: 8.14.0 + acorn-typescript@1.4.13(acorn@8.12.1): dependencies: acorn: 8.12.1 acorn@8.12.1: {} + acorn@8.14.0: {} + agent-base@7.1.1: dependencies: debug: 4.3.6 @@ -2997,7 +3061,7 @@ snapshots: dependencies: is-windows: 1.0.2 - binary-extensions@2.2.0: + binary-extensions@2.3.0: optional: true brace-expansion@1.1.11: @@ -3013,6 +3077,11 @@ snapshots: dependencies: fill-range: 7.0.1 + braces@3.0.3: + dependencies: + fill-range: 7.1.1 + optional: true + buffer-from@1.1.2: {} bundle-name@4.1.0: @@ -3040,10 +3109,10 @@ snapshots: check-error@2.1.1: {} - chokidar@3.5.3: + chokidar@3.6.0: dependencies: anymatch: 3.1.3 - braces: 3.0.2 + braces: 3.0.3 glob-parent: 5.1.2 is-binary-path: 2.1.0 is-glob: 4.0.3 @@ -3100,6 +3169,10 @@ snapshots: dependencies: ms: 2.1.2 + debug@4.4.0: + dependencies: + ms: 2.1.3 + decimal.js@10.4.3: {} deep-eql@5.0.2: {} @@ -3202,8 +3275,8 @@ snapshots: eslint-plugin-es-x@7.8.0(eslint@9.9.1): dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@9.9.1) - '@eslint-community/regexpp': 4.11.0 + '@eslint-community/eslint-utils': 4.4.1(eslint@9.9.1) + '@eslint-community/regexpp': 4.12.1 eslint: 9.9.1 eslint-compat-utils: 0.5.1(eslint@9.9.1) @@ -3211,31 +3284,31 @@ snapshots: eslint-plugin-n@17.9.0(eslint@9.9.1): dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@9.9.1) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.9.1) enhanced-resolve: 5.17.1 eslint: 9.9.1 eslint-plugin-es-x: 7.8.0(eslint@9.9.1) - get-tsconfig: 4.7.6 - globals: 15.9.0 + get-tsconfig: 4.8.1 + globals: 15.13.0 ignore: 5.3.2 minimatch: 9.0.5 semver: 7.6.3 eslint-plugin-svelte@2.38.0(eslint@9.9.1)(svelte@packages+svelte): dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@9.9.1) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.9.1) '@jridgewell/sourcemap-codec': 1.5.0 - debug: 4.3.6 + debug: 4.4.0 eslint: 9.9.1 eslint-compat-utils: 0.5.1(eslint@9.9.1) esutils: 2.0.3 known-css-properties: 0.30.0 - postcss: 8.4.47 - postcss-load-config: 3.1.4(postcss@8.4.47) - postcss-safe-parser: 6.0.0(postcss@8.4.47) + postcss: 8.4.49 + postcss-load-config: 3.1.4(postcss@8.4.49) + postcss-safe-parser: 6.0.0(postcss@8.4.49) postcss-selector-parser: 6.1.2 semver: 7.6.3 - svelte-eslint-parser: 0.41.0(svelte@packages+svelte) + svelte-eslint-parser: 0.43.0(svelte@packages+svelte) optionalDependencies: svelte: link:packages/svelte transitivePeerDependencies: @@ -3305,8 +3378,8 @@ snapshots: espree@9.6.1: dependencies: - acorn: 8.12.1 - acorn-jsx: 5.3.2(acorn@8.12.1) + acorn: 8.14.0 + acorn-jsx: 5.3.2(acorn@8.14.0) eslint-visitor-keys: 3.4.3 esprima@4.0.1: {} @@ -3315,10 +3388,10 @@ snapshots: dependencies: estraverse: 5.3.0 - esrap@1.2.3: + esrap@1.3.0: dependencies: '@jridgewell/sourcemap-codec': 1.5.0 - '@types/estree': 1.0.6 + '@typescript-eslint/types': 8.2.0 esrecurse@4.3.0: dependencies: @@ -3384,6 +3457,11 @@ snapshots: dependencies: to-regex-range: 5.0.1 + fill-range@7.1.1: + dependencies: + to-regex-range: 5.0.1 + optional: true + find-up@4.1.0: dependencies: locate-path: 5.0.0 @@ -3442,7 +3520,7 @@ snapshots: get-stream@8.0.1: {} - get-tsconfig@4.7.6: + get-tsconfig@4.8.1: dependencies: resolve-pkg-maps: 1.0.0 @@ -3465,6 +3543,8 @@ snapshots: globals@14.0.0: {} + globals@15.13.0: {} + globals@15.9.0: {} globalyzer@0.1.0: {} @@ -3524,7 +3604,7 @@ snapshots: ignore@5.3.2: {} - immutable@4.3.4: + immutable@4.3.7: optional: true import-fresh@3.3.0: @@ -3536,7 +3616,7 @@ snapshots: is-binary-path@2.1.0: dependencies: - binary-extensions: 2.2.0 + binary-extensions: 2.3.0 optional: true is-core-module@2.13.1: @@ -3796,8 +3876,12 @@ snapshots: ms@2.1.2: {} + ms@2.1.3: {} + nanoid@3.3.7: {} + nanoid@3.3.8: {} + natural-compare@1.4.0: {} node-fetch@2.7.0: @@ -3896,6 +3980,8 @@ snapshots: picocolors@1.1.0: {} + picocolors@1.1.1: {} + picomatch@2.3.1: {} picomatch@4.0.2: {} @@ -3915,20 +4001,20 @@ snapshots: '@polka/url': 1.0.0-next.25 trouter: 4.0.0 - postcss-load-config@3.1.4(postcss@8.4.47): + postcss-load-config@3.1.4(postcss@8.4.49): dependencies: lilconfig: 2.1.0 yaml: 1.10.2 optionalDependencies: - postcss: 8.4.47 + postcss: 8.4.49 - postcss-safe-parser@6.0.0(postcss@8.4.47): + postcss-safe-parser@6.0.0(postcss@8.4.49): dependencies: - postcss: 8.4.47 + postcss: 8.4.49 - postcss-scss@4.0.9(postcss@8.4.47): + postcss-scss@4.0.9(postcss@8.4.49): dependencies: - postcss: 8.4.47 + postcss: 8.4.49 postcss-selector-parser@6.1.2: dependencies: @@ -3941,6 +4027,12 @@ snapshots: picocolors: 1.1.0 source-map-js: 1.2.1 + postcss@8.4.49: + dependencies: + nanoid: 3.3.8 + picocolors: 1.1.1 + source-map-js: 1.2.1 + prelude-ls@1.2.1: {} prettier-plugin-svelte@3.1.2(prettier@3.2.4)(svelte@packages+svelte): @@ -4032,8 +4124,8 @@ snapshots: sass@1.70.0: dependencies: - chokidar: 3.5.3 - immutable: 4.3.4 + chokidar: 3.6.0 + immutable: 4.3.7 source-map-js: 1.2.1 optional: true @@ -4129,13 +4221,13 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - svelte-eslint-parser@0.41.0(svelte@packages+svelte): + svelte-eslint-parser@0.43.0(svelte@packages+svelte): dependencies: eslint-scope: 7.2.2 eslint-visitor-keys: 3.4.3 espree: 9.6.1 - postcss: 8.4.47 - postcss-scss: 4.0.9(postcss@8.4.47) + postcss: 8.4.49 + postcss-scss: 4.0.9(postcss@8.4.49) optionalDependencies: svelte: link:packages/svelte From d98b23002939049b3289ca5153feb1acbdd262e6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 17 Dec 2024 19:04:46 -0500 Subject: [PATCH 2/8] ignore type exports when looking for undefineds --- packages/svelte/src/compiler/phases/2-analyze/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index 042e88fa2f83..d17cc34a5f68 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -698,8 +698,16 @@ export function analyze_component(root, source, options) { } for (const node of analysis.module.ast.body) { - if (node.type === 'ExportNamedDeclaration' && node.specifiers !== null && node.source == null) { + if ( + node.type === 'ExportNamedDeclaration' && + // @ts-expect-error + node.exportKind !== 'type' && + node.specifiers !== null && + node.source == null + ) { for (const specifier of node.specifiers) { + // @ts-expect-error + if (specifier.exportKind === 'type') continue; if (specifier.local.type !== 'Identifier') continue; const binding = analysis.module.scope.get(specifier.local.name); From 4fca88071e15d13a5bb31ef9783cbf124e7e4fa6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 17 Dec 2024 19:16:04 -0500 Subject: [PATCH 3/8] sanitize stuff --- .../src/compiler/phases/1-parse/remove_typescript_nodes.js | 6 ++++-- packages/svelte/src/compiler/phases/scope.js | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js b/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js index fa4bf166453d..5e4fa231dec3 100644 --- a/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js +++ b/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js @@ -18,12 +18,14 @@ function remove_this_param(node, context) { /** @type {Visitors} */ const visitors = { _(node, context) { + context.next(); + // TODO there may come a time when we decide to preserve type annotations. // until that day comes, we just delete them so they don't confuse esrap delete node.typeAnnotation; delete node.typeParameters; - - context.next(); + delete node.returnType; + delete node.accessibility; }, Decorator(node) { e.typescript_invalid_feature(node, 'decorators (related TSC proposal is not stage 4 yet)'); diff --git a/packages/svelte/src/compiler/phases/scope.js b/packages/svelte/src/compiler/phases/scope.js index 3536dd6a1865..20dcfa2821c8 100644 --- a/packages/svelte/src/compiler/phases/scope.js +++ b/packages/svelte/src/compiler/phases/scope.js @@ -433,7 +433,13 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) { }, ImportDeclaration(node, { state }) { + // @ts-expect-error + if (node.importKind === 'type') return; + for (const specifier of node.specifiers) { + // @ts-expect-error + if (specifier.importKind === 'type') continue; + state.scope.declare(specifier.local, 'normal', 'import', node); } }, From 1ce188a8929cdaccf2db0267ad0f001cbd9f5783 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 17 Dec 2024 19:22:18 -0500 Subject: [PATCH 4/8] changeset --- .changeset/purple-donuts-talk.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/purple-donuts-talk.md diff --git a/.changeset/purple-donuts-talk.md b/.changeset/purple-donuts-talk.md new file mode 100644 index 000000000000..2bb348cd193a --- /dev/null +++ b/.changeset/purple-donuts-talk.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: bump esrap, prevent malformed AST From 232936aa13e36208fdcab812668e22e9a65b285d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 17 Dec 2024 20:02:25 -0500 Subject: [PATCH 5/8] fix --- packages/svelte/package.json | 2 +- .../src/compiler/phases/3-transform/index.js | 4 + packages/svelte/tsconfig.json | 2 +- packages/svelte/types/index.d.ts | 3072 ----------------- pnpm-lock.yaml | 12 +- 5 files changed, 8 insertions(+), 3084 deletions(-) delete mode 100644 packages/svelte/types/index.d.ts diff --git a/packages/svelte/package.json b/packages/svelte/package.json index eca51f3998f1..6603fe9b42ce 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -147,7 +147,7 @@ "aria-query": "^5.3.1", "axobject-query": "^4.1.0", "esm-env": "^1.2.1", - "esrap": "^1.3.0", + "esrap": "^1.3.1", "is-reference": "^3.0.3", "locate-character": "^3.0.0", "magic-string": "^0.30.11", diff --git a/packages/svelte/src/compiler/phases/3-transform/index.js b/packages/svelte/src/compiler/phases/3-transform/index.js index 8f6597ee1298..d0739d6cc446 100644 --- a/packages/svelte/src/compiler/phases/3-transform/index.js +++ b/packages/svelte/src/compiler/phases/3-transform/index.js @@ -33,12 +33,15 @@ export function transform_component(analysis, source, options) { : client_component(analysis, options); const js_source_name = get_source_name(options.filename, options.outputFilename, 'input.svelte'); + + // @ts-expect-error const js = print(program, { // include source content; makes it easier/more robust looking up the source map code // (else esrap does return null for source and sourceMapContent which may trip up tooling) sourceMapContent: source, sourceMapSource: js_source_name }); + merge_with_preprocessor_map(js, options, js_source_name); const css = @@ -92,6 +95,7 @@ export function transform_module(analysis, source, options) { } return { + // @ts-expect-error js: print(program, { // include source content; makes it easier/more robust looking up the source map code // (else esrap does return null for source and sourceMapContent which may trip up tooling) diff --git a/packages/svelte/tsconfig.json b/packages/svelte/tsconfig.json index 380307901edd..8852a4301c30 100644 --- a/packages/svelte/tsconfig.json +++ b/packages/svelte/tsconfig.json @@ -40,5 +40,5 @@ "./tests/runtime-browser/test-ssr.ts", "./tests/*/samples/*/_config.js" ], - "exclude": ["./scripts/process-messages/templates/", "./src/compiler/optimizer/"] + "exclude": ["./scripts/process-messages/templates/", "./scripts/_bundle.js", "./src/compiler/optimizer/"] } diff --git a/packages/svelte/types/index.d.ts b/packages/svelte/types/index.d.ts deleted file mode 100644 index 671f68bff72a..000000000000 --- a/packages/svelte/types/index.d.ts +++ /dev/null @@ -1,3072 +0,0 @@ -declare module 'svelte' { - /** - * @deprecated In Svelte 4, components are classes. In Svelte 5, they are functions. - * Use `mount` instead to instantiate components. - * See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) - * for more info. - */ - export interface ComponentConstructorOptions< - Props extends Record = Record - > { - target: Element | Document | ShadowRoot; - anchor?: Element; - props?: Props; - context?: Map; - hydrate?: boolean; - intro?: boolean; - recover?: boolean; - sync?: boolean; - $$inline?: boolean; - } - - /** - * Utility type for ensuring backwards compatibility on a type level that if there's a default slot, add 'children' to the props - */ - type Properties = Props & - (Slots extends { default: any } - ? // This is unfortunate because it means "accepts no props" turns into "accepts any prop" - // but the alternative is non-fixable type errors because of the way TypeScript index - // signatures work (they will always take precedence and make an impossible-to-satisfy children type). - Props extends Record - ? any - : { children?: any } - : {}); - - /** - * This was the base class for Svelte components in Svelte 4. Svelte 5+ components - * are completely different under the hood. For typing, use `Component` instead. - * To instantiate components, use `mount` instead. - * See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) for more info. - */ - export class SvelteComponent< - Props extends Record = Record, - Events extends Record = any, - Slots extends Record = any - > { - /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */ - static element?: typeof HTMLElement; - - [prop: string]: any; - /** - * @deprecated This constructor only exists when using the `asClassComponent` compatibility helper, which - * is a stop-gap solution. Migrate towards using `mount` instead. See - * [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) for more info. - */ - constructor(options: ComponentConstructorOptions>); - /** - * For type checking capabilities only. - * Does not exist at runtime. - * ### DO NOT USE! - */ - $$prop_def: Props; // Without Properties: unnecessary, causes type bugs - /** - * For type checking capabilities only. - * Does not exist at runtime. - * ### DO NOT USE! - */ - $$events_def: Events; - /** - * For type checking capabilities only. - * Does not exist at runtime. - * ### DO NOT USE! - */ - $$slot_def: Slots; - /** - * For type checking capabilities only. - * Does not exist at runtime. - * ### DO NOT USE! - */ - $$bindings?: string; - - /** - * @deprecated This method only exists when using one of the legacy compatibility helpers, which - * is a stop-gap solution. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) - * for more info. - */ - $destroy(): void; - - /** - * @deprecated This method only exists when using one of the legacy compatibility helpers, which - * is a stop-gap solution. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) - * for more info. - */ - $on>( - type: K, - callback: (e: Events[K]) => void - ): () => void; - - /** - * @deprecated This method only exists when using one of the legacy compatibility helpers, which - * is a stop-gap solution. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) - * for more info. - */ - $set(props: Partial): void; - } - - const brand: unique symbol; - type Brand = { [brand]: B }; - type Branded = T & Brand; - - /** - * Internal implementation details that vary between environments - */ - export type ComponentInternals = Branded<{}, 'ComponentInternals'>; - - /** - * Can be used to create strongly typed Svelte components. - * - * #### Example: - * - * You have component library on npm called `component-library`, from which - * you export a component called `MyComponent`. For Svelte+TypeScript users, - * you want to provide typings. Therefore you create a `index.d.ts`: - * ```ts - * import type { Component } from 'svelte'; - * export declare const MyComponent: Component<{ foo: string }> {} - * ``` - * Typing this makes it possible for IDEs like VS Code with the Svelte extension - * to provide intellisense and to use the component like this in a Svelte file - * with TypeScript: - * ```svelte - * - * - * ``` - */ - export interface Component< - Props extends Record = {}, - Exports extends Record = {}, - Bindings extends keyof Props | '' = string - > { - /** - * @param internal An internal object used by Svelte. Do not use or modify. - * @param props The props passed to the component. - */ - ( - this: void, - internals: ComponentInternals, - props: Props - ): { - /** - * @deprecated This method only exists when using one of the legacy compatibility helpers, which - * is a stop-gap solution. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) - * for more info. - */ - $on?(type: string, callback: (e: any) => void): () => void; - /** - * @deprecated This method only exists when using one of the legacy compatibility helpers, which - * is a stop-gap solution. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) - * for more info. - */ - $set?(props: Partial): void; - } & Exports; - /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */ - element?: typeof HTMLElement; - /** Does not exist at runtime, for typing capabilities only. DO NOT USE */ - z_$$bindings?: Bindings; - } - - /** - * @deprecated Use `Component` instead. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) for more information. - */ - export class SvelteComponentTyped< - Props extends Record = Record, - Events extends Record = any, - Slots extends Record = any - > extends SvelteComponent {} - - /** - * @deprecated The new `Component` type does not have a dedicated Events type. Use `ComponentProps` instead. - * - * @description - * Convenience type to get the events the given component expects. Example: - * ```html - * - * - * - * ``` - */ - export type ComponentEvents = - Comp extends SvelteComponent ? Events : never; - - /** - * Convenience type to get the props the given component expects. - * - * Example: Ensure a variable contains the props expected by `MyComponent`: - * - * ```ts - * import type { ComponentProps } from 'svelte'; - * import MyComponent from './MyComponent.svelte'; - * - * // Errors if these aren't the correct props expected by MyComponent. - * const props: ComponentProps = { foo: 'bar' }; - * ``` - * - * > [!NOTE] In Svelte 4, you would do `ComponentProps` because `MyComponent` was a class. - * - * Example: A generic function that accepts some component and infers the type of its props: - * - * ```ts - * import type { Component, ComponentProps } from 'svelte'; - * import MyComponent from './MyComponent.svelte'; - * - * function withProps>( - * component: TComponent, - * props: ComponentProps - * ) {}; - * - * // Errors if the second argument is not the correct props expected by the component in the first argument. - * withProps(MyComponent, { foo: 'bar' }); - * ``` - */ - export type ComponentProps> = - Comp extends SvelteComponent - ? Props - : Comp extends Component - ? Props - : never; - - /** - * @deprecated This type is obsolete when working with the new `Component` type. - * - * @description - * Convenience type to get the type of a Svelte component. Useful for example in combination with - * dynamic components using ``. - * - * Example: - * ```html - * - * - * - * - * ``` - */ - export type ComponentType = (new ( - options: ComponentConstructorOptions< - Comp extends SvelteComponent ? Props : Record - > - ) => Comp) & { - /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */ - element?: typeof HTMLElement; - }; - - const SnippetReturn: unique symbol; - - // Use an interface instead of a type, makes for better intellisense info because the type is named in more situations. - /** - * The type of a `#snippet` block. You can use it to (for example) express that your component expects a snippet of a certain type: - * ```ts - * let { banner }: { banner: Snippet<[{ text: string }]> } = $props(); - * ``` - * You can only call a snippet through the `{@render ...}` tag. - * - * https://svelte.dev/docs/svelte/snippet - * - * @template Parameters the parameters that the snippet expects (if any) as a tuple. - */ - export interface Snippet { - ( - this: void, - // this conditional allows tuples but not arrays. Arrays would indicate a - // rest parameter type, which is not supported. If rest parameters are added - // in the future, the condition can be removed. - ...args: number extends Parameters['length'] ? never : Parameters - ): { - '{@render ...} must be called with a Snippet': "import type { Snippet } from 'svelte'"; - } & typeof SnippetReturn; - } - - interface DispatchOptions { - cancelable?: boolean; - } - - export interface EventDispatcher> { - // Implementation notes: - // - undefined extends X instead of X extends undefined makes this work better with both strict and nonstrict mode - // - | null | undefined is added for convenience, as they are equivalent for the custom event constructor (both result in a null detail) - ( - ...args: null extends EventMap[Type] - ? [type: Type, parameter?: EventMap[Type] | null | undefined, options?: DispatchOptions] - : undefined extends EventMap[Type] - ? [type: Type, parameter?: EventMap[Type] | null | undefined, options?: DispatchOptions] - : [type: Type, parameter: EventMap[Type], options?: DispatchOptions] - ): boolean; - } - - /** - * Defines the options accepted by the `mount()` function. - */ - export type MountOptions = Record> = { - /** - * Target element where the component will be mounted. - */ - target: Document | Element | ShadowRoot; - /** - * Optional node inside `target`. When specified, it is used to render the component immediately before it. - */ - anchor?: Node; - /** - * Allows the specification of events. - * @deprecated Use callback props instead. - */ - events?: Record any>; - /** - * Can be accessed via `getContext()` at the component level. - */ - context?: Map; - /** - * Whether or not to play transitions on initial render. - * @default true - */ - intro?: boolean; - } & ({} extends Props - ? { - /** - * Component properties. - */ - props?: Props; - } - : { - /** - * Component properties. - */ - props: Props; - }); - /** - * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM. - * It must be called during the component's initialisation (but doesn't need to live *inside* the component; - * it can be called from an external module). - * - * If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted. - * - * `onMount` does not run inside [server-side components](https://svelte.dev/docs/svelte/svelte-server#render). - * - * */ - export function onMount(fn: () => NotFunction | Promise> | (() => any)): void; - /** - * Schedules a callback to run immediately before the component is unmounted. - * - * Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the - * only one that runs inside a server-side component. - * - * */ - export function onDestroy(fn: () => any): void; - /** - * Creates an event dispatcher that can be used to dispatch [component events](https://svelte.dev/docs/svelte/legacy-on#Component-events). - * Event dispatchers are functions that can take two arguments: `name` and `detail`. - * - * Component events created with `createEventDispatcher` create a - * [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent). - * These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture). - * The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail) - * property and can contain any type of data. - * - * The event dispatcher can be typed to narrow the allowed event names and the type of the `detail` argument: - * ```ts - * const dispatch = createEventDispatcher<{ - * loaded: never; // does not take a detail argument - * change: string; // takes a detail argument of type string, which is required - * optional: number | null; // takes an optional detail argument of type number - * }>(); - * ``` - * - * @deprecated Use callback props and/or the `$host()` rune instead — see [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Event-changes-Component-events) - * */ - export function createEventDispatcher = any>(): EventDispatcher; - /** - * Schedules a callback to run immediately before the component is updated after any state change. - * - * The first time the callback runs will be before the initial `onMount`. - * - * In runes mode use `$effect.pre` instead. - * - * @deprecated Use [`$effect.pre`](https://svelte.dev/docs/svelte/$effect#$effect.pre) instead - * */ - export function beforeUpdate(fn: () => void): void; - /** - * Schedules a callback to run immediately after the component has been updated. - * - * The first time the callback runs will be after the initial `onMount`. - * - * In runes mode use `$effect` instead. - * - * @deprecated Use [`$effect`](https://svelte.dev/docs/svelte/$effect) instead - * */ - export function afterUpdate(fn: () => void): void; - /** - * Synchronously flushes any pending state changes and those that result from it. - * */ - export function flushSync(fn?: (() => void) | undefined): void; - /** - * Create a snippet programmatically - * */ - export function createRawSnippet(fn: (...params: Getters) => { - render: () => string; - setup?: (element: Element) => void | (() => void); - }): Snippet; - /** Anything except a function */ - type NotFunction = T extends Function ? never : T; - /** - * Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component. - * Transitions will play during the initial render unless the `intro` option is set to `false`. - * - * */ - export function mount, Exports extends Record>(component: ComponentType> | Component, options: MountOptions): Exports; - /** - * Hydrates a component on the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component - * - * */ - export function hydrate, Exports extends Record>(component: ComponentType> | Component, options: {} extends Props ? { - target: Document | Element | ShadowRoot; - props?: Props; - events?: Record any>; - context?: Map; - intro?: boolean; - recover?: boolean; - } : { - target: Document | Element | ShadowRoot; - props: Props; - events?: Record any>; - context?: Map; - intro?: boolean; - recover?: boolean; - }): Exports; - /** - * Unmounts a component that was previously mounted using `mount` or `hydrate`. - * - * Since 5.13.0, if `options.outro` is `true`, [transitions](https://svelte.dev/docs/svelte/transition) will play before the component is removed from the DOM. - * - * Returns a `Promise` that resolves after transitions have completed if `options.outro` is true, or immediately otherwise (prior to 5.13.0, returns `void`). - * - * ```js - * import { mount, unmount } from 'svelte'; - * import App from './App.svelte'; - * - * const app = mount(App, { target: document.body }); - * - * // later... - * unmount(app, { outro: true }); - * ``` - * */ - export function unmount(component: Record, options?: { - outro?: boolean; - } | undefined): Promise; - /** - * Returns a promise that resolves once any pending state changes have been applied. - * */ - export function tick(): Promise; - /** - * When used inside a [`$derived`](https://svelte.dev/docs/svelte/$derived) or [`$effect`](https://svelte.dev/docs/svelte/$effect), - * any state read inside `fn` will not be treated as a dependency. - * - * ```ts - * $effect(() => { - * // this will run when `data` changes, but not when `time` changes - * save(data, { - * timestamp: untrack(() => time) - * }); - * }); - * ``` - * */ - export function untrack(fn: () => T): T; - /** - * Retrieves the context that belongs to the closest parent component with the specified `key`. - * Must be called during component initialisation. - * - * */ - export function getContext(key: any): T; - /** - * Associates an arbitrary `context` object with the current component and the specified `key` - * and returns that object. The context is then available to children of the component - * (including slotted content) with `getContext`. - * - * Like lifecycle functions, this must be called during component initialisation. - * - * */ - export function setContext(key: any, context: T): T; - /** - * Checks whether a given `key` has been set in the context of a parent component. - * Must be called during component initialisation. - * - * */ - export function hasContext(key: any): boolean; - /** - * Retrieves the whole context map that belongs to the closest parent component. - * Must be called during component initialisation. Useful, for example, if you - * programmatically create a component and want to pass the existing context to it. - * - * */ - export function getAllContexts = Map>(): T; - type Getters = { - [K in keyof T]: () => T[K]; - }; - - export {}; -} - -declare module 'svelte/action' { - /** - * Actions can return an object containing the two properties defined in this interface. Both are optional. - * - update: An action can have a parameter. This method will be called whenever that parameter changes, - * immediately after Svelte has applied updates to the markup. `ActionReturn` and `ActionReturn` both - * mean that the action accepts no parameters. - * - destroy: Method that is called after the element is unmounted - * - * Additionally, you can specify which additional attributes and events the action enables on the applied element. - * This applies to TypeScript typings only and has no effect at runtime. - * - * Example usage: - * ```ts - * interface Attributes { - * newprop?: string; - * 'on:event': (e: CustomEvent) => void; - * } - * - * export function myAction(node: HTMLElement, parameter: Parameter): ActionReturn { - * // ... - * return { - * update: (updatedParameter) => {...}, - * destroy: () => {...} - * }; - * } - * ``` - */ - export interface ActionReturn< - Parameter = undefined, - Attributes extends Record = Record - > { - update?: (parameter: Parameter) => void; - destroy?: () => void; - /** - * ### DO NOT USE THIS - * This exists solely for type-checking and has no effect at runtime. - * Set this through the `Attributes` generic instead. - */ - $$_attributes?: Attributes; - } - - /** - * Actions are functions that are called when an element is created. - * You can use this interface to type such actions. - * The following example defines an action that only works on `
` elements - * and optionally accepts a parameter which it has a default value for: - * ```ts - * export const myAction: Action = (node, param = { someProperty: true }) => { - * // ... - * } - * ``` - * `Action` and `Action` both signal that the action accepts no parameters. - * - * You can return an object with methods `update` and `destroy` from the function and type which additional attributes and events it has. - * See interface `ActionReturn` for more details. - */ - export interface Action< - Element = HTMLElement, - Parameter = undefined, - Attributes extends Record = Record - > { - ( - ...args: undefined extends Parameter - ? [node: Node, parameter?: Parameter] - : [node: Node, parameter: Parameter] - ): void | ActionReturn; - } - - // Implementation notes: - // - undefined extends X instead of X extends undefined makes this work better with both strict and nonstrict mode - - export {}; -} - -declare module 'svelte/animate' { - // todo: same as Transition, should it be shared? - export interface AnimationConfig { - delay?: number; - duration?: number; - easing?: (t: number) => number; - css?: (t: number, u: number) => string; - tick?: (t: number, u: number) => void; - } - - export interface FlipParams { - delay?: number; - duration?: number | ((len: number) => number); - easing?: (t: number) => number; - } - /** - * The flip function calculates the start and end position of an element and animates between them, translating the x and y values. - * `flip` stands for [First, Last, Invert, Play](https://aerotwist.com/blog/flip-your-animations/). - * - * */ - export function flip(node: Element, { from, to }: { - from: DOMRect; - to: DOMRect; - }, params?: FlipParams): AnimationConfig; - - export {}; -} - -declare module 'svelte/compiler' { - import type { Expression, Identifier, ArrayExpression, ArrowFunctionExpression, VariableDeclaration, VariableDeclarator, MemberExpression, Node, ObjectExpression, Pattern, Program, ChainExpression, SimpleCallExpression, SequenceExpression } from 'estree'; - import type { SourceMap } from 'magic-string'; - import type { Location } from 'locate-character'; - /** - * `compile` converts your `.svelte` source code into a JavaScript module that exports a component - * - * @param source The component source code - * @param options The compiler options - * */ - export function compile(source: string, options: CompileOptions): CompileResult; - /** - * `compileModule` takes your JavaScript source code containing runes, and turns it into a JavaScript module. - * - * @param source The component source code - * */ - export function compileModule(source: string, options: ModuleCompileOptions): CompileResult; - /** - * The parse function parses a component, returning only its abstract syntax tree. - * - * The `modern` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST. - * `modern` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7. - * - * */ - export function parse(source: string, options: { - filename?: string; - modern: true; - loose?: boolean; - }): AST.Root; - /** - * The parse function parses a component, returning only its abstract syntax tree. - * - * The `modern` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST. - * `modern` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7. - * - * */ - export function parse(source: string, options?: { - filename?: string; - modern?: false; - loose?: boolean; - } | undefined): Record; - /** - * @deprecated Replace this with `import { walk } from 'estree-walker'` - * */ - export function walk(): never; - /** - * The result of a preprocessor run. If the preprocessor does not return a result, it is assumed that the code is unchanged. - */ - export interface Processed { - /** - * The new code - */ - code: string; - /** - * A source map mapping back to the original code - */ - map?: string | object; // we are opaque with the type here to avoid dependency on the remapping module for our public types. - /** - * A list of additional files to watch for changes - */ - dependencies?: string[]; - /** - * Only for script/style preprocessors: The updated attributes to set on the tag. If undefined, attributes stay unchanged. - */ - attributes?: Record; - toString?: () => string; - } - - /** - * A markup preprocessor that takes a string of code and returns a processed version. - */ - export type MarkupPreprocessor = (options: { - /** - * The whole Svelte file content - */ - content: string; - /** - * The filename of the Svelte file - */ - filename?: string; - }) => Processed | void | Promise; - - /** - * A script/style preprocessor that takes a string of code and returns a processed version. - */ - export type Preprocessor = (options: { - /** - * The script/style tag content - */ - content: string; - /** - * The attributes on the script/style tag - */ - attributes: Record; - /** - * The whole Svelte file content - */ - markup: string; - /** - * The filename of the Svelte file - */ - filename?: string; - }) => Processed | void | Promise; - - /** - * A preprocessor group is a set of preprocessors that are applied to a Svelte file. - */ - export interface PreprocessorGroup { - /** Name of the preprocessor. Will be a required option in the next major version */ - name?: string; - markup?: MarkupPreprocessor; - style?: Preprocessor; - script?: Preprocessor; - } - /** The return value of `compile` from `svelte/compiler` */ - export interface CompileResult { - /** The compiled JavaScript */ - js: { - /** The generated code */ - code: string; - /** A source map */ - map: SourceMap; - }; - /** The compiled CSS */ - css: null | { - /** The generated code */ - code: string; - /** A source map */ - map: SourceMap; - }; - /** - * An array of warning objects that were generated during compilation. Each warning has several properties: - * - `code` is a string identifying the category of warning - * - `message` describes the issue in human-readable terms - * - `start` and `end`, if the warning relates to a specific location, are objects with `line`, `column` and `character` properties - */ - warnings: Warning[]; - /** - * Metadata about the compiled component - */ - metadata: { - /** - * Whether the file was compiled in runes mode, either because of an explicit option or inferred from usage. - * For `compileModule`, this is always `true` - */ - runes: boolean; - }; - /** The AST */ - ast: any; - } - - export interface Warning extends ICompileDiagnostic {} - - export interface CompileError extends ICompileDiagnostic {} - - type CssHashGetter = (args: { - name: string; - filename: string; - css: string; - hash: (input: string) => string; - }) => string; - - export interface CompileOptions extends ModuleCompileOptions { - /** - * Sets the name of the resulting JavaScript class (though the compiler will rename it if it would otherwise conflict with other variables in scope). - * If unspecified, will be inferred from `filename` - */ - name?: string; - /** - * If `true`, tells the compiler to generate a custom element constructor instead of a regular Svelte component. - * - * @default false - */ - customElement?: boolean; - /** - * If `true`, getters and setters will be created for the component's props. If `false`, they will only be created for readonly exported values (i.e. those declared with `const`, `class` and `function`). If compiling with `customElement: true` this option defaults to `true`. - * - * @default false - * @deprecated This will have no effect in runes mode - */ - accessors?: boolean; - /** - * The namespace of the element; e.g., `"html"`, `"svg"`, `"mathml"`. - * - * @default 'html' - */ - namespace?: Namespace; - /** - * If `true`, tells the compiler that you promise not to mutate any objects. - * This allows it to be less conservative about checking whether values have changed. - * - * @default false - * @deprecated This will have no effect in runes mode - */ - immutable?: boolean; - /** - * - `'injected'`: styles will be included in the `head` when using `render(...)`, and injected into the document (if not already present) when the component mounts. For components compiled as custom elements, styles are injected to the shadow root. - * - `'external'`: the CSS will only be returned in the `css` field of the compilation result. Most Svelte bundler plugins will set this to `'external'` and use the CSS that is statically generated for better performance, as it will result in smaller JavaScript bundles and the output can be served as cacheable `.css` files. - * This is always `'injected'` when compiling with `customElement` mode. - */ - css?: 'injected' | 'external'; - /** - * A function that takes a `{ hash, css, name, filename }` argument and returns the string that is used as a classname for scoped CSS. - * It defaults to returning `svelte-${hash(css)}`. - * - * @default undefined - */ - cssHash?: CssHashGetter; - /** - * If `true`, your HTML comments will be preserved in the output. By default, they are stripped out. - * - * @default false - */ - preserveComments?: boolean; - /** - * If `true`, whitespace inside and between elements is kept as you typed it, rather than removed or collapsed to a single space where possible. - * - * @default false - */ - preserveWhitespace?: boolean; - /** - * Set to `true` to force the compiler into runes mode, even if there are no indications of runes usage. - * Set to `false` to force the compiler into ignoring runes, even if there are indications of runes usage. - * Set to `undefined` (the default) to infer runes mode from the component code. - * Is always `true` for JS/TS modules compiled with Svelte. - * Will be `true` by default in Svelte 6. - * Note that setting this to `true` in your `svelte.config.js` will force runes mode for your entire project, including components in `node_modules`, - * which is likely not what you want. If you're using Vite, consider using [dynamicCompileOptions](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#dynamiccompileoptions) instead. - * @default undefined - */ - runes?: boolean | undefined; - /** - * If `true`, exposes the Svelte major version in the browser by adding it to a `Set` stored in the global `window.__svelte.v`. - * - * @default true - */ - discloseVersion?: boolean; - /** - * @deprecated Use these only as a temporary solution before migrating your code - */ - compatibility?: { - /** - * Applies a transformation so that the default export of Svelte files can still be instantiated the same way as in Svelte 4 — - * as a class when compiling for the browser (as though using `createClassComponent(MyComponent, {...})` from `svelte/legacy`) - * or as an object with a `.render(...)` method when compiling for the server - * @default 5 - */ - componentApi?: 4 | 5; - }; - /** - * An initial sourcemap that will be merged into the final output sourcemap. - * This is usually the preprocessor sourcemap. - * - * @default null - */ - sourcemap?: object | string; - /** - * Used for your JavaScript sourcemap. - * - * @default null - */ - outputFilename?: string; - /** - * Used for your CSS sourcemap. - * - * @default null - */ - cssOutputFilename?: string; - /** - * If `true`, compiles components with hot reloading support. - * - * @default false - */ - hmr?: boolean; - /** - * If `true`, returns the modern version of the AST. - * Will become `true` by default in Svelte 6, and the option will be removed in Svelte 7. - * - * @default false - */ - modernAst?: boolean; - } - - export interface ModuleCompileOptions { - /** - * If `true`, causes extra code to be added that will perform runtime checks and provide debugging information during development. - * - * @default false - */ - dev?: boolean; - /** - * If `"client"`, Svelte emits code designed to run in the browser. - * If `"server"`, Svelte emits code suitable for server-side rendering. - * If `false`, nothing is generated. Useful for tooling that is only interested in warnings. - * - * @default 'client' - */ - generate?: 'client' | 'server' | false; - /** - * Used for debugging hints and sourcemaps. Your bundler plugin will set it automatically. - */ - filename?: string; - /** - * Used for ensuring filenames don't leak filesystem information. Your bundler plugin will set it automatically. - * @default process.cwd() on node-like environments, undefined elsewhere - */ - rootDir?: string; - /** - * A function that gets a `Warning` as an argument and returns a boolean. - * Use this to filter out warnings. Return `true` to keep the warning, `false` to discard it. - */ - warningFilter?: (warning: Warning) => boolean; - } - /** - * - `html` — the default, for e.g. `
` or `` - * - `svg` — for e.g. `` or `` - * - `mathml` — for e.g. `` or `` - */ - type Namespace = 'html' | 'svg' | 'mathml'; - - export namespace AST { - export interface BaseNode { - type: string; - start: number; - end: number; - } - - export interface Fragment { - type: 'Fragment'; - nodes: Array; - } - - export interface Root extends BaseNode { - type: 'Root'; - /** - * Inline options provided by `` — these override options passed to `compile(...)` - */ - options: SvelteOptions | null; - fragment: Fragment; - /** The parsed `(fn: () => U, options?: SpringOpts): Spring; - - /** - * Sets `spring.target` to `value` and returns a `Promise` that resolves if and when `spring.current` catches up to it. - * - * If `options.instant` is `true`, `spring.current` immediately matches `spring.target`. - * - * If `options.preserveMomentum` is provided, the spring will continue on its current trajectory for - * the specified number of milliseconds. This is useful for things like 'fling' gestures. - */ - set(value: T, options?: SpringUpdateOpts): Promise; - - damping: number; - precision: number; - stiffness: number; - /** - * The end value of the spring. - * This property only exists on the `Spring` class, not the legacy `spring` store. - */ - target: T; - /** - * The current value of the spring. - * This property only exists on the `Spring` class, not the legacy `spring` store. - */ - get current(): T; - } - - export interface Tweened extends Readable { - set(value: T, opts?: TweenedOptions): Promise; - update(updater: Updater, opts?: TweenedOptions): Promise; - } - /** Callback to inform of a value updates. */ - type Subscriber = (value: T) => void; - - /** Unsubscribes from value updates. */ - type Unsubscriber = () => void; - - /** Readable interface for subscribing. */ - interface Readable { - /** - * Subscribe on value changes. - * @param run subscription callback - * @param invalidate cleanup callback - */ - subscribe(this: void, run: Subscriber, invalidate?: () => void): Unsubscriber; - } - interface SpringOpts { - stiffness?: number; - damping?: number; - precision?: number; - } - - interface SpringUpdateOpts { - /** - * @deprecated Only use this for the spring store; does nothing when set on the Spring class - */ - hard?: any; - /** - * @deprecated Only use this for the spring store; does nothing when set on the Spring class - */ - soft?: string | number | boolean; - /** - * Only use this for the Spring class; does nothing when set on the spring store - */ - instant?: boolean; - /** - * Only use this for the Spring class; does nothing when set on the spring store - */ - preserveMomentum?: number; - } - - type Updater = (target_value: T, value: T) => T; - - interface TweenedOptions { - delay?: number; - duration?: number | ((from: T, to: T) => number); - easing?: (t: number) => number; - interpolate?: (a: T, b: T) => (t: number) => T; - } - /** - * A [media query](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery) that matches if the user [prefers reduced motion](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion). - * - * ```svelte - * - * - * - * - * {#if visible} - *

- * flies in, unless the user prefers reduced motion - *

- * {/if} - * ``` - * @since 5.7.0 - */ - export const prefersReducedMotion: MediaQuery; - /** - * The spring function in Svelte creates a store whose value is animated, with a motion that simulates the behavior of a spring. This means when the value changes, instead of transitioning at a steady rate, it "bounces" like a spring would, depending on the physics parameters provided. This adds a level of realism to the transitions and can enhance the user experience. - * - * @deprecated Use [`Spring`](https://svelte.dev/docs/svelte/svelte-motion#Spring) instead - * */ - export function spring(value?: T | undefined, opts?: SpringOpts | undefined): Spring; - /** - * A tweened store in Svelte is a special type of store that provides smooth transitions between state values over time. - * - * @deprecated Use [`Tween`](https://svelte.dev/docs/svelte/svelte-motion#Tween) instead - * */ - export function tweened(value?: T | undefined, defaults?: TweenedOptions | undefined): Tweened; - /** - * A wrapper for a value that tweens smoothly to its target value. Changes to `tween.target` will cause `tween.current` to - * move towards it over time, taking account of the `delay`, `duration` and `easing` options. - * - * ```svelte - * - * - * - * - * ``` - * @since 5.8.0 - */ - export class Tween { - /** - * Create a tween whose value is bound to the return value of `fn`. This must be called - * inside an effect root (for example, during component initialisation). - * - * ```svelte - * - * ``` - * - */ - static of(fn: () => U, options?: TweenedOptions | undefined): Tween; - - constructor(value: T, options?: TweenedOptions); - /** - * Sets `tween.target` to `value` and returns a `Promise` that resolves if and when `tween.current` catches up to it. - * - * If `options` are provided, they will override the tween's defaults. - * */ - set(value: T, options?: TweenedOptions | undefined): Promise; - get current(): T; - set target(v: T); - get target(): T; - #private; - } - - export {}; -} - -declare module 'svelte/reactivity' { - export class SvelteDate extends Date { - - constructor(...params: any[]); - #private; - } - export class SvelteSet extends Set { - - constructor(value?: Iterable | null | undefined); - - add(value: T): this; - #private; - } - export class SvelteMap extends Map { - - constructor(value?: Iterable | null | undefined); - - set(key: K, value: V): this; - #private; - } - export class SvelteURL extends URL { - get searchParams(): SvelteURLSearchParams; - #private; - } - const REPLACE: unique symbol; - export class SvelteURLSearchParams extends URLSearchParams { - - [REPLACE](params: URLSearchParams): void; - #private; - } - /** - * Creates a media query and provides a `current` property that reflects whether or not it matches. - * - * Use it carefully — during server-side rendering, there is no way to know what the correct value should be, potentially causing content to change upon hydration. - * If you can use the media query in CSS to achieve the same effect, do that. - * - * ```svelte - * - * - *

{large.current ? 'large screen' : 'small screen'}

- * ``` - * @extends {ReactiveValue} - * @since 5.7.0 - */ - export class MediaQuery extends ReactiveValue { - /** - * @param query A media query string - * @param fallback Fallback value for the server - */ - constructor(query: string, fallback?: boolean | undefined); - } - /** - * Returns a `subscribe` function that, if called in an effect (including expressions in the template), - * calls its `start` callback with an `update` function. Whenever `update` is called, the effect re-runs. - * - * If `start` returns a function, it will be called when the effect is destroyed. - * - * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects - * are active, and the returned teardown function will only be called when all effects are destroyed. - * - * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery): - * - * ```js - * import { createSubscriber } from 'svelte/reactivity'; - * import { on } from 'svelte/events'; - * - * export class MediaQuery { - * #query; - * #subscribe; - * - * constructor(query) { - * this.#query = window.matchMedia(`(${query})`); - * - * this.#subscribe = createSubscriber((update) => { - * // when the `change` event occurs, re-run any effects that read `this.current` - * const off = on(this.#query, 'change', update); - * - * // stop listening when all the effects are destroyed - * return () => off(); - * }); - * } - * - * get current() { - * this.#subscribe(); - * - * // Return the current state of the query, whether or not we're in an effect - * return this.#query.matches; - * } - * } - * ``` - * @since 5.7.0 - */ - export function createSubscriber(start: (update: () => void) => (() => void) | void): () => void; - class ReactiveValue { - - constructor(fn: () => T, onsubscribe: (update: () => void) => void); - get current(): T; - #private; - } - - export {}; -} - -declare module 'svelte/reactivity/window' { - /** - * `scrollX.current` is a reactive view of `window.scrollX`. On the server it is `undefined`. - * @since 5.11.0 - */ - export const scrollX: ReactiveValue; - /** - * `scrollY.current` is a reactive view of `window.scrollY`. On the server it is `undefined`. - * @since 5.11.0 - */ - export const scrollY: ReactiveValue; - /** - * `innerWidth.current` is a reactive view of `window.innerWidth`. On the server it is `undefined`. - * @since 5.11.0 - */ - export const innerWidth: ReactiveValue; - /** - * `innerHeight.current` is a reactive view of `window.innerHeight`. On the server it is `undefined`. - * @since 5.11.0 - */ - export const innerHeight: ReactiveValue; - /** - * `outerWidth.current` is a reactive view of `window.outerWidth`. On the server it is `undefined`. - * @since 5.11.0 - */ - export const outerWidth: ReactiveValue; - /** - * `outerHeight.current` is a reactive view of `window.outerHeight`. On the server it is `undefined`. - * @since 5.11.0 - */ - export const outerHeight: ReactiveValue; - /** - * `screenLeft.current` is a reactive view of `window.screenLeft`. It is updated inside a `requestAnimationFrame` callback. On the server it is `undefined`. - * @since 5.11.0 - */ - export const screenLeft: ReactiveValue; - /** - * `screenTop.current` is a reactive view of `window.screenTop`. It is updated inside a `requestAnimationFrame` callback. On the server it is `undefined`. - * @since 5.11.0 - */ - export const screenTop: ReactiveValue; - /** - * `online.current` is a reactive view of `navigator.onLine`. On the server it is `undefined`. - * @since 5.11.0 - */ - export const online: ReactiveValue; - /** - * `devicePixelRatio.current` is a reactive view of `window.devicePixelRatio`. On the server it is `undefined`. - * Note that behaviour differs between browsers — on Chrome it will respond to the current zoom level, - * on Firefox and Safari it won't. - * @since 5.11.0 - */ - export const devicePixelRatio: { - get current(): number | undefined; - }; - class ReactiveValue { - - constructor(fn: () => T, onsubscribe: (update: () => void) => void); - get current(): T; - #private; - } - - export {}; -} - -declare module 'svelte/server' { - import type { ComponentProps, Component, SvelteComponent, ComponentType } from 'svelte'; - /** - * Only available on the server and when compiling with the `server` option. - * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app. - */ - export function render< - Comp extends SvelteComponent | Component, - Props extends ComponentProps = ComponentProps - >( - ...args: {} extends Props - ? [ - component: Comp extends SvelteComponent ? ComponentType : Comp, - options?: { props?: Omit; context?: Map } - ] - : [ - component: Comp extends SvelteComponent ? ComponentType : Comp, - options: { props: Omit; context?: Map } - ] - ): RenderOutput; - interface RenderOutput { - /** HTML that goes into the `` */ - head: string; - /** @deprecated use `body` instead */ - html: string; - /** HTML that goes somewhere into the `` */ - body: string; - } - - export {}; -} - -declare module 'svelte/store' { - /** Callback to inform of a value updates. */ - export type Subscriber = (value: T) => void; - - /** Unsubscribes from value updates. */ - export type Unsubscriber = () => void; - - /** Callback to update a value. */ - export type Updater = (value: T) => T; - - /** - * Start and stop notification callbacks. - * This function is called when the first subscriber subscribes. - * - * @param set Function that sets the value of the store. - * @param update Function that sets the value of the store after passing the current value to the update function. - * @returns Optionally, a cleanup function that is called when the last remaining - * subscriber unsubscribes. - */ - export type StartStopNotifier = ( - set: (value: T) => void, - update: (fn: Updater) => void - ) => void | (() => void); - - /** Readable interface for subscribing. */ - export interface Readable { - /** - * Subscribe on value changes. - * @param run subscription callback - * @param invalidate cleanup callback - */ - subscribe(this: void, run: Subscriber, invalidate?: () => void): Unsubscriber; - } - - /** Writable interface for both updating and subscribing. */ - export interface Writable extends Readable { - /** - * Set value and inform subscribers. - * @param value to set - */ - set(this: void, value: T): void; - - /** - * Update value using callback and inform subscribers. - * @param updater callback - */ - update(this: void, updater: Updater): void; - } - export function toStore(get: () => V, set: (v: V) => void): Writable; - - export function toStore(get: () => V): Readable; - - export function fromStore(store: Writable): { - current: V; - }; - - export function fromStore(store: Readable): { - readonly current: V; - }; - /** - * Creates a `Readable` store that allows reading by subscription. - * - * @param value initial value - * */ - export function readable(value?: T | undefined, start?: StartStopNotifier | undefined): Readable; - /** - * Create a `Writable` store that allows both updating and reading by subscription. - * - * @param value initial value - * */ - export function writable(value?: T | undefined, start?: StartStopNotifier | undefined): Writable; - /** - * Derived value store by synchronizing one or more readable stores and - * applying an aggregation function over its input values. - * - * */ - export function derived(stores: S, fn: (values: StoresValues, set: (value: T) => void, update: (fn: Updater) => void) => Unsubscriber | void, initial_value?: T | undefined): Readable; - /** - * Derived value store by synchronizing one or more readable stores and - * applying an aggregation function over its input values. - * - * */ - export function derived(stores: S, fn: (values: StoresValues) => T, initial_value?: T | undefined): Readable; - /** - * Takes a store and returns a new one derived from the old one that is readable. - * - * @param store - store to make readonly - * */ - export function readonly(store: Readable): Readable; - /** - * Get the current value from a store by subscribing and immediately unsubscribing. - * - * */ - export function get(store: Readable): T; - /** One or more `Readable`s. */ - type Stores = Readable | [Readable, ...Array>] | Array>; - - /** One or more values from `Readable` stores. */ - type StoresValues = - T extends Readable ? U : { [K in keyof T]: T[K] extends Readable ? U : never }; - - export {}; -} - -declare module 'svelte/transition' { - export type EasingFunction = (t: number) => number; - - export interface TransitionConfig { - delay?: number; - duration?: number; - easing?: EasingFunction; - css?: (t: number, u: number) => string; - tick?: (t: number, u: number) => void; - } - - export interface BlurParams { - delay?: number; - duration?: number; - easing?: EasingFunction; - amount?: number | string; - opacity?: number; - } - - export interface FadeParams { - delay?: number; - duration?: number; - easing?: EasingFunction; - } - - export interface FlyParams { - delay?: number; - duration?: number; - easing?: EasingFunction; - x?: number | string; - y?: number | string; - opacity?: number; - } - - export interface SlideParams { - delay?: number; - duration?: number; - easing?: EasingFunction; - axis?: 'x' | 'y'; - } - - export interface ScaleParams { - delay?: number; - duration?: number; - easing?: EasingFunction; - start?: number; - opacity?: number; - } - - export interface DrawParams { - delay?: number; - speed?: number; - duration?: number | ((len: number) => number); - easing?: EasingFunction; - } - - export interface CrossfadeParams { - delay?: number; - duration?: number | ((len: number) => number); - easing?: EasingFunction; - } - /** - * Animates a `blur` filter alongside an element's opacity. - * - * */ - export function blur(node: Element, { delay, duration, easing, amount, opacity }?: BlurParams | undefined): TransitionConfig; - /** - * Animates the opacity of an element from 0 to the current opacity for `in` transitions and from the current opacity to 0 for `out` transitions. - * - * */ - export function fade(node: Element, { delay, duration, easing }?: FadeParams | undefined): TransitionConfig; - /** - * Animates the x and y positions and the opacity of an element. `in` transitions animate from the provided values, passed as parameters to the element's default values. `out` transitions animate from the element's default values to the provided values. - * - * */ - export function fly(node: Element, { delay, duration, easing, x, y, opacity }?: FlyParams | undefined): TransitionConfig; - /** - * Slides an element in and out. - * - * */ - export function slide(node: Element, { delay, duration, easing, axis }?: SlideParams | undefined): TransitionConfig; - /** - * Animates the opacity and scale of an element. `in` transitions animate from the provided values, passed as parameters, to an element's current (default) values. `out` transitions animate from an element's default values to the provided values. - * - * */ - export function scale(node: Element, { delay, duration, easing, start, opacity }?: ScaleParams | undefined): TransitionConfig; - /** - * Animates the stroke of an SVG element, like a snake in a tube. `in` transitions begin with the path invisible and draw the path to the screen over time. `out` transitions start in a visible state and gradually erase the path. `draw` only works with elements that have a `getTotalLength` method, like `` and ``. - * - * */ - export function draw(node: SVGElement & { - getTotalLength(): number; - }, { delay, speed, duration, easing }?: DrawParams | undefined): TransitionConfig; - /** - * The `crossfade` function creates a pair of [transitions](https://svelte.dev/docs/svelte/transition) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used. - * - * */ - export function crossfade({ fallback, ...defaults }: CrossfadeParams & { - fallback?: (node: Element, params: CrossfadeParams, intro: boolean) => TransitionConfig; - }): [(node: any, params: CrossfadeParams & { - key: any; - }) => () => TransitionConfig, (node: any, params: CrossfadeParams & { - key: any; - }) => () => TransitionConfig]; - - export {}; -} - -declare module 'svelte/events' { - // Once https://github.com/microsoft/TypeScript/issues/59980 is fixed we can put these overloads into the JSDoc comments of the `on` function - - /** - * Attaches an event handler to the window and returns a function that removes the handler. Using this - * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively - * (with attributes like `onclick`), which use event delegation for performance reasons - */ - export function on( - window: Window, - type: Type, - handler: (this: Window, event: WindowEventMap[Type]) => any, - options?: AddEventListenerOptions | undefined - ): () => void; - /** - * Attaches an event handler to the document and returns a function that removes the handler. Using this - * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively - * (with attributes like `onclick`), which use event delegation for performance reasons - */ - export function on( - document: Document, - type: Type, - handler: (this: Document, event: DocumentEventMap[Type]) => any, - options?: AddEventListenerOptions | undefined - ): () => void; - /** - * Attaches an event handler to an element and returns a function that removes the handler. Using this - * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively - * (with attributes like `onclick`), which use event delegation for performance reasons - */ - export function on( - element: Element, - type: Type, - handler: (this: Element, event: HTMLElementEventMap[Type]) => any, - options?: AddEventListenerOptions | undefined - ): () => void; - /** - * Attaches an event handler to an element and returns a function that removes the handler. Using this - * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively - * (with attributes like `onclick`), which use event delegation for performance reasons - */ - export function on( - element: Element, - type: Type, - handler: (this: Element, event: MediaQueryListEventMap[Type]) => any, - options?: AddEventListenerOptions | undefined - ): () => void; - /** - * Attaches an event handler to an element and returns a function that removes the handler. Using this - * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively - * (with attributes like `onclick`), which use event delegation for performance reasons - */ - export function on( - element: EventTarget, - type: string, - handler: EventListener, - options?: AddEventListenerOptions | undefined - ): () => void; - - export {}; -} - -declare module 'svelte/types/compiler/preprocess' { - /** @deprecated import this from 'svelte/preprocess' instead */ - export type MarkupPreprocessor = MarkupPreprocessor_1; - /** @deprecated import this from 'svelte/preprocess' instead */ - export type Preprocessor = Preprocessor_1; - /** @deprecated import this from 'svelte/preprocess' instead */ - export type PreprocessorGroup = PreprocessorGroup_1; - /** @deprecated import this from 'svelte/preprocess' instead */ - export type Processed = Processed_1; - /** @deprecated import this from 'svelte/preprocess' instead */ - export type SveltePreprocessor = SveltePreprocessor_1< - PreprocessorType, - Options - >; - /** - * The result of a preprocessor run. If the preprocessor does not return a result, it is assumed that the code is unchanged. - */ - interface Processed_1 { - /** - * The new code - */ - code: string; - /** - * A source map mapping back to the original code - */ - map?: string | object; // we are opaque with the type here to avoid dependency on the remapping module for our public types. - /** - * A list of additional files to watch for changes - */ - dependencies?: string[]; - /** - * Only for script/style preprocessors: The updated attributes to set on the tag. If undefined, attributes stay unchanged. - */ - attributes?: Record; - toString?: () => string; - } - - /** - * A markup preprocessor that takes a string of code and returns a processed version. - */ - type MarkupPreprocessor_1 = (options: { - /** - * The whole Svelte file content - */ - content: string; - /** - * The filename of the Svelte file - */ - filename?: string; - }) => Processed_1 | void | Promise; - - /** - * A script/style preprocessor that takes a string of code and returns a processed version. - */ - type Preprocessor_1 = (options: { - /** - * The script/style tag content - */ - content: string; - /** - * The attributes on the script/style tag - */ - attributes: Record; - /** - * The whole Svelte file content - */ - markup: string; - /** - * The filename of the Svelte file - */ - filename?: string; - }) => Processed_1 | void | Promise; - - /** - * A preprocessor group is a set of preprocessors that are applied to a Svelte file. - */ - interface PreprocessorGroup_1 { - /** Name of the preprocessor. Will be a required option in the next major version */ - name?: string; - markup?: MarkupPreprocessor_1; - style?: Preprocessor_1; - script?: Preprocessor_1; - } - - /** - * @description Utility type to extract the type of a preprocessor from a preprocessor group - * @deprecated Create this utility type yourself instead - */ - interface SveltePreprocessor_1< - PreprocessorType extends keyof PreprocessorGroup_1, - Options = any - > { - (options?: Options): Required>; - } - - export {}; -} - -declare module 'svelte/types/compiler/interfaces' { - import type { Location } from 'locate-character'; - /** @deprecated import this from 'svelte' instead */ - export type CompileOptions = CompileOptions_1; - /** @deprecated import this from 'svelte' instead */ - export type Warning = Warning_1; - interface Warning_1 extends ICompileDiagnostic {} - - type CssHashGetter = (args: { - name: string; - filename: string; - css: string; - hash: (input: string) => string; - }) => string; - - interface CompileOptions_1 extends ModuleCompileOptions { - /** - * Sets the name of the resulting JavaScript class (though the compiler will rename it if it would otherwise conflict with other variables in scope). - * If unspecified, will be inferred from `filename` - */ - name?: string; - /** - * If `true`, tells the compiler to generate a custom element constructor instead of a regular Svelte component. - * - * @default false - */ - customElement?: boolean; - /** - * If `true`, getters and setters will be created for the component's props. If `false`, they will only be created for readonly exported values (i.e. those declared with `const`, `class` and `function`). If compiling with `customElement: true` this option defaults to `true`. - * - * @default false - * @deprecated This will have no effect in runes mode - */ - accessors?: boolean; - /** - * The namespace of the element; e.g., `"html"`, `"svg"`, `"mathml"`. - * - * @default 'html' - */ - namespace?: Namespace; - /** - * If `true`, tells the compiler that you promise not to mutate any objects. - * This allows it to be less conservative about checking whether values have changed. - * - * @default false - * @deprecated This will have no effect in runes mode - */ - immutable?: boolean; - /** - * - `'injected'`: styles will be included in the `head` when using `render(...)`, and injected into the document (if not already present) when the component mounts. For components compiled as custom elements, styles are injected to the shadow root. - * - `'external'`: the CSS will only be returned in the `css` field of the compilation result. Most Svelte bundler plugins will set this to `'external'` and use the CSS that is statically generated for better performance, as it will result in smaller JavaScript bundles and the output can be served as cacheable `.css` files. - * This is always `'injected'` when compiling with `customElement` mode. - */ - css?: 'injected' | 'external'; - /** - * A function that takes a `{ hash, css, name, filename }` argument and returns the string that is used as a classname for scoped CSS. - * It defaults to returning `svelte-${hash(css)}`. - * - * @default undefined - */ - cssHash?: CssHashGetter; - /** - * If `true`, your HTML comments will be preserved in the output. By default, they are stripped out. - * - * @default false - */ - preserveComments?: boolean; - /** - * If `true`, whitespace inside and between elements is kept as you typed it, rather than removed or collapsed to a single space where possible. - * - * @default false - */ - preserveWhitespace?: boolean; - /** - * Set to `true` to force the compiler into runes mode, even if there are no indications of runes usage. - * Set to `false` to force the compiler into ignoring runes, even if there are indications of runes usage. - * Set to `undefined` (the default) to infer runes mode from the component code. - * Is always `true` for JS/TS modules compiled with Svelte. - * Will be `true` by default in Svelte 6. - * Note that setting this to `true` in your `svelte.config.js` will force runes mode for your entire project, including components in `node_modules`, - * which is likely not what you want. If you're using Vite, consider using [dynamicCompileOptions](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#dynamiccompileoptions) instead. - * @default undefined - */ - runes?: boolean | undefined; - /** - * If `true`, exposes the Svelte major version in the browser by adding it to a `Set` stored in the global `window.__svelte.v`. - * - * @default true - */ - discloseVersion?: boolean; - /** - * @deprecated Use these only as a temporary solution before migrating your code - */ - compatibility?: { - /** - * Applies a transformation so that the default export of Svelte files can still be instantiated the same way as in Svelte 4 — - * as a class when compiling for the browser (as though using `createClassComponent(MyComponent, {...})` from `svelte/legacy`) - * or as an object with a `.render(...)` method when compiling for the server - * @default 5 - */ - componentApi?: 4 | 5; - }; - /** - * An initial sourcemap that will be merged into the final output sourcemap. - * This is usually the preprocessor sourcemap. - * - * @default null - */ - sourcemap?: object | string; - /** - * Used for your JavaScript sourcemap. - * - * @default null - */ - outputFilename?: string; - /** - * Used for your CSS sourcemap. - * - * @default null - */ - cssOutputFilename?: string; - /** - * If `true`, compiles components with hot reloading support. - * - * @default false - */ - hmr?: boolean; - /** - * If `true`, returns the modern version of the AST. - * Will become `true` by default in Svelte 6, and the option will be removed in Svelte 7. - * - * @default false - */ - modernAst?: boolean; - } - - interface ModuleCompileOptions { - /** - * If `true`, causes extra code to be added that will perform runtime checks and provide debugging information during development. - * - * @default false - */ - dev?: boolean; - /** - * If `"client"`, Svelte emits code designed to run in the browser. - * If `"server"`, Svelte emits code suitable for server-side rendering. - * If `false`, nothing is generated. Useful for tooling that is only interested in warnings. - * - * @default 'client' - */ - generate?: 'client' | 'server' | false; - /** - * Used for debugging hints and sourcemaps. Your bundler plugin will set it automatically. - */ - filename?: string; - /** - * Used for ensuring filenames don't leak filesystem information. Your bundler plugin will set it automatically. - * @default process.cwd() on node-like environments, undefined elsewhere - */ - rootDir?: string; - /** - * A function that gets a `Warning` as an argument and returns a boolean. - * Use this to filter out warnings. Return `true` to keep the warning, `false` to discard it. - */ - warningFilter?: (warning: Warning_1) => boolean; - } - /** - * - `html` — the default, for e.g. `
` or `` - * - `svg` — for e.g. `` or `` - * - `mathml` — for e.g. `` or `` - */ - type Namespace = 'html' | 'svg' | 'mathml'; - type ICompileDiagnostic = { - code: string; - message: string; - stack?: string; - filename?: string; - start?: Location; - end?: Location; - position?: [number, number]; - frame?: string; - }; - - export {}; -}declare module '*.svelte' { - // use prettier-ignore for a while because of https://github.com/sveltejs/language-tools/commit/026111228b5814a9109cc4d779d37fb02955fb8b - // prettier-ignore - import { SvelteComponent } from 'svelte' - import { LegacyComponentType } from 'svelte/legacy'; - const Comp: LegacyComponentType; - type Comp = SvelteComponent; - export default Comp; -} - -/** - * Declares reactive state. - * - * Example: - * ```ts - * let count = $state(0); - * ``` - * - * https://svelte.dev/docs/svelte/$state - * - * @param initial The initial value - */ -declare function $state(initial: T): T; -declare function $state(): T | undefined; - -declare namespace $state { - type Primitive = string | number | boolean | null | undefined; - - type TypedArray = - | Int8Array - | Uint8Array - | Uint8ClampedArray - | Int16Array - | Uint16Array - | Int32Array - | Uint32Array - | Float32Array - | Float64Array - | BigInt64Array - | BigUint64Array; - - /** The things that `structuredClone` can handle — https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm */ - export type Cloneable = - | ArrayBuffer - | DataView - | Date - | Error - | Map - | RegExp - | Set - | TypedArray - // web APIs - | Blob - | CryptoKey - | DOMException - | DOMMatrix - | DOMMatrixReadOnly - | DOMPoint - | DOMPointReadOnly - | DOMQuad - | DOMRect - | DOMRectReadOnly - | File - | FileList - | FileSystemDirectoryHandle - | FileSystemFileHandle - | FileSystemHandle - | ImageBitmap - | ImageData - | RTCCertificate - | VideoFrame; - - /** Turn `SvelteDate`, `SvelteMap` and `SvelteSet` into their non-reactive counterparts. (`URL` is uncloneable.) */ - type NonReactive = T extends Date - ? Date - : T extends Map - ? Map - : T extends Set - ? Set - : T; - - type Snapshot = T extends Primitive - ? T - : T extends Cloneable - ? NonReactive - : T extends { toJSON(): infer R } - ? R - : T extends Array - ? Array> - : T extends object - ? T extends { [key: string]: any } - ? { [K in keyof T]: Snapshot } - : never - : never; - - /** - * Declares state that is _not_ made deeply reactive — instead of mutating it, - * you must reassign it. - * - * Example: - * ```ts - * - * - * - * ``` - * - * https://svelte.dev/docs/svelte/$state#$state.raw - * - * @param initial The initial value - */ - export function raw(initial: T): T; - export function raw(): T | undefined; - /** - * To take a static snapshot of a deeply reactive `$state` proxy, use `$state.snapshot`: - * - * Example: - * ```ts - * - * ``` - * - * https://svelte.dev/docs/svelte/$state#$state.snapshot - * - * @param state The value to snapshot - */ - export function snapshot(state: T): Snapshot; - - // prevent intellisense from being unhelpful - /** @deprecated */ - export const apply: never; - /** @deprecated */ - // @ts-ignore - export const arguments: never; - /** @deprecated */ - export const bind: never; - /** @deprecated */ - export const call: never; - /** @deprecated */ - export const caller: never; - /** @deprecated */ - export const length: never; - /** @deprecated */ - export const name: never; - /** @deprecated */ - export const prototype: never; - /** @deprecated */ - export const toString: never; -} - -/** - * Declares derived state, i.e. one that depends on other state variables. - * The expression inside `$derived(...)` should be free of side-effects. - * - * Example: - * ```ts - * let double = $derived(count * 2); - * ``` - * - * https://svelte.dev/docs/svelte/$derived - * - * @param expression The derived state expression - */ -declare function $derived(expression: T): T; - -declare namespace $derived { - /** - * Sometimes you need to create complex derivations that don't fit inside a short expression. - * In these cases, you can use `$derived.by` which accepts a function as its argument. - * - * Example: - * ```ts - * let total = $derived.by(() => { - * let result = 0; - * for (const n of numbers) { - * result += n; - * } - * return result; - * }); - * ``` - * - * https://svelte.dev/docs/svelte/$derived#$derived.by - */ - export function by(fn: () => T): T; - - // prevent intellisense from being unhelpful - /** @deprecated */ - export const apply: never; - /** @deprecated */ - // @ts-ignore - export const arguments: never; - /** @deprecated */ - export const bind: never; - /** @deprecated */ - export const call: never; - /** @deprecated */ - export const caller: never; - /** @deprecated */ - export const length: never; - /** @deprecated */ - export const name: never; - /** @deprecated */ - export const prototype: never; - /** @deprecated */ - export const toString: never; -} - -/** - * Runs code when a component is mounted to the DOM, and then whenever its dependencies change, i.e. `$state` or `$derived` values. - * The timing of the execution is after the DOM has been updated. - * - * Example: - * ```ts - * $effect(() => console.log('The count is now ' + count)); - * ``` - * - * If you return a function from the effect, it will be called right before the effect is run again, or when the component is unmounted. - * - * Does not run during server side rendering. - * - * https://svelte.dev/docs/svelte/$effect - * @param fn The function to execute - */ -declare function $effect(fn: () => void | (() => void)): void; - -declare namespace $effect { - /** - * Runs code right before a component is mounted to the DOM, and then whenever its dependencies change, i.e. `$state` or `$derived` values. - * The timing of the execution is right before the DOM is updated. - * - * Example: - * ```ts - * $effect.pre(() => console.log('The count is now ' + count)); - * ``` - * - * If you return a function from the effect, it will be called right before the effect is run again, or when the component is unmounted. - * - * Does not run during server side rendering. - * - * https://svelte.dev/docs/svelte/$effect#$effect.pre - * @param fn The function to execute - */ - export function pre(fn: () => void | (() => void)): void; - - /** - * The `$effect.tracking` rune is an advanced feature that tells you whether or not the code is running inside a tracking context, such as an effect or inside your template. - * - * Example: - * ```svelte - * - * - *

in template: {$effect.tracking()}

- * ``` - * - * This allows you to (for example) add things like subscriptions without causing memory leaks, by putting them in child effects. - * - * https://svelte.dev/docs/svelte/$effect#$effect.tracking - */ - export function tracking(): boolean; - - /** - * The `$effect.root` rune is an advanced feature that creates a non-tracked scope that doesn't auto-cleanup. This is useful for - * nested effects that you want to manually control. This rune also allows for creation of effects outside of the component - * initialisation phase. - * - * Example: - * ```svelte - * - * - * - * ``` - * - * https://svelte.dev/docs/svelte/$effect#$effect.root - */ - export function root(fn: () => void | (() => void)): () => void; - - // prevent intellisense from being unhelpful - /** @deprecated */ - export const apply: never; - /** @deprecated */ - // @ts-ignore - export const arguments: never; - /** @deprecated */ - export const bind: never; - /** @deprecated */ - export const call: never; - /** @deprecated */ - export const caller: never; - /** @deprecated */ - export const length: never; - /** @deprecated */ - export const name: never; - /** @deprecated */ - export const prototype: never; - /** @deprecated */ - export const toString: never; -} - -/** - * Declares the props that a component accepts. Example: - * - * ```ts - * let { optionalProp = 42, requiredProp, bindableProp = $bindable() }: { optionalProp?: number; requiredProps: string; bindableProp: boolean } = $props(); - * ``` - * - * https://svelte.dev/docs/svelte/$props - */ -declare function $props(): any; - -/** - * Declares a prop as bindable, meaning the parent component can use `bind:propName={value}` to bind to it. - * - * ```ts - * let { propName = $bindable() }: { propName: boolean } = $props(); - * ``` - * - * https://svelte.dev/docs/svelte/$bindable - */ -declare function $bindable(fallback?: T): T; - -/** - * Inspects one or more values whenever they, or the properties they contain, change. Example: - * - * ```ts - * $inspect(someValue, someOtherValue) - * ``` - * - * `$inspect` returns a `with` function, which you can invoke with a callback function that - * will be called with the value and the event type (`'init'` or `'update'`) on every change. - * By default, the values will be logged to the console. - * - * ```ts - * $inspect(x).with(console.trace); - * $inspect(x, y).with(() => { debugger; }); - * ``` - * - * https://svelte.dev/docs/svelte/$inspect - */ -declare function $inspect( - ...values: T -): { with: (fn: (type: 'init' | 'update', ...values: T) => void) => void }; - -declare namespace $inspect { - /** - * Tracks which reactive state changes caused an effect to re-run. Must be the first - * statement of a function body. Example: - * - * ```svelte - * - */ - export function trace(name: string): void; -} - -/** - * Retrieves the `this` reference of the custom element that contains this component. Example: - * - * ```svelte - * - * - * - * - * - * ``` - * - * Only available inside custom element components, and only on the client-side. - * - * https://svelte.dev/docs/svelte/$host - */ -declare function $host(): El; - -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b5becc375a55..c79c0dab30fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -84,8 +84,8 @@ importers: specifier: ^1.2.1 version: 1.2.1 esrap: - specifier: ^1.3.0 - version: 1.3.0 + specifier: ^1.3.1 + version: link:../../../../esrap is-reference: specifier: ^3.0.3 version: 3.0.3 @@ -1139,9 +1139,6 @@ packages: resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} engines: {node: '>=0.10'} - esrap@1.3.0: - resolution: {integrity: sha512-LPT4X5Ur2sGnkQscwgWXRPVDuQrbuJbrStLmVXVXd+lGQ/HoYmcAa47t0Egzw1bYHwhF0w+6DTkxL1Xctp10XQ==} - esrecurse@4.3.0: resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} engines: {node: '>=4.0'} @@ -3388,11 +3385,6 @@ snapshots: dependencies: estraverse: 5.3.0 - esrap@1.3.0: - dependencies: - '@jridgewell/sourcemap-codec': 1.5.0 - '@typescript-eslint/types': 8.2.0 - esrecurse@4.3.0: dependencies: estraverse: 5.3.0 From 1c617139d2b5d3905be9d3f312a824a482521e7d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 17 Dec 2024 20:03:40 -0500 Subject: [PATCH 6/8] oops --- packages/svelte/types/index.d.ts | 3072 ++++++++++++++++++++++++++++++ 1 file changed, 3072 insertions(+) create mode 100644 packages/svelte/types/index.d.ts diff --git a/packages/svelte/types/index.d.ts b/packages/svelte/types/index.d.ts new file mode 100644 index 000000000000..671f68bff72a --- /dev/null +++ b/packages/svelte/types/index.d.ts @@ -0,0 +1,3072 @@ +declare module 'svelte' { + /** + * @deprecated In Svelte 4, components are classes. In Svelte 5, they are functions. + * Use `mount` instead to instantiate components. + * See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) + * for more info. + */ + export interface ComponentConstructorOptions< + Props extends Record = Record + > { + target: Element | Document | ShadowRoot; + anchor?: Element; + props?: Props; + context?: Map; + hydrate?: boolean; + intro?: boolean; + recover?: boolean; + sync?: boolean; + $$inline?: boolean; + } + + /** + * Utility type for ensuring backwards compatibility on a type level that if there's a default slot, add 'children' to the props + */ + type Properties = Props & + (Slots extends { default: any } + ? // This is unfortunate because it means "accepts no props" turns into "accepts any prop" + // but the alternative is non-fixable type errors because of the way TypeScript index + // signatures work (they will always take precedence and make an impossible-to-satisfy children type). + Props extends Record + ? any + : { children?: any } + : {}); + + /** + * This was the base class for Svelte components in Svelte 4. Svelte 5+ components + * are completely different under the hood. For typing, use `Component` instead. + * To instantiate components, use `mount` instead. + * See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) for more info. + */ + export class SvelteComponent< + Props extends Record = Record, + Events extends Record = any, + Slots extends Record = any + > { + /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */ + static element?: typeof HTMLElement; + + [prop: string]: any; + /** + * @deprecated This constructor only exists when using the `asClassComponent` compatibility helper, which + * is a stop-gap solution. Migrate towards using `mount` instead. See + * [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) for more info. + */ + constructor(options: ComponentConstructorOptions>); + /** + * For type checking capabilities only. + * Does not exist at runtime. + * ### DO NOT USE! + */ + $$prop_def: Props; // Without Properties: unnecessary, causes type bugs + /** + * For type checking capabilities only. + * Does not exist at runtime. + * ### DO NOT USE! + */ + $$events_def: Events; + /** + * For type checking capabilities only. + * Does not exist at runtime. + * ### DO NOT USE! + */ + $$slot_def: Slots; + /** + * For type checking capabilities only. + * Does not exist at runtime. + * ### DO NOT USE! + */ + $$bindings?: string; + + /** + * @deprecated This method only exists when using one of the legacy compatibility helpers, which + * is a stop-gap solution. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) + * for more info. + */ + $destroy(): void; + + /** + * @deprecated This method only exists when using one of the legacy compatibility helpers, which + * is a stop-gap solution. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) + * for more info. + */ + $on>( + type: K, + callback: (e: Events[K]) => void + ): () => void; + + /** + * @deprecated This method only exists when using one of the legacy compatibility helpers, which + * is a stop-gap solution. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) + * for more info. + */ + $set(props: Partial): void; + } + + const brand: unique symbol; + type Brand = { [brand]: B }; + type Branded = T & Brand; + + /** + * Internal implementation details that vary between environments + */ + export type ComponentInternals = Branded<{}, 'ComponentInternals'>; + + /** + * Can be used to create strongly typed Svelte components. + * + * #### Example: + * + * You have component library on npm called `component-library`, from which + * you export a component called `MyComponent`. For Svelte+TypeScript users, + * you want to provide typings. Therefore you create a `index.d.ts`: + * ```ts + * import type { Component } from 'svelte'; + * export declare const MyComponent: Component<{ foo: string }> {} + * ``` + * Typing this makes it possible for IDEs like VS Code with the Svelte extension + * to provide intellisense and to use the component like this in a Svelte file + * with TypeScript: + * ```svelte + * + * + * ``` + */ + export interface Component< + Props extends Record = {}, + Exports extends Record = {}, + Bindings extends keyof Props | '' = string + > { + /** + * @param internal An internal object used by Svelte. Do not use or modify. + * @param props The props passed to the component. + */ + ( + this: void, + internals: ComponentInternals, + props: Props + ): { + /** + * @deprecated This method only exists when using one of the legacy compatibility helpers, which + * is a stop-gap solution. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) + * for more info. + */ + $on?(type: string, callback: (e: any) => void): () => void; + /** + * @deprecated This method only exists when using one of the legacy compatibility helpers, which + * is a stop-gap solution. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) + * for more info. + */ + $set?(props: Partial): void; + } & Exports; + /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */ + element?: typeof HTMLElement; + /** Does not exist at runtime, for typing capabilities only. DO NOT USE */ + z_$$bindings?: Bindings; + } + + /** + * @deprecated Use `Component` instead. See [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes) for more information. + */ + export class SvelteComponentTyped< + Props extends Record = Record, + Events extends Record = any, + Slots extends Record = any + > extends SvelteComponent {} + + /** + * @deprecated The new `Component` type does not have a dedicated Events type. Use `ComponentProps` instead. + * + * @description + * Convenience type to get the events the given component expects. Example: + * ```html + * + * + * + * ``` + */ + export type ComponentEvents = + Comp extends SvelteComponent ? Events : never; + + /** + * Convenience type to get the props the given component expects. + * + * Example: Ensure a variable contains the props expected by `MyComponent`: + * + * ```ts + * import type { ComponentProps } from 'svelte'; + * import MyComponent from './MyComponent.svelte'; + * + * // Errors if these aren't the correct props expected by MyComponent. + * const props: ComponentProps = { foo: 'bar' }; + * ``` + * + * > [!NOTE] In Svelte 4, you would do `ComponentProps` because `MyComponent` was a class. + * + * Example: A generic function that accepts some component and infers the type of its props: + * + * ```ts + * import type { Component, ComponentProps } from 'svelte'; + * import MyComponent from './MyComponent.svelte'; + * + * function withProps>( + * component: TComponent, + * props: ComponentProps + * ) {}; + * + * // Errors if the second argument is not the correct props expected by the component in the first argument. + * withProps(MyComponent, { foo: 'bar' }); + * ``` + */ + export type ComponentProps> = + Comp extends SvelteComponent + ? Props + : Comp extends Component + ? Props + : never; + + /** + * @deprecated This type is obsolete when working with the new `Component` type. + * + * @description + * Convenience type to get the type of a Svelte component. Useful for example in combination with + * dynamic components using ``. + * + * Example: + * ```html + * + * + * + * + * ``` + */ + export type ComponentType = (new ( + options: ComponentConstructorOptions< + Comp extends SvelteComponent ? Props : Record + > + ) => Comp) & { + /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */ + element?: typeof HTMLElement; + }; + + const SnippetReturn: unique symbol; + + // Use an interface instead of a type, makes for better intellisense info because the type is named in more situations. + /** + * The type of a `#snippet` block. You can use it to (for example) express that your component expects a snippet of a certain type: + * ```ts + * let { banner }: { banner: Snippet<[{ text: string }]> } = $props(); + * ``` + * You can only call a snippet through the `{@render ...}` tag. + * + * https://svelte.dev/docs/svelte/snippet + * + * @template Parameters the parameters that the snippet expects (if any) as a tuple. + */ + export interface Snippet { + ( + this: void, + // this conditional allows tuples but not arrays. Arrays would indicate a + // rest parameter type, which is not supported. If rest parameters are added + // in the future, the condition can be removed. + ...args: number extends Parameters['length'] ? never : Parameters + ): { + '{@render ...} must be called with a Snippet': "import type { Snippet } from 'svelte'"; + } & typeof SnippetReturn; + } + + interface DispatchOptions { + cancelable?: boolean; + } + + export interface EventDispatcher> { + // Implementation notes: + // - undefined extends X instead of X extends undefined makes this work better with both strict and nonstrict mode + // - | null | undefined is added for convenience, as they are equivalent for the custom event constructor (both result in a null detail) + ( + ...args: null extends EventMap[Type] + ? [type: Type, parameter?: EventMap[Type] | null | undefined, options?: DispatchOptions] + : undefined extends EventMap[Type] + ? [type: Type, parameter?: EventMap[Type] | null | undefined, options?: DispatchOptions] + : [type: Type, parameter: EventMap[Type], options?: DispatchOptions] + ): boolean; + } + + /** + * Defines the options accepted by the `mount()` function. + */ + export type MountOptions = Record> = { + /** + * Target element where the component will be mounted. + */ + target: Document | Element | ShadowRoot; + /** + * Optional node inside `target`. When specified, it is used to render the component immediately before it. + */ + anchor?: Node; + /** + * Allows the specification of events. + * @deprecated Use callback props instead. + */ + events?: Record any>; + /** + * Can be accessed via `getContext()` at the component level. + */ + context?: Map; + /** + * Whether or not to play transitions on initial render. + * @default true + */ + intro?: boolean; + } & ({} extends Props + ? { + /** + * Component properties. + */ + props?: Props; + } + : { + /** + * Component properties. + */ + props: Props; + }); + /** + * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM. + * It must be called during the component's initialisation (but doesn't need to live *inside* the component; + * it can be called from an external module). + * + * If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted. + * + * `onMount` does not run inside [server-side components](https://svelte.dev/docs/svelte/svelte-server#render). + * + * */ + export function onMount(fn: () => NotFunction | Promise> | (() => any)): void; + /** + * Schedules a callback to run immediately before the component is unmounted. + * + * Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the + * only one that runs inside a server-side component. + * + * */ + export function onDestroy(fn: () => any): void; + /** + * Creates an event dispatcher that can be used to dispatch [component events](https://svelte.dev/docs/svelte/legacy-on#Component-events). + * Event dispatchers are functions that can take two arguments: `name` and `detail`. + * + * Component events created with `createEventDispatcher` create a + * [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent). + * These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture). + * The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail) + * property and can contain any type of data. + * + * The event dispatcher can be typed to narrow the allowed event names and the type of the `detail` argument: + * ```ts + * const dispatch = createEventDispatcher<{ + * loaded: never; // does not take a detail argument + * change: string; // takes a detail argument of type string, which is required + * optional: number | null; // takes an optional detail argument of type number + * }>(); + * ``` + * + * @deprecated Use callback props and/or the `$host()` rune instead — see [migration guide](https://svelte.dev/docs/svelte/v5-migration-guide#Event-changes-Component-events) + * */ + export function createEventDispatcher = any>(): EventDispatcher; + /** + * Schedules a callback to run immediately before the component is updated after any state change. + * + * The first time the callback runs will be before the initial `onMount`. + * + * In runes mode use `$effect.pre` instead. + * + * @deprecated Use [`$effect.pre`](https://svelte.dev/docs/svelte/$effect#$effect.pre) instead + * */ + export function beforeUpdate(fn: () => void): void; + /** + * Schedules a callback to run immediately after the component has been updated. + * + * The first time the callback runs will be after the initial `onMount`. + * + * In runes mode use `$effect` instead. + * + * @deprecated Use [`$effect`](https://svelte.dev/docs/svelte/$effect) instead + * */ + export function afterUpdate(fn: () => void): void; + /** + * Synchronously flushes any pending state changes and those that result from it. + * */ + export function flushSync(fn?: (() => void) | undefined): void; + /** + * Create a snippet programmatically + * */ + export function createRawSnippet(fn: (...params: Getters) => { + render: () => string; + setup?: (element: Element) => void | (() => void); + }): Snippet; + /** Anything except a function */ + type NotFunction = T extends Function ? never : T; + /** + * Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component. + * Transitions will play during the initial render unless the `intro` option is set to `false`. + * + * */ + export function mount, Exports extends Record>(component: ComponentType> | Component, options: MountOptions): Exports; + /** + * Hydrates a component on the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component + * + * */ + export function hydrate, Exports extends Record>(component: ComponentType> | Component, options: {} extends Props ? { + target: Document | Element | ShadowRoot; + props?: Props; + events?: Record any>; + context?: Map; + intro?: boolean; + recover?: boolean; + } : { + target: Document | Element | ShadowRoot; + props: Props; + events?: Record any>; + context?: Map; + intro?: boolean; + recover?: boolean; + }): Exports; + /** + * Unmounts a component that was previously mounted using `mount` or `hydrate`. + * + * Since 5.13.0, if `options.outro` is `true`, [transitions](https://svelte.dev/docs/svelte/transition) will play before the component is removed from the DOM. + * + * Returns a `Promise` that resolves after transitions have completed if `options.outro` is true, or immediately otherwise (prior to 5.13.0, returns `void`). + * + * ```js + * import { mount, unmount } from 'svelte'; + * import App from './App.svelte'; + * + * const app = mount(App, { target: document.body }); + * + * // later... + * unmount(app, { outro: true }); + * ``` + * */ + export function unmount(component: Record, options?: { + outro?: boolean; + } | undefined): Promise; + /** + * Returns a promise that resolves once any pending state changes have been applied. + * */ + export function tick(): Promise; + /** + * When used inside a [`$derived`](https://svelte.dev/docs/svelte/$derived) or [`$effect`](https://svelte.dev/docs/svelte/$effect), + * any state read inside `fn` will not be treated as a dependency. + * + * ```ts + * $effect(() => { + * // this will run when `data` changes, but not when `time` changes + * save(data, { + * timestamp: untrack(() => time) + * }); + * }); + * ``` + * */ + export function untrack(fn: () => T): T; + /** + * Retrieves the context that belongs to the closest parent component with the specified `key`. + * Must be called during component initialisation. + * + * */ + export function getContext(key: any): T; + /** + * Associates an arbitrary `context` object with the current component and the specified `key` + * and returns that object. The context is then available to children of the component + * (including slotted content) with `getContext`. + * + * Like lifecycle functions, this must be called during component initialisation. + * + * */ + export function setContext(key: any, context: T): T; + /** + * Checks whether a given `key` has been set in the context of a parent component. + * Must be called during component initialisation. + * + * */ + export function hasContext(key: any): boolean; + /** + * Retrieves the whole context map that belongs to the closest parent component. + * Must be called during component initialisation. Useful, for example, if you + * programmatically create a component and want to pass the existing context to it. + * + * */ + export function getAllContexts = Map>(): T; + type Getters = { + [K in keyof T]: () => T[K]; + }; + + export {}; +} + +declare module 'svelte/action' { + /** + * Actions can return an object containing the two properties defined in this interface. Both are optional. + * - update: An action can have a parameter. This method will be called whenever that parameter changes, + * immediately after Svelte has applied updates to the markup. `ActionReturn` and `ActionReturn` both + * mean that the action accepts no parameters. + * - destroy: Method that is called after the element is unmounted + * + * Additionally, you can specify which additional attributes and events the action enables on the applied element. + * This applies to TypeScript typings only and has no effect at runtime. + * + * Example usage: + * ```ts + * interface Attributes { + * newprop?: string; + * 'on:event': (e: CustomEvent) => void; + * } + * + * export function myAction(node: HTMLElement, parameter: Parameter): ActionReturn { + * // ... + * return { + * update: (updatedParameter) => {...}, + * destroy: () => {...} + * }; + * } + * ``` + */ + export interface ActionReturn< + Parameter = undefined, + Attributes extends Record = Record + > { + update?: (parameter: Parameter) => void; + destroy?: () => void; + /** + * ### DO NOT USE THIS + * This exists solely for type-checking and has no effect at runtime. + * Set this through the `Attributes` generic instead. + */ + $$_attributes?: Attributes; + } + + /** + * Actions are functions that are called when an element is created. + * You can use this interface to type such actions. + * The following example defines an action that only works on `
` elements + * and optionally accepts a parameter which it has a default value for: + * ```ts + * export const myAction: Action = (node, param = { someProperty: true }) => { + * // ... + * } + * ``` + * `Action` and `Action` both signal that the action accepts no parameters. + * + * You can return an object with methods `update` and `destroy` from the function and type which additional attributes and events it has. + * See interface `ActionReturn` for more details. + */ + export interface Action< + Element = HTMLElement, + Parameter = undefined, + Attributes extends Record = Record + > { + ( + ...args: undefined extends Parameter + ? [node: Node, parameter?: Parameter] + : [node: Node, parameter: Parameter] + ): void | ActionReturn; + } + + // Implementation notes: + // - undefined extends X instead of X extends undefined makes this work better with both strict and nonstrict mode + + export {}; +} + +declare module 'svelte/animate' { + // todo: same as Transition, should it be shared? + export interface AnimationConfig { + delay?: number; + duration?: number; + easing?: (t: number) => number; + css?: (t: number, u: number) => string; + tick?: (t: number, u: number) => void; + } + + export interface FlipParams { + delay?: number; + duration?: number | ((len: number) => number); + easing?: (t: number) => number; + } + /** + * The flip function calculates the start and end position of an element and animates between them, translating the x and y values. + * `flip` stands for [First, Last, Invert, Play](https://aerotwist.com/blog/flip-your-animations/). + * + * */ + export function flip(node: Element, { from, to }: { + from: DOMRect; + to: DOMRect; + }, params?: FlipParams): AnimationConfig; + + export {}; +} + +declare module 'svelte/compiler' { + import type { Expression, Identifier, ArrayExpression, ArrowFunctionExpression, VariableDeclaration, VariableDeclarator, MemberExpression, Node, ObjectExpression, Pattern, Program, ChainExpression, SimpleCallExpression, SequenceExpression } from 'estree'; + import type { SourceMap } from 'magic-string'; + import type { Location } from 'locate-character'; + /** + * `compile` converts your `.svelte` source code into a JavaScript module that exports a component + * + * @param source The component source code + * @param options The compiler options + * */ + export function compile(source: string, options: CompileOptions): CompileResult; + /** + * `compileModule` takes your JavaScript source code containing runes, and turns it into a JavaScript module. + * + * @param source The component source code + * */ + export function compileModule(source: string, options: ModuleCompileOptions): CompileResult; + /** + * The parse function parses a component, returning only its abstract syntax tree. + * + * The `modern` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST. + * `modern` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7. + * + * */ + export function parse(source: string, options: { + filename?: string; + modern: true; + loose?: boolean; + }): AST.Root; + /** + * The parse function parses a component, returning only its abstract syntax tree. + * + * The `modern` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST. + * `modern` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7. + * + * */ + export function parse(source: string, options?: { + filename?: string; + modern?: false; + loose?: boolean; + } | undefined): Record; + /** + * @deprecated Replace this with `import { walk } from 'estree-walker'` + * */ + export function walk(): never; + /** + * The result of a preprocessor run. If the preprocessor does not return a result, it is assumed that the code is unchanged. + */ + export interface Processed { + /** + * The new code + */ + code: string; + /** + * A source map mapping back to the original code + */ + map?: string | object; // we are opaque with the type here to avoid dependency on the remapping module for our public types. + /** + * A list of additional files to watch for changes + */ + dependencies?: string[]; + /** + * Only for script/style preprocessors: The updated attributes to set on the tag. If undefined, attributes stay unchanged. + */ + attributes?: Record; + toString?: () => string; + } + + /** + * A markup preprocessor that takes a string of code and returns a processed version. + */ + export type MarkupPreprocessor = (options: { + /** + * The whole Svelte file content + */ + content: string; + /** + * The filename of the Svelte file + */ + filename?: string; + }) => Processed | void | Promise; + + /** + * A script/style preprocessor that takes a string of code and returns a processed version. + */ + export type Preprocessor = (options: { + /** + * The script/style tag content + */ + content: string; + /** + * The attributes on the script/style tag + */ + attributes: Record; + /** + * The whole Svelte file content + */ + markup: string; + /** + * The filename of the Svelte file + */ + filename?: string; + }) => Processed | void | Promise; + + /** + * A preprocessor group is a set of preprocessors that are applied to a Svelte file. + */ + export interface PreprocessorGroup { + /** Name of the preprocessor. Will be a required option in the next major version */ + name?: string; + markup?: MarkupPreprocessor; + style?: Preprocessor; + script?: Preprocessor; + } + /** The return value of `compile` from `svelte/compiler` */ + export interface CompileResult { + /** The compiled JavaScript */ + js: { + /** The generated code */ + code: string; + /** A source map */ + map: SourceMap; + }; + /** The compiled CSS */ + css: null | { + /** The generated code */ + code: string; + /** A source map */ + map: SourceMap; + }; + /** + * An array of warning objects that were generated during compilation. Each warning has several properties: + * - `code` is a string identifying the category of warning + * - `message` describes the issue in human-readable terms + * - `start` and `end`, if the warning relates to a specific location, are objects with `line`, `column` and `character` properties + */ + warnings: Warning[]; + /** + * Metadata about the compiled component + */ + metadata: { + /** + * Whether the file was compiled in runes mode, either because of an explicit option or inferred from usage. + * For `compileModule`, this is always `true` + */ + runes: boolean; + }; + /** The AST */ + ast: any; + } + + export interface Warning extends ICompileDiagnostic {} + + export interface CompileError extends ICompileDiagnostic {} + + type CssHashGetter = (args: { + name: string; + filename: string; + css: string; + hash: (input: string) => string; + }) => string; + + export interface CompileOptions extends ModuleCompileOptions { + /** + * Sets the name of the resulting JavaScript class (though the compiler will rename it if it would otherwise conflict with other variables in scope). + * If unspecified, will be inferred from `filename` + */ + name?: string; + /** + * If `true`, tells the compiler to generate a custom element constructor instead of a regular Svelte component. + * + * @default false + */ + customElement?: boolean; + /** + * If `true`, getters and setters will be created for the component's props. If `false`, they will only be created for readonly exported values (i.e. those declared with `const`, `class` and `function`). If compiling with `customElement: true` this option defaults to `true`. + * + * @default false + * @deprecated This will have no effect in runes mode + */ + accessors?: boolean; + /** + * The namespace of the element; e.g., `"html"`, `"svg"`, `"mathml"`. + * + * @default 'html' + */ + namespace?: Namespace; + /** + * If `true`, tells the compiler that you promise not to mutate any objects. + * This allows it to be less conservative about checking whether values have changed. + * + * @default false + * @deprecated This will have no effect in runes mode + */ + immutable?: boolean; + /** + * - `'injected'`: styles will be included in the `head` when using `render(...)`, and injected into the document (if not already present) when the component mounts. For components compiled as custom elements, styles are injected to the shadow root. + * - `'external'`: the CSS will only be returned in the `css` field of the compilation result. Most Svelte bundler plugins will set this to `'external'` and use the CSS that is statically generated for better performance, as it will result in smaller JavaScript bundles and the output can be served as cacheable `.css` files. + * This is always `'injected'` when compiling with `customElement` mode. + */ + css?: 'injected' | 'external'; + /** + * A function that takes a `{ hash, css, name, filename }` argument and returns the string that is used as a classname for scoped CSS. + * It defaults to returning `svelte-${hash(css)}`. + * + * @default undefined + */ + cssHash?: CssHashGetter; + /** + * If `true`, your HTML comments will be preserved in the output. By default, they are stripped out. + * + * @default false + */ + preserveComments?: boolean; + /** + * If `true`, whitespace inside and between elements is kept as you typed it, rather than removed or collapsed to a single space where possible. + * + * @default false + */ + preserveWhitespace?: boolean; + /** + * Set to `true` to force the compiler into runes mode, even if there are no indications of runes usage. + * Set to `false` to force the compiler into ignoring runes, even if there are indications of runes usage. + * Set to `undefined` (the default) to infer runes mode from the component code. + * Is always `true` for JS/TS modules compiled with Svelte. + * Will be `true` by default in Svelte 6. + * Note that setting this to `true` in your `svelte.config.js` will force runes mode for your entire project, including components in `node_modules`, + * which is likely not what you want. If you're using Vite, consider using [dynamicCompileOptions](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#dynamiccompileoptions) instead. + * @default undefined + */ + runes?: boolean | undefined; + /** + * If `true`, exposes the Svelte major version in the browser by adding it to a `Set` stored in the global `window.__svelte.v`. + * + * @default true + */ + discloseVersion?: boolean; + /** + * @deprecated Use these only as a temporary solution before migrating your code + */ + compatibility?: { + /** + * Applies a transformation so that the default export of Svelte files can still be instantiated the same way as in Svelte 4 — + * as a class when compiling for the browser (as though using `createClassComponent(MyComponent, {...})` from `svelte/legacy`) + * or as an object with a `.render(...)` method when compiling for the server + * @default 5 + */ + componentApi?: 4 | 5; + }; + /** + * An initial sourcemap that will be merged into the final output sourcemap. + * This is usually the preprocessor sourcemap. + * + * @default null + */ + sourcemap?: object | string; + /** + * Used for your JavaScript sourcemap. + * + * @default null + */ + outputFilename?: string; + /** + * Used for your CSS sourcemap. + * + * @default null + */ + cssOutputFilename?: string; + /** + * If `true`, compiles components with hot reloading support. + * + * @default false + */ + hmr?: boolean; + /** + * If `true`, returns the modern version of the AST. + * Will become `true` by default in Svelte 6, and the option will be removed in Svelte 7. + * + * @default false + */ + modernAst?: boolean; + } + + export interface ModuleCompileOptions { + /** + * If `true`, causes extra code to be added that will perform runtime checks and provide debugging information during development. + * + * @default false + */ + dev?: boolean; + /** + * If `"client"`, Svelte emits code designed to run in the browser. + * If `"server"`, Svelte emits code suitable for server-side rendering. + * If `false`, nothing is generated. Useful for tooling that is only interested in warnings. + * + * @default 'client' + */ + generate?: 'client' | 'server' | false; + /** + * Used for debugging hints and sourcemaps. Your bundler plugin will set it automatically. + */ + filename?: string; + /** + * Used for ensuring filenames don't leak filesystem information. Your bundler plugin will set it automatically. + * @default process.cwd() on node-like environments, undefined elsewhere + */ + rootDir?: string; + /** + * A function that gets a `Warning` as an argument and returns a boolean. + * Use this to filter out warnings. Return `true` to keep the warning, `false` to discard it. + */ + warningFilter?: (warning: Warning) => boolean; + } + /** + * - `html` — the default, for e.g. `
` or `` + * - `svg` — for e.g. `` or `` + * - `mathml` — for e.g. `` or `` + */ + type Namespace = 'html' | 'svg' | 'mathml'; + + export namespace AST { + export interface BaseNode { + type: string; + start: number; + end: number; + } + + export interface Fragment { + type: 'Fragment'; + nodes: Array; + } + + export interface Root extends BaseNode { + type: 'Root'; + /** + * Inline options provided by `` — these override options passed to `compile(...)` + */ + options: SvelteOptions | null; + fragment: Fragment; + /** The parsed `(fn: () => U, options?: SpringOpts): Spring; + + /** + * Sets `spring.target` to `value` and returns a `Promise` that resolves if and when `spring.current` catches up to it. + * + * If `options.instant` is `true`, `spring.current` immediately matches `spring.target`. + * + * If `options.preserveMomentum` is provided, the spring will continue on its current trajectory for + * the specified number of milliseconds. This is useful for things like 'fling' gestures. + */ + set(value: T, options?: SpringUpdateOpts): Promise; + + damping: number; + precision: number; + stiffness: number; + /** + * The end value of the spring. + * This property only exists on the `Spring` class, not the legacy `spring` store. + */ + target: T; + /** + * The current value of the spring. + * This property only exists on the `Spring` class, not the legacy `spring` store. + */ + get current(): T; + } + + export interface Tweened extends Readable { + set(value: T, opts?: TweenedOptions): Promise; + update(updater: Updater, opts?: TweenedOptions): Promise; + } + /** Callback to inform of a value updates. */ + type Subscriber = (value: T) => void; + + /** Unsubscribes from value updates. */ + type Unsubscriber = () => void; + + /** Readable interface for subscribing. */ + interface Readable { + /** + * Subscribe on value changes. + * @param run subscription callback + * @param invalidate cleanup callback + */ + subscribe(this: void, run: Subscriber, invalidate?: () => void): Unsubscriber; + } + interface SpringOpts { + stiffness?: number; + damping?: number; + precision?: number; + } + + interface SpringUpdateOpts { + /** + * @deprecated Only use this for the spring store; does nothing when set on the Spring class + */ + hard?: any; + /** + * @deprecated Only use this for the spring store; does nothing when set on the Spring class + */ + soft?: string | number | boolean; + /** + * Only use this for the Spring class; does nothing when set on the spring store + */ + instant?: boolean; + /** + * Only use this for the Spring class; does nothing when set on the spring store + */ + preserveMomentum?: number; + } + + type Updater = (target_value: T, value: T) => T; + + interface TweenedOptions { + delay?: number; + duration?: number | ((from: T, to: T) => number); + easing?: (t: number) => number; + interpolate?: (a: T, b: T) => (t: number) => T; + } + /** + * A [media query](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery) that matches if the user [prefers reduced motion](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion). + * + * ```svelte + * + * + * + * + * {#if visible} + *

+ * flies in, unless the user prefers reduced motion + *

+ * {/if} + * ``` + * @since 5.7.0 + */ + export const prefersReducedMotion: MediaQuery; + /** + * The spring function in Svelte creates a store whose value is animated, with a motion that simulates the behavior of a spring. This means when the value changes, instead of transitioning at a steady rate, it "bounces" like a spring would, depending on the physics parameters provided. This adds a level of realism to the transitions and can enhance the user experience. + * + * @deprecated Use [`Spring`](https://svelte.dev/docs/svelte/svelte-motion#Spring) instead + * */ + export function spring(value?: T | undefined, opts?: SpringOpts | undefined): Spring; + /** + * A tweened store in Svelte is a special type of store that provides smooth transitions between state values over time. + * + * @deprecated Use [`Tween`](https://svelte.dev/docs/svelte/svelte-motion#Tween) instead + * */ + export function tweened(value?: T | undefined, defaults?: TweenedOptions | undefined): Tweened; + /** + * A wrapper for a value that tweens smoothly to its target value. Changes to `tween.target` will cause `tween.current` to + * move towards it over time, taking account of the `delay`, `duration` and `easing` options. + * + * ```svelte + * + * + * + * + * ``` + * @since 5.8.0 + */ + export class Tween { + /** + * Create a tween whose value is bound to the return value of `fn`. This must be called + * inside an effect root (for example, during component initialisation). + * + * ```svelte + * + * ``` + * + */ + static of(fn: () => U, options?: TweenedOptions | undefined): Tween; + + constructor(value: T, options?: TweenedOptions); + /** + * Sets `tween.target` to `value` and returns a `Promise` that resolves if and when `tween.current` catches up to it. + * + * If `options` are provided, they will override the tween's defaults. + * */ + set(value: T, options?: TweenedOptions | undefined): Promise; + get current(): T; + set target(v: T); + get target(): T; + #private; + } + + export {}; +} + +declare module 'svelte/reactivity' { + export class SvelteDate extends Date { + + constructor(...params: any[]); + #private; + } + export class SvelteSet extends Set { + + constructor(value?: Iterable | null | undefined); + + add(value: T): this; + #private; + } + export class SvelteMap extends Map { + + constructor(value?: Iterable | null | undefined); + + set(key: K, value: V): this; + #private; + } + export class SvelteURL extends URL { + get searchParams(): SvelteURLSearchParams; + #private; + } + const REPLACE: unique symbol; + export class SvelteURLSearchParams extends URLSearchParams { + + [REPLACE](params: URLSearchParams): void; + #private; + } + /** + * Creates a media query and provides a `current` property that reflects whether or not it matches. + * + * Use it carefully — during server-side rendering, there is no way to know what the correct value should be, potentially causing content to change upon hydration. + * If you can use the media query in CSS to achieve the same effect, do that. + * + * ```svelte + * + * + *

{large.current ? 'large screen' : 'small screen'}

+ * ``` + * @extends {ReactiveValue} + * @since 5.7.0 + */ + export class MediaQuery extends ReactiveValue { + /** + * @param query A media query string + * @param fallback Fallback value for the server + */ + constructor(query: string, fallback?: boolean | undefined); + } + /** + * Returns a `subscribe` function that, if called in an effect (including expressions in the template), + * calls its `start` callback with an `update` function. Whenever `update` is called, the effect re-runs. + * + * If `start` returns a function, it will be called when the effect is destroyed. + * + * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects + * are active, and the returned teardown function will only be called when all effects are destroyed. + * + * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery): + * + * ```js + * import { createSubscriber } from 'svelte/reactivity'; + * import { on } from 'svelte/events'; + * + * export class MediaQuery { + * #query; + * #subscribe; + * + * constructor(query) { + * this.#query = window.matchMedia(`(${query})`); + * + * this.#subscribe = createSubscriber((update) => { + * // when the `change` event occurs, re-run any effects that read `this.current` + * const off = on(this.#query, 'change', update); + * + * // stop listening when all the effects are destroyed + * return () => off(); + * }); + * } + * + * get current() { + * this.#subscribe(); + * + * // Return the current state of the query, whether or not we're in an effect + * return this.#query.matches; + * } + * } + * ``` + * @since 5.7.0 + */ + export function createSubscriber(start: (update: () => void) => (() => void) | void): () => void; + class ReactiveValue { + + constructor(fn: () => T, onsubscribe: (update: () => void) => void); + get current(): T; + #private; + } + + export {}; +} + +declare module 'svelte/reactivity/window' { + /** + * `scrollX.current` is a reactive view of `window.scrollX`. On the server it is `undefined`. + * @since 5.11.0 + */ + export const scrollX: ReactiveValue; + /** + * `scrollY.current` is a reactive view of `window.scrollY`. On the server it is `undefined`. + * @since 5.11.0 + */ + export const scrollY: ReactiveValue; + /** + * `innerWidth.current` is a reactive view of `window.innerWidth`. On the server it is `undefined`. + * @since 5.11.0 + */ + export const innerWidth: ReactiveValue; + /** + * `innerHeight.current` is a reactive view of `window.innerHeight`. On the server it is `undefined`. + * @since 5.11.0 + */ + export const innerHeight: ReactiveValue; + /** + * `outerWidth.current` is a reactive view of `window.outerWidth`. On the server it is `undefined`. + * @since 5.11.0 + */ + export const outerWidth: ReactiveValue; + /** + * `outerHeight.current` is a reactive view of `window.outerHeight`. On the server it is `undefined`. + * @since 5.11.0 + */ + export const outerHeight: ReactiveValue; + /** + * `screenLeft.current` is a reactive view of `window.screenLeft`. It is updated inside a `requestAnimationFrame` callback. On the server it is `undefined`. + * @since 5.11.0 + */ + export const screenLeft: ReactiveValue; + /** + * `screenTop.current` is a reactive view of `window.screenTop`. It is updated inside a `requestAnimationFrame` callback. On the server it is `undefined`. + * @since 5.11.0 + */ + export const screenTop: ReactiveValue; + /** + * `online.current` is a reactive view of `navigator.onLine`. On the server it is `undefined`. + * @since 5.11.0 + */ + export const online: ReactiveValue; + /** + * `devicePixelRatio.current` is a reactive view of `window.devicePixelRatio`. On the server it is `undefined`. + * Note that behaviour differs between browsers — on Chrome it will respond to the current zoom level, + * on Firefox and Safari it won't. + * @since 5.11.0 + */ + export const devicePixelRatio: { + get current(): number | undefined; + }; + class ReactiveValue { + + constructor(fn: () => T, onsubscribe: (update: () => void) => void); + get current(): T; + #private; + } + + export {}; +} + +declare module 'svelte/server' { + import type { ComponentProps, Component, SvelteComponent, ComponentType } from 'svelte'; + /** + * Only available on the server and when compiling with the `server` option. + * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app. + */ + export function render< + Comp extends SvelteComponent | Component, + Props extends ComponentProps = ComponentProps + >( + ...args: {} extends Props + ? [ + component: Comp extends SvelteComponent ? ComponentType : Comp, + options?: { props?: Omit; context?: Map } + ] + : [ + component: Comp extends SvelteComponent ? ComponentType : Comp, + options: { props: Omit; context?: Map } + ] + ): RenderOutput; + interface RenderOutput { + /** HTML that goes into the `` */ + head: string; + /** @deprecated use `body` instead */ + html: string; + /** HTML that goes somewhere into the `` */ + body: string; + } + + export {}; +} + +declare module 'svelte/store' { + /** Callback to inform of a value updates. */ + export type Subscriber = (value: T) => void; + + /** Unsubscribes from value updates. */ + export type Unsubscriber = () => void; + + /** Callback to update a value. */ + export type Updater = (value: T) => T; + + /** + * Start and stop notification callbacks. + * This function is called when the first subscriber subscribes. + * + * @param set Function that sets the value of the store. + * @param update Function that sets the value of the store after passing the current value to the update function. + * @returns Optionally, a cleanup function that is called when the last remaining + * subscriber unsubscribes. + */ + export type StartStopNotifier = ( + set: (value: T) => void, + update: (fn: Updater) => void + ) => void | (() => void); + + /** Readable interface for subscribing. */ + export interface Readable { + /** + * Subscribe on value changes. + * @param run subscription callback + * @param invalidate cleanup callback + */ + subscribe(this: void, run: Subscriber, invalidate?: () => void): Unsubscriber; + } + + /** Writable interface for both updating and subscribing. */ + export interface Writable extends Readable { + /** + * Set value and inform subscribers. + * @param value to set + */ + set(this: void, value: T): void; + + /** + * Update value using callback and inform subscribers. + * @param updater callback + */ + update(this: void, updater: Updater): void; + } + export function toStore(get: () => V, set: (v: V) => void): Writable; + + export function toStore(get: () => V): Readable; + + export function fromStore(store: Writable): { + current: V; + }; + + export function fromStore(store: Readable): { + readonly current: V; + }; + /** + * Creates a `Readable` store that allows reading by subscription. + * + * @param value initial value + * */ + export function readable(value?: T | undefined, start?: StartStopNotifier | undefined): Readable; + /** + * Create a `Writable` store that allows both updating and reading by subscription. + * + * @param value initial value + * */ + export function writable(value?: T | undefined, start?: StartStopNotifier | undefined): Writable; + /** + * Derived value store by synchronizing one or more readable stores and + * applying an aggregation function over its input values. + * + * */ + export function derived(stores: S, fn: (values: StoresValues, set: (value: T) => void, update: (fn: Updater) => void) => Unsubscriber | void, initial_value?: T | undefined): Readable; + /** + * Derived value store by synchronizing one or more readable stores and + * applying an aggregation function over its input values. + * + * */ + export function derived(stores: S, fn: (values: StoresValues) => T, initial_value?: T | undefined): Readable; + /** + * Takes a store and returns a new one derived from the old one that is readable. + * + * @param store - store to make readonly + * */ + export function readonly(store: Readable): Readable; + /** + * Get the current value from a store by subscribing and immediately unsubscribing. + * + * */ + export function get(store: Readable): T; + /** One or more `Readable`s. */ + type Stores = Readable | [Readable, ...Array>] | Array>; + + /** One or more values from `Readable` stores. */ + type StoresValues = + T extends Readable ? U : { [K in keyof T]: T[K] extends Readable ? U : never }; + + export {}; +} + +declare module 'svelte/transition' { + export type EasingFunction = (t: number) => number; + + export interface TransitionConfig { + delay?: number; + duration?: number; + easing?: EasingFunction; + css?: (t: number, u: number) => string; + tick?: (t: number, u: number) => void; + } + + export interface BlurParams { + delay?: number; + duration?: number; + easing?: EasingFunction; + amount?: number | string; + opacity?: number; + } + + export interface FadeParams { + delay?: number; + duration?: number; + easing?: EasingFunction; + } + + export interface FlyParams { + delay?: number; + duration?: number; + easing?: EasingFunction; + x?: number | string; + y?: number | string; + opacity?: number; + } + + export interface SlideParams { + delay?: number; + duration?: number; + easing?: EasingFunction; + axis?: 'x' | 'y'; + } + + export interface ScaleParams { + delay?: number; + duration?: number; + easing?: EasingFunction; + start?: number; + opacity?: number; + } + + export interface DrawParams { + delay?: number; + speed?: number; + duration?: number | ((len: number) => number); + easing?: EasingFunction; + } + + export interface CrossfadeParams { + delay?: number; + duration?: number | ((len: number) => number); + easing?: EasingFunction; + } + /** + * Animates a `blur` filter alongside an element's opacity. + * + * */ + export function blur(node: Element, { delay, duration, easing, amount, opacity }?: BlurParams | undefined): TransitionConfig; + /** + * Animates the opacity of an element from 0 to the current opacity for `in` transitions and from the current opacity to 0 for `out` transitions. + * + * */ + export function fade(node: Element, { delay, duration, easing }?: FadeParams | undefined): TransitionConfig; + /** + * Animates the x and y positions and the opacity of an element. `in` transitions animate from the provided values, passed as parameters to the element's default values. `out` transitions animate from the element's default values to the provided values. + * + * */ + export function fly(node: Element, { delay, duration, easing, x, y, opacity }?: FlyParams | undefined): TransitionConfig; + /** + * Slides an element in and out. + * + * */ + export function slide(node: Element, { delay, duration, easing, axis }?: SlideParams | undefined): TransitionConfig; + /** + * Animates the opacity and scale of an element. `in` transitions animate from the provided values, passed as parameters, to an element's current (default) values. `out` transitions animate from an element's default values to the provided values. + * + * */ + export function scale(node: Element, { delay, duration, easing, start, opacity }?: ScaleParams | undefined): TransitionConfig; + /** + * Animates the stroke of an SVG element, like a snake in a tube. `in` transitions begin with the path invisible and draw the path to the screen over time. `out` transitions start in a visible state and gradually erase the path. `draw` only works with elements that have a `getTotalLength` method, like `` and ``. + * + * */ + export function draw(node: SVGElement & { + getTotalLength(): number; + }, { delay, speed, duration, easing }?: DrawParams | undefined): TransitionConfig; + /** + * The `crossfade` function creates a pair of [transitions](https://svelte.dev/docs/svelte/transition) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used. + * + * */ + export function crossfade({ fallback, ...defaults }: CrossfadeParams & { + fallback?: (node: Element, params: CrossfadeParams, intro: boolean) => TransitionConfig; + }): [(node: any, params: CrossfadeParams & { + key: any; + }) => () => TransitionConfig, (node: any, params: CrossfadeParams & { + key: any; + }) => () => TransitionConfig]; + + export {}; +} + +declare module 'svelte/events' { + // Once https://github.com/microsoft/TypeScript/issues/59980 is fixed we can put these overloads into the JSDoc comments of the `on` function + + /** + * Attaches an event handler to the window and returns a function that removes the handler. Using this + * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively + * (with attributes like `onclick`), which use event delegation for performance reasons + */ + export function on( + window: Window, + type: Type, + handler: (this: Window, event: WindowEventMap[Type]) => any, + options?: AddEventListenerOptions | undefined + ): () => void; + /** + * Attaches an event handler to the document and returns a function that removes the handler. Using this + * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively + * (with attributes like `onclick`), which use event delegation for performance reasons + */ + export function on( + document: Document, + type: Type, + handler: (this: Document, event: DocumentEventMap[Type]) => any, + options?: AddEventListenerOptions | undefined + ): () => void; + /** + * Attaches an event handler to an element and returns a function that removes the handler. Using this + * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively + * (with attributes like `onclick`), which use event delegation for performance reasons + */ + export function on( + element: Element, + type: Type, + handler: (this: Element, event: HTMLElementEventMap[Type]) => any, + options?: AddEventListenerOptions | undefined + ): () => void; + /** + * Attaches an event handler to an element and returns a function that removes the handler. Using this + * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively + * (with attributes like `onclick`), which use event delegation for performance reasons + */ + export function on( + element: Element, + type: Type, + handler: (this: Element, event: MediaQueryListEventMap[Type]) => any, + options?: AddEventListenerOptions | undefined + ): () => void; + /** + * Attaches an event handler to an element and returns a function that removes the handler. Using this + * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively + * (with attributes like `onclick`), which use event delegation for performance reasons + */ + export function on( + element: EventTarget, + type: string, + handler: EventListener, + options?: AddEventListenerOptions | undefined + ): () => void; + + export {}; +} + +declare module 'svelte/types/compiler/preprocess' { + /** @deprecated import this from 'svelte/preprocess' instead */ + export type MarkupPreprocessor = MarkupPreprocessor_1; + /** @deprecated import this from 'svelte/preprocess' instead */ + export type Preprocessor = Preprocessor_1; + /** @deprecated import this from 'svelte/preprocess' instead */ + export type PreprocessorGroup = PreprocessorGroup_1; + /** @deprecated import this from 'svelte/preprocess' instead */ + export type Processed = Processed_1; + /** @deprecated import this from 'svelte/preprocess' instead */ + export type SveltePreprocessor = SveltePreprocessor_1< + PreprocessorType, + Options + >; + /** + * The result of a preprocessor run. If the preprocessor does not return a result, it is assumed that the code is unchanged. + */ + interface Processed_1 { + /** + * The new code + */ + code: string; + /** + * A source map mapping back to the original code + */ + map?: string | object; // we are opaque with the type here to avoid dependency on the remapping module for our public types. + /** + * A list of additional files to watch for changes + */ + dependencies?: string[]; + /** + * Only for script/style preprocessors: The updated attributes to set on the tag. If undefined, attributes stay unchanged. + */ + attributes?: Record; + toString?: () => string; + } + + /** + * A markup preprocessor that takes a string of code and returns a processed version. + */ + type MarkupPreprocessor_1 = (options: { + /** + * The whole Svelte file content + */ + content: string; + /** + * The filename of the Svelte file + */ + filename?: string; + }) => Processed_1 | void | Promise; + + /** + * A script/style preprocessor that takes a string of code and returns a processed version. + */ + type Preprocessor_1 = (options: { + /** + * The script/style tag content + */ + content: string; + /** + * The attributes on the script/style tag + */ + attributes: Record; + /** + * The whole Svelte file content + */ + markup: string; + /** + * The filename of the Svelte file + */ + filename?: string; + }) => Processed_1 | void | Promise; + + /** + * A preprocessor group is a set of preprocessors that are applied to a Svelte file. + */ + interface PreprocessorGroup_1 { + /** Name of the preprocessor. Will be a required option in the next major version */ + name?: string; + markup?: MarkupPreprocessor_1; + style?: Preprocessor_1; + script?: Preprocessor_1; + } + + /** + * @description Utility type to extract the type of a preprocessor from a preprocessor group + * @deprecated Create this utility type yourself instead + */ + interface SveltePreprocessor_1< + PreprocessorType extends keyof PreprocessorGroup_1, + Options = any + > { + (options?: Options): Required>; + } + + export {}; +} + +declare module 'svelte/types/compiler/interfaces' { + import type { Location } from 'locate-character'; + /** @deprecated import this from 'svelte' instead */ + export type CompileOptions = CompileOptions_1; + /** @deprecated import this from 'svelte' instead */ + export type Warning = Warning_1; + interface Warning_1 extends ICompileDiagnostic {} + + type CssHashGetter = (args: { + name: string; + filename: string; + css: string; + hash: (input: string) => string; + }) => string; + + interface CompileOptions_1 extends ModuleCompileOptions { + /** + * Sets the name of the resulting JavaScript class (though the compiler will rename it if it would otherwise conflict with other variables in scope). + * If unspecified, will be inferred from `filename` + */ + name?: string; + /** + * If `true`, tells the compiler to generate a custom element constructor instead of a regular Svelte component. + * + * @default false + */ + customElement?: boolean; + /** + * If `true`, getters and setters will be created for the component's props. If `false`, they will only be created for readonly exported values (i.e. those declared with `const`, `class` and `function`). If compiling with `customElement: true` this option defaults to `true`. + * + * @default false + * @deprecated This will have no effect in runes mode + */ + accessors?: boolean; + /** + * The namespace of the element; e.g., `"html"`, `"svg"`, `"mathml"`. + * + * @default 'html' + */ + namespace?: Namespace; + /** + * If `true`, tells the compiler that you promise not to mutate any objects. + * This allows it to be less conservative about checking whether values have changed. + * + * @default false + * @deprecated This will have no effect in runes mode + */ + immutable?: boolean; + /** + * - `'injected'`: styles will be included in the `head` when using `render(...)`, and injected into the document (if not already present) when the component mounts. For components compiled as custom elements, styles are injected to the shadow root. + * - `'external'`: the CSS will only be returned in the `css` field of the compilation result. Most Svelte bundler plugins will set this to `'external'` and use the CSS that is statically generated for better performance, as it will result in smaller JavaScript bundles and the output can be served as cacheable `.css` files. + * This is always `'injected'` when compiling with `customElement` mode. + */ + css?: 'injected' | 'external'; + /** + * A function that takes a `{ hash, css, name, filename }` argument and returns the string that is used as a classname for scoped CSS. + * It defaults to returning `svelte-${hash(css)}`. + * + * @default undefined + */ + cssHash?: CssHashGetter; + /** + * If `true`, your HTML comments will be preserved in the output. By default, they are stripped out. + * + * @default false + */ + preserveComments?: boolean; + /** + * If `true`, whitespace inside and between elements is kept as you typed it, rather than removed or collapsed to a single space where possible. + * + * @default false + */ + preserveWhitespace?: boolean; + /** + * Set to `true` to force the compiler into runes mode, even if there are no indications of runes usage. + * Set to `false` to force the compiler into ignoring runes, even if there are indications of runes usage. + * Set to `undefined` (the default) to infer runes mode from the component code. + * Is always `true` for JS/TS modules compiled with Svelte. + * Will be `true` by default in Svelte 6. + * Note that setting this to `true` in your `svelte.config.js` will force runes mode for your entire project, including components in `node_modules`, + * which is likely not what you want. If you're using Vite, consider using [dynamicCompileOptions](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#dynamiccompileoptions) instead. + * @default undefined + */ + runes?: boolean | undefined; + /** + * If `true`, exposes the Svelte major version in the browser by adding it to a `Set` stored in the global `window.__svelte.v`. + * + * @default true + */ + discloseVersion?: boolean; + /** + * @deprecated Use these only as a temporary solution before migrating your code + */ + compatibility?: { + /** + * Applies a transformation so that the default export of Svelte files can still be instantiated the same way as in Svelte 4 — + * as a class when compiling for the browser (as though using `createClassComponent(MyComponent, {...})` from `svelte/legacy`) + * or as an object with a `.render(...)` method when compiling for the server + * @default 5 + */ + componentApi?: 4 | 5; + }; + /** + * An initial sourcemap that will be merged into the final output sourcemap. + * This is usually the preprocessor sourcemap. + * + * @default null + */ + sourcemap?: object | string; + /** + * Used for your JavaScript sourcemap. + * + * @default null + */ + outputFilename?: string; + /** + * Used for your CSS sourcemap. + * + * @default null + */ + cssOutputFilename?: string; + /** + * If `true`, compiles components with hot reloading support. + * + * @default false + */ + hmr?: boolean; + /** + * If `true`, returns the modern version of the AST. + * Will become `true` by default in Svelte 6, and the option will be removed in Svelte 7. + * + * @default false + */ + modernAst?: boolean; + } + + interface ModuleCompileOptions { + /** + * If `true`, causes extra code to be added that will perform runtime checks and provide debugging information during development. + * + * @default false + */ + dev?: boolean; + /** + * If `"client"`, Svelte emits code designed to run in the browser. + * If `"server"`, Svelte emits code suitable for server-side rendering. + * If `false`, nothing is generated. Useful for tooling that is only interested in warnings. + * + * @default 'client' + */ + generate?: 'client' | 'server' | false; + /** + * Used for debugging hints and sourcemaps. Your bundler plugin will set it automatically. + */ + filename?: string; + /** + * Used for ensuring filenames don't leak filesystem information. Your bundler plugin will set it automatically. + * @default process.cwd() on node-like environments, undefined elsewhere + */ + rootDir?: string; + /** + * A function that gets a `Warning` as an argument and returns a boolean. + * Use this to filter out warnings. Return `true` to keep the warning, `false` to discard it. + */ + warningFilter?: (warning: Warning_1) => boolean; + } + /** + * - `html` — the default, for e.g. `
` or `` + * - `svg` — for e.g. `` or `` + * - `mathml` — for e.g. `` or `` + */ + type Namespace = 'html' | 'svg' | 'mathml'; + type ICompileDiagnostic = { + code: string; + message: string; + stack?: string; + filename?: string; + start?: Location; + end?: Location; + position?: [number, number]; + frame?: string; + }; + + export {}; +}declare module '*.svelte' { + // use prettier-ignore for a while because of https://github.com/sveltejs/language-tools/commit/026111228b5814a9109cc4d779d37fb02955fb8b + // prettier-ignore + import { SvelteComponent } from 'svelte' + import { LegacyComponentType } from 'svelte/legacy'; + const Comp: LegacyComponentType; + type Comp = SvelteComponent; + export default Comp; +} + +/** + * Declares reactive state. + * + * Example: + * ```ts + * let count = $state(0); + * ``` + * + * https://svelte.dev/docs/svelte/$state + * + * @param initial The initial value + */ +declare function $state(initial: T): T; +declare function $state(): T | undefined; + +declare namespace $state { + type Primitive = string | number | boolean | null | undefined; + + type TypedArray = + | Int8Array + | Uint8Array + | Uint8ClampedArray + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + | Float32Array + | Float64Array + | BigInt64Array + | BigUint64Array; + + /** The things that `structuredClone` can handle — https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm */ + export type Cloneable = + | ArrayBuffer + | DataView + | Date + | Error + | Map + | RegExp + | Set + | TypedArray + // web APIs + | Blob + | CryptoKey + | DOMException + | DOMMatrix + | DOMMatrixReadOnly + | DOMPoint + | DOMPointReadOnly + | DOMQuad + | DOMRect + | DOMRectReadOnly + | File + | FileList + | FileSystemDirectoryHandle + | FileSystemFileHandle + | FileSystemHandle + | ImageBitmap + | ImageData + | RTCCertificate + | VideoFrame; + + /** Turn `SvelteDate`, `SvelteMap` and `SvelteSet` into their non-reactive counterparts. (`URL` is uncloneable.) */ + type NonReactive = T extends Date + ? Date + : T extends Map + ? Map + : T extends Set + ? Set + : T; + + type Snapshot = T extends Primitive + ? T + : T extends Cloneable + ? NonReactive + : T extends { toJSON(): infer R } + ? R + : T extends Array + ? Array> + : T extends object + ? T extends { [key: string]: any } + ? { [K in keyof T]: Snapshot } + : never + : never; + + /** + * Declares state that is _not_ made deeply reactive — instead of mutating it, + * you must reassign it. + * + * Example: + * ```ts + * + * + * + * ``` + * + * https://svelte.dev/docs/svelte/$state#$state.raw + * + * @param initial The initial value + */ + export function raw(initial: T): T; + export function raw(): T | undefined; + /** + * To take a static snapshot of a deeply reactive `$state` proxy, use `$state.snapshot`: + * + * Example: + * ```ts + * + * ``` + * + * https://svelte.dev/docs/svelte/$state#$state.snapshot + * + * @param state The value to snapshot + */ + export function snapshot(state: T): Snapshot; + + // prevent intellisense from being unhelpful + /** @deprecated */ + export const apply: never; + /** @deprecated */ + // @ts-ignore + export const arguments: never; + /** @deprecated */ + export const bind: never; + /** @deprecated */ + export const call: never; + /** @deprecated */ + export const caller: never; + /** @deprecated */ + export const length: never; + /** @deprecated */ + export const name: never; + /** @deprecated */ + export const prototype: never; + /** @deprecated */ + export const toString: never; +} + +/** + * Declares derived state, i.e. one that depends on other state variables. + * The expression inside `$derived(...)` should be free of side-effects. + * + * Example: + * ```ts + * let double = $derived(count * 2); + * ``` + * + * https://svelte.dev/docs/svelte/$derived + * + * @param expression The derived state expression + */ +declare function $derived(expression: T): T; + +declare namespace $derived { + /** + * Sometimes you need to create complex derivations that don't fit inside a short expression. + * In these cases, you can use `$derived.by` which accepts a function as its argument. + * + * Example: + * ```ts + * let total = $derived.by(() => { + * let result = 0; + * for (const n of numbers) { + * result += n; + * } + * return result; + * }); + * ``` + * + * https://svelte.dev/docs/svelte/$derived#$derived.by + */ + export function by(fn: () => T): T; + + // prevent intellisense from being unhelpful + /** @deprecated */ + export const apply: never; + /** @deprecated */ + // @ts-ignore + export const arguments: never; + /** @deprecated */ + export const bind: never; + /** @deprecated */ + export const call: never; + /** @deprecated */ + export const caller: never; + /** @deprecated */ + export const length: never; + /** @deprecated */ + export const name: never; + /** @deprecated */ + export const prototype: never; + /** @deprecated */ + export const toString: never; +} + +/** + * Runs code when a component is mounted to the DOM, and then whenever its dependencies change, i.e. `$state` or `$derived` values. + * The timing of the execution is after the DOM has been updated. + * + * Example: + * ```ts + * $effect(() => console.log('The count is now ' + count)); + * ``` + * + * If you return a function from the effect, it will be called right before the effect is run again, or when the component is unmounted. + * + * Does not run during server side rendering. + * + * https://svelte.dev/docs/svelte/$effect + * @param fn The function to execute + */ +declare function $effect(fn: () => void | (() => void)): void; + +declare namespace $effect { + /** + * Runs code right before a component is mounted to the DOM, and then whenever its dependencies change, i.e. `$state` or `$derived` values. + * The timing of the execution is right before the DOM is updated. + * + * Example: + * ```ts + * $effect.pre(() => console.log('The count is now ' + count)); + * ``` + * + * If you return a function from the effect, it will be called right before the effect is run again, or when the component is unmounted. + * + * Does not run during server side rendering. + * + * https://svelte.dev/docs/svelte/$effect#$effect.pre + * @param fn The function to execute + */ + export function pre(fn: () => void | (() => void)): void; + + /** + * The `$effect.tracking` rune is an advanced feature that tells you whether or not the code is running inside a tracking context, such as an effect or inside your template. + * + * Example: + * ```svelte + * + * + *

in template: {$effect.tracking()}

+ * ``` + * + * This allows you to (for example) add things like subscriptions without causing memory leaks, by putting them in child effects. + * + * https://svelte.dev/docs/svelte/$effect#$effect.tracking + */ + export function tracking(): boolean; + + /** + * The `$effect.root` rune is an advanced feature that creates a non-tracked scope that doesn't auto-cleanup. This is useful for + * nested effects that you want to manually control. This rune also allows for creation of effects outside of the component + * initialisation phase. + * + * Example: + * ```svelte + * + * + * + * ``` + * + * https://svelte.dev/docs/svelte/$effect#$effect.root + */ + export function root(fn: () => void | (() => void)): () => void; + + // prevent intellisense from being unhelpful + /** @deprecated */ + export const apply: never; + /** @deprecated */ + // @ts-ignore + export const arguments: never; + /** @deprecated */ + export const bind: never; + /** @deprecated */ + export const call: never; + /** @deprecated */ + export const caller: never; + /** @deprecated */ + export const length: never; + /** @deprecated */ + export const name: never; + /** @deprecated */ + export const prototype: never; + /** @deprecated */ + export const toString: never; +} + +/** + * Declares the props that a component accepts. Example: + * + * ```ts + * let { optionalProp = 42, requiredProp, bindableProp = $bindable() }: { optionalProp?: number; requiredProps: string; bindableProp: boolean } = $props(); + * ``` + * + * https://svelte.dev/docs/svelte/$props + */ +declare function $props(): any; + +/** + * Declares a prop as bindable, meaning the parent component can use `bind:propName={value}` to bind to it. + * + * ```ts + * let { propName = $bindable() }: { propName: boolean } = $props(); + * ``` + * + * https://svelte.dev/docs/svelte/$bindable + */ +declare function $bindable(fallback?: T): T; + +/** + * Inspects one or more values whenever they, or the properties they contain, change. Example: + * + * ```ts + * $inspect(someValue, someOtherValue) + * ``` + * + * `$inspect` returns a `with` function, which you can invoke with a callback function that + * will be called with the value and the event type (`'init'` or `'update'`) on every change. + * By default, the values will be logged to the console. + * + * ```ts + * $inspect(x).with(console.trace); + * $inspect(x, y).with(() => { debugger; }); + * ``` + * + * https://svelte.dev/docs/svelte/$inspect + */ +declare function $inspect( + ...values: T +): { with: (fn: (type: 'init' | 'update', ...values: T) => void) => void }; + +declare namespace $inspect { + /** + * Tracks which reactive state changes caused an effect to re-run. Must be the first + * statement of a function body. Example: + * + * ```svelte + * + */ + export function trace(name: string): void; +} + +/** + * Retrieves the `this` reference of the custom element that contains this component. Example: + * + * ```svelte + * + * + * + * + * + * ``` + * + * Only available inside custom element components, and only on the client-side. + * + * https://svelte.dev/docs/svelte/$host + */ +declare function $host(): El; + +//# sourceMappingURL=index.d.ts.map \ No newline at end of file From abadc6af034c624bad1f19b743a4f21e76083c3a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 17 Dec 2024 20:13:23 -0500 Subject: [PATCH 7/8] try this? --- pnpm-lock.yaml | 188 ++++++++++++++----------------------------------- 1 file changed, 52 insertions(+), 136 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c79c0dab30fa..1de6883a48ee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -85,7 +85,7 @@ importers: version: 1.2.1 esrap: specifier: ^1.3.1 - version: link:../../../../esrap + version: 1.3.1 is-reference: specifier: ^3.0.3 version: 3.0.3 @@ -405,20 +405,10 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 - '@eslint-community/eslint-utils@4.4.1': - resolution: {integrity: sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 - '@eslint-community/regexpp@4.11.0': resolution: {integrity: sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - '@eslint-community/regexpp@4.12.1': - resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==} - engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - '@eslint/config-array@0.18.0': resolution: {integrity: sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -785,11 +775,6 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - acorn@8.14.0: - resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} - engines: {node: '>=0.4.0'} - hasBin: true - agent-base@7.1.1: resolution: {integrity: sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==} engines: {node: '>= 14'} @@ -853,8 +838,8 @@ packages: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} - binary-extensions@2.3.0: - resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} + binary-extensions@2.2.0: + resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} engines: {node: '>=8'} brace-expansion@1.1.11: @@ -867,10 +852,6 @@ packages: resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} engines: {node: '>=8'} - braces@3.0.3: - resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} - engines: {node: '>=8'} - buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} @@ -901,8 +882,8 @@ packages: resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} engines: {node: '>= 16'} - chokidar@3.6.0: - resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} + chokidar@3.5.3: + resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} engines: {node: '>= 8.10.0'} ci-info@3.9.0: @@ -927,7 +908,7 @@ packages: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} cross-spawn@5.1.0: resolution: {integrity: sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==} @@ -961,15 +942,6 @@ packages: supports-color: optional: true - debug@4.4.0: - resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - decimal.js@10.4.3: resolution: {integrity: sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==} @@ -1139,6 +1111,9 @@ packages: resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} engines: {node: '>=0.10'} + esrap@1.3.1: + resolution: {integrity: sha512-KpAH3+QsDmtOP1KOW04CbD1PgzWsIHjB8tOCk3PCb8xzNGn8XkjI8zl80i09fmXdzQyaS8tcsKCCDzHF7AcowA==} + esrecurse@4.3.0: resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} engines: {node: '>=4.0'} @@ -1200,10 +1175,6 @@ packages: resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} engines: {node: '>=8'} - fill-range@7.1.1: - resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} - engines: {node: '>=8'} - find-up@4.1.0: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} engines: {node: '>=8'} @@ -1259,8 +1230,8 @@ packages: resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} engines: {node: '>=16'} - get-tsconfig@4.8.1: - resolution: {integrity: sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==} + get-tsconfig@4.7.6: + resolution: {integrity: sha512-ZAqrLlu18NbDdRaHq+AKXzAmqIUPswPWKUchfytdAjiRFnCe5ojG2bstg6mRiZabkKfCoL/e98pbBELIV/YCeA==} glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} @@ -1278,10 +1249,6 @@ packages: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} - globals@15.13.0: - resolution: {integrity: sha512-49TewVEz0UxZjr1WYYsWpPrhyC/B/pA8Bq0fUmet2n+eR7yn0IvNzNaoBwnK6mdkzcN+se7Ez9zUgULTz2QH4g==} - engines: {node: '>=18'} - globals@15.9.0: resolution: {integrity: sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==} engines: {node: '>=18'} @@ -1344,8 +1311,8 @@ packages: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} - immutable@4.3.7: - resolution: {integrity: sha512-1hqclzwYwjRDFLjcFxOM5AYkkG0rpFPpr1RLPMEuGczoS7YA8gLhy8SWXYRAA/XwfEHpfo3cw5JGioS32fnMRw==} + immutable@4.3.4: + resolution: {integrity: sha512-fsXeu4J4i6WNWSikpI88v/PcVflZz+6kMhUfIwc5SY+poQRPnaf5V7qds6SUyUN3cVxEzuCab7QIoLOQ+DQ1wA==} import-fresh@3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} @@ -1631,19 +1598,11 @@ packages: ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - ms@2.1.3: - resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - nanoid@3.3.8: - resolution: {integrity: sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==} - engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} - hasBin: true - natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} @@ -1763,9 +1722,6 @@ packages: picocolors@1.1.0: resolution: {integrity: sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==} - picocolors@1.1.1: - resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} - picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} @@ -1824,10 +1780,6 @@ packages: resolution: {integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==} engines: {node: ^10 || ^12 || >=14} - postcss@8.4.49: - resolution: {integrity: sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==} - engines: {node: ^10 || ^12 || >=14} - prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -2037,11 +1989,11 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} - svelte-eslint-parser@0.43.0: - resolution: {integrity: sha512-GpU52uPKKcVnh8tKN5P4UZpJ/fUDndmq7wfsvoVXsyP+aY0anol7Yqo01fyrlaWGMFfm4av5DyrjlaXdLRJvGA==} + svelte-eslint-parser@0.41.0: + resolution: {integrity: sha512-L6f4hOL+AbgfBIB52Z310pg1d2QjRqm7wy3kI1W6hhdhX5bvu7+f0R6w4ykp5HoDdzq+vGhIJmsisaiJDGmVfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: - svelte: ^3.37.0 || ^4.0.0 || ^5.0.0 + svelte: ^3.37.0 || ^4.0.0 || ^5.0.0-next.191 peerDependenciesMeta: svelte: optional: true @@ -2586,15 +2538,8 @@ snapshots: eslint: 9.9.1 eslint-visitor-keys: 3.4.3 - '@eslint-community/eslint-utils@4.4.1(eslint@9.9.1)': - dependencies: - eslint: 9.9.1 - eslint-visitor-keys: 3.4.3 - '@eslint-community/regexpp@4.11.0': {} - '@eslint-community/regexpp@4.12.1': {} - '@eslint/config-array@0.18.0': dependencies: '@eslint/object-schema': 2.1.4 @@ -2788,7 +2733,7 @@ snapshots: '@stylistic/eslint-plugin-js@1.8.0(eslint@9.9.1)': dependencies: '@types/eslint': 8.56.12 - acorn: 8.14.0 + acorn: 8.12.1 escape-string-regexp: 4.0.0 eslint: 9.9.1 eslint-visitor-keys: 3.4.3 @@ -2993,18 +2938,12 @@ snapshots: dependencies: acorn: 8.12.1 - acorn-jsx@5.3.2(acorn@8.14.0): - dependencies: - acorn: 8.14.0 - acorn-typescript@1.4.13(acorn@8.12.1): dependencies: acorn: 8.12.1 acorn@8.12.1: {} - acorn@8.14.0: {} - agent-base@7.1.1: dependencies: debug: 4.3.6 @@ -3058,7 +2997,7 @@ snapshots: dependencies: is-windows: 1.0.2 - binary-extensions@2.3.0: + binary-extensions@2.2.0: optional: true brace-expansion@1.1.11: @@ -3074,11 +3013,6 @@ snapshots: dependencies: fill-range: 7.0.1 - braces@3.0.3: - dependencies: - fill-range: 7.1.1 - optional: true - buffer-from@1.1.2: {} bundle-name@4.1.0: @@ -3106,10 +3040,10 @@ snapshots: check-error@2.1.1: {} - chokidar@3.6.0: + chokidar@3.5.3: dependencies: anymatch: 3.1.3 - braces: 3.0.3 + braces: 3.0.2 glob-parent: 5.1.2 is-binary-path: 2.1.0 is-glob: 4.0.3 @@ -3166,10 +3100,6 @@ snapshots: dependencies: ms: 2.1.2 - debug@4.4.0: - dependencies: - ms: 2.1.3 - decimal.js@10.4.3: {} deep-eql@5.0.2: {} @@ -3272,8 +3202,8 @@ snapshots: eslint-plugin-es-x@7.8.0(eslint@9.9.1): dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.9.1) - '@eslint-community/regexpp': 4.12.1 + '@eslint-community/eslint-utils': 4.4.0(eslint@9.9.1) + '@eslint-community/regexpp': 4.11.0 eslint: 9.9.1 eslint-compat-utils: 0.5.1(eslint@9.9.1) @@ -3281,31 +3211,31 @@ snapshots: eslint-plugin-n@17.9.0(eslint@9.9.1): dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.9.1) + '@eslint-community/eslint-utils': 4.4.0(eslint@9.9.1) enhanced-resolve: 5.17.1 eslint: 9.9.1 eslint-plugin-es-x: 7.8.0(eslint@9.9.1) - get-tsconfig: 4.8.1 - globals: 15.13.0 + get-tsconfig: 4.7.6 + globals: 15.9.0 ignore: 5.3.2 minimatch: 9.0.5 semver: 7.6.3 eslint-plugin-svelte@2.38.0(eslint@9.9.1)(svelte@packages+svelte): dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.9.1) + '@eslint-community/eslint-utils': 4.4.0(eslint@9.9.1) '@jridgewell/sourcemap-codec': 1.5.0 - debug: 4.4.0 + debug: 4.3.6 eslint: 9.9.1 eslint-compat-utils: 0.5.1(eslint@9.9.1) esutils: 2.0.3 known-css-properties: 0.30.0 - postcss: 8.4.49 - postcss-load-config: 3.1.4(postcss@8.4.49) - postcss-safe-parser: 6.0.0(postcss@8.4.49) + postcss: 8.4.47 + postcss-load-config: 3.1.4(postcss@8.4.47) + postcss-safe-parser: 6.0.0(postcss@8.4.47) postcss-selector-parser: 6.1.2 semver: 7.6.3 - svelte-eslint-parser: 0.43.0(svelte@packages+svelte) + svelte-eslint-parser: 0.41.0(svelte@packages+svelte) optionalDependencies: svelte: link:packages/svelte transitivePeerDependencies: @@ -3375,8 +3305,8 @@ snapshots: espree@9.6.1: dependencies: - acorn: 8.14.0 - acorn-jsx: 5.3.2(acorn@8.14.0) + acorn: 8.12.1 + acorn-jsx: 5.3.2(acorn@8.12.1) eslint-visitor-keys: 3.4.3 esprima@4.0.1: {} @@ -3385,6 +3315,11 @@ snapshots: dependencies: estraverse: 5.3.0 + esrap@1.3.1: + dependencies: + '@jridgewell/sourcemap-codec': 1.5.0 + '@typescript-eslint/types': 8.2.0 + esrecurse@4.3.0: dependencies: estraverse: 5.3.0 @@ -3449,11 +3384,6 @@ snapshots: dependencies: to-regex-range: 5.0.1 - fill-range@7.1.1: - dependencies: - to-regex-range: 5.0.1 - optional: true - find-up@4.1.0: dependencies: locate-path: 5.0.0 @@ -3512,7 +3442,7 @@ snapshots: get-stream@8.0.1: {} - get-tsconfig@4.8.1: + get-tsconfig@4.7.6: dependencies: resolve-pkg-maps: 1.0.0 @@ -3535,8 +3465,6 @@ snapshots: globals@14.0.0: {} - globals@15.13.0: {} - globals@15.9.0: {} globalyzer@0.1.0: {} @@ -3596,7 +3524,7 @@ snapshots: ignore@5.3.2: {} - immutable@4.3.7: + immutable@4.3.4: optional: true import-fresh@3.3.0: @@ -3608,7 +3536,7 @@ snapshots: is-binary-path@2.1.0: dependencies: - binary-extensions: 2.3.0 + binary-extensions: 2.2.0 optional: true is-core-module@2.13.1: @@ -3868,12 +3796,8 @@ snapshots: ms@2.1.2: {} - ms@2.1.3: {} - nanoid@3.3.7: {} - nanoid@3.3.8: {} - natural-compare@1.4.0: {} node-fetch@2.7.0: @@ -3972,8 +3896,6 @@ snapshots: picocolors@1.1.0: {} - picocolors@1.1.1: {} - picomatch@2.3.1: {} picomatch@4.0.2: {} @@ -3993,20 +3915,20 @@ snapshots: '@polka/url': 1.0.0-next.25 trouter: 4.0.0 - postcss-load-config@3.1.4(postcss@8.4.49): + postcss-load-config@3.1.4(postcss@8.4.47): dependencies: lilconfig: 2.1.0 yaml: 1.10.2 optionalDependencies: - postcss: 8.4.49 + postcss: 8.4.47 - postcss-safe-parser@6.0.0(postcss@8.4.49): + postcss-safe-parser@6.0.0(postcss@8.4.47): dependencies: - postcss: 8.4.49 + postcss: 8.4.47 - postcss-scss@4.0.9(postcss@8.4.49): + postcss-scss@4.0.9(postcss@8.4.47): dependencies: - postcss: 8.4.49 + postcss: 8.4.47 postcss-selector-parser@6.1.2: dependencies: @@ -4019,12 +3941,6 @@ snapshots: picocolors: 1.1.0 source-map-js: 1.2.1 - postcss@8.4.49: - dependencies: - nanoid: 3.3.8 - picocolors: 1.1.1 - source-map-js: 1.2.1 - prelude-ls@1.2.1: {} prettier-plugin-svelte@3.1.2(prettier@3.2.4)(svelte@packages+svelte): @@ -4116,8 +4032,8 @@ snapshots: sass@1.70.0: dependencies: - chokidar: 3.6.0 - immutable: 4.3.7 + chokidar: 3.5.3 + immutable: 4.3.4 source-map-js: 1.2.1 optional: true @@ -4213,13 +4129,13 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - svelte-eslint-parser@0.43.0(svelte@packages+svelte): + svelte-eslint-parser@0.41.0(svelte@packages+svelte): dependencies: eslint-scope: 7.2.2 eslint-visitor-keys: 3.4.3 espree: 9.6.1 - postcss: 8.4.49 - postcss-scss: 4.0.9(postcss@8.4.49) + postcss: 8.4.47 + postcss-scss: 4.0.9(postcss@8.4.47) optionalDependencies: svelte: link:packages/svelte From 3e5e7c3038ea87b73d26b1cda92f659ffcee9fa3 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 17 Dec 2024 20:17:36 -0500 Subject: [PATCH 8/8] prettier --- packages/svelte/tsconfig.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/svelte/tsconfig.json b/packages/svelte/tsconfig.json index 8852a4301c30..c9f0fb3b2bba 100644 --- a/packages/svelte/tsconfig.json +++ b/packages/svelte/tsconfig.json @@ -40,5 +40,9 @@ "./tests/runtime-browser/test-ssr.ts", "./tests/*/samples/*/_config.js" ], - "exclude": ["./scripts/process-messages/templates/", "./scripts/_bundle.js", "./src/compiler/optimizer/"] + "exclude": [ + "./scripts/process-messages/templates/", + "./scripts/_bundle.js", + "./src/compiler/optimizer/" + ] }