@kerebron/extension-menu 0.4.3 → 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.
- package/README.md +80 -0
- package/assets/custom-menu.css +26 -6
- package/assets/menu.css +2 -2
- package/esm/_dnt.polyfills.d.ts +101 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +127 -0
- package/esm/editor/src/utilities/getShadowRoot.d.ts +2 -0
- package/esm/editor/src/utilities/getShadowRoot.d.ts.map +1 -0
- package/esm/editor/src/utilities/getShadowRoot.js +16 -0
- package/esm/editor/src/utilities/mod.d.ts +6 -0
- package/esm/editor/src/utilities/mod.d.ts.map +1 -0
- package/esm/editor/src/utilities/mod.js +5 -0
- package/esm/editor/src/utilities/toRawTextResult.d.ts +3 -0
- package/esm/editor/src/utilities/toRawTextResult.d.ts.map +1 -0
- package/esm/editor/src/utilities/toRawTextResult.js +21 -0
- package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts +8 -0
- package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/AutocompletePlugin.js +232 -0
- package/esm/extension-autocomplete/src/DefaultRenderer.d.ts +17 -0
- package/esm/extension-autocomplete/src/DefaultRenderer.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/DefaultRenderer.js +137 -0
- package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts +26 -0
- package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/ExtensionAutocomplete.js +30 -0
- package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts +11 -0
- package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/createDefaultMatcher.js +58 -0
- package/esm/extension-autocomplete/src/createRegexMatcher.d.ts +4 -0
- package/esm/extension-autocomplete/src/createRegexMatcher.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/createRegexMatcher.js +50 -0
- package/esm/extension-autocomplete/src/mod.d.ts +3 -0
- package/esm/extension-autocomplete/src/mod.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/mod.js +2 -0
- package/esm/extension-autocomplete/src/types.d.ts +60 -0
- package/esm/extension-autocomplete/src/types.d.ts.map +1 -0
- package/esm/extension-autocomplete/src/types.js +1 -0
- package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +15 -0
- package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/ExtensionHtml.js +108 -0
- package/esm/extension-lsp/src/DiagnosticPlugin.d.ts +32 -0
- package/esm/extension-lsp/src/DiagnosticPlugin.d.ts.map +1 -0
- package/esm/extension-lsp/src/DiagnosticPlugin.js +131 -0
- package/esm/extension-lsp/src/ExtensionLsp.d.ts +25 -0
- package/esm/extension-lsp/src/ExtensionLsp.d.ts.map +1 -0
- package/esm/extension-lsp/src/ExtensionLsp.js +126 -0
- package/esm/extension-lsp/src/LSPClient.d.ts +56 -0
- package/esm/extension-lsp/src/LSPClient.d.ts.map +1 -0
- package/esm/extension-lsp/src/LSPClient.js +449 -0
- package/esm/extension-lsp/src/LspStatus.d.ts +34 -0
- package/esm/extension-lsp/src/LspStatus.d.ts.map +1 -0
- package/esm/extension-lsp/src/LspStatus.js +127 -0
- package/esm/extension-lsp/src/computeIncrementalChanges.d.ts +8 -0
- package/esm/extension-lsp/src/computeIncrementalChanges.d.ts.map +1 -0
- package/esm/extension-lsp/src/computeIncrementalChanges.js +82 -0
- package/esm/extension-lsp/src/createLspAutocomplete.d.ts +23 -0
- package/esm/extension-lsp/src/createLspAutocomplete.d.ts.map +1 -0
- package/esm/extension-lsp/src/createLspAutocomplete.js +68 -0
- package/esm/extension-lsp/src/workspace.d.ts +62 -0
- package/esm/extension-lsp/src/workspace.d.ts.map +1 -0
- package/esm/extension-lsp/src/workspace.js +168 -0
- package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts +36 -0
- package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts.map +1 -0
- package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.js +240 -0
- package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts +26 -0
- package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts.map +1 -0
- package/esm/extension-markdown/src/DocumentMarkdownTokenizer.js +115 -0
- package/esm/extension-markdown/src/ExtensionMarkdown.d.ts +22 -0
- package/esm/extension-markdown/src/ExtensionMarkdown.d.ts.map +1 -0
- package/esm/extension-markdown/src/ExtensionMarkdown.js +48 -0
- package/esm/extension-markdown/src/MarkdownParser.d.ts +61 -0
- package/esm/extension-markdown/src/MarkdownParser.d.ts.map +1 -0
- package/esm/extension-markdown/src/MarkdownParser.js +249 -0
- package/esm/extension-markdown/src/MarkdownSerializer.d.ts +42 -0
- package/esm/extension-markdown/src/MarkdownSerializer.d.ts.map +1 -0
- package/esm/extension-markdown/src/MarkdownSerializer.js +325 -0
- package/esm/extension-markdown/src/PositionMapper.d.ts +15 -0
- package/esm/extension-markdown/src/PositionMapper.d.ts.map +1 -0
- package/esm/extension-markdown/src/PositionMapper.js +100 -0
- package/esm/extension-markdown/src/TokenSource.d.ts +11 -0
- package/esm/extension-markdown/src/TokenSource.d.ts.map +1 -0
- package/esm/extension-markdown/src/TokenSource.js +39 -0
- package/esm/extension-markdown/src/mdToPmConverter.d.ts +5 -0
- package/esm/extension-markdown/src/mdToPmConverter.d.ts.map +1 -0
- package/esm/extension-markdown/src/mdToPmConverter.js +111 -0
- package/esm/extension-markdown/src/pmToMdConverter.d.ts +16 -0
- package/esm/extension-markdown/src/pmToMdConverter.d.ts.map +1 -0
- package/esm/extension-markdown/src/pmToMdConverter.js +433 -0
- package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts +4 -0
- package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts.map +1 -0
- package/esm/extension-markdown/src/token_handlers/basic_token_handlers.js +151 -0
- package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts +3 -0
- package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts.map +1 -0
- package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.js +34 -0
- package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts +6 -0
- package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts.map +1 -0
- package/esm/extension-markdown/src/token_handlers/inline_token_handlers.js +380 -0
- package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts +3 -0
- package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts.map +1 -0
- package/esm/extension-markdown/src/token_handlers/lists_token_handlers.js +323 -0
- package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts +9 -0
- package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts.map +1 -0
- package/esm/extension-markdown/src/token_handlers/table_token_handlers.js +308 -0
- package/esm/extension-markdown/src/treeSitterTokenizer.d.ts +5 -0
- package/esm/extension-markdown/src/treeSitterTokenizer.d.ts.map +1 -0
- package/esm/extension-markdown/src/treeSitterTokenizer.js +769 -0
- package/esm/extension-markdown/src/types.d.ts +28 -0
- package/esm/extension-markdown/src/types.d.ts.map +1 -0
- package/esm/extension-markdown/src/types.js +131 -0
- package/esm/extension-markdown/src/utils.d.ts +8 -0
- package/esm/extension-markdown/src/utils.d.ts.map +1 -0
- package/esm/extension-markdown/src/utils.js +86 -0
- package/esm/extension-menu/src/CustomMenuPlugin.d.ts +7 -3
- package/esm/extension-menu/src/CustomMenuPlugin.d.ts.map +1 -1
- package/esm/extension-menu/src/CustomMenuPlugin.js +60 -4
- package/esm/extension-menu/src/ExtensionCustomMenu.d.ts +6 -2
- package/esm/extension-menu/src/ExtensionCustomMenu.d.ts.map +1 -1
- package/esm/extension-menu/src/ExtensionCustomMenu.js +36 -1
- package/esm/extension-menu/src/mod.d.ts +1 -0
- package/esm/extension-menu/src/mod.d.ts.map +1 -1
- package/esm/extension-menu/src/mod.js +1 -0
- package/esm/extension-yjs/src/CollaborationStatus.d.ts +59 -0
- package/esm/extension-yjs/src/CollaborationStatus.d.ts.map +1 -0
- package/esm/extension-yjs/src/CollaborationStatus.js +286 -0
- package/esm/tree-sitter-shim/src/main.d.ts +15 -0
- package/esm/tree-sitter-shim/src/main.d.ts.map +1 -0
- package/esm/tree-sitter-shim/src/main.js +25 -0
- package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts +6 -0
- package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts.map +1 -0
- package/esm/tree-sitter-shim/src/tree_sitter/node.js +1 -0
- package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts +7 -0
- package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts.map +1 -0
- package/esm/tree-sitter-shim/src/tree_sitter/parser.js +5 -0
- package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts +6 -0
- package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts.map +1 -0
- package/esm/tree-sitter-shim/src/tree_sitter/tree.js +1 -0
- package/esm/wasm/src/mod.d.ts +12 -0
- package/esm/wasm/src/mod.d.ts.map +1 -0
- package/esm/wasm/src/mod.js +48 -0
- package/esm/wasm/wasm.d.ts +138 -0
- package/esm/wasm/wasm.d.ts.map +1 -0
- package/esm/wasm/wasm.js +120 -0
- package/package.json +4 -2
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
+
const CSS_PREFIX = 'kb-collab-status';
|
|
3
|
+
/**
|
|
4
|
+
* Plugin key for accessing collaboration status state
|
|
5
|
+
*/
|
|
6
|
+
export const collaborationStatusPluginKey = new PluginKey('collaboration-status');
|
|
7
|
+
/**
|
|
8
|
+
* Creates a ProseMirror plugin that tracks collaboration status and user presence.
|
|
9
|
+
* This plugin maintains state that can be accessed by other components.
|
|
10
|
+
*/
|
|
11
|
+
export function collaborationStatusPlugin(awareness, options = {}) {
|
|
12
|
+
return new Plugin({
|
|
13
|
+
key: collaborationStatusPluginKey,
|
|
14
|
+
state: {
|
|
15
|
+
init() {
|
|
16
|
+
return {
|
|
17
|
+
status: 'connecting',
|
|
18
|
+
users: getUsers(awareness),
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
apply(tr, value) {
|
|
22
|
+
const meta = tr.getMeta(collaborationStatusPluginKey);
|
|
23
|
+
if (meta) {
|
|
24
|
+
return { ...value, ...meta };
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
view(editorView) {
|
|
30
|
+
const updateUsers = () => {
|
|
31
|
+
const users = getUsers(awareness);
|
|
32
|
+
editorView.dispatch(editorView.state.tr.setMeta(collaborationStatusPluginKey, { users }));
|
|
33
|
+
};
|
|
34
|
+
awareness.on('change', updateUsers);
|
|
35
|
+
return {
|
|
36
|
+
destroy() {
|
|
37
|
+
awareness.off('change', updateUsers);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function getUsers(awareness) {
|
|
44
|
+
const users = [];
|
|
45
|
+
awareness.getStates().forEach((state, clientId) => {
|
|
46
|
+
if (state.user) {
|
|
47
|
+
users.push({
|
|
48
|
+
clientId,
|
|
49
|
+
name: state.user.name || `User ${clientId}`,
|
|
50
|
+
color: state.user.color || '#888888',
|
|
51
|
+
colorLight: state.user.colorLight,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return users;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A menu element that displays collaboration status, user count, and a dropdown of users.
|
|
59
|
+
*/
|
|
60
|
+
export class CollaborationStatusElement {
|
|
61
|
+
constructor(options) {
|
|
62
|
+
Object.defineProperty(this, "awareness", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: void 0
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(this, "provider", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true,
|
|
72
|
+
value: void 0
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(this, "dom", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
configurable: true,
|
|
77
|
+
writable: true,
|
|
78
|
+
value: null
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(this, "statusDot", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: null
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(this, "userCount", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true,
|
|
89
|
+
writable: true,
|
|
90
|
+
value: null
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(this, "dropdown", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
configurable: true,
|
|
95
|
+
writable: true,
|
|
96
|
+
value: null
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(this, "userList", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
configurable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
value: null
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(this, "isOpen", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
configurable: true,
|
|
107
|
+
writable: true,
|
|
108
|
+
value: false
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(this, "status", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
configurable: true,
|
|
113
|
+
writable: true,
|
|
114
|
+
value: 'connecting'
|
|
115
|
+
});
|
|
116
|
+
this.awareness = options.awareness;
|
|
117
|
+
this.provider = options.provider;
|
|
118
|
+
}
|
|
119
|
+
render(view) {
|
|
120
|
+
// Create main container
|
|
121
|
+
this.dom = document.createElement('div');
|
|
122
|
+
this.dom.className = `${CSS_PREFIX}`;
|
|
123
|
+
this.dom.setAttribute('role', 'button');
|
|
124
|
+
this.dom.setAttribute('aria-haspopup', 'true');
|
|
125
|
+
this.dom.setAttribute('aria-expanded', 'false');
|
|
126
|
+
// Create status indicator button
|
|
127
|
+
const button = document.createElement('button');
|
|
128
|
+
button.type = 'button';
|
|
129
|
+
button.className = `${CSS_PREFIX}__button`;
|
|
130
|
+
button.title = 'Collaboration status';
|
|
131
|
+
button.setAttribute('aria-label', 'Collaboration status');
|
|
132
|
+
// Status dot
|
|
133
|
+
this.statusDot = document.createElement('span');
|
|
134
|
+
this.statusDot.className =
|
|
135
|
+
`${CSS_PREFIX}__dot ${CSS_PREFIX}__dot--connecting`;
|
|
136
|
+
button.appendChild(this.statusDot);
|
|
137
|
+
// User count badge
|
|
138
|
+
this.userCount = document.createElement('span');
|
|
139
|
+
this.userCount.className = `${CSS_PREFIX}__count`;
|
|
140
|
+
this.userCount.textContent = '0';
|
|
141
|
+
button.appendChild(this.userCount);
|
|
142
|
+
// Dropdown chevron
|
|
143
|
+
const chevron = document.createElement('span');
|
|
144
|
+
chevron.className = `${CSS_PREFIX}__chevron`;
|
|
145
|
+
chevron.innerHTML =
|
|
146
|
+
`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>`;
|
|
147
|
+
button.appendChild(chevron);
|
|
148
|
+
this.dom.appendChild(button);
|
|
149
|
+
// Create dropdown
|
|
150
|
+
this.dropdown = document.createElement('div');
|
|
151
|
+
this.dropdown.className = `${CSS_PREFIX}__dropdown`;
|
|
152
|
+
this.dropdown.style.display = 'none';
|
|
153
|
+
// Dropdown header
|
|
154
|
+
const header = document.createElement('div');
|
|
155
|
+
header.className = `${CSS_PREFIX}__header`;
|
|
156
|
+
header.textContent = 'Collaborators';
|
|
157
|
+
this.dropdown.appendChild(header);
|
|
158
|
+
// User list
|
|
159
|
+
this.userList = document.createElement('div');
|
|
160
|
+
this.userList.className = `${CSS_PREFIX}__users`;
|
|
161
|
+
this.dropdown.appendChild(this.userList);
|
|
162
|
+
this.dom.appendChild(this.dropdown);
|
|
163
|
+
// Event handlers
|
|
164
|
+
button.addEventListener('click', (e) => {
|
|
165
|
+
e.preventDefault();
|
|
166
|
+
e.stopPropagation();
|
|
167
|
+
this.toggleDropdown();
|
|
168
|
+
});
|
|
169
|
+
// Close on outside click
|
|
170
|
+
const closeHandler = (e) => {
|
|
171
|
+
if (this.isOpen && this.dom && !this.dom.contains(e.target)) {
|
|
172
|
+
this.closeDropdown();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
document.addEventListener('click', closeHandler);
|
|
176
|
+
// Listen for awareness changes
|
|
177
|
+
const awarenessChangeHandler = () => {
|
|
178
|
+
this.updateUserList();
|
|
179
|
+
};
|
|
180
|
+
this.awareness.on('change', awarenessChangeHandler);
|
|
181
|
+
// Listen for provider status changes
|
|
182
|
+
if (this.provider && typeof this.provider.on === 'function') {
|
|
183
|
+
this.provider.on('status', (event) => {
|
|
184
|
+
this.setStatus(event.status);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
// Initial update
|
|
188
|
+
this.updateUserList();
|
|
189
|
+
const update = (_state) => {
|
|
190
|
+
// Always visible
|
|
191
|
+
return true;
|
|
192
|
+
};
|
|
193
|
+
return { dom: this.dom, update };
|
|
194
|
+
}
|
|
195
|
+
setStatus(status) {
|
|
196
|
+
this.status = status;
|
|
197
|
+
if (this.statusDot) {
|
|
198
|
+
this.statusDot.className =
|
|
199
|
+
`${CSS_PREFIX}__dot ${CSS_PREFIX}__dot--${status}`;
|
|
200
|
+
}
|
|
201
|
+
if (this.dom) {
|
|
202
|
+
this.dom.setAttribute('data-status', status);
|
|
203
|
+
const button = this.dom.querySelector('button');
|
|
204
|
+
if (button) {
|
|
205
|
+
const statusLabels = {
|
|
206
|
+
connected: 'Connected',
|
|
207
|
+
connecting: 'Connecting...',
|
|
208
|
+
disconnected: 'Disconnected',
|
|
209
|
+
};
|
|
210
|
+
button.title = `${statusLabels[status]} - Click to see collaborators`;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
updateUserList() {
|
|
215
|
+
if (!this.userList || !this.userCount)
|
|
216
|
+
return;
|
|
217
|
+
const users = getUsers(this.awareness);
|
|
218
|
+
const currentClientId = this.awareness.clientID;
|
|
219
|
+
// Update count (including self)
|
|
220
|
+
this.userCount.textContent = String(users.length);
|
|
221
|
+
// Clear and rebuild user list
|
|
222
|
+
this.userList.innerHTML = '';
|
|
223
|
+
if (users.length === 0) {
|
|
224
|
+
const emptyMessage = document.createElement('div');
|
|
225
|
+
emptyMessage.className = `${CSS_PREFIX}__empty`;
|
|
226
|
+
emptyMessage.textContent = 'No users connected';
|
|
227
|
+
this.userList.appendChild(emptyMessage);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
// Sort users: current user first, then alphabetically
|
|
231
|
+
const sortedUsers = [...users].sort((a, b) => {
|
|
232
|
+
if (a.clientId === currentClientId)
|
|
233
|
+
return -1;
|
|
234
|
+
if (b.clientId === currentClientId)
|
|
235
|
+
return 1;
|
|
236
|
+
return a.name.localeCompare(b.name);
|
|
237
|
+
});
|
|
238
|
+
sortedUsers.forEach((user) => {
|
|
239
|
+
const userItem = document.createElement('div');
|
|
240
|
+
userItem.className = `${CSS_PREFIX}__user`;
|
|
241
|
+
// Color indicator
|
|
242
|
+
const colorDot = document.createElement('span');
|
|
243
|
+
colorDot.className = `${CSS_PREFIX}__user-color`;
|
|
244
|
+
colorDot.style.backgroundColor = user.color;
|
|
245
|
+
userItem.appendChild(colorDot);
|
|
246
|
+
// User name
|
|
247
|
+
const userName = document.createElement('span');
|
|
248
|
+
userName.className = `${CSS_PREFIX}__user-name`;
|
|
249
|
+
userName.textContent = user.name;
|
|
250
|
+
userItem.appendChild(userName);
|
|
251
|
+
// "You" badge for current user
|
|
252
|
+
if (user.clientId === currentClientId) {
|
|
253
|
+
const youBadge = document.createElement('span');
|
|
254
|
+
youBadge.className = `${CSS_PREFIX}__you-badge`;
|
|
255
|
+
youBadge.textContent = '(you)';
|
|
256
|
+
userItem.appendChild(youBadge);
|
|
257
|
+
}
|
|
258
|
+
this.userList.appendChild(userItem);
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
toggleDropdown() {
|
|
262
|
+
if (this.isOpen) {
|
|
263
|
+
this.closeDropdown();
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
this.openDropdown();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
openDropdown() {
|
|
270
|
+
if (!this.dropdown || !this.dom)
|
|
271
|
+
return;
|
|
272
|
+
this.isOpen = true;
|
|
273
|
+
this.dropdown.style.display = 'block';
|
|
274
|
+
this.dom.setAttribute('aria-expanded', 'true');
|
|
275
|
+
this.dom.classList.add(`${CSS_PREFIX}--open`);
|
|
276
|
+
this.updateUserList(); // Refresh on open
|
|
277
|
+
}
|
|
278
|
+
closeDropdown() {
|
|
279
|
+
if (!this.dropdown || !this.dom)
|
|
280
|
+
return;
|
|
281
|
+
this.isOpen = false;
|
|
282
|
+
this.dropdown.style.display = 'none';
|
|
283
|
+
this.dom.setAttribute('aria-expanded', 'false');
|
|
284
|
+
this.dom.classList.remove(`${CSS_PREFIX}--open`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility shim for deno_tree_sitter -> web-tree-sitter
|
|
3
|
+
* This provides the same createParser API that deno_tree_sitter exports
|
|
4
|
+
*/
|
|
5
|
+
import Parser from 'web-tree-sitter';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a tree-sitter parser from WASM binary data.
|
|
8
|
+
* Compatible with deno_tree_sitter's createParser API.
|
|
9
|
+
*
|
|
10
|
+
* @param wasmBinary - The WASM binary data (Uint8Array or ArrayBuffer)
|
|
11
|
+
* @returns A configured Parser instance with the language set
|
|
12
|
+
*/
|
|
13
|
+
export declare function createParser(wasmBinary: Uint8Array | ArrayBuffer): Promise<Parser>;
|
|
14
|
+
export { Parser };
|
|
15
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/tree-sitter-shim/src/main.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,UAAU,GAAG,WAAW,GACnC,OAAO,CAAC,MAAM,CAAC,CAWjB;AAGD,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility shim for deno_tree_sitter -> web-tree-sitter
|
|
3
|
+
* This provides the same createParser API that deno_tree_sitter exports
|
|
4
|
+
*/
|
|
5
|
+
import Parser from 'web-tree-sitter';
|
|
6
|
+
let initialized = false;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a tree-sitter parser from WASM binary data.
|
|
9
|
+
* Compatible with deno_tree_sitter's createParser API.
|
|
10
|
+
*
|
|
11
|
+
* @param wasmBinary - The WASM binary data (Uint8Array or ArrayBuffer)
|
|
12
|
+
* @returns A configured Parser instance with the language set
|
|
13
|
+
*/
|
|
14
|
+
export async function createParser(wasmBinary) {
|
|
15
|
+
if (!initialized) {
|
|
16
|
+
await Parser.init();
|
|
17
|
+
initialized = true;
|
|
18
|
+
}
|
|
19
|
+
const parser = new Parser();
|
|
20
|
+
const language = await Parser.Language.load(wasmBinary);
|
|
21
|
+
parser.setLanguage(language);
|
|
22
|
+
return parser;
|
|
23
|
+
}
|
|
24
|
+
// Re-export other items from main.js for compatibility
|
|
25
|
+
export { Parser };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../src/tree-sitter-shim/src/tree_sitter/node.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAE1C,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../../src/tree-sitter-shim/src/tree_sitter/parser.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,YAAY,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../../src/tree-sitter-shim/src/tree_sitter/tree.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAE1C,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import manifest from '../wasm.js';
|
|
2
|
+
export declare function getLangsList(): string[];
|
|
3
|
+
export declare function getLangTreeSitter(lang: string, cdnUrl?: string): {
|
|
4
|
+
lang: string;
|
|
5
|
+
repo: string;
|
|
6
|
+
files: string[];
|
|
7
|
+
queries: any;
|
|
8
|
+
};
|
|
9
|
+
export declare function fetchWasm(wasmUrl: string): Promise<Uint8Array>;
|
|
10
|
+
export declare function fetchTextResource(url: string): Promise<string>;
|
|
11
|
+
export { manifest };
|
|
12
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/wasm/src/mod.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAIlC,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAMvC;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,SAAgC;;;;;EAuBvC;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAWpE;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAapE;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
+
import manifest from '../wasm.js';
|
|
3
|
+
const __dirname = globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).dirname;
|
|
4
|
+
export function getLangsList() {
|
|
5
|
+
return manifest
|
|
6
|
+
.map((item) => item.repo.split('-').pop())
|
|
7
|
+
.filter((item) => 'string' === typeof item);
|
|
8
|
+
}
|
|
9
|
+
export function getLangTreeSitter(lang, cdnUrl = 'http://localhost:8000/wasm/') {
|
|
10
|
+
const langManifest = manifest.find((item) => item.repo.endsWith('-' + lang));
|
|
11
|
+
if (!langManifest) {
|
|
12
|
+
throw new Error('No grammar for: ' + lang);
|
|
13
|
+
}
|
|
14
|
+
if (!cdnUrl.endsWith('/')) {
|
|
15
|
+
cdnUrl += '/';
|
|
16
|
+
}
|
|
17
|
+
const dir = langManifest.repo.split('/')[1];
|
|
18
|
+
cdnUrl += dir + '/';
|
|
19
|
+
const queries = Object.entries(langManifest.queries)
|
|
20
|
+
.map((entry) => [entry[0], cdnUrl + entry[0]]);
|
|
21
|
+
return {
|
|
22
|
+
lang,
|
|
23
|
+
repo: langManifest.repo,
|
|
24
|
+
files: langManifest.files.map((file) => cdnUrl + file),
|
|
25
|
+
queries: Object.fromEntries(queries),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export async function fetchWasm(wasmUrl) {
|
|
29
|
+
if ('Deno' in dntShim.dntGlobalThis) { // Test or server-side
|
|
30
|
+
return globalThis.Deno.readFileSync(__dirname + '/../files' + wasmUrl);
|
|
31
|
+
}
|
|
32
|
+
const response = await fetch(wasmUrl);
|
|
33
|
+
if (response.status >= 400) {
|
|
34
|
+
throw new Error(`Error fetching ${response.status}`);
|
|
35
|
+
}
|
|
36
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
37
|
+
}
|
|
38
|
+
export async function fetchTextResource(url) {
|
|
39
|
+
if ('Deno' in dntShim.dntGlobalThis) {
|
|
40
|
+
return new TextDecoder().decode(globalThis.Deno.readFileSync(__dirname + '/../files' + url));
|
|
41
|
+
}
|
|
42
|
+
const responseScm = await fetch(url);
|
|
43
|
+
if (responseScm.status >= 400) {
|
|
44
|
+
throw new Error(`Error fetching ${responseScm.status}`);
|
|
45
|
+
}
|
|
46
|
+
return await responseScm.text();
|
|
47
|
+
}
|
|
48
|
+
export { manifest };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
declare const _default: ({
|
|
2
|
+
repo: string;
|
|
3
|
+
version: string;
|
|
4
|
+
files: string[];
|
|
5
|
+
queries: {
|
|
6
|
+
"highlights.scm": string;
|
|
7
|
+
"injections.scm": string;
|
|
8
|
+
"highlights-inline.scm": string;
|
|
9
|
+
"injections-inline.scm": string;
|
|
10
|
+
"highlights-dtd.scm"?: undefined;
|
|
11
|
+
"tags.scm"?: undefined;
|
|
12
|
+
"locals.scm"?: undefined;
|
|
13
|
+
"highlights-jsx.scm"?: undefined;
|
|
14
|
+
"highlights-params.scm"?: undefined;
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
repo: string;
|
|
18
|
+
version: string;
|
|
19
|
+
files: string[];
|
|
20
|
+
queries: {
|
|
21
|
+
"highlights.scm": string;
|
|
22
|
+
"injections.scm"?: undefined;
|
|
23
|
+
"highlights-inline.scm"?: undefined;
|
|
24
|
+
"injections-inline.scm"?: undefined;
|
|
25
|
+
"highlights-dtd.scm"?: undefined;
|
|
26
|
+
"tags.scm"?: undefined;
|
|
27
|
+
"locals.scm"?: undefined;
|
|
28
|
+
"highlights-jsx.scm"?: undefined;
|
|
29
|
+
"highlights-params.scm"?: undefined;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
repo: string;
|
|
33
|
+
version: string;
|
|
34
|
+
files: string[];
|
|
35
|
+
queries: {
|
|
36
|
+
"highlights.scm": string;
|
|
37
|
+
"highlights-dtd.scm": string;
|
|
38
|
+
"injections.scm"?: undefined;
|
|
39
|
+
"highlights-inline.scm"?: undefined;
|
|
40
|
+
"injections-inline.scm"?: undefined;
|
|
41
|
+
"tags.scm"?: undefined;
|
|
42
|
+
"locals.scm"?: undefined;
|
|
43
|
+
"highlights-jsx.scm"?: undefined;
|
|
44
|
+
"highlights-params.scm"?: undefined;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
repo: string;
|
|
48
|
+
version: string;
|
|
49
|
+
files: string[];
|
|
50
|
+
queries: {
|
|
51
|
+
"highlights.scm": string;
|
|
52
|
+
"injections.scm": string;
|
|
53
|
+
"highlights-inline.scm"?: undefined;
|
|
54
|
+
"injections-inline.scm"?: undefined;
|
|
55
|
+
"highlights-dtd.scm"?: undefined;
|
|
56
|
+
"tags.scm"?: undefined;
|
|
57
|
+
"locals.scm"?: undefined;
|
|
58
|
+
"highlights-jsx.scm"?: undefined;
|
|
59
|
+
"highlights-params.scm"?: undefined;
|
|
60
|
+
};
|
|
61
|
+
} | {
|
|
62
|
+
repo: string;
|
|
63
|
+
version: string;
|
|
64
|
+
files: string[];
|
|
65
|
+
queries: {
|
|
66
|
+
"highlights.scm": string;
|
|
67
|
+
"injections.scm": string;
|
|
68
|
+
"tags.scm": string;
|
|
69
|
+
"highlights-inline.scm"?: undefined;
|
|
70
|
+
"injections-inline.scm"?: undefined;
|
|
71
|
+
"highlights-dtd.scm"?: undefined;
|
|
72
|
+
"locals.scm"?: undefined;
|
|
73
|
+
"highlights-jsx.scm"?: undefined;
|
|
74
|
+
"highlights-params.scm"?: undefined;
|
|
75
|
+
};
|
|
76
|
+
} | {
|
|
77
|
+
repo: string;
|
|
78
|
+
version: string;
|
|
79
|
+
files: string[];
|
|
80
|
+
queries: {
|
|
81
|
+
"highlights.scm": string;
|
|
82
|
+
"locals.scm": string;
|
|
83
|
+
"tags.scm": string;
|
|
84
|
+
"injections.scm"?: undefined;
|
|
85
|
+
"highlights-inline.scm"?: undefined;
|
|
86
|
+
"injections-inline.scm"?: undefined;
|
|
87
|
+
"highlights-dtd.scm"?: undefined;
|
|
88
|
+
"highlights-jsx.scm"?: undefined;
|
|
89
|
+
"highlights-params.scm"?: undefined;
|
|
90
|
+
};
|
|
91
|
+
} | {
|
|
92
|
+
repo: string;
|
|
93
|
+
version: string;
|
|
94
|
+
files: string[];
|
|
95
|
+
queries: {
|
|
96
|
+
"highlights.scm": string;
|
|
97
|
+
"tags.scm": string;
|
|
98
|
+
"injections.scm"?: undefined;
|
|
99
|
+
"highlights-inline.scm"?: undefined;
|
|
100
|
+
"injections-inline.scm"?: undefined;
|
|
101
|
+
"highlights-dtd.scm"?: undefined;
|
|
102
|
+
"locals.scm"?: undefined;
|
|
103
|
+
"highlights-jsx.scm"?: undefined;
|
|
104
|
+
"highlights-params.scm"?: undefined;
|
|
105
|
+
};
|
|
106
|
+
} | {
|
|
107
|
+
repo: string;
|
|
108
|
+
version: string;
|
|
109
|
+
files: string[];
|
|
110
|
+
queries: {
|
|
111
|
+
"highlights.scm": string;
|
|
112
|
+
"highlights-jsx.scm": string;
|
|
113
|
+
"highlights-params.scm": string;
|
|
114
|
+
"injections.scm": string;
|
|
115
|
+
"locals.scm": string;
|
|
116
|
+
"tags.scm": string;
|
|
117
|
+
"highlights-inline.scm"?: undefined;
|
|
118
|
+
"injections-inline.scm"?: undefined;
|
|
119
|
+
"highlights-dtd.scm"?: undefined;
|
|
120
|
+
};
|
|
121
|
+
} | {
|
|
122
|
+
repo: string;
|
|
123
|
+
files: string[];
|
|
124
|
+
queries: {
|
|
125
|
+
"highlights.scm": string;
|
|
126
|
+
"injections.scm"?: undefined;
|
|
127
|
+
"highlights-inline.scm"?: undefined;
|
|
128
|
+
"injections-inline.scm"?: undefined;
|
|
129
|
+
"highlights-dtd.scm"?: undefined;
|
|
130
|
+
"tags.scm"?: undefined;
|
|
131
|
+
"locals.scm"?: undefined;
|
|
132
|
+
"highlights-jsx.scm"?: undefined;
|
|
133
|
+
"highlights-params.scm"?: undefined;
|
|
134
|
+
};
|
|
135
|
+
version?: undefined;
|
|
136
|
+
})[];
|
|
137
|
+
export default _default;
|
|
138
|
+
//# sourceMappingURL=wasm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../../src/wasm/wasm.js"],"names":[],"mappings":""}
|