@symbo.ls/fetch 2.11.36 → 2.11.39
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 +22 -12
- package/index.js +20 -9
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -30,13 +30,13 @@ var fetch_exports = {};
|
|
|
30
30
|
__export(fetch_exports, {
|
|
31
31
|
fetch: () => fetch,
|
|
32
32
|
fetchProject: () => fetchProject,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
fetchProjectAsync: () => fetchProjectAsync,
|
|
34
|
+
fetchRemote: () => fetchRemote
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(fetch_exports);
|
|
37
37
|
var utils = __toESM(require("@domql/utils"), 1);
|
|
38
38
|
var globals = __toESM(require("@domql/globals"), 1);
|
|
39
|
-
const { overwriteDeep, deepDestringify
|
|
39
|
+
const { overwriteDeep, deepDestringify } = utils;
|
|
40
40
|
const { window } = globals;
|
|
41
41
|
const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev") || window.location.host.includes("symbo.ls") : true;
|
|
42
42
|
const SERVER_URL = IS_DEVELOPMENT ? "localhost:13335" : "https://api.symbols.dev";
|
|
@@ -46,7 +46,7 @@ const defaultOptions = {
|
|
|
46
46
|
const fetch = globalThis.fetch;
|
|
47
47
|
const fetchRemote = async (key, options = defaultOptions) => {
|
|
48
48
|
const baseUrl = options.endpoint ? options.endpoint.includes("http") ? options.endpoint : `https://${options.endpoint}/` : SERVER_URL;
|
|
49
|
-
const route = options.serviceRoute ? utils.isArray(options.serviceRoute) ? options.serviceRoute.join(",") : options.serviceRoute : "";
|
|
49
|
+
const route = options.serviceRoute ? utils.isArray(options.serviceRoute) ? options.serviceRoute.map((v) => v.toLowerCase()).join(",") : options.serviceRoute : "";
|
|
50
50
|
let response;
|
|
51
51
|
try {
|
|
52
52
|
response = await fetch(baseUrl + route, {
|
|
@@ -64,22 +64,32 @@ const fetchProject = async (key, options) => {
|
|
|
64
64
|
const data = await fetchRemote(key, editor);
|
|
65
65
|
const evalData = IS_DEVELOPMENT ? deepDestringify(data) : deepDestringify(data.releases[0]);
|
|
66
66
|
if (editor.serviceRoute) {
|
|
67
|
-
|
|
67
|
+
console.log(editor.serviceRoute);
|
|
68
|
+
console.log(evalData);
|
|
69
|
+
console.log(options);
|
|
70
|
+
if (utils.isArray(editor.serviceRoute)) {
|
|
71
|
+
editor.serviceRoute.forEach((route) => {
|
|
72
|
+
overwriteDeep(options[route], evalData[route.toLowerCase()]);
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
overwriteDeep(options[editor.serviceRoute], evalData);
|
|
76
|
+
}
|
|
68
77
|
} else {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
["state", "designSystem", "components", "snippets", "pages"].forEach((key2) => {
|
|
79
|
+
overwriteDeep(options[key2], evalData[key2.toLowerCase()]);
|
|
80
|
+
});
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
83
|
return options;
|
|
75
84
|
};
|
|
76
|
-
const
|
|
85
|
+
const fetchProjectAsync = async (key, options, callback) => {
|
|
77
86
|
const { editor } = options;
|
|
78
87
|
if (editor && editor.remote) {
|
|
79
88
|
const data = await fetchRemote(key, editor);
|
|
89
|
+
console.log(IS_DEVELOPMENT, data);
|
|
90
|
+
console.log(options);
|
|
80
91
|
const evalData = IS_DEVELOPMENT ? deepDestringify(data) : deepDestringify(data.releases[0]);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
callback(state);
|
|
92
|
+
console.log(evalData);
|
|
93
|
+
callback(evalData);
|
|
84
94
|
}
|
|
85
95
|
};
|
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as utils from '@domql/utils'
|
|
4
4
|
import * as globals from '@domql/globals'
|
|
5
5
|
|
|
6
|
-
const { overwriteDeep, deepDestringify
|
|
6
|
+
const { overwriteDeep, deepDestringify } = utils
|
|
7
7
|
const { window } = globals
|
|
8
8
|
|
|
9
9
|
const IS_DEVELOPMENT = window && window.location
|
|
@@ -28,7 +28,7 @@ export const fetchRemote = async (key, options = defaultOptions) => {
|
|
|
28
28
|
: SERVER_URL
|
|
29
29
|
const route = options.serviceRoute
|
|
30
30
|
? utils.isArray(options.serviceRoute)
|
|
31
|
-
? options.serviceRoute.join(',')
|
|
31
|
+
? options.serviceRoute.map(v => v.toLowerCase()).join(',')
|
|
32
32
|
: options.serviceRoute
|
|
33
33
|
: ''
|
|
34
34
|
|
|
@@ -55,26 +55,37 @@ export const fetchProject = async (key, options) => {
|
|
|
55
55
|
: deepDestringify(data.releases[0])
|
|
56
56
|
|
|
57
57
|
if (editor.serviceRoute) {
|
|
58
|
-
|
|
58
|
+
console.log(editor.serviceRoute)
|
|
59
|
+
console.log(evalData)
|
|
60
|
+
console.log(options)
|
|
61
|
+
if (utils.isArray(editor.serviceRoute)) {
|
|
62
|
+
editor.serviceRoute.forEach(route => {
|
|
63
|
+
overwriteDeep(options[route], evalData[route.toLowerCase()])
|
|
64
|
+
})
|
|
65
|
+
} else {
|
|
66
|
+
overwriteDeep(options[editor.serviceRoute], evalData)
|
|
67
|
+
}
|
|
59
68
|
} else {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
['state', 'designSystem', 'components', 'snippets', 'pages'].forEach(key => {
|
|
70
|
+
overwriteDeep(options[key], evalData[key.toLowerCase()])
|
|
71
|
+
})
|
|
63
72
|
}
|
|
64
73
|
}
|
|
65
74
|
|
|
66
75
|
return options
|
|
67
76
|
}
|
|
68
77
|
|
|
69
|
-
export const
|
|
78
|
+
export const fetchProjectAsync = async (key, options, callback) => {
|
|
70
79
|
const { editor } = options
|
|
71
80
|
|
|
72
81
|
if (editor && editor.remote) {
|
|
73
82
|
const data = await fetchRemote(key, editor)
|
|
83
|
+
console.log(IS_DEVELOPMENT, data)
|
|
84
|
+
console.log(options)
|
|
74
85
|
const evalData = IS_DEVELOPMENT
|
|
75
86
|
? deepDestringify(data)
|
|
76
87
|
: deepDestringify(data.releases[0])
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
console.log(evalData)
|
|
89
|
+
callback(evalData)
|
|
79
90
|
}
|
|
80
91
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/fetch",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.39",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"gitHead": "
|
|
5
|
+
"gitHead": "2f40754c45ab3e9132e5335d3f01fcf7d2ac977b",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"module": "index.js",
|
|
8
8
|
"main": "index.js",
|