create-microact-app 1.0.1

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 (213) hide show
  1. package/index.js +95 -0
  2. package/package.json +21 -0
  3. package/templates/vanilla/.github/workflows/deploy.yml +38 -0
  4. package/templates/vanilla/index.html +13 -0
  5. package/templates/vanilla/node_modules/.package-lock.json +207 -0
  6. package/templates/vanilla/node_modules/@esbuild/darwin-x64/README.md +3 -0
  7. package/templates/vanilla/node_modules/@esbuild/darwin-x64/bin/esbuild +0 -0
  8. package/templates/vanilla/node_modules/@esbuild/darwin-x64/package.json +17 -0
  9. package/templates/vanilla/node_modules/@monygroupcorp/microact/README.md +154 -0
  10. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.cjs.js +1749 -0
  11. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.cjs.js.map +1 -0
  12. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.esm.js +1743 -0
  13. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.esm.js.map +1 -0
  14. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.umd.js +2 -0
  15. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.umd.js.map +1 -0
  16. package/templates/vanilla/node_modules/@monygroupcorp/microact/example/index.html +13 -0
  17. package/templates/vanilla/node_modules/@monygroupcorp/microact/example/index.js +63 -0
  18. package/templates/vanilla/node_modules/@monygroupcorp/microact/package.json +38 -0
  19. package/templates/vanilla/node_modules/@monygroupcorp/microact/rollup.config.cjs +30 -0
  20. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/Component.js +831 -0
  21. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/DOMUpdater.js +320 -0
  22. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/EventBus.js +123 -0
  23. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/Router.js +253 -0
  24. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/UpdateScheduler.js +218 -0
  25. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/index.js +6 -0
  26. package/templates/vanilla/node_modules/esbuild/LICENSE.md +21 -0
  27. package/templates/vanilla/node_modules/esbuild/README.md +3 -0
  28. package/templates/vanilla/node_modules/esbuild/bin/esbuild +0 -0
  29. package/templates/vanilla/node_modules/esbuild/install.js +287 -0
  30. package/templates/vanilla/node_modules/esbuild/lib/main.d.ts +660 -0
  31. package/templates/vanilla/node_modules/esbuild/lib/main.js +2393 -0
  32. package/templates/vanilla/node_modules/esbuild/package.json +42 -0
  33. package/templates/vanilla/node_modules/nanoid/LICENSE +20 -0
  34. package/templates/vanilla/node_modules/nanoid/README.md +39 -0
  35. package/templates/vanilla/node_modules/nanoid/async/index.browser.cjs +69 -0
  36. package/templates/vanilla/node_modules/nanoid/async/index.browser.js +34 -0
  37. package/templates/vanilla/node_modules/nanoid/async/index.cjs +71 -0
  38. package/templates/vanilla/node_modules/nanoid/async/index.d.ts +56 -0
  39. package/templates/vanilla/node_modules/nanoid/async/index.js +35 -0
  40. package/templates/vanilla/node_modules/nanoid/async/index.native.js +26 -0
  41. package/templates/vanilla/node_modules/nanoid/async/package.json +12 -0
  42. package/templates/vanilla/node_modules/nanoid/bin/nanoid.cjs +55 -0
  43. package/templates/vanilla/node_modules/nanoid/index.browser.cjs +72 -0
  44. package/templates/vanilla/node_modules/nanoid/index.browser.js +34 -0
  45. package/templates/vanilla/node_modules/nanoid/index.cjs +85 -0
  46. package/templates/vanilla/node_modules/nanoid/index.d.cts +91 -0
  47. package/templates/vanilla/node_modules/nanoid/index.d.ts +91 -0
  48. package/templates/vanilla/node_modules/nanoid/index.js +45 -0
  49. package/templates/vanilla/node_modules/nanoid/nanoid.js +1 -0
  50. package/templates/vanilla/node_modules/nanoid/non-secure/index.cjs +34 -0
  51. package/templates/vanilla/node_modules/nanoid/non-secure/index.d.ts +33 -0
  52. package/templates/vanilla/node_modules/nanoid/non-secure/index.js +21 -0
  53. package/templates/vanilla/node_modules/nanoid/non-secure/package.json +6 -0
  54. package/templates/vanilla/node_modules/nanoid/package.json +89 -0
  55. package/templates/vanilla/node_modules/nanoid/url-alphabet/index.cjs +7 -0
  56. package/templates/vanilla/node_modules/nanoid/url-alphabet/index.js +3 -0
  57. package/templates/vanilla/node_modules/nanoid/url-alphabet/package.json +6 -0
  58. package/templates/vanilla/node_modules/picocolors/LICENSE +15 -0
  59. package/templates/vanilla/node_modules/picocolors/README.md +21 -0
  60. package/templates/vanilla/node_modules/picocolors/package.json +25 -0
  61. package/templates/vanilla/node_modules/picocolors/picocolors.browser.js +4 -0
  62. package/templates/vanilla/node_modules/picocolors/picocolors.d.ts +5 -0
  63. package/templates/vanilla/node_modules/picocolors/picocolors.js +75 -0
  64. package/templates/vanilla/node_modules/picocolors/types.d.ts +51 -0
  65. package/templates/vanilla/node_modules/postcss/LICENSE +20 -0
  66. package/templates/vanilla/node_modules/postcss/README.md +29 -0
  67. package/templates/vanilla/node_modules/postcss/lib/at-rule.d.ts +140 -0
  68. package/templates/vanilla/node_modules/postcss/lib/at-rule.js +25 -0
  69. package/templates/vanilla/node_modules/postcss/lib/comment.d.ts +68 -0
  70. package/templates/vanilla/node_modules/postcss/lib/comment.js +13 -0
  71. package/templates/vanilla/node_modules/postcss/lib/container.d.ts +483 -0
  72. package/templates/vanilla/node_modules/postcss/lib/container.js +447 -0
  73. package/templates/vanilla/node_modules/postcss/lib/css-syntax-error.d.ts +248 -0
  74. package/templates/vanilla/node_modules/postcss/lib/css-syntax-error.js +133 -0
  75. package/templates/vanilla/node_modules/postcss/lib/declaration.d.ts +151 -0
  76. package/templates/vanilla/node_modules/postcss/lib/declaration.js +24 -0
  77. package/templates/vanilla/node_modules/postcss/lib/document.d.ts +69 -0
  78. package/templates/vanilla/node_modules/postcss/lib/document.js +33 -0
  79. package/templates/vanilla/node_modules/postcss/lib/fromJSON.d.ts +9 -0
  80. package/templates/vanilla/node_modules/postcss/lib/fromJSON.js +54 -0
  81. package/templates/vanilla/node_modules/postcss/lib/input.d.ts +227 -0
  82. package/templates/vanilla/node_modules/postcss/lib/input.js +265 -0
  83. package/templates/vanilla/node_modules/postcss/lib/lazy-result.d.ts +190 -0
  84. package/templates/vanilla/node_modules/postcss/lib/lazy-result.js +550 -0
  85. package/templates/vanilla/node_modules/postcss/lib/list.d.ts +60 -0
  86. package/templates/vanilla/node_modules/postcss/lib/list.js +58 -0
  87. package/templates/vanilla/node_modules/postcss/lib/map-generator.js +368 -0
  88. package/templates/vanilla/node_modules/postcss/lib/no-work-result.d.ts +46 -0
  89. package/templates/vanilla/node_modules/postcss/lib/no-work-result.js +138 -0
  90. package/templates/vanilla/node_modules/postcss/lib/node.d.ts +556 -0
  91. package/templates/vanilla/node_modules/postcss/lib/node.js +449 -0
  92. package/templates/vanilla/node_modules/postcss/lib/parse.d.ts +9 -0
  93. package/templates/vanilla/node_modules/postcss/lib/parse.js +42 -0
  94. package/templates/vanilla/node_modules/postcss/lib/parser.js +611 -0
  95. package/templates/vanilla/node_modules/postcss/lib/postcss.d.mts +69 -0
  96. package/templates/vanilla/node_modules/postcss/lib/postcss.d.ts +458 -0
  97. package/templates/vanilla/node_modules/postcss/lib/postcss.js +101 -0
  98. package/templates/vanilla/node_modules/postcss/lib/postcss.mjs +30 -0
  99. package/templates/vanilla/node_modules/postcss/lib/previous-map.d.ts +81 -0
  100. package/templates/vanilla/node_modules/postcss/lib/previous-map.js +144 -0
  101. package/templates/vanilla/node_modules/postcss/lib/processor.d.ts +115 -0
  102. package/templates/vanilla/node_modules/postcss/lib/processor.js +67 -0
  103. package/templates/vanilla/node_modules/postcss/lib/result.d.ts +205 -0
  104. package/templates/vanilla/node_modules/postcss/lib/result.js +42 -0
  105. package/templates/vanilla/node_modules/postcss/lib/root.d.ts +87 -0
  106. package/templates/vanilla/node_modules/postcss/lib/root.js +61 -0
  107. package/templates/vanilla/node_modules/postcss/lib/rule.d.ts +126 -0
  108. package/templates/vanilla/node_modules/postcss/lib/rule.js +27 -0
  109. package/templates/vanilla/node_modules/postcss/lib/stringifier.d.ts +46 -0
  110. package/templates/vanilla/node_modules/postcss/lib/stringifier.js +353 -0
  111. package/templates/vanilla/node_modules/postcss/lib/stringify.d.ts +9 -0
  112. package/templates/vanilla/node_modules/postcss/lib/stringify.js +11 -0
  113. package/templates/vanilla/node_modules/postcss/lib/symbols.js +5 -0
  114. package/templates/vanilla/node_modules/postcss/lib/terminal-highlight.js +70 -0
  115. package/templates/vanilla/node_modules/postcss/lib/tokenize.js +266 -0
  116. package/templates/vanilla/node_modules/postcss/lib/warn-once.js +13 -0
  117. package/templates/vanilla/node_modules/postcss/lib/warning.d.ts +147 -0
  118. package/templates/vanilla/node_modules/postcss/lib/warning.js +37 -0
  119. package/templates/vanilla/node_modules/postcss/package.json +88 -0
  120. package/templates/vanilla/node_modules/rollup/LICENSE.md +695 -0
  121. package/templates/vanilla/node_modules/rollup/README.md +125 -0
  122. package/templates/vanilla/node_modules/rollup/dist/bin/rollup +1715 -0
  123. package/templates/vanilla/node_modules/rollup/dist/es/getLogFilter.js +64 -0
  124. package/templates/vanilla/node_modules/rollup/dist/es/package.json +1 -0
  125. package/templates/vanilla/node_modules/rollup/dist/es/rollup.js +17 -0
  126. package/templates/vanilla/node_modules/rollup/dist/es/shared/node-entry.js +27273 -0
  127. package/templates/vanilla/node_modules/rollup/dist/es/shared/watch.js +4857 -0
  128. package/templates/vanilla/node_modules/rollup/dist/getLogFilter.d.ts +5 -0
  129. package/templates/vanilla/node_modules/rollup/dist/getLogFilter.js +69 -0
  130. package/templates/vanilla/node_modules/rollup/dist/loadConfigFile.d.ts +20 -0
  131. package/templates/vanilla/node_modules/rollup/dist/loadConfigFile.js +29 -0
  132. package/templates/vanilla/node_modules/rollup/dist/rollup.d.ts +1012 -0
  133. package/templates/vanilla/node_modules/rollup/dist/rollup.js +31 -0
  134. package/templates/vanilla/node_modules/rollup/dist/shared/fsevents-importer.js +37 -0
  135. package/templates/vanilla/node_modules/rollup/dist/shared/index.js +4571 -0
  136. package/templates/vanilla/node_modules/rollup/dist/shared/loadConfigFile.js +546 -0
  137. package/templates/vanilla/node_modules/rollup/dist/shared/rollup.js +27351 -0
  138. package/templates/vanilla/node_modules/rollup/dist/shared/watch-cli.js +561 -0
  139. package/templates/vanilla/node_modules/rollup/dist/shared/watch-proxy.js +87 -0
  140. package/templates/vanilla/node_modules/rollup/dist/shared/watch.js +316 -0
  141. package/templates/vanilla/node_modules/rollup/package.json +181 -0
  142. package/templates/vanilla/node_modules/source-map-js/LICENSE +28 -0
  143. package/templates/vanilla/node_modules/source-map-js/README.md +765 -0
  144. package/templates/vanilla/node_modules/source-map-js/lib/array-set.js +121 -0
  145. package/templates/vanilla/node_modules/source-map-js/lib/base64-vlq.js +140 -0
  146. package/templates/vanilla/node_modules/source-map-js/lib/base64.js +67 -0
  147. package/templates/vanilla/node_modules/source-map-js/lib/binary-search.js +111 -0
  148. package/templates/vanilla/node_modules/source-map-js/lib/mapping-list.js +79 -0
  149. package/templates/vanilla/node_modules/source-map-js/lib/quick-sort.js +132 -0
  150. package/templates/vanilla/node_modules/source-map-js/lib/source-map-consumer.d.ts +1 -0
  151. package/templates/vanilla/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
  152. package/templates/vanilla/node_modules/source-map-js/lib/source-map-generator.d.ts +1 -0
  153. package/templates/vanilla/node_modules/source-map-js/lib/source-map-generator.js +444 -0
  154. package/templates/vanilla/node_modules/source-map-js/lib/source-node.d.ts +1 -0
  155. package/templates/vanilla/node_modules/source-map-js/lib/source-node.js +413 -0
  156. package/templates/vanilla/node_modules/source-map-js/lib/util.js +594 -0
  157. package/templates/vanilla/node_modules/source-map-js/package.json +71 -0
  158. package/templates/vanilla/node_modules/source-map-js/source-map.d.ts +104 -0
  159. package/templates/vanilla/node_modules/source-map-js/source-map.js +8 -0
  160. package/templates/vanilla/node_modules/vite/LICENSE.md +3396 -0
  161. package/templates/vanilla/node_modules/vite/README.md +20 -0
  162. package/templates/vanilla/node_modules/vite/bin/openChrome.applescript +95 -0
  163. package/templates/vanilla/node_modules/vite/bin/vite.js +61 -0
  164. package/templates/vanilla/node_modules/vite/client.d.ts +281 -0
  165. package/templates/vanilla/node_modules/vite/dist/client/client.mjs +725 -0
  166. package/templates/vanilla/node_modules/vite/dist/client/client.mjs.map +1 -0
  167. package/templates/vanilla/node_modules/vite/dist/client/env.mjs +30 -0
  168. package/templates/vanilla/node_modules/vite/dist/client/env.mjs.map +1 -0
  169. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-7ec6f216.js +914 -0
  170. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-827b23df.js +66713 -0
  171. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-c423598f.js +561 -0
  172. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-f0c7dae0.js +7930 -0
  173. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-f1e8587f.js +7646 -0
  174. package/templates/vanilla/node_modules/vite/dist/node/cli.js +929 -0
  175. package/templates/vanilla/node_modules/vite/dist/node/constants.js +130 -0
  176. package/templates/vanilla/node_modules/vite/dist/node/index.d.ts +3548 -0
  177. package/templates/vanilla/node_modules/vite/dist/node/index.js +158 -0
  178. package/templates/vanilla/node_modules/vite/dist/node-cjs/publicUtils.cjs +4555 -0
  179. package/templates/vanilla/node_modules/vite/index.cjs +34 -0
  180. package/templates/vanilla/node_modules/vite/package.json +173 -0
  181. package/templates/vanilla/node_modules/vite/types/customEvent.d.ts +35 -0
  182. package/templates/vanilla/node_modules/vite/types/hmrPayload.d.ts +61 -0
  183. package/templates/vanilla/node_modules/vite/types/hot.d.ts +32 -0
  184. package/templates/vanilla/node_modules/vite/types/importGlob.d.ts +97 -0
  185. package/templates/vanilla/node_modules/vite/types/importMeta.d.ts +26 -0
  186. package/templates/vanilla/node_modules/vite/types/metadata.d.ts +10 -0
  187. package/templates/vanilla/node_modules/vite/types/package.json +4 -0
  188. package/templates/vanilla/package-lock.json +589 -0
  189. package/templates/vanilla/package.json +17 -0
  190. package/templates/vanilla/src/components/App.js +60 -0
  191. package/templates/vanilla/src/components/Card.js +21 -0
  192. package/templates/vanilla/src/components/Hero.js +15 -0
  193. package/templates/vanilla/src/components/InteractiveDemo.js +59 -0
  194. package/templates/vanilla/src/main.js +9 -0
  195. package/templates/vanilla/src/style/main.css +172 -0
  196. package/templates/vanilla/vite.config.js +8 -0
  197. package/templates/web3/.env.example +15 -0
  198. package/templates/web3/.github/workflows/deploy.yml +38 -0
  199. package/templates/web3/README.md +33 -0
  200. package/templates/web3/contracts/foundry.toml +11 -0
  201. package/templates/web3/contracts/script/Deploy.s.sol +13 -0
  202. package/templates/web3/contracts/src/Counter.sol +21 -0
  203. package/templates/web3/index.html +13 -0
  204. package/templates/web3/package.json +25 -0
  205. package/templates/web3/scripts/chain-start.mjs +305 -0
  206. package/templates/web3/scripts/chain-stop.mjs +34 -0
  207. package/templates/web3/scripts/deploy.mjs +155 -0
  208. package/templates/web3/scripts/setup.mjs +42 -0
  209. package/templates/web3/src/components/App.js +49 -0
  210. package/templates/web3/src/components/CounterCard.js +111 -0
  211. package/templates/web3/src/main.js +54 -0
  212. package/templates/web3/src/style/main.css +345 -0
  213. package/templates/web3/vite.config.js +29 -0
