@morlay/dsh-client-ui-primitives 0.0.2-alpha.3 → 0.0.2-alpha.5

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/dist/client.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as isLocalReference, i as formatReference, n as ReferenceSpan, o as parseReference, r as findReferences, s as parseReferenceToken, t as Reference } from "./reference-Do8Uwujy.cjs";
1
+ import { a as formatReferenceMention, c as parseReferenceToken, i as formatReference, n as ReferenceSpan, o as isLocalReference, r as findReferences, s as parseReference, t as Reference } from "./reference-BX54bj6_.cjs";
2
2
  import { Context } from "@deepseek-ai/cordis";
3
3
  import { ComponentProps, ComponentPropsWithRef, ElementType, ForwardRefExoticComponent, Ref, RefAttributes } from "react";
4
4
  import { MarkdownFileMentions, MarkdownLabels, MarkdownLabels as MarkdownLabels$1, MarkdownPathImages } from "@deepseek-ai/dsh-client-ui-primitives";
@@ -10880,4 +10880,4 @@ declare const ReferenceMarkdown: import("react").MemoExoticComponent<({ text, la
10880
10880
  declare const inject: readonly string[];
10881
10881
  declare function apply(_ctx: Context): void;
10882
10882
  //#endregion
10883
- export { type CSSObject, type CSSProps, type CSSSelector, type CSSValue, type CSSVar, type CSSVarRef, MarkdownCopySeat, type Reference, type ReferenceActions, ReferenceMarkdown, type ReferenceMarkdownProps, type ReferenceSpan, type StyledComponent, Styling, Token, type TokenVars, type Tokens, apply, designTokens, dsw, findReferences, formatReference, inject, isLocalReference, markdownLabels, parseReference, parseReferenceToken, referenceMentions, styleOf, styled, styling };
10883
+ export { type CSSObject, type CSSProps, type CSSSelector, type CSSValue, type CSSVar, type CSSVarRef, MarkdownCopySeat, type Reference, type ReferenceActions, ReferenceMarkdown, type ReferenceMarkdownProps, type ReferenceSpan, type StyledComponent, Styling, Token, type TokenVars, type Tokens, apply, designTokens, dsw, findReferences, formatReference, formatReferenceMention, inject, isLocalReference, markdownLabels, parseReference, parseReferenceToken, referenceMentions, styleOf, styled, styling };
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as isLocalReference, i as formatReference, n as ReferenceSpan, o as parseReference, r as findReferences, s as parseReferenceToken, t as Reference } from "./reference-Do8Uwujy.mjs";
1
+ import { a as formatReferenceMention, c as parseReferenceToken, i as formatReference, n as ReferenceSpan, o as isLocalReference, r as findReferences, s as parseReference, t as Reference } from "./reference-BX54bj6_.mjs";
2
2
  import { ComponentProps, ComponentPropsWithRef, ElementType, ForwardRefExoticComponent, Ref, RefAttributes } from "react";
3
3
  import { MarkdownFileMentions, MarkdownLabels, MarkdownLabels as MarkdownLabels$1, MarkdownPathImages } from "@deepseek-ai/dsh-client-ui-primitives";
4
4
  import { Context } from "@deepseek-ai/cordis";
@@ -10880,4 +10880,4 @@ declare const ReferenceMarkdown: import("react").MemoExoticComponent<({ text, la
10880
10880
  declare const inject: readonly string[];
10881
10881
  declare function apply(_ctx: Context): void;
10882
10882
  //#endregion
10883
- export { type CSSObject, type CSSProps, type CSSSelector, type CSSValue, type CSSVar, type CSSVarRef, MarkdownCopySeat, type Reference, type ReferenceActions, ReferenceMarkdown, type ReferenceMarkdownProps, type ReferenceSpan, type StyledComponent, Styling, Token, type TokenVars, type Tokens, apply, designTokens, dsw, findReferences, formatReference, inject, isLocalReference, markdownLabels, parseReference, parseReferenceToken, referenceMentions, styleOf, styled, styling };
10883
+ export { type CSSObject, type CSSProps, type CSSSelector, type CSSValue, type CSSVar, type CSSVarRef, MarkdownCopySeat, type Reference, type ReferenceActions, ReferenceMarkdown, type ReferenceMarkdownProps, type ReferenceSpan, type StyledComponent, Styling, Token, type TokenVars, type Tokens, apply, designTokens, dsw, findReferences, formatReference, formatReferenceMention, inject, isLocalReference, markdownLabels, parseReference, parseReferenceToken, referenceMentions, styleOf, styled, styling };
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ReferenceSpan, r as findReferences, s as parseReferenceToken, t as Reference } from "./reference-Do8Uwujy.cjs";
1
+ import { c as parseReferenceToken, n as ReferenceSpan, r as findReferences, t as Reference } from "./reference-BX54bj6_.cjs";
2
2
  //#region src/index.d.ts
3
3
  declare function apply(): void;
4
4
  //#endregion
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ReferenceSpan, r as findReferences, s as parseReferenceToken, t as Reference } from "./reference-Do8Uwujy.mjs";
1
+ import { c as parseReferenceToken, n as ReferenceSpan, r as findReferences, t as Reference } from "./reference-BX54bj6_.mjs";
2
2
  //#region src/index.d.ts
3
3
  declare function apply(): void;
4
4
  //#endregion
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as parseReferenceToken, t as findReferences } from "./reference-BLcMVsqa.mjs";
1
+ import { o as parseReferenceToken, t as findReferences } from "./reference-Dxy9uQYz.mjs";
2
2
  //#region src/index.ts
