@bevel-software/platform-shared 0.25.2 → 0.27.0
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/git/pr.types.d.ts +101 -0
- package/dist/git/pr.types.d.ts.map +1 -1
- package/dist/git/types.d.ts +76 -2
- package/dist/git/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/workflow/events.d.ts +24 -1
- package/dist/workflow/events.d.ts.map +1 -1
- package/dist/workflow/events.js +1 -0
- package/dist/workflow/events.js.map +1 -1
- package/dist/workflow/interface.d.ts +42 -1
- package/dist/workflow/interface.d.ts.map +1 -1
- package/dist/workflow/types.d.ts +57 -3
- package/dist/workflow/types.d.ts.map +1 -1
- package/dist/workspace/kb-layout.d.ts +40 -101
- package/dist/workspace/kb-layout.d.ts.map +1 -1
- package/dist/workspace/kb-layout.js +40 -159
- package/dist/workspace/kb-layout.js.map +1 -1
- package/dist/workspace/md-links.d.ts +138 -0
- package/dist/workspace/md-links.d.ts.map +1 -0
- package/dist/workspace/md-links.js +703 -0
- package/dist/workspace/md-links.js.map +1 -0
- package/dist/workspace/platform-files.d.ts +25 -24
- package/dist/workspace/platform-files.d.ts.map +1 -1
- package/dist/workspace/platform-files.js +41 -25
- package/dist/workspace/platform-files.js.map +1 -1
- package/package.json +1 -1
- package/src/git/pr.types.ts +99 -0
- package/src/git/types.ts +80 -2
- package/src/index.ts +1 -0
- package/src/workflow/events.ts +26 -0
- package/src/workflow/interface.ts +42 -0
- package/src/workflow/types.ts +48 -4
- package/src/workspace/kb-layout.ts +39 -172
- package/src/workspace/md-links.ts +757 -0
- package/src/workspace/platform-files.ts +44 -26
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The markdown link grammar a move rewrites with: where the links in a page
|
|
3
|
+
* are, what each one points at, and how to point it somewhere else without
|
|
4
|
+
* changing anything else about it.
|
|
5
|
+
*
|
|
6
|
+
* Pure and dependency-free, so the backend's move and the web app can share
|
|
7
|
+
* it. The resolver half is the web app's (`resolveKbHref` in the frontend's
|
|
8
|
+
* `routing/kb-routes.ts`) restated here; a parity test there holds the two to
|
|
9
|
+
* one answer on a shared fixture set.
|
|
10
|
+
*
|
|
11
|
+
* What it deliberately is NOT: a markdown parser. It finds link
|
|
12
|
+
* DESTINATIONS — inline links, images, reference definitions, and the inline
|
|
13
|
+
* links in a node's frontmatter (the `nodeType` link) — as character spans, so
|
|
14
|
+
* a rewrite splices the new destination into the old one's place and every
|
|
15
|
+
* other byte of the file stays as it was. Code — fenced blocks, indented
|
|
16
|
+
* blocks and inline code — is skipped: a path written there is an example,
|
|
17
|
+
* not a link.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* An id-link destination: a node's frontmatter id (`project-hexis`), optionally
|
|
21
|
+
* with a heading anchor. The web app's `NODE_ID_LINK_RE`, restated: an id-link
|
|
22
|
+
* points at a node wherever it lives, so a move never changes one.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MD_ID_LINK_RE: RegExp;
|
|
25
|
+
/** One link destination found in a page. */
|
|
26
|
+
export interface MdLinkSpan {
|
|
27
|
+
/** `link` and `image` are inline (`[x](d)`, ``); `definition` is `[x]: d`. */
|
|
28
|
+
kind: 'link' | 'image' | 'definition';
|
|
29
|
+
/** Offsets of the destination as written, angle brackets excluded. */
|
|
30
|
+
start: number;
|
|
31
|
+
end: number;
|
|
32
|
+
/** The destination as written (`text.slice(start, end)`). */
|
|
33
|
+
destination: string;
|
|
34
|
+
/** Written as `<dest>`. */
|
|
35
|
+
angle: boolean;
|
|
36
|
+
/** Inside the `---` frontmatter block. */
|
|
37
|
+
inFrontmatter: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Every link destination in a markdown page, in document order. Code is
|
|
41
|
+
* skipped: fenced blocks (``` and ~~~, in lists and quotes too) and inline code
|
|
42
|
+
* spans. A footnote (`[^1]: …`) is not a reference definition.
|
|
43
|
+
*/
|
|
44
|
+
export declare function scanMarkdownLinks(text: string): MdLinkSpan[];
|
|
45
|
+
/**
|
|
46
|
+
* The `href`/`src` values of the raw HTML tags a markdown page carries —
|
|
47
|
+
* what the app renders as a link or a picture that the markdown grammar does
|
|
48
|
+
* not rewrite. Only an unescaped `<tag …>` outside code counts: a tag in a
|
|
49
|
+
* fence, a code span or behind a `\<` is an example, and a bare `href=` in
|
|
50
|
+
* prose is prose.
|
|
51
|
+
*/
|
|
52
|
+
export declare function scanMarkdownHtmlLinks(text: string): HtmlLinkTarget[];
|
|
53
|
+
/**
|
|
54
|
+
* The `href`/`src` values in an HTML page. A move never rewrites an HTML page
|
|
55
|
+
* (most of its links are built in scripts nobody can see), so these are only
|
|
56
|
+
* read, to report the page.
|
|
57
|
+
*/
|
|
58
|
+
export declare function scanHtmlLinks(text: string): string[];
|
|
59
|
+
/** One `href` or `src` value in an HTML tag; `image` says which — a `src` is a picture, and a picture resolves as one. */
|
|
60
|
+
export interface HtmlLinkTarget {
|
|
61
|
+
destination: string;
|
|
62
|
+
image: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** {@link scanHtmlLinks}, with each value's attribute kept: `src` is an image, `href` a link. */
|
|
65
|
+
export declare function scanHtmlLinkTargets(text: string): HtmlLinkTarget[];
|
|
66
|
+
/** How a link names its target, which a rewrite keeps. */
|
|
67
|
+
export type MdLinkForm = 'relative' | 'root' | 'workspace';
|
|
68
|
+
/** A link destination that names a file or folder in the workspace. */
|
|
69
|
+
export interface ResolvedMdLink {
|
|
70
|
+
form: MdLinkForm;
|
|
71
|
+
/** Workspace-relative (`knowledge-base/…`), decoded. */
|
|
72
|
+
path: string;
|
|
73
|
+
/** `#anchor` as written, or ''. */
|
|
74
|
+
hash: string;
|
|
75
|
+
/** The branch a `/workspace/<branch>/…` link names; null otherwise. */
|
|
76
|
+
branch: string | null;
|
|
77
|
+
}
|
|
78
|
+
export interface ResolveMdLinkOptions {
|
|
79
|
+
/** The workspace-relative file the link sits in. */
|
|
80
|
+
basePath: string;
|
|
81
|
+
/** The clone folder (`knowledge-base`), for the mangled-path repair. */
|
|
82
|
+
kbDirName: string | null;
|
|
83
|
+
/** An image source gets no mangled-path repair (see the web app's resolver). */
|
|
84
|
+
image?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** An href as a browser reads it: outer controls and spaces off, inner tabs and line breaks out. */
|
|
87
|
+
export declare function normalizeMdHref(href: string): string;
|
|
88
|
+
/** `relative` against the file `basePath`, as the web app resolves it. */
|
|
89
|
+
export declare function resolveMdRelativePath(basePath: string, relative: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* What a destination written in `basePath` points at, or null when it names
|
|
92
|
+
* no workspace path a move could affect: an external URL, an id-link, a
|
|
93
|
+
* same-page `#anchor`, or a bare `/workspace/<branch>`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function resolveMdLink(destination: string, opts: ResolveMdLinkOptions): ResolvedMdLink | null;
|
|
96
|
+
/**
|
|
97
|
+
* The destination `span` must carry once its file sits at `newBase` and its
|
|
98
|
+
* target at `newTarget`, in the form it was written in: relative stays
|
|
99
|
+
* relative (`./` and a trailing `/` kept), root-anchored stays root-anchored,
|
|
100
|
+
* an app URL keeps its branch segment; encoding, anchor — and, because only
|
|
101
|
+
* the destination is spliced, the title — stay as they were.
|
|
102
|
+
*/
|
|
103
|
+
export declare function retargetMdDestination(span: Pick<MdLinkSpan, 'destination' | 'angle' | 'inFrontmatter'>, resolved: ResolvedMdLink, newBase: string, newTarget: string): string;
|
|
104
|
+
/** One destination a rewrite changed. */
|
|
105
|
+
export interface MdLinkEdit {
|
|
106
|
+
from: string;
|
|
107
|
+
to: string;
|
|
108
|
+
}
|
|
109
|
+
export interface RewriteMdLinksOptions {
|
|
110
|
+
/** Where the file is now (workspace-relative). */
|
|
111
|
+
oldPath: string;
|
|
112
|
+
/** Where the file will be after the move (`oldPath` when it does not move). */
|
|
113
|
+
newPath: string;
|
|
114
|
+
/** A workspace path's place after the move, or null when it does not move. */
|
|
115
|
+
mapPath: (path: string) => string | null;
|
|
116
|
+
kbDirName: string | null;
|
|
117
|
+
/** The branch the move happens on: a link (not an image) to another branch's app URL is left alone. */
|
|
118
|
+
branch: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Rewrite the links in one markdown page so that, once it sits at `newPath`
|
|
122
|
+
* and every moved path is at its new place, each points at the same target it
|
|
123
|
+
* did before. A link that already does is left alone, as is every byte that is
|
|
124
|
+
* not a changed destination.
|
|
125
|
+
*/
|
|
126
|
+
export declare function rewriteMdLinks(text: string, opts: RewriteMdLinksOptions): {
|
|
127
|
+
text: string;
|
|
128
|
+
edits: MdLinkEdit[];
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The destinations in an HTML page that point at a moved path, or (for a page
|
|
132
|
+
* that moves itself) whose relative target the move would break. Reported,
|
|
133
|
+
* never rewritten.
|
|
134
|
+
*/
|
|
135
|
+
export declare function htmlLinksAffectedByMove(text: string, opts: RewriteMdLinksOptions,
|
|
136
|
+
/** The targets to judge: an HTML page's by default, a markdown page's from {@link scanMarkdownHtmlLinks}. */
|
|
137
|
+
targets?: HtmlLinkTarget[]): string[];
|
|
138
|
+
//# sourceMappingURL=md-links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-links.d.ts","sourceRoot":"","sources":["../../src/workspace/md-links.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;GAIG;AACH,eAAO,MAAM,aAAa,QAAmC,CAAC;AAK9D,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,qFAAqF;IACrF,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;IACtC,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAA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