diff --git a/.changeset/beige-emus-deny.md b/.changeset/beige-emus-deny.md new file mode 100644 index 00000000..18986799 --- /dev/null +++ b/.changeset/beige-emus-deny.md @@ -0,0 +1,5 @@ +--- +'@xyflow/svelte': patch +--- + +Refactor internal use of contexts diff --git a/examples/svelte/.eslintignore b/examples/svelte/.eslintignore deleted file mode 100644 index 38972655..00000000 --- a/examples/svelte/.eslintignore +++ /dev/null @@ -1,13 +0,0 @@ -.DS_Store -node_modules -/build -/.svelte-kit -/package -.env -.env.* -!.env.example - -# Ignore files for PNPM, NPM and YARN -pnpm-lock.yaml -package-lock.json -yarn.lock diff --git a/examples/svelte/.eslintrc.cjs b/examples/svelte/.eslintrc.cjs deleted file mode 100644 index ebc19589..00000000 --- a/examples/svelte/.eslintrc.cjs +++ /dev/null @@ -1,30 +0,0 @@ -module.exports = { - root: true, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:svelte/recommended', - 'prettier' - ], - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - parserOptions: { - sourceType: 'module', - ecmaVersion: 2020, - extraFileExtensions: ['.svelte'] - }, - env: { - browser: true, - es2017: true, - node: true - }, - overrides: [ - { - files: ['*.svelte'], - parser: 'svelte-eslint-parser', - parserOptions: { - parser: '@typescript-eslint/parser' - } - } - ] -}; diff --git a/examples/svelte/.gitignore b/examples/svelte/.gitignore index 6635cf55..294b3857 100644 --- a/examples/svelte/.gitignore +++ b/examples/svelte/.gitignore @@ -1,10 +1,24 @@ -.DS_Store node_modules -/build + +# Output +.output +.vercel +.netlify +.wrangler /.svelte-kit -/package +/build +/dist + +# OS +.DS_Store +Thumbs.db + +# Env .env .env.* !.env.example +!.env.test + +# Vite vite.config.js.timestamp-* vite.config.ts.timestamp-* diff --git a/examples/svelte/.npmrc b/examples/svelte/.npmrc index 0c05da45..4fd02195 100644 --- a/examples/svelte/.npmrc +++ b/examples/svelte/.npmrc @@ -1,2 +1 @@ -engine-strict=true -resolution-mode=highest +engine-strict=true \ No newline at end of file diff --git a/examples/svelte/eslint.config.js b/examples/svelte/eslint.config.js new file mode 100644 index 00000000..2c49fa64 --- /dev/null +++ b/examples/svelte/eslint.config.js @@ -0,0 +1,41 @@ +import prettier from 'eslint-config-prettier'; +import { fileURLToPath } from 'node:url'; +import { includeIgnoreFile } from '@eslint/compat'; +import js from '@eslint/js'; +import svelte from 'eslint-plugin-svelte'; +import { defineConfig } from 'eslint/config'; +import globals from 'globals'; +import ts from 'typescript-eslint'; +import svelteConfig from './svelte.config.js'; + +const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)); + +export default defineConfig( + includeIgnoreFile(gitignorePath), + js.configs.recommended, + ...ts.configs.recommended, + ...svelte.configs.recommended, + prettier, + ...svelte.configs.prettier, + { + languageOptions: { + globals: { ...globals.browser, ...globals.node } + }, + rules: { + // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects. + // see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors + 'no-undef': 'off' + } + }, + { + files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'], + languageOptions: { + parserOptions: { + projectService: true, + extraFileExtensions: ['.svelte'], + parser: ts.parser, + svelteConfig + } + } + } +); diff --git a/examples/svelte/package.json b/examples/svelte/package.json index 82f47029..2f3e5d47 100644 --- a/examples/svelte/package.json +++ b/examples/svelte/package.json @@ -12,25 +12,25 @@ "format": "prettier --plugin-search-dir . --write ." }, "devDependencies": { - "@sveltejs/adapter-auto": "^6.0.0", - "@sveltejs/kit": "^2.20.7", - "@typescript-eslint/eslint-plugin": "^8.34.0", - "@typescript-eslint/parser": "^8.34.0", - "eslint": "^9.24.0", - "eslint-config-prettier": "^10.1.2", - "eslint-plugin-svelte": "^3.5.1", - "prettier": "^3.5.3", - "prettier-plugin-svelte": "^3.3.3", - "svelte": "^5.27.0", - "svelte-check": "^4.1.6", + "@sveltejs/adapter-auto": "^7.0.0", + "@sveltejs/kit": "^2.49.1", + "@typescript-eslint/eslint-plugin": "^8.48.1", + "@typescript-eslint/parser": "^8.48.1", + "eslint": "^9.39.1", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-svelte": "^3.13.0", + "prettier": "^3.7.4", + "prettier-plugin-svelte": "^3.4.0", + "svelte": "^5.45.4", + "svelte-check": "^4.3.4", "tslib": "^2.8.1", - "typescript": "^5.8.3", - "vite": "^6.3.0" + "typescript": "^5.9.3", + "vite": "^7.2.6" }, "type": "module", "dependencies": { - "@dagrejs/dagre": "^1.1.4", - "@sveltejs/vite-plugin-svelte": "^5.0.3", + "@dagrejs/dagre": "^1.1.8", + "@sveltejs/vite-plugin-svelte": "^6.2.1", "@xyflow/svelte": "workspace:^" } } diff --git a/examples/svelte/src/routes/examples/edge-toolbar/CustomEdge.svelte b/examples/svelte/src/routes/examples/edge-toolbar/CustomEdge.svelte index 24876c64..b624d0ce 100644 --- a/examples/svelte/src/routes/examples/edge-toolbar/CustomEdge.svelte +++ b/examples/svelte/src/routes/examples/edge-toolbar/CustomEdge.svelte @@ -21,6 +21,6 @@ - + diff --git a/examples/svelte/svelte.config.js b/examples/svelte/svelte.config.js index 94011562..10899539 100644 --- a/examples/svelte/svelte.config.js +++ b/examples/svelte/svelte.config.js @@ -5,7 +5,7 @@ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; const config = { // Consult https://kit.svelte.dev/docs/integrations#preprocessors // for more information about preprocessors - preprocess: vitePreprocess({ script: true }), + preprocess: vitePreprocess(), compilerOptions: { runes: true }, diff --git a/examples/svelte/tsconfig.json b/examples/svelte/tsconfig.json index 2bb201c3..8625d4ce 100644 --- a/examples/svelte/tsconfig.json +++ b/examples/svelte/tsconfig.json @@ -9,7 +9,9 @@ "skipLibCheck": true, "sourceMap": true, "strict": true, - "target": "ES2022", + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", "verbatimModuleSyntax": true, "isolatedModules": true } diff --git a/packages/svelte/eslint.config.js b/packages/svelte/eslint.config.js index 56e30008..668d61b0 100644 --- a/packages/svelte/eslint.config.js +++ b/packages/svelte/eslint.config.js @@ -1,29 +1,34 @@ -import globals from 'globals'; +import prettier from 'eslint-config-prettier'; +import { fileURLToPath } from 'node:url'; +import { includeIgnoreFile } from '@eslint/compat'; import js from '@eslint/js'; -import ts from 'typescript-eslint'; import svelte from 'eslint-plugin-svelte'; -import eslintConfigPrettier from 'eslint-config-prettier'; +import { defineConfig } from 'eslint/config'; +import globals from 'globals'; +import ts from 'typescript-eslint'; import svelteConfig from './svelte.config.js'; -export default ts.config( +const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)); + +export default defineConfig( + includeIgnoreFile(gitignorePath), js.configs.recommended, ...ts.configs.recommended, ...svelte.configs.recommended, - eslintConfigPrettier, + prettier, + ...svelte.configs.prettier, { languageOptions: { - ecmaVersion: 2020, - sourceType: 'module', - globals: { - ...globals.browser, - ...globals.es2017, - ...globals.node - } + globals: { ...globals.browser, ...globals.node } + }, + rules: { + // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects. + // see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors + 'no-undef': 'off' } }, { files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'], - ignores: ['eslint.config.js', 'svelte.config.js'], languageOptions: { parserOptions: { projectService: true, @@ -32,8 +37,5 @@ export default ts.config( svelteConfig } } - }, - { - ignores: ['.svelte-kit/*', 'build/*', 'dist/*'] // Add common ignore patterns } ); diff --git a/packages/svelte/package.json b/packages/svelte/package.json index c2dd3ba6..b04a36ec 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -55,35 +55,36 @@ "@xyflow/system": "workspace:*" }, "devDependencies": { - "@eslint/js": "^9.28.0", - "@sveltejs/adapter-auto": "^6.0.1", - "@sveltejs/kit": "^2.21.4", - "@sveltejs/package": "^2.3.11", - "@sveltejs/vite-plugin-svelte": "^5.1.0", - "@typescript-eslint/eslint-plugin": "^8.34.0", - "@typescript-eslint/parser": "^8.34.0", - "autoprefixer": "^10.4.21", - "cssnano": "^7.0.7", - "dotenv": "^16.5.0", - "eslint": "^9.28.0", - "eslint-config-prettier": "^10.1.5", - "eslint-plugin-svelte": "^3.9.2", - "globals": "^16.2.0", - "postcss": "^8.5.4", + "@eslint/compat": "^2.0.0", + "@eslint/js": "^9.39.1", + "@sveltejs/adapter-auto": "^7.0.0", + "@sveltejs/kit": "^2.49.1", + "@sveltejs/package": "^2.5.7", + "@sveltejs/vite-plugin-svelte": "^6.2.1", + "@typescript-eslint/eslint-plugin": "^8.48.1", + "@typescript-eslint/parser": "^8.48.1", + "autoprefixer": "^10.4.22", + "cssnano": "^7.1.2", + "dotenv": "^17.2.3", + "eslint": "^9.39.1", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-svelte": "^3.13.0", + "globals": "^16.5.0", + "postcss": "^8.5.6", "postcss-cli": "^11.0.1", "postcss-combine-duplicated-selectors": "^10.0.3", - "postcss-import": "^16.1.0", + "postcss-import": "^16.1.1", "postcss-nested": "^7.0.2", "postcss-rename": "^0.8.0", - "prettier": "^3.5.3", + "prettier": "^3.7.4", "prettier-plugin-svelte": "^3.4.0", - "svelte": "^5.33.19", - "svelte-check": "^4.2.1", - "svelte-eslint-parser": "^1.2.0", + "svelte": "^5.45.4", + "svelte-check": "^4.3.4", + "svelte-eslint-parser": "^1.4.0", "svelte-preprocess": "^6.0.3", "tslib": "^2.8.1", - "typescript": "^5.8.3", - "typescript-eslint": "^8.34.0" + "typescript": "^5.9.3", + "typescript-eslint": "^8.48.1" }, "peerDependencies": { "svelte": "^5.25.0" diff --git a/packages/svelte/src/lib/components/EdgeLabel/EdgeLabel.svelte b/packages/svelte/src/lib/components/EdgeLabel/EdgeLabel.svelte index b01ce307..ab48ef0d 100644 --- a/packages/svelte/src/lib/components/EdgeLabel/EdgeLabel.svelte +++ b/packages/svelte/src/lib/components/EdgeLabel/EdgeLabel.svelte @@ -1,11 +1,11 @@
{ - if (selectEdgeOnClick) store.handleEdgeSelection(edgeId); + if (selectEdgeOnClick && edgeId) store.handleEdgeSelection(edgeId); }} {...rest} > diff --git a/packages/svelte/src/lib/components/EdgeReconnectAnchor/EdgeReconnectAnchor.svelte b/packages/svelte/src/lib/components/EdgeReconnectAnchor/EdgeReconnectAnchor.svelte index 81f0ab2d..2a4975df 100644 --- a/packages/svelte/src/lib/components/EdgeReconnectAnchor/EdgeReconnectAnchor.svelte +++ b/packages/svelte/src/lib/components/EdgeReconnectAnchor/EdgeReconnectAnchor.svelte @@ -1,8 +1,8 @@