@@ -0,0 +1,725 @@
1
+ import '@vite/env';
2
+
3
+ const base$1 = __BASE__ || '/';
4
+ // set :host styles to make playwright detect the element as visible
5
+ const template = /*html*/ `
6
+ <style>
7
+ :host {
8
+ position: fixed;
9
+ top: 0;
10
+ left: 0;
11
+ width: 100%;
12
+ height: 100%;
13
+ z-index: 99999;
14
+ --monospace: 'SFMono-Regular', Consolas,
15
+ 'Liberation Mono', Menlo, Courier, monospace;
16
+ --red: #ff5555;
17
+ --yellow: #e2aa53;
18
+ --purple: #cfa4ff;
19
+ --cyan: #2dd9da;
20
+ --dim: #c9c9c9;
21
+
22
+ --window-background: #181818;
23
+ --window-color: #d8d8d8;
24
+ }
25
+
26
+ .backdrop {
27
+ position: fixed;
28
+ z-index: 99999;
29
+ top: 0;
30
+ left: 0;
31
+ width: 100%;
32
+ height: 100%;
33
+ overflow-y: scroll;
34
+ margin: 0;
35
+ background: rgba(0, 0, 0, 0.66);
36
+ }
37
+
38
+ .window {
39
+ font-family: var(--monospace);
40
+ line-height: 1.5;
41
+ width: 800px;
42
+ color: var(--window-color);
43
+ margin: 30px auto;
44
+ padding: 25px 40px;
45
+ position: relative;
46
+ background: var(--window-background);
47
+ border-radius: 6px 6px 8px 8px;
48
+ box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
49
+ overflow: hidden;
50
+ border-top: 8px solid var(--red);
51
+ direction: ltr;
52
+ text-align: left;
53
+ }
54
+
55
+ pre {
56
+ font-family: var(--monospace);
57
+ font-size: 16px;
58
+ margin-top: 0;
59
+ margin-bottom: 1em;
60
+ overflow-x: scroll;
61
+ scrollbar-width: none;
62
+ }
63
+
64
+ pre::-webkit-scrollbar {
65
+ display: none;
66
+ }
67
+
68
+ .message {
69
+ line-height: 1.3;
70
+ font-weight: 600;
71
+ white-space: pre-wrap;
72
+ }
73
+
74
+ .message-body {
75
+ color: var(--red);
76
+ }
77
+
78
+ .plugin {
79
+ color: var(--purple);
80
+ }
81
+
82
+ .file {
83
+ color: var(--cyan);
84
+ margin-bottom: 0;
85
+ white-space: pre-wrap;
86
+ word-break: break-all;
87
+ }
88
+
89
+ .frame {
90
+ color: var(--yellow);
91
+ }
92
+
93
+ .stack {
94
+ font-size: 13px;
95
+ color: var(--dim);
96
+ }
97
+
98
+ .tip {
99
+ font-size: 13px;
100
+ color: #999;
101
+ border-top: 1px dotted #999;
102
+ padding-top: 13px;
103
+ line-height: 1.8;
104
+ }
105
+
106
+ code {
107
+ font-size: 13px;
108
+ font-family: var(--monospace);
109
+ color: var(--yellow);
110
+ }
111
+
112
+ .file-link {
113
+ text-decoration: underline;
114
+ cursor: pointer;
115
+ }
116
+
117
+ kbd {
118
+ line-height: 1.5;
119
+ font-family: ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
120
+ font-size: 0.75rem;
121
+ font-weight: 700;
122
+ background-color: rgb(38, 40, 44);
123
+ color: rgb(166, 167, 171);
124
+ padding: 0.15rem 0.3rem;
125
+ border-radius: 0.25rem;
126
+ border-width: 0.0625rem 0.0625rem 0.1875rem;
127
+ border-style: solid;
128
+ border-color: rgb(54, 57, 64);
129
+ border-image: initial;
130
+ }
131
+ </style>
132
+ <div class="backdrop" part="backdrop">
133
+ <div class="window" part="window">
134
+ <pre class="message" part="message"><span class="plugin" part="plugin"></span><span class="message-body" part="message-body"></span></pre>
135
+ <pre class="file" part="file"></pre>
136
+ <pre class="frame" part="frame"></pre>
137
+ <pre class="stack" part="stack"></pre>
138
+ <div class="tip" part="tip">
139
+ Click outside, press <kbd>Esc</kbd> key, or fix the code to dismiss.<br>
140
+ You can also disable this overlay by setting
141
+ <code part="config-option-name">server.hmr.overlay</code> to <code part="config-option-value">false</code> in <code part="config-file-name">vite.config.js.</code>
142
+ </div>
143
+ </div>
144
+ </div>
145
+ `;
146
+ const fileRE = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
147
+ const codeframeRE = /^(?:>?\s+\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm;
148
+ // Allow `ErrorOverlay` to extend `HTMLElement` even in environments where
149
+ // `HTMLElement` was not originally defined.
150
+ const { HTMLElement = class {
151
+ } } = globalThis;
152
+ class ErrorOverlay extends HTMLElement {
153
+ constructor(err, links = true) {
154
+ var _a;
155
+ super();
156
+ this.root = this.attachShadow({ mode: 'open' });
157
+ this.root.innerHTML = template;
158
+ codeframeRE.lastIndex = 0;
159
+ const hasFrame = err.frame && codeframeRE.test(err.frame);
160
+ const message = hasFrame
161
+ ? err.message.replace(codeframeRE, '')
162
+ : err.message;
163
+ if (err.plugin) {
164
+ this.text('.plugin', `[plugin:${err.plugin}] `);
165
+ }
166
+ this.text('.message-body', message.trim());
167
+ const [file] = (((_a = err.loc) === null || _a === void 0 ? void 0 : _a.file) || err.id || 'unknown file').split(`?`);
168
+ if (err.loc) {
169
+ this.text('.file', `${file}:${err.loc.line}:${err.loc.column}`, links);
170
+ }
171
+ else if (err.id) {
172
+ this.text('.file', file);
173
+ }
174
+ if (hasFrame) {
175
+ this.text('.frame', err.frame.trim());
176
+ }
177
+ this.text('.stack', err.stack, links);
178
+ this.root.querySelector('.window').addEventListener('click', (e) => {
179
+ e.stopPropagation();
180
+ });
181
+ this.addEventListener('click', () => {
182
+ this.close();
183
+ });
184
+ this.closeOnEsc = (e) => {
185
+ if (e.key === 'Escape' || e.code === 'Escape') {
186
+ this.close();
187
+ }
188
+ };
189
+ document.addEventListener('keydown', this.closeOnEsc);
190
+ }
191
+ text(selector, text, linkFiles = false) {
192
+ const el = this.root.querySelector(selector);
193
+ if (!linkFiles) {
194
+ el.textContent = text;
195
+ }
196
+ else {
197
+ let curIndex = 0;
198
+ let match;
199
+ fileRE.lastIndex = 0;
200
+ while ((match = fileRE.exec(text))) {
201
+ const { 0: file, index } = match;
202
+ if (index != null) {
203
+ const frag = text.slice(curIndex, index);
204
+ el.appendChild(document.createTextNode(frag));
205
+ const link = document.createElement('a');
206
+ link.textContent = file;
207
+ link.className = 'file-link';
208
+ link.onclick = () => {
209
+ fetch(`${base$1}__open-in-editor?file=` + encodeURIComponent(file));
210
+ };
211
+ el.appendChild(link);
212
+ curIndex += frag.length + file.length;
213
+ }
214
+ }
215
+ }
216
+ }
217
+ close() {
218
+ var _a;
219
+ (_a = this.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this);
220
+ document.removeEventListener('keydown', this.closeOnEsc);
221
+ }
222
+ }
223
+ const overlayId = 'vite-error-overlay';
224
+ const { customElements } = globalThis; // Ensure `customElements` is defined before the next line.
225
+ if (customElements && !customElements.get(overlayId)) {
226
+ customElements.define(overlayId, ErrorOverlay);
227
+ }
228
+
229
+ console.debug('[vite] connecting...');
230
+ const importMetaUrl = new URL(import.meta.url);
231
+ // use server configuration, then fallback to inference
232
+ const serverHost = __SERVER_HOST__;
233
+ const socketProtocol = __HMR_PROTOCOL__ || (importMetaUrl.protocol === 'https:' ? 'wss' : 'ws');
234
+ const hmrPort = __HMR_PORT__;
235
+ const socketHost = `${__HMR_HOSTNAME__ || importMetaUrl.hostname}:${hmrPort || importMetaUrl.port}${__HMR_BASE__}`;
236
+ const directSocketHost = __HMR_DIRECT_TARGET__;
237
+ const base = __BASE__ || '/';
238
+ const wsToken = __WS_TOKEN__;
239
+ const messageBuffer = [];
240
+ let socket;
241
+ try {
242
+ let fallback;
243
+ // only use fallback when port is inferred to prevent confusion
244
+ if (!hmrPort) {
245
+ fallback = () => {
246
+ // fallback to connecting directly to the hmr server
247
+ // for servers which does not support proxying websocket
248
+ socket = setupWebSocket(socketProtocol, directSocketHost, () => {
249
+ const currentScriptHostURL = new URL(import.meta.url);
250
+ const currentScriptHost = currentScriptHostURL.host +
251
+ currentScriptHostURL.pathname.replace(/@vite\/client$/, '');
252
+ console.error('[vite] failed to connect to websocket.\n' +
253
+ 'your current setup:\n' +
254
+ ` (browser) ${currentScriptHost} <--[HTTP]--> ${serverHost} (server)\n` +
255
+ ` (browser) ${socketHost} <--[WebSocket (failing)]--> ${directSocketHost} (server)\n` +
256
+ 'Check out your Vite / network configuration and https://vitejs.dev/config/server-options.html#server-hmr .');
257
+ });
258
+ socket.addEventListener('open', () => {
259
+ console.info('[vite] Direct websocket connection fallback. Check out https://vitejs.dev/config/server-options.html#server-hmr to remove the previous connection error.');
260
+ }, { once: true });
261
+ };
262
+ }
263
+ socket = setupWebSocket(socketProtocol, socketHost, fallback);
264
+ }
265
+ catch (error) {
266
+ console.error(`[vite] failed to connect to websocket (${error}). `);
267
+ }
268
+ function setupWebSocket(protocol, hostAndPath, onCloseWithoutOpen) {
269
+ const socket = new WebSocket(`${protocol}://${hostAndPath}?token=${wsToken}`, 'vite-hmr');
270
+ let isOpened = false;
271
+ socket.addEventListener('open', () => {
272
+ isOpened = true;
273
+ notifyListeners('vite:ws:connect', { webSocket: socket });
274
+ }, { once: true });
275
+ // Listen for messages
276
+ socket.addEventListener('message', async ({ data }) => {
277
+ handleMessage(JSON.parse(data));
278
+ });
279
+ // ping server
280
+ socket.addEventListener('close', async ({ wasClean }) => {
281
+ if (wasClean)
282
+ return;
283
+ if (!isOpened && onCloseWithoutOpen) {
284
+ onCloseWithoutOpen();
285
+ return;
286
+ }
287
+ notifyListeners('vite:ws:disconnect', { webSocket: socket });
288
+ console.log(`[vite] server connection lost. polling for restart...`);
289
+ await waitForSuccessfulPing(protocol, hostAndPath);
290
+ location.reload();
291
+ });
292
+ return socket;
293
+ }
294
+ function warnFailedFetch(err, path) {
295
+ if (!err.message.match('fetch')) {
296
+ console.error(err);
297
+ }
298
+ console.error(`[hmr] Failed to reload ${path}. ` +
299
+ `This could be due to syntax errors or importing non-existent ` +
300
+ `modules. (see errors above)`);
301
+ }
302
+ function cleanUrl(pathname) {
303
+ const url = new URL(pathname, location.toString());
304
+ url.searchParams.delete('direct');
305
+ return url.pathname + url.search;
306
+ }
307
+ let isFirstUpdate = true;
308
+ const outdatedLinkTags = new WeakSet();
309
+ const debounceReload = (time) => {
310
+ let timer;
311
+ return () => {
312
+ if (timer) {
313
+ clearTimeout(timer);
314
+ timer = null;
315
+ }
316
+ timer = setTimeout(() => {
317
+ location.reload();
318
+ }, time);
319
+ };
320
+ };
321
+ const pageReload = debounceReload(50);
322
+ async function handleMessage(payload) {
323
+ switch (payload.type) {
324
+ case 'connected':
325
+ console.debug(`[vite] connected.`);
326
+ sendMessageBuffer();
327
+ // proxy(nginx, docker) hmr ws maybe caused timeout,
328
+ // so send ping package let ws keep alive.
329
+ setInterval(() => {
330
+ if (socket.readyState === socket.OPEN) {
331
+ socket.send('{"type":"ping"}');
332
+ }
333
+ }, __HMR_TIMEOUT__);
334
+ break;
335
+ case 'update':
336
+ notifyListeners('vite:beforeUpdate', payload);
337
+ // if this is the first update and there's already an error overlay, it
338
+ // means the page opened with existing server compile error and the whole
339
+ // module script failed to load (since one of the nested imports is 500).
340
+ // in this case a normal update won't work and a full reload is needed.
341
+ if (isFirstUpdate && hasErrorOverlay()) {
342
+ window.location.reload();
343
+ return;
344
+ }
345
+ else {
346
+ clearErrorOverlay();
347
+ isFirstUpdate = false;
348
+ }
349
+ await Promise.all(payload.updates.map(async (update) => {
350
+ if (update.type === 'js-update') {
351
+ return queueUpdate(fetchUpdate(update));
352
+ }
353
+ // css-update
354
+ // this is only sent when a css file referenced with <link> is updated
355
+ const { path, timestamp } = update;
356
+ const searchUrl = cleanUrl(path);
357
+ // can't use querySelector with `[href*=]` here since the link may be
358
+ // using relative paths so we need to use link.href to grab the full
359
+ // URL for the include check.
360
+ const el = Array.from(document.querySelectorAll('link')).find((e) => !outdatedLinkTags.has(e) && cleanUrl(e.href).includes(searchUrl));
361
+ if (!el) {
362
+ return;
363
+ }
364
+ const newPath = `${base}${searchUrl.slice(1)}${searchUrl.includes('?') ? '&' : '?'}t=${timestamp}`;
365
+ // rather than swapping the href on the existing tag, we will
366
+ // create a new link tag. Once the new stylesheet has loaded we
367
+ // will remove the existing link tag. This removes a Flash Of
368
+ // Unstyled Content that can occur when swapping out the tag href
369
+ // directly, as the new stylesheet has not yet been loaded.
370
+ return new Promise((resolve) => {
371
+ const newLinkTag = el.cloneNode();
372
+ newLinkTag.href = new URL(newPath, el.href).href;
373
+ const removeOldEl = () => {
374
+ el.remove();
375
+ console.debug(`[vite] css hot updated: ${searchUrl}`);
376
+ resolve();
377
+ };
378
+ newLinkTag.addEventListener('load', removeOldEl);
379
+ newLinkTag.addEventListener('error', removeOldEl);
380
+ outdatedLinkTags.add(el);
381
+ el.after(newLinkTag);
382
+ });
383
+ }));
384
+ notifyListeners('vite:afterUpdate', payload);
385
+ break;
386
+ case 'custom': {
387
+ notifyListeners(payload.event, payload.data);
388
+ break;
389
+ }
390
+ case 'full-reload':
391
+ notifyListeners('vite:beforeFullReload', payload);
392
+ if (payload.path && payload.path.endsWith('.html')) {
393
+ // if html file is edited, only reload the page if the browser is
394
+ // currently on that page.
395
+ const pagePath = decodeURI(location.pathname);
396
+ const payloadPath = base + payload.path.slice(1);
397
+ if (pagePath === payloadPath ||
398
+ payload.path === '/index.html' ||
399
+ (pagePath.endsWith('/') && pagePath + 'index.html' === payloadPath)) {
400
+ pageReload();
401
+ }
402
+ return;
403
+ }
404
+ else {
405
+ pageReload();
406
+ }
407
+ break;
408
+ case 'prune':
409
+ notifyListeners('vite:beforePrune', payload);
410
+ // After an HMR update, some modules are no longer imported on the page
411
+ // but they may have left behind side effects that need to be cleaned up
412
+ // (.e.g style injections)
413
+ // TODO Trigger their dispose callbacks.
414
+ payload.paths.forEach((path) => {
415
+ const fn = pruneMap.get(path);
416
+ if (fn) {
417
+ fn(dataMap.get(path));
418
+ }
419
+ });
420
+ break;
421
+ case 'error': {
422
+ notifyListeners('vite:error', payload);
423
+ const err = payload.err;
424
+ if (enableOverlay) {
425
+ createErrorOverlay(err);
426
+ }
427
+ else {
428
+ console.error(`[vite] Internal Server Error\n${err.message}\n${err.stack}`);
429
+ }
430
+ break;
431
+ }
432
+ default: {
433
+ const check = payload;
434
+ return check;
435
+ }
436
+ }
437
+ }
438
+ function notifyListeners(event, data) {
439
+ const cbs = customListenersMap.get(event);
440
+ if (cbs) {
441
+ cbs.forEach((cb) => cb(data));
442
+ }
443
+ }
444
+ const enableOverlay = __HMR_ENABLE_OVERLAY__;
445
+ function createErrorOverlay(err) {
446
+ if (!enableOverlay)
447
+ return;
448
+ clearErrorOverlay();
449
+ document.body.appendChild(new ErrorOverlay(err));
450
+ }
451
+ function clearErrorOverlay() {
452
+ document
453
+ .querySelectorAll(overlayId)
454
+ .forEach((n) => n.close());
455
+ }
456
+ function hasErrorOverlay() {
457
+ return document.querySelectorAll(overlayId).length;
458
+ }
459
+ let pending = false;
460
+ let queued = [];
461
+ /**
462
+ * buffer multiple hot updates triggered by the same src change
463
+ * so that they are invoked in the same order they were sent.
464
+ * (otherwise the order may be inconsistent because of the http request round trip)
465
+ */
466
+ async function queueUpdate(p) {
467
+ queued.push(p);
468
+ if (!pending) {
469
+ pending = true;
470
+ await Promise.resolve();
471
+ pending = false;
472
+ const loading = [...queued];
473
+ queued = [];
474
+ (await Promise.all(loading)).forEach((fn) => fn && fn());
475
+ }
476
+ }
477
+ async function waitForSuccessfulPing(socketProtocol, hostAndPath, ms = 1000) {
478
+ const pingHostProtocol = socketProtocol === 'wss' ? 'https' : 'http';
479
+ const ping = async () => {
480
+ // A fetch on a websocket URL will return a successful promise with status 400,
481
+ // but will reject a networking error.
482
+ // When running on middleware mode, it returns status 426, and an cors error happens if mode is not no-cors
483
+ try {
484
+ await fetch(`${pingHostProtocol}://${hostAndPath}`, {
485
+ mode: 'no-cors',
486
+ headers: {
487
+ // Custom headers won't be included in a request with no-cors so (ab)use one of the
488
+ // safelisted headers to identify the ping request
489
+ Accept: 'text/x-vite-ping',
490
+ },
491
+ });
492
+ return true;
493
+ }
494
+ catch { }
495
+ return false;
496
+ };
497
+ if (await ping()) {
498
+ return;
499
+ }
500
+ await wait(ms);
501
+ // eslint-disable-next-line no-constant-condition
502
+ while (true) {
503
+ if (document.visibilityState === 'visible') {
504
+ if (await ping()) {
505
+ break;
506
+ }
507
+ await wait(ms);
508
+ }
509
+ else {
510
+ await waitForWindowShow();
511
+ }
512
+ }
513
+ }
514
+ function wait(ms) {
515
+ return new Promise((resolve) => setTimeout(resolve, ms));
516
+ }
517
+ function waitForWindowShow() {
518
+ return new Promise((resolve) => {
519
+ const onChange = async () => {
520
+ if (document.visibilityState === 'visible') {
521
+ resolve();
522
+ document.removeEventListener('visibilitychange', onChange);
523
+ }
524
+ };
525
+ document.addEventListener('visibilitychange', onChange);
526
+ });
527
+ }
528
+ const sheetsMap = new Map();
529
+ // collect existing style elements that may have been inserted during SSR
530
+ // to avoid FOUC or duplicate styles
531
+ if ('document' in globalThis) {
532
+ document.querySelectorAll('style[data-vite-dev-id]').forEach((el) => {
533
+ sheetsMap.set(el.getAttribute('data-vite-dev-id'), el);
534
+ });
535
+ }
536
+ // all css imports should be inserted at the same position
537
+ // because after build it will be a single css file
538
+ let lastInsertedStyle;
539
+ function updateStyle(id, content) {
540
+ let style = sheetsMap.get(id);
541
+ if (!style) {
542
+ style = document.createElement('style');
543
+ style.setAttribute('type', 'text/css');
544
+ style.setAttribute('data-vite-dev-id', id);
545
+ style.textContent = content;
546
+ if (!lastInsertedStyle) {
547
+ document.head.appendChild(style);
548
+ // reset lastInsertedStyle after async
549
+ // because dynamically imported css will be splitted into a different file
550
+ setTimeout(() => {
551
+ lastInsertedStyle = undefined;
552
+ }, 0);
553
+ }
554
+ else {
555
+ lastInsertedStyle.insertAdjacentElement('afterend', style);
556
+ }
557
+ lastInsertedStyle = style;
558
+ }
559
+ else {
560
+ style.textContent = content;
561
+ }
562
+ sheetsMap.set(id, style);
563
+ }
564
+ function removeStyle(id) {
565
+ const style = sheetsMap.get(id);
566
+ if (style) {
567
+ document.head.removeChild(style);
568
+ sheetsMap.delete(id);
569
+ }
570
+ }
571
+ async function fetchUpdate({ path, acceptedPath, timestamp, explicitImportRequired, }) {
572
+ const mod = hotModulesMap.get(path);
573
+ if (!mod) {
574
+ // In a code-splitting project,
575
+ // it is common that the hot-updating module is not loaded yet.
576
+ // https://github.com/vitejs/vite/issues/721
577
+ return;
578
+ }
579
+ let fetchedModule;
580
+ const isSelfUpdate = path === acceptedPath;
581
+ // determine the qualified callbacks before we re-import the modules
582
+ const qualifiedCallbacks = mod.callbacks.filter(({ deps }) => deps.includes(acceptedPath));
583
+ if (isSelfUpdate || qualifiedCallbacks.length > 0) {
584
+ const disposer = disposeMap.get(acceptedPath);
585
+ if (disposer)
586
+ await disposer(dataMap.get(acceptedPath));
587
+ const [acceptedPathWithoutQuery, query] = acceptedPath.split(`?`);
588
+ try {
589
+ fetchedModule = await import(
590
+ /* @vite-ignore */
591
+ base +
592
+ acceptedPathWithoutQuery.slice(1) +
593
+ `?${explicitImportRequired ? 'import&' : ''}t=${timestamp}${query ? `&${query}` : ''}`);
594
+ }
595
+ catch (e) {
596
+ warnFailedFetch(e, acceptedPath);
597
+ }
598
+ }
599
+ return () => {
600
+ for (const { deps, fn } of qualifiedCallbacks) {
601
+ fn(deps.map((dep) => (dep === acceptedPath ? fetchedModule : undefined)));
602
+ }
603
+ const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
604
+ console.debug(`[vite] hot updated: ${loggedPath}`);
605
+ };
606
+ }
607
+ function sendMessageBuffer() {
608
+ if (socket.readyState === 1) {
609
+ messageBuffer.forEach((msg) => socket.send(msg));
610
+ messageBuffer.length = 0;
611
+ }
612
+ }
613
+ const hotModulesMap = new Map();
614
+ const disposeMap = new Map();
615
+ const pruneMap = new Map();
616
+ const dataMap = new Map();
617
+ const customListenersMap = new Map();
618
+ const ctxToListenersMap = new Map();
619
+ function createHotContext(ownerPath) {
620
+ if (!dataMap.has(ownerPath)) {
621
+ dataMap.set(ownerPath, {});
622
+ }
623
+ // when a file is hot updated, a new context is created
624
+ // clear its stale callbacks
625
+ const mod = hotModulesMap.get(ownerPath);
626
+ if (mod) {
627
+ mod.callbacks = [];
628
+ }
629
+ // clear stale custom event listeners
630
+ const staleListeners = ctxToListenersMap.get(ownerPath);
631
+ if (staleListeners) {
632
+ for (const [event, staleFns] of staleListeners) {
633
+ const listeners = customListenersMap.get(event);
634
+ if (listeners) {
635
+ customListenersMap.set(event, listeners.filter((l) => !staleFns.includes(l)));
636
+ }
637
+ }
638
+ }
639
+ const newListeners = new Map();
640
+ ctxToListenersMap.set(ownerPath, newListeners);
641
+ function acceptDeps(deps, callback = () => { }) {
642
+ const mod = hotModulesMap.get(ownerPath) || {
643
+ id: ownerPath,
644
+ callbacks: [],
645
+ };
646
+ mod.callbacks.push({
647
+ deps,
648
+ fn: callback,
649
+ });
650
+ hotModulesMap.set(ownerPath, mod);
651
+ }
652
+ const hot = {
653
+ get data() {
654
+ return dataMap.get(ownerPath);
655
+ },
656
+ accept(deps, callback) {
657
+ if (typeof deps === 'function' || !deps) {
658
+ // self-accept: hot.accept(() => {})
659
+ acceptDeps([ownerPath], ([mod]) => deps === null || deps === void 0 ? void 0 : deps(mod));
660
+ }
661
+ else if (typeof deps === 'string') {
662
+ // explicit deps
663
+ acceptDeps([deps], ([mod]) => callback === null || callback === void 0 ? void 0 : callback(mod));
664
+ }
665
+ else if (Array.isArray(deps)) {
666
+ acceptDeps(deps, callback);
667
+ }
668
+ else {
669
+ throw new Error(`invalid hot.accept() usage.`);
670
+ }
671
+ },
672
+ // export names (first arg) are irrelevant on the client side, they're
673
+ // extracted in the server for propagation
674
+ acceptExports(_, callback) {
675
+ acceptDeps([ownerPath], ([mod]) => callback === null || callback === void 0 ? void 0 : callback(mod));
676
+ },
677
+ dispose(cb) {
678
+ disposeMap.set(ownerPath, cb);
679
+ },
680
+ prune(cb) {
681
+ pruneMap.set(ownerPath, cb);
682
+ },
683
+ // Kept for backward compatibility (#11036)
684
+ // @ts-expect-error untyped
685
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
686
+ decline() { },
687
+ // tell the server to re-perform hmr propagation from this module as root
688
+ invalidate(message) {
689
+ notifyListeners('vite:invalidate', { path: ownerPath, message });
690
+ this.send('vite:invalidate', { path: ownerPath, message });
691
+ console.debug(`[vite] invalidate ${ownerPath}${message ? `: ${message}` : ''}`);
692
+ },
693
+ // custom events
694
+ on(event, cb) {
695
+ const addToMap = (map) => {
696
+ const existing = map.get(event) || [];
697
+ existing.push(cb);
698
+ map.set(event, existing);
699
+ };
700
+ addToMap(customListenersMap);
701
+ addToMap(newListeners);
702
+ },
703
+ send(event, data) {
704
+ messageBuffer.push(JSON.stringify({ type: 'custom', event, data }));
705
+ sendMessageBuffer();
706
+ },
707
+ };
708
+ return hot;
709
+ }
710
+ /**
711
+ * urls here are dynamic import() urls that couldn't be statically analyzed
712
+ */
713
+ function injectQuery(url, queryToInject) {
714
+ // skip urls that won't be handled by vite
715
+ if (url[0] !== '.' && url[0] !== '/') {
716
+ return url;
717
+ }
718
+ // can't use pathname from URL since it may be relative like ../
719
+ const pathname = url.replace(/#.*$/, '').replace(/\?.*$/, '');
720
+ const { search, hash } = new URL(url, 'http://vitejs.dev');
721
+ return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${hash || ''}`;
722
+ }
723
+
724
+ export { ErrorOverlay, createHotContext, injectQuery, removeStyle, updateStyle };
725
+ //# sourceMappingURL=client.mjs.map