@vizhub/runtime 0.3.0 → 0.3.2
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/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/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/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/package.json +14 -7
@@ -0,0 +1,14 @@
|
|
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
|
+
export * from "./sourceMapErrorFixture";
|
@@ -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,6 @@
|
|
1
|
+
import { VizContent } from "@vizhub/viz-types";
|
2
|
+
export declare const sampleContent: VizContent;
|
3
|
+
export declare const sampleContentVizImport: VizContent;
|
4
|
+
export declare const sampleContentVizImportSlug: VizContent;
|
5
|
+
export declare const sampleContentWithCSS: VizContent;
|
6
|
+
export declare const sampleContentVizImportWithCSS: VizContent;
|
@@ -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,15 @@
|
|
1
|
+
import { Browser, Page } from "puppeteer";
|
2
|
+
import { VizCache } from "../v3/vizCache";
|
3
|
+
import { FileCollection, VizId } from "@vizhub/viz-types";
|
4
|
+
import { SlugCache } from "../v3/slugCache";
|
5
|
+
import { SvelteCompiler } from "../v3/transformSvelte";
|
6
|
+
export declare function testInBrowser({ browser, files, vizCache, slugCache, vizId, expectedLog, evaluateInBrowser, getSvelteCompiler, }: {
|
7
|
+
browser: Browser;
|
8
|
+
files?: FileCollection;
|
9
|
+
vizCache?: VizCache;
|
10
|
+
slugCache?: SlugCache;
|
11
|
+
vizId?: VizId;
|
12
|
+
expectedLog: string | RegExp;
|
13
|
+
evaluateInBrowser?: (page: Page) => Promise<any>;
|
14
|
+
getSvelteCompiler?: () => Promise<SvelteCompiler>;
|
15
|
+
}): Promise<void>;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Browser } from "puppeteer";
|
2
|
+
import { FileCollection } from "@vizhub/viz-types";
|
3
|
+
interface TestStackTraceOptions {
|
4
|
+
browser: Browser;
|
5
|
+
files: FileCollection;
|
6
|
+
expectedLineNumber: number;
|
7
|
+
}
|
8
|
+
export declare function testStackTrace({ browser, files, expectedLineNumber, }: TestStackTraceOptions): Promise<void>;
|
9
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export type runtimeVersion = "v1" | "v2" | "v3" | "v4";
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { FileCollection, VizContent } from "@vizhub/viz-types";
|
2
|
+
/**
|
3
|
+
* Converts VizContent format to FileCollection format
|
4
|
+
* VizContent has files as {id: {name, text}} structure
|
5
|
+
* FileCollection is a simple {name: text} structure
|
6
|
+
*/
|
7
|
+
export declare const vizContentToFileCollection: (vizContent: VizContent) => FileCollection;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { RollupBuild, RollupOptions } from "rollup";
|
2
|
+
import { FileCollection } from "@vizhub/viz-types";
|
3
|
+
export declare const computeBundleJSV2: ({ files, rollup, enableSourcemap, }: {
|
4
|
+
files: FileCollection;
|
5
|
+
rollup: (options: RollupOptions) => Promise<RollupBuild>;
|
6
|
+
enableSourcemap?: boolean;
|
7
|
+
}) => Promise<string>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { v2Build } from "./v2Build.js";
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { RollupBuild, RollupOptions } from "rollup";
|
2
|
+
import { FileCollection } from "@vizhub/viz-types";
|
3
|
+
export declare const v2Build: ({ files, rollup, enableSourcemap, }: {
|
4
|
+
files: FileCollection;
|
5
|
+
rollup: (options: RollupOptions) => Promise<RollupBuild>;
|
6
|
+
enableSourcemap?: boolean;
|
7
|
+
}) => Promise<FileCollection>;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { RollupBuild, RollupOptions } from "rollup";
|
2
|
+
import { VizCache } from "./vizCache";
|
3
|
+
import { FileCollection, VizId } from "@vizhub/viz-types";
|
4
|
+
import { SlugCache } from "./slugCache";
|
5
|
+
import { SvelteCompiler } from "./transformSvelte";
|
6
|
+
export declare const computeBundleJSV3: ({ files, rollup, enableSourcemap, vizCache, vizId, slugCache, getSvelteCompiler, }: {
|
7
|
+
files: FileCollection;
|
8
|
+
rollup: (options: RollupOptions) => Promise<RollupBuild>;
|
9
|
+
enableSourcemap?: boolean;
|
10
|
+
vizCache: VizCache;
|
11
|
+
vizId: VizId;
|
12
|
+
slugCache?: SlugCache;
|
13
|
+
getSvelteCompiler?: () => Promise<SvelteCompiler>;
|
14
|
+
}) => Promise<{
|
15
|
+
src: string;
|
16
|
+
cssFiles: string[];
|
17
|
+
}>;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { FileCollection, VizContent } from "@vizhub/viz-types";
|
2
|
+
/**
|
3
|
+
* Creates a VizContent object with the given files
|
4
|
+
* @param files An object with file names as keys and file content as values
|
5
|
+
* @param title Optional title for the content
|
6
|
+
* @returns A VizContent object with randomly generated IDs
|
7
|
+
*/
|
8
|
+
export declare const createVizContent: (files: FileCollection, title?: string) => VizContent;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { v3Build } from "./v3Build.js";
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { VizContent, VizId } from "@vizhub/viz-types";
|
2
|
+
export type V3Runtime = {
|
3
|
+
handleCodeChange: (content: VizContent) => void;
|
4
|
+
invalidateVizCache: (changedVizIds: Array<VizId>) => void;
|
5
|
+
resetSrcdoc: (changedVizIds: Array<VizId>) => void;
|
6
|
+
};
|
7
|
+
export declare const setupV3Runtime: ({ vizId, iframe, setSrcdocErrorMessage, getLatestContent, resolveSlugKey, writeFile, worker, }: {
|
8
|
+
vizId: VizId;
|
9
|
+
iframe: HTMLIFrameElement;
|
10
|
+
setSrcdocErrorMessage: (error: string | null) => void;
|
11
|
+
getLatestContent: (vizId: VizId) => Promise<VizContent>;
|
12
|
+
resolveSlugKey: (slugKey: string) => Promise<VizId>;
|
13
|
+
writeFile: (fileName: string, content: string) => void;
|
14
|
+
worker: Worker;
|
15
|
+
}) => V3Runtime;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { VizId } from "@vizhub/viz-types";
|
2
|
+
export type SlugIdentifier = `${string}/${string}`;
|
3
|
+
export type SlugCache = {
|
4
|
+
get: (slug: SlugIdentifier) => Promise<VizId>;
|
5
|
+
set: (slug: SlugIdentifier, vizId: VizId) => void;
|
6
|
+
invalidate: (slug: SlugIdentifier) => void;
|
7
|
+
};
|
8
|
+
export declare const createSlugCache: ({ initialMappings, handleCacheMiss, }: {
|
9
|
+
initialMappings?: Record<SlugIdentifier, VizId>;
|
10
|
+
handleCacheMiss?: (slug: SlugIdentifier) => Promise<VizId>;
|
11
|
+
}) => SlugCache;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const dsvParseSrc = "var EOL = {},\n EOF = {},\n QUOTE = 34,\n NEWLINE = 10,\n RETURN = 13;\n\nfunction objectConverter(columns) {\n return new Function(\n 'd',\n 'return {' +\n columns\n .map(function (name, i) {\n return (\n JSON.stringify(name) + ': d[' + i + '] || \"\"'\n );\n })\n .join(',') +\n '}',\n );\n}\n\nfunction customConverter(columns, f) {\n var object = objectConverter(columns);\n return function (row, i) {\n return f(object(row), i, columns);\n };\n}\n\nfunction dsv(delimiter) {\n var DELIMITER = delimiter.charCodeAt(0);\n\n function parse(text, f) {\n var convert,\n columns,\n rows = parseRows(text, function (row, i) {\n if (convert) return convert(row, i - 1);\n (columns = row),\n (convert = f\n ? customConverter(row, f)\n : objectConverter(row));\n });\n rows.columns = columns || [];\n return rows;\n }\n\n function parseRows(text, f) {\n var rows = [], // output rows\n N = text.length,\n I = 0, // current character index\n n = 0, // current line number\n t, // current token\n eof = N <= 0, // current token followed by EOF?\n eol = false; // current token followed by EOL?\n\n // Strip the trailing newline.\n if (text.charCodeAt(N - 1) === NEWLINE) --N;\n if (text.charCodeAt(N - 1) === RETURN) --N;\n\n function token() {\n if (eof) return EOF;\n if (eol) return (eol = false), EOL;\n\n // Unescape quotes.\n var i,\n j = I,\n c;\n if (text.charCodeAt(j) === QUOTE) {\n while (\n (I++ < N && text.charCodeAt(I) !== QUOTE) ||\n text.charCodeAt(++I) === QUOTE\n );\n if ((i = I) >= N) eof = true;\n else if ((c = text.charCodeAt(I++)) === NEWLINE)\n eol = true;\n else if (c === RETURN) {\n eol = true;\n if (text.charCodeAt(I) === NEWLINE) ++I;\n }\n return text.slice(j + 1, i - 1).replace(/\"\"/g, '\"');\n }\n\n // Find next delimiter or newline.\n while (I < N) {\n if ((c = text.charCodeAt((i = I++))) === NEWLINE)\n eol = true;\n else if (c === RETURN) {\n eol = true;\n if (text.charCodeAt(I) === NEWLINE) ++I;\n } else if (c !== DELIMITER) continue;\n return text.slice(j, i);\n }\n\n // Return last token before EOF.\n return (eof = true), text.slice(j, N);\n }\n\n while ((t = token()) !== EOF) {\n var row = [];\n while (t !== EOL && t !== EOF)\n row.push(t), (t = token());\n if (f && (row = f(row, n++)) == null) continue;\n rows.push(row);\n }\n\n return rows;\n }\n\n return {\n parse: parse,\n };\n}\n\nvar csv = dsv(',');\n\nvar csvParse = csv.parse;\n\nvar tsv = dsv('\t');\n\nvar tsvParse = tsv.parse;\n\nexport { csvParse, tsvParse };";
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { InputPluginOption } from "rollup";
|
2
|
+
export type SvelteCompiler = (code: string, options: any) => {
|
3
|
+
js: string;
|
4
|
+
};
|
5
|
+
export declare const svelteCompilerUrl = "https://cdn.jsdelivr.net/npm/svelte@4.2.9/compiler.cjs";
|
6
|
+
export declare const transformSvelte: ({ getSvelteCompiler, }: {
|
7
|
+
getSvelteCompiler?: () => Promise<any>;
|
8
|
+
}) => InputPluginOption;
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { VizContent, VizId } from "@vizhub/viz-types";
|
2
|
+
import type { PackageJson } from "../common/packageJson";
|
3
|
+
export type V3BuildResult = {
|
4
|
+
src: string | undefined;
|
5
|
+
pkg: PackageJson | undefined;
|
6
|
+
warnings: Array<V3BuildError>;
|
7
|
+
time: number;
|
8
|
+
cssFiles: Array<ResolvedVizFileId>;
|
9
|
+
};
|
10
|
+
export type V3BuildError = {
|
11
|
+
code: string;
|
12
|
+
message: string;
|
13
|
+
};
|
14
|
+
export type ResolvedVizFileId = string;
|
15
|
+
export type V3WorkerMessage = {
|
16
|
+
type: "contentRequest";
|
17
|
+
vizId: VizId;
|
18
|
+
} | {
|
19
|
+
type: "contentResponse";
|
20
|
+
vizId: VizId;
|
21
|
+
content: VizContent;
|
22
|
+
} | {
|
23
|
+
type: "buildRequest";
|
24
|
+
vizId: VizId;
|
25
|
+
enableSourcemap: boolean;
|
26
|
+
} | {
|
27
|
+
type: "buildResponse";
|
28
|
+
buildResult?: V3BuildResult;
|
29
|
+
error?: Error;
|
30
|
+
} | {
|
31
|
+
type: "invalidateVizCacheRequest";
|
32
|
+
changedVizIds: Array<VizId>;
|
33
|
+
} | {
|
34
|
+
type: "invalidateVizCacheResponse";
|
35
|
+
} | {
|
36
|
+
type: "resolveSlugRequest";
|
37
|
+
slugKey: string;
|
38
|
+
requestId: string;
|
39
|
+
} | {
|
40
|
+
type: "resolveSlugResponse";
|
41
|
+
slugKey: string;
|
42
|
+
vizId: VizId;
|
43
|
+
requestId: string;
|
44
|
+
} | {
|
45
|
+
type: "resetSrcdocRequest";
|
46
|
+
vizId: VizId;
|
47
|
+
changedVizIds: Array<VizId>;
|
48
|
+
} | {
|
49
|
+
type: "resetSrcdocResponse";
|
50
|
+
srcdoc?: string;
|
51
|
+
error?: Error;
|
52
|
+
};
|
53
|
+
export type V3WindowMessage = {
|
54
|
+
type: "runJS";
|
55
|
+
src: string;
|
56
|
+
} | {
|
57
|
+
type: "runCSS";
|
58
|
+
src: string;
|
59
|
+
id: ResolvedVizFileId;
|
60
|
+
} | {
|
61
|
+
type: "runDone";
|
62
|
+
} | {
|
63
|
+
type: "runError";
|
64
|
+
error: Error;
|
65
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { RollupBuild, RollupOptions } from "rollup";
|
2
|
+
import { VizCache } from "./vizCache";
|
3
|
+
import { FileCollection, VizId } from "@vizhub/viz-types";
|
4
|
+
import { SlugCache } from "./slugCache";
|
5
|
+
import { SvelteCompiler } from "./transformSvelte";
|
6
|
+
export declare const v3Build: ({ files, rollup, enableSourcemap, vizCache, vizId, slugCache, getSvelteCompiler, }: {
|
7
|
+
files: FileCollection;
|
8
|
+
rollup: (options: RollupOptions) => Promise<RollupBuild>;
|
9
|
+
enableSourcemap?: boolean;
|
10
|
+
vizCache: VizCache;
|
11
|
+
vizId: VizId;
|
12
|
+
slugCache?: SlugCache;
|
13
|
+
getSvelteCompiler?: () => Promise<SvelteCompiler>;
|
14
|
+
}) => Promise<string>;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { VizContent, VizId } from "@vizhub/viz-types";
|
2
|
+
export type VizCache = {
|
3
|
+
get: (vizId: string) => Promise<VizContent>;
|
4
|
+
set: (content: VizContent) => void;
|
5
|
+
invalidate: (vizId: string) => void;
|
6
|
+
};
|
7
|
+
export declare const createVizCache: ({ initialContents, handleCacheMiss, }: {
|
8
|
+
initialContents: Array<VizContent>;
|
9
|
+
handleCacheMiss?: (vizId: VizId) => Promise<VizContent>;
|
10
|
+
}) => VizCache;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { InputPluginOption } from "rollup";
|
2
|
+
import { ResolvedVizFileId } from "./types";
|
3
|
+
import { VizCache } from "./vizCache";
|
4
|
+
export declare const vizLoad: ({ vizCache, trackCSSImport, }: {
|
5
|
+
vizCache: VizCache;
|
6
|
+
trackCSSImport: (cssFile: ResolvedVizFileId) => void;
|
7
|
+
}) => InputPluginOption;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { RollupBuild, RollupOptions } from "rollup";
|
2
|
+
import { FileCollection } from "@vizhub/viz-types";
|
3
|
+
/**
|
4
|
+
* Build for v4 runtime
|
5
|
+
*/
|
6
|
+
export declare const v4Build: ({ files, rollup, enableSourcemap, }: {
|
7
|
+
files: FileCollection;
|
8
|
+
rollup: (options: RollupOptions) => Promise<RollupBuild>;
|
9
|
+
enableSourcemap?: boolean;
|
10
|
+
}) => Promise<FileCollection>;
|
package/package.json
CHANGED
@@ -1,21 +1,28 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vizhub/runtime",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.2",
|
4
4
|
"description": "Flexible runtime environment for data visualization sandboxes",
|
5
5
|
"type": "module",
|
6
|
-
"main": "./dist/index.js",
|
7
|
-
"
|
6
|
+
"main": "./dist/cjs/index.js",
|
7
|
+
"module": "./dist/esm/index.js",
|
8
|
+
"types": "./dist/types/index.d.ts",
|
8
9
|
"exports": {
|
9
10
|
".": {
|
10
|
-
"
|
11
|
-
"
|
11
|
+
"import": "./dist/esm/index.js",
|
12
|
+
"require": "./dist/cjs/index.js",
|
13
|
+
"default": "./dist/esm/index.js",
|
14
|
+
"types": "./dist/types/index.d.ts"
|
12
15
|
}
|
13
16
|
},
|
14
17
|
"files": [
|
15
|
-
"dist"
|
18
|
+
"dist",
|
19
|
+
"README.md"
|
16
20
|
],
|
17
21
|
"scripts": {
|
18
|
-
"build": "
|
22
|
+
"build": "npm run build:esm && npm run build:cjs && npm run build:types",
|
23
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
24
|
+
"build:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
|
25
|
+
"build:types": "tsc --emitDeclarationOnly --declarationDir ./dist/types",
|
19
26
|
"prepublishOnly": "npm run build",
|
20
27
|
"test": "vitest run",
|
21
28
|
"test:watch": "vitest",
|