vite-plugin-taro-runtime 0.6.7

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 (168) hide show
  1. package/LICENSE +174 -0
  2. package/README.md +45 -0
  3. package/dist/bom/URL.d.ts +53 -0
  4. package/dist/bom/URL.js +222 -0
  5. package/dist/bom/URL.js.map +1 -0
  6. package/dist/bom/URLSearchParams.d.ts +3 -0
  7. package/dist/bom/URLSearchParams.js +131 -0
  8. package/dist/bom/URLSearchParams.js.map +1 -0
  9. package/dist/bom/document.d.ts +5 -0
  10. package/dist/bom/document.js +185 -0
  11. package/dist/bom/document.js.map +1 -0
  12. package/dist/bom/getComputedStyle.d.ts +8 -0
  13. package/dist/bom/getComputedStyle.js +9 -0
  14. package/dist/bom/getComputedStyle.js.map +1 -0
  15. package/dist/bom/history.d.ts +34 -0
  16. package/dist/bom/history.js +121 -0
  17. package/dist/bom/history.js.map +1 -0
  18. package/dist/bom/location.d.ts +40 -0
  19. package/dist/bom/location.js +240 -0
  20. package/dist/bom/location.js.map +1 -0
  21. package/dist/bom/navigator.d.ts +3 -0
  22. package/dist/bom/navigator.js +24 -0
  23. package/dist/bom/navigator.js.map +1 -0
  24. package/dist/bom/raf.d.ts +5 -0
  25. package/dist/bom/raf.js +33 -0
  26. package/dist/bom/raf.js.map +1 -0
  27. package/dist/bom/window.d.ts +28 -0
  28. package/dist/bom/window.js +93 -0
  29. package/dist/bom/window.js.map +1 -0
  30. package/dist/constants/index.d.ts +59 -0
  31. package/dist/constants/index.js +62 -0
  32. package/dist/constants/index.js.map +1 -0
  33. package/dist/current.d.ts +22 -0
  34. package/dist/current.js +9 -0
  35. package/dist/current.js.map +1 -0
  36. package/dist/dom/anchor-element.js +54 -0
  37. package/dist/dom/anchor-element.js.map +1 -0
  38. package/dist/dom/class-list.d.ts +19 -0
  39. package/dist/dom/class-list.js +92 -0
  40. package/dist/dom/class-list.js.map +1 -0
  41. package/dist/dom/document.d.ts +24 -0
  42. package/dist/dom/document.js +80 -0
  43. package/dist/dom/document.js.map +1 -0
  44. package/dist/dom/element.d.ts +43 -0
  45. package/dist/dom/element.js +317 -0
  46. package/dist/dom/element.js.map +1 -0
  47. package/dist/dom/event-source.d.ts +9 -0
  48. package/dist/dom/event-source.js +17 -0
  49. package/dist/dom/event-source.js.map +1 -0
  50. package/dist/dom/event-target.d.ts +11 -0
  51. package/dist/dom/event-target.js +83 -0
  52. package/dist/dom/event-target.js.map +1 -0
  53. package/dist/dom/event.d.ts +27 -0
  54. package/dist/dom/event.js +160 -0
  55. package/dist/dom/event.js.map +1 -0
  56. package/dist/dom/form.d.ts +12 -0
  57. package/dist/dom/form.js +38 -0
  58. package/dist/dom/form.js.map +1 -0
  59. package/dist/dom/node.d.ts +79 -0
  60. package/dist/dom/node.js +301 -0
  61. package/dist/dom/node.js.map +1 -0
  62. package/dist/dom/node_types.d.ts +12 -0
  63. package/dist/dom/root.d.ts +21 -0
  64. package/dist/dom/root.js +186 -0
  65. package/dist/dom/root.js.map +1 -0
  66. package/dist/dom/style.d.ts +17 -0
  67. package/dist/dom/style.js +168 -0
  68. package/dist/dom/style.js.map +1 -0
  69. package/dist/dom/style_properties.js +187 -0
  70. package/dist/dom/style_properties.js.map +1 -0
  71. package/dist/dom/svg.d.ts +6 -0
  72. package/dist/dom/svg.js +8 -0
  73. package/dist/dom/svg.js.map +1 -0
  74. package/dist/dom/text.d.ts +17 -0
  75. package/dist/dom/text.js +41 -0
  76. package/dist/dom/text.js.map +1 -0
  77. package/dist/dom/transfer.js +15 -0
  78. package/dist/dom/transfer.js.map +1 -0
  79. package/dist/dom/tree.js +38 -0
  80. package/dist/dom/tree.js.map +1 -0
  81. package/dist/dom-external/element.js +36 -0
  82. package/dist/dom-external/element.js.map +1 -0
  83. package/dist/dom-external/index.js +39 -0
  84. package/dist/dom-external/index.js.map +1 -0
  85. package/dist/dom-external/inner-html/html.d.ts +5 -0
  86. package/dist/dom-external/inner-html/html.js +35 -0
  87. package/dist/dom-external/inner-html/html.js.map +1 -0
  88. package/dist/dom-external/inner-html/parser.d.ts +20 -0
  89. package/dist/dom-external/inner-html/parser.js +216 -0
  90. package/dist/dom-external/inner-html/parser.js.map +1 -0
  91. package/dist/dom-external/inner-html/scanner.js +304 -0
  92. package/dist/dom-external/inner-html/scanner.js.map +1 -0
  93. package/dist/dom-external/inner-html/style.js +235 -0
  94. package/dist/dom-external/inner-html/style.js.map +1 -0
  95. package/dist/dom-external/inner-html/tags.js +26 -0
  96. package/dist/dom-external/inner-html/tags.js.map +1 -0
  97. package/dist/dom-external/inner-html/utils.js +12 -0
  98. package/dist/dom-external/inner-html/utils.js.map +1 -0
  99. package/dist/dom-external/mutation-observer/implements.d.ts +55 -0
  100. package/dist/dom-external/mutation-observer/implements.js +108 -0
  101. package/dist/dom-external/mutation-observer/implements.js.map +1 -0
  102. package/dist/dom-external/mutation-observer/index.d.ts +15 -0
  103. package/dist/dom-external/mutation-observer/index.js +35 -0
  104. package/dist/dom-external/mutation-observer/index.js.map +1 -0
  105. package/dist/dom-external/mutation-observer/record.d.ts +28 -0
  106. package/dist/dom-external/node.js +75 -0
  107. package/dist/dom-external/node.js.map +1 -0
  108. package/dist/dsl/common.d.ts +17 -0
  109. package/dist/dsl/common.js +376 -0
  110. package/dist/dsl/common.js.map +1 -0
  111. package/dist/dsl/instance.d.ts +97 -0
  112. package/dist/emitter/emitter.d.ts +8 -0
  113. package/dist/emitter/emitter.js +7 -0
  114. package/dist/emitter/emitter.js.map +1 -0
  115. package/dist/env.d.ts +9 -0
  116. package/dist/env.js +9 -0
  117. package/dist/env.js.map +1 -0
  118. package/dist/hydrate.d.ts +13 -0
  119. package/dist/hydrate.js +104 -0
  120. package/dist/hydrate.js.map +1 -0
  121. package/dist/index.cjs.d.ts +921 -0
  122. package/dist/index.cjs.js +5401 -0
  123. package/dist/index.cjs.js.map +1 -0
  124. package/dist/index.d.ts +43 -0
  125. package/dist/index.js +36 -0
  126. package/dist/index.js.map +1 -0
  127. package/dist/interface/animate.d.ts +83 -0
  128. package/dist/interface/element.d.ts +6 -0
  129. package/dist/interface/event-target.d.ts +13 -0
  130. package/dist/interface/event.d.ts +16 -0
  131. package/dist/interface/hydrate.d.ts +33 -0
  132. package/dist/interface/node.d.ts +10 -0
  133. package/dist/interface/options.d.ts +19 -0
  134. package/dist/interface/utils.d.ts +4 -0
  135. package/dist/next-tick.d.ts +5 -0
  136. package/dist/next-tick.js +47 -0
  137. package/dist/next-tick.js.map +1 -0
  138. package/dist/options.d.ts +5 -0
  139. package/dist/options.js +7 -0
  140. package/dist/options.js.map +1 -0
  141. package/dist/perf.d.ts +10 -0
  142. package/dist/perf.js +49 -0
  143. package/dist/perf.js.map +1 -0
  144. package/dist/polyfill/array.js +56 -0
  145. package/dist/polyfill/array.js.map +1 -0
  146. package/dist/polyfill/index.d.ts +3 -0
  147. package/dist/polyfill/index.js +34 -0
  148. package/dist/polyfill/index.js.map +1 -0
  149. package/dist/polyfill/intersection-observer.js +597 -0
  150. package/dist/polyfill/intersection-observer.js.map +1 -0
  151. package/dist/polyfill/object.js +102 -0
  152. package/dist/polyfill/object.js.map +1 -0
  153. package/dist/runtime.esm.d.ts +921 -0
  154. package/dist/runtime.esm.js +5274 -0
  155. package/dist/runtime.esm.js.map +1 -0
  156. package/dist/utils/cache.d.ts +14 -0
  157. package/dist/utils/cache.js +27 -0
  158. package/dist/utils/cache.js.map +1 -0
  159. package/dist/utils/index.d.ts +26 -0
  160. package/dist/utils/index.js +99 -0
  161. package/dist/utils/index.js.map +1 -0
  162. package/dist/utils/lodash.d.ts +4 -0
  163. package/dist/utils/lodash.js +32 -0
  164. package/dist/utils/lodash.js.map +1 -0
  165. package/dist/utils/router.d.ts +9 -0
  166. package/dist/utils/router.js +24 -0
  167. package/dist/utils/router.js.map +1 -0
  168. package/package.json +39 -0
