[mod] wsl

This commit is contained in:
Andy Bunce 2025-11-11 15:36:33 +00:00
parent b741dc5952
commit ddd772f563
69 changed files with 26660 additions and 25940 deletions

View file

@ -1,8 +1,8 @@
#Ignoring git and other folders
.git
.github
.settings
src/
#Ignoring all the markdown
#Ignoring git and other folders
.git
.github
.settings
src/
#Ignoring all the markdown
*.md

26
.vscode/launch.json vendored
View file

@ -1,14 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "jdk",
"request": "launch",
"name": "Launch Java App"
}
]
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "jdk",
"request": "launch",
"name": "Launch Java App"
}
]
}

146
LICENSE
View file

@ -1,73 +1,73 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright 2025 Andy Bunce
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright 2025 Andy Bunce
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

176
README.md
View file

@ -1,88 +1,88 @@
Work in progress.
An attempt to write a [Language Server Protocol](https://en.wikipedia.org/wiki/Language_Server_Protocol) server for and in XQuery 4.0. It tracks the draft specifications at https://qt4cg.org/
It written for BaseX 12.0 and uses the [BaseX websocket](https://docs.basex.org/main/WebSockets) feature.
# Demo
The demos expect `Docker` or `Podman` on the local machine. This is only a requirement for the demos.
1 Clone this repo
2. Run `docker compose up -d` The LSP server shall now running on port 3000 (edit `compose.yaml` to change port)
3. In a browser navigate to `http://localhost:3000/static/clients/codemirror/` to see the CodeMirror 6 demo.
In principle, the LSP can be used in any environment that can make use of a LSP server accessed via a websocket.
## LSP Server
* `webapp/lsp` The LSP implementation in XQuery using WebSockets for transport and the [JSON-RPC](https://www.jsonrpc.org/specification) 2.0 API for data format.
## Sample html clients
Samples using common browser based code editors are available. The `CodeMirror 6` sample is the most functional.
These examples are self contained (no internet access required). Some make use of recent html features, for instance [popovertarget](https://caniuse.com/?search=popovertarget)
### `CodeMirror6` https://codemirror.net/
* `webapp/static/codemirror` A test html page using the [CodeMirror6 editor](https://codemirror.net/) that connects to the BaseX LSP instance
#### uses
* https://codemirror.net/docs/ref/#lsp-client
* [https://github.com/codemirror/legacy-modes/](https://github.com/codemirror/legacy-modes/blob/main/README.md#modexquery) `xquery` mode provides browser based syntax highlighting (XQuery 3.1?)
#### alternative LSP interfaces
* https://github.com/FurqanSoftware/codemirror-languageserver
* https://hjr265.me/blog/codemirror-lsp/
### `Ace Editor`
* `webapp/static/ace` A test html page using the [Ace editor](https://ace.c9.io/) that connects to the BaseX LSP instance
@TODO fix
#### Uses
* https://github.com/mkslanc/ace-linters https://mkslanc.github.io/ace-linters/
Make a websocket server for lsp on port 3000
https://mkslanc.github.io/ace-linters/websocket.html
http://localhost:3000/exampleServer
https://github.com/mkslanc/ace-linters/blob/c1b317e01299016ac7da6588361228637f4eac25/packages/demo/websockets-lsp/server/server.ts
I needed `set NODE_OPTIONS=--max_old_space_size=8192` for build to complete
Or `node --max-old-space-size=8192 node_modules/webpack-dev-serve
r/bin/webpack-dev-server.js`
### `Monaco editor`
@TODO create
https://socket.dev/npm/package/monaco-editor
### Server dev notes
State is held in [websocket attributes](https://docs.basex.org/main/WebSocket_Functions#websocket_attributes).
|Name|Use|
|----|---|
|id|wsid|
|connectTime|dateTime of connection|
|initialized|set true after client sends initialized message|
|client|the client initialize message|
|files|A map whose keys are open uris, values are maps (doctype-> attribute name where doctype is stored| |
|file-{uuid}|name of websocket attribute containing the textDocument|
|parse-{uuid}|name of websocket attribute containing parse tree XML|
```mermaid
sequenceDiagram
WS->>lsp-ws: message
lsp-ws->>rpc: reply
rpc->>+John: John, can you hear me?
```
#### XQuery 4.0 parser
The ebnf is taken from Gunther Rademacher's rex-parser-generator
[XQuery-40.ebnf](https://github.com/GuntherRademacher/rex-parser-generator/blob/main/docs/sample-grammars/XQuery-40.ebnf)
The script [scripts/rex.xq](scripts/rex.xq) can generate XQuery or Java parser code from this.
The npm `package.json` script `javac` can create a jar file from the Java source.
## Related links
java -cp org.eclipse.lemminx-uber.jar org.eclipse.lemminx.XMLServerSocketLauncher`
Work in progress.
An attempt to write a [Language Server Protocol](https://en.wikipedia.org/wiki/Language_Server_Protocol) server for and in XQuery 4.0. It tracks the draft specifications at https://qt4cg.org/
It written for BaseX 12.0 and uses the [BaseX websocket](https://docs.basex.org/main/WebSockets) feature.
# Demo
The demos expect `Docker` or `Podman` on the local machine. This is only a requirement for the demos.
1 Clone this repo
2. Run `docker compose up -d` The LSP server shall now running on port 3000 (edit `compose.yaml` to change port)
3. In a browser navigate to `http://localhost:3000/static/clients/codemirror/` to see the CodeMirror 6 demo.
In principle, the LSP can be used in any environment that can make use of a LSP server accessed via a websocket.
## LSP Server
* `webapp/lsp` The LSP implementation in XQuery using WebSockets for transport and the [JSON-RPC](https://www.jsonrpc.org/specification) 2.0 API for data format.
## Sample html clients
Samples using common browser based code editors are available. The `CodeMirror 6` sample is the most functional.
These examples are self contained (no internet access required). Some make use of recent html features, for instance [popovertarget](https://caniuse.com/?search=popovertarget)
### `CodeMirror6` https://codemirror.net/
* `webapp/static/codemirror` A test html page using the [CodeMirror6 editor](https://codemirror.net/) that connects to the BaseX LSP instance
#### uses
* https://codemirror.net/docs/ref/#lsp-client
* [https://github.com/codemirror/legacy-modes/](https://github.com/codemirror/legacy-modes/blob/main/README.md#modexquery) `xquery` mode provides browser based syntax highlighting (XQuery 3.1?)
#### alternative LSP interfaces
* https://github.com/FurqanSoftware/codemirror-languageserver
* https://hjr265.me/blog/codemirror-lsp/
### `Ace Editor`
* `webapp/static/ace` A test html page using the [Ace editor](https://ace.c9.io/) that connects to the BaseX LSP instance
@TODO fix
#### Uses
* https://github.com/mkslanc/ace-linters https://mkslanc.github.io/ace-linters/
Make a websocket server for lsp on port 3000
https://mkslanc.github.io/ace-linters/websocket.html
http://localhost:3000/exampleServer
https://github.com/mkslanc/ace-linters/blob/c1b317e01299016ac7da6588361228637f4eac25/packages/demo/websockets-lsp/server/server.ts
I needed `set NODE_OPTIONS=--max_old_space_size=8192` for build to complete
Or `node --max-old-space-size=8192 node_modules/webpack-dev-serve
r/bin/webpack-dev-server.js`
### `Monaco editor`
@TODO create
https://socket.dev/npm/package/monaco-editor
### Server dev notes
State is held in [websocket attributes](https://docs.basex.org/main/WebSocket_Functions#websocket_attributes).
|Name|Use|
|----|---|
|id|wsid|
|connectTime|dateTime of connection|
|initialized|set true after client sends initialized message|
|client|the client initialize message|
|files|A map whose keys are open uris, values are maps (doctype-> attribute name where doctype is stored| |
|file-{uuid}|name of websocket attribute containing the textDocument|
|parse-{uuid}|name of websocket attribute containing parse tree XML|
```mermaid
sequenceDiagram
WS->>lsp-ws: message
lsp-ws->>rpc: reply
rpc->>+John: John, can you hear me?
```
#### XQuery 4.0 parser
The ebnf is taken from Gunther Rademacher's rex-parser-generator
[XQuery-40.ebnf](https://github.com/GuntherRademacher/rex-parser-generator/blob/main/docs/sample-grammars/XQuery-40.ebnf)
The script [scripts/rex.xq](scripts/rex.xq) can generate XQuery or Java parser code from this.
The npm `package.json` script `javac` can create a jar file from the Java source.
## Related links
java -cp org.eclipse.lemminx-uber.jar org.eclipse.lemminx.XMLServerSocketLauncher`

View file

@ -1,137 +1,137 @@
import { EditorState, StateEffect, Compartment } from '@codemirror/state';
import {
lineNumbers, highlightActiveLineGutter, highlightWhitespace,
drawSelection, rectangularSelection, crosshairCursor, highlightActiveLine,
keymap, dropCursor, EditorView,tooltips
} from '@codemirror/view';
import { openSearchPanel, highlightSelectionMatches, searchKeymap } from '@codemirror/search';
import { openLintPanel, lintGutter, lintKeymap, linter } from "@codemirror/lint"
import { indentWithTab, history, defaultKeymap, historyKeymap } from '@codemirror/commands';
import {
foldGutter, indentOnInput, indentUnit, bracketMatching, foldKeymap,
syntaxHighlighting, defaultHighlightStyle, StreamLanguage
} from '@codemirror/language';
import { closeBrackets, autocompletion, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete';
import {
LSPClient, LSPPlugin, languageServerSupport, languageServerExtensions,
formatDocument, formatKeymap
} from "@codemirror/lsp-client";
import { xQuery } from "@codemirror/legacy-modes/mode/xquery"
// Language
import { xml } from "@codemirror/lang-xml";
import { showMinimap } from "@replit/codemirror-minimap"
let create = (v) => {
const dom = document.createElement('div');
return { dom }
}
const compartment = new Compartment();
let curOpts = {
lineWrap: true,
minimap: true,
highlightWhitespace: true
}
// array of extensions reflecting opts
function optExts(opts) {
let exts = []
if (opts.lineWrap) exts.push(EditorView.lineWrapping)
if (opts.highlightWhitespace) exts.push(highlightWhitespace())
if (opts.minimap) exts.push(
showMinimap.compute(['doc'], (state) => {
return {
create,
/* optional showOverlay: 'mouse-over' */
displayText: 'characters'
}
}));
return exts
}
function updateCompartment(opts) {
view.dispatch({
effects: [compartment.reconfigure(optExts(opts))]
});
}
// return promise with socket map or reject if no connect
function simpleWebSocketTransport(uri) {
let handlers = [];
return new Promise(function (resolve, reject) {
let sock = new WebSocket(uri);
sock.onmessage = e => { for (let h of handlers) h(e.data.toString()); };
sock.onerror = e => reject(e);
sock.onopen = () => resolve({
socket: sock,
send: (message) => sock.send(message),
subscribe: (handler) => handlers.push(handler),
unsubscribe: (handler) => handlers = handlers.filter(h => h != handler)
});
}
);
};
const baseExts = [
lineNumbers(),
highlightActiveLineGutter(),
history(),
foldGutter(),
lintGutter(),
drawSelection(),
dropCursor(),
EditorState.allowMultipleSelections.of(true),
tooltips({ }), // clipped
keymap.of([indentWithTab]),
indentOnInput(),
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
bracketMatching(),
closeBrackets(),
autocompletion(),
rectangularSelection(),
crosshairCursor(),
highlightActiveLine(),
highlightSelectionMatches(),
keymap.of([
...closeBracketsKeymap,
...defaultKeymap,
...searchKeymap,
...historyKeymap,
...foldKeymap,
...completionKeymap,
...lintKeymap
]),
StreamLanguage.define(xQuery),
compartment.of(optExts(curOpts))
];
// map cmd->{keybings,fn}
function listCommands(view) {
const commands = new Map();
const keymaps = view.state.facet(keymap);
for (let km of keymaps) {
for (let binding of km) {
if (binding.run && binding.run.name) {
commands.set(binding.run.name, { key: binding.key, fn: binding.run });
}
}
}
return commands;
};
export {
baseExts, EditorView, EditorState, StateEffect, LSPPlugin, LSPClient,
openSearchPanel, openLintPanel, languageServerSupport, languageServerExtensions,
simpleWebSocketTransport, linter, formatDocument, keymap, formatKeymap, listCommands, updateCompartment, curOpts
import { EditorState, StateEffect, Compartment } from '@codemirror/state';
import {
lineNumbers, highlightActiveLineGutter, highlightWhitespace,
drawSelection, rectangularSelection, crosshairCursor, highlightActiveLine,
keymap, dropCursor, EditorView,tooltips
} from '@codemirror/view';
import { openSearchPanel, highlightSelectionMatches, searchKeymap } from '@codemirror/search';
import { openLintPanel, lintGutter, lintKeymap, linter } from "@codemirror/lint"
import { indentWithTab, history, defaultKeymap, historyKeymap } from '@codemirror/commands';
import {
foldGutter, indentOnInput, indentUnit, bracketMatching, foldKeymap,
syntaxHighlighting, defaultHighlightStyle, StreamLanguage
} from '@codemirror/language';
import { closeBrackets, autocompletion, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete';
import {
LSPClient, LSPPlugin, languageServerSupport, languageServerExtensions,
formatDocument, formatKeymap
} from "@codemirror/lsp-client";
import { xQuery } from "@codemirror/legacy-modes/mode/xquery"
// Language
import { xml } from "@codemirror/lang-xml";
import { showMinimap } from "@replit/codemirror-minimap"
let create = (v) => {
const dom = document.createElement('div');
return { dom }
}
const compartment = new Compartment();
let curOpts = {
lineWrap: true,
minimap: true,
highlightWhitespace: true
}
// array of extensions reflecting opts
function optExts(opts) {
let exts = []
if (opts.lineWrap) exts.push(EditorView.lineWrapping)
if (opts.highlightWhitespace) exts.push(highlightWhitespace())
if (opts.minimap) exts.push(
showMinimap.compute(['doc'], (state) => {
return {
create,
/* optional showOverlay: 'mouse-over' */
displayText: 'characters'
}
}));
return exts
}
function updateCompartment(opts) {
view.dispatch({
effects: [compartment.reconfigure(optExts(opts))]
});
}
// return promise with socket map or reject if no connect
function simpleWebSocketTransport(uri) {
let handlers = [];
return new Promise(function (resolve, reject) {
let sock = new WebSocket(uri);
sock.onmessage = e => { for (let h of handlers) h(e.data.toString()); };
sock.onerror = e => reject(e);
sock.onopen = () => resolve({
socket: sock,
send: (message) => sock.send(message),
subscribe: (handler) => handlers.push(handler),
unsubscribe: (handler) => handlers = handlers.filter(h => h != handler)
});
}
);
};
const baseExts = [
lineNumbers(),
highlightActiveLineGutter(),
history(),
foldGutter(),
lintGutter(),
drawSelection(),
dropCursor(),
EditorState.allowMultipleSelections.of(true),
tooltips({ }), // clipped
keymap.of([indentWithTab]),
indentOnInput(),
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
bracketMatching(),
closeBrackets(),
autocompletion(),
rectangularSelection(),
crosshairCursor(),
highlightActiveLine(),
highlightSelectionMatches(),
keymap.of([
...closeBracketsKeymap,
...defaultKeymap,
...searchKeymap,
...historyKeymap,
...foldKeymap,
...completionKeymap,
...lintKeymap
]),
StreamLanguage.define(xQuery),
compartment.of(optExts(curOpts))
];
// map cmd->{keybings,fn}
function listCommands(view) {
const commands = new Map();
const keymaps = view.state.facet(keymap);
for (let km of keymaps) {
for (let binding of km) {
if (binding.run && binding.run.name) {
commands.set(binding.run.name, { key: binding.key, fn: binding.run });
}
}
}
return commands;
};
export {
baseExts, EditorView, EditorState, StateEffect, LSPPlugin, LSPClient,
openSearchPanel, openLintPanel, languageServerSupport, languageServerExtensions,
simpleWebSocketTransport, linter, formatDocument, keymap, formatKeymap, listCommands, updateCompartment, curOpts
};

View file

@ -1,41 +1,41 @@
import {basicSetup, EditorView} from "codemirror"
import { EditorState } from '@codemirror/state';
import { LSPClient, LSPPlugin, languageServerSupport } from "@codemirror/lsp-client";
import {StreamLanguage} from "@codemirror/language"
import { xQuery } from "@codemirror/legacy-modes/mode/xquery"
function simpleWebSocketTransport(uri) {
let handlers = [];
return new Promise(function (resolve, reject) {
let sock = new WebSocket(uri);
sock.onmessage = e => { for (let h of handlers) h(e.data.toString()); };
sock.onerror = e => reject(e);
sock.onopen = () => resolve({
socket: sock,
send: (message) => sock.send(message),
subscribe: (handler) => handlers.push(handler),
unsubscribe: (handler) => handlers = handlers.filter(h => h != handler)
});
}
);
};
simpleWebSocketTransport("ws://localhost:3000/ws/lsp")
.then(transport => {
client = new LSPClient().connect(transport);
let extLsp = languageServerSupport(client, file, "xquery");
const doc = view.state.doc.toString();
const state = lsp.createEditorState(doc, [...lsp.baseExts, extLsp, extLint]);
view.setState(state);
})
.catch(r => { alert("connection failed: " + server) });
new EditorView({
doc: "xquery version '3.1';\n(:~ comment:)\nmodule namespace pdfbox='ns';\n",
extensions: [basicSetup, StreamLanguage.define(xQuery)],
parent: document.body
import {basicSetup, EditorView} from "codemirror"
import { EditorState } from '@codemirror/state';
import { LSPClient, LSPPlugin, languageServerSupport } from "@codemirror/lsp-client";
import {StreamLanguage} from "@codemirror/language"
import { xQuery } from "@codemirror/legacy-modes/mode/xquery"
function simpleWebSocketTransport(uri) {
let handlers = [];
return new Promise(function (resolve, reject) {
let sock = new WebSocket(uri);
sock.onmessage = e => { for (let h of handlers) h(e.data.toString()); };
sock.onerror = e => reject(e);
sock.onopen = () => resolve({
socket: sock,
send: (message) => sock.send(message),
subscribe: (handler) => handlers.push(handler),
unsubscribe: (handler) => handlers = handlers.filter(h => h != handler)
});
}
);
};
simpleWebSocketTransport("ws://localhost:3000/ws/lsp")
.then(transport => {
client = new LSPClient().connect(transport);
let extLsp = languageServerSupport(client, file, "xquery");
const doc = view.state.doc.toString();
const state = lsp.createEditorState(doc, [...lsp.baseExts, extLsp, extLint]);
view.setState(state);
})
.catch(r => { alert("connection failed: " + server) });
new EditorView({
doc: "xquery version '3.1';\n(:~ comment:)\nmodule namespace pdfbox='ns';\n",
extensions: [basicSetup, StreamLanguage.define(xQuery)],
parent: document.body
});

View file

@ -1,28 +1,28 @@
import * as aceBuilds from 'https://esm.run/ace-builds';
import ace from 'https://cdn.jsdelivr.net/npm/ace/+esm'
/* import 'ace-builds/src-noconflict/mode-javascript';
import 'ace-builds/src-noconflict/theme-chrome'; */
/* import {AceLanguageClient} from "ace-linters/build/ace-language-client";
const serverData = {
module: () => import("ace-linters/build/language-client"),
modes: "json|json5",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"), // your websocket server address
}
*/
// Initialize the editor
const editor = ace.edit("editor", {
theme: "ace/theme/chrome",
mode: "ace/mode/javascript",
fontSize: "14px",
showPrintMargin: false,
useWorker: false // Disable web worker for this simple demo
});
// Create a language provider for WebSocket
//let languageProvider = AceLanguageClient.for(serverData);
import * as aceBuilds from 'https://esm.run/ace-builds';
import ace from 'https://cdn.jsdelivr.net/npm/ace/+esm'
/* import 'ace-builds/src-noconflict/mode-javascript';
import 'ace-builds/src-noconflict/theme-chrome'; */
/* import {AceLanguageClient} from "ace-linters/build/ace-language-client";
const serverData = {
module: () => import("ace-linters/build/language-client"),
modes: "json|json5",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"), // your websocket server address
}
*/
// Initialize the editor
const editor = ace.edit("editor", {
theme: "ace/theme/chrome",
mode: "ace/mode/javascript",
fontSize: "14px",
showPrintMargin: false,
useWorker: false // Disable web worker for this simple demo
});
// Create a language provider for WebSocket
//let languageProvider = AceLanguageClient.for(serverData);
//languageProvider.registerEditor(editor);

View file

@ -1,44 +1,44 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>BaseX LSP</title>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ace.js"></script>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ext-language_tools.js"></script>
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-linters.js"></script>
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-language-client.js"></script>
</head>
<body>
<div>something</div>
<div id="editor" style="height: 100px">some text</div>
<script>
let servers = [
{
module: () => import("ace-linters/build/language-client"),
modes: "astro",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:8080/ws/lsp"
//"ws://127.0.0.1:3000/exampleserver"
),
}
];
let languageProvider = AceLanguageClient.for(servers);
ace.require("ace/ext/language_tools"); //To allow autocompletion
var editor = ace.edit("editor", {
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
mode: "ace/mode/json"
});
languageProvider.registerEditor(editor);
editor.session.setMode("astro"); // mode now contains "ace/mode/javascript".
</script>
</body>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>BaseX LSP</title>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ace.js"></script>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ext-language_tools.js"></script>
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-linters.js"></script>
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-language-client.js"></script>
</head>
<body>
<div>something</div>
<div id="editor" style="height: 100px">some text</div>
<script>
let servers = [
{
module: () => import("ace-linters/build/language-client"),
modes: "astro",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:8080/ws/lsp"
//"ws://127.0.0.1:3000/exampleserver"
),
}
];
let languageProvider = AceLanguageClient.for(servers);
ace.require("ace/ext/language_tools"); //To allow autocompletion
var editor = ace.edit("editor", {
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
mode: "ace/mode/json"
});
languageProvider.registerEditor(editor);
editor.session.setMode("astro"); // mode now contains "ace/mode/javascript".
</script>
</body>
</html>

View file

@ -1,39 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Editor</title>
<style type="text/css" media="screen">
body {
overflow: hidden;
}
#editor {
margin: 0;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body>
<pre id="editor">function foo(items) {
var i;
for (i = 0; i &lt; items.length; i++) {
alert("Ace Rocks " + items[i]);
}
}</pre>
<script src="src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/javascript");
</script>
</body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Editor</title>
<style type="text/css" media="screen">
body {
overflow: hidden;
}
#editor {
margin: 0;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body>
<pre id="editor">function foo(items) {
var i;
for (i = 0; i &lt; items.length; i++) {
alert("Ace Rocks " + items[i]);
}
}</pre>
<script src="src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/javascript");
</script>
</body>
</html>

View file

@ -1,3 +1,3 @@
REM default port 5008
REM https://download.eclipse.org/lemminx/releases/0.31.0/
REM default port 5008
REM https://download.eclipse.org/lemminx/releases/0.31.0/
java -cp org.eclipse.lemminx-uber.jar org.eclipse.lemminx.XMLServerSocketLauncher

View file

@ -1,72 +1,72 @@
(:~ web socket for ace
:)
module namespace lsp="urn:quodatum:vscode";
import module namespace ws = "http://basex.org/modules/ws";
declare
%ws:connect('/ws/exampleServer')
function lsp:connect()
as empty-sequence(){
let $_:=trace(ws:id(),"BaseX socket id: ")
return ()
};
(:~
: Processes a WebSocket message.
: @param $message message
:)
declare
%ws:message('/ws/exampleServer', '{$message}')
function lsp:message(
$message as xs:string
) as empty-sequence() {
let $json:=json:parse($message, map{ 'format': 'xquery' })
let $id:=$json?id
let $_:=trace($id,"MESSAGE id: ")
return switch($json?method=>trace("method: "))
case "initialize" return
let $a:=map{
"capabilities":map{"textDocumentSync":2,
"completionProvider":map{"resolveProvider":false(),"triggerCharacters":["\",":"]},
"hoverProvider":true(),
"documentSymbolProvider":true(),
"documentRangeFormattingProvider":false(),
"colorProvider":map{},
"foldingRangeProvider":true(),
"selectionRangeProvider":true(),
"documentLinkProvider":map{}
}
}
let $a:=trace($a,"A: ")
return lsp:send-result($a,$id,ws:id())
default
return error()
};
declare %ws:error('/ws/exampleServer', '{$error}')
function lsp:error($error)
{
let $_:=trace($error,"ERROR ")
return ()
};
(:~
: Closes a WebSocket connection. Unregisters the user and notifies all clients.
:)
declare
%ws:close('/ws/exampleServer')
function lsp:close() as empty-sequence() {
let $_:=trace("CLOSE")
return ()
};
declare
function lsp:send-result($result as map(*),$rpcId as xs:string, $wsId as xs:string)
as empty-sequence()
{
let $json:=map{"jsonrpc":"2.0","id":$rpcId,"result":$result}=>trace("RESULT: ")
return ws:send($json,$wsId)
};
(:~ web socket for ace
:)
module namespace lsp="urn:quodatum:vscode";
import module namespace ws = "http://basex.org/modules/ws";
declare
%ws:connect('/ws/exampleServer')
function lsp:connect()
as empty-sequence(){
let $_:=trace(ws:id(),"BaseX socket id: ")
return ()
};
(:~
: Processes a WebSocket message.
: @param $message message
:)
declare
%ws:message('/ws/exampleServer', '{$message}')
function lsp:message(
$message as xs:string
) as empty-sequence() {
let $json:=json:parse($message, map{ 'format': 'xquery' })
let $id:=$json?id
let $_:=trace($id,"MESSAGE id: ")
return switch($json?method=>trace("method: "))
case "initialize" return
let $a:=map{
"capabilities":map{"textDocumentSync":2,
"completionProvider":map{"resolveProvider":false(),"triggerCharacters":["\",":"]},
"hoverProvider":true(),
"documentSymbolProvider":true(),
"documentRangeFormattingProvider":false(),
"colorProvider":map{},
"foldingRangeProvider":true(),
"selectionRangeProvider":true(),
"documentLinkProvider":map{}
}
}
let $a:=trace($a,"A: ")
return lsp:send-result($a,$id,ws:id())
default
return error()
};
declare %ws:error('/ws/exampleServer', '{$error}')
function lsp:error($error)
{
let $_:=trace($error,"ERROR ")
return ()
};
(:~
: Closes a WebSocket connection. Unregisters the user and notifies all clients.
:)
declare
%ws:close('/ws/exampleServer')
function lsp:close() as empty-sequence() {
let $_:=trace("CLOSE")
return ()
};
declare
function lsp:send-result($result as map(*),$rpcId as xs:string, $wsId as xs:string)
as empty-sequence()
{
let $json:=map{"jsonrpc":"2.0","id":$rpcId,"result":$result}=>trace("RESULT: ")
return ws:send($json,$wsId)
};

View file

@ -1,4 +1,4 @@
<script>
const webSocket = new WebSocket("ws://localhost:5008");
alert("hi");
<script>
const webSocket = new WebSocket("ws://localhost:5008");
alert("hi");
</script>

View file

@ -1,30 +1,30 @@
import "ace-code/esm-resolver";
import {jsonContent} from "../docs-example/json-example";
import {json5Content, json5Schema} from "../docs-example/json5-example";
import {addFormatCommand, createEditorWithLSP} from "../utils";
import {AceLanguageClient, LanguageClientConfig} from "ace-linters/build/ace-language-client";
let modes = [
{name: "json", mode: "ace/mode/json", content: jsonContent, options: {jsonSchemaUri: "common-form.schema.json"}},
{name: "json5", mode: "ace/mode/json5", content: json5Content, options: {jsonSchemaUri: json5Schema}},
]
const serverData: LanguageClientConfig = {
module: () => import("ace-linters/build/language-client"),
modes: "json|json5",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:3000/exampleServer"),
}
let languageProvider = AceLanguageClient.for(serverData);
let i = 0;
for (let mode of modes) {
// @ts-expect-error
createEditorWithLSP(mode, i, languageProvider);
i++;
}
// @ts-expect-error
addFormatCommand(languageProvider);
import "ace-code/esm-resolver";
import {jsonContent} from "../docs-example/json-example";
import {json5Content, json5Schema} from "../docs-example/json5-example";
import {addFormatCommand, createEditorWithLSP} from "../utils";
import {AceLanguageClient, LanguageClientConfig} from "ace-linters/build/ace-language-client";
let modes = [
{name: "json", mode: "ace/mode/json", content: jsonContent, options: {jsonSchemaUri: "common-form.schema.json"}},
{name: "json5", mode: "ace/mode/json5", content: json5Content, options: {jsonSchemaUri: json5Schema}},
]
const serverData: LanguageClientConfig = {
module: () => import("ace-linters/build/language-client"),
modes: "json|json5",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:3000/exampleServer"),
}
let languageProvider = AceLanguageClient.for(serverData);
let i = 0;
for (let mode of modes) {
// @ts-expect-error
createEditorWithLSP(mode, i, languageProvider);
i++;
}
// @ts-expect-error
addFormatCommand(languageProvider);

View file

@ -1,11 +1,11 @@
# Sample language server
This is just sample websocket server based on vscode-json-languageserver
## Getting Started
To run the server, simply follow these steps:
1. Install dependencies by running `npm i`
2. Start the server by running `npm run start-server`
And that's it! Your sample language server on 3000 port should now be up and running.
# Sample language server
This is just sample websocket server based on vscode-json-languageserver
## Getting Started
To run the server, simply follow these steps:
1. Install dependencies by running `npm i`
2. Start the server by running `npm run start-server`
And that's it! Your sample language server on 3000 port should now be up and running.

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,12 @@
{
"name": "sample-server",
"version": "1.0.0",
"scripts": {
"start-server": "node --loader ts-node/esm server.ts"
},
"dependencies": {
"vscode-json-languageserver": "^1.3.4",
"ts-node": "^10.8.1"
},
"type": "module"
}
{
"name": "sample-server",
"version": "1.0.0",
"scripts": {
"start-server": "node --loader ts-node/esm server.ts"
},
"dependencies": {
"vscode-json-languageserver": "^1.3.4",
"ts-node": "^10.8.1"
},
"type": "module"
}

View file

@ -1,98 +1,98 @@
import fs from "fs";
import {WebSocketServer} from 'ws';
import * as http from 'http';
import {fileURLToPath, URL} from 'url';
import * as net from 'net';
import express from 'express';
import * as rpc from 'vscode-ws-jsonrpc';
// @ts-ignore
import * as jsonServer from 'vscode-json-languageserver/out/jsonServer.js'
import requestLight from "request-light";
import vscodeUri from "vscode-uri";
import {createConnection} from 'vscode-languageserver/lib/node/main.js';
import path from 'path';
export function startLanguageServer(webSocket: rpc.IWebSocket) {
const messageReader = new rpc.WebSocketMessageReader(webSocket);
const messageWriter = new rpc.WebSocketMessageWriter(webSocket);
const connection = createConnection(messageReader, messageWriter);
jsonServer.startServer(connection, {
file: getFileService(),
http: getHTTPService(),
configureHttpRequests: requestLight.configure
});
}
function getHTTPService() {
return {
getContent(uri: any) {
const headers = {'Accept-Encoding': 'gzip, deflate'};
return requestLight.xhr({url: uri, followRedirects: 5, headers}).then(response => {
return response.responseText;
}, (error) => {
return Promise.reject(error.responseText || requestLight.getErrorStatusDescription(error.status) || error.toString());
});
}
};
}
function getFileService() {
return {
getContent(location: any) {
return new Promise((resolve, reject) => {
const uri = vscodeUri.URI.parse(location);
fs.readFile(uri.fsPath, 'utf8', (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
}
};
}
const serverFilePath = fileURLToPath(import.meta.url);
const serverDir = path.dirname(serverFilePath);
process.on('uncaughtException', (err: any) => {
console.error('Uncaught Exception: ', err.toString());
if (err.stack) {
console.error(err.stack);
}
});
const app = express();
app.use(express.static(serverDir));
const server = app.listen(3000);
const webSocketServer = new WebSocketServer({
noServer: true,
perMessageDeflate: false
});
server.on('upgrade', (request: http.IncomingMessage, socket: net.Socket, head: Buffer) => {
const baseURL = `http://${request.headers.host}/`;
const pathname = request.url ? new URL(request.url, baseURL).pathname : undefined;
if (pathname === '/exampleServer') {
webSocketServer.handleUpgrade(request, socket, head, webSocket => {
const socket: rpc.IWebSocket = {
send: content => webSocket.send(content, error => {
if (error) {
throw error;
}
}),
onMessage: cb => webSocket.on('message', cb),
onError: cb => webSocket.on('error', cb),
onClose: cb => webSocket.on('close', cb),
dispose: () => webSocket.close()
};
if (webSocket.readyState === webSocket.OPEN) {
startLanguageServer(socket);
} else {
webSocket.on('open', () => startLanguageServer(socket));
}
});
}
});
import fs from "fs";
import {WebSocketServer} from 'ws';
import * as http from 'http';
import {fileURLToPath, URL} from 'url';
import * as net from 'net';
import express from 'express';
import * as rpc from 'vscode-ws-jsonrpc';
// @ts-ignore
import * as jsonServer from 'vscode-json-languageserver/out/jsonServer.js'
import requestLight from "request-light";
import vscodeUri from "vscode-uri";
import {createConnection} from 'vscode-languageserver/lib/node/main.js';
import path from 'path';
export function startLanguageServer(webSocket: rpc.IWebSocket) {
const messageReader = new rpc.WebSocketMessageReader(webSocket);
const messageWriter = new rpc.WebSocketMessageWriter(webSocket);
const connection = createConnection(messageReader, messageWriter);
jsonServer.startServer(connection, {
file: getFileService(),
http: getHTTPService(),
configureHttpRequests: requestLight.configure
});
}
function getHTTPService() {
return {
getContent(uri: any) {
const headers = {'Accept-Encoding': 'gzip, deflate'};
return requestLight.xhr({url: uri, followRedirects: 5, headers}).then(response => {
return response.responseText;
}, (error) => {
return Promise.reject(error.responseText || requestLight.getErrorStatusDescription(error.status) || error.toString());
});
}
};
}
function getFileService() {
return {
getContent(location: any) {
return new Promise((resolve, reject) => {
const uri = vscodeUri.URI.parse(location);
fs.readFile(uri.fsPath, 'utf8', (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
}
};
}
const serverFilePath = fileURLToPath(import.meta.url);
const serverDir = path.dirname(serverFilePath);
process.on('uncaughtException', (err: any) => {
console.error('Uncaught Exception: ', err.toString());
if (err.stack) {
console.error(err.stack);
}
});
const app = express();
app.use(express.static(serverDir));
const server = app.listen(3000);
const webSocketServer = new WebSocketServer({
noServer: true,
perMessageDeflate: false
});
server.on('upgrade', (request: http.IncomingMessage, socket: net.Socket, head: Buffer) => {
const baseURL = `http://${request.headers.host}/`;
const pathname = request.url ? new URL(request.url, baseURL).pathname : undefined;
if (pathname === '/exampleServer') {
webSocketServer.handleUpgrade(request, socket, head, webSocket => {
const socket: rpc.IWebSocket = {
send: content => webSocket.send(content, error => {
if (error) {
throw error;
}
}),
onMessage: cb => webSocket.on('message', cb),
onError: cb => webSocket.on('error', cb),
onClose: cb => webSocket.on('close', cb),
dispose: () => webSocket.close()
};
if (webSocket.readyState === webSocket.OPEN) {
startLanguageServer(socket);
} else {
webSocket.on('open', () => startLanguageServer(socket));
}
});
}
});

View file

@ -1,23 +1,23 @@
# basex lsp, use with
services:
basex:
image: ghcr.io/quodatum/basexhttp:basex-12.0
container_name: basex-lsp
restart: unless-stopped
ports:
- "3000:8080"
- "3001:1984"
volumes:
- ./data:/srv/basex/data
# - ./webapp/web.xml:/srv/basex/webapp/WEB-INF/web.xml # set websocket options 12.1+
- ./webapp/custom:/srv/basex/lib/custom:ro # jars
- ./webapp/lsp:/srv/basex/webapp/lsp
- ./webapp/static/clients:/srv/basex/webapp/static/clients:ro
- ./webapp/lsp-manager:/srv/basex/webapp/lsp-manager
# - ./repo:/srv/basex/repo
environment:
- "BASEX_JVM= -Dorg.basex.RESTXQERRORS=false -Dorg.basex.LOGEXCLUDE=/dba"
- "SERVER_OPTS= "
volumes:
basex-lsp:
# basex lsp, use with
services:
basex:
image: ghcr.io/quodatum/basexhttp:basex-12.0
container_name: basex-lsp
restart: unless-stopped
ports:
- "3000:8080"
- "3001:1984"
volumes:
- ./data:/srv/basex/data
# - ./webapp/web.xml:/srv/basex/webapp/WEB-INF/web.xml # set websocket options 12.1+
- ./webapp/custom:/srv/basex/lib/custom:ro # jars
- ./webapp/lsp:/srv/basex/webapp/lsp
- ./webapp/static/clients:/srv/basex/webapp/static/clients:ro
- ./webapp/lsp-manager:/srv/basex/webapp/lsp-manager
# - ./repo:/srv/basex/repo
environment:
- "BASEX_JVM= -Dorg.basex.RESTXQERRORS=false -Dorg.basex.LOGEXCLUDE=/dba"
- "SERVER_OPTS= "
volumes:
basex-lsp:

File diff suppressed because one or more lines are too long

View file

@ -1,19 +1,19 @@
# Pipelines
## Scripts
### Update local ebnf and fos catalog
`scripts/update-sources.xq`
### Update xq4.java
`scripts/rex.xq`
### Build `jar`
npm script `javac`
## Others
https://github.com/GuntherRademacher/rex-parser-generator/blob/main/docs/sample-grammars/XQuery-40.ebnf
<any/><token>:=</token><any/>
$p update 
replace node //token[.=':='][preceding-siblings::*[1]/element()][following-siblings::*[1]/element()]with (' ',.,' ')...........................
# Pipelines
## Scripts
### Update local ebnf and fos catalog
`scripts/update-sources.xq`
### Update xq4.java
`scripts/rex.xq`
### Build `jar`
npm script `javac`
## Others
https://github.com/GuntherRademacher/rex-parser-generator/blob/main/docs/sample-grammars/XQuery-40.ebnf
<any/><token>:=</token><any/>
$p update 
replace node //token[.=':='][preceding-siblings::*[1]/element()][following-siblings::*[1]/element()]with (' ',.,' ')...........................
---------------Nico Verwer: SMAX (Separated Markup API for XML). SMAX (Separated Markup API for XML) https://github.com/nverwer/SMAX

View file

@ -1,25 +1,25 @@
lsp websocket messages
```json
{"jsonrpc":"2.0","id":0,
"method":"initialize",
"params":{"capabilities":{"textDocument":{"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"synchronization":{"dynamicRegistration":true,"willSave":false,"didSave":false,"willSaveWaitUntil":false},"formatting":{"dynamicRegistration":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":false,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":false,"preselectSupport":false},"contextSupport":false},"signatureHelp":{"signatureInformation":{"documentationFormat":["markdown","plaintext"],"activeParameterSupport":true}},"documentHighlight":{"dynamicRegistration":true},"semanticTokens":{"multilineTokenSupport":false,"overlappingTokenSupport":false,"tokenTypes":[],"tokenModifiers":[],"formats":["relative"],"requests":{"full":{"delta":false},"range":true},"augmentsSyntaxTokens":true}},"workspace":{"didChangeConfiguration":{"dynamicRegistration":true}}},"processId":null,"rootUri":"","workspaceFolders":null}
}
```
<=
{"jsonrpc":"2.0","id":0,
"result":{"capabilities":{"textDocumentSync":2,"completionProvider":{"resolveProvider":false,"triggerCharacters":["\"",":"]},"hoverProvider":true,"documentSymbolProvider":true,"documentRangeFormattingProvider":false,"colorProvider":{},"foldingRangeProvider":true,"selectionRangeProvider":true,"documentLinkProvider":{}}}
}
{"jsonrpc":"2.0","method":"initialized","params":{}}
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}
<=
{"jsonrpc":"2.0",
"method":"textDocument/publishDiagnostics",
"params":{"uri":"session1.json","diagnostics":[]}
}
<=
lsp websocket messages
```json
{"jsonrpc":"2.0","id":0,
"method":"initialize",
"params":{"capabilities":{"textDocument":{"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"synchronization":{"dynamicRegistration":true,"willSave":false,"didSave":false,"willSaveWaitUntil":false},"formatting":{"dynamicRegistration":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":false,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":false,"preselectSupport":false},"contextSupport":false},"signatureHelp":{"signatureInformation":{"documentationFormat":["markdown","plaintext"],"activeParameterSupport":true}},"documentHighlight":{"dynamicRegistration":true},"semanticTokens":{"multilineTokenSupport":false,"overlappingTokenSupport":false,"tokenTypes":[],"tokenModifiers":[],"formats":["relative"],"requests":{"full":{"delta":false},"range":true},"augmentsSyntaxTokens":true}},"workspace":{"didChangeConfiguration":{"dynamicRegistration":true}}},"processId":null,"rootUri":"","workspaceFolders":null}
}
```
<=
{"jsonrpc":"2.0","id":0,
"result":{"capabilities":{"textDocumentSync":2,"completionProvider":{"resolveProvider":false,"triggerCharacters":["\"",":"]},"hoverProvider":true,"documentSymbolProvider":true,"documentRangeFormattingProvider":false,"colorProvider":{},"foldingRangeProvider":true,"selectionRangeProvider":true,"documentLinkProvider":{}}}
}
{"jsonrpc":"2.0","method":"initialized","params":{}}
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}
<=
{"jsonrpc":"2.0",
"method":"textDocument/publishDiagnostics",
"params":{"uri":"session1.json","diagnostics":[]}
}
<=
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"session1.json","diagnostics":[{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":16}},"message":"Expected comma","severity":1,"code":514,"source":"json"}]}}

720
get-docker.sh Normal file
View file

@ -0,0 +1,720 @@
#!/bin/sh
set -e
# Docker Engine for Linux installation script.
#
# This script is intended as a convenient way to configure docker's package
# repositories and to install Docker Engine, This script is not recommended
# for production environments. Before running this script, make yourself familiar
# with potential risks and limitations, and refer to the installation manual
# at https://docs.docker.com/engine/install/ for alternative installation methods.
#
# The script:
#
# - Requires `root` or `sudo` privileges to run.
# - Attempts to detect your Linux distribution and version and configure your
# package management system for you.
# - Doesn't allow you to customize most installation parameters.
# - Installs dependencies and recommendations without asking for confirmation.
# - Installs the latest stable release (by default) of Docker CLI, Docker Engine,
# Docker Buildx, Docker Compose, containerd, and runc. When using this script
# to provision a machine, this may result in unexpected major version upgrades
# of these packages. Always test upgrades in a test environment before
# deploying to your production systems.
# - Isn't designed to upgrade an existing Docker installation. When using the
# script to update an existing installation, dependencies may not be updated
# to the expected version, resulting in outdated versions.
#
# Source code is available at https://github.com/docker/docker-install/
#
# Usage
# ==============================================================================
#
# To install the latest stable versions of Docker CLI, Docker Engine, and their
# dependencies:
#
# 1. download the script
#
# $ curl -fsSL https://get.docker.com -o install-docker.sh
#
# 2. verify the script's content
#
# $ cat install-docker.sh
#
# 3. run the script with --dry-run to verify the steps it executes
#
# $ sh install-docker.sh --dry-run
#
# 4. run the script either as root, or using sudo to perform the installation.
#
# $ sudo sh install-docker.sh
#
# Command-line options
# ==============================================================================
#
# --version <VERSION>
# Use the --version option to install a specific version, for example:
#
# $ sudo sh install-docker.sh --version 23.0
#
# --channel <stable|test>
#
# Use the --channel option to install from an alternative installation channel.
# The following example installs the latest versions from the "test" channel,
# which includes pre-releases (alpha, beta, rc):
#
# $ sudo sh install-docker.sh --channel test
#
# Alternatively, use the script at https://test.docker.com, which uses the test
# channel as default.
#
# --mirror <Aliyun|AzureChinaCloud>
#
# Use the --mirror option to install from a mirror supported by this script.
# Available mirrors are "Aliyun" (https://mirrors.aliyun.com/docker-ce), and
# "AzureChinaCloud" (https://mirror.azure.cn/docker-ce), for example:
#
# $ sudo sh install-docker.sh --mirror AzureChinaCloud
#
# --setup-repo
#
# Use the --setup-repo option to configure Docker's package repositories without
# installing Docker packages. This is useful when you want to add the repository
# but install packages separately:
#
# $ sudo sh install-docker.sh --setup-repo
#
# ==============================================================================
# Git commit from https://github.com/docker/docker-install when
# the script was uploaded (Should only be modified by upload job):
SCRIPT_COMMIT_SHA="7d96bd3c5235ab2121bcb855dd7b3f3f37128ed4"
# strip "v" prefix if present
VERSION="${VERSION#v}"
# The channel to install from:
# * stable
# * test
DEFAULT_CHANNEL_VALUE="stable"
if [ -z "$CHANNEL" ]; then
CHANNEL=$DEFAULT_CHANNEL_VALUE
fi
DEFAULT_DOWNLOAD_URL="https://download.docker.com"
if [ -z "$DOWNLOAD_URL" ]; then
DOWNLOAD_URL=$DEFAULT_DOWNLOAD_URL
fi
DEFAULT_REPO_FILE="docker-ce.repo"
if [ -z "$REPO_FILE" ]; then
REPO_FILE="$DEFAULT_REPO_FILE"
# Automatically default to a staging repo fora
# a staging download url (download-stage.docker.com)
case "$DOWNLOAD_URL" in
*-stage*) REPO_FILE="docker-ce-staging.repo";;
esac
fi
mirror=''
DRY_RUN=${DRY_RUN:-}
REPO_ONLY=${REPO_ONLY:-0}
while [ $# -gt 0 ]; do
case "$1" in
--channel)
CHANNEL="$2"
shift
;;
--dry-run)
DRY_RUN=1
;;
--mirror)
mirror="$2"
shift
;;
--version)
VERSION="${2#v}"
shift
;;
--setup-repo)
REPO_ONLY=1
shift
;;
--*)
echo "Illegal option $1"
;;
esac
shift $(( $# > 0 ? 1 : 0 ))
done
case "$mirror" in
Aliyun)
DOWNLOAD_URL="https://mirrors.aliyun.com/docker-ce"
;;
AzureChinaCloud)
DOWNLOAD_URL="https://mirror.azure.cn/docker-ce"
;;
"")
;;
*)
>&2 echo "unknown mirror '$mirror': use either 'Aliyun', or 'AzureChinaCloud'."
exit 1
;;
esac
case "$CHANNEL" in
stable|test)
;;
*)
>&2 echo "unknown CHANNEL '$CHANNEL': use either stable or test."
exit 1
;;
esac
command_exists() {
command -v "$@" > /dev/null 2>&1
}
# version_gte checks if the version specified in $VERSION is at least the given
# SemVer (Maj.Minor[.Patch]), or CalVer (YY.MM) version.It returns 0 (success)
# if $VERSION is either unset (=latest) or newer or equal than the specified
# version, or returns 1 (fail) otherwise.
#
# examples:
#
# VERSION=23.0
# version_gte 23.0 // 0 (success)
# version_gte 20.10 // 0 (success)
# version_gte 19.03 // 0 (success)
# version_gte 26.1 // 1 (fail)
version_gte() {
if [ -z "$VERSION" ]; then
return 0
fi
version_compare "$VERSION" "$1"
}
# version_compare compares two version strings (either SemVer (Major.Minor.Path),
# or CalVer (YY.MM) version strings. It returns 0 (success) if version A is newer
# or equal than version B, or 1 (fail) otherwise. Patch releases and pre-release
# (-alpha/-beta) are not taken into account
#
# examples:
#
# version_compare 23.0.0 20.10 // 0 (success)
# version_compare 23.0 20.10 // 0 (success)
# version_compare 20.10 19.03 // 0 (success)
# version_compare 20.10 20.10 // 0 (success)
# version_compare 19.03 20.10 // 1 (fail)
version_compare() (
set +x
yy_a="$(echo "$1" | cut -d'.' -f1)"
yy_b="$(echo "$2" | cut -d'.' -f1)"
if [ "$yy_a" -lt "$yy_b" ]; then
return 1
fi
if [ "$yy_a" -gt "$yy_b" ]; then
return 0
fi
mm_a="$(echo "$1" | cut -d'.' -f2)"
mm_b="$(echo "$2" | cut -d'.' -f2)"
# trim leading zeros to accommodate CalVer
mm_a="${mm_a#0}"
mm_b="${mm_b#0}"
if [ "${mm_a:-0}" -lt "${mm_b:-0}" ]; then
return 1
fi
return 0
)
is_dry_run() {
if [ -z "$DRY_RUN" ]; then
return 1
else
return 0
fi
}
is_wsl() {
case "$(uname -r)" in
*microsoft* ) true ;; # WSL 2
*Microsoft* ) true ;; # WSL 1
* ) false;;
esac
}
is_darwin() {
case "$(uname -s)" in
*darwin* ) true ;;
*Darwin* ) true ;;
* ) false;;
esac
}
deprecation_notice() {
distro=$1
distro_version=$2
echo
printf "\033[91;1mDEPRECATION WARNING\033[0m\n"
printf " This Linux distribution (\033[1m%s %s\033[0m) reached end-of-life and is no longer supported by this script.\n" "$distro" "$distro_version"
echo " No updates or security fixes will be released for this distribution, and users are recommended"
echo " to upgrade to a currently maintained version of $distro."
echo
printf "Press \033[1mCtrl+C\033[0m now to abort this script, or wait for the installation to continue."
echo
sleep 10
}
get_distribution() {
lsb_dist=""
# Every system that we officially support has /etc/os-release
if [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
# Returning an empty string here should be alright since the
# case statements don't act unless you provide an actual value
echo "$lsb_dist"
}
echo_docker_as_nonroot() {
if is_dry_run; then
return
fi
if command_exists docker && [ -e /var/run/docker.sock ]; then
(
set -x
$sh_c 'docker version'
) || true
fi
# intentionally mixed spaces and tabs here -- tabs are stripped by "<<-EOF", spaces are kept in the output
echo
echo "================================================================================"
echo
if version_gte "20.10"; then
echo "To run Docker as a non-privileged user, consider setting up the"
echo "Docker daemon in rootless mode for your user:"
echo
echo " dockerd-rootless-setuptool.sh install"
echo
echo "Visit https://docs.docker.com/go/rootless/ to learn about rootless mode."
echo
fi
echo
echo "To run the Docker daemon as a fully privileged service, but granting non-root"
echo "users access, refer to https://docs.docker.com/go/daemon-access/"
echo
echo "WARNING: Access to the remote API on a privileged Docker daemon is equivalent"
echo " to root access on the host. Refer to the 'Docker daemon attack surface'"
echo " documentation for details: https://docs.docker.com/go/attack-surface/"
echo
echo "================================================================================"
echo
}
# Check if this is a forked Linux distro
check_forked() {
# Check for lsb_release command existence, it usually exists in forked distros
if command_exists lsb_release; then
# Check if the `-u` option is supported
set +e
lsb_release -a -u > /dev/null 2>&1
lsb_release_exit_code=$?
set -e
# Check if the command has exited successfully, it means we're in a forked distro
if [ "$lsb_release_exit_code" = "0" ]; then
# Print info about current distro
cat <<-EOF
You're using '$lsb_dist' version '$dist_version'.
EOF
# Get the upstream release info
lsb_dist=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'id' | cut -d ':' -f 2 | tr -d '[:space:]')
dist_version=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'codename' | cut -d ':' -f 2 | tr -d '[:space:]')
# Print info about upstream distro
cat <<-EOF
Upstream release is '$lsb_dist' version '$dist_version'.
EOF
else
if [ -r /etc/debian_version ] && [ "$lsb_dist" != "ubuntu" ] && [ "$lsb_dist" != "raspbian" ]; then
if [ "$lsb_dist" = "osmc" ]; then
# OSMC runs Raspbian
lsb_dist=raspbian
else
# We're Debian and don't even know it!
lsb_dist=debian
fi
dist_version="$(sed 's/\/.*//' /etc/debian_version | sed 's/\..*//')"
case "$dist_version" in
13)
dist_version="trixie"
;;
12)
dist_version="bookworm"
;;
11)
dist_version="bullseye"
;;
10)
dist_version="buster"
;;
9)
dist_version="stretch"
;;
8)
dist_version="jessie"
;;
esac
fi
fi
fi
}
do_install() {
echo "# Executing docker install script, commit: $SCRIPT_COMMIT_SHA"
if command_exists docker; then
cat >&2 <<-'EOF'
Warning: the "docker" command appears to already exist on this system.
If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.
If you installed the current Docker package using this script and are using it
again to update Docker, you can ignore this message, but be aware that the
script resets any custom changes in the deb and rpm repo configuration
files to match the parameters passed to the script.
You may press Ctrl+C now to abort this script.
EOF
( set -x; sleep 20 )
fi
user="$(id -un 2>/dev/null || true)"
sh_c='sh -c'
if [ "$user" != 'root' ]; then
if command_exists sudo; then
sh_c='sudo -E sh -c'
elif command_exists su; then
sh_c='su -c'
else
cat >&2 <<-'EOF'
Error: this installer needs the ability to run commands as root.
We are unable to find either "sudo" or "su" available to make this happen.
EOF
exit 1
fi
fi
if is_dry_run; then
sh_c="echo"
fi
# perform some very rudimentary platform detection
lsb_dist=$( get_distribution )
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
if is_wsl; then
echo
echo "WSL DETECTED: We recommend using Docker Desktop for Windows."
echo "Please get Docker Desktop from https://www.docker.com/products/docker-desktop/"
echo
cat >&2 <<-'EOF'
You may press Ctrl+C now to abort this script.
EOF
( set -x; sleep 20 )
fi
case "$lsb_dist" in
ubuntu)
if command_exists lsb_release; then
dist_version="$(lsb_release --codename | cut -f2)"
fi
if [ -z "$dist_version" ] && [ -r /etc/lsb-release ]; then
dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")"
fi
;;
debian|raspbian)
dist_version="$(sed 's/\/.*//' /etc/debian_version | sed 's/\..*//')"
case "$dist_version" in
13)
dist_version="trixie"
;;
12)
dist_version="bookworm"
;;
11)
dist_version="bullseye"
;;
10)
dist_version="buster"
;;
9)
dist_version="stretch"
;;
8)
dist_version="jessie"
;;
esac
;;
centos|rhel)
if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
fi
;;
*)
if command_exists lsb_release; then
dist_version="$(lsb_release --release | cut -f2)"
fi
if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
fi
;;
esac
# Check if this is a forked Linux distro
check_forked
# Print deprecation warnings for distro versions that recently reached EOL,
# but may still be commonly used (especially LTS versions).
case "$lsb_dist.$dist_version" in
centos.8|centos.7|rhel.7)
deprecation_notice "$lsb_dist" "$dist_version"
;;
debian.buster|debian.stretch|debian.jessie)
deprecation_notice "$lsb_dist" "$dist_version"
;;
raspbian.buster|raspbian.stretch|raspbian.jessie)
deprecation_notice "$lsb_dist" "$dist_version"
;;
ubuntu.focal|ubuntu.bionic|ubuntu.xenial|ubuntu.trusty)
deprecation_notice "$lsb_dist" "$dist_version"
;;
ubuntu.oracular|ubuntu.mantic|ubuntu.lunar|ubuntu.kinetic|ubuntu.impish|ubuntu.hirsute|ubuntu.groovy|ubuntu.eoan|ubuntu.disco|ubuntu.cosmic)
deprecation_notice "$lsb_dist" "$dist_version"
;;
fedora.*)
if [ "$dist_version" -lt 41 ]; then
deprecation_notice "$lsb_dist" "$dist_version"
fi
;;
esac
# Run setup for each distro accordingly
case "$lsb_dist" in
ubuntu|debian|raspbian)
pre_reqs="ca-certificates curl"
apt_repo="deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] $DOWNLOAD_URL/linux/$lsb_dist $dist_version $CHANNEL"
(
if ! is_dry_run; then
set -x
fi
$sh_c 'apt-get -qq update >/dev/null'
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get -y -qq install $pre_reqs >/dev/null"
$sh_c 'install -m 0755 -d /etc/apt/keyrings'
$sh_c "curl -fsSL \"$DOWNLOAD_URL/linux/$lsb_dist/gpg\" -o /etc/apt/keyrings/docker.asc"
$sh_c "chmod a+r /etc/apt/keyrings/docker.asc"
$sh_c "echo \"$apt_repo\" > /etc/apt/sources.list.d/docker.list"
$sh_c 'apt-get -qq update >/dev/null'
)
if [ "$REPO_ONLY" = "1" ]; then
exit 0
fi
pkg_version=""
if [ -n "$VERSION" ]; then
if is_dry_run; then
echo "# WARNING: VERSION pinning is not supported in DRY_RUN"
else
# Will work for incomplete versions IE (17.12), but may not actually grab the "latest" if in the test channel
pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/~ce~.*/g' | sed 's/-/.*/g')"
search_command="apt-cache madison docker-ce | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3"
pkg_version="$($sh_c "$search_command")"
echo "INFO: Searching repository for VERSION '$VERSION'"
echo "INFO: $search_command"
if [ -z "$pkg_version" ]; then
echo
echo "ERROR: '$VERSION' not found amongst apt-cache madison results"
echo
exit 1
fi
if version_gte "18.09"; then
search_command="apt-cache madison docker-ce-cli | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3"
echo "INFO: $search_command"
cli_pkg_version="=$($sh_c "$search_command")"
fi
pkg_version="=$pkg_version"
fi
fi
(
pkgs="docker-ce${pkg_version%=}"
if version_gte "18.09"; then
# older versions didn't ship the cli and containerd as separate packages
pkgs="$pkgs docker-ce-cli${cli_pkg_version%=} containerd.io"
fi
if version_gte "20.10"; then
pkgs="$pkgs docker-compose-plugin docker-ce-rootless-extras$pkg_version"
fi
if version_gte "23.0"; then
pkgs="$pkgs docker-buildx-plugin"
fi
if version_gte "28.2"; then
pkgs="$pkgs docker-model-plugin"
fi
if ! is_dry_run; then
set -x
fi
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get -y -qq install $pkgs >/dev/null"
)
echo_docker_as_nonroot
exit 0
;;
centos|fedora|rhel)
if [ "$(uname -m)" = "s390x" ]; then
echo "Effective v27.5, please consult RHEL distro statement for s390x support."
exit 1
fi
repo_file_url="$DOWNLOAD_URL/linux/$lsb_dist/$REPO_FILE"
(
if ! is_dry_run; then
set -x
fi
if command_exists dnf5; then
$sh_c "dnf -y -q --setopt=install_weak_deps=False install dnf-plugins-core"
$sh_c "dnf5 config-manager addrepo --overwrite --save-filename=docker-ce.repo --from-repofile='$repo_file_url'"
if [ "$CHANNEL" != "stable" ]; then
$sh_c "dnf5 config-manager setopt \"docker-ce-*.enabled=0\""
$sh_c "dnf5 config-manager setopt \"docker-ce-$CHANNEL.enabled=1\""
fi
$sh_c "dnf makecache"
elif command_exists dnf; then
$sh_c "dnf -y -q --setopt=install_weak_deps=False install dnf-plugins-core"
$sh_c "rm -f /etc/yum.repos.d/docker-ce.repo /etc/yum.repos.d/docker-ce-staging.repo"
$sh_c "dnf config-manager --add-repo $repo_file_url"
if [ "$CHANNEL" != "stable" ]; then
$sh_c "dnf config-manager --set-disabled \"docker-ce-*\""
$sh_c "dnf config-manager --set-enabled \"docker-ce-$CHANNEL\""
fi
$sh_c "dnf makecache"
else
$sh_c "yum -y -q install yum-utils"
$sh_c "rm -f /etc/yum.repos.d/docker-ce.repo /etc/yum.repos.d/docker-ce-staging.repo"
$sh_c "yum-config-manager --add-repo $repo_file_url"
if [ "$CHANNEL" != "stable" ]; then
$sh_c "yum-config-manager --disable \"docker-ce-*\""
$sh_c "yum-config-manager --enable \"docker-ce-$CHANNEL\""
fi
$sh_c "yum makecache"
fi
)
if [ "$REPO_ONLY" = "1" ]; then
exit 0
fi
pkg_version=""
if command_exists dnf; then
pkg_manager="dnf"
pkg_manager_flags="-y -q --best"
else
pkg_manager="yum"
pkg_manager_flags="-y -q"
fi
if [ -n "$VERSION" ]; then
if is_dry_run; then
echo "# WARNING: VERSION pinning is not supported in DRY_RUN"
else
if [ "$lsb_dist" = "fedora" ]; then
pkg_suffix="fc$dist_version"
else
pkg_suffix="el"
fi
pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/\\\\.ce.*/g' | sed 's/-/.*/g').*$pkg_suffix"
search_command="$pkg_manager list --showduplicates docker-ce | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'"
pkg_version="$($sh_c "$search_command")"
echo "INFO: Searching repository for VERSION '$VERSION'"
echo "INFO: $search_command"
if [ -z "$pkg_version" ]; then
echo
echo "ERROR: '$VERSION' not found amongst $pkg_manager list results"
echo
exit 1
fi
if version_gte "18.09"; then
# older versions don't support a cli package
search_command="$pkg_manager list --showduplicates docker-ce-cli | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'"
cli_pkg_version="$($sh_c "$search_command" | cut -d':' -f 2)"
fi
# Cut out the epoch and prefix with a '-'
pkg_version="-$(echo "$pkg_version" | cut -d':' -f 2)"
fi
fi
(
pkgs="docker-ce$pkg_version"
if version_gte "18.09"; then
# older versions didn't ship the cli and containerd as separate packages
if [ -n "$cli_pkg_version" ]; then
pkgs="$pkgs docker-ce-cli-$cli_pkg_version containerd.io"
else
pkgs="$pkgs docker-ce-cli containerd.io"
fi
fi
if version_gte "20.10"; then
pkgs="$pkgs docker-compose-plugin docker-ce-rootless-extras$pkg_version"
fi
if version_gte "23.0"; then
pkgs="$pkgs docker-buildx-plugin docker-model-plugin"
fi
if ! is_dry_run; then
set -x
fi
$sh_c "$pkg_manager $pkg_manager_flags install $pkgs"
)
echo_docker_as_nonroot
exit 0
;;
sles)
echo "Effective v27.5, please consult SLES distro statement for s390x support."
exit 1
;;
*)
if [ -z "$lsb_dist" ]; then
if is_darwin; then
echo
echo "ERROR: Unsupported operating system 'macOS'"
echo "Please get Docker Desktop from https://www.docker.com/products/docker-desktop"
echo
exit 1
fi
fi
echo
echo "ERROR: Unsupported distribution '$lsb_dist'"
echo
exit 1
;;
esac
exit 1
}
# wrapped up in a function so that we have some protection against only getting
# half the file during "curl | sh"
do_install

