@kerebron/extension-menu 0.4.2 → 0.4.4

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.
Files changed (146) hide show
  1. package/README.md +80 -0
  2. package/assets/custom-menu.css +26 -6
  3. package/assets/menu.css +2 -2
  4. package/esm/_dnt.polyfills.d.ts +101 -0
  5. package/esm/_dnt.polyfills.d.ts.map +1 -0
  6. package/esm/_dnt.polyfills.js +127 -0
  7. package/esm/_dnt.shims.d.ts +1 -5
  8. package/esm/_dnt.shims.d.ts.map +1 -1
  9. package/esm/_dnt.shims.js +1 -5
  10. package/esm/editor/src/utilities/getShadowRoot.d.ts +2 -0
  11. package/esm/editor/src/utilities/getShadowRoot.d.ts.map +1 -0
  12. package/esm/editor/src/utilities/getShadowRoot.js +16 -0
  13. package/esm/editor/src/utilities/mod.d.ts +6 -0
  14. package/esm/editor/src/utilities/mod.d.ts.map +1 -0
  15. package/esm/editor/src/utilities/mod.js +5 -0
  16. package/esm/editor/src/utilities/toRawTextResult.d.ts +3 -0
  17. package/esm/editor/src/utilities/toRawTextResult.d.ts.map +1 -0
  18. package/esm/editor/src/utilities/toRawTextResult.js +21 -0
  19. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts +8 -0
  20. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts.map +1 -0
  21. package/esm/extension-autocomplete/src/AutocompletePlugin.js +232 -0
  22. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts +17 -0
  23. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts.map +1 -0
  24. package/esm/extension-autocomplete/src/DefaultRenderer.js +137 -0
  25. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts +26 -0
  26. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts.map +1 -0
  27. package/esm/extension-autocomplete/src/ExtensionAutocomplete.js +30 -0
  28. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts +11 -0
  29. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts.map +1 -0
  30. package/esm/extension-autocomplete/src/createDefaultMatcher.js +58 -0
  31. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts +4 -0
  32. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts.map +1 -0
  33. package/esm/extension-autocomplete/src/createRegexMatcher.js +50 -0
  34. package/esm/extension-autocomplete/src/mod.d.ts +3 -0
  35. package/esm/extension-autocomplete/src/mod.d.ts.map +1 -0
  36. package/esm/extension-autocomplete/src/mod.js +2 -0
  37. package/esm/extension-autocomplete/src/types.d.ts +60 -0
  38. package/esm/extension-autocomplete/src/types.d.ts.map +1 -0
  39. package/esm/extension-autocomplete/src/types.js +1 -0
  40. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +15 -0
  41. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +1 -0
  42. package/esm/extension-basic-editor/src/ExtensionHtml.js +108 -0
  43. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts +32 -0
  44. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts.map +1 -0
  45. package/esm/extension-lsp/src/DiagnosticPlugin.js +131 -0
  46. package/esm/extension-lsp/src/ExtensionLsp.d.ts +25 -0
  47. package/esm/extension-lsp/src/ExtensionLsp.d.ts.map +1 -0
  48. package/esm/extension-lsp/src/ExtensionLsp.js +126 -0
  49. package/esm/extension-lsp/src/LSPClient.d.ts +56 -0
  50. package/esm/extension-lsp/src/LSPClient.d.ts.map +1 -0
  51. package/esm/extension-lsp/src/LSPClient.js +449 -0
  52. package/esm/extension-lsp/src/LspStatus.d.ts +34 -0
  53. package/esm/extension-lsp/src/LspStatus.d.ts.map +1 -0
  54. package/esm/extension-lsp/src/LspStatus.js +127 -0
  55. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts +8 -0
  56. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts.map +1 -0
  57. package/esm/extension-lsp/src/computeIncrementalChanges.js +82 -0
  58. package/esm/extension-lsp/src/createLspAutocomplete.d.ts +23 -0
  59. package/esm/extension-lsp/src/createLspAutocomplete.d.ts.map +1 -0
  60. package/esm/extension-lsp/src/createLspAutocomplete.js +68 -0
  61. package/esm/extension-lsp/src/workspace.d.ts +62 -0
  62. package/esm/extension-lsp/src/workspace.d.ts.map +1 -0
  63. package/esm/extension-lsp/src/workspace.js +168 -0
  64. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts +36 -0
  65. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts.map +1 -0
  66. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.js +240 -0
  67. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts +26 -0
  68. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts.map +1 -0
  69. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.js +115 -0
  70. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts +22 -0
  71. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts.map +1 -0
  72. package/esm/extension-markdown/src/ExtensionMarkdown.js +48 -0
  73. package/esm/extension-markdown/src/MarkdownParser.d.ts +61 -0
  74. package/esm/extension-markdown/src/MarkdownParser.d.ts.map +1 -0
  75. package/esm/extension-markdown/src/MarkdownParser.js +249 -0
  76. package/esm/extension-markdown/src/MarkdownSerializer.d.ts +42 -0
  77. package/esm/extension-markdown/src/MarkdownSerializer.d.ts.map +1 -0
  78. package/esm/extension-markdown/src/MarkdownSerializer.js +325 -0
  79. package/esm/extension-markdown/src/PositionMapper.d.ts +15 -0
  80. package/esm/extension-markdown/src/PositionMapper.d.ts.map +1 -0
  81. package/esm/extension-markdown/src/PositionMapper.js +100 -0
  82. package/esm/extension-markdown/src/TokenSource.d.ts +11 -0
  83. package/esm/extension-markdown/src/TokenSource.d.ts.map +1 -0
  84. package/esm/extension-markdown/src/TokenSource.js +39 -0
  85. package/esm/extension-markdown/src/mdToPmConverter.d.ts +5 -0
  86. package/esm/extension-markdown/src/mdToPmConverter.d.ts.map +1 -0
  87. package/esm/extension-markdown/src/mdToPmConverter.js +111 -0
  88. package/esm/extension-markdown/src/pmToMdConverter.d.ts +16 -0
  89. package/esm/extension-markdown/src/pmToMdConverter.d.ts.map +1 -0
  90. package/esm/extension-markdown/src/pmToMdConverter.js +433 -0
  91. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts +4 -0
  92. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts.map +1 -0
  93. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.js +151 -0
  94. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts +3 -0
  95. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts.map +1 -0
  96. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.js +34 -0
  97. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts +6 -0
  98. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts.map +1 -0
  99. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.js +380 -0
  100. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts +3 -0
  101. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts.map +1 -0
  102. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.js +323 -0
  103. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts +9 -0
  104. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts.map +1 -0
  105. package/esm/extension-markdown/src/token_handlers/table_token_handlers.js +308 -0
  106. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts +5 -0
  107. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts.map +1 -0
  108. package/esm/extension-markdown/src/treeSitterTokenizer.js +769 -0
  109. package/esm/extension-markdown/src/types.d.ts +28 -0
  110. package/esm/extension-markdown/src/types.d.ts.map +1 -0
  111. package/esm/extension-markdown/src/types.js +131 -0
  112. package/esm/extension-markdown/src/utils.d.ts +8 -0
  113. package/esm/extension-markdown/src/utils.d.ts.map +1 -0
  114. package/esm/extension-markdown/src/utils.js +86 -0
  115. package/esm/extension-menu/src/CustomMenuPlugin.d.ts +7 -3
  116. package/esm/extension-menu/src/CustomMenuPlugin.d.ts.map +1 -1
  117. package/esm/extension-menu/src/CustomMenuPlugin.js +60 -4
  118. package/esm/extension-menu/src/ExtensionCustomMenu.d.ts +6 -2
  119. package/esm/extension-menu/src/ExtensionCustomMenu.d.ts.map +1 -1
  120. package/esm/extension-menu/src/ExtensionCustomMenu.js +36 -1
  121. package/esm/extension-menu/src/menu.d.ts +1 -1
  122. package/esm/extension-menu/src/mod.d.ts +1 -0
  123. package/esm/extension-menu/src/mod.d.ts.map +1 -1
  124. package/esm/extension-menu/src/mod.js +1 -0
  125. package/esm/extension-yjs/src/CollaborationStatus.d.ts +59 -0
  126. package/esm/extension-yjs/src/CollaborationStatus.d.ts.map +1 -0
  127. package/esm/extension-yjs/src/CollaborationStatus.js +286 -0
  128. package/esm/tree-sitter-shim/src/main.d.ts +15 -0
  129. package/esm/tree-sitter-shim/src/main.d.ts.map +1 -0
  130. package/esm/tree-sitter-shim/src/main.js +25 -0
  131. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts +6 -0
  132. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts.map +1 -0
  133. package/esm/tree-sitter-shim/src/tree_sitter/node.js +1 -0
  134. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts +7 -0
  135. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts.map +1 -0
  136. package/esm/tree-sitter-shim/src/tree_sitter/parser.js +5 -0
  137. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts +6 -0
  138. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts.map +1 -0
  139. package/esm/tree-sitter-shim/src/tree_sitter/tree.js +1 -0
  140. package/esm/wasm/src/mod.d.ts +12 -0
  141. package/esm/wasm/src/mod.d.ts.map +1 -0
  142. package/esm/wasm/src/mod.js +48 -0
  143. package/esm/wasm/wasm.d.ts +138 -0
  144. package/esm/wasm/wasm.d.ts.map +1 -0
  145. package/esm/wasm/wasm.js +120 -0
  146. package/package.json +3 -2
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Compares two strings and computes the minimal set of text changes
3
+ * using a diff-based approach (simple line-by-line + character diff for simplicity).
4
+ * Returns an array of TextEdit-like changes that transform `previous` into `current`.
5
+ */
6
+ export function computeIncrementalChanges(previous, current) {
7
+ if (previous.length === 0) {
8
+ return [
9
+ {
10
+ text: current,
11
+ },
12
+ ];
13
+ }
14
+ const prevLines = previous.split(/\r\n|\r|\n/);
15
+ const currLines = current.split(/\r\n|\r|\n/);
16
+ const changes = [];
17
+ let startLine = 0;
18
+ let insertedText = '';
19
+ // Find common prefix
20
+ while (startLine < prevLines.length && startLine < currLines.length) {
21
+ if (prevLines[startLine] === currLines[startLine]) {
22
+ startLine++;
23
+ }
24
+ else {
25
+ break;
26
+ }
27
+ }
28
+ // If entire document is the same
29
+ if (startLine === prevLines.length &&
30
+ startLine === currLines.length) {
31
+ return changes; // No changes
32
+ }
33
+ // Find common suffix starting from the end
34
+ let endLinePrev = prevLines.length - 1;
35
+ let endLineCurr = currLines.length - 1;
36
+ while (endLinePrev >= startLine &&
37
+ endLineCurr >= startLine &&
38
+ prevLines[endLinePrev] === currLines[endLineCurr]) {
39
+ endLinePrev--;
40
+ endLineCurr--;
41
+ }
42
+ // Region to replace: from startLine to endLinePrev (inclusive)
43
+ const replaceStart = { line: startLine, character: 0 };
44
+ let replaceEnd;
45
+ if (endLinePrev >= startLine) {
46
+ const lastDeletedLine = prevLines[endLinePrev];
47
+ replaceEnd = {
48
+ line: endLinePrev,
49
+ character: lastDeletedLine.length,
50
+ };
51
+ }
52
+ else {
53
+ // Deletion ends at the start of the next line
54
+ replaceEnd = { line: startLine, character: 0 };
55
+ }
56
+ // Build inserted text: lines from startLine to endLineCurr
57
+ const insertedLines = currLines.slice(startLine, endLineCurr + 1);
58
+ insertedText = insertedLines.join('\n');
59
+ // If we're inserting at the end of the file, adjust range
60
+ if (startLine === prevLines.length) {
61
+ // Inserting after last line
62
+ replaceEnd = {
63
+ line: prevLines.length - 1,
64
+ character: prevLines[prevLines.length - 1].length,
65
+ };
66
+ if (insertedLines.length === 0) {
67
+ // Inserting empty at EOF
68
+ insertedText = '\n';
69
+ }
70
+ }
71
+ // Create the range for deletion
72
+ const range = {
73
+ start: replaceStart,
74
+ end: replaceEnd,
75
+ };
76
+ // Push the incremental change
77
+ changes.push({
78
+ range,
79
+ text: insertedText,
80
+ });
81
+ return changes;
82
+ }
@@ -0,0 +1,23 @@
1
+ import { DefaultRenderer } from '../../extension-autocomplete/src/DefaultRenderer.js';
2
+ import { TextRange } from '../../editor/src/mod.js';
3
+ import { type AutocompleteProps } from '../../extension-autocomplete/src/mod.js';
4
+ import { ExtensionLsp } from './ExtensionLsp.js';
5
+ interface CompletionItem {
6
+ label: string;
7
+ detail: string;
8
+ insertText: string;
9
+ }
10
+ export declare class CustomRenderer extends DefaultRenderer<CompletionItem> {
11
+ createListItem(item: CompletionItem, cnt: number): any;
12
+ }
13
+ export declare function cleanPlaceholders(input: string): string;
14
+ export declare function createLspAutocomplete(extensionLsp: ExtensionLsp): {
15
+ autocompleteConfig: {
16
+ renderer: CustomRenderer;
17
+ matchers: import("../../extension-autocomplete/src/types.js").AutocompleteMatcher[];
18
+ getItems: (query: string, props: AutocompleteProps) => Promise<CompletionItem[]>;
19
+ onSelect: (selected: CompletionItem, range: TextRange) => Promise<void>;
20
+ };
21
+ };
22
+ export {};
23
+ //# sourceMappingURL=createLspAutocomplete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createLspAutocomplete.d.ts","sourceRoot":"","sources":["../../../src/extension-lsp/src/createLspAutocomplete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AACtF,OAAO,EAAmB,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,cAAe,SAAQ,eAAe,CAAC,cAAc,CAAC;IACxD,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM;CAa1D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,YAAY;;;;0BAOpC,MAAM,SAAS,iBAAiB;6BAiC7B,cAAc,SAAS,SAAS;;EAiB9D"}
@@ -0,0 +1,68 @@
1
+ import { DefaultRenderer } from '../../extension-autocomplete/src/DefaultRenderer.js';
2
+ import { createRegexMatcher, } from '../../extension-autocomplete/src/mod.js';
3
+ export class CustomRenderer extends DefaultRenderer {
4
+ createListItem(item, cnt) {
5
+ const li = document.createElement('li');
6
+ if (cnt === this.pos) {
7
+ li.classList.add('active');
8
+ }
9
+ li.innerText = item.label;
10
+ li.title = item.detail;
11
+ li.style.cursor = 'pointer';
12
+ li.addEventListener('click', () => {
13
+ this.command(item);
14
+ });
15
+ return li;
16
+ }
17
+ }
18
+ export function cleanPlaceholders(input) {
19
+ const regex = /\$\{\d+:([^}]+)}/g;
20
+ return input.replace(regex, '$1');
21
+ }
22
+ export function createLspAutocomplete(extensionLsp) {
23
+ const editor = extensionLsp.getEditor();
24
+ const renderer = new CustomRenderer(editor);
25
+ const config = {
26
+ renderer,
27
+ matchers: [createRegexMatcher([/\w+/, /(^|\s)@\w*/, /^#\w*/])],
28
+ getItems: async (query, props) => {
29
+ const { mapper } = extensionLsp.source.getMappedContent();
30
+ const lspPos = mapper.toRawTextLspPos(props.range.from);
31
+ const client = extensionLsp.getClient(extensionLsp.mainLang);
32
+ if (client) {
33
+ client.sync();
34
+ try {
35
+ const completions = await client.request('textDocument/completion', {
36
+ textDocument: { uri: extensionLsp.uri },
37
+ position: lspPos,
38
+ context: { triggerKind: 2, triggerCharacter: query },
39
+ });
40
+ if (Array.isArray(completions)) {
41
+ return completions;
42
+ }
43
+ return completions.items;
44
+ }
45
+ catch (err) {
46
+ console.error(err.message);
47
+ return [];
48
+ }
49
+ }
50
+ else {
51
+ return [];
52
+ }
53
+ },
54
+ onSelect: async (selected, range) => {
55
+ const rawText = cleanPlaceholders(selected.insertText);
56
+ const slice = await extensionLsp.extensionMarkdown.fromMarkdown(rawText);
57
+ if (slice.content.content.length === 1) {
58
+ const first = slice.content.content[0];
59
+ if (first.isBlock) {
60
+ editor.chain().insertBlockSmart(range.from, first).run();
61
+ return;
62
+ }
63
+ }
64
+ editor.chain().replaceRangeSlice(range, slice).run();
65
+ },
66
+ };
67
+ return { autocompleteConfig: config };
68
+ }
@@ -0,0 +1,62 @@
1
+ import type * as lsp from 'vscode-languageserver-protocol';
2
+ import type { EditorUi } from '../../editor/src/mod.js';
3
+ import { LSPClient } from './LSPClient.js';
4
+ import { PositionMapper } from '../../extension-markdown/src/PositionMapper.js';
5
+ export interface LspSource {
6
+ ui: EditorUi;
7
+ getMappedContent(): {
8
+ content: string;
9
+ mapper: PositionMapper;
10
+ };
11
+ }
12
+ export interface WorkspaceFile {
13
+ uri: string;
14
+ languageId: string;
15
+ version: number;
16
+ content: string;
17
+ source: LspSource;
18
+ getUi(): EditorUi | undefined;
19
+ mapper: PositionMapper;
20
+ }
21
+ interface WorkspaceFileUpdate {
22
+ file: WorkspaceFile;
23
+ prevDoc: string;
24
+ changes: lsp.TextDocumentContentChangeEvent[];
25
+ }
26
+ export declare abstract class Workspace {
27
+ readonly client: LSPClient;
28
+ abstract files: WorkspaceFile[];
29
+ protected isConnected: boolean;
30
+ constructor(client: LSPClient);
31
+ getFile(uri: string): WorkspaceFile | null;
32
+ abstract syncFiles(): readonly WorkspaceFileUpdate[];
33
+ requestFile(uri: string): Promise<WorkspaceFile | null>;
34
+ abstract openFile(uri: string, languageId: string, source: LspSource): void;
35
+ abstract changedFile(uri: string): void;
36
+ abstract closeFile(uri: string): void;
37
+ connected(): Promise<void>;
38
+ disconnected(): void;
39
+ getUi(uri: string): Promise<EditorUi | undefined>;
40
+ }
41
+ declare class DefaultWorkspaceFile implements WorkspaceFile {
42
+ readonly uri: string;
43
+ readonly languageId: string;
44
+ version: number;
45
+ content: string;
46
+ mapper: PositionMapper;
47
+ source: LspSource;
48
+ syncedContent: string;
49
+ constructor(uri: string, languageId: string, version: number, content: string, mapper: PositionMapper, source: LspSource);
50
+ getUi(): EditorUi;
51
+ }
52
+ export declare class DefaultWorkspace extends Workspace {
53
+ files: DefaultWorkspaceFile[];
54
+ private fileVersions;
55
+ nextFileVersion(uri: string): number;
56
+ syncFiles(): WorkspaceFileUpdate[];
57
+ changedFile(uri: string): Promise<void>;
58
+ openFile(uri: string, languageId: string, source: LspSource): void;
59
+ closeFile(uri: string): void;
60
+ }
61
+ export {};
62
+ //# sourceMappingURL=workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/extension-lsp/src/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAC;AAG3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAGhF,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,QAAQ,CAAC;IACb,gBAAgB,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,cAAc,CAAA;KAAE,CAAC;CACjE;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAA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E,cAAc;IACtB,MAAM,EAAE,SAAS;IAPnB,aAAa,EAAE,MAAM,CAAM;gBAEvB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,SAAS;IAI1B,KAAK;CAGN;AAED,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,KAAK,EAAE,oBAAoB,EAAE,CAAM;IACnC,OAAO,CAAC,YAAY,CAAkD;IAEtE,eAAe,CAAC,GAAG,EAAE,MAAM;IAI3B,SAAS;IAaH,WAAW,CAAC,GAAG,EAAE,MAAM;IAkC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;IAsB3D,SAAS,CAAC,GAAG,EAAE,MAAM;CAOtB"}
@@ -0,0 +1,168 @@
1
+ import { TextDocumentSyncKind } from 'vscode-languageserver-protocol';
2
+ import { computeIncrementalChanges } from './computeIncrementalChanges.js';
3
+ export class Workspace {
4
+ constructor(client) {
5
+ Object.defineProperty(this, "client", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: client
10
+ });
11
+ Object.defineProperty(this, "isConnected", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: false
16
+ });
17
+ }
18
+ getFile(uri) {
19
+ return this.files.find((f) => f.uri == uri) || null;
20
+ }
21
+ requestFile(uri) {
22
+ return Promise.resolve(this.getFile(uri));
23
+ }
24
+ async connected() {
25
+ this.isConnected = true;
26
+ for await (const file of this.files) {
27
+ const result = await this.client.didOpen(file);
28
+ }
29
+ }
30
+ disconnected() {
31
+ for (const file of this.files) {
32
+ this.client.workspace.closeFile(file.uri);
33
+ }
34
+ this.isConnected = false;
35
+ }
36
+ getUi(uri) {
37
+ const file = this.getFile(uri);
38
+ return Promise.resolve(file ? file.getUi() : undefined);
39
+ }
40
+ }
41
+ class DefaultWorkspaceFile {
42
+ constructor(uri, languageId, version, content, mapper, source) {
43
+ Object.defineProperty(this, "uri", {
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true,
47
+ value: uri
48
+ });
49
+ Object.defineProperty(this, "languageId", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: languageId
54
+ });
55
+ Object.defineProperty(this, "version", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: version
60
+ });
61
+ Object.defineProperty(this, "content", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: content
66
+ });
67
+ Object.defineProperty(this, "mapper", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: mapper
72
+ });
73
+ Object.defineProperty(this, "source", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: source
78
+ });
79
+ Object.defineProperty(this, "syncedContent", {
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true,
83
+ value: ''
84
+ });
85
+ }
86
+ getUi() {
87
+ return this.source.ui;
88
+ }
89
+ }
90
+ export class DefaultWorkspace extends Workspace {
91
+ constructor() {
92
+ super(...arguments);
93
+ Object.defineProperty(this, "files", {
94
+ enumerable: true,
95
+ configurable: true,
96
+ writable: true,
97
+ value: []
98
+ });
99
+ Object.defineProperty(this, "fileVersions", {
100
+ enumerable: true,
101
+ configurable: true,
102
+ writable: true,
103
+ value: Object.create(null)
104
+ });
105
+ }
106
+ nextFileVersion(uri) {
107
+ return this.fileVersions[uri] = (this.fileVersions[uri] ?? -1) + 1;
108
+ }
109
+ syncFiles() {
110
+ if (!this.client.supportSync) {
111
+ return [];
112
+ }
113
+ const result = [];
114
+ for (const file of this.files) {
115
+ this.changedFile(file.uri);
116
+ }
117
+ return result;
118
+ }
119
+ async changedFile(uri) {
120
+ const file = this.files.find((f) => f.uri == uri) || null;
121
+ if (file) {
122
+ const { content, mapper } = file.source.getMappedContent();
123
+ if (!this.isConnected) {
124
+ file.content = content;
125
+ file.mapper = mapper;
126
+ return;
127
+ }
128
+ if (await this.client.notification('textDocument/didChange', {
129
+ textDocument: { uri: file.uri, version: file.version },
130
+ contentChanges: contentChangesFor(file, content, mapper, this.client.supportSync == TextDocumentSyncKind.Incremental),
131
+ })) {
132
+ file.syncedContent = file.content;
133
+ file.content = content;
134
+ file.mapper = mapper;
135
+ file.version = this.nextFileVersion(file.uri);
136
+ }
137
+ }
138
+ }
139
+ openFile(uri, languageId, source) {
140
+ // if (uri) {}
141
+ if (this.getFile(uri)) {
142
+ this.closeFile(uri);
143
+ }
144
+ const mappedContent = source.getMappedContent();
145
+ const { content, mapper } = mappedContent;
146
+ const file = new DefaultWorkspaceFile(uri, languageId, this.nextFileVersion(uri), content, mapper, source);
147
+ this.files.push(file);
148
+ this.client.didOpen(file);
149
+ }
150
+ closeFile(uri) {
151
+ const file = this.getFile(uri);
152
+ if (file) {
153
+ this.files = this.files.filter((f) => f.uri !== uri);
154
+ this.client.didClose(uri);
155
+ }
156
+ }
157
+ }
158
+ var Sync;
159
+ (function (Sync) {
160
+ Sync[Sync["AlwaysIfSmaller"] = 1024] = "AlwaysIfSmaller";
161
+ })(Sync || (Sync = {}));
162
+ function contentChangesFor(file, newContent, mapper, supportInc) {
163
+ if (!supportInc || newContent.length < Sync.AlwaysIfSmaller) {
164
+ return [{ text: newContent }];
165
+ }
166
+ const changes = computeIncrementalChanges(file.content, newContent);
167
+ return changes.reverse();
168
+ }
@@ -0,0 +1,36 @@
1
+ import type { Mark, Node } from 'prosemirror-model';
2
+ import { Token } from './types.js';
3
+ export type MarkTokenizerSpec = {
4
+ open?: string | ((mark: Mark) => Token);
5
+ close?: string | ((mark: Mark) => Token);
6
+ mixable?: boolean;
7
+ expelEnclosingWhitespace?: boolean;
8
+ escape?: boolean;
9
+ };
10
+ export type DocumentMarkdownTokenizerSpec = {
11
+ open?: string | ((node: Node) => Token);
12
+ close?: string | ((node: Node) => Token);
13
+ selfClose?: string | ((node: Node) => Token);
14
+ };
15
+ export declare class DocumentMarkdownInlineTokenizer {
16
+ readonly nodes: {
17
+ [node: string]: (node: Node, index: number) => DocumentMarkdownTokenizerSpec;
18
+ };
19
+ readonly marks: {
20
+ [mark: string]: MarkTokenizerSpec;
21
+ };
22
+ readonly options: {
23
+ hardBreakNodeName: string;
24
+ };
25
+ constructor(nodes: {
26
+ [node: string]: (node: Node, index: number) => DocumentMarkdownTokenizerSpec;
27
+ }, marks: {
28
+ [mark: string]: MarkTokenizerSpec;
29
+ }, options: {
30
+ hardBreakNodeName: string;
31
+ });
32
+ private getMark;
33
+ renderInline(parent: Node, currentPos: number, level: number): Array<Token>;
34
+ markString(mark: Mark, open: boolean, tokens: Token[]): void;
35
+ }
36
+ //# sourceMappingURL=DocumentMarkdownInlineTokenizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentMarkdownInlineTokenizer.d.ts","sourceRoot":"","sources":["../../../src/extension-markdown/src/DocumentMarkdownInlineTokenizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC;IACxC,KAAK,CAAC,EAA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