@spcsn/taro-runtime 0.1.0 → 0.1.2

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 (63) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/assertClassBrand.js +7 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/checkPrivateRedeclaration.js +6 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldGet2.js +7 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldInitSpec.js +7 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldSet2.js +7 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateMethodInitSpec.js +7 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/defineProperty.js +12 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/objectSpread2.js +25 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPrimitive.js +14 -0
  10. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPropertyKey.js +9 -0
  11. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/typeof.js +11 -0
  12. package/dist/bom/URL.js +36 -27
  13. package/dist/bom/URL.js.map +1 -1
  14. package/dist/bom/URLSearchParams.js +18 -14
  15. package/dist/bom/URLSearchParams.js.map +1 -1
  16. package/dist/bom/document.js +3 -2
  17. package/dist/bom/document.js.map +1 -1
  18. package/dist/bom/history.js +52 -40
  19. package/dist/bom/history.js.map +1 -1
  20. package/dist/bom/location.js +101 -91
  21. package/dist/bom/location.js.map +1 -1
  22. package/dist/bom/window.js +1 -1
  23. package/dist/bom/window.js.map +1 -1
  24. package/dist/dom/anchor-element.js +16 -8
  25. package/dist/dom/anchor-element.js.map +1 -1
  26. package/dist/dom/class-list.js.map +1 -1
  27. package/dist/dom/document.js.map +1 -1
  28. package/dist/dom/element.js +2 -1
  29. package/dist/dom/element.js.map +1 -1
  30. package/dist/dom/event-target.js +2 -4
  31. package/dist/dom/event-target.js.map +1 -1
  32. package/dist/dom/event.js +18 -17
  33. package/dist/dom/event.js.map +1 -1
  34. package/dist/dom/form.js +2 -1
  35. package/dist/dom/form.js.map +1 -1
  36. package/dist/dom/node.js +9 -6
  37. package/dist/dom/node.js.map +1 -1
  38. package/dist/dom/root.js +2 -4
  39. package/dist/dom/root.js.map +1 -1
  40. package/dist/dom/text.js.map +1 -1
  41. package/dist/dom/transfer.js.map +1 -1
  42. package/dist/dom/tree.js +1 -1
  43. package/dist/dom/tree.js.map +1 -1
  44. package/dist/dom-external/mutation-observer/implements.js +1 -1
  45. package/dist/dom-external/mutation-observer/implements.js.map +1 -1
  46. package/dist/dsl/common.js +21 -18
  47. package/dist/dsl/common.js.map +1 -1
  48. package/dist/hydrate.js +10 -7
  49. package/dist/hydrate.js.map +1 -1
  50. package/dist/index.cjs.js +392 -260
  51. package/dist/index.cjs.js.map +1 -1
  52. package/dist/next-tick.js +6 -4
  53. package/dist/next-tick.js.map +1 -1
  54. package/dist/perf.js +10 -6
  55. package/dist/perf.js.map +1 -1
  56. package/dist/runtime.esm.js +392 -260
  57. package/dist/runtime.esm.js.map +1 -1
  58. package/dist/utils/cache.js.map +1 -1
  59. package/dist/utils/index.js +9 -6
  60. package/dist/utils/index.js.map +1 -1
  61. package/dist/utils/router.js +2 -1
  62. package/dist/utils/router.js.map +1 -1
  63. package/package.json +2 -2
@@ -2,74 +2,78 @@ import "../constants/index.js";
2
2
  import { Events } from "../emitter/emitter.js";
3
3
  import env from "../env.js";
4
4
  import { RuntimeCache } from "../utils/cache.js";
5
+ import { _classPrivateMethodInitSpec } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateMethodInitSpec.js";
6
+ import { _classPrivateFieldInitSpec } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldInitSpec.js";
7
+ import { _assertClassBrand } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/assertClassBrand.js";
8
+ import { _classPrivateFieldSet2 } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldSet2.js";
9
+ import { _classPrivateFieldGet2 } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldGet2.js";
5
10
  import { isNumber, isString } from "@spcsn/taro-shared";
6
11
  //#region src/bom/history.ts
7
12
  const cache = new RuntimeCache("history");
13
+ var _location = /* @__PURE__ */ new WeakMap();
14
+ var _stack = /* @__PURE__ */ new WeakMap();
15
+ var _cur = /* @__PURE__ */ new WeakMap();
16
+ var _window = /* @__PURE__ */ new WeakMap();
17
+ var _TaroHistory_brand = /* @__PURE__ */ new WeakSet();
8
18
  var TaroHistory = class extends Events {
9
- #location;
10
- #stack = [];
11
- #cur = 0;
12
- #window;
13
19
  constructor(location, options) {
14
20
  super();
15
- this.#window = options.window;
16
- this.#location = location;
17
- this.#location.on("__record_history__", (href) => {
18
- this.#cur++;
19
- this.#stack = this.#stack.slice(0, this.#cur);
20
- this.#stack.push({
21
+ _classPrivateMethodInitSpec(this, _TaroHistory_brand);
22
+ _classPrivateFieldInitSpec(this, _location, void 0);
23
+ _classPrivateFieldInitSpec(this, _stack, []);
24
+ _classPrivateFieldInitSpec(this, _cur, 0);
25
+ _classPrivateFieldInitSpec(this, _window, void 0);
26
+ _classPrivateFieldSet2(_window, this, options.window);
27
+ _classPrivateFieldSet2(_location, this, location);
28
+ _classPrivateFieldGet2(_location, this).on("__record_history__", (href) => {
29
+ var _this$cur;
30
+ _classPrivateFieldSet2(_cur, this, (_this$cur = _classPrivateFieldGet2(_cur, this), _this$cur++, _this$cur));
31
+ _classPrivateFieldSet2(_stack, this, _classPrivateFieldGet2(_stack, this).slice(0, _classPrivateFieldGet2(_cur, this)));
32
+ _classPrivateFieldGet2(_stack, this).push({
21
33
  state: null,
22
34
  title: "",
23
35
  url: href
24
36
  });
25
37
  }, null);
26
- this.#location.on("__reset_history__", (href) => {
27
- this.#reset(href);
38
+ _classPrivateFieldGet2(_location, this).on("__reset_history__", (href) => {
39
+ _assertClassBrand(_TaroHistory_brand, this, _reset).call(this, href);
28
40
  }, null);
29
41
  this.on("0", () => {
30
- this.#reset();
42
+ _assertClassBrand(_TaroHistory_brand, this, _reset).call(this);
31
43
  }, null);
32
44
  this.on("1", (pageId) => {
33
45
  cache.set(pageId, {
34
- location: this.#location,
35
- stack: this.#stack.slice(),
36
- cur: this.#cur
46
+ location: _classPrivateFieldGet2(_location, this),
47
+ stack: _classPrivateFieldGet2(_stack, this).slice(),
48
+ cur: _classPrivateFieldGet2(_cur, this)
37
49
  });
38
50
  }, null);
39
51
  this.on("2", (pageId) => {
40
52
  if (cache.has(pageId)) {
41
53
  const ctx = cache.get(pageId);
42
- this.#location = ctx.location;
43
- this.#stack = ctx.stack;
44
- this.#cur = ctx.cur;
54
+ _classPrivateFieldSet2(_location, this, ctx.location);
55
+ _classPrivateFieldSet2(_stack, this, ctx.stack);
56
+ _classPrivateFieldSet2(_cur, this, ctx.cur);
45
57
  }
46
58
  }, null);
47
59
  this.on("3", (pageId) => {
48
60
  cache.delete(pageId);
49
61
  }, null);
50
- this.#reset();
51
- }
52
- #reset(href = "") {
53
- this.#stack = [{
54
- state: null,
55
- title: "",
56
- url: href || this.#location.href
57
- }];
58
- this.#cur = 0;
62
+ _assertClassBrand(_TaroHistory_brand, this, _reset).call(this);
59
63
  }
60
64
  get length() {
61
- return this.#stack.length;
65
+ return _classPrivateFieldGet2(_stack, this).length;
62
66
  }
63
67
  get state() {
64
- return this.#stack[this.#cur].state;
68
+ return _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)].state;
65
69
  }
