@deepseek-ai/dsh-util-workspace-path 0.1.7-alpha.2 → 0.1.7-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 +2 -2
- package/README.md +2 -0
- package/README.zh.md +2 -0
- package/lib/index.js +11 -1
- package/lib/types/index.d.ts +7 -0
- package/package.json +1 -1
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
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
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 2de3157ee8bbe5ea216be303c1a1520d4b92126c
|
|
6
|
+
README.zh.md: b46402b0ecf4025224768a29af1ea984ff7d497f
|
package/README.md
CHANGED
|
@@ -26,6 +26,8 @@ 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 non-HTTP 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
|
+
|
|
29
31
|
-----
|
|
30
32
|
|
|
31
33
|
## Known Limitations and Deferred Work
|
package/README.zh.md
CHANGED
|
@@ -26,6 +26,8 @@ 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,保留字面量百分号与部署前缀,并拒绝非 HTTP 应用基址、相对路径、网络路径前缀和控制字符。Markdown 调用方先解码所写 URL;原生文件卡片路径原样传入。
|
|
30
|
+
|
|
29
31
|
-----
|
|
30
32
|
|
|
31
33
|
## 已知限制与暂缓事项
|
package/lib/index.js
CHANGED
|
@@ -186,5 +186,15 @@ function relativizeToCwd(text, cwd) {
|
|
|
186
186
|
if (text.startsWith(`${root}/`) || text.startsWith(`${root}\\`)) return text.slice(root.length + 1);
|
|
187
187
|
return text;
|
|
188
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Address a decoded absolute file path through the authenticated file route.
|
|
191
|
+
* @param base - HTTP(S) application base, including its deployment prefix.
|
|
192
|
+
* @param path - Native file path; URL escapes in authored Markdown must already be decoded.
|
|
193
|
+
* @returns File URL, or undefined for unsupported transports and non-absolute paths.
|
|
194
|
+
*/
|
|
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;
|
|
197
|
+
return new URL(`api/file?path=${encodeURIComponent(path)}`, base).href;
|
|
198
|
+
}
|
|
189
199
|
//#endregion
|
|
190
|
-
export { abbreviateHomePath, absoluteFileAddress, fileAddressFor, isAbsoluteWorkspacePath, parseFileAddress, pathPartsOf, relativizeToCwd, resolveWorkspacePath, sessionFileAddress, workspaceTitleOf };
|
|
200
|
+
export { abbreviateHomePath, absoluteFileAddress, fileAddressFor, fileMediaUrl, isAbsoluteWorkspacePath, parseFileAddress, pathPartsOf, relativizeToCwd, resolveWorkspacePath, sessionFileAddress, workspaceTitleOf };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -57,4 +57,11 @@ export declare function fileAddressFor(sessionId: string, cwd: string | undefine
|
|
|
57
57
|
* @returns the path relative to the workspace root, or unchanged when it is not rooted there.
|
|
58
58
|
*/
|
|
59
59
|
export declare function relativizeToCwd(text: string, cwd: string | undefined): string;
|
|
60
|
+
/**
|
|
61
|
+
* Address a decoded absolute file path through the authenticated file route.
|
|
62
|
+
* @param base - HTTP(S) application base, including its deployment prefix.
|
|
63
|
+
* @param path - Native file path; URL escapes in authored Markdown must already be decoded.
|
|
64
|
+
* @returns File URL, or undefined for unsupported transports and non-absolute paths.
|
|
65
|
+
*/
|
|
66
|
+
export declare function fileMediaUrl(base: string, path: string): string | undefined;
|
|
60
67
|
//# sourceMappingURL=index.d.ts.map
|