package/LICENSE ADDED
@@ -0,0 +1,174 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 O2Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ========================================================================
24
+
25
+ MIT (react-devtools):
26
+ The following files embed [react-devtools](https://github.com/facebook/react) MIT:
27
+ `/packages/taro-plugin-react-devtools/src/backend/index.js`
28
+ See `/LICENSE` for details of the license.
29
+
30
+ ==================
31
+
32
+ MIT (vue-devtools):
33
+ The following files embed [vue-devtools](https://github.com/vuejs/devtools) MIT:
34
+ `/packages/taro-plugin-vue-devtools/src/backend/*`
35
+ See `/LICENSE` for details of the license.
36
+
37
+ ==================
38
+
39
+ MIT (vite):
40
+ The following files embed [vite](https://github.com/vitejs/vite) MIT:
41
+ `/packages/taro-webpack5-prebundle/src/prebundle/scanImport.ts`,
42
+ `/packages/taro-webpack5-prebundle/src/prebundle/bundle.ts`,
43
+ `/packages/taro-webpack5-prebundle/src/h5.ts`,
44
+ `/packages/taro-webpack5-prebundle/src/min.ts`
45
+ See `/LICENSE` for details of the license.
46
+
47
+ ==================
48
+
49
+ MIT (webpack):
50
+ The following files embed [webpack](https://github.com/webpack/webpack) MIT:
51
+ `/packages/taro-webpack5-prebundle/src/webpack/TaroContainerEntryModule.ts`,
52
+ `/packages/taro-webpack5-prebundle/src/webpack/TaroContainerPlugin.ts`,
53
+ `/packages/taro-webpack5-prebundle/src/webpack/TaroContainerReferencePlugin.ts`,
54
+ `/packages/taro-webpack5-prebundle/src/webpack/TaroModuleFederationPlugin.ts`
55
+ See `/LICENSE` for details of the license.
56
+
57
+ ==================
58
+
59
+ MIT (sizzle):
60
+ The following files embed [sizzle](https://github.com/jquery/sizzle) MIT:
61
+ `/packages/taro-extends/src/jquery/sizzle.js`
62
+ See `/LICENSE.txt` for details of the license.
63
+
64
+ ==================
65
+
66
+ MIT (zepto):
67
+ The following files embed [zepto](https://github.com/madrobby/zepto) MIT:
68
+ `/packages/taro-extends/src/jquery/zepto.js`,
69
+ `/packages/taro-extends/src/jquery/event.js`
70
+ See `/MIT-LICENSE` for details of the license.
71
+
72
+ ==================
73
+
74
+ MIT (css-to-react-native):
75
+ The following files embed [css-to-react-native](https://github.com/styled-components/css-to-react-native) MIT:
76
+ `/packages/css-to-react-native/src/css-to-react-native/*`
77
+ See `/LICENSE.md` for details of the license.
78
+
79
+ ==================
80
+
81
+ MIT (reactify-wc):
82
+ The following files embed [reactify-wc](https://github.com/BBKolton/reactify-wc) MIT:
83
+ `/packages/taro-components-library-react/src/component-lib/reactify-wc.ts`
84
+ See `/LICENSE` for details of the license.
85
+
86
+ ==================
87
+
88
+ MIT (ant-design-mobile-rn):
89
+ The following files embed [ant-design-mobile-rn](https://github.com/ant-design/ant-design-mobile-rn) MIT:
90
+ `/packages/taro-components-rn/src/components/Swiper/carousel.tsx`
91
+ See `/LICENSE` for details of the license.
92
+
93
+ ==================
94
+
95
+ MIT (react-wx-images-viewer):
96
+ The following files embed [react-wx-images-viewer](https://github.com/react-ld/react-wx-images-viewer) MIT:
97
+ `/packages/taro-h5/src/api/media/image/previewImage.ts`
98
+ See `/LICENSE` for details of the license.
99
+
100
+ ==================
101
+
102
+ MIT (webpack-contrib/css-loader):
103
+ The following files embed [webpack-contrib/css-loader](https://github.com/webpack-contrib/css-loader) MIT:
104
+ `/packages/taro-rn-style-transformer/src/utils/index.ts`
105
+ See `/LICENSE` for details of the license.
106
+
107
+ ==================
108
+
109
+ MIT (react-native):
110
+ The following files embed [react-native](https://github.com/facebook/react-native) MIT:
111
+ `/packages/taro-rn-style-transformer/src/transforms/StyleSheet/*`
112
+ See `/LICENSE` for details of the license.
113
+
114
+ ==================
115
+
116
+ MIT (myrne/performance-now):
117
+ The following files embed [myrne/performance-now](https://github.com/myrne/performance-now) MIT:
118
+ `/packages/taro-runtime/src/bom/raf.ts`
119
+ See `/LICENSE` for details of the license.
120
+
121
+ ==================
122
+
123
+ Apache (chameleon-api):
124
+ The following files embed [chameleon-api](https://github.com/chameleon-team/chameleon-api) Apache:
125
+ `/packages/taro-h5/src/api/device/clipboard.ts`
126
+
127
+ ==================
128
+
129
+ MIT (uni-app):
130
+ The following files embed [uni-app](https://github.com/dcloudio/uni-app) MIT:
131
+ `/packages/taro-components-rn/src/components/Video/index.tsx`
132
+ See `/LICENSE` for details of the license.
133
+
134
+ ==================
135
+
136
+ MIT (miniprogram-render):
137
+ The following files embed [miniprogram-render](https://github.com/Tencent/kbone) MIT:
138
+ `/packages/taro-plugin-http/src/runtime/Cookie.ts`
139
+ See `/LICENSE` for details of the license.
140
+
141
+ ==================
142
+
143
+ MIT (stencil-ds-output-targets):
144
+ The following files embed [stencil-ds-output-targets](https://github.com/ionic-team/stencil-ds-output-targets/) MIT:
145
+ `/packages/taro-components-library-react/src/react-component-lib/utils/attachProps.ts`
146
+ `/packages/taro-components-library-react/src/react-component-lib/utils/case.ts`
147
+ `/packages/taro-components-library-react/src/react-component-lib/utils/dev.ts`
148
+ `/packages/taro-components-library-react/src/react-component-lib/utils/index.tsx`
149
+ `/packages/taro-components-library-react/src/react-component-lib/createComponent.tsx`
150
+ `/packages/taro-components-library-react/src/react-component-lib/createOverlayComponent.tsx`
151
+ `/packages/taro-components-library-react/src/react-component-lib/interfaces.ts`
152
+ `/packages/taro-components-library-vue3/src/vue-component-lib/utils.ts`
153
+ See `/LICENSE` for details of the license.
154
+
155
+ ==================
156
+
157
+ MIT (weui):
158
+ The following files embed [weui](https://github.com/Tencent/weui) MIT:
159
+ `/packages/taro-components/src/components/*.scss`
160
+ See `/LICENSE.txt` for details of the license.
161
+
162
+ ==================
163
+
164
+ Apache-2.0 (intersection-observer):
165
+ The following files embed [intersection-observer](https://github.com/GoogleChromeLabs/intersection-observer) Apache-2.0:
166
+ `/packages/taro-api/src/polyfill/intersection-observer.ts`
167
+ See `/LICENSE.txt` for details of the license.
168
+
169
+ ==================
170
+
171
+ MIT (babel-plugin-jsx-dom-expressions):
172
+ The following files embed [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions) MIT:
173
+ `/packages/babel-plugin-transform-solid-jsx/src/*`
174
+ See `/LICENSE` for details of the license.
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # vite-plugin-taro-runtime
2
+
3
+ > WX App-wrap build of `@tarojs/runtime@4.2.0` for `vite-plugin-taro`.
4
+
5
+ ## Status
6
+
7
+ This is a generated support package. It is published so `vite-plugin-taro` can use one reproducibly patched Taro runtime. Application code should not import this package directly.
8
+
9
+ Most apps should install `vite-plugin-taro` and import app-facing APIs through its virtual modules instead:
10
+
11
+ ```tsx
12
+ import { View } from 'virtual:taro/components'
13
+ import Taro from 'virtual:taro/api'
14
+ ```
15
+
16
+ ## Why this package exists
17
+
18
+ The WX renderer needs direct `page.*` paths and an opaque private Page outlet while H5 retains upstream Taro behavior. This package is produced from the upstream Taro npm tarball plus a small local patch, then published under the `vite-plugin-taro-runtime` name for reproducible installs.
19
+
20
+ ## Generated source
21
+
22
+ - Generator: [`scripts/build-patched-taro-packages.ts`](../../scripts/build-patched-taro-packages.ts)
23
+ - Patch: [`patches/@tarojs__runtime@4.2.0.patch`](../../patches/@tarojs__runtime@4.2.0.patch)
24
+ - Output package directory: [`packages/taro-runtime`](.)
25
+
26
+ Regenerate from the repository root:
27
+
28
+ ```sh
29
+ pnpm prepare:taro
30
+ ```
31
+
32
+ ## Maintenance checklist
33
+
34
+ When updating the upstream Taro version:
35
+
36
+ 1. Update `upstreamVersion` in `scripts/build-patched-taro-packages.ts`.
37
+ 2. Refresh the matching patch file in `patches/`.
38
+ 3. Update this package version in `package.json`.
39
+ 4. Update this package README.
40
+ 5. Run `pnpm prepare:taro`.
41
+ 6. Run `pnpm build:plugin`, `pnpm typecheck`, `pnpm build:loan-genius:wx`, and `pnpm build:loan-genius:h5`.
42
+
43
+ ## License
44
+
45
+ MIT. Upstream Taro is MIT licensed by O2Team. See [`LICENSE`](LICENSE).
@@ -0,0 +1,53 @@
1
+ declare class TaroURL {
2
+ #private;
3
+ static createObjectURL(): void;
4
+ static revokeObjectURL(): void;
5
+ constructor(url: string, base?: string);
6
+ get protocol(): string;
7
+ set protocol(val: string);
8
+ get host(): string;
9
+ set host(val: string);
10
+ get hostname(): string;
11
+ set hostname(val: string);
12
+ get port(): string;
13
+ set port(val: string);
14
+ get pathname(): string;
15
+ set pathname(val: string);
16
+ get search(): string;
17
+ set search(val: string);
18
+ get hash(): string;
19
+ set hash(val: string);
20
+ get href(): string;
21
+ set href(val: string);
22
+ get origin(): string;
23
+ set origin(val: string);
24
+ get searchParams(): URLSearchParams;
25
+ toString(): string;
26
+ toJSON(): string;
27
+ _toRaw(): {
28
+ protocol: string;
29
+ port: string;
30
+ host: string;
31
+ hostname: string;
32
+ pathname: string;
33
+ hash: string;
34
+ search: string;
35
+ origin: string;
36
+ href: string;
37
+ };
38
+ }
39
+
40
+ declare const TaroURLProvider: typeof TaroURL;
41
+ declare function parseUrl(url?: string): {
42
+ href: string;
43
+ origin: string;
44
+ protocol: string;
45
+ hostname: string;
46
+ host: string;
47
+ port: string;
48
+ pathname: string;
49
+ search: string;
50
+ hash: string;
51
+ };
52
+
53
+ export { TaroURL, TaroURLProvider, parseUrl };
@@ -0,0 +1,222 @@
1
+ import { __classPrivateFieldSet, __classPrivateFieldGet } from 'tslib';
2
+ import { isString, isUndefined } from '@tarojs/shared';
3
+ import env from '../env.js';
4
+ import { URLSearchParams } from './URLSearchParams.js';
5
+
6
+ var _TaroURL_hash, _TaroURL_hostname, _TaroURL_pathname, _TaroURL_port, _TaroURL_protocol, _TaroURL_search;
7
+ class TaroURL {
8
+ static createObjectURL() {
9
+ throw new Error('Oops, not support URL.createObjectURL() in miniprogram.');
10
+ }
11
+ static revokeObjectURL() {
12
+ throw new Error('Oops, not support URL.revokeObjectURL() in miniprogram.');
13
+ }
14
+ constructor(url, base) {
15
+ /* private property */
16
+ _TaroURL_hash.set(this, '');
17
+ _TaroURL_hostname.set(this, '');
18
+ _TaroURL_pathname.set(this, '');
19
+ _TaroURL_port.set(this, '');
20
+ _TaroURL_protocol.set(this, '');
21
+ _TaroURL_search.set(this, void 0);
22
+ if (!isString(url))
23
+ url = String(url);
24
+ const parseResult = parseUrlBase(url, base);
25
+ const { hash, hostname, pathname, port, protocol, search } = parseResult;
26
+ __classPrivateFieldSet(this, _TaroURL_hash, hash, "f");
27
+ __classPrivateFieldSet(this, _TaroURL_hostname, hostname, "f");
28
+ __classPrivateFieldSet(this, _TaroURL_pathname, pathname || '/', "f");
29
+ __classPrivateFieldSet(this, _TaroURL_port, port, "f");
30
+ __classPrivateFieldSet(this, _TaroURL_protocol, protocol, "f");
31
+ __classPrivateFieldSet(this, _TaroURL_search, new URLSearchParams(search), "f");
32
+ }
33
+ /* public property */
34
+ get protocol() {
35
+ return __classPrivateFieldGet(this, _TaroURL_protocol, "f");
36
+ }
37
+ set protocol(val) {
38
+ isString(val) && (__classPrivateFieldSet(this, _TaroURL_protocol, val.trim(), "f"));
39
+ }
40
+ get host() {
41
+ return this.hostname + (this.port ? ':' + this.port : '');
42
+ }
43
+ set host(val) {
44
+ if (val && isString(val)) {
45
+ val = val.trim();
46
+ const { hostname, port } = parseUrl(`//${val}`);
47
+ this.hostname = hostname;
48
+ this.port = port;
49
+ }
50
+ }
51
+ get hostname() {
52
+ return __classPrivateFieldGet(this, _TaroURL_hostname, "f");
53
+ }
54
+ set hostname(val) {
55
+ val && isString(val) && (__classPrivateFieldSet(this, _TaroURL_hostname, val.trim(), "f"));
56
+ }
57
+ get port() {
58
+ return __classPrivateFieldGet(this, _TaroURL_port, "f");
59
+ }
60
+ set port(val) {
61
+ isString(val) && (__classPrivateFieldSet(this, _TaroURL_port, val.trim(), "f"));
62
+ }
63
+ get pathname() {
64
+ return __classPrivateFieldGet(this, _TaroURL_pathname, "f");
65
+ }
66
+ set pathname(val) {
67
+ if (isString(val)) {
68
+ val = val.trim();
69
+ const HEAD_REG = /^(\/|\.\/|\.\.\/)/;
70
+ let temp = val;
71
+ while (HEAD_REG.test(temp)) {
72
+ temp = temp.replace(HEAD_REG, '');
73
+ }
74
+ if (temp)
75
+ __classPrivateFieldSet(this, _TaroURL_pathname, '/' + temp, "f");
76
+ else
77
+ __classPrivateFieldSet(this, _TaroURL_pathname, '/', "f");
78
+ }
79
+ }
80
+ get search() {
81
+ const val = __classPrivateFieldGet(this, _TaroURL_search, "f").toString();
82
+ return (val.length === 0 || val.startsWith('?')) ? val : `?${val}`;
83
+ }
84
+ set search(val) {
85
+ if (isString(val)) {
86
+ val = val.trim();
87
+ __classPrivateFieldSet(this, _TaroURL_search, new URLSearchParams(val), "f");
88
+ }
89
+ }
90
+ get hash() {
91
+ return __classPrivateFieldGet(this, _TaroURL_hash, "f");
92
+ }
93
+ set hash(val) {
94
+ if (isString(val)) {
95
+ val = val.trim();
96
+ if (val)
97
+ __classPrivateFieldSet(this, _TaroURL_hash, val.startsWith('#') ? val : `#${val}`, "f");
98
+ else
99
+ __classPrivateFieldSet(this, _TaroURL_hash, '', "f");
100
+ }
101
+ }
102
+ get href() {
103
+ return `${this.protocol}//${this.host}${this.pathname}${this.search}${this.hash}`;
104
+ }
105
+ set href(val) {
106
+ if (val && isString(val)) {
107
+ val = val.trim();
108
+ const { protocol, hostname, port, hash, search, pathname } = parseUrl(val);
109
+ this.protocol = protocol;
110
+ this.hostname = hostname;
111
+ this.pathname = pathname;
112
+ this.port = port;
113
+ this.hash = hash;
114
+ this.search = search;
115
+ }
116
+ }
117
+ get origin() {
118
+ return `${this.protocol}//${this.host}`;
119
+ }
120
+ set origin(val) {
121
+ if (val && isString(val)) {
122
+ val = val.trim();
123
+ const { protocol, hostname, port } = parseUrl(val);
124
+ this.protocol = protocol;
125
+ this.hostname = hostname;
126
+ this.port = port;
127
+ }
128
+ }
129
+ get searchParams() {
130
+ return __classPrivateFieldGet(this, _TaroURL_search, "f");
131
+ }
132
+ // public method
133
+ toString() {
134
+ return this.href;
135
+ }
136
+ toJSON() {
137
+ return this.toString();
138
+ }
139
+ // convenient for deconstructor
140
+ _toRaw() {
141
+ return {
142
+ protocol: this.protocol,
143
+ port: this.port,
144
+ host: this.host,
145
+ hostname: this.hostname,
146
+ pathname: this.pathname,
147
+ hash: this.hash,
148
+ search: this.search,
149
+ origin: this.origin,
150
+ href: this.href,
151
+ };
152
+ }
153
+ }
154
+ _TaroURL_hash = new WeakMap(), _TaroURL_hostname = new WeakMap(), _TaroURL_pathname = new WeakMap(), _TaroURL_port = new WeakMap(), _TaroURL_protocol = new WeakMap(), _TaroURL_search = new WeakMap();
155
+ // Note: 小程序端 vite 打包成 commonjs,const URL = xxx 会报错,所以把 URL 改为 TaroURLProvider
156
+ const TaroURLProvider = process.env.TARO_PLATFORM === 'web' ? env.window.URL : TaroURL;
157
+ function parseUrl(url = '') {
158
+ const result = {
159
+ href: '',
160
+ origin: '',
161
+ protocol: '',
162
+ hostname: '',
163
+ host: '',
164
+ port: '',
165
+ pathname: '',
166
+ search: '',
167
+ hash: ''
168
+ };
169
+ if (!url || !isString(url))
170
+ return result;
171
+ url = url.trim();
172
+ const PATTERN = /^(([^:/?#]+):)?\/\/(([^/?#]+):(.+)@)?([^/?#:]*)(:(\d+))?([^?#]*)(\?([^#]*))?(#(.*))?/;
173
+ const matches = url.match(PATTERN);
174
+ if (!matches)
175
+ return result;
176
+ // TODO: username & password ?
177
+ result.protocol = matches[1] || 'https:';
178
+ result.hostname = matches[6] || 'taro.com';
179
+ result.port = matches[8] || '';
180
+ result.pathname = matches[9] || '/';
181
+ result.search = matches[10] || '';
182
+ result.hash = matches[12] || '';
183
+ result.href = url;
184
+ result.origin = result.protocol + '//' + result.hostname + (result.port ? `:${result.port}` : '');
185
+ result.host = result.hostname + (result.port ? `:${result.port}` : '');
186
+ return result;
187
+ }
188
+ function parseUrlBase(url, base) {
189
+ const VALID_URL = /^(https?:)\/\//i;
190
+ let fullUrl = '';
191
+ let parsedBase = null;
192
+ if (!isUndefined(base)) {
193
+ base = String(base).trim();
194
+ if (!VALID_URL.test(base))
195
+ throw new TypeError(`Failed to construct 'URL': Invalid base URL`);
196
+ parsedBase = parseUrl(base);
197
+ }
198
+ url = String(url).trim();
199
+ if (VALID_URL.test(url)) {
200
+ fullUrl = url;
201
+ }
202
+ else if (parsedBase) {
203
+ if (url) {
204
+ if (url.startsWith('//')) {
205
+ fullUrl = parsedBase.protocol + url;
206
+ }
207
+ else {
208
+ fullUrl = parsedBase.origin + (url.startsWith('/') ? url : `/${url}`);
209
+ }
210
+ }
211
+ else {
212
+ fullUrl = parsedBase.href;
213
+ }
214
+ }
215
+ else {
216
+ throw new TypeError(`Failed to construct 'URL': Invalid URL`);
217
+ }
218
+ return parseUrl(fullUrl);
219
+ }
220
+
221
+ export { TaroURLProvider, parseUrl };
222
+ //# sourceMappingURL=URL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"URL.js","sources":["../../../src/bom/URL.ts"],"sourcesContent":["import { isString, isUndefined } from '@tarojs/shared'\n\nimport env from '../env'\nimport { URLSearchParams } from './URLSearchParams'\n\nclass TaroURL {\n static createObjectURL () {\n throw new Error('Oops, not support URL.createObjectURL() in miniprogram.')\n }\n\n static revokeObjectURL () {\n throw new Error('Oops, not support URL.revokeObjectURL() in miniprogram.')\n }\n\n /* private property */\n #hash = ''\n #hostname = ''\n #pathname = ''\n #port = ''\n #protocol = ''\n #search: URLSearchParams\n\n constructor (url: string, base?: string) {\n if (!isString(url)) url = String(url)\n\n const parseResult = parseUrlBase(url, base)\n const { hash, hostname, pathname, port, protocol, search } = parseResult\n\n this.#hash = hash\n this.#hostname = hostname\n this.#pathname = pathname || '/'\n this.#port = port\n this.#protocol = protocol\n this.#search = new URLSearchParams(search)\n }\n\n /* public property */\n get protocol () {\n return this.#protocol\n }\n\n set protocol (val: string) {\n isString(val) && (this.#protocol = val.trim())\n }\n\n get host () {\n return this.hostname + (this.port ? ':' + this.port : '')\n }\n\n set host (val: string) {\n if (val && isString(val)) {\n val = val.trim()\n const { hostname, port } = parseUrl(`//${val}`)\n this.hostname = hostname\n this.port = port\n }\n }\n\n get hostname () {\n return this.#hostname\n }\n\n set hostname (val: string) {\n val && isString(val) && (this.#hostname = val.trim())\n }\n\n get port () {\n return this.#port\n }\n\n set port (val: string) {\n isString(val) && (this.#port = val.trim())\n }\n\n get pathname () {\n return this.#pathname\n }\n\n set pathname (val: string) {\n if (isString(val)) {\n val = val.trim()\n const HEAD_REG = /^(\\/|\\.\\/|\\.\\.\\/)/\n let temp = val\n while (HEAD_REG.test(temp)) {\n temp = temp.replace(HEAD_REG, '')\n }\n if (temp) this.#pathname = '/' + temp\n else this.#pathname = '/'\n }\n }\n\n get search () {\n const val = this.#search.toString()\n return (val.length === 0 || val.startsWith('?')) ? val : `?${val}`\n }\n\n set search (val: string) {\n if (isString(val)) {\n val = val.trim()\n this.#search = new URLSearchParams(val)\n }\n }\n\n get hash () {\n return this.#hash\n }\n\n set hash (val: string) {\n if (isString(val)) {\n val = val.trim()\n if (val) this.#hash = val.startsWith('#') ? val : `#${val}`\n else this.#hash = ''\n }\n }\n\n get href () {\n return `${this.protocol}//${this.host}${this.pathname}${this.search}${this.hash}`\n }\n\n set href (val: string) {\n if (val && isString(val)) {\n val = val.trim()\n const { protocol, hostname, port, hash, search, pathname } = parseUrl(val)\n this.protocol = protocol\n this.hostname = hostname\n this.pathname = pathname\n this.port = port\n this.hash = hash\n this.search = search\n }\n }\n\n get origin () {\n return `${this.protocol}//${this.host}`\n }\n\n set origin (val: string) {\n if (val && isString(val)) {\n val = val.trim()\n const { protocol, hostname, port } = parseUrl(val)\n this.protocol = protocol\n this.hostname = hostname\n this.port = port\n }\n }\n\n get searchParams () {\n return this.#search\n }\n\n // public method\n toString () {\n return this.href\n }\n\n toJSON () {\n return this.toString()\n }\n\n // convenient for deconstructor\n _toRaw () {\n return {\n protocol: this.protocol,\n port: this.port,\n host: this.host,\n hostname: this.hostname,\n pathname: this.pathname,\n hash: this.hash,\n search: this.search,\n origin: this.origin,\n href: this.href,\n }\n }\n}\n\nexport type { TaroURL }\n\n// Note: 小程序端 vite 打包成 commonjs,const URL = xxx 会报错,所以把 URL 改为 TaroURLProvider\nexport const TaroURLProvider: typeof TaroURL = process.env.TARO_PLATFORM === 'web' ? env.window.URL : TaroURL\n\nexport function parseUrl (url = '') {\n const result = {\n href: '',\n origin: '',\n protocol: '',\n hostname: '',\n host: '',\n port: '',\n pathname: '',\n search: '',\n hash: ''\n }\n if (!url || !isString(url)) return result\n\n url = url.trim()\n const PATTERN = /^(([^:/?#]+):)?\\/\\/(([^/?#]+):(.+)@)?([^/?#:]*)(:(\\d+))?([^?#]*)(\\?([^#]*))?(#(.*))?/\n const matches = url.match(PATTERN)\n\n if (!matches) return result\n\n // TODO: username & password ?\n result.protocol = matches[1] || 'https:'\n result.hostname = matches[6] || 'taro.com'\n result.port = matches[8] || ''\n result.pathname = matches[9] || '/'\n result.search = matches[10] || ''\n result.hash = matches[12] || ''\n result.href = url\n result.origin = result.protocol + '//' + result.hostname + (result.port ? `:${result.port}` : '')\n result.host = result.hostname + (result.port ? `:${result.port}` : '')\n\n return result\n}\n\nfunction parseUrlBase (url: string, base?: string) {\n const VALID_URL = /^(https?:)\\/\\//i\n\n let fullUrl = ''\n let parsedBase: ReturnType<typeof parseUrl> | null = null\n\n if (!isUndefined(base)) {\n base = String(base).trim()\n if (!VALID_URL.test(base)) throw new TypeError(`Failed to construct 'URL': Invalid base URL`)\n parsedBase = parseUrl(base)\n }\n\n url = String(url).trim()\n\n if (VALID_URL.test(url)) {\n fullUrl = url\n } else if (parsedBase) {\n if (url) {\n if (url.startsWith('//')) {\n fullUrl = parsedBase.protocol + url\n } else {\n fullUrl = parsedBase.origin + (url.startsWith('/') ? url : `/${url}`)\n }\n } else {\n fullUrl = parsedBase.href\n }\n } else {\n throw new TypeError(`Failed to construct 'URL': Invalid URL`)\n }\n\n return parseUrl(fullUrl)\n}\n"],"names":[],"mappings":";;;;;;AAKA,MAAM,OAAO,CAAA;AACX,IAAA,OAAO,eAAe,GAAA;AACpB,QAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;;AAG5E,IAAA,OAAO,eAAe,GAAA;AACpB,QAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;;IAW5E,WAAa,CAAA,GAAW,EAAE,IAAa,EAAA;;AAPvC,QAAA,aAAA,CAAA,GAAA,CAAA,IAAA,EAAQ,EAAE,CAAA;AACV,QAAA,iBAAA,CAAA,GAAA,CAAA,IAAA,EAAY,EAAE,CAAA;AACd,QAAA,iBAAA,CAAA,GAAA,CAAA,IAAA,EAAY,EAAE,CAAA;AACd,QAAA,aAAA,CAAA,GAAA,CAAA,IAAA,EAAQ,EAAE,CAAA;AACV,QAAA,iBAAA,CAAA,GAAA,CAAA,IAAA,EAAY,EAAE,CAAA;QACd,eAAwB,CAAA,GAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AAGtB,QAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;AAAE,YAAA,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QAErC,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC;AAC3C,QAAA,MAAM,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AC,EAAE;AACxB,gBAAA,OAAO,GAAG,UAAU,CAAC,QAAQ,GAAG,GAAG;;iBAC9B;gBACL,OAAO,GAAG,UAAU,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAI,CAAA,EAAA,GAAG,CAAE,CAAA,CAAC;;;aAElE;AACL,YAAA,OAAO,GAAG,UAAU,CAAC,IAAI;;;SAEtB;AACL,QAAA,MAAM,IAAI,SAAS,CAAC,CAAA,sCAAA,CAAwC,CAAC;;AAG/D,IAAA,OAAO,QAAQ,CAAC,OAAO,CAAC;AAC1B;;;;"}
@@ -0,0 +1,3 @@
1
+ declare const URLSearchParams: any;
2
+
3
+ export { URLSearchParams };
@@ -0,0 +1,131 @@
1
+ import { __classPrivateFieldGet } from 'tslib';
2
+ import { isArray } from '@tarojs/shared';
3
+ import env from '../env.js';
4
+
5
+ var _dict, _a;
6
+ const findReg = /[!'()~]|%20|%00/g;
7
+ const plusReg = /\+/g;
8
+ const replaceCharMap = {
9
+ '!': '%21',
10
+ "'": '%27',
11
+ '(': '%28',
12
+ ')': '%29',
13
+ '~': '%7E',
14
+ '%20': '+',
15
+ '%00': '\x00',
16
+ };
17
+ function replacer(match) {
18
+ return replaceCharMap[match];
19
+ }
20
+ function appendTo(dict, name, value) {
21
+ const res = isArray(value) ? value.join(',') : value;
22
+ if (name in dict)
23
+ dict[name].push(res);
24
+ else
25
+ dict[name] = [res];
26
+ }
27
+ function addEach(value, key) {
28
+ appendTo(this, key, value);
29
+ }
30
+ function decode(str) {
31
+ return decodeURIComponent(str.replace(plusReg, ' '));
32
+ }
33
+ function encode(str) {
34
+ return encodeURIComponent(str).replace(findReg, replacer);
35
+ }
36
+ const URLSearchParams = process.env.TARO_PLATFORM === 'web' ? env.window.URLSearchParams : (_a = class {
37
+ constructor(query) {
38
+ _dict.set(this, Object.create(null));
39
+ query !== null && query !== void 0 ? query : (query = '');
40
+ const dict = __classPrivateFieldGet(this, _dict, "f");
41
+ if (typeof query === 'string') {
42
+ if (query.charAt(0) === '?') {
43
+ query = query.slice(1);
44
+ }
45
+ for (let pairs = query.split('&'), i = 0, length = pairs.length; i < length; i++) {
46
+ const value = pairs[i];
47
+ const index = value.indexOf('=');
48
+ // 针对不规范的 url 参数做容错处理,如:word=你%好
49
+ try {
50
+ if (index > -1) {
51
+ appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
52
+ }
53
+ else if (value.length) {
54
+ appendTo(dict, decode(value), '');
55
+ }
56
+ }
57
+ catch (err) {
58
+ if (process.env.NODE_ENV !== 'production') {
59
+ console.warn(`[Taro warn] URL 参数 ${value} decode 异常`);
60
+ }
61
+ }
62
+ }
63
+ }
64
+ else {
65
+ if (isArray(query)) {
66
+ for (let i = 0, length = query.length; i < length; i++) {
67
+ const value = query[i];
68
+ appendTo(dict, value[0], value[1]);
69
+ }
70
+ }
71
+ else if (query.forEach) {
72
+ query.forEach(addEach, dict);
73
+ }
74
+ else {
75
+ for (const key in query) {
76
+ appendTo(dict, key, query[key]);
77
+ }
78
+ }
79
+ }
80
+ }
81
+ append(name, value) {
82
+ appendTo(__classPrivateFieldGet(this, _dict, "f"), name, value);
83
+ }
84
+ delete(name) {
85
+ delete __classPrivateFieldGet(this, _dict, "f")[name];
86
+ }
87
+ get(name) {
88
+ const dict = __classPrivateFieldGet(this, _dict, "f");
89
+ return name in dict ? dict[name][0] : null;
90
+ }
91
+ getAll(name) {
92
+ const dict = __classPrivateFieldGet(this, _dict, "f");
93
+ return name in dict ? dict[name].slice(0) : [];
94
+ }
95
+ has(name) {
96
+ return name in __classPrivateFieldGet(this, _dict, "f");
97
+ }
98
+ keys() {
99
+ return Object.keys(__classPrivateFieldGet(this, _dict, "f"));
100
+ }
101
+ set(name, value) {
102
+ __classPrivateFieldGet(this, _dict, "f")[name] = ['' + value];
103
+ }
104
+ forEach(callback, thisArg) {
105
+ const dict = __classPrivateFieldGet(this, _dict, "f");
106
+ Object.getOwnPropertyNames(dict).forEach(function (name) {
107
+ dict[name].forEach(function (value) {
108
+ callback.call(thisArg, value, name, this);
109
+ }, this);
110
+ }, this);
111
+ }
112
+ toJSON() {
113
+ return {};
114
+ }
115
+ toString() {
116
+ const dict = __classPrivateFieldGet(this, _dict, "f");
117
+ const query = [];
118
+ for (const key in dict) {
119
+ const name = encode(key);
120
+ for (let i = 0, value = dict[key]; i < value.length; i++) {
121
+ query.push(name + '=' + encode(value[i]));
122
+ }
123
+ }
124
+ return query.join('&');
125
+ }
126
+ },
127
+ _dict = new WeakMap(),
128
+ _a);
129
+
130
+ export { URLSearchParams };
131
+ //# sourceMappingURL=URLSearchParams.js.map