@vizhub/runtime 0.3.0 → 0.3.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 (260) hide show
  1. package/dist/cjs/buildHTML.js +71 -0
  2. package/dist/cjs/common/packageJson.js +81 -0
  3. package/dist/cjs/common/packageJson.test.js +148 -0
  4. package/dist/cjs/common/sucrasePlugin.js +27 -0
  5. package/dist/cjs/common/virtualFileSystem.js +79 -0
  6. package/dist/cjs/determineRuntimeVersion.js +26 -0
  7. package/dist/cjs/determineRuntimeVersion.test.js +103 -0
  8. package/dist/cjs/index.js +9 -0
  9. package/dist/cjs/package.json +1 -0
  10. package/dist/cjs/test/fixtures/v1/basicHTML.js +18 -0
  11. package/dist/cjs/test/fixtures/v1/fetchProxy.js +15 -0
  12. package/dist/cjs/test/fixtures/v1/index.js +15 -0
  13. package/dist/cjs/test/fixtures/v1/jsScriptTag.js +12 -0
  14. package/dist/cjs/test/fixtures/v1/protocolTest.js +18 -0
  15. package/dist/cjs/test/fixtures/v1/styleTest.js +18 -0
  16. package/dist/cjs/test/fixtures/v1/xmlTest.js +22 -0
  17. package/dist/cjs/test/fixtures/v2/basicBundle.js +8 -0
  18. package/dist/cjs/test/fixtures/v2/basicBundleNoExtension.js +8 -0
  19. package/dist/cjs/test/fixtures/v2/d3Import.js +10 -0
  20. package/dist/cjs/test/fixtures/v2/d3ImportPkg.js +22 -0
  21. package/dist/cjs/test/fixtures/v2/d3RosettaImportPkg.js +22 -0
  22. package/dist/cjs/test/fixtures/v2/es6Preserve.js +9 -0
  23. package/dist/cjs/test/fixtures/v2/generatorSupport.js +9 -0
  24. package/dist/cjs/test/fixtures/v2/index.js +45 -0
  25. package/dist/cjs/test/fixtures/v2/jsxTranspile.js +9 -0
  26. package/dist/cjs/test/fixtures/v2/reactDomImport.js +11 -0
  27. package/dist/cjs/test/fixtures/v2/reactDomImportPkg.js +27 -0
  28. package/dist/cjs/test/fixtures/v2/reactImport.js +10 -0
  29. package/dist/cjs/test/fixtures/v2/reactImportPkg.js +20 -0
  30. package/dist/cjs/test/fixtures/v2/sourceMapErrorFixture.js +22 -0
  31. package/dist/cjs/test/fixtures/v2/unicodeSupport.js +9 -0
  32. package/dist/cjs/test/fixtures/v3/basicIndexJS.js +10 -0
  33. package/dist/cjs/test/fixtures/v3/cssImport.js +12 -0
  34. package/dist/cjs/test/fixtures/v3/csvImport.js +14 -0
  35. package/dist/cjs/test/fixtures/v3/csvStrangeChars.js +15 -0
  36. package/dist/cjs/test/fixtures/v3/index.js +25 -0
  37. package/dist/cjs/test/fixtures/v3/jsExport.js +13 -0
  38. package/dist/cjs/test/fixtures/v3/sourcemap.js +13 -0
  39. package/dist/cjs/test/fixtures/v3/svelte.js +21 -0
  40. package/dist/cjs/test/fixtures/v3/vizContent.js +14 -0
  41. package/dist/cjs/test/fixtures/v3/vizImport.js +88 -0
  42. package/dist/cjs/test/fixtures/v4/d3Usage.js +34 -0
  43. package/dist/cjs/test/fixtures/v4/esmBuild.js +21 -0
  44. package/dist/cjs/test/fixtures/v4/fetchInterception.js +21 -0
  45. package/dist/cjs/test/fixtures/v4/index.js +21 -0
  46. package/dist/cjs/test/fixtures/v4/jsScriptTagTypeModule.js +21 -0
  47. package/dist/cjs/test/fixtures/v4/jsScriptTagTypeModules.js +15 -0
  48. package/dist/cjs/test/fixtures/v4/reactHooks.js +50 -0
  49. package/dist/cjs/test/fixtures/v4/reactJsx.js +37 -0
  50. package/dist/cjs/test/fixtures/v4/threeJsUsage.js +27 -0
  51. package/dist/cjs/test/fixtures/v4/typeScriptSupport.js +32 -0
  52. package/dist/cjs/test/testInBrowser.js +50 -0
  53. package/dist/cjs/test/testStackTrace.js +58 -0
  54. package/dist/cjs/test/v1.test.js +70 -0
  55. package/dist/cjs/test/v2.test.js +124 -0
  56. package/dist/cjs/test/v3.test.js +119 -0
  57. package/dist/cjs/test/v4.test.js +105 -0
  58. package/dist/cjs/types.js +2 -0
  59. package/dist/cjs/utils/vizContentToFileCollection.js +23 -0
  60. package/dist/cjs/utils/vizContentToFileCollection.test.js +77 -0
  61. package/dist/cjs/v2/computeBundleJSV2.js +33 -0
  62. package/dist/cjs/v2/getComputedIndexHtml.js +86 -0
  63. package/dist/cjs/v2/getComputedIndexHtml.test.js +136 -0
  64. package/dist/cjs/v2/index.js +5 -0
  65. package/dist/cjs/v2/v2Build.js +15 -0
  66. package/dist/cjs/v3/cleanRollupErrorMessage.js +13 -0
  67. package/dist/cjs/v3/computeBundleJSV3.js +52 -0
  68. package/dist/cjs/v3/createVizContent.js +27 -0
  69. package/dist/cjs/v3/extractVizImport.js +27 -0
  70. package/dist/cjs/v3/extractVizImport.test.js +32 -0
  71. package/dist/cjs/v3/htmlTemplate.js +93 -0
  72. package/dist/cjs/v3/index.js +5 -0
  73. package/dist/cjs/v3/parseId.js +9 -0
  74. package/dist/cjs/v3/parseId.test.js +27 -0
  75. package/dist/cjs/v3/setupV3Runtime.js +345 -0
  76. package/dist/cjs/v3/slugCache.js +39 -0
  77. package/dist/cjs/v3/slugCache.test.js +107 -0
  78. package/dist/cjs/v3/transformDSV/dsvParseSrc.js +124 -0
  79. package/dist/cjs/v3/transformDSV/index.js +44 -0
  80. package/dist/cjs/v3/transformSvelte.js +81 -0
  81. package/dist/cjs/v3/types.js +2 -0
  82. package/dist/cjs/v3/v3Build.js +34 -0
  83. package/dist/cjs/v3/vizCache.js +40 -0
  84. package/dist/cjs/v3/vizCache.test.js +100 -0
  85. package/dist/cjs/v3/vizLoad.js +50 -0
  86. package/dist/cjs/v3/vizResolve.js +73 -0
  87. package/dist/cjs/v4/index.js +138 -0
  88. package/dist/esm/buildHTML.js +67 -0
  89. package/dist/esm/common/packageJson.js +71 -0
  90. package/dist/esm/common/packageJson.test.js +146 -0
  91. package/dist/esm/common/sucrasePlugin.js +24 -0
  92. package/dist/esm/common/virtualFileSystem.js +75 -0
  93. package/dist/esm/determineRuntimeVersion.js +22 -0
  94. package/dist/esm/determineRuntimeVersion.test.js +101 -0
  95. package/dist/esm/index.js +3 -0
  96. package/dist/esm/test/fixtures/v1/basicHTML.js +15 -0
  97. package/dist/esm/test/fixtures/v1/fetchProxy.js +12 -0
  98. package/dist/esm/test/fixtures/v1/index.js +6 -0
  99. package/dist/esm/test/fixtures/v1/jsScriptTag.js +9 -0
  100. package/dist/esm/test/fixtures/v1/protocolTest.js +15 -0
  101. package/dist/esm/test/fixtures/v1/styleTest.js +15 -0
  102. package/dist/esm/test/fixtures/v1/xmlTest.js +19 -0
  103. package/dist/esm/test/fixtures/v2/basicBundle.js +5 -0
  104. package/dist/esm/test/fixtures/v2/basicBundleNoExtension.js +5 -0
  105. package/dist/esm/test/fixtures/v2/d3Import.js +7 -0
  106. package/dist/esm/test/fixtures/v2/d3ImportPkg.js +19 -0
  107. package/dist/esm/test/fixtures/v2/d3RosettaImportPkg.js +19 -0
  108. package/dist/esm/test/fixtures/v2/es6Preserve.js +6 -0
  109. package/dist/esm/test/fixtures/v2/generatorSupport.js +6 -0
  110. package/dist/esm/test/fixtures/v2/index.js +15 -0
  111. package/dist/esm/test/fixtures/v2/jsxTranspile.js +6 -0
  112. package/dist/esm/test/fixtures/v2/reactDomImport.js +8 -0
  113. package/dist/esm/test/fixtures/v2/reactDomImportPkg.js +24 -0
  114. package/dist/esm/test/fixtures/v2/reactImport.js +7 -0
  115. package/dist/esm/test/fixtures/v2/reactImportPkg.js +17 -0
  116. package/dist/esm/test/fixtures/v2/sourceMapErrorFixture.js +19 -0
  117. package/dist/esm/test/fixtures/v2/unicodeSupport.js +6 -0
  118. package/dist/esm/test/fixtures/v3/basicIndexJS.js +7 -0
  119. package/dist/esm/test/fixtures/v3/cssImport.js +9 -0
  120. package/dist/esm/test/fixtures/v3/csvImport.js +11 -0
  121. package/dist/esm/test/fixtures/v3/csvStrangeChars.js +12 -0
  122. package/dist/esm/test/fixtures/v3/index.js +9 -0
  123. package/dist/esm/test/fixtures/v3/jsExport.js +10 -0
  124. package/dist/esm/test/fixtures/v3/sourcemap.js +10 -0
  125. package/dist/esm/test/fixtures/v3/svelte.js +18 -0
  126. package/dist/esm/test/fixtures/v3/vizContent.js +11 -0
  127. package/dist/esm/test/fixtures/v3/vizImport.js +85 -0
  128. package/dist/esm/test/fixtures/v4/d3Usage.js +31 -0
  129. package/dist/esm/test/fixtures/v4/esmBuild.js +18 -0
  130. package/dist/esm/test/fixtures/v4/fetchInterception.js +18 -0
  131. package/dist/esm/test/fixtures/v4/index.js +9 -0
  132. package/dist/esm/test/fixtures/v4/jsScriptTagTypeModule.js +18 -0
  133. package/dist/esm/test/fixtures/v4/jsScriptTagTypeModules.js +12 -0
  134. package/dist/esm/test/fixtures/v4/reactHooks.js +47 -0
  135. package/dist/esm/test/fixtures/v4/reactJsx.js +34 -0
  136. package/dist/esm/test/fixtures/v4/threeJsUsage.js +24 -0
  137. package/dist/esm/test/fixtures/v4/typeScriptSupport.js +29 -0
  138. package/dist/esm/test/testInBrowser.js +47 -0
  139. package/dist/esm/test/testStackTrace.js +55 -0
  140. package/dist/esm/test/v1.test.js +65 -0
  141. package/dist/esm/test/v2.test.js +121 -0
  142. package/dist/esm/test/v3.test.js +114 -0
  143. package/dist/esm/test/v4.test.js +100 -0
  144. package/dist/esm/types.js +1 -0
  145. package/dist/esm/utils/vizContentToFileCollection.js +19 -0
  146. package/dist/esm/utils/vizContentToFileCollection.test.js +75 -0
  147. package/dist/esm/v2/computeBundleJSV2.js +29 -0
  148. package/dist/esm/v2/getComputedIndexHtml.js +81 -0
  149. package/dist/esm/v2/getComputedIndexHtml.test.js +134 -0
  150. package/dist/esm/v2/index.js +1 -0
  151. package/dist/esm/v2/v2Build.js +11 -0
  152. package/dist/esm/v3/cleanRollupErrorMessage.js +9 -0
  153. package/dist/esm/v3/computeBundleJSV3.js +48 -0
  154. package/dist/esm/v3/createVizContent.js +23 -0
  155. package/dist/esm/v3/extractVizImport.js +23 -0
  156. package/dist/esm/v3/extractVizImport.test.js +30 -0
  157. package/dist/esm/v3/htmlTemplate.js +89 -0
  158. package/dist/esm/v3/index.js +1 -0
  159. package/dist/esm/v3/parseId.js +5 -0
  160. package/dist/esm/v3/parseId.test.js +25 -0
  161. package/dist/esm/v3/setupV3Runtime.js +341 -0
  162. package/dist/esm/v3/slugCache.js +35 -0
  163. package/dist/esm/v3/slugCache.test.js +105 -0
  164. package/dist/esm/v3/transformDSV/dsvParseSrc.js +121 -0
  165. package/dist/esm/v3/transformDSV/index.js +40 -0
  166. package/dist/esm/v3/transformSvelte.js +77 -0
  167. package/dist/esm/v3/types.js +1 -0
  168. package/dist/esm/v3/v3Build.js +30 -0
  169. package/dist/esm/v3/vizCache.js +36 -0
  170. package/dist/esm/v3/vizCache.test.js +98 -0
  171. package/dist/esm/v3/vizLoad.js +46 -0
  172. package/dist/esm/v3/vizResolve.js +69 -0
  173. package/dist/esm/v4/index.js +134 -0
  174. package/dist/types/buildHTML.d.ts +14 -0
  175. package/dist/types/common/packageJson.d.ts +39 -0
  176. package/dist/types/common/packageJson.test.d.ts +1 -0
  177. package/dist/types/common/sucrasePlugin.d.ts +2 -0
  178. package/dist/types/common/virtualFileSystem.d.ts +3 -0
  179. package/dist/types/determineRuntimeVersion.d.ts +3 -0
  180. package/dist/types/determineRuntimeVersion.test.d.ts +1 -0
  181. package/dist/types/index.d.ts +3 -0
  182. package/dist/types/test/fixtures/v1/basicHTML.d.ts +3 -0
  183. package/dist/types/test/fixtures/v1/fetchProxy.d.ts +5 -0
  184. package/dist/types/test/fixtures/v1/index.d.ts +6 -0
  185. package/dist/types/test/fixtures/v1/jsScriptTag.d.ts +4 -0
  186. package/dist/types/test/fixtures/v1/protocolTest.d.ts +3 -0
  187. package/dist/types/test/fixtures/v1/styleTest.d.ts +4 -0
  188. package/dist/types/test/fixtures/v1/xmlTest.d.ts +4 -0
  189. package/dist/types/test/fixtures/v2/basicBundle.d.ts +5 -0
  190. package/dist/types/test/fixtures/v2/basicBundleNoExtension.d.ts +5 -0
  191. package/dist/types/test/fixtures/v2/d3Import.d.ts +4 -0
  192. package/dist/types/test/fixtures/v2/d3ImportPkg.d.ts +5 -0
  193. package/dist/types/test/fixtures/v2/d3RosettaImportPkg.d.ts +5 -0
  194. package/dist/types/test/fixtures/v2/es6Preserve.d.ts +4 -0
  195. package/dist/types/test/fixtures/v2/generatorSupport.d.ts +4 -0
  196. package/dist/types/test/fixtures/v2/index.d.ts +14 -0
  197. package/dist/types/test/fixtures/v2/jsxTranspile.d.ts +4 -0
  198. package/dist/types/test/fixtures/v2/reactDomImport.d.ts +4 -0
  199. package/dist/types/test/fixtures/v2/reactDomImportPkg.d.ts +5 -0
  200. package/dist/types/test/fixtures/v2/reactImport.d.ts +4 -0
  201. package/dist/types/test/fixtures/v2/reactImportPkg.d.ts +5 -0
  202. package/dist/types/test/fixtures/v2/sourceMapErrorFixture.d.ts +5 -0
  203. package/dist/types/test/fixtures/v2/unicodeSupport.d.ts +4 -0
  204. package/dist/types/test/fixtures/v3/basicIndexJS.d.ts +3 -0
  205. package/dist/types/test/fixtures/v3/cssImport.d.ts +4 -0
  206. package/dist/types/test/fixtures/v3/csvImport.d.ts +4 -0
  207. package/dist/types/test/fixtures/v3/csvStrangeChars.d.ts +4 -0
  208. package/dist/types/test/fixtures/v3/index.d.ts +9 -0
  209. package/dist/types/test/fixtures/v3/jsExport.d.ts +4 -0
  210. package/dist/types/test/fixtures/v3/sourcemap.d.ts +3 -0
  211. package/dist/types/test/fixtures/v3/svelte.d.ts +4 -0
  212. package/dist/types/test/fixtures/v3/vizContent.d.ts +2 -0
  213. package/dist/types/test/fixtures/v3/vizImport.d.ts +6 -0
  214. package/dist/types/test/fixtures/v4/d3Usage.d.ts +5 -0
  215. package/dist/types/test/fixtures/v4/esmBuild.d.ts +5 -0
  216. package/dist/types/test/fixtures/v4/fetchInterception.d.ts +5 -0
  217. package/dist/types/test/fixtures/v4/index.d.ts +9 -0
  218. package/dist/types/test/fixtures/v4/jsScriptTagTypeModule.d.ts +4 -0
  219. package/dist/types/test/fixtures/v4/jsScriptTagTypeModules.d.ts +5 -0
  220. package/dist/types/test/fixtures/v4/reactHooks.d.ts +6 -0
  221. package/dist/types/test/fixtures/v4/reactJsx.d.ts +6 -0
  222. package/dist/types/test/fixtures/v4/threeJsUsage.d.ts +4 -0
  223. package/dist/types/test/fixtures/v4/typeScriptSupport.d.ts +5 -0
  224. package/dist/types/test/testInBrowser.d.ts +15 -0
  225. package/dist/types/test/testStackTrace.d.ts +9 -0
  226. package/dist/types/test/v1.test.d.ts +1 -0
  227. package/dist/types/test/v2.test.d.ts +1 -0
  228. package/dist/types/test/v3.test.d.ts +1 -0
  229. package/dist/types/test/v4.test.d.ts +1 -0
  230. package/dist/types/types.d.ts +1 -0
  231. package/dist/types/utils/vizContentToFileCollection.d.ts +7 -0
  232. package/dist/types/utils/vizContentToFileCollection.test.d.ts +1 -0
  233. package/dist/types/v2/computeBundleJSV2.d.ts +7 -0
  234. package/dist/types/v2/getComputedIndexHtml.d.ts +4 -0
  235. package/dist/types/v2/getComputedIndexHtml.test.d.ts +1 -0
  236. package/dist/types/v2/index.d.ts +1 -0
  237. package/dist/types/v2/v2Build.d.ts +7 -0
  238. package/dist/types/v3/cleanRollupErrorMessage.d.ts +4 -0
  239. package/dist/types/v3/computeBundleJSV3.d.ts +17 -0
  240. package/dist/types/v3/createVizContent.d.ts +8 -0
  241. package/dist/types/v3/extractVizImport.d.ts +6 -0
  242. package/dist/types/v3/extractVizImport.test.d.ts +1 -0
  243. package/dist/types/v3/htmlTemplate.d.ts +5 -0
  244. package/dist/types/v3/index.d.ts +1 -0
  245. package/dist/types/v3/parseId.d.ts +6 -0
  246. package/dist/types/v3/parseId.test.d.ts +1 -0
  247. package/dist/types/v3/setupV3Runtime.d.ts +15 -0
  248. package/dist/types/v3/slugCache.d.ts +11 -0
  249. package/dist/types/v3/slugCache.test.d.ts +1 -0
  250. package/dist/types/v3/transformDSV/dsvParseSrc.d.ts +1 -0
  251. package/dist/types/v3/transformDSV/index.d.ts +2 -0
  252. package/dist/types/v3/transformSvelte.d.ts +8 -0
  253. package/dist/types/v3/types.d.ts +65 -0
  254. package/dist/types/v3/v3Build.d.ts +14 -0
  255. package/dist/types/v3/vizCache.d.ts +10 -0
  256. package/dist/types/v3/vizCache.test.d.ts +1 -0
  257. package/dist/types/v3/vizLoad.d.ts +7 -0
  258. package/dist/types/v3/vizResolve.d.ts +7 -0
  259. package/dist/types/v4/index.d.ts +10 -0
  260. package/package.json +14 -7
