@matdata/yasqe 4.7.4 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ts/grammar/tokenizer.js +560 -0
- package/build/ts/grammar/tokenizer.js.map +1 -0
- package/build/ts/src/CodeMirror.d.ts +13 -4
- package/build/ts/src/CodeMirror.js +20 -0
- package/build/ts/src/CodeMirror.js.map +1 -0
- package/build/ts/src/autocompleters/classes.js +34 -0
- package/build/ts/src/autocompleters/classes.js.map +1 -0
- package/build/ts/src/autocompleters/index.d.ts +1 -0
- package/build/ts/src/autocompleters/index.js +255 -0
- package/build/ts/src/autocompleters/index.js.map +1 -0
- package/build/ts/src/autocompleters/prefixes.js +100 -0
- package/build/ts/src/autocompleters/prefixes.js.map +1 -0
- package/build/ts/src/autocompleters/properties.js +28 -0
- package/build/ts/src/autocompleters/properties.js.map +1 -0
- package/build/ts/src/autocompleters/variables.js +45 -0
- package/build/ts/src/autocompleters/variables.js.map +1 -0
- package/build/ts/src/defaults.d.ts +19 -16
- package/build/ts/src/defaults.js +125 -0
- package/build/ts/src/defaults.js.map +1 -0
- package/build/ts/src/imgs.js +8 -0
- package/build/ts/src/imgs.js.map +1 -0
- package/build/ts/src/index.d.ts +19 -15
- package/build/ts/src/index.js +775 -0
- package/build/ts/src/index.js.map +1 -0
- package/build/ts/src/prefixFold.js +85 -0
- package/build/ts/src/prefixFold.js.map +1 -0
- package/build/ts/src/prefixUtils.js +47 -0
- package/build/ts/src/prefixUtils.js.map +1 -0
- package/build/ts/src/sparql.js +182 -0
- package/build/ts/src/sparql.js.map +1 -0
- package/build/ts/src/tokenUtils.js +98 -0
- package/build/ts/src/tokenUtils.js.map +1 -0
- package/build/ts/src/tooltip.js +19 -0
- package/build/ts/src/tooltip.js.map +1 -0
- package/build/ts/src/trie.js +144 -0
- package/build/ts/src/trie.js.map +1 -0
- package/build/yasqe.min.css +2 -2
- package/build/yasqe.min.css.map +7 -1
- package/build/yasqe.min.js +69 -3
- package/build/yasqe.min.js.map +7 -1
- package/grammar/_tokenizer-table.js +4735 -4737
- package/grammar/tokenizer.ts +1 -1
- package/package.json +1 -1
- package/src/CodeMirror.ts +14 -14
- package/src/autocompleters/index.ts +4 -4
- package/src/autocompleters/show-hint.scss +1 -1
- package/src/defaults.ts +2 -2
- package/src/index.ts +2 -2
- package/build/yasqe.html +0 -108
- package/build/yasqe.min.js.LICENSE.txt +0 -3
package/grammar/tokenizer.ts
CHANGED
|
@@ -44,8 +44,8 @@ export interface Token {
|
|
|
44
44
|
string: string;
|
|
45
45
|
start: number;
|
|
46
46
|
}
|
|
47
|
+
import * as grammar from "./_tokenizer-table.js";
|
|
47
48
|
export default function (config: CodeMirror.EditorConfiguration): CodeMirror.Mode<State> {
|
|
48
|
-
const grammar = require("./_tokenizer-table.js");
|
|
49
49
|
const ll1_table = grammar.table;
|
|
50
50
|
|
|
51
51
|
const IRI_REF = '<[^<>"`|{}^\\\x00-\x20]*>';
|
package/package.json
CHANGED
package/src/CodeMirror.ts
CHANGED
|
@@ -8,24 +8,24 @@ import {
|
|
|
8
8
|
EditorConfiguration as CmEditorConfiguration,
|
|
9
9
|
} from "codemirror";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
import _CodeMirror from "codemirror";
|
|
12
12
|
|
|
13
13
|
import * as sparql11Mode from "../grammar/tokenizer";
|
|
14
14
|
import { default as prefixFold } from "./prefixFold";
|
|
15
15
|
import { TokenizerState } from "./index";
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
import "codemirror/addon/fold/foldcode.js";
|
|
18
|
+
import "codemirror/addon/fold/foldgutter.js";
|
|
19
|
+
import "codemirror/addon/fold/xml-fold.js";
|
|
20
|
+
import "codemirror/addon/fold/brace-fold.js";
|
|
21
|
+
import "codemirror/addon/hint/show-hint.js";
|
|
22
|
+
import "codemirror/addon/search/searchcursor.js";
|
|
23
|
+
import "codemirror/addon/search/match-highlighter.js";
|
|
24
|
+
import "codemirror/addon/edit/matchbrackets.js";
|
|
25
|
+
import "codemirror/addon/runmode/runmode.js";
|
|
26
|
+
import "codemirror/lib/codemirror.css";
|
|
27
|
+
import "codemirror/addon/fold/foldgutter.css";
|
|
28
|
+
import "./scss/codemirrorMods.scss";
|
|
29
29
|
|
|
30
30
|
_CodeMirror.registerHelper("fold", "prefix", prefixFold);
|
|
31
31
|
_CodeMirror.defineMode("sparql11", sparql11Mode.default);
|
|
@@ -50,5 +50,5 @@ interface CodeMirror extends Omit<CmEditor, "getOption" | "setOption" | "on" | "
|
|
|
50
50
|
|
|
51
51
|
foldCode(firstPrefixLine: number, prefix: string, collapse: "fold" | "unfold"): void;
|
|
52
52
|
}
|
|
53
|
-
const CodeMirror:
|
|
53
|
+
const CodeMirror: any = _CodeMirror;
|
|
54
54
|
export default CodeMirror;
|
|
@@ -2,8 +2,8 @@ import { default as Yasqe, Token, Hint, Position, Config, HintFn, HintConfig } f
|
|
|
2
2
|
import Trie from "../trie";
|
|
3
3
|
import { EventEmitter } from "events";
|
|
4
4
|
import { take } from "lodash-es";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import CodeMirror from "codemirror";
|
|
6
|
+
import "./show-hint.scss";
|
|
7
7
|
export interface CompleterConfig {
|
|
8
8
|
onInitialize?: (this: CompleterConfig, yasqe: Yasqe) => void; //allows for e.g. registering event listeners in yasqe, like the prefix autocompleter does
|
|
9
9
|
isValidCompletionPosition: (yasqe: Yasqe) => boolean;
|
|
@@ -81,7 +81,7 @@ export class Completer extends EventEmitter {
|
|
|
81
81
|
if (this.trie) return Promise.resolve(take(this.trie.autoComplete(stringToAutocomplete), SUGGESTIONS_LIMIT));
|
|
82
82
|
if (this.config.get instanceof Array)
|
|
83
83
|
return Promise.resolve(
|
|
84
|
-
this.config.get.filter((possibleMatch) => possibleMatch.indexOf(stringToAutocomplete) === 0)
|
|
84
|
+
this.config.get.filter((possibleMatch) => possibleMatch.indexOf(stringToAutocomplete) === 0),
|
|
85
85
|
);
|
|
86
86
|
//assuming it's a function
|
|
87
87
|
return Promise.resolve(this.config.get(this.yasqe, token)).then((r) => {
|
|
@@ -300,7 +300,7 @@ export function postprocessIriCompletion(_yasqe: Yasqe, token: AutocompletionTok
|
|
|
300
300
|
export const fetchFromLov = (
|
|
301
301
|
yasqe: Yasqe,
|
|
302
302
|
type: "class" | "property",
|
|
303
|
-
token?: AutocompletionToken
|
|
303
|
+
token?: AutocompletionToken,
|
|
304
304
|
): Promise<string[]> => {
|
|
305
305
|
var reqProtocol = window.location.protocol.indexOf("http") === 0 ? "https://" : "http://";
|
|
306
306
|
const notificationKey = "autocomplete_" + type;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//This is a copy of the codemirror show-hint css
|
|
2
|
-
//Including this ourselves, as we don't want this css to be auto-scoped to yasqe
|
|
2
|
+
//Including this ourselves, as we don't want this css to be auto-scoped to yasqe
|
|
3
3
|
.CodeMirror-hints {
|
|
4
4
|
position: absolute;
|
|
5
5
|
z-index: 10;
|
package/src/defaults.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { default as Yasqe, Config, PlainRequestConfig } from "./";
|
|
8
8
|
import * as queryString from "query-string";
|
|
9
|
+
import CodeMirror from "codemirror";
|
|
9
10
|
//need to pass Yasqe object as argument, as the imported version might not have inherited all (e.g. `fold`) props of Codemirror yet
|
|
10
11
|
export default function get() {
|
|
11
12
|
const prefixCcApi = "https://prefix.cc/popular/all.file.json";
|
|
12
|
-
const CodeMirror = require("codemirror");
|
|
13
13
|
const config: Omit<Config, "requestConfig"> = {
|
|
14
14
|
mode: "sparql11",
|
|
15
15
|
value: `PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
@@ -135,7 +135,7 @@ SELECT * WHERE {
|
|
|
135
135
|
queryArgument: undefined, //undefined means: get query argument based on query mode
|
|
136
136
|
endpoint: "https://dbpedia.org/sparql",
|
|
137
137
|
method: "POST",
|
|
138
|
-
acceptHeaderGraph: "
|
|
138
|
+
acceptHeaderGraph: "text/turtle,*/*;q=0.9",
|
|
139
139
|
acceptHeaderSelect: "application/sparql-results+json,*/*;q=0.9",
|
|
140
140
|
acceptHeaderUpdate: "text/plain,*/*;q=0.9",
|
|
141
141
|
namedGraphs: [],
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import "./scss/yasqe.scss";
|
|
2
|
+
import "./scss/buttons.scss";
|
|
3
3
|
import { findFirstPrefixLine } from "./prefixFold";
|
|
4
4
|
import { getPrefixesFromQuery, addPrefixes, removePrefixes, Prefixes } from "./prefixUtils";
|
|
5
5
|
import { getPreviousNonWsToken, getNextNonWsToken, getCompleteToken } from "./tokenUtils";
|
package/build/yasqe.html
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
<!doctype html><html><head><meta charset="UTF-8"/><style>body {
|
|
2
|
-
font-family: "Roboto", sans-serif;
|
|
3
|
-
margin: 0px;
|
|
4
|
-
}
|
|
5
|
-
.navItem a {
|
|
6
|
-
color: #555;
|
|
7
|
-
text-decoration: none;
|
|
8
|
-
padding: 5px;
|
|
9
|
-
padding-right: 15px;
|
|
10
|
-
}
|
|
11
|
-
.navItem a:hover {
|
|
12
|
-
color: #222;
|
|
13
|
-
}
|
|
14
|
-
.navItem.active a {
|
|
15
|
-
color: black;
|
|
16
|
-
font-size: 110%;
|
|
17
|
-
}</style><link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"/><style></style><script defer="defer" src="/yasqe.min.js"></script><link href="/yasqe.min.css" rel="stylesheet"></head><body><div style="background:#eee"><nav style="display: flex"><img src="webpack/yasgui.png" style="max-height:50px;padding:5px;margin-left: 10px" alt="Yasgui Logo"/><ul style="display: flex; list-style: none; align-self: center"><li class="navItem false"><a class="nav-link" href="yasgui.html">Yasgui</a></li><li class="navItem active"><a class="nav-link" href="yasqe.html">Yasqe</a></li><li class="navItem false"><a class="nav-link" href="yasr.html">Yasr</a></li></ul></nav></div><div style="display:none; background-color: grey; color:yellow" id="noExternalServicesWarning">Running yasqe without references to external services such as LOV and prefix.cc Mainly useful for test-suite purposes</div><a id="noExternalServicesToggle" style="display:none;" href="/yasqe.html?noExternalServices=1">Run yasqe without references to external services</a><div id="yasqe"></div><script>var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
|
|
18
|
-
if (isIE11) {
|
|
19
|
-
var polyfills = document.createElement("script");
|
|
20
|
-
polyfills.setAttribute("src", "//yasgui.triply.cc/yasgui.polyfill.min.js");
|
|
21
|
-
document.head.appendChild(polyfills);
|
|
22
|
-
}
|
|
23
|
-
window.onpageshow = function() {
|
|
24
|
-
const noExternalServices = document.location.search.indexOf("noExternalServices") >= 0;
|
|
25
|
-
if (noExternalServices) {
|
|
26
|
-
document.getElementById('noExternalServicesWarning').style.display = 'block'
|
|
27
|
-
//avoid references to external services such as lov and prefix.cc
|
|
28
|
-
//Useful for unit-testing purposes
|
|
29
|
-
Yasqe.defaults.autocompleters.splice(Yasqe.defaults.autocompleters.indexOf("prefixes"), 1);
|
|
30
|
-
Yasqe.forkAutocompleter("prefixes", {
|
|
31
|
-
name: "prefixes-local",
|
|
32
|
-
persistenceId: null,
|
|
33
|
-
get: () => {
|
|
34
|
-
return new Promise(resolve => {
|
|
35
|
-
setTimeout(() => {
|
|
36
|
-
resolve(
|
|
37
|
-
[
|
|
38
|
-
"foaf: <http://xmlns.com/foaf/0.1/>",
|
|
39
|
-
"geo: <http://www.opengis.net/ont/geosparql#>",
|
|
40
|
-
"rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>",
|
|
41
|
-
"rdfa: <http://www.w3.org/ns/rdfa#>",
|
|
42
|
-
"rdfdata: <http://rdf.data-vocabulary.org/rdf.xml#>",
|
|
43
|
-
"rdfdf: <http://www.openlinksw.com/virtrdf-data-formats#>",
|
|
44
|
-
"rdfg: <http://www.w3.org/2004/03/trix/rdfg-1/>",
|
|
45
|
-
"rdfp: <https://w3id.org/rdfp/>",
|
|
46
|
-
"rdfs: <http://www.w3.org/2000/01/rdf-schema#>",
|
|
47
|
-
"testa: <https://test.a.com/>",
|
|
48
|
-
"testb: <https://test.b.com/>",
|
|
49
|
-
"testc: <https://test.c.com/>"
|
|
50
|
-
],
|
|
51
|
-
20
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
Yasqe.defaults.autocompleters.splice(Yasqe.defaults.autocompleters.indexOf("property"), 1);
|
|
58
|
-
const propCompletions = [
|
|
59
|
-
"http://www.opengis.net/ont/geosparql#defaultGeometry",
|
|
60
|
-
"http://www.opengis.net/ont/geosparql#asWKT",
|
|
61
|
-
"http://www.opengis.net/ont/geosparql#asGML"
|
|
62
|
-
];
|
|
63
|
-
for (let i = 0; i < 1000; i++) {
|
|
64
|
-
propCompletions.push("https://test.a.com/" + i);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
Yasqe.forkAutocompleter("property", {
|
|
68
|
-
name: "property-local",
|
|
69
|
-
get: function(yasqe, token) {
|
|
70
|
-
console.log(
|
|
71
|
-
propCompletions,
|
|
72
|
-
propCompletions.filter(iri => token.autocompletionString.indexOf(iri) === 0)
|
|
73
|
-
);
|
|
74
|
-
return new Promise(resolve => {
|
|
75
|
-
setTimeout(() => {
|
|
76
|
-
resolve(propCompletions.filter(iri => iri.indexOf(token.autocompletionString) === 0));
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
const classCompletions = [];
|
|
82
|
-
for (let i = 0; i < 1000; i++) {
|
|
83
|
-
classCompletions.push("https://test.b.com/" + i);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
Yasqe.defaults.autocompleters.splice(Yasqe.defaults.autocompleters.indexOf("class"), 1);
|
|
87
|
-
Yasqe.forkAutocompleter("class", {
|
|
88
|
-
name: "class-local",
|
|
89
|
-
get: function(yasqe, token) {
|
|
90
|
-
return new Promise(resolve => {
|
|
91
|
-
setTimeout(() => {
|
|
92
|
-
resolve(classCompletions.filter(iri => iri.indexOf(token.autocompletionString) === 0));
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
} else {
|
|
98
|
-
document.getElementById('noExternalServicesToggle').style.display = 'block'
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
window.yasqe = new Yasqe(document.getElementById("yasqe"));
|
|
102
|
-
window.yasqe.on("queryResponse", function() {
|
|
103
|
-
console.log("response event", arguments);
|
|
104
|
-
});
|
|
105
|
-
window.yasqe.on("query", function() {
|
|
106
|
-
console.log("query event", arguments);
|
|
107
|
-
});
|
|
108
|
-
};</script></body></html>
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */
|
|
2
|
-
|
|
3
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|