3
3
  function apply() {}
4
4
  //#endregion
@@ -24,6 +24,7 @@ declare function parseReference(value: string, title?: string): Reference | unde
24
24
  declare function parseReferenceToken(value: string): Reference | undefined;
25
25
  declare function formatReference(reference: Reference): string;
26
26
  declare function isLocalReference(reference: Reference): boolean;
27
+ declare function formatReferenceMention(reference: Reference): string;
27
28
  declare function findReferences(text: string): readonly ReferenceSpan[];
28
29
  //#endregion
29
- export { isLocalReference as a, formatReference as i, ReferenceSpan as n, parseReference as o, findReferences as r, parseReferenceToken as s, Reference as t };
30
+ export { formatReferenceMention as a, parseReferenceToken as c, formatReference as i, ReferenceSpan as n, isLocalReference as o, findReferences as r, parseReference as s, Reference as t };
@@ -24,6 +24,7 @@ declare function parseReference(value: string, title?: string): Reference | unde
24
24
  declare function parseReferenceToken(value: string): Reference | undefined;
25
25
  declare function formatReference(reference: Reference): string;
26
26
  declare function isLocalReference(reference: Reference): boolean;
27
+ declare function formatReferenceMention(reference: Reference): string;
27
28
  declare function findReferences(text: string): readonly ReferenceSpan[];
28
29
  //#endregion
29
- export { isLocalReference as a, formatReference as i, ReferenceSpan as n, parseReference as o, findReferences as r, parseReferenceToken as s, Reference as t };
30
+ export { formatReferenceMention as a, parseReferenceToken as c, formatReference as i, ReferenceSpan as n, isLocalReference as o, findReferences as r, parseReference as s, Reference as t };
@@ -1,6 +1,6 @@
1
1
  import { fromMarkdown } from "mdast-util-from-markdown";
2
2
  import { gfmFromMarkdown } from "mdast-util-gfm";
3
- import { asciiAlpha, asciiAlphanumeric, asciiDigit, markdownLineEndingOrSpace, unicodePunctuation, unicodeWhitespace } from "micromark-util-character";
3
+ import { asciiAlpha, asciiAlphanumeric, asciiDigit, markdownLineEnding, markdownLineEndingOrSpace, unicodePunctuation, unicodeWhitespace } from "micromark-util-character";
4
4
  import { gfm } from "micromark-extension-gfm";
5
5
  import { codes, types } from "micromark-util-symbol";
6
6
  //#region src/reference.ts