4266
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,37 +1,37 @@
{
"dependencies": {
"@codemirror/commands": "^6.10.0",
"@codemirror/lang-javascript": "^6.2.4",
"@codemirror/lang-markdown": "^6.5.0",
"@codemirror/lang-xml": "^6.1.0",
"@codemirror/language-data": "^6.5.2",
"@codemirror/legacy-modes": "^6.5.2",
"@codemirror/lint": "^6.9.1",
"@codemirror/lsp-client": "^6.2.0",
"@codemirror/search": "^6.5.11",
"@codemirror/theme-one-dark": "^6.1.3",
"@codemirror/view": "^6.38.6",
"@quietui/quiet-browser": "^1.6.1",
"@replit/codemirror-minimap": "^0.5.2",
"@zenfs/core": "^2.4.2",
"@zenfs/dom": "^1.2.5",
"ace-builds": "^1.43.4",
"ace-linters": "^1.8.5",
"beercss": "^3.12.13"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-typescript": "^12.1.4",
"minify": "^9.1.0",
"rollup": "4",
"rollup-plugin-tla": "^0.0.2"
},
"scripts": {
"build": "rollup cm6/index.js -m true -f iife -o dist/cm6.bundle.js -p node-resolve,tla --output.name cm6",
"lsp-build": "rollup bundles/cm6/lsp.js -m true -f iife -o webapp/static/clients/codemirror/lsp.bundle.js -p node-resolve,tla --output.name lsp",
"lsp-min": "cd webapp/static/clients/codemirror && npx minify lsp.bundle.js > lsp.bundle.min.js ",
"min": "cd dist && npx minify cm6.bundle.js > cm6.bundle.min.js && npx minify lsp.bundle.js > lsp.bundle.min.js",
"javac": "cd bundles/grammar && javac --release 17 -cp %BASEX12%\\BaseX.jar -d build xq4.java && cd build && jar cf ../../../webapp/custom/xq4.jar . ",
"railroad server": "cd C:/Users/mrwhe/apps/rr-2.5-java11 && java -jar rr.war -gui -port:5555"
}
}
{
"dependencies": {
"@codemirror/commands": "^6.10.0",
"@codemirror/lang-javascript": "^6.2.4",
"@codemirror/lang-markdown": "^6.5.0",
"@codemirror/lang-xml": "^6.1.0",
"@codemirror/language-data": "^6.5.2",
"@codemirror/legacy-modes": "^6.5.2",
"@codemirror/lint": "^6.9.1",
"@codemirror/lsp-client": "^6.2.0",
"@codemirror/search": "^6.5.11",
"@codemirror/theme-one-dark": "^6.1.3",
"@codemirror/view": "^6.38.6",
"@quietui/quiet-browser": "^1.6.1",
"@replit/codemirror-minimap": "^0.5.2",
"@zenfs/core": "^2.4.2",
"@zenfs/dom": "^1.2.5",
"ace-builds": "^1.43.4",
"ace-linters": "^1.8.5",
"beercss": "^3.12.13"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-typescript": "^12.1.4",
"minify": "^9.1.0",
"rollup": "4",
"rollup-plugin-tla": "^0.0.2"
},
"scripts": {
"build": "rollup cm6/index.js -m true -f iife -o dist/cm6.bundle.js -p node-resolve,tla --output.name cm6",
"lsp-build": "rollup bundles/cm6/lsp.js -m true -f iife -o webapp/static/clients/codemirror/lsp.bundle.js -p node-resolve,tla --output.name lsp",
"lsp-min": "cd webapp/static/clients/codemirror && npx minify lsp.bundle.js > lsp.bundle.min.js ",
"min": "cd dist && npx minify cm6.bundle.js > cm6.bundle.min.js && npx minify lsp.bundle.js > lsp.bundle.min.js",
"javac": "cd bundles/grammar && javac --release 17 -cp %BASEX12%\\BaseX.jar -d build xq4.java && cd build && jar cf ../../../webapp/custom/xq4.jar . ",
"railroad server": "cd C:/Users/mrwhe/apps/rr-2.5-java11 && java -jar rr.war -gui -port:5555"
}
}

