use eslint auto fix

This commit is contained in:
duanfuxiang 2025-01-07 12:27:22 +08:00
parent d8573c7889
commit 8d253faddc
41 changed files with 890 additions and 1569 deletions

View File

@ -11,7 +11,11 @@ const config = {
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
plugins: [
'@typescript-eslint/eslint-plugin',
'no-inline-styles',
'css-modules'
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
@ -59,6 +63,16 @@ const config = {
},
},
],
'no-console': 'warn',
'no-inline-styles/no-inline-styles': 'error',
'@typescript-eslint/consistent-type-assertions': [
'error',
{
'assertionStyle': 'never'
}
],
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/prefer-regexp-exec': 'error',
},
ignorePatterns: [
'.eslintrc.js',

1477
main.js

File diff suppressed because one or more lines are too long

785
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "obsidian-infio-copilot",
"version": "0.0.1",
"version": "0.0.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "obsidian-infio-copilot",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",
"dependencies": {
"@anthropic-ai/sdk": "^0.27.3",
@ -66,16 +66,19 @@
"builtin-modules": "3.3.0",
"drizzle-kit": "^0.26.2",
"esbuild": "0.17.3",
"eslint": "^8.57.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-css-modules": "^2.12.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-neverthrow": "^1.1.4",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-no-inline-styles": "^1.0.5",
"eslint-plugin-react": "^7.37.3",
"eslint-plugin-react-hooks": "^5.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"obsidian": "latest",
"prettier": "^3.4.2",
"stylelint": "^16.12.0",
"ts-jest": "^29.2.5",
"tslib": "2.4.0",
"typescript": "^4.9.0"
@ -663,6 +666,96 @@
"integrity": "sha512-ZykIcDTVv5UNmKWSTLAs3VukO6NDJkkSKxrgUTDPBkAlORVT3H9n5DbRjRl8xIotklscHdbLIa0b9+y3mQq73g==",
"license": "MIT"
},
"node_modules/@csstools/css-parser-algorithms": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.4.tgz",
"integrity": "sha512-Up7rBoV77rv29d3uKHUIVubz1BTcgyUK72IvCQAbfbMv584xHcGKCKbWh7i8hPrRJ7qU4Y8IO3IY9m+iTB7P3A==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/csstools"
},
{
"type": "opencollective",
"url": "https://opencollective.com/csstools"
}
],
"license": "MIT",
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@csstools/css-tokenizer": "^3.0.3"
}
},
"node_modules/@csstools/css-tokenizer": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.3.tgz",
"integrity": "sha512-UJnjoFsmxfKUdNYdWgOB0mWUypuLvAfQPH1+pyvRJs6euowbFkFC6P13w1l8mJyi3vxYMxc9kld5jZEGRQs6bw==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/csstools"
},
{
"type": "opencollective",
"url": "https://opencollective.com/csstools"
}
],
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/@csstools/media-query-list-parser": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@csstools/media-query-list-parser/-/media-query-list-parser-4.0.2.tgz",
"integrity": "sha512-EUos465uvVvMJehckATTlNqGj4UJWkTmdWuDMjqvSUkjGpmOyFZBVwb4knxCm/k2GMTXY+c/5RkdndzFYWeX5A==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/csstools"
},
{
"type": "opencollective",
"url": "https://opencollective.com/csstools"
}
],
"license": "MIT",
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@csstools/css-parser-algorithms": "^3.0.4",
"@csstools/css-tokenizer": "^3.0.3"
}
},
"node_modules/@csstools/selector-specificity": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-5.0.0.tgz",
"integrity": "sha512-PCqQV3c4CoVm3kdPhyeZ07VmBRdH2EpMFA/pd9OASpOEC3aXNGoqPDAZ80D0cLpMBxnmk0+yNhGsEx31hq7Gtw==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/csstools"
},
{
"type": "opencollective",
"url": "https://opencollective.com/csstools"
}
],
"license": "MIT-0",
"engines": {
"node": ">=18"
},
"peerDependencies": {
"postcss-selector-parser": "^7.0.0"
}
},
"node_modules/@drizzle-team/brocli": {
"version": "0.10.2",
"resolved": "https://registry.npmjs.org/@drizzle-team/brocli/-/brocli-0.10.2.tgz",
@ -670,6 +763,17 @@
"dev": true,
"license": "Apache-2.0"
},
"node_modules/@dual-bundle/import-meta-resolve": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/@dual-bundle/import-meta-resolve/-/import-meta-resolve-4.1.0.tgz",
"integrity": "sha512-+nxncfwHM5SgAtrVzgpzJOI1ol0PkumhVo469KCf9lUi21IGcY90G98VuHm9VRrUypmAzawAHO9bs6hqeADaVg==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/@electric-sql/pglite": {
"version": "0.2.14",
"resolved": "https://registry.npmjs.org/@electric-sql/pglite/-/pglite-0.2.14.tgz",
@ -4165,6 +4269,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/astral-regex": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
"integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/async": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",
@ -4724,6 +4838,13 @@
"dev": true,
"license": "MIT"
},
"node_modules/colord": {
"version": "2.9.3",
"resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz",
"integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==",
"dev": true,
"license": "MIT"
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@ -4769,6 +4890,33 @@
"dev": true,
"license": "MIT"
},
"node_modules/cosmiconfig": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.0.tgz",
"integrity": "sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==",
"dev": true,
"license": "MIT",
"dependencies": {
"env-paths": "^2.2.1",
"import-fresh": "^3.3.0",
"js-yaml": "^4.1.0",
"parse-json": "^5.2.0"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/d-fischer"
},
"peerDependencies": {
"typescript": ">=4.9.5"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/create-jest": {
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz",
@ -4806,6 +4954,43 @@
"node": ">= 8"
}
},
"node_modules/css-functions-list": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/css-functions-list/-/css-functions-list-3.2.3.tgz",
"integrity": "sha512-IQOkD3hbR5KrN93MtcYuad6YPuTSUhntLHDuLEbFWE+ff2/XSZNdZG+LcbbIW5AXKg/WFIfYItIzVoHngHXZzA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12 || >=16"
}
},
"node_modules/css-tree": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.1.0.tgz",
"integrity": "sha512-0eW44TGN5SQXU1mWSkKwFstI/22X2bG1nYzZTYMAWjylYURhse752YgbE4Cx46AC+bAvI+/dYTPRk1LqSUnu6w==",
"dev": true,
"license": "MIT",
"dependencies": {
"mdn-data": "2.12.2",
"source-map-js": "^1.0.1"
},
"engines": {
"node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"
}
},
"node_modules/cssesc": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",
"integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==",
"dev": true,
"license": "MIT",
"bin": {
"cssesc": "bin/cssesc"
},
"engines": {
"node": ">=4"
}
},
"node_modules/cssom": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz",
@ -5750,6 +5935,16 @@
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/env-paths": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
"integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/error-ex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@ -6147,6 +6342,23 @@
"ms": "^2.1.1"
}
},
"node_modules/eslint-plugin-css-modules": {
"version": "2.12.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-css-modules/-/eslint-plugin-css-modules-2.12.0.tgz",
"integrity": "sha512-ruFBdad69ABrbCDCh5mXj7UzNmrvytfzPACjyvZWIAjFZAG8BXpYSbqmE8gU5wF+pIzV3jU2CWhLvfekXT/IgQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"gonzales-pe": "^4.3.0",
"lodash": "^4.17.2"
},
"engines": {
"node": ">=4.0.0"
},
"peerDependencies": {
"eslint": ">=2.0.0"
}
},
"node_modules/eslint-plugin-import": {
"version": "2.31.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.31.0.tgz",
@ -6257,6 +6469,16 @@
"eslint": ">=5.16.0"
}
},
"node_modules/eslint-plugin-no-inline-styles": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/eslint-plugin-no-inline-styles/-/eslint-plugin-no-inline-styles-1.0.5.tgz",
"integrity": "sha512-nftOfHV/ag0P0vEPQ3p54HVpGCp6k/E+pHdYnRm2wDK8QhClfmMjrCw+POL5RH/SN1AmTifCTh5VzkeubLgMpA==",
"dev": true,
"license": "MIT",
"dependencies": {
"lodash.get": "^4.4.2"
}
},
"node_modules/eslint-plugin-react": {
"version": "7.37.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.3.tgz",
@ -6667,6 +6889,33 @@
"dev": true,
"license": "MIT"
},
"node_modules/fast-uri": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.5.tgz",
"integrity": "sha512-5JnBCWpFlMo0a3ciDy/JckMzzv1U9coZrIhedq+HXxxUfDTAiS0LA8OKVao4G9BxmCVck/jtA5r3KAtRWEyD8Q==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "BSD-3-Clause"
},
"node_modules/fastest-levenshtein": {
"version": "1.0.16",
"resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz",
"integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 4.9.1"
}
},
"node_modules/fastq": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.18.0.tgz",
@ -7088,6 +7337,47 @@
"node": "*"
}
},
"node_modules/global-modules": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/global-modules/-/global-modules-2.0.0.tgz",
"integrity": "sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==",
"dev": true,
"license": "MIT",
"dependencies": {
"global-prefix": "^3.0.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/global-prefix": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-3.0.0.tgz",
"integrity": "sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==",
"dev": true,
"license": "MIT",
"dependencies": {
"ini": "^1.3.5",
"kind-of": "^6.0.2",
"which": "^1.3.1"
},
"engines": {
"node": ">=6"
}
},
"node_modules/global-prefix/node_modules/which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"which": "bin/which"
}
},
"node_modules/globals": {
"version": "13.24.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz",
@ -7142,6 +7432,29 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/globjoin": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/globjoin/-/globjoin-0.1.4.tgz",
"integrity": "sha512-xYfnw62CKG8nLkZBfWbhWwDw02CHty86jfPcc2cr3ZfeuK9ysoVPPEUxf21bAD/rWAgk52SuBrLJlefNy8mvFg==",
"dev": true,
"license": "MIT"
},
"node_modules/gonzales-pe": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/gonzales-pe/-/gonzales-pe-4.3.0.tgz",
"integrity": "sha512-otgSPpUmdWJ43VXyiNgEYE4luzHCL2pz4wQ0OnDluC6Eg4Ko3Vexy/SrSynglw/eR+OhkzmqFCZa/OFa/RgAOQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"minimist": "^1.2.5"
},
"bin": {
"gonzales": "bin/gonzales.js"
},
"engines": {
"node": ">=0.6.0"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
@ -7458,6 +7771,19 @@
"dev": true,
"license": "MIT"
},
"node_modules/html-tags": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/html-tags/-/html-tags-3.3.1.tgz",
"integrity": "sha512-ztqyC3kLto0e9WbNp0aeP+M3kTt+nbaIveGmUxAtZa+8iFgKLUOD4YKM5j+f3QD89bra7UeumolZHKuOXnTmeQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/html-url-attributes": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz",
@ -7605,6 +7931,13 @@
"dev": true,
"license": "ISC"
},
"node_modules/ini": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
"dev": true,
"license": "ISC"
},
"node_modules/inline-style-parser": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.4.tgz",
@ -7950,6 +8283,16 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-plain-object": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-potential-custom-element-name": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
@ -9119,6 +9462,16 @@
"json-buffer": "3.0.1"
}
},
"node_modules/kind-of": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/kleur": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
@ -9129,6 +9482,13 @@
"node": ">=6"
}
},
"node_modules/known-css-properties": {
"version": "0.35.0",
"resolved": "https://registry.npmjs.org/known-css-properties/-/known-css-properties-0.35.0.tgz",
"integrity": "sha512-a/RAk2BfKk+WFGhhOCAYqSiFLc34k8Mt/6NWRI4joER0EYUzXIcFivjjnoD3+XU1DggLn/tZc3DOAgke7l8a4A==",
"dev": true,
"license": "MIT"
},
"node_modules/langchain": {
"version": "0.3.9",
"resolved": "https://registry.npmjs.org/langchain/-/langchain-0.3.9.tgz",
@ -9300,6 +9660,13 @@
"integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==",
"license": "MIT"
},
"node_modules/lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==",
"dev": true,
"license": "MIT"
},
"node_modules/lodash.isequal": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
@ -9320,6 +9687,13 @@
"dev": true,
"license": "MIT"
},
"node_modules/lodash.truncate": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz",
"integrity": "sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==",
"dev": true,
"license": "MIT"
},
"node_modules/longest-streak": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz",
@ -9424,6 +9798,17 @@
"node": ">= 0.4"
}
},
"node_modules/mathml-tag-names": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz",
"integrity": "sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/mdast-util-find-and-replace": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.2.tgz",
@ -9706,6 +10091,26 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdn-data": {
"version": "2.12.2",
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.12.2.tgz",
"integrity": "sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==",
"dev": true,
"license": "CC0-1.0"
},
"node_modules/meow": {
"version": "13.2.0",
"resolved": "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz",
"integrity": "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/merge-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
@ -10379,6 +10784,25 @@
"mustache": "bin/mustache"
}
},
"node_modules/nanoid": {
"version": "3.3.8",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz",
"integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
@ -11087,6 +11511,90 @@
"node": ">= 0.4"
}
},
"node_modules/postcss": {
"version": "8.4.49",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.49.tgz",
"integrity": "sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==",
"dev": true,
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/postcss"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"dependencies": {
"nanoid": "^3.3.7",
"picocolors": "^1.1.1",
"source-map-js": "^1.2.1"
},
"engines": {
"node": "^10 || ^12 || >=14"
}
},
"node_modules/postcss-resolve-nested-selector": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/postcss-resolve-nested-selector/-/postcss-resolve-nested-selector-0.1.6.tgz",
"integrity": "sha512-0sglIs9Wmkzbr8lQwEyIzlDOOC9bGmfVKcJTaxv3vMmd3uo4o4DerC3En0bnmgceeql9BfC8hRkp7cg0fjdVqw==",
"dev": true,
"license": "MIT"
},
"node_modules/postcss-safe-parser": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/postcss-safe-parser/-/postcss-safe-parser-7.0.1.tgz",
"integrity": "sha512-0AioNCJZ2DPYz5ABT6bddIqlhgwhpHZ/l65YAYo0BCIn0xiDpsnTHz0gnoTGk0OXZW0JRs+cDwL8u/teRdz+8A==",
"dev": true,
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/postcss-safe-parser"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"engines": {
"node": ">=18.0"
},
"peerDependencies": {
"postcss": "^8.4.31"
}
},
"node_modules/postcss-selector-parser": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.0.0.tgz",
"integrity": "sha512-9RbEr1Y7FFfptd/1eEdntyjMwLeghW1bHX9GWjXo19vx4ytPQhANltvVxDggzJl7mnWM+dX28kb6cyS/4iQjlQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"cssesc": "^3.0.0",
"util-deprecate": "^1.0.2"
},
"engines": {
"node": ">=4"
}
},
"node_modules/postcss-value-parser": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
"dev": true,
"license": "MIT"
},
"node_modules/prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
@ -11650,6 +12158,16 @@
"node": ">=0.10.0"
}
},
"node_modules/require-from-string": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
@ -12060,6 +12578,40 @@
"node": ">=8"
}
},
"node_modules/slice-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz",
"integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"astral-regex": "^2.0.0",
"is-fullwidth-code-point": "^3.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/slice-ansi?sponsor=1"
}
},
"node_modules/slice-ansi/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
@ -12069,6 +12621,16 @@
"node": ">=0.10.0"
}
},
"node_modules/source-map-js": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/source-map-support": {
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
@ -12316,6 +12878,150 @@
"inline-style-parser": "0.2.4"
}
},
"node_modules/stylelint": {
"version": "16.12.0",
"resolved": "https://registry.npmjs.org/stylelint/-/stylelint-16.12.0.tgz",
"integrity": "sha512-F8zZ3L/rBpuoBZRvI4JVT20ZanPLXfQLzMOZg1tzPflRVh9mKpOZ8qcSIhh1my3FjAjZWG4T2POwGnmn6a6hbg==",
"dev": true,
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/stylelint"
},
{
"type": "github",
"url": "https://github.com/sponsors/stylelint"
}
],
"license": "MIT",
"dependencies": {
"@csstools/css-parser-algorithms": "^3.0.4",
"@csstools/css-tokenizer": "^3.0.3",
"@csstools/media-query-list-parser": "^4.0.2",
"@csstools/selector-specificity": "^5.0.0",
"@dual-bundle/import-meta-resolve": "^4.1.0",
"balanced-match": "^2.0.0",
"colord": "^2.9.3",
"cosmiconfig": "^9.0.0",
"css-functions-list": "^3.2.3",
"css-tree": "^3.0.1",
"debug": "^4.3.7",
"fast-glob": "^3.3.2",
"fastest-levenshtein": "^1.0.16",
"file-entry-cache": "^9.1.0",
"global-modules": "^2.0.0",
"globby": "^11.1.0",
"globjoin": "^0.1.4",
"html-tags": "^3.3.1",
"ignore": "^6.0.2",
"imurmurhash": "^0.1.4",
"is-plain-object": "^5.0.0",
"known-css-properties": "^0.35.0",
"mathml-tag-names": "^2.1.3",
"meow": "^13.2.0",
"micromatch": "^4.0.8",
"normalize-path": "^3.0.0",
"picocolors": "^1.1.1",
"postcss": "^8.4.49",
"postcss-resolve-nested-selector": "^0.1.6",
"postcss-safe-parser": "^7.0.1",
"postcss-selector-parser": "^7.0.0",
"postcss-value-parser": "^4.2.0",
"resolve-from": "^5.0.0",
"string-width": "^4.2.3",
"supports-hyperlinks": "^3.1.0",
"svg-tags": "^1.0.0",
"table": "^6.9.0",
"write-file-atomic": "^5.0.1"
},
"bin": {
"stylelint": "bin/stylelint.mjs"
},
"engines": {
"node": ">=18.12.0"
}
},
"node_modules/stylelint/node_modules/balanced-match": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-2.0.0.tgz",
"integrity": "sha512-1ugUSr8BHXRnK23KfuYS+gVMC3LB8QGH9W1iGtDPsNWoQbgtXSExkBu2aDR4epiGWZOjZsj6lDl/N/AqqTC3UA==",
"dev": true,
"license": "MIT"
},
"node_modules/stylelint/node_modules/file-entry-cache": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-9.1.0.tgz",
"integrity": "sha512-/pqPFG+FdxWQj+/WSuzXSDaNzxgTLr/OrR1QuqfEZzDakpdYE70PwUxL7BPUa8hpjbvY1+qvCl8k+8Tq34xJgg==",
"dev": true,
"license": "MIT",
"dependencies": {
"flat-cache": "^5.0.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/stylelint/node_modules/flat-cache": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-5.0.0.tgz",
"integrity": "sha512-JrqFmyUl2PnPi1OvLyTVHnQvwQ0S+e6lGSwu8OkAZlSaNIZciTY2H/cOOROxsBA1m/LZNHDsqAgDZt6akWcjsQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"flatted": "^3.3.1",
"keyv": "^4.5.4"
},
"engines": {
"node": ">=18"
}
},
"node_modules/stylelint/node_modules/ignore": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-6.0.2.tgz",
"integrity": "sha512-InwqeHHN2XpumIkMvpl/DCJVrAHgCsG5+cn1XlnLWGwtZBm8QJfSusItfrwx81CTp5agNZqpKU2J/ccC5nGT4A==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 4"
}
},
"node_modules/stylelint/node_modules/resolve-from": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/stylelint/node_modules/signal-exit": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/stylelint/node_modules/write-file-atomic": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz",
"integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==",
"dev": true,
"license": "ISC",
"dependencies": {
"imurmurhash": "^0.1.4",
"signal-exit": "^4.0.1"
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
}
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@ -12329,6 +13035,23 @@
"node": ">=8"
}
},
"node_modules/supports-hyperlinks": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-3.1.0.tgz",
"integrity": "sha512-2rn0BZ+/f7puLOHZm1HOJfwBggfaHXUpPUSSG/SWM4TWp5KCfmNYwnC3hruy2rZlMnmWZ+QAGpZfchu3f3695A==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-flag": "^4.0.0",
"supports-color": "^7.0.0"
},
"engines": {
"node": ">=14.18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
@ -12342,6 +13065,12 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/svg-tags": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/svg-tags/-/svg-tags-1.0.0.tgz",
"integrity": "sha512-ovssysQTa+luh7A5Weu3Rta6FJlFBBbInjOh722LIt6klpU2/HtdUbszju/G4devcvk8PGt7FCLv5wftu3THUA==",
"dev": true
},
"node_modules/symbol-tree": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
@ -12349,6 +13078,47 @@
"dev": true,
"license": "MIT"
},
"node_modules/table": {
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/table/-/table-6.9.0.tgz",
"integrity": "sha512-9kY+CygyYM6j02t5YFHbNz2FN5QmYGv9zAjVp4lCDjlCw7amdckXlEt/bjMhUIfj4ThGRE4gCUH5+yGnNuPo5A==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
"ajv": "^8.0.1",
"lodash.truncate": "^4.4.2",
"slice-ansi": "^4.0.0",
"string-width": "^4.2.3",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/table/node_modules/ajv": {
"version": "8.17.1",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz",
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
"dev": true,
"license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"fast-uri": "^3.0.1",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/table/node_modules/json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
"dev": true,
"license": "MIT"
},
"node_modules/test-exclude": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz",
@ -12948,6 +13718,13 @@
}
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"dev": true,
"license": "MIT"
},
"node_modules/uuid": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",

