@symbo.ls/fetch 2.10.162 → 2.10.168
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/cjs/index.js +10 -4
- package/index.js +11 -3
- package/package.json +8 -8
- package/dist/esm/index.js +0 -50
package/dist/cjs/index.js
CHANGED
|
@@ -55,7 +55,7 @@ const fetchRemote = async (key, options = defaultOptions) => {
|
|
|
55
55
|
} catch (e) {
|
|
56
56
|
console.error(e);
|
|
57
57
|
}
|
|
58
|
-
return await response
|
|
58
|
+
return await response.json();
|
|
59
59
|
};
|
|
60
60
|
const fetchProject = async (key, options) => {
|
|
61
61
|
const { editor } = options;
|
|
@@ -63,9 +63,13 @@ const fetchProject = async (key, options) => {
|
|
|
63
63
|
const data = await fetchRemote(key, editor);
|
|
64
64
|
const evalData = deepDestringify(data);
|
|
65
65
|
if (editor.serviceRoute) {
|
|
66
|
-
overwriteDeep(options[editor.serviceRoute]
|
|
67
|
-
} else
|
|
68
|
-
|
|
66
|
+
overwriteDeep(evalData, options[editor.serviceRoute]);
|
|
67
|
+
} else {
|
|
68
|
+
const obj = { ...evalData, designSystem: evalData.designsystem };
|
|
69
|
+
delete obj.designsystem;
|
|
70
|
+
overwriteDeep(obj, options);
|
|
71
|
+
}
|
|
72
|
+
console.log(options);
|
|
69
73
|
}
|
|
70
74
|
return options;
|
|
71
75
|
};
|
|
@@ -74,6 +78,8 @@ const fetchStateAsync = async (key, options, callback) => {
|
|
|
74
78
|
if (editor && editor.remote) {
|
|
75
79
|
const data = await fetchRemote(key, editor);
|
|
76
80
|
const state = editor.serviceRoute === "state" ? data : data.state;
|
|
81
|
+
console.log(editor);
|
|
82
|
+
console.log(state);
|
|
77
83
|
if (isObject(state))
|
|
78
84
|
callback(state);
|
|
79
85
|
}
|
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ export const fetchRemote = async (key, options = defaultOptions) => {
|
|
|
32
32
|
console.error(e)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
return await response
|
|
35
|
+
return await response.json()
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export const fetchProject = async (key, options) => {
|
|
@@ -43,8 +43,14 @@ export const fetchProject = async (key, options) => {
|
|
|
43
43
|
const evalData = deepDestringify(data)
|
|
44
44
|
|
|
45
45
|
if (editor.serviceRoute) {
|
|
46
|
-
overwriteDeep(options[editor.serviceRoute]
|
|
47
|
-
} else
|
|
46
|
+
overwriteDeep(evalData, options[editor.serviceRoute])
|
|
47
|
+
} else {
|
|
48
|
+
const obj = { ...evalData, designSystem: evalData.designsystem }
|
|
49
|
+
delete obj.designsystem
|
|
50
|
+
overwriteDeep(obj, options)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log(options)
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
return options
|
|
@@ -56,6 +62,8 @@ export const fetchStateAsync = async (key, options, callback) => {
|
|
|
56
62
|
if (editor && editor.remote) {
|
|
57
63
|
const data = await fetchRemote(key, editor)
|
|
58
64
|
const state = editor.serviceRoute === 'state' ? data : data.state
|
|
65
|
+
console.log(editor)
|
|
66
|
+
console.log(state)
|
|
59
67
|
if (isObject(state)) callback(state)
|
|
60
68
|
}
|
|
61
69
|
}
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/fetch",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.168",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"gitHead": "
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"@domql/utils": "latest"
|
|
8
|
-
},
|
|
5
|
+
"gitHead": "c9937422aa846691fa6187c7a3975c313114617a",
|
|
9
6
|
"type": "module",
|
|
10
|
-
"module": "
|
|
11
|
-
"main": "
|
|
7
|
+
"module": "index.js",
|
|
8
|
+
"main": "index.js",
|
|
12
9
|
"exports": "./dist/cjs/index.js",
|
|
13
10
|
"source": "index.js",
|
|
14
11
|
"files": [
|
|
15
12
|
"*.js",
|
|
16
13
|
"dist"
|
|
17
14
|
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@domql/utils": "latest"
|
|
17
|
+
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"copy:package:cjs": "cp ../../.build/package-cjs.json dist/cjs/package.json",
|
|
20
20
|
"build:esm": "npx esbuild ./index.js --target=es2020 --format=esm --outdir=dist/esm",
|
|
21
21
|
"build:cjs": "npx esbuild ./index.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
22
22
|
"build:iife": "npx esbuild ./index.js --target=es2020 --format=iife --outdir=dist/iife --bundle --minify",
|
|
23
|
-
"build": "yarn build:
|
|
23
|
+
"build": "yarn build:cjs",
|
|
24
24
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/dist/esm/index.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as utils from "@domql/utils";
|
|
2
|
-
import * as globals from "@domql/globals";
|
|
3
|
-
const { overwriteDeep, deepDestringify, isObject } = utils;
|
|
4
|
-
const { window } = globals;
|
|
5
|
-
const SERVER_URL = window && window.location && window.location.host.includes("local") ? "localhost:13335" : "https://api.symbols.dev";
|
|
6
|
-
const defaultOptions = {
|
|
7
|
-
endpoint: SERVER_URL
|
|
8
|
-
};
|
|
9
|
-
const fetch = window ? window.fetch : fetch;
|
|
10
|
-
const fetchRemote = async (key, options = defaultOptions) => {
|
|
11
|
-
const baseUrl = `https://${options.endpoint || SERVER_URL}/`;
|
|
12
|
-
const route = options.serviceRoute || "";
|
|
13
|
-
let response;
|
|
14
|
-
try {
|
|
15
|
-
response = await window.fetch(baseUrl + route, {
|
|
16
|
-
method: "GET",
|
|
17
|
-
headers: { "Content-Type": "application/json", "X-AppKey": key }
|
|
18
|
-
});
|
|
19
|
-
} catch (e) {
|
|
20
|
-
console.error(e);
|
|
21
|
-
}
|
|
22
|
-
return await response ? response.json() : {};
|
|
23
|
-
};
|
|
24
|
-
const fetchProject = async (key, options) => {
|
|
25
|
-
const { editor } = options;
|
|
26
|
-
if (editor && editor.remote) {
|
|
27
|
-
const data = await fetchRemote(key, editor);
|
|
28
|
-
const evalData = deepDestringify(data);
|
|
29
|
-
if (editor.serviceRoute) {
|
|
30
|
-
overwriteDeep(options[editor.serviceRoute], evalData);
|
|
31
|
-
} else
|
|
32
|
-
overwriteDeep(options, evalData);
|
|
33
|
-
}
|
|
34
|
-
return options;
|
|
35
|
-
};
|
|
36
|
-
const fetchStateAsync = async (key, options, callback) => {
|
|
37
|
-
const { editor } = options;
|
|
38
|
-
if (editor && editor.remote) {
|
|
39
|
-
const data = await fetchRemote(key, editor);
|
|
40
|
-
const state = editor.serviceRoute === "state" ? data : data.state;
|
|
41
|
-
if (isObject(state))
|
|
42
|
-
callback(state);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
export {
|
|
46
|
-
fetch,
|
|
47
|
-
fetchProject,
|
|
48
|
-
fetchRemote,
|
|
49
|
-
fetchStateAsync
|
|
50
|
-
};
|