@deepseek-ai/dsh-util-workspace-path 0.1.7-rc.1 → 0.2.0-rc.1
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.i18n.yaml +24 -5
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/index.js +2 -2
- package/lib/types/index.d.ts +1 -1
- package/package.json +1 -1
package/README.i18n.yaml
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
# Bilingual-pair consistency record (docs/i18n/README.md):
|
|
2
|
-
#
|
|
3
|
-
#
|
|
1
|
+
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
|
2
|
+
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
|
3
|
+
# After editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/util/workspace-path/README.md
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/:
|
|
6
|
+
en: e8d97ffa99a57ab7
|
|
7
|
+
zh: 2d7247c47412c30a
|
|
8
|
+
/dsh-util-workspace-path:
|
|
9
|
+
en: 328c592b68c88e44
|
|
10
|
+
zh: 7a2f03def21b86fe
|
|
11
|
+
/dsh-util-workspace-path/summary:
|
|
12
|
+
en: ffdecddc9c4957ad
|
|
13
|
+
zh: 33cf84892aa5e669
|
|
14
|
+
/dsh-util-workspace-path/table-of-contents:
|
|
15
|
+
en: e8236aa6cbcb7dca
|
|
16
|
+
zh: 500e57982344c0fa
|
|
17
|
+
/dsh-util-workspace-path/file-addresses:
|
|
18
|
+
en: fa695bca8bd534e0
|
|
19
|
+
zh: d8feffb4794adfcd
|
|
20
|
+
/dsh-util-workspace-path/known-limitations-and-deferred-work:
|
|
21
|
+
en: 1e6d448f4f0030c4
|
|
22
|
+
zh: c050dd5e470fe47b
|
|
23
|
+
/dsh-util-workspace-path/known-limitations-and-deferred-work/dev-note:
|
|
24
|
+
en: cfc7173facebc57c
|
|
25
|
+
zh: 4ea51377d7c9c147
|
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ A resource address is `dsh-resource://<type>/…`, and the type — the URI host
|
|
|
26
26
|
|
|
27
27
|
`sessionFileAddress(sessionId, path)` normalizes `\` to `/` and drops leading `./`, but preserves leading `/` characters. Every id and path segment is component-encoded with `:` kept literal. `fileAddressFor(sessionId, cwd, path)` always builds a Session address: paths inside `cwd` become relative; other absolute paths, including when `cwd` is unknown, stay absolute within that Session address. `absoluteFileAddress(absolutePath)` builds only the Session-less form. `parseFileAddress(address)` checks the exact file-address prefix, ignores query and fragment suffixes, decodes each segment, and returns `{ scope, sessionId, path }` for a Session address or `{ scope, path }` for the Session-less form. Another type or scheme, an unknown scope, a missing id or path, or a malformed escape returns `undefined`.
|
|
28
28
|
|
|
29
|
-
`fileMediaUrl(base, path)` builds an authenticated file-route URL from an already-decoded absolute path. It preserves literal percent signs and deployment prefixes, and rejects
|
|
29
|
+
`fileMediaUrl(base, path)` builds an authenticated file-route URL from an already-decoded absolute path. It accepts HTTP(S) application bases and the Desktop `dsh-app://app/` origin, preserves literal percent signs and deployment prefixes, and rejects other application bases, relative paths, network-path prefixes, and control characters. Markdown owners decode authored URLs before calling it; native file-card paths are passed unchanged.
|
|
30
30
|
|
|
31
31
|
-----
|
|
32
32
|
|
package/README.zh.md
CHANGED
|
@@ -26,7 +26,7 @@ kind: "package-library"
|
|
|
26
26
|
|
|
27
27
|
`sessionFileAddress(sessionId, path)` 将 `\` 归一为 `/`,去掉前导 `./`,但保留前导 `/` 字符。id 和每个路径段都做组件编码,`:` 保持字面。`fileAddressFor(sessionId, cwd, path)` 始终构造 Session 地址:`cwd` 内的路径转为相对路径;其他绝对路径(包括 `cwd` 未知时)仍作为该 Session 地址内的绝对路径。`absoluteFileAddress(absolutePath)` 只构造不带 Session 的形式。`parseFileAddress(address)` 检查精确的文件地址前缀、忽略查询与片段后缀、逐段解码,并为 Session 地址返回 `{ scope, sessionId, path }`,为不带 Session 的形式返回 `{ scope, path }`。其他 type 或 scheme、未知作用域、缺 id 或路径,或错误转义都返回 `undefined`。
|
|
28
28
|
|
|
29
|
-
`fileMediaUrl(base, path)` 从已解码的绝对路径生成带认证文件路由的 URL
|
|
29
|
+
`fileMediaUrl(base, path)` 从已解码的绝对路径生成带认证文件路由的 URL,支持 HTTP(S) 应用基址与桌面端 `dsh-app://app/` 来源,保留字面量百分号与部署前缀,并拒绝其他应用基址、相对路径、网络路径前缀和控制字符。Markdown 调用方先解码所写 URL;原生文件卡片路径原样传入。
|
|
30
30
|
|
|
31
31
|
-----
|
|
32
32
|
|
package/lib/index.js
CHANGED
|
@@ -188,12 +188,12 @@ function relativizeToCwd(text, cwd) {
|
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
190
|
* Address a decoded absolute file path through the authenticated file route.
|
|
191
|
-
* @param base - HTTP(S) application base, including its deployment prefix
|
|
191
|
+
* @param base - HTTP(S) application base, including its deployment prefix, or `dsh-app://app/`.
|
|
192
192
|
* @param path - Native file path; URL escapes in authored Markdown must already be decoded.
|
|
193
193
|
* @returns File URL, or undefined for unsupported transports and non-absolute paths.
|
|
194
194
|
*/
|
|
195
195
|
function fileMediaUrl(base, path) {
|
|
196
|
-
if (!/^https?:/u.test(base) || !isAbsoluteWorkspacePath(path) || /^[/\\]{2}/u.test(path) || /[\u0000-\u001f\u007f]/u.test(path)) return void 0;
|
|
196
|
+
if (!/^https?:/u.test(base) && !base.startsWith("dsh-app://app/") || !isAbsoluteWorkspacePath(path) || /^[/\\]{2}/u.test(path) || /[\u0000-\u001f\u007f]/u.test(path)) return void 0;
|
|
197
197
|
return new URL(`api/file?path=${encodeURIComponent(path)}`, base).href;
|
|
198
198
|
}
|
|
199
199
|
//#endregion
|
package/lib/types/index.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export declare function fileAddressFor(sessionId: string, cwd: string | undefine
|
|
|
59
59
|
export declare function relativizeToCwd(text: string, cwd: string | undefined): string;
|
|
60
60
|
/**
|
|
61
61
|
* Address a decoded absolute file path through the authenticated file route.
|
|
62
|
-
* @param base - HTTP(S) application base, including its deployment prefix
|
|
62
|
+
* @param base - HTTP(S) application base, including its deployment prefix, or `dsh-app://app/`.
|
|
63
63
|
* @param path - Native file path; URL escapes in authored Markdown must already be decoded.
|
|
64
64
|
* @returns File URL, or undefined for unsupported transports and non-absolute paths.
|
|
65
65
|
*/
|