View file

@ -1,14 +1,14 @@
import tla from 'rollup-plugin-tla';
import nodeResolve from 'rollup-node-resolve';
export default defineConfig({
input: 'src/editor.js',
output: {
format: 'iife',
dir: './dist',
file:"acm6.bundle.js",
name: `__Expose`,
sourcemap: true,
},
plugins: [ nodeResolve(),tla()],
import tla from 'rollup-plugin-tla';
import nodeResolve from 'rollup-node-resolve';
export default defineConfig({
input: 'src/editor.js',
output: {
format: 'iife',
dir: './dist',
file:"acm6.bundle.js",
name: `__Expose`,
sourcemap: true,
},
plugins: [ nodeResolve(),tla()],
});

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,15 @@
{
"jsonrpc": "2.0",
"method": "textDocument/didChange",
"params": {
"textDocument": {
"uri": "file:///some/file.xml",
"version": 1
},
"contentChanges": [
{
"text": "3+1f"
}
]
}
{
"jsonrpc": "2.0",
"method": "textDocument/didChange",
"params": {
"textDocument": {
"uri": "file:///some/file.xml",
"version": 1
},
"contentChanges": [
{
"text": "3+1f"
}
]
}
}

View file

@ -1,25 +1,25 @@
{
"jsonrpc": "2.0",
"method": "textDocument/didChange",
"params": {
"textDocument": {
"uri": "file:///some/file.xml",
"version": 2
},
"contentChanges": [
{
"range": {
"start": {
"line": 1,
"character": 4
},
"end": {
"line": 1,
"character": 4
}
},
"text": "d"
}
]
}
{
"jsonrpc": "2.0",
"method": "textDocument/didChange",
"params": {
"textDocument": {
"uri": "file:///some/file.xml",
"version": 2
},
"contentChanges": [
{
"range": {
"start": {
"line": 1,
"character": 4
},
"end": {
"line": 1,
"character": 4
}
},
"text": "d"
}
]
}
}

View file

@ -1,12 +1,12 @@
{
"jsonrpc": "2.0",
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"uri": "file:///some/file.xml",
"languageId": "xml",
"text": "<foo at=42><bar>test</bar></foo>vvvbvbvbvbvbv\nvv\n\nvcccccccccccccc\n",
"version": 0
}
}
{
"jsonrpc": "2.0",
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"uri": "file:///some/file.xml",
"languageId": "xml",
"text": "<foo at=42><bar>test</bar></foo>vvvbvbvbvbvbv\nvv\n\nvcccccccccccccc\n",
"version": 0
}
}
}

View file

@ -1,14 +1,14 @@
{
"jsonrpc": "2.0",
"id": 2,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file:///session1.json"
},
"position": {
"line": 2,
"character": 22
}
}
{
"jsonrpc": "2.0",
"id": 2,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file:///session1.json"
},
"position": {
"line": 2,
"character": 22
}
}
}

View file

@ -1,68 +1,68 @@
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"processId": null,
"clientInfo": {
"name": "@codemirror/lsp-client"
},
"rootUri": null,
"capabilities": {
"general": {
"markdown": {
"parser": "marked"
}
},
"textDocument": {
"completion": {
"completionItem": {
"snippetSupport": true,
"documentationFormat": [
"plaintext",
"markdown"
],
"insertReplaceSupport": false
},
"completionList": {
"itemDefaults": [
"commitCharacters",
"editRange",
"insertTextFormat"
]
},
"completionItemKind": {
"valueSet": []
},
"contextSupport": true
},
"hover": {
"contentFormat": [
"markdown",
"plaintext"
]
},
"formatting": {},
"rename": {},
"signatureHelp": {
"contextSupport": true,
"signatureInformation": {
"documentationFormat": [
"markdown",
"plaintext"
],
"parameterInformation": {
"labelOffsetSupport": true
},
"activeParameterSupport": true
}
},
"definition": {},
"declaration": {},
"implementation": {},
"typeDefinition": {},
"references": {}
}
}
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"processId": null,
"clientInfo": {
"name": "@codemirror/lsp-client"
},
"rootUri": null,
"capabilities": {
"general": {
"markdown": {
"parser": "marked"
}
},
"textDocument": {
"completion": {
"completionItem": {
"snippetSupport": true,
"documentationFormat": [
"plaintext",
"markdown"
],
"insertReplaceSupport": false
},
"completionList": {
"itemDefaults": [
"commitCharacters",
"editRange",
"insertTextFormat"
]
},
"completionItemKind": {
"valueSet": []
},
"contextSupport": true
},
"hover": {
"contentFormat": [
"markdown",
"plaintext"
]
},
"formatting": {},
"rename": {},
"signatureHelp": {
"contextSupport": true,
"signatureInformation": {
"documentationFormat": [
"markdown",
"plaintext"
],
"parameterInformation": {
"labelOffsetSupport": true
},
"activeParameterSupport": true
}
},
"definition": {},
"declaration": {},
"implementation": {},
"typeDefinition": {},
"references": {}
}
}
}
}

View file

@ -1,32 +1,32 @@
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"capabilities": {
"textDocumentSync": 2,
"completionProvider": {
"resolveProvider": false,
"triggerCharacters": [
"\"",
":"
],
"documentSelector": [
{
"language": "xquery"
}
]
},
"hoverProvider": true,
"documentSymbolProvider": true,
"documentRangeFormattingProvider": false,
"colorProvider": {},
"foldingRangeProvider": true,
"selectionRangeProvider": true,
"documentLinkProvider": {},
"serverInfo": {
"name": "My Custom Language Server",
"version": "1.0.0"
}
}
}
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"capabilities": {
"textDocumentSync": 2,
"completionProvider": {
"resolveProvider": false,
"triggerCharacters": [
"\"",
":"
],
"documentSelector": [
{
"language": "xquery"
}
]
},
"hoverProvider": true,
"documentSymbolProvider": true,
"documentRangeFormattingProvider": false,
"colorProvider": {},
"foldingRangeProvider": true,
"selectionRangeProvider": true,
"documentLinkProvider": {},
"serverInfo": {
"name": "My Custom Language Server",
"version": "1.0.0"
}
}
}
}

View file

