@xfe-repo/web-utils 1.1.0 → 1.1.4

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.
@@ -0,0 +1,35 @@
1
+ // src/storage.ts
2
+ import cookie from "js-cookie";
3
+ import queryString from "query-string";
4
+ var cookies = cookie.withConverter({
5
+ read(value) {
6
+ return value;
7
+ },
8
+ write(value) {
9
+ return encodeURIComponent(`${value}`);
10
+ }
11
+ });
12
+ function parseUrlQuery(options) {
13
+ let { search, hash } = window.location;
14
+ if (!search && hash.indexOf("?") !== -1) {
15
+ search = `?${hash.split("?")[1]}`;
16
+ }
17
+ return queryString.parse(search, options);
18
+ }
19
+ function getUrlQuery(key) {
20
+ const queryJson = parseUrlQuery({ parseBooleans: true, parseNumbers: true });
21
+ return queryJson[key];
22
+ }
23
+ function setUrlQuery(queryJson) {
24
+ let { hash } = window.location;
25
+ const search = queryString.stringify(queryJson, { skipNull: true, skipEmptyString: true });
26
+ const url = `?${search}${hash.split("?")[0]}`;
27
+ window.history.replaceState({}, "", url);
28
+ }
29
+
30
+ export {
31
+ cookies,
32
+ parseUrlQuery,
33
+ getUrlQuery,
34
+ setUrlQuery
35
+ };
package/dist/env.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/env.ts
@@ -40,6 +50,20 @@ __export(env_exports, {
40
50
  sentryConfig: () => sentryConfig
41
51
  });
42
52
  module.exports = __toCommonJS(env_exports);
53
+
54
+ // src/storage.ts
55
+ var import_js_cookie = __toESM(require("js-cookie"));
56
+ var import_query_string = __toESM(require("query-string"));
57
+ var cookies = import_js_cookie.default.withConverter({
58
+ read(value) {
59
+ return value;
60
+ },
61
+ write(value) {
62
+ return encodeURIComponent(`${value}`);
63
+ }
64
+ });
65
+
66
+ // src/env.ts
43
67
  var isServer = typeof window === "undefined";
44
68
  var isClient = !isServer;
45
69
  var isSSR = isClient && Boolean(window.__SSR_RESULT__);
@@ -54,7 +78,7 @@ var isAndroid = /android/i.test(navigator.userAgent);
54
78
  var isWeiXin = /MicroMessenger/i.test(navigator.userAgent);
55
79
  var isProduction = process.env["NODE_ENV"] === "production";
56
80
  var release = process.env["REACT_APP_RELEASE"] || "dev";
57
- var apiEnv = process.env["REACT_APP_API_ENV"];
81
+ var apiEnv = process.env["REACT_APP_API_ENV"] || cookies.get("apiEnv");
58
82
  var business = process.env["REACT_APP_BUSINESS"];
59
83
  var assetsHost = "https://imgs.xianghuanji.com/";
60
84
  var erpSaasOriginDic = {
package/dist/env.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ cookies
3
+ } from "./chunk-RF6YQEI2.mjs";
1
4
  import "./chunk-3K5GXOTC.mjs";
2
5
 
3
6
  // src/env.ts
@@ -15,7 +18,7 @@ var isAndroid = /android/i.test(navigator.userAgent);
15
18
  var isWeiXin = /MicroMessenger/i.test(navigator.userAgent);
16
19
  var isProduction = process.env["NODE_ENV"] === "production";
17
20
  var release = process.env["REACT_APP_RELEASE"] || "dev";
18
- var apiEnv = process.env["REACT_APP_API_ENV"];
21
+ var apiEnv = process.env["REACT_APP_API_ENV"] || cookies.get("apiEnv");
19
22
  var business = process.env["REACT_APP_BUSINESS"];
20
23
  var assetsHost = "https://imgs.xianghuanji.com/";
21
24
  var erpSaasOriginDic = {
package/dist/storage.mjs CHANGED
@@ -1,33 +1,10 @@
1
+ import {
2
+ cookies,
3
+ getUrlQuery,
4
+ parseUrlQuery,
5
+ setUrlQuery
6
+ } from "./chunk-RF6YQEI2.mjs";
1
7
  import "./chunk-3K5GXOTC.mjs";
2
-
3
- // src/storage.ts
4
- import cookie from "js-cookie";
5
- import queryString from "query-string";
6
- var cookies = cookie.withConverter({
7
- read(value) {
8
- return value;
9
- },
10
- write(value) {
11
- return encodeURIComponent(`${value}`);
12
- }
13
- });
14
- function parseUrlQuery(options) {
15
- let { search, hash } = window.location;
16
- if (!search && hash.indexOf("?") !== -1) {
17
- search = `?${hash.split("?")[1]}`;
18
- }
19
- return queryString.parse(search, options);
20
- }
21
- function getUrlQuery(key) {
22
- const queryJson = parseUrlQuery({ parseBooleans: true, parseNumbers: true });
23
- return queryJson[key];
24
- }
25
- function setUrlQuery(queryJson) {
26
- let { hash } = window.location;
27
- const search = queryString.stringify(queryJson, { skipNull: true, skipEmptyString: true });
28
- const url = `?${search}${hash.split("?")[0]}`;
29
- window.history.replaceState({}, "", url);
30
- }
31
8
  export {
32
9
  cookies,
33
10
  getUrlQuery,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-utils",
3
- "version": "1.1.0",
3
+ "version": "1.1.4",
4
4
  "sideEffects": false,
5
5
  "module": "dist/*.js",
6
6
  "types": "types/*.d.ts",
@@ -26,8 +26,8 @@
26
26
  "devDependencies": {
27
27
  "@types/js-cookie": "^3.0.5",
28
28
  "@types/node": "^20.10.3",
29
- "@xfe-repo/typescript-config": "0.0.3",
30
- "@xfe-repo/eslint-config": "0.0.2"
29
+ "@xfe-repo/eslint-config": "0.0.4",
30
+ "@xfe-repo/typescript-config": "0.0.6"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup",