@vizhub/runtime 0.2.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.
- package/README.md +280 -128
- package/dist/buildHTML.d.ts +14 -0
- package/dist/buildHTML.js +67 -0
- package/dist/cjs/buildHTML.js +71 -0
- package/dist/cjs/common/packageJson.js +81 -0
- package/dist/cjs/common/packageJson.test.js +148 -0
- package/dist/cjs/common/sucrasePlugin.js +27 -0
- package/dist/cjs/common/virtualFileSystem.js +79 -0
- package/dist/cjs/determineRuntimeVersion.js +26 -0
- package/dist/cjs/determineRuntimeVersion.test.js +103 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test/fixtures/v1/basicHTML.js +18 -0
- package/dist/cjs/test/fixtures/v1/fetchProxy.js +15 -0
- package/dist/cjs/test/fixtures/v1/index.js +15 -0
- package/dist/cjs/test/fixtures/v1/jsScriptTag.js +12 -0
- package/dist/cjs/test/fixtures/v1/protocolTest.js +18 -0
- package/dist/cjs/test/fixtures/v1/styleTest.js +18 -0
- package/dist/cjs/test/fixtures/v1/xmlTest.js +22 -0
- package/dist/cjs/test/fixtures/v2/basicBundle.js +8 -0
- package/dist/cjs/test/fixtures/v2/basicBundleNoExtension.js +8 -0
- package/dist/cjs/test/fixtures/v2/d3Import.js +10 -0
- package/dist/cjs/test/fixtures/v2/d3ImportPkg.js +22 -0
- package/dist/cjs/test/fixtures/v2/d3RosettaImportPkg.js +22 -0
- package/dist/cjs/test/fixtures/v2/es6Preserve.js +9 -0
- package/dist/cjs/test/fixtures/v2/generatorSupport.js +9 -0
- package/dist/cjs/test/fixtures/v2/index.js +45 -0
- package/dist/cjs/test/fixtures/v2/jsxTranspile.js +9 -0
- package/dist/cjs/test/fixtures/v2/reactDomImport.js +11 -0
- package/dist/cjs/test/fixtures/v2/reactDomImportPkg.js +27 -0
- package/dist/cjs/test/fixtures/v2/reactImport.js +10 -0
- package/dist/cjs/test/fixtures/v2/reactImportPkg.js +20 -0
- package/dist/cjs/test/fixtures/v2/sourceMapErrorFixture.js +22 -0
- package/dist/cjs/test/fixtures/v2/unicodeSupport.js +9 -0
- package/dist/cjs/test/fixtures/v3/basicIndexJS.js +10 -0
- package/dist/cjs/test/fixtures/v3/cssImport.js +12 -0
- package/dist/cjs/test/fixtures/v3/csvImport.js +14 -0
- package/dist/cjs/test/fixtures/v3/csvStrangeChars.js +15 -0
- package/dist/cjs/test/fixtures/v3/index.js +25 -0
- package/dist/cjs/test/fixtures/v3/jsExport.js +13 -0
- package/dist/cjs/test/fixtures/v3/sourcemap.js +13 -0
- package/dist/cjs/test/fixtures/v3/svelte.js +21 -0
- package/dist/cjs/test/fixtures/v3/vizContent.js +14 -0
- package/dist/cjs/test/fixtures/v3/vizImport.js +88 -0
- package/dist/cjs/test/fixtures/v4/d3Usage.js +34 -0
- package/dist/cjs/test/fixtures/v4/esmBuild.js +21 -0
- package/dist/cjs/test/fixtures/v4/fetchInterception.js +21 -0
- package/dist/cjs/test/fixtures/v4/index.js +21 -0
- package/dist/cjs/test/fixtures/v4/jsScriptTagTypeModule.js +21 -0
- package/dist/cjs/test/fixtures/v4/jsScriptTagTypeModules.js +15 -0
- package/dist/cjs/test/fixtures/v4/reactHooks.js +50 -0
- package/dist/cjs/test/fixtures/v4/reactJsx.js +37 -0
- package/dist/cjs/test/fixtures/v4/threeJsUsage.js +27 -0
- package/dist/cjs/test/fixtures/v4/typeScriptSupport.js +32 -0
- package/dist/cjs/test/testInBrowser.js +50 -0
- package/dist/cjs/test/testStackTrace.js +58 -0
- package/dist/cjs/test/v1.test.js +70 -0
- package/dist/cjs/test/v2.test.js +124 -0
- package/dist/cjs/test/v3.test.js +119 -0
- package/dist/cjs/test/v4.test.js +105 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils/vizContentToFileCollection.js +23 -0
- package/dist/cjs/utils/vizContentToFileCollection.test.js +77 -0
- package/dist/cjs/v2/computeBundleJSV2.js +33 -0
- package/dist/cjs/v2/getComputedIndexHtml.js +86 -0
- package/dist/cjs/v2/getComputedIndexHtml.test.js +136 -0
- package/dist/cjs/v2/index.js +5 -0
- package/dist/cjs/v2/v2Build.js +15 -0
- package/dist/cjs/v3/cleanRollupErrorMessage.js +13 -0
- package/dist/cjs/v3/computeBundleJSV3.js +52 -0
- package/dist/cjs/v3/createVizContent.js +27 -0
- package/dist/cjs/v3/extractVizImport.js +27 -0
- package/dist/cjs/v3/extractVizImport.test.js +32 -0
- package/dist/cjs/v3/htmlTemplate.js +93 -0
- package/dist/cjs/v3/index.js +5 -0
- package/dist/cjs/v3/parseId.js +9 -0
- package/dist/cjs/v3/parseId.test.js +27 -0
- package/dist/cjs/v3/setupV3Runtime.js +345 -0
- package/dist/cjs/v3/slugCache.js +39 -0
- package/dist/cjs/v3/slugCache.test.js +107 -0
- package/dist/cjs/v3/transformDSV/dsvParseSrc.js +124 -0
- package/dist/cjs/v3/transformDSV/index.js +44 -0
- package/dist/cjs/v3/transformSvelte.js +81 -0
- package/dist/cjs/v3/types.js +2 -0
- package/dist/cjs/v3/v3Build.js +34 -0
- package/dist/cjs/v3/vizCache.js +40 -0
- package/dist/cjs/v3/vizCache.test.js +100 -0
- package/dist/cjs/v3/vizLoad.js +50 -0
- package/dist/cjs/v3/vizResolve.js +73 -0
- package/dist/cjs/v4/index.js +138 -0
- package/dist/common/packageJson.d.ts +1 -1
- package/dist/common/virtualFileSystem.d.ts +1 -1
- package/dist/determineRuntimeVersion.d.ts +2 -1
- package/dist/esm/buildHTML.js +67 -0
- package/dist/esm/common/packageJson.js +71 -0
- package/dist/esm/common/packageJson.test.js +146 -0
- package/dist/esm/common/sucrasePlugin.js +24 -0
- package/dist/esm/common/virtualFileSystem.js +75 -0
- package/dist/esm/determineRuntimeVersion.js +22 -0
- package/dist/esm/determineRuntimeVersion.test.js +101 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/test/fixtures/v1/basicHTML.js +15 -0
- package/dist/esm/test/fixtures/v1/fetchProxy.js +12 -0
- package/dist/esm/test/fixtures/v1/index.js +6 -0
- package/dist/esm/test/fixtures/v1/jsScriptTag.js +9 -0
- package/dist/esm/test/fixtures/v1/protocolTest.js +15 -0
- package/dist/esm/test/fixtures/v1/styleTest.js +15 -0
- package/dist/esm/test/fixtures/v1/xmlTest.js +19 -0
- package/dist/esm/test/fixtures/v2/basicBundle.js +5 -0
- package/dist/esm/test/fixtures/v2/basicBundleNoExtension.js +5 -0
- package/dist/esm/test/fixtures/v2/d3Import.js +7 -0
- package/dist/esm/test/fixtures/v2/d3ImportPkg.js +19 -0
- package/dist/esm/test/fixtures/v2/d3RosettaImportPkg.js +19 -0
- package/dist/esm/test/fixtures/v2/es6Preserve.js +6 -0
- package/dist/esm/test/fixtures/v2/generatorSupport.js +6 -0
- package/dist/esm/test/fixtures/v2/index.js +15 -0
- package/dist/esm/test/fixtures/v2/jsxTranspile.js +6 -0
- package/dist/esm/test/fixtures/v2/reactDomImport.js +8 -0
- package/dist/esm/test/fixtures/v2/reactDomImportPkg.js +24 -0
- package/dist/esm/test/fixtures/v2/reactImport.js +7 -0
- package/dist/esm/test/fixtures/v2/reactImportPkg.js +17 -0
- package/dist/esm/test/fixtures/v2/sourceMapErrorFixture.js +19 -0
- package/dist/esm/test/fixtures/v2/unicodeSupport.js +6 -0
- package/dist/esm/test/fixtures/v3/basicIndexJS.js +7 -0
- package/dist/esm/test/fixtures/v3/cssImport.js +9 -0
- package/dist/esm/test/fixtures/v3/csvImport.js +11 -0
- package/dist/esm/test/fixtures/v3/csvStrangeChars.js +12 -0
- package/dist/esm/test/fixtures/v3/index.js +9 -0
- package/dist/esm/test/fixtures/v3/jsExport.js +10 -0
- package/dist/esm/test/fixtures/v3/sourcemap.js +10 -0
- package/dist/esm/test/fixtures/v3/svelte.js +18 -0
- package/dist/esm/test/fixtures/v3/vizContent.js +11 -0
- package/dist/esm/test/fixtures/v3/vizImport.js +85 -0
- package/dist/esm/test/fixtures/v4/d3Usage.js +31 -0
- package/dist/esm/test/fixtures/v4/esmBuild.js +18 -0
- package/dist/esm/test/fixtures/v4/fetchInterception.js +18 -0
- package/dist/esm/test/fixtures/v4/index.js +9 -0
- package/dist/esm/test/fixtures/v4/jsScriptTagTypeModule.js +18 -0
- package/dist/esm/test/fixtures/v4/jsScriptTagTypeModules.js +12 -0
- package/dist/esm/test/fixtures/v4/reactHooks.js +47 -0
- package/dist/esm/test/fixtures/v4/reactJsx.js +34 -0
- package/dist/esm/test/fixtures/v4/threeJsUsage.js +24 -0
- package/dist/esm/test/fixtures/v4/typeScriptSupport.js +29 -0
- package/dist/esm/test/testInBrowser.js +47 -0
- package/dist/esm/test/testStackTrace.js +55 -0
- package/dist/esm/test/v1.test.js +65 -0
- package/dist/esm/test/v2.test.js +121 -0
- package/dist/esm/test/v3.test.js +114 -0
- package/dist/esm/test/v4.test.js +100 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/vizContentToFileCollection.js +19 -0
- package/dist/esm/utils/vizContentToFileCollection.test.js +75 -0
- package/dist/esm/v2/computeBundleJSV2.js +29 -0
- package/dist/esm/v2/getComputedIndexHtml.js +81 -0
- package/dist/esm/v2/getComputedIndexHtml.test.js +134 -0
- package/dist/esm/v2/index.js +1 -0
- package/dist/esm/v2/v2Build.js +11 -0
- package/dist/esm/v3/cleanRollupErrorMessage.js +9 -0
- package/dist/esm/v3/computeBundleJSV3.js +48 -0
- package/dist/esm/v3/createVizContent.js +23 -0
- package/dist/esm/v3/extractVizImport.js +23 -0
- package/dist/esm/v3/extractVizImport.test.js +30 -0
- package/dist/esm/v3/htmlTemplate.js +89 -0
- package/dist/esm/v3/index.js +1 -0
- package/dist/esm/v3/parseId.js +5 -0
- package/dist/esm/v3/parseId.test.js +25 -0
- package/dist/esm/v3/setupV3Runtime.js +341 -0
- package/dist/esm/v3/slugCache.js +35 -0
- package/dist/esm/v3/slugCache.test.js +105 -0
- package/dist/esm/v3/transformDSV/dsvParseSrc.js +121 -0
- package/dist/esm/v3/transformDSV/index.js +40 -0
- package/dist/esm/v3/transformSvelte.js +77 -0
- package/dist/esm/v3/types.js +1 -0
- package/dist/esm/v3/v3Build.js +30 -0
- package/dist/esm/v3/vizCache.js +36 -0
- package/dist/esm/v3/vizCache.test.js +98 -0
- package/dist/esm/v3/vizLoad.js +46 -0
- package/dist/esm/v3/vizResolve.js +69 -0
- package/dist/esm/v4/index.js +134 -0
- package/dist/index.d.ts +3 -14
- package/dist/index.js +3 -67
- package/dist/test/testInBrowser.d.ts +1 -2
- package/dist/test/testStackTrace.d.ts +1 -1
- package/dist/types/buildHTML.d.ts +14 -0
- package/dist/types/common/packageJson.d.ts +39 -0
- package/dist/types/common/packageJson.test.d.ts +1 -0
- package/dist/types/common/sucrasePlugin.d.ts +2 -0
- package/dist/types/common/virtualFileSystem.d.ts +3 -0
- package/dist/types/determineRuntimeVersion.d.ts +3 -0
- package/dist/types/determineRuntimeVersion.test.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/test/fixtures/v1/basicHTML.d.ts +3 -0
- package/dist/types/test/fixtures/v1/fetchProxy.d.ts +5 -0
- package/dist/types/test/fixtures/v1/index.d.ts +6 -0
- package/dist/types/test/fixtures/v1/jsScriptTag.d.ts +4 -0
- package/dist/types/test/fixtures/v1/protocolTest.d.ts +3 -0
- package/dist/types/test/fixtures/v1/styleTest.d.ts +4 -0
- package/dist/types/test/fixtures/v1/xmlTest.d.ts +4 -0
- package/dist/types/test/fixtures/v2/basicBundle.d.ts +5 -0
- package/dist/types/test/fixtures/v2/basicBundleNoExtension.d.ts +5 -0
- package/dist/types/test/fixtures/v2/d3Import.d.ts +4 -0
- package/dist/types/test/fixtures/v2/d3ImportPkg.d.ts +5 -0
- package/dist/types/test/fixtures/v2/d3RosettaImportPkg.d.ts +5 -0
- package/dist/types/test/fixtures/v2/es6Preserve.d.ts +4 -0
- package/dist/types/test/fixtures/v2/generatorSupport.d.ts +4 -0
- package/dist/types/test/fixtures/v2/index.d.ts +14 -0
- package/dist/types/test/fixtures/v2/jsxTranspile.d.ts +4 -0
- package/dist/types/test/fixtures/v2/reactDomImport.d.ts +4 -0
- package/dist/types/test/fixtures/v2/reactDomImportPkg.d.ts +5 -0
- package/dist/types/test/fixtures/v2/reactImport.d.ts +4 -0
- package/dist/types/test/fixtures/v2/reactImportPkg.d.ts +5 -0
- package/dist/types/test/fixtures/v2/sourceMapErrorFixture.d.ts +5 -0
- package/dist/types/test/fixtures/v2/unicodeSupport.d.ts +4 -0
- package/dist/types/test/fixtures/v3/basicIndexJS.d.ts +3 -0
- package/dist/types/test/fixtures/v3/cssImport.d.ts +4 -0
- package/dist/types/test/fixtures/v3/csvImport.d.ts +4 -0
- package/dist/types/test/fixtures/v3/csvStrangeChars.d.ts +4 -0
- package/dist/types/test/fixtures/v3/index.d.ts +9 -0
- package/dist/types/test/fixtures/v3/jsExport.d.ts +4 -0
- package/dist/types/test/fixtures/v3/sourcemap.d.ts +3 -0
- package/dist/types/test/fixtures/v3/svelte.d.ts +4 -0
- package/dist/types/test/fixtures/v3/vizContent.d.ts +2 -0
- package/dist/types/test/fixtures/v3/vizImport.d.ts +6 -0
- package/dist/types/test/fixtures/v4/d3Usage.d.ts +5 -0
- package/dist/types/test/fixtures/v4/esmBuild.d.ts +5 -0
- package/dist/types/test/fixtures/v4/fetchInterception.d.ts +5 -0
- package/dist/types/test/fixtures/v4/index.d.ts +9 -0
- package/dist/types/test/fixtures/v4/jsScriptTagTypeModule.d.ts +4 -0
- package/dist/types/test/fixtures/v4/jsScriptTagTypeModules.d.ts +5 -0
- package/dist/types/test/fixtures/v4/reactHooks.d.ts +6 -0
- package/dist/types/test/fixtures/v4/reactJsx.d.ts +6 -0
- package/dist/types/test/fixtures/v4/threeJsUsage.d.ts +4 -0
- package/dist/types/test/fixtures/v4/typeScriptSupport.d.ts +5 -0
- package/dist/types/test/testInBrowser.d.ts +15 -0
- package/dist/types/test/testStackTrace.d.ts +9 -0
- package/dist/types/test/v1.test.d.ts +1 -0
- package/dist/types/test/v2.test.d.ts +1 -0
- package/dist/types/test/v3.test.d.ts +1 -0
- package/dist/types/test/v4.test.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/utils/vizContentToFileCollection.d.ts +7 -0
- package/dist/types/utils/vizContentToFileCollection.test.d.ts +1 -0
- package/dist/types/v2/computeBundleJSV2.d.ts +7 -0
- package/dist/types/v2/getComputedIndexHtml.d.ts +4 -0
- package/dist/types/v2/getComputedIndexHtml.test.d.ts +1 -0
- package/dist/types/v2/index.d.ts +1 -0
- package/dist/types/v2/v2Build.d.ts +7 -0
- package/dist/types/v3/cleanRollupErrorMessage.d.ts +4 -0
- package/dist/types/v3/computeBundleJSV3.d.ts +17 -0
- package/dist/types/v3/createVizContent.d.ts +8 -0
- package/dist/types/v3/extractVizImport.d.ts +6 -0
- package/dist/types/v3/extractVizImport.test.d.ts +1 -0
- package/dist/types/v3/htmlTemplate.d.ts +5 -0
- package/dist/types/v3/index.d.ts +1 -0
- package/dist/types/v3/parseId.d.ts +6 -0
- package/dist/types/v3/parseId.test.d.ts +1 -0
- package/dist/types/v3/setupV3Runtime.d.ts +15 -0
- package/dist/types/v3/slugCache.d.ts +11 -0
- package/dist/types/v3/slugCache.test.d.ts +1 -0
- package/dist/types/v3/transformDSV/dsvParseSrc.d.ts +1 -0
- package/dist/types/v3/transformDSV/index.d.ts +2 -0
- package/dist/types/v3/transformSvelte.d.ts +8 -0
- package/dist/types/v3/types.d.ts +65 -0
- package/dist/types/v3/v3Build.d.ts +14 -0
- package/dist/types/v3/vizCache.d.ts +10 -0
- package/dist/types/v3/vizCache.test.d.ts +1 -0
- package/dist/types/v3/vizLoad.d.ts +7 -0
- package/dist/types/v3/vizResolve.d.ts +7 -0
- package/dist/types/v4/index.d.ts +10 -0
- package/dist/types.d.ts +0 -1
- package/dist/utils/vizContentToFileCollection.d.ts +1 -2
- package/dist/v2/computeBundleJSV2.d.ts +1 -1
- package/dist/v2/getComputedIndexHtml.d.ts +1 -1
- package/dist/v2/v2Build.d.ts +1 -1
- package/dist/v3/cleanRollupErrorMessage.d.ts +4 -0
- package/dist/v3/cleanRollupErrorMessage.js +9 -0
- package/dist/v3/computeBundleJSV3.d.ts +1 -2
- package/dist/v3/createVizContent.d.ts +1 -2
- package/dist/v3/setupV3Runtime.d.ts +15 -0
- package/dist/v3/setupV3Runtime.js +341 -0
- package/dist/v3/v3Build.d.ts +1 -2
- package/dist/v3/v3Build.js +1 -1
- package/dist/v3/vizLoad.js +1 -1
- package/dist/v4/index.d.ts +1 -1
- package/package.json +25 -16
@@ -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,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,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,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
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
export const reactJsx = {
|
2
|
+
"index.html": `<!DOCTYPE html>
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>React JSX 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 App from './App.jsx';
|
15
|
+
|
16
|
+
ReactDOM.createRoot(document.getElementById('root')).render(
|
17
|
+
<React.StrictMode>
|
18
|
+
<App />
|
19
|
+
</React.StrictMode>
|
20
|
+
);`,
|
21
|
+
"App.jsx": `import React from 'react';
|
22
|
+
|
23
|
+
function App() {
|
24
|
+
return <div>Hello React JSX!</div>;
|
25
|
+
}
|
26
|
+
|
27
|
+
export default App;`,
|
28
|
+
"package.json": `{
|
29
|
+
"dependencies": {
|
30
|
+
"react": "^18.2.0",
|
31
|
+
"react-dom": "^18.2.0"
|
32
|
+
}
|
33
|
+
}`,
|
34
|
+
};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
export const threeJsUsage = {
|
2
|
+
"index.html": `<!DOCTYPE html>
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Three.js Test</title>
|
6
|
+
<script type="importmap">
|
7
|
+
{
|
8
|
+
"imports": {
|
9
|
+
"three": "https://cdn.jsdelivr.net/npm/three@0.175.0/build/three.module.js",
|
10
|
+
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.175.0/examples/jsm/"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
</script>
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<script type="module" src="index.js"></script>
|
17
|
+
</body>
|
18
|
+
</html>`,
|
19
|
+
"index.js": `
|
20
|
+
import * as THREE from 'three';
|
21
|
+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
22
|
+
console.log('Three.js imports:', typeof THREE, typeof OrbitControls);
|
23
|
+
`,
|
24
|
+
};
|
@@ -0,0 +1,29 @@
|
|
1
|
+
export const typeScriptSupport = {
|
2
|
+
"index.html": `<!DOCTYPE html>
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>TypeScript Test</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="app"></div>
|
9
|
+
<script type="module" src="index.ts"></script>
|
10
|
+
</body>
|
11
|
+
</html>`,
|
12
|
+
"index.ts": `import { Person } from './person';
|
13
|
+
|
14
|
+
const person: Person = {
|
15
|
+
name: 'John Doe',
|
16
|
+
age: 30
|
17
|
+
};
|
18
|
+
|
19
|
+
document.getElementById('app')!.innerHTML = \`
|
20
|
+
<h1>Hello, \${person.name}!</h1>
|
21
|
+
<p>You are \${person.age} years old.</p>
|
22
|
+
\`;
|
23
|
+
|
24
|
+
console.log('TypeScript is working');`,
|
25
|
+
"person.ts": `export interface Person {
|
26
|
+
name: string;
|
27
|
+
age: number;
|
28
|
+
}`,
|
29
|
+
};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { rollup } from "rollup";
|
2
|
+
import { expect } from "vitest";
|
3
|
+
import { buildHTML } from "../index";
|
4
|
+
const DEBUG = false;
|
5
|
+
export async function testInBrowser({ browser, files, vizCache, slugCache, vizId, expectedLog, evaluateInBrowser, getSvelteCompiler, }) {
|
6
|
+
const page = await browser.newPage();
|
7
|
+
try {
|
8
|
+
// Capture console.log output
|
9
|
+
const logs = [];
|
10
|
+
page.on("console", (message) => logs.push(message.text()));
|
11
|
+
// Capture page errors
|
12
|
+
page.on("pageerror", (error) => {
|
13
|
+
console.error("[testInBrowser] pageerror:", error);
|
14
|
+
});
|
15
|
+
// Load the HTML
|
16
|
+
const html = await buildHTML({
|
17
|
+
files,
|
18
|
+
vizCache,
|
19
|
+
slugCache,
|
20
|
+
vizId,
|
21
|
+
rollup,
|
22
|
+
getSvelteCompiler,
|
23
|
+
});
|
24
|
+
await page.setContent(html);
|
25
|
+
// Wait a bit for scripts to execute
|
26
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
27
|
+
DEBUG && console.log("[testInBrowser] html:", html);
|
28
|
+
DEBUG && console.log("[testInBrowser] logs:", logs);
|
29
|
+
// Check console output
|
30
|
+
if (typeof expectedLog === "string") {
|
31
|
+
expect(logs).toContain(expectedLog);
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
// If it's a RegExp, find a log that matches
|
35
|
+
const matchingLog = logs.find((log) => expectedLog.test(log));
|
36
|
+
expect(matchingLog).toBeDefined();
|
37
|
+
}
|
38
|
+
// If evaluateInBrowser is provided, run it and expect the result to be truthy
|
39
|
+
if (evaluateInBrowser) {
|
40
|
+
const result = await evaluateInBrowser(page);
|
41
|
+
expect(result).toBeTruthy();
|
42
|
+
}
|
43
|
+
}
|
44
|
+
finally {
|
45
|
+
await page.close();
|
46
|
+
}
|
47
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { rollup } from "rollup";
|
2
|
+
import { expect } from "vitest";
|
3
|
+
import { buildHTML } from "../index";
|
4
|
+
const DEBUG = false;
|
5
|
+
// Invokes Puppeteer to test the HTML in a browser,
|
6
|
+
// and isolates the console.log output to check against expectedLog.
|
7
|
+
// Captures stack trace from an error in the page and validates that sourcemaps are working
|
8
|
+
export async function testStackTrace({ browser, files, expectedLineNumber, }) {
|
9
|
+
const page = await browser.newPage();
|
10
|
+
let errorCaptured = false;
|
11
|
+
try {
|
12
|
+
// Enable sourcemaps for proper stack traces
|
13
|
+
const html = await buildHTML({
|
14
|
+
files,
|
15
|
+
rollup,
|
16
|
+
enableSourcemap: true,
|
17
|
+
});
|
18
|
+
// Capture page errors with their stack traces
|
19
|
+
page.on("pageerror", (error) => {
|
20
|
+
errorCaptured = true;
|
21
|
+
const stack = error.stack || "";
|
22
|
+
DEBUG &&
|
23
|
+
console.log("[testStackTrace] Error stack:", stack);
|
24
|
+
// Verify the error message contains the expected text
|
25
|
+
expect(error.message).toContain("Hello main!");
|
26
|
+
// Find any stack frame with a line number close to what we expect
|
27
|
+
// Different browsers format stack traces differently
|
28
|
+
const stackLines = stack.split("\n");
|
29
|
+
let foundExpectedLineNumber = false;
|
30
|
+
for (const line of stackLines) {
|
31
|
+
// Look for patterns like: at generateError (error.js:3:3) or at file:///path/bundle.js:20:3
|
32
|
+
const lineMatches = line.match(/:(\d+):/);
|
33
|
+
if (lineMatches && lineMatches[1]) {
|
34
|
+
const lineNumber = parseInt(lineMatches[1], 10);
|
35
|
+
DEBUG &&
|
36
|
+
console.log(`[testStackTrace] Found line number in stack: ${lineNumber}`);
|
37
|
+
// Check if this line number matches any of our expected line numbers
|
38
|
+
if (expectedLineNumber === lineNumber) {
|
39
|
+
foundExpectedLineNumber = true;
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
expect(foundExpectedLineNumber, `Stack trace should contain expected line number(s): ${expectedLineNumber}`).toBe(true);
|
45
|
+
});
|
46
|
+
await page.setContent(html);
|
47
|
+
// Wait a bit for scripts to execute and error to be thrown
|
48
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
49
|
+
// Verify that we actually captured an error
|
50
|
+
expect(errorCaptured, "An error should have been thrown").toBe(true);
|
51
|
+
}
|
52
|
+
finally {
|
53
|
+
await page.close();
|
54
|
+
}
|
55
|
+
}
|