@deepseek-ai/dsh-client-ui-sidebar-documentpreview 0.2.0-rc.1 → 0.2.1-alpha.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 +4 -4
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/lib/client.frontmatter-fields.js +5768 -0
- package/lib/client.js +57 -5
- package/lib/types/client/markdown/MarkdownBody.d.ts +2 -0
- package/lib/types/client/markdown/frontmatter-fields.d.ts +20 -0
- package/lib/types/client/markdown/frontmatter.d.ts +13 -0
- package/package.json +24 -23
package/lib/client.js
CHANGED
|
@@ -1506,6 +1506,23 @@ window.__ModuleLoader__.load({
|
|
|
1506
1506
|
*/
|
|
1507
1507
|
const documentTabInfoFactory = (_standard, useTabInfo) => useTabInfo;
|
|
1508
1508
|
//#endregion
|
|
1509
|
+
//#region lib/types/client/markdown/frontmatter.js
|
|
1510
|
+
/** Leading YAML frontmatter split from a Markdown document before Markdown parsing. */
|
|
1511
|
+
const FRONTMATTER = /^\uFEFF?---[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??(?:---|\.\.\.)[ \t]*(?:\r?\n|$)/u;
|
|
1512
|
+
/**
|
|
1513
|
+
* Split a leading YAML frontmatter block from Markdown text without parsing its YAML.
|
|
1514
|
+
* @param text - Markdown source; an unterminated block is not frontmatter.
|
|
1515
|
+
* @returns frontmatter source and the remaining body, or `undefined` when the text has none.
|
|
1516
|
+
*/
|
|
1517
|
+
function splitFrontmatter(text) {
|
|
1518
|
+
const match = FRONTMATTER.exec(text);
|
|
1519
|
+
if (match === null) return void 0;
|
|
1520
|
+
return {
|
|
1521
|
+
source: match[1] ?? "",
|
|
1522
|
+
body: text.slice(match[0].length)
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
//#endregion
|
|
1509
1526
|
//#region lib/types/client/markdown/path-images.js
|
|
1510
1527
|
/** Local Markdown image destinations served by the authenticated file route. */
|
|
1511
1528
|
/**
|
|
@@ -1533,7 +1550,7 @@ window.__ModuleLoader__.load({
|
|
|
1533
1550
|
}
|
|
1534
1551
|
//#endregion
|
|
1535
1552
|
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-sidebar-documentpreview/src/client/markdown/MarkdownBody.module.css.mjs
|
|
1536
|
-
const css$7 = "._0RKuNG_document{min-width:0;font-family:var(--dsw-font,inherit);white-space:normal;padding:10px 12px}";
|
|
1553
|
+
const css$7 = "._0RKuNG_document{min-width:0;font-family:var(--dsw-font,inherit);white-space:normal;padding:10px 12px}._0RKuNG_frontmatter{border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);font:var(--dsw-font-markdown-small);color:var(--dsw-alias-label-primary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0 0 16px;padding:10px 12px}._0RKuNG_frontmatter:empty{display:none}._0RKuNG_frontmatterSource{font-family:var(--ds-font-family-code);white-space:inherit;margin:0}";
|
|
1537
1554
|
const tagId$7 = "@deepseek-ai/dsh-client-ui-sidebar-documentpreview/MarkdownBody.module.css";
|
|
1538
1555
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$7) + "]") === null) {
|
|
1539
1556
|
const tag = document.createElement("style");
|
|
@@ -1542,12 +1559,23 @@ window.__ModuleLoader__.load({
|
|
|
1542
1559
|
tag.textContent = css$7;
|
|
1543
1560
|
document.head.appendChild(tag);
|
|
1544
1561
|
}
|
|
1545
|
-
var MarkdownBody_module_css_default = {
|
|
1562
|
+
var MarkdownBody_module_css_default = {
|
|
1563
|
+
"document": "_0RKuNG_document",
|
|
1564
|
+
"frontmatter": "_0RKuNG_frontmatter",
|
|
1565
|
+
"frontmatterSource": "_0RKuNG_frontmatterSource"
|
|
1566
|
+
};
|
|
1546
1567
|
//#endregion
|
|
1547
1568
|
//#region lib/types/client/markdown/MarkdownBody.js
|
|
1548
1569
|
/** One retained Markdown renderer over the document owner's accumulated text. */
|
|
1570
|
+
/** Show the verbatim frontmatter when the field-list chunk cannot load. */
|
|
1571
|
+
function FrontmatterFallback({ fallback }) {
|
|
1572
|
+
return fallback;
|
|
1573
|
+
}
|
|
1574
|
+
const FrontmatterFields = (0, react.lazy)(() => require.async("./client.frontmatter-fields.js").then((module) => ({ default: module.FrontmatterFields }), () => ({ default: FrontmatterFallback })));
|
|
1549
1575
|
/**
|
|
1550
1576
|
* Render one accumulated document; EOF completes the primitive's full parse.
|
|
1577
|
+
* A leading YAML frontmatter block renders as a field list instead of Markdown; its
|
|
1578
|
+
* verbatim source stands in while the field-list chunk loads or when it fails.
|
|
1551
1579
|
* @param props - owner-loaded contents and localized primitive labels.
|
|
1552
1580
|
* @returns Markdown content, or nothing for a non-text delivery.
|
|
1553
1581
|
*/
|
|
@@ -1579,15 +1607,39 @@ window.__ModuleLoader__.load({
|
|
|
1579
1607
|
wrapLabel,
|
|
1580
1608
|
unwrapLabel
|
|
1581
1609
|
]);
|
|
1610
|
+
const text = content.kind === "text" ? content.text : "";
|
|
1611
|
+
const split = (0, react.useMemo)(() => splitFrontmatter(text), [text]);
|
|
1582
1612
|
if (content.kind !== "text") return null;
|
|
1583
|
-
return (0, react_jsx_runtime.
|
|
1613
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
1584
1614
|
className: MarkdownBody_module_css_default.document,
|
|
1585
1615
|
"data-document-markdown": true,
|
|
1586
|
-
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MarkdownText, {
|
|
1587
|
-
text:
|
|
1616
|
+
children: [split === void 0 ? null : (0, react_jsx_runtime.jsx)(FrontmatterBox, { source: split.source }), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MarkdownText, {
|
|
1617
|
+
text: split?.body ?? text,
|
|
1588
1618
|
streaming: !content.eof,
|
|
1589
1619
|
labels,
|
|
1590
1620
|
pathImages
|
|
1621
|
+
})]
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Frame one frontmatter block and choose its field list or verbatim source.
|
|
1626
|
+
* @param props - YAML between the frontmatter delimiters.
|
|
1627
|
+
* @returns the metadata box; it collapses when the document has no content.
|
|
1628
|
+
*/
|
|
1629
|
+
function FrontmatterBox({ source }) {
|
|
1630
|
+
const verbatim = (0, react_jsx_runtime.jsx)("pre", {
|
|
1631
|
+
className: MarkdownBody_module_css_default.frontmatterSource,
|
|
1632
|
+
children: source
|
|
1633
|
+
});
|
|
1634
|
+
return (0, react_jsx_runtime.jsx)("div", {
|
|
1635
|
+
className: MarkdownBody_module_css_default.frontmatter,
|
|
1636
|
+
"data-document-frontmatter": true,
|
|
1637
|
+
children: (0, react_jsx_runtime.jsx)(react.Suspense, {
|
|
1638
|
+
fallback: verbatim,
|
|
1639
|
+
children: (0, react_jsx_runtime.jsx)(FrontmatterFields, {
|
|
1640
|
+
source,
|
|
1641
|
+
fallback: verbatim
|
|
1642
|
+
})
|
|
1591
1643
|
})
|
|
1592
1644
|
});
|
|
1593
1645
|
}
|
|
@@ -5,6 +5,8 @@ import type { DocumentPreviewProps } from '../document/contract.ts';
|
|
|
5
5
|
export type MarkdownBodyProps = DocumentPreviewProps & PropsLocale<'documentMarkdown'>;
|
|
6
6
|
/**
|
|
7
7
|
* Render one accumulated document; EOF completes the primitive's full parse.
|
|
8
|
+
* A leading YAML frontmatter block renders as a field list instead of Markdown; its
|
|
9
|
+
* verbatim source stands in while the field-list chunk loads or when it fails.
|
|
8
10
|
* @param props - owner-loaded contents and localized primitive labels.
|
|
9
11
|
* @returns Markdown content, or nothing for a non-text delivery.
|
|
10
12
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field list for a Markdown document's leading YAML frontmatter. The Markdown
|
|
3
|
+
* body loads this module lazily so the YAML parser stays out of the startup
|
|
4
|
+
* chunk.
|
|
5
|
+
*/
|
|
6
|
+
import { type ReactNode } from 'react';
|
|
7
|
+
/** Owner inputs for the lazily loaded field list. */
|
|
8
|
+
export interface FrontmatterFieldsProps {
|
|
9
|
+
/** YAML between the frontmatter delimiters. */
|
|
10
|
+
source: string;
|
|
11
|
+
/** Verbatim block shown for invalid YAML and non-mapping documents. */
|
|
12
|
+
fallback: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Render frontmatter fields, or the owner's verbatim block when the YAML is not a mapping.
|
|
16
|
+
* @param props - frontmatter source and its verbatim fallback.
|
|
17
|
+
* @returns the field list, the fallback, or nothing for a document without content.
|
|
18
|
+
*/
|
|
19
|
+
export declare function FrontmatterFields({ source, fallback }: FrontmatterFieldsProps): ReactNode;
|
|
20
|
+
//# sourceMappingURL=frontmatter-fields.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Leading YAML frontmatter split from a Markdown document before Markdown parsing. */
|
|
2
|
+
/** Frontmatter source between its delimiters and the Markdown body after the closing delimiter. */
|
|
3
|
+
export interface FrontmatterSplit {
|
|
4
|
+
source: string;
|
|
5
|
+
body: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Split a leading YAML frontmatter block from Markdown text without parsing its YAML.
|
|
9
|
+
* @param text - Markdown source; an unterminated block is not frontmatter.
|
|
10
|
+
* @returns frontmatter source and the remaining body, or `undefined` when the text has none.
|
|
11
|
+
*/
|
|
12
|
+
export declare function splitFrontmatter(text: string): FrontmatterSplit | undefined;
|
|
13
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-client-ui-sidebar-documentpreview",
|
|
3
3
|
"description": "Extensible Sidebar previews for Office documents, spreadsheets, Markdown, code, images, PDF, HTML, and plain text",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1-alpha.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
45
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@fortune-sheet/core": "1.0.4",
|
|
@@ -61,26 +61,27 @@
|
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-dom": "^18.2.0",
|
|
63
63
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
|
64
|
-
"
|
|
65
|
-
"@deepseek-ai/
|
|
66
|
-
"@deepseek-ai/dsh-api-
|
|
67
|
-
"@deepseek-ai/dsh-api-
|
|
68
|
-
"@deepseek-ai/dsh-
|
|
69
|
-
"@deepseek-ai/dsh-client-
|
|
70
|
-
"@deepseek-ai/dsh-client-
|
|
71
|
-
"@deepseek-ai/dsh-client-
|
|
72
|
-
"@deepseek-ai/dsh-client-
|
|
73
|
-
"@deepseek-ai/dsh-client-
|
|
74
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.2.
|
|
75
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.2.
|
|
76
|
-
"@deepseek-ai/dsh-client-ui-
|
|
77
|
-
"@deepseek-ai/dsh-client-ui-
|
|
78
|
-
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.
|
|
79
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.
|
|
80
|
-
"@deepseek-ai/dsh-office-to-pdf": "0.2.
|
|
81
|
-
"@deepseek-ai/dsh-host-webserver": "0.2.
|
|
82
|
-
"@deepseek-ai/dsh-session": "0.2.
|
|
83
|
-
"@deepseek-ai/dsh-util-workspace-path": "0.2.
|
|
64
|
+
"yaml": "^2.9.0",
|
|
65
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1",
|
|
66
|
+
"@deepseek-ai/dsh-api-gateway": "0.2.1-alpha.1",
|
|
67
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.1-alpha.1",
|
|
68
|
+
"@deepseek-ai/dsh-api-workspace-files": "0.2.1-alpha.1",
|
|
69
|
+
"@deepseek-ai/dsh-client-connection": "0.2.1-alpha.1",
|
|
70
|
+
"@deepseek-ai/dsh-client-resources": "0.2.1-alpha.1",
|
|
71
|
+
"@deepseek-ai/dsh-client-test-runtime": "0.2.1-alpha.1",
|
|
72
|
+
"@deepseek-ai/dsh-client-ui-dockkit": "0.2.1-alpha.1",
|
|
73
|
+
"@deepseek-ai/dsh-client-store": "0.2.1-alpha.1",
|
|
74
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.1-alpha.1",
|
|
75
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.1-alpha.1",
|
|
76
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.1-alpha.1",
|
|
77
|
+
"@deepseek-ai/dsh-client-ui-session": "0.2.1-alpha.1",
|
|
78
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.1-alpha.1",
|
|
79
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-alpha.1",
|
|
80
|
+
"@deepseek-ai/dsh-office-to-pdf": "0.2.1-alpha.1",
|
|
81
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.1-alpha.1",
|
|
82
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.1",
|
|
83
|
+
"@deepseek-ai/dsh-util-workspace-path": "0.2.1-alpha.1",
|
|
84
|
+
"@deepseek-ai/dsh-client-locale": "0.2.1-alpha.1"
|
|
84
85
|
},
|
|
85
86
|
"files": [
|
|
86
87
|
"lib/index.js",
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
"lib/types/**/*.d.ts"
|
|
90
91
|
],
|
|
91
92
|
"dependencies": {
|
|
92
|
-
"@deepseek-ai/schemastery": "~3.18.
|
|
93
|
+
"@deepseek-ai/schemastery": "~3.18.5-alpha.1"
|
|
93
94
|
},
|
|
94
95
|
"scripts": {
|
|
95
96
|
"bundle": "tsdown",
|