66
70
  go(delta) {
67
71
  if (!isNumber(delta) || isNaN(delta)) return;
68
- let targetIdx = this.#cur + delta;
72
+ let targetIdx = _classPrivateFieldGet2(_cur, this) + delta;
69
73
  targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
70
- this.#cur = targetIdx;
71
- this.#location.trigger("__set_href_without_history__", this.#stack[this.#cur].url);
72
- this.#window.trigger("popstate", this.#stack[this.#cur]);
74
+ _classPrivateFieldSet2(_cur, this, targetIdx);
75
+ _classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)].url);
76
+ _classPrivateFieldGet2(_window, this).trigger("popstate", _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)]);
73
77
  }
74
78
  back() {
75
79
  this.go(-1);
@@ -79,28 +83,36 @@ var TaroHistory = class extends Events {
79
83
  }
80
84
  pushState(state, title, url) {
81
85
  if (!url || !isString(url)) return;
82
- this.#stack = this.#stack.slice(0, this.#cur + 1);
83
- this.#stack.push({
86
+ _classPrivateFieldSet2(_stack, this, _classPrivateFieldGet2(_stack, this).slice(0, _classPrivateFieldGet2(_cur, this) + 1));
87
+ _classPrivateFieldGet2(_stack, this).push({
84
88
  state,
85
89
  title,
86
90
  url
87
91
  });
88
- this.#cur = this.length - 1;
89
- this.#location.trigger("__set_href_without_history__", url);
92
+ _classPrivateFieldSet2(_cur, this, this.length - 1);
93
+ _classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", url);
90
94
  }
91
95
  replaceState(state, title, url) {
92
96
  if (!url || !isString(url)) return;
93
- this.#stack[this.#cur] = {
97
+ _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)] = {
94
98
  state,
95
99
  title,
96
100
  url
97
101
  };
98
- this.#location.trigger("__set_href_without_history__", url);
102
+ _classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", url);
99
103
  }
100
104
  get cache() {
101
105
  return cache;
102
106
  }
103
107
  };
108
+ function _reset(href = "") {
109
+ _classPrivateFieldSet2(_stack, this, [{
110
+ state: null,
111
+ title: "",
112
+ url: href || _classPrivateFieldGet2(_location, this).href
113
+ }]);
114
+ _classPrivateFieldSet2(_cur, this, 0);
115
+ }
104
116
  const History = process.env.TARO_PLATFORM === "web" ? env.window.History : TaroHistory;
105
117
  //#endregion
106
118
  export { History };
