From 93e8c76ea856b31a1c0902b5b9f2148dddf5c36a Mon Sep 17 00:00:00 2001 From: 3y3 <3y3@ya.ru> Date: Tue, 24 Sep 2024 15:17:40 +0300 Subject: [PATCH] fix: Fix release scripts --- .github/workflows/quality.yaml | 2 +- .github/workflows/tests.yaml | 2 +- package-lock.json | 607 +++++++++++++++++++++++++++++++-- package.json | 10 +- src/worker/score.ts | 63 +++- tsconfig.json | 2 + 6 files changed, 651 insertions(+), 35 deletions(-) diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml index c877e74..e1f665a 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/quality.yaml @@ -1,4 +1,4 @@ -name: OpenAPI code quality +name: Search code quality on: pull_request: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c0fda50..c0f75b6 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,4 +1,4 @@ -name: OpenAPI tests +name: Search tests on: pull_request: diff --git a/package-lock.json b/package-lock.json index 186a335..05dafa6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,17 +13,18 @@ "node-html-parser": "^6.1.13" }, "devDependencies": { - "@diplodoc/client": "^2.8.0", - "@diplodoc/components": "^4.11.2", + "@diplodoc/client": "^3.0.0-beta-1", + "@diplodoc/components": "^4.13.0", "@diplodoc/lint": "^1.1.3", "@diplodoc/tsconfig": "^1.0.2", "@esbuild-plugins/tsconfig-paths": "^0.1.2", "@types/lunr": "^2.3.7", "esbuild": "^0.19.10", - "esbuild-node-externals": "^1.14.0" + "esbuild-node-externals": "^1.14.0", + "typescript": "^5.6.2" }, "peerDependencies": { - "@diplodoc/client": "^2.8.0", + "@diplodoc/client": "^3.0.0-beta-1", "@diplodoc/components": "^4.11.2" } }, @@ -576,15 +577,15 @@ } }, "node_modules/@diplodoc/client": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/@diplodoc/client/-/client-2.8.0.tgz", - "integrity": "sha512-Mu2OMWVVpThCpLN1O393idI8U3Ai2uninu31HbO1U/MI1cG5UCjeZDSKMVxxDxFVrq3rGzthySzFxLw4v7fmtQ==", + "version": "3.0.0-beta-1", + "resolved": "https://registry.npmjs.org/@diplodoc/client/-/client-3.0.0-beta-1.tgz", + "integrity": "sha512-qKg7XpNLlwN3dVyd/mVofxdbVv+APW+E0K5ydrhbFtpVeCoaLM8zK4BHMivQS6CRKIaccJ6IVgOWU+TapDNo9g==", "dev": true, "license": "ISC", "dependencies": { "@diplodoc/latex-extension": "^1.0.2", "@diplodoc/mermaid-extension": "^1.2.1", - "@diplodoc/transform": "^4.10.3", + "@diplodoc/transform": "^4.31.3", "url": "^0.11.0" }, "engines": { @@ -593,14 +594,15 @@ } }, "node_modules/@diplodoc/components": { - "version": "4.11.2", - "resolved": "https://registry.npmjs.org/@diplodoc/components/-/components-4.11.2.tgz", - "integrity": "sha512-Q7AJqL/2hp/42XNJ/KMgqps21CO1Yj2EigL08UQlV6M6ES+zhsJTE1btec5/H4JdBQEPbwbIEUxFTcYnNMqg6A==", + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@diplodoc/components/-/components-4.13.0.tgz", + "integrity": "sha512-XbUGScpr7ODeicxGpY1MmEYan/gz1D20UchGbpkYe0Ff8kwgkpoqx4+p8a2xD8T7rIThCP2ZWLztpzrZEpTneg==", "dev": true, "license": "MIT", "dependencies": { "@gravity-ui/components": "^3.6.0", "@gravity-ui/icons": "^2.5.0", + "@gravity-ui/page-constructor": "^5.22.0", "@gravity-ui/uikit": "^6.2.0", "@popperjs/core": "^2.11.2", "bem-cn-lite": "4.1.0", @@ -612,6 +614,7 @@ "react-hotkeys-hook": "^3.3.1", "react-i18next": "11.15.6", "react-popper": "^2.2.5", + "react-transition-group": "^4.4.5", "scroll-into-view-if-needed": "2.2.29", "url": "^0.11.1" }, @@ -704,9 +707,9 @@ } }, "node_modules/@diplodoc/tabs-extension": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@diplodoc/tabs-extension/-/tabs-extension-3.3.1.tgz", - "integrity": "sha512-uzLLJlkmiBSlTEc5eXD2QeqqYwFXOW2gUZ4LFAf1ViyzJGs9lAvWui0hizqq5VuQgttD2TSJ0pBQ9RvTQoFf5g==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/@diplodoc/tabs-extension/-/tabs-extension-3.3.2.tgz", + "integrity": "sha512-aCfesaBWfNOlfKTidGA78pdhAJc63oQTb3zLUolr3xDkj8dadW3hE6YlXFDdTo0tpPrmKhVfm+7O0UGKFzrf1A==", "dev": true, "license": "MIT", "peerDependencies": { @@ -719,14 +722,14 @@ } }, "node_modules/@diplodoc/transform": { - "version": "4.31.2", - "resolved": "https://registry.npmjs.org/@diplodoc/transform/-/transform-4.31.2.tgz", - "integrity": "sha512-nazb35uHC5uAHO8jA/lojhGtKTvrfUcp1flvqiiL8grCBEM3fi7j55Zhq2GqAM44/db0odXAkVZDbPdqxFEN7w==", + "version": "4.31.3", + "resolved": "https://registry.npmjs.org/@diplodoc/transform/-/transform-4.31.3.tgz", + "integrity": "sha512-s2TXuDfoXNZaYq+HIxEoit25fyzg2mB4AbUIQw5iwhp7scEtG2eykxInQHy3kB/MjOO686cJ/DrCvrvJOg7T1A==", "dev": true, "license": "MIT", "dependencies": { "@diplodoc/cut-extension": "^0.2.5", - "@diplodoc/tabs-extension": "^3.3.1", + "@diplodoc/tabs-extension": "^3.3.2", "chalk": "^4.1.2", "cheerio": "^1.0.0", "css": "^3.0.0", @@ -1400,6 +1403,24 @@ "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0" } }, + "node_modules/@gravity-ui/date-components": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/@gravity-ui/date-components/-/date-components-2.10.1.tgz", + "integrity": "sha512-7g5SYEzpkQnb5L+e/k0S9pS9zY4r+Dus4x/5Bpbdn7WLR8j0/ONWyQIY8ZQxkvZPKrmeMyha2bNi8QGJZRHFcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bem-react/classname": "^1.6.0", + "@gravity-ui/date-utils": "^2.5.3", + "@gravity-ui/icons": "^2.2.0", + "tslib": "^2.6.2" + }, + "peerDependencies": { + "@gravity-ui/uikit": "^6.0.0", + "react": ">=17.0.0", + "react-dom": ">=17.0.0" + } + }, "node_modules/@gravity-ui/date-utils": { "version": "2.5.3", "resolved": "https://registry.npmjs.org/@gravity-ui/date-utils/-/date-utils-2.5.3.tgz", @@ -1411,6 +1432,30 @@ "lodash": "^4.17.0" } }, + "node_modules/@gravity-ui/dynamic-forms": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/@gravity-ui/dynamic-forms/-/dynamic-forms-4.12.0.tgz", + "integrity": "sha512-JNiGLHj2y7t1/coV4AbpgV1D3Crwk00VIK7EDXRLQvteSGUwpZQ5puM9M89DMZZK3DBcWCpQO9f4GWLxXwLCTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bem-react/classname": "^1.6.0", + "@gravity-ui/components": "^3.0.0", + "@gravity-ui/date-components": "^2.4.0", + "@gravity-ui/date-utils": "^2.4.0", + "@gravity-ui/i18n": "^1.2.0", + "@gravity-ui/icons": "^2.8.1", + "lodash": "^4.17.20" + }, + "peerDependencies": { + "@gravity-ui/uikit": "^6.0.0", + "final-form": "^4.20.2", + "react": "^16.0.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0", + "react-final-form": "^6.5.3", + "react-is": "^16.0.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/@gravity-ui/eslint-config": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/@gravity-ui/eslint-config/-/eslint-config-3.2.0.tgz", @@ -1474,6 +1519,129 @@ } } }, + "node_modules/@gravity-ui/page-constructor": { + "version": "5.26.1", + "resolved": "https://registry.npmjs.org/@gravity-ui/page-constructor/-/page-constructor-5.26.1.tgz", + "integrity": "sha512-0yvG5bg5E6m3wlPYiCCxUN0F7s8mcDUfHMK7Sd6QFclkP/v4lfKjCgJ81+aqmt3zeG87qctdjYgvpgaU21wy4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bem-react/classname": "^1.6.0", + "@gravity-ui/components": "^3.8.0", + "@gravity-ui/dynamic-forms": "^4.11.0", + "@gravity-ui/i18n": "^1.3.0", + "@react-spring/web": "^9.7.3", + "ajv": "^8.12.0", + "ajv-keywords": "^5.1.0", + "final-form": "^4.20.9", + "github-buttons": "2.23.0", + "js-yaml-source-map": "^0.2.2", + "lodash": "^4.17.21", + "monaco-editor": "^0.38.0", + "react-final-form": "^6.5.9", + "react-monaco-editor": "^0.53.0", + "react-player": "^2.9.0", + "react-slick": "^0.29.0", + "react-transition-group": "^4.4.2", + "react-waypoint": "^10.1.0", + "sanitize-html": "2.12.1", + "snakecase-keys": "^5.1.0", + "swiper": "^6.8.4", + "typograf": "^6.14.0", + "utility-types": "^3.10.0", + "uuid": "^9.0.0" + }, + "peerDependencies": { + "@diplodoc/transform": "^4.10.4", + "@gravity-ui/uikit": "^6.0.0", + "react": "^16.0.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@gravity-ui/page-constructor/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/@gravity-ui/page-constructor/node_modules/ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3" + }, + "peerDependencies": { + "ajv": "^8.8.2" + } + }, + "node_modules/@gravity-ui/page-constructor/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@gravity-ui/page-constructor/node_modules/htmlparser2": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", + "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", + "dev": true, + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "entities": "^4.4.0" + } + }, + "node_modules/@gravity-ui/page-constructor/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/@gravity-ui/page-constructor/node_modules/sanitize-html": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.12.1.tgz", + "integrity": "sha512-Plh+JAn0UVDpBRP/xEjsk+xDCoOvMBwQUf/K+/cBAVuTbtX8bj2VB7S1sL1dssVpykqp0/KPSesHrqXtokVBpA==", + "dev": true, + "license": "MIT", + "dependencies": { + "deepmerge": "^4.2.2", + "escape-string-regexp": "^4.0.0", + "htmlparser2": "^8.0.0", + "is-plain-object": "^5.0.0", + "parse-srcset": "^1.0.2", + "postcss": "^8.3.11" + } + }, "node_modules/@gravity-ui/prettier-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@gravity-ui/prettier-config/-/prettier-config-1.1.0.tgz", @@ -1733,6 +1901,84 @@ "url": "https://opencollective.com/popperjs" } }, + "node_modules/@react-spring/animated": { + "version": "9.7.4", + "resolved": "https://registry.npmjs.org/@react-spring/animated/-/animated-9.7.4.tgz", + "integrity": "sha512-7As+8Pty2QlemJ9O5ecsuPKjmO0NKvmVkRR1n6mEotFgWar8FKuQt2xgxz3RTgxcccghpx1YdS1FCdElQNexmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@react-spring/shared": "~9.7.4", + "@react-spring/types": "~9.7.4" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@react-spring/core": { + "version": "9.7.4", + "resolved": "https://registry.npmjs.org/@react-spring/core/-/core-9.7.4.tgz", + "integrity": "sha512-GzjA44niEJBFUe9jN3zubRDDDP2E4tBlhNlSIkTChiNf9p4ZQlgXBg50qbXfSXHQPHak/ExYxwhipKVsQ/sUTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@react-spring/animated": "~9.7.4", + "@react-spring/shared": "~9.7.4", + "@react-spring/types": "~9.7.4" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/react-spring/donate" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@react-spring/rafz": { + "version": "9.7.4", + "resolved": "https://registry.npmjs.org/@react-spring/rafz/-/rafz-9.7.4.tgz", + "integrity": "sha512-mqDI6rW0Ca8IdryOMiXRhMtVGiEGLIO89vIOyFQXRIwwIMX30HLya24g9z4olDvFyeDW3+kibiKwtZnA4xhldA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@react-spring/shared": { + "version": "9.7.4", + "resolved": "https://registry.npmjs.org/@react-spring/shared/-/shared-9.7.4.tgz", + "integrity": "sha512-bEPI7cQp94dOtCFSEYpxvLxj0+xQfB5r9Ru1h8OMycsIq7zFZon1G0sHrBLaLQIWeMCllc4tVDYRTLIRv70C8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@react-spring/rafz": "~9.7.4", + "@react-spring/types": "~9.7.4" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@react-spring/types": { + "version": "9.7.4", + "resolved": "https://registry.npmjs.org/@react-spring/types/-/types-9.7.4.tgz", + "integrity": "sha512-iQVztO09ZVfsletMiY+DpT/JRiBntdsdJ4uqk3UJFhrhS8mIC9ZOZbmfGSRs/kdbNPQkVyzucceDicQ/3Mlj9g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@react-spring/web": { + "version": "9.7.4", + "resolved": "https://registry.npmjs.org/@react-spring/web/-/web-9.7.4.tgz", + "integrity": "sha512-UMvCZp7I5HCVIleSa4BwbNxynqvj+mJjG2m20VO2yPoi2pnCYANy58flvz9v/YcXTAvsmL655FV3pm5fbr6akA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@react-spring/animated": "~9.7.4", + "@react-spring/core": "~9.7.4", + "@react-spring/shared": "~9.7.4", + "@react-spring/types": "~9.7.4" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/@rtsao/scc": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", @@ -2768,6 +3014,13 @@ "dev": true, "license": "MIT" }, + "node_modules/consolidated-events": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/consolidated-events/-/consolidated-events-2.0.2.tgz", + "integrity": "sha512-2/uRVMdRypf5z/TW/ncD/66l75P5hH2vM/GR8Jf8HLc2xnfJtmina6F6du8+v4Z2vTrMo7jC+W1tmEEuuELgkQ==", + "dev": true, + "license": "MIT" + }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -3257,6 +3510,16 @@ "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" } }, + "node_modules/dom7": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/dom7/-/dom7-3.0.0.tgz", + "integrity": "sha512-oNlcUdHsC4zb7Msx7JN3K0Nro1dzJ48knvBOnDPKJ2GV9wl1i5vydJZUSyOfrkKFDZEud/jBsTk92S/VGSAe/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "ssr-window": "^3.0.0-alpha.1" + } + }, "node_modules/domelementtype": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", @@ -3298,6 +3561,17 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/electron-to-chromium": { "version": "1.5.20", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.20.tgz", @@ -3340,6 +3614,13 @@ "node": ">=10.13.0" } }, + "node_modules/enquire.js": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/enquire.js/-/enquire.js-2.1.6.tgz", + "integrity": "sha512-/KujNpO+PT63F7Hlpu4h3pE3TokKRHN26JYmQpPyjkRD/N57R7bPDNojMXdi7uveAKjYB7yQnartCxZnFWr0Xw==", + "dev": true, + "license": "MIT" + }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", @@ -4515,6 +4796,23 @@ "node": ">=8" } }, + "node_modules/final-form": { + "version": "4.20.10", + "resolved": "https://registry.npmjs.org/final-form/-/final-form-4.20.10.tgz", + "integrity": "sha512-TL48Pi1oNHeMOHrKv1bCJUrWZDcD3DIG6AGYVNOnyZPr7Bd/pStN0pL+lfzF5BNoj/FclaoiaLenk4XUIFVYng==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.10.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/final-form" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -4714,6 +5012,13 @@ "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" } }, + "node_modules/github-buttons": { + "version": "2.23.0", + "resolved": "https://registry.npmjs.org/github-buttons/-/github-buttons-2.23.0.tgz", + "integrity": "sha512-2REUOV3ue6NmT0QThhfzfYmeSoYpCG73+tL7Ir2C7P+gshRerI05WuIQuhDkE2Zlg5Wc39hc2DHj+pE23mGJvw==", + "dev": true, + "license": "BSD-2-Clause" + }, "node_modules/github-slugger": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.5.0.tgz", @@ -5776,6 +6081,16 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/js-yaml-source-map": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/js-yaml-source-map/-/js-yaml-source-map-0.2.2.tgz", + "integrity": "sha512-z45Aww8oXJh9GuWUnwmvHsAkB7I/oWrkoHU554UQ8Ik4dyhVrk/nwClTI435feU7QIy7E0XaW8jHvZ4QxaAjog==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "js-yaml": "^4.0.0" + } + }, "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -5817,6 +6132,16 @@ "dev": true, "license": "MIT" }, + "node_modules/json2mq": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/json2mq/-/json2mq-0.2.0.tgz", + "integrity": "sha512-SzoRg7ux5DWTII9J2qkrZrqV1gt+rTaoufMxEzXbS26Uid0NwaJd123HcoB80TgubEppxxIGdNxCx50fEoEWQA==", + "dev": true, + "license": "MIT", + "dependencies": { + "string-convert": "^0.2.0" + } + }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -6032,6 +6357,13 @@ "node": ">=18.0.0" } }, + "node_modules/load-script": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/load-script/-/load-script-1.0.0.tgz", + "integrity": "sha512-kPEjMFtZvwL9TaZo0uZ2ml+Ye9HUMmPwbYRJ324qF9tqMejwykJ5ggTyvzmrbBeapCAbk98BSbTeovHEEP1uCA==", + "dev": true, + "license": "MIT" + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -6055,6 +6387,13 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash.debounce": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -6177,6 +6516,16 @@ "loose-envify": "cli.js" } }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.0.3" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -6508,6 +6857,13 @@ "node": ">= 6" } }, + "node_modules/monaco-editor": { + "version": "0.38.0", + "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.38.0.tgz", + "integrity": "sha512-11Fkh6yzEmwx7O0YoLxeae0qEGFwmyPRlVxpg7oF9czOOCB/iCjdJrG5I67da5WiXK3YJCxoz9TJFE8Tfq/v9A==", + "dev": true, + "license": "MIT" + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -6541,6 +6897,17 @@ "dev": true, "license": "MIT" }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dev": true, + "license": "MIT", + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, "node_modules/node-html-parser": { "version": "6.1.13", "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-6.1.13.tgz", @@ -7366,6 +7733,24 @@ "dev": true, "license": "MIT" }, + "node_modules/react-final-form": { + "version": "6.5.9", + "resolved": "https://registry.npmjs.org/react-final-form/-/react-final-form-6.5.9.tgz", + "integrity": "sha512-x3XYvozolECp3nIjly+4QqxdjSSWfcnpGEL5K8OBT6xmGrq5kBqbA6+/tOqoom9NwqIPPbxPNsOViFlbKgowbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.15.4" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/final-form" + }, + "peerDependencies": { + "final-form": "^4.20.4", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-gtm-module": { "version": "2.0.11", "resolved": "https://registry.npmjs.org/react-gtm-module/-/react-gtm-module-2.0.11.tgz", @@ -7418,6 +7803,38 @@ "dev": true, "license": "MIT" }, + "node_modules/react-monaco-editor": { + "version": "0.53.0", + "resolved": "https://registry.npmjs.org/react-monaco-editor/-/react-monaco-editor-0.53.0.tgz", + "integrity": "sha512-ZITzsauH4CsicCGddtpgjRACaKNTVEL2hnjYFx8QMuc8zmsgfgq7D2GcF8OQsa2URIdGm/Zl7YwY2fmWpvqs/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "prop-types": "^15.8.1" + }, + "peerDependencies": { + "@types/react": ">=16 <= 18", + "monaco-editor": "^0.38.0", + "react": ">=16 <= 18" + } + }, + "node_modules/react-player": { + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/react-player/-/react-player-2.16.0.tgz", + "integrity": "sha512-mAIPHfioD7yxO0GNYVFD1303QFtI3lyyQZLY229UEAp/a10cSW+hPcakg0Keq8uWJxT2OiT/4Gt+Lc9bD6bJmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "deepmerge": "^4.0.0", + "load-script": "^1.0.0", + "memoize-one": "^5.1.1", + "prop-types": "^15.7.2", + "react-fast-compare": "^3.0.1" + }, + "peerDependencies": { + "react": ">=16.6.0" + } + }, "node_modules/react-popper": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.3.0.tgz", @@ -7467,6 +7884,24 @@ "dev": true, "license": "MIT" }, + "node_modules/react-slick": { + "version": "0.29.0", + "resolved": "https://registry.npmjs.org/react-slick/-/react-slick-0.29.0.tgz", + "integrity": "sha512-TGdOKE+ZkJHHeC4aaoH85m8RnFyWqdqRfAGkhd6dirmATXMZWAxOpTLmw2Ll/jPTQ3eEG7ercFr/sbzdeYCJXA==", + "dev": true, + "license": "MIT", + "dependencies": { + "classnames": "^2.2.5", + "enquire.js": "^2.1.6", + "json2mq": "^0.2.0", + "lodash.debounce": "^4.0.8", + "resize-observer-polyfill": "^1.5.0" + }, + "peerDependencies": { + "react": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", @@ -7495,6 +7930,29 @@ "react-dom": "^15.3.0 || ^16.0.0-alpha || ^17.0.0 || ^18.0.0" } }, + "node_modules/react-waypoint": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/react-waypoint/-/react-waypoint-10.3.0.tgz", + "integrity": "sha512-iF1y2c1BsoXuEGz08NoahaLFIGI9gTUAAOKip96HUmylRT6DUtpgoBPjk/Y8dfcFVmfVDvUzWjNXpZyKTOV0SQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.12.5", + "consolidated-events": "^1.1.0 || ^2.0.0", + "prop-types": "^15.0.0", + "react-is": "^17.0.1 || ^18.0.0" + }, + "peerDependencies": { + "react": "^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/react-waypoint/node_modules/react-is": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", + "dev": true, + "license": "MIT" + }, "node_modules/react-window": { "version": "1.8.10", "resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.10.tgz", @@ -8054,6 +8512,45 @@ "node": ">=8.0.0" } }, + "node_modules/snake-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", + "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", + "dev": true, + "license": "MIT", + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/snakecase-keys": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/snakecase-keys/-/snakecase-keys-5.5.0.tgz", + "integrity": "sha512-r3kRtnoPu3FxGJ3fny6PKNnU3pteb29o6qAa0ugzhSseKNWRkw1dw8nIjXMyyKaU9vQxxVIE62Mb3bKbdrgpiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "map-obj": "^4.1.0", + "snake-case": "^3.0.4", + "type-fest": "^3.12.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/snakecase-keys/node_modules/type-fest": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.13.1.tgz", + "integrity": "sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -8129,6 +8626,13 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/ssr-window": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ssr-window/-/ssr-window-3.0.0.tgz", + "integrity": "sha512-q+8UfWDg9Itrg0yWK7oe5p/XRCJpJF9OBtXfOPgSJl+u3Xd5KI328RUEvUqSMVM9CiQUEf1QdBzJMkYGErj9QA==", + "dev": true, + "license": "MIT" + }, "node_modules/stop-iteration-iterator": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz", @@ -8152,6 +8656,13 @@ "node": ">=0.6.19" } }, + "node_modules/string-convert": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/string-convert/-/string-convert-0.2.1.tgz", + "integrity": "sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==", + "dev": true, + "license": "MIT" + }, "node_modules/string-width": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", @@ -8656,6 +9167,31 @@ "node": ">= 10" } }, + "node_modules/swiper": { + "version": "6.8.4", + "resolved": "https://registry.npmjs.org/swiper/-/swiper-6.8.4.tgz", + "integrity": "sha512-O+buF9Q+sMA0H7luMS8R59hCaJKlpo8PXhQ6ZYu6Rn2v9OsFd4d1jmrv14QvxtQpKAvL/ZiovEeANI/uDGet7g==", + "dev": true, + "funding": [ + { + "type": "patreon", + "url": "https://www.patreon.com/vladimirkharlampidi" + }, + { + "type": "open_collective", + "url": "http://opencollective.com/swiper" + } + ], + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "dom7": "^3.0.0", + "ssr-window": "^3.0.0" + }, + "engines": { + "node": ">= 4.7.0" + } + }, "node_modules/synckit": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.1.tgz", @@ -9029,7 +9565,6 @@ "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -9038,6 +9573,16 @@ "node": ">=14.17" } }, + "node_modules/typograf": { + "version": "6.15.1", + "resolved": "https://registry.npmjs.org/typograf/-/typograf-6.15.1.tgz", + "integrity": "sha512-G1IIJlh4ycW+rvTspdgZKQoj/fKpmwif6MUhrmn3LY50W8njRnBqdFIJcfDqbmDg+RmmP51R9jdjjMwBYA5P0Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", @@ -9161,6 +9706,30 @@ "dev": true, "license": "MIT" }, + "node_modules/utility-types": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.11.0.tgz", + "integrity": "sha512-6Z7Ma2aVEWisaL6TvBCy7P8rm2LQoPv6dJ7ecIaIixHcwfbJ0x7mWdbcwlIM5IGQxPZSFYeqRCqlOOeKoJYMkw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", diff --git a/package.json b/package.json index 233654f..ae652cc 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "build:clean": "rm -rf lib", "prepublishOnly": "npm run build", "test": "exit 0", + "typecheck": "tsc --noEmit", "lint": "lint update && lint", "lint:fix": "lint update && lint fix", "pre-commit": "lint update && lint-staged", @@ -25,21 +26,22 @@ "author": "", "license": "MIT", "devDependencies": { - "@diplodoc/client": "^2.8.0", - "@diplodoc/components": "^4.11.2", + "@diplodoc/client": "^3.0.0-beta-1", + "@diplodoc/components": "^4.13.0", "@diplodoc/lint": "^1.1.3", "@diplodoc/tsconfig": "^1.0.2", "@esbuild-plugins/tsconfig-paths": "^0.1.2", "@types/lunr": "^2.3.7", "esbuild": "^0.19.10", - "esbuild-node-externals": "^1.14.0" + "esbuild-node-externals": "^1.14.0", + "typescript": "^5.6.2" }, "dependencies": { "lunr": "^2.3.9", "node-html-parser": "^6.1.13" }, "peerDependencies": { - "@diplodoc/client": "^2.8.0", + "@diplodoc/client": "^3.0.0-beta-1", "@diplodoc/components": "^4.11.2" } } diff --git a/src/worker/score.ts b/src/worker/score.ts index 54a327d..faf6435 100644 --- a/src/worker/score.ts +++ b/src/worker/score.ts @@ -20,6 +20,7 @@ type ScoreState = { type ScoreResult = { score: number; position: Position; + phrase: string; }; export type Score = { @@ -96,7 +97,7 @@ export function phrased(result: Index.Result, terms: string[]) { function nextScore() { const {score, position} = state; - results.push({score, position}); + results.push({score, position, phrase}); state.score = 0; state.position = state.curr.position.slice() as Position; @@ -130,15 +131,22 @@ export function phrased(result: Index.Result, terms: string[]) { } function scoreToken() { - if (!state.prev) { - state.score += 2; + const {prev, curr} = state; + + state.score += 2; + + if (!prev) { return nextToken; } // This is partially buggy, if phrase has more that one similar token - if (distance(state.prev.position, state.curr.position) <= MERGE_TOLERANCE) { - state.score += phrase.includes(state.phrase) ? 10 : 2; - state.position[1] = state.curr.position[1]; + if (distance(prev.position, curr.position) <= MERGE_TOLERANCE) { + if (phrase.includes(state.phrase)) { + state.score += 10; + } + + state.position[1] = curr.position[1]; + return nextToken; } @@ -146,10 +154,15 @@ export function phrased(result: Index.Result, terms: string[]) { } function scoreWildcard() { - if (!state.prev) { - state.score += 0.5; - } else if (distance(state.prev.position, state.curr.position) <= MERGE_TOLERANCE) { - state.score += phrase.includes(state.phrase) ? 1 : 0.5; + const {prev, curr} = state; + + state.score += 0.5; + + if (prev && distance(prev.position, curr.position) <= MERGE_TOLERANCE) { + if (phrase.includes(state.phrase)) { + state.score += 0.5; + } + state.position[1] = state.curr.position[1]; } @@ -157,6 +170,7 @@ export function phrased(result: Index.Result, terms: string[]) { } function end() { + results = dedupe(results); return null; } } @@ -198,3 +212,32 @@ function normalize(result: Index.Result): Record { return fields; } + +function dedupe(tokens: ScoreResult[]) { + if (!tokens.length) { + return tokens; + } + + let prev = tokens[0]; + const result = [prev]; + for (let i = 1; i < tokens.length; i++) { + const next = tokens[i] as ScoreResult; + + if (isIntersection(prev.position, next.position)) { + result.pop(); + result.push((prev = withMaxScore(prev, next))); + } else { + result.push((prev = next)); + } + } + + return result; +} + +function isIntersection(a: Position, b: Position) { + return (a[1] >= b[0] && a[1] <= b[1]) || (a[1] >= b[0] && a[1] <= b[1]); +} + +function withMaxScore(a: ScoreResult, b: ScoreResult) { + return a.score >= b.score ? a : b; +} diff --git a/tsconfig.json b/tsconfig.json index 6dfb76b..3f28eab 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "@diplodoc/tsconfig", "compilerOptions": { + "target": "es2019", + "lib": ["es2019"], "moduleResolution": "bundler", "jsx": "react", "declaration": true,