diff --git a/.eslintignore b/.eslintignore index d123c10530..67a89ff12c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,7 +4,7 @@ _output test/*/samples/*/output.js # automatically generated -internal_exports.ts +internal_exports.js # output files animate/*.js diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 72% rename from .eslintrc.js rename to .eslintrc.cjs index fff483ac0a..fe93fe6d36 100644 --- a/.eslintrc.js +++ b/.eslintrc.cjs @@ -1,6 +1,6 @@ module.exports = { root: true, - extends: ['@sveltejs', 'prettier'], + extends: ['@sveltejs'], settings: { 'import/core-modules': [ 'svelte', @@ -8,8 +8,7 @@ module.exports = { 'svelte/store', 'svelte/easing', 'estree' - ], - 'svelte3/compiler': require('./compiler') + ] }, rules: { '@typescript-eslint/no-non-null-assertion': 'off' diff --git a/.gitignore b/.gitignore index e70d995994..963ae9f26e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ .vscode node_modules *.map -/src/compiler/compile/internal_exports.ts +/src/compiler/compile/internal_exports.js /compiler.d.ts /compiler.*js /index.*js @@ -17,6 +17,7 @@ node_modules /animate /scratch/ /test/*/samples/_ +/test/runtime/shards /yarn-error.log _actual*.* _output diff --git a/.prettierignore b/.prettierignore index ea3ec75537..58dfd819cd 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,7 +2,7 @@ !/elements !/scripts !/src -src/compiler/compile/internal_exports.ts +src/compiler/compile/internal_exports.js !/test !documentation !sites @@ -12,3 +12,4 @@ src/compiler/compile/internal_exports.ts /test/**/expected* /test/**/_output /types +!vitest.config.js diff --git a/generate-types.mjs b/generate-types.mjs new file mode 100644 index 0000000000..707bf746fd --- /dev/null +++ b/generate-types.mjs @@ -0,0 +1,162 @@ +// This script generates the TypeScript definitions + +import { execSync } from 'child_process'; +import { readFileSync, writeFileSync, readdirSync, existsSync, copyFileSync, statSync } from 'fs'; + +execSync('tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly', { stdio: 'inherit' }); + +function modify(path, modifyFn) { + const content = readFileSync(path, 'utf8'); + writeFileSync(path, modifyFn(content)); +} + +function adjust(input) { + // Remove typedef jsdoc (duplicated in the type definition) + input = input.replace(/\/\*\*\n(\r)? \* @typedef .+?\*\//gs, ''); + input = input.replace(/\/\*\* @typedef .+?\*\//gs, ''); + + // Extract the import paths and types + const import_regex = /import\(("|')(.+?)("|')\)\.(\w+)/g; + let import_match; + const import_map = new Map(); + + while ((import_match = import_regex.exec(input)) !== null) { + const imports = import_map.get(import_match[2]) || new Map(); + let name = import_match[4]; + if ([...imports.keys()].includes(name)) continue; + + let i = 1; + if (name === 'default') { + name = import_match[2].split('/').pop().split('.').shift().replace(/[^a-z0-9]/gi, '_'); + } + while ([...import_map].some(([path, names]) => path !== import_match[2] && names.has(name))) { + name = `${name}${i++}`; + } + + imports.set(import_match[4], name); + import_map.set(import_match[2], imports); + } + + // Replace inline imports with their type names + const transformed = input.replace(import_regex, (_match, _quote, path, _quote2, name) => { + return import_map.get(path).get(name); + }); + + // Remove/adjust @template, @param and @returns lines + // TODO rethink if we really need to do this for @param and @returns, doesn't show up in hover so unnecessary + const lines = transformed.split("\n"); + + let filtered_lines = []; + let removing = null; + let openCount = 1; + let closedCount = 0; + + for (let line of lines) { + let start_removing = false; + if (line.trim().startsWith("* @template")) { + removing = "template"; + start_removing = true; + } + + if (line.trim().startsWith("* @param {")) { + openCount = 1; + closedCount = 0; + removing = "param"; + start_removing = true; + } + + if (line.trim().startsWith("* @returns {")) { + openCount = 1; + closedCount = 0; + removing = "returns"; + start_removing = true; + } + + if (removing === "returns" || removing === "param") { + let i = start_removing ? line.indexOf('{') + 1 : 0; + for (; i < line.length; i++) { + if (line[i] === "{") openCount++; + if (line[i] === "}") closedCount++; + if (openCount === closedCount) break; + } + if (openCount === closedCount) { + line = start_removing ? (line.slice(0, line.indexOf('{')) + line.slice(i + 1)) : (` * @${removing} ` + line.slice(i + 1)); + removing = null; + } + } + + if (removing && !start_removing && (line.trim().startsWith("* @") || line.trim().startsWith("*/"))) { + removing = null; + } + + if (!removing) { + filtered_lines.push(line); + } + } + + // Replace generic type names with their plain versions + const renamed_generics = filtered_lines.map(line => { + return line.replace(/(\W|\s)([A-Z][\w\d$]*)_\d+(\W|\s)/g, "$1$2$3"); + }); + + // Generate the import statement for the types used + const import_statements = Array.from(import_map.entries()) + .map(([path, names]) => { + const default_name = names.get('default'); + names.delete('default'); + const default_import = default_name ? (default_name + (names.size ? ', ' : ' ')) : ''; + const named_imports = names.size ? `{ ${[...names.values()].join(', ')} } ` : ''; + return `import ${default_import}${named_imports}from '${path}';` + }) + .join("\n"); + + return [import_statements, ...renamed_generics].join("\n"); +} + +let did_replace = false; + +function walk(dir) { + const files = readdirSync(dir); + const _dir = dir.slice('types/'.length) + + for (const file of files) { + const path = `${dir}/${file}`; + if (file.endsWith('.d.ts')) { + modify(path, content => { + content = adjust(content); + + if (file === 'index.d.ts' && existsSync(`src/${_dir}/public.d.ts`)) { + copyFileSync(`src/${_dir}/public.d.ts`, `${dir}/public.d.ts`); + content = "export * from './public.js';\n" + content; + } + + if (file === 'Component.d.ts' && dir.includes('runtime')) { + if (!content.includes('$set(props: Partial): void;\n}')) { + throw new Error('Component.js was modified in a way that automatic patching of d.ts file no longer works. Please adjust it'); + } else { + content = content.replace('$set(props: Partial): void;\n}', '$set(props: Partial): void;\n [accessor:string]: any;\n}'); + did_replace = true; + } + } + + return content; + }); + } else if (statSync(path).isDirectory()) { + if (existsSync(`src/${_dir}/${file}/private.d.ts`)) { + copyFileSync(`src/${_dir}/${file}/private.d.ts`, `${path}/private.d.ts`); + } + if (existsSync(`src/${_dir}/${file}/interfaces.d.ts`)) { + copyFileSync(`src/${_dir}/${file}/interfaces.d.ts`, `${path}/interfaces.d.ts`); + } + walk(path); + } + } +} + +walk('types'); + +if (!did_replace) { + throw new Error('Component.js file in runtime does no longer exist so that automatic patching of the d.ts file no longer works. Please adjust it'); +} + +copyFileSync(`src/runtime/ambient.d.ts`, `types/runtime/ambient.d.ts`); diff --git a/package.json b/package.json index 45123e4e7e..b94bebb49b 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "svelte", "version": "4.0.0-next.0", "description": "Cybernetically enhanced web apps", + "type": "module", "module": "index.mjs", "main": "index", "files": [ @@ -89,7 +90,7 @@ "dev": "rollup -cw", "posttest": "agadoo internal/index.mjs", "prepublishOnly": "node check_publish_env.js && npm run lint && npm run build && npm test", - "tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly", + "tsd": "node ./generate-types.mjs", "lint": "eslint \"{src,test}/**/*.{ts,js}\" --cache" }, "repository": { @@ -119,23 +120,24 @@ "@rollup/plugin-sucrase": "^5.0.1", "@rollup/plugin-typescript": "^11.1.0", "@rollup/plugin-virtual": "^3.0.1", - "@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.8.0", + "@sveltejs/eslint-config": "^6.0.1", "@types/aria-query": "^5.0.1", "@types/estree": "^1.0.0", "@types/mocha": "^10.0.1", "@types/node": "^14.14.31", "@typescript-eslint/eslint-plugin": "^5.58.0", - "@typescript-eslint/parser": "^5.58.0", "acorn": "^8.8.2", "agadoo": "^3.0.0", "aria-query": "^5.1.3", "axobject-query": "^3.1.1", "code-red": "^1.0.0", "css-tree": "^2.3.1", - "eslint": "^8.35.0", + "esbuild": "^0.17.19", + "eslint": "^8.40.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-import": "^2.27.5", - "eslint-plugin-svelte3": "^4.0.0", + "eslint-plugin-svelte": "^2.28.0", + "eslint-plugin-unicorn": "^47.0.0", "estree-walker": "^3.0.3", "happy-dom": "^9.18.3", "is-reference": "^3.0.1", @@ -147,13 +149,14 @@ "prettier": "^2.8.8", "prettier-plugin-svelte": "^2.10.0", "rollup": "^3.20.2", + "rollup-plugin-dts": "^5.3.0", "source-map": "^0.7.4", "source-map-support": "^0.5.21", "tiny-glob": "^0.2.9", "tslib": "^2.5.0", "typescript": "^5.0.4", "util": "^0.12.5", - "vitest": "^0.31.0" + "vitest": "^0.31.1" }, "packageManager": "pnpm@8.4.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a51cd60c5c..06d015a38d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,8 +35,8 @@ importers: specifier: ^3.0.1 version: 3.0.1(rollup@3.20.2) '@sveltejs/eslint-config': - specifier: github:sveltejs/eslint-config#v5.8.0 - version: github.com/sveltejs/eslint-config/9a7d728e03ac433e5856a6e06775c17ee986d641(@typescript-eslint/eslint-plugin@5.58.0)(@typescript-eslint/parser@5.58.0)(eslint-plugin-import@2.27.5)(eslint-plugin-node@11.1.0)(eslint-plugin-svelte3@4.0.0)(eslint@8.35.0)(typescript@5.0.4) + specifier: ^6.0.1 + version: 6.0.1(@typescript-eslint/eslint-plugin@5.58.0)(@typescript-eslint/parser@5.58.0)(eslint-config-prettier@8.8.0)(eslint-plugin-import@2.27.5)(eslint-plugin-node@11.1.0)(eslint-plugin-svelte@2.28.0)(eslint-plugin-unicorn@47.0.0)(eslint@8.40.0)(typescript@5.0.4) '@types/aria-query': specifier: ^5.0.1 version: 5.0.1 @@ -51,10 +51,7 @@ importers: version: 14.14.31 '@typescript-eslint/eslint-plugin': specifier: ^5.58.0 - version: 5.58.0(@typescript-eslint/parser@5.58.0)(eslint@8.35.0)(typescript@5.0.4) - '@typescript-eslint/parser': - specifier: ^5.58.0 - version: 5.58.0(eslint@8.35.0)(typescript@5.0.4) + version: 5.58.0(@typescript-eslint/parser@5.58.0)(eslint@8.40.0)(typescript@5.0.4) acorn: specifier: ^8.8.2 version: 8.8.2 @@ -73,18 +70,24 @@ importers: css-tree: specifier: ^2.3.1 version: 2.3.1 + esbuild: + specifier: ^0.17.19 + version: 0.17.19 eslint: - specifier: ^8.35.0 - version: 8.35.0 + specifier: ^8.40.0 + version: 8.40.0 eslint-config-prettier: specifier: ^8.8.0 - version: 8.8.0(eslint@8.35.0) + version: 8.8.0(eslint@8.40.0) eslint-plugin-import: specifier: ^2.27.5 - version: 2.27.5(@typescript-eslint/parser@5.58.0)(eslint@8.35.0) - eslint-plugin-svelte3: - specifier: ^4.0.0 - version: 4.0.0(eslint@8.35.0)(svelte@3.59.1) + version: 2.27.5(@typescript-eslint/parser@5.58.0)(eslint@8.40.0) + eslint-plugin-svelte: + specifier: ^2.28.0 + version: 2.28.0(eslint@8.40.0)(svelte@3.59.1) + eslint-plugin-unicorn: + specifier: ^47.0.0 + version: 47.0.0(eslint@8.40.0) estree-walker: specifier: ^3.0.3 version: 3.0.3 @@ -118,6 +121,9 @@ importers: rollup: specifier: ^3.20.2 version: 3.20.2 + rollup-plugin-dts: + specifier: ^5.3.0 + version: 5.3.0(rollup@3.20.2)(typescript@5.0.4) source-map: specifier: ^0.7.4 version: 0.7.4 @@ -137,8 +143,8 @@ importers: specifier: ^0.12.5 version: 0.12.5 vitest: - specifier: ^0.31.0 - version: 0.31.0(happy-dom@9.18.3)(jsdom@21.1.1) + specifier: ^0.31.1 + version: 0.31.1(happy-dom@9.18.3)(jsdom@21.1.1) sites/svelte.dev: dependencies: @@ -147,13 +153,13 @@ importers: version: 2.22.0 '@sveltejs/repl': specifier: ^0.5.0-next.3 - version: 0.5.0-next.3(@codemirror/lang-html@6.4.3)(@lezer/common@1.0.2)(@lezer/javascript@1.4.3)(@lezer/lr@1.3.4)(@sveltejs/kit@1.16.3)(svelte@) + version: 0.5.0-next.3(@codemirror/lang-html@6.4.3)(@lezer/common@1.0.2)(@lezer/javascript@1.4.3)(@lezer/lr@1.3.4)(@sveltejs/kit@1.18.0)(svelte@) cookie: specifier: ^0.5.0 version: 0.5.0 devalue: specifier: ^4.3.1 - version: 4.3.1 + version: 4.3.2 do-not-zip: specifier: ^1.0.0 version: 1.0.0 @@ -169,19 +175,19 @@ importers: version: 2.4.1 '@sveltejs/adapter-vercel': specifier: ^2.4.3 - version: 2.4.3(@sveltejs/kit@1.16.3) + version: 2.4.3(@sveltejs/kit@1.18.0) '@sveltejs/kit': specifier: ^1.16.3 - version: 1.16.3(svelte@)(vite@4.3.7) + version: 1.18.0(svelte@)(vite@4.3.8) '@sveltejs/site-kit': specifier: ^5.2.1 - version: 5.2.1(@sveltejs/kit@1.16.3)(svelte@) + version: 5.2.1(@sveltejs/kit@1.18.0)(svelte@) '@types/marked': specifier: ^4.3.0 version: 4.3.0 '@types/node': specifier: ^20.1.7 - version: 20.1.7 + version: 20.2.3 degit: specifier: ^2.8.4 version: 2.8.4 @@ -208,10 +214,10 @@ importers: version: 2.10.0(prettier@2.8.8)(svelte@) rollup: specifier: ^3.22.0 - version: 3.22.0 + version: 3.23.0 rollup-plugin-dts: specifier: ^5.3.0 - version: 5.3.0(rollup@3.22.0)(typescript@5.0.4) + version: 5.3.0(rollup@3.23.0)(typescript@5.0.4) sass: specifier: ^1.62.1 version: 1.62.1 @@ -235,7 +241,7 @@ importers: version: link:../.. svelte-check: specifier: ^3.3.2 - version: 3.3.2(sass@1.62.1)(svelte@) + version: 3.3.2(postcss@8.4.23)(sass@1.62.1)(svelte@) tiny-glob: specifier: ^0.2.9 version: 0.2.9 @@ -247,10 +253,10 @@ importers: version: 5.0.4 vite: specifier: ^4.3.7 - version: 4.3.7(@types/node@20.1.7)(sass@1.62.1) + version: 4.3.8(@types/node@20.2.3)(sass@1.62.1) vite-imagetools: specifier: ^5.0.4 - version: 5.0.4(rollup@3.22.0) + version: 5.0.4(rollup@3.23.0) packages: @@ -269,13 +275,11 @@ packages: dependencies: '@babel/highlight': 7.18.6 dev: true - optional: true /@babel/helper-validator-identifier@7.19.1: resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} engines: {node: '>=6.9.0'} dev: true - optional: true /@babel/highlight@7.18.6: resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==} @@ -285,9 +289,8 @@ packages: chalk: 2.4.2 js-tokens: 4.0.0 dev: true - optional: true - /@codemirror/autocomplete@6.7.1(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(@lezer/common@1.0.2): + /@codemirror/autocomplete@6.7.1(@codemirror/language@6.7.0)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(@lezer/common@1.0.2): resolution: {integrity: sha512-hSxf9S0uB+GV+gBsjY1FZNo53e1FFdzPceRfCfD1gWOnV6o21GfB5J5Wg9G/4h76XZMPrF0A6OCK/Rz5+V1egg==} peerDependencies: '@codemirror/language': ^6.0.0 @@ -295,29 +298,29 @@ packages: '@codemirror/view': ^6.0.0 '@lezer/common': ^1.0.0 dependencies: - '@codemirror/language': 6.6.0 - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 + '@codemirror/language': 6.7.0 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 '@lezer/common': 1.0.2 dev: false /@codemirror/commands@6.2.4: resolution: {integrity: sha512-42lmDqVH0ttfilLShReLXsDfASKLXzfyC36bzwcqzox9PlHulMcsUOfHXNo2X2aFMVNUoQ7j+d4q5bnfseYoOA==} dependencies: - '@codemirror/language': 6.6.0 - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 + '@codemirror/language': 6.7.0 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 '@lezer/common': 1.0.2 dev: false - /@codemirror/lang-css@6.2.0(@codemirror/view@6.11.1): + /@codemirror/lang-css@6.2.0(@codemirror/view@6.12.0): resolution: {integrity: sha512-oyIdJM29AyRPM3+PPq1I2oIk8NpUfEN3kAM05XWDDs6o3gSneIKaVJifT2P+fqONLou2uIgXynFyMUDQvo/szA==} dependencies: - '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(@lezer/common@1.0.2) - '@codemirror/language': 6.6.0 - '@codemirror/state': 6.2.0 + '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.7.0)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(@lezer/common@1.0.2) + '@codemirror/language': 6.7.0 + '@codemirror/state': 6.2.1 '@lezer/common': 1.0.2 - '@lezer/css': 1.1.1 + '@lezer/css': 1.1.2 transitivePeerDependencies: - '@codemirror/view' dev: false @@ -325,25 +328,25 @@ packages: /@codemirror/lang-html@6.4.3: resolution: {integrity: sha512-VKzQXEC8nL69Jg2hvAFPBwOdZNvL8tMFOrdFwWpU+wc6a6KEkndJ/19R5xSaglNX6v2bttm8uIEFYxdQDcIZVQ==} dependencies: - '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(@lezer/common@1.0.2) - '@codemirror/lang-css': 6.2.0(@codemirror/view@6.11.1) + '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.7.0)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(@lezer/common@1.0.2) + '@codemirror/lang-css': 6.2.0(@codemirror/view@6.12.0) '@codemirror/lang-javascript': 6.1.8 - '@codemirror/language': 6.6.0 - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 + '@codemirror/language': 6.7.0 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 '@lezer/common': 1.0.2 - '@lezer/css': 1.1.1 + '@lezer/css': 1.1.2 '@lezer/html': 1.3.4 dev: false /@codemirror/lang-javascript@6.1.8: resolution: {integrity: sha512-5cIA6IOkslTu1DtldcYnj7hsBm3p+cD37qSaKvW1kV16M6q9ysKvKrveCOWgbrj4+ilSWRL2JtSLudbeB158xg==} dependencies: - '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(@lezer/common@1.0.2) - '@codemirror/language': 6.6.0 + '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.7.0)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(@lezer/common@1.0.2) + '@codemirror/language': 6.7.0 '@codemirror/lint': 6.2.1 - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 '@lezer/common': 1.0.2 '@lezer/javascript': 1.4.3 dev: false @@ -351,7 +354,7 @@ packages: /@codemirror/lang-json@6.0.1: resolution: {integrity: sha512-+T1flHdgpqDDlJZ2Lkil/rLiRy684WMLc74xUnjJH48GQdfJo/pudlTRreZmKwzP8/tGdKf83wlbAdOCzlJOGQ==} dependencies: - '@codemirror/language': 6.6.0 + '@codemirror/language': 6.7.0 '@lezer/json': 1.0.0 dev: false @@ -359,18 +362,18 @@ packages: resolution: {integrity: sha512-n87Ms6Y5UYb1UkFu8sRzTLfq/yyF1y2AYiWvaVdbBQi5WDj1tFk5N+AKA+WC0Jcjc1VxvrCCM0iizjdYYi9sFQ==} dependencies: '@codemirror/lang-html': 6.4.3 - '@codemirror/language': 6.6.0 - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 + '@codemirror/language': 6.7.0 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 '@lezer/common': 1.0.2 '@lezer/markdown': 1.0.2 dev: false - /@codemirror/language@6.6.0: - resolution: {integrity: sha512-cwUd6lzt3MfNYOobdjf14ZkLbJcnv4WtndYaoBkbor/vF+rCNguMPK0IRtvZJG4dsWiaWPcK8x1VijhvSxnstg==} + /@codemirror/language@6.7.0: + resolution: {integrity: sha512-4SMwe6Fwn57klCUsVN0y4/h/iWT+XIXFEmop2lIHHuWO0ubjCrF3suqSZLyOQlznxkNnNbOOfKe5HQbQGCAmTg==} dependencies: - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 '@lezer/common': 1.0.2 '@lezer/highlight': 1.1.4 '@lezer/lr': 1.3.4 @@ -380,29 +383,29 @@ packages: /@codemirror/lint@6.2.1: resolution: {integrity: sha512-y1muai5U/uUPAGRyHMx9mHuHLypPcHWxzlZGknp/U5Mdb5Ol8Q5ZLp67UqyTbNFJJ3unVxZ8iX3g1fMN79S1JQ==} dependencies: - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 - crelt: 1.0.5 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 + crelt: 1.0.6 dev: false /@codemirror/search@6.4.0: resolution: {integrity: sha512-zMDgaBXah+nMLK2dHz9GdCnGbQu+oaGRXS1qviqNZkvOCv/whp5XZFyoikLp/23PM9RBcbuKUUISUmQHM1eRHw==} dependencies: - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 - crelt: 1.0.5 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 + crelt: 1.0.6 dev: false - /@codemirror/state@6.2.0: - resolution: {integrity: sha512-69QXtcrsc3RYtOtd+GsvczJ319udtBf1PTrr2KbLWM/e2CXUPnh0Nz9AUo8WfhSQ7GeL8dPVNUmhQVgpmuaNGA==} + /@codemirror/state@6.2.1: + resolution: {integrity: sha512-RupHSZ8+OjNT38zU9fKH2sv+Dnlr8Eb8sl4NOnnqz95mCFTZUaiRP8Xv5MeeaG0px2b8Bnfe7YGwCV3nsBhbuw==} dev: false - /@codemirror/view@6.11.1: - resolution: {integrity: sha512-ffKhfty5XcadA2/QSmDCnG6ZQnDfKT4YsH9ACWluhoTpkHuW5gMAK07s9Y76j/OzUqyoUuF+/VISr9BuCWzPqw==} + /@codemirror/view@6.12.0: + resolution: {integrity: sha512-xNHvbJBc2v8JuEcIGOck6EUGShpP+TYGCEMVEVQMYxbFXfMhYnoF3znxB/2GgeKR0nrxBs+nhBupiTYQqCp2kw==} dependencies: - '@codemirror/state': 6.2.0 + '@codemirror/state': 6.2.1 style-mod: 4.0.3 - w3c-keyname: 2.2.6 + w3c-keyname: 2.2.7 dev: false /@esbuild/android-arm64@0.17.19: @@ -581,14 +584,14 @@ packages: requiresBuild: true optional: true - /@eslint-community/eslint-utils@4.4.0(eslint@8.35.0): + /@eslint-community/eslint-utils@4.4.0(eslint@8.40.0): resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.35.0 - eslint-visitor-keys: 3.4.0 + eslint: 8.40.0 + eslint-visitor-keys: 3.4.1 dev: true /@eslint-community/regexpp@4.5.0: @@ -596,13 +599,13 @@ packages: engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} dev: true - /@eslint/eslintrc@2.0.2: - resolution: {integrity: sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==} + /@eslint/eslintrc@2.0.3: + resolution: {integrity: sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 debug: 4.3.4 - espree: 9.5.1 + espree: 9.5.2 globals: 13.20.0 ignore: 5.2.4 import-fresh: 3.3.0 @@ -613,8 +616,8 @@ packages: - supports-color dev: true - /@eslint/js@8.35.0: - resolution: {integrity: sha512-JXdzbRiWclLVoD8sNUjR443VVlYqiYmDVT6rGUEIEHU5YJW0gaVZwV2xgM7D4arkvASqD0IlLUVjHiFuxaftRw==} + /@eslint/js@8.40.0: + resolution: {integrity: sha512-ElyB54bJIhXQYVKjDSvCkPO1iU1tSAeVQJbllWJq1XQSmmA4dgFk8CbiBGpiOPxleE48vDogxCtmMYku4HSVLA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true @@ -1022,8 +1025,8 @@ packages: resolution: {integrity: sha512-SVgiGtMnMnW3ActR8SXgsDhw7a0w0ChHSYAyAUxxrOiJ1OqYWEKk/xJd84tTSPo1mo6DXLObAJALNnd0Hrv7Ng==} dev: false - /@lezer/css@1.1.1: - resolution: {integrity: sha512-mSjx+unLLapEqdOYDejnGBokB5+AiJKZVclmud0MKQOKx3DLJ5b5VTCstgDDknR6iIV4gVrN6euzsCnj0A2gQA==} + /@lezer/css@1.1.2: + resolution: {integrity: sha512-5TKMAReXukfEmIiZprDlGfZVfOOCyEStFi1YLzxclm9H3G/HHI49/2wzlRT6bQw5r7PoZVEtjTItEkb/UuZQyg==} dependencies: '@lezer/highlight': 1.1.4 '@lezer/lr': 1.3.4 @@ -1077,18 +1080,18 @@ packages: detect-libc: 2.0.1 https-proxy-agent: 5.0.1 make-dir: 3.1.0 - node-fetch: 2.6.7 + node-fetch: 2.6.11 nopt: 5.0.0 npmlog: 5.0.1 rimraf: 3.0.2 - semver: 7.4.0 - tar: 6.1.14 + semver: 7.5.1 + tar: 6.1.15 transitivePeerDependencies: - encoding - supports-color dev: true - /@neocodemirror/svelte@0.0.8(@codemirror/commands@6.2.4)(@codemirror/language@6.6.0)(@codemirror/lint@6.2.1)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(codemirror@6.0.1): + /@neocodemirror/svelte@0.0.8(@codemirror/commands@6.2.4)(@codemirror/language@6.7.0)(@codemirror/lint@6.2.1)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(codemirror@6.0.1): resolution: {integrity: sha512-t3CP/ZsWgPYzrhqLH9Dukw0GNpMJSpqGBYAQFP1OvYXerd9xwBdXcKovP/x5SmKAiJF6cvWey/5plZNzJvB3vQ==} peerDependencies: '@codemirror/commands': ^6.2.0 @@ -1099,10 +1102,10 @@ packages: codemirror: ^6.0.1 dependencies: '@codemirror/commands': 6.2.4 - '@codemirror/language': 6.6.0 + '@codemirror/language': 6.7.0 '@codemirror/lint': 6.2.1 - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 codemirror: 6.0.1(@lezer/common@1.0.2) csstype: 3.1.2 nanostores: 0.8.1 @@ -1143,7 +1146,7 @@ packages: /@polka/url@1.0.0-next.21: resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==} - /@replit/codemirror-lang-svelte@6.0.0(@codemirror/autocomplete@6.7.1)(@codemirror/lang-css@6.2.0)(@codemirror/lang-html@6.4.3)(@codemirror/lang-javascript@6.1.8)(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(@lezer/common@1.0.2)(@lezer/highlight@1.1.4)(@lezer/javascript@1.4.3)(@lezer/lr@1.3.4): + /@replit/codemirror-lang-svelte@6.0.0(@codemirror/autocomplete@6.7.1)(@codemirror/lang-css@6.2.0)(@codemirror/lang-html@6.4.3)(@codemirror/lang-javascript@6.1.8)(@codemirror/language@6.7.0)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(@lezer/common@1.0.2)(@lezer/highlight@1.1.4)(@lezer/javascript@1.4.3)(@lezer/lr@1.3.4): resolution: {integrity: sha512-U2OqqgMM6jKelL0GNWbAmqlu1S078zZNoBqlJBW+retTc5M4Mha6/Y2cf4SVg6ddgloJvmcSpt4hHrVoM4ePRA==} peerDependencies: '@codemirror/autocomplete': ^6.0.0 @@ -1158,13 +1161,13 @@ packages: '@lezer/javascript': ^1.2.0 '@lezer/lr': ^1.0.0 dependencies: - '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(@lezer/common@1.0.2) - '@codemirror/lang-css': 6.2.0(@codemirror/view@6.11.1) + '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.7.0)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(@lezer/common@1.0.2) + '@codemirror/lang-css': 6.2.0(@codemirror/view@6.12.0) '@codemirror/lang-html': 6.4.3 '@codemirror/lang-javascript': 6.1.8 - '@codemirror/language': 6.6.0 - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 + '@codemirror/language': 6.7.0 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 '@lezer/common': 1.0.2 '@lezer/highlight': 1.1.4 '@lezer/javascript': 1.4.3 @@ -1297,16 +1300,16 @@ packages: '@resvg/resvg-js-win32-x64-msvc': 2.4.1 dev: true - /@rich_harris/svelte-split-pane@1.1.0(svelte@): - resolution: {integrity: sha512-gxDfPqRSRx11/t+cs5ao0pXzKSO6CiBDmbcVwD8o/zToNZZTZjompoRmvRRICT9OhPxwwl/87nXJEToorPyICg==} + /@rich_harris/svelte-split-pane@1.1.1(svelte@): + resolution: {integrity: sha512-y2RRLyrN6DCeIgwA423aAIv/T5JqQeOl2XogBQ/21DvA2IF7oyrLUtXMxmQL2va2NFdeJO6MDx6nDX5X7kau7A==} peerDependencies: svelte: ^3.54.0 dependencies: svelte: 'link:' dev: false - /@rollup/browser@3.21.7: - resolution: {integrity: sha512-fscnmExHrLUwQUFt/0428Urv2GWKB3ymk1BAHz8WIxipMcG23ZmChpLEH1CoGTYnLIHgd/cpL1dGxBYAAMEcLQ==} + /@rollup/browser@3.23.0: + resolution: {integrity: sha512-NL8JDhJT41oZahtkr7hkEw4X+4hOj/+DiXvSnJLzcd1S2t1v+0o4vAcpRMdZY2/PC6qrX1ZMOHulMGRIvhkdMg==} dev: false /@rollup/plugin-commonjs@24.1.0(rollup@3.20.2): @@ -1441,7 +1444,7 @@ packages: rollup: 3.20.2 dev: true - /@rollup/pluginutils@5.0.2(rollup@3.22.0): + /@rollup/pluginutils@5.0.2(rollup@3.23.0): resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} engines: {node: '>=14.0.0'} peerDependencies: @@ -1453,7 +1456,7 @@ packages: '@types/estree': 1.0.1 estree-walker: 2.0.2 picomatch: 2.3.1 - rollup: 3.22.0 + rollup: 3.23.0 dev: true /@shuding/opentype.js@1.4.0-beta.0: @@ -1521,12 +1524,12 @@ packages: - supports-color dev: false - /@sveltejs/adapter-vercel@2.4.3(@sveltejs/kit@1.16.3): + /@sveltejs/adapter-vercel@2.4.3(@sveltejs/kit@1.18.0): resolution: {integrity: sha512-3k/3udwaioFYdKDAgQcWSByB+KCbtjX+ARonYGCtYE0iuxWLStrESxy3SaU+17XD5Frh8w7tfY8ft4TV3ej3Dg==} peerDependencies: '@sveltejs/kit': ^1.5.0 dependencies: - '@sveltejs/kit': 1.16.3(svelte@)(vite@4.3.7) + '@sveltejs/kit': 1.18.0(svelte@)(vite@4.3.8) '@vercel/nft': 0.22.6 esbuild: 0.17.19 transitivePeerDependencies: @@ -1534,8 +1537,32 @@ packages: - supports-color dev: true - /@sveltejs/kit@1.16.3(svelte@)(vite@4.3.7): - resolution: {integrity: sha512-8uv0udYRpVuE1BweFidcWHfL+u2gAANKmvIal1dN/FWPBl7DJYbt9zYEtr3bNTiXystT8Sn0Wp54RfwpbPqHjQ==} + /@sveltejs/eslint-config@6.0.1(@typescript-eslint/eslint-plugin@5.58.0)(@typescript-eslint/parser@5.58.0)(eslint-config-prettier@8.8.0)(eslint-plugin-import@2.27.5)(eslint-plugin-node@11.1.0)(eslint-plugin-svelte@2.28.0)(eslint-plugin-unicorn@47.0.0)(eslint@8.40.0)(typescript@5.0.4): + resolution: {integrity: sha512-oBoekhwqTicLUgIKNbR84wTgPSfZRbLDkeFtLEiifuXkS2B34xVZ6mOaSwITh/eBYvAZc90RLO8L5sXKmTXulQ==} + peerDependencies: + '@typescript-eslint/eslint-plugin': '>= 5' + '@typescript-eslint/parser': '>= 5' + eslint: '>= 8' + eslint-config-prettier: '>= 8' + eslint-plugin-import: '>= 2' + eslint-plugin-node: '>= 11' + eslint-plugin-svelte: '>= 2' + eslint-plugin-unicorn: '>= 47' + typescript: '>= 5' + dependencies: + '@typescript-eslint/eslint-plugin': 5.58.0(@typescript-eslint/parser@5.58.0)(eslint@8.40.0)(typescript@5.0.4) + '@typescript-eslint/parser': 5.58.0(eslint@8.40.0)(typescript@5.0.4) + eslint: 8.40.0 + eslint-config-prettier: 8.8.0(eslint@8.40.0) + eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.58.0)(eslint@8.40.0) + eslint-plugin-node: 11.1.0(eslint@8.40.0) + eslint-plugin-svelte: 2.28.0(eslint@8.40.0)(svelte@3.59.1) + eslint-plugin-unicorn: 47.0.0(eslint@8.40.0) + typescript: 5.0.4 + dev: true + + /@sveltejs/kit@1.18.0(svelte@)(vite@4.3.8): + resolution: {integrity: sha512-QE5X9gCG34khrO6j01ZbRXtVx+yyUNe8PmVPeG0M+I8eyFejqYMEhD1JtjCrLzpd4KukvuO8bL35M1VWmPM7hQ==} engines: {node: ^16.14 || >=18} hasBin: true requiresBuild: true @@ -1543,10 +1570,10 @@ packages: svelte: ^3.54.0 vite: ^4.0.0 dependencies: - '@sveltejs/vite-plugin-svelte': 2.2.0(svelte@)(vite@4.3.7) + '@sveltejs/vite-plugin-svelte': 2.2.0(svelte@)(vite@4.3.8) '@types/cookie': 0.5.1 cookie: 0.5.0 - devalue: 4.3.1 + devalue: 4.3.2 esm-env: 1.0.0 kleur: 4.1.5 magic-string: 0.30.0 @@ -1557,32 +1584,32 @@ packages: svelte: 'link:' tiny-glob: 0.2.9 undici: 5.22.1 - vite: 4.3.7(@types/node@20.1.7)(sass@1.62.1) + vite: 4.3.8(@types/node@20.2.3)(sass@1.62.1) transitivePeerDependencies: - supports-color - /@sveltejs/repl@0.5.0-next.3(@codemirror/lang-html@6.4.3)(@lezer/common@1.0.2)(@lezer/javascript@1.4.3)(@lezer/lr@1.3.4)(@sveltejs/kit@1.16.3)(svelte@): + /@sveltejs/repl@0.5.0-next.3(@codemirror/lang-html@6.4.3)(@lezer/common@1.0.2)(@lezer/javascript@1.4.3)(@lezer/lr@1.3.4)(@sveltejs/kit@1.18.0)(svelte@): resolution: {integrity: sha512-objIeGuUkgKcMUklAZ7XL0x/4eO3ocTFgaQnn18eVl/L1KkZALdPUEvvrgkiJ4GPQ4cqAwLv0LdYr3Z62p+48w==} peerDependencies: svelte: ^3.54.0 dependencies: - '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(@lezer/common@1.0.2) + '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.7.0)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(@lezer/common@1.0.2) '@codemirror/commands': 6.2.4 - '@codemirror/lang-css': 6.2.0(@codemirror/view@6.11.1) + '@codemirror/lang-css': 6.2.0(@codemirror/view@6.12.0) '@codemirror/lang-javascript': 6.1.8 '@codemirror/lang-json': 6.0.1 '@codemirror/lang-markdown': 6.1.1 - '@codemirror/language': 6.6.0 + '@codemirror/language': 6.7.0 '@codemirror/lint': 6.2.1 - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 '@jridgewell/sourcemap-codec': 1.4.15 '@lezer/highlight': 1.1.4 - '@neocodemirror/svelte': 0.0.8(@codemirror/commands@6.2.4)(@codemirror/language@6.6.0)(@codemirror/lint@6.2.1)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(codemirror@6.0.1) - '@replit/codemirror-lang-svelte': 6.0.0(@codemirror/autocomplete@6.7.1)(@codemirror/lang-css@6.2.0)(@codemirror/lang-html@6.4.3)(@codemirror/lang-javascript@6.1.8)(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(@lezer/common@1.0.2)(@lezer/highlight@1.1.4)(@lezer/javascript@1.4.3)(@lezer/lr@1.3.4) - '@rich_harris/svelte-split-pane': 1.1.0(svelte@) - '@rollup/browser': 3.21.7 - '@sveltejs/site-kit': 5.0.4(@sveltejs/kit@1.16.3)(svelte@) + '@neocodemirror/svelte': 0.0.8(@codemirror/commands@6.2.4)(@codemirror/language@6.7.0)(@codemirror/lint@6.2.1)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(codemirror@6.0.1) + '@replit/codemirror-lang-svelte': 6.0.0(@codemirror/autocomplete@6.7.1)(@codemirror/lang-css@6.2.0)(@codemirror/lang-html@6.4.3)(@codemirror/lang-javascript@6.1.8)(@codemirror/language@6.7.0)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(@lezer/common@1.0.2)(@lezer/highlight@1.1.4)(@lezer/javascript@1.4.3)(@lezer/lr@1.3.4) + '@rich_harris/svelte-split-pane': 1.1.1(svelte@) + '@rollup/browser': 3.23.0 + '@sveltejs/site-kit': 5.0.4(@sveltejs/kit@1.18.0)(svelte@) acorn: 8.8.2 codemirror: 6.0.1(@lezer/common@1.0.2) esm-env: 1.0.0 @@ -1599,31 +1626,31 @@ packages: - '@sveltejs/kit' dev: false - /@sveltejs/site-kit@5.0.4(@sveltejs/kit@1.16.3)(svelte@): + /@sveltejs/site-kit@5.0.4(@sveltejs/kit@1.18.0)(svelte@): resolution: {integrity: sha512-bn0Lk3hmIz/pDTMvVjiVX/US4OPoc1CzfceI0Y0ljxHs2fdxRTZz881xvItZRF7istLIueoFR1x3HAZPdI2F6g==} peerDependencies: '@sveltejs/kit': ^1.0.0 svelte: ^3.54.0 dependencies: - '@sveltejs/kit': 1.16.3(svelte@)(vite@4.3.7) + '@sveltejs/kit': 1.18.0(svelte@)(vite@4.3.8) esm-env: 1.0.0 svelte: 'link:' svelte-local-storage-store: 0.4.0(svelte@) dev: false - /@sveltejs/site-kit@5.2.1(@sveltejs/kit@1.16.3)(svelte@): + /@sveltejs/site-kit@5.2.1(@sveltejs/kit@1.18.0)(svelte@): resolution: {integrity: sha512-KBl/PlC/I+Db7mm8WHOCtNOyi1nyxicAVuqZ1+NXN6CJTlDtedFouo0sltGaOQgndbXgGmLr8IfCPz/MWgBVKw==} peerDependencies: '@sveltejs/kit': ^1.0.0 svelte: ^3.54.0 dependencies: - '@sveltejs/kit': 1.16.3(svelte@)(vite@4.3.7) + '@sveltejs/kit': 1.18.0(svelte@)(vite@4.3.8) esm-env: 1.0.0 svelte: 'link:' svelte-local-storage-store: 0.4.0(svelte@) dev: true - /@sveltejs/vite-plugin-svelte@2.2.0(svelte@)(vite@4.3.7): + /@sveltejs/vite-plugin-svelte@2.2.0(svelte@)(vite@4.3.8): resolution: {integrity: sha512-KDtdva+FZrZlyug15KlbXuubntAPKcBau0K7QhAIqC5SAy0uDbjZwoexDRx0L0J2T4niEfC6FnA9GuQQJKg+Aw==} engines: {node: ^14.18.0 || >= 16} peerDependencies: @@ -1636,8 +1663,8 @@ packages: magic-string: 0.30.0 svelte: 'link:' svelte-hmr: 0.15.1(svelte@) - vite: 4.3.7(@types/node@20.1.7)(sass@1.62.1) - vitefu: 0.2.4(vite@4.3.7) + vite: 4.3.8(@types/node@20.2.3)(sass@1.62.1) + vitefu: 0.2.4(vite@4.3.8) transitivePeerDependencies: - supports-color @@ -1707,8 +1734,12 @@ packages: resolution: {integrity: sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==} dev: true - /@types/node@20.1.7: - resolution: {integrity: sha512-WCuw/o4GSwDGMoonES8rcvwsig77dGCMbZDrZr2x4ZZiNW4P/gcoZXe/0twgtobcTkmg9TuKflxYL/DuwDyJzg==} + /@types/node@20.2.3: + resolution: {integrity: sha512-pg9d0yC4rVNWQzX8U7xb4olIOFuuVL9za3bzMT2pu2SU0SNEi66i2qrvhE2qt0HvkhuCaWJu7pLNOt/Pj8BIrw==} + + /@types/normalize-package-data@2.4.1: + resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} + dev: true /@types/phoenix@1.5.6: resolution: {integrity: sha512-e7jZ6I9uyRGsg7MNwQcarmBvRlbGb9DibbocE9crVnxqsy6C23RMxLWbJ2CQ3vgCW7taoL1L+F02EcjA6ld7XA==} @@ -1729,10 +1760,10 @@ packages: /@types/websocket@1.0.5: resolution: {integrity: sha512-NbsqiNX9CnEfC1Z0Vf4mE1SgAJ07JnRYcNex7AJ9zAVzmiGHmjKFEk7O4TJIsgv2B1sLEb6owKFZrACwdYngsQ==} dependencies: - '@types/node': 20.1.7 + '@types/node': 20.2.3 dev: false - /@typescript-eslint/eslint-plugin@5.58.0(@typescript-eslint/parser@5.58.0)(eslint@8.35.0)(typescript@5.0.4): + /@typescript-eslint/eslint-plugin@5.58.0(@typescript-eslint/parser@5.58.0)(eslint@8.40.0)(typescript@5.0.4): resolution: {integrity: sha512-vxHvLhH0qgBd3/tW6/VccptSfc8FxPQIkmNTVLWcCOVqSBvqpnKkBTYrhcGlXfSnd78azwe+PsjYFj0X34/njA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1744,12 +1775,12 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.5.0 - '@typescript-eslint/parser': 5.58.0(eslint@8.35.0)(typescript@5.0.4) + '@typescript-eslint/parser': 5.58.0(eslint@8.40.0)(typescript@5.0.4) '@typescript-eslint/scope-manager': 5.58.0 - '@typescript-eslint/type-utils': 5.58.0(eslint@8.35.0)(typescript@5.0.4) - '@typescript-eslint/utils': 5.58.0(eslint@8.35.0)(typescript@5.0.4) + '@typescript-eslint/type-utils': 5.58.0(eslint@8.40.0)(typescript@5.0.4) + '@typescript-eslint/utils': 5.58.0(eslint@8.40.0)(typescript@5.0.4) debug: 4.3.4 - eslint: 8.35.0 + eslint: 8.40.0 grapheme-splitter: 1.0.4 ignore: 5.2.4 natural-compare-lite: 1.4.0 @@ -1760,7 +1791,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@5.58.0(eslint@8.35.0)(typescript@5.0.4): + /@typescript-eslint/parser@5.58.0(eslint@8.40.0)(typescript@5.0.4): resolution: {integrity: sha512-ixaM3gRtlfrKzP8N6lRhBbjTow1t6ztfBvQNGuRM8qH1bjFFXIJ35XY+FC0RRBKn3C6cT+7VW1y8tNm7DwPHDQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1774,7 +1805,7 @@ packages: '@typescript-eslint/types': 5.58.0 '@typescript-eslint/typescript-estree': 5.58.0(typescript@5.0.4) debug: 4.3.4 - eslint: 8.35.0 + eslint: 8.40.0 typescript: 5.0.4 transitivePeerDependencies: - supports-color @@ -1788,7 +1819,7 @@ packages: '@typescript-eslint/visitor-keys': 5.58.0 dev: true - /@typescript-eslint/type-utils@5.58.0(eslint@8.35.0)(typescript@5.0.4): + /@typescript-eslint/type-utils@5.58.0(eslint@8.40.0)(typescript@5.0.4): resolution: {integrity: sha512-FF5vP/SKAFJ+LmR9PENql7fQVVgGDOS+dq3j+cKl9iW/9VuZC/8CFmzIP0DLKXfWKpRHawJiG70rVH+xZZbp8w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1799,9 +1830,9 @@ packages: optional: true dependencies: '@typescript-eslint/typescript-estree': 5.58.0(typescript@5.0.4) - '@typescript-eslint/utils': 5.58.0(eslint@8.35.0)(typescript@5.0.4) + '@typescript-eslint/utils': 5.58.0(eslint@8.40.0)(typescript@5.0.4) debug: 4.3.4 - eslint: 8.35.0 + eslint: 8.40.0 tsutils: 3.21.0(typescript@5.0.4) typescript: 5.0.4 transitivePeerDependencies: @@ -1834,19 +1865,19 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@5.58.0(eslint@8.35.0)(typescript@5.0.4): + /@typescript-eslint/utils@5.58.0(eslint@8.40.0)(typescript@5.0.4): resolution: {integrity: sha512-gAmLOTFXMXOC+zP1fsqm3VceKSBQJNzV385Ok3+yzlavNHZoedajjS4UyS21gabJYcobuigQPs/z71A9MdJFqQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.35.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.40.0) '@types/json-schema': 7.0.11 '@types/semver': 7.3.13 '@typescript-eslint/scope-manager': 5.58.0 '@typescript-eslint/types': 5.58.0 '@typescript-eslint/typescript-estree': 5.58.0(typescript@5.0.4) - eslint: 8.35.0 + eslint: 8.40.0 eslint-scope: 5.1.1 semver: 7.4.0 transitivePeerDependencies: @@ -1909,39 +1940,39 @@ packages: - supports-color dev: true - /@vitest/expect@0.31.0: - resolution: {integrity: sha512-Jlm8ZTyp6vMY9iz9Ny9a0BHnCG4fqBa8neCF6Pk/c/6vkUk49Ls6UBlgGAU82QnzzoaUs9E/mUhq/eq9uMOv/g==} + /@vitest/expect@0.31.1: + resolution: {integrity: sha512-BV1LyNvhnX+eNYzJxlHIGPWZpwJFZaCcOIzp2CNG0P+bbetenTupk6EO0LANm4QFt0TTit+yqx7Rxd1qxi/SQA==} dependencies: - '@vitest/spy': 0.31.0 - '@vitest/utils': 0.31.0 + '@vitest/spy': 0.31.1 + '@vitest/utils': 0.31.1 chai: 4.3.7 dev: true - /@vitest/runner@0.31.0: - resolution: {integrity: sha512-H1OE+Ly7JFeBwnpHTrKyCNm/oZgr+16N4qIlzzqSG/YRQDATBYmJb/KUn3GrZaiQQyL7GwpNHVZxSQd6juLCgw==} + /@vitest/runner@0.31.1: + resolution: {integrity: sha512-imWuc82ngOtxdCUpXwtEzZIuc1KMr+VlQ3Ondph45VhWoQWit5yvG/fFcldbnCi8DUuFi+NmNx5ehMUw/cGLUw==} dependencies: - '@vitest/utils': 0.31.0 + '@vitest/utils': 0.31.1 concordance: 5.0.4 p-limit: 4.0.0 pathe: 1.1.0 dev: true - /@vitest/snapshot@0.31.0: - resolution: {integrity: sha512-5dTXhbHnyUMTMOujZPB0wjFjQ6q5x9c8TvAsSPUNKjp1tVU7i9pbqcKPqntyu2oXtmVxKbuHCqrOd+Ft60r4tg==} + /@vitest/snapshot@0.31.1: + resolution: {integrity: sha512-L3w5uU9bMe6asrNzJ8WZzN+jUTX4KSgCinEJPXyny0o90fG4FPQMV0OWsq7vrCWfQlAilMjDnOF9nP8lidsJ+g==} dependencies: magic-string: 0.30.0 pathe: 1.1.0 pretty-format: 27.5.1 dev: true - /@vitest/spy@0.31.0: - resolution: {integrity: sha512-IzCEQ85RN26GqjQNkYahgVLLkULOxOm5H/t364LG0JYb3Apg0PsYCHLBYGA006+SVRMWhQvHlBBCyuByAMFmkg==} + /@vitest/spy@0.31.1: + resolution: {integrity: sha512-1cTpt2m9mdo3hRLDyCG2hDQvRrePTDgEJBFQQNz1ydHHZy03EiA6EpFxY+7ODaY7vMRCie+WlFZBZ0/dQWyssQ==} dependencies: tinyspy: 2.1.0 dev: true - /@vitest/utils@0.31.0: - resolution: {integrity: sha512-kahaRyLX7GS1urekRXN2752X4gIgOGVX4Wo8eDUGUkTWlGpXzf5ZS6N9RUUS+Re3XEE8nVGqNyxkSxF5HXlGhQ==} + /@vitest/utils@0.31.1: + resolution: {integrity: sha512-yFyRD5ilwojsZfo3E0BnH72pSVSuLg2356cN1tCEe/0RtDzxTPYwOomIC+eQbot7m6DRy4tPZw+09mB7NkbMmA==} dependencies: concordance: 5.0.4 loupe: 2.3.6 @@ -2023,7 +2054,6 @@ packages: dependencies: color-convert: 1.9.3 dev: true - optional: true /ansi-styles@4.3.0: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} @@ -2279,7 +2309,6 @@ packages: escape-string-regexp: 1.0.5 supports-color: 5.5.0 dev: true - optional: true /chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} @@ -2316,6 +2345,18 @@ packages: engines: {node: '>=10'} dev: true + /ci-info@3.8.0: + resolution: {integrity: sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==} + engines: {node: '>=8'} + dev: true + + /clean-regexp@1.0.0: + resolution: {integrity: sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==} + engines: {node: '>=4'} + dependencies: + escape-string-regexp: 1.0.5 + dev: true + /code-block-writer@12.0.0: resolution: {integrity: sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==} dev: true @@ -2333,13 +2374,13 @@ packages: /codemirror@6.0.1(@lezer/common@1.0.2): resolution: {integrity: sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==} dependencies: - '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.6.0)(@codemirror/state@6.2.0)(@codemirror/view@6.11.1)(@lezer/common@1.0.2) + '@codemirror/autocomplete': 6.7.1(@codemirror/language@6.7.0)(@codemirror/state@6.2.1)(@codemirror/view@6.12.0)(@lezer/common@1.0.2) '@codemirror/commands': 6.2.4 - '@codemirror/language': 6.6.0 + '@codemirror/language': 6.7.0 '@codemirror/lint': 6.2.1 '@codemirror/search': 6.4.0 - '@codemirror/state': 6.2.0 - '@codemirror/view': 6.11.1 + '@codemirror/state': 6.2.1 + '@codemirror/view': 6.12.0 transitivePeerDependencies: - '@lezer/common' dev: false @@ -2349,7 +2390,6 @@ packages: dependencies: color-name: 1.1.3 dev: true - optional: true /color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} @@ -2361,7 +2401,6 @@ packages: /color-name@1.1.3: resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} dev: true - optional: true /color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} @@ -2429,8 +2468,8 @@ packages: resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} engines: {node: '>= 0.6'} - /crelt@1.0.5: - resolution: {integrity: sha512-+BO9wPPi+DWTDcNYhr/W90myha8ptzftZT+LwcmUbbok0rcP/fequmFYCw8NMoH7pkAZQzU78b3kYrlua5a9eA==} + /crelt@1.0.6: + resolution: {integrity: sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==} dev: false /cross-fetch@3.1.6: @@ -2641,8 +2680,8 @@ packages: engines: {node: '>=8'} dev: true - /devalue@4.3.1: - resolution: {integrity: sha512-Kc0TSP9IUU9eg55au5Q3YtqaYI2cgntVpunJV9Exbm9nvlBeTE5p2NqYHfpuXK6+VF2hF5PI+BPFPUti7e2N1g==} + /devalue@4.3.2: + resolution: {integrity: sha512-KqFl6pOgOW+Y6wJgu80rHpo2/3H07vr8ntR9rkkFIRETewbf5GaYYcakYfiKz89K+sLsuPkQIZaXDMjUObZwWg==} /dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} @@ -2704,6 +2743,12 @@ packages: engines: {node: '>=0.12'} dev: true + /error-ex@1.3.2: + resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} + dependencies: + is-arrayish: 0.2.1 + dev: true + /es-abstract@1.21.2: resolution: {integrity: sha512-y/B5POM2iBnIxCiernH1G7rC9qQoM77lLIMQLuob0zhp8C56Po81+2Nj0WFKnd0pNReDTnkYryc+zhOzpEIROg==} engines: {node: '>= 0.4'} @@ -2844,7 +2889,6 @@ packages: resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} engines: {node: '>=0.8.0'} dev: true - optional: true /escape-string-regexp@4.0.0: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} @@ -2864,13 +2908,13 @@ packages: source-map: 0.6.1 dev: true - /eslint-config-prettier@8.8.0(eslint@8.35.0): + /eslint-config-prettier@8.8.0(eslint@8.40.0): resolution: {integrity: sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==} hasBin: true peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.35.0 + eslint: 8.40.0 dev: true /eslint-import-resolver-node@0.3.7: @@ -2883,7 +2927,7 @@ packages: - supports-color dev: true - /eslint-module-utils@2.7.4(@typescript-eslint/parser@5.58.0)(eslint-import-resolver-node@0.3.7)(eslint@8.35.0): + /eslint-module-utils@2.7.4(@typescript-eslint/parser@5.58.0)(eslint-import-resolver-node@0.3.7)(eslint@8.40.0): resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==} engines: {node: '>=4'} peerDependencies: @@ -2904,26 +2948,26 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.58.0(eslint@8.35.0)(typescript@5.0.4) + '@typescript-eslint/parser': 5.58.0(eslint@8.40.0)(typescript@5.0.4) debug: 3.2.7 - eslint: 8.35.0 + eslint: 8.40.0 eslint-import-resolver-node: 0.3.7 transitivePeerDependencies: - supports-color dev: true - /eslint-plugin-es@3.0.1(eslint@8.35.0): + /eslint-plugin-es@3.0.1(eslint@8.40.0): resolution: {integrity: sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=4.19.1' dependencies: - eslint: 8.35.0 + eslint: 8.40.0 eslint-utils: 2.1.0 regexpp: 3.2.0 dev: true - /eslint-plugin-import@2.27.5(@typescript-eslint/parser@5.58.0)(eslint@8.35.0): + /eslint-plugin-import@2.27.5(@typescript-eslint/parser@5.58.0)(eslint@8.40.0): resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==} engines: {node: '>=4'} peerDependencies: @@ -2933,15 +2977,15 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.58.0(eslint@8.35.0)(typescript@5.0.4) + '@typescript-eslint/parser': 5.58.0(eslint@8.40.0)(typescript@5.0.4) array-includes: 3.1.6 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 debug: 3.2.7 doctrine: 2.1.0 - eslint: 8.35.0 + eslint: 8.40.0 eslint-import-resolver-node: 0.3.7 - eslint-module-utils: 2.7.4(@typescript-eslint/parser@5.58.0)(eslint-import-resolver-node@0.3.7)(eslint@8.35.0) + eslint-module-utils: 2.7.4(@typescript-eslint/parser@5.58.0)(eslint-import-resolver-node@0.3.7)(eslint@8.40.0) has: 1.0.3 is-core-module: 2.12.0 is-glob: 4.0.3 @@ -2956,14 +3000,14 @@ packages: - supports-color dev: true - /eslint-plugin-node@11.1.0(eslint@8.35.0): + /eslint-plugin-node@11.1.0(eslint@8.40.0): resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=5.16.0' dependencies: - eslint: 8.35.0 - eslint-plugin-es: 3.0.1(eslint@8.35.0) + eslint: 8.40.0 + eslint-plugin-es: 3.0.1(eslint@8.40.0) eslint-utils: 2.1.0 ignore: 5.2.4 minimatch: 3.1.2 @@ -2971,14 +3015,55 @@ packages: semver: 6.3.0 dev: true - /eslint-plugin-svelte3@4.0.0(eslint@8.35.0)(svelte@3.59.1): - resolution: {integrity: sha512-OIx9lgaNzD02+MDFNLw0GEUbuovNcglg+wnd/UY0fbZmlQSz7GlQiQ1f+yX0XvC07XPcDOnFcichqI3xCwp71g==} + /eslint-plugin-svelte@2.28.0(eslint@8.40.0)(svelte@3.59.1): + resolution: {integrity: sha512-bXPXKnjq5uKoVAQtC2E0L1Vp+mmJ3nlC9jyz8zwfZ99pQROL2h7Hes01QdYil1vxgh6tLXl5YVpZ2wwyAbBz5g==} + engines: {node: ^14.17.0 || >=16.0.0} peerDependencies: - eslint: '>=8.0.0' - svelte: ^3.2.0 + eslint: ^7.0.0 || ^8.0.0-0 + svelte: ^3.37.0 + peerDependenciesMeta: + svelte: + optional: true dependencies: - eslint: 8.35.0 + '@eslint-community/eslint-utils': 4.4.0(eslint@8.40.0) + '@jridgewell/sourcemap-codec': 1.4.15 + debug: 4.3.4 + eslint: 8.40.0 + esutils: 2.0.3 + known-css-properties: 0.27.0 + postcss: 8.4.23 + postcss-load-config: 3.1.4(postcss@8.4.23) + postcss-safe-parser: 6.0.0(postcss@8.4.23) svelte: 3.59.1 + svelte-eslint-parser: 0.28.0(svelte@3.59.1) + transitivePeerDependencies: + - supports-color + - ts-node + dev: true + + /eslint-plugin-unicorn@47.0.0(eslint@8.40.0): + resolution: {integrity: sha512-ivB3bKk7fDIeWOUmmMm9o3Ax9zbMz1Bsza/R2qm46ufw4T6VBFBaJIR1uN3pCKSmSXm8/9Nri8V+iUut1NhQGA==} + engines: {node: '>=16'} + peerDependencies: + eslint: '>=8.38.0' + dependencies: + '@babel/helper-validator-identifier': 7.19.1 + '@eslint-community/eslint-utils': 4.4.0(eslint@8.40.0) + ci-info: 3.8.0 + clean-regexp: 1.0.0 + eslint: 8.40.0 + esquery: 1.5.0 + indent-string: 4.0.0 + is-builtin-module: 3.2.1 + jsesc: 3.0.2 + lodash: 4.17.21 + pluralize: 8.0.0 + read-pkg-up: 7.0.1 + regexp-tree: 0.1.27 + regjsparser: 0.10.0 + safe-regex: 2.1.1 + semver: 7.5.1 + strip-indent: 3.0.0 dev: true /eslint-scope@5.1.1: @@ -2989,8 +3074,8 @@ packages: estraverse: 4.3.0 dev: true - /eslint-scope@7.1.1: - resolution: {integrity: sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==} + /eslint-scope@7.2.0: + resolution: {integrity: sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: esrecurse: 4.3.0 @@ -3004,38 +3089,30 @@ packages: eslint-visitor-keys: 1.3.0 dev: true - /eslint-utils@3.0.0(eslint@8.35.0): - resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} - engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} - peerDependencies: - eslint: '>=5' - dependencies: - eslint: 8.35.0 - eslint-visitor-keys: 2.1.0 - dev: true - /eslint-visitor-keys@1.3.0: resolution: {integrity: sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==} engines: {node: '>=4'} dev: true - /eslint-visitor-keys@2.1.0: - resolution: {integrity: sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==} - engines: {node: '>=10'} - dev: true - /eslint-visitor-keys@3.4.0: resolution: {integrity: sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /eslint@8.35.0: - resolution: {integrity: sha512-BxAf1fVL7w+JLRQhWl2pzGeSiGqbWumV4WNvc9Rhp6tiCtm4oHnyPBSEtMGZwrQgudFQ+otqzWoPB7x+hxoWsw==} + /eslint-visitor-keys@3.4.1: + resolution: {integrity: sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dev: true + + /eslint@8.40.0: + resolution: {integrity: sha512-bvR+TsP9EHL3TqNtj9sCNJVAFK3fBN8Q7g5waghxyRsPLIMwL73XSKnZFK0hk/O2ANC+iAoq6PWMQ+IfBAJIiQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: - '@eslint/eslintrc': 2.0.2 - '@eslint/js': 8.35.0 + '@eslint-community/eslint-utils': 4.4.0(eslint@8.40.0) + '@eslint-community/regexpp': 4.5.0 + '@eslint/eslintrc': 2.0.3 + '@eslint/js': 8.40.0 '@humanwhocodes/config-array': 0.11.8 '@humanwhocodes/module-importer': 1.0.1 '@nodelib/fs.walk': 1.2.8 @@ -3045,10 +3122,9 @@ packages: debug: 4.3.4 doctrine: 3.0.0 escape-string-regexp: 4.0.0 - eslint-scope: 7.1.1 - eslint-utils: 3.0.0(eslint@8.35.0) - eslint-visitor-keys: 3.4.0 - espree: 9.5.1 + eslint-scope: 7.2.0 + eslint-visitor-keys: 3.4.1 + espree: 9.5.2 esquery: 1.5.0 esutils: 2.0.3 fast-deep-equal: 3.1.3 @@ -3070,7 +3146,6 @@ packages: minimatch: 3.1.2 natural-compare: 1.4.0 optionator: 0.9.1 - regexpp: 3.2.0 strip-ansi: 6.0.1 strip-json-comments: 3.1.1 text-table: 0.2.0 @@ -3081,13 +3156,13 @@ packages: /esm-env@1.0.0: resolution: {integrity: sha512-Cf6VksWPsTuW01vU9Mk/3vRue91Zevka5SjyNf3nEpokFRuqt/KjUQoGAwq9qMmhpLTHmXzSIrFRw8zxWzmFBA==} - /espree@9.5.1: - resolution: {integrity: sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==} + /espree@9.5.2: + resolution: {integrity: sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: acorn: 8.8.2 acorn-jsx: 5.3.2(acorn@8.8.2) - eslint-visitor-keys: 3.4.0 + eslint-visitor-keys: 3.4.1 dev: true /esprima@4.0.1: @@ -3225,6 +3300,14 @@ packages: dependencies: to-regex-range: 5.0.1 + /find-up@4.1.0: + resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} + engines: {node: '>=8'} + dependencies: + locate-path: 5.0.0 + path-exists: 4.0.0 + dev: true + /find-up@5.0.0: resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} engines: {node: '>=10'} @@ -3480,7 +3563,6 @@ packages: resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} engines: {node: '>=4'} dev: true - optional: true /has-flag@4.0.0: resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} @@ -3526,6 +3608,10 @@ packages: engines: {node: '>=6'} dev: true + /hosted-git-info@2.8.9: + resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} + dev: true + /html-encoding-sniffer@3.0.0: resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==} engines: {node: '>=12'} @@ -3599,6 +3685,11 @@ packages: engines: {node: '>=0.8.19'} dev: true + /indent-string@4.0.0: + resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} + engines: {node: '>=8'} + dev: true + /inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} dependencies: @@ -3644,6 +3735,10 @@ packages: is-typed-array: 1.1.10 dev: true + /is-arrayish@0.2.1: + resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} + dev: true + /is-arrayish@0.3.2: resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==} dev: true @@ -3872,7 +3967,6 @@ packages: /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} dev: true - optional: true /js-yaml@4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} @@ -3922,6 +4016,21 @@ packages: - utf-8-validate dev: true + /jsesc@0.5.0: + resolution: {integrity: sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==} + hasBin: true + dev: true + + /jsesc@3.0.2: + resolution: {integrity: sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==} + engines: {node: '>=6'} + hasBin: true + dev: true + + /json-parse-even-better-errors@2.3.1: + resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} + dev: true + /json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} dev: true @@ -3945,6 +4054,10 @@ packages: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} + /known-css-properties@0.27.0: + resolution: {integrity: sha512-uMCj6+hZYDoffuvAJjFAPz56E9uoowFHmTkqRtRq5WyC5Q6Cu/fTZKNQpX/RbzChBYLLl3lo8CjFZBAZXq9qFg==} + dev: true + /levn@0.3.0: resolution: {integrity: sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==} engines: {node: '>= 0.8.0'} @@ -3961,6 +4074,11 @@ packages: type-check: 0.4.0 dev: true + /lilconfig@2.1.0: + resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==} + engines: {node: '>=10'} + dev: true + /linebreak@1.1.0: resolution: {integrity: sha512-MHp03UImeVhB7XZtjd0E4n6+3xr5Dq/9xI/5FptGk5FrbDR3zagPa2DS6U8ks/3HjbKWG9Q1M2ufOzxV2qLYSQ==} dependencies: @@ -3994,6 +4112,13 @@ packages: resolution: {integrity: sha512-n2GmejDXtOPBAZdIiEFy5dJ5N38xBCXLNOtw2WpB9kGh6pnrEuKlwYI+Tkpofc4wDtVXHtoAOJaMRlYG/oYaxg==} dev: true + /locate-path@5.0.0: + resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} + engines: {node: '>=8'} + dependencies: + p-locate: 4.1.0 + dev: true + /locate-path@6.0.0: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} @@ -4270,7 +4395,6 @@ packages: optional: true dependencies: whatwg-url: 5.0.0 - dev: false /node-fetch@2.6.7: resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==} @@ -4305,6 +4429,15 @@ packages: abbrev: 1.1.1 dev: true + /normalize-package-data@2.5.0: + resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} + dependencies: + hosted-git-info: 2.8.9 + resolve: 1.22.2 + semver: 5.7.1 + validate-npm-package-license: 3.0.4 + dev: true + /normalize-path@3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} @@ -4397,6 +4530,13 @@ packages: word-wrap: 1.2.3 dev: true + /p-limit@2.3.0: + resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} + engines: {node: '>=6'} + dependencies: + p-try: 2.2.0 + dev: true + /p-limit@3.1.0: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} engines: {node: '>=10'} @@ -4411,6 +4551,13 @@ packages: yocto-queue: 1.0.0 dev: true + /p-locate@4.1.0: + resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} + engines: {node: '>=8'} + dependencies: + p-limit: 2.3.0 + dev: true + /p-locate@5.0.0: resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} engines: {node: '>=10'} @@ -4418,6 +4565,11 @@ packages: p-limit: 3.1.0 dev: true + /p-try@2.2.0: + resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} + engines: {node: '>=6'} + dev: true + /pako@0.2.9: resolution: {integrity: sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==} dev: true @@ -4459,6 +4611,16 @@ packages: resolution: {integrity: sha512-ft3iAoLOB/MlwbNXgzy43SWGP6sQki2jQvAyBg/zDFAgr9bfNWZIUj42Kw2eJIl8kEi4PbgE6U1Zau/HwI75HA==} dev: true + /parse-json@5.2.0: + resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} + engines: {node: '>=8'} + dependencies: + '@babel/code-frame': 7.21.4 + error-ex: 1.3.2 + json-parse-even-better-errors: 2.3.1 + lines-and-columns: 1.2.4 + dev: true + /parse5@7.1.2: resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==} dependencies: @@ -4551,6 +4713,11 @@ packages: hasBin: true dev: true + /pluralize@8.0.0: + resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} + engines: {node: '>=4'} + dev: true + /pngjs@3.4.0: resolution: {integrity: sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==} engines: {node: '>=4.0.0'} @@ -4561,6 +4728,32 @@ packages: engines: {node: '>=12.13.0'} dev: true + /postcss-load-config@3.1.4(postcss@8.4.23): + resolution: {integrity: sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==} + engines: {node: '>= 10'} + peerDependencies: + postcss: '>=8.0.9' + ts-node: '>=9.0.0' + peerDependenciesMeta: + postcss: + optional: true + ts-node: + optional: true + dependencies: + lilconfig: 2.1.0 + postcss: 8.4.23 + yaml: 1.10.2 + dev: true + + /postcss-safe-parser@6.0.0(postcss@8.4.23): + resolution: {integrity: sha512-FARHN8pwH+WiS2OPCxJI8FuRJpTVnn6ZNFiqAM2aeW2LwTHWWmWgIyKC6cUo0L8aeKiF/14MNvnpls6R2PBeMQ==} + engines: {node: '>=12.0'} + peerDependencies: + postcss: ^8.3.3 + dependencies: + postcss: 8.4.23 + dev: true + /postcss-value-parser@4.2.0: resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==} dev: true @@ -4680,6 +4873,25 @@ packages: resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} dev: true + /read-pkg-up@7.0.1: + resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} + engines: {node: '>=8'} + dependencies: + find-up: 4.1.0 + read-pkg: 5.2.0 + type-fest: 0.8.1 + dev: true + + /read-pkg@5.2.0: + resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} + engines: {node: '>=8'} + dependencies: + '@types/normalize-package-data': 2.4.1 + normalize-package-data: 2.5.0 + parse-json: 5.2.0 + type-fest: 0.6.0 + dev: true + /readable-stream@3.6.2: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} @@ -4713,6 +4925,11 @@ packages: resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} dev: true + /regexp-tree@0.1.27: + resolution: {integrity: sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==} + hasBin: true + dev: true + /regexp.prototype.flags@1.4.3: resolution: {integrity: sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==} engines: {node: '>= 0.4'} @@ -4727,6 +4944,13 @@ packages: engines: {node: '>=8'} dev: true + /regjsparser@0.10.0: + resolution: {integrity: sha512-qx+xQGZVsy55CH0a1hiVwHmqjLryfh7wQyF5HO07XJ9f7dQMY/gPQHhlyDkIzJKC+x2fUCpCcUODUUUFrm7SHA==} + hasBin: true + dependencies: + jsesc: 0.5.0 + dev: true + /requires-port@1.0.0: resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} dev: true @@ -4774,7 +4998,21 @@ packages: glob: 7.2.3 dev: true - /rollup-plugin-dts@5.3.0(rollup@3.22.0)(typescript@5.0.4): + /rollup-plugin-dts@5.3.0(rollup@3.20.2)(typescript@5.0.4): + resolution: {integrity: sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==} + engines: {node: '>=v14'} + peerDependencies: + rollup: ^3.0.0 + typescript: ^4.1 || ^5.0 + dependencies: + magic-string: 0.30.0 + rollup: 3.20.2 + typescript: 5.0.4 + optionalDependencies: + '@babel/code-frame': 7.21.4 + dev: true + + /rollup-plugin-dts@5.3.0(rollup@3.23.0)(typescript@5.0.4): resolution: {integrity: sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==} engines: {node: '>=v14'} peerDependencies: @@ -4782,7 +5020,7 @@ packages: typescript: ^4.1 || ^5.0 dependencies: magic-string: 0.30.0 - rollup: 3.22.0 + rollup: 3.23.0 typescript: 5.0.4 optionalDependencies: '@babel/code-frame': 7.21.4 @@ -4796,8 +5034,8 @@ packages: fsevents: 2.3.2 dev: true - /rollup@3.22.0: - resolution: {integrity: sha512-imsigcWor5Y/dC0rz2q0bBt9PabcL3TORry2hAa6O6BuMvY71bqHyfReAz5qyAqiQATD1m70qdntqBfBQjVWpQ==} + /rollup@3.23.0: + resolution: {integrity: sha512-h31UlwEi7FHihLe1zbk+3Q7z1k/84rb9BSwmBSr/XjOCEaBJ2YyedQDuM0t/kfOS0IxM+vk1/zI9XxYj9V+NJQ==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: @@ -4831,6 +5069,12 @@ packages: is-regex: 1.1.4 dev: true + /safe-regex@2.1.1: + resolution: {integrity: sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==} + dependencies: + regexp-tree: 0.1.27 + dev: true + /safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} dev: true @@ -4885,6 +5129,11 @@ packages: xmlchars: 2.2.0 dev: true + /semver@5.7.1: + resolution: {integrity: sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==} + hasBin: true + dev: true + /semver@6.3.0: resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==} hasBin: true @@ -5059,6 +5308,28 @@ packages: engines: {node: '>= 8'} dev: true + /spdx-correct@3.2.0: + resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==} + dependencies: + spdx-expression-parse: 3.0.1 + spdx-license-ids: 3.0.13 + dev: true + + /spdx-exceptions@2.3.0: + resolution: {integrity: sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==} + dev: true + + /spdx-expression-parse@3.0.1: + resolution: {integrity: sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==} + dependencies: + spdx-exceptions: 2.3.0 + spdx-license-ids: 3.0.13 + dev: true + + /spdx-license-ids@3.0.13: + resolution: {integrity: sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w==} + dev: true + /stackback@0.0.2: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} dev: true @@ -5189,7 +5460,6 @@ packages: dependencies: has-flag: 3.0.0 dev: true - optional: true /supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} @@ -5203,7 +5473,7 @@ packages: engines: {node: '>= 0.4'} dev: true - /svelte-check@3.3.2(sass@1.62.1)(svelte@): + /svelte-check@3.3.2(postcss@8.4.23)(sass@1.62.1)(svelte@): resolution: {integrity: sha512-67j3rI0LDc2DvL0ON/2pvCasVVD3nHDrTkZNr4eITNfo2oFXdw7SIyMOiFj4swu+pjmFQAigytBK1IWyik8dBw==} hasBin: true peerDependencies: @@ -5216,7 +5486,7 @@ packages: picocolors: 1.0.0 sade: 1.8.1 svelte: 'link:' - svelte-preprocess: 5.0.3(sass@1.62.1)(svelte@)(typescript@5.0.4) + svelte-preprocess: 5.0.3(postcss@8.4.23)(sass@1.62.1)(svelte@)(typescript@5.0.4) typescript: 5.0.4 transitivePeerDependencies: - '@babel/core' @@ -5230,6 +5500,21 @@ packages: - sugarss dev: true + /svelte-eslint-parser@0.28.0(svelte@3.59.1): + resolution: {integrity: sha512-qWg5M3CIp7LkcdG5bpn44QEd48UxvgxG5L+Sbl701EG8Wujht7EqJuJhqgzvO3bbI9ENbWCXK49eCcwiNnpMzw==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + svelte: ^3.37.0 + peerDependenciesMeta: + svelte: + optional: true + dependencies: + eslint-scope: 7.2.0 + eslint-visitor-keys: 3.4.1 + espree: 9.5.2 + svelte: 3.59.1 + dev: true + /svelte-hmr@0.15.1(svelte@): resolution: {integrity: sha512-BiKB4RZ8YSwRKCNVdNxK/GfY+r4Kjgp9jCLEy0DuqAKfmQtpL38cQK3afdpjw4sqSs4PLi3jIPJIFp259NkZtA==} engines: {node: ^12.20 || ^14.13.1 || >= 16} @@ -5250,7 +5535,7 @@ packages: dependencies: svelte: 'link:' - /svelte-preprocess@5.0.3(sass@1.62.1)(svelte@)(typescript@5.0.4): + /svelte-preprocess@5.0.3(postcss@8.4.23)(sass@1.62.1)(svelte@)(typescript@5.0.4): resolution: {integrity: sha512-GrHF1rusdJVbOZOwgPWtpqmaexkydznKzy5qIC2FabgpFyKN57bjMUUUqPRfbBXK5igiEWn1uO/DXsa2vJ5VHA==} engines: {node: '>= 14.10.0'} requiresBuild: true @@ -5291,6 +5576,7 @@ packages: '@types/pug': 2.0.6 detect-indent: 6.1.0 magic-string: 0.27.0 + postcss: 8.4.23 sass: 1.62.1 sorcery: 0.11.0 strip-indent: 3.0.0 @@ -5327,8 +5613,8 @@ packages: readable-stream: 3.6.2 dev: true - /tar@6.1.14: - resolution: {integrity: sha512-piERznXu0U7/pW7cdSn7hjqySIVTYT6F76icmFk7ptU7dDYlXTm5r9A6K04R2vU3olYgoKeo1Cg3eeu5nhftAw==} + /tar@6.1.15: + resolution: {integrity: sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A==} engines: {node: '>=10'} dependencies: chownr: 2.0.0 @@ -5499,6 +5785,16 @@ packages: engines: {node: '>=10'} dev: true + /type-fest@0.6.0: + resolution: {integrity: sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==} + engines: {node: '>=8'} + dev: true + + /type-fest@0.8.1: + resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==} + engines: {node: '>=8'} + dev: true + /type@1.2.0: resolution: {integrity: sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==} dev: false @@ -5603,18 +5899,25 @@ packages: which-typed-array: 1.1.9 dev: true - /vite-imagetools@5.0.4(rollup@3.22.0): + /validate-npm-package-license@3.0.4: + resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} + dependencies: + spdx-correct: 3.2.0 + spdx-expression-parse: 3.0.1 + dev: true + + /vite-imagetools@5.0.4(rollup@3.23.0): resolution: {integrity: sha512-EIRstqWlmoQipsucFCioqCYpfp+rG5v8gpKDFvFJBxEKEAEBPnxW+swmE5dfoRQkwMKkYwmBWeXYsnMaDohUtg==} engines: {node: '>=12.0.0'} dependencies: - '@rollup/pluginutils': 5.0.2(rollup@3.22.0) + '@rollup/pluginutils': 5.0.2(rollup@3.23.0) imagetools-core: 4.0.3 transitivePeerDependencies: - rollup dev: true - /vite-node@0.31.0(@types/node@20.1.7): - resolution: {integrity: sha512-8x1x1LNuPvE2vIvkSB7c1mApX5oqlgsxzHQesYF7l5n1gKrEmrClIiZuOFbFDQcjLsmcWSwwmrWrcGWm9Fxc/g==} + /vite-node@0.31.1(@types/node@20.2.3): + resolution: {integrity: sha512-BajE/IsNQ6JyizPzu9zRgHrBwczkAs0erQf/JRpgTIESpKvNj9/Gd0vxX905klLkb0I0SJVCKbdrl5c6FnqYKA==} engines: {node: '>=v14.18.0'} hasBin: true dependencies: @@ -5623,7 +5926,7 @@ packages: mlly: 1.2.1 pathe: 1.1.0 picocolors: 1.0.0 - vite: 4.3.7(@types/node@20.1.7)(sass@1.62.1) + vite: 4.3.8(@types/node@20.2.3)(sass@1.62.1) transitivePeerDependencies: - '@types/node' - less @@ -5634,8 +5937,8 @@ packages: - terser dev: true - /vite@4.3.7(@types/node@20.1.7)(sass@1.62.1): - resolution: {integrity: sha512-MTIFpbIm9v7Hh5b0wSBgkcWzSBz7SAa6K/cBTwS4kUiQJfQLFlZZRJRQgqunCVzhTPCk674tW+0Qaqh3Q00dBg==} + /vite@4.3.8(@types/node@20.2.3)(sass@1.62.1): + resolution: {integrity: sha512-uYB8PwN7hbMrf4j1xzGDk/lqjsZvCDbt/JC5dyfxc19Pg8kRm14LinK/uq+HSLNswZEoKmweGdtpbnxRtrAXiQ==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true peerDependencies: @@ -5659,15 +5962,15 @@ packages: terser: optional: true dependencies: - '@types/node': 20.1.7 + '@types/node': 20.2.3 esbuild: 0.17.19 postcss: 8.4.23 - rollup: 3.22.0 + rollup: 3.23.0 sass: 1.62.1 optionalDependencies: fsevents: 2.3.2 - /vitefu@0.2.4(vite@4.3.7): + /vitefu@0.2.4(vite@4.3.8): resolution: {integrity: sha512-fanAXjSaf9xXtOOeno8wZXIhgia+CZury481LsDaV++lSvcU2R9Ch2bPh3PYFyoHW+w9LqAeYRISVQjUIew14g==} peerDependencies: vite: ^3.0.0 || ^4.0.0 @@ -5675,10 +5978,10 @@ packages: vite: optional: true dependencies: - vite: 4.3.7(@types/node@20.1.7)(sass@1.62.1) + vite: 4.3.8(@types/node@20.2.3)(sass@1.62.1) - /vitest@0.31.0(happy-dom@9.18.3)(jsdom@21.1.1): - resolution: {integrity: sha512-JwWJS9p3GU9GxkG7eBSmr4Q4x4bvVBSswaCFf1PBNHiPx00obfhHRJfgHcnI0ffn+NMlIh9QGvG75FlaIBdKGA==} + /vitest@0.31.1(happy-dom@9.18.3)(jsdom@21.1.1): + resolution: {integrity: sha512-/dOoOgzoFk/5pTvg1E65WVaobknWREN15+HF+0ucudo3dDG/vCZoXTQrjIfEaWvQXmqScwkRodrTbM/ScMpRcQ==} engines: {node: '>=v14.18.0'} hasBin: true peerDependencies: @@ -5710,12 +6013,12 @@ packages: dependencies: '@types/chai': 4.3.5 '@types/chai-subset': 1.3.3 - '@types/node': 20.1.7 - '@vitest/expect': 0.31.0 - '@vitest/runner': 0.31.0 - '@vitest/snapshot': 0.31.0 - '@vitest/spy': 0.31.0 - '@vitest/utils': 0.31.0 + '@types/node': 20.2.3 + '@vitest/expect': 0.31.1 + '@vitest/runner': 0.31.1 + '@vitest/snapshot': 0.31.1 + '@vitest/spy': 0.31.1 + '@vitest/utils': 0.31.1 acorn: 8.8.2 acorn-walk: 8.2.0 cac: 6.7.14 @@ -5732,8 +6035,8 @@ packages: strip-literal: 1.0.1 tinybench: 2.5.0 tinypool: 0.5.0 - vite: 4.3.7(@types/node@20.1.7)(sass@1.62.1) - vite-node: 0.31.0(@types/node@20.1.7) + vite: 4.3.8(@types/node@20.2.3)(sass@1.62.1) + vite-node: 0.31.1(@types/node@20.2.3) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -5756,8 +6059,8 @@ packages: resolution: {integrity: sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==} dev: true - /w3c-keyname@2.2.6: - resolution: {integrity: sha512-f+fciywl1SJEniZHD6H+kUO8gOnwIr7f4ijKA6+ZvJFjeGi1r4PDLl53Ayud9O/rk64RqgoQine0feoeOU0kXg==} + /w3c-keyname@2.2.7: + resolution: {integrity: sha512-XB8aa62d4rrVfoZYQaYNy3fy+z4nrfy2ooea3/0BnBzXW0tSdZ+lRgjzBZhk0La0H6h8fVyYCxx/qkQcAIuvfg==} dev: false /w3c-xmlserializer@4.0.0: @@ -5954,6 +6257,11 @@ packages: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} dev: true + /yaml@1.10.2: + resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==} + engines: {node: '>= 6'} + dev: true + /yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} @@ -5967,26 +6275,3 @@ packages: /yoga-wasm-web@0.3.3: resolution: {integrity: sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA==} dev: true - - github.com/sveltejs/eslint-config/9a7d728e03ac433e5856a6e06775c17ee986d641(@typescript-eslint/eslint-plugin@5.58.0)(@typescript-eslint/parser@5.58.0)(eslint-plugin-import@2.27.5)(eslint-plugin-node@11.1.0)(eslint-plugin-svelte3@4.0.0)(eslint@8.35.0)(typescript@5.0.4): - resolution: {tarball: https://codeload.github.com/sveltejs/eslint-config/tar.gz/9a7d728e03ac433e5856a6e06775c17ee986d641} - id: github.com/sveltejs/eslint-config/9a7d728e03ac433e5856a6e06775c17ee986d641 - name: '@sveltejs/eslint-config' - version: 5.8.0 - peerDependencies: - '@typescript-eslint/eslint-plugin': '>= 3' - '@typescript-eslint/parser': '>= 3' - eslint: '>= 7' - eslint-plugin-import: '>= 2' - eslint-plugin-node: '>= 11' - eslint-plugin-svelte3: '>= 2' - typescript: '>= 3' - dependencies: - '@typescript-eslint/eslint-plugin': 5.58.0(@typescript-eslint/parser@5.58.0)(eslint@8.35.0)(typescript@5.0.4) - '@typescript-eslint/parser': 5.58.0(eslint@8.35.0)(typescript@5.0.4) - eslint: 8.35.0 - eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.58.0)(eslint@8.35.0) - eslint-plugin-node: 11.1.0(eslint@8.35.0) - eslint-plugin-svelte3: 4.0.0(eslint@8.35.0)(svelte@3.59.1) - typescript: 5.0.4 - dev: true diff --git a/rollup.config.mjs b/rollup.config.mjs index 54b988b51b..d7f59264dc 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -32,7 +32,7 @@ const runtime_entrypoints = Object.fromEntries( fs .readdirSync('src/runtime', { withFileTypes: true }) .filter((dirent) => dirent.isDirectory()) - .map((dirent) => [dirent.name, `src/runtime/${dirent.name}/index.ts`]) + .map((dirent) => [dirent.name, `src/runtime/${dirent.name}/index.js`]) ); /** @@ -42,8 +42,8 @@ export default [ { input: { ...runtime_entrypoints, - index: 'src/runtime/index.ts', - ssr: 'src/runtime/ssr.ts' + index: 'src/runtime/index.js', + ssr: 'src/runtime/ssr.js' }, output: ['es', 'cjs'].map( /** @returns {import('rollup').OutputOptions} */ @@ -85,7 +85,7 @@ export default [ const mod = bundle[`internal/index.mjs`]; if (mod) { fs.writeFileSync( - 'src/compiler/compile/internal_exports.ts', + 'src/compiler/compile/internal_exports.js', `// This file is automatically generated\n` + `export default new Set(${JSON.stringify(mod.exports)});` ); @@ -103,7 +103,7 @@ export default [ }, /* compiler.js */ { - input: 'src/compiler/index.ts', + input: 'src/compiler/index.js', plugins: [ replace({ preventAssignment: true, diff --git a/scripts/globals-extractor.mjs b/scripts/globals-extractor.mjs index 47dbc240ff..b9706dfb92 100644 --- a/scripts/globals-extractor.mjs +++ b/scripts/globals-extractor.mjs @@ -9,7 +9,7 @@ see: https://github.com/microsoft/TypeScript/tree/main/lib import http from 'https'; import fs from 'fs'; -const GLOBAL_TS_PATH = './src/compiler/utils/globals.ts'; +const GLOBAL_TS_PATH = './src/compiler/utils/globals.js'; // MEMO: add additional objects/functions which existed in `src/compiler/utils/names.ts` // before this script was introduced but could not be retrieved by this process. diff --git a/src/compiler/Stats.ts b/src/compiler/Stats.js similarity index 64% rename from src/compiler/Stats.ts rename to src/compiler/Stats.js index e22c18e0f0..637a3fcc69 100644 --- a/src/compiler/Stats.ts +++ b/src/compiler/Stats.js @@ -6,39 +6,52 @@ const now = } : () => self.performance.now(); -interface Timing { - label: string; - start: number; - end: number; - children: Timing[]; -} - +/** @param {any} timings */ function collapse_timings(timings) { const result = {}; - timings.forEach((timing) => { - result[timing.label] = Object.assign( - { - total: timing.end - timing.start - }, - timing.children && collapse_timings(timing.children) - ); - }); + timings.forEach( + /** @param {any} timing */ (timing) => { + result[timing.label] = Object.assign( + { + total: timing.end - timing.start + }, + timing.children && collapse_timings(timing.children) + ); + } + ); return result; } export default class Stats { - start_time: number; - current_timing: Timing; - current_children: Timing[]; - timings: Timing[]; - stack: Timing[]; + /** + * @typedef {Object} Timing + * @property {string} label + * @property {number} start + * @property {number} end + * @property {Timing[]} children + */ + + /** @type {number} */ + start_time; + /** @type {Timing} */ + current_timing; + + /** @type {Timing[]} */ + current_children; + + /** @type {Timing[]} */ + timings; + + /** @type {Timing[]} */ + stack; constructor() { this.start_time = now(); this.stack = []; this.current_children = this.timings = []; } + /** @param {any} label */ start(label) { const timing = { label, @@ -46,27 +59,24 @@ export default class Stats { end: null, children: [] }; - this.current_children.push(timing); this.stack.push(timing); - this.current_timing = timing; this.current_children = timing.children; } + /** @param {any} label */ stop(label) { if (label !== this.current_timing.label) { throw new Error( `Mismatched timing labels (expected ${this.current_timing.label}, got ${label})` ); } - this.current_timing.end = now(); this.stack.pop(); this.current_timing = this.stack[this.stack.length - 1]; this.current_children = this.current_timing ? this.current_timing.children : this.timings; } - render() { const timings = Object.assign( { @@ -74,7 +84,6 @@ export default class Stats { }, collapse_timings(this.timings) ); - return { timings }; diff --git a/src/compiler/compile/Component.js b/src/compiler/compile/Component.js new file mode 100644 index 0000000000..5a4b063651 --- /dev/null +++ b/src/compiler/compile/Component.js @@ -0,0 +1,1903 @@ +import { walk } from 'estree-walker'; +import { getLocator } from 'locate-character'; +import { reserved, is_valid } from '../utils/names.js'; +import globals from '../utils/globals.js'; +import { namespaces, valid_namespaces } from '../utils/namespaces.js'; +import create_module from './create_module.js'; +import { create_scopes, extract_names, extract_identifiers } from './utils/scope.js'; +import Stylesheet from './css/Stylesheet.js'; +import Fragment from './nodes/Fragment.js'; +import internal_exports from './internal_exports.js'; +import error from '../utils/error.js'; +import get_code_frame from '../utils/get_code_frame.js'; +import flatten_reference from './utils/flatten_reference.js'; +import is_used_as_reference from './utils/is_used_as_reference.js'; +import is_reference from 'is-reference'; +import fuzzymatch from '../utils/fuzzymatch.js'; +import get_object from './utils/get_object.js'; +import add_to_set from './utils/add_to_set.js'; +import check_graph_for_cycles from './utils/check_graph_for_cycles.js'; +import { print, b } from 'code-red'; +import { is_reserved_keyword } from './utils/reserved_keywords.js'; +import { apply_preprocessor_sourcemap } from '../utils/mapped_code.js'; +import { clone } from '../utils/clone.js'; +import compiler_warnings from './compiler_warnings.js'; +import compiler_errors from './compiler_errors.js'; +import { + extract_ignores_above_position, + extract_svelte_ignore_from_comments +} from '../utils/extract_svelte_ignore.js'; +import check_enable_sourcemap from './utils/check_enable_sourcemap.js'; + +const regex_leading_directory_separator = /^[/\\]/; +const regex_starts_with_term_export = /^Export/; +const regex_contains_term_function = /Function/; + +export default class Component { + /** @type {import('../Stats.js').default} */ + stats; + + /** @type {import('../interfaces.js').Warning[]} */ + warnings; + + /** @type {Set} */ + ignores; + + /** @type {Array>} */ + ignore_stack = []; + + /** @type {import('../interfaces.js').Ast} */ + ast; + + /** @type {import('../interfaces.js').Ast} */ + original_ast; + + /** @type {string} */ + source; + + /** @type {import('estree').Identifier} */ + name; + + /** @type {import('../interfaces.js').CompileOptions} */ + compile_options; + + /** @type {import('./nodes/Fragment.js').default} */ + fragment; + + /** @type {import('./utils/scope.js').Scope} */ + module_scope; + + /** @type {import('./utils/scope.js').Scope} */ + instance_scope; + + /** @type {WeakMap} */ + instance_scope_map; + + /** @type {ComponentOptions} */ + component_options; + + /** @type {string} */ + namespace; + + /** @type {string} */ + tag; + + /** @type {boolean} */ + accessors; + + /** @type {import('../interfaces.js').Var[]} */ + vars = []; + + /** @type {Map} */ + var_lookup = new Map(); + + /** @type {import('estree').ImportDeclaration[]} */ + imports = []; + + /** @type {import('estree').ExportNamedDeclaration[]} */ + exports_from = []; + + /** @type {import('estree').ExportNamedDeclaration[]} */ + instance_exports_from = []; + + /** @type {Set} */ + hoistable_nodes = new Set(); + + /** @type {Map} */ + node_for_declaration = new Map(); + + /** @type {Array} */ + partly_hoisted = []; + + /** @type {Array} */ + fully_hoisted = []; + /** + * @type {Array<{ + * assignees: Set; + * dependencies: Set; + * node: import('estree').Node; + * declaration: import('estree').Node; + * }>} + */ + reactive_declarations = []; + + /** @type {Set} */ + reactive_declaration_nodes = new Set(); + /** */ + has_reactive_assignments = false; + + /** @type {Set} */ + injected_reactive_declaration_vars = new Set(); + + /** @type {Map} */ + helpers = new Map(); + + /** @type {Map} */ + globals = new Map(); + + /** @type {Map>} */ + indirect_dependencies = new Map(); + + /** @type {string} */ + file; + + /** @type {(c: number) => { line: number; column: number }} */ + locate; + + /** @type {import('./nodes/Element.js').default[]} */ + elements = []; + + /** @type {import('./css/Stylesheet.js').default} */ + stylesheet; + + /** @type {Map} */ + aliases = new Map(); + + /** @type {Set} */ + used_names = new Set(); + + /** @type {Set} */ + globally_used_names = new Set(); + + /** @type {Map} */ + slots = new Map(); + + /** @type {Set} */ + slot_outlets = new Set(); + + /** @type {import('./nodes/shared/Tag.js').default[]} */ + tags = []; + + /** + * @param {import('../interfaces.js').Ast} ast + * @param {string} source + * @param {string} name + * @param {import('../interfaces.js').CompileOptions} compile_options + * @param {import('../Stats.js').default} stats + * @param {import('../interfaces.js').Warning[]} warnings + */ + constructor(ast, source, name, compile_options, stats, warnings) { + this.name = { type: 'Identifier', name }; + this.stats = stats; + this.warnings = warnings; + this.ast = ast; + this.source = source; + this.compile_options = compile_options; + // the instance JS gets mutated, so we park + // a copy here for later. TODO this feels gross + this.original_ast = clone({ + html: ast.html, + css: ast.css, + instance: ast.instance, + module: ast.module + }); + this.file = + compile_options.filename && + (typeof process !== 'undefined' + ? compile_options.filename + .replace(process.cwd(), '') + .replace(regex_leading_directory_separator, '') + : compile_options.filename); + this.locate = getLocator(this.source, { offsetLine: 1 }); + // styles + this.stylesheet = new Stylesheet({ + source, + ast, + filename: compile_options.filename, + component_name: name, + dev: compile_options.dev, + get_css_hash: compile_options.cssHash + }); + this.stylesheet.validate(this); + this.component_options = process_component_options(this, this.ast.html.children); + this.namespace = + namespaces[this.component_options.namespace] || this.component_options.namespace; + if (compile_options.customElement) { + this.tag = this.component_options.customElement?.tag || compile_options.tag || this.name.name; + } else { + this.tag = this.name.name; + } + this.walk_module_js(); + this.push_ignores( + this.ast.instance + ? extract_ignores_above_position(this.ast.instance.start, this.ast.html.children) + : [] + ); + this.walk_instance_js_pre_template(); + this.pop_ignores(); + this.fragment = new Fragment(this, ast.html); + this.name = this.get_unique_name(name); + this.push_ignores( + this.ast.instance + ? extract_ignores_above_position(this.ast.instance.start, this.ast.html.children) + : [] + ); + this.walk_instance_js_post_template(); + this.pop_ignores(); + this.elements.forEach(/** @param {any} element */ (element) => this.stylesheet.apply(element)); + this.stylesheet.reify(); + this.stylesheet.warn_on_unused_selectors(this); + } + + /** + * @param {import('estree').Node} node + * @param {import('../interfaces.js').Var} variable + * @param {any} add_to_lookup + */ + add_var(node, variable, add_to_lookup = true) { + this.vars.push(variable); + if (add_to_lookup) { + if (this.var_lookup.has(variable.name)) { + const exists_var = this.var_lookup.get(variable.name); + if (exists_var.module && exists_var.imported) { + this.error(/** @type {any} */ (node), compiler_errors.illegal_variable_declaration); + } + } + this.var_lookup.set(variable.name, variable); + } + } + + /** + * @param {import('estree').Node} node + * @param {string} name + */ + add_reference(node, name) { + const variable = this.var_lookup.get(name); + if (variable) { + variable.referenced = true; + } else if (is_reserved_keyword(name)) { + this.add_var(node, { + name, + injected: true, + referenced: true + }); + } else if (name[0] === '$') { + this.add_var(node, { + name, + injected: true, + referenced: true, + mutated: true, + writable: true + }); + const subscribable_name = name.slice(1); + const variable = this.var_lookup.get(subscribable_name); + if (variable) { + variable.referenced = true; + variable.subscribable = true; + } + } else { + if (this.compile_options.varsReport === 'full') { + this.add_var(node, { name, referenced: true }, false); + } + this.used_names.add(name); + } + } + + /** @param {string} name */ + alias(name) { + if (!this.aliases.has(name)) { + this.aliases.set(name, this.get_unique_name(name)); + } + return this.aliases.get(name); + } + + /** @param {import('./nodes/Element.js').default} element */ + apply_stylesheet(element) { + this.elements.push(element); + } + + /** @param {string} name */ + global(name) { + const alias = this.alias(name); + this.globals.set(name, alias); + return alias; + } + + /** @param {{ js: import('estree').Node[]; css: import('../interfaces.js').CssResult }} [result] */ + generate(result) { + let js = null; + let css = null; + if (result) { + const { compile_options, name } = this; + const { format = 'esm' } = compile_options; + const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'__VERSION__'}`; + + /** @type {any} */ + const program = { type: 'Program', body: result.js }; + walk(program, { + enter: /** + * @param {import('estree').Node} node + * @param {import('estree').Node} parent + * @param {any} key + */ (node, parent, key) => { + if (node.type === 'Identifier') { + if (node.name[0] === '@') { + if (node.name[1] === '_') { + const alias = this.global(node.name.slice(2)); + node.name = alias.name; + } else { + let name = node.name.slice(1); + if (compile_options.hydratable) { + if (internal_exports.has(`${name}_hydration`)) { + name += '_hydration'; + } else if (internal_exports.has(`${name}Hydration`)) { + name += 'Hydration'; + } + } + if (compile_options.dev) { + if (internal_exports.has(`${name}_dev`)) { + name += '_dev'; + } else if (internal_exports.has(`${name}Dev`)) { + name += 'Dev'; + } + } + const alias = this.alias(name); + this.helpers.set(name, alias); + node.name = alias.name; + } + } else if (node.name[0] !== '#' && !is_valid(node.name)) { + // this hack allows x`foo.${bar}` where bar could be invalid + + /** @type {import('estree').Literal} */ + const literal = { type: 'Literal', value: node.name }; + if (parent.type === 'Property' && key === 'key') { + parent.key = literal; + } else if (parent.type === 'MemberExpression' && key === 'property') { + parent.property = literal; + parent.computed = true; + } + } + } + } + }); + const referenced_globals = Array.from( + this.globals, + /** @param {any}params_0 */ + ([name, alias]) => name !== alias.name && { name, alias } + ).filter(Boolean); + if (referenced_globals.length) { + this.helpers.set('globals', this.alias('globals')); + } + const imported_helpers = Array.from( + this.helpers, + /** @param {any}params_0 */ ([name, alias]) => ({ + name, + alias + }) + ); + create_module( + program, + format, + name, + banner, + compile_options.sveltePath, + imported_helpers, + referenced_globals, + this.imports, + this.vars + .filter( + /** @param {any} variable */ (variable) => variable.module && variable.export_name + ) + .map( + /** @param {any} variable */ (variable) => ({ + name: variable.name, + as: variable.export_name + }) + ), + this.exports_from + ); + css = compile_options.customElement ? { code: null, map: null } : result.css; + const js_sourcemap_enabled = check_enable_sourcemap(compile_options.enableSourcemap, 'js'); + if (!js_sourcemap_enabled) { + js = print(program); + js.map = null; + } else { + const sourcemap_source_filename = get_sourcemap_source_filename(compile_options); + js = print(program, { + sourceMapSource: sourcemap_source_filename + }); + js.map.sources = [sourcemap_source_filename]; + js.map.sourcesContent = [this.source]; + js.map = apply_preprocessor_sourcemap( + sourcemap_source_filename, + js.map, + /** @type {string | import('@ampproject/remapping').RawSourceMap | import('@ampproject/remapping').DecodedSourceMap} */ ( + compile_options.sourcemap + ) + ); + } + } + return { + js, + css, + ast: this.original_ast, + warnings: this.warnings, + vars: this.get_vars_report(), + stats: this.stats.render() + }; + } + + /** + * @param {string} name + * @param {import('./utils/scope.js').Scope} [scope] + * @returns {import('estree').Identifier} + */ + get_unique_name(name, scope) { + let alias = name; + for ( + let i = 1; + reserved.has(alias) || + this.var_lookup.has(alias) || + this.used_names.has(alias) || + this.globally_used_names.has(alias) || + (scope && scope.has(alias)); + + ) { + alias = `${name}_${i++}`; + } + this.used_names.add(alias); + return { type: 'Identifier', name: alias }; + } + get_unique_name_maker() { + const local_used_names = new Set(); + + /** @param {string} name */ + function add(name) { + local_used_names.add(name); + } + reserved.forEach(add); + internal_exports.forEach(add); + this.var_lookup.forEach( + /** + * @param {any} _value + * @param {any} key + */ (_value, key) => add(key) + ); + + /** + * @param {string} name + * @returns {import('estree').Identifier} + */ + return (name) => { + let alias = name; + for ( + let i = 1; + this.used_names.has(alias) || local_used_names.has(alias); + alias = `${name}_${i++}` + ); + local_used_names.add(alias); + this.globally_used_names.add(alias); + return { + type: 'Identifier', + name: alias + }; + }; + } + + /** @returns {import('../interfaces.js').Var[]} */ + get_vars_report() { + const { compile_options, vars } = this; + const vars_report = + compile_options.varsReport === false + ? [] + : compile_options.varsReport === 'full' + ? vars + : vars.filter(/** @param {any} v */ (v) => !v.global && !v.internal); + return vars_report.map( + /** @param {any} v */ (v) => ({ + name: v.name, + export_name: v.export_name || null, + injected: v.injected || false, + module: v.module || false, + mutated: v.mutated || false, + reassigned: v.reassigned || false, + referenced: v.referenced || false, + writable: v.writable || false, + referenced_from_script: v.referenced_from_script || false + }) + ); + } + /** + * @param {{ + * start: number; + * end: number; + * }} pos + * @param {{ + * code: string; + * message: string; + * }} e + */ + error(pos, e) { + if (this.compile_options.errorMode === 'warn') { + this.warn(pos, e); + } else { + error(e.message, { + name: 'ValidationError', + code: e.code, + source: this.source, + start: pos.start, + end: pos.end, + filename: this.compile_options.filename + }); + } + } + /** + * @param {{ + * start: number; + * end: number; + * }} pos + * @param {{ + * code: string; + * message: string; + * }} warning + */ + warn(pos, warning) { + if (this.ignores && this.ignores.has(warning.code)) { + return; + } + const start = this.locate(pos.start); + const end = this.locate(pos.end); + const frame = get_code_frame(this.source, start.line - 1, start.column); + this.warnings.push({ + code: warning.code, + message: warning.message, + frame, + start, + end, + pos: pos.start, + filename: this.compile_options.filename, + toString: () => `${warning.message} (${start.line}:${start.column})\n${frame}` + }); + } + + /** @param {any} node */ + extract_imports(node) { + this.imports.push(node); + } + + /** + * @param {any} node + * @param {any} module_script + */ + extract_exports(node, module_script = false) { + const ignores = extract_svelte_ignore_from_comments(node); + if (ignores.length) this.push_ignores(ignores); + const result = this._extract_exports(node, module_script); + if (ignores.length) this.pop_ignores(); + return result; + } + + /** + * @private + * @param {import('estree').ExportDefaultDeclaration | import('estree').ExportNamedDeclaration | import('estree').ExportAllDeclaration} node + * @param {boolean} module_script + */ + _extract_exports(node, module_script) { + if (node.type === 'ExportDefaultDeclaration') { + return this.error(/** @type {any} */ (node), compiler_errors.default_export); + } + if (node.type === 'ExportNamedDeclaration') { + if (node.source) { + if (module_script) { + this.exports_from.push(node); + } else { + this.instance_exports_from.push(node); + } + return null; + } + if (node.declaration) { + if (node.declaration.type === 'VariableDeclaration') { + node.declaration.declarations.forEach( + /** @param {any} declarator */ (declarator) => { + extract_names(declarator.id).forEach( + /** @param {any} name */ (name) => { + const variable = this.var_lookup.get(name); + variable.export_name = name; + if ( + declarator.init?.type === 'Literal' && + typeof declarator.init.value === 'boolean' + ) { + variable.is_boolean = true; + } + if ( + !module_script && + variable.writable && + !( + variable.referenced || + variable.referenced_from_script || + variable.subscribable + ) + ) { + this.warn( + /** @type {any} */ (declarator), + compiler_warnings.unused_export_let(this.name.name, name) + ); + } + } + ); + } + ); + } else { + const { name } = node.declaration.id; + const variable = this.var_lookup.get(name); + variable.export_name = name; + } + return node.declaration; + } else { + node.specifiers.forEach( + /** @param {any} specifier */ (specifier) => { + const variable = this.var_lookup.get(specifier.local.name); + if (variable) { + variable.export_name = specifier.exported.name; + if ( + !module_script && + variable.writable && + !(variable.referenced || variable.referenced_from_script || variable.subscribable) + ) { + this.warn( + /** @type {any} */ (specifier), + compiler_warnings.unused_export_let(this.name.name, specifier.exported.name) + ); + } + } + } + ); + return null; + } + } + } + + /** @param {any} script */ + extract_javascript(script) { + if (!script) return null; + return script.content.body.filter( + /** @param {any} node */ (node) => { + if (!node) return false; + if (this.hoistable_nodes.has(node)) return false; + if (this.reactive_declaration_nodes.has(node)) return false; + if (node.type === 'ImportDeclaration') return false; + if (node.type === 'ExportDeclaration' && node.specifiers.length > 0) return false; + return true; + } + ); + } + walk_module_js() { + const component = this; + const script = this.ast.module; + if (!script) return; + walk(script.content, { + /** @param {import('estree').Node} node */ + enter(node) { + if (node.type === 'LabeledStatement' && node.label.name === '$') { + component.warn( + /** @type {any} */ (node), + compiler_warnings.module_script_reactive_declaration + ); + } + } + }); + const { scope, globals } = create_scopes(script.content); + this.module_scope = scope; + scope.declarations.forEach( + /** + * @param {any} node + * @param {any} name + */ (node, name) => { + if (name[0] === '$') { + return this.error(/** @type {any} */ (node), compiler_errors.illegal_declaration); + } + const writable = + node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let'); + const imported = node.type.startsWith('Import'); + this.add_var(node, { + name, + module: true, + hoistable: true, + writable, + imported + }); + } + ); + globals.forEach( + /** + * @param {any} node + * @param {any} name + */ (node, name) => { + if (name[0] === '$') { + return this.error(/** @type {any} */ (node), compiler_errors.illegal_subscription); + } else { + this.add_var(node, { + name, + global: true, + hoistable: true + }); + } + } + ); + const { body } = script.content; + let i = body.length; + while (--i >= 0) { + const node = body[i]; + if (node.type === 'ImportDeclaration') { + this.extract_imports(node); + body.splice(i, 1); + } + if (regex_starts_with_term_export.test(node.type)) { + const replacement = this.extract_exports(node, true); + if (replacement) { + body[i] = replacement; + } else { + body.splice(i, 1); + } + } + } + } + walk_instance_js_pre_template() { + const script = this.ast.instance; + if (!script) return; + // inject vars for reactive declarations + script.content.body.forEach( + /** @param {any} node */ (node) => { + if (node.type !== 'LabeledStatement') return; + if (node.body.type !== 'ExpressionStatement') return; + const { expression } = node.body; + if (expression.type !== 'AssignmentExpression') return; + if (expression.left.type === 'MemberExpression') return; + extract_names(expression.left).forEach( + /** @param {any} name */ (name) => { + if (!this.var_lookup.has(name) && name[0] !== '$') { + this.injected_reactive_declaration_vars.add(name); + } + } + ); + } + ); + const { scope: instance_scope, map, globals } = create_scopes(script.content); + this.instance_scope = instance_scope; + this.instance_scope_map = map; + instance_scope.declarations.forEach( + /** + * @param {any} node + * @param {any} name + */ (node, name) => { + if (name[0] === '$') { + return this.error(/** @type {any} */ (node), compiler_errors.illegal_declaration); + } + const writable = + node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let'); + const imported = node.type.startsWith('Import'); + this.add_var(node, { + name, + initialised: instance_scope.initialised_declarations.has(name), + writable, + imported + }); + this.node_for_declaration.set(name, node); + } + ); + // NOTE: add store variable first, then only $store value + // as `$store` will mark `store` variable as referenced and subscribable + const global_keys = Array.from(globals.keys()); + const sorted_globals = [ + ...global_keys.filter(/** @param {any} key */ (key) => key[0] !== '$'), + ...global_keys.filter(/** @param {any} key */ (key) => key[0] === '$') + ]; + sorted_globals.forEach( + /** @param {any} name */ (name) => { + if (this.var_lookup.has(name)) return; + const node = globals.get(name); + if (this.injected_reactive_declaration_vars.has(name)) { + this.add_var(node, { + name, + injected: true, + writable: true, + reassigned: true, + initialised: true + }); + } else if (is_reserved_keyword(name)) { + this.add_var(node, { + name, + injected: true + }); + } else if (name[0] === '$') { + if (name === '$' || name[1] === '$') { + return this.error(/** @type {any} */ (node), compiler_errors.illegal_global(name)); + } + this.add_var(node, { + name, + injected: true, + mutated: true, + writable: true + }); + this.add_reference(node, name.slice(1)); + const variable = this.var_lookup.get(name.slice(1)); + if (variable) { + variable.subscribable = true; + variable.referenced_from_script = true; + } + } else { + this.add_var(node, { + name, + global: true, + hoistable: true + }); + } + } + ); + this.track_references_and_mutations(); + } + walk_instance_js_post_template() { + const script = this.ast.instance; + if (!script) return; + this.post_template_walk(); + this.hoist_instance_declarations(); + this.extract_reactive_declarations(); + this.check_if_tags_content_dynamic(); + } + post_template_walk() { + const script = this.ast.instance; + if (!script) return; + const component = this; + const { content } = script; + const { instance_scope, instance_scope_map: map } = this; + let scope = instance_scope; + const to_remove = []; + + /** + * @param {any} parent + * @param {any} prop + * @param {any} index + */ + const remove = (parent, prop, index) => { + to_remove.unshift([parent, prop, index]); + }; + let scope_updated = false; + const current_function_stack = []; + + /** @type {import('estree').FunctionDeclaration | import('estree').FunctionExpression} */ + let current_function = null; + walk(content, { + /** + * @param {import('estree').Node} node + * @param {import('estree').Node} parent + * @param {any} prop + * @param {any} index + */ + enter(node, parent, prop, index) { + if (node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') { + current_function_stack.push((current_function = node)); + } + if (map.has(node)) { + scope = map.get(node); + } + let deep = false; + + /** @type {string[]} */ + let names = []; + if (node.type === 'AssignmentExpression') { + if (node.left.type === 'ArrayPattern') { + walk(node.left, { + /** + * @param {import('estree').Node} node + * @param {import('estree').Node} parent + */ + enter(node, parent) { + if ( + node.type === 'Identifier' && + parent.type !== 'MemberExpression' && + (parent.type !== 'AssignmentPattern' || parent.right !== node) + ) { + names.push(node.name); + } + } + }); + } else { + deep = node.left.type === 'MemberExpression'; + names = deep ? [get_object(node.left).name] : extract_names(node.left); + } + } else if (node.type === 'UpdateExpression') { + deep = node.argument.type === 'MemberExpression'; + const { name } = get_object(node.argument); + names.push(name); + } + if (names.length > 0) { + names.forEach( + /** @param {any} name */ (name) => { + let current_scope = scope; + let declaration; + while (current_scope) { + if (current_scope.declarations.has(name)) { + declaration = current_scope.declarations.get(name); + break; + } + current_scope = current_scope.parent; + } + if (declaration && /** @type {any} */ (declaration).kind === 'const' && !deep) { + component.error(/** @type {any} */ (node), { + code: 'assignment-to-const', + message: 'You are assigning to a const' + }); + } + } + ); + } + if (node.type === 'ImportDeclaration') { + component.extract_imports(node); + // TODO: to use actual remove + remove(parent, prop, index); + return this.skip(); + } + if (regex_starts_with_term_export.test(node.type)) { + const replacement = component.extract_exports(node); + if (replacement) { + this.replace(replacement); + } else { + // TODO: to use actual remove + remove(parent, prop, index); + } + return this.skip(); + } + component.warn_on_undefined_store_value_references(node, parent, prop, scope); + }, + + /** @param {import('estree').Node} node */ + leave(node) { + if (node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') { + current_function_stack.pop(); + current_function = current_function_stack[current_function_stack.length - 1]; + } + // do it on leave, to prevent infinite loop + if ( + component.compile_options.dev && + component.compile_options.loopGuardTimeout > 0 && + (!current_function || (!current_function.generator && !current_function.async)) + ) { + const to_replace_for_loop_protect = component.loop_protect( + node, + scope, + component.compile_options.loopGuardTimeout + ); + if (to_replace_for_loop_protect) { + this.replace(to_replace_for_loop_protect); + scope_updated = true; + } + } + if (map.has(node)) { + scope = scope.parent; + } + } + }); + for (const [parent, prop, index] of to_remove) { + if (parent) { + if (index !== null) { + parent[prop].splice(index, 1); + } else { + delete parent[prop]; + } + } + } + if (scope_updated) { + const { scope, map } = create_scopes(script.content); + this.instance_scope = scope; + this.instance_scope_map = map; + } + } + track_references_and_mutations() { + const script = this.ast.instance; + if (!script) return; + const component = this; + const { content } = script; + const { instance_scope, module_scope, instance_scope_map: map } = this; + let scope = instance_scope; + walk(content, { + /** + * @param {import('estree').Node} node + * @param {import('estree').Node} parent + */ + enter(node, parent) { + if (map.has(node)) { + scope = map.get(node); + } + if (node.type === 'AssignmentExpression' || node.type === 'UpdateExpression') { + const assignee = node.type === 'AssignmentExpression' ? node.left : node.argument; + const names = extract_names(/** @type {import('estree').Node} */ (assignee)); + const deep = assignee.type === 'MemberExpression'; + names.forEach( + /** @param {any} name */ (name) => { + const scope_owner = scope.find_owner(name); + if ( + scope_owner !== null + ? scope_owner === instance_scope + : module_scope && module_scope.has(name) + ) { + const variable = component.var_lookup.get(name); + variable[deep ? 'mutated' : 'reassigned'] = true; + } + } + ); + } + if (is_used_as_reference(node, parent)) { + const object = get_object(node); + if (scope.find_owner(object.name) === instance_scope) { + const variable = component.var_lookup.get(object.name); + variable.referenced_from_script = true; + } + } + }, + + /** @param {import('estree').Node} node */ + leave(node) { + if (map.has(node)) { + scope = scope.parent; + } + } + }); + } + + /** + * @param {import('estree').Node} node + * @param {import('estree').Node} parent + * @param {string | number | symbol} prop + * @param {import('./utils/scope.js').Scope} scope + */ + warn_on_undefined_store_value_references(node, parent, prop, scope) { + if (node.type === 'LabeledStatement' && node.label.name === '$' && parent.type !== 'Program') { + this.warn(/** @type {any} */ (node), compiler_warnings.non_top_level_reactive_declaration); + } + if ( + is_reference( + /** @type {import('is-reference').NodeWithPropertyDefinition} */ (node), + /** @type {import('is-reference').NodeWithPropertyDefinition} */ (parent) + ) + ) { + const object = get_object(node); + const { name } = object; + if (name[0] === '$') { + if (!scope.has(name)) { + this.warn_if_undefined(name, object, null); + } + if ( + name[1] !== '$' && + scope.has(name.slice(1)) && + scope.find_owner(name.slice(1)) !== this.instance_scope + ) { + if ( + !( + (regex_contains_term_function.test(parent.type) && prop === 'params') || + (parent.type === 'VariableDeclarator' && prop === 'id') + ) + ) { + return this.error(/** @type {any} */ (node), compiler_errors.contextual_store); + } + } + } + } + } + + /** + * @param {any} node + * @param {import('./utils/scope.js').Scope} scope + * @param {number} timeout + * @returns {import('estree').Node} + */ + loop_protect(node, scope, timeout) { + if ( + node.type === 'WhileStatement' || + node.type === 'ForStatement' || + node.type === 'DoWhileStatement' + ) { + const guard = this.get_unique_name('guard', scope); + this.used_names.add(guard.name); + const before = b`const ${guard} = @loop_guard(${timeout})`; + const inside = b`${guard}();`; + // wrap expression statement with BlockStatement + if (node.body.type !== 'BlockStatement') { + node.body = { + type: 'BlockStatement', + body: [node.body] + }; + } + node.body.body.push(inside[0]); + return { + type: 'BlockStatement', + body: [before[0], node] + }; + } + return null; + } + + /** @param {(variable: import('../interfaces.js').Var) => import('estree').Node[]} get_insert */ + rewrite_props(get_insert) { + if (!this.ast.instance) return; + const component = this; + const { instance_scope, instance_scope_map: map } = this; + let scope = instance_scope; + walk(this.ast.instance.content, { + /** @param {import('estree').Node} node */ + enter(node) { + if (regex_contains_term_function.test(node.type)) { + return this.skip(); + } + if (map.has(node)) { + scope = map.get(node); + } + if (node.type === 'ExportNamedDeclaration' && node.declaration) { + return this.replace(node.declaration); + } + if (node.type === 'VariableDeclaration') { + // NOTE: `var` does not follow block scoping + if (node.kind === 'var' || scope === instance_scope) { + const inserts = []; + const props = []; + + /** + * @param {import('estree').Identifier} exported + * @param {import('estree').Pattern} local + * @param {import('estree').Expression} default_value + */ + function add_new_props(exported, local, default_value) { + props.push({ + type: 'Property', + method: false, + shorthand: false, + computed: false, + kind: 'init', + key: exported, + value: default_value + ? { + type: 'AssignmentPattern', + left: local, + right: default_value + } + : local + }); + } + // transform + // ``` + // export let { x, y = 123 } = OBJ, z = 456 + // ``` + // into + // ``` + // let { x: x$, y: y$ = 123 } = OBJ; + // let { x = x$, y = y$, z = 456 } = $$props; + // ``` + for (let index = 0; index < node.declarations.length; index++) { + const declarator = node.declarations[index]; + if (declarator.id.type !== 'Identifier') { + /** + * @param {import('estree').Identifier} local + * @returns {import('estree').Identifier} + */ + function get_new_name(local) { + const variable = component.var_lookup.get(local.name); + if (variable.subscribable) { + inserts.push(get_insert(variable)); + } + if (variable.export_name && variable.writable) { + const alias_name = component.get_unique_name(local.name); + add_new_props( + { type: 'Identifier', name: variable.export_name }, + local, + alias_name + ); + return alias_name; + } + return local; + } + + /** @param {import('estree').Pattern} param */ + function rename_identifiers(param) { + switch (param.type) { + case 'ObjectPattern': { + /** @param {import('estree').Property | import('estree').RestElement} prop */ + const handle_prop = (prop) => { + if (prop.type === 'RestElement') { + rename_identifiers(prop); + } else if (prop.value.type === 'Identifier') { + prop.value = get_new_name(prop.value); + } else { + rename_identifiers(/** @type {import('estree').Pattern} */ (prop.value)); + } + }; + param.properties.forEach(handle_prop); + break; + } + case 'ArrayPattern': { + /** + * @param {import('estree').Pattern | null} element + * @param {number} index + * @param {Array} array + */ + const handle_element = (element, index, array) => { + if (element) { + if (element.type === 'Identifier') { + array[index] = get_new_name(element); + } else { + rename_identifiers(element); + } + } + }; + param.elements.forEach(handle_element); + break; + } + case 'RestElement': + if (param.argument.type === 'Identifier') { + param.argument = get_new_name(param.argument); + } else { + rename_identifiers(param.argument); + } + break; + case 'AssignmentPattern': + if (param.left.type === 'Identifier') { + param.left = get_new_name(param.left); + } else { + rename_identifiers(param.left); + } + break; + } + } + rename_identifiers(declarator.id); + } else { + const { name } = declarator.id; + const variable = component.var_lookup.get(name); + const is_props = variable.export_name && variable.writable; + if (is_props) { + add_new_props( + { type: 'Identifier', name: variable.export_name }, + declarator.id, + declarator.init + ); + node.declarations.splice(index--, 1); + } + if (variable.subscribable && (is_props || declarator.init)) { + inserts.push(get_insert(variable)); + } + } + } + this.replace( + /** @type {any} */ ( + b` + ${node.declarations.length ? node : null} + ${props.length > 0 && b`let { ${props} } = $$props;`} + ${inserts} + ` + ) + ); + return this.skip(); + } + } + }, + + /** @param {import('estree').Node} node */ + leave(node) { + if (map.has(node)) { + scope = scope.parent; + } + } + }); + } + hoist_instance_declarations() { + // we can safely hoist variable declarations that are + // initialised to literals, and functions that don't + // reference instance variables other than other + // hoistable functions. TODO others? + const { hoistable_nodes, var_lookup, injected_reactive_declaration_vars, imports } = this; + const top_level_function_declarations = new Map(); + const { body } = this.ast.instance.content; + for (let i = 0; i < body.length; i += 1) { + const node = body[i]; + if (node.type === 'VariableDeclaration') { + const all_hoistable = node.declarations.every( + /** @param {any} d */ (d) => { + if (!d.init) return false; + if (d.init.type !== 'Literal') return false; + // everything except const values can be changed by e.g. svelte devtools + // which means we can't hoist it + if (node.kind !== 'const' && this.compile_options.dev) return false; + const { name } = /** @type {import('estree').Identifier} */ (d.id); + const v = this.var_lookup.get(name); + if (v.reassigned) return false; + if (v.export_name) return false; + if (this.var_lookup.get(name).reassigned) return false; + if ( + this.vars.find( + /** @param {any} variable */ (variable) => variable.name === name && variable.module + ) + ) { + return false; + } + return true; + } + ); + if (all_hoistable) { + node.declarations.forEach( + /** @param {any} d */ (d) => { + const variable = this.var_lookup.get( + /** @type {import('estree').Identifier} */ (d.id).name + ); + variable.hoistable = true; + } + ); + hoistable_nodes.add(node); + body.splice(i--, 1); + this.fully_hoisted.push(node); + } + } + if ( + node.type === 'ExportNamedDeclaration' && + node.declaration && + node.declaration.type === 'FunctionDeclaration' + ) { + top_level_function_declarations.set(node.declaration.id.name, node); + } + if (node.type === 'FunctionDeclaration') { + top_level_function_declarations.set(node.id.name, node); + } + } + const checked = new Set(); + const walking = new Set(); + + /** @param {any} fn_declaration */ + const is_hoistable = (fn_declaration) => { + if (fn_declaration.type === 'ExportNamedDeclaration') { + fn_declaration = fn_declaration.declaration; + } + const instance_scope = this.instance_scope; + let scope = this.instance_scope; + const map = this.instance_scope_map; + let hoistable = true; + // handle cycles + walking.add(fn_declaration); + walk(fn_declaration, { + /** + * @param {import('estree').Node} node + * @param {any} parent + */ + enter(node, parent) { + if (!hoistable) return this.skip(); + if (map.has(node)) { + scope = map.get(node); + } + if ( + is_reference( + /** @type {import('is-reference').NodeWithPropertyDefinition} */ (node), + /** @type {import('is-reference').NodeWithPropertyDefinition} */ (parent) + ) + ) { + const { name } = flatten_reference(node); + const owner = scope.find_owner(name); + if (injected_reactive_declaration_vars.has(name)) { + hoistable = false; + } else if (name[0] === '$' && !owner) { + hoistable = false; + } else if (owner === instance_scope) { + const variable = var_lookup.get(name); + if (variable.reassigned || variable.mutated) hoistable = false; + if (name === fn_declaration.id.name) return; + if (variable.hoistable) return; + if (top_level_function_declarations.has(name)) { + const other_declaration = top_level_function_declarations.get(name); + if (walking.has(other_declaration)) { + hoistable = false; + } else if ( + other_declaration.type === 'ExportNamedDeclaration' && + walking.has(other_declaration.declaration) + ) { + hoistable = false; + } else if (!is_hoistable(other_declaration)) { + hoistable = false; + } + } else { + hoistable = false; + } + } + this.skip(); + } + }, + + /** @param {import('estree').Node} node */ + leave(node) { + if (map.has(node)) { + scope = scope.parent; + } + } + }); + checked.add(fn_declaration); + walking.delete(fn_declaration); + return hoistable; + }; + for (const [name, node] of top_level_function_declarations) { + if (is_hoistable(node)) { + const variable = this.var_lookup.get(name); + variable.hoistable = true; + hoistable_nodes.add(node); + const i = body.indexOf(node); + body.splice(i, 1); + this.fully_hoisted.push(node); + } + } + for (const { specifiers } of imports) { + for (const specifier of specifiers) { + const variable = var_lookup.get(specifier.local.name); + if (!variable.mutated || variable.subscribable) { + variable.hoistable = true; + } + } + } + } + extract_reactive_declarations() { + const component = this; + /** + * @type {Array<{ + * assignees: Set; + * dependencies: Set; + * node: import('estree').Node; + * declaration: import('estree').Node; + * }>} + */ + const unsorted_reactive_declarations = []; + this.ast.instance.content.body.forEach( + /** @param {any} node */ (node) => { + const ignores = extract_svelte_ignore_from_comments(node); + if (ignores.length) this.push_ignores(ignores); + if (node.type === 'LabeledStatement' && node.label.name === '$') { + this.reactive_declaration_nodes.add(node); + const assignees = new Set(); + const assignee_nodes = new Set(); + const dependencies = new Set(); + const module_dependencies = new Set(); + let scope = this.instance_scope; + const { declarations: outset_scope_decalarations } = this.instance_scope; + const map = this.instance_scope_map; + walk(node.body, { + /** + * @param {import('estree').Node} node + * @param {any} parent + */ + enter(node, parent) { + if (node.type === 'VariableDeclaration' && node.kind === 'var') { + const is_var_in_outset = node.declarations.some( + /** @param {import('estree').VariableDeclarator} declaration */ (declaration) => { + /** @type {string[]} */ + const names = extract_names(declaration.id); + return !!names.find( + /** @param {string} name */ (name) => { + const var_node = outset_scope_decalarations.get(name); + return var_node === node; + } + ); + } + ); + if (is_var_in_outset) { + return component.error( + /** @type {any} */ (node), + compiler_errors.invalid_var_declaration + ); + } + } + if (map.has(node)) { + scope = map.get(node); + } + if (node.type === 'AssignmentExpression') { + const left = get_object(node.left); + extract_identifiers(left).forEach( + /** @param {any} node */ (node) => { + assignee_nodes.add(node); + assignees.add(node.name); + } + ); + if (node.operator !== '=') { + dependencies.add(left.name); + } + } else if (node.type === 'UpdateExpression') { + const identifier = get_object(node.argument); + assignees.add(identifier.name); + } else if ( + is_reference( + /** @type {import('is-reference').NodeWithPropertyDefinition} */ (node), + /** @type {import('is-reference').NodeWithPropertyDefinition} */ (parent) + ) + ) { + const identifier = get_object(node); + if (!assignee_nodes.has(identifier)) { + const { name } = identifier; + const owner = scope.find_owner(name); + const variable = component.var_lookup.get(name); + let should_add_as_dependency = true; + if (variable) { + variable.is_reactive_dependency = true; + if (variable.module && variable.writable) { + should_add_as_dependency = false; + module_dependencies.add(name); + } + } + const is_writable_or_mutated = + variable && (variable.writable || variable.mutated); + if ( + should_add_as_dependency && + (!owner || owner === component.instance_scope) && + (name[0] === '$' || is_writable_or_mutated) + ) { + dependencies.add(name); + } + } + this.skip(); + } + }, + + /** @param {import('estree').Node} node */ + leave(node) { + if (map.has(node)) { + scope = scope.parent; + } + } + }); + if (module_dependencies.size > 0 && dependencies.size === 0) { + component.warn( + /** @type {any} */ (node.body), + compiler_warnings.module_script_variable_reactive_declaration( + Array.from(module_dependencies) + ) + ); + } + const { expression } = /** @type {import('estree').ExpressionStatement} */ (node.body); + const declaration = + expression && /** @type {import('estree').AssignmentExpression} */ (expression).left; + unsorted_reactive_declarations.push({ + assignees, + dependencies, + node, + declaration + }); + } + if (ignores.length) this.pop_ignores(); + } + ); + const lookup = new Map(); + unsorted_reactive_declarations.forEach( + /** @param {any} declaration */ (declaration) => { + declaration.assignees.forEach( + /** @param {any} name */ (name) => { + if (!lookup.has(name)) { + lookup.set(name, []); + } + // TODO warn or error if a name is assigned to in + // multiple reactive declarations? + lookup.get(name).push(declaration); + } + ); + } + ); + const cycle = check_graph_for_cycles( + unsorted_reactive_declarations.reduce( + /** + * @param {any} acc + * @param {any} declaration + */ (acc, declaration) => { + declaration.assignees.forEach( + /** @param {any} v */ (v) => { + declaration.dependencies.forEach( + /** @param {any} w */ (w) => { + if (!declaration.assignees.has(w)) { + acc.push([v, w]); + } + } + ); + } + ); + return acc; + }, + [] + ) + ); + if (cycle && cycle.length) { + const declarationList = lookup.get(cycle[0]); + const declaration = declarationList[0]; + return this.error(declaration.node, compiler_errors.cyclical_reactive_declaration(cycle)); + } + + /** @param {any} declaration */ + const add_declaration = (declaration) => { + if (this.reactive_declarations.includes(declaration)) return; + declaration.dependencies.forEach( + /** @param {any} name */ (name) => { + if (declaration.assignees.has(name)) return; + const earlier_declarations = lookup.get(name); + if (earlier_declarations) { + earlier_declarations.forEach(add_declaration); + } + } + ); + this.reactive_declarations.push(declaration); + }; + unsorted_reactive_declarations.forEach(add_declaration); + } + check_if_tags_content_dynamic() { + this.tags.forEach( + /** @param {any} tag */ (tag) => { + tag.check_if_content_dynamic(); + } + ); + } + + /** + * @param {string} name + * @param {any} node + * @param {import('./nodes/shared/TemplateScope.js').default} template_scope + */ + warn_if_undefined(name, node, template_scope) { + if (name[0] === '$') { + if (name === '$' || (name[1] === '$' && !is_reserved_keyword(name))) { + return this.error(node, compiler_errors.illegal_global(name)); + } + this.has_reactive_assignments = true; // TODO does this belong here? + if (is_reserved_keyword(name)) return; + name = name.slice(1); + } + if (this.var_lookup.has(name) && !this.var_lookup.get(name).global) return; + if (template_scope && template_scope.names.has(name)) return; + if (globals.has(name) && node.type !== 'InlineComponent') return; + this.warn(node, compiler_warnings.missing_declaration(name, !!this.ast.instance)); + } + + /** @param {any} ignores */ + push_ignores(ignores) { + this.ignores = new Set(this.ignores || []); + add_to_set(this.ignores, ignores); + this.ignore_stack.push(this.ignores); + } + pop_ignores() { + this.ignore_stack.pop(); + this.ignores = this.ignore_stack[this.ignore_stack.length - 1]; + } +} +const regex_valid_tag_name = /^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/; + +/** + * @param {Component} component + * @param {any} nodes + */ +function process_component_options(component, nodes) { + /** @type {ComponentOptions} */ + const component_options = { + immutable: component.compile_options.immutable || false, + accessors: + 'accessors' in component.compile_options + ? component.compile_options.accessors + : !!component.compile_options.customElement, + preserveWhitespace: !!component.compile_options.preserveWhitespace, + namespace: component.compile_options.namespace + }; + const node = nodes.find(/** @param {any} node */ (node) => node.name === 'svelte:options'); + + /** + * @param {any} attribute + * @param {any}params_0 + */ + function get_value(attribute, { code, message }) { + const { value } = attribute; + const chunk = value[0]; + if (!chunk) return true; + if (value.length > 1) { + return component.error(attribute, { code, message }); + } + if (chunk.type === 'Text') return chunk.data; + if (chunk.expression.type !== 'Literal') { + return component.error(attribute, { code, message }); + } + return chunk.expression.value; + } + if (node) { + node.attributes.forEach( + /** @param {any} attribute */ (attribute) => { + if (attribute.type === 'Attribute') { + const { name } = attribute; + + /** + * @param {import('../interfaces.js').Attribute} attribute + * @param {string} tag + */ + function parse_tag(attribute, tag) { + if (typeof tag !== 'string' && tag !== null) { + return component.error(attribute, compiler_errors.invalid_tag_attribute); + } + if (tag && !regex_valid_tag_name.test(tag)) { + return component.error(attribute, compiler_errors.invalid_tag_property); + } + if (tag && !component.compile_options.customElement) { + component.warn(attribute, compiler_warnings.missing_custom_element_compile_options); + } + component_options.customElement = + component_options.customElement || /** @type {any} */ ({}); + component_options.customElement.tag = tag; + } + switch (name) { + case 'tag': { + component.warn(attribute, compiler_warnings.tag_option_deprecated); + parse_tag(attribute, get_value(attribute, compiler_errors.invalid_tag_attribute)); + break; + } + case 'customElement': { + component_options.customElement = + component_options.customElement || /** @type {any} */ ({}); + const { value } = attribute; + if (value[0].type === 'MustacheTag' && value[0].expression?.value === null) { + component_options.customElement.tag = null; + break; + } else if (value[0].type === 'Text') { + parse_tag(attribute, get_value(attribute, compiler_errors.invalid_tag_attribute)); + break; + } else if (value[0].expression.type !== 'ObjectExpression') { + return component.error(attribute, compiler_errors.invalid_customElement_attribute); + } + const tag = value[0].expression.properties.find( + /** @param {any} prop */ (prop) => prop.key.name === 'tag' + ); + if (tag) { + parse_tag(tag, tag.value?.value); + } else { + return component.error(attribute, compiler_errors.invalid_customElement_attribute); + } + const props = value[0].expression.properties.find( + /** @param {any} prop */ + (prop) => prop.key.name === 'props' + ); + if (props) { + const error = () => + component.error(attribute, compiler_errors.invalid_props_attribute); + if (props.value?.type !== 'ObjectExpression') { + return error(); + } + component_options.customElement.props = {}; + for (const property of /** @type {import('estree').ObjectExpression} */ ( + props.value + ).properties) { + if ( + property.type !== 'Property' || + property.computed || + property.key.type !== 'Identifier' || + property.value.type !== 'ObjectExpression' + ) { + return error(); + } + component_options.customElement.props[property.key.name] = {}; + for (const prop of property.value.properties) { + if ( + prop.type !== 'Property' || + prop.computed || + prop.key.type !== 'Identifier' || + prop.value.type !== 'Literal' + ) { + return error(); + } + if ( + ['reflect', 'attribute', 'type'].indexOf(prop.key.name) === -1 || + (prop.key.name === 'type' && + ['String', 'Number', 'Boolean', 'Array', 'Object'].indexOf( + /** @type {string} */ (prop.value.value) + ) === -1) || + (prop.key.name === 'reflect' && typeof prop.value.value !== 'boolean') || + (prop.key.name === 'attribute' && typeof prop.value.value !== 'string') + ) { + return error(); + } + component_options.customElement.props[property.key.name][prop.key.name] = + prop.value.value; + } + } + } + const shadow = value[0].expression.properties.find( + /** @param {any} prop */ + (prop) => prop.key.name === 'shadow' + ); + if (shadow) { + const shadowdom = shadow.value?.value; + if (shadowdom !== 'open' && shadowdom !== 'none') { + return component.error(shadow, compiler_errors.invalid_shadow_attribute); + } + component_options.customElement.shadow = shadowdom; + } + break; + } + case 'namespace': { + const ns = get_value(attribute, compiler_errors.invalid_namespace_attribute); + if (typeof ns !== 'string') { + return component.error(attribute, compiler_errors.invalid_namespace_attribute); + } + if (valid_namespaces.indexOf(ns) === -1) { + const match = fuzzymatch(ns, valid_namespaces); + return component.error( + attribute, + compiler_errors.invalid_namespace_property(ns, match) + ); + } + component_options.namespace = ns; + break; + } + case 'accessors': + case 'immutable': + case 'preserveWhitespace': { + const value = get_value(attribute, compiler_errors.invalid_attribute_value(name)); + if (typeof value !== 'boolean') { + return component.error(attribute, compiler_errors.invalid_attribute_value(name)); + } + component_options[name] = value; + break; + } + default: + return component.error( + attribute, + compiler_errors.invalid_options_attribute_unknown(name) + ); + } + } else { + return component.error(attribute, compiler_errors.invalid_options_attribute); + } + } + ); + } + return component_options; +} + +/** + * @param {string} from + * @param {string} to + */ +function get_relative_path(from, to) { + const from_parts = from.split(/[/\\]/); + const to_parts = to.split(/[/\\]/); + from_parts.pop(); // get dirname + while (from_parts[0] === to_parts[0]) { + from_parts.shift(); + to_parts.shift(); + } + if (from_parts.length) { + let i = from_parts.length; + while (i--) from_parts[i] = '..'; + } + return from_parts.concat(to_parts).join('/'); +} + +/** @param {string} filename */ +function get_basename(filename) { + return filename.split(/[/\\]/).pop(); +} + +/** @param {import('../interfaces.js').CompileOptions} compile_options */ +function get_sourcemap_source_filename(compile_options) { + if (!compile_options.filename) return null; + return compile_options.outputFilename + ? get_relative_path(compile_options.outputFilename, compile_options.filename) + : get_basename(compile_options.filename); +} + +/** @typedef {Object} ComponentOptions + * @property {string} [namespace] + * @property {boolean} [immutable] + * @property {boolean} [accessors] + * @property {boolean} [preserveWhitespace] + * @property {Object} [customElement] + * @property {string|null} customElement.tag + * @property {'open'|'none'} [customElement.shadow] + * @property {Record} [customElement.props] + */ diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts deleted file mode 100644 index 14f68a08f0..0000000000 --- a/src/compiler/compile/Component.ts +++ /dev/null @@ -1,1842 +0,0 @@ -import type { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping'; -import { walk } from 'estree-walker'; -import { getLocator } from 'locate-character'; -import Stats from '../Stats'; -import { reserved, is_valid } from '../utils/names'; -import globals from '../utils/globals'; -import { namespaces, valid_namespaces } from '../utils/namespaces'; -import create_module from './create_module'; -import { create_scopes, extract_names, Scope, extract_identifiers } from './utils/scope'; -import Stylesheet from './css/Stylesheet'; -import Fragment from './nodes/Fragment'; -import internal_exports from './internal_exports'; -import { Ast, CompileOptions, Var, Warning, CssResult, Attribute } from '../interfaces'; -import error from '../utils/error'; -import get_code_frame from '../utils/get_code_frame'; -import flatten_reference from './utils/flatten_reference'; -import is_used_as_reference from './utils/is_used_as_reference'; -import is_reference, { NodeWithPropertyDefinition } from 'is-reference'; -import TemplateScope from './nodes/shared/TemplateScope'; -import fuzzymatch from '../utils/fuzzymatch'; -import get_object from './utils/get_object'; -import Slot from './nodes/Slot'; -import { - Node, - ImportDeclaration, - ExportNamedDeclaration, - Identifier, - ExpressionStatement, - AssignmentExpression, - Literal, - Property, - RestElement, - ExportDefaultDeclaration, - ExportAllDeclaration, - FunctionDeclaration, - FunctionExpression, - VariableDeclarator, - ObjectExpression, - Pattern, - Expression -} from 'estree'; -import add_to_set from './utils/add_to_set'; -import check_graph_for_cycles from './utils/check_graph_for_cycles'; -import { print, b } from 'code-red'; -import { is_reserved_keyword } from './utils/reserved_keywords'; -import { apply_preprocessor_sourcemap } from '../utils/mapped_code'; -import Element from './nodes/Element'; -import { clone } from '../utils/clone'; -import compiler_warnings from './compiler_warnings'; -import compiler_errors from './compiler_errors'; -import { - extract_ignores_above_position, - extract_svelte_ignore_from_comments -} from '../utils/extract_svelte_ignore'; -import check_enable_sourcemap from './utils/check_enable_sourcemap'; -import Tag from './nodes/shared/Tag'; - -interface ComponentOptions { - namespace?: string; - immutable?: boolean; - accessors?: boolean; - preserveWhitespace?: boolean; - customElement?: { - tag: string | null; - shadow?: 'open' | 'none'; - props?: Record< - string, - { - attribute?: string; - reflect?: boolean; - type?: 'String' | 'Boolean' | 'Number' | 'Array' | 'Object'; - } - >; - }; -} - -const regex_leading_directory_separator = /^[/\\]/; -const regex_starts_with_term_export = /^Export/; -const regex_contains_term_function = /Function/; - -export default class Component { - stats: Stats; - warnings: Warning[]; - ignores: Set; - ignore_stack: Array> = []; - - ast: Ast; - original_ast: Ast; - source: string; - name: Identifier; - compile_options: CompileOptions; - fragment: Fragment; - module_scope: Scope; - instance_scope: Scope; - instance_scope_map: WeakMap; - - component_options: ComponentOptions; - namespace: string; - tag: string; - accessors: boolean; - - vars: Var[] = []; - var_lookup: Map = new Map(); - - imports: ImportDeclaration[] = []; - exports_from: ExportNamedDeclaration[] = []; - instance_exports_from: ExportNamedDeclaration[] = []; - - hoistable_nodes: Set = new Set(); - node_for_declaration: Map = new Map(); - partly_hoisted: Array = []; - fully_hoisted: Array = []; - reactive_declarations: Array<{ - assignees: Set; - dependencies: Set; - node: Node; - declaration: Node; - }> = []; - reactive_declaration_nodes: Set = new Set(); - has_reactive_assignments = false; - injected_reactive_declaration_vars: Set = new Set(); - helpers: Map = new Map(); - globals: Map = new Map(); - - indirect_dependencies: Map> = new Map(); - - file: string; - locate: (c: number) => { line: number; column: number }; - - elements: Element[] = []; - stylesheet: Stylesheet; - - aliases: Map = new Map(); - used_names: Set = new Set(); - globally_used_names: Set = new Set(); - - slots: Map = new Map(); - slot_outlets: Set = new Set(); - - tags: Tag[] = []; - - constructor( - ast: Ast, - source: string, - name: string, - compile_options: CompileOptions, - stats: Stats, - warnings: Warning[] - ) { - this.name = { type: 'Identifier', name }; - - this.stats = stats; - this.warnings = warnings; - this.ast = ast; - this.source = source; - this.compile_options = compile_options; - - // the instance JS gets mutated, so we park - // a copy here for later. TODO this feels gross - this.original_ast = clone({ - html: ast.html, - css: ast.css, - instance: ast.instance, - module: ast.module - }); - - this.file = - compile_options.filename && - (typeof process !== 'undefined' - ? compile_options.filename - .replace(process.cwd(), '') - .replace(regex_leading_directory_separator, '') - : compile_options.filename); - this.locate = getLocator(this.source, { offsetLine: 1 }); - - // styles - this.stylesheet = new Stylesheet({ - source, - ast, - filename: compile_options.filename, - component_name: name, - dev: compile_options.dev, - get_css_hash: compile_options.cssHash - }); - this.stylesheet.validate(this); - - this.component_options = process_component_options(this, this.ast.html.children); - this.namespace = - namespaces[this.component_options.namespace] || this.component_options.namespace; - - if (compile_options.customElement) { - this.tag = this.component_options.customElement?.tag || compile_options.tag || this.name.name; - } else { - this.tag = this.name.name; - } - - this.walk_module_js(); - - this.push_ignores( - this.ast.instance - ? extract_ignores_above_position(this.ast.instance.start, this.ast.html.children) - : [] - ); - this.walk_instance_js_pre_template(); - this.pop_ignores(); - - this.fragment = new Fragment(this, ast.html); - this.name = this.get_unique_name(name); - - this.push_ignores( - this.ast.instance - ? extract_ignores_above_position(this.ast.instance.start, this.ast.html.children) - : [] - ); - this.walk_instance_js_post_template(); - this.pop_ignores(); - - this.elements.forEach((element) => this.stylesheet.apply(element)); - this.stylesheet.reify(); - this.stylesheet.warn_on_unused_selectors(this); - } - - add_var(node: Node, variable: Var, add_to_lookup = true) { - this.vars.push(variable); - - if (add_to_lookup) { - if (this.var_lookup.has(variable.name)) { - const exists_var = this.var_lookup.get(variable.name); - if (exists_var.module && exists_var.imported) { - this.error(node as any, compiler_errors.illegal_variable_declaration); - } - } - this.var_lookup.set(variable.name, variable); - } - } - - add_reference(node: Node, name: string) { - const variable = this.var_lookup.get(name); - - if (variable) { - variable.referenced = true; - } else if (is_reserved_keyword(name)) { - this.add_var(node, { - name, - injected: true, - referenced: true - }); - } else if (name[0] === '$') { - this.add_var(node, { - name, - injected: true, - referenced: true, - mutated: true, - writable: true - }); - - const subscribable_name = name.slice(1); - - const variable = this.var_lookup.get(subscribable_name); - if (variable) { - variable.referenced = true; - variable.subscribable = true; - } - } else { - if (this.compile_options.varsReport === 'full') { - this.add_var(node, { name, referenced: true }, false); - } - - this.used_names.add(name); - } - } - - alias(name: string) { - if (!this.aliases.has(name)) { - this.aliases.set(name, this.get_unique_name(name)); - } - - return this.aliases.get(name); - } - - apply_stylesheet(element: Element) { - this.elements.push(element); - } - - global(name: string) { - const alias = this.alias(name); - this.globals.set(name, alias); - return alias; - } - - generate(result?: { js: Node[]; css: CssResult }) { - let js = null; - let css = null; - - if (result) { - const { compile_options, name } = this; - const { format = 'esm' } = compile_options; - - const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'__VERSION__'}`; - - const program: any = { type: 'Program', body: result.js }; - - walk(program, { - enter: (node: Node, parent: Node, key) => { - if (node.type === 'Identifier') { - if (node.name[0] === '@') { - if (node.name[1] === '_') { - const alias = this.global(node.name.slice(2)); - node.name = alias.name; - } else { - let name = node.name.slice(1); - - if (compile_options.hydratable) { - if (internal_exports.has(`${name}_hydration`)) { - name += '_hydration'; - } else if (internal_exports.has(`${name}Hydration`)) { - name += 'Hydration'; - } - } - - if (compile_options.dev) { - if (internal_exports.has(`${name}_dev`)) { - name += '_dev'; - } else if (internal_exports.has(`${name}Dev`)) { - name += 'Dev'; - } - } - - const alias = this.alias(name); - this.helpers.set(name, alias); - node.name = alias.name; - } - } else if (node.name[0] !== '#' && !is_valid(node.name)) { - // this hack allows x`foo.${bar}` where bar could be invalid - const literal: Literal = { type: 'Literal', value: node.name }; - - if (parent.type === 'Property' && key === 'key') { - parent.key = literal; - } else if (parent.type === 'MemberExpression' && key === 'property') { - parent.property = literal; - parent.computed = true; - } - } - } - } - }); - - const referenced_globals = Array.from( - this.globals, - ([name, alias]) => name !== alias.name && { name, alias } - ).filter(Boolean); - if (referenced_globals.length) { - this.helpers.set('globals', this.alias('globals')); - } - const imported_helpers = Array.from(this.helpers, ([name, alias]) => ({ - name, - alias - })); - - create_module( - program, - format, - name, - banner, - compile_options.sveltePath, - imported_helpers, - referenced_globals, - this.imports, - this.vars - .filter((variable) => variable.module && variable.export_name) - .map((variable) => ({ - name: variable.name, - as: variable.export_name - })), - this.exports_from - ); - - css = compile_options.customElement ? { code: null, map: null } : result.css; - - const js_sourcemap_enabled = check_enable_sourcemap(compile_options.enableSourcemap, 'js'); - - if (!js_sourcemap_enabled) { - js = print(program); - js.map = null; - } else { - const sourcemap_source_filename = get_sourcemap_source_filename(compile_options); - - js = print(program, { - sourceMapSource: sourcemap_source_filename - }); - - js.map.sources = [sourcemap_source_filename]; - - js.map.sourcesContent = [this.source]; - - js.map = apply_preprocessor_sourcemap( - sourcemap_source_filename, - js.map, - compile_options.sourcemap as string | RawSourceMap | DecodedSourceMap - ); - } - } - - return { - js, - css, - ast: this.original_ast, - warnings: this.warnings, - vars: this.get_vars_report(), - stats: this.stats.render() - }; - } - - get_unique_name(name: string, scope?: Scope): Identifier { - let alias = name; - for ( - let i = 1; - reserved.has(alias) || - this.var_lookup.has(alias) || - this.used_names.has(alias) || - this.globally_used_names.has(alias) || - (scope && scope.has(alias)); - - ) { - alias = `${name}_${i++}`; - } - this.used_names.add(alias); - return { type: 'Identifier', name: alias }; - } - - get_unique_name_maker() { - const local_used_names = new Set(); - - function add(name: string) { - local_used_names.add(name); - } - - reserved.forEach(add); - internal_exports.forEach(add); - this.var_lookup.forEach((_value, key) => add(key)); - - return (name: string): Identifier => { - let alias = name; - for ( - let i = 1; - this.used_names.has(alias) || local_used_names.has(alias); - alias = `${name}_${i++}` - ); - local_used_names.add(alias); - this.globally_used_names.add(alias); - - return { - type: 'Identifier', - name: alias - }; - }; - } - - get_vars_report(): Var[] { - const { compile_options, vars } = this; - - const vars_report = - compile_options.varsReport === false - ? [] - : compile_options.varsReport === 'full' - ? vars - : vars.filter((v) => !v.global && !v.internal); - - return vars_report.map((v) => ({ - name: v.name, - export_name: v.export_name || null, - injected: v.injected || false, - module: v.module || false, - mutated: v.mutated || false, - reassigned: v.reassigned || false, - referenced: v.referenced || false, - writable: v.writable || false, - referenced_from_script: v.referenced_from_script || false - })); - } - - error( - pos: { - start: number; - end: number; - }, - e: { - code: string; - message: string; - } - ) { - if (this.compile_options.errorMode === 'warn') { - this.warn(pos, e); - } else { - error(e.message, { - name: 'ValidationError', - code: e.code, - source: this.source, - start: pos.start, - end: pos.end, - filename: this.compile_options.filename - }); - } - } - - warn( - pos: { - start: number; - end: number; - }, - warning: { - code: string; - message: string; - } - ) { - if (this.ignores && this.ignores.has(warning.code)) { - return; - } - - const start = this.locate(pos.start); - const end = this.locate(pos.end); - - const frame = get_code_frame(this.source, start.line - 1, start.column); - - this.warnings.push({ - code: warning.code, - message: warning.message, - frame, - start, - end, - pos: pos.start, - filename: this.compile_options.filename, - toString: () => `${warning.message} (${start.line}:${start.column})\n${frame}` - }); - } - - extract_imports(node) { - this.imports.push(node); - } - - extract_exports(node, module_script = false) { - const ignores = extract_svelte_ignore_from_comments(node); - if (ignores.length) this.push_ignores(ignores); - const result = this._extract_exports(node, module_script); - if (ignores.length) this.pop_ignores(); - return result; - } - - private _extract_exports( - node: ExportDefaultDeclaration | ExportNamedDeclaration | ExportAllDeclaration, - module_script: boolean - ) { - if (node.type === 'ExportDefaultDeclaration') { - return this.error(node as any, compiler_errors.default_export); - } - - if (node.type === 'ExportNamedDeclaration') { - if (node.source) { - if (module_script) { - this.exports_from.push(node); - } else { - this.instance_exports_from.push(node); - } - return null; - } - if (node.declaration) { - if (node.declaration.type === 'VariableDeclaration') { - node.declaration.declarations.forEach((declarator) => { - extract_names(declarator.id).forEach((name) => { - const variable = this.var_lookup.get(name); - variable.export_name = name; - if ( - declarator.init?.type === 'Literal' && - typeof declarator.init.value === 'boolean' - ) { - variable.is_boolean = true; - } - if ( - !module_script && - variable.writable && - !(variable.referenced || variable.referenced_from_script || variable.subscribable) - ) { - this.warn( - declarator as any, - compiler_warnings.unused_export_let(this.name.name, name) - ); - } - }); - }); - } else { - const { name } = node.declaration.id; - - const variable = this.var_lookup.get(name); - variable.export_name = name; - } - - return node.declaration; - } else { - node.specifiers.forEach((specifier) => { - const variable = this.var_lookup.get(specifier.local.name); - - if (variable) { - variable.export_name = specifier.exported.name; - - if ( - !module_script && - variable.writable && - !(variable.referenced || variable.referenced_from_script || variable.subscribable) - ) { - this.warn( - specifier as any, - compiler_warnings.unused_export_let(this.name.name, specifier.exported.name) - ); - } - } - }); - - return null; - } - } - } - - extract_javascript(script) { - if (!script) return null; - - return script.content.body.filter((node) => { - if (!node) return false; - if (this.hoistable_nodes.has(node)) return false; - if (this.reactive_declaration_nodes.has(node)) return false; - if (node.type === 'ImportDeclaration') return false; - if (node.type === 'ExportDeclaration' && node.specifiers.length > 0) return false; - return true; - }); - } - - walk_module_js() { - const component = this; - const script = this.ast.module; - if (!script) return; - - walk(script.content, { - enter(node: Node) { - if (node.type === 'LabeledStatement' && node.label.name === '$') { - component.warn(node as any, compiler_warnings.module_script_reactive_declaration); - } - } - }); - - const { scope, globals } = create_scopes(script.content); - this.module_scope = scope; - - scope.declarations.forEach((node, name) => { - if (name[0] === '$') { - return this.error(node as any, compiler_errors.illegal_declaration); - } - - const writable = - node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let'); - const imported = node.type.startsWith('Import'); - - this.add_var(node, { - name, - module: true, - hoistable: true, - writable, - imported - }); - }); - - globals.forEach((node, name) => { - if (name[0] === '$') { - return this.error(node as any, compiler_errors.illegal_subscription); - } else { - this.add_var(node, { - name, - global: true, - hoistable: true - }); - } - }); - - const { body } = script.content; - let i = body.length; - while (--i >= 0) { - const node = body[i]; - if (node.type === 'ImportDeclaration') { - this.extract_imports(node); - body.splice(i, 1); - } - - if (regex_starts_with_term_export.test(node.type)) { - const replacement = this.extract_exports(node, true); - if (replacement) { - body[i] = replacement; - } else { - body.splice(i, 1); - } - } - } - } - - walk_instance_js_pre_template() { - const script = this.ast.instance; - if (!script) return; - - // inject vars for reactive declarations - script.content.body.forEach((node) => { - if (node.type !== 'LabeledStatement') return; - if (node.body.type !== 'ExpressionStatement') return; - - const { expression } = node.body; - if (expression.type !== 'AssignmentExpression') return; - if (expression.left.type === 'MemberExpression') return; - - extract_names(expression.left).forEach((name) => { - if (!this.var_lookup.has(name) && name[0] !== '$') { - this.injected_reactive_declaration_vars.add(name); - } - }); - }); - - const { scope: instance_scope, map, globals } = create_scopes(script.content); - this.instance_scope = instance_scope; - this.instance_scope_map = map; - - instance_scope.declarations.forEach((node, name) => { - if (name[0] === '$') { - return this.error(node as any, compiler_errors.illegal_declaration); - } - - const writable = - node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let'); - const imported = node.type.startsWith('Import'); - - this.add_var(node, { - name, - initialised: instance_scope.initialised_declarations.has(name), - writable, - imported - }); - - this.node_for_declaration.set(name, node); - }); - - // NOTE: add store variable first, then only $store value - // as `$store` will mark `store` variable as referenced and subscribable - const global_keys = Array.from(globals.keys()); - const sorted_globals = [ - ...global_keys.filter((key) => key[0] !== '$'), - ...global_keys.filter((key) => key[0] === '$') - ]; - - sorted_globals.forEach((name) => { - if (this.var_lookup.has(name)) return; - const node = globals.get(name); - - if (this.injected_reactive_declaration_vars.has(name)) { - this.add_var(node, { - name, - injected: true, - writable: true, - reassigned: true, - initialised: true - }); - } else if (is_reserved_keyword(name)) { - this.add_var(node, { - name, - injected: true - }); - } else if (name[0] === '$') { - if (name === '$' || name[1] === '$') { - return this.error(node as any, compiler_errors.illegal_global(name)); - } - - this.add_var(node, { - name, - injected: true, - mutated: true, - writable: true - }); - - this.add_reference(node, name.slice(1)); - - const variable = this.var_lookup.get(name.slice(1)); - if (variable) { - variable.subscribable = true; - variable.referenced_from_script = true; - } - } else { - this.add_var(node, { - name, - global: true, - hoistable: true - }); - } - }); - - this.track_references_and_mutations(); - } - - walk_instance_js_post_template() { - const script = this.ast.instance; - if (!script) return; - - this.post_template_walk(); - - this.hoist_instance_declarations(); - this.extract_reactive_declarations(); - this.check_if_tags_content_dynamic(); - } - - post_template_walk() { - const script = this.ast.instance; - if (!script) return; - - const component = this; - const { content } = script; - const { instance_scope, instance_scope_map: map } = this; - - let scope = instance_scope; - - const to_remove = []; - const remove = (parent, prop, index) => { - to_remove.unshift([parent, prop, index]); - }; - let scope_updated = false; - - const current_function_stack = []; - let current_function: FunctionDeclaration | FunctionExpression = null; - - walk(content, { - enter(node: Node, parent: Node, prop, index) { - if (node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') { - current_function_stack.push((current_function = node)); - } - - if (map.has(node)) { - scope = map.get(node); - } - - let deep = false; - let names: string[] = []; - - if (node.type === 'AssignmentExpression') { - if (node.left.type === 'ArrayPattern') { - walk(node.left, { - enter(node: Node, parent: Node) { - if ( - node.type === 'Identifier' && - parent.type !== 'MemberExpression' && - (parent.type !== 'AssignmentPattern' || parent.right !== node) - ) { - names.push(node.name); - } - } - }); - } else { - deep = node.left.type === 'MemberExpression'; - names = deep ? [get_object(node.left).name] : extract_names(node.left); - } - } else if (node.type === 'UpdateExpression') { - deep = node.argument.type === 'MemberExpression'; - const { name } = get_object(node.argument); - names.push(name); - } - if (names.length > 0) { - names.forEach((name) => { - let current_scope = scope; - let declaration; - - while (current_scope) { - if (current_scope.declarations.has(name)) { - declaration = current_scope.declarations.get(name); - break; - } - current_scope = current_scope.parent; - } - - if (declaration && declaration.kind === 'const' && !deep) { - component.error(node as any, { - code: 'assignment-to-const', - message: 'You are assigning to a const' - }); - } - }); - } - - if (node.type === 'ImportDeclaration') { - component.extract_imports(node); - // TODO: to use actual remove - remove(parent, prop, index); - return this.skip(); - } - - if (regex_starts_with_term_export.test(node.type)) { - const replacement = component.extract_exports(node); - if (replacement) { - this.replace(replacement); - } else { - // TODO: to use actual remove - remove(parent, prop, index); - } - return this.skip(); - } - - component.warn_on_undefined_store_value_references(node, parent, prop, scope); - }, - - leave(node: Node) { - if (node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') { - current_function_stack.pop(); - current_function = current_function_stack[current_function_stack.length - 1]; - } - - // do it on leave, to prevent infinite loop - if ( - component.compile_options.dev && - component.compile_options.loopGuardTimeout > 0 && - (!current_function || (!current_function.generator && !current_function.async)) - ) { - const to_replace_for_loop_protect = component.loop_protect( - node, - scope, - component.compile_options.loopGuardTimeout - ); - if (to_replace_for_loop_protect) { - this.replace(to_replace_for_loop_protect); - scope_updated = true; - } - } - - if (map.has(node)) { - scope = scope.parent; - } - } - }); - - for (const [parent, prop, index] of to_remove) { - if (parent) { - if (index !== null) { - parent[prop].splice(index, 1); - } else { - delete parent[prop]; - } - } - } - - if (scope_updated) { - const { scope, map } = create_scopes(script.content); - this.instance_scope = scope; - this.instance_scope_map = map; - } - } - - track_references_and_mutations() { - const script = this.ast.instance; - if (!script) return; - - const component = this; - const { content } = script; - const { instance_scope, module_scope, instance_scope_map: map } = this; - - let scope = instance_scope; - - walk(content, { - enter(node: Node, parent: Node) { - if (map.has(node)) { - scope = map.get(node); - } - - if (node.type === 'AssignmentExpression' || node.type === 'UpdateExpression') { - const assignee = node.type === 'AssignmentExpression' ? node.left : node.argument; - const names = extract_names(assignee as Node); - - const deep = assignee.type === 'MemberExpression'; - - names.forEach((name) => { - const scope_owner = scope.find_owner(name); - if ( - scope_owner !== null - ? scope_owner === instance_scope - : module_scope && module_scope.has(name) - ) { - const variable = component.var_lookup.get(name); - variable[deep ? 'mutated' : 'reassigned'] = true; - } - }); - } - - if (is_used_as_reference(node, parent)) { - const object = get_object(node); - if (scope.find_owner(object.name) === instance_scope) { - const variable = component.var_lookup.get(object.name); - variable.referenced_from_script = true; - } - } - }, - - leave(node: Node) { - if (map.has(node)) { - scope = scope.parent; - } - } - }); - } - - warn_on_undefined_store_value_references( - node: Node, - parent: Node, - prop: string | number | symbol, - scope: Scope - ) { - if (node.type === 'LabeledStatement' && node.label.name === '$' && parent.type !== 'Program') { - this.warn(node as any, compiler_warnings.non_top_level_reactive_declaration); - } - - if (is_reference(node as NodeWithPropertyDefinition, parent as NodeWithPropertyDefinition)) { - const object = get_object(node); - const { name } = object; - - if (name[0] === '$') { - if (!scope.has(name)) { - this.warn_if_undefined(name, object, null); - } - - if ( - name[1] !== '$' && - scope.has(name.slice(1)) && - scope.find_owner(name.slice(1)) !== this.instance_scope - ) { - if ( - !( - (regex_contains_term_function.test(parent.type) && prop === 'params') || - (parent.type === 'VariableDeclarator' && prop === 'id') - ) - ) { - return this.error(node as any, compiler_errors.contextual_store); - } - } - } - } - } - - loop_protect(node, scope: Scope, timeout: number): Node | null { - if ( - node.type === 'WhileStatement' || - node.type === 'ForStatement' || - node.type === 'DoWhileStatement' - ) { - const guard = this.get_unique_name('guard', scope); - this.used_names.add(guard.name); - - const before = b`const ${guard} = @loop_guard(${timeout})`; - const inside = b`${guard}();`; - - // wrap expression statement with BlockStatement - if (node.body.type !== 'BlockStatement') { - node.body = { - type: 'BlockStatement', - body: [node.body] - }; - } - node.body.body.push(inside[0]); - - return { - type: 'BlockStatement', - body: [before[0], node] - }; - } - return null; - } - - rewrite_props(get_insert: (variable: Var) => Node[]) { - if (!this.ast.instance) return; - - const component = this; - const { instance_scope, instance_scope_map: map } = this; - let scope = instance_scope; - - walk(this.ast.instance.content, { - enter(node: Node) { - if (regex_contains_term_function.test(node.type)) { - return this.skip(); - } - - if (map.has(node)) { - scope = map.get(node); - } - - if (node.type === 'ExportNamedDeclaration' && node.declaration) { - return this.replace(node.declaration); - } - - if (node.type === 'VariableDeclaration') { - // NOTE: `var` does not follow block scoping - if (node.kind === 'var' || scope === instance_scope) { - const inserts = []; - const props = []; - - function add_new_props( - exported: Identifier, - local: Pattern, - default_value: Expression - ) { - props.push({ - type: 'Property', - method: false, - shorthand: false, - computed: false, - kind: 'init', - key: exported, - value: default_value - ? { - type: 'AssignmentPattern', - left: local, - right: default_value - } - : local - }); - } - - // transform - // ``` - // export let { x, y = 123 } = OBJ, z = 456 - // ``` - // into - // ``` - // let { x: x$, y: y$ = 123 } = OBJ; - // let { x = x$, y = y$, z = 456 } = $$props; - // ``` - for (let index = 0; index < node.declarations.length; index++) { - const declarator = node.declarations[index]; - if (declarator.id.type !== 'Identifier') { - function get_new_name(local: Identifier): Identifier { - const variable = component.var_lookup.get(local.name); - if (variable.subscribable) { - inserts.push(get_insert(variable)); - } - - if (variable.export_name && variable.writable) { - const alias_name = component.get_unique_name(local.name); - add_new_props( - { type: 'Identifier', name: variable.export_name }, - local, - alias_name - ); - return alias_name; - } - return local; - } - - function rename_identifiers(param: Pattern) { - switch (param.type) { - case 'ObjectPattern': { - const handle_prop = (prop: Property | RestElement) => { - if (prop.type === 'RestElement') { - rename_identifiers(prop); - } else if (prop.value.type === 'Identifier') { - prop.value = get_new_name(prop.value); - } else { - rename_identifiers(prop.value as Pattern); - } - }; - - param.properties.forEach(handle_prop); - break; - } - case 'ArrayPattern': { - const handle_element = ( - element: Pattern | null, - index: number, - array: Array - ) => { - if (element) { - if (element.type === 'Identifier') { - array[index] = get_new_name(element); - } else { - rename_identifiers(element); - } - } - }; - - param.elements.forEach(handle_element); - break; - } - - case 'RestElement': - if (param.argument.type === 'Identifier') { - param.argument = get_new_name(param.argument); - } else { - rename_identifiers(param.argument); - } - break; - - case 'AssignmentPattern': - if (param.left.type === 'Identifier') { - param.left = get_new_name(param.left); - } else { - rename_identifiers(param.left); - } - break; - } - } - - rename_identifiers(declarator.id); - } else { - const { name } = declarator.id; - const variable = component.var_lookup.get(name); - const is_props = variable.export_name && variable.writable; - if (is_props) { - add_new_props( - { type: 'Identifier', name: variable.export_name }, - declarator.id, - declarator.init - ); - node.declarations.splice(index--, 1); - } - if (variable.subscribable && (is_props || declarator.init)) { - inserts.push(get_insert(variable)); - } - } - } - - this.replace( - b` - ${node.declarations.length ? node : null} - ${props.length > 0 && b`let { ${props} } = $$props;`} - ${inserts} - ` as any - ); - return this.skip(); - } - } - }, - - leave(node: Node) { - if (map.has(node)) { - scope = scope.parent; - } - } - }); - } - - hoist_instance_declarations() { - // we can safely hoist variable declarations that are - // initialised to literals, and functions that don't - // reference instance variables other than other - // hoistable functions. TODO others? - - const { hoistable_nodes, var_lookup, injected_reactive_declaration_vars, imports } = this; - - const top_level_function_declarations = new Map(); - - const { body } = this.ast.instance.content; - - for (let i = 0; i < body.length; i += 1) { - const node = body[i]; - - if (node.type === 'VariableDeclaration') { - const all_hoistable = node.declarations.every((d) => { - if (!d.init) return false; - if (d.init.type !== 'Literal') return false; - - // everything except const values can be changed by e.g. svelte devtools - // which means we can't hoist it - if (node.kind !== 'const' && this.compile_options.dev) return false; - - const { name } = d.id as Identifier; - - const v = this.var_lookup.get(name); - if (v.reassigned) return false; - if (v.export_name) return false; - - if (this.var_lookup.get(name).reassigned) return false; - if (this.vars.find((variable) => variable.name === name && variable.module)) { - return false; - } - - return true; - }); - - if (all_hoistable) { - node.declarations.forEach((d) => { - const variable = this.var_lookup.get((d.id as Identifier).name); - variable.hoistable = true; - }); - - hoistable_nodes.add(node); - - body.splice(i--, 1); - this.fully_hoisted.push(node); - } - } - - if ( - node.type === 'ExportNamedDeclaration' && - node.declaration && - node.declaration.type === 'FunctionDeclaration' - ) { - top_level_function_declarations.set(node.declaration.id.name, node); - } - - if (node.type === 'FunctionDeclaration') { - top_level_function_declarations.set(node.id.name, node); - } - } - - const checked = new Set(); - const walking = new Set(); - - const is_hoistable = (fn_declaration) => { - if (fn_declaration.type === 'ExportNamedDeclaration') { - fn_declaration = fn_declaration.declaration; - } - - const instance_scope = this.instance_scope; - let scope = this.instance_scope; - const map = this.instance_scope_map; - - let hoistable = true; - - // handle cycles - walking.add(fn_declaration); - - walk(fn_declaration, { - enter(node: Node, parent) { - if (!hoistable) return this.skip(); - - if (map.has(node)) { - scope = map.get(node); - } - - if ( - is_reference(node as NodeWithPropertyDefinition, parent as NodeWithPropertyDefinition) - ) { - const { name } = flatten_reference(node); - const owner = scope.find_owner(name); - - if (injected_reactive_declaration_vars.has(name)) { - hoistable = false; - } else if (name[0] === '$' && !owner) { - hoistable = false; - } else if (owner === instance_scope) { - const variable = var_lookup.get(name); - - if (variable.reassigned || variable.mutated) hoistable = false; - - if (name === fn_declaration.id.name) return; - - if (variable.hoistable) return; - - if (top_level_function_declarations.has(name)) { - const other_declaration = top_level_function_declarations.get(name); - - if (walking.has(other_declaration)) { - hoistable = false; - } else if ( - other_declaration.type === 'ExportNamedDeclaration' && - walking.has(other_declaration.declaration) - ) { - hoistable = false; - } else if (!is_hoistable(other_declaration)) { - hoistable = false; - } - } else { - hoistable = false; - } - } - - this.skip(); - } - }, - - leave(node: Node) { - if (map.has(node)) { - scope = scope.parent; - } - } - }); - - checked.add(fn_declaration); - walking.delete(fn_declaration); - - return hoistable; - }; - - for (const [name, node] of top_level_function_declarations) { - if (is_hoistable(node)) { - const variable = this.var_lookup.get(name); - variable.hoistable = true; - hoistable_nodes.add(node); - - const i = body.indexOf(node); - body.splice(i, 1); - this.fully_hoisted.push(node); - } - } - - for (const { specifiers } of imports) { - for (const specifier of specifiers) { - const variable = var_lookup.get(specifier.local.name); - - if (!variable.mutated || variable.subscribable) { - variable.hoistable = true; - } - } - } - } - - extract_reactive_declarations() { - const component = this; - - const unsorted_reactive_declarations: Array<{ - assignees: Set; - dependencies: Set; - node: Node; - declaration: Node; - }> = []; - - this.ast.instance.content.body.forEach((node) => { - const ignores = extract_svelte_ignore_from_comments(node); - if (ignores.length) this.push_ignores(ignores); - - if (node.type === 'LabeledStatement' && node.label.name === '$') { - this.reactive_declaration_nodes.add(node); - - const assignees = new Set(); - const assignee_nodes = new Set(); - const dependencies = new Set(); - const module_dependencies = new Set(); - - let scope = this.instance_scope; - const { declarations: outset_scope_decalarations } = this.instance_scope; - const map = this.instance_scope_map; - - walk(node.body, { - enter(node: Node, parent) { - if (node.type === 'VariableDeclaration' && node.kind === 'var') { - const is_var_in_outset = node.declarations.some((declaration: VariableDeclarator) => { - const names: string[] = extract_names(declaration.id); - return !!names.find((name: string) => { - const var_node = outset_scope_decalarations.get(name); - return var_node === node; - }); - }); - if (is_var_in_outset) { - return component.error(node as any, compiler_errors.invalid_var_declaration); - } - } - if (map.has(node)) { - scope = map.get(node); - } - - if (node.type === 'AssignmentExpression') { - const left = get_object(node.left); - - extract_identifiers(left).forEach((node) => { - assignee_nodes.add(node); - assignees.add(node.name); - }); - - if (node.operator !== '=') { - dependencies.add(left.name); - } - } else if (node.type === 'UpdateExpression') { - const identifier = get_object(node.argument); - assignees.add(identifier.name); - } else if ( - is_reference(node as NodeWithPropertyDefinition, parent as NodeWithPropertyDefinition) - ) { - const identifier = get_object(node); - if (!assignee_nodes.has(identifier)) { - const { name } = identifier; - const owner = scope.find_owner(name); - const variable = component.var_lookup.get(name); - let should_add_as_dependency = true; - - if (variable) { - variable.is_reactive_dependency = true; - if (variable.module && variable.writable) { - should_add_as_dependency = false; - module_dependencies.add(name); - } - } - const is_writable_or_mutated = variable && (variable.writable || variable.mutated); - if ( - should_add_as_dependency && - (!owner || owner === component.instance_scope) && - (name[0] === '$' || is_writable_or_mutated) - ) { - dependencies.add(name); - } - } - - this.skip(); - } - }, - - leave(node: Node) { - if (map.has(node)) { - scope = scope.parent; - } - } - }); - - if (module_dependencies.size > 0 && dependencies.size === 0) { - component.warn( - node.body as any, - compiler_warnings.module_script_variable_reactive_declaration( - Array.from(module_dependencies) - ) - ); - } - - const { expression } = node.body as ExpressionStatement; - const declaration = expression && (expression as AssignmentExpression).left; - - unsorted_reactive_declarations.push({ - assignees, - dependencies, - node, - declaration - }); - } - - if (ignores.length) this.pop_ignores(); - }); - - const lookup = new Map(); - - unsorted_reactive_declarations.forEach((declaration) => { - declaration.assignees.forEach((name) => { - if (!lookup.has(name)) { - lookup.set(name, []); - } - - // TODO warn or error if a name is assigned to in - // multiple reactive declarations? - lookup.get(name).push(declaration); - }); - }); - - const cycle = check_graph_for_cycles( - unsorted_reactive_declarations.reduce((acc, declaration) => { - declaration.assignees.forEach((v) => { - declaration.dependencies.forEach((w) => { - if (!declaration.assignees.has(w)) { - acc.push([v, w]); - } - }); - }); - return acc; - }, []) - ); - - if (cycle && cycle.length) { - const declarationList = lookup.get(cycle[0]); - const declaration = declarationList[0]; - return this.error(declaration.node, compiler_errors.cyclical_reactive_declaration(cycle)); - } - - const add_declaration = (declaration) => { - if (this.reactive_declarations.includes(declaration)) return; - - declaration.dependencies.forEach((name) => { - if (declaration.assignees.has(name)) return; - const earlier_declarations = lookup.get(name); - if (earlier_declarations) { - earlier_declarations.forEach(add_declaration); - } - }); - - this.reactive_declarations.push(declaration); - }; - - unsorted_reactive_declarations.forEach(add_declaration); - } - - check_if_tags_content_dynamic() { - this.tags.forEach((tag) => { - tag.check_if_content_dynamic(); - }); - } - - warn_if_undefined(name: string, node, template_scope: TemplateScope) { - if (name[0] === '$') { - if (name === '$' || (name[1] === '$' && !is_reserved_keyword(name))) { - return this.error(node, compiler_errors.illegal_global(name)); - } - - this.has_reactive_assignments = true; // TODO does this belong here? - - if (is_reserved_keyword(name)) return; - - name = name.slice(1); - } - - if (this.var_lookup.has(name) && !this.var_lookup.get(name).global) return; - if (template_scope && template_scope.names.has(name)) return; - if (globals.has(name) && node.type !== 'InlineComponent') return; - - this.warn(node, compiler_warnings.missing_declaration(name, !!this.ast.instance)); - } - - push_ignores(ignores) { - this.ignores = new Set(this.ignores || []); - add_to_set(this.ignores, ignores); - this.ignore_stack.push(this.ignores); - } - - pop_ignores() { - this.ignore_stack.pop(); - this.ignores = this.ignore_stack[this.ignore_stack.length - 1]; - } -} - -const regex_valid_tag_name = /^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/; - -function process_component_options(component: Component, nodes) { - const component_options: ComponentOptions = { - immutable: component.compile_options.immutable || false, - accessors: - 'accessors' in component.compile_options - ? component.compile_options.accessors - : !!component.compile_options.customElement, - preserveWhitespace: !!component.compile_options.preserveWhitespace, - namespace: component.compile_options.namespace - }; - - const node = nodes.find((node) => node.name === 'svelte:options'); - - function get_value(attribute, { code, message }) { - const { value } = attribute; - const chunk = value[0]; - - if (!chunk) return true; - - if (value.length > 1) { - return component.error(attribute, { code, message }); - } - - if (chunk.type === 'Text') return chunk.data; - - if (chunk.expression.type !== 'Literal') { - return component.error(attribute, { code, message }); - } - - return chunk.expression.value; - } - - if (node) { - node.attributes.forEach((attribute) => { - if (attribute.type === 'Attribute') { - const { name } = attribute; - - function parse_tag(attribute: Attribute, tag: string) { - if (typeof tag !== 'string' && tag !== null) { - return component.error(attribute, compiler_errors.invalid_tag_attribute); - } - - if (tag && !regex_valid_tag_name.test(tag)) { - return component.error(attribute, compiler_errors.invalid_tag_property); - } - - if (tag && !component.compile_options.customElement) { - component.warn(attribute, compiler_warnings.missing_custom_element_compile_options); - } - - component_options.customElement = component_options.customElement || ({} as any); - component_options.customElement.tag = tag; - } - - switch (name) { - case 'tag': { - component.warn(attribute, compiler_warnings.tag_option_deprecated); - parse_tag(attribute, get_value(attribute, compiler_errors.invalid_tag_attribute)); - break; - } - - case 'customElement': { - component_options.customElement = component_options.customElement || ({} as any); - - const { value } = attribute; - - if (value[0].type === 'MustacheTag' && value[0].expression?.value === null) { - component_options.customElement.tag = null; - break; - } else if (value[0].type === 'Text') { - parse_tag(attribute, get_value(attribute, compiler_errors.invalid_tag_attribute)); - break; - } else if (value[0].expression.type !== 'ObjectExpression') { - return component.error(attribute, compiler_errors.invalid_customElement_attribute); - } - - const tag = value[0].expression.properties.find((prop: any) => prop.key.name === 'tag'); - if (tag) { - parse_tag(tag, tag.value?.value); - } else { - return component.error(attribute, compiler_errors.invalid_customElement_attribute); - } - - const props = value[0].expression.properties.find( - (prop: any) => prop.key.name === 'props' - ); - if (props) { - const error = () => - component.error(attribute, compiler_errors.invalid_props_attribute); - if (props.value?.type !== 'ObjectExpression') { - return error(); - } - - component_options.customElement.props = {}; - - for (const property of (props.value as ObjectExpression).properties) { - if ( - property.type !== 'Property' || - property.computed || - property.key.type !== 'Identifier' || - property.value.type !== 'ObjectExpression' - ) { - return error(); - } - component_options.customElement.props[property.key.name] = {}; - for (const prop of property.value.properties) { - if ( - prop.type !== 'Property' || - prop.computed || - prop.key.type !== 'Identifier' || - prop.value.type !== 'Literal' - ) { - return error(); - } - if ( - ['reflect', 'attribute', 'type'].indexOf(prop.key.name) === -1 || - (prop.key.name === 'type' && - ['String', 'Number', 'Boolean', 'Array', 'Object'].indexOf( - prop.value.value as string - ) === -1) || - (prop.key.name === 'reflect' && typeof prop.value.value !== 'boolean') || - (prop.key.name === 'attribute' && typeof prop.value.value !== 'string') - ) { - return error(); - } - component_options.customElement.props[property.key.name][prop.key.name] = - prop.value.value; - } - } - } - - const shadow = value[0].expression.properties.find( - (prop: any) => prop.key.name === 'shadow' - ); - if (shadow) { - const shadowdom = shadow.value?.value; - - if (shadowdom !== 'open' && shadowdom !== 'none') { - return component.error(shadow, compiler_errors.invalid_shadow_attribute); - } - - component_options.customElement.shadow = shadowdom; - } - - break; - } - - case 'namespace': { - const ns = get_value(attribute, compiler_errors.invalid_namespace_attribute); - - if (typeof ns !== 'string') { - return component.error(attribute, compiler_errors.invalid_namespace_attribute); - } - - if (valid_namespaces.indexOf(ns) === -1) { - const match = fuzzymatch(ns, valid_namespaces); - return component.error( - attribute, - compiler_errors.invalid_namespace_property(ns, match) - ); - } - - component_options.namespace = ns; - break; - } - - case 'accessors': - case 'immutable': - case 'preserveWhitespace': { - const value = get_value(attribute, compiler_errors.invalid_attribute_value(name)); - - if (typeof value !== 'boolean') { - return component.error(attribute, compiler_errors.invalid_attribute_value(name)); - } - - component_options[name] = value; - break; - } - - default: - return component.error( - attribute, - compiler_errors.invalid_options_attribute_unknown(name) - ); - } - } else { - return component.error(attribute, compiler_errors.invalid_options_attribute); - } - }); - } - - return component_options; -} - -function get_relative_path(from: string, to: string) { - const from_parts = from.split(/[/\\]/); - const to_parts = to.split(/[/\\]/); - - from_parts.pop(); // get dirname - - while (from_parts[0] === to_parts[0]) { - from_parts.shift(); - to_parts.shift(); - } - - if (from_parts.length) { - let i = from_parts.length; - while (i--) from_parts[i] = '..'; - } - - return from_parts.concat(to_parts).join('/'); -} - -function get_basename(filename: string) { - return filename.split(/[/\\]/).pop(); -} - -function get_sourcemap_source_filename(compile_options: CompileOptions) { - if (!compile_options.filename) return null; - - return compile_options.outputFilename - ? get_relative_path(compile_options.outputFilename, compile_options.filename) - : get_basename(compile_options.filename); -} diff --git a/src/compiler/compile/compiler_errors.ts b/src/compiler/compile/compiler_errors.js similarity index 82% rename from src/compiler/compile/compiler_errors.ts rename to src/compiler/compile/compiler_errors.js index 40c5758842..02b0f7120a 100644 --- a/src/compiler/compile/compiler_errors.ts +++ b/src/compiler/compile/compiler_errors.js @@ -1,36 +1,48 @@ // All compiler errors should be listed and accessed from here - /** * @internal */ export default { - invalid_binding_elements: (element: string, binding: string) => ({ + invalid_binding_elements: /** + * @param {string} element + * @param {string} binding + */ (element, binding) => ({ code: 'invalid-binding', message: `'${binding}' is not a valid binding on <${element}> elements` }), - invalid_binding_element_with: (elements: string, binding: string) => ({ + invalid_binding_element_with: /** + * @param {string} elements + * @param {string} binding + */ (elements, binding) => ({ code: 'invalid-binding', message: `'${binding}' binding can only be used with ${elements}` }), - invalid_binding_on: (binding: string, element: string, post?: string) => ({ + invalid_binding_on: /** + * @param {string} binding + * @param {string} element + * @param {string} [post] + */ (binding, element, post) => ({ code: 'invalid-binding', message: `'${binding}' is not a valid binding on ${element}` + (post || '') }), - invalid_binding_foreign: (binding: string) => ({ + invalid_binding_foreign: /** @param {string} binding */ (binding) => ({ code: 'invalid-binding', message: `'${binding}' is not a valid binding. Foreign elements only support bind:this` }), - invalid_binding_no_checkbox: (binding: string, is_radio: boolean) => ({ + invalid_binding_no_checkbox: /** + * @param {string} binding + * @param {boolean} is_radio + */ (binding, is_radio) => ({ code: 'invalid-binding', message: `'${binding}' binding can only be used with ` + (is_radio ? ' — for , use \'group\' binding' : '') }), - invalid_binding: (binding: string) => ({ + invalid_binding: /** @param {string} binding */ (binding) => ({ code: 'invalid-binding', message: `'${binding}' is not a valid binding` }), - invalid_binding_window: (parts: string[]) => ({ + invalid_binding_window: /** @param {string[]} parts */ (parts) => ({ code: 'invalid-binding', message: `Bindings on must be to top-level properties, e.g. '${ parts[parts.length - 1] @@ -52,7 +64,7 @@ export default { code: 'invalid-binding', message: 'Cannot bind to a variable which is not writable' }, - binding_undeclared: (name: string) => ({ + binding_undeclared: /** @param {string} name */ (name) => ({ code: 'binding-undeclared', message: `${name} is not declared` }), @@ -77,15 +89,18 @@ export default { code: 'dynamic-contenteditable-attribute', message: "'contenteditable' attribute cannot be dynamic if element uses two-way binding" }, - invalid_event_modifier_combination: (modifier1: string, modifier2: string) => ({ + invalid_event_modifier_combination: /** + * @param {string} modifier1 + * @param {string} modifier2 + */ (modifier1, modifier2) => ({ code: 'invalid-event-modifier', message: `The '${modifier1}' and '${modifier2}' modifiers cannot be used together` }), - invalid_event_modifier_legacy: (modifier: string) => ({ + invalid_event_modifier_legacy: /** @param {string} modifier */ (modifier) => ({ code: 'invalid-event-modifier', message: `The '${modifier}' modifier cannot be used in legacy mode` }), - invalid_event_modifier: (valid: string) => ({ + invalid_event_modifier: /** @param {string} valid */ (valid) => ({ code: 'invalid-event-modifier', message: `Valid event modifiers are ${valid}` }), @@ -98,7 +113,7 @@ export default { message: 'A