@@ -1 +1 @@
1
- {"version":3,"file":"history.js","names":["#window","#location","#cur","#stack","#reset"],"sources":["../../src/bom/history.ts"],"sourcesContent":["import { isNumber, isString } from '@spcsn/taro-shared';\n\nimport { CONTEXT_ACTIONS } from '../constants';\nimport { Events } from '../emitter/emitter';\nimport env from '../env';\nimport { RuntimeCache } from '../utils/cache';\n\nimport type { TaroLocation } from './location';\n\nexport interface HistoryState {\n state: Record<string, any> | null;\n title: string;\n url: string;\n}\n\ntype Options = {\n window: any;\n};\ntype HistoryContext = {\n location: TaroLocation;\n stack: HistoryState[];\n cur: number;\n};\nconst cache = new RuntimeCache<HistoryContext>('history');\n\nclass TaroHistory extends Events {\n /* private property */\n #location: TaroLocation;\n #stack: HistoryState[] = [];\n #cur = 0;\n\n #window: any;\n\n constructor(location: TaroLocation, options: Options) {\n super();\n\n this.#window = options.window;\n this.#location = location;\n\n this.#location.on(\n '__record_history__',\n (href: string) => {\n this.#cur++;\n this.#stack = this.#stack.slice(0, this.#cur);\n this.#stack.push({\n state: null,\n title: '',\n url: href,\n });\n },\n null,\n );\n\n this.#location.on(\n '__reset_history__',\n (href: string) => {\n this.#reset(href);\n },\n null,\n );\n\n // 切换上下文行为\n\n this.on(\n CONTEXT_ACTIONS.INIT,\n () => {\n this.#reset();\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RESTORE,\n (pageId: string) => {\n cache.set(pageId, {\n location: this.#location,\n stack: this.#stack.slice(),\n cur: this.#cur,\n });\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RECOVER,\n (pageId: string) => {\n if (cache.has(pageId)) {\n const ctx = cache.get(pageId)!;\n this.#location = ctx.location;\n this.#stack = ctx.stack;\n this.#cur = ctx.cur;\n }\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.DESTROY,\n (pageId: string) => {\n cache.delete(pageId);\n },\n null,\n );\n\n this.#reset();\n }\n\n #reset(href = '') {\n this.#stack = [\n {\n state: null,\n title: '',\n url: href || this.#location.href,\n },\n ];\n this.#cur = 0;\n }\n\n /* public property */\n get length() {\n return this.#stack.length;\n }\n\n get state() {\n return this.#stack[this.#cur].state;\n }\n\n /* public method */\n go(delta: number) {\n if (!isNumber(delta) || isNaN(delta)) return;\n\n let targetIdx = this.#cur + delta;\n targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);\n\n this.#cur = targetIdx;\n\n this.#location.trigger('__set_href_without_history__', this.#stack[this.#cur].url);\n this.#window.trigger('popstate', this.#stack[this.#cur]);\n }\n\n back() {\n this.go(-1);\n }\n\n forward() {\n this.go(1);\n }\n\n pushState(state: any, title: string, url: string) {\n if (!url || !isString(url)) return;\n this.#stack = this.#stack.slice(0, this.#cur + 1);\n this.#stack.push({\n state,\n title,\n url,\n });\n this.#cur = this.length - 1;\n\n this.#location.trigger('__set_href_without_history__', url);\n }\n\n replaceState(state: any, title: string, url: string) {\n if (!url || !isString(url)) return;\n this.#stack[this.#cur] = {\n state,\n title,\n url,\n };\n\n this.#location.trigger('__set_href_without_history__', url);\n }\n\n // For debug\n get cache() {\n return cache;\n }\n}\n\nexport type { TaroHistory };\nexport const History: typeof TaroHistory = process.env.TARO_PLATFORM === 'web' ? env.window.History : TaroHistory;\n"],"mappings":";;;;;;AAuBA,MAAM,QAAQ,IAAI,aAA6B,SAAS;AAExD,IAAM,cAAN,cAA0B,OAAO;CAE/B;CACA,SAAyB,CAAC;CAC1B,OAAO;CAEP;CAEA,YAAY,UAAwB,SAAkB;EACpD,MAAM;EAEN,KAAKA,UAAU,QAAQ;EACvB,KAAKC,YAAY;EAEjB,KAAKA,UAAU,GACb,uBACC,SAAiB;GAChB,KAAKC;GACL,KAAKC,SAAS,KAAKA,OAAO,MAAM,GAAG,KAAKD,IAAI;GAC5C,KAAKC,OAAO,KAAK;IACf,OAAO;IACP,OAAO;IACP,KAAK;GACP,CAAC;E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ACR,KAAK,GAAG,CAAC;CACX;CAEA,UAAU,OAAY,OAAe,KAAa;EAChD,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,GAAG;EAC5B,KAAKC,SAAS,KAAKA,OAAO,MAAM,GAAG,KAAKD,OAAO,CAAC;EAChD,KAAKC,OAAO,KAAK;GACf;GACA;GACA;EACF,CAAC;EACD,KAAKD,OAAO,KAAK,SAAS;EAE1B,KAAKD,UAAU,QAAQ,gCAAgC,GAAG;CAC5D;CAEA,aAAa,OAAY,OAAe,KAAa;EACnD,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,GAAG;EAC5B,KAAKE,OAAO,KAAKD,QAAQ;GACvB;GACA;GACA;EACF;EAEA,KAAKD,UAAU,QAAQ,gCAAgC,GAAG;CAC5D;CAGA,IAAI,QAAQ;EACV,OAAO;CACT;AACF;AAGA,MAAa,UAA8B,QAAQ,IAAI,kBAAkB,QAAQ,IAAI,OAAO,UAAU"}
1
+ {"version":3,"file":"history.js","names":[],"sources":["../../src/bom/history.ts"],"sourcesContent":["import { isNumber, isString } from '@spcsn/taro-shared';\n\nimport { CONTEXT_ACTIONS } from '../constants';\nimport { Events } from '../emitter/emitter';\nimport env from '../env';\nimport { RuntimeCache } from '../utils/cache';\n\nimport type { TaroLocation } from './location';\n\nexport interface HistoryState {\n state: Record<string, any> | null;\n title: string;\n url: string;\n}\n\ntype Options = {\n window: any;\n};\ntype HistoryContext = {\n location: TaroLocation;\n stack: HistoryState[];\n cur: number;\n};\nconst cache = new RuntimeCache<HistoryContext>('history');\n\nclass TaroHistory extends Events {\n /* private property */\n #location: TaroLocation;\n #stack: HistoryState[] = [];\n #cur = 0;\n\n #window: any;\n\n constructor(location: TaroLocation, options: Options) {\n super();\n\n this.#window = options.window;\n this.#location = location;\n\n this.#location.on(\n '__record_history__',\n (href: string) => {\n this.#cur++;\n this.#stack = this.#stack.slice(0, this.#cur);\n this.#stack.push({\n state: null,\n title: '',\n url: href,\n });\n },\n null,\n );\n\n this.#location.on(\n '__reset_history__',\n (href: string) => {\n this.#reset(href);\n },\n null,\n );\n\n // 切换上下文行为\n\n this.on(\n CONTEXT_ACTIONS.INIT,\n () => {\n this.#reset();\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RESTORE,\n (pageId: string) => {\n cache.set(pageId, {\n location: this.#location,\n stack: this.#stack.slice(),\n cur: this.#cur,\n });\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RECOVER,\n (pageId: string) => {\n if (cache.has(pageId)) {\n const ctx = cache.get(pageId)!;\n this.#location = ctx.location;\n this.#stack = ctx.stack;\n this.#cur = ctx.cur;\n }\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.DESTROY,\n (pageId: string) => {\n cache.delete(pageId);\n },\n null,\n );\n\n this.#reset();\n }\n\n #reset(href = '') {\n this.#stack = [\n {\n state: null,\n title: '',\n url: href || this.#location.href,\n },\n ];\n this.#cur = 0;\n }\n\n /* public property */\n get length() {\n return this.#stack.length;\n }\n\n get state() {\n return this.#stack[this.#cur].state;\n }\n\n /* public method */\n go(delta: number) {\n if (!isNumber(delta) || isNaN(delta)) return;\n\n let targetIdx = this.#cur + delta;\n targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);\n\n this.#cur = targetIdx;\n\n this.#location.trigger('__set_href_without_history__', this.#stack[this.#cur].url);\n this.#window.trigger('popstate', this.#stack[this.#cur]);\n }\n\n back() {\n this.go(-1);\n }\n\n forward() {\n this.go(1);\n }\n\n pushState(state: any, title: string, url: string) {\n if (!url || !isString(url)) return;\n this.#stack = this.#stack.slice(0, this.#cur + 1);\n this.#stack.push({\n state,\n title,\n url,\n });\n this.#cur = this.length - 1;\n\n this.#location.trigger('__set_href_without_history__', url);\n }\n\n replaceState(state: any, title: string, url: string) {\n if (!url || !isString(url)) return;\n this.#stack[this.#cur] = {\n state,\n title,\n url,\n };\n\n this.#location.trigger('__set_href_without_history__', url);\n }\n\n // For debug\n get cache() {\n return cache;\n }\n}\n\nexport type { TaroHistory };\nexport const History: typeof TaroHistory = process.env.TARO_PLATFORM === 'web' ? env.window.History : TaroHistory;\n"],"mappings":";;;;;;;;;;;AAuBA,MAAM,QAAQ,IAAI,aAA6B,SAAS;;;;;;AAExD,IAAM,cAAN,cAA0B,OAAO;CAQ/B,YAAY,UAAwB,SAAkB;EACpD,MAAM;;;2CANiB,CAAC,CAAA;yCACnB,CAAA;;EAOL,uBAAA,SAAA,MAAe,QAAQ,MAAA;EACvB,uBAAA,WAAA,MAAiB,QAAA;EAEjB,uBAAA,WAAA,IAAA,EAAe,GACb,uBACC,SAAiB;;gCAChB,OAAA,YAAA,uBAAA,MAAA,IAAA,GAAA,aAAA,UAAA;GACA,uBAAA,QAAA,MAAA,uBAAA,QAAc,IAAA,EAAY,MAAM,GAAA,uBAAA,MAAG,IAAA,CAAS,CAAA;GAC5C,uBAAA,QAAA,IAAA,EAAY,KAAK;IACf,OAAO;IACP,OAAO;IACP,KAAK;GACP,CAAC;EACH,GACA,IACF;EAEA,uBAAA,WAAA,IAAA,EAAe,GACb,sBACC,SAAiB;GAChB,kBAAA,oBAAA,MAAA,MAAA,EAAA,KAAA,MAAY,IAAI;EAClB,GACA,IACF;EAIA,KAAK,GAAA,WAEG;GACJ,kBAAA,oBAAA,MAAA,MAAA,EAAA,KAAA,IAAY;EACd,GACA,IACF;EAEA,KAAK,GAAA,MAEF,WAAmB;GAClB,MAAM,IAAI,QAAQ;IAChB,UAAA,uBAAA,WAAU,IAAA;IACV,OAAA,uBAAA,QAAO,IAAA,EAAY,MAAM;IACzB,KAAA,uBAAA,MAAK,IAAA;GACP,CAAC;EACH,GACA,IACF;EAEA,KAAK,GAAA,MAEF,WAAmB;GAClB,IAAI,MAAM,IAAI,MAAM,GAAG;IACrB,MAAM,MAAM,MAAM,IAAI,MAAM;IAC5B,uBAAA,WAAA,MAAiB,IAAI,QAAA;IACrB,uBAAA,QAAA,MAAc,IAAI,KAAA;IAClB,uBAAA,MAAA,MAAY,IAAI,GAAA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B,uBAAA,QAAA,IAAA,EAAA,uBAAA,MAAY,IAAA,KAAa;GACvB;GACA;GACA;EACF;EAEA,uBAAA,WAAA,IAAA,EAAe,QAAQ,gCAAgC,GAAG;CAC5D;CAGA,IAAI,QAAQ;EACV,OAAO;CACT;AACF;AArEE,SAAA,OAAO,OAAO,IAAI;CAChB,uBAAA,QAAA,MAAc,CACZ;EACE,OAAO;EACP,OAAO;EACP,KAAK,QAAA,uBAAA,WAAQ,IAAA,EAAe;CAC9B,CACF,CAAA;CACA,uBAAA,MAAA,MAAY,CAAA;AACd;AA+DF,MAAa,UAA8B,QAAQ,IAAI,kBAAkB,QAAQ,IAAI,OAAO,UAAU"}
@@ -2,29 +2,39 @@ import "../constants/index.js";
2
2
  import { Events } from "../emitter/emitter.js";
3
3
  import env from "../env.js";
4
4
  import { RuntimeCache } from "../utils/cache.js";
5
+ import { _classPrivateMethodInitSpec } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateMethodInitSpec.js";
6
+ import { _classPrivateFieldInitSpec } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldInitSpec.js";
7
+ import { _assertClassBrand } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/assertClassBrand.js";
8
+ import { _classPrivateFieldSet2 } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldSet2.js";
9
+ import { _classPrivateFieldGet2 } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldGet2.js";
5
10
  import { getCurrentInstance } from "../current.js";
6
11
  import { TaroURLProvider } from "./URL.js";
7
12
  import { isNumber, isString, warn } from "@spcsn/taro-shared";
8
13
  //#region src/bom/location.ts
9
14
  const INIT_URL = "https://taro.com";
10
15
  const cache = new RuntimeCache("location");