@@ -13,6 +13,7 @@ const EXTERNAL_PROTOCOLS = [
13
13
  const LINE_FRAGMENT = /^L(\d+)(?:C(\d+))?(?:-L(\d+))?$/u;
14
14
  const SCHEME = /^([A-Za-z][A-Za-z0-9+.-]*):/u;
15
15
  const BARE_PATH = /^([^:]+):(\d+)(?::(\d+))?$/u;
16
+ const MENTION_WHITESPACE = /\s/u;
16
17
  const URI_UNSAFE = /[%#()\s<>"`]/gu;
17
18
  const PATH_PUNCTUATION = [
18
19
  codes.slash,
@@ -69,6 +70,10 @@ function formatReference(reference) {
69
70
  function isLocalReference(reference) {
70
71
  return !EXTERNAL_PROTOCOLS.includes(reference.protocol);
71
72
  }
73
+ function formatReferenceMention(reference) {
74
+ const path = reference.path ?? "";
75
+ return MENTION_WHITESPACE.test(path) ? `@"${path}"` : `@${path}`;
76
+ }
72
77
  function findReferences(text) {
73
78
  const spans = [];
74
79
  if (text === "" || !TRIGGERS.some((trigger) => text.includes(trigger))) return spans;
@@ -125,8 +130,29 @@ const tokenizeReference = function(effects, ok, nok) {
125
130
  return headStart(code);
126
131
  }
127
132
  function afterAt(code) {
133
+ if (code === codes.quotationMark) {
134
+ effects.consume(code);
135
+ return quotedPath;
136
+ }
128
137
  return asciiAlpha(code) ? headStart(code) : pathStart(code);
129
138
  }
139
+ function quotedPath(code) {
140
+ if (code === null || markdownLineEnding(code)) return nok(code);
141
+ effects.consume(code);
142
+ return code === codes.quotationMark ? afterQuotedPath : quotedPath;
143
+ }
144
+ function afterQuotedPath(code) {
145
+ if (code !== codes.numberSign) return finish(code);
146
+ effects.consume(code);
147
+ return fragmentInside;
148
+ }
149
+ function fragmentInside(code) {
150
+ if (isPathCode(code) || code === codes.numberSign) {
151
+ effects.consume(code);
152
+ return fragmentInside;
153
+ }
154
+ return finish(code);
155
+ }
130
156
  function headStart(code) {
131
157
  if (!asciiAlpha(code)) return nok(code);
132
158
  head = "";
@@ -325,6 +351,7 @@ function textOf(node) {
325
351
  function parseBareReference(raw) {
326
352
  const body = raw.startsWith("@") ? raw.slice(1) : raw;
327
353
  if (body === "") return void 0;
354
+ if (body.startsWith(QUOTED_PATH)) return parseQuotedReference(body);
328
355
  const scheme = SCHEME.exec(body);
329
356
  if (scheme !== null && isKnownScheme(scheme[1])) return parseReference(body);
330
357
  const matched = BARE_PATH.exec(body);
@@ -341,6 +368,21 @@ function parseBareReference(raw) {
341
368
  ...column === void 0 ? {} : { column: Number(column) }
342
369
  };
343
370
  }
371
+ /** 引号 mention 的起手字符:`@"path with spaces"`。 */
372
+ const QUOTED_PATH = "\"";
373
+ function parseQuotedReference(body) {
374
+ const end = body.indexOf(QUOTED_PATH, 1);
375
+ if (end === -1) return void 0;
376
+ const path = body.slice(1, end);
377
+ if (path === "") return void 0;
378
+ const fragment = splitLineFragment(body.slice(end + 1));
379
+ if (fragment.head !== "") return void 0;
380
+ return {
381
+ protocol: DEFAULT_PROTOCOL,
382
+ path,
383
+ ...fragment.lines
384
+ };
385
+ }
344
386
  function referenceFromMarkdown() {
345
387
  return {
346
388
  enter: { reference: enterReference },
@@ -403,4 +445,4 @@ function decodeUri(value) {
403
445
  }
404
446
  }
405
447
  //#endregion
406
- export { parseReferenceToken as a, parseReference as i, formatReference as n, isLocalReference as r, findReferences as t };
448
+ export { parseReference as a, isLocalReference as i, formatReference as n, parseReferenceToken as o, formatReferenceMention as r, findReferences as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morlay/dsh-client-ui-primitives",
3
- "version": "0.0.2-alpha.3",
3
+ "version": "0.0.2-alpha.5",
4
4
  "description": "css-in-js styling kit (styled / Token / Styling) for the forked conversation UI: consumes the official --dsw-* design tokens, so no CSS Modules precompile step is needed.",
5
5
  "keywords": [
6
6
  "client",
@@ -7,6 +7,7 @@ export * from "./markdown-labels.ts";
7
7
  export {
8
8
  findReferences,
9
9
  formatReference,
10
+ formatReferenceMention,
10
11
  isLocalReference,
11
12
  parseReference,
12
13
  parseReferenceToken,