@ohos-ports/rsbuild-core 2.2.9-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -0
  3. package/bin/rsbuild.js +20 -0
  4. package/compiled/@rstackjs/load-config/index.d.ts +87 -0
  5. package/compiled/@rstackjs/load-config/license +21 -0
  6. package/compiled/@rstackjs/load-config/package.json +1 -0
  7. package/compiled/chokidar/index.d.ts +385 -0
  8. package/compiled/chokidar/license +21 -0
  9. package/compiled/chokidar/package.json +1 -0
  10. package/compiled/connect-next/index.d.ts +57 -0
  11. package/compiled/connect-next/license +26 -0
  12. package/compiled/connect-next/package.json +1 -0
  13. package/compiled/cors/index.d.ts +56 -0
  14. package/compiled/cors/license +22 -0
  15. package/compiled/cors/package.json +1 -0
  16. package/compiled/css-loader/api.js +85 -0
  17. package/compiled/css-loader/getUrl.js +26 -0
  18. package/compiled/css-loader/index.d.ts +1 -0
  19. package/compiled/css-loader/index.js +2 -0
  20. package/compiled/css-loader/license +20 -0
  21. package/compiled/css-loader/noSourceMaps.js +5 -0
  22. package/compiled/css-loader/package.json +1 -0
  23. package/compiled/css-loader/sourceMaps.js +16 -0
  24. package/compiled/html-rspack-plugin/default_index.ejs +9 -0
  25. package/compiled/html-rspack-plugin/htmlLoader.js +157 -0
  26. package/compiled/html-rspack-plugin/index.d.ts +395 -0
  27. package/compiled/html-rspack-plugin/index.js +2400 -0
  28. package/compiled/html-rspack-plugin/license +20 -0
  29. package/compiled/html-rspack-plugin/package.json +1 -0
  30. package/compiled/http-proxy-middleware/index.d.ts +455 -0
  31. package/compiled/http-proxy-middleware/license +22 -0
  32. package/compiled/http-proxy-middleware/package.json +1 -0
  33. package/compiled/jiti/LICENSE +21 -0
  34. package/compiled/jiti/README.md +258 -0
  35. package/compiled/jiti/dist/babel.cjs +47446 -0
  36. package/compiled/jiti/dist/jiti.cjs +5990 -0
  37. package/compiled/jiti/lib/jiti-cli.mjs +19 -0
  38. package/compiled/jiti/lib/jiti-hooks.mjs +89 -0
  39. package/compiled/jiti/lib/jiti-native.mjs +76 -0
  40. package/compiled/jiti/lib/jiti-register.d.mts +1 -0
  41. package/compiled/jiti/lib/jiti-register.mjs +2 -0
  42. package/compiled/jiti/lib/jiti-static.mjs +19 -0
  43. package/compiled/jiti/lib/jiti.cjs +24 -0
  44. package/compiled/jiti/lib/jiti.d.cts +8 -0
  45. package/compiled/jiti/lib/jiti.d.mts +8 -0
  46. package/compiled/jiti/lib/jiti.mjs +23 -0
  47. package/compiled/jiti/lib/types.d.ts +420 -0
  48. package/compiled/jiti/package.json +146 -0
  49. package/compiled/postcss/index.js +1 -0
  50. package/compiled/postcss/lib/at-rule.d.ts +139 -0
  51. package/compiled/postcss/lib/comment.d.ts +67 -0
  52. package/compiled/postcss/lib/container.d.ts +474 -0
  53. package/compiled/postcss/lib/css-syntax-error.d.ts +247 -0
  54. package/compiled/postcss/lib/declaration.d.ts +150 -0
  55. package/compiled/postcss/lib/document.d.ts +68 -0
  56. package/compiled/postcss/lib/fromJSON.d.ts +9 -0
  57. package/compiled/postcss/lib/input.d.ts +226 -0
  58. package/compiled/postcss/lib/lazy-result.d.ts +189 -0
  59. package/compiled/postcss/lib/list.d.ts +60 -0
  60. package/compiled/postcss/lib/no-work-result.d.ts +45 -0
  61. package/compiled/postcss/lib/node.d.ts +555 -0
  62. package/compiled/postcss/lib/parse.d.ts +9 -0
  63. package/compiled/postcss/lib/postcss.d.ts +464 -0
  64. package/compiled/postcss/lib/previous-map.d.ts +80 -0
  65. package/compiled/postcss/lib/processor.d.ts +114 -0
  66. package/compiled/postcss/lib/result.d.ts +204 -0
  67. package/compiled/postcss/lib/root.d.ts +86 -0
  68. package/compiled/postcss/lib/rule.d.ts +126 -0
  69. package/compiled/postcss/lib/source-map-js.d.ts +4 -0
  70. package/compiled/postcss/lib/stringifier.d.ts +45 -0
  71. package/compiled/postcss/lib/stringify.d.ts +9 -0
  72. package/compiled/postcss/lib/warning.d.ts +146 -0
  73. package/compiled/postcss/license +20 -0
  74. package/compiled/postcss/package.json +1 -0
  75. package/compiled/postcss-loader/index.d.ts +1 -0
  76. package/compiled/postcss-loader/index.js +721 -0
  77. package/compiled/postcss-loader/license +20 -0
  78. package/compiled/postcss-loader/package.json +1 -0
  79. package/compiled/rslog/index.d.ts +98 -0
  80. package/compiled/rslog/license +21 -0
  81. package/compiled/rslog/package.json +1 -0
  82. package/compiled/rspack-chain/license +22 -0
  83. package/compiled/rspack-chain/package.json +1 -0
  84. package/compiled/rspack-chain/types/index.d.ts +515 -0
  85. package/compiled/rspack-manifest-plugin/index.d.ts +52 -0
  86. package/compiled/rspack-manifest-plugin/license +21 -0
  87. package/compiled/rspack-manifest-plugin/package.json +1 -0
  88. package/compiled/style-loader/index.d.ts +1 -0
  89. package/compiled/style-loader/index.js +370 -0
  90. package/compiled/style-loader/license +20 -0
  91. package/compiled/style-loader/package.json +1 -0
  92. package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
  93. package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
  94. package/compiled/style-loader/runtime/insertBySelector.js +34 -0
  95. package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
  96. package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
  97. package/compiled/style-loader/runtime/isOldIE.js +17 -0
  98. package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
  99. package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
  100. package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
  101. package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
  102. package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
  103. package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
  104. package/compiled/ws/index.d.ts +445 -0
  105. package/compiled/ws/license +21 -0
  106. package/compiled/ws/package.json +1 -0
  107. package/dist/build.d.ts +4 -0
  108. package/dist/c.js +10 -0
  109. package/dist/chokidar.js +2 -0
  110. package/dist/chokidar.js.LICENSE.txt +1 -0
  111. package/dist/cli/commands.d.ts +31 -0
  112. package/dist/cli/index.d.ts +7 -0
  113. package/dist/cli/init.d.ts +7 -0
  114. package/dist/client/f~0.js +22 -0
  115. package/dist/client/hmr.js +267 -0
  116. package/dist/client/overlay.js +214 -0
  117. package/dist/configChain.d.ts +84 -0
  118. package/dist/connect-next.js +2 -0
  119. package/dist/connect-next.js.LICENSE.txt +57 -0
  120. package/dist/constants.d.ts +67 -0
  121. package/dist/cors.js +188 -0
  122. package/dist/cors.js.LICENSE.txt +11 -0
  123. package/dist/createCompiler.d.ts +6 -0
  124. package/dist/createContext.d.ts +12 -0
  125. package/dist/createRsbuild.d.ts +4 -0
  126. package/dist/cssUrlLoader.mjs +34 -0
  127. package/dist/defaultConfig.d.ts +23 -0
  128. package/dist/freshImport.js +90 -0
  129. package/dist/helpers/cachedImport.d.ts +2 -0
  130. package/dist/helpers/compiler.d.ts +5 -0
  131. package/dist/helpers/css.d.ts +3 -0
  132. package/dist/helpers/exitHook.d.ts +3 -0
  133. package/dist/helpers/format.d.ts +4 -0
  134. package/dist/helpers/fs.d.ts +16 -0
  135. package/dist/helpers/html.d.ts +2 -0
  136. package/dist/helpers/index.d.ts +29 -0
  137. package/dist/helpers/overlayConfig.d.ts +4 -0
  138. package/dist/helpers/packageJson.d.ts +9 -0
  139. package/dist/helpers/path.d.ts +22 -0
  140. package/dist/helpers/restartManager.d.ts +15 -0
  141. package/dist/helpers/stats.d.ts +17 -0
  142. package/dist/helpers/url.d.ts +11 -0
  143. package/dist/helpers/vendors.d.ts +12 -0
  144. package/dist/helpers/version.d.ts +7 -0
  145. package/dist/hooks.d.ts +41 -0
  146. package/dist/http-proxy-middleware.js +14 -0
  147. package/dist/http-proxy-middleware.js.LICENSE.txt +34 -0
  148. package/dist/ignoreCssLoader.mjs +9 -0
  149. package/dist/index.d.ts +28 -0
  150. package/dist/index.js +1 -0
  151. package/dist/initConfigs.d.ts +18 -0
  152. package/dist/initPlugins.d.ts +7 -0
  153. package/dist/inspectConfig.d.ts +7 -0
  154. package/dist/launch-editor-middleware.js +1 -0
  155. package/dist/loadConfig.d.ts +31 -0
  156. package/dist/loadEnv.d.ts +54 -0
  157. package/dist/loader/cssUrlLoader.d.ts +9 -0
  158. package/dist/loader/ignoreCssLoader.d.ts +10 -0
  159. package/dist/loader/transformLoader.d.ts +8 -0
  160. package/dist/loader/transformRawLoader.d.ts +4 -0
  161. package/dist/loader/workerLoader.d.ts +6 -0
  162. package/dist/logger.d.ts +24 -0
  163. package/dist/m.js +10348 -0
  164. package/dist/m.js.LICENSE.txt +26 -0
  165. package/dist/manifest-plugin.js +1 -0
  166. package/dist/memfs.js +1 -0
  167. package/dist/mergeConfig.d.ts +7 -0
  168. package/dist/open.js +2 -0
  169. package/dist/pluginHelper.d.ts +4 -0
  170. package/dist/pluginManager.d.ts +19 -0
  171. package/dist/plugins/appIcon.d.ts +2 -0
  172. package/dist/plugins/asset.d.ts +3 -0
  173. package/dist/plugins/basic.d.ts +4 -0
  174. package/dist/plugins/cache.d.ts +2 -0
  175. package/dist/plugins/cleanOutput.d.ts +2 -0
  176. package/dist/plugins/css.d.ts +8 -0
  177. package/dist/plugins/define.d.ts +2 -0
  178. package/dist/plugins/entry.d.ts +2 -0
  179. package/dist/plugins/externals.d.ts +9 -0
  180. package/dist/plugins/fileSize.d.ts +7 -0
  181. package/dist/plugins/html.d.ts +9 -0
  182. package/dist/plugins/inlineChunk.d.ts +6 -0
  183. package/dist/plugins/lazyCompilation.d.ts +2 -0
  184. package/dist/plugins/manifest.d.ts +2 -0
  185. package/dist/plugins/minimize.d.ts +10 -0
  186. package/dist/plugins/moduleFederation.d.ts +2 -0
  187. package/dist/plugins/nodeAddons.d.ts +2 -0
  188. package/dist/plugins/nonce.d.ts +2 -0
  189. package/dist/plugins/output.d.ts +2 -0
  190. package/dist/plugins/progress.d.ts +2 -0
  191. package/dist/plugins/resolve.d.ts +2 -0
  192. package/dist/plugins/resourceHints.d.ts +2 -0
  193. package/dist/plugins/rsdoctor.d.ts +2 -0
  194. package/dist/plugins/rspackProfile.d.ts +4 -0
  195. package/dist/plugins/server.d.ts +3 -0
  196. package/dist/plugins/sourceMap.d.ts +2 -0
  197. package/dist/plugins/splitChunks.d.ts +4 -0
  198. package/dist/plugins/sri.d.ts +2 -0
  199. package/dist/plugins/swc.d.ts +4 -0
  200. package/dist/plugins/target.d.ts +2 -0
  201. package/dist/plugins/wasm.d.ts +2 -0
  202. package/dist/plugins/worker.d.ts +2 -0
  203. package/dist/r.js +7 -0
  204. package/dist/range-parser.js +55 -0
  205. package/dist/range-parser.js.LICENSE.txt +6 -0
  206. package/dist/remapping.js +201 -0
  207. package/dist/restart.d.ts +15 -0
  208. package/dist/rslib-runtime.js +49 -0
  209. package/dist/rspack-plugins/RsbuildHtmlPlugin.d.ts +37 -0
  210. package/dist/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +36 -0
  211. package/dist/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +27 -0
  212. package/dist/rspack-plugins/resource-hints/extractChunks.d.ts +22 -0
  213. package/dist/rspack-plugins/resource-hints/getResourceType.d.ts +21 -0
  214. package/dist/rspackConfig.d.ts +8 -0
  215. package/dist/server/ansiHTML.d.ts +3 -0
  216. package/dist/server/assets-middleware/getFileFromUrl.d.ts +11 -0
  217. package/dist/server/assets-middleware/index.d.ts +35 -0
  218. package/dist/server/assets-middleware/memoryFileSystem.d.ts +2 -0
  219. package/dist/server/assets-middleware/middleware.d.ts +7 -0
  220. package/dist/server/assets-middleware/parseTokenList.d.ts +1 -0
  221. package/dist/server/assets-middleware/setupOutputFileSystem.d.ts +3 -0
  222. package/dist/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
  223. package/dist/server/browserLogs.d.ts +8 -0
  224. package/dist/server/buildManager.d.ts +32 -0
  225. package/dist/server/cliShortcuts.d.ts +19 -0
  226. package/dist/server/compileState.d.ts +5 -0
  227. package/dist/server/devMiddlewares.d.ts +18 -0
  228. package/dist/server/devServer.d.ts +47 -0
  229. package/dist/server/environment.d.ts +8 -0
  230. package/dist/server/gracefulShutdown.d.ts +8 -0
  231. package/dist/server/gzipMiddleware.d.ts +2 -0
  232. package/dist/server/helper.d.ts +118 -0
  233. package/dist/server/historyApiFallback.d.ts +10 -0
  234. package/dist/server/hmrFallback.d.ts +1 -0
  235. package/dist/server/httpServer.d.ts +7 -0
  236. package/dist/server/middlewares.d.ts +31 -0
  237. package/dist/server/open.d.ts +12 -0
  238. package/dist/server/overlay.d.ts +3 -0
  239. package/dist/server/previewServer.d.ts +4 -0
  240. package/dist/server/proxy.d.ts +7 -0
  241. package/dist/server/publicPathnames.d.ts +2 -0
  242. package/dist/server/runner/asModule.d.ts +2 -0
  243. package/dist/server/runner/basic.d.ts +25 -0
  244. package/dist/server/runner/cjs.d.ts +10 -0
  245. package/dist/server/runner/esm.d.ts +6 -0
  246. package/dist/server/runner/index.d.ts +6 -0
  247. package/dist/server/runner/type.d.ts +42 -0
  248. package/dist/server/serverSetup.d.ts +2 -0
  249. package/dist/server/socketServer.d.ts +113 -0
  250. package/dist/server/watchFiles.d.ts +15 -0
  251. package/dist/sirv.js +122 -0
  252. package/dist/tinyglobby.js +1 -0
  253. package/dist/trace-mapping.js +548 -0
  254. package/dist/transformLoader.mjs +36 -0
  255. package/dist/transformRawLoader.mjs +4 -0
  256. package/dist/types/config.d.ts +1796 -0
  257. package/dist/types/context.d.ts +89 -0
  258. package/dist/types/hooks.d.ts +261 -0
  259. package/dist/types/index.d.ts +8 -0
  260. package/dist/types/plugin.d.ts +479 -0
  261. package/dist/types/rsbuild.d.ts +241 -0
  262. package/dist/types/rspack.d.ts +10 -0
  263. package/dist/types/thirdParty.d.ts +161 -0
  264. package/dist/types/utils.d.ts +16 -0
  265. package/dist/workerLoader.mjs +94 -0
  266. package/dist/ws.js +2 -0
  267. package/package.json +107 -0
  268. package/static/openChrome.applescript +95 -0
  269. package/types.d.ts +422 -0
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var memo;
4
+
5
+ /* istanbul ignore next */
6
+ function isOldIE() {
7
+ if (typeof memo === "undefined") {
8
+ // Test for IE <= 9 as proposed by Browserhacks
9
+ // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
10
+ // Tests for existence of standard globals is to allow style-loader
11
+ // to operate correctly into non-standard environments
12
+ // @see https://github.com/webpack-contrib/style-loader/issues/177
13
+ memo = Boolean(typeof window !== "undefined" && typeof document !== "undefined" && document.all && !window.atob);
14
+ }
15
+ return memo;
16
+ }
17
+ module.exports = isOldIE;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ /* istanbul ignore next */
4
+ function setAttributesWithoutAttributes(styleElement, attributes) {
5
+ var nonce = typeof __webpack_nonce__ !== "undefined" ? __webpack_nonce__ : null;
6
+ if (nonce) {
7
+ attributes.nonce = nonce;
8
+ }
9
+ Object.keys(attributes).forEach(function (key) {
10
+ styleElement.setAttribute(key, attributes[key]);
11
+ });
12
+ }
13
+ module.exports = setAttributesWithoutAttributes;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ /* istanbul ignore next */
4
+ function setAttributesWithoutAttributes(styleElement, attributes) {
5
+ Object.keys(attributes).forEach(function (key) {
6
+ styleElement.setAttribute(key, attributes[key]);
7
+ });
8
+ }
9
+ module.exports = setAttributesWithoutAttributes;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ /* istanbul ignore next */
4
+ function setAttributesWithoutAttributes(styleElement) {
5
+ var nonce = typeof __webpack_nonce__ !== "undefined" ? __webpack_nonce__ : null;
6
+ if (nonce) {
7
+ styleElement.setAttribute("nonce", nonce);
8
+ }
9
+ }
10
+ module.exports = setAttributesWithoutAttributes;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ /* istanbul ignore next */
4
+ var replaceText = function replaceText() {
5
+ var textStore = [];
6
+ return function replace(index, replacement) {
7
+ textStore[index] = replacement;
8
+ return textStore.filter(Boolean).join("\n");
9
+ };
10
+ }();
11
+
12
+ /* istanbul ignore next */
13
+ function apply(styleElement, index, remove, obj) {
14
+ var css;
15
+ if (remove) {
16
+ css = "";
17
+ } else {
18
+ css = "";
19
+ if (obj.supports) {
20
+ css += "@supports (".concat(obj.supports, ") {");
21
+ }
22
+ if (obj.media) {
23
+ css += "@media ".concat(obj.media, " {");
24
+ }
25
+ var needLayer = typeof obj.layer !== "undefined";
26
+ if (needLayer) {
27
+ css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
28
+ }
29
+ css += obj.css;
30
+ if (needLayer) {
31
+ css += "}";
32
+ }
33
+ if (obj.media) {
34
+ css += "}";
35
+ }
36
+ if (obj.supports) {
37
+ css += "}";
38
+ }
39
+ }
40
+
41
+ // For old IE
42
+ /* istanbul ignore if */
43
+ if (styleElement.styleSheet) {
44
+ styleElement.styleSheet.cssText = replaceText(index, css);
45
+ } else {
46
+ var cssNode = document.createTextNode(css);
47
+ var childNodes = styleElement.childNodes;
48
+ if (childNodes[index]) {
49
+ styleElement.removeChild(childNodes[index]);
50
+ }
51
+ if (childNodes.length) {
52
+ styleElement.insertBefore(cssNode, childNodes[index]);
53
+ } else {
54
+ styleElement.appendChild(cssNode);
55
+ }
56
+ }
57
+ }
58
+ var singletonData = {
59
+ singleton: null,
60
+ singletonCounter: 0
61
+ };
62
+
63
+ /* istanbul ignore next */
64
+ function domAPI(options) {
65
+ if (typeof document === "undefined") return {
66
+ update: function update() {},
67
+ remove: function remove() {}
68
+ };
69
+
70
+ // eslint-disable-next-line no-undef,no-use-before-define
71
+ var styleIndex = singletonData.singletonCounter++;
72
+ var styleElement =
73
+ // eslint-disable-next-line no-undef,no-use-before-define
74
+ singletonData.singleton || (
75
+ // eslint-disable-next-line no-undef,no-use-before-define
76
+ singletonData.singleton = options.insertStyleElement(options));
77
+ return {
78
+ update: function update(obj) {
79
+ apply(styleElement, styleIndex, false, obj);
80
+ },
81
+ remove: function remove(obj) {
82
+ apply(styleElement, styleIndex, true, obj);
83
+ }
84
+ };
85
+ }
86
+ module.exports = domAPI;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ /* istanbul ignore next */
4
+ function apply(styleElement, options, obj) {
5
+ var css = "";
6
+ if (obj.supports) {
7
+ css += "@supports (".concat(obj.supports, ") {");
8
+ }
9
+ if (obj.media) {
10
+ css += "@media ".concat(obj.media, " {");
11
+ }
12
+ var needLayer = typeof obj.layer !== "undefined";
13
+ if (needLayer) {
14
+ css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
15
+ }
16
+ css += obj.css;
17
+ if (needLayer) {
18
+ css += "}";
19
+ }
20
+ if (obj.media) {
21
+ css += "}";
22
+ }
23
+ if (obj.supports) {
24
+ css += "}";
25
+ }
26
+ var sourceMap = obj.sourceMap;
27
+ if (sourceMap && typeof btoa !== "undefined") {
28
+ css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
29
+ }
30
+
31
+ // For old IE
32
+ /* istanbul ignore if */
33
+ options.styleTagTransform(css, styleElement, options.options);
34
+ }
35
+ function removeStyleElement(styleElement) {
36
+ // istanbul ignore if
37
+ if (styleElement.parentNode === null) {
38
+ return false;
39
+ }
40
+ styleElement.parentNode.removeChild(styleElement);
41
+ }
42
+
43
+ /* istanbul ignore next */
44
+ function domAPI(options) {
45
+ if (typeof document === "undefined") {
46
+ return {
47
+ update: function update() {},
48
+ remove: function remove() {}
49
+ };
50
+ }
51
+ var styleElement = options.insertStyleElement(options);
52
+ return {
53
+ update: function update(obj) {
54
+ apply(styleElement, options, obj);
55
+ },
56
+ remove: function remove() {
57
+ removeStyleElement(styleElement);
58
+ }
59
+ };
60
+ }
61
+ module.exports = domAPI;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ /* istanbul ignore next */
4
+ function styleTagTransform(css, styleElement) {
5
+ if (styleElement.styleSheet) {
6
+ styleElement.styleSheet.cssText = css;
7
+ } else {
8
+ while (styleElement.firstChild) {
9
+ styleElement.removeChild(styleElement.firstChild);
10
+ }
11
+ styleElement.appendChild(document.createTextNode(css));
12
+ }
13
+ }
14
+ module.exports = styleTagTransform;
@@ -0,0 +1,445 @@
1
+ /// <reference types="node" />
2
+
3
+ import { EventEmitter } from "events";
4
+ import {
5
+ Agent,
6
+ ClientRequest,
7
+ ClientRequestArgs,
8
+ IncomingMessage,
9
+ OutgoingHttpHeaders,
10
+ Server as HTTPServer,
11
+ } from "http";
12
+ import { Server as HTTPSServer } from "https";
13
+ import { createConnection } from "net";
14
+ import { Duplex, DuplexOptions } from "stream";
15
+ import { SecureContextOptions } from "tls";
16
+ import { URL } from "url";
17
+ import { ZlibOptions } from "zlib";
18
+
19
+ // can not get all overload of BufferConstructor['from'], need to copy all it's first arguments here
20
+ // https://github.com/microsoft/TypeScript/issues/32164
21
+ type BufferLike =
22
+ | string
23
+ | Buffer
24
+ | DataView
25
+ | number
26
+ | ArrayBufferView
27
+ | Uint8Array
28
+ | ArrayBuffer
29
+ | SharedArrayBuffer
30
+ | Blob
31
+ | readonly any[]
32
+ | readonly number[]
33
+ | { valueOf(): ArrayBuffer }
34
+ | { valueOf(): SharedArrayBuffer }
35
+ | { valueOf(): Uint8Array }
36
+ | { valueOf(): readonly number[] }
37
+ | { valueOf(): string }
38
+ | { [Symbol.toPrimitive](hint: string): string };
39
+
40
+ // WebSocket socket.
41
+ declare class WebSocket extends EventEmitter {
42
+ /** The connection is not yet open. */
43
+ static readonly CONNECTING: 0;
44
+ /** The connection is open and ready to communicate. */
45
+ static readonly OPEN: 1;
46
+ /** The connection is in the process of closing. */
47
+ static readonly CLOSING: 2;
48
+ /** The connection is closed. */
49
+ static readonly CLOSED: 3;
50
+
51
+ binaryType: "nodebuffer" | "arraybuffer" | "fragments";
52
+ readonly bufferedAmount: number;
53
+ readonly extensions: string;
54
+ /** Indicates whether the websocket is paused */
55
+ readonly isPaused: boolean;
56
+ readonly protocol: string;
57
+ /** The current state of the connection */
58
+ readonly readyState:
59
+ | typeof WebSocket.CONNECTING
60
+ | typeof WebSocket.OPEN
61
+ | typeof WebSocket.CLOSING
62
+ | typeof WebSocket.CLOSED;
63
+ readonly url: string;
64
+
65
+ /** The connection is not yet open. */
66
+ readonly CONNECTING: 0;
67
+ /** The connection is open and ready to communicate. */
68
+ readonly OPEN: 1;
69
+ /** The connection is in the process of closing. */
70
+ readonly CLOSING: 2;
71
+ /** The connection is closed. */
72
+ readonly CLOSED: 3;
73
+
74
+ onopen: ((event: WebSocket.Event) => void) | null;
75
+ onerror: ((event: WebSocket.ErrorEvent) => void) | null;
76
+ onclose: ((event: WebSocket.CloseEvent) => void) | null;
77
+ onmessage: ((event: WebSocket.MessageEvent) => void) | null;
78
+
79
+ constructor(address: null);
80
+ constructor(address: string | URL, options?: WebSocket.ClientOptions | ClientRequestArgs);
81
+ constructor(
82
+ address: string | URL,
83
+ protocols?: string | string[],
84
+ options?: WebSocket.ClientOptions | ClientRequestArgs,
85
+ );
86
+
87
+ close(code?: number, data?: string | Buffer): void;
88
+ ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
89
+ pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
90
+ // https://github.com/websockets/ws/issues/2076#issuecomment-1250354722
91
+ send(data: BufferLike, cb?: (err?: Error) => void): void;
92
+ send(
93
+ data: BufferLike,
94
+ options: {
95
+ mask?: boolean | undefined;
96
+ binary?: boolean | undefined;
97
+ compress?: boolean | undefined;
98
+ fin?: boolean | undefined;
99
+ },
100
+ cb?: (err?: Error) => void,
101
+ ): void;
102
+ terminate(): void;
103
+
104
+ /**
105
+ * Pause the websocket causing it to stop emitting events. Some events can still be
106
+ * emitted after this is called, until all buffered data is consumed. This method
107
+ * is a noop if the ready state is `CONNECTING` or `CLOSED`.
108
+ */
109
+ pause(): void;
110
+ /**
111
+ * Make a paused socket resume emitting events. This method is a noop if the ready
112
+ * state is `CONNECTING` or `CLOSED`.
113
+ */
114
+ resume(): void;
115
+
116
+ // HTML5 WebSocket events
117
+ addEventListener<K extends keyof WebSocket.WebSocketEventMap>(
118
+ type: K,
119
+ listener:
120
+ | ((event: WebSocket.WebSocketEventMap[K]) => void)
121
+ | { handleEvent(event: WebSocket.WebSocketEventMap[K]): void },
122
+ options?: WebSocket.EventListenerOptions,
123
+ ): void;
124
+ removeEventListener<K extends keyof WebSocket.WebSocketEventMap>(
125
+ type: K,
126
+ listener:
127
+ | ((event: WebSocket.WebSocketEventMap[K]) => void)
128
+ | { handleEvent(event: WebSocket.WebSocketEventMap[K]): void },
129
+ ): void;
130
+
131
+ // Events
132
+ on(event: "close", listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
133
+ on(event: "error", listener: (this: WebSocket, error: Error) => void): this;
134
+ on(event: "upgrade", listener: (this: WebSocket, request: IncomingMessage) => void): this;
135
+ on(event: "message", listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
136
+ on(event: "open", listener: (this: WebSocket) => void): this;
137
+ on(event: "ping" | "pong", listener: (this: WebSocket, data: Buffer) => void): this;
138
+ on(event: "redirect", listener: (this: WebSocket, url: string, request: ClientRequest) => void): this;
139
+ on(
140
+ event: "unexpected-response",
141
+ listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void,
142
+ ): this;
143
+ on(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
144
+
145
+ once(event: "close", listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
146
+ once(event: "error", listener: (this: WebSocket, error: Error) => void): this;
147
+ once(event: "upgrade", listener: (this: WebSocket, request: IncomingMessage) => void): this;
148
+ once(event: "message", listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
149
+ once(event: "open", listener: (this: WebSocket) => void): this;
150
+ once(event: "ping" | "pong", listener: (this: WebSocket, data: Buffer) => void): this;
151
+ once(event: "redirect", listener: (this: WebSocket, url: string, request: ClientRequest) => void): this;
152
+ once(
153
+ event: "unexpected-response",
154
+ listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void,
155
+ ): this;
156
+ once(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
157
+
158
+ off(event: "close", listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
159
+ off(event: "error", listener: (this: WebSocket, error: Error) => void): this;
160
+ off(event: "upgrade", listener: (this: WebSocket, request: IncomingMessage) => void): this;
161
+ off(event: "message", listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
162
+ off(event: "open", listener: (this: WebSocket) => void): this;
163
+ off(event: "ping" | "pong", listener: (this: WebSocket, data: Buffer) => void): this;
164
+ off(event: "redirect", listener: (this: WebSocket, url: string, request: ClientRequest) => void): this;
165
+ off(
166
+ event: "unexpected-response",
167
+ listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void,
168
+ ): this;
169
+ off(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
170
+
171
+ addListener(event: "close", listener: (code: number, reason: Buffer) => void): this;
172
+ addListener(event: "error", listener: (error: Error) => void): this;
173
+ addListener(event: "upgrade", listener: (request: IncomingMessage) => void): this;
174
+ addListener(event: "message", listener: (data: WebSocket.RawData, isBinary: boolean) => void): this;
175
+ addListener(event: "open", listener: () => void): this;
176
+ addListener(event: "ping" | "pong", listener: (data: Buffer) => void): this;
177
+ addListener(event: "redirect", listener: (url: string, request: ClientRequest) => void): this;
178
+ addListener(
179
+ event: "unexpected-response",
180
+ listener: (request: ClientRequest, response: IncomingMessage) => void,
181
+ ): this;
182
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
183
+
184
+ removeListener(event: "close", listener: (code: number, reason: Buffer) => void): this;
185
+ removeListener(event: "error", listener: (error: Error) => void): this;
186
+ removeListener(event: "upgrade", listener: (request: IncomingMessage) => void): this;
187
+ removeListener(event: "message", listener: (data: WebSocket.RawData, isBinary: boolean) => void): this;
188
+ removeListener(event: "open", listener: () => void): this;
189
+ removeListener(event: "ping" | "pong", listener: (data: Buffer) => void): this;
190
+ removeListener(event: "redirect", listener: (url: string, request: ClientRequest) => void): this;
191
+ removeListener(
192
+ event: "unexpected-response",
193
+ listener: (request: ClientRequest, response: IncomingMessage) => void,
194
+ ): this;
195
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
196
+ }
197
+
198
+ declare const WebSocketAlias: typeof WebSocket;
199
+ interface WebSocketAlias extends WebSocket {} // eslint-disable-line @typescript-eslint/no-empty-interface
200
+
201
+ declare namespace WebSocket {
202
+ /**
203
+ * Data represents the raw message payload received over the WebSocket.
204
+ */
205
+ type RawData = Buffer | ArrayBuffer | Buffer[];
206
+
207
+ /**
208
+ * Data represents the message payload received over the WebSocket.
209
+ */
210
+ type Data = string | Buffer | ArrayBuffer | Buffer[];
211
+
212
+ /**
213
+ * CertMeta represents the accepted types for certificate & key data.
214
+ */
215
+ type CertMeta = string | string[] | Buffer | Buffer[];
216
+
217
+ /**
218
+ * VerifyClientCallbackSync is a synchronous callback used to inspect the
219
+ * incoming message. The return value (boolean) of the function determines
220
+ * whether or not to accept the handshake.
221
+ */
222
+ type VerifyClientCallbackSync<Request extends IncomingMessage = IncomingMessage> = (info: {
223
+ origin: string;
224
+ secure: boolean;
225
+ req: Request;
226
+ }) => boolean;
227
+
228
+ /**
229
+ * VerifyClientCallbackAsync is an asynchronous callback used to inspect the
230
+ * incoming message. The return value (boolean) of the function determines
231
+ * whether or not to accept the handshake.
232
+ */
233
+ type VerifyClientCallbackAsync<Request extends IncomingMessage = IncomingMessage> = (
234
+ info: { origin: string; secure: boolean; req: Request },
235
+ callback: (res: boolean, code?: number, message?: string, headers?: OutgoingHttpHeaders) => void,
236
+ ) => void;
237
+
238
+ /**
239
+ * FinishRequestCallback is a callback for last minute customization of the
240
+ * headers. If finishRequest is set, then it has the responsibility to call
241
+ * request.end() once it is done setting request headers.
242
+ */
243
+ type FinishRequestCallback = (request: ClientRequest, websocket: WebSocket) => void;
244
+
245
+ interface ClientOptions extends SecureContextOptions {
246
+ protocol?: string | undefined;
247
+ followRedirects?: boolean | undefined;
248
+ generateMask?(mask: Buffer): void;
249
+ handshakeTimeout?: number | undefined;
250
+ maxRedirects?: number | undefined;
251
+ perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
252
+ localAddress?: string | undefined;
253
+ protocolVersion?: number | undefined;
254
+ headers?: { [key: string]: string } | undefined;
255
+ origin?: string | undefined;
256
+ agent?: Agent | undefined;
257
+ host?: string | undefined;
258
+ family?: number | undefined;
259
+ checkServerIdentity?(servername: string, cert: CertMeta): boolean;
260
+ rejectUnauthorized?: boolean | undefined;
261
+ allowSynchronousEvents?: boolean | undefined;
262
+ autoPong?: boolean | undefined;
263
+ maxPayload?: number | undefined;
264
+ skipUTF8Validation?: boolean | undefined;
265
+ createConnection?: typeof createConnection | undefined;
266
+ finishRequest?: FinishRequestCallback | undefined;
267
+ }
268
+
269
+ interface PerMessageDeflateOptions {
270
+ serverNoContextTakeover?: boolean | undefined;
271
+ clientNoContextTakeover?: boolean | undefined;
272
+ serverMaxWindowBits?: number | undefined;
273
+ clientMaxWindowBits?: number | undefined;
274
+ zlibDeflateOptions?: {
275
+ flush?: number | undefined;
276
+ finishFlush?: number | undefined;
277
+ chunkSize?: number | undefined;
278
+ windowBits?: number | undefined;
279
+ level?: number | undefined;
280
+ memLevel?: number | undefined;
281
+ strategy?: number | undefined;
282
+ dictionary?: Buffer | Buffer[] | DataView | undefined;
283
+ info?: boolean | undefined;
284
+ } | undefined;
285
+ zlibInflateOptions?: ZlibOptions | undefined;
286
+ threshold?: number | undefined;
287
+ concurrencyLimit?: number | undefined;
288
+ }
289
+
290
+ interface Event {
291
+ type: string;
292
+ target: WebSocket;
293
+ }
294
+
295
+ interface ErrorEvent {
296
+ error: any;
297
+ message: string;
298
+ type: string;
299
+ target: WebSocket;
300
+ }
301
+
302
+ interface CloseEvent {
303
+ wasClean: boolean;
304
+ code: number;
305
+ reason: string;
306
+ type: string;
307
+ target: WebSocket;
308
+ }
309
+
310
+ interface MessageEvent {
311
+ data: Data;
312
+ type: string;
313
+ target: WebSocket;
314
+ }
315
+
316
+ interface WebSocketEventMap {
317
+ open: Event;
318
+ error: ErrorEvent;
319
+ close: CloseEvent;
320
+ message: MessageEvent;
321
+ }
322
+
323
+ interface EventListenerOptions {
324
+ once?: boolean | undefined;
325
+ }
326
+
327
+ interface ServerOptions<
328
+ U extends typeof WebSocket.WebSocket = typeof WebSocket.WebSocket,
329
+ V extends typeof IncomingMessage = typeof IncomingMessage,
330
+ > {
331
+ host?: string | undefined;
332
+ port?: number | undefined;
333
+ backlog?: number | undefined;
334
+ server?: HTTPServer<V> | HTTPSServer<V> | undefined;
335
+ verifyClient?:
336
+ | VerifyClientCallbackAsync<InstanceType<V>>
337
+ | VerifyClientCallbackSync<InstanceType<V>>
338
+ | undefined;
339
+ handleProtocols?: (protocols: Set<string>, request: InstanceType<V>) => string | false;
340
+ path?: string | undefined;
341
+ noServer?: boolean | undefined;
342
+ allowSynchronousEvents?: boolean | undefined;
343
+ autoPong?: boolean | undefined;
344
+ clientTracking?: boolean | undefined;
345
+ perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
346
+ maxPayload?: number | undefined;
347
+ skipUTF8Validation?: boolean | undefined;
348
+ WebSocket?: U | undefined;
349
+ }
350
+
351
+ interface AddressInfo {
352
+ address: string;
353
+ family: string;
354
+ port: number;
355
+ }
356
+
357
+ // WebSocket Server
358
+ class Server<
359
+ T extends typeof WebSocket.WebSocket = typeof WebSocket.WebSocket,
360
+ U extends typeof IncomingMessage = typeof IncomingMessage,
361
+ > extends EventEmitter {
362
+ options: ServerOptions<T, U>;
363
+ path: string;
364
+ clients: Set<InstanceType<T>>;
365
+
366
+ constructor(options?: ServerOptions<T, U>, callback?: () => void);
367
+
368
+ address(): AddressInfo | string | null;
369
+ close(cb?: (err?: Error) => void): void;
370
+ handleUpgrade(
371
+ request: InstanceType<U>,
372
+ socket: Duplex,
373
+ upgradeHead: Buffer,
374
+ callback: (client: InstanceType<T>, request: InstanceType<U>) => void,
375
+ ): void;
376
+ shouldHandle(request: InstanceType<U>): boolean | Promise<boolean>;
377
+
378
+ // Events
379
+ on(
380
+ event: "connection",
381
+ cb: (this: Server<T>, websocket: InstanceType<T>, request: InstanceType<U>) => void,
382
+ ): this;
383
+ on(event: "error", cb: (this: Server<T>, error: Error) => void): this;
384
+ on(event: "headers", cb: (this: Server<T>, headers: string[], request: InstanceType<U>) => void): this;
385
+ on(event: "close" | "listening", cb: (this: Server<T>) => void): this;
386
+ on(
387
+ event: "wsClientError",
388
+ cb: (this: Server<T>, error: Error, socket: Duplex, request: InstanceType<U>) => void,
389
+ ): this;
390
+ on(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
391
+
392
+ once(
393
+ event: "connection",
394
+ cb: (this: Server<T>, websocket: InstanceType<T>, request: InstanceType<U>) => void,
395
+ ): this;
396
+ once(event: "error", cb: (this: Server<T>, error: Error) => void): this;
397
+ once(event: "headers", cb: (this: Server<T>, headers: string[], request: InstanceType<U>) => void): this;
398
+ once(event: "close" | "listening", cb: (this: Server<T>) => void): this;
399
+ once(
400
+ event: "wsClientError",
401
+ cb: (this: Server<T>, error: Error, socket: Duplex, request: InstanceType<U>) => void,
402
+ ): this;
403
+ once(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
404
+
405
+ off(
406
+ event: "connection",
407
+ cb: (this: Server<T>, socket: InstanceType<T>, request: InstanceType<U>) => void,
408
+ ): this;
409
+ off(event: "error", cb: (this: Server<T>, error: Error) => void): this;
410
+ off(event: "headers", cb: (this: Server<T>, headers: string[], request: InstanceType<U>) => void): this;
411
+ off(event: "close" | "listening", cb: (this: Server<T>) => void): this;
412
+ off(
413
+ event: "wsClientError",
414
+ cb: (this: Server<T>, error: Error, socket: Duplex, request: InstanceType<U>) => void,
415
+ ): this;
416
+ off(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
417
+
418
+ addListener(event: "connection", cb: (websocket: InstanceType<T>, request: InstanceType<U>) => void): this;
419
+ addListener(event: "error", cb: (error: Error) => void): this;
420
+ addListener(event: "headers", cb: (headers: string[], request: InstanceType<U>) => void): this;
421
+ addListener(event: "close" | "listening", cb: () => void): this;
422
+ addListener(event: "wsClientError", cb: (error: Error, socket: Duplex, request: InstanceType<U>) => void): this;
423
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
424
+
425
+ removeListener(event: "connection", cb: (websocket: InstanceType<T>, request: InstanceType<U>) => void): this;
426
+ removeListener(event: "error", cb: (error: Error) => void): this;
427
+ removeListener(event: "headers", cb: (headers: string[], request: InstanceType<U>) => void): this;
428
+ removeListener(event: "close" | "listening", cb: () => void): this;
429
+ removeListener(
430
+ event: "wsClientError",
431
+ cb: (error: Error, socket: Duplex, request: InstanceType<U>) => void,
432
+ ): this;
433
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
434
+ }
435
+
436
+ const WebSocketServer: typeof Server;
437
+ interface WebSocketServer extends Server {} // eslint-disable-line @typescript-eslint/no-empty-interface
438
+ const WebSocket: typeof WebSocketAlias;
439
+ interface WebSocket extends WebSocketAlias {} // eslint-disable-line @typescript-eslint/no-empty-interface
440
+
441
+ // WebSocket stream
442
+ function createWebSocketStream(websocket: WebSocket, options?: DuplexOptions): Duplex;
443
+ }
444
+
445
+ export = WebSocket;
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
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
@@ -0,0 +1 @@
1
+ {"name":"ws","version":"8.18.1","license":"MIT","types":"index.d.ts","type":"commonjs"}