@startinblox/core 2.0.0-beta.16 → 2.0.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -13,10 +13,10 @@ To start developing in `sib-core`, you need:
|
|
|
13
13
|
npm install
|
|
14
14
|
|
|
15
15
|
# 2. Build the framework
|
|
16
|
-
npm run build
|
|
16
|
+
npm run build
|
|
17
17
|
|
|
18
|
-
# 3.
|
|
19
|
-
npm run
|
|
18
|
+
# 3. Build and watch together
|
|
19
|
+
npm run dev
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
You can now see examples at [http://127.0.0.1:3000](http://127.0.0.1:3000/).
|
|
@@ -26,17 +26,23 @@ To develop new features for `sib-core`, you can add an HTML example file in `/ex
|
|
|
26
26
|
Don't forget to import the framework:
|
|
27
27
|
|
|
28
28
|
```html
|
|
29
|
-
<script type="module" src="../
|
|
29
|
+
<script type="module" src="../src/index.ts"></script>
|
|
30
30
|
```
|
|
31
31
|
You can now write HTML using `sib-core` and test it in your browser.
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
## Testing
|
|
35
|
+
|
|
35
36
|
You can test the API by running:
|
|
36
37
|
```shell
|
|
37
38
|
npm run test
|
|
38
39
|
```
|
|
39
40
|
|
|
41
|
+
Or alternatively, you can select the tests you would like to run by using the Cypress UI:
|
|
42
|
+
```shell
|
|
43
|
+
npm run cypress:open
|
|
44
|
+
```
|
|
45
|
+
|
|
40
46
|
# Mixin API
|
|
41
47
|
## How it works
|
|
42
48
|
Here is a simplified schema of how the API works to create a component:
|
|
@@ -2089,12 +2089,12 @@ export {
|
|
|
2089
2089
|
importInlineCSS as i,
|
|
2090
2090
|
importCSS as j,
|
|
2091
2091
|
helpers as k,
|
|
2092
|
-
|
|
2092
|
+
getRawContext as l,
|
|
2093
2093
|
mergeContexts as m,
|
|
2094
2094
|
normalizeContext as n,
|
|
2095
|
-
|
|
2095
|
+
isUrlOrRelativePath as o,
|
|
2096
2096
|
parseFieldsString as p,
|
|
2097
|
-
|
|
2097
|
+
jsonldContextParserExports as q,
|
|
2098
2098
|
stringToDom as r,
|
|
2099
2099
|
setDeepProperty as s,
|
|
2100
2100
|
transformArrayToContainer as t,
|
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A, h, y, c, A as A2, d, a, x, e, f, b, g,
|
|
1
|
+
import { A, h, y, c, A as A2, d, a, x, e, f, b, g, l, j, i, v, o, w, m, n, p, s, r, t, u } from "./helpers-4GFJ8HI8.js";
|
|
2
2
|
export {
|
|
3
3
|
A as AsyncIterableBuilder,
|
|
4
4
|
h as asyncQuerySelector,
|
|
@@ -12,11 +12,11 @@ export {
|
|
|
12
12
|
f as findClosingBracketMatchIndex,
|
|
13
13
|
b as fuzzyCompare,
|
|
14
14
|
g as generalComparator,
|
|
15
|
-
|
|
15
|
+
l as getRawContext,
|
|
16
16
|
j as importCSS,
|
|
17
17
|
i as importInlineCSS,
|
|
18
18
|
v as importJS,
|
|
19
|
-
|
|
19
|
+
o as isUrlOrRelativePath,
|
|
20
20
|
w as loadScript,
|
|
21
21
|
m as mergeContexts,
|
|
22
22
|
n as normalizeContext,
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
var _a2;
|
|
5
|
-
import { g as getDefaultExportFromCjs, s as store, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as commonjsGlobal } from "./store-
|
|
6
|
-
import { d as defineComponent, n as normalizeContext, u as uniqID, e as evalTemplateString, a as doesResourceContainList, c as compare, p as parseFieldsString, f as findClosingBracketMatchIndex, g as generalComparator, b as fuzzyCompare, h as asyncQuerySelector, i as importInlineCSS, j as importCSS, t as transformArrayToContainer, s as setDeepProperty } from "./helpers-
|
|
7
|
-
import { k } from "./helpers-
|
|
5
|
+
import { g as getDefaultExportFromCjs, s as store, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as commonjsGlobal } from "./store-D1e5vOG_.js";
|
|
6
|
+
import { d as defineComponent, n as normalizeContext, u as uniqID, e as evalTemplateString, a as doesResourceContainList, c as compare, p as parseFieldsString, f as findClosingBracketMatchIndex, g as generalComparator, b as fuzzyCompare, h as asyncQuerySelector, i as importInlineCSS, j as importCSS, t as transformArrayToContainer, s as setDeepProperty } from "./helpers-4GFJ8HI8.js";
|
|
7
|
+
import { k } from "./helpers-4GFJ8HI8.js";
|
|
8
8
|
if (!("flat" in Array.prototype)) {
|
|
9
9
|
Object.defineProperty(Array.prototype, "flat", {
|
|
10
10
|
configurable: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { m as mergeContexts, n as normalizeContext, l as
|
|
4
|
+
import { m as mergeContexts, n as normalizeContext, l as getRawContext, o as isUrlOrRelativePath, q as jsonldContextParserExports, a as doesResourceContainList } from "./helpers-4GFJ8HI8.js";
|
|
5
5
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
6
6
|
function getDefaultExportFromCjs(x) {
|
|
7
7
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -9029,8 +9029,15 @@ class CustomGetter {
|
|
|
9029
9029
|
getResourceData() {
|
|
9030
9030
|
return this.resource;
|
|
9031
9031
|
}
|
|
9032
|
+
/**
|
|
9033
|
+
* Get the list of resources associated with the list predicate of the resource
|
|
9034
|
+
* If the resource is a container, it will return the ldp:contains list
|
|
9035
|
+
* If the resource is a dcat:Catalog, it will return the dcat:dataset list
|
|
9036
|
+
* If the resource is not a container or a catalog, it will return null
|
|
9037
|
+
* @returns object[] | null
|
|
9038
|
+
*/
|
|
9032
9039
|
getContainerList() {
|
|
9033
|
-
if (this.
|
|
9040
|
+
if (this.hasType("ldp:Container")) {
|
|
9034
9041
|
return this.getLdpContains();
|
|
9035
9042
|
}
|
|
9036
9043
|
if (this.getType() === "dcat:Catalog") {
|
|
@@ -9039,8 +9046,8 @@ class CustomGetter {
|
|
|
9039
9046
|
return null;
|
|
9040
9047
|
}
|
|
9041
9048
|
/**
|
|
9042
|
-
* return true resource seems complete
|
|
9043
|
-
*
|
|
9049
|
+
* return true if resource seems complete
|
|
9050
|
+
* A resource is considered complete if it has at least one property which is not a permission
|
|
9044
9051
|
*/
|
|
9045
9052
|
isFullResource() {
|
|
9046
9053
|
const propertiesKeys = Object.keys(this.resource).filter(
|
|
@@ -9058,7 +9065,9 @@ class CustomGetter {
|
|
|
9058
9065
|
* @returns
|
|
9059
9066
|
*/
|
|
9060
9067
|
async getPermissions() {
|
|
9061
|
-
|
|
9068
|
+
const perms = this.getExpandedPredicate("permissions");
|
|
9069
|
+
if (!perms) return [];
|
|
9070
|
+
let permissions = this.resource[perms];
|
|
9062
9071
|
if (!permissions) {
|
|
9063
9072
|
await this.getResource(
|
|
9064
9073
|
this.resourceId,
|
|
@@ -9066,7 +9075,7 @@ class CustomGetter {
|
|
|
9066
9075
|
this.parentId,
|
|
9067
9076
|
true
|
|
9068
9077
|
);
|
|
9069
|
-
permissions = this.
|
|
9078
|
+
permissions = this.resource[perms];
|
|
9070
9079
|
}
|
|
9071
9080
|
if (!Array.isArray(permissions)) permissions = [permissions];
|
|
9072
9081
|
return permissions ? permissions : [];
|
|
@@ -9075,8 +9084,23 @@ class CustomGetter {
|
|
|
9075
9084
|
* returns compacted @type of resource
|
|
9076
9085
|
*/
|
|
9077
9086
|
getType() {
|
|
9087
|
+
if (Array.isArray(this.resource["@type"])) {
|
|
9088
|
+
return this.resource["@type"].map((type) => this.getCompactedIri(type));
|
|
9089
|
+
}
|
|
9078
9090
|
return this.resource["@type"] ? this.getCompactedIri(this.resource["@type"]) : "";
|
|
9079
9091
|
}
|
|
9092
|
+
/**
|
|
9093
|
+
* Check if the resource has a specific type
|
|
9094
|
+
* @param type
|
|
9095
|
+
*/
|
|
9096
|
+
hasType(type) {
|
|
9097
|
+
const types2 = this.getType();
|
|
9098
|
+
if (!types2) return false;
|
|
9099
|
+
if (Array.isArray(types2)) {
|
|
9100
|
+
return types2.includes(this.getCompactedIri(type));
|
|
9101
|
+
}
|
|
9102
|
+
return types2 === this.getCompactedIri(type);
|
|
9103
|
+
}
|
|
9080
9104
|
/**
|
|
9081
9105
|
* Remove the resource from the cache
|
|
9082
9106
|
*/
|
|
@@ -9120,13 +9144,13 @@ class CustomGetter {
|
|
|
9120
9144
|
case "@id":
|
|
9121
9145
|
if (this.resource["@id"])
|
|
9122
9146
|
return this.getCompactedIri(this.resource["@id"]);
|
|
9123
|
-
console.log(this.resource, this.resource["@id"]);
|
|
9124
9147
|
return;
|
|
9125
9148
|
case "@type":
|
|
9126
9149
|
return this.resource["@type"];
|
|
9127
9150
|
// return synchronously
|
|
9128
9151
|
case "properties":
|
|
9129
9152
|
return this.getProperties();
|
|
9153
|
+
case "ldp:contains":
|
|
9130
9154
|
case "listPredicate":
|
|
9131
9155
|
return this.getContainerList();
|
|
9132
9156
|
// returns standard arrays synchronously
|
|
@@ -9134,10 +9158,10 @@ class CustomGetter {
|
|
|
9134
9158
|
return this.getPermissions();
|
|
9135
9159
|
// get expanded permissions
|
|
9136
9160
|
case "clientContext":
|
|
9137
|
-
return this.clientContext;
|
|
9161
|
+
return getRawContext(this.clientContext);
|
|
9138
9162
|
// get saved client context to re-fetch easily a resource
|
|
9139
9163
|
case "serverContext":
|
|
9140
|
-
return this.serverContext;
|
|
9164
|
+
return getRawContext(this.serverContext);
|
|
9141
9165
|
// get saved client context to re-fetch easily a resource
|
|
9142
9166
|
case "then":
|
|
9143
9167
|
return;
|
package/dist/store.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startinblox/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.17",
|
|
4
4
|
"description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|