@symbo.ls/fetch 2.27.0 → 2.27.10

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
@@ -26,17 +26,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var fetch_exports = {};
30
- __export(fetch_exports, {
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
31
  fetch: () => fetch,
32
32
  fetchProject: () => fetchProject,
33
33
  fetchProjectAsync: () => fetchProjectAsync,
34
34
  fetchRemote: () => fetchRemote
35
35
  });
36
- module.exports = __toCommonJS(fetch_exports);
36
+ module.exports = __toCommonJS(index_exports);
37
37
  var utils = __toESM(require("@domql/utils"), 1);
38
38
  const { window, overwriteDeep, deepDestringify } = utils;
39
- const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev.") : true;
39
+ const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev.") : utils.isDevelopment();
40
40
  const SERVER_URL = IS_DEVELOPMENT ? "http://localhost:13335/get" : "https://api.symbols.app/get";
41
41
  const defaultOptions = {
42
42
  endpoint: SERVER_URL
@@ -49,14 +49,16 @@ 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) {
56
- if (utils.isFunction(options.onError))
57
- return options.onError(e);
58
- else
59
- console.error(e);
60
+ if (utils.isFunction(options.onError)) return options.onError(e);
61
+ else console.error(e);
60
62
  }
61
63
  };
62
64
  const fetchProject = async (key, options) => {
@@ -73,6 +75,7 @@ const fetchProject = async (key, options) => {
73
75
  overwriteDeep(options[editor.serviceRoute], evalData);
74
76
  }
75
77
  } else {
78
+ ;
76
79
  [
77
80
  "state",
78
81
  "designSystem",
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as utils from "@domql/utils";
2
2
  const { window, overwriteDeep, deepDestringify } = utils;
3
- const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev.") : true;
3
+ const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev.") : utils.isDevelopment();
4
4
  const SERVER_URL = IS_DEVELOPMENT ? "http://localhost:13335/get" : "https://api.symbols.app/get";
5
5
  const defaultOptions = {
6
6
  endpoint: SERVER_URL
@@ -13,14 +13,16 @@ 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) {
20
- if (utils.isFunction(options.onError))
21
- return options.onError(e);
22
- else
23
- console.error(e);
24
+ if (utils.isFunction(options.onError)) return options.onError(e);
25
+ else console.error(e);
24
26
  }
25
27
  };
26
28
  const fetchProject = async (key, options) => {
@@ -37,6 +39,7 @@ const fetchProject = async (key, options) => {
37
39
  overwriteDeep(options[editor.serviceRoute], evalData);
38
40
  }
39
41
  } else {
42
+ ;
40
43
  [
41
44
  "state",
42
45
  "designSystem",
package/index.js CHANGED
@@ -6,7 +6,7 @@ const { window, overwriteDeep, deepDestringify } = utils
6
6
  const IS_DEVELOPMENT =
7
7
  window && window.location
8
8
  ? window.location.host.includes('dev.')
9
- : process.env.NODE_ENV === 'development'
9
+ : utils.isDevelopment()
10
10
 
11
11
  const SERVER_URL = IS_DEVELOPMENT
12
12
  ? 'http://localhost:13335/get'
@@ -22,7 +22,7 @@ export const fetchRemote = async (key, options = defaultOptions) => {
22
22
  const baseUrl = options.endpoint || SERVER_URL
23
23
  const route = options.serviceRoute
24
24
  ? utils.isArray(options.serviceRoute)
25
- ? options.serviceRoute.map((v) => v.toLowerCase() + '=true').join('&')
25
+ ? options.serviceRoute.map(v => v.toLowerCase() + '=true').join('&')
26
26
  : options.serviceRoute
27
27
  : ''
28
28
 
@@ -30,7 +30,11 @@ export const fetchRemote = async (key, options = defaultOptions) => {
30
30
  try {
31
31
  response = await fetch(baseUrl + '/' + '?' + route, {
32
32
  method: 'GET',
33
- headers: { 'Content-Type': 'application/json', 'X-AppKey': key, 'X-Metadata': options.metadata }
33
+ headers: {
34
+ 'Content-Type': 'application/json',
35
+ 'X-AppKey': key,
36
+ 'X-Metadata': options.metadata
37
+ }
34
38
  })
35
39
 
36
40
  return await response.json()
@@ -45,20 +49,21 @@ export const fetchProject = async (key, options) => {
45
49
 
46
50
  if (editor && editor.remote) {
47
51
  const data = await fetchRemote(key, editor)
48
- const evalData = (IS_DEVELOPMENT || options.isDevelopment)
49
- ? deepDestringify(data)
50
- : deepDestringify(data.releases[0])
52
+ const evalData =
53
+ IS_DEVELOPMENT || options.isDevelopment
54
+ ? deepDestringify(data)
55
+ : deepDestringify(data.releases[0])
51
56
 
52
57
  if (editor.serviceRoute) {
53
58
  if (utils.isArray(editor.serviceRoute)) {
54
- editor.serviceRoute.forEach((route) => {
59
+ editor.serviceRoute.forEach(route => {
55
60
  overwriteDeep(options[route], evalData[route.toLowerCase()])
56
61
  })
57
62
  } else {
58
63
  overwriteDeep(options[editor.serviceRoute], evalData)
59
64
  }
60
65
  } else {
61
- [
66
+ ;[
62
67
  'state',
63
68
  'designSystem',
64
69
  'components',
@@ -68,7 +73,7 @@ export const fetchProject = async (key, options) => {
68
73
  'files',
69
74
  'packages',
70
75
  'functions'
71
- ].forEach((key) => {
76
+ ].forEach(key => {
72
77
  overwriteDeep(options[key], evalData[key.toLowerCase()])
73
78
  })
74
79
  }
@@ -82,9 +87,10 @@ export const fetchProjectAsync = async (key, options, callback) => {
82
87
 
83
88
  if (editor && editor.remote) {
84
89
  const data = await fetchRemote(key, editor)
85
- const evalData = (IS_DEVELOPMENT || options.isDevelopment)
86
- ? deepDestringify(data)
87
- : deepDestringify(data.releases[0])
90
+ const evalData =
91
+ IS_DEVELOPMENT || options.isDevelopment
92
+ ? deepDestringify(data)
93
+ : deepDestringify(data.releases[0])
88
94
  callback(evalData)
89
95
  }
90
96
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@symbo.ls/fetch",
3
- "version": "2.27.0",
3
+ "version": "2.27.10",
4
4
  "license": "MIT",
5
- "gitHead": "40a924693178a7d7b9e94aac0282b9d31602eca7",
5
+ "gitHead": "668d24f518bdb163357897504c5912c085638d3e",
6
6
  "type": "module",
7
7
  "module": "index.js",
8
8
  "main": "index.js",
@@ -10,9 +10,9 @@
10
10
  "jsdelivr": "dist/iife/index.js",
11
11
  "exports": {
12
12
  ".": {
13
- "default": "./dist/esm/index.js",
14
13
  "import": "./dist/esm/index.js",
15
- "require": "./dist/cjs/index.js"
14
+ "require": "./dist/cjs/index.js",
15
+ "default": "./dist/esm/index.js"
16
16
  }
17
17
  },
18
18
  "source": "index.js",
@@ -22,13 +22,13 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
25
- "build:esm": "npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
26
- "build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
27
- "build:iife": "npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
25
+ "build:esm": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
26
+ "build:cjs": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
27
+ "build:iife": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
28
28
  "build": "rimraf -I dist; npm run build:cjs; npm run build:esm",
29
29
  "prepublish": "npm run build; npm run copy:package:cjs"
30
30
  },
31
31
  "dependencies": {
32
- "@domql/utils": "^2.27.0"
32
+ "@domql/utils": "^2.27.10"
33
33
  }
34
34
  }