@startinblox/core 0.19.0-beta.2 → 0.19.0-beta.21
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/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css → assets/MarkerCluster-614dea0a.css} +0 -0
- package/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css → assets/MarkerCluster.Default-61258232.css} +0 -0
- package/dist/assets/en-e53105c5.js +14 -0
- package/dist/assets/en-e53105c5.js.map +1 -0
- package/dist/assets/fr-a7fcdb64.js +14 -0
- package/dist/assets/fr-a7fcdb64.js.map +1 -0
- package/dist/{_snowpack/pkg/fusejs.js → assets/helpers-411e08e4.js} +499 -454
- package/dist/assets/helpers-411e08e4.js.map +1 -0
- package/dist/{_snowpack/pkg/leaflet/dist/leaflet.css → assets/leaflet-3c081932.css} +3 -3
- package/dist/helpers.js +22 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.js +54873 -48
- package/dist/index.js.map +1 -0
- package/package.json +7 -22
- package/dist/_snowpack/pkg/autolinker.js +0 -4429
- package/dist/_snowpack/pkg/autolinker.js.map +0 -1
- package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js +0 -353
- package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js.map +0 -1
- package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js +0 -26
- package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js.map +0 -1
- package/dist/_snowpack/pkg/common/decode-26fbf385.js +0 -185
- package/dist/_snowpack/pkg/common/decode-26fbf385.js.map +0 -1
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js +0 -1104
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js.map +0 -1
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js +0 -26198
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +0 -1
- package/dist/_snowpack/pkg/dialog-polyfill.js +0 -826
- package/dist/_snowpack/pkg/dialog-polyfill.js.map +0 -1
- package/dist/_snowpack/pkg/fusejs.js.map +0 -1
- package/dist/_snowpack/pkg/import-map.json +0 -25
- package/dist/_snowpack/pkg/jsonld-context-parser.js +0 -836
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map +0 -1
- package/dist/_snowpack/pkg/jsonld.js +0 -11760
- package/dist/_snowpack/pkg/jsonld.js.map +0 -1
- package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -39
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -48
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -87
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html.js +0 -94
- package/dist/_snowpack/pkg/lit-html.js.map +0 -1
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js +0 -68
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +0 -1
- package/dist/_snowpack/pkg/markdown-it.js +0 -11307
- package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
- package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -971
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
- package/dist/_snowpack/pkg/quill.js +0 -14441
- package/dist/_snowpack/pkg/quill.js.map +0 -1
- package/dist/_snowpack/pkg/slim-select.js +0 -714
- package/dist/_snowpack/pkg/slim-select.js.map +0 -1
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1149
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/tui-calendar.js +0 -46503
- package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
- package/dist/components/solid-ac-checker.js +0 -45
- package/dist/components/solid-calendar.js +0 -66
- package/dist/components/solid-delete.js +0 -96
- package/dist/components/solid-display.js +0 -150
- package/dist/components/solid-form-search.js +0 -173
- package/dist/components/solid-form.js +0 -257
- package/dist/components/solid-lang.js +0 -35
- package/dist/components/solid-map.js +0 -204
- package/dist/components/solid-table.js +0 -181
- package/dist/components/solid-widget.js +0 -72
- package/dist/import.css +0 -4
- package/dist/libs/Component.js +0 -13
- package/dist/libs/ComponentFactory.js +0 -165
- package/dist/libs/Compositor.js +0 -96
- package/dist/libs/Sib.js +0 -44
- package/dist/libs/filter.js +0 -184
- package/dist/libs/helpers.js +0 -185
- package/dist/libs/interfaces.js +0 -6
- package/dist/libs/lit-helpers.js +0 -139
- package/dist/libs/polyfills.js +0 -35
- package/dist/libs/store/custom-getter.js +0 -313
- package/dist/libs/store/server-pagination.js +0 -19
- package/dist/libs/store/server-search.js +0 -32
- package/dist/libs/store/store.js +0 -560
- package/dist/locales/en.json +0 -10
- package/dist/locales/en.json.proxy.js +0 -2
- package/dist/locales/fr.json +0 -10
- package/dist/locales/fr.json.proxy.js +0 -2
- package/dist/mixins/attributeBinderMixin.js +0 -113
- package/dist/mixins/contextMixin.js +0 -26
- package/dist/mixins/counterMixin.js +0 -54
- package/dist/mixins/federationMixin.js +0 -57
- package/dist/mixins/filterMixin.js +0 -152
- package/dist/mixins/grouperMixin.js +0 -73
- package/dist/mixins/highlighterMixin.js +0 -36
- package/dist/mixins/interfaces.js +0 -6
- package/dist/mixins/listMixin.js +0 -116
- package/dist/mixins/nextMixin.js +0 -23
- package/dist/mixins/paginateMixin.js +0 -97
- package/dist/mixins/requiredMixin.js +0 -38
- package/dist/mixins/serverPaginationMixin.js +0 -122
- package/dist/mixins/sorterMixin.js +0 -131
- package/dist/mixins/storeMixin.js +0 -139
- package/dist/mixins/translationMixin.js +0 -58
- package/dist/mixins/validationMixin.js +0 -95
- package/dist/mixins/widgetMixin.js +0 -364
- package/dist/new-widgets/attributeMixins/actionMixin.js +0 -13
- package/dist/new-widgets/attributeMixins/blankMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/index.js +0 -19
- package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -27
- package/dist/new-widgets/attributeMixins/numberMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -16
- package/dist/new-widgets/attributeMixins/telMixin.js +0 -7
- package/dist/new-widgets/baseWidgetMixin.js +0 -109
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -96
- package/dist/new-widgets/callbackMixins/index.js +0 -7
- package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -37
- package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
- package/dist/new-widgets/interfaces.js +0 -1
- package/dist/new-widgets/new-widget-factory.js +0 -91
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -26
- package/dist/new-widgets/templateAdditionMixins/index.js +0 -13
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -16
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -18
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -29
- package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -54
- package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -423
- package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -11
- package/dist/new-widgets/templates/index.js +0 -6
- package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -16
- package/dist/new-widgets/templatesDependencies/altMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -60
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -34
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -10
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -41
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -59
- package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -82
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/formMixin.js +0 -56
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -10
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -13
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -125
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
- package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -100
- package/dist/new-widgets/templatesDependencies/setMixin.js +0 -9
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -9
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -14
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -29
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -12
- package/dist/new-widgets/valueTransformationMixins/index.js +0 -15
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -30
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -13
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -21
- package/dist/solid-template-element.js +0 -144
- package/dist/style/default-theme.css.proxy.js +0 -10
- package/dist/widgets/baseWidget.js +0 -267
- package/dist/widgets/widget-factory.js +0 -20
- /package/dist/{style/default-theme.css → assets/default-theme-d0f20a8a.css} +0 -0
- /package/dist/{_snowpack/pkg/quill/dist/quill.snow.css → assets/quill.snow-8f222e44.css} +0 -0
- /package/dist/{new-widgets/callbackMixins/slimselect.css → assets/slimselect-43e3ebc8.css} +0 -0
|
@@ -1,836 +0,0 @@
|
|
|
1
|
-
import { c as createCommonjsModule, a as commonjsGlobal, b as getDefaultExportFromCjs } from './common/_commonjsHelpers-0597c316.js';
|
|
2
|
-
|
|
3
|
-
// native patch for: node-fetch, whatwg-fetch
|
|
4
|
-
// ref: https://github.com/tc39/proposal-global
|
|
5
|
-
var getGlobal = function () {
|
|
6
|
-
if (typeof self !== 'undefined') { return self; }
|
|
7
|
-
if (typeof window !== 'undefined') { return window; }
|
|
8
|
-
if (typeof global !== 'undefined') { return global; }
|
|
9
|
-
throw new Error('unable to locate global object');
|
|
10
|
-
};
|
|
11
|
-
var global = getGlobal();
|
|
12
|
-
global.fetch.bind(global);
|
|
13
|
-
const Headers = global.Headers;
|
|
14
|
-
const Request = global.Request;
|
|
15
|
-
const Response = global.Response;
|
|
16
|
-
|
|
17
|
-
// the whatwg-fetch polyfill installs the fetch() function
|
|
18
|
-
// on the global object (window or self)
|
|
19
|
-
//
|
|
20
|
-
// Return that as the export for use in Webpack, Browserify etc.
|
|
21
|
-
|
|
22
|
-
var fetchNpmBrowserify = self.fetch.bind(self);
|
|
23
|
-
|
|
24
|
-
var Resolve = createCommonjsModule(function (module, exports) {
|
|
25
|
-
|
|
26
|
-
Object.defineProperty(exports, "__esModule", {
|
|
27
|
-
value: true
|
|
28
|
-
});
|
|
29
|
-
exports.removeDotSegmentsOfPath = exports.removeDotSegments = exports.resolve = void 0;
|
|
30
|
-
/**
|
|
31
|
-
* Convert the given relative IRI to an absolute IRI
|
|
32
|
-
* by taking into account the given optional baseIRI.
|
|
33
|
-
*
|
|
34
|
-
* @param {string} relativeIRI The relative IRI to convert to an absolute IRI.
|
|
35
|
-
* @param {string} baseIRI The optional base IRI.
|
|
36
|
-
* @return {string} an absolute IRI.
|
|
37
|
-
*/
|
|
38
|
-
function resolve(relativeIRI, baseIRI) {
|
|
39
|
-
baseIRI = baseIRI || '';
|
|
40
|
-
const baseFragmentPos = baseIRI.indexOf('#');
|
|
41
|
-
// Ignore any fragments in the base IRI
|
|
42
|
-
if (baseFragmentPos > 0) {
|
|
43
|
-
baseIRI = baseIRI.substr(0, baseFragmentPos);
|
|
44
|
-
}
|
|
45
|
-
// Convert empty value directly to base IRI
|
|
46
|
-
if (!relativeIRI.length) {
|
|
47
|
-
// At this point, the baseIRI MUST be absolute, otherwise we error
|
|
48
|
-
if (baseIRI.indexOf(':') < 0) {
|
|
49
|
-
throw new Error(`Found invalid baseIRI '${baseIRI}' for value '${relativeIRI}'`);
|
|
50
|
-
}
|
|
51
|
-
return baseIRI;
|
|
52
|
-
}
|
|
53
|
-
// If the value starts with a query character, concat directly (but strip the existing query)
|
|
54
|
-
if (relativeIRI.startsWith('?')) {
|
|
55
|
-
const baseQueryPos = baseIRI.indexOf('?');
|
|
56
|
-
if (baseQueryPos > 0) {
|
|
57
|
-
baseIRI = baseIRI.substr(0, baseQueryPos);
|
|
58
|
-
}
|
|
59
|
-
return baseIRI + relativeIRI;
|
|
60
|
-
}
|
|
61
|
-
// If the value starts with a fragment character, concat directly
|
|
62
|
-
if (relativeIRI.startsWith('#')) {
|
|
63
|
-
return baseIRI + relativeIRI;
|
|
64
|
-
}
|
|
65
|
-
// Ignore baseIRI if it is empty
|
|
66
|
-
if (!baseIRI.length) {
|
|
67
|
-
const relativeColonPos = relativeIRI.indexOf(':');
|
|
68
|
-
if (relativeColonPos < 0) {
|
|
69
|
-
throw new Error(`Found invalid relative IRI '${relativeIRI}' for a missing baseIRI`);
|
|
70
|
-
}
|
|
71
|
-
return removeDotSegmentsOfPath(relativeIRI, relativeColonPos);
|
|
72
|
-
}
|
|
73
|
-
// Ignore baseIRI if the value is absolute
|
|
74
|
-
const valueColonPos = relativeIRI.indexOf(':');
|
|
75
|
-
if (valueColonPos >= 0) {
|
|
76
|
-
return removeDotSegmentsOfPath(relativeIRI, valueColonPos);
|
|
77
|
-
}
|
|
78
|
-
// At this point, the baseIRI MUST be absolute, otherwise we error
|
|
79
|
-
const baseColonPos = baseIRI.indexOf(':');
|
|
80
|
-
if (baseColonPos < 0) {
|
|
81
|
-
throw new Error(`Found invalid baseIRI '${baseIRI}' for value '${relativeIRI}'`);
|
|
82
|
-
}
|
|
83
|
-
const baseIRIScheme = baseIRI.substr(0, baseColonPos + 1);
|
|
84
|
-
// Inherit the baseIRI scheme if the value starts with '//'
|
|
85
|
-
if (relativeIRI.indexOf('//') === 0) {
|
|
86
|
-
return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
|
|
87
|
-
}
|
|
88
|
-
// Check cases where '://' occurs in the baseIRI, and where there is no '/' after a ':' anymore.
|
|
89
|
-
let baseSlashAfterColonPos;
|
|
90
|
-
if (baseIRI.indexOf('//', baseColonPos) === baseColonPos + 1) {
|
|
91
|
-
// If there is no additional '/' after the '//'.
|
|
92
|
-
baseSlashAfterColonPos = baseIRI.indexOf('/', baseColonPos + 3);
|
|
93
|
-
if (baseSlashAfterColonPos < 0) {
|
|
94
|
-
// If something other than a '/' follows the '://', append the value after a '/',
|
|
95
|
-
// otherwise, prefix the value with only the baseIRI scheme.
|
|
96
|
-
if (baseIRI.length > baseColonPos + 3) {
|
|
97
|
-
return baseIRI + '/' + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
|
|
98
|
-
} else {
|
|
99
|
-
return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
// If there is not even a single '/' after the ':'
|
|
104
|
-
baseSlashAfterColonPos = baseIRI.indexOf('/', baseColonPos + 1);
|
|
105
|
-
if (baseSlashAfterColonPos < 0) {
|
|
106
|
-
// If we don't have a '/' after the ':',
|
|
107
|
-
// prefix the value with only the baseIRI scheme.
|
|
108
|
-
return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
// If the value starts with a '/', then prefix it with everything before the first effective slash of the base IRI.
|
|
112
|
-
if (relativeIRI.indexOf('/') === 0) {
|
|
113
|
-
return baseIRI.substr(0, baseSlashAfterColonPos) + removeDotSegments(relativeIRI);
|
|
114
|
-
}
|
|
115
|
-
let baseIRIPath = baseIRI.substr(baseSlashAfterColonPos);
|
|
116
|
-
const baseIRILastSlashPos = baseIRIPath.lastIndexOf('/');
|
|
117
|
-
// Ignore everything after the last '/' in the baseIRI path
|
|
118
|
-
if (baseIRILastSlashPos >= 0 && baseIRILastSlashPos < baseIRIPath.length - 1) {
|
|
119
|
-
baseIRIPath = baseIRIPath.substr(0, baseIRILastSlashPos + 1);
|
|
120
|
-
// Also remove the first character of the relative path if it starts with '.' (and not '..' or './')
|
|
121
|
-
// This change is only allowed if there is something else following the path
|
|
122
|
-
if (relativeIRI[0] === '.' && relativeIRI[1] !== '.' && relativeIRI[1] !== '/' && relativeIRI[2]) {
|
|
123
|
-
relativeIRI = relativeIRI.substr(1);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// Prefix the value with the baseIRI path where
|
|
127
|
-
relativeIRI = baseIRIPath + relativeIRI;
|
|
128
|
-
// Remove dot segment from the IRI
|
|
129
|
-
relativeIRI = removeDotSegments(relativeIRI);
|
|
130
|
-
// Prefix our transformed value with the part of the baseIRI until the first '/' after the first ':'.
|
|
131
|
-
return baseIRI.substr(0, baseSlashAfterColonPos) + relativeIRI;
|
|
132
|
-
}
|
|
133
|
-
exports.resolve = resolve;
|
|
134
|
-
/**
|
|
135
|
-
* Remove dot segments from the given path,
|
|
136
|
-
* as described in https://www.ietf.org/rfc/rfc3986.txt (page 32).
|
|
137
|
-
* @param {string} path An IRI path.
|
|
138
|
-
* @return {string} A path, will always start with a '/'.
|
|
139
|
-
*/
|
|
140
|
-
function removeDotSegments(path) {
|
|
141
|
-
// Prepare a buffer with segments between each '/.
|
|
142
|
-
// Each segment represents an array of characters.
|
|
143
|
-
const segmentBuffers = [];
|
|
144
|
-
let i = 0;
|
|
145
|
-
while (i < path.length) {
|
|
146
|
-
// Remove '/.' or '/..'
|
|
147
|
-
switch (path[i]) {
|
|
148
|
-
case '/':
|
|
149
|
-
if (path[i + 1] === '.') {
|
|
150
|
-
if (path[i + 2] === '.') {
|
|
151
|
-
// Start a new segment if we find an invalid character after the '.'
|
|
152
|
-
if (!isCharacterAllowedAfterRelativePathSegment(path[i + 3])) {
|
|
153
|
-
segmentBuffers.push([]);
|
|
154
|
-
i++;
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
// Go to parent directory,
|
|
158
|
-
// so we remove a parent segment
|
|
159
|
-
segmentBuffers.pop();
|
|
160
|
-
// Ensure that we end with a slash if there is a trailing '/..'
|
|
161
|
-
if (!path[i + 3]) {
|
|
162
|
-
segmentBuffers.push([]);
|
|
163
|
-
}
|
|
164
|
-
i += 3;
|
|
165
|
-
} else {
|
|
166
|
-
// Start a new segment if we find an invalid character after the '.'
|
|
167
|
-
if (!isCharacterAllowedAfterRelativePathSegment(path[i + 2])) {
|
|
168
|
-
segmentBuffers.push([]);
|
|
169
|
-
i++;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
// Ensure that we end with a slash if there is a trailing '/.'
|
|
173
|
-
if (!path[i + 2]) {
|
|
174
|
-
segmentBuffers.push([]);
|
|
175
|
-
}
|
|
176
|
-
// Go to the current directory,
|
|
177
|
-
// so we do nothing
|
|
178
|
-
i += 2;
|
|
179
|
-
}
|
|
180
|
-
} else {
|
|
181
|
-
// Start a new segment
|
|
182
|
-
segmentBuffers.push([]);
|
|
183
|
-
i++;
|
|
184
|
-
}
|
|
185
|
-
break;
|
|
186
|
-
case '#':
|
|
187
|
-
case '?':
|
|
188
|
-
// Query and fragment string should be appended unchanged
|
|
189
|
-
if (!segmentBuffers.length) {
|
|
190
|
-
segmentBuffers.push([]);
|
|
191
|
-
}
|
|
192
|
-
segmentBuffers[segmentBuffers.length - 1].push(path.substr(i));
|
|
193
|
-
// Break the while loop
|
|
194
|
-
i = path.length;
|
|
195
|
-
break;
|
|
196
|
-
default:
|
|
197
|
-
// Not a special character, just append it to our buffer
|
|
198
|
-
if (!segmentBuffers.length) {
|
|
199
|
-
segmentBuffers.push([]);
|
|
200
|
-
}
|
|
201
|
-
segmentBuffers[segmentBuffers.length - 1].push(path[i]);
|
|
202
|
-
i++;
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return '/' + segmentBuffers.map(buffer => buffer.join('')).join('/');
|
|
207
|
-
}
|
|
208
|
-
exports.removeDotSegments = removeDotSegments;
|
|
209
|
-
/**
|
|
210
|
-
* Removes dot segments of the given IRI.
|
|
211
|
-
* @param {string} iri An IRI (or part of IRI).
|
|
212
|
-
* @param {number} colonPosition The position of the first ':' in the IRI.
|
|
213
|
-
* @return {string} The IRI where dot segments were removed.
|
|
214
|
-
*/
|
|
215
|
-
function removeDotSegmentsOfPath(iri, colonPosition) {
|
|
216
|
-
// Determine where we should start looking for the first '/' that indicates the start of the path
|
|
217
|
-
let searchOffset = colonPosition + 1;
|
|
218
|
-
if (colonPosition >= 0) {
|
|
219
|
-
if (iri[colonPosition + 1] === '/' && iri[colonPosition + 2] === '/') {
|
|
220
|
-
searchOffset = colonPosition + 3;
|
|
221
|
-
}
|
|
222
|
-
} else {
|
|
223
|
-
if (iri[0] === '/' && iri[1] === '/') {
|
|
224
|
-
searchOffset = 2;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
// Determine the path
|
|
228
|
-
const pathSeparator = iri.indexOf('/', searchOffset);
|
|
229
|
-
if (pathSeparator < 0) {
|
|
230
|
-
return iri;
|
|
231
|
-
}
|
|
232
|
-
const base = iri.substr(0, pathSeparator);
|
|
233
|
-
const path = iri.substr(pathSeparator);
|
|
234
|
-
// Remove dot segments from the path
|
|
235
|
-
return base + removeDotSegments(path);
|
|
236
|
-
}
|
|
237
|
-
exports.removeDotSegmentsOfPath = removeDotSegmentsOfPath;
|
|
238
|
-
function isCharacterAllowedAfterRelativePathSegment(character) {
|
|
239
|
-
return !character || character === '#' || character === '?' || character === '/';
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
var relativeToAbsoluteIri = createCommonjsModule(function (module, exports) {
|
|
244
|
-
|
|
245
|
-
var __createBinding = commonjsGlobal && commonjsGlobal.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
246
|
-
if (k2 === undefined) k2 = k;
|
|
247
|
-
Object.defineProperty(o, k2, {
|
|
248
|
-
enumerable: true,
|
|
249
|
-
get: function () {
|
|
250
|
-
return m[k];
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
} : function (o, m, k, k2) {
|
|
254
|
-
if (k2 === undefined) k2 = k;
|
|
255
|
-
o[k2] = m[k];
|
|
256
|
-
});
|
|
257
|
-
var __exportStar = commonjsGlobal && commonjsGlobal.__exportStar || function (m, exports) {
|
|
258
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
259
|
-
};
|
|
260
|
-
Object.defineProperty(exports, "__esModule", {
|
|
261
|
-
value: true
|
|
262
|
-
});
|
|
263
|
-
__exportStar(Resolve, exports);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
var FetchDocumentLoader_1 = createCommonjsModule(function (module, exports) {
|
|
267
|
-
|
|
268
|
-
var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
269
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
270
|
-
function fulfilled(value) {
|
|
271
|
-
try {
|
|
272
|
-
step(generator.next(value));
|
|
273
|
-
} catch (e) {
|
|
274
|
-
reject(e);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
function rejected(value) {
|
|
278
|
-
try {
|
|
279
|
-
step(generator["throw"](value));
|
|
280
|
-
} catch (e) {
|
|
281
|
-
reject(e);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
function step(result) {
|
|
285
|
-
result.done ? resolve(result.value) : new P(function (resolve) {
|
|
286
|
-
resolve(result.value);
|
|
287
|
-
}).then(fulfilled, rejected);
|
|
288
|
-
}
|
|
289
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
290
|
-
});
|
|
291
|
-
};
|
|
292
|
-
Object.defineProperty(exports, "__esModule", {
|
|
293
|
-
value: true
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Loads documents via the fetch API.
|
|
298
|
-
*/
|
|
299
|
-
class FetchDocumentLoader {
|
|
300
|
-
load(url) {
|
|
301
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
302
|
-
const response = yield fetch(url, {
|
|
303
|
-
headers: {
|
|
304
|
-
accept: 'application/ld+json'
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
if (response.ok) {
|
|
308
|
-
return yield response.json();
|
|
309
|
-
} else {
|
|
310
|
-
throw new Error(`No valid context was found at ${url}: ${response.statusText}`);
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
exports.FetchDocumentLoader = FetchDocumentLoader;
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
var ContextParser_1 = createCommonjsModule(function (module, exports) {
|
|
319
|
-
|
|
320
|
-
var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
321
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
322
|
-
function fulfilled(value) {
|
|
323
|
-
try {
|
|
324
|
-
step(generator.next(value));
|
|
325
|
-
} catch (e) {
|
|
326
|
-
reject(e);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
function rejected(value) {
|
|
330
|
-
try {
|
|
331
|
-
step(generator["throw"](value));
|
|
332
|
-
} catch (e) {
|
|
333
|
-
reject(e);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
function step(result) {
|
|
337
|
-
result.done ? resolve(result.value) : new P(function (resolve) {
|
|
338
|
-
resolve(result.value);
|
|
339
|
-
}).then(fulfilled, rejected);
|
|
340
|
-
}
|
|
341
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
342
|
-
});
|
|
343
|
-
};
|
|
344
|
-
Object.defineProperty(exports, "__esModule", {
|
|
345
|
-
value: true
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Parses JSON-LD contexts.
|
|
352
|
-
*/
|
|
353
|
-
class ContextParser {
|
|
354
|
-
constructor(options) {
|
|
355
|
-
options = options || {};
|
|
356
|
-
this.documentLoader = options.documentLoader || new FetchDocumentLoader_1.FetchDocumentLoader();
|
|
357
|
-
this.documentCache = {};
|
|
358
|
-
this.validate = !options.skipValidation;
|
|
359
|
-
this.expandContentTypeToBase = options.expandContentTypeToBase;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Check if the given term is a valid compact IRI.
|
|
363
|
-
* Otherwise, it may be an IRI.
|
|
364
|
-
* @param {string} term A term.
|
|
365
|
-
* @return {boolean} If it is a compact IRI.
|
|
366
|
-
*/
|
|
367
|
-
static isCompactIri(term) {
|
|
368
|
-
return term.indexOf(':') >= 0 && !(term && term[0] === '#');
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Get the prefix from the given term.
|
|
372
|
-
* @see https://json-ld.org/spec/latest/json-ld/#compact-iris
|
|
373
|
-
* @param {string} term A term that is an URL or a prefixed URL.
|
|
374
|
-
* @param {IJsonLdContextNormalized} context A context.
|
|
375
|
-
* @return {string} The prefix or null.
|
|
376
|
-
*/
|
|
377
|
-
static getPrefix(term, context) {
|
|
378
|
-
// Do not consider relative IRIs starting with a hash as compact IRIs
|
|
379
|
-
if (term && term[0] === '#') {
|
|
380
|
-
return null;
|
|
381
|
-
}
|
|
382
|
-
const separatorPos = term.indexOf(':');
|
|
383
|
-
if (separatorPos >= 0) {
|
|
384
|
-
// Suffix can not begin with two slashes
|
|
385
|
-
if (term.length > separatorPos + 1 && term.charAt(separatorPos + 1) === '/' && term.charAt(separatorPos + 2) === '/') {
|
|
386
|
-
return null;
|
|
387
|
-
}
|
|
388
|
-
const prefix = term.substr(0, separatorPos);
|
|
389
|
-
// Prefix can not be an underscore (this is a blank node)
|
|
390
|
-
if (prefix === '_') {
|
|
391
|
-
return null;
|
|
392
|
-
}
|
|
393
|
-
// Prefix must match a term in the active context
|
|
394
|
-
if (context[prefix]) {
|
|
395
|
-
return prefix;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
return null;
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* From a given context entry value, get the string value, or the @id field.
|
|
402
|
-
* @param contextValue A value for a term in a context.
|
|
403
|
-
* @return {string} The id value, or null.
|
|
404
|
-
*/
|
|
405
|
-
static getContextValueId(contextValue) {
|
|
406
|
-
if (contextValue === null || typeof contextValue === 'string') {
|
|
407
|
-
return contextValue;
|
|
408
|
-
}
|
|
409
|
-
const id = contextValue['@id'];
|
|
410
|
-
return id ? id : null;
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Expand the term or prefix of the given term if it has one,
|
|
414
|
-
* otherwise return the term as-is.
|
|
415
|
-
*
|
|
416
|
-
* This will try to expand the IRI as much as possible.
|
|
417
|
-
*
|
|
418
|
-
* Iff in vocab-mode, then other references to other terms in the context can be used,
|
|
419
|
-
* such as to `myTerm`:
|
|
420
|
-
* ```
|
|
421
|
-
* {
|
|
422
|
-
* "myTerm": "http://example.org/myLongTerm"
|
|
423
|
-
* }
|
|
424
|
-
* ```
|
|
425
|
-
*
|
|
426
|
-
* @param {string} term A term that is an URL or a prefixed URL.
|
|
427
|
-
* @param {IJsonLdContextNormalized} context A context.
|
|
428
|
-
* @param {boolean} vocab If the term is a predicate or type and should be expanded based on @vocab,
|
|
429
|
-
* otherwise it is considered a regular term that is expanded based on @base.
|
|
430
|
-
* @return {string} The expanded term, the term as-is, or null if it was explicitly disabled in the context.
|
|
431
|
-
*/
|
|
432
|
-
static expandTerm(term, context, vocab) {
|
|
433
|
-
ContextParser.assertNormalized(context);
|
|
434
|
-
const contextValue = context[term];
|
|
435
|
-
// Immediately return if the term was disabled in the context
|
|
436
|
-
if (contextValue === null || contextValue && contextValue['@id'] === null) {
|
|
437
|
-
return null;
|
|
438
|
-
}
|
|
439
|
-
// Check the @id
|
|
440
|
-
if (contextValue && vocab) {
|
|
441
|
-
const value = this.getContextValueId(contextValue);
|
|
442
|
-
if (value && value !== term) {
|
|
443
|
-
return value;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
// Check if the term is prefixed
|
|
447
|
-
const prefix = ContextParser.getPrefix(term, context);
|
|
448
|
-
if (prefix) {
|
|
449
|
-
const value = this.getContextValueId(context[prefix]);
|
|
450
|
-
if (value) {
|
|
451
|
-
return value + term.substr(prefix.length + 1);
|
|
452
|
-
}
|
|
453
|
-
} else if (vocab && context['@vocab'] && term.charAt(0) !== '@' && !ContextParser.isCompactIri(term)) {
|
|
454
|
-
return context['@vocab'] + term;
|
|
455
|
-
} else if (!vocab && context['@base'] && term.charAt(0) !== '@' && !ContextParser.isCompactIri(term)) {
|
|
456
|
-
return relativeToAbsoluteIri.resolve(term, context['@base']);
|
|
457
|
-
}
|
|
458
|
-
return term;
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Compact the given term using @base, @vocab, an aliased term, or a prefixed term.
|
|
462
|
-
*
|
|
463
|
-
* This will try to compact the IRI as much as possible.
|
|
464
|
-
*
|
|
465
|
-
* @param {string} iri An IRI to compact.
|
|
466
|
-
* @param {IJsonLdContextNormalized} context The context to compact with.
|
|
467
|
-
* @param {boolean} vocab If the term is a predicate or type and should be compacted based on @vocab,
|
|
468
|
-
* otherwise it is considered a regular term that is compacted based on @base.
|
|
469
|
-
* @return {string} The compacted term or the IRI as-is.
|
|
470
|
-
*/
|
|
471
|
-
static compactIri(iri, context, vocab) {
|
|
472
|
-
ContextParser.assertNormalized(context);
|
|
473
|
-
// Try @vocab compacting
|
|
474
|
-
if (vocab && context['@vocab'] && iri.startsWith(context['@vocab'])) {
|
|
475
|
-
return iri.substr(context['@vocab'].length);
|
|
476
|
-
}
|
|
477
|
-
// Try @base compacting
|
|
478
|
-
if (!vocab && context['@base'] && iri.startsWith(context['@base'])) {
|
|
479
|
-
return iri.substr(context['@base'].length);
|
|
480
|
-
}
|
|
481
|
-
// Loop over all terms in the context
|
|
482
|
-
// This will try to prefix as short as possible.
|
|
483
|
-
// Once a fully compacted alias is found, return immediately, as we can not go any shorter.
|
|
484
|
-
const shortestPrefixing = {
|
|
485
|
-
prefix: '',
|
|
486
|
-
suffix: iri
|
|
487
|
-
};
|
|
488
|
-
for (const key in context) {
|
|
489
|
-
const value = context[key];
|
|
490
|
-
if (value && !key.startsWith('@')) {
|
|
491
|
-
const contextIri = this.getContextValueId(value);
|
|
492
|
-
if (iri.startsWith(contextIri)) {
|
|
493
|
-
const suffix = iri.substr(contextIri.length);
|
|
494
|
-
if (!suffix) {
|
|
495
|
-
if (vocab) {
|
|
496
|
-
// Immediately return on compacted alias
|
|
497
|
-
return key;
|
|
498
|
-
}
|
|
499
|
-
} else if (suffix.length < shortestPrefixing.suffix.length) {
|
|
500
|
-
// Overwrite the shortest prefix
|
|
501
|
-
shortestPrefixing.prefix = key;
|
|
502
|
-
shortestPrefixing.suffix = suffix;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
// Return the shortest prefix
|
|
508
|
-
if (shortestPrefixing.prefix) {
|
|
509
|
-
return shortestPrefixing.prefix + ':' + shortestPrefixing.suffix;
|
|
510
|
-
}
|
|
511
|
-
return iri;
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* An an assert to check if the given context has been normalized.
|
|
515
|
-
* An error will be thrown otherwise.
|
|
516
|
-
* @param {JsonLdContext} context A context.
|
|
517
|
-
*/
|
|
518
|
-
static assertNormalized(context) {
|
|
519
|
-
if (typeof context === 'string' || Array.isArray(context) || context['@context']) {
|
|
520
|
-
throw new Error('The given context is not normalized. Make sure to call ContextParser.parse() first.');
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Check if the given context value can be a prefix value.
|
|
525
|
-
* @param value A context value.
|
|
526
|
-
* @return {boolean} If it can be a prefix value.
|
|
527
|
-
*/
|
|
528
|
-
static isPrefixValue(value) {
|
|
529
|
-
return value && (typeof value === 'string' || value['@id'] || value['@type']);
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Check if the given IRI is valid.
|
|
533
|
-
* @param {string} iri A potential IRI.
|
|
534
|
-
* @return {boolean} If the given IRI is valid.
|
|
535
|
-
*/
|
|
536
|
-
static isValidIri(iri) {
|
|
537
|
-
return ContextParser.IRI_REGEX.test(iri);
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* Add an @id term for all @reverse terms.
|
|
541
|
-
* @param {IJsonLdContextNormalized} context A context.
|
|
542
|
-
* @return {IJsonLdContextNormalized} The mutated input context.
|
|
543
|
-
*/
|
|
544
|
-
static idifyReverseTerms(context) {
|
|
545
|
-
for (const key of Object.keys(context)) {
|
|
546
|
-
const value = context[key];
|
|
547
|
-
if (value && typeof value === 'object') {
|
|
548
|
-
if (value['@reverse'] && !value['@id']) {
|
|
549
|
-
if (typeof value['@reverse'] !== 'string') {
|
|
550
|
-
throw new Error(`Invalid @reverse value: '${value['@reverse']}'`);
|
|
551
|
-
}
|
|
552
|
-
value['@id'] = value['@reverse'];
|
|
553
|
-
value['@reverse'] = true;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return context;
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Expand all prefixed terms in the given context.
|
|
561
|
-
* @param {IJsonLdContextNormalized} context A context.
|
|
562
|
-
* @param {boolean} expandContentTypeToBase If @type inside the context may be expanded
|
|
563
|
-
* via @base if @vocab is set to null.
|
|
564
|
-
* @return {IJsonLdContextNormalized} The mutated input context.
|
|
565
|
-
*/
|
|
566
|
-
static expandPrefixedTerms(context, expandContentTypeToBase) {
|
|
567
|
-
for (const key of Object.keys(context)) {
|
|
568
|
-
// Only expand allowed keys
|
|
569
|
-
if (ContextParser.EXPAND_KEYS_BLACKLIST.indexOf(key) < 0) {
|
|
570
|
-
// Error if we try to alias a keyword to something else.
|
|
571
|
-
if (key[0] === '@' && ContextParser.ALIAS_KEYS_BLACKLIST.indexOf(key) >= 0) {
|
|
572
|
-
throw new Error(`Keywords can not be aliased to something else.
|
|
573
|
-
Tried mapping ${key} to ${context[key]}`);
|
|
574
|
-
}
|
|
575
|
-
// Loop because prefixes might be nested
|
|
576
|
-
while (ContextParser.isPrefixValue(context[key])) {
|
|
577
|
-
const value = context[key];
|
|
578
|
-
let changed = false;
|
|
579
|
-
if (typeof value === 'string') {
|
|
580
|
-
context[key] = ContextParser.expandTerm(value, context, true);
|
|
581
|
-
changed = changed || value !== context[key];
|
|
582
|
-
} else {
|
|
583
|
-
const id = value['@id'];
|
|
584
|
-
const type = value['@type'];
|
|
585
|
-
if (id) {
|
|
586
|
-
context[key]['@id'] = ContextParser.expandTerm(id, context, true);
|
|
587
|
-
changed = changed || id !== context[key]['@id'];
|
|
588
|
-
}
|
|
589
|
-
if (type && type !== '@vocab') {
|
|
590
|
-
// First check @vocab, then fallback to @base
|
|
591
|
-
context[key]['@type'] = ContextParser.expandTerm(type, context, true);
|
|
592
|
-
if (expandContentTypeToBase && type === context[key]['@type']) {
|
|
593
|
-
context[key]['@type'] = ContextParser.expandTerm(type, context, false);
|
|
594
|
-
}
|
|
595
|
-
changed = changed || type !== context[key]['@type'];
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
if (!changed) {
|
|
599
|
-
break;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
return context;
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* Normalize the @language entries in the given context to lowercase.
|
|
608
|
-
* @param {IJsonLdContextNormalized} context A context.
|
|
609
|
-
* @return {IJsonLdContextNormalized} The mutated input context.
|
|
610
|
-
*/
|
|
611
|
-
static normalize(context) {
|
|
612
|
-
for (const key of Object.keys(context)) {
|
|
613
|
-
if (key === '@language' && typeof context[key] === 'string') {
|
|
614
|
-
context[key] = context[key].toLowerCase();
|
|
615
|
-
} else {
|
|
616
|
-
const value = context[key];
|
|
617
|
-
if (value && typeof value === 'object') {
|
|
618
|
-
if (typeof value['@language'] === 'string') {
|
|
619
|
-
value['@language'] = value['@language'].toLowerCase();
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
return context;
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* Validate the entries of the given context.
|
|
628
|
-
* @param {IJsonLdContextNormalized} context A context.
|
|
629
|
-
*/
|
|
630
|
-
static validate(context) {
|
|
631
|
-
for (const key of Object.keys(context)) {
|
|
632
|
-
const value = context[key];
|
|
633
|
-
const valueType = typeof value;
|
|
634
|
-
// First check if the key is a keyword
|
|
635
|
-
if (key[0] === '@') {
|
|
636
|
-
switch (key.substr(1)) {
|
|
637
|
-
case 'vocab':
|
|
638
|
-
if (value !== null && valueType !== 'string') {
|
|
639
|
-
throw new Error(`Found an invalid @vocab IRI: ${value}`);
|
|
640
|
-
}
|
|
641
|
-
break;
|
|
642
|
-
case 'base':
|
|
643
|
-
if (value !== null && valueType !== 'string') {
|
|
644
|
-
throw new Error(`Found an invalid @base IRI: ${context[key]}`);
|
|
645
|
-
}
|
|
646
|
-
break;
|
|
647
|
-
case 'language':
|
|
648
|
-
if (value !== null && valueType !== 'string') {
|
|
649
|
-
throw new Error(`Found an invalid @language string: ${value}`);
|
|
650
|
-
}
|
|
651
|
-
break;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
// Otherwise, consider the key a term
|
|
655
|
-
if (value !== null) {
|
|
656
|
-
switch (valueType) {
|
|
657
|
-
case 'string':
|
|
658
|
-
// Always valid
|
|
659
|
-
break;
|
|
660
|
-
case 'object':
|
|
661
|
-
if (!ContextParser.isCompactIri(key) && !('@id' in value) && (value['@type'] === '@id' ? !context['@base'] : !context['@vocab'])) {
|
|
662
|
-
throw new Error(`Missing @id in context entry: '${key}': '${JSON.stringify(value)}'`);
|
|
663
|
-
}
|
|
664
|
-
for (const objectKey of Object.keys(value)) {
|
|
665
|
-
const objectValue = value[objectKey];
|
|
666
|
-
if (!objectValue) {
|
|
667
|
-
continue;
|
|
668
|
-
}
|
|
669
|
-
switch (objectKey) {
|
|
670
|
-
case '@id':
|
|
671
|
-
if (objectValue[0] === '@' && objectValue !== '@type' && objectValue !== '@id') {
|
|
672
|
-
throw new Error(`Illegal keyword alias in term value, found: '${key}': '${JSON.stringify(value)}'`);
|
|
673
|
-
}
|
|
674
|
-
break;
|
|
675
|
-
case '@type':
|
|
676
|
-
if (objectValue !== '@id' && objectValue !== '@vocab' && (objectValue[0] === '_' || !ContextParser.isValidIri(objectValue))) {
|
|
677
|
-
throw new Error(`A context @type must be an absolute IRI, found: '${key}': '${objectValue}'`);
|
|
678
|
-
}
|
|
679
|
-
break;
|
|
680
|
-
case '@reverse':
|
|
681
|
-
if (typeof objectValue === 'string' && value['@id'] && value['@id'] !== objectValue) {
|
|
682
|
-
throw new Error(`Found non-matching @id and @reverse term values in '${key}':\
|
|
683
|
-
'${objectValue}' and '${value['@id']}'`);
|
|
684
|
-
}
|
|
685
|
-
break;
|
|
686
|
-
case '@container':
|
|
687
|
-
if (objectValue === '@list' && value['@reverse']) {
|
|
688
|
-
throw new Error(`Term value can not be @container: @list and @reverse at the same time on '${key}'`);
|
|
689
|
-
}
|
|
690
|
-
if (ContextParser.CONTAINERS.indexOf(objectValue) < 0) {
|
|
691
|
-
throw new Error(`Invalid term @container for '${key}' ('${objectValue}'), \
|
|
692
|
-
must be one of ${ContextParser.CONTAINERS.join(', ')}`);
|
|
693
|
-
}
|
|
694
|
-
break;
|
|
695
|
-
case '@language':
|
|
696
|
-
if (objectValue !== null && typeof objectValue !== 'string') {
|
|
697
|
-
throw new Error(`Found an invalid term @language string in: '${key}': '${JSON.stringify(value)}'`);
|
|
698
|
-
}
|
|
699
|
-
break;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
break;
|
|
703
|
-
default:
|
|
704
|
-
throw new Error(`Found an invalid term value: '${key}': '${value}'`);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* Resolve relative context IRIs, or return full IRIs as-is.
|
|
711
|
-
* @param {string} contextIri A context IRI.
|
|
712
|
-
* @param {string} baseIri A base IRI.
|
|
713
|
-
* @return {string} The normalized context IRI.
|
|
714
|
-
*/
|
|
715
|
-
static normalizeContextIri(contextIri, baseIri) {
|
|
716
|
-
if (!ContextParser.isValidIri(contextIri)) {
|
|
717
|
-
contextIri = relativeToAbsoluteIri.resolve(contextIri, baseIri);
|
|
718
|
-
if (!ContextParser.isValidIri(contextIri)) {
|
|
719
|
-
throw new Error(`Invalid context IRI: ${contextIri}`);
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
return contextIri;
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* Parse a JSON-LD context in any form.
|
|
726
|
-
* @param {JsonLdContext} context A context, URL to a context, or an array of contexts/URLs.
|
|
727
|
-
* @param {IParseOptions} options Optional parsing options.
|
|
728
|
-
* @return {Promise<IJsonLdContextNormalized>} A promise resolving to the context.
|
|
729
|
-
*/
|
|
730
|
-
parse(context, {
|
|
731
|
-
baseIri,
|
|
732
|
-
parentContext,
|
|
733
|
-
external
|
|
734
|
-
} = {}) {
|
|
735
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
736
|
-
if (context === null || context === undefined) {
|
|
737
|
-
// Context that are explicitly set to null are empty.
|
|
738
|
-
return baseIri ? {
|
|
739
|
-
'@base': baseIri
|
|
740
|
-
} : {};
|
|
741
|
-
} else if (typeof context === 'string') {
|
|
742
|
-
return this.parse(yield this.load(ContextParser.normalizeContextIri(context, baseIri)), {
|
|
743
|
-
baseIri,
|
|
744
|
-
parentContext,
|
|
745
|
-
external: true
|
|
746
|
-
});
|
|
747
|
-
} else if (Array.isArray(context)) {
|
|
748
|
-
// As a performance consideration, first load all external contexts in parallel.
|
|
749
|
-
const contexts = yield Promise.all(context.map(subContext => {
|
|
750
|
-
if (typeof subContext === 'string') {
|
|
751
|
-
return this.load(ContextParser.normalizeContextIri(subContext, baseIri));
|
|
752
|
-
} else {
|
|
753
|
-
return subContext;
|
|
754
|
-
}
|
|
755
|
-
}));
|
|
756
|
-
return contexts.reduce((accContextPromise, contextEntry) => accContextPromise.then(accContext => this.parse(contextEntry, {
|
|
757
|
-
baseIri: accContext && accContext['@base'] || baseIri,
|
|
758
|
-
external,
|
|
759
|
-
parentContext: accContext
|
|
760
|
-
})), Promise.resolve(parentContext));
|
|
761
|
-
} else if (typeof context === 'object') {
|
|
762
|
-
if (context['@context']) {
|
|
763
|
-
return yield this.parse(context['@context'], {
|
|
764
|
-
baseIri,
|
|
765
|
-
parentContext,
|
|
766
|
-
external
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
// Make a deep clone of the given context, to avoid modifying it.
|
|
770
|
-
context = JSON.parse(JSON.stringify(context)); // No better way in JS at the moment...
|
|
771
|
-
// We have an actual context object.
|
|
772
|
-
let newContext = {};
|
|
773
|
-
// According to the JSON-LD spec, @base must be ignored from external contexts.
|
|
774
|
-
if (external) {
|
|
775
|
-
delete context['@base'];
|
|
776
|
-
}
|
|
777
|
-
// Override the base IRI if provided.
|
|
778
|
-
if (baseIri) {
|
|
779
|
-
if (!('@base' in context)) {
|
|
780
|
-
// The context base is the document base
|
|
781
|
-
context['@base'] = baseIri;
|
|
782
|
-
} else if (context['@base'] !== null && !ContextParser.isValidIri(context['@base'])) {
|
|
783
|
-
// The context base is relative to the document base
|
|
784
|
-
context['@base'] = relativeToAbsoluteIri.resolve(context['@base'], baseIri);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
newContext = Object.assign({}, newContext, parentContext, context);
|
|
788
|
-
ContextParser.idifyReverseTerms(newContext);
|
|
789
|
-
ContextParser.expandPrefixedTerms(newContext, this.expandContentTypeToBase);
|
|
790
|
-
ContextParser.normalize(newContext);
|
|
791
|
-
if (this.validate) {
|
|
792
|
-
ContextParser.validate(newContext);
|
|
793
|
-
}
|
|
794
|
-
return newContext;
|
|
795
|
-
} else {
|
|
796
|
-
throw new Error(`Tried parsing a context that is not a string, array or object, but got ${context}`);
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
load(url) {
|
|
801
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
802
|
-
const cached = this.documentCache[url];
|
|
803
|
-
if (cached) {
|
|
804
|
-
return Array.isArray(cached) ? cached.slice() : Object.assign({}, cached);
|
|
805
|
-
}
|
|
806
|
-
return this.documentCache[url] = (yield this.documentLoader.load(url))['@context'];
|
|
807
|
-
});
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
// Regex for valid IRIs
|
|
811
|
-
ContextParser.IRI_REGEX = /^([A-Za-z][A-Za-z0-9+-.]*|_):[^ "<>{}|\\\[\]`]*$/;
|
|
812
|
-
// Keys in the contexts that will not be expanded based on the base IRI
|
|
813
|
-
ContextParser.EXPAND_KEYS_BLACKLIST = ['@base', '@vocab', '@language'];
|
|
814
|
-
// Keys in the contexts that may not be aliased
|
|
815
|
-
ContextParser.ALIAS_KEYS_BLACKLIST = ['@container', '@graph', '@id', '@index', '@list', '@nest', '@none', '@prefix', '@reverse', '@set', '@type', '@value'];
|
|
816
|
-
// All valid @container values
|
|
817
|
-
ContextParser.CONTAINERS = ['@list', '@set', '@index', '@language'];
|
|
818
|
-
exports.ContextParser = ContextParser;
|
|
819
|
-
});
|
|
820
|
-
|
|
821
|
-
var jsonldContextParser = createCommonjsModule(function (module, exports) {
|
|
822
|
-
|
|
823
|
-
function __export(m) {
|
|
824
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
825
|
-
}
|
|
826
|
-
Object.defineProperty(exports, "__esModule", {
|
|
827
|
-
value: true
|
|
828
|
-
});
|
|
829
|
-
__export(ContextParser_1);
|
|
830
|
-
__export(FetchDocumentLoader_1);
|
|
831
|
-
});
|
|
832
|
-
|
|
833
|
-
var __pika_web_default_export_for_treeshaking__ = /*@__PURE__*/getDefaultExportFromCjs(jsonldContextParser);
|
|
834
|
-
|
|
835
|
-
export default __pika_web_default_export_for_treeshaking__;
|
|
836
|
-
//# sourceMappingURL=jsonld-context-parser.js.map
|