@ -1,5 +1,5 @@
{
"jsonrpc": "2.0"
{
"jsonrpc": "2.0"
}

View file

@ -1,19 +1,19 @@
module namespace wsa = 'app/sockets';
import module namespace ws="http://basex.org/modules/ws";
declare function wsa:wsids()
as xs:string*
{
ws:ids()
};
declare %rest:path('/app/api/sockets')
function wsa:list()
as element(ul)
{
<ul>{
wsa:wsids()!<li><a href="/app/sockets/{.}">{.}</a></li>
}</ul>
module namespace wsa = 'app/sockets';
import module namespace ws="http://basex.org/modules/ws";
declare function wsa:wsids()
as xs:string*
{
ws:ids()
};
declare %rest:path('/app/api/sockets')
function wsa:list()
as element(ul)
{
<ul>{
wsa:wsids()!<li><a href="/app/sockets/{.}">{.}</a></li>
}</ul>
};

View file

@ -1,26 +1,26 @@
module namespace _ = 'app/error-reporting';
import module namespace cm = "app/cm" at "common.xqm";
declare
%rest:error("*")
%rest:error-param("code", "{$code}")
%rest:error-param("description", "{$description}")
%rest:error-param("value", "{$value}")
%rest:error-param("module", "{$module}")
%rest:error-param("line-number", "{$line-number}")
%rest:error-param("column-number","{$column-number}")
%rest:error-param("additional", "{$additional}")
function _:error($code,$description,$value,
$module,$line-number,$column-number,$additional) {
let $err:=map{"code":$code, "description":$description,
"value": _:format($value), "module": $module,
"line-number": $line-number, "column-number": $column-number,
"additional": _:format($additional)}
return cm:htmx2("error.htm", $err)
};
declare function _:format($item)
as xs:string{
serialize($item,map{"method":"basex"})
module namespace _ = 'app/error-reporting';
import module namespace cm = "app/cm" at "common.xqm";
declare
%rest:error("*")
%rest:error-param("code", "{$code}")
%rest:error-param("description", "{$description}")
%rest:error-param("value", "{$value}")
%rest:error-param("module", "{$module}")
%rest:error-param("line-number", "{$line-number}")
%rest:error-param("column-number","{$column-number}")
%rest:error-param("additional", "{$additional}")
function _:error($code,$description,$value,
$module,$line-number,$column-number,$additional) {
let $err:=map{"code":$code, "description":$description,
"value": _:format($value), "module": $module,
"line-number": $line-number, "column-number": $column-number,
"additional": _:format($additional)}
return cm:htmx2("error.htm", $err)
};
declare function _:format($item)
as xs:string{
serialize($item,map{"method":"basex"})
};

View file

@ -1,102 +1,102 @@
xquery version '3.1';
(:~ save conversion outputs to file
ensures target folders created
save multiple docs when root <wrapper> found
optionally serialize XML with default namespace
@author quodatum Andy Bunce
:)
module namespace outlet = 'urn:conversion:outlet';
(: serialization options
key is arbitary name, value is BaseX serialization option map
for xml serializations the non-standard 'ns' option supplies a namespace to use as default ' :)
declare variable $outlet:serial:=map{
"xvrl": map{"method":"xml","ns":"http://www.xproc.org/ns/xvrl"},
"docbook":map{"method":"xml","ns":"http://docbook.org/ns/docbook"},
"csv": map{"method":"text"},
"xml": map{"method":"xml"}
};
(:~save $doc to $dest unless empty,will create directories as required
@param $opts serialization options and ns to set a default namespace :)
declare function outlet:save($doc as item(),$dest as xs:string?,$opts as map(*)?)
as xs:string?{
if (exists($dest))
then
let $doc:=if($opts?ns)
then outlet:change-element-ns-deep($doc,$opts?ns,"")
else $doc
return (
file:create-dir(file:parent($dest)),
file:write($dest,$doc,map:remove($opts,"ns")),
$dest
)
};
(:~ save file or files if node is wrapper
@return paths to saved files
:)
declare function outlet:save-wrapper($doc as item(),$dest as xs:string?,$opts as map(*)?)
as xs:string*{
if ($doc/wrapper)
then $doc/wrapper/result! outlet:save(*,file:resolve-path(@href,$dest),$opts)
else outlet:save($doc,$dest,$opts)
};
(:~ from functx http://www.xqueryfunctions.com/xq/functx_change-element-ns-deep.html :)
declare function outlet:change-element-ns-deep
( $nodes as node()* ,
$newns as xs:string ,
$prefix as xs:string ) as node()* {
for $node in $nodes
return if ($node instance of element())
then (element
{QName ($newns,
concat($prefix,
if ($prefix = '')
then ''
else ':',
local-name($node)))}
{$node/@*,
outlet:change-element-ns-deep($node/node(),
$newns, $prefix)})
else if ($node instance of document-node())
then outlet:change-element-ns-deep($node/node(),
$newns, $prefix)
else $node
} ;
(:~ @see https://stackoverflow.com/a/8600987/3210344 :)
declare function outlet:remove-prefixes($node as node(), $prefixes as xs:string*)
as node(){
typeswitch ($node)
case element()
return
if ($prefixes = ('#all', prefix-from-QName(node-name($node)))) then
element {QName(namespace-uri($node), local-name($node))} {
$node/@*,
$node/node()/outlet:remove-prefixes(., $prefixes)
}
else
element {node-name($node)} {
$node/@*,
$node/node()/outlet:remove-prefixes(., $prefixes)
}
case document-node()
return
document {
$node/node()/outlet:remove-prefixes(., $prefixes)
}
default
return $node
};
(:~ relative file paths below folder $path, matching $selector :)
declare function outlet:select($path as xs:string,$selector as map(xs:string,item()*))
as xs:string*
{
file:list($path,true(),$selector?pattern)
[some $i in $selector?include satisfies contains(.,$i)]
[every $x in $selector?exclude satisfies not(contains(.,$x))]
xquery version '3.1';
(:~ save conversion outputs to file
ensures target folders created
save multiple docs when root <wrapper> found
optionally serialize XML with default namespace
@author quodatum Andy Bunce
:)
module namespace outlet = 'urn:conversion:outlet';
(: serialization options
key is arbitary name, value is BaseX serialization option map
for xml serializations the non-standard 'ns' option supplies a namespace to use as default ' :)
declare variable $outlet:serial:=map{
"xvrl": map{"method":"xml","ns":"http://www.xproc.org/ns/xvrl"},
"docbook":map{"method":"xml","ns":"http://docbook.org/ns/docbook"},
"csv": map{"method":"text"},
"xml": map{"method":"xml"}
};
(:~save $doc to $dest unless empty,will create directories as required
@param $opts serialization options and ns to set a default namespace :)
declare function outlet:save($doc as item(),$dest as xs:string?,$opts as map(*)?)
as xs:string?{
if (exists($dest))
then
let $doc:=if($opts?ns)
then outlet:change-element-ns-deep($doc,$opts?ns,"")
else $doc
return (
file:create-dir(file:parent($dest)),
file:write($dest,$doc,map:remove($opts,"ns")),
$dest
)
};
(:~ save file or files if node is wrapper
@return paths to saved files
:)
declare function outlet:save-wrapper($doc as item(),$dest as xs:string?,$opts as map(*)?)
as xs:string*{
if ($doc/wrapper)
then $doc/wrapper/result! outlet:save(*,file:resolve-path(@href,$dest),$opts)
else outlet:save($doc,$dest,$opts)
};
(:~ from functx http://www.xqueryfunctions.com/xq/functx_change-element-ns-deep.html :)
declare function outlet:change-element-ns-deep
( $nodes as node()* ,
$newns as xs:string ,
$prefix as xs:string ) as node()* {
for $node in $nodes
return if ($node instance of element())
then (element
{QName ($newns,
concat($prefix,
if ($prefix = '')
then ''
else ':',
local-name($node)))}
{$node/@*,
outlet:change-element-ns-deep($node/node(),
$newns, $prefix)})
else if ($node instance of document-node())
then outlet:change-element-ns-deep($node/node(),
$newns, $prefix)
else $node
} ;
(:~ @see https://stackoverflow.com/a/8600987/3210344 :)
declare function outlet:remove-prefixes($node as node(), $prefixes as xs:string*)
as node(){
typeswitch ($node)
case element()
return
if ($prefixes = ('#all', prefix-from-QName(node-name($node)))) then
element {QName(namespace-uri($node), local-name($node))} {
$node/@*,
$node/node()/outlet:remove-prefixes(., $prefixes)
}
else
element {node-name($node)} {
$node/@*,
$node/node()/outlet:remove-prefixes(., $prefixes)
}
case document-node()
return
document {
$node/node()/outlet:remove-prefixes(., $prefixes)
}
default
return $node
};
(:~ relative file paths below folder $path, matching $selector :)
declare function outlet:select($path as xs:string,$selector as map(xs:string,item()*))
as xs:string*
{
file:list($path,true(),$selector?pattern)
[some $i in $selector?include satisfies contains(.,$i)]
[every $x in $selector?exclude satisfies not(contains(.,$x))]
};

View file

@ -1,199 +1,199 @@
xquery version '3.1';
(:~
Library to manage running multiple jobs using BaseX job:eval,
where the jobs are the execution of one function for a set of arguments
The function will have signature `fn($key as xs:string) as element()`
The function will typically create outputs and have side effects.
State information is persisted with the storage module, using the key '_wrangle'
It is a map{$wid: {"jobs":}}
requires basex 10+
@licence BSD
@author: quodatum
@date: 2023/02/12
:)
module namespace wrangle = 'urn:quodatum:wrangler';
(:~ semantic version :)
declare variable $wrangle:version:="1.0.0";
(:~ used in bindings to indicate a wrangle job and as store key :)
declare variable $wrangle:id:="_wrangle";
(:~
submit wrangle jobs for each $item
@param wrangle data{xq:...,bindings:..}
@return unique id for the job set
:)
declare function wrangle:queue($items as item()*,$wrangle as map(*))
as xs:string{
let $wid := random:uuid()
let $jobs := $items!job:eval($wrangle?xq,
map:merge(($wrangle?bindings(.),map:entry($wrangle:id,$wid))),
map{"cache":true()}
)
let $this := map:entry($wid,map:entry("jobs",$jobs!map:entry(.,
map{
"complete":false(),
"details":job:list-details(.)
})))
let $_:=store:put($wrangle:id,map:merge((($this,wrangle:store()))))
return $wid
};
(:~ active wrangle ids :)
declare function wrangle:active()
as xs:string*{
job:list()!job:bindings(.)?($wrangle:id)=>distinct-values()
};
(:~ known wrangles :)
declare function wrangle:list()
as xs:string*{
wrangle:store()=>map:keys()
};
(:~ details for $wid wrangle :)
declare function wrangle:list-details($wid as xs:string)
as map(*){
wrangle:store()=>map:get($wid)
};
(:~ all wrangled jobs :)
declare function wrangle:job-list()
as xs:string*{
job:list()[job:bindings(.)=>map:contains($wrangle:id)]
};
(:~ jobs for wrangle id :)
declare function wrangle:job-list($wid as xs:string)
as xs:string*{
job:list()[job:bindings(.)?($wrangle:id) eq $wid]
};
(:~ is wrangle id finished (or unknown) :)
declare function wrangle:finished($wid as xs:string)
as xs:string*{
every $job in job:list()[job:bindings(.)?($wrangle:id) eq $wid] satisfies job:finished($job)
};
(:~ wait wrangle id finished (or unknown) :)
declare function wrangle:wait($wid as xs:string)
as empty-sequence(){
let $done:=every $job in job:list()[job:bindings(.)?($wrangle:id) eq $wid]
satisfies empty(job:wait($job))
return if($done) then ()
};
(:~ cancel wrangle id :)
declare function wrangle:remove($wid as xs:string)
as empty-sequence(){
job:list()[job:bindings(.)?($wrangle:id) eq $wid]!job:remove(.),
store:put($wrangle:id,wrangle:store()=>map:remove($wid))
};
(:~ tally of non-zero job status for $wid "scheduled", "queued", "running", "cached" :)
declare function wrangle:status($wid as xs:string)
as map(*){
wrangle:job-list($wid)!job:list-details(.)/@state/string()
=>fold-left(map{},wrangle:tally-count#2)
};
(:~ job-results with no error as sequence:)
declare function wrangle:results($wid as xs:string)
as item()*{
wrangle:job-list($wid)!wrangle:job-result(.)[not(?error)]?result
};
(:~ error counts keyed on $err:code :)
declare function wrangle:errors($wid as xs:string)
as map(*){
wrangle:job-list($wid)!wrangle:job-result(.)[?error]?result?code!string()
=>fold-left(map{},wrangle:tally-count#2)
};
(:~ key is $err:code values are joblists :)
declare function wrangle:jobs-by-error($wid as xs:string)
as map(*){
(for $jobId in wrangle:job-list($wid)
let $result:=wrangle:job-result($jobId)[?error]
where exists($result)
return map:entry($result?result?code!string(),$jobId)
)
=> map:merge( map{"duplicates":"combine"})
};
(:~ return key for job:)
declare function wrangle:job-key($jobId as xs:string)
as xs:string{
let $b:=job:bindings($jobId)
return $b?(map:keys($b)[. ne $wrangle:id])
};
(:~ return map from peek at result:)
declare function wrangle:job-result($jobId as xs:string)
as map(*){
try{
map{
"error":false(),
"result": job:result($jobId,map{"keep":true()})
}
}catch *{
map{
"error":true(),
"result": map{"description": $err:description,
"code": $err:code,
"line": $err:column-number,
"additional": $err:additional,
"value":$err:value
}
}
}
};
(:~ XQuery for background service :)
declare function wrangle:service()
as xs:string{
``[
import module namespace wrangle = 'urn:quodatum:wrangler:v1'; at "`{ static-base-uri() }`";
let $done:=wrangle:job-list()[job:finished(.)]
if(exists($done))
then let $w:=store:get($wrangle:id)
for $job in $done
group by $wid= job:bindings($job)?($wrangle:id)
for $job in $job
let $_:=store:put($wrangle:id)
]``
};
(:~ schedule as service :)
declare function wrangle:schedule-service()
as xs:string{
wrangle:service()
=>job:eval((), map { 'id':$wrangle:id, 'service':true(),
'interval': 'PT1S','log': $wrangle:id})
};
(:~ cached data as map :)
declare function wrangle:store()
as map(*){
store:get-or-put($wrangle:id,function(){map{}})
};
(:~ @return map string->count for fold-left :)
declare %private function wrangle:tally-count($r as map(*),$this as xs:string)
as map(*){
map:merge(
(map:entry($this,if(map:contains($r,$this)) then $r($this)+1 else 1),$r),
map{"duplicates":"use-first"}
)
};
(:~ @return map string->(string*) for fold-left :)
declare %private function wrangle:tally-list($r as map(*),$key as xs:string,$value as xs:string)
as map(*){
map:merge(
(map:entry($key,$value),$r),
map{"duplicates":"combine"}
)
xquery version '3.1';
(:~
Library to manage running multiple jobs using BaseX job:eval,
where the jobs are the execution of one function for a set of arguments
The function will have signature `fn($key as xs:string) as element()`
The function will typically create outputs and have side effects.
State information is persisted with the storage module, using the key '_wrangle'
It is a map{$wid: {"jobs":}}
requires basex 10+
@licence BSD
@author: quodatum
@date: 2023/02/12
:)
module namespace wrangle = 'urn:quodatum:wrangler';
(:~ semantic version :)
declare variable $wrangle:version:="1.0.0";
(:~ used in bindings to indicate a wrangle job and as store key :)
declare variable $wrangle:id:="_wrangle";
(:~
submit wrangle jobs for each $item
@param wrangle data{xq:...,bindings:..}
@return unique id for the job set
:)
declare function wrangle:queue($items as item()*,$wrangle as map(*))
as xs:string{
let $wid := random:uuid()
let $jobs := $items!job:eval($wrangle?xq,
map:merge(($wrangle?bindings(.),map:entry($wrangle:id,$wid))),
map{"cache":true()}
)
let $this := map:entry($wid,map:entry("jobs",$jobs!map:entry(.,
map{
"complete":false(),
"details":job:list-details(.)
})))
let $_:=store:put($wrangle:id,map:merge((($this,wrangle:store()))))
return $wid
};
(:~ active wrangle ids :)
declare function wrangle:active()
as xs:string*{
job:list()!job:bindings(.)?($wrangle:id)=>distinct-values()
};
(:~ known wrangles :)
declare function wrangle:list()
as xs:string*{
wrangle:store()=>map:keys()
};
(:~ details for $wid wrangle :)
declare function wrangle:list-details($wid as xs:string)
as map(*){
wrangle:store()=>map:get($wid)
};
(:~ all wrangled jobs :)
declare function wrangle:job-list()
as xs:string*{
job:list()[job:bindings(.)=>map:contains($wrangle:id)]
};
(:~ jobs for wrangle id :)
declare function wrangle:job-list($wid as xs:string)
as xs:string*{
job:list()[job:bindings(.)?($wrangle:id) eq $wid]
};
(:~ is wrangle id finished (or unknown) :)
declare function wrangle:finished($wid as xs:string)
as xs:string*{
every $job in job:list()[job:bindings(.)?($wrangle:id) eq $wid] satisfies job:finished($job)
};
(:~ wait wrangle id finished (or unknown) :)
declare function wrangle:wait($wid as xs:string)
as empty-sequence(){
let $done:=every $job in job:list()[job:bindings(.)?($wrangle:id) eq $wid]
satisfies empty(job:wait($job))
return if($done) then ()
};
(:~ cancel wrangle id :)
declare function wrangle:remove($wid as xs:string)
as empty-sequence(){
job:list()[job:bindings(.)?($wrangle:id) eq $wid]!job:remove(.),
store:put($wrangle:id,wrangle:store()=>map:remove($wid))
};
(:~ tally of non-zero job status for $wid "scheduled", "queued", "running", "cached" :)
declare function wrangle:status($wid as xs:string)
as map(*){
wrangle:job-list($wid)!job:list-details(.)/@state/string()
=>fold-left(map{},wrangle:tally-count#2)
};
(:~ job-results with no error as sequence:)
declare function wrangle:results($wid as xs:string)
as item()*{
wrangle:job-list($wid)!wrangle:job-result(.)[not(?error)]?result
};
(:~ error counts keyed on $err:code :)
declare function wrangle:errors($wid as xs:string)
as map(*){
wrangle:job-list($wid)!wrangle:job-result(.)[?error]?result?code!string()
=>fold-left(map{},wrangle:tally-count#2)
};
(:~ key is $err:code values are joblists :)
declare function wrangle:jobs-by-error($wid as xs:string)
as map(*){
(for $jobId in wrangle:job-list($wid)
let $result:=wrangle:job-result($jobId)[?error]
where exists($result)
return map:entry($result?result?code!string(),$jobId)
)
=> map:merge( map{"duplicates":"combine"})
};
(:~ return key for job:)
declare function wrangle:job-key($jobId as xs:string)
as xs:string{
let $b:=job:bindings($jobId)
return $b?(map:keys($b)[. ne $wrangle:id])
};
(:~ return map from peek at result:)
declare function wrangle:job-result($jobId as xs:string)
as map(*){
try{
map{
"error":false(),
"result": job:result($jobId,map{"keep":true()})
}
}catch *{
map{
"error":true(),
"result": map{"description": $err:description,
"code": $err:code,
"line": $err:column-number,
"additional": $err:additional,
"value":$err:value
}
}
}
};
(:~ XQuery for background service :)
declare function wrangle:service()
as xs:string{
``[
import module namespace wrangle = 'urn:quodatum:wrangler:v1'; at "`{ static-base-uri() }`";
let $done:=wrangle:job-list()[job:finished(.)]
if(exists($done))
then let $w:=store:get($wrangle:id)
for $job in $done
group by $wid= job:bindings($job)?($wrangle:id)
for $job in $job
let $_:=store:put($wrangle:id)
]``
};
(:~ schedule as service :)
declare function wrangle:schedule-service()
as xs:string{
wrangle:service()
=>job:eval((), map { 'id':$wrangle:id, 'service':true(),
'interval': 'PT1S','log': $wrangle:id})
};
(:~ cached data as map :)
declare function wrangle:store()
as map(*){
store:get-or-put($wrangle:id,function(){map{}})
};
(:~ @return map string->count for fold-left :)
declare %private function wrangle:tally-count($r as map(*),$this as xs:string)
as map(*){
map:merge(
(map:entry($this,if(map:contains($r,$this)) then $r($this)+1 else 1),$r),
map{"duplicates":"use-first"}
)
};
(:~ @return map string->(string*) for fold-left :)
declare %private function wrangle:tally-list($r as map(*),$key as xs:string,$value as xs:string)
as map(*){
map:merge(
(map:entry($key,$value),$r),
map{"duplicates":"combine"}
)
};

View file

@ -1,21 +1,21 @@
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>dev</title>
</head>
<body>
<div layout:fragment="content">
<sl-breadcrumb>
<sl-breadcrumb-item href="/app/dev">DEV</sl-breadcrumb-item>
<sl-breadcrumb-item>dba</sl-breadcrumb-item>
</sl-breadcrumb>
<iframe src="/dba/logs?input=%2Fapp%2F|£" allowScripts="true"
style="width:100%;height:80vh;overflow:clip;"></iframe>
</div>
</body>
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>dev</title>
</head>
<body>
<div layout:fragment="content">
<sl-breadcrumb>
<sl-breadcrumb-item href="/app/dev">DEV</sl-breadcrumb-item>
<sl-breadcrumb-item>dba</sl-breadcrumb-item>
</sl-breadcrumb>
<iframe src="/dba/logs?input=%2Fapp%2F|£" allowScripts="true"
style="width:100%;height:80vh;overflow:clip;"></iframe>
</div>
</body>
</html>

View file

@ -1,40 +1,40 @@
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>Dev home</title>
</head>
<body>
<div layout:fragment="content">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Dev</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a href="/app/dev/dba" class="nav-link" >dba</a>
</li>
<li class="nav-item">
<a href="/app/dev/jobs" class="nav-link" >jobs</a>
</li>
<li class="nav-item">
<a href="/dba/logs?input=%2Fapp%2F|£" target="_blank" class="nav-link" >DBA <sl-icon name="box-arrow-up-right"></sl-icon></a>
</li>
<li class="nav-item">
<a href="/app/api" target="_blank" class="nav-link" >wadl <sl-icon name="box-arrow-up-right"></sl-icon></a>
</li>
</ul>
</div>
</div>
</nav>
list tasks etc
</div>
</body>
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>Dev home</title>
</head>
<body>
<div layout:fragment="content">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Dev</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a href="/app/dev/dba" class="nav-link" >dba</a>
</li>
<li class="nav-item">
<a href="/app/dev/jobs" class="nav-link" >jobs</a>
</li>
<li class="nav-item">
<a href="/dba/logs?input=%2Fapp%2F|£" target="_blank" class="nav-link" >DBA <sl-icon name="box-arrow-up-right"></sl-icon></a>
</li>
<li class="nav-item">
<a href="/app/api" target="_blank" class="nav-link" >wadl <sl-icon name="box-arrow-up-right"></sl-icon></a>
</li>
</ul>
</div>
</div>
</nav>
list tasks etc
</div>
</body>
</html>

View file

@ -1,28 +1,28 @@
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>Jobs</title>
</head>
<body>
<div layout:fragment="content" class="container-fluid">
<div class="d-flex ">
<sl-breadcrumb class="flex-grow-1" >
<sl-breadcrumb-item href="/app/jobs">Jobs home</sl-breadcrumb-item>
<sl-breadcrumb-item>jobs <span class="badge bg-secondary">4</span></sl-breadcrumb-item>
</sl-breadcrumb>
<sl-switch id="job-refresh" checked="checked" >Refresh</sl-switch>
</div>
<h2>Jobs</h2>
<hr />
<div hx-get="/app/jobs/table" hx-trigger="every 1s [htmx.find('#job-refresh').checked]" >
Nothing Yet!
</div>
</div>
</body>
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>Jobs</title>
</head>
<body>
<div layout:fragment="content" class="container-fluid">
<div class="d-flex ">
<sl-breadcrumb class="flex-grow-1" >
<sl-breadcrumb-item href="/app/jobs">Jobs home</sl-breadcrumb-item>
<sl-breadcrumb-item>jobs <span class="badge bg-secondary">4</span></sl-breadcrumb-item>
</sl-breadcrumb>
<sl-switch id="job-refresh" checked="checked" >Refresh</sl-switch>
</div>
<h2>Jobs</h2>
<hr />
<div hx-get="/app/jobs/table" hx-trigger="every 1s [htmx.find('#job-refresh').checked]" >
Nothing Yet!
</div>
</div>
</body>
</html>

View file

@ -1,27 +1,27 @@
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>Error</title>
</head>
<body>
<div layout:fragment="content" class="container">
<h2 >Error: <span th:text="${code}" class="btn btn-danger"></span></h2>
<dl>
<dt>Description</dt>
<dd th:text="${description}"></dd>
<dt>Value</dt>
<dd th:text="${value}"></dd>
<dt>Module</dt>
<dd ><span th:text="${module}"/>[<span th:text="${line-number}"/>,<span th:text="${column-number}"/>]</dd>
<dt>Additional</dt>
<dd>
<pre th:text="${additional}"></pre>
</dd>
</dl>
</div>
</body>
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>Error</title>
</head>
<body>
<div layout:fragment="content" class="container">
<h2 >Error: <span th:text="${code}" class="btn btn-danger"></span></h2>
<dl>
<dt>Description</dt>
<dd th:text="${description}"></dd>
<dt>Value</dt>
<dd th:text="${value}"></dd>
<dt>Module</dt>
<dd ><span th:text="${module}"/>[<span th:text="${line-number}"/>,<span th:text="${column-number}"/>]</dd>
<dt>Additional</dt>
<dd>
<pre th:text="${additional}"></pre>
</dd>
</dl>
</div>
</body>
</html>

View file

@ -1,64 +1,64 @@
<!DOCTYPE html>
<html layout:decorate="~{layout.htm}"
xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<title>Home</title>
</head>
<body>
<div layout:fragment="content" class="container">
<!-- have a button POST a click via AJAX -->
<div style="display:inline-flex">
<p th:text="${version}">ver</p>
<sl-button hx-get="http://v2.jokeapi.dev/joke/Any?format=txt&amp;safe-mode&amp;type=single" hx-target="#joke-container" variant="default" hx-confirm="Do you want a Joke?">
<sl-icon slot="prefix" name="emoji-laughing"></sl-icon>Joke
</sl-button>
<p id="joke-container" style="flex-grow:4"> </p>
</div>
<hr />
<form hx-put="/pdf3/api/contact/1" hx-target="this" hx-swap="outerHTML">
<div>
<label>First Name</label>
<input type="text" name="firstName" value="Joe"/>
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" name="lastName" value="Blow"/>
</div>
<div class="form-group">
<label>Email Address</label>
<input type="email" name="email" value="joe@blow.com"/>
</div>
<button class="btn">Submit</button>
<button class="btn" hx-get="/contact/1">Cancel</button>
</form>
<hr />
<h2>Contacts</h2>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody id="contacts-table" hx-get="/pdf3/api/contacts/table" hx-trigger="newContact from:body">
</tbody>
</table>
<h2>Add A Contact</h2>
<form hx-post="/pdf3/api/contacts">
<label>
Name
<input name="name" type="text"/>
</label>
<label>
Email
<input name="email" type="email"/>
</label>
</form>
<hr />
</div>
</body>
<!DOCTYPE html>
<html layout:decorate="~{layout.htm}"
xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<title>Home</title>
</head>
<body>
<div layout:fragment="content" class="container">
<!-- have a button POST a click via AJAX -->
<div style="display:inline-flex">
<p th:text="${version}">ver</p>
<sl-button hx-get="http://v2.jokeapi.dev/joke/Any?format=txt&amp;safe-mode&amp;type=single" hx-target="#joke-container" variant="default" hx-confirm="Do you want a Joke?">
<sl-icon slot="prefix" name="emoji-laughing"></sl-icon>Joke
</sl-button>
<p id="joke-container" style="flex-grow:4"> </p>
</div>
<hr />
<form hx-put="/pdf3/api/contact/1" hx-target="this" hx-swap="outerHTML">
<div>
<label>First Name</label>
<input type="text" name="firstName" value="Joe"/>
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" name="lastName" value="Blow"/>
</div>
<div class="form-group">
<label>Email Address</label>
<input type="email" name="email" value="joe@blow.com"/>
</div>
<button class="btn">Submit</button>
<button class="btn" hx-get="/contact/1">Cancel</button>
</form>
<hr />
<h2>Contacts</h2>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody id="contacts-table" hx-get="/pdf3/api/contacts/table" hx-trigger="newContact from:body">
</tbody>
</table>
<h2>Add A Contact</h2>
<form hx-post="/pdf3/api/contacts">
<label>
Name
<input name="name" type="text"/>
</label>
<label>
Email
<input name="email" type="email"/>
</label>
</form>
<hr />
</div>
</body>
</html>

View file

@ -1,68 +1,68 @@
<!DOCTYPE HTML5>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="htmx-config"
content='{
"responseHandling":[
{"code":"204", "swap": false},
{"code":"[23]..", "swap": true},
{"code":"404", "swap": true},
{"code":"[45]..", "swap": false, "error":true},
{"code":"...", "swap": true}
],
"selfRequestsOnly": false
}'
/>
<title>LSP manager</title>
<link rel="icon" href="/app/static/favicon.png" />
<link rel="stylesheet" href="https://unpkg.com/missing.css@1.2.0" />
<link rel="stylesheet" href="/app/static/styles.css" />
<script defer="defer" src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.7/dist/htmx.js" integrity="sha384-yWakaGAFicqusuwOYEmoRjLNOC+6OFsdmwC2lbGQaRELtuVEqNzt11c2J711DeCZ" crossorigin="anonymous"></script>
<script defer="defer" src="/app/static/script.js"></script>
</head>
<body hx-boost="true" hx-indicator="#indicator" data-bs-theme="light" >
<div class='App'>
<header id="header" class="navbar">
<nav >
<ul role="list">
<li >
<a class="active" aria-current="page" href="/app/home">Home</a>
</li>
<li >
<a href="/app/socket">connections </a>
</li>
</ul>
</nav>
</header>
<main id="main" class="App-main">
<p layout:fragment="content">MAIN</p>
</main>
<footer id="footer">
<button onclick="toast('Hi. '+new Date())">toast</button>
LoggedIn: ??
<button type="button" class="btn btn-primary" id="liveToastBtn">Show live toast</button>
</footer>
</div>
</body>
<!DOCTYPE HTML5>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="htmx-config"
content='{
"responseHandling":[
{"code":"204", "swap": false},
{"code":"[23]..", "swap": true},
{"code":"404", "swap": true},
{"code":"[45]..", "swap": false, "error":true},
{"code":"...", "swap": true}
],
"selfRequestsOnly": false
}'
/>
<title>LSP manager</title>
<link rel="icon" href="/app/static/favicon.png" />
<link rel="stylesheet" href="https://unpkg.com/missing.css@1.2.0" />
<link rel="stylesheet" href="/app/static/styles.css" />
<script defer="defer" src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.7/dist/htmx.js" integrity="sha384-yWakaGAFicqusuwOYEmoRjLNOC+6OFsdmwC2lbGQaRELtuVEqNzt11c2J711DeCZ" crossorigin="anonymous"></script>
<script defer="defer" src="/app/static/script.js"></script>
</head>
<body hx-boost="true" hx-indicator="#indicator" data-bs-theme="light" >
<div class='App'>
<header id="header" class="navbar">
<nav >
<ul role="list">
<li >
<a class="active" aria-current="page" href="/app/home">Home</a>
</li>
<li >
<a href="/app/socket">connections </a>
</li>
</ul>
</nav>
</header>
<main id="main" class="App-main">
<p layout:fragment="content">MAIN</p>
</main>
<footer id="footer">
<button onclick="toast('Hi. '+new Date())">toast</button>
LoggedIn: ??
<button type="button" class="btn btn-primary" id="liveToastBtn">Show live toast</button>
</footer>
</div>
</body>
</html>

View file

@ -1,25 +1,25 @@
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>Login</title>
</head>
<body>
<div layout:fragment="content">
<form onsubmit="${login}" action="${router.guardUrl()}">
<fieldset style="width:50%;">
<sl-input label="User name" value="${session.login}" oninput="${html.set(session, 'login')}"
clearable="clearable"></sl-input>
<sl-input value="${session.password}" oninput="${html.set(session, 'password')}" type="password"
label="Password" password-toggle="password-toggle" clearable="clearable"></sl-input>
<input type="checkbox" checked="${session.loggedIn}" />
</fieldset>
<button type="submit">Login</button>
<button onclick="${fastlogin}">Fast</button>
</form>
</div>
</body>
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>Login</title>
</head>
<body>
<div layout:fragment="content">
<form onsubmit="${login}" action="${router.guardUrl()}">
<fieldset style="width:50%;">
<sl-input label="User name" value="${session.login}" oninput="${html.set(session, 'login')}"
clearable="clearable"></sl-input>
<sl-input value="${session.password}" oninput="${html.set(session, 'password')}" type="password"
label="Password" password-toggle="password-toggle" clearable="clearable"></sl-input>
<input type="checkbox" checked="${session.loggedIn}" />
</fieldset>
<button type="submit">Login</button>
<button onclick="${fastlogin}">Fast</button>
</form>
</div>
</body>
</html>

View file

@ -1,42 +1,42 @@
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>test</title>
</head>
<body>
<div layout:fragment="content">
<sl-card class="card-overview">
<div slot="header">
<sl-tooltip>
<div th:text="${pdf.slug}" slot="content">path</div>
<sl-badge th:text="${pdf.index}">{pdf.index}</sl-badge>
</sl-tooltip>
<a th:href="@{/pdfs/{pdf.id}/raw}" href="/app/pdfs/{pdf.id}/details"><small>{pdf}</small></a>
<sl-button-group label="History">
<sl-icon-button name="file-earmark-pdf" label="Settings"
th:href="@{/pdfs/{pdf.id}/raw}" href="/app/pdfs/{pdf.id}/view"></sl-icon-button>
</sl-button-group>
</div>
<div style="display:flex;">
<div>
<a href="/app/pdfs/{pdf.id}/details" class="holder center">
<img src="/app/pdfs/{pdf.id}/cover" loading="{index >10?'lazy':'eager'}"
alt="A kitten sits patiently." />
</a>
</div>
<div>
slug:<br /><small th:text="${pdf.id}">{pdf.id}</small><br />
</div>
</div>
</sl-card>
</div>
</body>
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>test</title>
</head>
<body>
<div layout:fragment="content">
<sl-card class="card-overview">
<div slot="header">
<sl-tooltip>
<div th:text="${pdf.slug}" slot="content">path</div>
<sl-badge th:text="${pdf.index}">{pdf.index}</sl-badge>
</sl-tooltip>
<a th:href="@{/pdfs/{pdf.id}/raw}" href="/app/pdfs/{pdf.id}/details"><small>{pdf}</small></a>
<sl-button-group label="History">
<sl-icon-button name="file-earmark-pdf" label="Settings"
th:href="@{/pdfs/{pdf.id}/raw}" href="/app/pdfs/{pdf.id}/view"></sl-icon-button>
</sl-button-group>
</div>
<div style="display:flex;">
<div>
<a href="/app/pdfs/{pdf.id}/details" class="holder center">
<img src="/app/pdfs/{pdf.id}/cover" loading="{index >10?'lazy':'eager'}"
alt="A kitten sits patiently." />
</a>
</div>
<div>
slug:<br /><small th:text="${pdf.id}">{pdf.id}</small><br />
</div>
</div>
</sl-card>
</div>
</body>
</html>

View file

@ -1,19 +1,19 @@
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>404</title>
</head>
<body>
<div layout:fragment="content">
<h2>Page not found:</h2>
<ul>
<li th:text="${path}">Page: pdf2/${ path }</li>
<li>Method: ${ method }</li>
</ul>
</div>
</body>
<!DOCTYPE HTML5>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.htm}">
<head>
<title>404</title>
</head>
<body>
<div layout:fragment="content">
<h2>Page not found:</h2>
<ul>
<li th:text="${path}">Page: pdf2/${ path }</li>
<li>Method: ${ method }</li>
</ul>
</div>
</body>
</html>

View file

@ -1,28 +1,28 @@
{
"capabilities": {
"textDocumentSync": 2,
"completionProvider": {
"resolveProvider": false,
"triggerCharacters": [
"\"",
":"
],
"documentSelector": [
{
"language": "xquery"
}
]
},
"hoverProvider": true,
"documentSymbolProvider": true,
"documentRangeFormattingProvider": false,
"colorProvider": false,
"foldingRangeProvider": false,
"selectionRangeProvider": false,
"documentLinkProvider": {},
"serverInfo": {
"name": "XQuery 4.0b Language Server",
"version": "0.0.2"
}
}
{
"capabilities": {
"textDocumentSync": 2,
"completionProvider": {
"resolveProvider": false,
"triggerCharacters": [
"\"",
":"
],
"documentSelector": [
{
"language": "xquery"
}
]
},
"hoverProvider": true,
"documentSymbolProvider": true,
"documentRangeFormattingProvider": false,
"colorProvider": false,
"foldingRangeProvider": false,
"selectionRangeProvider": false,
"documentLinkProvider": {},
"serverInfo": {
"name": "XQuery 4.0b Language Server",
"version": "0.0.2"
}
}
}

View file

@ -1,7 +1,7 @@
{
"tabSize": 2,
"insertSpaces": true,
"trimTrailingWhitespace": true,
"insertFinalNewline": true,
"trimFinalNewlines": true
{
"tabSize": 2,
"insertSpaces": true,
"trimTrailingWhitespace": true,
"insertFinalNewline": true,
"trimFinalNewlines": true
}

View file

@ -1,266 +1,266 @@
{
"new library module": {
"isFileTemplate": true,
"prefix": "library module",
"body": [
"xquery version '3.1';",
"(:~",
"@author: ",
"@date: $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE",
":)",
"module namespace ${1:prefix} = '${2:http://www.example.com/}';",
""
],
"description": "New library module template"
},
"new main module": {
"isFileTemplate": true,
"prefix": "main module",
"body": [
"xquery version '3.1';",
"(:~",
":)",
"${1:expr}",
""
],
"description": "New main module template"
},
"flowr": {
"prefix": [
"for",
"flowr"
],
"body": [
"for \\$${1:var} at \\$${2:pos} in ${3:expr}",
"let \\$${4:var2} := ${5:expr}",
"where ${6:boolean}",
"order by ${7:expr}",
"return ${8:expr2}"
],
"description": "Full FLOWR expression"
},
"return": {
"prefix": "return",
"body": "return ${1:expr}"
},
"import": {
"prefix": "import",
"body": "import module namespace ${1:ns} = '${2:http://www.example.com/}';",
"description": "Import module"
},
"if": {
"prefix": "if",
"body": [
"if (${1:boolean})",
"then ${2:expr1}",
"else ${3:expr2}"
],
"description": "If then else expression"
},
"module": {
"prefix": "module",
"body": "module namespace ${1:ns} = '${2:http://www.example.com}';"
},
"every": {
"prefix": "every",
"body": "every \\$${1:varname} in ${2:expr} satisfies ${3:expr}"
},
"some": {
"prefix": "some",
"body": "some \\$${1:varname} in ${2:expr} satisfies ${3:expr}"
},
"declare namespace": {
"prefix": [
"declare",
"namespace"
],
"body": [
"declare ${1:prefix}='${2:namespace}';",
""
],
"description": "declare namespace"
},
"declare base-uri": {
"prefix": [
"declare",
"baseuri"
],
"body": [
"declare base-uri '${1:uriliteral}';",
""
],
"description": "declare base-uri"
},
"declare option": {
"prefix": [
"declare",
"option"
],
"body": [
"declare option ${1:eqname} '${2:string}';",
""
],
"description": "declare option"
},
"declare function": {
"prefix": [
"declare",
"function"
],
"body": [
"(:~ ${1:name} :)",
"declare function ${2:ns}:${1:name}()",
"as ${3:type}{",
"${3:expr}",
"};",
""
],
"description": "declare function"
},
"declare variable": {
"prefix": [
"declare",
"variable"
],
"body": [
"(:~ \\$${1:varname} :)",
"declare variable \\$${1:varname} := ${2:expr};",
""
],
"description": "declare variable"
},
"switch": {
"prefix": "switch",
"body": [
"switch(${1:foo})",
"case ${2:foo} return ${3:true}",
"default return ${4:false}"
],
"description": "switch statement"
},
"typeswitch": {
"prefix": "type",
"body": [
"typeswitch(${1:foo})",
"case ${2:foo} return ${3:true}",
"default return ${4:false}"
],
"description": "typeswitch statement"
},
"try": {
"prefix": "try",
"body": [
"try {",
" ${1:expr}",
"} catch ${2:*}",
" { ${3:expr}",
"}"
],
"description": "try catch"
},
"tumbling": {
"prefix": [
"for",
"tumbling",
"window"
],
"body": [
"for tumbling window \\$${1:varname} in ${2:expr}",
"start at \\$${3:start} when ${4:expr}",
"end at \\$${5:end} when ${6:expr}",
"return ${7:expr}"
],
"description": "tumbling window"
},
"sliding": {
"prefix": [
"for",
"sliding",
"window"
],
"body": [
"for sliding window \\$${1:varname} in ${2:expr}",
"start at \\$${3:start} when ${4:expr}",
"end at \\$${5:end} when ${6:expr}",
"return ${7:expr}"
],
"description": "sliding window"
},
"let": {
"prefix": "let",
"body": "let \\$${1:varname} := ${2:expr}"
},
"castable": {
"body": "castable as ${1:atomicType}"
},
"cast": {
"body": "cast as ${1:atomicType}"
},
"update insert": {
"prefix": [
"update",
"insert"
],
"body": "insert node ${1:expr} into ${2:xpath}"
},
"update delete": {
"prefix": ["delete","update"],
"body": "delete node ${1:xpath}"
},
"update replace node": {
"prefix":["update","replace"],
"body": "replace node ${1:xpath} with ${2:expr}"
},
"update replace value": {
"prefix": [ "update",
"replace",
"value"
],
"body": "replace value of node ${1:xpath} with ${2:expr}"
},
"update rename": {
"prefix": [
"update",
"rename"
],
"body": "rename node ${1:xpath} as ${2:eqname}"
},
"copy modify return": {
"prefix": [
"copy",
"modify",
"return"
],
"body": [
"copy \\$${1:varname} := ${2:node}",
"modify ${3:updates}",
"return \\$${1:varname}"
]
},
"transform with": {
"prefix": [
"transform",
"with",
"update"
],
"body": [
"${1:node} transform with {",
" ${2:update}",
"}"
]
},
"transform update": {
"prefix": [
"transform",
"update"
],
"body": [
"${1:node} update {",
"${2:update}",
"}"
]
}
}
{
"new library module": {
"isFileTemplate": true,
"prefix": "library module",
"body": [
"xquery version '3.1';",
"(:~",
"@author: ",
"@date: $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE",
":)",
"module namespace ${1:prefix} = '${2:http://www.example.com/}';",
""
],
"description": "New library module template"
},
"new main module": {
"isFileTemplate": true,
"prefix": "main module",
"body": [
"xquery version '3.1';",
"(:~",
":)",
"${1:expr}",
""
],
"description": "New main module template"
},
"flowr": {
"prefix": [
"for",
"flowr"
],
"body": [
"for \\$${1:var} at \\$${2:pos} in ${3:expr}",
"let \\$${4:var2} := ${5:expr}",
"where ${6:boolean}",
"order by ${7:expr}",
"return ${8:expr2}"
],
"description": "Full FLOWR expression"
},
"return": {
"prefix": "return",
"body": "return ${1:expr}"
},
"import": {
"prefix": "import",
"body": "import module namespace ${1:ns} = '${2:http://www.example.com/}';",
"description": "Import module"
},
"if": {
"prefix": "if",
"body": [
"if (${1:boolean})",
"then ${2:expr1}",
"else ${3:expr2}"
],
"description": "If then else expression"
},
"module": {
"prefix": "module",
"body": "module namespace ${1:ns} = '${2:http://www.example.com}';"
},
"every": {
"prefix": "every",
"body": "every \\$${1:varname} in ${2:expr} satisfies ${3:expr}"
},
"some": {
"prefix": "some",
"body": "some \\$${1:varname} in ${2:expr} satisfies ${3:expr}"
},
"declare namespace": {
"prefix": [
"declare",
"namespace"
],
"body": [
"declare ${1:prefix}='${2:namespace}';",
""
],
"description": "declare namespace"
},
"declare base-uri": {
"prefix": [
"declare",
"baseuri"
],
"body": [
"declare base-uri '${1:uriliteral}';",
""
],
"description": "declare base-uri"
},
"declare option": {
"prefix": [
"declare",
"option"
],
"body": [
"declare option ${1:eqname} '${2:string}';",
""
],
"description": "declare option"
},
"declare function": {
"prefix": [
"declare",
"function"
],
"body": [
"(:~ ${1:name} :)",
"declare function ${2:ns}:${1:name}()",
"as ${3:type}{",
"${3:expr}",
"};",
""
],
"description": "declare function"
},
"declare variable": {
"prefix": [
"declare",
"variable"
],
"body": [
"(:~ \\$${1:varname} :)",
"declare variable \\$${1:varname} := ${2:expr};",
""
],
"description": "declare variable"
},
"switch": {
"prefix": "switch",
"body": [
"switch(${1:foo})",
"case ${2:foo} return ${3:true}",
"default return ${4:false}"
],
"description": "switch statement"
},
"typeswitch": {
"prefix": "type",
"body": [
"typeswitch(${1:foo})",
"case ${2:foo} return ${3:true}",
"default return ${4:false}"
],
"description": "typeswitch statement"
},
"try": {
"prefix": "try",
"body": [
"try {",
" ${1:expr}",
"} catch ${2:*}",
" { ${3:expr}",
"}"
],
"description": "try catch"
},
"tumbling": {
"prefix": [
"for",
"tumbling",
"window"
],
"body": [
"for tumbling window \\$${1:varname} in ${2:expr}",
"start at \\$${3:start} when ${4:expr}",
"end at \\$${5:end} when ${6:expr}",
"return ${7:expr}"
],
"description": "tumbling window"
},
"sliding": {
"prefix": [
"for",
"sliding",
"window"
],
"body": [
"for sliding window \\$${1:varname} in ${2:expr}",
"start at \\$${3:start} when ${4:expr}",
"end at \\$${5:end} when ${6:expr}",
"return ${7:expr}"
],
"description": "sliding window"
},
"let": {
"prefix": "let",
"body": "let \\$${1:varname} := ${2:expr}"
},
"castable": {
"body": "castable as ${1:atomicType}"
},
"cast": {
"body": "cast as ${1:atomicType}"
},
"update insert": {
"prefix": [
"update",
"insert"
],
"body": "insert node ${1:expr} into ${2:xpath}"
},
"update delete": {
"prefix": ["delete","update"],
"body": "delete node ${1:xpath}"
},
"update replace node": {
"prefix":["update","replace"],
"body": "replace node ${1:xpath} with ${2:expr}"
},
"update replace value": {
"prefix": [ "update",
"replace",
"value"
],
"body": "replace value of node ${1:xpath} with ${2:expr}"
},
"update rename": {
"prefix": [
"update",
"rename"
],
"body": "rename node ${1:xpath} as ${2:eqname}"
},
"copy modify return": {
"prefix": [
"copy",
"modify",
"return"
],
"body": [
"copy \\$${1:varname} := ${2:node}",
"modify ${3:updates}",
"return \\$${1:varname}"
]
},
"transform with": {
"prefix": [
"transform",
"with",
"update"
],
"body": [
"${1:node} transform with {",
" ${2:update}",
"}"
]
},
"transform update": {
"prefix": [
"transform",
"update"
],
"body": [
"${1:node} update {",
"${2:update}",
"}"
]
}
}

View file

@ -1,279 +1,279 @@
{
"new library module": {
"isFileTemplate": true,
"prefix": "library module",
"body": [
"xquery version '3.1';",
"(:~",
"@author: ",
"@date: $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE",
":)",
"module namespace ${1:prefix} = '${2:http://www.example.com/}';",
""
],
"description": "New library module template"
},
"new main module": {
"isFileTemplate": true,
"prefix": "main module",
"body": [
"xquery version '3.1';",
"(:~",
":)",
"${1:expr}",
""
],
"description": "New main module template"
},
"flowr": {
"prefix": [
"for",
"flowr"
],
"body": [
"for \\$${1:var} at \\$${2:pos} in ${3:expr}",
"let \\$${4:var2} := ${5:expr}",
"where ${6:boolean}",
"order by ${7:expr}",
"return ${8:expr2}"
],
"description": "Full FLOWR expression"
},
"return": {
"prefix": "return",
"body": "return ${1:expr}"
},
"import": {
"prefix": "import",
"body": "import module namespace ${1:ns} = '${2:http://www.example.com/}';",
"description": "Import module"
},
"if": {
"prefix": "if",
"body": [
"if (${1:boolean})",
"then ${2:expr1}",
"else ${3:expr2}"
],
"description": "If then else expression"
},
"module": {
"prefix": "module",
"body": "module namespace ${1:ns} = '${2:http://www.example.com}';"
},
"every": {
"prefix": "every",
"body": "every \\$${1:varname} in ${2:expr} satisfies ${3:expr}"
},
"some": {
"prefix": "some",
"body": "some \\$${1:varname} in ${2:expr} satisfies ${3:expr}"
},
"declare namespace": {
"prefix": [
"declare",
"namespace"
],
"body": [
"declare ${1:prefix}='${2:namespace}';",
""
],
"description": "declare namespace"
},
"declare base-uri": {
"prefix": [
"declare",
"baseuri"
],
"body": [
"declare base-uri '${1:uriliteral}';",
""
],
"description": "declare base-uri"
},
"declare option": {
"prefix": [
"declare",
"option"
],
"body": [
"declare option ${1:eqname} '${2:string}';",
""
],
"description": "declare option"
},
"declare function": {
"prefix": [
"declare",
"function"
],
"body": [
"(:~ ${1:name} :)",
"declare function ${2:ns}:${1:name}()",
"as ${3:type}{",
"${3:expr}",
"};",
""
],
"description": "declare function"
},
"declare variable": {
"prefix": [
"declare",
"variable"
],
"body": [
"(:~ \\$${1:varname} :)",
"declare variable \\$${1:varname} := ${2:expr};",
""
],
"description": "declare variable"
},
"switch": {
"prefix": "switch",
"body": [
"switch(${1:foo})",
"case ${2:foo} return ${3:true}",
"default return ${4:false}"
],
"description": "switch statement"
},
"typeswitch": {
"prefix": "type",
"body": [
"typeswitch(${1:foo})",
"case ${2:foo} return ${3:true}",
"default return ${4:false}"
],
"description": "typeswitch statement"
},
"try": {
"prefix": "try",
"body": [
"try {",
" ${1:expr}",
"} catch ${2:*}",
" { ${3:expr}",
"}"
],
"description": "try catch"
},
"tumbling": {
"prefix": [
"for",
"tumbling",
"window"
],
"body": [
"for tumbling window \\$${1:varname} in ${2:expr}",
"start at \\$${3:start} when ${4:expr}",
"end at \\$${5:end} when ${6:expr}",
"return ${7:expr}"
],
"description": "tumbling window"
},
"sliding": {
"prefix": [
"for",
"sliding",
"window"
],
"body": [
"for sliding window \\$${1:varname} in ${2:expr}",
"start at \\$${3:start} when ${4:expr}",
"end at \\$${5:end} when ${6:expr}",
"return ${7:expr}"
],
"description": "sliding window"
},
"let": {
"prefix": "let",
"body": "let \\$${1:varname} := ${2:expr}"
},
"castable": {
"body": "castable as ${1:atomicType}"
},
"cast": {
"body": "cast as ${1:atomicType}"
},
// Updates ***************
"update insert": {
"prefix": [
"update",
"insert"
],
"body": "insert node ${1:expr} into ${2:xpath}"
},
"update delete": {
"prefix": ["delete","update"],
"body": "delete node ${1:xpath}"
},
"update replace node": {
"prefix":["update","replace"],
"body": "replace node ${1:xpath} with ${2:expr}"
},
"update replace value": {
"prefix": [ "update",
"replace",
"value"
],
"body": "replace value of node ${1:xpath} with ${2:expr}"
},
"update rename": {
"prefix": [
"update",
"rename"
],
"body": "rename node ${1:xpath} as ${2:eqname}"
},
"copy modify return": {
"prefix": [
"copy",
"modify",
"return"
],
"body": [
"copy \\$${1:varname} := ${2:node}",
"modify ${3:updates}",
"return \\$${1:varname}"
]
},
"transform with": {
"prefix": [
"transform",
"with",
"update"
],
"body": [
"${1:node} transform with {",
" ${2:update}",
"}"
]
},
"transform update": {
"prefix": [
"transform",
"update"
],
"body": [
"${1:node} update {",
"${2:update}",
"}"
]
}
}
//snippet group
// group by $${1:varname} := ${2:expr}
//snippet order
// order by ${1:expr} ${2:descending}
//snippet stable
// stable order by ${1:expr}
//snippet count
// count $${1:varname}
//snippet ordered
// ordered { ${1:expr} }
//snippet unordered
// unordered { ${1:expr} }
//snippet treat
// treat as ${1:expr}
{
"new library module": {
"isFileTemplate": true,
"prefix": "library module",
"body": [
"xquery version '3.1';",
"(:~",
"@author: ",
"@date: $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE",
":)",
"module namespace ${1:prefix} = '${2:http://www.example.com/}';",
""
],
"description": "New library module template"
},
"new main module": {
"isFileTemplate": true,
"prefix": "main module",
"body": [
"xquery version '3.1';",
"(:~",
":)",
"${1:expr}",
""
],
"description": "New main module template"
},
"flowr": {
"prefix": [
"for",
"flowr"
],
"body": [
"for \\$${1:var} at \\$${2:pos} in ${3:expr}",
"let \\$${4:var2} := ${5:expr}",
"where ${6:boolean}",
"order by ${7:expr}",
"return ${8:expr2}"
],
"description": "Full FLOWR expression"
},
"return": {
"prefix": "return",
"body": "return ${1:expr}"
},
"import": {
"prefix": "import",
"body": "import module namespace ${1:ns} = '${2:http://www.example.com/}';",
"description": "Import module"
},
"if": {
"prefix": "if",
"body": [
"if (${1:boolean})",
"then ${2:expr1}",
"else ${3:expr2}"
],
"description": "If then else expression"
},
"module": {
"prefix": "module",
"body": "module namespace ${1:ns} = '${2:http://www.example.com}';"
},
"every": {
"prefix": "every",
"body": "every \\$${1:varname} in ${2:expr} satisfies ${3:expr}"
},
"some": {
"prefix": "some",
"body": "some \\$${1:varname} in ${2:expr} satisfies ${3:expr}"
},
"declare namespace": {
"prefix": [
"declare",
"namespace"
],
"body": [
"declare ${1:prefix}='${2:namespace}';",
""
],
"description": "declare namespace"
},
"declare base-uri": {
"prefix": [
"declare",
"baseuri"
],
"body": [
"declare base-uri '${1:uriliteral}';",
""
],
"description": "declare base-uri"
},
"declare option": {
"prefix": [
"declare",
"option"
],
"body": [
"declare option ${1:eqname} '${2:string}';",
""
],
"description": "declare option"
},
"declare function": {
"prefix": [
"declare",
"function"
],
"body": [
"(:~ ${1:name} :)",
"declare function ${2:ns}:${1:name}()",
"as ${3:type}{",
"${3:expr}",
"};",
""
],
"description": "declare function"
},
"declare variable": {
"prefix": [
"declare",
"variable"
],
"body": [
"(:~ \\$${1:varname} :)",
"declare variable \\$${1:varname} := ${2:expr};",
""
],
"description": "declare variable"
},
"switch": {
"prefix": "switch",
"body": [
"switch(${1:foo})",
"case ${2:foo} return ${3:true}",
"default return ${4:false}"
],
"description": "switch statement"
},
"typeswitch": {
"prefix": "type",
"body": [
"typeswitch(${1:foo})",
"case ${2:foo} return ${3:true}",
"default return ${4:false}"
],
"description": "typeswitch statement"
},
"try": {
"prefix": "try",
"body": [
"try {",
" ${1:expr}",
"} catch ${2:*}",
" { ${3:expr}",
"}"
],
"description": "try catch"
},
"tumbling": {
"prefix": [
"for",
"tumbling",
"window"
],
"body": [
"for tumbling window \\$${1:varname} in ${2:expr}",
"start at \\$${3:start} when ${4:expr}",
"end at \\$${5:end} when ${6:expr}",
"return ${7:expr}"
],
"description": "tumbling window"
},
"sliding": {
"prefix": [
"for",
"sliding",
"window"
],
"body": [
"for sliding window \\$${1:varname} in ${2:expr}",
"start at \\$${3:start} when ${4:expr}",
"end at \\$${5:end} when ${6:expr}",
"return ${7:expr}"
],
"description": "sliding window"
},
"let": {
"prefix": "let",
"body": "let \\$${1:varname} := ${2:expr}"
},
"castable": {
"body": "castable as ${1:atomicType}"
},
"cast": {
"body": "cast as ${1:atomicType}"
},
// Updates ***************
"update insert": {
"prefix": [
"update",
"insert"
],
"body": "insert node ${1:expr} into ${2:xpath}"
},
"update delete": {
"prefix": ["delete","update"],
"body": "delete node ${1:xpath}"
},
"update replace node": {
"prefix":["update","replace"],
"body": "replace node ${1:xpath} with ${2:expr}"
},
"update replace value": {
"prefix": [ "update",
"replace",
"value"
],
"body": "replace value of node ${1:xpath} with ${2:expr}"
},
"update rename": {
"prefix": [
"update",
"rename"
],
"body": "rename node ${1:xpath} as ${2:eqname}"
},
"copy modify return": {
"prefix": [
"copy",
"modify",
"return"
],
"body": [
"copy \\$${1:varname} := ${2:node}",
"modify ${3:updates}",
"return \\$${1:varname}"
]
},
"transform with": {
"prefix": [
"transform",
"with",
"update"
],
"body": [
"${1:node} transform with {",
" ${2:update}",
"}"
]
},
"transform update": {
"prefix": [
"transform",
"update"
],
"body": [
"${1:node} update {",
"${2:update}",
"}"
]
}
}
//snippet group
// group by $${1:varname} := ${2:expr}
//snippet order
// order by ${1:expr} ${2:descending}
//snippet stable
// stable order by ${1:expr}
//snippet count
// count $${1:varname}
//snippet ordered
// ordered { ${1:expr} }
//snippet unordered
// unordered { ${1:expr} }
//snippet treat
// treat as ${1:expr}

View file

@ -1,18 +1,18 @@
module namespace lint="lsp/lint";
(:
Describes a problem or hint for a piece of code.
from: number The start position of the relevant text.
to: number The end position. May be equal to from, though actually covering text is preferable.
severity: "error" | "hint" | "info" | "warning". The severity of the problem. This will influence how it is displayed.
markClass?: string When given, add an extra CSS class to parts of the code that this diagnostic applies to.
source?: string An optional source string indicating where the diagnostic is coming from. You can put the name of your linter here, if applicable.
message: string The message associated with this diagnostic.
renderMessage?: fn(view: EditorView) → Node An optional custom rendering function that displays the message as a DOM node.
actions?: readonly Action[] An optional array of actions that can be taken on this diagnostic.
module namespace lint="lsp/lint";
(:
Describes a problem or hint for a piece of code.
from: number The start position of the relevant text.
to: number The end position. May be equal to from, though actually covering text is preferable.
severity: "error" | "hint" | "info" | "warning". The severity of the problem. This will influence how it is displayed.
markClass?: string When given, add an extra CSS class to parts of the code that this diagnostic applies to.
source?: string An optional source string indicating where the diagnostic is coming from. You can put the name of your linter here, if applicable.
message: string The message associated with this diagnostic.
renderMessage?: fn(view: EditorView) → Node An optional custom rendering function that displays the message as a DOM node.
actions?: readonly Action[] An optional array of actions that can be taken on this diagnostic.
:)

View file

@ -1,4 +1,4 @@
job:eval(xs:anyURI("parse.xq"),
{"textDocument":"2+3","webSocket":ws:id()},
{ 'cache': true() }
job:eval(xs:anyURI("parse.xq"),
{"textDocument":"2+3","webSocket":ws:id()},
{ 'cache': true() }
)

View file

@ -1,28 +1,28 @@
import * as aceBuilds from 'https://esm.run/ace-builds';
import ace from 'https://cdn.jsdelivr.net/npm/ace/+esm'
/* import 'ace-builds/src-noconflict/mode-javascript';
import 'ace-builds/src-noconflict/theme-chrome'; */
/* import {AceLanguageClient} from "ace-linters/build/ace-language-client";
const serverData = {
module: () => import("ace-linters/build/language-client"),
modes: "json|json5",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"), // your websocket server address
}
*/
// Initialize the editor
const editor = ace.edit("editor", {
theme: "ace/theme/chrome",
mode: "ace/mode/javascript",
fontSize: "14px",
showPrintMargin: false,
useWorker: false // Disable web worker for this simple demo
});
// Create a language provider for WebSocket
//let languageProvider = AceLanguageClient.for(serverData);
import * as aceBuilds from 'https://esm.run/ace-builds';
import ace from 'https://cdn.jsdelivr.net/npm/ace/+esm'
/* import 'ace-builds/src-noconflict/mode-javascript';
import 'ace-builds/src-noconflict/theme-chrome'; */
/* import {AceLanguageClient} from "ace-linters/build/ace-language-client";
const serverData = {
module: () => import("ace-linters/build/language-client"),
modes: "json|json5",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"), // your websocket server address
}
*/
// Initialize the editor
const editor = ace.edit("editor", {
theme: "ace/theme/chrome",
mode: "ace/mode/javascript",
fontSize: "14px",
showPrintMargin: false,
useWorker: false // Disable web worker for this simple demo
});
// Create a language provider for WebSocket
//let languageProvider = AceLanguageClient.for(serverData);
//languageProvider.registerEditor(editor);

View file

@ -1,52 +1,52 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>BaseX LSP</title>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ace.js"></script>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ext-language_tools.js"></script>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ext-modelist.js"></script>
<!-- -->
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-linters.js"></script>
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-language-client.js"></script>
<script type="module" src="acego.js"></script>
</head>
<body>
<div>something<button onclick="foo()">send</button><a href="/dba/logs" target="_blank">dba</a></div>
<div id="editor" style="height: 100px">some text</div>
<script>
var modelist = ace.require('ace/ext/modelist');
if(modelist.modesByName['json'] == undefined) {
console.log("mode doesn't exist");
}
var servers = [
{
module: () => import("XXXXXace-linters/build/language-client"),
modes: "json",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"),
}
];
let languageProvider = AceLanguageClient.for(servers);
ace.require("ace/ext/language_tools"); //To allow autocompletion
var editor = ace.edit("editor", {
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
mode: "json"
});
languageProvider.registerEditor(editor);
// editor.session.setMode("astro"); // mode now contains "ace/mode/javascript".
function foo(){
servers[0].socket.send("TTTTT")
alert("hi")
}
</script>
</body>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>BaseX LSP</title>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ace.js"></script>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ext-language_tools.js"></script>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ext-modelist.js"></script>
<!-- -->
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-linters.js"></script>
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-language-client.js"></script>
<script type="module" src="acego.js"></script>
</head>
<body>
<div>something<button onclick="foo()">send</button><a href="/dba/logs" target="_blank">dba</a></div>
<div id="editor" style="height: 100px">some text</div>
<script>
var modelist = ace.require('ace/ext/modelist');
if(modelist.modesByName['json'] == undefined) {
console.log("mode doesn't exist");
}
var servers = [
{
module: () => import("XXXXXace-linters/build/language-client"),
modes: "json",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"),
}
];
let languageProvider = AceLanguageClient.for(servers);
ace.require("ace/ext/language_tools"); //To allow autocompletion
var editor = ace.edit("editor", {
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
mode: "json"
});
languageProvider.registerEditor(editor);
// editor.session.setMode("astro"); // mode now contains "ace/mode/javascript".
function foo(){
servers[0].socket.send("TTTTT")
alert("hi")
}
</script>
</body>
</html>

View file

@ -1,29 +1,29 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,height=device-height" />
<title>BaseX LSP Demo WIP</title>
<link rel="stylesheet" href="styles.css">
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ace.js"></script>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ext-language_tools.js"></script>
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-linters.js"></script>
<script src="https://www.unpkg.com/ace-linters@latest/build/service-manager.js"></script>
</head>
<body>
<header>something
<button onclick="opts(editor)">console</button>
<button onclick="editor.showSettingsMenu();">Settings</button>
<a href="/dba/logs" target="_blank">dba</a>
</header>
<div>
<div id="settings" style="height: 100px">sett</div>
<div id="editor" style="height: 100px">some text</div>
</div>
<script src="script.js"></script>
</body>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,height=device-height" />
<title>BaseX LSP Demo WIP</title>
<link rel="stylesheet" href="styles.css">
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ace.js"></script>
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ext-language_tools.js"></script>
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-linters.js"></script>
<script src="https://www.unpkg.com/ace-linters@latest/build/service-manager.js"></script>
</head>
<body>
<header>something
<button onclick="opts(editor)">console</button>
<button onclick="editor.showSettingsMenu();">Settings</button>
<a href="/dba/logs" target="_blank">dba</a>
</header>
<div>
<div id="settings" style="height: 100px">sett</div>
<div id="editor" style="height: 100px">some text</div>
</div>
<script src="script.js"></script>
</body>
</html>

View file

@ -1,42 +1,42 @@
ace.require("ace/ext/language_tools"); //To allow autocompletion
var editor = ace.edit("editor", {
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
theme: "ace/theme/chrome",
mode: "ace/mode/html",
fontSize: "14px",
showPrintMargin: false,
useWorker: false // Disable web worker for this simple demo
});
ace.require('ace/ext/settings_menu');
editor.setTheme("ace/theme/github");
//editor.session.setMode("ace/mode/html");
editor.commands.addCommands([
{
name: "showSettingsMenu",
bindKey: {
win: "Ctrl-q",
mac: "Ctrl-q"
},
exec: function (editor) {
editor.showSettingsMenu();
},
readOnly: true
}
]);
var provider = LanguageProvider.fromCdn("https://www.unpkg.com/ace-linters@latest/build/");
provider.registerEditor(editor);
const serverData = {
module: () => import("https://www.unpkg.com/ace-linters@latest/build/language-client"),
modes: "json|json5",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"), // your websocket server address
}
function opts(editor) {
const modes=editor.session.$modes;
console.log(editor.session.$modeId);
console.log(Object.keys(modes));
ace.require("ace/ext/language_tools"); //To allow autocompletion
var editor = ace.edit("editor", {
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
theme: "ace/theme/chrome",
mode: "ace/mode/html",
fontSize: "14px",
showPrintMargin: false,
useWorker: false // Disable web worker for this simple demo
});
ace.require('ace/ext/settings_menu');
editor.setTheme("ace/theme/github");
//editor.session.setMode("ace/mode/html");
editor.commands.addCommands([
{
name: "showSettingsMenu",
bindKey: {
win: "Ctrl-q",
mac: "Ctrl-q"
},
exec: function (editor) {
editor.showSettingsMenu();
},
readOnly: true
}
]);
var provider = LanguageProvider.fromCdn("https://www.unpkg.com/ace-linters@latest/build/");
provider.registerEditor(editor);
const serverData = {
module: () => import("https://www.unpkg.com/ace-linters@latest/build/language-client"),
modes: "json|json5",
type: "socket",
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"), // your websocket server address
}
function opts(editor) {
const modes=editor.session.$modes;
console.log(editor.session.$modeId);
console.log(Object.keys(modes));
}

View file

@ -1,33 +1,33 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,height=device-height" />
<title>BaseX LSP</title>
</head>
<body>
<div>Socket <button onclick="foo()">send</button><a href="/dba/logs" target="_blank">dba</a></div>
<script>
var socket = new WebSocket("ws://127.0.0.1:3000/ws/lsp") // address of your websocket server
// Listen for possible errors
socket.addEventListener("error", (event) => {
console.log("WebSocket error: ", event);
});
socket.addEventListener("close", (event) => {
console.log("closed", event.code, event.reason, event.wasClean);
});
socket.addEventListener("open", (event) => {
setInterval(function ping() { socket.send('{"type":"ping","msg":"staying alive"}'); }, 100000);
socket.send('{"type":"ping","msg":"Hello Server!"}');
});
function foo() {
socket.send('{"type":"ping","msg":"foo!"}');
};
</script>
</body>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,height=device-height" />
<title>BaseX LSP</title>
</head>
<body>
<div>Socket <button onclick="foo()">send</button><a href="/dba/logs" target="_blank">dba</a></div>
<script>
var socket = new WebSocket("ws://127.0.0.1:3000/ws/lsp") // address of your websocket server
// Listen for possible errors
socket.addEventListener("error", (event) => {
console.log("WebSocket error: ", event);
});
socket.addEventListener("close", (event) => {
console.log("closed", event.code, event.reason, event.wasClean);
});
socket.addEventListener("open", (event) => {
setInterval(function ping() { socket.send('{"type":"ping","msg":"staying alive"}'); }, 100000);
socket.send('{"type":"ping","msg":"Hello Server!"}');
});
function foo() {
socket.send('{"type":"ping","msg":"foo!"}');
};
</script>
</body>
</html>

View file

@ -1,7 +1,7 @@
header {
background-color: aqua;
}
.box {
border: 2px dotted rgb(96 139 168);
display: flex;
header {
background-color: aqua;
}
.box {
border: 2px dotted rgb(96 139 168);
display: flex;
}

View file

@ -1,122 +1,122 @@
@import url("../codicon@0.0.40/codicon.css");
:root {
color-scheme: light dark;
--quiet-primary-seed: #e98d61;
--quiet-content-spacing: 0.75rem;
--quiet-form-control-height-md:0.9rem;
--quiet-focus-width: 2px;
--quiet-focus-offset: 0px;
}
form header {
background-color: burlywood;
}
.page-wrap {
background: white;
height: 100vh ;
display: grid;
grid-template-columns: minmax(10px, 1fr) minmax(10px, 4fr);
grid-template-rows: min-content min-content 1fr min-content;
details {
}
details[open] {
flex-grow: 1;
overflow: hidden;
}
summary {
background-color: var(--quiet-neutral-fill-softer);
}
/* Set editor dimensions */
#editor {
max-width: 100%;
overflow: hidden;
height: 75cqh;
}
/* Stretch editor to fit inside its containing div */
.cm-editor {
height: 100%;
width: 100%;
overflow: auto;
}
details[open]::details-content {
padding: 0.1em;
border: thin solid grey;
overflow: auto;
}
::backdrop {
backdrop-filter: blur(2px);
}
@media (max-width: 600px) {
grid-template-columns: 100%;
grid-template-rows: auto;
>* {
grid-column: 1 / -1 !important;
grid-row: auto !important;
}
}
}
#tConnect:state(unchecked) {
outline: dashed 4px deeppink;
outline-offset: 4px;
}
.page-header {
grid-column: 1 / -1;
display: flex;
justify-content: space-between;
background: #ffecb3;
}
.page-sidebar {
grid-column: 1 / 2;
grid-row: 2 / 4;
display: flex;
flex-direction: column;
details {
display: flex;
flex-direction: column;
}
}
.page-nav {
grid-column: 2 / 3;
background: red;
}
.page-main {
grid-column: 2 / 3;
display: flex;
flex-direction: column;
}
.page-footer {
grid-column: 1 / -1;
background: #ffecb3;
display: flex;
justify-content: space-between;
padding:2px;
@import url("../codicon@0.0.40/codicon.css");
:root {
color-scheme: light dark;
--quiet-primary-seed: #e98d61;
--quiet-content-spacing: 0.75rem;
--quiet-form-control-height-md:0.9rem;
--quiet-focus-width: 2px;
--quiet-focus-offset: 0px;
}
form header {
background-color: burlywood;
}
.page-wrap {
background: white;
height: 100vh ;
display: grid;
grid-template-columns: minmax(10px, 1fr) minmax(10px, 4fr);
grid-template-rows: min-content min-content 1fr min-content;
details {
}
details[open] {
flex-grow: 1;
overflow: hidden;
}
summary {
background-color: var(--quiet-neutral-fill-softer);
}
/* Set editor dimensions */
#editor {
max-width: 100%;
overflow: hidden;
height: 75cqh;
}
/* Stretch editor to fit inside its containing div */
.cm-editor {
height: 100%;
width: 100%;
overflow: auto;
}
details[open]::details-content {
padding: 0.1em;
border: thin solid grey;
overflow: auto;
}
::backdrop {
backdrop-filter: blur(2px);
}
@media (max-width: 600px) {
grid-template-columns: 100%;
grid-template-rows: auto;
>* {
grid-column: 1 / -1 !important;
grid-row: auto !important;
}
}
}
#tConnect:state(unchecked) {
outline: dashed 4px deeppink;
outline-offset: 4px;
}
.page-header {
grid-column: 1 / -1;
display: flex;
justify-content: space-between;
background: #ffecb3;
}
.page-sidebar {
grid-column: 1 / 2;
grid-row: 2 / 4;
display: flex;
flex-direction: column;
details {
display: flex;
flex-direction: column;
}
}
.page-nav {
grid-column: 2 / 3;
background: red;
}
.page-main {
grid-column: 2 / 3;
display: flex;
flex-direction: column;
}
.page-footer {
grid-column: 1 / -1;
background: #ffecb3;
display: flex;
justify-content: space-between;
padding:2px;
}

View file

@ -1,307 +1,307 @@
<!doctype html>
<html lang="en" class="quiet-cloak quiet-blue"
data-quiet="/static/clients/quietui@1.6.2/dist"> <!-- also quiet-dark -->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Codemirror6 example using BaseX LSP</title>
<link rel="icon" type="image/png" href="../favicon.png" />
<!-- Quiet theme + autoloader -->
<!-- Default theme (if not already installed) -->
<link rel="stylesheet" href="/static/clients/quietui@1.6.2/dist/themes/quiet.css">
<!-- Quiet Restyle -->
<link rel="stylesheet" href="/static/clients/quietui@1.6.2/dist/themes/restyle.css">
<script type="module" src="/static/clients/quietui@1.6.2/dist/quiet.loader.js"></script>
<script type="module" src="icons.js"></script>
<link rel="stylesheet" href="grail.css" />
</head>
<body>
<div class="page-wrap">
<header class="page-header">
<quiet-dropdown placement="right">
<quiet-button slot="trigger">File
<quiet-icon slot="end" name="chevron-right"></quiet-icon>
</quiet-button>
<quiet-dropdown-item id="bnNew">
<quiet-icon slot="start" name="file"></quiet-icon>New...
<div slot="details">create a new doc</div>
</quiet-dropdown-item>
<quiet-dropdown-item id="bnRead">
<quiet-icon slot="start" name="folder-open"></quiet-icon>Open...
<div slot="details">select a local file</div>
</quiet-dropdown-item>
<input type="file" id="fileElem" multiple accept="*/*" style="display: none;" />
<quiet-dropdown-item id="popover__url">
<quiet-icon slot="start" name="link"></quiet-icon>Url...
<div slot="details">Fetch from a url</div>
</quiet-dropdown-item>
</quiet-dropdown>
<div>
<span class="quiet-h4">XQuery 4.0 LSP client</span>
<quiet-toggle-icon id="tConnect" label="Connection status" size="lg"
style="--checked-color: green;--unchecked-color: red;">
<quiet-icon slot="unchecked" name="network-off" family="outline"></quiet-icon>
<quiet-icon slot="checked" name="network" family="outline"></quiet-icon>
</quiet-toggle-icon>
<quiet-tooltip id="tipConnect" for="tConnect">I'm a tooltip</quiet-tooltip>
</div>
<quiet-button-group>
<quiet-dropdown>
<quiet-button slot="trigger" with-caret>Dev tools</quiet-button>
<quiet-dropdown-item href="/app/home" target="lsp" rel="noreferrer noopener">
LSP Manager <quiet-icon name="external-link" slot="icon"></quiet-icon></quiet-dropdown-item>
<quiet-dropdown-item href="/dba/logs" target="dba" rel="noreferrer noopener">
Dba <quiet-icon name="external-link" slot="icon"></quiet-icon></quiet-dropdown-item>
<quiet-divider></quiet-divider>
</quiet-dropdown>
<button popovertarget="popAbout" type="button">
<quiet-icon name="help"></quiet-icon>
</button>
</quiet-button-group>
</header>
<main id="main" class="page-main" style="overflow: auto;">
<quiet-toolbar style="padding:2px;background-color: var(--quiet-neutral-fill-softer);">
<quiet-button-group>
<quiet-button id="search" title="Search" icon-label="search" size="xs">
<quiet-icon name="search"></quiet-icon>
</quiet-button>
<quiet-button id="lint" title="Display diagnostics" icon-label="diagnostics" size="xs">
<quiet-icon name="message-report"></quiet-icon>
</quiet-button>
<quiet-button id="symbols2" title="symbols" icon-label="Symbols" size="xs">
<quiet-icon name="icons"></quiet-icon>
</quiet-button>
<quiet-button id="format" type="button" title="Format (Shift-Alt-f)" icon-label="Format" size="xs">
<quiet-icon name="align-justified"></quiet-icon>
</quiet-button>
</quiet-button-group>
<quiet-button-group>
<button id="sync" title="Sync changes to server">
<i class="codicon codicon-sync"></i>
</button>
<button id="cmdList" title="Command and key mapping help">
<i class="codicon codicon-record-keys"></i>
</button>
<button type="button" popovertarget="popSettings" title="Settings">
<i class="codicon codicon-settings"></i>
</button>
<button id="fullscreen" title="Full screen editor" type="button">
<i class="codicon codicon-screen-full"></i>
</button>
<button id="bnSave" type="button" title="save view">
<i class="codicon codicon-git-stash"></i></button>
<button id="bnLoad" type="button" title="load view">
<i class="codicon codicon-git-stash-pop"></i></button>
<button id="bnWordAt" type="button" title="word at">
<i class="codicon codicon-whole-word"></i></button>
<quiet-button id="bnDebug" title="Debug " icon-label="debug" size="xs">
<quiet-icon library="codicon" name="debug"></quiet-icon>
</quiet-button>
</quiet-button-group>
</quiet-toolbar>
<!-- Editor goes in here -->
<div id="editor"></div>
</main>
<aside class="page-sidebar">
<details id="workspacePanel" open="open">
<summary class='bg-info'>WORKSPACE <i class='codicon codicon-kebab-vertical' style="float:right"></i>
</summary>
<quiet-listbox size="sm">
<quiet-listbox-item value="file:///some/file.xqm">file:///some/file.xqm</quiet-listbox-item>
<quiet-listbox-item value="2">Luna</quiet-listbox-item>
<quiet-listbox-item value="3">Meowy McGee</quiet-listbox-item>
<quiet-listbox-item value="4">Milo</quiet-listbox-item>
<quiet-listbox-item value="5">Mittens</quiet-listbox-item>
<quiet-listbox-item value="6">Oliver</quiet-listbox-item>
</quiet-listbox>
</details>
<details id="symPanel">
<summary>OUTLINE
<quiet-dropdown id="symOptions" style="display:inline-block;float:right;">
<quiet-icon id="symTrigger" name="dots-vertical" slot="trigger"></quiet-icon>
<quiet-dropdown-item type="checkbox" value="canvas" checked>Follow cursor</quiet-dropdown-item>
<quiet-divider></quiet-divider>
<quiet-dropdown-item type="checkbox" value="position" checked>sort by:
Position</quiet-dropdown-item>
<quiet-dropdown-item type="checkbox" value="name">sort by: Name</quiet-dropdown-item>
<quiet-dropdown-item type="checkbox" value="category">sort by: Category</quiet-dropdown-item>
</quiet-dropdown>
</summary>
<qd-list id="symList" style="flex-grow:1;"></qd-list>
</details>
<details id="msgPanel">
<summary>MESSAGES
<i id="msgIcon" class='codicon codicon-kebab-vertical' style="float:right"></i>
</summary>
<qd-list id="msgList" style="flex-grow:1;"></qd-list>
</details>
</aside>
<footer class="page-footer">
<div style="display:flex;">
<div>
<label for="iFile">File:</label>
<input id="iFile" type="url" value="file:///some/file.xqm"
style="width:20em;display:inline-block;" />
<label for="symbols">Symbols:</label>
<select id="symbols" disabled="disabled" style="width:10em;display:inline-block;"></select>
</div>
</div>
<quiet-relative-time live id="relative-time__live" numeric='always' format='short' style="width:10em;"></quiet-relative-time>
<select id="language" style="width:10em;display:inline-block;">
<option selected>Language</option>
<option value="plaintext">plaintext</option>
<option value="xquery">xquery</option>
<option value="xml">xml</option>
</select>
</footer>
</div>
<!-- dialogs -->
<quiet-popover id="popWeb" for="popover__url">
<div style="display:flex;background: #ffecb3;">
<div style="flex: 1 1 auto;">Load a document from the web</div>
<quiet-button icon-label="Close" appearance="text" data-popover="close">
<quiet-icon name="x"></quiet-icon>
</quiet-button>
</div>
<form id="popUrl">
<quiet-text-field type="url" name="url" label="URL to fetch" placeholder="http://..." with-clear required
style="width: 20em;">
<datalist>
<option
value="https://raw.githubusercontent.com/expkg-zone58/pdfbox/refs/heads/main/src/Pdfbox3.xqm">
Pdfbox3.xqm (expkg-zone58/pdfbox) </option>
<option
value="https://raw.githubusercontent.com/Quodatum/xqdoca/refs/heads/master/src/main/lib/model.xqm">
model.xqm (Quodatum/xqdoca)</option>
<option
value="https://git.quodatum.duckdns.org/api/v1/repos/quodatum/basex-lsp/raw/webapp/lsp/lsp-text.xqm">
lsp-text.xqm (quodatum/basex-lsp FORGEIO)</option>
<option
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xq">
generator.xquery</option>
</datalist>
</quiet-text-field>
<quiet-button type="submit" variant="primary">Fetch</quiet-button>
</form>
</quiet-popover>
<!-- Popovers -->
<dialog id="popConnect" popover>
<form>
<header>Connect to LSP
<button type="button" class="btn-close" aria-label="Close"
onclick="$('popConnect').hidePopover(); "></button>
</header>
<div class="modal-body">
<div id="state">🔴</div>
<input id="iServer" type="text" style="width:25em" />
</div>
<div class="modal-footer">
<button id="connect">connect</button>
</div>
</form>
</dialog>
<dialog id="popCmds" popover>
<form>
<header>Commands and keys
<button type="button" class="btn-close" aria-label="Close"
onclick="$('popCmds').hidePopover(); "></button>
</header>
<div id="popHelpInfo" class="modal-body" style="height: 50vh;overflow:scroll;">
</div>
<div class="modal-footer">
</div>
</form>
</dialog>
<dialog id="popAbout" popover>
<form>
<header>Help</header>
<div class="modal-body" style="height: 50vh;overflow:scroll;">
<p>TODO help info</p>
</div>
<div class="modal-footer">
</div>
</form>
</dialog>
<!-- <popup-info id="popHelp">hhhh</popup-info> -->
<dialog id="popSettings" popover>
<form id="fSettings">
<header>Editor configuration
<button type="button" class="btn-close" aria-label="Close"
onclick="$('popSettings').hidePopover(); "></button>
</header>
<div class="modal-body">
<div class="mb-3 form-check">
<input name="wrapLines" type="checkbox" class="form-check-input" id="lineWrap">
<label class="form-check-label" for="lineWrap">Wrap lines</label>
</div>
<div class="mb-3 form-check">
<input name="highlightWhitespace" type="checkbox" class="form-check-input" id="highlightWhitespace">
<label class="form-check-label" for="highlightWhitespace">highlight Whitespace</label>
</div>
<div class="mb-3 form-check">
<input name="minimap" type="checkbox" class="form-check-input" id="minimap">
<label class="form-check-label" for="minimap">Show minimap</label>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Apply</button>
</div>
</form>
</dialog>
<!-- CodeMirror 6 -->
<script src="./lsp.bundle.js"></script>
<script src="./script.js"></script>
<script src="./wc-qd-list.js"></script>
</body>
<!doctype html>
<html lang="en" class="quiet-cloak quiet-blue"
data-quiet="/static/clients/quietui@1.6.2/dist"> <!-- also quiet-dark -->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Codemirror6 example using BaseX LSP</title>
<link rel="icon" type="image/png" href="../favicon.png" />
<!-- Quiet theme + autoloader -->
<!-- Default theme (if not already installed) -->
<link rel="stylesheet" href="/static/clients/quietui@1.6.2/dist/themes/quiet.css">
<!-- Quiet Restyle -->
<link rel="stylesheet" href="/static/clients/quietui@1.6.2/dist/themes/restyle.css">
<script type="module" src="/static/clients/quietui@1.6.2/dist/quiet.loader.js"></script>
<script type="module" src="icons.js"></script>
<link rel="stylesheet" href="grail.css" />
</head>
<body>
<div class="page-wrap">
<header class="page-header">
<quiet-dropdown placement="right">
<quiet-button slot="trigger">File
<quiet-icon slot="end" name="chevron-right"></quiet-icon>
</quiet-button>
<quiet-dropdown-item id="bnNew">
<quiet-icon slot="start" name="file"></quiet-icon>New...
<div slot="details">create a new doc</div>
</quiet-dropdown-item>
<quiet-dropdown-item id="bnRead">
<quiet-icon slot="start" name="folder-open"></quiet-icon>Open...
<div slot="details">select a local file</div>
</quiet-dropdown-item>
<input type="file" id="fileElem" multiple accept="*/*" style="display: none;" />
<quiet-dropdown-item id="popover__url">
<quiet-icon slot="start" name="link"></quiet-icon>Url...
<div slot="details">Fetch from a url</div>
</quiet-dropdown-item>
</quiet-dropdown>
<div>
<span class="quiet-h4">XQuery 4.0 LSP client</span>
<quiet-toggle-icon id="tConnect" label="Connection status" size="lg"
style="--checked-color: green;--unchecked-color: red;">
<quiet-icon slot="unchecked" name="network-off" family="outline"></quiet-icon>
<quiet-icon slot="checked" name="network" family="outline"></quiet-icon>
</quiet-toggle-icon>
<quiet-tooltip id="tipConnect" for="tConnect">I'm a tooltip</quiet-tooltip>
</div>
<quiet-button-group>
<quiet-dropdown>
<quiet-button slot="trigger" with-caret>Dev tools</quiet-button>
<quiet-dropdown-item href="/app/home" target="lsp" rel="noreferrer noopener">
LSP Manager <quiet-icon name="external-link" slot="icon"></quiet-icon></quiet-dropdown-item>
<quiet-dropdown-item href="/dba/logs" target="dba" rel="noreferrer noopener">
Dba <quiet-icon name="external-link" slot="icon"></quiet-icon></quiet-dropdown-item>
<quiet-divider></quiet-divider>
</quiet-dropdown>
<button popovertarget="popAbout" type="button">
<quiet-icon name="help"></quiet-icon>
</button>
</quiet-button-group>
</header>
<main id="main" class="page-main" style="overflow: auto;">
<quiet-toolbar style="padding:2px;background-color: var(--quiet-neutral-fill-softer);">
<quiet-button-group>
<quiet-button id="search" title="Search" icon-label="search" size="xs">
<quiet-icon name="search"></quiet-icon>
</quiet-button>
<quiet-button id="lint" title="Display diagnostics" icon-label="diagnostics" size="xs">
<quiet-icon name="message-report"></quiet-icon>
</quiet-button>
<quiet-button id="symbols2" title="symbols" icon-label="Symbols" size="xs">
<quiet-icon name="icons"></quiet-icon>
</quiet-button>
<quiet-button id="format" type="button" title="Format (Shift-Alt-f)" icon-label="Format" size="xs">
<quiet-icon name="align-justified"></quiet-icon>
</quiet-button>
</quiet-button-group>
<quiet-button-group>
<button id="sync" title="Sync changes to server">
<i class="codicon codicon-sync"></i>
</button>
<button id="cmdList" title="Command and key mapping help">
<i class="codicon codicon-record-keys"></i>
</button>
<button type="button" popovertarget="popSettings" title="Settings">
<i class="codicon codicon-settings"></i>
</button>
<button id="fullscreen" title="Full screen editor" type="button">
<i class="codicon codicon-screen-full"></i>
</button>
<button id="bnSave" type="button" title="save view">
<i class="codicon codicon-git-stash"></i></button>
<button id="bnLoad" type="button" title="load view">
<i class="codicon codicon-git-stash-pop"></i></button>
<button id="bnWordAt" type="button" title="word at">
<i class="codicon codicon-whole-word"></i></button>
<quiet-button id="bnDebug" title="Debug " icon-label="debug" size="xs">
<quiet-icon library="codicon" name="debug"></quiet-icon>
</quiet-button>
</quiet-button-group>
</quiet-toolbar>
<!-- Editor goes in here -->
<div id="editor"></div>
</main>
<aside class="page-sidebar">
<details id="workspacePanel" open="open">
<summary class='bg-info'>WORKSPACE <i class='codicon codicon-kebab-vertical' style="float:right"></i>
</summary>
<quiet-listbox size="sm">
<quiet-listbox-item value="file:///some/file.xqm">file:///some/file.xqm</quiet-listbox-item>
<quiet-listbox-item value="2">Luna</quiet-listbox-item>
<quiet-listbox-item value="3">Meowy McGee</quiet-listbox-item>
<quiet-listbox-item value="4">Milo</quiet-listbox-item>
<quiet-listbox-item value="5">Mittens</quiet-listbox-item>
<quiet-listbox-item value="6">Oliver</quiet-listbox-item>
</quiet-listbox>
</details>
<details id="symPanel">
<summary>OUTLINE
<quiet-dropdown id="symOptions" style="display:inline-block;float:right;">
<quiet-icon id="symTrigger" name="dots-vertical" slot="trigger"></quiet-icon>
<quiet-dropdown-item type="checkbox" value="canvas" checked>Follow cursor</quiet-dropdown-item>
<quiet-divider></quiet-divider>
<quiet-dropdown-item type="checkbox" value="position" checked>sort by:
Position</quiet-dropdown-item>
<quiet-dropdown-item type="checkbox" value="name">sort by: Name</quiet-dropdown-item>
<quiet-dropdown-item type="checkbox" value="category">sort by: Category</quiet-dropdown-item>
</quiet-dropdown>
</summary>
<qd-list id="symList" style="flex-grow:1;"></qd-list>
</details>
<details id="msgPanel">
<summary>MESSAGES
<i id="msgIcon" class='codicon codicon-kebab-vertical' style="float:right"></i>
</summary>
<qd-list id="msgList" style="flex-grow:1;"></qd-list>
</details>
</aside>
<footer class="page-footer">
<div style="display:flex;">
<div>
<label for="iFile">File:</label>
<input id="iFile" type="url" value="file:///some/file.xqm"
style="width:20em;display:inline-block;" />
<label for="symbols">Symbols:</label>
<select id="symbols" disabled="disabled" style="width:10em;display:inline-block;"></select>
</div>
</div>
<quiet-relative-time live id="relative-time__live" numeric='always' format='short' style="width:10em;"></quiet-relative-time>
<select id="language" style="width:10em;display:inline-block;">
<option selected>Language</option>
<option value="plaintext">plaintext</option>
<option value="xquery">xquery</option>
<option value="xml">xml</option>
</select>
</footer>
</div>
<!-- dialogs -->
<quiet-popover id="popWeb" for="popover__url">
<div style="display:flex;background: #ffecb3;">
<div style="flex: 1 1 auto;">Load a document from the web</div>
<quiet-button icon-label="Close" appearance="text" data-popover="close">
<quiet-icon name="x"></quiet-icon>
</quiet-button>
</div>
<form id="popUrl">
<quiet-text-field type="url" name="url" label="URL to fetch" placeholder="http://..." with-clear required
style="width: 20em;">
<datalist>
<option
value="https://raw.githubusercontent.com/expkg-zone58/pdfbox/refs/heads/main/src/Pdfbox3.xqm">
Pdfbox3.xqm (expkg-zone58/pdfbox) </option>
<option
value="https://raw.githubusercontent.com/Quodatum/xqdoca/refs/heads/master/src/main/lib/model.xqm">
model.xqm (Quodatum/xqdoca)</option>
<option
value="https://git.quodatum.duckdns.org/api/v1/repos/quodatum/basex-lsp/raw/webapp/lsp/lsp-text.xqm">
lsp-text.xqm (quodatum/basex-lsp FORGEIO)</option>
<option
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xq">
generator.xquery</option>
</datalist>
</quiet-text-field>
<quiet-button type="submit" variant="primary">Fetch</quiet-button>
</form>
</quiet-popover>
<!-- Popovers -->
<dialog id="popConnect" popover>
<form>
<header>Connect to LSP
<button type="button" class="btn-close" aria-label="Close"
onclick="$('popConnect').hidePopover(); "></button>
</header>
<div class="modal-body">
<div id="state">🔴</div>
<input id="iServer" type="text" style="width:25em" />
</div>
<div class="modal-footer">
<button id="connect">connect</button>
</div>
</form>
</dialog>
<dialog id="popCmds" popover>
<form>
<header>Commands and keys
<button type="button" class="btn-close" aria-label="Close"
onclick="$('popCmds').hidePopover(); "></button>
</header>
<div id="popHelpInfo" class="modal-body" style="height: 50vh;overflow:scroll;">
</div>
<div class="modal-footer">
</div>
</form>
</dialog>
<dialog id="popAbout" popover>
<form>
<header>Help</header>
<div class="modal-body" style="height: 50vh;overflow:scroll;">
<p>TODO help info</p>
</div>
<div class="modal-footer">
</div>
</form>
</dialog>
<!-- <popup-info id="popHelp">hhhh</popup-info> -->
<dialog id="popSettings" popover>
<form id="fSettings">
<header>Editor configuration
<button type="button" class="btn-close" aria-label="Close"
onclick="$('popSettings').hidePopover(); "></button>
</header>
<div class="modal-body">
<div class="mb-3 form-check">
<input name="wrapLines" type="checkbox" class="form-check-input" id="lineWrap">
<label class="form-check-label" for="lineWrap">Wrap lines</label>
</div>
<div class="mb-3 form-check">
<input name="highlightWhitespace" type="checkbox" class="form-check-input" id="highlightWhitespace">
<label class="form-check-label" for="highlightWhitespace">highlight Whitespace</label>
</div>
<div class="mb-3 form-check">
<input name="minimap" type="checkbox" class="form-check-input" id="minimap">
<label class="form-check-label" for="minimap">Show minimap</label>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Apply</button>
</div>
</form>
</dialog>
<!-- CodeMirror 6 -->
<script src="./lsp.bundle.js"></script>
<script src="./script.js"></script>
<script src="./wc-qd-list.js"></script>
</body>
</html>

View file

@ -1,6 +1,6 @@
import { registerIconLibrary } from '/static/clients/quietui@1.6.2/dist/quiet.loader.js';
registerIconLibrary('codicon', {
resolve: (name, family) => {
return `/static/clients/codicon@0.0.40/icons/${name}.svg`
import { registerIconLibrary } from '/static/clients/quietui@1.6.2/dist/quiet.loader.js';
registerIconLibrary('codicon', {
resolve: (name, family) => {
return `/static/clients/codicon@0.0.40/icons/${name}.svg`
}});

View file

@ -1,196 +1,196 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Codemirror6 example using BaseX LSP</title>
<link rel="icon" type="image/png" href="../favicon.png" />
<link href="../bootstrap@5.3.7.css" rel="stylesheet" />
<link rel="stylesheet" href="grail.css" />
</head>
<body>
<div class="page-wrap">
<header class="page-header">
<nav class="navbar bg-body-tertiary">
<div class="container-fluid">
<a id="help" class="navbar-brand">XQuery 4.0 LSP client
<button id="popcon" popovertarget="popConnect" class="btn btn-danger">
<i class="codicon codicon-vm-outline"></i>
</button>
</a>
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Editor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Msgs</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/dba/logs" target="dba">Dba</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
</div>
</nav>
</header>
<nav class="page-nav">
<div class="navbar py-0 bg-light">
<div class="btn-group mr-2" role="group" aria-label="First group">
<label for="file">File:</label>
<input id="iFile" type="url" value="file:///some/file.xqm" />
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
</div>
<div class="btn-group btn-group-sm " role="group" aria-label="Second group">
<button id="search" title="Search" type="button" class="btn btn-light"><i
class="codicon codicon-search"></i></button>
<button id="lint" title="Display diagnostics" type="button" class="btn btn-light"><i
class="codicon codicon-report"></i></button>
<button id="symbols2" type="button" class="btn btn-light" title="symbols">
<i class="codicon codicon-symbol-misc"></i></button>
<button id="format" type="button" class="btn btn-light" title="Format (Shift-Alt-f)"><i
class="codicon codicon-list-flat"></i></button>
<button id="sync" title="Sync changes to server" type="button" class="btn btn-light">
<i class="codicon codicon-sync"></i>
</button>
<button id="fullscreen" title="Full screen editor" type="button" class="btn btn-light">
<i class="codicon codicon-screen-full"></i>
</button>
<button type="button" class="btn btn-light" popovertarget="popSettings" title="Settings">
<i class="codicon codicon-settings"></i></button>
</div>
<div class="btn-group" role="group" aria-label="Third group">
<button id="syntax" type="button" class="btn btn-light" title="Unused"><i
class="codicon codicon-comment"></i></button>
<button id="cmd" type="button" class="btn btn-light" title="Cmd list to console">
<i class="codicon codicon-debug-console"></i>
</button>
<button id="wordAt" type="button" class="btn btn-light" title="word at">
<i>1</i></button>
<button id="unused3" type="button" class="btn btn-light" title="unused3">
<i>3</i></button>
</div>
</div>
</nav>
<main class="page-main" style="overflow: auto;">
<!-- Editor goes in here -->
<div id="editor"></div>
</main>
<aside class="page-sidebar">
<details id="workspacePanel" open="open" >
<summary class='bg-info'>Workspace <b>0</b></summary>
<select id="load">
<option selected value="">load..</option>
<optgroup label="XQuery3">
<option
value="https://raw.githubusercontent.com/expkg-zone58/pdfbox/refs/heads/main/src/Pdfbox3.xqm">
Pdfbox3.xqm</option>
<option
value="https://raw.githubusercontent.com/Quodatum/xqdoca/refs/heads/master/src/main/lib/model.xqm">
model.xqm</option>
</optgroup>
<optgroup label="XQuery4">
<option
value="https://git.quodatum.duckdns.org/quodatum/basex-lsp/raw/branch/main/webapp/lsp/lsp-text.xqm">
lsp-text.xqm</option>
<option value="../../../lsp/lsp-text.xqm">
lsp-text.xqm</option>
</optgroup>
<optgroup label="xpath">
<option
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xq">
generator.xquery</option>
</optgroup>
</select>
<ul id="traffic" style="overflow: scroll;">
<li>-</li>
</ul>
</details>
<details id="symPanel">
<summary >OutLine <b>0</b></summary>
<json-list id="symList" ></json-list>
</details>
<details id="msgPanel" >
<summary >Messages <b>0</b></summary>
<div id="msg">(msgs)<i class='codicon codicon-symbol-method'></i></div>
</details>
</aside>
<footer class="page-footer">
Footer <select id="language">
<option selected>Language</option>
<option value="plaintext">plaintext</option>
<option value="xquery">xquery</option>
<option value="xml">xml</option>
</select>
<button popovertarget="popHelp"><i class="codicon codicon-info"></i></button>
</footer>
</div>
<!-- Popovers -->
<dialog id="popConnect" popover>
<header>Connect to LSP
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</header>
<div class="modal-body">
<div id="state">🔴</div>
<input id="iServer" type="text" style="width:25em" />
</div>
<div class="modal-footer">
<button id="connect">connect</button>
</div>
</dialog>
<!-- <popup-info id="popHelp">hhhh</popup-info> -->
<dialog id="popSettings" popover>
<form id="fSettings">
<header>Editor configuration
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
onclick="$('popSettings').hidePopover(); "></button>
</header>
<div class="modal-body">
<div class="mb-3 form-check">
<input name="wrap-lines" type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Wrap lines</label>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Apply</button>
</div>
</form>
</dialog>
<!-- CodeMirror 6 -->
<script src="./lsp.bundle.js"></script>
<script src="./script.js"></script>
<script src="./list.js"></script>
</body>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Codemirror6 example using BaseX LSP</title>
<link rel="icon" type="image/png" href="../favicon.png" />
<link href="../bootstrap@5.3.7.css" rel="stylesheet" />
<link rel="stylesheet" href="grail.css" />
</head>
<body>
<div class="page-wrap">
<header class="page-header">
<nav class="navbar bg-body-tertiary">
<div class="container-fluid">
<a id="help" class="navbar-brand">XQuery 4.0 LSP client
<button id="popcon" popovertarget="popConnect" class="btn btn-danger">
<i class="codicon codicon-vm-outline"></i>
</button>
</a>
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Editor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Msgs</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/dba/logs" target="dba">Dba</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
</div>
</nav>
</header>
<nav class="page-nav">
<div class="navbar py-0 bg-light">
<div class="btn-group mr-2" role="group" aria-label="First group">
<label for="file">File:</label>
<input id="iFile" type="url" value="file:///some/file.xqm" />
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
</div>
<div class="btn-group btn-group-sm " role="group" aria-label="Second group">
<button id="search" title="Search" type="button" class="btn btn-light"><i
class="codicon codicon-search"></i></button>
<button id="lint" title="Display diagnostics" type="button" class="btn btn-light"><i
class="codicon codicon-report"></i></button>
<button id="symbols2" type="button" class="btn btn-light" title="symbols">
<i class="codicon codicon-symbol-misc"></i></button>
<button id="format" type="button" class="btn btn-light" title="Format (Shift-Alt-f)"><i
class="codicon codicon-list-flat"></i></button>
<button id="sync" title="Sync changes to server" type="button" class="btn btn-light">
<i class="codicon codicon-sync"></i>
</button>
<button id="fullscreen" title="Full screen editor" type="button" class="btn btn-light">
<i class="codicon codicon-screen-full"></i>
</button>
<button type="button" class="btn btn-light" popovertarget="popSettings" title="Settings">
<i class="codicon codicon-settings"></i></button>
</div>
<div class="btn-group" role="group" aria-label="Third group">
<button id="syntax" type="button" class="btn btn-light" title="Unused"><i
class="codicon codicon-comment"></i></button>
<button id="cmd" type="button" class="btn btn-light" title="Cmd list to console">
<i class="codicon codicon-debug-console"></i>
</button>
<button id="wordAt" type="button" class="btn btn-light" title="word at">
<i>1</i></button>
<button id="unused3" type="button" class="btn btn-light" title="unused3">
<i>3</i></button>
</div>
</div>
</nav>
<main class="page-main" style="overflow: auto;">
<!-- Editor goes in here -->
<div id="editor"></div>
</main>
<aside class="page-sidebar">
<details id="workspacePanel" open="open" >
<summary class='bg-info'>Workspace <b>0</b></summary>
<select id="load">
<option selected value="">load..</option>
<optgroup label="XQuery3">
<option
value="https://raw.githubusercontent.com/expkg-zone58/pdfbox/refs/heads/main/src/Pdfbox3.xqm">
Pdfbox3.xqm</option>
<option
value="https://raw.githubusercontent.com/Quodatum/xqdoca/refs/heads/master/src/main/lib/model.xqm">
model.xqm</option>
</optgroup>
<optgroup label="XQuery4">
<option
value="https://git.quodatum.duckdns.org/quodatum/basex-lsp/raw/branch/main/webapp/lsp/lsp-text.xqm">
lsp-text.xqm</option>
<option value="../../../lsp/lsp-text.xqm">
lsp-text.xqm</option>
</optgroup>
<optgroup label="xpath">
<option
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xq">
generator.xquery</option>
</optgroup>
</select>
<ul id="traffic" style="overflow: scroll;">
<li>-</li>
</ul>
</details>
<details id="symPanel">
<summary >OutLine <b>0</b></summary>
<json-list id="symList" ></json-list>
</details>
<details id="msgPanel" >
<summary >Messages <b>0</b></summary>
<div id="msg">(msgs)<i class='codicon codicon-symbol-method'></i></div>
</details>
</aside>
<footer class="page-footer">
Footer <select id="language">
<option selected>Language</option>
<option value="plaintext">plaintext</option>
<option value="xquery">xquery</option>
<option value="xml">xml</option>
</select>
<button popovertarget="popHelp"><i class="codicon codicon-info"></i></button>
</footer>
</div>
<!-- Popovers -->
<dialog id="popConnect" popover>
<header>Connect to LSP
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</header>
<div class="modal-body">
<div id="state">🔴</div>
<input id="iServer" type="text" style="width:25em" />
</div>
<div class="modal-footer">
<button id="connect">connect</button>
</div>
</dialog>
<!-- <popup-info id="popHelp">hhhh</popup-info> -->
<dialog id="popSettings" popover>
<form id="fSettings">
<header>Editor configuration
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
onclick="$('popSettings').hidePopover(); "></button>
</header>
<div class="modal-body">
<div class="mb-3 form-check">
<input name="wrap-lines" type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Wrap lines</label>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Apply</button>
</div>
</form>
</dialog>
<!-- CodeMirror 6 -->
<script src="./lsp.bundle.js"></script>
<script src="./script.js"></script>
<script src="./list.js"></script>
</body>
</html>

View file

@ -31344,103 +31344,103 @@ ${text}</tr>
},
});
let create = (v) => {
const dom = document.createElement('div');
return { dom }
};
const compartment = new Compartment();
let curOpts = {
lineWrap: true,
minimap: true,
highlightWhitespace: true
};
// array of extensions reflecting opts
function optExts(opts) {
let exts = [];
if (opts.lineWrap) exts.push(EditorView.lineWrapping);
if (opts.highlightWhitespace) exts.push(highlightWhitespace());
if (opts.minimap) exts.push(
showMinimap.compute(['doc'], (state) => {
return {
create,
/* optional showOverlay: 'mouse-over' */
displayText: 'characters'
}
}));
return exts
}
function updateCompartment(opts) {
view.dispatch({
effects: [compartment.reconfigure(optExts(opts))]
});
}
// return promise with socket map or reject if no connect
function simpleWebSocketTransport(uri) {
let handlers = [];
return new Promise(function (resolve, reject) {
let sock = new WebSocket(uri);
sock.onmessage = e => { for (let h of handlers) h(e.data.toString()); };
sock.onerror = e => reject(e);
sock.onopen = () => resolve({
socket: sock,
send: (message) => sock.send(message),
subscribe: (handler) => handlers.push(handler),
unsubscribe: (handler) => handlers = handlers.filter(h => h != handler)
});
}
);
}
const baseExts = [
lineNumbers(),
highlightActiveLineGutter(),
history(),
foldGutter(),
lintGutter(),
drawSelection(),
dropCursor(),
EditorState.allowMultipleSelections.of(true),
tooltips({ }), // clipped
keymap.of([indentWithTab]),
indentOnInput(),
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
bracketMatching(),
closeBrackets(),
autocompletion(),
rectangularSelection(),
crosshairCursor(),
highlightActiveLine(),
highlightSelectionMatches(),
keymap.of([
...closeBracketsKeymap,
...defaultKeymap,
...searchKeymap,
...historyKeymap,
...foldKeymap,
...completionKeymap,
...lintKeymap
]),
StreamLanguage.define(xQuery),
compartment.of(optExts(curOpts))
];
// map cmd->{keybings,fn}
function listCommands(view) {
const commands = new Map();
const keymaps = view.state.facet(keymap);
for (let km of keymaps) {
for (let binding of km) {
if (binding.run && binding.run.name) {
commands.set(binding.run.name, { key: binding.key, fn: binding.run });
}
}
}
return commands;
let create = (v) => {
const dom = document.createElement('div');
return { dom }
};
const compartment = new Compartment();
let curOpts = {
lineWrap: true,
minimap: true,
highlightWhitespace: true
};
// array of extensions reflecting opts
function optExts(opts) {
let exts = [];
if (opts.lineWrap) exts.push(EditorView.lineWrapping);
if (opts.highlightWhitespace) exts.push(highlightWhitespace());
if (opts.minimap) exts.push(
showMinimap.compute(['doc'], (state) => {
return {
create,
/* optional showOverlay: 'mouse-over' */
displayText: 'characters'
}
}));
return exts
}
function updateCompartment(opts) {
view.dispatch({
effects: [compartment.reconfigure(optExts(opts))]
});
}
// return promise with socket map or reject if no connect
function simpleWebSocketTransport(uri) {
let handlers = [];
return new Promise(function (resolve, reject) {
let sock = new WebSocket(uri);
sock.onmessage = e => { for (let h of handlers) h(e.data.toString()); };
sock.onerror = e => reject(e);
sock.onopen = () => resolve({
socket: sock,
send: (message) => sock.send(message),
subscribe: (handler) => handlers.push(handler),
unsubscribe: (handler) => handlers = handlers.filter(h => h != handler)
});
}
);
}
const baseExts = [
lineNumbers(),
highlightActiveLineGutter(),
history(),
foldGutter(),
lintGutter(),
drawSelection(),
dropCursor(),
EditorState.allowMultipleSelections.of(true),
tooltips({ }), // clipped
keymap.of([indentWithTab]),
indentOnInput(),
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
bracketMatching(),
closeBrackets(),
autocompletion(),
rectangularSelection(),
crosshairCursor(),
highlightActiveLine(),
highlightSelectionMatches(),
keymap.of([
...closeBracketsKeymap,
...defaultKeymap,
...searchKeymap,
...historyKeymap,
...foldKeymap,
...completionKeymap,
...lintKeymap
]),
StreamLanguage.define(xQuery),
compartment.of(optExts(curOpts))
];
// map cmd->{keybings,fn}
function listCommands(view) {
const commands = new Map();
const keymaps = view.state.facet(keymap);
for (let km of keymaps) {
for (let binding of km) {
if (binding.run && binding.run.name) {
commands.set(binding.run.name, { key: binding.key, fn: binding.run });
}
}
}
return commands;
}
exports.EditorState = EditorState;

View file

@ -1,246 +1,246 @@
const view = new lsp.EditorView({
extensions: lsp.baseExts,
parent: document.getElementById("editor")
});
let doc = "xquery version '3.1';\n(:~ comment:)\nmodule namespace pdfbox='ns';\n";
var client; // https://codemirror.net/docs/ref/#lsp-client
var workspace = {
"file:///some/file.xqm": null
};
function $(id) { return document.getElementById(id) };
// Load saved content from localStorage when the page loads
window.addEventListener('load', () => {
const savedText = localStorage.getItem('code');
if (savedText) doc = savedText;
let svr = localStorage.getItem('lsp');
if (!svr) {
let x = new URL(window.location.href);
x.protocol = "ws";
x.pathname = "ws/lsp"
svr = x.href;
}
$("iServer").value = svr;
formFromStore('fSettings');
view.setState(lsp.EditorState.create({ doc: doc, extensions: lsp.baseExts }));
lsp.updateCompartment(objectFromForm('fSettings'))
connect();
});
// Save content to localStorage when the page is about to unload
window.addEventListener('beforeunload', () => {
const doc = view.state.doc.toString();
localStorage.setItem('code', doc);
localStorage.setItem('lsp', $("iServer").value);
});
$("connect").onclick = e => { e.preventDefault(); connect() };
$("symTrigger").onclick = e => { e.preventDefault(); };
$("symOptions").onclick = e => { e.preventDefault(); };
$("bnNew").onclick = e => {
let name = prompt("New file name?", "untitled.xq");
if (name === null) return;
docSwitch("", name);
};
$("search").onclick = e => lsp.openSearchPanel(view);
$("fullscreen").onclick = e => $("editor").requestFullscreen();
$("bnWordAt").onclick = e => {
let pos = view.state.selection.main.head;
let w = view.state.wordAt(pos);
alert("wordAt " + JSON.stringify(w));
};
$("symbols2").onclick = e => {
client.sync();
client.request("textDocument/documentSymbol", { "textDocument": { "uri": $("iFile").value } })
.then(r => {
console.log("symbols", r)
$("symPanel").open = true;
$("symList").setData(r);
});
};
$("cmdList").onclick = e => {
let cmds = lsp.listCommands(view);
let result = "";
[...cmds.keys()].sort().forEach(key => {
result += `<li>${key} ${cmds.get(key).key}</li>`
});
$("popHelpInfo").innerHTML = `<ul>${result}</ul>`
$("popCmds").showPopover()
};
$("symList").addEventListener("itemSelected", e => {
const plugin = lsp.LSPPlugin.get(view)
if (!plugin) return;
const sel = e.detail.range // or selectionRange;
console.log("SYM selection range", sel);
const an = plugin.fromPosition(sel.start)
const hd = plugin.fromPosition(sel.end)
view.dispatch({ selection: { anchor: an, head: hd }, scrollIntoView: true });
});
$("lint").onclick = async e => {
console.log("word", view.state.wordAt(1));
lsp.openLintPanel(view);
};
$("sync").onclick = e => { client.sync(); console.log("XXXsync"); };
// state a state
$("bnSave").onclick = e => { workspace[iFile] = view.state; };
$("bnLoad").onclick = e => { const v = workspace[iFile]; if (v) view.setState(v) };
// select local file
$("bnRead").onclick = e => { $("fileElem").click(); };
$("fileElem").onchange = e => {
let file = e.target.files[0]
let fr = new FileReader();
fr.onload = () => docSwitch(fr.result, file.name);
fr.readAsText(file);
};
$("format").onclick = e => { console.log("FMT", lsp.formatDocument(view)); };
$("popUrl").onsubmit = e => {
e.preventDefault();
const f = objectFromForm("popUrl");
fetch(f.url)
.then(response => response.text())
.then(t => {
docSwitch(t, f.url)
$("popWeb").open = false;
})
.catch(error => {
alert("CORS?: " + error)
});
};
$("bnDebug").onclick = e => { debugger; };
$("tConnect").addEventListener('quiet-change', e => {
e.preventDefault();
$("popConnect").showPopover()
});
$("msgIcon").onclick = e => {
e.preventDefault();
alert("NOT YET")
};
function updateSettings(event) {
event.preventDefault();
console.log("COPTS", lsp.curOpts);
const opts = {
lineWrap: $("lineWrap").checked,
highlightWhitespace: $("highlightWhitespace").checked,
minimap: $("minimap").checked
}
console.log(opts)
lsp.updateCompartment(opts);
$('popSettings').hidePopover();
formToStore("fSettings");
};
$("fSettings").addEventListener("submit", updateSettings);
function connect() {
const server = $("iServer").value;
const file = $("iFile").value;
lsp.simpleWebSocketTransport(server)
.then(transport => {
transport.socket.onclose = (event) => $("tConnect").checked = false;
transport.socket.oneror = (event) => $("msg").innerText = "sock error!";
transport.subscribe(incoming);
client = new lsp.LSPClient({ extensions: lsp.languageServerExtensions() });
client.connect(transport);
$("popConnect").hidePopover();
$("tConnect").checked = true;
$("tipConnect").innerText=server;
const extLsp = client.plugin(file, "xquery");
view.dispatch({
effects: lsp.StateEffect.appendConfig.of(
[lsp.linter(null, { autoPanel: true }), ...extLsp,
lsp.keymap.of([...lsp.formatKeymap])])
})
})
.catch(e => {
console.log(e);
$("tConnect").checked = false;
alert("connection failed: " + server)
});
};
// change active doc
function docSwitch(text,urlNew) {
const urlOld=$("iFile").value;
client.workspace.closeFile(urlOld);
view.dispatch({
changes: {
from: 0,
to: view.state.doc.length,
insert: text
}
})
client.workspace.openFile(urlNew,"xquery",view)
$("iFile").value = urlNew;
};
function incoming(msg) {
const rpc = JSON.parse(msg);
log(rpc);
};
function log(rpc) {
console.log("<-", rpc)
const when = (new Date()).toISOString();
const msg = { name: rpc.method ?? rpc.id, detail: when.substring(1 + when.indexOf("T")), kind: 23 /* event */ };
//name,details,kind
$("msgList").setData([msg], true)
$("relative-time__live").date=new Date();
};
function formFromStore(name) {
let v = localStorage.getItem(name)
if (!!v) formDeserialize($(name), v);
};
function formToStore(name) {
localStorage.setItem(name, formSerialize($(name)));
};
function objectFromForm(name) {
const data = new FormData($(name));
//https://stackabuse.com/convert-form-data-to-javascript-object/
return Object.fromEntries(data.entries());
}
function formSerialize(form) {
const data = new FormData(form);
//https://stackoverflow.com/a/44033425/1869660
return new URLSearchParams(data).toString();
}
function formDeserialize(form, data) {
const entries = (new URLSearchParams(data)).entries();
for (const [key, val] of entries) {
//http://javascript-coder.com/javascript-form/javascript-form-value.phtml
const input = form.elements[key];
switch (input.type) {
case 'checkbox': input.checked = !!val; break;
default: input.value = val; break;
}
}
const view = new lsp.EditorView({
extensions: lsp.baseExts,
parent: document.getElementById("editor")
});
let doc = "xquery version '3.1';\n(:~ comment:)\nmodule namespace pdfbox='ns';\n";
var client; // https://codemirror.net/docs/ref/#lsp-client
var workspace = {
"file:///some/file.xqm": null
};
function $(id) { return document.getElementById(id) };
// Load saved content from localStorage when the page loads
window.addEventListener('load', () => {
const savedText = localStorage.getItem('code');
if (savedText) doc = savedText;
let svr = localStorage.getItem('lsp');
if (!svr) {
let x = new URL(window.location.href);
x.protocol = "ws";
x.pathname = "ws/lsp"
svr = x.href;
}
$("iServer").value = svr;
formFromStore('fSettings');
view.setState(lsp.EditorState.create({ doc: doc, extensions: lsp.baseExts }));
lsp.updateCompartment(objectFromForm('fSettings'))
connect();
});
// Save content to localStorage when the page is about to unload
window.addEventListener('beforeunload', () => {
const doc = view.state.doc.toString();
localStorage.setItem('code', doc);
localStorage.setItem('lsp', $("iServer").value);
});
$("connect").onclick = e => { e.preventDefault(); connect() };
$("symTrigger").onclick = e => { e.preventDefault(); };
$("symOptions").onclick = e => { e.preventDefault(); };
$("bnNew").onclick = e => {
let name = prompt("New file name?", "untitled.xq");
if (name === null) return;
docSwitch("", name);
};
$("search").onclick = e => lsp.openSearchPanel(view);
$("fullscreen").onclick = e => $("editor").requestFullscreen();
$("bnWordAt").onclick = e => {
let pos = view.state.selection.main.head;
let w = view.state.wordAt(pos);
alert("wordAt " + JSON.stringify(w));
};
$("symbols2").onclick = e => {
client.sync();
client.request("textDocument/documentSymbol", { "textDocument": { "uri": $("iFile").value } })
.then(r => {
console.log("symbols", r)
$("symPanel").open = true;
$("symList").setData(r);
});
};
$("cmdList").onclick = e => {
let cmds = lsp.listCommands(view);
let result = "";
[...cmds.keys()].sort().forEach(key => {
result += `<li>${key} ${cmds.get(key).key}</li>`
});
$("popHelpInfo").innerHTML = `<ul>${result}</ul>`
$("popCmds").showPopover()
};
$("symList").addEventListener("itemSelected", e => {
const plugin = lsp.LSPPlugin.get(view)
if (!plugin) return;
const sel = e.detail.range // or selectionRange;
console.log("SYM selection range", sel);
const an = plugin.fromPosition(sel.start)
const hd = plugin.fromPosition(sel.end)
view.dispatch({ selection: { anchor: an, head: hd }, scrollIntoView: true });
});
$("lint").onclick = async e => {
console.log("word", view.state.wordAt(1));
lsp.openLintPanel(view);
};
$("sync").onclick = e => { client.sync(); console.log("XXXsync"); };
// state a state
$("bnSave").onclick = e => { workspace[iFile] = view.state; };
$("bnLoad").onclick = e => { const v = workspace[iFile]; if (v) view.setState(v) };
// select local file
$("bnRead").onclick = e => { $("fileElem").click(); };
$("fileElem").onchange = e => {
let file = e.target.files[0]
let fr = new FileReader();
fr.onload = () => docSwitch(fr.result, file.name);
fr.readAsText(file);
};
$("format").onclick = e => { console.log("FMT", lsp.formatDocument(view)); };
$("popUrl").onsubmit = e => {
e.preventDefault();
const f = objectFromForm("popUrl");
fetch(f.url)
.then(response => response.text())
.then(t => {
docSwitch(t, f.url)
$("popWeb").open = false;
})
.catch(error => {
alert("CORS?: " + error)
});
};
$("bnDebug").onclick = e => { debugger; };
$("tConnect").addEventListener('quiet-change', e => {
e.preventDefault();
$("popConnect").showPopover()
});
$("msgIcon").onclick = e => {
e.preventDefault();
alert("NOT YET")
};
function updateSettings(event) {
event.preventDefault();
console.log("COPTS", lsp.curOpts);
const opts = {
lineWrap: $("lineWrap").checked,
highlightWhitespace: $("highlightWhitespace").checked,
minimap: $("minimap").checked
}
console.log(opts)
lsp.updateCompartment(opts);
$('popSettings').hidePopover();
formToStore("fSettings");
};
$("fSettings").addEventListener("submit", updateSettings);
function connect() {
const server = $("iServer").value;
const file = $("iFile").value;
lsp.simpleWebSocketTransport(server)
.then(transport => {
transport.socket.onclose = (event) => $("tConnect").checked = false;
transport.socket.oneror = (event) => $("msg").innerText = "sock error!";
transport.subscribe(incoming);
client = new lsp.LSPClient({ extensions: lsp.languageServerExtensions() });
client.connect(transport);
$("popConnect").hidePopover();
$("tConnect").checked = true;
$("tipConnect").innerText=server;
const extLsp = client.plugin(file, "xquery");
view.dispatch({
effects: lsp.StateEffect.appendConfig.of(
[lsp.linter(null, { autoPanel: true }), ...extLsp,
lsp.keymap.of([...lsp.formatKeymap])])
})
})
.catch(e => {
console.log(e);
$("tConnect").checked = false;
alert("connection failed: " + server)
});
};
// change active doc
function docSwitch(text,urlNew) {
const urlOld=$("iFile").value;
client.workspace.closeFile(urlOld);
view.dispatch({
changes: {
from: 0,
to: view.state.doc.length,
insert: text
}
})
client.workspace.openFile(urlNew,"xquery",view)
$("iFile").value = urlNew;
};
function incoming(msg) {
const rpc = JSON.parse(msg);
log(rpc);
};
function log(rpc) {
console.log("<-", rpc)
const when = (new Date()).toISOString();
const msg = { name: rpc.method ?? rpc.id, detail: when.substring(1 + when.indexOf("T")), kind: 23 /* event */ };
//name,details,kind
$("msgList").setData([msg], true)
$("relative-time__live").date=new Date();
};
function formFromStore(name) {
let v = localStorage.getItem(name)
if (!!v) formDeserialize($(name), v);
};
function formToStore(name) {
localStorage.setItem(name, formSerialize($(name)));
};
function objectFromForm(name) {
const data = new FormData($(name));
//https://stackabuse.com/convert-form-data-to-javascript-object/
return Object.fromEntries(data.entries());
}
function formSerialize(form) {
const data = new FormData(form);
//https://stackoverflow.com/a/44033425/1869660
return new URLSearchParams(data).toString();
}
function formDeserialize(form, data) {
const entries = (new URLSearchParams(data)).entries();
for (const [key, val] of entries) {
//http://javascript-coder.com/javascript-form/javascript-form-value.phtml
const input = form.elements[key];
switch (input.type) {
case 'checkbox': input.checked = !!val; break;
default: input.value = val; break;
}
}
}

View file

@ -1,35 +1,35 @@
@import url("../bootstrap-icons.min.css");
html { height: 100%;}
body { min-height: 100vh; }
/* Set editor dimensions */
#editor {
height: 400px;
max-width: 100%;
overflow: hidden;
background-color: burlywood;
}
/* Stretch editor to fit inside its containing div */
.cm-editor {
height: 100%;
width: 100%;
overflow: auto;
}
/* header */
nav {
background-color: burlywood!;
}
.nav-pills > li > a
{
/* adjust padding for height*/
padding-top: 4px;
padding-bottom: 4px;
}
dialog > header
{
background-color: burlywood;
@import url("../bootstrap-icons.min.css");
html { height: 100%;}
body { min-height: 100vh; }
/* Set editor dimensions */
#editor {
height: 400px;
max-width: 100%;
overflow: hidden;
background-color: burlywood;
}
/* Stretch editor to fit inside its containing div */
.cm-editor {
height: 100%;
width: 100%;
overflow: auto;
}
/* header */
nav {
background-color: burlywood!;
}
.nav-pills > li > a
{
/* adjust padding for height*/
padding-top: 4px;
padding-bottom: 4px;
}
dialog > header
{
background-color: burlywood;
}

View file

@ -1,204 +1,204 @@
/* Define a web component providing a settable and selectable list
$("symList").setData(r, append = false);
where r is array of objects with properties name,detail,kind
https://stackoverflow.com/questions/50404970/web-components-pass-data-to-and-from
https://www.w3schools.com/howto/howto_js_treeview.asp
*/
class ListComponent extends HTMLElement {
#shadow;
#data;
#iconKinds; //array from kind integer to codicon name
constructor() {
super();
this.#shadow = this.attachShadow({ mode: "open", delegatesFocus: true });
this.#data = [];
// codicons kind
this.#iconKinds = [
'symbol-file',
'symbol-class',
'symbol-namespace',
'symbol-structure',
'symbol-class',
'symbol-method',
'symbol-property',
'symbol-field',
'symbol-method-arrow',
'symbol-enum',
'symbol-interface',
'symbol-method',
'symbol-variable',
'symbol-constant',
'symbol-string',
'symbol-numeric',
'symbol-boolean',
'symbol-array',
'symbol-structure',
'symbol-key',
'dash',
'symbol-enum-member',
'symbol-misc',
'symbol-event',
'symbol-operator',
'symbol-parameter'
];
this.render();
}
setData(newData, append = false) {
if (!Array.isArray(newData)) {
console.warn("Invalid format, expected an array.");
return;
}
this.#data = append ? this.#data.concat(newData) : structuredClone(newData);
this.render();
}
set data(value) {
this.setData(value, false);
}
get data() {
return this.#data;
}
/* Render the list items #data */
render() {
// eventhandler for click and keyboard, updates usage of selected class and raises event
const select = e => {
if(e.type ==="keyup" && !(e.key==="Enter" )) return;
this.#shadow.querySelectorAll('li.selected').forEach(item => { item.className = ''; });
e.currentTarget.className = 'selected';
const i=e.currentTarget.getAttribute("data-index")
console.log('Item index clicked:', i,this.#data[i]);
// You can dispatch a custom event here if needed.
this.dispatchEvent(new CustomEvent('itemSelected', {
detail: this.#data[i],
bubbles: true,
composed: true
}));
};
// create list and items
const list = document.createElement('ul');
list.style = "overflow: auto;";
this.#data.forEach((item, index) => {
const listItem = document.createElement('li');
const icon=this.#iconKinds[item.kind];
listItem.setAttribute("tabindex", "0")
listItem.setAttribute("data-index", index)
listItem.innerHTML = `<i class='codicon codicon-${icon}'
title='${icon}'></i>
<span >${item.name} - ${item.detail}</span>`;
listItem.addEventListener('click', select);
listItem.addEventListener('keyup', select);
list.appendChild(listItem);
});
this.#shadow.innerHTML = '';
const style = document.createElement('style');
style.textContent = `
@import url("../codicon@0.0.40/codicon.css");
ul { list-style-type: none; padding:0;margin:0;overflow: auto;
background-color: #f8f9fa;font-size: 80%;}
li { padding: 0 0 0 2px; cursor: pointer; width:100%; }
li:not(.selected) :hover { background-color: #ccc; }
.selected { background-color: #0d6efd;color: #ffff;}
i {vertical-align: middle;}
`;
this.#shadow.appendChild(style);
this.#shadow.appendChild(list);
}
/* Render an error message if JSON fetching fails */
renderError(error) {
this.#shadow.innerHTML = `<p>Error loading data: ${error.message}</p>`;
}
}
/* Define the new custom element */
customElements.define('qd-list', ListComponent);
class PanelComponent extends HTMLElement {
#shadow;
#data;
#iconKinds; //array from kind integer to codicon name
constructor() {
super();
this.#shadow = this.attachShadow({ mode: "open", delegatesFocus: true });
this.#data = [];
this.#iconKinds = [];
this.render();
}
setData(newData, append = false) {
if (!Array.isArray(newData)) {
console.warn("Invalid format, expected an array.");
return;
}
this.#data = append ? this.#data.concat(newData) : structuredClone(newData);
this.render();
}
set data(value) {
this.setData(value, false);
}
get data() {
return this.#data;
}
/* Render the list items #data */
render() {
const list = document.createElement('ul');
list.style = "overflow: auto;";
const select = e => {
if(e.type ==="keyup" && !(e.key==="Enter" )) return;
this.#shadow.querySelectorAll('li.selected').forEach(item => { item.className = ''; });
e.currentTarget.className = 'selected';
const i=e.currentTarget.getAttribute("data-index")
console.log('Item index clicked:', i,this.#data[i]);
// You can dispatch a custom event here if needed.
this.dispatchEvent(new CustomEvent('itemSelected', {
detail: this.#data[i],
bubbles: true,
composed: true
}));
};
this.#data.forEach((item, index) => {
const listItem = document.createElement('li');
const icon=this.#iconKinds[item.kind];
listItem.setAttribute("tabindex", "0")
listItem.setAttribute("data-index", index)
listItem.innerHTML = `<span title='A ${icon}'>XX<i class='codicon codicon-${icon}' >*</i></span>
<span >${item.name} - ${item.detail}</span>`;
listItem.addEventListener('click', select);
listItem.addEventListener('keyup', select);
list.appendChild(listItem);
});
this.#shadow.innerHTML = '';
const style = document.createElement('style');
style.textContent = `
@import url("../codicon@0.0.40/codicon.css");
ul { list-style-type: none; padding:0;margin:0;
background-color: #e3e4e4ff;font-size: 80%; scrollbar-color: #000077 #bada55;}
li { padding: 0 0 0 2px; border-bottom: 1px solid #ccc; cursor: pointer; width:100%; }
li:not(.selected) :hover { background-color: #ccc; }
.selected { background-color: #0d6efd;color: #ffff;}
i {vertical-align: middle;}
`;
this.#shadow.appendChild(style);
this.#shadow.appendChild(list);
}
/* Render an error message if JSON fetching fails */
renderError(error) {
this.#shadow.innerHTML = `<p>Error loading data: ${error.message}</p>`;
}
}
/* Define the new custom element */
customElements.define('qd-panel', PanelComponent);
/* Define a web component providing a settable and selectable list
$("symList").setData(r, append = false);
where r is array of objects with properties name,detail,kind
https://stackoverflow.com/questions/50404970/web-components-pass-data-to-and-from
https://www.w3schools.com/howto/howto_js_treeview.asp
*/
class ListComponent extends HTMLElement {
#shadow;
#data;
#iconKinds; //array from kind integer to codicon name
constructor() {
super();
this.#shadow = this.attachShadow({ mode: "open", delegatesFocus: true });
this.#data = [];
// codicons kind
this.#iconKinds = [
'symbol-file',
'symbol-class',
'symbol-namespace',
'symbol-structure',
'symbol-class',
'symbol-method',
'symbol-property',
'symbol-field',
'symbol-method-arrow',
'symbol-enum',
'symbol-interface',
'symbol-method',
'symbol-variable',
'symbol-constant',
'symbol-string',
'symbol-numeric',
'symbol-boolean',
'symbol-array',
'symbol-structure',
'symbol-key',
'dash',
'symbol-enum-member',
'symbol-misc',
'symbol-event',
'symbol-operator',
'symbol-parameter'
];
this.render();
}
setData(newData, append = false) {
if (!Array.isArray(newData)) {
console.warn("Invalid format, expected an array.");
return;
}
this.#data = append ? this.#data.concat(newData) : structuredClone(newData);
this.render();
}
set data(value) {
this.setData(value, false);
}
get data() {
return this.#data;
}
/* Render the list items #data */
render() {
// eventhandler for click and keyboard, updates usage of selected class and raises event
const select = e => {
if(e.type ==="keyup" && !(e.key==="Enter" )) return;
this.#shadow.querySelectorAll('li.selected').forEach(item => { item.className = ''; });
e.currentTarget.className = 'selected';
const i=e.currentTarget.getAttribute("data-index")
console.log('Item index clicked:', i,this.#data[i]);
// You can dispatch a custom event here if needed.
this.dispatchEvent(new CustomEvent('itemSelected', {
detail: this.#data[i],
bubbles: true,
composed: true
}));
};
// create list and items
const list = document.createElement('ul');
list.style = "overflow: auto;";
this.#data.forEach((item, index) => {
const listItem = document.createElement('li');
const icon=this.#iconKinds[item.kind];
listItem.setAttribute("tabindex", "0")
listItem.setAttribute("data-index", index)
listItem.innerHTML = `<i class='codicon codicon-${icon}'
title='${icon}'></i>
<span >${item.name} - ${item.detail}</span>`;
listItem.addEventListener('click', select);
listItem.addEventListener('keyup', select);
list.appendChild(listItem);
});
this.#shadow.innerHTML = '';
const style = document.createElement('style');
style.textContent = `
@import url("../codicon@0.0.40/codicon.css");
ul { list-style-type: none; padding:0;margin:0;overflow: auto;
background-color: #f8f9fa;font-size: 80%;}
li { padding: 0 0 0 2px; cursor: pointer; width:100%; }
li:not(.selected) :hover { background-color: #ccc; }
.selected { background-color: #0d6efd;color: #ffff;}
i {vertical-align: middle;}
`;
this.#shadow.appendChild(style);
this.#shadow.appendChild(list);
}
/* Render an error message if JSON fetching fails */
renderError(error) {
this.#shadow.innerHTML = `<p>Error loading data: ${error.message}</p>`;
}
}
/* Define the new custom element */
customElements.define('qd-list', ListComponent);
class PanelComponent extends HTMLElement {
#shadow;
#data;
#iconKinds; //array from kind integer to codicon name
constructor() {
super();
this.#shadow = this.attachShadow({ mode: "open", delegatesFocus: true });
this.#data = [];
this.#iconKinds = [];
this.render();
}
setData(newData, append = false) {
if (!Array.isArray(newData)) {
console.warn("Invalid format, expected an array.");
return;
}
this.#data = append ? this.#data.concat(newData) : structuredClone(newData);
this.render();
}
set data(value) {
this.setData(value, false);
}
get data() {
return this.#data;
}
/* Render the list items #data */
render() {
const list = document.createElement('ul');
list.style = "overflow: auto;";
const select = e => {
if(e.type ==="keyup" && !(e.key==="Enter" )) return;
this.#shadow.querySelectorAll('li.selected').forEach(item => { item.className = ''; });
e.currentTarget.className = 'selected';
const i=e.currentTarget.getAttribute("data-index")
console.log('Item index clicked:', i,this.#data[i]);
// You can dispatch a custom event here if needed.
this.dispatchEvent(new CustomEvent('itemSelected', {
detail: this.#data[i],
bubbles: true,
composed: true
}));
};
this.#data.forEach((item, index) => {
const listItem = document.createElement('li');
const icon=this.#iconKinds[item.kind];
listItem.setAttribute("tabindex", "0")
listItem.setAttribute("data-index", index)
listItem.innerHTML = `<span title='A ${icon}'>XX<i class='codicon codicon-${icon}' >*</i></span>
<span >${item.name} - ${item.detail}</span>`;
listItem.addEventListener('click', select);
listItem.addEventListener('keyup', select);
list.appendChild(listItem);
});
this.#shadow.innerHTML = '';
const style = document.createElement('style');
style.textContent = `
@import url("../codicon@0.0.40/codicon.css");
ul { list-style-type: none; padding:0;margin:0;
background-color: #e3e4e4ff;font-size: 80%; scrollbar-color: #000077 #bada55;}
li { padding: 0 0 0 2px; border-bottom: 1px solid #ccc; cursor: pointer; width:100%; }
li:not(.selected) :hover { background-color: #ccc; }
.selected { background-color: #0d6efd;color: #ffff;}
i {vertical-align: middle;}
`;
this.#shadow.appendChild(style);
this.#shadow.appendChild(list);
}
/* Render an error message if JSON fetching fails */
renderError(error) {
this.#shadow.innerHTML = `<p>Error loading data: ${error.message}</p>`;
}
}
/* Define the new custom element */
customElements.define('qd-panel', PanelComponent);

View file

@ -1,33 +1,33 @@
// a popover dialog NOT WORKING
class PopupInfo extends HTMLElement {
constructor() {
// Always call super first in constructor
super();
}
connectedCallback() {
// Create a shadow root
const shadow = this.attachShadow({ mode: "open" });
// Create spans
const dialog = document.createElement("dialog");
dialog.setAttribute("id", this.getAttribute("id"));
dialog.setAttribute("popover","popover");
const header = document.createElement("header");
header.innerText="HEADE"
const main = document.createElement("main");
main.innerText="MAIN"
const footer = document.createElement("footer");
footer.innerText="WWW"
dialog.appendChild(header);
dialog.appendChild(main);
dialog.appendChild(footer)
// Attach the created elements to the shadow dom
shadow.appendChild(dialog);
}
}
// Define the new element
customElements.define("popup-info", PopupInfo);
// a popover dialog NOT WORKING
class PopupInfo extends HTMLElement {
constructor() {
// Always call super first in constructor
super();
}
connectedCallback() {
// Create a shadow root
const shadow = this.attachShadow({ mode: "open" });
// Create spans
const dialog = document.createElement("dialog");
dialog.setAttribute("id", this.getAttribute("id"));
dialog.setAttribute("popover","popover");
const header = document.createElement("header");
header.innerText="HEADE"
const main = document.createElement("main");
main.innerText="MAIN"
const footer = document.createElement("footer");
footer.innerText="WWW"
dialog.appendChild(header);
dialog.appendChild(main);
dialog.appendChild(footer)
// Attach the created elements to the shadow dom
shadow.appendChild(dialog);
}
}
// Define the new element
customElements.define("popup-info", PopupInfo);

View file

@ -1,7 +1,7 @@
```html
<i class='codicon codicon-symbol-method'></i>
```
* [search codicon icons](https://microsoft.github.io/vscode-codicons/dist/codicon.html)
* https://github.com/microsoft/vscode-codicons
```html
<i class='codicon codicon-symbol-method'></i>
```
* [search codicon icons](https://microsoft.github.io/vscode-codicons/dist/codicon.html)
* https://github.com/microsoft/vscode-codicons
* https://github.com/microsoft/vscode-codicons/releases/tag/v0.0.40