@@ -0,0 +1,6 @@
1
+ export { basicHTML } from "./basicHTML";
2
+ export { jsScriptTag } from "./jsScriptTag";
3
+ export { fetchProxy } from "./fetchProxy";
4
+ export { styleTest } from "./styleTest";
5
+ export { xmlTest } from "./xmlTest";
6
+ export { protocolTest } from "./protocolTest";
@@ -0,0 +1,9 @@
1
+ export const jsScriptTag = {
2
+ "index.html": `<!DOCTYPE html>
3
+ <html>
4
+ <body>
5
+ <script src="index.js"></script>
6
+ </body>
7
+ </html>`,
8
+ "index.js": `console.log('Hello, JS!');`,
9
+ };
@@ -0,0 +1,15 @@
1
+ export const protocolTest = {
2
+ "index.html": `<!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <link href="//fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
6
+ <script src="//code.jquery.com/jquery-3.6.0.min.js"></script>
7
+ </head>
8
+ <body>
9
+ <div>Protocol Test</div>
10
+ <script>
11
+ console.log('Protocol test loaded');
12
+ </script>
13
+ </body>
14
+ </html>`,
15
+ };
@@ -0,0 +1,15 @@
1
+ export const styleTest = {
2
+ "index.html": `<!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <link rel="stylesheet" href="styles.css">
6
+ </head>
7
+ <body>
8
+ <div id="test">Test</div>
9
+ <script>
10
+ console.log(window.getComputedStyle(document.getElementById('test')).color);
11
+ </script>
12
+ </body>
13
+ </html>`,
14
+ "styles.css": `#test { color: rgb(255, 0, 0); }`,
15
+ };
@@ -0,0 +1,19 @@
1
+ export const xmlTest = {
2
+ "index.html": `<!DOCTYPE html>
3
+ <html>
4
+ <body>
5
+ <script>
6
+ const xhr = new XMLHttpRequest();
7
+ xhr.open('GET', 'data.xml');
8
+ xhr.onload = () => {
9
+ console.log(xhr.responseXML.documentElement.nodeName);
10
+ };
11
+ xhr.send();
12
+ </script>
13
+ </body>
14
+ </html>`,
15
+ "data.xml": `<?xml version="1.0" encoding="UTF-8"?>
16
+ <root>
17
+ <item>Test</item>
18
+ </root>`,
19
+ };
@@ -0,0 +1,5 @@
1
+ export const basicBundle = {
2
+ "index.html": "<script src='bundle.js'></script>",
3
+ "index.js": 'import { foo } from "./foo.js"; console.log(foo);',
4
+ "foo.js": 'export const foo = "bar";',
5
+ };
@@ -0,0 +1,5 @@
1
+ export const basicBundleNoExtension = {
2
+ "index.html": "<script src='bundle.js'></script>",
3
+ "index.js": 'import { foo } from "./foo"; console.log(foo);',
4
+ "foo.js": 'export const foo = "bar";',
5
+ };
@@ -0,0 +1,7 @@
1
+ export const d3Import = {
2
+ "index.html": `
3
+ <script src='https://cdn.jsdelivr.net/npm/d3@6.7.0/dist/d3.min.js'></script>
4
+ <script src='bundle.js'></script>
5
+ `,
6
+ "index.js": 'import { select } from "d3"; console.log(typeof select);',
7
+ };
@@ -0,0 +1,19 @@
1
+ export const d3ImportPkg = {
2
+ "index.html": `
3
+ <script src='bundle.js'></script>
4
+ `,
5
+ "index.js": 'import { select } from "d3"; console.log(typeof select);',
6
+ "package.json": `{
7
+ "dependencies": {
8
+ "d3": "6.7.0"
9
+ },
10
+ "vizhub": {
11
+ "libraries": {
12
+ "d3": {
13
+ "global": "d3",
14
+ "path": "/dist/d3.min.js"
15
+ }
16
+ }
17
+ }
18
+ }`,
19
+ };
@@ -0,0 +1,19 @@
1
+ export const d3RosettaImportPkg = {
2
+ "index.html": `
3
+ <script src='bundle.js'></script>
4
+ `,
5
+ "index.js": 'import { one } from "d3-rosetta"; console.log(typeof one);',
6
+ "package.json": `{
7
+ "dependencies": {
8
+ "d3-rosetta": "1.0.0"
9
+ },
10
+ "vizhub": {
11
+ "libraries": {
12
+ "d3-rosetta": {
13
+ "global": "d3Rosetta",
14
+ "path": "/dist/d3-rosetta.umd.js"
15
+ }
16
+ }
17
+ }
18
+ }`,
19
+ };
@@ -0,0 +1,6 @@
1
+ export const es6Preserve = {
2
+ "index.html": `
3
+ <script src='bundle.js'></script>
4
+ `,
5
+ "index.js": "const fn = a => a * a; console.log(fn(4));",
6
+ };
@@ -0,0 +1,6 @@
1
+ export const generatorSupport = {
2
+ "index.html": `
3
+ <script src='bundle.js'></script>
4
+ `,
5
+ "index.js": "console.log(function* () { yield 5; }().next().value)",
6
+ };
@@ -0,0 +1,15 @@
1
+ export { basicBundle } from "./basicBundle";
2
+ export { basicBundleNoExtension } from "./basicBundleNoExtension";
3
+ export { d3Import } from "./d3Import";
4
+ export { d3ImportPkg } from "./d3ImportPkg";
5
+ export { reactImport } from "./reactImport";
6
+ export { reactImportPkg } from "./reactImportPkg";
7
+ export { reactDomImport } from "./reactDomImport";
8
+ export { reactDomImportPkg } from "./reactDomImportPkg";
9
+ export { jsxTranspile } from "./jsxTranspile";
10
+ export { es6Preserve } from "./es6Preserve";
11
+ export { generatorSupport } from "./generatorSupport";
12
+ export { unicodeSupport } from "./unicodeSupport";
13
+ export { d3RosettaImportPkg } from "./d3RosettaImportPkg";
14
+ // Make sure to add the sourceMapErrorFixture to the exports
15
+ export * from "./sourceMapErrorFixture";
@@ -0,0 +1,6 @@
1
+ export const jsxTranspile = {
2
+ "index.html": `
3
+ <script src='bundle.js'></script>
4
+ `,
5
+ "index.js": "<div>Hello JSX!</div>",
6
+ };
@@ -0,0 +1,8 @@
1
+ export const reactDomImport = {
2
+ "index.html": `
3
+ <script src='https://cdn.jsdelivr.net/npm/react@18.3.1/umd/react.production.min.js'></script>
4
+ <script src='https://cdn.jsdelivr.net/npm/react-dom@18.3.1/umd/react-dom.production.min.js'></script>
5
+ <script src='bundle.js'></script>
6
+ `,
7
+ "index.js": 'import ReactDOM from "react-dom"; console.log(typeof ReactDOM);',
8
+ };
@@ -0,0 +1,24 @@
1
+ export const reactDomImportPkg = {
2
+ "index.html": `
3
+ <script src='bundle.js'></script>
4
+ `,
5
+ "index.js": 'import ReactDOM from "react-dom"; console.log(typeof ReactDOM);',
6
+ "package.json": `{
7
+ "dependencies": {
8
+ "react": "18.2.0",
9
+ "react-dom": "18.2.0"
10
+ },
11
+ "vizhub": {
12
+ "libraries": {
13
+ "react": {
14
+ "global": "React",
15
+ "path": "/umd/react.production.min.js"
16
+ },
17
+ "react-dom": {
18
+ "global": "ReactDOM",
19
+ "path": "/umd/react-dom.production.min.js"
20
+ }
21
+ }
22
+ }
23
+ }`,
24
+ };
@@ -0,0 +1,7 @@
1
+ export const reactImport = {
2
+ "index.html": `
3
+ <script src='https://cdn.jsdelivr.net/npm/react@18.3.1/umd/react.production.min.js'></script>
4
+ <script src='bundle.js'></script>
5
+ `,
6
+ "index.js": 'import React from "react"; console.log(typeof React);',
7
+ };
@@ -0,0 +1,17 @@
1
+ export const reactImportPkg = {
2
+ "index.html": `<script src='bundle.js'></script>`,
3
+ "index.js": 'import React from "react"; console.log(typeof React);',
4
+ "package.json": `{
5
+ "dependencies": {
6
+ "react": "18.2.0"
7
+ },
8
+ "vizhub": {
9
+ "libraries": {
10
+ "react": {
11
+ "global": "React",
12
+ "path": "/umd/react.production.min.js"
13
+ }
14
+ }
15
+ }
16
+ }`,
17
+ };
@@ -0,0 +1,19 @@
1
+ export const sourceMapErrorFixture = {
2
+ "index.html": "<script src='bundle.js'></script>",
3
+ "index.js": `
4
+ import { generateError } from "./error.js";
5
+
6
+ // Line numbers are important for this test
7
+ // This will be line 6 in the original source
8
+ generateError();
9
+
10
+ // Add a console log to help debug
11
+ console.log("If you see this, the error was caught by the window.onerror handler");
12
+ `,
13
+ "error.js": `
14
+ export function generateError() {
15
+ // This is line 3 in error.js
16
+ throw new Error("Test error for sourcemap validation");
17
+ }
18
+ `,
19
+ };
@@ -0,0 +1,6 @@
1
+ export const unicodeSupport = {
2
+ "index.html": `
3
+ <script src='bundle.js'></script>
4
+ `,
5
+ "index.js": 'console.log("Привет")',
6
+ };
@@ -0,0 +1,7 @@
1
+ export const basicIndexJS = {
2
+ "index.js": `
3
+ export const main = () => {
4
+ console.log("Hello main!");
5
+ }
6
+ `,
7
+ };
@@ -0,0 +1,9 @@
1
+ export const cssImport = {
2
+ "index.js": `
3
+ import './styles.css';
4
+ console.log(getComputedStyle(document.body).color);
5
+ `,
6
+ "styles.css": `
7
+ body { color: red; }
8
+ `,
9
+ };
@@ -0,0 +1,11 @@
1
+ export const csvImport = {
2
+ "index.js": `
3
+ import data from './data.csv';
4
+ console.log(data[0].variety);
5
+ `,
6
+ "data.csv": `"sepal.length","sepal.width","petal.length","petal.width","variety"
7
+ 5.1,3.5,1.4,.2,"Setosa"
8
+ 4.9,3,1.4,.2,"Setosa"
9
+ 4.7,3.2,1.3,.2,"Setosa"
10
+ 4.6,3.1,1.5,.2,"Setosa"`,
11
+ };
@@ -0,0 +1,12 @@
1
+ export const csvStrangeChars = {
2
+ "index.js": `
3
+ import data from './data.csv';
4
+ console.log(data[0].Country);
5
+ `,
6
+ "data.csv": `Country,Users,New users,Engaged sessions,Engagement rate,Engaged sessions per user,Average engagement time,Event count,Conversions,Total revenue
7
+ Türkiye,180,177,133,0.5450819672131147,0.7388888888888889,86.22777777777777,1007,0,0
8
+ (not set),28,27,2,0.06896551724137931,0.07142857142857142,7.178571428571429,101,0,0
9
+ Myanmar (Burma),11,11,29,0.58,2.6363636363636362,141.0909090909091,209,0,0
10
+ Côte d'Ivoire,10,10,8,0.6666666666666666,0.8,33.4,57,0,0
11
+ Réunion,1,1,0,0,0,0,5,0,0`,
12
+ };
@@ -0,0 +1,9 @@
1
+ export { basicIndexJS } from "./basicIndexJS";
2
+ export { sampleVizContent } from "./vizContent";
3
+ export { jsExport } from "./jsExport";
4
+ export { cssImport } from "./cssImport";
5
+ export { csvImport } from "./csvImport";
6
+ export { csvStrangeChars } from "./csvStrangeChars";
7
+ export { sampleContent, sampleContentVizImport, sampleContentVizImportSlug, sampleContentWithCSS, sampleContentVizImportWithCSS, } from "./vizImport";
8
+ export { svelte } from "./svelte";
9
+ export { sourcemap } from "./sourcemap";
@@ -0,0 +1,10 @@
1
+ export const jsExport = {
2
+ "index.js": `
3
+ import { innerMessage } from './message';
4
+ export const message = "Outer " + innerMessage;
5
+ console.log(message);
6
+ `,
7
+ "message.js": `
8
+ export const innerMessage = "Inner";
9
+ `,
10
+ };
@@ -0,0 +1,10 @@
1
+ export const sourcemap = {
2
+ "index.js": `
3
+ const x = 1;
4
+ const y = 2;
5
+ console.log(x + y);
6
+
7
+ // The error should resolve to this line number, 6.
8
+ throw new Error("Hello main!");
9
+ `,
10
+ };
@@ -0,0 +1,18 @@
1
+ export const svelte = {
2
+ "App.svelte": `
3
+ <script>
4
+ const name = 'Svelte';
5
+ console.log(name);
6
+ </script>
7
+ <h1>Hello {name}!</h1>
8
+ `,
9
+ "index.js": `
10
+ import App from './App.svelte';
11
+
12
+ export const main = (container) => {
13
+ new App({
14
+ target: container,
15
+ });
16
+ };
17
+ `,
18
+ };
@@ -0,0 +1,11 @@
1
+ import { createVizContent } from "../../../v3/createVizContent";
2
+ // Content for testing JS imports
3
+ export const sampleVizContent = createVizContent({
4
+ "index.js": `
5
+ import { innerMessage } from './message';
6
+ export const message = "Outer " + innerMessage;
7
+ `,
8
+ "message.js": `
9
+ export const innerMessage = "Inner";
10
+ `,
11
+ });
@@ -0,0 +1,85 @@
1
+ // Sample content for testing JS imports
2
+ export const sampleContent = {
3
+ id: "84bddfb1cc0545f299e5083c3e71e0bb",
4
+ files: {
5
+ "7548392": {
6
+ name: "index.js",
7
+ text: `
8
+ import { innerMessage } from './message';
9
+ export const message = "Outer " + innerMessage;
10
+ `,
11
+ },
12
+ "6714854": {
13
+ name: "message.js",
14
+ text: `
15
+ export const innerMessage = "Inner";
16
+ `,
17
+ },
18
+ },
19
+ title: "Sample Content for Exporting",
20
+ };
21
+ // Sample content for testing JS imports
22
+ // across vizzes by id
23
+ export const sampleContentVizImport = {
24
+ id: "a6014044e0c6425f911a7e128e1928a6",
25
+ files: {
26
+ "7548392": {
27
+ name: "index.js",
28
+ text: `
29
+ import { message } from '@joe/${sampleContent.id}';
30
+ console.log("Imported from viz: " + message);
31
+ `,
32
+ },
33
+ },
34
+ title: "Sample Content for Viz Importing",
35
+ };
36
+ // Sample content for testing JS imports
37
+ // across vizzes by slug
38
+ export const sampleContentVizImportSlug = {
39
+ id: "6f8aec8c3cd348d7a7d4661cc8d75c9a",
40
+ files: {
41
+ "7548392": {
42
+ name: "index.js",
43
+ text: `
44
+ import { message } from '@joe/sample-content-slug';
45
+ console.log("Imported from viz with slug: " + message);
46
+ `,
47
+ },
48
+ },
49
+ title: "Sample Content for Viz Importing",
50
+ };
51
+ // Sample content for testing CSS imports
52
+ export const sampleContentWithCSS = {
53
+ id: "cd52ba7f80834807b72e66ce4abac185",
54
+ files: {
55
+ "5473849": {
56
+ name: "index.js",
57
+ text: `
58
+ import './styles.css';
59
+ `,
60
+ },
61
+ "0175432": {
62
+ name: "styles.css",
63
+ text: `
64
+ body { color: red; }
65
+ `,
66
+ },
67
+ },
68
+ title: "Sample Content for CSS Importing",
69
+ };
70
+ // Sample content for testing CSS imports
71
+ // across vizzes
72
+ export const sampleContentVizImportWithCSS = {
73
+ id: "816040d214484b41b653bd6916a11fd9",
74
+ files: {
75
+ "7548392": {
76
+ name: "index.js",
77
+ text: `
78
+ // Import for the CSS side effect
79
+ import '@joe/${sampleContentWithCSS.id}';
80
+ console.log(getComputedStyle(document.body).color);
81
+ `,
82
+ },
83
+ },
84
+ title: "Sample Content for Viz Importing with CSS",
85
+ };
@@ -0,0 +1,31 @@
1
+ export const d3Usage = {
2
+ "index.html": `<!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title>D3 Test</title>
6
+ </head>
7
+ <body>
8
+ <div id="chart"></div>
9
+ <script type="module" src="index.js"></script>
10
+ </body>
11
+ </html>`,
12
+ "index.js": `import * as d3 from 'd3';
13
+
14
+ const svg = d3.select('#chart')
15
+ .append('svg')
16
+ .attr('width', 100)
17
+ .attr('height', 100);
18
+
19
+ svg.append('circle')
20
+ .attr('cx', 50)
21
+ .attr('cy', 50)
22
+ .attr('r', 40)
23
+ .style('fill', 'blue');
24
+
25
+ console.log('D3 chart rendered successfully');`,
26
+ "package.json": `{
27
+ "dependencies": {
28
+ "d3": "^7.8.5"
29
+ }
30
+ }`,
31
+ };
@@ -0,0 +1,18 @@
1
+ export const esmBuild = {
2
+ "index.html": `<!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title>ESM Build Test</title>
6
+ </head>
7
+ <body>
8
+ <script type="module" src="index.js"></script>
9
+ </body>
10
+ </html>`,
11
+ "index.js": `import { format } from 'date-fns';
12
+ console.log(format(new Date(), 'yyyy-MM-dd'));`,
13
+ "package.json": `{
14
+ "dependencies": {
15
+ "date-fns": "2.30.0"
16
+ }
17
+ }`,
18
+ };
@@ -0,0 +1,18 @@
1
+ export const fetchInterception = {
2
+ "index.html": `<!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title>Fetch Interception Test</title>
6
+ </head>
7
+ <body>
8
+ <script type="module" src="index.js"></script>
9
+ </body>
10
+ </html>`,
11
+ "index.js": `
12
+ fetch("data.json")
13
+ .then(response => response.json())
14
+ .then(data => console.log(data.message));`,
15
+ "data.json": `{
16
+ "message": "Fetch intercepted successfully"
17
+ }`,
18
+ };
@@ -0,0 +1,9 @@
1
+ export { jsScriptTagTypeModule } from "./jsScriptTagTypeModule";
2
+ export { jsScriptTagTypeModules } from "./jsScriptTagTypeModules";
3
+ export { fetchInterception } from "./fetchInterception";
4
+ export { esmBuild } from "./esmBuild";
5
+ export { reactJsx } from "./reactJsx";
6
+ export { d3Usage } from "./d3Usage";
7
+ export { threeJsUsage } from "./threeJsUsage";
8
+ export { reactHooks } from "./reactHooks";
9
+ export { typeScriptSupport } from "./typeScriptSupport";
@@ -0,0 +1,18 @@
1
+ export const jsScriptTagTypeModule = {
2
+ "index.html": `<!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <script type="importmap">
6
+ {
7
+ "imports": {
8
+ "greeter": "data:text/javascript;charset=utf-8,export const greeting = \\"Hello, ES Module!\\";"
9
+ }
10
+ }
11
+ </script>
12
+ </head>
13
+ <body>
14
+ <script type="module" src="index.js"></script>
15
+ </body>
16
+ </html>`,
17
+ "index.js": `import { greeting } from 'greeter';\nconsole.log(greeting);`,
18
+ };
@@ -0,0 +1,12 @@
1
+ export const jsScriptTagTypeModules = {
2
+ "index.html": `<!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ </head>
6
+ <body>
7
+ <script type="module" src="index.js"></script>
8
+ </body>
9
+ </html>`,
10
+ "index.js": `import { greeting } from './greeter.js';\nconsole.log(greeting);`,
11
+ "greeter.js": `export const greeting = "Hello, ES Module File!";`,
12
+ };
@@ -0,0 +1,47 @@
1
+ export const reactHooks = {
2
+ "index.html": `<!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title>React Hooks Test</title>
6
+ </head>
7
+ <body>
8
+ <div id="root"></div>
9
+ <script type="module" src="index.jsx"></script>
10
+ </body>
11
+ </html>`,
12
+ "index.jsx": `import React from 'react';
13
+ import ReactDOM from 'react-dom/client';
14
+ import Counter from './Counter.jsx';
15
+
16
+ ReactDOM.createRoot(document.getElementById('root')).render(
17
+ <React.StrictMode>
18
+ <Counter />
19
+ </React.StrictMode>
20
+ );`,
21
+ "Counter.jsx": `import React, { useState, useEffect } from 'react';
22
+
23
+ function Counter() {
24
+ const [count, setCount] = useState(0);
25
+
26
+ useEffect(() => {
27
+ console.log('React Hooks working: count is ' + count);
28
+ }, [count]);
29
+
30
+ return (
31
+ <div>
32
+ <p>You clicked {count} times</p>
33
+ <button onClick={() => setCount(count + 1)}>
34
+ Click me
35
+ </button>
36
+ </div>
37
+ );
38
+ }
39
+
40
+ export default Counter;`,
41
+ "package.json": `{
42
+ "dependencies": {
43
+ "react": "^18.2.0",
44
+ "react-dom": "^18.2.0"
45
+ }
46
+ }`,
47
+ };