@ray-js/location 0.4.12 → 0.4.15-beta-0

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.
Files changed (2) hide show
  1. package/lib/location.js +84 -89
  2. package/package.json +7 -7
package/lib/location.js CHANGED
@@ -1,98 +1,93 @@
1
- import "core-js/modules/es.object.define-properties.js";
2
- import "core-js/modules/es.regexp.exec.js";
3
- import "core-js/modules/es.string.replace.js";
4
- import "core-js/modules/es.string.search.js";
5
1
  import { url } from '@ray-js/library';
6
2
  import router from '@ray-js/router';
7
3
  /**
8
4
  * 跨平台全局 location 对象,惰性获取,读取时再进行页面路径计算,性能较低
9
5
  * 小程序原生 NavBar 跳转的页面无法预先进行设置,所以仅支持在读取可用
10
6
  */
11
-
12
- var location = {
13
- href: '',
14
- hash: '',
15
- host: '',
16
- hostname: '',
17
- params: {},
18
- pathname: '',
19
- port: '',
20
- protocol: '',
21
- query: {},
22
- search: ''
7
+ const location = {
8
+ href: '',
9
+ hash: '',
10
+ host: '',
11
+ hostname: '',
12
+ params: {},
13
+ pathname: '',
14
+ port: '',
15
+ protocol: '',
16
+ query: {},
17
+ search: '',
23
18
  };
24
19
  Object.defineProperties(location, {
25
- href: {
26
- enumerable: true,
27
- configurable: false,
28
- get: function get() {
29
- return router.hostHref.replace(/____h_a_s_h____=[^&]+&?/, '');
30
- }
31
- },
32
- hash: {
33
- enumerable: true,
34
- configurable: false,
35
- get: function get() {
36
- var q = url.parse(router.hostHref);
37
- return q.hash || (q.query || {})['____h_a_s_h____'];
38
- }
39
- },
40
- host: {
41
- enumerable: true,
42
- configurable: false,
43
- get: function get() {
44
- return url.parse(this.href).host;
45
- }
46
- },
47
- hostname: {
48
- enumerable: true,
49
- configurable: false,
50
- get: function get() {
51
- return url.parse(this.href).hostname;
52
- }
53
- },
54
- pathname: {
55
- enumerable: true,
56
- configurable: false,
57
- get: function get() {
58
- return url.parse(this.href).pathname;
59
- }
60
- },
61
- port: {
62
- enumerable: true,
63
- configurable: false,
64
- get: function get() {
65
- return url.parse(this.href).port;
66
- }
67
- },
68
- protocol: {
69
- enumerable: true,
70
- configurable: false,
71
- get: function get() {
72
- return url.parse(this.href).protocol;
73
- }
74
- },
75
- search: {
76
- enumerable: true,
77
- configurable: false,
78
- get: function get() {
79
- return url.parse(this.href).search;
80
- }
81
- },
82
- query: {
83
- enumerable: true,
84
- configurable: false,
85
- get: function get() {
86
- return url.parse(this.href).query;
87
- }
88
- },
89
- params: {
90
- enumerable: true,
91
- configurable: false,
92
- get: function get() {
93
- var page = router.scheduler.getMatchedPage(this.pathname);
94
- return (page === null || page === void 0 ? void 0 : page.params) || {};
95
- }
96
- }
20
+ href: {
21
+ enumerable: true,
22
+ configurable: false,
23
+ get() {
24
+ return router.hostHref.replace(/____h_a_s_h____=[^&]+&?/, '');
25
+ },
26
+ },
27
+ hash: {
28
+ enumerable: true,
29
+ configurable: false,
30
+ get() {
31
+ const q = url.parse(router.hostHref);
32
+ return q.hash || (q.query || {})['____h_a_s_h____'];
33
+ },
34
+ },
35
+ host: {
36
+ enumerable: true,
37
+ configurable: false,
38
+ get() {
39
+ return url.parse(this.href).host;
40
+ },
41
+ },
42
+ hostname: {
43
+ enumerable: true,
44
+ configurable: false,
45
+ get() {
46
+ return url.parse(this.href).hostname;
47
+ },
48
+ },
49
+ pathname: {
50
+ enumerable: true,
51
+ configurable: false,
52
+ get() {
53
+ return url.parse(this.href).pathname;
54
+ },
55
+ },
56
+ port: {
57
+ enumerable: true,
58
+ configurable: false,
59
+ get() {
60
+ return url.parse(this.href).port;
61
+ },
62
+ },
63
+ protocol: {
64
+ enumerable: true,
65
+ configurable: false,
66
+ get() {
67
+ return url.parse(this.href).protocol;
68
+ },
69
+ },
70
+ search: {
71
+ enumerable: true,
72
+ configurable: false,
73
+ get() {
74
+ return url.parse(this.href).search;
75
+ },
76
+ },
77
+ query: {
78
+ enumerable: true,
79
+ configurable: false,
80
+ get() {
81
+ return url.parse(this.href).query;
82
+ },
83
+ },
84
+ params: {
85
+ enumerable: true,
86
+ configurable: false,
87
+ get() {
88
+ const page = router.scheduler.getMatchedPage(this.pathname);
89
+ return (page === null || page === void 0 ? void 0 : page.params) || {};
90
+ },
91
+ },
97
92
  });
98
- export { location };
93
+ export { location };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/location",
3
- "version": "0.4.12",
3
+ "version": "0.4.15-beta-0",
4
4
  "description": "Ray Core",
5
5
  "keywords": [
6
6
  "ray"
@@ -20,13 +20,13 @@
20
20
  "watch": "tsc -p ./tsconfig.build.json --module esnext --outDir lib --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@ray-js/library": "^0.4.12",
24
- "@ray-js/router": "^0.4.12",
25
- "@ray-js/router-mp": "^0.4.12"
23
+ "@ray-js/library": "^0.4.15-beta-0",
24
+ "@ray-js/router": "^0.4.15-beta-0",
25
+ "@ray-js/router-mp": "^0.4.15-beta-0"
26
26
  },
27
27
  "devDependencies": {
28
- "@ray-js/cli": "^0.4.12",
29
- "@ray-js/types": "^0.4.12"
28
+ "@ray-js/cli": "^0.4.15-beta-0",
29
+ "@ray-js/types": "^0.4.15-beta-0"
30
30
  },
31
31
  "maintainers": [
32
32
  {
@@ -34,6 +34,6 @@
34
34
  "email": "tuyafe@tuya.com"
35
35
  }
36
36
  ],
37
- "gitHead": "2ac747db1f49c6f391d916eb697d5900f0736de3",
37
+ "gitHead": "c9b5b2e847299ecbd30c8b1feb2413045c139bf7",
38
38
  "repository": {}
39
39
  }