16
+ var _url = /* @__PURE__ */ new WeakMap();
17
+ var _noCheckUrl = /* @__PURE__ */ new WeakMap();
18
+ var _window = /* @__PURE__ */ new WeakMap();
19
+ var _TaroLocation_brand = /* @__PURE__ */ new WeakSet();
11
20
  var TaroLocation = class extends Events {
12
- #url = new TaroURLProvider(INIT_URL);
13
- #noCheckUrl = false;
14
- #window;
15
21
  constructor(options) {
16
22
  super();
17
- this.#window = options.window;
18
- this.#reset();
23
+ _classPrivateMethodInitSpec(this, _TaroLocation_brand);
24
+ _classPrivateFieldInitSpec(this, _url, new TaroURLProvider(INIT_URL));
25
+ _classPrivateFieldInitSpec(this, _noCheckUrl, false);
26
+ _classPrivateFieldInitSpec(this, _window, void 0);
27
+ _classPrivateFieldSet2(_window, this, options.window);
28
+ _assertClassBrand(_TaroLocation_brand, this, _reset).call(this);
19
29
  this.on("__set_href_without_history__", (href) => {
20
- this.#noCheckUrl = true;
21
- const lastHash = this.#url.hash;
22
- this.#url.href = generateFullUrl(href);
23
- if (lastHash !== this.#url.hash) this.#window.trigger("hashchange");
24
- this.#noCheckUrl = false;
30
+ _classPrivateFieldSet2(_noCheckUrl, this, true);
31
+ const lastHash = _classPrivateFieldGet2(_url, this).hash;
32
+ _classPrivateFieldGet2(_url, this).href = generateFullUrl(href);
33
+ if (lastHash !== _classPrivateFieldGet2(_url, this).hash) _classPrivateFieldGet2(_window, this).trigger("hashchange");
34
+ _classPrivateFieldSet2(_noCheckUrl, this, false);
25
35
  }, null);
26
36
  this.on("0", () => {
27
- this.#reset();
37
+ _assertClassBrand(_TaroLocation_brand, this, _reset).call(this);
28
38
  }, null);
29
39
  this.on("1", (pageId) => {
30
40
  cache.set(pageId, { lastHref: this.href });
@@ -32,145 +42,104 @@ var TaroLocation = class extends Events {
32
42
  this.on("2", (pageId) => {
33
43
  if (cache.has(pageId)) {
34
44
  const ctx = cache.get(pageId);
35
- this.#noCheckUrl = true;
36
- this.#url.href = ctx.lastHref;
37
- this.#noCheckUrl = false;
45
+ _classPrivateFieldSet2(_noCheckUrl, this, true);
46
+ _classPrivateFieldGet2(_url, this).href = ctx.lastHref;
47
+ _classPrivateFieldSet2(_noCheckUrl, this, false);
38
48
  }
39
49
  }, null);
40
50
  this.on("3", (pageId) => {
41
51
  cache.delete(pageId);
42
52
  }, null);
43
53
  }
44
- #reset() {
45
- const router = getCurrentInstance().router;
46
- if (router) {
47
- const { path, params } = router;
48
- const searchArr = Object.keys(params).map((key) => {
49
- return `${key}=${params[key]}`;
50
- });
51
- const searchStr = searchArr.length > 0 ? "?" + searchArr.join("&") : "";
52
- const url = `${INIT_URL}${path.startsWith("/") ? path : "/" + path}${searchStr}`;
53
- this.#url = new TaroURLProvider(url);
54
- this.trigger("__reset_history__", this.href);
55
- }
56
- }
57
- #getPreValue() {
58
- return this.#url._toRaw();
59
- }
60
- #rollBack(href) {
61
- this.#url.href = href;
62
- }
63
- #recordHistory() {
64
- this.trigger("__record_history__", this.href);
65
- }
66
- /**
67
- * 校验url的变化,是否需要更新history
68
- */
69
- #checkUrlChange(preValue) {
70
- if (this.#noCheckUrl) return false;
71
- const { protocol, hostname, port, pathname, search, hash } = this.#url._toRaw();
72
- if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
73
- this.#rollBack(preValue.href);
74
- return false;
75
- }
76
- if (pathname !== preValue.pathname) return true;
77
- if (search !== preValue.search) return true;
78
- if (hash !== preValue.hash) {
79
- this.#window.trigger("hashchange");
80
- return true;
81
- }
82
- this.#rollBack(preValue.href);
83
- return false;
84
- }
85
54
  get protocol() {
86
- return this.#url.protocol;
55
+ return _classPrivateFieldGet2(_url, this).protocol;
87
56
  }
