@matdata/yasqe 5.20.0 → 5.20.2
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/prefixes.json +3534 -0
- package/build/ts/src/autocompleters/prefixes.js +14 -9
- package/build/ts/src/autocompleters/prefixes.js.map +1 -1
- package/build/ts/src/defaults.d.ts +1 -1
- package/build/ts/src/defaults.js +1 -1
- package/build/ts/src/defaults.js.map +1 -1
- package/build/ts/src/index.d.ts +2 -2
- package/build/ts/src/prefixes.json +3525 -0
- package/build/yasqe.min.css.map +1 -1
- package/build/yasqe.min.js +84 -84
- package/build/yasqe.min.js.map +4 -4
- package/package.json +1 -1
- package/src/autocompleters/prefixes.ts +18 -9
- package/src/defaults.ts +1 -1
- package/src/index.ts +1 -1
- package/src/prefixes.json +3534 -0
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Autocompleter from "./";
|
|
2
2
|
import { sortBy } from "lodash-es";
|
|
3
|
+
import bundledPrefixes from "../prefixes.json";
|
|
3
4
|
var tokenTypes: { [id: string]: "prefixed" | "var" } = {
|
|
4
5
|
"string-2": "prefixed",
|
|
5
6
|
atom: "var",
|
|
@@ -90,21 +91,29 @@ var conf: Autocompleter.CompleterConfig = {
|
|
|
90
91
|
return true;
|
|
91
92
|
},
|
|
92
93
|
get: function (yasqe) {
|
|
93
|
-
|
|
94
|
+
const url = yasqe.config.prefixCcApi;
|
|
95
|
+
|
|
96
|
+
const buildPrefixArray = (resp: Record<string, string>): string[] => {
|
|
97
|
+
const prefixArray: string[] = [];
|
|
98
|
+
for (const prefix in resp) {
|
|
99
|
+
prefixArray.push(`${prefix}: <${resp[prefix]}>`);
|
|
100
|
+
}
|
|
101
|
+
return prefixArray.sort();
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
if (!url) {
|
|
105
|
+
// Default: use bundled prefix data (refreshed from prefix.cc at build time)
|
|
106
|
+
return Promise.resolve(buildPrefixArray(bundledPrefixes));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return fetch(url)
|
|
94
110
|
.then((response) => {
|
|
95
111
|
if (!response.ok) {
|
|
96
112
|
throw new Error("Failed to fetch prefixes");
|
|
97
113
|
}
|
|
98
114
|
return response.json();
|
|
99
115
|
})
|
|
100
|
-
.then((resp) =>
|
|
101
|
-
const prefixArray: string[] = [];
|
|
102
|
-
for (const prefix in resp) {
|
|
103
|
-
const completeString = `${prefix}: <${resp[prefix]}>`;
|
|
104
|
-
prefixArray.push(completeString); // the array we want to store in local storage
|
|
105
|
-
}
|
|
106
|
-
return prefixArray.sort();
|
|
107
|
-
});
|
|
116
|
+
.then((resp) => buildPrefixArray(resp));
|
|
108
117
|
},
|
|
109
118
|
preProcessToken: function (yasqe, token) {
|
|
110
119
|
var previousToken = yasqe.getPreviousNonWsToken(yasqe.getDoc().getCursor().line, token);
|
package/src/defaults.ts
CHANGED
|
@@ -9,7 +9,7 @@ import * as queryString from "query-string";
|
|
|
9
9
|
import CodeMirror from "codemirror";
|
|
10
10
|
//need to pass Yasqe object as argument, as the imported version might not have inherited all (e.g. `fold`) props of Codemirror yet
|
|
11
11
|
export default function get() {
|
|
12
|
-
const prefixCcApi =
|
|
12
|
+
const prefixCcApi = null; // null = use bundled prefix data (packages/yasqe/src/prefixes.json, refreshed each build)
|
|
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#>
|
package/src/index.ts
CHANGED
|
@@ -2353,7 +2353,7 @@ export interface Config extends Partial<CodeMirror.EditorConfiguration> {
|
|
|
2353
2353
|
resizeable: boolean;
|
|
2354
2354
|
editorHeight: string;
|
|
2355
2355
|
queryingDisabled: string | undefined; // The string will be the message displayed when hovered
|
|
2356
|
-
prefixCcApi: string; //
|
|
2356
|
+
prefixCcApi: string | null; // URL to fetch prefix data from; null (default) uses the bundled prefix data
|
|
2357
2357
|
showFormatButton: boolean; // Show a button to format the query
|
|
2358
2358
|
showMapButton: boolean; // Show a button to create WKT literals from map input
|
|
2359
2359
|
checkConstructVariables: boolean; // Check for undefined variables in CONSTRUCT queries
|