@unparallel/url-manager 0.0.3 → 0.0.5

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.
@@ -1,45 +1,45 @@
1
1
  var l = Object.defineProperty;
2
- var c = (h, e, t) => e in h ? l(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t;
3
- var o = (h, e, t) => c(h, typeof e != "symbol" ? e + "" : e, t);
4
- import m from "query-string";
2
+ var m = (o, e, t) => e in o ? l(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var n = (o, e, t) => m(o, typeof e != "symbol" ? e + "" : e, t);
4
+ import c from "query-string";
5
5
  import { EventEmitter as u } from "events";
6
6
  import { URLManagerTools as w } from "../URLManagerTools/index.js";
7
- class n extends w {
7
+ class h extends w {
8
8
  constructor(t, s) {
9
9
  super();
10
- o(this, "id");
11
- o(this, "disableUrlManager");
12
- o(this, "hashLength");
13
- o(this, "hash");
14
- o(this, "events");
15
- o(this, "urlManagerComponentId");
16
- this.id = t.id, this.disableUrlManager = !!s, this.hashLength = 6, this.hash = n.generateHash(this.id, t.hashChain), this.events = new u(), this.urlManagerComponentId = t.urlManagerComponentId;
10
+ n(this, "id");
11
+ n(this, "disableUrlManager");
12
+ n(this, "hashLength");
13
+ n(this, "hash");
14
+ n(this, "events");
15
+ n(this, "urlManagerComponentId");
16
+ this.id = t.id, this.disableUrlManager = !!s, this.hashLength = 6, this.hash = h.generateHash(this.id, t.hashChain), this.events = new u(), this.urlManagerComponentId = t.urlManagerComponentId;
17
17
  }
18
18
  setNewHashChain(t) {
19
19
  const s = this.hash;
20
- this.hash = n.generateHash(this.id, t), s != this.hash && this.events.emit("hashChange", this.hash);
20
+ this.hash = h.generateHash(this.id, t), s != this.hash && this.events.emit("hashChange", this.hash);
21
21
  }
22
22
  updateKey(t, s, i) {
23
23
  if (this.disableUrlManager)
24
24
  return;
25
25
  const d = { [t]: s };
26
26
  let r = this.getJSONFromComponent(this.hash);
27
- r = { ...r, ...d }, console.log(r);
27
+ r = { ...r, ...d };
28
28
  const a = new URL(window.location.href);
29
- a.searchParams.set(this.hash, n.getEncodedStrFromJSON(r)), i ? window.history.pushState({}, "", a) : window.history.pushState({}, "", a);
29
+ a.searchParams.set(this.hash, h.getEncodedStrFromJSON(r)), i ? window.history.pushState({}, "", a) : window.history.pushState({}, "", a);
30
30
  }
31
31
  getKeyFromComponent(t) {
32
32
  if (window.location) {
33
- const i = m.parse(window.location.search)[this.hash];
33
+ const i = c.parse(window.location.search)[this.hash];
34
34
  if (typeof i == "string")
35
- return n.getJSONFromEncodedStr(i)[t];
35
+ return h.getJSONFromEncodedStr(i)[t];
36
36
  }
37
37
  }
38
38
  getJSONFromComponent(t) {
39
39
  if (window.location)
40
- return n.getJSONFromHash(t, window.location.search);
40
+ return h.getJSONFromHash(t, window.location.search);
41
41
  }
42
42
  }
43
43
  export {
44
- n as URLManager
44
+ h as URLManager
45
45
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unparallel/url-manager",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",
@@ -25,13 +25,14 @@
25
25
  "dependencies": {
26
26
  "events": "^3.3.0",
27
27
  "object-hash": "^3.0.0",
28
- "query-string": "^9.3.1"
28
+ "query-string": "^5.1.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@eslint/js": "^9.17.0",
32
32
  "@release-it/keep-a-changelog": "^7.0.1",
33
33
  "@types/events": "^3.0.3",
34
34
  "@types/object-hash": "^3.0.6",
35
+ "@types/query-string": "^6.2.0",
35
36
  "@types/react": "^18.3.18",
36
37
  "@types/react-dom": "^18.3.5",
37
38
  "@vitejs/plugin-react": "^4.3.4",