@vizhub/runtime 0.1.4 → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +376 -178
- package/dist/buildHTML.d.ts +14 -0
- package/dist/buildHTML.js +67 -0
- package/dist/common/packageJson.d.ts +39 -0
- package/dist/common/packageJson.js +71 -0
- package/dist/common/packageJson.test.d.ts +1 -0
- package/dist/common/packageJson.test.js +146 -0
- package/dist/common/sucrasePlugin.d.ts +2 -0
- package/dist/common/sucrasePlugin.js +24 -0
- package/dist/common/virtualFileSystem.d.ts +3 -0
- package/dist/common/virtualFileSystem.js +75 -0
- package/dist/determineRuntimeVersion.d.ts +3 -0
- package/dist/determineRuntimeVersion.js +22 -0
- package/dist/determineRuntimeVersion.test.d.ts +1 -0
- package/dist/determineRuntimeVersion.test.js +101 -0
- package/dist/fixtures/basicHTML.d.ts +2 -0
- package/dist/fixtures/basicHTML.js +22 -0
- package/dist/fixtures/fetchProxy.d.ts +2 -0
- package/dist/fixtures/fetchProxy.js +25 -0
- package/dist/fixtures/index.d.ts +3 -0
- package/dist/fixtures/index.js +9 -0
- package/dist/fixtures/jsScriptTag.d.ts +2 -0
- package/dist/fixtures/jsScriptTag.js +19 -0
- package/dist/index.d.ts +3 -8
- package/dist/index.js +3 -24890
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +50 -0
- package/dist/magicSandbox/fixProtocollessUrls.d.ts +4 -0
- package/dist/magicSandbox/fixProtocollessUrls.js +10 -0
- package/dist/magicSandbox/generateInterceptorScript.d.ts +4 -0
- package/dist/magicSandbox/generateInterceptorScript.js +178 -0
- package/dist/magicSandbox/index.d.ts +19 -0
- package/dist/magicSandbox/index.js +48 -0
- package/dist/test/fixtures/basicHTML.d.ts +2 -0
- package/dist/test/fixtures/basicHTML.js +19 -0
- package/dist/test/fixtures/fetchProxy.d.ts +2 -0
- package/dist/test/fixtures/fetchProxy.js +22 -0
- package/dist/test/fixtures/index.d.ts +6 -0
- package/dist/test/fixtures/index.js +6 -0
- package/dist/test/fixtures/jsScriptTag.d.ts +2 -0
- package/dist/test/fixtures/jsScriptTag.js +16 -0
- package/dist/test/fixtures/magicSandbox/basicHTML.d.ts +5 -0
- package/dist/test/fixtures/magicSandbox/basicHTML.js +17 -0
- package/dist/test/fixtures/magicSandbox/fetchProxy.d.ts +11 -0
- package/dist/test/fixtures/magicSandbox/fetchProxy.js +18 -0
- package/dist/test/fixtures/magicSandbox/index.d.ts +6 -0
- package/dist/test/fixtures/magicSandbox/index.js +6 -0
- package/dist/test/fixtures/magicSandbox/jsScriptTag.d.ts +8 -0
- package/dist/test/fixtures/magicSandbox/jsScriptTag.js +13 -0
- package/dist/test/fixtures/magicSandbox/protocolTest.d.ts +5 -0
- package/dist/test/fixtures/magicSandbox/protocolTest.js +17 -0
- package/dist/test/fixtures/magicSandbox/styleTest.d.ts +8 -0
- package/dist/test/fixtures/magicSandbox/styleTest.js +19 -0
- package/dist/test/fixtures/magicSandbox/xmlTest.d.ts +8 -0
- package/dist/test/fixtures/magicSandbox/xmlTest.js +23 -0
- package/dist/test/fixtures/protocolTest.d.ts +2 -0
- package/dist/test/fixtures/protocolTest.js +19 -0
- package/dist/test/fixtures/styleTest.d.ts +2 -0
- package/dist/test/fixtures/styleTest.js +22 -0
- package/dist/test/fixtures/v1/basicHTML.d.ts +3 -0
- package/dist/test/fixtures/v1/basicHTML.js +15 -0
- package/dist/test/fixtures/v1/fetchProxy.d.ts +5 -0
- package/dist/test/fixtures/v1/fetchProxy.js +12 -0
- package/dist/test/fixtures/v1/index.d.ts +6 -0
- package/dist/test/fixtures/v1/index.js +6 -0
- package/dist/test/fixtures/v1/jsScriptTag.d.ts +4 -0
- package/dist/test/fixtures/v1/jsScriptTag.js +9 -0
- package/dist/test/fixtures/v1/protocolTest.d.ts +3 -0
- package/dist/test/fixtures/v1/protocolTest.js +15 -0
- package/dist/test/fixtures/v1/styleTest.d.ts +4 -0
- package/dist/test/fixtures/v1/styleTest.js +15 -0
- package/dist/test/fixtures/v1/xmlTest.d.ts +4 -0
- package/dist/test/fixtures/v1/xmlTest.js +19 -0
- package/dist/test/fixtures/v2/basicBundle.d.ts +5 -0
- package/dist/test/fixtures/v2/basicBundle.js +5 -0
- package/dist/test/fixtures/v2/basicBundleNoExtension.d.ts +5 -0
- package/dist/test/fixtures/v2/basicBundleNoExtension.js +5 -0
- package/dist/test/fixtures/v2/d3Import.d.ts +4 -0
- package/dist/test/fixtures/v2/d3Import.js +7 -0
- package/dist/test/fixtures/v2/d3ImportPkg.d.ts +5 -0
- package/dist/test/fixtures/v2/d3ImportPkg.js +19 -0
- package/dist/test/fixtures/v2/d3RosettaImportPkg.d.ts +5 -0
- package/dist/test/fixtures/v2/d3RosettaImportPkg.js +19 -0
- package/dist/test/fixtures/v2/es6Preserve.d.ts +4 -0
- package/dist/test/fixtures/v2/es6Preserve.js +6 -0
- package/dist/test/fixtures/v2/generatorSupport.d.ts +4 -0
- package/dist/test/fixtures/v2/generatorSupport.js +6 -0
- package/dist/test/fixtures/v2/index.d.ts +14 -0
- package/dist/test/fixtures/v2/index.js +15 -0
- package/dist/test/fixtures/v2/jsxTranspile.d.ts +4 -0
- package/dist/test/fixtures/v2/jsxTranspile.js +6 -0
- package/dist/test/fixtures/v2/reactDomImport.d.ts +4 -0
- package/dist/test/fixtures/v2/reactDomImport.js +8 -0
- package/dist/test/fixtures/v2/reactDomImportPkg.d.ts +5 -0
- package/dist/test/fixtures/v2/reactDomImportPkg.js +24 -0
- package/dist/test/fixtures/v2/reactImport.d.ts +4 -0
- package/dist/test/fixtures/v2/reactImport.js +7 -0
- package/dist/test/fixtures/v2/reactImportPkg.d.ts +5 -0
- package/dist/test/fixtures/v2/reactImportPkg.js +17 -0
- package/dist/test/fixtures/v2/sourceMapErrorFixture.d.ts +5 -0
- package/dist/test/fixtures/v2/sourceMapErrorFixture.js +19 -0
- package/dist/test/fixtures/v2/unicodeSupport.d.ts +4 -0
- package/dist/test/fixtures/v2/unicodeSupport.js +6 -0
- package/dist/test/fixtures/v3/basicIndexJS.d.ts +3 -0
- package/dist/test/fixtures/v3/basicIndexJS.js +7 -0
- package/dist/test/fixtures/v3/cssImport.d.ts +4 -0
- package/dist/test/fixtures/v3/cssImport.js +9 -0
- package/dist/test/fixtures/v3/csvImport.d.ts +4 -0
- package/dist/test/fixtures/v3/csvImport.js +11 -0
- package/dist/test/fixtures/v3/csvStrangeChars.d.ts +4 -0
- package/dist/test/fixtures/v3/csvStrangeChars.js +12 -0
- package/dist/test/fixtures/v3/index.d.ts +9 -0
- package/dist/test/fixtures/v3/index.js +9 -0
- package/dist/test/fixtures/v3/jsExport.d.ts +4 -0
- package/dist/test/fixtures/v3/jsExport.js +10 -0
- package/dist/test/fixtures/v3/sourcemap.d.ts +3 -0
- package/dist/test/fixtures/v3/sourcemap.js +10 -0
- package/dist/test/fixtures/v3/svelte.d.ts +4 -0
- package/dist/test/fixtures/v3/svelte.js +18 -0
- package/dist/test/fixtures/v3/vizContent.d.ts +2 -0
- package/dist/test/fixtures/v3/vizContent.js +11 -0
- package/dist/test/fixtures/v3/vizImport.d.ts +6 -0
- package/dist/test/fixtures/v3/vizImport.js +85 -0
- package/dist/test/fixtures/v4/d3Usage.d.ts +5 -0
- package/dist/test/fixtures/v4/d3Usage.js +31 -0
- package/dist/test/fixtures/v4/esmBuild.d.ts +5 -0
- package/dist/test/fixtures/v4/esmBuild.js +18 -0
- package/dist/test/fixtures/v4/fetchInterception.d.ts +5 -0
- package/dist/test/fixtures/v4/fetchInterception.js +18 -0
- package/dist/test/fixtures/v4/index.d.ts +9 -0
- package/dist/test/fixtures/v4/index.js +9 -0
- package/dist/test/fixtures/v4/jsScriptTagTypeModule.d.ts +4 -0
- package/dist/test/fixtures/v4/jsScriptTagTypeModule.js +18 -0
- package/dist/test/fixtures/v4/jsScriptTagTypeModules.d.ts +5 -0
- package/dist/test/fixtures/v4/jsScriptTagTypeModules.js +12 -0
- package/dist/test/fixtures/v4/reactHooks.d.ts +6 -0
- package/dist/test/fixtures/v4/reactHooks.js +47 -0
- package/dist/test/fixtures/v4/reactJsx.d.ts +6 -0
- package/dist/test/fixtures/v4/reactJsx.js +34 -0
- package/dist/test/fixtures/v4/threeJsUsage.d.ts +4 -0
- package/dist/test/fixtures/v4/threeJsUsage.js +24 -0
- package/dist/test/fixtures/v4/typeScriptSupport.d.ts +5 -0
- package/dist/test/fixtures/v4/typeScriptSupport.js +29 -0
- package/dist/test/fixtures/xmlTest.d.ts +2 -0
- package/dist/test/fixtures/xmlTest.js +26 -0
- package/dist/test/index.test.d.ts +1 -0
- package/dist/test/index.test.js +40 -0
- package/dist/test/testInBrowser.d.ts +15 -0
- package/dist/test/testInBrowser.js +47 -0
- package/dist/test/testStackTrace.d.ts +9 -0
- package/dist/test/testStackTrace.js +55 -0
- package/dist/test/v1.test.d.ts +1 -0
- package/dist/test/v1.test.js +65 -0
- package/dist/test/v2.test.d.ts +1 -0
- package/dist/test/v2.test.js +121 -0
- package/dist/test/v3.test.d.ts +1 -0
- package/dist/test/v3.test.js +114 -0
- package/dist/test/v4.test.d.ts +1 -0
- package/dist/test/v4.test.js +100 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +1 -0
- package/dist/utils/getFileText.d.ts +2 -0
- package/dist/utils/getFileText.js +13 -0
- package/dist/utils/getFileText.test.d.ts +1 -0
- package/dist/utils/getFileText.test.js +72 -0
- package/dist/utils/vizContentToFileCollection.d.ts +7 -0
- package/dist/utils/vizContentToFileCollection.js +19 -0
- package/dist/utils/vizContentToFileCollection.test.d.ts +1 -0
- package/dist/utils/vizContentToFileCollection.test.js +75 -0
- package/dist/v2/computeBundleJSV2.d.ts +7 -0
- package/dist/v2/computeBundleJSV2.js +29 -0
- package/dist/v2/getComputedIndexHtml.d.ts +4 -0
- package/dist/v2/getComputedIndexHtml.js +81 -0
- package/dist/v2/getComputedIndexHtml.test.d.ts +1 -0
- package/dist/v2/getComputedIndexHtml.test.js +134 -0
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.js +1 -0
- package/dist/v2/v2Build.d.ts +7 -0
- package/dist/v2/v2Build.js +11 -0
- package/dist/{v3Runtime → v3}/cleanRollupErrorMessage.d.ts +0 -1
- package/dist/v3/cleanRollupErrorMessage.js +9 -0
- package/dist/v3/computeBundleJSV3.d.ts +17 -0
- package/dist/v3/computeBundleJSV3.js +48 -0
- package/dist/v3/createVizContent.d.ts +8 -0
- package/dist/v3/createVizContent.js +23 -0
- package/dist/{v3Runtime → v3}/extractVizImport.d.ts +2 -3
- package/dist/v3/extractVizImport.js +23 -0
- package/dist/v3/extractVizImport.test.d.ts +1 -0
- package/dist/v3/extractVizImport.test.js +30 -0
- package/dist/v3/htmlTemplate.d.ts +5 -0
- package/dist/v3/htmlTemplate.js +89 -0
- package/dist/v3/index.d.ts +1 -0
- package/dist/v3/index.js +1 -0
- package/dist/v3/parseId.d.ts +6 -0
- package/dist/v3/parseId.js +5 -0
- package/dist/v3/parseId.test.d.ts +1 -0
- package/dist/v3/parseId.test.js +25 -0
- package/dist/{v3Runtime → v3}/setupV3Runtime.d.ts +5 -5
- package/dist/v3/setupV3Runtime.js +341 -0
- package/dist/v3/slugCache.d.ts +11 -0
- package/dist/v3/slugCache.js +35 -0
- package/dist/v3/slugCache.test.d.ts +1 -0
- package/dist/v3/slugCache.test.js +105 -0
- package/dist/v3/transformDSV/dsvParseSrc.d.ts +1 -0
- package/dist/v3/transformDSV/dsvParseSrc.js +121 -0
- package/dist/v3/transformDSV/index.d.ts +2 -0
- package/dist/v3/transformDSV/index.js +40 -0
- package/dist/{v3Runtime → v3}/transformSvelte.d.ts +4 -2
- package/dist/v3/transformSvelte.js +77 -0
- package/dist/{v3Runtime → v3}/types.d.ts +18 -18
- package/dist/v3/types.js +1 -0
- package/dist/v3/v3Build.d.ts +14 -0
- package/dist/v3/v3Build.js +30 -0
- package/dist/v3/vizCache.d.ts +10 -0
- package/dist/v3/vizCache.js +36 -0
- package/dist/v3/vizCache.test.d.ts +1 -0
- package/dist/v3/vizCache.test.js +98 -0
- package/dist/{v3Runtime → v3}/vizLoad.d.ts +3 -4
- package/dist/v3/vizLoad.js +46 -0
- package/dist/v3/vizResolve.d.ts +7 -0
- package/dist/v3/vizResolve.js +69 -0
- package/dist/v4/index.d.ts +10 -0
- package/dist/v4/index.js +134 -0
- package/package.json +37 -38
- package/dist/assets/setupV3Runtime-BVr5lyKp.js +0 -240
- package/dist/computeSrcDoc.d.ts +0 -13
- package/dist/computeSrcDoc.d.ts.map +0 -1
- package/dist/computeSrcDoc.test.d.ts +0 -2
- package/dist/computeSrcDoc.test.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/useRuntime.d.ts +0 -13
- package/dist/useRuntime.d.ts.map +0 -1
- package/dist/v2Runtime/bundle/bubleJSXOnly.d.ts +0 -5
- package/dist/v2Runtime/bundle/bubleJSXOnly.d.ts.map +0 -1
- package/dist/v2Runtime/bundle/packageJson.d.ts +0 -10
- package/dist/v2Runtime/bundle/packageJson.d.ts.map +0 -1
- package/dist/v2Runtime/computeSrcDocV2.d.ts +0 -3
- package/dist/v2Runtime/computeSrcDocV2.d.ts.map +0 -1
- package/dist/v2Runtime/computeSrcDocV2.test.d.ts +0 -2
- package/dist/v2Runtime/computeSrcDocV2.test.d.ts.map +0 -1
- package/dist/v2Runtime/getComputedIndexHtml.d.ts +0 -4
- package/dist/v2Runtime/getComputedIndexHtml.d.ts.map +0 -1
- package/dist/v2Runtime/getComputedIndexHtml.test.d.ts +0 -2
- package/dist/v2Runtime/getComputedIndexHtml.test.d.ts.map +0 -1
- package/dist/v2Runtime/getText.d.ts +0 -3
- package/dist/v2Runtime/getText.d.ts.map +0 -1
- package/dist/v2Runtime/transformFiles.d.ts +0 -3
- package/dist/v2Runtime/transformFiles.d.ts.map +0 -1
- package/dist/v2Runtime/v3FilesToV2Files.d.ts +0 -3
- package/dist/v2Runtime/v3FilesToV2Files.d.ts.map +0 -1
- package/dist/v2Runtime/v3FilesToV2Files.test.d.ts +0 -2
- package/dist/v2Runtime/v3FilesToV2Files.test.d.ts.map +0 -1
- package/dist/v3Runtime/build.d.ts +0 -14
- package/dist/v3Runtime/build.d.ts.map +0 -1
- package/dist/v3Runtime/build.test.d.ts +0 -2
- package/dist/v3Runtime/build.test.d.ts.map +0 -1
- package/dist/v3Runtime/cleanRollupErrorMessage.d.ts.map +0 -1
- package/dist/v3Runtime/computeSrcDocV3.d.ts +0 -7
- package/dist/v3Runtime/computeSrcDocV3.d.ts.map +0 -1
- package/dist/v3Runtime/extractVizImport.d.ts.map +0 -1
- package/dist/v3Runtime/extractVizImport.test.d.ts +0 -2
- package/dist/v3Runtime/extractVizImport.test.d.ts.map +0 -1
- package/dist/v3Runtime/generateRollupErrorMessage.d.ts +0 -5
- package/dist/v3Runtime/generateRollupErrorMessage.d.ts.map +0 -1
- package/dist/v3Runtime/importFromViz.d.ts +0 -1
- package/dist/v3Runtime/importFromViz.d.ts.map +0 -1
- package/dist/v3Runtime/index.d.ts +0 -2
- package/dist/v3Runtime/index.d.ts.map +0 -1
- package/dist/v3Runtime/parseId.d.ts +0 -7
- package/dist/v3Runtime/parseId.d.ts.map +0 -1
- package/dist/v3Runtime/setupV3Runtime.d.ts.map +0 -1
- package/dist/v3Runtime/transformDSV/index.d.ts +0 -3
- package/dist/v3Runtime/transformDSV/index.d.ts.map +0 -1
- package/dist/v3Runtime/transformSvelte.d.ts.map +0 -1
- package/dist/v3Runtime/types.d.ts.map +0 -1
- package/dist/v3Runtime/urlLoad.d.ts +0 -1
- package/dist/v3Runtime/urlLoad.d.ts.map +0 -1
- package/dist/v3Runtime/virtual.d.ts +0 -1
- package/dist/v3Runtime/virtual.d.ts.map +0 -1
- package/dist/v3Runtime/vizCache.d.ts +0 -11
- package/dist/v3Runtime/vizCache.d.ts.map +0 -1
- package/dist/v3Runtime/vizCache.test.d.ts +0 -2
- package/dist/v3Runtime/vizCache.test.d.ts.map +0 -1
- package/dist/v3Runtime/vizLoad.d.ts.map +0 -1
- package/dist/v3Runtime/vizLoadSvelte.d.ts +0 -1
- package/dist/v3Runtime/vizLoadSvelte.d.ts.map +0 -1
- package/dist/v3Runtime/vizResolve.d.ts +0 -10
- package/dist/v3Runtime/vizResolve.d.ts.map +0 -1
- package/dist/v3Runtime/worker.d.ts +0 -2
- package/dist/v3Runtime/worker.d.ts.map +0 -1
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Datavis Tech INC
|
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.
|
package/README.md
CHANGED
@@ -1,257 +1,455 @@
|
|
1
|
-
# @vizhub
|
1
|
+
# @vizhub/runtime
|
2
2
|
|
3
|
-
|
3
|
+
[](https://www.npmjs.com/package/@vizhub/runtime)
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
4
5
|
|
5
|
-
|
6
|
+
A powerful, flexible runtime environment for executing code sandboxes in the browser. `@vizhub/runtime` powers [VizHub](https://vizhub.com/) and can be used to build similar interactive coding platforms.
|
6
7
|
|
7
|
-
|
8
|
-
- **File transformations**: Transforms various file types (e.g., JavaScript, CSS, CSV, Svelte) to be used in the runtime environment.
|
9
|
-
- **Hot reloading**: Automatically reloads visualizations when files are updated, providing a smooth development experience.
|
10
|
-
- **Dependency management**: Handles external dependencies via CDN and supports custom package configurations.
|
11
|
-
- **Virtual file system**: Implements a virtual file system for handling imports and file loading within the runtime.
|
12
|
-
- **Web Worker-based build system**: Uses Web Workers to offload the build process, ensuring a responsive UI during development.
|
13
|
-
- **Multi-version runtime support**: Supports both V2 and V3 runtime environments, allowing for backward compatibility and future-proofing.
|
8
|
+
## Overview
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
Install the package using npm:
|
10
|
+
`@vizhub/runtime` intelligently detects the appropriate runtime version based on the provided files and generates executable HTML that can be used within an iframe's `srcdoc` attribute. It handles everything from simple HTML/JS/CSS combinations to complex module bundling, dependency resolution, and cross-viz imports.
|
18
11
|
|
19
|
-
|
20
|
-
npm install @vizhub-core/runtime
|
21
|
-
```
|
12
|
+
## Runtime Versions
|
22
13
|
|
23
|
-
|
14
|
+
The library automatically detects which runtime version to use based on the files provided:
|
24
15
|
|
25
|
-
|
16
|
+
- **v1**: When only `index.html` is present
|
17
|
+
- **v2**: When both `index.html` and `index.js` (or `index.jsx`) are present
|
18
|
+
- **v3**: When only `index.js` is present (no `index.html`)
|
19
|
+
- **v4**: When `index.html` contains ES module scripts with import maps
|
26
20
|
|
27
|
-
|
21
|
+
| Feature | **V1** | **V2** | **V3** | **V4** |
|
22
|
+
| --------------------- | ----------------- | ------------------------------ | --------------------------------- | ---------------------------- |
|
23
|
+
| **When Used** | Only `index.html` | `index.html` + `index.js/.jsx` | Only `index.js` (no `index.html`) | `index.html` with ES modules |
|
24
|
+
| **`index.html`** | User-provided | User-provided | Auto-generated | User-provided |
|
25
|
+
| **ES Modules** | ☐ | ✅ | ✅ | ✅ |
|
26
|
+
| **UMD Libraries** | ✅ | ✅ | ✅ | ☐ |
|
27
|
+
| **ESM Libraries** | ☐ | ☐ | ☐ | ✅ |
|
28
|
+
| **JSX Support** | ☐ | ✅ | ☐ | ✅ |
|
29
|
+
| **Svelte Support** | ☐ | ☐ | ✅ | ☐ |
|
30
|
+
| **Cross-Viz Imports** | ☐ | ☐ | ✅ | ☐ |
|
31
|
+
| **State Management** | ☐ | ☐ | ✅ | ☐ |
|
32
|
+
| **Import from CSV** | ☐ | ☐ | ✅ | ☐ |
|
33
|
+
| **`fetch` proxy** | ✅ | ✅ | ☐ | ✅ |
|
34
|
+
| **Best For** | Simple HTML demos | React with CDN deps | Svelte / reusable D3 | Modern module-based apps |
|
28
35
|
|
29
|
-
|
36
|
+
## V1 Runtime
|
30
37
|
|
31
|
-
|
32
|
-
import { expect, test } from "vitest";
|
33
|
-
import { rollup } from "rollup";
|
34
|
-
import { computeSrcDoc, createVizCache, VizCache } from "@vizhub/runtime";
|
35
|
-
|
36
|
-
test("computeSrcDoc", async () => {
|
37
|
-
const content = {
|
38
|
-
files: {
|
39
|
-
"32748932": {
|
40
|
-
name: "index.js",
|
41
|
-
text: "export const main = (container) => container.innerHTML = 'Hello, world!';",
|
42
|
-
},
|
43
|
-
},
|
44
|
-
};
|
38
|
+
The V1 runtime is the simplest version, designed for basic HTML, CSS, and JavaScript projects. This runtime is automatically selected when your project contains only an `index.html` file.
|
45
39
|
|
46
|
-
|
47
|
-
initialContents: [content],
|
48
|
-
handleCacheMiss: async () => {
|
49
|
-
return content;
|
50
|
-
},
|
51
|
-
});
|
40
|
+
### How It Works
|
52
41
|
|
53
|
-
|
54
|
-
throw new Error("Not implemented");
|
55
|
-
};
|
42
|
+
In V1 runtime:
|
56
43
|
|
57
|
-
|
58
|
-
|
59
|
-
|
44
|
+
- Your `index.html` file is executed directly in the browser
|
45
|
+
- You can include inline JavaScript and CSS within your HTML file
|
46
|
+
- The runtime provides fetch request proxying to handle cross-origin requests
|
60
47
|
|
61
|
-
|
62
|
-
rollup,
|
63
|
-
content,
|
64
|
-
vizCache,
|
65
|
-
resolveSlug,
|
66
|
-
getSvelteCompiler,
|
67
|
-
});
|
48
|
+
### Example Usage
|
68
49
|
|
69
|
-
|
50
|
+
As a VizHub user, you simply need to create an `index.html` file containing your entire project:
|
70
51
|
|
71
|
-
|
72
|
-
/\/\/# sourceMappingURL=.*$/gm,
|
73
|
-
""
|
74
|
-
);
|
52
|
+
**index.html**
|
75
53
|
|
76
|
-
|
54
|
+
```html
|
55
|
+
<!DOCTYPE html>
|
77
56
|
<html>
|
78
57
|
<head>
|
79
|
-
<meta charset="utf-8">
|
80
58
|
<style>
|
81
59
|
body {
|
82
|
-
|
83
|
-
overflow: hidden;
|
84
|
-
}
|
85
|
-
#viz-container-${randomID} {
|
86
|
-
height: 100vh;
|
60
|
+
font-family: sans-serif;
|
87
61
|
}
|
88
62
|
</style>
|
89
63
|
</head>
|
90
64
|
<body>
|
91
|
-
<
|
92
|
-
<script id="injected-script">(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports):typeof define==='function'&&define.amd?define(['exports'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.Viz={}));})(this,(function(exports){'use strict';const main = (container) => container.innerHTML = 'Hello, world!';exports.main=main;}));
|
93
|
-
|
94
|
-
|
65
|
+
<h1>Hello World</h1>
|
95
66
|
<script>
|
96
|
-
(
|
97
|
-
let cleanup;
|
98
|
-
const render = () => {
|
99
|
-
const container = document.getElementById('viz-container-${randomID}');
|
100
|
-
typeof cleanup === 'function' && cleanup();
|
101
|
-
cleanup = Viz.main(container, { state: window.state, setState, writeFile });
|
102
|
-
};
|
103
|
-
const setState = (next) => {
|
104
|
-
window.state = next(window.state);
|
105
|
-
render();
|
106
|
-
};
|
107
|
-
const writeFile = (fileName, content) => {
|
108
|
-
parent.postMessage({ type: 'writeFile', fileName, content }, "*");
|
109
|
-
};
|
110
|
-
const run = () => {
|
111
|
-
try {
|
112
|
-
setState((state) => state || {});
|
113
|
-
} catch (error) {
|
114
|
-
console.error(error);
|
115
|
-
parent.postMessage({ type: 'runError', error }, "*");
|
116
|
-
}
|
117
|
-
}
|
118
|
-
run();
|
119
|
-
const runJS = (src) => {
|
120
|
-
document.getElementById('injected-script')?.remove();
|
121
|
-
const script = document.createElement('script');
|
122
|
-
script.textContent = src;
|
123
|
-
script.id = 'injected-script';
|
124
|
-
document.body.appendChild(script);
|
125
|
-
run();
|
126
|
-
};
|
127
|
-
const runCSS = (src, id) => {
|
128
|
-
const styleElementId = 'injected-style' + id;
|
129
|
-
let style = document.getElementById(styleElementId);
|
130
|
-
if (!style) {
|
131
|
-
style = document.createElement('style');
|
132
|
-
style.type = 'text/css';
|
133
|
-
style.id = styleElementId;
|
134
|
-
document.head.appendChild(style);
|
135
|
-
}
|
136
|
-
style.textContent = src;
|
137
|
-
};
|
138
|
-
onmessage = (message) => {
|
139
|
-
switch (message.data.type) {
|
140
|
-
case 'runJS':
|
141
|
-
runJS(message.data.src);
|
142
|
-
parent.postMessage({ type: 'runDone' }, "*");
|
143
|
-
break;
|
144
|
-
case 'runCSS':
|
145
|
-
runCSS(message.data.src, message.data.id);
|
146
|
-
break;
|
147
|
-
case 'ping':
|
148
|
-
parent.postMessage({ type: 'pong' }, "*");
|
149
|
-
break;
|
150
|
-
default:
|
151
|
-
break;
|
152
|
-
}
|
153
|
-
}
|
154
|
-
})();
|
67
|
+
console.log("Hello from V1 runtime!");
|
155
68
|
</script>
|
156
69
|
</body>
|
157
|
-
</html
|
158
|
-
});
|
70
|
+
</html>
|
159
71
|
```
|
160
72
|
|
161
|
-
|
73
|
+
V1 is ideal for simple demonstrations or when you want complete control over your HTML structure.
|
162
74
|
|
163
|
-
##
|
75
|
+
## V2 Runtime
|
164
76
|
|
165
|
-
|
77
|
+
The V2 runtime introduces JavaScript bundling with Rollup, JSX support, and CDN-based dependency resolution. This runtime is automatically selected when your project contains both an `index.html` and an `index.js` (or `index.jsx`) file.
|
166
78
|
|
167
|
-
|
79
|
+
### How It Works
|
168
80
|
|
169
|
-
|
81
|
+
In V2 runtime:
|
170
82
|
|
171
|
-
-
|
172
|
-
-
|
173
|
-
-
|
174
|
-
-
|
175
|
-
-
|
83
|
+
- Your JavaScript files are bundled together using Rollup
|
84
|
+
- Internally, a file named `bundle.js` is created
|
85
|
+
- The `index.html` file references this `bundle.js` file
|
86
|
+
- You can use ES6 modules to import/export code
|
87
|
+
- JSX syntax is supported for React development
|
88
|
+
- Dependencies listed in `package.json` are automatically resolved via CDNs (jsDelivr/unpkg)
|
89
|
+
- The bundled JavaScript is referenced in your HTML file
|
176
90
|
|
177
|
-
|
91
|
+
### Example Usage
|
178
92
|
|
179
|
-
|
93
|
+
As a VizHub user, you'll typically create:
|
180
94
|
|
181
|
-
|
182
|
-
|
95
|
+
1. An `index.html` file that references a `bundle.js` file
|
96
|
+
2. An `index.js` (or `index.jsx`) file as your entry point
|
97
|
+
3. Additional JavaScript modules as needed
|
98
|
+
4. A `package.json` file to list dependencies
|
183
99
|
|
184
|
-
|
100
|
+
**index.html**
|
185
101
|
|
186
|
-
|
102
|
+
```html
|
103
|
+
<!DOCTYPE html>
|
104
|
+
<html>
|
105
|
+
<body>
|
106
|
+
<div id="root"></div>
|
107
|
+
<script src="bundle.js"></script>
|
108
|
+
</body>
|
109
|
+
</html>
|
110
|
+
```
|
111
|
+
|
112
|
+
**index.js**
|
113
|
+
|
114
|
+
```javascript
|
115
|
+
import { render } from "./render";
|
116
|
+
render(document.getElementById("root"));
|
117
|
+
```
|
187
118
|
|
188
|
-
|
119
|
+
**render.js**
|
189
120
|
|
190
|
-
|
191
|
-
|
121
|
+
```javascript
|
122
|
+
export function render(element) {
|
123
|
+
element.innerHTML = "<h1>Hello from V2 runtime!</h1>";
|
124
|
+
}
|
125
|
+
```
|
192
126
|
|
193
|
-
|
127
|
+
**package.json**
|
194
128
|
|
195
|
-
|
129
|
+
```json
|
130
|
+
{
|
131
|
+
"dependencies": {
|
132
|
+
"d3": "7.8.5",
|
133
|
+
"react": "18.2.0",
|
134
|
+
"react-dom": "18.2.0"
|
135
|
+
}
|
136
|
+
}
|
137
|
+
```
|
196
138
|
|
197
|
-
|
198
|
-
- **`set(content)`**: Adds or updates the content of a visualization in the cache.
|
199
|
-
- **`invalidate(vizId)`**: Invalidates the cache for a specific visualization.
|
139
|
+
V2 is ideal for more complex projects that require modular JavaScript and external dependencies that provide UMD builds. Note that the V2 runtime does not support ESM builds for external dependencies (see V4 if you need this).
|
200
140
|
|
201
|
-
|
141
|
+
## V3 Runtime
|
202
142
|
|
203
|
-
|
143
|
+
The V3 runtime provides advanced module bundling with Svelte support and cross-viz imports. This runtime is automatically selected when your project contains an `index.js` file but no `index.html` file.
|
204
144
|
|
205
|
-
|
145
|
+
### How It Works
|
206
146
|
|
207
|
-
|
147
|
+
In V3 runtime:
|
208
148
|
|
209
|
-
|
149
|
+
- Your JavaScript modules are bundled together using Rollup
|
150
|
+
- A default HTML structure is automatically generated
|
151
|
+
- Svelte components are supported
|
152
|
+
- Cross-viz imports allow you to import code from other viz instances
|
153
|
+
- The runtime provides a built-in state management system
|
210
154
|
|
211
|
-
|
155
|
+
### State Management in V3
|
212
156
|
|
213
|
-
|
157
|
+
V3 runtime includes a built-in state management system via the [unidirectional-data-flow](https://www.npmjs.com/package/unidirectional-data-flow) package ([GitHub](https://github.com/vizhub-core/unidirectional-data-flow)). This provides React-like state management capabilities with:
|
214
158
|
|
215
|
-
-
|
216
|
-
-
|
159
|
+
- A `main` entry point
|
160
|
+
- A minimal state management system based on `state` and `setState`
|
161
|
+
- Similar semantics to React's `useState` hook: `const [state, setState] = useState({})`
|
162
|
+
- Automatic re-rendering when state changes
|
217
163
|
|
218
|
-
|
164
|
+
### The Problem: Re-using D3 Rendering Logic Across Frameworks
|
219
165
|
|
220
|
-
|
166
|
+
While frameworks like React, Svelte, Vue, and Angular offer state management and DOM manipulation solutions, D3 excels in data transformation and visualization, particularly with axes, transitions, and behaviors (e.g. zoom, drag, and brush). These D3 features require direct access to the DOM, making it challenging to replicate them effectively within frameworks.
|
221
167
|
|
222
|
-
|
168
|
+
### The Solution: Unidirectional Data Flow
|
169
|
+
|
170
|
+
Unidirectional data flow is a pattern that can be cleanly invoked from multiple frameworks. In this paradigm, a single function is responsible for updating the DOM or rendering visuals based on a single, central state. As the state updates, the function re-renders the visualization in an idempotent manner, meaning it can run multiple times without causing side effects. Here's what the entry point function looks like for a D3-based visualization that uses unidirectional data flow:
|
171
|
+
|
172
|
+
**index.js**
|
173
|
+
|
174
|
+
```js
|
175
|
+
export const main = (container, { state, setState }) => {
|
176
|
+
// Your reusable D3-based rendering logic goes here
|
177
|
+
};
|
178
|
+
```
|
223
179
|
|
224
|
-
|
180
|
+
- **`container`**: A DOM element where the visualization will be rendered
|
181
|
+
- **`state`**: An object representing the current state of the application, initially empty
|
182
|
+
- **`setState`**: A function that updates the state using immutable update patterns
|
183
|
+
|
184
|
+
Whenever `setState` is invoked, `main` re-executes with the new state, ensuring that the rendering logic is both dynamic and responsive.
|
185
|
+
|
186
|
+
For cross-viz imports, you can reference other vizzes directly:
|
187
|
+
|
188
|
+
**example-with-import.js**
|
189
|
+
|
190
|
+
```javascript
|
191
|
+
// Import from another viz using @username/vizIdOrSlug syntax
|
192
|
+
import { someFunction } from "@username/my-other-viz";
|
193
|
+
```
|
194
|
+
|
195
|
+
V3 is ideal for modern JavaScript applications that benefit from automatic HTML structure generation and built-in state management. Additional features of V3 include:
|
196
|
+
|
197
|
+
- **Cross-Viz Imports**: Import code from other viz instances using `@username/vizIdOrSlug` syntax
|
198
|
+
- **Import from CSV**: Import CSV files directly into your viz
|
199
|
+
|
200
|
+
## V4 Runtime
|
201
|
+
|
202
|
+
The V4 runtime leverages modern ES Modules with import maps for direct browser execution. This runtime is automatically selected when your project's `index.html` contains ES module scripts with import maps.
|
203
|
+
|
204
|
+
### How It Works
|
205
|
+
|
206
|
+
In V4 runtime:
|
207
|
+
|
208
|
+
- Native browser ES modules are used without bundling
|
209
|
+
- Import maps allow you to specify module resolution directly in the browser
|
210
|
+
- Module paths can be aliased for cleaner imports
|
211
|
+
- External dependencies can be loaded directly from CDNs
|
212
|
+
|
213
|
+
### Example Usage
|
214
|
+
|
215
|
+
As a VizHub user, you'll create an `index.html` file with import maps and ES module scripts:
|
216
|
+
|
217
|
+
**index.html**
|
218
|
+
|
219
|
+
```html
|
220
|
+
<!DOCTYPE html>
|
221
|
+
<html>
|
222
|
+
<head>
|
223
|
+
<script type="importmap">
|
224
|
+
{
|
225
|
+
"imports": {
|
226
|
+
"utils": "./utils.js",
|
227
|
+
"d3": "https://cdn.jsdelivr.net/npm/d3@7.8.5/+esm"
|
228
|
+
}
|
229
|
+
}
|
230
|
+
</script>
|
231
|
+
</head>
|
232
|
+
<body>
|
233
|
+
<div id="app"></div>
|
234
|
+
<script type="module" src="index.js"></script>
|
235
|
+
</body>
|
236
|
+
</html>
|
237
|
+
```
|
238
|
+
|
239
|
+
**index.js**
|
240
|
+
|
241
|
+
```javascript
|
242
|
+
import { createApp } from "utils";
|
243
|
+
import * as d3 from "d3";
|
244
|
+
|
245
|
+
createApp(document.getElementById("app"));
|
246
|
+
```
|
225
247
|
|
226
|
-
|
248
|
+
**utils.js**
|
249
|
+
|
250
|
+
```javascript
|
251
|
+
export function createApp(element) {
|
252
|
+
element.innerHTML = "<h1>Hello from V4 runtime!</h1>";
|
253
|
+
}
|
254
|
+
```
|
255
|
+
|
256
|
+
V4 is ideal for modern browsers with native ES module support and when you want direct control over module resolution.
|
257
|
+
|
258
|
+
## Key Features
|
259
|
+
|
260
|
+
- **Multi-Version Runtime Support**
|
261
|
+
|
262
|
+
- **v1**: Simple HTML execution with fetch proxying
|
263
|
+
- **v2**: JavaScript bundling with Rollup, JSX support, and CDN-based dependency resolution
|
264
|
+
- **v3**: Advanced module bundling with Svelte support and cross-viz imports
|
265
|
+
- **v4**: Modern ES Modules with import maps for direct browser execution
|
266
|
+
|
267
|
+
- **Comprehensive Tooling**
|
268
|
+
|
269
|
+
- **Bundling**: Seamless integration with Rollup for module bundling
|
270
|
+
- **Transpilation**: Support for JSX (v2) and Svelte components (v3)
|
271
|
+
- **Dependency Management**: Automatic resolution via CDNs (jsDelivr/unpkg)
|
272
|
+
- **Caching**: Efficient viz content and slug resolution caching
|
273
|
+
- **Debugging**: Sourcemap generation for improved debugging experience
|
274
|
+
|
275
|
+
- **Advanced Capabilities**
|
276
|
+
- **Cross-Viz Imports**: Import code from other viz instances using `@username/vizIdOrSlug` syntax
|
277
|
+
- **Fetch Interception**: Handle cross-origin requests and authentication
|
278
|
+
- **File Type Support**: Process JS, JSX, CSS, CSV, JSON, and more
|
279
|
+
|
280
|
+
## Installation
|
227
281
|
|
228
282
|
```bash
|
229
|
-
|
230
|
-
|
283
|
+
npm install @vizhub/runtime
|
284
|
+
```
|
285
|
+
|
286
|
+
## Usage
|
287
|
+
|
288
|
+
### Basic Usage
|
289
|
+
|
290
|
+
```javascript
|
291
|
+
import { buildHTML } from "@vizhub/runtime";
|
292
|
+
import { rollup } from "rollup";
|
293
|
+
|
294
|
+
// Simple v1 runtime (HTML only)
|
295
|
+
const html = await buildHTML({
|
296
|
+
files: {
|
297
|
+
"index.html":
|
298
|
+
"<html><body><h1>Hello World</h1></body></html>",
|
299
|
+
},
|
300
|
+
});
|
301
|
+
|
302
|
+
// v2 runtime with bundling
|
303
|
+
const html = await buildHTML({
|
304
|
+
files: {
|
305
|
+
"index.html":
|
306
|
+
'<html><body><div id="root"></div><script src="bundle.js"></script></body></html>',
|
307
|
+
"index.js":
|
308
|
+
'import { message } from "./message"; console.log(message);',
|
309
|
+
"message.js":
|
310
|
+
'export const message = "Hello, bundled world!";',
|
311
|
+
},
|
312
|
+
rollup,
|
313
|
+
});
|
314
|
+
|
315
|
+
// Use the generated HTML in an iframe
|
316
|
+
const iframe = document.createElement("iframe");
|
317
|
+
iframe.srcdoc = html;
|
318
|
+
document.body.appendChild(iframe);
|
319
|
+
```
|
320
|
+
|
321
|
+
### Advanced Usage: v3 Runtime with Cross-Viz Imports
|
322
|
+
|
323
|
+
```javascript
|
324
|
+
import {
|
325
|
+
buildHTML,
|
326
|
+
createVizCache,
|
327
|
+
createSlugCache,
|
328
|
+
} from "@vizhub/runtime";
|
329
|
+
import { rollup } from "rollup";
|
330
|
+
import { compile } from "svelte/compiler";
|
331
|
+
|
332
|
+
// Create caches for viz content and slug resolution
|
333
|
+
const vizCache = createVizCache({
|
334
|
+
initialContents: [
|
335
|
+
{
|
336
|
+
id: "viz-123",
|
337
|
+
files: {
|
338
|
+
file1: {
|
339
|
+
name: "index.js",
|
340
|
+
text: "export const value = 42;",
|
341
|
+
},
|
342
|
+
},
|
343
|
+
},
|
344
|
+
],
|
345
|
+
handleCacheMiss: async (vizId) => {
|
346
|
+
// Fetch viz content from your backend
|
347
|
+
return await fetchVizContent(vizId);
|
348
|
+
},
|
349
|
+
});
|
350
|
+
|
351
|
+
const slugCache = createSlugCache({
|
352
|
+
initialMappings: {
|
353
|
+
"username/my-viz": "viz-123",
|
354
|
+
},
|
355
|
+
handleCacheMiss: async (slug) => {
|
356
|
+
// Resolve slug to vizId from your backend
|
357
|
+
return await resolveSlug(slug);
|
358
|
+
},
|
359
|
+
});
|
360
|
+
|
361
|
+
// Build HTML with cross-viz imports
|
362
|
+
const html = await buildHTML({
|
363
|
+
files: {
|
364
|
+
"index.js":
|
365
|
+
'import { value } from "@username/my-viz"; console.log(value);',
|
366
|
+
},
|
367
|
+
rollup,
|
368
|
+
vizCache,
|
369
|
+
vizId: "current-viz-id",
|
370
|
+
slugCache,
|
371
|
+
getSvelteCompiler: async () => compile,
|
372
|
+
});
|
231
373
|
```
|
232
374
|
|
233
|
-
|
375
|
+
## API Reference
|
376
|
+
|
377
|
+
### buildHTML(options)
|
378
|
+
|
379
|
+
Builds HTML that can be used as the `srcdoc` of an iframe.
|
380
|
+
|
381
|
+
#### Options
|
382
|
+
|
383
|
+
- **files**: `FileCollection` - A map of filenames to their contents
|
384
|
+
- **rollup**: `(options: RollupOptions) => Promise<RollupBuild>` - Rollup function (required for v2, v3, v4)
|
385
|
+
- **enableSourcemap**: `boolean` - Whether to include sourcemaps (default: true)
|
386
|
+
- **vizCache**: `VizCache` - Cache for viz content (required for v3 with cross-viz imports)
|
387
|
+
- **vizId**: `string` - ID of the current viz (required for v3 with cross-viz imports)
|
388
|
+
- **slugCache**: `SlugCache` - Cache for slug resolution (optional for v3)
|
389
|
+
- **getSvelteCompiler**: `() => Promise<SvelteCompiler>` - Function that returns Svelte compiler (optional for v3)
|
390
|
+
|
391
|
+
### createVizCache(options)
|
392
|
+
|
393
|
+
Creates a cache for viz content.
|
394
|
+
|
395
|
+
#### Options
|
396
|
+
|
397
|
+
- **initialContents**: `VizContent[]` - Initial viz contents to populate the cache
|
398
|
+
- **handleCacheMiss**: `(vizId: string) => Promise<VizContent>` - Function to handle cache misses
|
399
|
+
|
400
|
+
### createSlugCache(options)
|
401
|
+
|
402
|
+
Creates a cache for slug resolution.
|
403
|
+
|
404
|
+
#### Options
|
405
|
+
|
406
|
+
- **initialMappings**: `Record<string, string>` - Initial slug to vizId mappings
|
407
|
+
- **handleCacheMiss**: `(slug: string) => Promise<string>` - Function to handle cache misses
|
408
|
+
|
409
|
+
## Development
|
410
|
+
|
411
|
+
### Setup
|
234
412
|
|
235
413
|
```bash
|
414
|
+
git clone https://github.com/vizhub-core/vizhub-runtime.git
|
415
|
+
cd vizhub-runtime
|
236
416
|
npm install
|
237
417
|
```
|
238
418
|
|
239
|
-
###
|
419
|
+
### Build
|
420
|
+
|
421
|
+
```bash
|
422
|
+
npm run build
|
423
|
+
```
|
240
424
|
|
241
|
-
|
425
|
+
### Test
|
242
426
|
|
243
427
|
```bash
|
244
|
-
npm
|
428
|
+
npm test
|
245
429
|
```
|
246
430
|
|
247
|
-
|
431
|
+
Run specific tests:
|
248
432
|
|
249
|
-
|
433
|
+
```bash
|
434
|
+
npx vitest run -t "should handle CSS imports"
|
435
|
+
```
|
436
|
+
|
437
|
+
### Type Checking
|
250
438
|
|
251
439
|
```bash
|
252
|
-
npm run
|
440
|
+
npm run typecheck
|
253
441
|
```
|
254
442
|
|
443
|
+
## Contributing
|
444
|
+
|
445
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
446
|
+
|
447
|
+
1. Fork the repository
|
448
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
449
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
450
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
451
|
+
5. Open a Pull Request
|
452
|
+
|
255
453
|
## License
|
256
454
|
|
257
|
-
This project is licensed under the MIT License
|
455
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { RollupBuild, RollupOptions } from "rollup";
|
2
|
+
import { VizCache } from "./v3/vizCache";
|
3
|
+
import { SlugCache } from "./v3/slugCache";
|
4
|
+
import { SvelteCompiler } from "./v3/transformSvelte";
|
5
|
+
import { FileCollection } from "@vizhub/viz-types";
|
6
|
+
export declare const buildHTML: ({ files, rollup, enableSourcemap, vizCache, vizId, slugCache, getSvelteCompiler, }: {
|
7
|
+
files?: FileCollection;
|
8
|
+
rollup?: (options: RollupOptions) => Promise<RollupBuild>;
|
9
|
+
enableSourcemap?: boolean;
|
10
|
+
vizCache?: VizCache;
|
11
|
+
vizId?: string;
|
12
|
+
slugCache?: SlugCache;
|
13
|
+
getSvelteCompiler?: () => Promise<SvelteCompiler>;
|
14
|
+
}) => Promise<string>;
|