feat(voice): enhance streaming engine and improve system reliability
Improve the PCM playback worklet with robust resampling and buffer management. Refactor the voice-stream service for better session teardown and error handling. Fix authentication issues by enabling credentials in HttpService and using relative URLs. Add Jalali date support and an AI model configuration tab in settings. Enhance diagnostics for voice transport and the audio engine.
This commit is contained in:
@@ -0,0 +1,90 @@
|
|||||||
|
---
|
||||||
|
name: ponytail
|
||||||
|
description: >
|
||||||
|
Forces the laziest solution that actually works, simplest, shortest, most
|
||||||
|
minimal. Channels a senior dev who has seen everything: question whether the
|
||||||
|
task needs to exist at all (YAGNI), reach for the standard library before
|
||||||
|
custom code, native platform features before dependencies, one line before
|
||||||
|
fifty. Use whenever the user says "ponytail", "be lazy", "lazy mode",
|
||||||
|
"simplest solution", "minimal solution", "yagni", "do less", or "shortest
|
||||||
|
path", and whenever they complain about over-engineering, bloat, boilerplate,
|
||||||
|
or unnecessary dependencies.
|
||||||
|
license: MIT
|
||||||
|
metadata:
|
||||||
|
category: development
|
||||||
|
source:
|
||||||
|
repository: 'https://github.com/DietrichGebert/ponytail'
|
||||||
|
path: skills/ponytail
|
||||||
|
commit: a945778b4a73b0b78c3c781a594b62cd3a324637
|
||||||
|
---
|
||||||
|
|
||||||
|
# Ponytail
|
||||||
|
|
||||||
|
You are a lazy senior developer. Lazy means efficient, not careless. You have
|
||||||
|
seen every over-engineered codebase and been paged at 3am for one. The best
|
||||||
|
code is the code never written.
|
||||||
|
|
||||||
|
## Persistence
|
||||||
|
|
||||||
|
ACTIVE EVERY RESPONSE. No drift back to over-building. Still active if
|
||||||
|
unsure. Off only: "stop ponytail" / "normal mode".
|
||||||
|
|
||||||
|
## The ladder
|
||||||
|
|
||||||
|
Stop at the first rung that holds:
|
||||||
|
|
||||||
|
1. **Does this need to exist at all?** Speculative need = skip it, say so in one line. (YAGNI)
|
||||||
|
2. **Stdlib does it?** Use it.
|
||||||
|
3. **Native platform feature covers it?** `<input type="date">` over a picker lib, CSS over JS, DB constraint over app code.
|
||||||
|
4. **Already-installed dependency solves it?** Use it. Never add a new one for what a few lines can do.
|
||||||
|
5. **Can it be one line?** One line.
|
||||||
|
6. **Only then:** the minimum code that works.
|
||||||
|
|
||||||
|
The ladder is a reflex, not a research project. Two rungs work → take the
|
||||||
|
higher one and move on. The first lazy solution that works is the right one.
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
- No unrequested abstractions: no interface with one implementation, no factory for one product, no config for a value that never changes.
|
||||||
|
- No boilerplate, no scaffolding "for later", later can scaffold for itself.
|
||||||
|
- Deletion over addition. Boring over clever, clever is what someone decodes at 3am.
|
||||||
|
- Fewest files possible. Shortest working diff wins.
|
||||||
|
- Complex request? Ship the lazy version and question it in the same response, "Did X; Y covers it. Need full X? Say so." Never stall on an answer you can default.
|
||||||
|
- Two stdlib options, same size? Take the one that's correct on edge cases. Lazy means writing less code, not picking the flimsier algorithm.
|
||||||
|
- Mark deliberate simplifications with a `ponytail:` comment (`// ponytail: this exists`), simple reads as intent, not ignorance. Shortcut with a known ceiling (global lock, O(n²) scan, naive heuristic)? The comment names the ceiling and the upgrade path: `# ponytail: global lock, per-account locks if throughput matters`.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
Code first. Then at most three short lines: what was skipped, when to add it.
|
||||||
|
No essays, no feature tours, no design notes. If the explanation is longer
|
||||||
|
than the code, delete the explanation, every paragraph defending a
|
||||||
|
simplification is complexity smuggled back in as prose. Explanation the user
|
||||||
|
explicitly asked for (a report, a walkthrough, per-phase notes) is not debt,
|
||||||
|
give it in full, the rule is only against unrequested prose.
|
||||||
|
|
||||||
|
Pattern: `[code] → skipped: [X], add when [Y].`
|
||||||
|
|
||||||
|
## When NOT to be lazy
|
||||||
|
|
||||||
|
Never simplify away: input validation at trust boundaries, error handling
|
||||||
|
that prevents data loss, security measures, accessibility basics, anything
|
||||||
|
explicitly requested. User insists on the full version → build it, no
|
||||||
|
re-arguing.
|
||||||
|
|
||||||
|
Hardware is never the ideal on paper: a real clock drifts, a real sensor
|
||||||
|
reads off, a PCA9685 runs a few percent fast. Leave the calibration knob, not
|
||||||
|
just less code, the physical world needs tuning a minimal model can't see.
|
||||||
|
|
||||||
|
Lazy code without its check is unfinished. Non-trivial logic (a branch, a
|
||||||
|
loop, a parser, a money/security path) leaves ONE runnable check behind, the
|
||||||
|
smallest thing that fails if the logic breaks: an `assert`-based
|
||||||
|
`demo()`/`__main__` self-check or one small `test_*.py`. No frameworks, no
|
||||||
|
fixtures, no per-function suites unless asked. Trivial one-liners need no
|
||||||
|
test, YAGNI applies to tests too.
|
||||||
|
|
||||||
|
## Boundaries
|
||||||
|
|
||||||
|
Ponytail governs what you build, not how you talk (pair with Caveman for
|
||||||
|
terse prose). "stop ponytail" / "normal mode": revert.
|
||||||
|
|
||||||
|
The shortest path to done is the right path.
|
||||||
Generated
+129
-62
@@ -21,6 +21,7 @@
|
|||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"ag-grid-angular": "^36.2.0",
|
"ag-grid-angular": "^36.2.0",
|
||||||
"ag-grid-community": "^36.2.0",
|
"ag-grid-community": "^36.2.0",
|
||||||
|
"moment-jalaali": "^0.10.5",
|
||||||
"ngx-toastr": "^14.3.0",
|
"ngx-toastr": "^14.3.0",
|
||||||
"papaparse": "^5.7.0",
|
"papaparse": "^5.7.0",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
@@ -34,6 +35,8 @@
|
|||||||
"@playwright/test": "^1.63.0",
|
"@playwright/test": "^1.63.0",
|
||||||
"@tailwindcss/postcss": "^4.3.3",
|
"@tailwindcss/postcss": "^4.3.3",
|
||||||
"@types/audioworklet": "^0.0.100",
|
"@types/audioworklet": "^0.0.100",
|
||||||
|
"@types/moment": "^2.11.29",
|
||||||
|
"@types/moment-jalaali": "^0.7.9",
|
||||||
"@types/papaparse": "^5.5.2",
|
"@types/papaparse": "^5.5.2",
|
||||||
"@types/three": "^0.186.0",
|
"@types/three": "^0.186.0",
|
||||||
"jsdom": "^30.1.2",
|
"jsdom": "^30.1.2",
|
||||||
@@ -541,7 +544,6 @@
|
|||||||
"version": "20.3.33",
|
"version": "20.3.33",
|
||||||
"resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-20.3.33.tgz",
|
"resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-20.3.33.tgz",
|
||||||
"integrity": "sha512-NKE4N4ssXysHLJQ7xVqvAv/yf3JfJxaFz5H+Ue+EnYToAmTxXe7uyt2MPRIydef/H63n7O9uphVp5P5GkRxVuA==",
|
"integrity": "sha512-NKE4N4ssXysHLJQ7xVqvAv/yf3JfJxaFz5H+Ue+EnYToAmTxXe7uyt2MPRIydef/H63n7O9uphVp5P5GkRxVuA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "7.29.7",
|
"@babel/core": "7.29.7",
|
||||||
@@ -613,6 +615,31 @@
|
|||||||
"rxjs": "^6.5.3 || ^7.4.0"
|
"rxjs": "^6.5.3 || ^7.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@angular/localize": {
|
||||||
|
"version": "20.3.33",
|
||||||
|
"resolved": "https://registry.npmjs.org/@angular/localize/-/localize-20.3.33.tgz",
|
||||||
|
"integrity": "sha512-2Rr23xegscTKOwSNJE4O/vqpK+owLPH6Z7MojctI/cIcu5RSE7RVw/r9Hs5XS4fhr81yHRWp/jRFQzzm3i6F4g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/core": "7.29.7",
|
||||||
|
"@types/babel__core": "7.20.5",
|
||||||
|
"tinyglobby": "^0.2.12",
|
||||||
|
"yargs": "^18.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"localize-extract": "tools/bundles/src/extract/cli.js",
|
||||||
|
"localize-migrate": "tools/bundles/src/migrate/cli.js",
|
||||||
|
"localize-translate": "tools/bundles/src/translate/cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@angular/compiler": "20.3.33",
|
||||||
|
"@angular/compiler-cli": "20.3.33"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@angular/platform-browser": {
|
"node_modules/@angular/platform-browser": {
|
||||||
"version": "20.3.33",
|
"version": "20.3.33",
|
||||||
"resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-20.3.33.tgz",
|
"resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-20.3.33.tgz",
|
||||||
@@ -710,7 +737,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",
|
||||||
"integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==",
|
"integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/helper-validator-identifier": "^7.29.7",
|
"@babel/helper-validator-identifier": "^7.29.7",
|
||||||
@@ -725,7 +751,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz",
|
||||||
"integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==",
|
"integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
@@ -735,7 +760,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz",
|
||||||
"integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==",
|
"integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.29.7",
|
"@babel/code-frame": "^7.29.7",
|
||||||
@@ -766,14 +790,12 @@
|
|||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
|
||||||
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
|
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@babel/core/node_modules/semver": {
|
"node_modules/@babel/core/node_modules/semver": {
|
||||||
"version": "6.3.1",
|
"version": "6.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||||
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bin": {
|
"bin": {
|
||||||
"semver": "bin/semver.js"
|
"semver": "bin/semver.js"
|
||||||
@@ -783,7 +805,6 @@
|
|||||||
"version": "7.29.8",
|
"version": "7.29.8",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz",
|
||||||
"integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==",
|
"integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/parser": "^7.29.8",
|
"@babel/parser": "^7.29.8",
|
||||||
@@ -813,7 +834,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz",
|
||||||
"integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==",
|
"integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/compat-data": "^7.29.7",
|
"@babel/compat-data": "^7.29.7",
|
||||||
@@ -830,7 +850,6 @@
|
|||||||
"version": "6.3.1",
|
"version": "6.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||||
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bin": {
|
"bin": {
|
||||||
"semver": "bin/semver.js"
|
"semver": "bin/semver.js"
|
||||||
@@ -840,7 +859,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz",
|
||||||
"integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==",
|
"integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
@@ -850,7 +868,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz",
|
||||||
"integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==",
|
"integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/traverse": "^7.29.7",
|
"@babel/traverse": "^7.29.7",
|
||||||
@@ -864,7 +881,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz",
|
||||||
"integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==",
|
"integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/helper-module-imports": "^7.29.7",
|
"@babel/helper-module-imports": "^7.29.7",
|
||||||
@@ -895,7 +911,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
|
||||||
"integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
|
"integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
@@ -905,7 +920,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
|
||||||
"integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
|
"integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
@@ -915,7 +929,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz",
|
||||||
"integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==",
|
"integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
@@ -925,7 +938,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz",
|
||||||
"integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==",
|
"integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/template": "^7.29.7",
|
"@babel/template": "^7.29.7",
|
||||||
@@ -939,7 +951,6 @@
|
|||||||
"version": "7.29.9",
|
"version": "7.29.9",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
|
||||||
"integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
|
"integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/types": "^7.29.8"
|
"@babel/types": "^7.29.8"
|
||||||
@@ -955,7 +966,6 @@
|
|||||||
"version": "7.29.7",
|
"version": "7.29.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz",
|
||||||
"integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==",
|
"integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.29.7",
|
"@babel/code-frame": "^7.29.7",
|
||||||
@@ -970,7 +980,6 @@
|
|||||||
"version": "7.29.8",
|
"version": "7.29.8",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.8.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.8.tgz",
|
||||||
"integrity": "sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg==",
|
"integrity": "sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.29.7",
|
"@babel/code-frame": "^7.29.7",
|
||||||
@@ -989,7 +998,6 @@
|
|||||||
"version": "7.29.8",
|
"version": "7.29.8",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",
|
||||||
"integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==",
|
"integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/helper-string-parser": "^7.29.7",
|
"@babel/helper-string-parser": "^7.29.7",
|
||||||
@@ -2019,7 +2027,6 @@
|
|||||||
"version": "0.3.13",
|
"version": "0.3.13",
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||||
"integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
|
"integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jridgewell/sourcemap-codec": "^1.5.0",
|
"@jridgewell/sourcemap-codec": "^1.5.0",
|
||||||
@@ -2030,7 +2037,6 @@
|
|||||||
"version": "2.3.5",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",
|
||||||
"integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",
|
"integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jridgewell/gen-mapping": "^0.3.5",
|
"@jridgewell/gen-mapping": "^0.3.5",
|
||||||
@@ -2041,7 +2047,6 @@
|
|||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
|
||||||
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
|
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
@@ -2051,14 +2056,12 @@
|
|||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",
|
||||||
"integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",
|
"integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@jridgewell/trace-mapping": {
|
"node_modules/@jridgewell/trace-mapping": {
|
||||||
"version": "0.3.31",
|
"version": "0.3.31",
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
|
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
|
||||||
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
|
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jridgewell/resolve-uri": "^3.1.0",
|
"@jridgewell/resolve-uri": "^3.1.0",
|
||||||
@@ -4100,6 +4103,51 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/babel__core": {
|
||||||
|
"version": "7.20.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
|
||||||
|
"integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/parser": "^7.20.7",
|
||||||
|
"@babel/types": "^7.20.7",
|
||||||
|
"@types/babel__generator": "*",
|
||||||
|
"@types/babel__template": "*",
|
||||||
|
"@types/babel__traverse": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/babel__generator": {
|
||||||
|
"version": "7.27.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.27.0.tgz",
|
||||||
|
"integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/types": "^7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/babel__template": {
|
||||||
|
"version": "7.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz",
|
||||||
|
"integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/parser": "^7.1.0",
|
||||||
|
"@babel/types": "^7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/babel__traverse": {
|
||||||
|
"version": "7.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.28.0.tgz",
|
||||||
|
"integrity": "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/types": "^7.28.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/chai": {
|
"node_modules/@types/chai": {
|
||||||
"version": "5.2.3",
|
"version": "5.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz",
|
||||||
@@ -4125,6 +4173,23 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/moment": {
|
||||||
|
"version": "2.11.29",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/moment/-/moment-2.11.29.tgz",
|
||||||
|
"integrity": "sha512-D5WIgbLYQzvgfsDnBhZFSTnt/BjGPOE+Jsh3k1BYYijJAkrn7ceeLvU4jtjKKXXuXN42O3ARlU4D/P9ezbQYFA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@types/moment-jalaali": {
|
||||||
|
"version": "0.7.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/moment-jalaali/-/moment-jalaali-0.7.9.tgz",
|
||||||
|
"integrity": "sha512-gsDOoAzRnCfQTbfdlUrCvX6R0wIto6CvwfvV2C3j4qJLK+DEiTK8Rl/xlOCBO9C6qeUfX8oyZ2UfjnXJTOvHSA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"moment": ">=2.14.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "26.6.4",
|
"version": "26.6.4",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.4.tgz",
|
||||||
@@ -4460,7 +4525,6 @@
|
|||||||
"version": "6.4.0",
|
"version": "6.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz",
|
||||||
"integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==",
|
"integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
@@ -4473,7 +4537,6 @@
|
|||||||
"version": "6.2.3",
|
"version": "6.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz",
|
||||||
"integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==",
|
"integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
@@ -4496,7 +4559,6 @@
|
|||||||
"version": "2.11.27",
|
"version": "2.11.27",
|
||||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.27.tgz",
|
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.27.tgz",
|
||||||
"integrity": "sha512-ElY12DaROGuan+lMmZ8Cvo/ZUbXPe7Enc/9VU/b1T3Kp4dwytRcNdR8DoSJN5SNJT/CuvcCA0DHDVmMOCePdRQ==",
|
"integrity": "sha512-ElY12DaROGuan+lMmZ8Cvo/ZUbXPe7Enc/9VU/b1T3Kp4dwytRcNdR8DoSJN5SNJT/CuvcCA0DHDVmMOCePdRQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"baseline-browser-mapping": "dist/cli.cjs"
|
"baseline-browser-mapping": "dist/cli.cjs"
|
||||||
@@ -4585,7 +4647,6 @@
|
|||||||
"version": "4.29.3",
|
"version": "4.29.3",
|
||||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.3.tgz",
|
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.3.tgz",
|
||||||
"integrity": "sha512-1R4kiYKXGViqEN0CnoDrXc1StD9niAwu+j2dukWzrD4bJgsD4lDmEp0CRbc6E/vYJIfTHwPmwyaKtVSudICdPA==",
|
"integrity": "sha512-1R4kiYKXGViqEN0CnoDrXc1StD9niAwu+j2dukWzrD4bJgsD4lDmEp0CRbc6E/vYJIfTHwPmwyaKtVSudICdPA==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
@@ -4766,7 +4827,6 @@
|
|||||||
"version": "1.0.30001814",
|
"version": "1.0.30001814",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001814.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001814.tgz",
|
||||||
"integrity": "sha512-/Uaf1lAzr59XcMpW0o96WoEfr+VXK2OX4U9AgFoiSHsVJ4HppnIFUjtYzsyDH2+tgANaQb2/oxYGwCPapN1FpA==",
|
"integrity": "sha512-/Uaf1lAzr59XcMpW0o96WoEfr+VXK2OX4U9AgFoiSHsVJ4HppnIFUjtYzsyDH2+tgANaQb2/oxYGwCPapN1FpA==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
@@ -4834,7 +4894,6 @@
|
|||||||
"version": "4.0.3",
|
"version": "4.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
|
||||||
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
|
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"readdirp": "^4.0.1"
|
"readdirp": "^4.0.1"
|
||||||
@@ -4916,7 +4975,6 @@
|
|||||||
"version": "9.0.1",
|
"version": "9.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz",
|
||||||
"integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
|
"integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"string-width": "^7.2.0",
|
"string-width": "^7.2.0",
|
||||||
@@ -4931,7 +4989,6 @@
|
|||||||
"version": "9.0.2",
|
"version": "9.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz",
|
||||||
"integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==",
|
"integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ansi-styles": "^6.2.1",
|
"ansi-styles": "^6.2.1",
|
||||||
@@ -5000,7 +5057,6 @@
|
|||||||
"version": "1.9.0",
|
"version": "1.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz",
|
||||||
"integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==",
|
"integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/cookie": {
|
"node_modules/cookie": {
|
||||||
@@ -5118,7 +5174,6 @@
|
|||||||
"version": "4.4.3",
|
"version": "4.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||||
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ms": "^2.1.3"
|
"ms": "^2.1.3"
|
||||||
@@ -5254,14 +5309,12 @@
|
|||||||
"version": "1.5.444",
|
"version": "1.5.444",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.444.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.444.tgz",
|
||||||
"integrity": "sha512-5ss/uJfoDYDHT0lfJzT6FbcskIzROIOPf0BbbFkGcvDzoJU7i//9GDrwwIHQVmIsrAGiF3ihpADBRIsrEFt1rQ==",
|
"integrity": "sha512-5ss/uJfoDYDHT0lfJzT6FbcskIzROIOPf0BbbFkGcvDzoJU7i//9GDrwwIHQVmIsrAGiF3ihpADBRIsrEFt1rQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/emoji-regex": {
|
"node_modules/emoji-regex": {
|
||||||
"version": "10.6.0",
|
"version": "10.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
||||||
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
|
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/encodeurl": {
|
"node_modules/encodeurl": {
|
||||||
@@ -5410,7 +5463,6 @@
|
|||||||
"version": "3.2.0",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
||||||
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
@@ -5575,7 +5627,6 @@
|
|||||||
"version": "6.5.0",
|
"version": "6.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
||||||
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
|
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.0.0"
|
"node": ">=12.0.0"
|
||||||
@@ -5680,7 +5731,6 @@
|
|||||||
"version": "1.0.0-beta.2",
|
"version": "1.0.0-beta.2",
|
||||||
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
|
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
|
||||||
"integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==",
|
"integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
@@ -5690,7 +5740,6 @@
|
|||||||
"version": "2.0.5",
|
"version": "2.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||||
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "6.* || 8.* || >= 10.*"
|
"node": "6.* || 8.* || >= 10.*"
|
||||||
@@ -5700,7 +5749,6 @@
|
|||||||
"version": "1.7.0",
|
"version": "1.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz",
|
||||||
"integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==",
|
"integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
@@ -6177,6 +6225,12 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/jalaali-js": {
|
||||||
|
"version": "1.2.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/jalaali-js/-/jalaali-js-1.2.8.tgz",
|
||||||
|
"integrity": "sha512-Jl/EwY84JwjW2wsWqeU4pNd22VNQ7EkjI36bDuLw31wH98WQW4fPjD0+mG7cdCK+Y8D6s9R3zLiQ3LaKu6bD8A==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/jiti": {
|
"node_modules/jiti": {
|
||||||
"version": "2.7.0",
|
"version": "2.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz",
|
||||||
@@ -6201,7 +6255,6 @@
|
|||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||||
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
|
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/jsdom": {
|
"node_modules/jsdom": {
|
||||||
@@ -6268,7 +6321,6 @@
|
|||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",
|
||||||
"integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==",
|
"integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"jsesc": "bin/jsesc"
|
"jsesc": "bin/jsesc"
|
||||||
@@ -6305,7 +6357,6 @@
|
|||||||
"version": "2.2.3",
|
"version": "2.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
||||||
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
|
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"json5": "lib/cli.js"
|
"json5": "lib/cli.js"
|
||||||
@@ -6775,7 +6826,6 @@
|
|||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
|
||||||
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
|
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"yallist": "^3.0.2"
|
"yallist": "^3.0.2"
|
||||||
@@ -7049,6 +7099,38 @@
|
|||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/moment": {
|
||||||
|
"version": "2.31.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/moment/-/moment-2.31.0.tgz",
|
||||||
|
"integrity": "sha512-0acOTfMiWOheYS4eoWb80yYMb/JLvVv9SHbs2PehaDzfUG0Bw855SKyk0IKTnPGa5+U2bmi3W68l1+sGLX/pvw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/moment-jalaali": {
|
||||||
|
"version": "0.10.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/moment-jalaali/-/moment-jalaali-0.10.5.tgz",
|
||||||
|
"integrity": "sha512-Xp0FsC0+jWG89/xcOrL880f97Tq7197P3saoMAqSIaF8vKr4Atr9XKtIOREGHTLUjOzJksfTHhQgxMgUJQupuw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"jalaali-js": "^1.2.8",
|
||||||
|
"moment": "^2.30.1",
|
||||||
|
"moment-timezone": "^0.6.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/moment-timezone": {
|
||||||
|
"version": "0.6.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.6.5.tgz",
|
||||||
|
"integrity": "sha512-KKzZAxGv2Qx4cnk6eSlvf4C+DLFW52vmMY5MN7UARY7GONbozkutylQG3DrrtmLCTXdQ5XZrqao9cI16bLFzXA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"moment": "^2.29.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mrmime": {
|
"node_modules/mrmime": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz",
|
||||||
@@ -7063,7 +7145,6 @@
|
|||||||
"version": "2.1.3",
|
"version": "2.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/msgpackr": {
|
"node_modules/msgpackr": {
|
||||||
@@ -7263,7 +7344,6 @@
|
|||||||
"version": "2.0.57",
|
"version": "2.0.57",
|
||||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.57.tgz",
|
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.57.tgz",
|
||||||
"integrity": "sha512-kQK9LGGFiHtrWiNhZtA7Qbw17AQz+dmsEKODRIVTXA9+e5MS/2gZEBhYJt13GrAz5/IOZKddH/0Z3TP/Zgo+yw==",
|
"integrity": "sha512-kQK9LGGFiHtrWiNhZtA7Qbw17AQz+dmsEKODRIVTXA9+e5MS/2gZEBhYJt13GrAz5/IOZKddH/0Z3TP/Zgo+yw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
@@ -7726,14 +7806,12 @@
|
|||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/picomatch": {
|
"node_modules/picomatch": {
|
||||||
"version": "4.0.4",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz",
|
||||||
"integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
|
"integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
@@ -8004,7 +8082,6 @@
|
|||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
||||||
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
|
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 14.18.0"
|
"node": ">= 14.18.0"
|
||||||
@@ -8018,7 +8095,6 @@
|
|||||||
"version": "0.2.2",
|
"version": "0.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz",
|
||||||
"integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==",
|
"integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==",
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
"node_modules/require-from-string": {
|
"node_modules/require-from-string": {
|
||||||
@@ -8192,7 +8268,6 @@
|
|||||||
"version": "7.7.2",
|
"version": "7.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
|
||||||
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
|
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bin": {
|
"bin": {
|
||||||
"semver": "bin/semver.js"
|
"semver": "bin/semver.js"
|
||||||
@@ -8570,7 +8645,6 @@
|
|||||||
"version": "7.2.0",
|
"version": "7.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
||||||
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"emoji-regex": "^10.3.0",
|
"emoji-regex": "^10.3.0",
|
||||||
@@ -8588,7 +8662,6 @@
|
|||||||
"version": "7.2.0",
|
"version": "7.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
|
||||||
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
|
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ansi-regex": "^6.2.2"
|
"ansi-regex": "^6.2.2"
|
||||||
@@ -8705,7 +8778,6 @@
|
|||||||
"version": "0.2.14",
|
"version": "0.2.14",
|
||||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz",
|
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz",
|
||||||
"integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==",
|
"integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fdir": "^6.4.4",
|
"fdir": "^6.4.4",
|
||||||
@@ -8872,7 +8944,7 @@
|
|||||||
"version": "5.9.3",
|
"version": "5.9.3",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||||
"dev": true,
|
"devOptional": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
@@ -8913,7 +8985,6 @@
|
|||||||
"version": "1.3.3",
|
"version": "1.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz",
|
||||||
"integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==",
|
"integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
@@ -9365,7 +9436,6 @@
|
|||||||
"version": "5.0.8",
|
"version": "5.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||||
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
@@ -9375,14 +9445,12 @@
|
|||||||
"version": "3.1.1",
|
"version": "3.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
|
||||||
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
|
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/yargs": {
|
"node_modules/yargs": {
|
||||||
"version": "18.0.0",
|
"version": "18.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-18.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yargs/-/yargs-18.0.0.tgz",
|
||||||
"integrity": "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==",
|
"integrity": "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cliui": "^9.0.1",
|
"cliui": "^9.0.1",
|
||||||
@@ -9400,7 +9468,6 @@
|
|||||||
"version": "22.0.0",
|
"version": "22.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz",
|
||||||
"integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==",
|
"integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20.19.0 || ^22.12.0 || >=23"
|
"node": "^20.19.0 || ^22.12.0 || >=23"
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"ag-grid-angular": "^36.2.0",
|
"ag-grid-angular": "^36.2.0",
|
||||||
"ag-grid-community": "^36.2.0",
|
"ag-grid-community": "^36.2.0",
|
||||||
|
"moment-jalaali": "^0.10.5",
|
||||||
"ngx-toastr": "^14.3.0",
|
"ngx-toastr": "^14.3.0",
|
||||||
"papaparse": "^5.7.0",
|
"papaparse": "^5.7.0",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
@@ -48,6 +49,8 @@
|
|||||||
"@playwright/test": "^1.63.0",
|
"@playwright/test": "^1.63.0",
|
||||||
"@tailwindcss/postcss": "^4.3.3",
|
"@tailwindcss/postcss": "^4.3.3",
|
||||||
"@types/audioworklet": "^0.0.100",
|
"@types/audioworklet": "^0.0.100",
|
||||||
|
"@types/moment": "^2.11.29",
|
||||||
|
"@types/moment-jalaali": "^0.7.9",
|
||||||
"@types/papaparse": "^5.5.2",
|
"@types/papaparse": "^5.5.2",
|
||||||
"@types/three": "^0.186.0",
|
"@types/three": "^0.186.0",
|
||||||
"jsdom": "^30.1.2",
|
"jsdom": "^30.1.2",
|
||||||
|
|||||||
+9
-2
@@ -1,7 +1,14 @@
|
|||||||
{
|
{
|
||||||
"/api": {
|
"/api": {
|
||||||
"target": "http://127.0.0.1:8080",
|
"target": "http://10.2.8.3:8080",
|
||||||
|
"secure": false,
|
||||||
|
"changeOrigin": true,
|
||||||
"ws": true,
|
"ws": true,
|
||||||
"changeOrigin": false
|
"logLevel": "debug"
|
||||||
|
},
|
||||||
|
"/users": {
|
||||||
|
"target": "http://10.2.8.3:8080",
|
||||||
|
"secure": false,
|
||||||
|
"changeOrigin": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,57 @@
|
|||||||
/**
|
/**
|
||||||
* Streaming PCM16 playback (contract: 24 kHz mono PCM16LE output, no WAV header).
|
* Streaming PCM16 playback (contract: 24 kHz mono PCM16LE output, no WAV header).
|
||||||
*
|
*
|
||||||
* Bounded playout queue: at most BOUND_SAMPLES (96,000 bytes) of source audio is admitted.
|
* Bounded playout queue. The cap is on OUTSTANDING SOURCE PCM — BOUND_BYTES (96,000 bytes
|
||||||
* When it fills, the processor reports `overflow` and the call must fail safely — PCM is
|
* = 48,000 source samples ≈ 2 s at 24 kHz mono PCM16) — and each stage uses ONE unit
|
||||||
* never silently dropped to keep the same context alive.
|
* consistently:
|
||||||
|
* admission + progress are booked in SOURCE samples (the contract/wire unit);
|
||||||
|
* the ring stores the RESAMPLED OUTPUT samples the AudioContext actually consumes.
|
||||||
|
* The output ring is sized to hold the source bound at the worst-case ratio
|
||||||
|
* (source bound ÷ ratio), so the SAME 2 s source cap holds at any real context rate
|
||||||
|
* (24k / 44.1k / 48k …) without widening the source limit, suppressing overflow or
|
||||||
|
* silently dropping PCM. If the queue fills anyway the processor posts `overflow` and the
|
||||||
|
* call fails safely.
|
||||||
*
|
*
|
||||||
* Real playback progress: `played_ms` is computed from the source samples actually
|
* Real playback progress: played_ms for a server audio_ref is the cumulative SOURCE
|
||||||
* consumed by `process()` per audio_ref (never an elapsed timer), kept cumulative per ref
|
* samples of THAT ref actually consumed by process(), never a timer. Queued audio keeps
|
||||||
* and reported roughly 4×/s, on ref changes, and on clear/flush/idle — so the main thread
|
* its own audio_ref when a different ref arrives (a FIFO of per-ref source spans), so
|
||||||
* can send the contract's `playback_progress` control message.
|
* progress is never credited to the wrong turn. Reported ~4×/s, on ref completion, and on
|
||||||
|
* clear/flush/idle, so the main thread can send the contract's playback_progress message.
|
||||||
*
|
*
|
||||||
* Messages in: { type: 'push', pcm: ArrayBuffer (Int16 mono), sampleRate, audioRef }
|
* Messages in: { type: 'push', pcm: ArrayBuffer (Int16 mono), sampleRate, audioRef }
|
||||||
* { type: 'clear' } barge-in: drop everything immediately
|
* { type: 'clear' } barge-in: drop everything immediately
|
||||||
* { type: 'flush' } end of turn: play what is left, then report 'idle'
|
* { type: 'flush' } end of turn: play what is left, then report 'idle'
|
||||||
* Messages out: { type: 'progress', audioRef, playedMs }
|
* Messages out: { type: 'progress', audioRef, playedMs }
|
||||||
* { type: 'idle' } buffer ran dry after playing
|
* { type: 'idle' } buffer ran dry after playing
|
||||||
* { type: 'overflow' } bounded queue filled — caller fails the session safely
|
* { type: 'overflow' } bounded queue filled — caller fails the session safely
|
||||||
*/
|
*/
|
||||||
const BOUND_BYTES = 96000; // contract cap for the playback queue
|
const BOUND_BYTES = 96000; // contract cap on outstanding SOURCE PCM16
|
||||||
|
const RESAMPLE_MARGIN = 64; // slack for fractional-boundary rounding (never widens the source bound)
|
||||||
const REPORT_INTERVAL_MS = 250;
|
const REPORT_INTERVAL_MS = 250;
|
||||||
|
|
||||||
class PcmPlaybackProcessor extends AudioWorkletProcessor {
|
class PcmPlaybackProcessor extends AudioWorkletProcessor {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.capacity = Math.floor(BOUND_BYTES / 2); // source samples (PCM16)
|
this.sourceCapacity = Math.floor(BOUND_BYTES / 2); // 48,000 SOURCE samples (the admission bound)
|
||||||
|
this.ratio = 1; // SOURCE samples per OUTPUT sample (resolved on first push)
|
||||||
|
this.sized = false; // true once the output ring matches the real context rate
|
||||||
|
this.capacity = this.sourceCapacity; // OUTPUT slots currently allocated (grows for upsampling)
|
||||||
this.buf = new Float32Array(this.capacity);
|
this.buf = new Float32Array(this.capacity);
|
||||||
this.r = 0;
|
this.r = 0;
|
||||||
this.w = 0;
|
this.w = 0;
|
||||||
this.count = 0;
|
this.count = 0; // OUTPUT samples currently queued
|
||||||
|
this.queuedSource = 0; // SOURCE samples currently queued (the admission bound unit)
|
||||||
this.prebuffer = Math.floor(sampleRate * 0.08); // jitter buffer before (re)starting
|
this.prebuffer = Math.floor(sampleRate * 0.08); // jitter buffer before (re)starting
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.prev = 0;
|
this.prev = 0;
|
||||||
this.pos = 1;
|
this.pos = 1;
|
||||||
this.ratio = 1; // source samples per output sample, set per push
|
// Per-audio_ref attribution. `refQueue` keeps the still-queued SOURCE span of each ref
|
||||||
this.currentRef = null;
|
// (merged per ref so it stays ≤ the number of turns); `refPlayedSamples` keeps each
|
||||||
this.refPlayedSamples = new Map(); // cumulative consumed source samples per audio_ref
|
// ref's cumulative consumed source. Together they tie queued audio to its own ref and
|
||||||
|
// keep progress cumulative and correct across ref changes.
|
||||||
|
this.refQueue = []; // [{ ref, src }] src = remaining SOURCE samples of that ref
|
||||||
|
this.refPlayedSamples = new Map();
|
||||||
|
this.playingRef = null; // ref currently being consumed / reported
|
||||||
this.unreportedSamples = 0;
|
this.unreportedSamples = 0;
|
||||||
this.overflowPosted = false;
|
this.overflowPosted = false;
|
||||||
this.port.onmessage = (e) => {
|
this.port.onmessage = (e) => {
|
||||||
@@ -46,18 +63,36 @@ class PcmPlaybackProcessor extends AudioWorkletProcessor {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Resolve the source→output ratio and size the output ring to hold the source bound. */
|
||||||
|
configure(ratio) {
|
||||||
|
if (this.sized && ratio === this.ratio) return;
|
||||||
|
this.ratio = ratio > 0 ? ratio : 1;
|
||||||
|
const need = Math.ceil(this.sourceCapacity / this.ratio) + RESAMPLE_MARGIN;
|
||||||
|
// Only grow while the ring is empty (first push): never drop queued audio.
|
||||||
|
if (need > this.capacity && this.count === 0) {
|
||||||
|
this.capacity = need;
|
||||||
|
this.buf = new Float32Array(this.capacity);
|
||||||
|
this.r = 0;
|
||||||
|
this.w = 0;
|
||||||
|
}
|
||||||
|
this.sized = true;
|
||||||
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
this.reportFinal(); // final cumulative report for the interrupted ref
|
||||||
this.r = this.w = this.count = 0;
|
this.r = this.w = this.count = 0;
|
||||||
|
this.queuedSource = 0;
|
||||||
|
this.refQueue.length = 0;
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.prev = 0;
|
this.prev = 0;
|
||||||
this.pos = 1;
|
this.pos = 1;
|
||||||
this.reportProgress(true); // final report for the interrupted ref
|
this.playingRef = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
flush() {
|
flush() {
|
||||||
if (this.count === 0) {
|
if (this.count === 0) {
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.reportProgress(true);
|
this.reportFinal();
|
||||||
this.port.postMessage({ type: 'idle' });
|
this.port.postMessage({ type: 'idle' });
|
||||||
} else {
|
} else {
|
||||||
this.started = true; // short tail: do not wait for the prebuffer
|
this.started = true; // short tail: do not wait for the prebuffer
|
||||||
@@ -68,16 +103,26 @@ class PcmPlaybackProcessor extends AudioWorkletProcessor {
|
|||||||
const n = int16.length;
|
const n = int16.length;
|
||||||
if (!n) return;
|
if (!n) return;
|
||||||
|
|
||||||
// Bounded queue: admitting this chunk past the cap is a safe failure, not a silent drop.
|
const ratio = srcRate / sampleRate; // SOURCE samples per OUTPUT sample
|
||||||
if (this.count + n > this.capacity) {
|
this.configure(ratio);
|
||||||
if (!this.overflowPosted) {
|
|
||||||
this.overflowPosted = true;
|
// OUTPUT samples this chunk will add — the exact count the resample loop performs.
|
||||||
this.port.postMessage({ type: 'overflow' });
|
const produced = this.pos < n ? Math.ceil((n - this.pos) / this.ratio) : 0;
|
||||||
}
|
|
||||||
return;
|
// Bounded queue — two consistent guards, each in its own unit:
|
||||||
}
|
// 1) SOURCE bound: the contract 96,000-byte cap, invariant across context rates.
|
||||||
|
if (this.queuedSource + n > this.sourceCapacity) return this.overflow();
|
||||||
|
// 2) OUTPUT storage: never let the ring overrun because a chunk resampled larger.
|
||||||
|
if (this.count + produced > this.capacity) return this.overflow();
|
||||||
|
|
||||||
|
this.queuedSource += n;
|
||||||
|
|
||||||
|
// Keep the audio_ref of the queued source span so consumption is credited correctly
|
||||||
|
// even when the next ref arrives while this one is still playing.
|
||||||
|
const last = this.refQueue[this.refQueue.length - 1];
|
||||||
|
if (last && last.ref === audioRef) last.src += n;
|
||||||
|
else this.refQueue.push({ ref: audioRef, src: n });
|
||||||
|
|
||||||
this.ratio = srcRate / sampleRate; // source samples per output sample
|
|
||||||
const src = new Float32Array(n + 1);
|
const src = new Float32Array(n + 1);
|
||||||
src[0] = this.prev;
|
src[0] = this.prev;
|
||||||
for (let i = 0; i < n; i++) src[i + 1] = int16[i] / 32768;
|
for (let i = 0; i < n; i++) src[i + 1] = int16[i] / 32768;
|
||||||
@@ -91,15 +136,19 @@ class PcmPlaybackProcessor extends AudioWorkletProcessor {
|
|||||||
}
|
}
|
||||||
this.prev = src[n];
|
this.prev = src[n];
|
||||||
this.pos = pos - n;
|
this.pos = pos - n;
|
||||||
|
}
|
||||||
|
|
||||||
if (audioRef !== this.currentRef) {
|
overflow() {
|
||||||
this.reportProgress(true); // final report for the ref that just ended
|
if (!this.overflowPosted) {
|
||||||
this.currentRef = audioRef;
|
this.overflowPosted = true;
|
||||||
this.reportProgress(true);
|
this.port.postMessage({ type: 'overflow' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write(v) {
|
write(v) {
|
||||||
|
// Defense in depth: admission already reserves the room, so this never discards in
|
||||||
|
// normal flow — but it guarantees the ring is never overwritten nor exceeds capacity.
|
||||||
|
if (this.count >= this.capacity) return;
|
||||||
this.buf[this.w] = v;
|
this.buf[this.w] = v;
|
||||||
this.w = (this.w + 1) % this.capacity;
|
this.w = (this.w + 1) % this.capacity;
|
||||||
this.count++;
|
this.count++;
|
||||||
@@ -123,20 +172,15 @@ class PcmPlaybackProcessor extends AudioWorkletProcessor {
|
|||||||
ch0[i] = 0;
|
ch0[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.currentRef && played > 0) {
|
if (played > 0) {
|
||||||
// Convert consumed output samples back to contract (source) samples.
|
const consumedSource = played * this.ratio; // OUTPUT played → SOURCE consumed
|
||||||
const consumed = played * this.ratio;
|
this.queuedSource = Math.max(0, this.queuedSource - consumedSource);
|
||||||
const ref = this.currentRef;
|
this.consumeSpans(consumedSource);
|
||||||
this.refPlayedSamples.set(ref, (this.refPlayedSamples.get(ref) ?? 0) + consumed);
|
this.reportCadence();
|
||||||
this.unreportedSamples += consumed;
|
|
||||||
const srcRate = this.ratio * sampleRate;
|
|
||||||
if ((this.unreportedSamples / srcRate) * 1000 >= REPORT_INTERVAL_MS) {
|
|
||||||
this.reportProgress(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (this.count === 0) {
|
if (this.count === 0) {
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.reportProgress(true);
|
this.reportFinal();
|
||||||
this.port.postMessage({ type: 'idle' });
|
this.port.postMessage({ type: 'idle' });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -147,14 +191,49 @@ class PcmPlaybackProcessor extends AudioWorkletProcessor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
reportProgress(force) {
|
/** Draw `amount` SOURCE samples off the front of the ref FIFO, crediting each ref. */
|
||||||
|
consumeSpans(amount) {
|
||||||
|
while (amount > 1e-6 && this.refQueue.length) {
|
||||||
|
const span = this.refQueue[0];
|
||||||
|
const take = amount < span.src ? amount : span.src;
|
||||||
|
span.src -= take;
|
||||||
|
amount -= take;
|
||||||
|
this.creditRef(span.ref, take);
|
||||||
|
if (span.src <= 1e-6) {
|
||||||
|
this.refQueue.shift();
|
||||||
|
this.postProgress(span.ref); // ref finished: post its final cumulative before the next ref
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
creditRef(ref, sourceSamples) {
|
||||||
|
this.refPlayedSamples.set(ref, (this.refPlayedSamples.get(ref) ?? 0) + sourceSamples);
|
||||||
|
this.playingRef = ref;
|
||||||
|
this.unreportedSamples += sourceSamples;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Final cumulative report for the ref currently playing (interruption / drain / clear). */
|
||||||
|
reportFinal() {
|
||||||
this.unreportedSamples = 0;
|
this.unreportedSamples = 0;
|
||||||
const ref = this.currentRef;
|
if (!this.playingRef) return;
|
||||||
if (!ref) return;
|
this.postProgress(this.playingRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Cadence report for the ref currently playing (~REPORT_INTERVAL_MS of consumed source). */
|
||||||
|
reportCadence() {
|
||||||
|
if (!this.playingRef) return;
|
||||||
const srcRate = this.ratio * sampleRate;
|
const srcRate = this.ratio * sampleRate;
|
||||||
|
if ((this.unreportedSamples / srcRate) * 1000 >= REPORT_INTERVAL_MS) {
|
||||||
|
this.reportFinal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
postProgress(ref) {
|
||||||
const playedSamples = this.refPlayedSamples.get(ref) ?? 0;
|
const playedSamples = this.refPlayedSamples.get(ref) ?? 0;
|
||||||
const playedMs = Math.max(0, Math.round((playedSamples / srcRate) * 1000));
|
const srcRate = this.ratio * sampleRate;
|
||||||
if (playedMs <= 0) return; // nothing has actually been heard for this ref yet
|
// floor: never claims an unheard millisecond; monotonic because it is cumulative.
|
||||||
|
const playedMs = Math.floor((playedSamples / srcRate) * 1000);
|
||||||
|
if (playedMs <= 0) return;
|
||||||
this.port.postMessage({ type: 'progress', audioRef: ref, playedMs });
|
this.port.postMessage({ type: 'progress', audioRef: ref, playedMs });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const routes: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
title: 'دستیار هوشمند',
|
title: 'دستیار هوش مصنوعی',
|
||||||
component: HomePage,
|
component: HomePage,
|
||||||
canActivate: [authGuard],
|
canActivate: [authGuard],
|
||||||
},
|
},
|
||||||
@@ -68,7 +68,7 @@ export const routes: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'chat-questions',
|
path: 'chat-questions',
|
||||||
title: 'سوالات چت سایت و اپلیکیشن',
|
title: 'سوالات چت وب اپلیکیشن',
|
||||||
component: ChatQuestionsPage,
|
component: ChatQuestionsPage,
|
||||||
canActivate: [authGuard],
|
canActivate: [authGuard],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -21,9 +21,13 @@ const BASE_NAV_ITEMS: NavItem[] = [
|
|||||||
label: 'بازخوانی تماسها از کال سنتر',
|
label: 'بازخوانی تماسها از کال سنتر',
|
||||||
route: '/call-center/calls',
|
route: '/call-center/calls',
|
||||||
},
|
},
|
||||||
{ icon: 'M7.9 20A9 9 0 1 0 4 16.1L2 22Z', label: 'سوالات چت سایت و اپلیکیشن', route: '/chat-questions' },
|
|
||||||
{
|
{
|
||||||
icon: 'M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37.996.608 2.296.07 2.573-1.066zM15 12a3 3 0 11-6 0 0 3 3 0 016 0z',
|
icon: 'M7.9 20A9 9 0 1 0 4 16.1L2 22Z',
|
||||||
|
label: 'سوالات چت وب اپلیکیشن',
|
||||||
|
route: '/chat-questions',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: 'M19.14 12.94c.04-.3.06-.61.06-.94s-.02-.64-.07-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.61-.22l-2.39.96a7.3 7.3 0 0 0-1.63-.94l-.36-2.54A.49.49 0 0 0 13.87 2h-3.84a.49.49 0 0 0-.49.42L9.18 4.96c-.59.23-1.14.55-1.63.94l-2.39-.96a.5.5 0 0 0-.61.22L2.63 8.48a.5.5 0 0 0 .12.64l2.03 1.58a7 7 0 0 0 0 1.88l-2.03 1.58a.5.5 0 0 0-.12.64l1.92 3.32c.13.22.39.31.61.22l2.39-.96c.49.39 1.04.71 1.63.94l.36 2.54c.03.24.24.42.49.42h3.84c.25 0 .46-.18.49-.42l.36-2.54c.59-.23 1.14-.55 1.63-.94l2.39.96c.22.09.48 0 .61-.22l1.92-3.32a.5.5 0 0 0-.12-.64zM12 15.5a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7z',
|
||||||
label: 'تنظیمات',
|
label: 'تنظیمات',
|
||||||
route: '/settings',
|
route: '/settings',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -63,12 +63,12 @@ export class CallCenterPage {
|
|||||||
description:
|
description:
|
||||||
'تماسهایی که هوش مصنوعی نتوانسته پاسخ دهد، به همراه سابقه گفتگو به کارشناس ارجاع میشود.',
|
'تماسهایی که هوش مصنوعی نتوانسته پاسخ دهد، به همراه سابقه گفتگو به کارشناس ارجاع میشود.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'sync',
|
id: 'sync',
|
||||||
icon: 'M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z',
|
icon: 'M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8M21 3v5h-5M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16M8 16H3v5',
|
||||||
title: 'همگامسازی وضعیت کارشناسان',
|
title: 'همگامسازی وضعیت کارشناسان',
|
||||||
description:
|
description:
|
||||||
'حاضر بودن، مرخصی و خارجشدن کارشناسان بین برنامه و سامانه کال سنتر همگام میشود.',
|
'حاضر بودن، مرخصی و خارجشدن کارشناسان بین برنامه و سامانه کال سنتر همگام میشود.',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Page-specific styles for «سوالات چت سایت و اپلیکیشن» (shared chrome: shared/styles/demo-page.css) */
|
/* Page-specific styles for «سوالات چت وب اپلیکیشن» (shared chrome: shared/styles/demo-page.css) */
|
||||||
|
|
||||||
.demo-list-main {
|
.demo-list-main {
|
||||||
flex: 1 1 22rem;
|
flex: 1 1 22rem;
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
<div>
|
<div>
|
||||||
<h1 class="demo-title">سوالات چت سایت و اپلیکیشن</h1>
|
<h1 class="demo-title">سوالات چت وب اپلیکیشن</h1>
|
||||||
<p class="demo-subtitle">پرسشهای ثبتشده در چت سایت و اپلیکیشن موبایل</p>
|
<p class="demo-subtitle">پرسشهای ثبتشده در چت وب اپلیکیشن </p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="demo-chip">نمایشی</span>
|
<span class="demo-chip">نمایشی</span>
|
||||||
@@ -53,9 +53,7 @@
|
|||||||
<div class="demo-card-header">
|
<div class="demo-card-header">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="demo-card-title">نمونه پرسشهای چت</h2>
|
<h2 class="demo-card-title">نمونه پرسشهای چت</h2>
|
||||||
<p class="demo-card-description">
|
<p class="demo-card-description">پرسشهای دریافتی به همراه منبع ثبت و وضعیت پاسخگویی.</p>
|
||||||
پرسشهای دریافتی به همراه منبع ثبت و وضعیت پاسخگویی.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<span class="demo-badge">داده نمونه</span>
|
<span class="demo-badge">داده نمونه</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -66,10 +64,18 @@
|
|||||||
<div class="demo-list-main">
|
<div class="demo-list-main">
|
||||||
<p class="demo-question">{{ item.question }}</p>
|
<p class="demo-question">{{ item.question }}</p>
|
||||||
<div class="demo-meta">
|
<div class="demo-meta">
|
||||||
<span class="demo-tag" [class.demo-tag--site]="item.sourceKind === 'site'" [class.demo-tag--app]="item.sourceKind === 'app'">
|
<span
|
||||||
|
class="demo-tag"
|
||||||
|
[class.demo-tag--site]="item.sourceKind === 'site'"
|
||||||
|
[class.demo-tag--app]="item.sourceKind === 'app'"
|
||||||
|
>
|
||||||
{{ item.source }}
|
{{ item.source }}
|
||||||
</span>
|
</span>
|
||||||
<span class="demo-tag" [class.demo-tag--answered]="item.statusKind === 'answered'" [class.demo-tag--pending]="item.statusKind === 'pending'">
|
<span
|
||||||
|
class="demo-tag"
|
||||||
|
[class.demo-tag--answered]="item.statusKind === 'answered'"
|
||||||
|
[class.demo-tag--pending]="item.statusKind === 'pending'"
|
||||||
|
>
|
||||||
{{ item.status }}
|
{{ item.status }}
|
||||||
</span>
|
</span>
|
||||||
<span>{{ item.date }}</span>
|
<span>{{ item.date }}</span>
|
||||||
@@ -98,8 +104,8 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<h3>پرسشی از چت ثبت نشده است</h3>
|
<h3>پرسشی از چت ثبت نشده است</h3>
|
||||||
<p>
|
<p>
|
||||||
پس از اتصال چت سایت و اپلیکیشن موبایل، پرسشهای جدید کاربران بهصورت خودکار در این صفحه نمایش
|
پس از اتصال چت سایت و اپلیکیشن موبایل، پرسشهای جدید کاربران بهصورت خودکار در این صفحه
|
||||||
داده میشود تا برای آنها پاسخ ثبت شود.
|
نمایش داده میشود تا برای آنها پاسخ ثبت شود.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ describe('ChatQuestionsPage', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const element: HTMLElement = fixture.nativeElement;
|
const element: HTMLElement = fixture.nativeElement;
|
||||||
expect(element.querySelector('.demo-title')?.textContent?.trim()).toBe('سوالات چت سایت و اپلیکیشن');
|
expect(element.querySelector('.demo-title')?.textContent?.trim()).toBe('سوالات چت وب اپلیکیشن');
|
||||||
expect(element.textContent).toContain('این بخش هنوز فعال نیست');
|
expect(element.textContent).toContain('این بخش هنوز فعال نیست');
|
||||||
expect(element.textContent).toContain('داده نمونه');
|
expect(element.textContent).toContain('داده نمونه');
|
||||||
|
|
||||||
|
|||||||
@@ -261,11 +261,20 @@
|
|||||||
.settings-tabs {
|
.settings-tabs {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tab-divider {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.tab-btn {
|
.tab-btn {
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tab-btn span {
|
||||||
|
white-space: normal;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
.tab-btn .tab-indicator {
|
.tab-btn .tab-indicator {
|
||||||
display: none;
|
display: none;
|
||||||
@@ -458,6 +467,15 @@
|
|||||||
background: var(--color-danger)/15;
|
background: var(--color-danger)/15;
|
||||||
color: var(--color-danger);
|
color: var(--color-danger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Plain text colours for the document active flag (no badge background). */
|
||||||
|
.doc-active {
|
||||||
|
color: var(--color-success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.doc-inactive {
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
.status-dot,
|
.status-dot,
|
||||||
.dot-queued,
|
.dot-queued,
|
||||||
.dot-processing,
|
.dot-processing,
|
||||||
|
|||||||
@@ -69,6 +69,37 @@
|
|||||||
></span>
|
></span>
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<div class="tab-divider w-px h-6 bg-black/25"></div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="tab-btn flex-1 flex items-center justify-center gap-2 px-4 py-3 text-sm font-medium text-[var(--text-muted)] transition-all duration-200 hover:text-[var(--text-primary)] relative"
|
||||||
|
[class.tab-active]="activeTab() === 'models'"
|
||||||
|
(click)="selectTab('models')"
|
||||||
|
role="tab"
|
||||||
|
[attr.aria-selected]="activeTab() === 'models'"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="w-4 h-4 transition-colors duration-200"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" />
|
||||||
|
<path d="M19 10v2a7 7 0 0 1-14 0v-2" />
|
||||||
|
<line x1="12" x2="12" y1="19" y2="22" />
|
||||||
|
</svg>
|
||||||
|
<span>تنظیمات مدلهای هوش مصنوعی</span>
|
||||||
|
@if (activeTab() === 'models') {
|
||||||
|
<span
|
||||||
|
class="tab-indicator absolute bottom-0 left-1/2 -translate-x-1/2 w-6 h-0.5 bg-primary rounded-full"
|
||||||
|
></span>
|
||||||
|
}
|
||||||
|
</button>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="settings-content p-6">
|
<div class="settings-content p-6">
|
||||||
@@ -313,13 +344,16 @@
|
|||||||
type="button"
|
type="button"
|
||||||
class="file-remove-btn p-1 text-[var(--text-muted)] rounded transition-colors hover:text-[var(--color-primary)]"
|
class="file-remove-btn p-1 text-[var(--text-muted)] rounded transition-colors hover:text-[var(--color-primary)]"
|
||||||
(click)="retryUpload($index)"
|
(click)="retryUpload($index)"
|
||||||
aria-label="دوبارهسعی آپلود"
|
aria-label="تلاش مجدد آپلود"
|
||||||
title="دوبارهسعی"
|
title="تلاش مجدد"
|
||||||
>
|
>
|
||||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none"
|
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none"
|
||||||
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||||
stroke-linejoin="round">
|
stroke-linejoin="round">
|
||||||
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
|
<path d="M20 7v5h-5" />
|
||||||
|
<path d="M4 17v-5h5" />
|
||||||
|
<path d="M5.6 9a7 7 0 0 1 11.55-2.6L20 12" />
|
||||||
|
<path d="M4 12l2.85 5.6A7 7 0 0 0 18.4 15" />
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
@@ -332,12 +366,20 @@
|
|||||||
<div class="documents-section mt-8">
|
<div class="documents-section mt-8">
|
||||||
@if (!isAdmin()) {
|
@if (!isAdmin()) {
|
||||||
<div class="documents-locked flex flex-col items-center justify-center gap-3 py-10 text-center">
|
<div class="documents-locked flex flex-col items-center justify-center gap-3 py-10 text-center">
|
||||||
<svg class="w-10 h-10 text-[var(--text-muted)]" viewBox="0 0 24 24" fill="none"
|
<svg
|
||||||
stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
|
class="w-5 h-5 text-primary"
|
||||||
stroke-linejoin="round">
|
viewBox="0 0 24 24"
|
||||||
<path d="M12 1.75v20.5" />
|
fill="none"
|
||||||
<path d="M4.25 12h15.5" />
|
stroke="currentColor"
|
||||||
</svg>
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
||||||
|
<polyline points="14 2 14 8 20 8" />
|
||||||
|
<line x1="8" y1="13" x2="16" y2="13" />
|
||||||
|
<line x1="8" y1="17" x2="16" y2="17" />
|
||||||
|
</svg>
|
||||||
<p class="text-sm text-[var(--text-secondary)]">مدیریت و لیست اسناد فقط برای ادمینها در دسترس است.</p>
|
<p class="text-sm text-[var(--text-secondary)]">مدیریت و لیست اسناد فقط برای ادمینها در دسترس است.</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -346,18 +388,19 @@
|
|||||||
<div class="section-header mb-4">
|
<div class="section-header mb-4">
|
||||||
<h2 class="text-xl font-semibold text-[var(--text-primary)] mb-1 flex items-center gap-2">
|
<h2 class="text-xl font-semibold text-[var(--text-primary)] mb-1 flex items-center gap-2">
|
||||||
<svg
|
<svg
|
||||||
class="w-5 h-5 text-primary"
|
class="w-5 h-5 text-primary"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
stroke-width="2"
|
stroke-width="2"
|
||||||
stroke-linecap="round"
|
stroke-linecap="round"
|
||||||
stroke-linejoin="round"
|
stroke-linejoin="round"
|
||||||
>
|
>
|
||||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
||||||
<polyline points="14 2 14 8 20 8" />
|
<polyline points="14 2 14 8 20 8" />
|
||||||
<polyline points="14 8 20 8 20 14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8z" />
|
<line x1="8" y1="13" x2="16" y2="13" />
|
||||||
</svg>
|
<line x1="8" y1="17" x2="16" y2="17" />
|
||||||
|
</svg>
|
||||||
اسناد آپلود شده
|
اسناد آپلود شده
|
||||||
</h2>
|
</h2>
|
||||||
<p class="text-sm text-[var(--text-muted)]">
|
<p class="text-sm text-[var(--text-muted)]">
|
||||||
@@ -367,13 +410,20 @@
|
|||||||
|
|
||||||
@if (documentsLoading() && documents().length === 0) {
|
@if (documentsLoading() && documents().length === 0) {
|
||||||
<div class="documents-loading flex items-center justify-center gap-2 py-10 text-[var(--text-muted)]">
|
<div class="documents-loading flex items-center justify-center gap-2 py-10 text-[var(--text-muted)]">
|
||||||
<svg class="w-5 h-5 animate-spin" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
<svg
|
||||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
class="w-5 h-5 animate-spin"
|
||||||
<line x1="12" y1="5" x2="12" y2="19" />
|
viewBox="0 0 24 24"
|
||||||
<path d="M19 12a7 7 0 1 1-14 0a7 7 0 0 1 14 0z" />
|
fill="none"
|
||||||
</svg>
|
stroke="currentColor"
|
||||||
<span>در حال بارگذاری اسناد...</span>
|
stroke-width="2"
|
||||||
</div>
|
stroke-linecap="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<circle cx="12" cy="12" r="9" stroke-opacity="0.2" />
|
||||||
|
<path d="M21 12a9 9 0 0 0-9-9" />
|
||||||
|
</svg>
|
||||||
|
<span>در حال بارگذاری اسناد...</span>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (documentsError() && documents().length === 0) {
|
@if (documentsError() && documents().length === 0) {
|
||||||
@@ -389,7 +439,7 @@
|
|||||||
<div class="documents-filters mb-3 flex items-center justify-between gap-2">
|
<div class="documents-filters mb-3 flex items-center justify-between gap-2">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<select
|
<select
|
||||||
class="form-select bg-[var(--input-bg)] text-[var(--text-secondary)] border border-[var(--input-border)] rounded-lg px-3 py-1.5 text-xs min-w-[130px] cursor-pointer"
|
class="form-select bg-[var(--color-input-bg)] text-[var(--text-secondary)] border border-[var(--color-input-border)] rounded-lg px-3 py-1.5 text-xs min-w-[130px] cursor-pointer"
|
||||||
[value]="activeFilter()"
|
[value]="activeFilter()"
|
||||||
(change)="activeFilter.set($any($event.target).value); applyDocumentFilters()"
|
(change)="activeFilter.set($any($event.target).value); applyDocumentFilters()"
|
||||||
>
|
>
|
||||||
@@ -407,11 +457,20 @@
|
|||||||
<span class="text-xs text-[var(--text-muted)]">فقط فعال</span>
|
<span class="text-xs text-[var(--text-muted)]">فقط فعال</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn--outline" (click)="refreshDocuments()" [disabled]="documentsLoading()">
|
<button type="button" class="btn btn--outline" (click)="refreshDocuments()" [disabled]="documentsLoading()">
|
||||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
<svg
|
||||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
class="w-4 h-4"
|
||||||
<path d="M3 12a9 9 0 0 1 9-9a9 9 0 1 1 0 18a9 9 0 0 1 0-18z" />
|
viewBox="0 0 24 24"
|
||||||
<path d="M12 8v4l2 2" />
|
fill="none"
|
||||||
</svg>
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M20 7v5h-5" />
|
||||||
|
<path d="M4 17v-5h5" />
|
||||||
|
<path d="M5.6 9a7 7 0 0 1 11.55-2.6L20 12" />
|
||||||
|
<path d="M4 12l2.85 5.6A7 7 0 0 0 18.4 15" />
|
||||||
|
</svg>
|
||||||
<span>بهروزرسانی</span>
|
<span>بهروزرسانی</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -472,12 +531,17 @@
|
|||||||
@if (doc.status === 'ready' && !isReviewNeeded(doc) && isAdmin()) {
|
@if (doc.status === 'ready' && !isReviewNeeded(doc) && isAdmin()) {
|
||||||
@if (togglingDocId() === doc.id) {
|
@if (togglingDocId() === doc.id) {
|
||||||
<div class="flex items-center gap-1.5 text-xs text-[var(--text-muted)]">
|
<div class="flex items-center gap-1.5 text-xs text-[var(--text-muted)]">
|
||||||
<svg class="w-3 h-3 animate-spin" viewBox="0 0 24 24" fill="none"
|
<svg
|
||||||
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
class="w-3 h-3 animate-spin"
|
||||||
stroke-linejoin="round">
|
viewBox="0 0 24 24"
|
||||||
<line x1="12" y1="5" x2="12" y2="19" />
|
fill="none"
|
||||||
<path d="M19 12a7 7 0 0 1-14 0a7 7 0 0 1 14 0z" />
|
stroke="currentColor"
|
||||||
</svg>
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
>
|
||||||
|
<circle cx="12" cy="12" r="9" stroke-opacity="0.2" />
|
||||||
|
<path d="M21 12a9 9 0 0 0-9-9" />
|
||||||
|
</svg>
|
||||||
<span>در حال بهروزرسانی</span>
|
<span>در حال بهروزرسانی</span>
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
@@ -493,8 +557,8 @@
|
|||||||
} @else {
|
} @else {
|
||||||
<span
|
<span
|
||||||
class="text-xs"
|
class="text-xs"
|
||||||
[class.text-[var(--color-success)]="doc.is_active"
|
[class.status-ready]="doc.is_active"
|
||||||
[class.text-[var(--text-muted)]="!doc.is_active"
|
[class.status-failed]="!doc.is_active"
|
||||||
>{{ doc.is_active ? 'فعال' : 'غیرفعال' }}</span
|
>{{ doc.is_active ? 'فعال' : 'غیرفعال' }}</span
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
@@ -508,13 +572,19 @@
|
|||||||
[disabled]="reviewingDocId() === doc.id"
|
[disabled]="reviewingDocId() === doc.id"
|
||||||
(click)="openReview(doc)"
|
(click)="openReview(doc)"
|
||||||
>
|
>
|
||||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none"
|
<svg
|
||||||
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
class="w-4 h-4"
|
||||||
stroke-linejoin="round">
|
viewBox="0 0 24 24"
|
||||||
<path d="M2 12s9-7 19-7c2.6 0 4.5 2 4.5 4.5S23.6 19 21 19s-4.5-2.5-4.5-4.5S17.4 7 9 7" />
|
fill="none"
|
||||||
<path d="M2 12s9 7 19 7c2.6 0 4.5-2 4.5-4.5S23.6 7 21 7s-4.5 2.5-4.5 4.5S16.6 17 21 17" />
|
stroke="currentColor"
|
||||||
<circle cx="12" cy="12" r="3" />
|
stroke-width="2"
|
||||||
</svg>
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z" />
|
||||||
|
<circle cx="12" cy="12" r="3" />
|
||||||
|
</svg>
|
||||||
<span>بازبینی سند</span>
|
<span>بازبینی سند</span>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
@@ -524,12 +594,21 @@
|
|||||||
class="btn btn--outline"
|
class="btn btn--outline"
|
||||||
(click)="retryDocument(doc)"
|
(click)="retryDocument(doc)"
|
||||||
>
|
>
|
||||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none"
|
<svg
|
||||||
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
class="w-4 h-4"
|
||||||
stroke-linejoin="round">
|
viewBox="0 0 24 24"
|
||||||
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M20 7v5h-5" />
|
||||||
|
<path d="M4 17v-5h5" />
|
||||||
|
<path d="M5.6 9a7 7 0 0 1 11.55-2.6L20 12" />
|
||||||
|
<path d="M4 12l2.85 5.6A7 7 0 0 0 18.4 15" />
|
||||||
</svg>
|
</svg>
|
||||||
<span>دوبارهسعی</span>
|
<span>تلاشمجدد</span>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -595,12 +674,18 @@
|
|||||||
<div class="review-modal-body">
|
<div class="review-modal-body">
|
||||||
@if (reviewLoading()) {
|
@if (reviewLoading()) {
|
||||||
<div class="review-loading flex items-center justify-center gap-2 py-8 text-[var(--text-muted)]">
|
<div class="review-loading flex items-center justify-center gap-2 py-8 text-[var(--text-muted)]">
|
||||||
<svg class="w-5 h-5 animate-spin" viewBox="0 0 24 24" fill="none"
|
<svg
|
||||||
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
class="w-5 h-5 animate-spin"
|
||||||
stroke-linejoin="round">
|
viewBox="0 0 24 24"
|
||||||
<line x1="12" y1="5" x2="12" y2="19" />
|
fill="none"
|
||||||
<path d="M19 12a7 7 0 0 1-14 0a7 7 0 0 1 14 0z" />
|
stroke="currentColor"
|
||||||
</svg>
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<circle cx="12" cy="12" r="9" stroke-opacity="0.2" />
|
||||||
|
<path d="M21 12a9 9 0 0 0-9-9" />
|
||||||
|
</svg>
|
||||||
<span>در حال بارگذاری شواهد...</span>
|
<span>در حال بارگذاری شواهد...</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -742,11 +827,22 @@
|
|||||||
<footer class="review-modal-footer border-t border-[var(--color-card-border)] p-3 flex justify-end gap-2">
|
<footer class="review-modal-footer border-t border-[var(--color-card-border)] p-3 flex justify-end gap-2">
|
||||||
@if (canRetryAfterReview()) {
|
@if (canRetryAfterReview()) {
|
||||||
<button type="button" class="btn btn--primary" (click)="finishReviewAndRetry()">
|
<button type="button" class="btn btn--primary" (click)="finishReviewAndRetry()">
|
||||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
<svg
|
||||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
class="w-4 h-4"
|
||||||
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
|
viewBox="0 0 24 24"
|
||||||
</svg>
|
fill="none"
|
||||||
<span>بستن و دوبارهسعی پردازش</span>
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<path d="M3 2v6h6" />
|
||||||
|
<path d="M21 12a9 9 0 0 0-15-6.7L3 8" />
|
||||||
|
<path d="M21 22v-6h-6" />
|
||||||
|
<path d="M3 12a9 9 0 0 0 15 6.7L21 16" />
|
||||||
|
</svg>
|
||||||
|
<span>بستن و تلاش مجدد پردازش</span>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
<button type="button" class="btn btn--outline" (click)="closeReview()">
|
<button type="button" class="btn btn--outline" (click)="closeReview()">
|
||||||
@@ -809,7 +905,7 @@
|
|||||||
<span class="text-xs text-[var(--text-muted)] block mt-0.5">
|
<span class="text-xs text-[var(--text-muted)] block mt-0.5">
|
||||||
در صورت فعال بودن، محتوای استخراجشده از اسناد باید توسط ادمین بازبینی و تأیید شود.
|
در صورت فعال بودن، محتوای استخراجشده از اسناد باید توسط ادمین بازبینی و تأیید شود.
|
||||||
</span>
|
</span>
|
||||||
<span class="text-xs text-[var(--color-warning)] mt-0.5">پیشنویس — ذخیرهسازی در فاز MVP پشتیبانی نمیشود</span>
|
<!-- <span class="text-xs text-[var(--color-warning)] mt-0.5">پیشنویس — ذخیرهسازی در فاز MVP پشتیبانی نمیشود</span> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-control shrink-0">
|
<div class="setting-control shrink-0">
|
||||||
<label class="toggle-switch" [class.toggle-active]="ocrAdminApproval()">
|
<label class="toggle-switch" [class.toggle-active]="ocrAdminApproval()">
|
||||||
@@ -820,8 +916,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-8">
|
</section>
|
||||||
<h3 class="text-lg font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2">
|
}
|
||||||
|
|
||||||
|
@if (activeTab() === 'models') {
|
||||||
|
<section class="models-section animate-fade-in">
|
||||||
|
<div class="section-header mb-6">
|
||||||
|
<h2 class="text-xl font-semibold text-[var(--text-primary)] mb-1 flex items-center gap-2">
|
||||||
<svg class="w-5 h-5 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
<svg class="w-5 h-5 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" />
|
<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" />
|
||||||
@@ -829,42 +930,42 @@
|
|||||||
<line x1="12" x2="12" y1="19" y2="22" />
|
<line x1="12" x2="12" y1="19" y2="22" />
|
||||||
</svg>
|
</svg>
|
||||||
تنظیمات مدلهای هوش مصنوعی
|
تنظیمات مدلهای هوش مصنوعی
|
||||||
</h3>
|
</h2>
|
||||||
<p class="text-xs text-[var(--text-muted)] mb-4">
|
<p class="text-sm text-[var(--text-muted)]">
|
||||||
هر کارت بهصورت مستقل پیکربندی میشود. در فاز MVP، این تنظیمات در حافظه نگهداری میشوند و به سرور ارسال نمیشوند.
|
هر کارت بهصورت مستقل پیکربندی میشود. در فاز MVP، این تنظیمات در حافظه نگهداری میشوند و به سرور ارسال نمیشوند.
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="ai-models-grid grid grid-cols-1 lg:grid-cols-2 gap-6">
|
<div class="ai-models-grid grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||||
<app-ai-model-config-card
|
<app-ai-model-config-card
|
||||||
title="تنظیمات مدل هوش مصنوعی"
|
title="تنظیمات مدل هوش مصنوعی"
|
||||||
task="text"
|
task="text"
|
||||||
[config]="textModelConfig()"
|
[config]="textModelConfig()"
|
||||||
(configChange)="textModelConfig.set($event)"
|
(configChange)="textModelConfig.set($event)"
|
||||||
[connected]="textModelConnected()"
|
[connected]="textModelConnected()"
|
||||||
(save)="saveModelConfig('text')"
|
(save)="saveModelConfig('text')"
|
||||||
(testConnection)="testModelConnection('text')"
|
(testConnection)="testModelConnection('text')"
|
||||||
></app-ai-model-config-card>
|
></app-ai-model-config-card>
|
||||||
|
|
||||||
<app-ai-model-config-card
|
<app-ai-model-config-card
|
||||||
title="تنظیمات مدل امبدینگ"
|
title="تنظیمات مدل امبدینگ"
|
||||||
task="embedding"
|
task="embedding"
|
||||||
[config]="embeddingModelConfig()"
|
[config]="embeddingModelConfig()"
|
||||||
(configChange)="embeddingModelConfig.set($event)"
|
(configChange)="embeddingModelConfig.set($event)"
|
||||||
[connected]="embeddingModelConnected()"
|
[connected]="embeddingModelConnected()"
|
||||||
(save)="saveModelConfig('embedding')"
|
(save)="saveModelConfig('embedding')"
|
||||||
(testConnection)="testModelConnection('embedding')"
|
(testConnection)="testModelConnection('embedding')"
|
||||||
></app-ai-model-config-card>
|
></app-ai-model-config-card>
|
||||||
|
|
||||||
<app-ai-model-config-card
|
<app-ai-model-config-card
|
||||||
title="تنظیمات مدل OCR"
|
title="تنظیمات مدل OCR"
|
||||||
task="ocr"
|
task="ocr"
|
||||||
[config]="ocrModelConfig()"
|
[config]="ocrModelConfig()"
|
||||||
(configChange)="ocrModelConfig.set($event)"
|
(configChange)="ocrModelConfig.set($event)"
|
||||||
[connected]="ocrModelConnected()"
|
[connected]="ocrModelConnected()"
|
||||||
(save)="saveModelConfig('ocr')"
|
(save)="saveModelConfig('ocr')"
|
||||||
(testConnection)="testModelConnection('ocr')"
|
(testConnection)="testModelConnection('ocr')"
|
||||||
></app-ai-model-config-card>
|
></app-ai-model-config-card>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-8">
|
<div class="mt-8">
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
AiModelConfig,
|
AiModelConfig,
|
||||||
AiTask,
|
AiTask,
|
||||||
} from '../../shared/ui/ai-model-config-card/ai-model-config-card.component';
|
} from '../../shared/ui/ai-model-config-card/ai-model-config-card.component';
|
||||||
import { toPersianDigits } from '../../shared/utils/format.util';
|
import { formatJalaliDateTime, toPersianDigits } from '../../shared/utils/format.util';
|
||||||
import {
|
import {
|
||||||
DocumentDetail,
|
DocumentDetail,
|
||||||
DocumentListItem,
|
DocumentListItem,
|
||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
DOCUMENT_STATUS_LABEL,
|
DOCUMENT_STATUS_LABEL,
|
||||||
} from '../../services/documents/documents.types';
|
} from '../../services/documents/documents.types';
|
||||||
|
|
||||||
type TabId = 'faq' | 'app';
|
type TabId = 'faq' | 'app' | 'models';
|
||||||
|
|
||||||
type UploadStatus = 'uploading' | 'done' | 'error';
|
type UploadStatus = 'uploading' | 'done' | 'error';
|
||||||
interface UploadTask {
|
interface UploadTask {
|
||||||
@@ -151,6 +151,7 @@ export class SettingsPage implements OnInit, OnDestroy {
|
|||||||
readonly tabs: { id: TabId; label: string }[] = [
|
readonly tabs: { id: TabId; label: string }[] = [
|
||||||
{ id: 'faq', label: 'آپلود FAQ' },
|
{ id: 'faq', label: 'آپلود FAQ' },
|
||||||
{ id: 'app', label: 'تنظیمات برنامه' },
|
{ id: 'app', label: 'تنظیمات برنامه' },
|
||||||
|
{ id: 'models', label: 'تنظیمات مدلهای هوش مصنوعی' },
|
||||||
];
|
];
|
||||||
|
|
||||||
readonly activeTab = signal<TabId>('faq');
|
readonly activeTab = signal<TabId>('faq');
|
||||||
@@ -347,21 +348,9 @@ export class SettingsPage implements OnInit, OnDestroy {
|
|||||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** تاریخ آپلود به صورت تاریخ و ساعت جلالی */
|
||||||
formatDateTime(iso: string): string {
|
formatDateTime(iso: string): string {
|
||||||
try {
|
return formatJalaliDateTime(iso);
|
||||||
const d = new Date(iso);
|
|
||||||
if (Number.isNaN(d.getTime())) {
|
|
||||||
return '—';
|
|
||||||
}
|
|
||||||
const y = d.getFullYear();
|
|
||||||
const m = String(d.getMonth() + 1).padStart(2, '0');
|
|
||||||
const day = String(d.getDate()).padStart(2, '0');
|
|
||||||
const hh = String(d.getHours()).padStart(2, '0');
|
|
||||||
const mm = String(d.getMinutes()).padStart(2, '0');
|
|
||||||
return toPersianDigits(`${y}/${m}/${day} ${hh}:${mm}`);
|
|
||||||
} catch {
|
|
||||||
return '—';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get fileCount(): number {
|
get fileCount(): number {
|
||||||
|
|||||||
@@ -39,7 +39,8 @@
|
|||||||
stroke-linecap="round"
|
stroke-linecap="round"
|
||||||
stroke-linejoin="round"
|
stroke-linejoin="round"
|
||||||
>
|
>
|
||||||
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
|
<path d="M20 11a8.1 8.1 0 0 0-15.5-2M4 4v5h5" />
|
||||||
|
<path d="M4 13a8.1 8.1 0 0 0 15.5 2M20 20v-5h-5" />
|
||||||
</svg>
|
</svg>
|
||||||
<span>بهروزرسانی</span>
|
<span>بهروزرسانی</span>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -50,11 +50,16 @@ export class HttpService {
|
|||||||
* the dev-server proxy (proxy.conf.json) forwards `/api` — including WebSocket
|
* the dev-server proxy (proxy.conf.json) forwards `/api` — including WebSocket
|
||||||
* upgrades — to the backend. The `rag_session` cookie therefore stays same-origin
|
* upgrades — to the backend. The `rag_session` cookie therefore stays same-origin
|
||||||
* and is sent automatically; no bearer token is used for the MVP endpoints.
|
* and is sent automatically; no bearer token is used for the MVP endpoints.
|
||||||
|
*
|
||||||
|
* NOTE: the origin MUST stay empty (`''`). Pointing these at an absolute host
|
||||||
|
* (e.g. `http://10.2.8.3:8080`) turns every request cross-origin, and browsers
|
||||||
|
* refuse to send the session cookie cross-origin over plain HTTP — the backend
|
||||||
|
* then answers 401 AUTH_REQUIRED even though the user is logged in.
|
||||||
*/
|
*/
|
||||||
private readonly baseUrl = 'http://10.0.8.51:1321';
|
private readonly baseUrl = '';
|
||||||
public readonly backendUrl = 'http://10.0.8.51:1321';
|
public readonly backendUrl = '';
|
||||||
public readonly apiUrl = 'http://10.0.8.51:1321';
|
public readonly apiUrl = '';
|
||||||
public readonly imagesUrl = 'http://10.0.8.51:1321';
|
public readonly imagesUrl = '';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly http: HttpClient,
|
private readonly http: HttpClient,
|
||||||
@@ -170,6 +175,7 @@ export class HttpService {
|
|||||||
.get<ApiResult<T>>(url, {
|
.get<ApiResult<T>>(url, {
|
||||||
headers,
|
headers,
|
||||||
params: options.params,
|
params: options.params,
|
||||||
|
withCredentials: true,
|
||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
map((response) => this.processResponse(response, options)),
|
map((response) => this.processResponse(response, options)),
|
||||||
@@ -206,7 +212,7 @@ export class HttpService {
|
|||||||
...headers,
|
...headers,
|
||||||
},
|
},
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
credentials: 'same-origin',
|
credentials: 'include',
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.ok || !response.body) {
|
if (!response.ok || !response.body) {
|
||||||
@@ -268,6 +274,7 @@ export class HttpService {
|
|||||||
.post<ApiResult<T>>(url, data, {
|
.post<ApiResult<T>>(url, data, {
|
||||||
headers: this.mergeHeaders(options.headers),
|
headers: this.mergeHeaders(options.headers),
|
||||||
params: options.params,
|
params: options.params,
|
||||||
|
withCredentials: true,
|
||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
map((response) => this.processResponse(response, options)),
|
map((response) => this.processResponse(response, options)),
|
||||||
@@ -281,6 +288,7 @@ export class HttpService {
|
|||||||
return this.http.post<T>(url, data, {
|
return this.http.post<T>(url, data, {
|
||||||
headers,
|
headers,
|
||||||
params: options.params,
|
params: options.params,
|
||||||
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +300,7 @@ export class HttpService {
|
|||||||
const url = `${this.baseUrl}/${endpoint}`;
|
const url = `${this.baseUrl}/${endpoint}`;
|
||||||
const headers = options.headers ? new HttpHeaders(options.headers) : new HttpHeaders();
|
const headers = options.headers ? new HttpHeaders(options.headers) : new HttpHeaders();
|
||||||
return this.http
|
return this.http
|
||||||
.patch<T>(url, data, { headers, params: options.params })
|
.patch<T>(url, data, { headers, params: options.params, withCredentials: true })
|
||||||
.pipe(catchError((err) => this.handleError(err, options.skipToast)));
|
.pipe(catchError((err) => this.handleError(err, options.skipToast)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,6 +323,7 @@ export class HttpService {
|
|||||||
params: options.params,
|
params: options.params,
|
||||||
reportProgress: true,
|
reportProgress: true,
|
||||||
observe: 'events',
|
observe: 'events',
|
||||||
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!options.signal) {
|
if (!options.signal) {
|
||||||
@@ -341,6 +350,7 @@ export class HttpService {
|
|||||||
return this.http.get<T>(url, {
|
return this.http.get<T>(url, {
|
||||||
headers,
|
headers,
|
||||||
params: options.params,
|
params: options.params,
|
||||||
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,6 +360,7 @@ export class HttpService {
|
|||||||
.put<ApiResult<T>>(url, data, {
|
.put<ApiResult<T>>(url, data, {
|
||||||
headers: this.mergeHeaders(options.headers),
|
headers: this.mergeHeaders(options.headers),
|
||||||
params: options.params,
|
params: options.params,
|
||||||
|
withCredentials: true,
|
||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
map((response) => this.processResponse(response, options)),
|
map((response) => this.processResponse(response, options)),
|
||||||
@@ -363,6 +374,7 @@ export class HttpService {
|
|||||||
.patch<ApiResult<T>>(url, data, {
|
.patch<ApiResult<T>>(url, data, {
|
||||||
headers: this.mergeHeaders(options.headers),
|
headers: this.mergeHeaders(options.headers),
|
||||||
params: options.params,
|
params: options.params,
|
||||||
|
withCredentials: true,
|
||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
map((response) => this.processResponse(response, options)),
|
map((response) => this.processResponse(response, options)),
|
||||||
@@ -376,6 +388,7 @@ export class HttpService {
|
|||||||
.delete<ApiResult<T>>(url, {
|
.delete<ApiResult<T>>(url, {
|
||||||
headers: this.mergeHeaders(options.headers),
|
headers: this.mergeHeaders(options.headers),
|
||||||
params: options.params,
|
params: options.params,
|
||||||
|
withCredentials: true,
|
||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
map((response) => this.processResponse(response, options)),
|
map((response) => this.processResponse(response, options)),
|
||||||
@@ -388,6 +401,7 @@ export class HttpService {
|
|||||||
.get(url, {
|
.get(url, {
|
||||||
headers: this.getHeaders(),
|
headers: this.getHeaders(),
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
|
withCredentials: true,
|
||||||
})
|
})
|
||||||
.pipe(catchError((err) => this.handleError(err, false)));
|
.pipe(catchError((err) => this.handleError(err, false)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,225 @@
|
|||||||
|
import { describe, it, vi } from 'vitest';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the REAL public/assets/worklets/pcm-playback.worklet.js in a stubbed AudioWorklet
|
||||||
|
* global scope (no browser, no node builtins) and returns a processor instance. The worklet
|
||||||
|
* references the ambient `sampleRate`, `AudioWorkletProcessor` and `registerProcessor`
|
||||||
|
* globals; we inject them on `globalThis` before importing the module, then vary
|
||||||
|
* `globalThis.sampleRate` per instance to exercise every context rate deterministically
|
||||||
|
* (the class reads `sampleRate` at call time, not at module-eval time).
|
||||||
|
*/
|
||||||
|
interface Proc {
|
||||||
|
out: Array<{ type: string; audioRef?: string; playedMs?: number }>;
|
||||||
|
port: { onmessage: (e: { data: unknown }) => void };
|
||||||
|
count: number;
|
||||||
|
capacity: number;
|
||||||
|
queuedSource: number;
|
||||||
|
sourceCapacity: number;
|
||||||
|
refPlayedSamples: Map<string, number>;
|
||||||
|
process: (inputs: unknown[][][], outputs: Float32Array[][]) => boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
class FakeAudioWorkletProcessor {
|
||||||
|
out: Array<{ type: string; audioRef?: string; playedMs?: number }> = [];
|
||||||
|
port: {
|
||||||
|
onmessage: ((e: { data: unknown }) => void) | null;
|
||||||
|
postMessage: (m: { type: string; audioRef?: string; playedMs?: number }) => void;
|
||||||
|
};
|
||||||
|
constructor() {
|
||||||
|
this.port = { onmessage: null, postMessage: (m) => this.out.push(m) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let Registered: (new () => Proc) | null = null;
|
||||||
|
const ensureRegistered = async (): Promise<new () => Proc> => {
|
||||||
|
if (Registered) return Registered;
|
||||||
|
const g = globalThis as unknown as Record<string, unknown>;
|
||||||
|
g['AudioWorkletProcessor'] = FakeAudioWorkletProcessor;
|
||||||
|
g['registerProcessor'] = (_name: string, cls: new () => Proc) => {
|
||||||
|
Registered = cls;
|
||||||
|
};
|
||||||
|
// The worklet is plain JS with Web Audio ambient globals; silence the missing ambient types.
|
||||||
|
// @ts-expect-error - worklet has no type declarations
|
||||||
|
await import('../../../../public/assets/worklets/pcm-playback.worklet.js');
|
||||||
|
if (!Registered) throw new Error('worklet did not register a processor');
|
||||||
|
return Registered;
|
||||||
|
};
|
||||||
|
|
||||||
|
async function loadPlaybackProcessor(contextRate: number): Promise<Proc> {
|
||||||
|
const ctor = await ensureRegistered();
|
||||||
|
(globalThis as unknown as { sampleRate: number }).sampleRate = contextRate;
|
||||||
|
return new ctor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A frame of 24 kHz wire PCM with a non-trivial ramp signal. */
|
||||||
|
function frame(sampleOffset: number, samples = 2400): Int16Array {
|
||||||
|
const pcm = new Int16Array(samples);
|
||||||
|
for (let i = 0; i < samples; i++) pcm[i] = ((sampleOffset + i) % 1000) - 500;
|
||||||
|
return pcm;
|
||||||
|
}
|
||||||
|
|
||||||
|
function push(proc: Proc, pcm: Int16Array, audioRef: string | null): void {
|
||||||
|
// The engine transfers the buffer; the worklet re-wraps it. Copy so the frame is reusable.
|
||||||
|
const copy = pcm.slice().buffer;
|
||||||
|
proc.port.onmessage({ data: { type: 'push', pcm: copy, sampleRate: 24000, audioRef } });
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear(proc: Proc): void {
|
||||||
|
proc.port.onmessage({ data: { type: 'clear' } });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One render quantum: emit `samples` output slots and let process() consume/emit. */
|
||||||
|
function render(proc: Proc, samples = 128): void {
|
||||||
|
proc.process([[]], [[new Float32Array(samples)]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Drain everything currently queued (bounded, so a bug cannot hang the test). */
|
||||||
|
function drain(proc: Proc, quantum = 1024): void {
|
||||||
|
let renders = 0;
|
||||||
|
while (proc.count > 0 && renders < 100000) {
|
||||||
|
render(proc, quantum);
|
||||||
|
renders++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const overflowCount = (proc: Proc): number => proc.out.filter((m) => m.type === 'overflow').length;
|
||||||
|
const idleCount = (proc: Proc): number => proc.out.filter((m) => m.type === 'idle').length;
|
||||||
|
const playedFor = (proc: Proc, ref: string): number =>
|
||||||
|
Math.max(0, ...proc.out.filter((m) => m.audioRef === ref).map((m) => m.playedMs ?? 0));
|
||||||
|
|
||||||
|
describe('pcm-playback.worklet', () => {
|
||||||
|
describe('bounded queue is rate-invariant (source units)', () => {
|
||||||
|
// 12 × 2400 source samples = 57,600 source bytes < the 96,000-byte bound: never overflow,
|
||||||
|
// whatever the context rate is. This is the exact reproduction that used to overflow at 48k.
|
||||||
|
for (const rate of [24000, 44100, 48000]) {
|
||||||
|
it(`admits 57,600 source bytes without overflow at a ${rate} Hz context`, async () => {
|
||||||
|
const proc = await loadPlaybackProcessor(rate);
|
||||||
|
for (let c = 0; c < 12; c++) push(proc, frame(c * 2400), 'aud-1');
|
||||||
|
|
||||||
|
expect(overflowCount(proc)).toBe(0);
|
||||||
|
expect(proc.queuedSource).toBe(12 * 2400); // 28,800 source samples admitted
|
||||||
|
expect(proc.queuedSource).toBeLessThanOrEqual(proc.sourceCapacity);
|
||||||
|
expect(proc.count).toBeLessThanOrEqual(proc.capacity); // never exceeds the ring
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// At any context rate the SAME 96,000 source bytes (48,000 samples) fit, and the next
|
||||||
|
// source sample overflows — the bound is on SOURCE PCM, so it must not depend on rate.
|
||||||
|
for (const rate of [24000, 48000]) {
|
||||||
|
it(`overflows only past the 96,000-byte source bound at ${rate} Hz`, async () => {
|
||||||
|
const proc = await loadPlaybackProcessor(rate);
|
||||||
|
for (let c = 0; c < 20; c++) {
|
||||||
|
push(proc, frame(c * 2400), 'aud-1');
|
||||||
|
expect(proc.count).toBeLessThanOrEqual(proc.capacity);
|
||||||
|
}
|
||||||
|
expect(proc.queuedSource).toBe(20 * 2400); // exactly 48,000 source samples
|
||||||
|
expect(overflowCount(proc)).toBe(0);
|
||||||
|
|
||||||
|
push(proc, frame(20 * 2400), 'aud-1'); // one source sample past the bound
|
||||||
|
expect(overflowCount(proc)).toBe(1);
|
||||||
|
expect(proc.count).toBeLessThanOrEqual(proc.capacity); // ring never overwritten
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('posts exactly one overflow under sustained overload (genuine overload fails safely)', async () => {
|
||||||
|
const proc = await loadPlaybackProcessor(48000);
|
||||||
|
for (let c = 0; c < 50; c++) push(proc, frame(c * 2400), 'aud-1');
|
||||||
|
expect(overflowCount(proc)).toBe(1); // not one per rejected chunk
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps queue and outstanding source bounded under continuous enqueue + consumption', async () => {
|
||||||
|
const proc = await loadPlaybackProcessor(48000);
|
||||||
|
let peakCount = 0;
|
||||||
|
let peakSource = 0;
|
||||||
|
// Model real time: push 20 ms frames (480 source samples) and consume ~2× that in output,
|
||||||
|
// so consumption outpaces production and the queue must stay near-empty (no overflow).
|
||||||
|
for (let turn = 0; turn < 300; turn++) {
|
||||||
|
push(proc, frame(turn * 480, 480), `aud-${turn % 3}`);
|
||||||
|
for (let i = 0; i < 4; i++) render(proc, 256); // 1024 output slots consumed
|
||||||
|
peakCount = Math.max(peakCount, proc.count);
|
||||||
|
peakSource = Math.max(peakSource, proc.queuedSource);
|
||||||
|
expect(proc.count).toBeLessThanOrEqual(proc.capacity);
|
||||||
|
}
|
||||||
|
expect(overflowCount(proc)).toBe(0);
|
||||||
|
expect(peakCount).toBeLessThanOrEqual(proc.capacity);
|
||||||
|
expect(peakSource).toBeLessThan(proc.sourceCapacity);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('fractional resampling across chunk boundaries', () => {
|
||||||
|
// 6,000 source samples = 250 ms at 24 kHz. A linear resampler carries ~1 sample of latency
|
||||||
|
// across a boundary, so reported progress is within 1 ms of 250 — but it must never
|
||||||
|
// OVER-claim (>250) and must not depend on where the chunk boundary falls.
|
||||||
|
for (const rate of [24000, 44100, 48000]) {
|
||||||
|
it(`reports the same ~250 ms whether split or whole at ${rate} Hz`, async () => {
|
||||||
|
const oneChunk = await loadPlaybackProcessor(rate);
|
||||||
|
push(oneChunk, frame(0, 6000), 'aud-1');
|
||||||
|
drain(oneChunk);
|
||||||
|
const singleFinal = playedFor(oneChunk, 'aud-1');
|
||||||
|
|
||||||
|
const twoChunks = await loadPlaybackProcessor(rate);
|
||||||
|
push(twoChunks, frame(0, 3000), 'aud-1');
|
||||||
|
push(twoChunks, frame(3000, 3000), 'aud-1');
|
||||||
|
drain(twoChunks);
|
||||||
|
const splitFinal = playedFor(twoChunks, 'aud-1');
|
||||||
|
|
||||||
|
expect(singleFinal).toBeGreaterThanOrEqual(249);
|
||||||
|
expect(singleFinal).toBeLessThanOrEqual(250); // never claim an unheard millisecond
|
||||||
|
expect(splitFinal).toBeGreaterThanOrEqual(249);
|
||||||
|
expect(splitFinal).toBeLessThanOrEqual(250);
|
||||||
|
expect(Math.abs(singleFinal - splitFinal)).toBeLessThanOrEqual(1); // boundary is seamless
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('progress is accurate, monotonic and per audio_ref', () => {
|
||||||
|
it('credits each queued ref its own consumed source (never the next ref)', async () => {
|
||||||
|
const proc = await loadPlaybackProcessor(24000); // ratio 1 → 3,000 source ≈ 125 ms
|
||||||
|
push(proc, frame(0, 3000), 'aud-a');
|
||||||
|
push(proc, frame(3000, 3000), 'aud-b'); // arrives while 'aud-a' is still queued
|
||||||
|
|
||||||
|
// Consume only the first half: it must all be credited to 'aud-a', never 'aud-b'.
|
||||||
|
render(proc, 1024);
|
||||||
|
render(proc, 1024);
|
||||||
|
expect(proc.out.filter((m) => m.audioRef === 'aud-b')).toHaveLength(0); // not heard yet
|
||||||
|
|
||||||
|
const aValues = proc.out.filter((m) => m.audioRef === 'aud-a').map((m) => m.playedMs ?? 0);
|
||||||
|
expect(aValues).toEqual([...aValues].sort((x, y) => x - y)); // monotonic
|
||||||
|
|
||||||
|
drain(proc);
|
||||||
|
|
||||||
|
// Each ref consumed only its own ~3,000 source samples (±1 sample of resampler lag),
|
||||||
|
// never the other ref's samples. The next-ref bug would credit 'aud-b' with 6,000.
|
||||||
|
expect(Math.abs((proc.refPlayedSamples.get('aud-a') ?? 0) - 3000)).toBeLessThanOrEqual(1);
|
||||||
|
expect(Math.abs((proc.refPlayedSamples.get('aud-b') ?? 0) - 3000)).toBeLessThanOrEqual(1);
|
||||||
|
const finalA = playedFor(proc, 'aud-a');
|
||||||
|
const finalB = playedFor(proc, 'aud-b');
|
||||||
|
expect(finalA).toBeGreaterThanOrEqual(124);
|
||||||
|
expect(finalA).toBeLessThanOrEqual(125);
|
||||||
|
expect(finalB).toBeLessThanOrEqual(125); // NOT 250: 'aud-a' samples were not credited to 'aud-b'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('interruption and clear', () => {
|
||||||
|
it('clears the queue and reports only the source actually consumed', async () => {
|
||||||
|
const proc = await loadPlaybackProcessor(24000);
|
||||||
|
push(proc, frame(0, 3000), 'aud-a');
|
||||||
|
render(proc, 128); // started, consumes 128 source samples (~5 ms)
|
||||||
|
clear(proc);
|
||||||
|
|
||||||
|
expect(proc.count).toBe(0);
|
||||||
|
expect(proc.queuedSource).toBe(0);
|
||||||
|
// Final progress reflects what was actually heard (~5 ms), not the whole 3,000 queue.
|
||||||
|
const finals = proc.out.filter((m) => m.type === 'progress' && m.audioRef === 'aud-a');
|
||||||
|
expect(finals.at(-1)?.playedMs).toBe(5);
|
||||||
|
expect(proc.refPlayedSamples.get('aud-a') ?? 0).toBeCloseTo(128, 5);
|
||||||
|
|
||||||
|
// A fresh ref plays normally after the interruption.
|
||||||
|
push(proc, frame(0, 3000), 'aud-b');
|
||||||
|
drain(proc);
|
||||||
|
expect(idleCount(proc)).toBe(1);
|
||||||
|
expect(playedFor(proc, 'aud-b')).toBeGreaterThanOrEqual(124);
|
||||||
|
expect(playedFor(proc, 'aud-b')).toBeLessThanOrEqual(125);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
|
||||||
import { Injectable, inject } from '@angular/core';
|
import { Injectable, inject } from '@angular/core';
|
||||||
import { firstValueFrom, race, throwError, Observable } from 'rxjs';
|
import { firstValueFrom, Observable } from 'rxjs';
|
||||||
import { delay } from 'rxjs/operators';
|
|
||||||
import { VOICE_STREAM_CONFIG, VoiceSessionStatus } from './voice-stream.types';
|
import { VOICE_STREAM_CONFIG, VoiceSessionStatus } from './voice-stream.types';
|
||||||
|
|
||||||
/** The voice helper's HTTP deadline: a client timeout never means the server rolled back. */
|
/**
|
||||||
const REQUEST_DEADLINE_MS = 5000;
|
* The voice helper's HTTP deadline: a client timeout never means the server rolled back.
|
||||||
|
* Generous on purpose — the UI runs against a remote backend through the dev-server proxy,
|
||||||
|
* and the first call after a reload pays the proxy connection setup.
|
||||||
|
*/
|
||||||
|
const REQUEST_DEADLINE_MS = 15000;
|
||||||
|
|
||||||
/** Error envelope from the contract: { error: { code, message, request_id, retryable, details } }. */
|
/** Error envelope from the contract: { error: { code, message, request_id, retryable, details } }. */
|
||||||
export class VoiceApiError extends Error {
|
export class VoiceApiError extends Error {
|
||||||
@@ -199,14 +202,52 @@ export class VoiceApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A short deadline keeps the UI responsive; the caller reconciles the uncertain outcome. */
|
/**
|
||||||
|
* A deadline that never aborts the request.
|
||||||
|
*
|
||||||
|
* `race()` is not usable here: when the timer wins, `race` unsubscribes the loser, so the
|
||||||
|
* HttpClient would abort its XHR. An aborted XHR is reported by the browser as
|
||||||
|
* "(canceled)" — with no status code at all — which is exactly what was observed for
|
||||||
|
* `/api/v1/me`. It also makes a reserve ambiguous ("did the server create it?") instead of
|
||||||
|
* letting it settle, which defeats the V03 reconciliation this flow is built around.
|
||||||
|
*
|
||||||
|
* Here the request subscription is deliberately kept alive: the UI still gets the timeout,
|
||||||
|
* the XHR runs to completion, and a late response is simply discarded.
|
||||||
|
*/
|
||||||
private withDeadline<T>(request: Observable<T>): Observable<T> {
|
private withDeadline<T>(request: Observable<T>): Observable<T> {
|
||||||
return race(
|
return new Observable<T>((observer) => {
|
||||||
request,
|
let settled = false;
|
||||||
throwError(() => new VoiceApiError(0, 'TIMEOUT', 'request-deadline')).pipe(
|
|
||||||
delay(REQUEST_DEADLINE_MS),
|
const timer = setTimeout(() => {
|
||||||
),
|
if (settled) return;
|
||||||
);
|
settled = true;
|
||||||
|
observer.error(new VoiceApiError(0, 'TIMEOUT', 'request-deadline'));
|
||||||
|
}, REQUEST_DEADLINE_MS);
|
||||||
|
|
||||||
|
request.subscribe({
|
||||||
|
next: (value) => {
|
||||||
|
if (settled) return;
|
||||||
|
settled = true;
|
||||||
|
clearTimeout(timer);
|
||||||
|
observer.next(value);
|
||||||
|
},
|
||||||
|
error: (err: unknown) => {
|
||||||
|
if (settled) return;
|
||||||
|
settled = true;
|
||||||
|
clearTimeout(timer);
|
||||||
|
observer.error(this.toApiError(err));
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
if (settled) return;
|
||||||
|
settled = true;
|
||||||
|
clearTimeout(timer);
|
||||||
|
observer.complete();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Only the timer is torn down: the in-flight request is left to finish naturally.
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private toApiError(err: unknown): VoiceApiError {
|
private toApiError(err: unknown): VoiceApiError {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Injectable, NgZone, inject } from '@angular/core';
|
import { Injectable, NgZone, inject } from '@angular/core';
|
||||||
import { MicrophoneService } from '../microphone/microphone.service';
|
import { MicrophoneError, MicrophoneService } from '../microphone/microphone.service';
|
||||||
import { VOICE_STREAM_CONFIG } from './voice-stream.types';
|
import { VOICE_STREAM_CONFIG } from './voice-stream.types';
|
||||||
|
|
||||||
export interface VoiceEngineHandlers {
|
export interface VoiceEngineHandlers {
|
||||||
@@ -72,15 +72,28 @@ export class VoiceAudioEngine {
|
|||||||
await this.ngZone.runOutsideAngular(() => this.buildGraph(stream, handlers));
|
await this.ngZone.runOutsideAngular(() => this.buildGraph(stream, handlers));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.stop();
|
this.stop();
|
||||||
throw err instanceof Error && err.name === 'MicrophoneError' ? err : new VoiceEngineError('worklet-failed');
|
// Preserve the specific engine error (unsupported vs worklet-failed); only a raw
|
||||||
|
// failure inside buildGraph is a generic worklet failure.
|
||||||
|
if (err instanceof MicrophoneError || err instanceof VoiceEngineError) throw err;
|
||||||
|
throw new VoiceEngineError('worklet-failed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async buildGraph(stream: MediaStream, handlers: VoiceEngineHandlers): Promise<void> {
|
private async buildGraph(stream: MediaStream, handlers: VoiceEngineHandlers): Promise<void> {
|
||||||
const cfg = this.config;
|
const cfg = this.config;
|
||||||
const ctx = new AudioContext({ latencyHint: 'interactive' });
|
// The wire format is fixed at 24 kHz mono PCM16. Request that context rate so the
|
||||||
|
// native path needs no conversion, but browsers MAY ignore the request — read the real
|
||||||
|
// `ctx.sampleRate` below and let the worklets resample to/from the wire rate when it
|
||||||
|
// differs. Never assume the requested rate (SKILLS.md §3.2).
|
||||||
|
const ctx = new AudioContext({ latencyHint: 'interactive', sampleRate: cfg.outputSampleRate });
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
|
||||||
|
// Explicitly reject an unusable context rate: a 0/NaN/non-finite rate cannot resample
|
||||||
|
// and must fail safely instead of silently producing no playback.
|
||||||
|
if (!Number.isFinite(ctx.sampleRate) || ctx.sampleRate < 8000 || ctx.sampleRate > 192000) {
|
||||||
|
throw new VoiceEngineError('unsupported');
|
||||||
|
}
|
||||||
|
|
||||||
const base = cfg.workletBasePath.replace(/\/$/, '');
|
const base = cfg.workletBasePath.replace(/\/$/, '');
|
||||||
await ctx.audioWorklet.addModule(`${base}/pcm-capture.worklet.js`);
|
await ctx.audioWorklet.addModule(`${base}/pcm-capture.worklet.js`);
|
||||||
await ctx.audioWorklet.addModule(`${base}/pcm-playback.worklet.js`);
|
await ctx.audioWorklet.addModule(`${base}/pcm-playback.worklet.js`);
|
||||||
@@ -136,6 +149,22 @@ export class VoiceAudioEngine {
|
|||||||
this.analyserData = new Uint8Array(this.analyser.fftSize);
|
this.analyserData = new Uint8Array(this.analyser.fftSize);
|
||||||
this.playback.connect(this.analyser);
|
this.playback.connect(this.analyser);
|
||||||
this.analyser.connect(ctx.destination);
|
this.analyser.connect(ctx.destination);
|
||||||
|
|
||||||
|
this.logPipelineDiagnostics(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bounded development diagnostics — one line per session, numbers only. Confirms the
|
||||||
|
* ACTUAL context rate/state (not the requested one) and that the playback graph is
|
||||||
|
* connected and running. Never logs audio, transcripts, cookies or credentials.
|
||||||
|
*/
|
||||||
|
private logPipelineDiagnostics(ctx: AudioContext): void {
|
||||||
|
const requested = this.config.outputSampleRate;
|
||||||
|
const resample = ctx.sampleRate === requested ? 'none' : 'worklet';
|
||||||
|
console.info(
|
||||||
|
`VoiceAudioEngine: ctx.sampleRate=${ctx.sampleRate}Hz (requested ${requested}Hz) ` +
|
||||||
|
`state=${ctx.state} playbackGraph=connected resample=${resample}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- playback --------------------------------------------------------------
|
// ---- playback --------------------------------------------------------------
|
||||||
|
|||||||
@@ -33,9 +33,21 @@ const READY_EVENT: VoiceServerEvent = {
|
|||||||
output_audio: { encoding: 'pcm_s16le', sample_rate: 24000, channels: 1 },
|
output_audio: { encoding: 'pcm_s16le', sample_rate: 24000, channels: 1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const OVERFLOW_MESSAGE = 'حجم صدای در حال پخش از محدودهٔ مجاز گذشت و گفتگو بهطور ایمن پایان یافت.';
|
||||||
|
const SEND_OVERFLOW_MESSAGE = 'حجم صدای ارسالی از محدودهٔ مجاز گذشت و گفتگو بهطور ایمن پایان یافت.';
|
||||||
|
|
||||||
/** Flush pending microtasks/timers so the service reaches a stable await point. */
|
/** Flush pending microtasks/timers so the service reaches a stable await point. */
|
||||||
const flush = (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 5));
|
const flush = (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 5));
|
||||||
|
|
||||||
|
type Mock = ReturnType<typeof vi.fn>;
|
||||||
|
type TransportMock = Omit<VoiceTransport, 'connect' | 'sendAudio' | 'sendControl' | 'close'> & {
|
||||||
|
handlers: VoiceTransportHandlers | null;
|
||||||
|
connect: Mock;
|
||||||
|
sendAudio: Mock;
|
||||||
|
sendControl: Mock;
|
||||||
|
close: Mock;
|
||||||
|
};
|
||||||
|
|
||||||
describe('VoiceStreamService (backend handoff contract)', () => {
|
describe('VoiceStreamService (backend handoff contract)', () => {
|
||||||
let service: VoiceStreamService;
|
let service: VoiceStreamService;
|
||||||
let api: {
|
let api: {
|
||||||
@@ -51,12 +63,15 @@ describe('VoiceStreamService (backend handoff contract)', () => {
|
|||||||
let engineHandlers: VoiceEngineHandlers | null;
|
let engineHandlers: VoiceEngineHandlers | null;
|
||||||
let transportHandlers: VoiceTransportHandlers | null;
|
let transportHandlers: VoiceTransportHandlers | null;
|
||||||
let controls: PlaybackProgressMessage[];
|
let controls: PlaybackProgressMessage[];
|
||||||
|
let transportMock: TransportMock;
|
||||||
|
let engineStop: ReturnType<typeof vi.fn>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
engineHandlers = null;
|
engineHandlers = null;
|
||||||
transportHandlers = null;
|
transportHandlers = null;
|
||||||
controls = [];
|
controls = [];
|
||||||
|
engineStop = vi.fn();
|
||||||
|
|
||||||
api = {
|
api = {
|
||||||
me: vi.fn().mockResolvedValue(ME),
|
me: vi.fn().mockResolvedValue(ME),
|
||||||
@@ -69,7 +84,7 @@ describe('VoiceStreamService (backend handoff contract)', () => {
|
|||||||
streamUrl: vi.fn().mockReturnValue('wss://ui.local/api/v1/voice/sessions/ses-1/stream'),
|
streamUrl: vi.fn().mockReturnValue('wss://ui.local/api/v1/voice/sessions/ses-1/stream'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const transportMock: VoiceTransport & { handlers: VoiceTransportHandlers | null } = {
|
transportMock = {
|
||||||
handlers: null,
|
handlers: null,
|
||||||
connect: vi.fn().mockImplementation((handlers: VoiceTransportHandlers) => {
|
connect: vi.fn().mockImplementation((handlers: VoiceTransportHandlers) => {
|
||||||
transportHandlers = handlers;
|
transportHandlers = handlers;
|
||||||
@@ -95,7 +110,7 @@ describe('VoiceStreamService (backend handoff contract)', () => {
|
|||||||
engineHandlers = handlers;
|
engineHandlers = handlers;
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}),
|
}),
|
||||||
stop: vi.fn(),
|
stop: engineStop,
|
||||||
setMuted: vi.fn(),
|
setMuted: vi.fn(),
|
||||||
enqueuePlayback: vi.fn(),
|
enqueuePlayback: vi.fn(),
|
||||||
clearPlayback: vi.fn(),
|
clearPlayback: vi.fn(),
|
||||||
@@ -228,10 +243,73 @@ describe('VoiceStreamService (backend handoff contract)', () => {
|
|||||||
|
|
||||||
engineHandlers?.onPlaybackOverflow();
|
engineHandlers?.onPlaybackOverflow();
|
||||||
|
|
||||||
expect(await ended).toBe('حجم صدای در حال پخش از محدودهٔ مجاز گذشت و گفتگو بهطور ایمن پایان یافت.');
|
expect(await ended).toBe(OVERFLOW_MESSAGE);
|
||||||
expect(service.connection()).toBe('disconnected');
|
expect(service.connection()).toBe('disconnected');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('uses a distinct message for capture/send overflow vs playback overflow', async () => {
|
||||||
|
await startConnected();
|
||||||
|
const ended = firstEndedError();
|
||||||
|
|
||||||
|
transportHandlers?.onOverflow('send');
|
||||||
|
|
||||||
|
expect(await ended).toBe(SEND_OVERFLOW_MESSAGE);
|
||||||
|
expect(await ended).not.toBe(OVERFLOW_MESSAGE);
|
||||||
|
expect(service.connection()).toBe('disconnected');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('concurrent overflow + socket close + Stop send one /close and one teardown', async () => {
|
||||||
|
await startConnected();
|
||||||
|
const ended = firstEndedError();
|
||||||
|
|
||||||
|
// Several end triggers race for the same session (the reported live failure).
|
||||||
|
engineHandlers?.onPlaybackOverflow(); // 1st → overflow error
|
||||||
|
engineHandlers?.onPlaybackOverflow(); // duplicate
|
||||||
|
transportHandlers?.onClose({ clean: false, code: 1006, reason: '' }); // socket close
|
||||||
|
service.end(); // manual Stop
|
||||||
|
|
||||||
|
expect(await ended).toBe(OVERFLOW_MESSAGE); // first meaningful error preserved
|
||||||
|
expect(api.closeVoiceSession).toHaveBeenCalledTimes(1); // V04 sent exactly once
|
||||||
|
expect(transportMock.close).toHaveBeenCalledTimes(1); // socket released once
|
||||||
|
expect(engineStop).toHaveBeenCalledTimes(1); // audio graph released once
|
||||||
|
expect(service.connection()).toBe('disconnected');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('releases local resources even when V04 /close fails', async () => {
|
||||||
|
await startConnected();
|
||||||
|
api.closeVoiceSession.mockRejectedValueOnce(new Error('V04 boom'));
|
||||||
|
|
||||||
|
await service.close();
|
||||||
|
|
||||||
|
expect(api.closeVoiceSession).toHaveBeenCalledTimes(1);
|
||||||
|
expect(transportMock.close).toHaveBeenCalledTimes(1);
|
||||||
|
expect(engineStop).toHaveBeenCalledTimes(1);
|
||||||
|
expect(service.connection()).toBe('disconnected');
|
||||||
|
expect(sessionStorage.getItem('voice_creation_attempt')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores stale callbacks: an old session cannot close or affect a new one', async () => {
|
||||||
|
await startConnected(); // session A
|
||||||
|
await service.close();
|
||||||
|
api.closeVoiceSession.mockClear();
|
||||||
|
engineStop.mockClear();
|
||||||
|
transportMock.close.mockClear();
|
||||||
|
|
||||||
|
// Late callbacks captured for session A arrive after A already ended.
|
||||||
|
engineHandlers?.onPlaybackOverflow();
|
||||||
|
transportHandlers?.onClose({ clean: false, code: 1006, reason: '' });
|
||||||
|
await flush();
|
||||||
|
expect(api.closeVoiceSession).not.toHaveBeenCalled();
|
||||||
|
expect(service.connection()).toBe('disconnected');
|
||||||
|
|
||||||
|
// A brand-new session is independent and closes exactly once on its own.
|
||||||
|
await startConnected(); // session B
|
||||||
|
expect(service.connection()).toBe('connected');
|
||||||
|
api.closeVoiceSession.mockClear();
|
||||||
|
await service.close();
|
||||||
|
expect(api.closeVoiceSession).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('requires a fresh conversation after CONTEXT_REVOKED and drops the old attempt', async () => {
|
it('requires a fresh conversation after CONTEXT_REVOKED and drops the old attempt', async () => {
|
||||||
await startConnected();
|
await startConnected();
|
||||||
const ended = firstEndedError();
|
const ended = firstEndedError();
|
||||||
|
|||||||
@@ -32,6 +32,29 @@ type TranscriptEvent = Extract<VoiceServerEvent, { type: 'transcript' }>;
|
|||||||
type SourcesEvent = Extract<VoiceServerEvent, { type: 'sources' }>;
|
type SourcesEvent = Extract<VoiceServerEvent, { type: 'sources' }>;
|
||||||
type ErrorEvent = Extract<VoiceServerEvent, { type: 'error' }>;
|
type ErrorEvent = Extract<VoiceServerEvent, { type: 'error' }>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for the single per-session cleanup (`teardown`). One cleanup runs per session and
|
||||||
|
* is shared by overflow, server error, socket close, manual Stop, unmount and start aborts.
|
||||||
|
*/
|
||||||
|
interface TeardownOptions {
|
||||||
|
/** User-facing (Persian) failure message carried on sessionEnded$. */
|
||||||
|
error?: string;
|
||||||
|
/** Machine-readable cause (e.g. `ws close 1006`) carried on sessionEnded$. */
|
||||||
|
detail?: string;
|
||||||
|
/**
|
||||||
|
* Intentional stop: final progress → V04 → release, the order the contract requires.
|
||||||
|
* `false` (default) releases local resources immediately and sends V04 best-effort —
|
||||||
|
* used for unmount / start-abort / page-leave, where instant release matters more.
|
||||||
|
*/
|
||||||
|
ordered?: boolean;
|
||||||
|
/** Send V04 /close for this session (default true). */
|
||||||
|
closeRemote?: boolean;
|
||||||
|
/** Emit sessionEnded$ if the call reached connected (default true). */
|
||||||
|
emitEnded?: boolean;
|
||||||
|
/** Keep the persisted creation attempt (ambiguous reserve / page-leave). Default false. */
|
||||||
|
keepAttempt?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
const MESSAGES = {
|
const MESSAGES = {
|
||||||
unsupported: 'گفتگوی صوتی در این مرورگر پشتیبانی نمیشود (اتصال امن HTTPS و مرورگر جدید لازم است).',
|
unsupported: 'گفتگوی صوتی در این مرورگر پشتیبانی نمیشود (اتصال امن HTTPS و مرورگر جدید لازم است).',
|
||||||
micDenied: 'دسترسی به میکروفون رد شد. اجازهی دسترسی را در تنظیمات مرورگر فعال کنید.',
|
micDenied: 'دسترسی به میکروفون رد شد. اجازهی دسترسی را در تنظیمات مرورگر فعال کنید.',
|
||||||
@@ -47,6 +70,7 @@ const MESSAGES = {
|
|||||||
connect: 'اتصال به سرور صوتی برقرار نشد. دوباره تلاش کنید.',
|
connect: 'اتصال به سرور صوتی برقرار نشد. دوباره تلاش کنید.',
|
||||||
badFormat: 'فرمت صدای سرور با برنامه سازگار نیست.',
|
badFormat: 'فرمت صدای سرور با برنامه سازگار نیست.',
|
||||||
overflow: 'حجم صدای در حال پخش از محدودهٔ مجاز گذشت و گفتگو بهطور ایمن پایان یافت.',
|
overflow: 'حجم صدای در حال پخش از محدودهٔ مجاز گذشت و گفتگو بهطور ایمن پایان یافت.',
|
||||||
|
sendOverflow: 'حجم صدای ارسالی از محدودهٔ مجاز گذشت و گفتگو بهطور ایمن پایان یافت.',
|
||||||
disconnected: 'ارتباط با سرور قطع شد و گفتگو پایان یافت.',
|
disconnected: 'ارتباط با سرور قطع شد و گفتگو پایان یافت.',
|
||||||
server: 'سرور گفتگوی صوتی با خطا مواجه شد.',
|
server: 'سرور گفتگوی صوتی با خطا مواجه شد.',
|
||||||
contextRevoked: 'محتوای دانش تغییر کرده و مکالمهٔ قبلی دیگر معتبر نیست. گفتگوی جدیدی شروع کنید.',
|
contextRevoked: 'محتوای دانش تغییر کرده و مکالمهٔ قبلی دیگر معتبر نیست. گفتگوی جدیدی شروع کنید.',
|
||||||
@@ -60,6 +84,8 @@ const INTERRUPTED_FLASH_MS = 150;
|
|||||||
const ERROR_BANNER_MS = 6000;
|
const ERROR_BANNER_MS = 6000;
|
||||||
/** Longest wait for the worklet's final playback report when closing a call. */
|
/** Longest wait for the worklet's final playback report when closing a call. */
|
||||||
const FINAL_PROGRESS_WAIT_MS = 300;
|
const FINAL_PROGRESS_WAIT_MS = 300;
|
||||||
|
/** Longest wait for V04 /close before releasing local resources anyway (the POST keeps running). */
|
||||||
|
const CLOSE_WAIT_MS = 3000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One live voice call against the backend handoff contract (§7–§9):
|
* One live voice call against the backend handoff contract (§7–§9):
|
||||||
@@ -106,6 +132,8 @@ export class VoiceStreamService {
|
|||||||
|
|
||||||
private transport: VoiceTransport | null = null;
|
private transport: VoiceTransport | null = null;
|
||||||
private remote: { sessionId: string; conversationId: string; csrf: string } | null = null;
|
private remote: { sessionId: string; conversationId: string; csrf: string } | null = null;
|
||||||
|
/** Single-flight guard: at most one cleanup runs per active session (one /close each). */
|
||||||
|
private cleanupPromise: Promise<void> | null = null;
|
||||||
private session = 0;
|
private session = 0;
|
||||||
private streaming = false;
|
private streaming = false;
|
||||||
private turnEnded = false;
|
private turnEnded = false;
|
||||||
@@ -149,6 +177,7 @@ export class VoiceStreamService {
|
|||||||
this.messages.set([]);
|
this.messages.set([]);
|
||||||
this.muted.set(false);
|
this.muted.set(false);
|
||||||
this.clearError();
|
this.clearError();
|
||||||
|
this.cleanupPromise = null;
|
||||||
this.resetTurnFlags();
|
this.resetTurnFlags();
|
||||||
this.lastConversationId = null;
|
this.lastConversationId = null;
|
||||||
this.currentAudioRef = null;
|
this.currentAudioRef = null;
|
||||||
@@ -221,8 +250,14 @@ export class VoiceStreamService {
|
|||||||
transport.connect({
|
transport.connect({
|
||||||
onEvent: (event) => this.ngZone.run(() => this.onServerEvent(event, session)),
|
onEvent: (event) => this.ngZone.run(() => this.onServerEvent(event, session)),
|
||||||
onAudio: (chunk) => this.onServerAudio(chunk, session),
|
onAudio: (chunk) => this.onServerAudio(chunk, session),
|
||||||
onClose: () => this.ngZone.run(() => this.failSession(MESSAGES.disconnected, session)),
|
onClose: (info) =>
|
||||||
onOverflow: () => this.ngZone.run(() => this.failSession(MESSAGES.overflow, session)),
|
this.ngZone.run(() => this.failSession(MESSAGES.disconnected, session, this.describeSocketClose(info))),
|
||||||
|
onOverflow: (which) =>
|
||||||
|
this.ngZone.run(() =>
|
||||||
|
// Playback queue overflow and capture/send overflow are different faults with
|
||||||
|
// different causes; give each its own message instead of one shared string.
|
||||||
|
this.failSession(which === 'send' ? MESSAGES.sendOverflow : MESSAGES.overflow, session),
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
@@ -262,39 +297,21 @@ export class VoiceStreamService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intentional close: final playback progress for the active audio_ref, then V04, and
|
* Intentional close: routes through the single per-session cleanup so final progress →
|
||||||
* only then the socket/audio teardown — the order required by the contract.
|
* V04 /close → release happens exactly once and in the order the contract requires.
|
||||||
|
* Concurrent callers (overflow / error / socket close / another Stop) reuse the same
|
||||||
|
* cleanup and cannot send a second /close or a second teardown.
|
||||||
*/
|
*/
|
||||||
async close(options: { error?: string } = {}): Promise<void> {
|
async close(options: { error?: string; detail?: string } = {}): Promise<void> {
|
||||||
if (!this.isOpen()) {
|
// Idle with no cleanup in flight: nothing to close. A persisted creation attempt from
|
||||||
// Idle: nothing to close. A persisted creation attempt from an ambiguous reserve
|
// an ambiguous reserve outcome is kept so the next start() reconciles it, not duplicates.
|
||||||
// outcome is kept so the next start() reconciles it instead of duplicating it.
|
if (this.connection() === 'disconnected' && !this.cleanupPromise) return;
|
||||||
return;
|
await this.teardown({
|
||||||
}
|
ordered: true,
|
||||||
const remote = this.remote;
|
closeRemote: true,
|
||||||
// 1) final, worklet-computed playback progress for the ref that is still playing
|
error: options.error,
|
||||||
await this.reportFinalProgress();
|
detail: options.detail,
|
||||||
// 2) V04 before the transport closes
|
});
|
||||||
if (remote) {
|
|
||||||
try {
|
|
||||||
await this.api.closeVoiceSession(remote.csrf, remote.sessionId);
|
|
||||||
} catch {
|
|
||||||
/* the session may already be closed/expired (e.g. 409 LIVE_SESSION_UNUSABLE) */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 3) release mic, worklets, AudioContext and the WebSocket
|
|
||||||
const wasConnected = this.connection() === 'connected';
|
|
||||||
const conversationId = this.remote?.conversationId ?? this.lastConversationId;
|
|
||||||
// Invalidate pending async work BEFORE resolving the session_ready waiter, so a
|
|
||||||
// start() still waiting sees a cancelled session instead of a connect failure.
|
|
||||||
this.session++;
|
|
||||||
this.rejectReady();
|
|
||||||
this.finalizeAll();
|
|
||||||
const messages = this.messages();
|
|
||||||
this.teardown();
|
|
||||||
if (wasConnected) {
|
|
||||||
this.sessionEnded$.next({ conversationId, messages, error: options.error });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -366,7 +383,7 @@ export class VoiceStreamService {
|
|||||||
dispose(): void {
|
dispose(): void {
|
||||||
this.rejectReady();
|
this.rejectReady();
|
||||||
if (!this.isOpen()) return; // keep an ambiguous attempt for reconciliation
|
if (!this.isOpen()) return; // keep an ambiguous attempt for reconciliation
|
||||||
this.teardown();
|
void this.teardown({ ordered: false, closeRemote: true, emitEnded: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- audio from the microphone (outside the zone) --------------------------
|
// ---- audio from the microphone (outside the zone) --------------------------
|
||||||
@@ -533,7 +550,10 @@ export class VoiceStreamService {
|
|||||||
|
|
||||||
private onServerError(event: ErrorEvent, session: number): void {
|
private onServerError(event: ErrorEvent, session: number): void {
|
||||||
const { message, retryable, code } = event.error;
|
const { message, retryable, code } = event.error;
|
||||||
console.warn('VoiceStreamService: server error', code, event.error.request_id);
|
// The server's `error` frame is the direct cause of a session ending here: below it
|
||||||
|
// drives failSession → V04 /close. `code` + `request_id` alone hide the message and
|
||||||
|
// any extra details, so log the whole frame.
|
||||||
|
console.warn('VoiceStreamService: server error frame', event.error);
|
||||||
|
|
||||||
// The old conversation/session is no longer usable: the user must start a fresh one
|
// The old conversation/session is no longer usable: the user must start a fresh one
|
||||||
// (Gemini interruption can also require ending the session entirely).
|
// (Gemini interruption can also require ending the session entirely).
|
||||||
@@ -547,7 +567,7 @@ export class VoiceStreamService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!retryable) {
|
if (!retryable) {
|
||||||
this.failSession(message || MESSAGES.server, session);
|
this.failSession(message || MESSAGES.server, session, `server error ${code}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,11 +713,29 @@ export class VoiceStreamService {
|
|||||||
|
|
||||||
// ---- lifecycle -------------------------------------------------------------
|
// ---- lifecycle -------------------------------------------------------------
|
||||||
|
|
||||||
private failSession(message: string, session: number): void {
|
/**
|
||||||
|
* The `CloseEvent` on the WebSocket carries the server's code and reason. Dropping it
|
||||||
|
* (as this handler used to) leaves a generic "disconnected" banner and no clue why the
|
||||||
|
* stream died, so the cause of an early disconnect cannot be diagnosed at all.
|
||||||
|
*
|
||||||
|
* Codes that matter in practice: 1000 = server ended the call normally, 1006 = the
|
||||||
|
* connection dropped with no close frame (proxy/network), 1008/1009 = policy violation
|
||||||
|
* (the server rejected a frame we sent), 1011 = server-side error.
|
||||||
|
*/
|
||||||
|
private describeSocketClose(info: { clean: boolean; code: number; reason: string }): string {
|
||||||
|
const reason = info.reason ? ` reason="${info.reason}"` : '';
|
||||||
|
const detail = `ws close ${info.code}${info.clean ? ' (clean)' : ''}${reason}`;
|
||||||
|
console.warn(`VoiceStreamService: socket closed — ${detail}`);
|
||||||
|
return detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
private failSession(message: string, session: number, detail?: string): void {
|
||||||
if (session !== this.session || !this.isOpen()) return;
|
if (session !== this.session || !this.isOpen()) return;
|
||||||
// `close()` performs the ordered teardown (final progress → V04 → transport) and
|
// `close()` runs the ordered single-flight cleanup (final progress → V04 → release)
|
||||||
// emits sessionEnded$ exactly once, carrying the failure message.
|
// and emits sessionEnded$ exactly once, carrying the first meaningful failure. The
|
||||||
void this.close({ error: message });
|
// `session`/isOpen guard above drops stale callbacks so an old session never ends a
|
||||||
|
// newer one.
|
||||||
|
void this.close({ error: message, detail });
|
||||||
}
|
}
|
||||||
|
|
||||||
private abortStart(
|
private abortStart(
|
||||||
@@ -705,44 +743,130 @@ export class VoiceStreamService {
|
|||||||
failure: { reason: VoiceStartFailure; message: string },
|
failure: { reason: VoiceStartFailure; message: string },
|
||||||
keepAttempt = false,
|
keepAttempt = false,
|
||||||
): VoiceStartResult {
|
): VoiceStartResult {
|
||||||
if (session === this.session) this.teardown({ keepAttempt });
|
// Start-only failure: release immediately (unmount-style) and best-effort V04 for any
|
||||||
|
// reservation that was made. Keep the attempt when it was an ambiguous reserve so the
|
||||||
|
// next start() reconciles it with the same ids instead of duplicating.
|
||||||
|
if (session === this.session) void this.teardown({ ordered: false, closeRemote: true, keepAttempt });
|
||||||
return this.failure(failure.reason, failure.message);
|
return this.failure(failure.reason, failure.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Releases every resource; idempotent. Invalidates all pending async work via `session`. */
|
/**
|
||||||
private teardown(options: { keepAttempt?: boolean } = {}): void {
|
* The ONE cleanup per session. Every end path funnels through here: overflow, server
|
||||||
this.session++;
|
* error, socket close, manual Stop, unmount, page-leave and start-abort. It is
|
||||||
|
* single-flight (`cleanupPromise`) so concurrent triggers share one pass — one /close and
|
||||||
|
* one resource release — and it marks the session stopping before any await, so stale
|
||||||
|
* callbacks cannot end a newer session.
|
||||||
|
*/
|
||||||
|
private teardown(options: TeardownOptions = {}): Promise<void> {
|
||||||
|
const existing = this.cleanupPromise;
|
||||||
|
if (existing) return existing; // a cleanup for the active session is already running
|
||||||
|
const promise = this.performTeardown(this.session, options).finally(() => {
|
||||||
|
if (this.cleanupPromise === promise) this.cleanupPromise = null;
|
||||||
|
});
|
||||||
|
this.cleanupPromise = promise;
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async performTeardown(session: number, options: TeardownOptions): Promise<void> {
|
||||||
|
const wasConnected = this.connection() === 'connected';
|
||||||
|
const conversationId = this.remote?.conversationId ?? this.lastConversationId;
|
||||||
|
const remote = this.remote;
|
||||||
|
const superseded = (): boolean => this.session !== session + 1;
|
||||||
|
|
||||||
|
// Stop admitting new media BEFORE any await.
|
||||||
this.streaming = false;
|
this.streaming = false;
|
||||||
this.resetTurnFlags();
|
|
||||||
this.clearSettleTimer();
|
const release = (): void => {
|
||||||
this.clearError();
|
// A newer session may have taken over during an await: never touch its resources.
|
||||||
this.resolveProgressWaiters();
|
if (superseded()) return;
|
||||||
this.currentAudioRef = null;
|
this.releaseLocal(options);
|
||||||
if (this.interruptTimer) {
|
};
|
||||||
clearTimeout(this.interruptTimer);
|
|
||||||
this.interruptTimer = null;
|
/** Drop all pending async work and supersede this session, so late callbacks are stale. */
|
||||||
|
const invalidate = (): void => {
|
||||||
|
if (this.session === session) this.session = session + 1;
|
||||||
|
this.resetTurnFlags();
|
||||||
|
this.rejectReady();
|
||||||
|
this.resolveProgressWaiters();
|
||||||
|
this.clearSettleTimer();
|
||||||
|
if (this.interruptTimer) {
|
||||||
|
clearTimeout(this.interruptTimer);
|
||||||
|
this.interruptTimer = null;
|
||||||
|
}
|
||||||
|
this.currentAudioRef = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.ordered) {
|
||||||
|
try {
|
||||||
|
// 1) final playback progress (bounded) — still needs ref + connected transport.
|
||||||
|
await this.reportFinalProgress();
|
||||||
|
// 2) supersede the session, then V04 /close (bounded), then 3) release.
|
||||||
|
invalidate();
|
||||||
|
if (options.closeRemote !== false && remote) {
|
||||||
|
await this.withTimeout(this.api.closeVoiceSession(remote.csrf, remote.sessionId), CLOSE_WAIT_MS);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* the session may already be closed/expired (e.g. 409 LIVE_SESSION_UNUSABLE) */
|
||||||
|
} finally {
|
||||||
|
if (options.ordered) this.finalizeAll();
|
||||||
|
release();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Unmount / start-abort / page-leave: invalidate + release immediately, then send V04
|
||||||
|
// best-effort in the background (it may not finish while the page is unloading).
|
||||||
|
invalidate();
|
||||||
|
release();
|
||||||
|
if (options.closeRemote !== false && remote) {
|
||||||
|
this.api.closeVoiceSession(remote.csrf, remote.sessionId).catch(() => {
|
||||||
|
/* already closed / expired: nothing to do */
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.ordered && options.emitEnded !== false && wasConnected && !superseded()) {
|
||||||
|
this.sessionEnded$.next({
|
||||||
|
conversationId,
|
||||||
|
messages: this.messages(),
|
||||||
|
error: options.error,
|
||||||
|
detail: options.detail,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Cancellable wait: resolve when `work` settles or after `ms`, whichever is first. The underlying request is left to finish. */
|
||||||
|
private withTimeout<T>(work: Promise<T>, ms: number): Promise<T | undefined> {
|
||||||
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
const timedOut = new Promise<undefined>((resolve) => {
|
||||||
|
timer = setTimeout(() => resolve(undefined), ms);
|
||||||
|
});
|
||||||
|
return Promise.race([work.catch((): undefined => undefined), timedOut]).finally(() =>
|
||||||
|
clearTimeout(timer),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Release mic, worklets, AudioContext, socket and timers. Runs even if V04 failed. */
|
||||||
|
private releaseLocal(options: TeardownOptions): void {
|
||||||
const transport = this.transport;
|
const transport = this.transport;
|
||||||
this.transport = null;
|
this.transport = null;
|
||||||
transport?.close();
|
transport?.close();
|
||||||
this.engine.stop();
|
this.engine.stop();
|
||||||
|
|
||||||
// The reservation is over: drop the attempt so the next start() mints fresh request ids —
|
|
||||||
// unless an ambiguous reserve failure still needs the same ids replayed/reconciled.
|
|
||||||
const remote = this.remote;
|
|
||||||
this.remote = null;
|
this.remote = null;
|
||||||
|
this.streaming = false;
|
||||||
|
// The reservation is over: drop the attempt so the next start() mints fresh request ids —
|
||||||
|
// unless an ambiguous reserve / page-leave still needs the same ids replayed/reconciled.
|
||||||
if (!options.keepAttempt) {
|
if (!options.keepAttempt) {
|
||||||
this.attempt = null;
|
this.attempt = null;
|
||||||
clearPersistedAttempt();
|
clearPersistedAttempt();
|
||||||
}
|
}
|
||||||
if (remote) this.closeRemote(remote);
|
|
||||||
|
|
||||||
|
this.clearError();
|
||||||
this.connection.set('disconnected');
|
this.connection.set('disconnected');
|
||||||
this.state.set('IDLE');
|
this.state.set('IDLE');
|
||||||
this.muted.set(false);
|
this.muted.set(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Best-effort one-off V04 for a reservation produced by a start() that was just superseded. */
|
||||||
private closeRemote(remote: { sessionId: string; csrf: string }): void {
|
private closeRemote(remote: { sessionId: string; csrf: string }): void {
|
||||||
this.api.closeVoiceSession(remote.csrf, remote.sessionId).catch(() => {
|
this.api.closeVoiceSession(remote.csrf, remote.sessionId).catch(() => {
|
||||||
/* already closed / expired (e.g. 409 LIVE_SESSION_UNUSABLE): nothing to do */
|
/* already closed / expired (e.g. 409 LIVE_SESSION_UNUSABLE): nothing to do */
|
||||||
@@ -751,19 +875,9 @@ export class VoiceStreamService {
|
|||||||
|
|
||||||
private onPageLeave = (): void => {
|
private onPageLeave = (): void => {
|
||||||
if (!this.isOpen()) return;
|
if (!this.isOpen()) return;
|
||||||
const transport = this.transport;
|
|
||||||
const remote = this.remote;
|
|
||||||
this.session++;
|
|
||||||
this.streaming = false;
|
|
||||||
this.transport = null;
|
|
||||||
transport?.close();
|
|
||||||
this.engine.stop();
|
|
||||||
this.remote = null;
|
|
||||||
if (remote) this.closeRemote(remote);
|
|
||||||
// The attempt id/path stay in sessionStorage on purpose: the next page load reconciles
|
// The attempt id/path stay in sessionStorage on purpose: the next page load reconciles
|
||||||
// it with V02/V03 (V04 may not complete while unloading) before anything else.
|
// it with V02/V03 (V04 may not complete while unloading) before anything else.
|
||||||
this.connection.set('disconnected');
|
void this.teardown({ ordered: false, closeRemote: true, keepAttempt: true, emitEnded: false });
|
||||||
this.state.set('IDLE');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private resetTurnFlags(): void {
|
private resetTurnFlags(): void {
|
||||||
|
|||||||
@@ -100,6 +100,12 @@ export interface VoiceSessionEnd {
|
|||||||
messages: VoiceMessage[];
|
messages: VoiceMessage[];
|
||||||
/** User-facing (Persian) message when the session ended because of a failure. */
|
/** User-facing (Persian) message when the session ended because of a failure. */
|
||||||
error?: string;
|
error?: string;
|
||||||
|
/**
|
||||||
|
* Machine-readable cause for logs/diagnostics, e.g. `ws close 1006 reason="…"`.
|
||||||
|
* The server's close code/reason says why the socket died; without it the only
|
||||||
|
* thing surfaced is a generic "disconnected" banner and the root cause is invisible.
|
||||||
|
*/
|
||||||
|
detail?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** V02/V03 polling shape (safe diagnostics only). */
|
/** V02/V03 polling shape (safe diagnostics only). */
|
||||||
@@ -128,7 +134,7 @@ export interface VoiceStreamConfig {
|
|||||||
|
|
||||||
export const DEFAULT_VOICE_STREAM_CONFIG: VoiceStreamConfig = {
|
export const DEFAULT_VOICE_STREAM_CONFIG: VoiceStreamConfig = {
|
||||||
apiBase: '/api/v1',
|
apiBase: '/api/v1',
|
||||||
apiOrigin: 'http://10.0.8.51:1322',
|
apiOrigin: '',
|
||||||
inputSampleRate: 24000,
|
inputSampleRate: 24000,
|
||||||
outputSampleRate: 24000,
|
outputSampleRate: 24000,
|
||||||
frameMs: 20,
|
frameMs: 20,
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ const MAX_QUEUE_MESSAGES = 100;
|
|||||||
* Plain WebSocket. Authentication is the `rag_session` cookie sent automatically on the
|
* Plain WebSocket. Authentication is the `rag_session` cookie sent automatically on the
|
||||||
* handshake, so the page is served from the same origin as the API (same-origin `/api`
|
* handshake, so the page is served from the same origin as the API (same-origin `/api`
|
||||||
* proxy). The contract has exactly one client→server JSON message: `playback_progress`.
|
* proxy). The contract has exactly one client→server JSON message: `playback_progress`.
|
||||||
|
*
|
||||||
|
* Diagnostics: every control frame received is kept in a short ring buffer and dumped when
|
||||||
|
* the socket dies, so the server's last message — normally an `error` frame carrying the
|
||||||
|
* real cause — is in the console instead of leaving only a bare close code.
|
||||||
*/
|
*/
|
||||||
export class WebSocketVoiceTransport implements VoiceTransport {
|
export class WebSocketVoiceTransport implements VoiceTransport {
|
||||||
private ws: WebSocket | null = null;
|
private ws: WebSocket | null = null;
|
||||||
@@ -41,6 +45,11 @@ export class WebSocketVoiceTransport implements VoiceTransport {
|
|||||||
private sendQueue: ArrayBuffer[] = [];
|
private sendQueue: ArrayBuffer[] = [];
|
||||||
private sendQueuedBytes = 0;
|
private sendQueuedBytes = 0;
|
||||||
private sendQueuedMessages = 0;
|
private sendQueuedMessages = 0;
|
||||||
|
/** Recent server control frames (newest last), replayed when the socket closes. */
|
||||||
|
private readonly recentFrames: string[] = [];
|
||||||
|
|
||||||
|
/** How many recent control frames to keep for a disconnect dump. */
|
||||||
|
private static readonly FRAME_TRACE_LIMIT = 12;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly url: string,
|
private readonly url: string,
|
||||||
@@ -70,11 +79,15 @@ export class WebSocketVoiceTransport implements VoiceTransport {
|
|||||||
|
|
||||||
ws.onmessage = (event: MessageEvent) => {
|
ws.onmessage = (event: MessageEvent) => {
|
||||||
if (typeof event.data === 'string') {
|
if (typeof event.data === 'string') {
|
||||||
|
let parsed: VoiceServerEvent | null = null;
|
||||||
try {
|
try {
|
||||||
handlers.onEvent(JSON.parse(event.data) as VoiceServerEvent);
|
parsed = JSON.parse(event.data) as VoiceServerEvent;
|
||||||
} catch {
|
} catch {
|
||||||
/* ignore malformed control frames */
|
/* ignore malformed control frames */
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
this.traceFrame(parsed);
|
||||||
|
handlers.onEvent(parsed);
|
||||||
} else if (event.data instanceof ArrayBuffer) {
|
} else if (event.data instanceof ArrayBuffer) {
|
||||||
handlers.onAudio(event.data);
|
handlers.onAudio(event.data);
|
||||||
}
|
}
|
||||||
@@ -84,7 +97,12 @@ export class WebSocketVoiceTransport implements VoiceTransport {
|
|||||||
if (!opened) {
|
if (!opened) {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
reject(new Error('connect-failed'));
|
reject(new Error('connect-failed'));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
// After the handshake a bare Event carries no detail; the `onclose` that follows
|
||||||
|
// has the code/reason. Log it anyway so the disconnect sequence is visible in the
|
||||||
|
// console instead of looking like a silent socket death.
|
||||||
|
console.warn('WebSocketVoiceTransport: socket error after open');
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onclose = (event: CloseEvent) => {
|
ws.onclose = (event: CloseEvent) => {
|
||||||
@@ -95,6 +113,7 @@ export class WebSocketVoiceTransport implements VoiceTransport {
|
|||||||
}
|
}
|
||||||
this.dropSendQueue();
|
this.dropSendQueue();
|
||||||
if (!this.closedByClient) {
|
if (!this.closedByClient) {
|
||||||
|
this.logDisconnect(event);
|
||||||
handlers.onClose({ clean: event.wasClean, code: event.code, reason: event.reason });
|
handlers.onClose({ clean: event.wasClean, code: event.code, reason: event.reason });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -150,6 +169,54 @@ export class WebSocketVoiceTransport implements VoiceTransport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keep a bounded trace of incoming control frames, and log an `error` frame verbatim —
|
||||||
|
* it is the server telling us why the call is about to end, and it is invisible unless
|
||||||
|
* something prints it.
|
||||||
|
*/
|
||||||
|
private traceFrame(event: VoiceServerEvent): void {
|
||||||
|
const type = event?.type;
|
||||||
|
if (type === 'error') {
|
||||||
|
console.warn('WebSocketVoiceTransport: server sent error frame', event);
|
||||||
|
this.recentFrames.push('error ' + WebSocketVoiceTransport.summarize(event));
|
||||||
|
} else {
|
||||||
|
this.recentFrames.push(WebSocketVoiceTransport.summarize(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.recentFrames.length > WebSocketVoiceTransport.FRAME_TRACE_LIMIT) {
|
||||||
|
this.recentFrames.shift();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Everything the backend asks for when a disconnect is reported: the close code/reason
|
||||||
|
* plus the frames that led up to it, newest first.
|
||||||
|
*/
|
||||||
|
private logDisconnect(event: CloseEvent): void {
|
||||||
|
const frames = [...this.recentFrames].reverse();
|
||||||
|
console.warn(
|
||||||
|
`WebSocketVoiceTransport: socket closed — code=${event.code} ` +
|
||||||
|
`clean=${event.wasClean} reason="${event.reason}"` +
|
||||||
|
(frames.length ? `\n last server frames (newest first):\n ${frames.join('\n ')}` : ''),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One compact line per control frame; errors are printed in full by traceFrame. */
|
||||||
|
private static summarize(event: VoiceServerEvent): string {
|
||||||
|
const type = event?.type ?? 'unknown';
|
||||||
|
if (type === 'transcript') {
|
||||||
|
const t = event as { status?: string; text?: string };
|
||||||
|
return `transcript[${t.status ?? '?'}] ${(t.text ?? '').slice(0, 80)}`;
|
||||||
|
}
|
||||||
|
if (type === 'audio_started' || type === 'audio_ended') {
|
||||||
|
return `${type} ${(event as { audio_ref?: string }).audio_ref ?? ''}`.trim();
|
||||||
|
}
|
||||||
|
if (type === 'error') {
|
||||||
|
return JSON.stringify(event);
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
private flushSendQueue(): void {
|
private flushSendQueue(): void {
|
||||||
const ws = this.ws;
|
const ws = this.ws;
|
||||||
const queue = this.sendQueue;
|
const queue = this.sendQueue;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Shared chrome for the symbolic demonstration pages:
|
/* Shared chrome for the symbolic demonstration pages:
|
||||||
«ارتباط با کال سنتر»، «بازخوانی تماسها از کال سنتر» and «سوالات چت سایت و اپلیکیشن».
|
«ارتباط با کال سنتر»، «بازخوانی تماسها از کال سنتر» and «سوالات چت وب اپلیکیشن».
|
||||||
Each page component includes this file through styleUrls, so keep every selector
|
Each page component includes this file through styleUrls, so keep every selector
|
||||||
page-agnostic (prefix: demo-). Visual language mirrors the reports/wallboard pages. */
|
page-agnostic (prefix: demo-). Visual language mirrors the reports/wallboard pages. */
|
||||||
|
|
||||||
@@ -75,7 +75,9 @@
|
|||||||
border: 1px solid var(--card-border);
|
border: 1px solid var(--card-border);
|
||||||
border-radius: 1.25rem;
|
border-radius: 1.25rem;
|
||||||
background: var(--card-bg);
|
background: var(--card-bg);
|
||||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06), 0 2px 10px rgba(0, 0, 0, 0.03);
|
box-shadow:
|
||||||
|
0 10px 40px rgba(0, 0, 0, 0.06),
|
||||||
|
0 2px 10px rgba(0, 0, 0, 0.03);
|
||||||
animation: demoFadeInUp 0.5s ease-out both;
|
animation: demoFadeInUp 0.5s ease-out both;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +300,10 @@
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.2s, border-color 0.2s, color 0.2s;
|
transition:
|
||||||
|
background-color 0.2s,
|
||||||
|
border-color 0.2s,
|
||||||
|
color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.demo-btn:disabled {
|
.demo-btn:disabled {
|
||||||
@@ -525,5 +530,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:host-context([data-bs-theme='dark']) .demo-card {
|
:host-context([data-bs-theme='dark']) .demo-card {
|
||||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3), 0 2px 10px rgba(0, 0, 0, 0.2);
|
box-shadow:
|
||||||
|
0 10px 40px rgba(0, 0, 0, 0.3),
|
||||||
|
0 2px 10px rgba(0, 0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,9 +54,9 @@
|
|||||||
appearance: none;
|
appearance: none;
|
||||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: right 0.75rem center;
|
background-position: right 1rem center;
|
||||||
padding-right: 2.5rem;
|
padding: 0.75rem 1rem;
|
||||||
padding-left: 0.75rem;
|
padding-right: 2.75rem;
|
||||||
background-color: var(--color-input-bg);
|
background-color: var(--color-input-bg);
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
border: 1px solid var(--color-input-border);
|
border: 1px solid var(--color-input-border);
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
|
|
||||||
.form-visibility-toggle {
|
.form-visibility-toggle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset-inline-start: 0.5rem;
|
inset-inline-end: 0.5rem;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
translate: 0 -50%;
|
translate: 0 -50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -41,44 +41,47 @@ interface ModelOption {
|
|||||||
<div class="ai-model-card settings-card">
|
<div class="ai-model-card settings-card">
|
||||||
<header class="ai-model-card-header">
|
<header class="ai-model-card-header">
|
||||||
<h3 class="text-base font-medium text-[var(--text-primary)]">{{ title() }}</h3>
|
<h3 class="text-base font-medium text-[var(--text-primary)]">{{ title() }}</h3>
|
||||||
<span class="ai-model-badge" [class.ai-model-badge--connected]="connected()"
|
<span class="ai-model-badge" [class.ai-model-badge--connected]="connected()">{{
|
||||||
>{{ connected() ? 'متصل' : 'متصل نشده' }}</span>
|
connected() ? 'متصل' : 'متصل نشده'
|
||||||
|
}}</span>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="ai-model-body space-y-4">
|
<div class="ai-model-body space-y-4">
|
||||||
<!-- Provider -->
|
<!-- Provider -->
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label class="form-label">ارائهدهنده</label>
|
<label class="form-label">ارائهدهنده</label>
|
||||||
<select
|
<select
|
||||||
class="form-select w-full"
|
class="form-select w-full"
|
||||||
[value]="config().provider"
|
[value]="config().provider"
|
||||||
(change)="onProviderChange($any($event.target).value)"
|
(change)="onProviderChange($any($event.target).value)"
|
||||||
>
|
>
|
||||||
@for (provider of providers(); track provider.value) {
|
@for (provider of providers(); track provider.value) {
|
||||||
<option [value]="provider.value">{{ provider.label }}</option>
|
<option [value]="provider.value">{{ provider.label }}</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Model -->
|
<!-- Model -->
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label class="form-label">مدل</label>
|
<label class="form-label">مدل</label>
|
||||||
<select
|
<select
|
||||||
class="form-select w-full"
|
class="form-select w-full"
|
||||||
[value]="config().model"
|
[value]="config().model"
|
||||||
(change)="onModelChange($any($event.target).value)"
|
(change)="onModelChange($any($event.target).value)"
|
||||||
>
|
>
|
||||||
@for (model of modelsForProvider(); track model.value) {
|
@for (model of modelsForProvider(); track model.value) {
|
||||||
<option [value]="model.value">{{ model.label }}</option>
|
<option [value]="model.value">{{ model.label }}</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- API key -->
|
<!-- API key -->
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
کلید API
|
کلید API
|
||||||
@if (apiKeyRequired()) { <span class="form-required" aria-hidden="true">*</span> }
|
@if (apiKeyRequired()) {
|
||||||
|
<span class="form-required" aria-hidden="true">*</span>
|
||||||
|
}
|
||||||
</label>
|
</label>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<input
|
<input
|
||||||
@@ -96,25 +99,42 @@ interface ModelOption {
|
|||||||
[attr.aria-label]="config().apiKeyVisible ? 'پنهان کن' : 'نمایش بده'"
|
[attr.aria-label]="config().apiKeyVisible ? 'پنهان کن' : 'نمایش بده'"
|
||||||
(click)="toggleApiKeyVisibility()"
|
(click)="toggleApiKeyVisibility()"
|
||||||
>
|
>
|
||||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
<svg
|
||||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
@if (config().apiKeyVisible) {
|
@if (config().apiKeyVisible) {
|
||||||
<path d="M1 1l22 22M10.5 10.5A2.5 2.5 0 0 0 13.5 13.5M9.9 9.9L4.15 18.5A9.92 9.92 0 0 1 1 12 11.5 11.5 0 0 1 9.9 9.9Zm10.2 10.2A11.5 11.5 0 0 0 23 12a11.5 11.5 0 0 1-3.35-7.75l2.1-2.1A11.33 11.33 0 0 1 23 12a11.5 11.5 0 0 0-3.35 7.75Z" />
|
<!-- Eye Off: API key is visible -->
|
||||||
<circle cx="12" cy="12" r="1" />
|
<path d="M10.58 10.58a2 2 0 0 0 2.83 2.83" />
|
||||||
<line x1="1" y1="1" x2="23" y2="23" />
|
<path
|
||||||
|
d="M16.68 16.68A10.7 10.7 0 0 1 12 17.75c-5 0-8.27-3.11-10-5.75a1.8 1.8 0 0 1 0-2A11.8 11.8 0 0 1 5.32 6.33"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M9.88 5.08A10.7 10.7 0 0 1 12 4.75c5 0 8.27 3.11 10 5.75a1.8 1.8 0 0 1 0 2 11.8 11.8 0 0 1-1.82 2.32"
|
||||||
|
/>
|
||||||
|
<line x1="2" y1="2" x2="22" y2="22" />
|
||||||
} @else {
|
} @else {
|
||||||
<path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7z" />
|
<!-- Eye: API key is hidden -->
|
||||||
|
<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z" />
|
||||||
<circle cx="12" cy="12" r="3" />
|
<circle cx="12" cy="12" r="3" />
|
||||||
<line x1="12" y1="1" x2="12" y2="12.01" />
|
|
||||||
}
|
}
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-hint">
|
<div class="form-hint">
|
||||||
@if (connected() && config().apiKey) {
|
@if (connected() && config().apiKey) {
|
||||||
<span class="text-[var(--text-muted)]">تنظیم شده — مقدار فعلی نمایش داده نمیشود</span>
|
<span class="text-[var(--text-muted)]"
|
||||||
|
>تنظیم شده — مقدار فعلی نمایش داده نمیشود</span
|
||||||
|
>
|
||||||
} @else {
|
} @else {
|
||||||
<span class="text-[var(--text-muted)]">کلید در حافظه نگهداری میشود و ذخیره نمیشود</span>
|
<span class="text-[var(--text-muted)]"
|
||||||
|
>کلید در حافظه نگهداری میشود و ذخیره نمیشود</span
|
||||||
|
>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -131,14 +151,21 @@ interface ModelOption {
|
|||||||
[attr.aria-label]="'آدرس سرویس ' + title()"
|
[attr.aria-label]="'آدرس سرویس ' + title()"
|
||||||
/>
|
/>
|
||||||
@if (!serviceUrlEditable()) {
|
@if (!serviceUrlEditable()) {
|
||||||
<span class="text-[var(--text-muted)] mt-1 text-xs">آدرس استاندارد {{ config().provider === 'local' ? 'سرویس محلی' : 'سرویس' }} بهصورت پیشفرض به کار میرود</span>
|
<span class="text-[var(--text-muted)] mt-1 text-xs"
|
||||||
|
>آدرس استاندارد {{ config().provider === 'local' ? 'سرویس محلی' : 'سرویس' }} بهصورت
|
||||||
|
پیشفرض به کار میرود</span
|
||||||
|
>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Actions -->
|
<!-- Actions -->
|
||||||
<div class="ai-model-actions flex gap-2 pt-2">
|
<div class="ai-model-actions flex gap-2 pt-2">
|
||||||
<button type="button" class="btn btn--primary flex-1" (click)="save.emit()">ذخیره تنظیمات</button>
|
<button type="button" class="btn btn--primary flex-1" (click)="save.emit()">
|
||||||
<button type="button" class="btn btn--outline flex-1" (click)="testConnection.emit()">بررسی اتصال</button>
|
ذخیره تنظیمات
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn--outline flex-1" (click)="testConnection.emit()">
|
||||||
|
بررسی اتصال
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -240,10 +267,7 @@ const DEFAULT_CONFIG_FOR: Record<AiProvider, { model: string; serviceUrl: string
|
|||||||
|
|
||||||
const MODEL_OPTION = (value: string, label: string): ModelOption => ({ value, label });
|
const MODEL_OPTION = (value: string, label: string): ModelOption => ({ value, label });
|
||||||
|
|
||||||
const MODELS_BY_TASK: Record<
|
const MODELS_BY_TASK: Record<AiTask, Partial<Record<AiProvider, ModelOption[]>>> = {
|
||||||
AiTask,
|
|
||||||
Partial<Record<AiProvider, ModelOption[]>>
|
|
||||||
> = {
|
|
||||||
text: {
|
text: {
|
||||||
openai: [
|
openai: [
|
||||||
MODEL_OPTION('gpt-4o', 'GPT-4o'),
|
MODEL_OPTION('gpt-4o', 'GPT-4o'),
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export interface ChatHistoryItem {
|
|||||||
imports: [CommonModule, RouterModule, CdkMenuModule],
|
imports: [CommonModule, RouterModule, CdkMenuModule],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
templateUrl: './sidebar.component.html',
|
templateUrl: './sidebar.component.html',
|
||||||
styleUrl: './sidebar.component.css'
|
styleUrl: './sidebar.component.css',
|
||||||
})
|
})
|
||||||
export class SidebarComponent {
|
export class SidebarComponent {
|
||||||
private readonly themeService = inject(ThemeService);
|
private readonly themeService = inject(ThemeService);
|
||||||
@@ -56,11 +56,11 @@ export class SidebarComponent {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'M7.9 20A9 9 0 1 0 4 16.1L2 22Z',
|
icon: 'M7.9 20A9 9 0 1 0 4 16.1L2 22Z',
|
||||||
label: 'سوالات چت سایت و اپلیکیشن',
|
label: 'سوالات چت وب اپلیکیشن',
|
||||||
route: '/chat-questions',
|
route: '/chat-questions',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.573-1.066zM15 12a3 3 0 11-6 0 3 3 0 016 0z',
|
icon: 'M19.14 12.94c.04-.3.06-.61.06-.94s-.02-.64-.07-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.61-.22l-2.39.96a7.3 7.3 0 0 0-1.63-.94l-.36-2.54A.49.49 0 0 0 13.87 2h-3.84a.49.49 0 0 0-.49.42L9.18 4.96c-.59.23-1.14.55-1.63.94l-2.39-.96a.5.5 0 0 0-.61.22L2.63 8.48a.5.5 0 0 0 .12.64l2.03 1.58a7 7 0 0 0 0 1.88l-2.03 1.58a.5.5 0 0 0-.12.64l1.92 3.32c.13.22.39.31.61.22l2.39-.96c.49.39 1.04.71 1.63.94l.36 2.54c.03.24.24.42.49.42h3.84c.25 0 .46-.18.49-.42l.36-2.54c.59-.23 1.14-.55 1.63-.94l2.39.96c.22.09.48 0 .61-.22l1.92-3.32a.5.5 0 0 0-.12-.64zM12 15.5a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7z',
|
||||||
label: 'تنظیمات',
|
label: 'تنظیمات',
|
||||||
route: '/settings',
|
route: '/settings',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import moment from 'moment-jalaali';
|
||||||
|
|
||||||
const PERSIAN_DIGITS = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
const PERSIAN_DIGITS = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
||||||
|
|
||||||
export function toPersianDigits(value: string | number): string {
|
export function toPersianDigits(value: string | number): string {
|
||||||
@@ -18,3 +20,12 @@ export function formatDecimal(value: number, fractionDigits = 1): string {
|
|||||||
export function formatPercent(value: number): string {
|
export function formatPercent(value: number): string {
|
||||||
return `${toPersianDigits(Math.round(value))}٪`;
|
return `${toPersianDigits(Math.round(value))}٪`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 2026-10-10 -> «۱۴۰۵/۰۷/۱۸ ۱۰:۲۵» */
|
||||||
|
export function formatJalaliDateTime(value: string | Date): string {
|
||||||
|
const date = typeof value === 'string' ? new Date(value) : value;
|
||||||
|
if (Number.isNaN(date.getTime())) {
|
||||||
|
return '—';
|
||||||
|
}
|
||||||
|
return toPersianDigits(moment(date).format('jYYYY/jMM/jDD HH:mm'));
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>FaqChatbot</title>
|
<title>دستیار هوش مصنوعی</title>
|
||||||
<base href="/">
|
<base href="/">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
|
color-scheme: light;
|
||||||
--app-bg: #f8fafc;
|
--app-bg: #f8fafc;
|
||||||
--app-text: #122033;
|
--app-text: #122033;
|
||||||
--sidebar-bg: #f8fafc;
|
--sidebar-bg: #f8fafc;
|
||||||
@@ -52,6 +53,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
[data-bs-theme="dark"] {
|
[data-bs-theme="dark"] {
|
||||||
|
color-scheme: dark;
|
||||||
--app-bg: #212121;
|
--app-bg: #212121;
|
||||||
--app-text: #ececec;
|
--app-text: #ececec;
|
||||||
--sidebar-bg: #171717;
|
--sidebar-bg: #171717;
|
||||||
@@ -128,6 +130,12 @@
|
|||||||
background-color: var(--scrollbar-track);
|
background-color: var(--scrollbar-track);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select option,
|
||||||
|
select optgroup {
|
||||||
|
background-color: var(--color-input-bg);
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
direction: rtl;
|
direction: rtl;
|
||||||
font-family: "Lahze", sans-serif;
|
font-family: "Lahze", sans-serif;
|
||||||
|
|||||||
Reference in New Issue
Block a user