@vizhub/runtime 0.3.1 → 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 +14 -14
- package/dist/cjs/v2/index.js +2 -2
- package/dist/cjs/v2/v2Build.js +4 -4
- package/dist/cjs/v3/index.js +2 -2
- package/dist/cjs/v3/transformSvelte.js +2 -2
- package/dist/cjs/v4/index.js +7 -7
- package/dist/esm/buildHTML.js +7 -7
- package/dist/esm/v2/index.js +1 -1
- package/dist/esm/v2/v2Build.js +2 -2
- package/dist/esm/v3/index.js +1 -1
- package/dist/esm/v3/transformSvelte.js +1 -1
- package/dist/esm/v4/index.js +3 -3
- package/dist/types/buildHTML.d.ts +3 -3
- package/dist/types/determineRuntimeVersion.d.ts +1 -1
- package/dist/types/v2/index.d.ts +1 -1
- package/dist/types/v3/index.d.ts +1 -1
- package/dist/types/v3/parseId.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/buildHTML.js
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.buildHTML = void 0;
|
4
4
|
const magic_sandbox_1 = require("magic-sandbox");
|
5
|
-
const
|
6
|
-
const
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
5
|
+
const determineRuntimeVersion_js_1 = require("./determineRuntimeVersion.js");
|
6
|
+
const index_js_1 = require("./v2/index.js");
|
7
|
+
const index_js_2 = require("./v3/index.js");
|
8
|
+
const index_js_3 = require("./v4/index.js");
|
9
|
+
const vizCache_js_1 = require("./v3/vizCache.js");
|
10
|
+
const createVizContent_js_1 = require("./v3/createVizContent.js");
|
11
|
+
const vizContentToFileCollection_js_1 = require("./utils/vizContentToFileCollection.js");
|
12
12
|
const DEBUG = false;
|
13
13
|
const buildHTML = async ({ files, rollup, enableSourcemap = true, vizCache, vizId, slugCache, getSvelteCompiler, }) => {
|
14
14
|
if (!files && !vizCache) {
|
@@ -18,12 +18,12 @@ const buildHTML = async ({ files, rollup, enableSourcemap = true, vizCache, vizI
|
|
18
18
|
throw new Error("vizId is required when using vizCache");
|
19
19
|
}
|
20
20
|
if (!files && vizCache && vizId) {
|
21
|
-
files = (0,
|
21
|
+
files = (0, vizContentToFileCollection_js_1.vizContentToFileCollection)(await vizCache.get(vizId));
|
22
22
|
}
|
23
23
|
if (!files) {
|
24
24
|
throw new Error("Upable to extract viz files");
|
25
25
|
}
|
26
|
-
const version = (0,
|
26
|
+
const version = (0, determineRuntimeVersion_js_1.determineRuntimeVersion)(files);
|
27
27
|
DEBUG && console.log("[buildHTML] version:", version);
|
28
28
|
if (version === "v1") {
|
29
29
|
return (0, magic_sandbox_1.magicSandbox)(files);
|
@@ -32,16 +32,16 @@ const buildHTML = async ({ files, rollup, enableSourcemap = true, vizCache, vizI
|
|
32
32
|
if (!rollup) {
|
33
33
|
throw new Error("Rollup is required for v2 runtime");
|
34
34
|
}
|
35
|
-
return (0, magic_sandbox_1.magicSandbox)(await (0,
|
35
|
+
return (0, magic_sandbox_1.magicSandbox)(await (0, index_js_1.v2Build)({ files, rollup, enableSourcemap }));
|
36
36
|
}
|
37
37
|
if (version === "v3") {
|
38
38
|
if (!rollup) {
|
39
39
|
throw new Error("Rollup is required for v3 runtime");
|
40
40
|
}
|
41
41
|
if (!vizCache && !vizId) {
|
42
|
-
const vizContent = (0,
|
42
|
+
const vizContent = (0, createVizContent_js_1.createVizContent)(files);
|
43
43
|
vizId = vizContent.id;
|
44
|
-
vizCache = (0,
|
44
|
+
vizCache = (0, vizCache_js_1.createVizCache)({
|
45
45
|
initialContents: [vizContent],
|
46
46
|
handleCacheMiss: async () => {
|
47
47
|
throw new Error("Cache miss handler not implemented");
|
@@ -51,7 +51,7 @@ const buildHTML = async ({ files, rollup, enableSourcemap = true, vizCache, vizI
|
|
51
51
|
if (!vizCache || !vizId) {
|
52
52
|
throw new Error("vizCache and vizId are required for v3 runtime");
|
53
53
|
}
|
54
|
-
return await (0,
|
54
|
+
return await (0, index_js_2.v3Build)({
|
55
55
|
files,
|
56
56
|
rollup,
|
57
57
|
vizCache,
|
@@ -64,7 +64,7 @@ const buildHTML = async ({ files, rollup, enableSourcemap = true, vizCache, vizI
|
|
64
64
|
if (!rollup) {
|
65
65
|
throw new Error("Rollup is required for v4 runtime");
|
66
66
|
}
|
67
|
-
return (0, magic_sandbox_1.magicSandbox)(await (0,
|
67
|
+
return (0, magic_sandbox_1.magicSandbox)(await (0, index_js_3.v4Build)({ files, rollup, enableSourcemap }));
|
68
68
|
}
|
69
69
|
throw new Error(`Unsupported runtime version: ${version}`);
|
70
70
|
};
|
package/dist/cjs/v2/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.v2Build = void 0;
|
4
|
-
var
|
5
|
-
Object.defineProperty(exports, "v2Build", { enumerable: true, get: function () { return
|
4
|
+
var v2Build_js_1 = require("./v2Build.js");
|
5
|
+
Object.defineProperty(exports, "v2Build", { enumerable: true, get: function () { return v2Build_js_1.v2Build; } });
|
package/dist/cjs/v2/v2Build.js
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.v2Build = void 0;
|
4
|
-
const
|
5
|
-
const
|
4
|
+
const getComputedIndexHtml_js_1 = require("./getComputedIndexHtml.js");
|
5
|
+
const computeBundleJSV2_js_1 = require("./computeBundleJSV2.js");
|
6
6
|
const v2Build = async ({ files, rollup, enableSourcemap, }) => ({
|
7
7
|
...files,
|
8
|
-
"bundle.js": await (0,
|
8
|
+
"bundle.js": await (0, computeBundleJSV2_js_1.computeBundleJSV2)({
|
9
9
|
files,
|
10
10
|
rollup,
|
11
11
|
enableSourcemap,
|
12
12
|
}),
|
13
|
-
"index.html": (0,
|
13
|
+
"index.html": (0, getComputedIndexHtml_js_1.getComputedIndexHtml)(files),
|
14
14
|
});
|
15
15
|
exports.v2Build = v2Build;
|
package/dist/cjs/v3/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.v3Build = void 0;
|
4
|
-
var
|
5
|
-
Object.defineProperty(exports, "v3Build", { enumerable: true, get: function () { return
|
4
|
+
var v3Build_js_1 = require("./v3Build.js");
|
5
|
+
Object.defineProperty(exports, "v3Build", { enumerable: true, get: function () { return v3Build_js_1.v3Build; } });
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.transformSvelte = exports.svelteCompilerUrl = void 0;
|
4
|
-
const
|
4
|
+
const parseId_js_1 = require("./parseId.js");
|
5
5
|
const debug = false;
|
6
6
|
// The cache of fetched files.
|
7
7
|
const fetchedFileCache = new Map();
|
@@ -60,7 +60,7 @@ const transformSvelte = ({ getSvelteCompiler, }) => ({
|
|
60
60
|
}
|
61
61
|
},
|
62
62
|
transform: async (code, id) => {
|
63
|
-
const { fileName } = (0,
|
63
|
+
const { fileName } = (0, parseId_js_1.parseId)(id);
|
64
64
|
const isSvelte = fileName.endsWith(".svelte");
|
65
65
|
if (isSvelte) {
|
66
66
|
if (!compile) {
|
package/dist/cjs/v4/index.js
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.v4Build = void 0;
|
4
4
|
const jsdom_1 = require("jsdom");
|
5
|
-
const
|
6
|
-
const
|
7
|
-
const
|
5
|
+
const virtualFileSystem_js_1 = require("../common/virtualFileSystem.js");
|
6
|
+
const sucrasePlugin_js_1 = require("../common/sucrasePlugin.js");
|
7
|
+
const packageJson_js_1 = require("../common/packageJson.js");
|
8
8
|
const DEBUG = false;
|
9
9
|
/**
|
10
10
|
* Extract module script entry points from index.html
|
@@ -28,7 +28,7 @@ const extractModuleEntryPoints = (html) => {
|
|
28
28
|
const bundleESModule = async ({ entryPoint, files, rollup, enableSourcemap = true, }) => {
|
29
29
|
const inputOptions = {
|
30
30
|
input: `./${entryPoint}`,
|
31
|
-
plugins: [(0,
|
31
|
+
plugins: [(0, virtualFileSystem_js_1.virtualFileSystem)(files), (0, sucrasePlugin_js_1.sucrasePlugin)()],
|
32
32
|
onwarn(warning, warn) {
|
33
33
|
// Suppress "treating module as external dependency" warnings
|
34
34
|
if (warning.code === "UNRESOLVED_IMPORT")
|
@@ -48,14 +48,14 @@ const bundleESModule = async ({ entryPoint, files, rollup, enableSourcemap = tru
|
|
48
48
|
* Generate an import map for all dependencies
|
49
49
|
*/
|
50
50
|
const generateImportMap = (files) => {
|
51
|
-
const deps = (0,
|
51
|
+
const deps = (0, packageJson_js_1.dependencies)(files);
|
52
52
|
if (Object.keys(deps).length === 0) {
|
53
53
|
return null;
|
54
54
|
}
|
55
|
-
const libraries = (0,
|
55
|
+
const libraries = (0, packageJson_js_1.getConfiguredLibraries)(files);
|
56
56
|
const imports = {};
|
57
57
|
Object.entries(deps).forEach(([name, version]) => {
|
58
|
-
const url = (0,
|
58
|
+
const url = (0, packageJson_js_1.dependencySource)({ name, version }, libraries);
|
59
59
|
imports[name] = url;
|
60
60
|
});
|
61
61
|
return JSON.stringify({ imports }, null, 2);
|
package/dist/esm/buildHTML.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import { magicSandbox } from "magic-sandbox";
|
2
|
-
import { determineRuntimeVersion } from "./determineRuntimeVersion";
|
3
|
-
import { v2Build } from "./v2";
|
4
|
-
import { v3Build } from "./v3";
|
5
|
-
import { v4Build } from "./v4";
|
6
|
-
import { createVizCache } from "./v3/vizCache";
|
7
|
-
import { createVizContent } from "./v3/createVizContent";
|
8
|
-
import { vizContentToFileCollection } from "./utils/vizContentToFileCollection";
|
2
|
+
import { determineRuntimeVersion } from "./determineRuntimeVersion.js";
|
3
|
+
import { v2Build } from "./v2/index.js";
|
4
|
+
import { v3Build } from "./v3/index.js";
|
5
|
+
import { v4Build } from "./v4/index.js";
|
6
|
+
import { createVizCache } from "./v3/vizCache.js";
|
7
|
+
import { createVizContent } from "./v3/createVizContent.js";
|
8
|
+
import { vizContentToFileCollection } from "./utils/vizContentToFileCollection.js";
|
9
9
|
const DEBUG = false;
|
10
10
|
export const buildHTML = async ({ files, rollup, enableSourcemap = true, vizCache, vizId, slugCache, getSvelteCompiler, }) => {
|
11
11
|
if (!files && !vizCache) {
|
package/dist/esm/v2/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { v2Build } from "./v2Build";
|
1
|
+
export { v2Build } from "./v2Build.js";
|
package/dist/esm/v2/v2Build.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { getComputedIndexHtml } from "./getComputedIndexHtml";
|
2
|
-
import { computeBundleJSV2 } from "./computeBundleJSV2";
|
1
|
+
import { getComputedIndexHtml } from "./getComputedIndexHtml.js";
|
2
|
+
import { computeBundleJSV2 } from "./computeBundleJSV2.js";
|
3
3
|
export const v2Build = async ({ files, rollup, enableSourcemap, }) => ({
|
4
4
|
...files,
|
5
5
|
"bundle.js": await computeBundleJSV2({
|
package/dist/esm/v3/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { v3Build } from "./v3Build";
|
1
|
+
export { v3Build } from "./v3Build.js";
|
package/dist/esm/v4/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { JSDOM } from "jsdom";
|
2
|
-
import { virtualFileSystem } from "../common/virtualFileSystem";
|
3
|
-
import { sucrasePlugin } from "../common/sucrasePlugin";
|
4
|
-
import { dependencies, getConfiguredLibraries, dependencySource, } from "../common/packageJson";
|
2
|
+
import { virtualFileSystem } from "../common/virtualFileSystem.js";
|
3
|
+
import { sucrasePlugin } from "../common/sucrasePlugin.js";
|
4
|
+
import { dependencies, getConfiguredLibraries, dependencySource, } from "../common/packageJson.js";
|
5
5
|
const DEBUG = false;
|
6
6
|
/**
|
7
7
|
* Extract module script entry points from index.html
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { FileCollection } from "@vizhub/viz-types";
|
2
2
|
import type { RollupBuild, RollupOptions } from "rollup";
|
3
|
-
import { VizCache } from "./v3/vizCache";
|
4
|
-
import { SlugCache } from "./v3/slugCache";
|
5
|
-
import { SvelteCompiler } from "./v3/transformSvelte";
|
3
|
+
import { VizCache } from "./v3/vizCache.js";
|
4
|
+
import { SlugCache } from "./v3/slugCache.js";
|
5
|
+
import { SvelteCompiler } from "./v3/transformSvelte.js";
|
6
6
|
export declare const buildHTML: ({ files, rollup, enableSourcemap, vizCache, vizId, slugCache, getSvelteCompiler, }: {
|
7
7
|
files?: FileCollection;
|
8
8
|
rollup?: (options: RollupOptions) => Promise<RollupBuild>;
|
package/dist/types/v2/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { v2Build } from "./v2Build";
|
1
|
+
export { v2Build } from "./v2Build.js";
|
package/dist/types/v3/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { v3Build } from "./v3Build";
|
1
|
+
export { v3Build } from "./v3Build.js";
|