@vizhub/runtime 0.3.2 → 0.3.3
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/v3/computeBundleJSV3.js +13 -13
- package/dist/cjs/v3/createVizContent.js +2 -2
- package/dist/cjs/v3/setupV3Runtime.js +5 -5
- package/dist/cjs/v3/transformDSV/index.js +4 -4
- package/dist/cjs/v3/v3Build.js +6 -6
- package/dist/cjs/v3/vizResolve.js +4 -4
- package/dist/esm/v3/computeBundleJSV3.js +6 -6
- package/dist/esm/v3/createVizContent.js +2 -2
- package/dist/esm/v3/setupV3Runtime.js +2 -2
- package/dist/esm/v3/transformDSV/index.js +2 -2
- package/dist/esm/v3/v3Build.js +3 -3
- package/dist/esm/v3/vizResolve.js +2 -2
- package/dist/types/v3/computeBundleJSV3.d.ts +3 -3
- package/dist/types/v3/types.d.ts +1 -1
- package/dist/types/v3/v3Build.d.ts +3 -3
- package/dist/types/v3/vizResolve.d.ts +1 -1
- package/package.json +1 -1
@@ -1,12 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.computeBundleJSV3 = void 0;
|
4
|
-
const
|
5
|
-
const
|
6
|
-
const
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
4
|
+
const sucrasePlugin_js_1 = require("../common/sucrasePlugin.js");
|
5
|
+
const packageJson_js_1 = require("../common/packageJson.js");
|
6
|
+
const index_js_1 = require("./transformDSV/index.js");
|
7
|
+
const vizResolve_js_1 = require("./vizResolve.js");
|
8
|
+
const vizLoad_js_1 = require("./vizLoad.js");
|
9
|
+
const transformSvelte_js_1 = require("./transformSvelte.js");
|
10
10
|
const computeBundleJSV3 = async ({ files, rollup, enableSourcemap = true, vizCache, vizId, slugCache, getSvelteCompiler, }) => {
|
11
11
|
// Track CSS imports
|
12
12
|
const cssFilesSet = new Set();
|
@@ -20,11 +20,11 @@ const computeBundleJSV3 = async ({ files, rollup, enableSourcemap = true, vizCac
|
|
20
20
|
const inputOptions = {
|
21
21
|
input: "./index.js",
|
22
22
|
plugins: [
|
23
|
-
(0,
|
24
|
-
(0,
|
25
|
-
(0,
|
26
|
-
(0,
|
27
|
-
(0,
|
23
|
+
(0, vizResolve_js_1.vizResolve)({ vizId, slugCache }),
|
24
|
+
(0, index_js_1.transformDSV)(),
|
25
|
+
(0, sucrasePlugin_js_1.sucrasePlugin)(),
|
26
|
+
(0, transformSvelte_js_1.transformSvelte)({ getSvelteCompiler }),
|
27
|
+
(0, vizLoad_js_1.vizLoad)({ vizCache, trackCSSImport }),
|
28
28
|
],
|
29
29
|
onwarn(warning, warn) {
|
30
30
|
// Suppress "treating module as external dependency" warnings
|
@@ -34,8 +34,8 @@ const computeBundleJSV3 = async ({ files, rollup, enableSourcemap = true, vizCac
|
|
34
34
|
},
|
35
35
|
};
|
36
36
|
const bundle = await rollup(inputOptions);
|
37
|
-
const pkg = (0,
|
38
|
-
const globals = (0,
|
37
|
+
const pkg = (0, packageJson_js_1.packageJSON)(files);
|
38
|
+
const globals = (0, packageJson_js_1.getGlobals)(pkg);
|
39
39
|
const outputOptions = {
|
40
40
|
format: "umd",
|
41
41
|
name: "Viz",
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.createVizContent = void 0;
|
4
|
-
const
|
4
|
+
const viz_utils_1 = require("@vizhub/viz-utils");
|
5
5
|
/**
|
6
6
|
* Creates a VizContent object with the given files
|
7
7
|
* @param files An object with file names as keys and file content as values
|
@@ -9,7 +9,7 @@ const uuid_1 = require("uuid");
|
|
9
9
|
* @returns A VizContent object with randomly generated IDs
|
10
10
|
*/
|
11
11
|
const createVizContent = (files, title = "Sample Content for Exporting") => {
|
12
|
-
const contentId = (0,
|
12
|
+
const contentId = (0, viz_utils_1.generateVizId)();
|
13
13
|
const contentFiles = {};
|
14
14
|
Object.entries(files).forEach(([fileName, fileContent]) => {
|
15
15
|
const fileId = Math.floor(Math.random() * 10000000).toString();
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.setupV3Runtime = void 0;
|
4
|
-
const parseId_1 = require("./parseId");
|
5
|
-
const cleanRollupErrorMessage_1 = require("./cleanRollupErrorMessage");
|
6
4
|
const viz_utils_1 = require("@vizhub/viz-utils");
|
5
|
+
const parseId_js_1 = require("./parseId.js");
|
6
|
+
const cleanRollupErrorMessage_js_1 = require("./cleanRollupErrorMessage.js");
|
7
7
|
// Flag for debugging.
|
8
8
|
const debug = false;
|
9
9
|
// Nothing happening.
|
@@ -85,7 +85,7 @@ const setupV3Runtime = ({ vizId, iframe, setSrcdocErrorMessage, getLatestContent
|
|
85
85
|
pendingBuildPromise = null;
|
86
86
|
}
|
87
87
|
if (error) {
|
88
|
-
setSrcdocErrorMessage((0,
|
88
|
+
setSrcdocErrorMessage((0, cleanRollupErrorMessage_js_1.cleanRollupErrorMessage)({
|
89
89
|
rawMessage: error.message,
|
90
90
|
vizId,
|
91
91
|
}));
|
@@ -140,7 +140,7 @@ const setupV3Runtime = ({ vizId, iframe, setSrcdocErrorMessage, getLatestContent
|
|
140
140
|
const srcdoc = message.srcdoc;
|
141
141
|
const error = message.error;
|
142
142
|
if (error) {
|
143
|
-
setSrcdocErrorMessage((0,
|
143
|
+
setSrcdocErrorMessage((0, cleanRollupErrorMessage_js_1.cleanRollupErrorMessage)({
|
144
144
|
rawMessage: error.message,
|
145
145
|
vizId,
|
146
146
|
}));
|
@@ -278,7 +278,7 @@ const setupV3Runtime = ({ vizId, iframe, setSrcdocErrorMessage, getLatestContent
|
|
278
278
|
if (iframe.contentWindow) {
|
279
279
|
// For each cssFiles
|
280
280
|
for (const cssFile of cssFiles) {
|
281
|
-
const { vizId, fileName } = (0,
|
281
|
+
const { vizId, fileName } = (0, parseId_js_1.parseId)(cssFile);
|
282
282
|
getLatestContent(vizId).then((content) => {
|
283
283
|
const src = (0, viz_utils_1.getFileText)(content, fileName);
|
284
284
|
if (src === null) {
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.transformDSV = void 0;
|
4
|
-
const
|
5
|
-
const
|
4
|
+
const parseId_js_1 = require("../parseId.js");
|
5
|
+
const dsvParseSrc_js_1 = require("./dsvParseSrc.js");
|
6
6
|
const DEBUG = false;
|
7
7
|
// Escape backticks in a string so that it can be
|
8
8
|
// used in a template literal. Also need to escape backslashes.
|
@@ -17,7 +17,7 @@ const transformDSV = () => ({
|
|
17
17
|
// `{vizId}/{fileName}`
|
18
18
|
transform: async (text, id) => {
|
19
19
|
DEBUG && console.log("[transformDSV]: load() " + id);
|
20
|
-
const { vizId, fileName } = (0,
|
20
|
+
const { vizId, fileName } = (0, parseId_js_1.parseId)(id);
|
21
21
|
DEBUG &&
|
22
22
|
console.log(" [transformDSV] vizId: " + vizId);
|
23
23
|
DEBUG &&
|
@@ -31,7 +31,7 @@ const transformDSV = () => ({
|
|
31
31
|
const parseFunction = isCSV ? "csvParse" : "tsvParse";
|
32
32
|
return {
|
33
33
|
code: `
|
34
|
-
${
|
34
|
+
${dsvParseSrc_js_1.dsvParseSrc}
|
35
35
|
const data = ${parseFunction}(\`${escapeBackticks(text)}\`);
|
36
36
|
export default data;
|
37
37
|
`,
|
package/dist/cjs/v3/v3Build.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.v3Build = void 0;
|
4
|
-
const computeBundleJSV3_1 = require("./computeBundleJSV3");
|
5
|
-
const htmlTemplate_1 = require("./htmlTemplate");
|
6
|
-
const parseId_1 = require("./parseId");
|
7
4
|
const viz_utils_1 = require("@vizhub/viz-utils");
|
5
|
+
const computeBundleJSV3_js_1 = require("./computeBundleJSV3.js");
|
6
|
+
const htmlTemplate_js_1 = require("./htmlTemplate.js");
|
7
|
+
const parseId_js_1 = require("./parseId.js");
|
8
8
|
const v3Build = async ({ files, rollup, enableSourcemap = true, vizCache, vizId, slugCache, getSvelteCompiler, }) => {
|
9
|
-
const { src, cssFiles } = await (0,
|
9
|
+
const { src, cssFiles } = await (0, computeBundleJSV3_js_1.computeBundleJSV3)({
|
10
10
|
files,
|
11
11
|
rollup,
|
12
12
|
enableSourcemap,
|
@@ -23,12 +23,12 @@ const v3Build = async ({ files, rollup, enableSourcemap = true, vizCache, vizId,
|
|
23
23
|
const id = cssFiles[i];
|
24
24
|
const indent = i > 0 ? " " : "\n ";
|
25
25
|
const styleElementId = "injected-style" + id;
|
26
|
-
const { vizId, fileName } = (0,
|
26
|
+
const { vizId, fileName } = (0, parseId_js_1.parseId)(id);
|
27
27
|
const content = await vizCache.get(vizId);
|
28
28
|
const src = (0, viz_utils_1.getFileText)(content, fileName);
|
29
29
|
styles += `${indent}<style id="${styleElementId}">${src}</style>`;
|
30
30
|
}
|
31
31
|
}
|
32
|
-
return (0,
|
32
|
+
return (0, htmlTemplate_js_1.htmlTemplate)({ cdn: "", src, styles });
|
33
33
|
};
|
34
34
|
exports.v3Build = v3Build;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.vizResolve = void 0;
|
4
|
-
const extractVizImport_1 = require("./extractVizImport");
|
5
|
-
const parseId_1 = require("./parseId");
|
6
4
|
const viz_utils_1 = require("@vizhub/viz-utils");
|
5
|
+
const extractVizImport_js_1 = require("./extractVizImport.js");
|
6
|
+
const parseId_js_1 = require("./parseId.js");
|
7
7
|
const debug = false;
|
8
8
|
const vizResolve = ({ vizId, slugCache, }) => ({
|
9
9
|
name: "vizResolve",
|
@@ -35,7 +35,7 @@ const vizResolve = ({ vizId, slugCache, }) => ({
|
|
35
35
|
// the entry point, so it should be resolved relative
|
36
36
|
// to the importer's directory
|
37
37
|
if (importer) {
|
38
|
-
const { vizId: importerVizId, fileName: importerFileName, } = (0,
|
38
|
+
const { vizId: importerVizId, fileName: importerFileName, } = (0, parseId_js_1.parseId)(importer);
|
39
39
|
// Get the directory of the importing file
|
40
40
|
const importerDir = importerFileName
|
41
41
|
.split("/")
|
@@ -52,7 +52,7 @@ const vizResolve = ({ vizId, slugCache, }) => ({
|
|
52
52
|
// Handle viz import resolution
|
53
53
|
// e.g. `import { foo } from '@curran/98e6d6509a1e407897d4f238a330efec'`
|
54
54
|
// e.g. `import { foo } from '@curran/scatter-plot'`
|
55
|
-
const vizImport = (0,
|
55
|
+
const vizImport = (0, extractVizImport_js_1.extractVizImport)(id);
|
56
56
|
if (vizImport) {
|
57
57
|
let vizId;
|
58
58
|
if ((0, viz_utils_1.isVizId)(vizImport.idOrSlug)) {
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { sucrasePlugin } from "../common/sucrasePlugin";
|
2
|
-
import { getGlobals, packageJSON, } from "../common/packageJson";
|
3
|
-
import { transformDSV } from "./transformDSV";
|
4
|
-
import { vizResolve } from "./vizResolve";
|
5
|
-
import { vizLoad } from "./vizLoad";
|
6
|
-
import { transformSvelte, } from "./transformSvelte";
|
1
|
+
import { sucrasePlugin } from "../common/sucrasePlugin.js";
|
2
|
+
import { getGlobals, packageJSON, } from "../common/packageJson.js";
|
3
|
+
import { transformDSV } from "./transformDSV/index.js";
|
4
|
+
import { vizResolve } from "./vizResolve.js";
|
5
|
+
import { vizLoad } from "./vizLoad.js";
|
6
|
+
import { transformSvelte, } from "./transformSvelte.js";
|
7
7
|
export const computeBundleJSV3 = async ({ files, rollup, enableSourcemap = true, vizCache, vizId, slugCache, getSvelteCompiler, }) => {
|
8
8
|
// Track CSS imports
|
9
9
|
const cssFilesSet = new Set();
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { generateVizId } from "@vizhub/viz-utils";
|
2
2
|
/**
|
3
3
|
* Creates a VizContent object with the given files
|
4
4
|
* @param files An object with file names as keys and file content as values
|
@@ -6,7 +6,7 @@ import { v4 as uuidv4 } from "uuid";
|
|
6
6
|
* @returns A VizContent object with randomly generated IDs
|
7
7
|
*/
|
8
8
|
export const createVizContent = (files, title = "Sample Content for Exporting") => {
|
9
|
-
const contentId =
|
9
|
+
const contentId = generateVizId();
|
10
10
|
const contentFiles = {};
|
11
11
|
Object.entries(files).forEach(([fileName, fileContent]) => {
|
12
12
|
const fileId = Math.floor(Math.random() * 10000000).toString();
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { parseId } from "./parseId";
|
2
|
-
import { cleanRollupErrorMessage } from "./cleanRollupErrorMessage";
|
3
1
|
import { getFileText } from "@vizhub/viz-utils";
|
2
|
+
import { parseId } from "./parseId.js";
|
3
|
+
import { cleanRollupErrorMessage } from "./cleanRollupErrorMessage.js";
|
4
4
|
// Flag for debugging.
|
5
5
|
const debug = false;
|
6
6
|
// Nothing happening.
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { parseId } from "../parseId";
|
2
|
-
import { dsvParseSrc } from "./dsvParseSrc";
|
1
|
+
import { parseId } from "../parseId.js";
|
2
|
+
import { dsvParseSrc } from "./dsvParseSrc.js";
|
3
3
|
const DEBUG = false;
|
4
4
|
// Escape backticks in a string so that it can be
|
5
5
|
// used in a template literal. Also need to escape backslashes.
|
package/dist/esm/v3/v3Build.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { computeBundleJSV3 } from "./computeBundleJSV3";
|
2
|
-
import { htmlTemplate } from "./htmlTemplate";
|
3
|
-
import { parseId } from "./parseId";
|
4
1
|
import { getFileText } from "@vizhub/viz-utils";
|
2
|
+
import { computeBundleJSV3 } from "./computeBundleJSV3.js";
|
3
|
+
import { htmlTemplate } from "./htmlTemplate.js";
|
4
|
+
import { parseId } from "./parseId.js";
|
5
5
|
export const v3Build = async ({ files, rollup, enableSourcemap = true, vizCache, vizId, slugCache, getSvelteCompiler, }) => {
|
6
6
|
const { src, cssFiles } = await computeBundleJSV3({
|
7
7
|
files,
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { extractVizImport } from "./extractVizImport";
|
2
|
-
import { parseId } from "./parseId";
|
3
1
|
import { isVizId } from "@vizhub/viz-utils";
|
2
|
+
import { extractVizImport } from "./extractVizImport.js";
|
3
|
+
import { parseId } from "./parseId.js";
|
4
4
|
const debug = false;
|
5
5
|
export const vizResolve = ({ vizId, slugCache, }) => ({
|
6
6
|
name: "vizResolve",
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import type { RollupBuild, RollupOptions } from "rollup";
|
2
|
-
import { VizCache } from "./vizCache";
|
3
2
|
import { FileCollection, VizId } from "@vizhub/viz-types";
|
4
|
-
import {
|
5
|
-
import {
|
3
|
+
import { VizCache } from "./vizCache.js";
|
4
|
+
import { SlugCache } from "./slugCache.js";
|
5
|
+
import { SvelteCompiler } from "./transformSvelte.js";
|
6
6
|
export declare const computeBundleJSV3: ({ files, rollup, enableSourcemap, vizCache, vizId, slugCache, getSvelteCompiler, }: {
|
7
7
|
files: FileCollection;
|
8
8
|
rollup: (options: RollupOptions) => Promise<RollupBuild>;
|
package/dist/types/v3/types.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { RollupBuild, RollupOptions } from "rollup";
|
2
|
-
import { VizCache } from "./vizCache";
|
2
|
+
import { VizCache } from "./vizCache.js";
|
3
3
|
import { FileCollection, VizId } from "@vizhub/viz-types";
|
4
|
-
import { SlugCache } from "./slugCache";
|
5
|
-
import { SvelteCompiler } from "./transformSvelte";
|
4
|
+
import { SlugCache } from "./slugCache.js";
|
5
|
+
import { SvelteCompiler } from "./transformSvelte.js";
|
6
6
|
export declare const v3Build: ({ files, rollup, enableSourcemap, vizCache, vizId, slugCache, getSvelteCompiler, }: {
|
7
7
|
files: FileCollection;
|
8
8
|
rollup: (options: RollupOptions) => Promise<RollupBuild>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { InputPluginOption } from "rollup";
|
2
2
|
import { VizId } from "@vizhub/viz-types";
|
3
|
-
import { SlugCache } from "./slugCache";
|
3
|
+
import { SlugCache } from "./slugCache.js";
|
4
4
|
export declare const vizResolve: ({ vizId, slugCache, }: {
|
5
5
|
vizId: VizId;
|
6
6
|
slugCache?: SlugCache;
|