@songtonyli/dsh-cli 0.1.58 → 0.1.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@deepseek-ai/dsh-agent-preset/skills/cordis-composition-reference/references/packages.md +1 -0
- package/node_modules/@deepseek-ai/dsh-api-session-controller/lib/client.js +1 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox/lib/index.js +59 -4
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.i18n.yaml +73 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.md +166 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.zh.md +166 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/exec-shim.js +227 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/index.js +704 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/package.json +62 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/lib/index.js +23 -0
- package/node_modules/@deepseek-ai/dsh-session/lib/index.js +1 -0
- package/node_modules/@deepseek-ai/dsh-session/lib/types/known-event-types.js +1 -0
- package/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/worker.cjs +1 -0
- package/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js +1 -0
- package/node_modules/@deepseek-ai/dsh-tool-cordis/lib/types/api-catalog.js +22 -0
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-fs/lib/index.js +24 -0
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.md +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.zh.md +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/lib/index.js +28 -3
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/package.json +7 -2
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/lib/index.js +14 -6
- package/node_modules/@deepseek-ai/dsh-tui-app/cordis.patch.yml +20 -0
- package/node_modules/@deepseek-ai/dsh-tui-app/package.json +1 -0
- package/node_modules/@deepseek-ai/libreoffice-kit/README.md +20 -5
- package/node_modules/@deepseek-ai/libreoffice-kit/README.zh.md +21 -6
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/cli.js +499 -253
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/font-snapshot-worker.js +37 -26
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/index.js +498 -252
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/worker.js +39 -13
- package/node_modules/@deepseek-ai/libreoffice-kit/package.json +5 -3
- package/node_modules/@earendil-works/pi-ai/README.md +4 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +117 -18
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +19 -8
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +24 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +3 -2
- package/node_modules/@earendil-works/pi-ai/package.json +6 -2
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@shikijs/core/dist/index.mjs +15 -12
- package/node_modules/@shikijs/core/package.json +4 -4
- package/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs +2 -4
- package/node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs +2 -4
- package/node_modules/@shikijs/engine-javascript/dist/index.mjs +1 -1
- package/node_modules/@shikijs/engine-javascript/dist/string-TLTPtCPs.mjs +115 -0
- package/node_modules/@shikijs/engine-javascript/package.json +3 -3
- package/node_modules/@shikijs/engine-oniguruma/package.json +3 -3
- package/node_modules/@shikijs/langs/dist/ada.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/ahk.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/beancount.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/coq.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/csharp.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/css.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/dart.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/dotenv.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/emacs-lisp.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/gn.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/handlebars.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/julia.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/latex.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/luau.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/marko.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/moonbit.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nextflow-groovy.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nextflow.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nushell.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/php.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/powershell.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/ruby.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/rust.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/sql.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/svelte.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/twig.mjs +3 -3
- package/node_modules/@shikijs/langs/dist/typespec.mjs +1 -1
- package/node_modules/@shikijs/langs/package.json +3 -3
- package/node_modules/@shikijs/primitive/dist/index.mjs +2 -1
- package/node_modules/@shikijs/primitive/package.json +3 -3
- package/node_modules/@shikijs/themes/dist/monokai.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/one-dark-pro.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/red.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/solarized-dark.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/solarized-light.mjs +1 -1
- package/node_modules/@shikijs/themes/package.json +3 -3
- package/node_modules/@shikijs/types/package.json +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +33 -11
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/exceptions.js +33 -11
- package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +3 -0
- package/node_modules/@smithy/core/package.json +1 -1
- package/node_modules/node-addon-native-custom-loader/lib/index.js +23 -10
- package/node_modules/node-addon-native-custom-loader/package.json +6 -1
- package/node_modules/node-addon-require-builtin/package.json +7 -2
- package/node_modules/powershell-utils/index.js +40 -19
- package/node_modules/powershell-utils/package.json +1 -1
- package/node_modules/powershell-utils/readme.md +69 -13
- package/node_modules/shiki/package.json +10 -10
- package/node_modules/wsl-utils/index.js +18 -37
- package/node_modules/wsl-utils/package.json +2 -2
- package/package.json +33 -29
- package/node_modules/@shikijs/engine-javascript/dist/scanner-DX8LRFGE.mjs +0 -77
- package/node_modules/open/node_modules/powershell-utils/index.js +0 -79
- package/node_modules/open/node_modules/powershell-utils/license +0 -9
- package/node_modules/open/node_modules/powershell-utils/package.json +0 -47
- package/node_modules/open/node_modules/powershell-utils/readme.md +0 -209
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* - DS4: "Prompt has X tokens, but the configured context size is Y tokens"
|
|
26
26
|
* - Cerebras: "400/413 status code (no body)"
|
|
27
27
|
* - Mistral: "Prompt contains X tokens ... too large for model with Y maximum context length"
|
|
28
|
-
* - z.ai: `{"code":"1261","message":"Prompt too long"}` or silent overflow via usage.input > contextWindow
|
|
28
|
+
* - z.ai: `{"code":"1261","message":"Prompt too long"}`, `{"code":"1261","message":"Prompt exceeds max length"}` (CN endpoint), or silent overflow via usage.input > contextWindow
|
|
29
29
|
* - Xiaomi MiMo: Truncates input to fill contextWindow exactly, then returns finish_reason "length"
|
|
30
30
|
* with output=0 (no room left to generate). Detected via stopReason "length" + zero output +
|
|
31
31
|
* input filling the context window.
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const OVERFLOW_PATTERNS = [
|
|
36
36
|
/prompt (?:is )?too long/i, // Anthropic and z.ai token overflow
|
|
37
|
+
/prompt exceeds max length/i, // z.ai CN endpoint token overflow
|
|
37
38
|
/request_too_large/i, // Anthropic request byte-size overflow (HTTP 413)
|
|
38
39
|
/input is too long for requested model/i, // Amazon Bedrock
|
|
39
40
|
/exceeds the context window/i, // OpenAI (Completions & Responses API)
|
|
@@ -30,14 +30,15 @@ function getRetryDelayMs(error, retryIndex, maxRetryDelayMs) {
|
|
|
30
30
|
const retryAfterMs = error.headers?.get("retry-after-ms");
|
|
31
31
|
if (retryAfterMs) {
|
|
32
32
|
const value = Number.parseFloat(retryAfterMs);
|
|
33
|
-
if (
|
|
33
|
+
if (Number.isFinite(value))
|
|
34
34
|
return validateServerRetryDelayMs(value, maxRetryDelayMs, error.message);
|
|
35
35
|
}
|
|
36
36
|
const retryAfter = error.headers?.get("retry-after");
|
|
37
37
|
if (retryAfter) {
|
|
38
38
|
const seconds = Number.parseFloat(retryAfter);
|
|
39
39
|
const delayMs = Number.isNaN(seconds) ? Date.parse(retryAfter) - Date.now() : seconds * 1000;
|
|
40
|
-
|
|
40
|
+
if (Number.isFinite(delayMs))
|
|
41
|
+
return validateServerRetryDelayMs(delayMs, maxRetryDelayMs, error.message);
|
|
41
42
|
}
|
|
42
43
|
const exponentialDelay = Math.min(0.5 * 2 ** retryIndex, 8) * 1000;
|
|
43
44
|
return exponentialDelay * (1 - Math.random() * 0.25);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@earendil-works/pi-ai",
|
|
3
|
-
"version": "0.99.
|
|
3
|
+
"version": "0.99.2",
|
|
4
4
|
"description": "Unified LLM API with automatic model discovery and provider configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"import": "./dist/index.js"
|
|
17
17
|
},
|
|
18
|
+
"./models": {
|
|
19
|
+
"types": "./dist/models.d.ts",
|
|
20
|
+
"import": "./dist/models.js"
|
|
21
|
+
},
|
|
18
22
|
"./compat": {
|
|
19
23
|
"types": "./dist/compat.d.ts",
|
|
20
24
|
"import": "./dist/compat.js"
|
|
@@ -54,7 +58,7 @@
|
|
|
54
58
|
"dependencies": {
|
|
55
59
|
"@anthropic-ai/sdk": "0.124.0",
|
|
56
60
|
"@aws-sdk/client-bedrock-runtime": "3.1127.0",
|
|
57
|
-
"@earendil-works/pi-telemetry": "^0.99.
|
|
61
|
+
"@earendil-works/pi-telemetry": "^0.99.2",
|
|
58
62
|
"@google/genai": "2.21.0",
|
|
59
63
|
"@smithy/node-http-handler": "4.12.1",
|
|
60
64
|
"http-proxy-agent": "9.1.0",
|
|
@@ -177,16 +177,17 @@ function flatTokenVariants(merged, variantsOrder, cssVariablePrefix, defaultColo
|
|
|
177
177
|
styles.forEach((cur, idx) => {
|
|
178
178
|
for (const key of styleKeys) {
|
|
179
179
|
const value = cur[key] || "inherit";
|
|
180
|
-
if (idx === 0 && defaultColor && COLOR_KEYS.includes(key))
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
if (idx === 0 && defaultColor && COLOR_KEYS.includes(key)) {
|
|
181
|
+
if (defaultColor === "light-dark()" && styles.length > 1) {
|
|
182
|
+
const lightIndex = variantsOrder.findIndex((t) => t === "light");
|
|
183
|
+
const darkIndex = variantsOrder.findIndex((t) => t === "dark");
|
|
184
|
+
if (lightIndex === -1 || darkIndex === -1) throw new ShikiError$1("When using `defaultColor: \"light-dark()\"`, you must provide both `light` and `dark` themes");
|
|
185
|
+
const lightValue = styles[lightIndex][key] || "inherit";
|
|
186
|
+
const darkValue = styles[darkIndex][key] || "inherit";
|
|
187
|
+
mergedStyles[key] = `light-dark(${lightValue}, ${darkValue})`;
|
|
188
|
+
if (colorsRendering === "css-vars") mergedStyles[varKey(idx, key)] = value;
|
|
189
|
+
} else mergedStyles[key] = value;
|
|
190
|
+
} else if (colorsRendering === "css-vars") mergedStyles[varKey(idx, key)] = value;
|
|
190
191
|
}
|
|
191
192
|
});
|
|
192
193
|
token.htmlStyle = mergedStyles;
|
|
@@ -829,8 +830,10 @@ function tokensToHast(tokens, options, transformerContext, grammarState = getLas
|
|
|
829
830
|
};
|
|
830
831
|
const { structure = "classic", tabindex = "0" } = options;
|
|
831
832
|
const properties = { class: `shiki ${options.themeName || ""}` };
|
|
832
|
-
if (options.rootStyle !== false)
|
|
833
|
-
|
|
833
|
+
if (options.rootStyle !== false) {
|
|
834
|
+
if (options.rootStyle != null) properties.style = options.rootStyle;
|
|
835
|
+
else properties.style = `background-color:${options.bg};color:${options.fg}`;
|
|
836
|
+
}
|
|
834
837
|
if (tabindex !== false && tabindex != null) properties.tabindex = tabindex.toString();
|
|
835
838
|
for (const [key, value] of Object.entries(options.meta || {})) if (!key.startsWith("_")) properties[key] = value;
|
|
836
839
|
let preNode = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"description": "Core of Shiki",
|
|
6
6
|
"author": "Pine Wu <octref@gmail.com>; Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"node": ">=20"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
+
"@shikijs/primitive": "4.5.0",
|
|
50
|
+
"@shikijs/types": "4.5.0",
|
|
49
51
|
"@shikijs/vscode-textmate": "^10.0.2",
|
|
50
52
|
"@types/hast": "^3.0.5",
|
|
51
|
-
"hast-util-to-html": "^9.0.5"
|
|
52
|
-
"@shikijs/primitive": "4.4.3",
|
|
53
|
-
"@shikijs/types": "4.4.3"
|
|
53
|
+
"hast-util-to-html": "^9.0.5"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as JavaScriptScanner, t as createJavaScriptEngineString } from "./string-TLTPtCPs.mjs";
|
|
2
2
|
import { toRegExp } from "oniguruma-to-es";
|
|
3
3
|
//#region src/engine-compile.ts
|
|
4
4
|
/**
|
|
@@ -38,9 +38,7 @@ function createJavaScriptRegexEngine(options = {}) {
|
|
|
38
38
|
createScanner(patterns) {
|
|
39
39
|
return new JavaScriptScanner(patterns, _options);
|
|
40
40
|
},
|
|
41
|
-
createString
|
|
42
|
-
return { content: s };
|
|
43
|
-
}
|
|
41
|
+
createString: createJavaScriptEngineString
|
|
44
42
|
};
|
|
45
43
|
}
|
|
46
44
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as JavaScriptScanner, t as createJavaScriptEngineString } from "./string-TLTPtCPs.mjs";
|
|
2
2
|
//#region src/engine-raw.ts
|
|
3
3
|
/**
|
|
4
4
|
* Raw JavaScript regex engine that only supports precompiled grammars.
|
|
@@ -18,9 +18,7 @@ function createJavaScriptRawEngine() {
|
|
|
18
18
|
createScanner(patterns) {
|
|
19
19
|
return new JavaScriptScanner(patterns, options);
|
|
20
20
|
},
|
|
21
|
-
createString
|
|
22
|
-
return { content: s };
|
|
23
|
-
}
|
|
21
|
+
createString: createJavaScriptEngineString
|
|
24
22
|
};
|
|
25
23
|
}
|
|
26
24
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as JavaScriptScanner } from "./string-TLTPtCPs.mjs";
|
|
2
2
|
import { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from "./engine-compile.mjs";
|
|
3
3
|
import { createJavaScriptRawEngine } from "./engine-raw.mjs";
|
|
4
4
|
export { JavaScriptScanner, createJavaScriptRawEngine, createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
//#region src/scanner.ts
|
|
2
|
+
const MAX = 4294967295;
|
|
3
|
+
function isSearchCacheable(regexp) {
|
|
4
|
+
return !regexp.sticky && !regexp.rawOptions?.strategy;
|
|
5
|
+
}
|
|
6
|
+
function toResult(index, indices) {
|
|
7
|
+
return {
|
|
8
|
+
index,
|
|
9
|
+
captureIndices: indices.map((indice) => {
|
|
10
|
+
if (indice == null) return {
|
|
11
|
+
start: MAX,
|
|
12
|
+
end: MAX,
|
|
13
|
+
length: 0
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
start: indice[0],
|
|
17
|
+
end: indice[1],
|
|
18
|
+
length: indice[1] - indice[0]
|
|
19
|
+
};
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
var JavaScriptScanner = class {
|
|
24
|
+
patterns;
|
|
25
|
+
options;
|
|
26
|
+
regexps;
|
|
27
|
+
/**
|
|
28
|
+
* Last search of each regexp on the current string, reused the way `vscode-oniguruma` does.
|
|
29
|
+
* `null` for regexps whose searches can't be reused.
|
|
30
|
+
*/
|
|
31
|
+
lastSearches;
|
|
32
|
+
constructor(patterns, options = {}) {
|
|
33
|
+
this.patterns = patterns;
|
|
34
|
+
this.options = options;
|
|
35
|
+
const { forgiving = false, cache, regexConstructor } = options;
|
|
36
|
+
if (!regexConstructor) throw new Error("Option `regexConstructor` is not provided");
|
|
37
|
+
this.regexps = patterns.map((p) => {
|
|
38
|
+
if (typeof p !== "string") return p;
|
|
39
|
+
const cached = cache?.get(p);
|
|
40
|
+
if (cached) {
|
|
41
|
+
if (cached instanceof RegExp) return cached;
|
|
42
|
+
if (forgiving) return null;
|
|
43
|
+
throw cached;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const regex = regexConstructor(p);
|
|
47
|
+
cache?.set(p, regex);
|
|
48
|
+
return regex;
|
|
49
|
+
} catch (e) {
|
|
50
|
+
cache?.set(p, e);
|
|
51
|
+
if (forgiving) return null;
|
|
52
|
+
throw e;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
this.lastSearches = this.regexps.map((regexp) => regexp && isSearchCacheable(regexp) ? {
|
|
56
|
+
strId: 0,
|
|
57
|
+
searchedFrom: 0,
|
|
58
|
+
matchIndex: -1,
|
|
59
|
+
indices: null
|
|
60
|
+
} : null);
|
|
61
|
+
}
|
|
62
|
+
findNextMatchSync(string, startPosition, _options) {
|
|
63
|
+
const str = typeof string === "string" ? string : string.content;
|
|
64
|
+
const strId = typeof string === "string" ? 0 : string.id || 0;
|
|
65
|
+
let bestIndex = -1;
|
|
66
|
+
let bestMatchIndex = 0;
|
|
67
|
+
let bestIndices = null;
|
|
68
|
+
for (let i = 0; i < this.regexps.length; i++) {
|
|
69
|
+
const regexp = this.regexps[i];
|
|
70
|
+
if (!regexp) continue;
|
|
71
|
+
try {
|
|
72
|
+
const last = strId ? this.lastSearches[i] : null;
|
|
73
|
+
let matchIndex;
|
|
74
|
+
let indices;
|
|
75
|
+
if (last && last.strId === strId && last.searchedFrom <= startPosition && (last.matchIndex === -1 || last.matchIndex >= startPosition)) {
|
|
76
|
+
matchIndex = last.matchIndex;
|
|
77
|
+
indices = last.indices;
|
|
78
|
+
} else {
|
|
79
|
+
regexp.lastIndex = startPosition;
|
|
80
|
+
const match = regexp.exec(str);
|
|
81
|
+
matchIndex = match ? match.index : -1;
|
|
82
|
+
indices = match ? match.indices : null;
|
|
83
|
+
if (last) {
|
|
84
|
+
last.strId = strId;
|
|
85
|
+
last.searchedFrom = startPosition;
|
|
86
|
+
last.matchIndex = matchIndex;
|
|
87
|
+
last.indices = indices;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (matchIndex === -1) continue;
|
|
91
|
+
if (matchIndex === startPosition) return toResult(i, indices);
|
|
92
|
+
if (bestIndex === -1 || matchIndex < bestMatchIndex) {
|
|
93
|
+
bestIndex = i;
|
|
94
|
+
bestMatchIndex = matchIndex;
|
|
95
|
+
bestIndices = indices;
|
|
96
|
+
}
|
|
97
|
+
} catch (e) {
|
|
98
|
+
if (this.options.forgiving) continue;
|
|
99
|
+
throw e;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return bestIndex === -1 ? null : toResult(bestIndex, bestIndices);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/string.ts
|
|
107
|
+
let lastStringId = 0;
|
|
108
|
+
function createJavaScriptEngineString(content) {
|
|
109
|
+
return {
|
|
110
|
+
content,
|
|
111
|
+
id: ++lastStringId
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { JavaScriptScanner as n, createJavaScriptEngineString as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/engine-javascript",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"description": "Engine for Shiki using JavaScript's native RegExp",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"node": ">=20"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@shikijs/types": "4.5.0",
|
|
34
35
|
"@shikijs/vscode-textmate": "^10.0.2",
|
|
35
|
-
"oniguruma-to-es": "^4.3.6"
|
|
36
|
-
"@shikijs/types": "4.4.3"
|
|
36
|
+
"oniguruma-to-es": "^4.3.6"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/engine-oniguruma",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"description": "Engine for Shiki using Oniguruma RegExp engine in WebAssembly",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"node": ">=20"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@shikijs/
|
|
36
|
-
"@shikijs/
|
|
35
|
+
"@shikijs/types": "4.5.0",
|
|
36
|
+
"@shikijs/vscode-textmate": "^10.0.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"vscode-oniguruma": "1.7.0"
|