View File

@ -9,7 +9,8 @@
"build": "npm run bundle-pglite && tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs",
"type:check": "tsc --noEmit",
"test": "jest"
"test": "jest",
"lint": "eslint 'src/**/*.{ts,tsx}'"
},
"keywords": [],
"author": "",
@ -28,19 +29,22 @@
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"eslint": "^8.57.0",
"builtin-modules": "3.3.0",
"drizzle-kit": "^0.26.2",
"esbuild": "0.17.3",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-css-modules": "^2.12.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-neverthrow": "^1.1.4",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-no-inline-styles": "^1.0.5",
"eslint-plugin-react": "^7.37.3",
"eslint-plugin-react-hooks": "^5.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"obsidian": "latest",
"prettier": "^3.4.2",
"stylelint": "^16.12.0",
"ts-jest": "^29.2.5",
"tslib": "2.4.0",
"typescript": "^4.9.0"

View File

@ -9,7 +9,7 @@ import { manualApplyChangesToFile } from '../../utils/apply';
import { removeAITags } from '../../utils/content-filter';
import { PromptGenerator } from '../../utils/prompt-generator';
interface InlineEditProps {
type InlineEditProps = {
source: string;
secStartLine: number;
secEndLine: number;
@ -17,7 +17,7 @@ interface InlineEditProps {
settings: InfioSettings;
}
interface InputAreaProps {
type InputAreaProps = {
value: string;
onChange: (value: string) => void;
}
@ -43,7 +43,7 @@ const InputArea: React.FC<InputAreaProps> = ({ value, onChange }) => {
);
};
interface ControlAreaProps {
type ControlAreaProps = {
settings: InfioSettings;
onSubmit: () => void;
selectedModel: string;
@ -144,15 +144,15 @@ export const InlineEdit: React.FC<InlineEditProps> = ({
};
const parseSmartComposeBlock = (content: string) => {
const match = content.match(/<infio_block[^>]*>([\s\S]*?)<\/infio_block>/);
const match = /<infio_block[^>]*>([\s\S]*?)<\/infio_block>/.exec(content);
if (!match) {
return null;
}
const blockContent = match[1].trim();
const attributes = match[0].match(/startLine="(\d+)"/);
const attributes = /startLine="(\d+)"/.exec(match[0]);
const startLine = attributes ? parseInt(attributes[1]) : undefined;
const endLineMatch = match[0].match(/endLine="(\d+)"/);
const endLineMatch = /endLine="(\d+)"/.exec(match[0]);
const endLine = endLineMatch ? parseInt(endLineMatch[1]) : undefined;
return {

View File

@ -1,5 +1,5 @@
import * as Handlebars from "handlebars";
import { err, ok, Result } from "neverthrow";
import { Result, err, ok } from "neverthrow";
import { FewShotExample } from "../../settings/versions";
import { CustomLLMModel } from "../../types/llm/model";

View File

@ -90,7 +90,7 @@ function startLocationOfEachWord(text: string): number[] {
}
function isWhiteSpaceChar(char: string | undefined): boolean {
return char !== undefined && char.match(/\s/) !== null;
return char !== undefined && (/\s/.exec(char)) !== null;
}
export default RemoveOverlap;

View File

@ -1,6 +1,6 @@
import { generateRandomString } from "../utils";
import Context from "../context-detection";
import { PrefixAndSuffix, PreProcessor } from "../types";
import { PreProcessor, PrefixAndSuffix } from "../types";
import { generateRandomString } from "../utils";
const DATA_VIEW_REGEX = /```dataview(js){0,1}(.|\n)*?```/gm;
const UNIQUE_CURSOR = `${generateRandomString(16)}`;

View File

@ -1,5 +1,5 @@
import Context from "../context-detection";
import { PrefixAndSuffix, PreProcessor } from "../types";
import { PreProcessor, PrefixAndSuffix } from "../types";
class LengthLimiter implements PreProcessor {
private readonly maxPrefixChars: number;

View File

@ -1,7 +1,7 @@
import { TFile } from "obsidian";
import { InfioSettings } from "../../../types/settings";
import { DocumentChanges } from "../../../render-plugin/document-changes-listener";
import { InfioSettings } from "../../../types/settings";
import { EventHandler } from "./types";

View File

@ -1,8 +1,8 @@
import { Notice } from "obsidian";
import Context from "../context-detection";
import EventListener from "../../../event-listener";
import { DocumentChanges } from "../../../render-plugin/document-changes-listener";
import Context from "../context-detection";
import State from "./state";

View File

@ -1,6 +1,6 @@
import Context from "../context-detection";
import EventListener from "../../../event-listener";
import { DocumentChanges } from "../../../render-plugin/document-changes-listener";
import Context from "../context-detection";
import State from "./state";

View File

@ -1,10 +1,10 @@
import { TFile } from "obsidian";
import { InfioSettings } from "../../../types/settings";
import { DocumentChanges } from "../../../render-plugin/document-changes-listener";
import { InfioSettings } from "../../../types/settings";
export interface EventHandler {
export type EventHandler = {
handleSettingChanged(settings: InfioSettings): void;
handleDocumentChange(documentChanges: DocumentChanges): Promise<void>;

View File

@ -2,14 +2,14 @@ import { Result } from "neverthrow";
import Context from "./context-detection";
export interface AutocompleteService {
export type AutocompleteService = {
fetchPredictions(
prefix: string,
suffix: string
): Promise<Result<string, Error>>;
}
export interface PostProcessor {
export type PostProcessor = {
process(
prefix: string,
suffix: string,
@ -18,23 +18,23 @@ export interface PostProcessor {
): string;
}
export interface PreProcessor {
export type PreProcessor = {
process(prefix: string, suffix: string, context: Context): PrefixAndSuffix;
removesCursor(prefix: string, suffix: string): boolean;
}
export interface PrefixAndSuffix {
export type PrefixAndSuffix = {
prefix: string;
suffix: string;
}
export interface ChatMessage {
export type ChatMessage = {
content: string;
role: "user" | "assistant" | "system";
}
export interface UserMessageFormattingInputs {
export type UserMessageFormattingInputs = {
prefix: string;
suffix: string;
}
@ -43,12 +43,12 @@ export type UserMessageFormatter = (
inputs: UserMessageFormattingInputs
) => string;
export interface ApiClient {
export type ApiClient = {
queryChatModel(messages: ChatMessage[]): Promise<Result<string, Error>>;
checkIfConfiguredCorrectly?(): Promise<string[]>;
}
export interface ModelOptions {
export type ModelOptions = {
temperature: number;
top_p: number;
frequency_penalty: number;

View File

@ -40,7 +40,7 @@ export function isMatchBetweenPathAndPatterns(
}
export function extractNextWordAndRemaining(suggestion: string): [string | undefined, string | undefined] {
const leadingWhitespacesMatch = suggestion.match(/^(\s*)/);
const leadingWhitespacesMatch = /^(\s*)/.exec(suggestion);
const leadingWhitespaces = leadingWhitespacesMatch ? leadingWhitespacesMatch[0] : '';
const trimmedSuggestion = suggestion.slice(leadingWhitespaces.length);
@ -48,11 +48,11 @@ export function extractNextWordAndRemaining(suggestion: string): [string | undef
let nextWord: string | undefined;
let remaining: string | undefined = undefined;
const whitespaceAfterNextWordMatch = trimmedSuggestion.match(/\s+/);
const whitespaceAfterNextWordMatch = /\s+/.exec(trimmedSuggestion);
if (!whitespaceAfterNextWordMatch) {
nextWord = trimmedSuggestion || undefined;
} else {
const whitespaceAfterNextWordStartingIndex = whitespaceAfterNextWordMatch.index!;
const whitespaceAfterNextWordStartingIndex = whitespaceAfterNextWordMatch.index;
const whitespaceAfterNextWord = whitespaceAfterNextWordMatch[0];
const whitespaceLength = whitespaceAfterNextWord.length;
const startOfWhitespaceAfterNextWordIndex = whitespaceAfterNextWordStartingIndex + whitespaceLength;

View File

@ -22,12 +22,12 @@ import {
LLMAPIKeyNotSetException,
} from './exception'
export interface RangeFilter {
export type RangeFilter = {
gte?: number;
lte?: number;
}
export interface ChunkFilter {
export type ChunkFilter = {
field: string;
match_all?: string[];
range?: RangeFilter;
@ -36,7 +36,7 @@ export interface ChunkFilter {
/**
* Interface for making requests to the Infio API
*/
export interface InfioRequest {
export type InfioRequest = {
/** Required: The content of the user message to attach to the topic and then generate an assistant message in response to */
messages: RequestMessage[];
// /** Required: The ID of the topic to attach the message to */

View File

@ -1,5 +1,5 @@
import { PGlite } from '@electric-sql/pglite'
// @ts-ignore
// @ts-expect-error
import { type PGliteWithLive, live } from '@electric-sql/pglite/live'
import { App, normalizePath } from 'obsidian'

View File

@ -271,7 +271,7 @@ export class VectorManager {
}
return null
}),
).then((files) => files.filter(Boolean) as TFile[])
).then((files) => files.filter(Boolean))
return filesToIndex
}

View File

@ -4,7 +4,7 @@ import { SUPPORT_EMBEDDING_SIMENTION } from '../constants'
import { EmbeddingModelId } from '../types/embedding'
// PostgreSQL column types
interface ColumnDefinition {
type ColumnDefinition = {
type: string
notNull?: boolean
primaryKey?: boolean
@ -14,7 +14,7 @@ interface ColumnDefinition {
dimensions?: number
}
interface TableDefinition {
type TableDefinition = {
name: string
columns: Record<string, ColumnDefinition>
indices?: Record<string, {
@ -61,7 +61,7 @@ export const vectorTables = SUPPORT_EMBEDDING_SIMENTION.reduce<
}, {})
// Type definitions for vector table
export interface VectorRecord {
export type VectorRecord = {
id: number
path: string
mtime: number
@ -91,7 +91,7 @@ export type TemplateContent = {
nodes: SerializedLexicalNode[]
}
export interface TemplateRecord {
export type TemplateRecord = {
id: string
name: string
content: TemplateContent
@ -113,14 +113,14 @@ export const templateTable: TableDefinition = {
}
}
export interface Conversation {
export type Conversation = {
id: string // uuid
title: string
createdAt: Date
updatedAt: Date
}
export interface Message {
export type Message = {
id: string // uuid
conversationId: string // uuid
role: 'user' | 'assistant'

View File

@ -1,4 +1,4 @@
export interface SqlMigration {
export type SqlMigration = {
description: string;
sql: string;
}

View File

@ -258,7 +258,7 @@ class EventListener implements EventHandler {
if (trigger.type === "string" && documentChanges.getPrefix().endsWith(trigger.value)) {
return true;
}
if (trigger.type === "regex" && documentChanges.getPrefix().match(trigger.value)) {
if (trigger.type === "regex" && (RegExp(trigger.value).exec(documentChanges.getPrefix()))) {
return true;
}
}

View File

@ -9,7 +9,7 @@ import {
WidgetType,
} from "@codemirror/view";
import { cancelSuggestion, InlineSuggestionState } from "./states";
import { InlineSuggestionState, cancelSuggestion } from "./states";
import { OptionalSuggestion, Suggestion } from "./types";
const RenderSuggestionPlugin = () =>

View File

@ -1,13 +1,13 @@
// @ts-nocheck
import { Text } from "@codemirror/state";
export interface Suggestion {
export type Suggestion = {
value: string;
render: boolean;
}
export type OptionalSuggestion = Suggestion | null;
export interface InlineSuggestion {
export type InlineSuggestion = {
suggestion: OptionalSuggestion;
doc: Text | null;
}

View File

@ -30,7 +30,7 @@ import {
MIN_TOP_P
} from "./versions";
interface IProps {
type IProps = {
onSettingsChanged(settings: InfioSettings): void;
settings: InfioSettings;

View File

@ -5,7 +5,7 @@ import { InfioSettings } from "../types/settings";
import ModelsSettings from "./ModelsSettings";
interface CustomSettingsProps {
type CustomSettingsProps = {
plugin: InfioPlugin;
}

View File

@ -1,6 +1,6 @@
import React from "react";
export interface DropdownComponentProps {
export type DropdownComponentProps = {
name: string;
description?: string;
options: string[];
@ -32,7 +32,7 @@ export const DropdownComponent: React.FC<DropdownComponentProps> = ({
</div>
);
export interface TextComponentProps {
export type TextComponentProps = {
name: string;
description?: string;
placeholder: string;
@ -62,7 +62,7 @@ export const TextComponent: React.FC<TextComponentProps> = ({
</div>
);
export interface ToggleComponentProps {
export type ToggleComponentProps = {
name?: string;
description?: string;
value: boolean;

View File

@ -6,7 +6,7 @@ import { InfioSettings } from "../types/settings";
import { DropdownComponent, TextComponent, ToggleComponent } from "./FormComponents";
interface ModelRowProps {
type ModelRowProps = {
model: CustomLLMModel;
canDelete: boolean;
onToggle: (enabled: boolean) => void;
@ -31,7 +31,7 @@ const ModelRow: React.FC<ModelRowProps> = ({ model, canDelete, onToggle, onDelet
</tr>
);
interface ModelFormProps {
type ModelFormProps = {
providers: string[];
onSubmit: (model: CustomLLMModel) => void;
isEmbeddingModel: boolean;
@ -96,7 +96,7 @@ const ModelForm: React.FC<ModelFormProps> = ({ providers, onSubmit, isEmbeddingM
);
};
interface ModelListProps {
type ModelListProps = {
models: CustomLLMModel[];
chatModelKey: string;
applyModelKey: string;
@ -139,7 +139,7 @@ const ModelList: React.FC<ModelListProps> = ({
</div>
);
interface ModelsSettingsProps {
type ModelsSettingsProps = {
settings: InfioSettings;
setSettings: (settings: InfioSettings) => void;
}

View File

@ -2,7 +2,7 @@ import * as React from "react";
import SettingsItem from "./SettingsItem";
interface IProps {
type IProps = {
name: string;
description: string;

View File

@ -2,7 +2,7 @@ import * as React from "react";
import SettingsItem from "./SettingsItem";
interface IProps {
type IProps = {
name: string;
description: string;

View File

@ -4,7 +4,7 @@ import * as React from "react";
import Context from "../../core/autocomplete/context-detection";
import { FewShotExample } from "../versions";
interface IProps {
type IProps = {
name: string;
description: string;

View File

@ -1,6 +1,6 @@
import * as React from "react";
interface IProps {
type IProps = {
name: string;
description: string | React.ReactNode;
errorMessage?: string;

View File

@ -3,7 +3,7 @@ import { useRef } from "react";
import SettingsItem from "./SettingsItem";
interface IProps {
type IProps = {
name: string;
description: string;

View File

@ -2,7 +2,7 @@ import * as React from "react";
import SettingsItem from "./SettingsItem";
interface IProps {
type IProps = {
name: string;
description: string;
placeholder: string;

View File

@ -3,7 +3,7 @@ import * as React from "react";
import { Trigger } from "../versions";
interface IProps {
type IProps = {
name: string;
description: string;
triggers: Trigger[];

View File

@ -1,7 +1,7 @@
import { z } from "zod";
import { azureOAIApiSettingsSchema, fewShotExampleSchema, MAX_DELAY, MAX_MAX_CHAR_LIMIT, MIN_DELAY, MIN_MAX_CHAR_LIMIT, modelOptionsSchema, openAIApiSettingsSchema } from "../shared";
import { MAX_DELAY, MAX_MAX_CHAR_LIMIT, MIN_DELAY, MIN_MAX_CHAR_LIMIT, azureOAIApiSettingsSchema, fewShotExampleSchema, modelOptionsSchema, openAIApiSettingsSchema } from "../shared";
import block_qoute_example from "./few-shot-examples/block-qoute-example";
import codeblock_function_completion from "./few-shot-examples/codeblock-function-completion";

View File

@ -1,13 +1,12 @@
import { z } from "zod";
import { isRegexValid, isValidIgnorePattern } from "../../../utils/auto-complete";
import {
azureOAIApiSettingsSchema, fewShotExampleSchema,
MAX_DELAY,
MAX_MAX_CHAR_LIMIT,
MAX_DELAY, MAX_MAX_CHAR_LIMIT,
MIN_DELAY,
MIN_MAX_CHAR_LIMIT,
azureOAIApiSettingsSchema,
fewShotExampleSchema,
modelOptionsSchema,
ollamaApiSettingsSchema,
openAIApiSettingsSchema,

View File

@ -3,11 +3,11 @@ import { z } from 'zod';
import { DEFAULT_MODELS } from '../constants';
import {
fewShotExampleSchema,
MAX_DELAY,
MAX_MAX_CHAR_LIMIT,
MIN_DELAY,
MIN_MAX_CHAR_LIMIT,
fewShotExampleSchema,
modelOptionsSchema
} from '../settings/versions/shared';
import { DEFAULT_AUTOCOMPLETE_SETTINGS } from "../settings/versions/v1/v1";

View File

@ -1,8 +1,8 @@
// @ts-nocheck
import { cloneDeep, each, get, has, isArray, isEqual, isNumber, isObject, isString, set, unset } from "lodash";
import * as mm from "micromatch";
import { err, ok, Result } from "neverthrow";
import { z, ZodError, ZodIssueCode, ZodType } from 'zod';
import { Result, err, ok } from "neverthrow";
import { ZodError, ZodIssueCode, ZodType, z } from 'zod';
import { DEFAULT_SETTINGS, PluginData, Settings } from "../settings/versions";
import { isSettingsV0, isSettingsV1, migrateFromV0ToV1 } from "../settings/versions/migration";
@ -77,7 +77,7 @@ function replaceValueWithDefaultValue<V, T>(
paths: string[],
defaultValue: T,
): V {
const result = cloneDeep(value) as any;
const result = cloneDeep(value);
paths.forEach(path => {
const originalValue = has(defaultValue, path) ? get(defaultValue, path) : undefined;
set(result, path, originalValue);
@ -100,7 +100,7 @@ function removeUnrecognizedKeys(value: JSONObject | null | undefined, error: Zod
// Array path will be handled separately by the value replacement function
.filter(issue => !isAnArrayPath(issue.path))
.flatMap(issue => {
// @ts-ignore
// @ts-expect-error
const keys = issue.keys;
return keys.map(key => [...issue.path, key].join('.'));
});

View File

@ -4,7 +4,7 @@ export function parseImageDataUrl(dataUrl: string): {
mimeType: string
base64Data: string
} {
const matches = dataUrl.match(/^data:([^;]+);base64,(.+)/)
const matches = /^data:([^;]+);base64,(.+)/.exec(dataUrl)
if (!matches) {
throw new Error('Invalid image data URL format')
}

View File

@ -4,55 +4,59 @@ import { calculateFileDistance } from './obsidian'
describe('calculateFileDistance', () => {
// Mock TFile class
class MockTFile {
class MockTFile extends TFile {
path: string
constructor(path: string) {
super()
this.path = path
}
}
it('should calculate the correct distance between files in the same folder', () => {
const file1 = new MockTFile('folder/file1.md') as TFile
const file2 = new MockTFile('folder/file2.md') as TFile
const file1 = new MockTFile('folder/file1.md')
const file2 = new MockTFile('folder/file2.md')
const result = calculateFileDistance(file1, file2)
expect(result).toBe(2)
})
it('should calculate the correct distance between files in different subfolders', () => {
const file1 = new MockTFile('folder1/folder2/file1.md') as TFile
const file2 = new MockTFile('folder1/folder3/file2.md') as TFile
const file1 = new MockTFile('folder1/folder2/file1.md')
const file2 = new MockTFile('folder1/folder3/file2.md')
const result = calculateFileDistance(file1, file2)
expect(result).toBe(4)
})
it('should return null for files in different top-level folders', () => {
const file1 = new MockTFile('folder1/file1.md') as TFile
const file2 = new MockTFile('folder2/file2.md') as TFile
const file1 = new MockTFile('folder1/file1.md')
const file2 = new MockTFile('folder2/file2.md')
const result = calculateFileDistance(file1, file2)
expect(result).toBeNull()
})
it('should handle files at different depths', () => {
const file1 = new MockTFile('folder1/folder2/subfolder/file1.md') as TFile
const file2 = new MockTFile('folder1/folder3/file2.md') as TFile
const file1 = new MockTFile('folder1/folder2/subfolder/file1.md')
const file2 = new MockTFile('folder1/folder3/file2.md')
const result = calculateFileDistance(file1, file2)
expect(result).toBe(5)
})
it('should return 0 for the same file', () => {
const file = new MockTFile('folder/file.md') as TFile
const file = new MockTFile('folder/file.md')
const result = calculateFileDistance(file, file)
expect(result).toBe(0)
})
it('should calculate the correct distance between a folder and a file', () => {
const file = new MockTFile('folder1/folder2/file1.md') as TFile
const folder = new MockTFile('folder1/folder2') as TFolder
const file = new MockTFile('folder1/folder2/file1.md')
const folder = new MockTFile('folder1/folder2')
if (!(folder instanceof TFolder)) {
throw new Error('Expected folder to be a TFolder instance')
}
const result = calculateFileDistance(file, folder)
expect(result).toBe(1)

View File

@ -98,7 +98,7 @@ export class YoutubeTranscript {
const videoPageBody = videoPageResponse.text
// Extract title using regex from <title> tags
const titleMatch = videoPageBody.match(/<title>(.*?)<\/title>/)
const titleMatch = /<title>(.*?)<\/title>/.exec(videoPageBody)
const title = titleMatch
? titleMatch[1].replace(' - YouTube', '').trim()
: ''
@ -189,7 +189,7 @@ export class YoutubeTranscript {
if (videoId.length === 11) {
return videoId
}
const matchId = videoId.match(RE_YOUTUBE)
const matchId = RE_YOUTUBE.exec(videoId)
if (matchId?.length) {
return matchId[1]
}