88
57
  set protocol(val) {
89
58
  if (!val || !isString(val) || !/^(http|https):$/i.test(val.trim())) return;
90
59
  val = val.trim();
91
- const preValue = this.#getPreValue();
92
- this.#url.protocol = val;
93
- if (this.#checkUrlChange(preValue)) this.#recordHistory();
60
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
61
+ _classPrivateFieldGet2(_url, this).protocol = val;
62
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
94
63
  }
95
64
  get host() {
96
- return this.#url.host;
65
+ return _classPrivateFieldGet2(_url, this).host;
97
66
  }
98
67
  set host(val) {
99
68
  if (!val || !isString(val)) return;
100
69
  val = val.trim();
101
- const preValue = this.#getPreValue();
102
- this.#url.host = val;
103
- if (this.#checkUrlChange(preValue)) this.#recordHistory();
70
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
71
+ _classPrivateFieldGet2(_url, this).host = val;
72
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
104
73
  }
105
74
  get hostname() {
106
- return this.#url.hostname;
75
+ return _classPrivateFieldGet2(_url, this).hostname;
107
76
  }
108
77
  set hostname(val) {
109
78
  if (!val || !isString(val)) return;
110
79
  val = val.trim();
111
- const preValue = this.#getPreValue();
112
- this.#url.hostname = val;
113
- if (this.#checkUrlChange(preValue)) this.#recordHistory();
80
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
81
+ _classPrivateFieldGet2(_url, this).hostname = val;
82
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
114
83
  }
115
84
  get port() {
116
- return this.#url.port;
85
+ return _classPrivateFieldGet2(_url, this).port;
117
86
  }
118
87
  set port(val) {
119
88
  const xVal = Number(val = val.trim());
120
89
  if (!isNumber(xVal) || xVal <= 0) return;
121
- const preValue = this.#getPreValue();
122
- this.#url.port = val;
123
- if (this.#checkUrlChange(preValue)) this.#recordHistory();
90
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
91
+ _classPrivateFieldGet2(_url, this).port = val;
92
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
124
93
  }
125
94
  get pathname() {
126
- return this.#url.pathname;
95
+ return _classPrivateFieldGet2(_url, this).pathname;
127
96
  }
128
97
  set pathname(val) {
129
98
  if (!val || !isString(val)) return;
130
99
  val = val.trim();
131
- const preValue = this.#getPreValue();
132
- this.#url.pathname = val;
133
- if (this.#checkUrlChange(preValue)) this.#recordHistory();
100
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
101
+ _classPrivateFieldGet2(_url, this).pathname = val;
102
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
134
103
  }
135
104
  get search() {
136
- return this.#url.search;
105
+ return _classPrivateFieldGet2(_url, this).search;
137
106
  }
138
107
  set search(val) {
139
108
  if (!val || !isString(val)) return;
140
109
  val = val.trim();
141
110
  val = val.startsWith("?") ? val : `?${val}`;
142
- const preValue = this.#getPreValue();
143
- this.#url.search = val;
144
- if (this.#checkUrlChange(preValue)) this.#recordHistory();
111
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
112
+ _classPrivateFieldGet2(_url, this).search = val;
113
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
145
114
  }
146
115
  get hash() {
147
- return this.#url.hash;
116
+ return _classPrivateFieldGet2(_url, this).hash;
148
117
  }
149
118
  set hash(val) {
150
119
  if (!val || !isString(val)) return;
151
120
  val = val.trim();
152
121
  val = val.startsWith("#") ? val : `#${val}`;
153
- const preValue = this.#getPreValue();
154
- this.#url.hash = val;
155
- if (this.#checkUrlChange(preValue)) this.#recordHistory();
122
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
123
+ _classPrivateFieldGet2(_url, this).hash = val;
124
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
156
125
  }
157
126
  get href() {
158
- return this.#url.href;
127
+ return _classPrivateFieldGet2(_url, this).href;
159
128
  }
160
129
  set href(val) {
161
130
  if (!val || !isString(val) || !/^(http:|https:)?\/\/.+/.test(val = val.trim())) return;
162
- const preValue = this.#getPreValue();
163
- this.#url.href = val;
164
- if (this.#checkUrlChange(preValue)) this.#recordHistory();
131
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
132
+ _classPrivateFieldGet2(_url, this).href = val;
133
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
165
134
  }
166
135
  get origin() {
167
- return this.#url.origin;
136
+ return _classPrivateFieldGet2(_url, this).origin;
168
137
  }
169
138
  set origin(val) {
170
139
  if (!val || !isString(val) || !/^(http:|https:)?\/\/.+/.test(val = val.trim())) return;
171
- const preValue = this.#getPreValue();
172
- this.#url.origin = val;
173
- if (this.#checkUrlChange(preValue)) this.#recordHistory();
140
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
141
+ _classPrivateFieldGet2(_url, this).origin = val;
142
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
174
143
  }
175
144
  assign() {
176
145
  warn(true, "小程序环境中调用location.assign()无效.");
@@ -188,6 +157,47 @@ var TaroLocation = class extends Events {
188
157
  return cache;
189
158
  }
190
159
  };
160
+ function _reset() {
161
+ const router = getCurrentInstance().router;
162
+ if (router) {
163
+ const { path, params } = router;
164
+ const searchArr = Object.keys(params).map((key) => {
165
+ return `${key}=${params[key]}`;
166
+ });
167
+ const searchStr = searchArr.length > 0 ? "?" + searchArr.join("&") : "";
168
+ const url = `${INIT_URL}${path.startsWith("/") ? path : "/" + path}${searchStr}`;
169
+ _classPrivateFieldSet2(_url, this, new TaroURLProvider(url));
170
+ this.trigger("__reset_history__", this.href);
171
+ }
172
+ }
173
+ function _getPreValue() {
174
+ return _classPrivateFieldGet2(_url, this)._toRaw();
175
+ }
176
+ function _rollBack(href) {
177
+ _classPrivateFieldGet2(_url, this).href = href;
178
+ }
179
+ function _recordHistory() {
180
+ this.trigger("__record_history__", this.href);
181
+ }
182
+ /**
183
+ * 校验url的变化,是否需要更新history
184
+ */
185
+ function _checkUrlChange(preValue) {
186
+ if (_classPrivateFieldGet2(_noCheckUrl, this)) return false;
187
+ const { protocol, hostname, port, pathname, search, hash } = _classPrivateFieldGet2(_url, this)._toRaw();
188
+ if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
189
+ _assertClassBrand(_TaroLocation_brand, this, _rollBack).call(this, preValue.href);
190
+ return false;
191
+ }
192
+ if (pathname !== preValue.pathname) return true;
193
+ if (search !== preValue.search) return true;
194
+ if (hash !== preValue.hash) {
195
+ _classPrivateFieldGet2(_window, this).trigger("hashchange");
196
+ return true;
197
+ }
198
+ _assertClassBrand(_TaroLocation_brand, this, _rollBack).call(this, preValue.href);
199
+ return false;
200
+ }
191
201
  const Location = process.env.TARO_PLATFORM === "web" ? env.window.Location : TaroLocation;
192
202
  function generateFullUrl(val = "") {
193
203
  const origin = INIT_URL;
@@ -1 +1 @@
1
- {"version":3,"file":"location.js","names":["#window","#reset","#noCheckUrl","#url","#rollBack","#getPreValue","#checkUrlChange","#recordHistory"],"sources":["../../src/bom/location.ts"],"sourcesContent":["import { isNumber, isString, warn } from '@spcsn/taro-shared';\n\nimport { CONTEXT_ACTIONS } from '../constants';\nimport { getCurrentInstance } from '../current';\nimport { Events } from '../emitter/emitter';\nimport env from '../env';\nimport { RuntimeCache } from '../utils/cache';\nimport { TaroURLProvider } from './URL';\n\ntype PreValue = ReturnType<typeof TaroURLProvider.prototype._toRaw>;\n\ntype Options = {\n window: any;\n};\ntype LocationContext = {\n lastHref: string;\n};\n\nconst INIT_URL = 'https://taro.com';\nconst cache = new RuntimeCache<LocationContext>('location');\n\nclass TaroLocation extends Events {\n /* private property */\n #url = new TaroURLProvider(INIT_URL);\n #noCheckUrl = false;\n #window: any;\n\n constructor(options: Options) {\n super();\n\n this.#window = options.window;\n\n this.#reset();\n\n this.on(\n '__set_href_without_history__',\n (href: string) => {\n this.#noCheckUrl = true;\n\n const lastHash = this.#url.hash;\n this.#url.href = generateFullUrl(href);\n\n if (lastHash !== this.#url.hash) {\n this.#window.trigger('hashchange');\n }\n\n this.#noCheckUrl = false;\n },\n null,\n );\n\n // 切换上下文行为\n this.on(\n CONTEXT_ACTIONS.INIT,\n () => {\n this.#reset();\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RESTORE,\n (pageId: string) => {\n cache.set(pageId, {\n lastHref: this.href,\n });\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RECOVER,\n (pageId: string) => {\n // 数据恢复时,不需要执行跳转\n if (cache.has(pageId)) {\n const ctx = cache.get(pageId)!;\n this.#noCheckUrl = true;\n this.#url.href = ctx.lastHref;\n this.#noCheckUrl = false;\n }\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.DESTROY,\n (pageId: string) => {\n cache.delete(pageId);\n },\n null,\n );\n }\n\n /* private method */\n #reset() {\n const Current = getCurrentInstance();\n const router = Current.router;\n if (router) {\n const { path, params } = router;\n const searchArr = Object.keys(params).map((key) => {\n return `${key}=${params[key]}`;\n });\n const searchStr = searchArr.length > 0 ? '?' + searchArr.join('&') : '';\n const url = `${INIT_URL}${path.startsWith('/') ? path : '/' + path}${searchStr}`;\n\n this.#url = new TaroURLProvider(url);\n\n this.trigger('__reset_history__', this.href);\n }\n }\n\n #getPreValue(): PreValue {\n return this.#url._toRaw();\n }\n\n #rollBack(href: string) {\n this.#url.href = href;\n }\n\n #recordHistory() {\n this.trigger('__record_history__', this.href);\n }\n\n /**\n * 校验url的变化,是否需要更新history\n */\n #checkUrlChange(preValue: PreValue): boolean {\n if (this.#noCheckUrl) {\n return false;\n }\n\n const { protocol, hostname, port, pathname, search, hash } = this.#url._toRaw();\n\n // 跨域三要素不允许修改\n if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {\n this.#rollBack(preValue.href);\n return false;\n }\n\n // pathname\n if (pathname !== preValue.pathname) {\n return true;\n }\n\n // search\n if (search !== preValue.search) {\n return true;\n }\n\n // hashchange\n if (hash !== preValue.hash) {\n this.#window.trigger('hashchange');\n return true;\n }\n\n this.#rollBack(preValue.href);\n return false;\n }\n\n /* public property */\n get protocol() {\n return this.#url.protocol;\n }\n\n set protocol(val: string) {\n const REG = /^(http|https):$/i;\n if (!val || !isString(val) || !REG.test(val.trim())) return;\n\n val = val.trim();\n const preValue = this.#getPreValue();\n this.#url.protocol = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get host() {\n return this.#url.host;\n }\n\n set host(val: string) {\n if (!val || !isString(val)) return;\n val = val.trim();\n\n const preValue = this.#getPreValue();\n this.#url.host = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get hostname() {\n return this.#url.hostname;\n }\n\n set hostname(val: string) {\n if (!val || !isString(val)) return;\n val = val.trim();\n\n const preValue = this.#getPreValue();\n this.#url.hostname = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get port() {\n return this.#url.port;\n }\n\n set port(val: string) {\n const xVal = Number((val = val.trim()));\n if (!isNumber(xVal) || xVal <= 0) return;\n\n const preValue = this.#getPreValue();\n this.#url.port = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get pathname() {\n return this.#url.pathname;\n }\n\n set pathname(val: string) {\n if (!val || !isString(val)) return;\n val = val.trim();\n\n const preValue = this.#getPreValue();\n this.#url.pathname = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get search() {\n return this.#url.search;\n }\n\n set search(val: string) {\n if (!val || !isString(val)) return;\n val = val.trim();\n val = val.startsWith('?') ? val : `?${val}`;\n\n const preValue = this.#getPreValue();\n this.#url.search = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get hash() {\n return this.#url.hash;\n }\n\n // 小程序的navigateTo存在截断hash字符串的问题\n set hash(val: string) {\n if (!val || !isString(val)) return;\n val = val.trim();\n val = val.startsWith('#') ? val : `#${val}`;\n\n const preValue = this.#getPreValue();\n this.#url.hash = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get href() {\n return this.#url.href;\n }\n\n set href(val: string) {\n const REG = /^(http:|https:)?\\/\\/.+/;\n if (!val || !isString(val) || !REG.test((val = val.trim()))) return;\n\n const preValue = this.#getPreValue();\n this.#url.href = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get origin() {\n return this.#url.origin;\n }\n\n set origin(val: string) {\n const REG = /^(http:|https:)?\\/\\/.+/;\n if (!val || !isString(val) || !REG.test((val = val.trim()))) return;\n\n const preValue = this.#getPreValue();\n this.#url.origin = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n /* public method */\n assign() {\n warn(true, '小程序环境中调用location.assign()无效.');\n }\n\n reload() {\n warn(true, '小程序环境中调用location.reload()无效.');\n }\n\n replace(url: string) {\n this.trigger('__set_href_without_history__', url);\n }\n\n toString() {\n return this.href;\n }\n\n // For debug\n get cache() {\n return cache;\n }\n}\n\nexport type { TaroLocation };\nexport const Location: typeof TaroLocation = process.env.TARO_PLATFORM === 'web' ? env.window.Location : TaroLocation;\n\nfunction generateFullUrl(val = '') {\n const origin = INIT_URL;\n if (/^[/?#]/.test(val)) {\n return origin + val;\n }\n return val;\n}\n"],"mappings":";;;;;;;;AAkBA,MAAM,WAAW;AACjB,MAAM,QAAQ,IAAI,aAA8B,UAAU;AAE1D,IAAM,eAAN,cAA2B,OAAO;CAEhC,OAAO,IAAI,gBAAgB,QAAQ;CACnC,cAAc;CACd;CAEA,YAAY,SAAkB;EAC5B,MAAM;EAEN,KAAKA,UAAU,QAAQ;EAEvB,KAAKC,OAAO;EAEZ,KAAK,GACH,iCACC,SAAiB;GAChB,KAAKC,cAAc;GAEnB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K;CACnB;CAEA,IAAI,KAAK,KAAa;EAEpB,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,yBAAI,KAAM,MAAM,IAAI,KAAK,CAAE,GAAG;EAE7D,MAAM,WAAW,KAAKE,aAAa;EACnC,KAAKF,KAAK,OAAO;EAEjB,IAAI,KAAKG,gBAAgB,QAAQ,GAAG,KAAKC,eAAe;CAC1D;CAEA,IAAI,SAAS;EACX,OAAO,KAAKJ,KAAK;CACnB;CAEA,IAAI,OAAO,KAAa;EAEtB,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,yBAAI,KAAM,MAAM,IAAI,KAAK,CAAE,GAAG;EAE7D,MAAM,WAAW,KAAKE,aAAa;EACnC,KAAKF,KAAK,SAAS;EAEnB,IAAI,KAAKG,gBAAgB,QAAQ,GAAG,KAAKC,eAAe;CAC1D;CAGA,SAAS;EACP,KAAK,MAAM,8BAA8B;CAC3C;CAEA,SAAS;EACP,KAAK,MAAM,8BAA8B;CAC3C;CAEA,QAAQ,KAAa;EACnB,KAAK,QAAQ,gCAAgC,GAAG;CAClD;CAEA,WAAW;EACT,OAAO,KAAK;CACd;CAGA,IAAI,QAAQ;EACV,OAAO;CACT;AACF;AAGA,MAAa,WAAgC,QAAQ,IAAI,kBAAkB,QAAQ,IAAI,OAAO,WAAW;AAEzG,SAAS,gBAAgB,MAAM,IAAI;CACjC,MAAM,SAAS;CACf,IAAI,SAAS,KAAK,GAAG,GACnB,OAAO,SAAS;CAElB,OAAO;AACT"}
1
+ {"version":3,"file":"location.js","names":[],"sources":["../../src/bom/location.ts"],"sourcesContent":["import { isNumber, isString, warn } from '@spcsn/taro-shared';\n\nimport { CONTEXT_ACTIONS } from '../constants';\nimport { getCurrentInstance } from '../current';\nimport { Events } from '../emitter/emitter';\nimport env from '../env';\nimport { RuntimeCache } from '../utils/cache';\nimport { TaroURLProvider } from './URL';\n\ntype PreValue = ReturnType<typeof TaroURLProvider.prototype._toRaw>;\n\ntype Options = {\n window: any;\n};\ntype LocationContext = {\n lastHref: string;\n};\n\nconst INIT_URL = 'https://taro.com';\nconst cache = new RuntimeCache<LocationContext>('location');\n\nclass TaroLocation extends Events {\n /* private property */\n #url = new TaroURLProvider(INIT_URL);\n #noCheckUrl = false;\n #window: any;\n\n constructor(options: Options) {\n super();\n\n this.#window = options.window;\n\n this.#reset();\n\n this.on(\n '__set_href_without_history__',\n (href: string) => {\n this.#noCheckUrl = true;\n\n const lastHash = this.#url.hash;\n this.#url.href = generateFullUrl(href);\n\n if (lastHash !== this.#url.hash) {\n this.#window.trigger('hashchange');\n }\n\n this.#noCheckUrl = false;\n },\n null,\n );\n\n // 切换上下文行为\n this.on(\n CONTEXT_ACTIONS.INIT,\n () => {\n this.#reset();\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RESTORE,\n (pageId: string) => {\n cache.set(pageId, {\n lastHref: this.href,\n });\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RECOVER,\n (pageId: string) => {\n // 数据恢复时,不需要执行跳转\n if (cache.has(pageId)) {\n const ctx = cache.get(pageId)!;\n this.#noCheckUrl = true;\n this.#url.href = ctx.lastHref;\n this.#noCheckUrl = false;\n }\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.DESTROY,\n (pageId: string) => {\n cache.delete(pageId);\n },\n null,\n );\n }\n\n /* private method */\n #reset() {\n const Current = getCurrentInstance();\n const router = Current.router;\n if (router) {\n const { path, params } = router;\n const searchArr = Object.keys(params).map((key) => {\n return `${key}=${params[key]}`;\n });\n const searchStr = searchArr.length > 0 ? '?' + searchArr.join('&') : '';\n const url = `${INIT_URL}${path.startsWith('/') ? path : '/' + path}${searchStr}`;\n\n this.#url = new TaroURLProvider(url);\n\n this.trigger('__reset_history__', this.href);\n }\n }\n\n #getPreValue(): PreValue {\n return this.#url._toRaw();\n }\n\n #rollBack(href: string) {\n this.#url.href = href;\n }\n\n #recordHistory() {\n this.trigger('__record_history__', this.href);\n }\n\n /**\n * 校验url的变化,是否需要更新history\n */\n #checkUrlChange(preValue: PreValue): boolean {\n if (this.#noCheckUrl) {\n return false;\n }\n\n const { protocol, hostname, port, pathname, search, hash } = this.#url._toRaw();\n\n // 跨域三要素不允许修改\n if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {\n this.#rollBack(preValue.href);\n return false;\n }\n\n // pathname\n if (pathname !== preValue.pathname) {\n return true;\n }\n\n // search\n if (search !== preValue.search) {\n return true;\n }\n\n // hashchange\n if (hash !== preValue.hash) {\n this.#window.trigger('hashchange');\n return true;\n }\n\n this.#rollBack(preValue.href);\n return false;\n }\n\n /* public property */\n get protocol() {\n return this.#url.protocol;\n }\n\n set protocol(val: string) {\n const REG = /^(http|https):$/i;\n if (!val || !isString(val) || !REG.test(val.trim())) return;\n\n val = val.trim();\n const preValue = this.#getPreValue();\n this.#url.protocol = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get host() {\n return this.#url.host;\n }\n\n set host(val: string) {\n if (!val || !isString(val)) return;\n val = val.trim();\n\n const preValue = this.#getPreValue();\n this.#url.host = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get hostname() {\n return this.#url.hostname;\n }\n\n set hostname(val: string) {\n if (!val || !isString(val)) return;\n val = val.trim();\n\n const preValue = this.#getPreValue();\n this.#url.hostname = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get port() {\n return this.#url.port;\n }\n\n set port(val: string) {\n const xVal = Number((val = val.trim()));\n if (!isNumber(xVal) || xVal <= 0) return;\n\n const preValue = this.#getPreValue();\n this.#url.port = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get pathname() {\n return this.#url.pathname;\n }\n\n set pathname(val: string) {\n if (!val || !isString(val)) return;\n val = val.trim();\n\n const preValue = this.#getPreValue();\n this.#url.pathname = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get search() {\n return this.#url.search;\n }\n\n set search(val: string) {\n if (!val || !isString(val)) return;\n val = val.trim();\n val = val.startsWith('?') ? val : `?${val}`;\n\n const preValue = this.#getPreValue();\n this.#url.search = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get hash() {\n return this.#url.hash;\n }\n\n // 小程序的navigateTo存在截断hash字符串的问题\n set hash(val: string) {\n if (!val || !isString(val)) return;\n val = val.trim();\n val = val.startsWith('#') ? val : `#${val}`;\n\n const preValue = this.#getPreValue();\n this.#url.hash = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get href() {\n return this.#url.href;\n }\n\n set href(val: string) {\n const REG = /^(http:|https:)?\\/\\/.+/;\n if (!val || !isString(val) || !REG.test((val = val.trim()))) return;\n\n const preValue = this.#getPreValue();\n this.#url.href = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n get origin() {\n return this.#url.origin;\n }\n\n set origin(val: string) {\n const REG = /^(http:|https:)?\\/\\/.+/;\n if (!val || !isString(val) || !REG.test((val = val.trim()))) return;\n\n const preValue = this.#getPreValue();\n this.#url.origin = val;\n\n if (this.#checkUrlChange(preValue)) this.#recordHistory();\n }\n\n /* public method */\n assign() {\n warn(true, '小程序环境中调用location.assign()无效.');\n }\n\n reload() {\n warn(true, '小程序环境中调用location.reload()无效.');\n }\n\n replace(url: string) {\n this.trigger('__set_href_without_history__', url);\n }\n\n toString() {\n return this.href;\n }\n\n // For debug\n get cache() {\n return cache;\n }\n}\n\nexport type { TaroLocation };\nexport const Location: typeof TaroLocation = process.env.TARO_PLATFORM === 'web' ? env.window.Location : TaroLocation;\n\nfunction generateFullUrl(val = '') {\n const origin = INIT_URL;\n if (/^[/?#]/.test(val)) {\n return origin + val;\n }\n return val;\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,WAAW;AACjB,MAAM,QAAQ,IAAI,aAA8B,UAAU;;;;;AAE1D,IAAM,eAAN,cAA2B,OAAO;CAMhC,YAAY,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M,SAAS;CACf,IAAI,SAAS,KAAK,GAAG,GACnB,OAAO,SAAS;CAElB,OAAO;AACT"}
@@ -23,7 +23,7 @@ var TaroWindow = class extends Events {
23
23
  console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
24
24
  }
25
25
  });
26
- this.Date ||= Date;
26
+ this.Date || (this.Date = Date);
27
27
  this.location = new Location({ window: this });
28
28
  this.history = new History(this.location, { window: this });
29
29
  this.initEvent();
@@ -1 +1 @@
1
- {"version":3,"file":"window.js","names":["navigator","raf","caf"],"sources":["../../src/bom/window.ts"],"sourcesContent":["import { isString } from '@spcsn/taro-shared';\n\nimport { CONTEXT_ACTIONS } from '../constants';\nimport { Events } from '../emitter/emitter';\nimport env from '../env';\nimport { taroGetComputedStyleProvider } from './getComputedStyle';\nimport { History } from './history';\nimport { Location } from './location';\nimport { nav as navigator } from './navigator';\nimport { caf, raf } from './raf';\n\nimport type { TaroHistory } from './history';\nimport type { TaroLocation } from './location';\n\nexport class TaroWindow extends Events {\n navigator = navigator;\n requestAnimationFrame = raf;\n cancelAnimationFrame = caf;\n getComputedStyle = taroGetComputedStyleProvider;\n Date: DateConstructor;\n\n location: TaroLocation;\n history: TaroHistory;\n XMLHttpRequest?: Partial<XMLHttpRequest>;\n\n constructor() {\n super();\n\n const globalProperties = [\n ...Object.getOwnPropertyNames(global || {}),\n ...Object.getOwnPropertySymbols(global || {}),\n ];\n\n globalProperties.forEach((property) => {\n if (property === 'atob' || property === 'document') return;\n if (!Object.prototype.hasOwnProperty.call(this, property)) {\n // 防止小程序环境下,window 上的某些 get 属性在赋值时报错\n try {\n this[property] = global[property];\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);\n }\n }\n }\n });\n\n this.Date ||= Date;\n\n // 应用启动时,提供给需要读取历史信息的库使用\n this.location = new Location({ window: this }) as any;\n // @ts-ignore\n this.history = new History(this.location, { window: this });\n\n this.initEvent();\n }\n\n initEvent() {\n const _location = this.location;\n const _history = this.history;\n\n this.on(\n CONTEXT_ACTIONS.INIT,\n (pageId: string) => {\n // 页面 onload,为该页面建立新的上下文信息\n _location.trigger(CONTEXT_ACTIONS.INIT, pageId);\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RECOVER,\n (pageId: string) => {\n // 页面 onshow,恢复当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RECOVER, pageId);\n _history.trigger(CONTEXT_ACTIONS.RECOVER, pageId);\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RESTORE,\n (pageId: string) => {\n // 页面 onhide,缓存当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RESTORE, pageId);\n _history.trigger(CONTEXT_ACTIONS.RESTORE, pageId);\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.DESTROY,\n (pageId: string) => {\n // 页面 onunload,清除当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.DESTROY, pageId);\n _history.trigger(CONTEXT_ACTIONS.DESTROY, pageId);\n },\n null,\n );\n }\n\n get document() {\n return env.document;\n }\n\n addEventListener(event: string, callback: (arg: any) => void) {\n if (!isString(event)) return;\n this.on(event, callback, null);\n }\n\n removeEventListener(event: string, callback: (arg: any) => void) {\n if (!isString(event)) return;\n this.off(event, callback, null);\n }\n\n setTimeout(...args: Parameters<typeof setTimeout>) {\n return setTimeout(...args);\n }\n\n clearTimeout(...args: Parameters<typeof clearTimeout>) {\n return clearTimeout(...args);\n }\n}\n\n// Note: 小程序端 vite 打包成 commonjs,const window = xxx 会报错,所以把 window 改为 taroWindowProvider,location 和 history 同理\nexport const taroWindowProvider: TaroWindow =\n process.env.TARO_PLATFORM === 'web' ? env.window : (env.window = new TaroWindow());\nexport const taroLocationProvider = taroWindowProvider.location;\nexport const taroHistoryProvider = taroWindowProvider.history;\n"],"mappings":";;;;;;;;;;AAcA,IAAa,aAAb,cAAgC,OAAO;CAWrC,cAAc;EACZ,MAAM;mBAX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IAAI,OAAO,UAAU,IAAI;CAChC;CAEA,WAAW,GAAG,MAAqC;EACjD,OAAO,WAAW,GAAG,IAAI;CAC3B;CAEA,aAAa,GAAG,MAAuC;EACrD,OAAO,aAAa,GAAG,IAAI;CAC7B;AACF;AAGA,MAAa,qBACX,QAAQ,IAAI,kBAAkB,QAAQ,IAAI,SAAU,IAAI,SAAS,IAAI,WAAW;AAClF,MAAa,uBAAuB,mBAAmB;AACvD,MAAa,sBAAsB,mBAAmB"}
1
+ {"version":3,"file":"window.js","names":["navigator","raf","caf"],"sources":["../../src/bom/window.ts"],"sourcesContent":["import { isString } from '@spcsn/taro-shared';\n\nimport { CONTEXT_ACTIONS } from '../constants';\nimport { Events } from '../emitter/emitter';\nimport env from '../env';\nimport { taroGetComputedStyleProvider } from './getComputedStyle';\nimport { History } from './history';\nimport { Location } from './location';\nimport { nav as navigator } from './navigator';\nimport { caf, raf } from './raf';\n\nimport type { TaroHistory } from './history';\nimport type { TaroLocation } from './location';\n\nexport class TaroWindow extends Events {\n navigator = navigator;\n requestAnimationFrame = raf;\n cancelAnimationFrame = caf;\n getComputedStyle = taroGetComputedStyleProvider;\n Date: DateConstructor;\n\n location: TaroLocation;\n history: TaroHistory;\n XMLHttpRequest?: Partial<XMLHttpRequest>;\n\n constructor() {\n super();\n\n const globalProperties = [\n ...Object.getOwnPropertyNames(global || {}),\n ...Object.getOwnPropertySymbols(global || {}),\n ];\n\n globalProperties.forEach((property) => {\n if (property === 'atob' || property === 'document') return;\n if (!Object.prototype.hasOwnProperty.call(this, property)) {\n // 防止小程序环境下,window 上的某些 get 属性在赋值时报错\n try {\n this[property] = global[property];\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);\n }\n }\n }\n });\n\n this.Date ||= Date;\n\n // 应用启动时,提供给需要读取历史信息的库使用\n this.location = new Location({ window: this }) as any;\n // @ts-ignore\n this.history = new History(this.location, { window: this });\n\n this.initEvent();\n }\n\n initEvent() {\n const _location = this.location;\n const _history = this.history;\n\n this.on(\n CONTEXT_ACTIONS.INIT,\n (pageId: string) => {\n // 页面 onload,为该页面建立新的上下文信息\n _location.trigger(CONTEXT_ACTIONS.INIT, pageId);\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RECOVER,\n (pageId: string) => {\n // 页面 onshow,恢复当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RECOVER, pageId);\n _history.trigger(CONTEXT_ACTIONS.RECOVER, pageId);\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.RESTORE,\n (pageId: string) => {\n // 页面 onhide,缓存当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RESTORE, pageId);\n _history.trigger(CONTEXT_ACTIONS.RESTORE, pageId);\n },\n null,\n );\n\n this.on(\n CONTEXT_ACTIONS.DESTROY,\n (pageId: string) => {\n // 页面 onunload,清除当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.DESTROY, pageId);\n _history.trigger(CONTEXT_ACTIONS.DESTROY, pageId);\n },\n null,\n );\n }\n\n get document() {\n return env.document;\n }\n\n addEventListener(event: string, callback: (arg: any) => void) {\n if (!isString(event)) return;\n this.on(event, callback, null);\n }\n\n removeEventListener(event: string, callback: (arg: any) => void) {\n if (!isString(event)) return;\n this.off(event, callback, null);\n }\n\n setTimeout(...args: Parameters<typeof setTimeout>) {\n return setTimeout(...args);\n }\n\n clearTimeout(...args: Parameters<typeof clearTimeout>) {\n return clearTimeout(...args);\n }\n}\n\n// Note: 小程序端 vite 打包成 commonjs,const window = xxx 会报错,所以把 window 改为 taroWindowProvider,location 和 history 同理\nexport const taroWindowProvider: TaroWindow =\n process.env.TARO_PLATFORM === 'web' ? env.window : (env.window = new TaroWindow());\nexport const taroLocationProvider = taroWindowProvider.location;\nexport const taroHistoryProvider = taroWindowProvider.history;\n"],"mappings":";;;;;;;;;;AAcA,IAAa,aAAb,cAAgC,OAAO;CAWrC,cAAc;EACZ,MAA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,oBAAoB,OAAe,UAA8B;EAC/D,IAAI,CAAC,SAAS,KAAK,GAAG;EACtB,KAAK,IAAI,OAAO,UAAU,IAAI;CAChC;CAEA,WAAW,GAAG,MAAqC;EACjD,OAAO,WAAW,GAAG,IAAI;CAC3B;CAEA,aAAa,GAAG,MAAuC;EACrD,OAAO,aAAa,GAAG,IAAI;CAC7B;AACF;AAGA,MAAa,qBACX,QAAQ,IAAI,kBAAkB,QAAQ,IAAI,SAAU,IAAI,SAAS,IAAI,WAAW;AAClF,MAAa,uBAAuB,mBAAmB;AACvD,MAAa,sBAAsB,mBAAmB"}
@@ -3,31 +3,39 @@ import { TaroElement } from "./element.js";
3
3
  //#region src/dom/anchor-element.ts
4
4
  var AnchorElement = class extends TaroElement {
5
5
  get href() {
6
- return this.props["href"] ?? "";
6
+ var _this$props$AnchorEle;
7
+ return (_this$props$AnchorEle = this.props["href"]) !== null && _this$props$AnchorEle !== void 0 ? _this$props$AnchorEle : "";
7
8
  }
8
9
  set href(val) {
9
10
  this.setAttribute("href", val);
10
11
  }
11
12
  get protocol() {
12
- return this.props["protocol"] ?? "";
13
+ var _this$props$AnchorEle2;
14
+ return (_this$props$AnchorEle2 = this.props["protocol"]) !== null && _this$props$AnchorEle2 !== void 0 ? _this$props$AnchorEle2 : "";
13
15
  }
14
16
  get host() {
15
- return this.props["host"] ?? "";
17
+ var _this$props$AnchorEle3;
18
+ return (_this$props$AnchorEle3 = this.props["host"]) !== null && _this$props$AnchorEle3 !== void 0 ? _this$props$AnchorEle3 : "";
16
19
  }
17
20
  get search() {
18
- return this.props["search"] ?? "";
21
+ var _this$props$AnchorEle4;
22
+ return (_this$props$AnchorEle4 = this.props["search"]) !== null && _this$props$AnchorEle4 !== void 0 ? _this$props$AnchorEle4 : "";
19
23
  }
20
24
  get hash() {
21
- return this.props["hash"] ?? "";
25
+ var _this$props$AnchorEle5;
26
+ return (_this$props$AnchorEle5 = this.props["hash"]) !== null && _this$props$AnchorEle5 !== void 0 ? _this$props$AnchorEle5 : "";
22
27
  }
23
28
  get hostname() {
24
- return this.props["hostname"] ?? "";
29
+ var _this$props$AnchorEle6;
30
+ return (_this$props$AnchorEle6 = this.props["hostname"]) !== null && _this$props$AnchorEle6 !== void 0 ? _this$props$AnchorEle6 : "";
25
31
  }
26
32
  get port() {
27
- return this.props["port"] ?? "";
33
+ var _this$props$AnchorEle7;
34
+ return (_this$props$AnchorEle7 = this.props["port"]) !== null && _this$props$AnchorEle7 !== void 0 ? _this$props$AnchorEle7 : "";
28
35
  }
29
36
  get pathname() {
30
- return this.props["pathname"] ?? "";
37
+ var _this$props$AnchorEle8;
38
+ return (_this$props$AnchorEle8 = this.props["pathname"]) !== null && _this$props$AnchorEle8 !== void 0 ? _this$props$AnchorEle8 : "";
31
39
  }
32
40
  setAttribute(qualifiedName, value) {
33
41
  if (qualifiedName === "href") {