@symbo.ls/fetch 3.1.2 → 3.2.7

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 CHANGED
@@ -35,9 +35,9 @@ __export(index_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(index_exports);
37
37
  var utils = __toESM(require("@domql/utils"), 1);
38
- const { window, overwriteDeep, deepDestringify } = utils;
39
- const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev.") : true;
40
- const SERVER_URL = IS_DEVELOPMENT ? "http://localhost:13335/get" : "https://api.symbols.app/get";
38
+ const { window, overwriteDeep, deepDestringifyFunctions } = utils;
39
+ const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev.") : utils.isDevelopment();
40
+ const SERVER_URL = IS_DEVELOPMENT ? "http://localhost:8080/get" : "https://api.symbols.app/get";
41
41
  const defaultOptions = {
42
42
  endpoint: SERVER_URL
43
43
  };
@@ -49,7 +49,11 @@ const fetchRemote = async (key, options = defaultOptions) => {
49
49
  try {
50
50
  response = await fetch(baseUrl + "/?" + route, {
51
51
  method: "GET",
52
- headers: { "Content-Type": "application/json", "X-AppKey": key, "X-Metadata": options.metadata }
52
+ headers: {
53
+ "Content-Type": "application/json",
54
+ "X-AppKey": key,
55
+ "X-Metadata": options.metadata
56
+ }
53
57
  });
54
58
  return await response.json();
55
59
  } catch (e) {
@@ -61,7 +65,7 @@ const fetchProject = async (key, options) => {
61
65
  const { editor } = options;
62
66
  if (editor && editor.remote) {
63
67
  const data = await fetchRemote(key, editor);
64
- const evalData = IS_DEVELOPMENT || options.isDevelopment ? deepDestringify(data) : deepDestringify(data.releases[0]);
68
+ const evalData = IS_DEVELOPMENT || options.isDevelopment ? deepDestringifyFunctions(data) : deepDestringifyFunctions(data.releases[0]);
65
69
  if (editor.serviceRoute) {
66
70
  if (utils.isArray(editor.serviceRoute)) {
67
71
  editor.serviceRoute.forEach((route) => {
@@ -71,6 +75,7 @@ const fetchProject = async (key, options) => {
71
75
  overwriteDeep(options[editor.serviceRoute], evalData);
72
76
  }
73
77
  } else {
78
+ ;
74
79
  [
75
80
  "state",
76
81
  "designSystem",
@@ -92,7 +97,7 @@ const fetchProjectAsync = async (key, options, callback) => {
92
97
  const { editor } = options;
93
98
  if (editor && editor.remote) {
94
99
  const data = await fetchRemote(key, editor);
95
- const evalData = IS_DEVELOPMENT || options.isDevelopment ? deepDestringify(data) : deepDestringify(data.releases[0]);
100
+ const evalData = IS_DEVELOPMENT || options.isDevelopment ? deepDestringifyFunctions(data) : deepDestringifyFunctions(data.releases[0]);
96
101
  callback(evalData);
97
102
  }
98
103
  };
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as utils from "@domql/utils";
2
- const { window, overwriteDeep, deepDestringify } = utils;
3
- const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev.") : true;
4
- const SERVER_URL = IS_DEVELOPMENT ? "http://localhost:13335/get" : "https://api.symbols.app/get";
2
+ const { window, overwriteDeep, deepDestringifyFunctions } = utils;
3
+ const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev.") : utils.isDevelopment();
4
+ const SERVER_URL = IS_DEVELOPMENT ? "http://localhost:8080/get" : "https://api.symbols.app/get";
5
5
  const defaultOptions = {
6
6
  endpoint: SERVER_URL
7
7
  };
@@ -13,7 +13,11 @@ const fetchRemote = async (key, options = defaultOptions) => {
13
13
  try {
14
14
  response = await fetch(baseUrl + "/?" + route, {
15
15
  method: "GET",
16
- headers: { "Content-Type": "application/json", "X-AppKey": key, "X-Metadata": options.metadata }
16
+ headers: {
17
+ "Content-Type": "application/json",
18
+ "X-AppKey": key,
19
+ "X-Metadata": options.metadata
20
+ }
17
21
  });
18
22
  return await response.json();
19
23
  } catch (e) {
@@ -25,7 +29,7 @@ const fetchProject = async (key, options) => {
25
29
  const { editor } = options;
26
30
  if (editor && editor.remote) {
27
31
  const data = await fetchRemote(key, editor);
28
- const evalData = IS_DEVELOPMENT || options.isDevelopment ? deepDestringify(data) : deepDestringify(data.releases[0]);
32
+ const evalData = IS_DEVELOPMENT || options.isDevelopment ? deepDestringifyFunctions(data) : deepDestringifyFunctions(data.releases[0]);
29
33
  if (editor.serviceRoute) {
30
34
  if (utils.isArray(editor.serviceRoute)) {
31
35
  editor.serviceRoute.forEach((route) => {
@@ -35,6 +39,7 @@ const fetchProject = async (key, options) => {
35
39
  overwriteDeep(options[editor.serviceRoute], evalData);
36
40
  }
37
41
  } else {
42
+ ;
38
43
  [
39
44
  "state",
40
45
  "designSystem",
@@ -56,7 +61,7 @@ const fetchProjectAsync = async (key, options, callback) => {
56
61
  const { editor } = options;
57
62
  if (editor && editor.remote) {
58
63
  const data = await fetchRemote(key, editor);
59
- const evalData = IS_DEVELOPMENT || options.isDevelopment ? deepDestringify(data) : deepDestringify(data.releases[0]);
64
+ const evalData = IS_DEVELOPMENT || options.isDevelopment ? deepDestringifyFunctions(data) : deepDestringifyFunctions(data.releases[0]);
60
65
  callback(evalData);
61
66
  }
62
67
  };