@ggterm/core 0.3.5 → 0.3.6
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/cli-plot.js +36 -7
- package/dist/serve.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli-plot.js
CHANGED
|
@@ -14653,23 +14653,46 @@ function handleServe(port) {
|
|
|
14653
14653
|
broadcast(payload);
|
|
14654
14654
|
}, 150);
|
|
14655
14655
|
});
|
|
14656
|
-
const vegaLitePath = join3(getGGTermDir(), "last-plot-vegalite.json");
|
|
14657
14656
|
let styleDebounce = null;
|
|
14657
|
+
let lastStyleBroadcast = 0;
|
|
14658
14658
|
watch(getGGTermDir(), (_event, filename) => {
|
|
14659
|
-
if (filename !== "last-plot-vegalite.json")
|
|
14659
|
+
if (filename !== "last-plot-vegalite.json" && filename !== "last-plot.json")
|
|
14660
14660
|
return;
|
|
14661
14661
|
if (styleDebounce)
|
|
14662
14662
|
clearTimeout(styleDebounce);
|
|
14663
14663
|
styleDebounce = setTimeout(() => {
|
|
14664
|
-
|
|
14664
|
+
const now = Date.now();
|
|
14665
|
+
if (now - lastStyleBroadcast < 500)
|
|
14665
14666
|
return;
|
|
14667
|
+
lastStyleBroadcast = now;
|
|
14666
14668
|
try {
|
|
14667
|
-
|
|
14669
|
+
let spec = null;
|
|
14668
14670
|
const latestId = getLatestPlotId();
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
+
if (filename === "last-plot.json") {
|
|
14672
|
+
const plotPath = join3(getGGTermDir(), "last-plot.json");
|
|
14673
|
+
if (!existsSync3(plotPath))
|
|
14674
|
+
return;
|
|
14675
|
+
const plot = JSON.parse(readFileSync3(plotPath, "utf-8"));
|
|
14676
|
+
const geomTypes = plot._provenance?.geomTypes || [];
|
|
14677
|
+
const hasCompositeMark = geomTypes.some((t) => COMPOSITE_MARKS.has(t));
|
|
14678
|
+
spec = plotSpecToVegaLite(plot.spec, { interactive: !hasCompositeMark });
|
|
14679
|
+
} else {
|
|
14680
|
+
const vegaLitePath = join3(getGGTermDir(), "last-plot-vegalite.json");
|
|
14681
|
+
if (!existsSync3(vegaLitePath))
|
|
14682
|
+
return;
|
|
14683
|
+
spec = JSON.parse(readFileSync3(vegaLitePath, "utf-8"));
|
|
14684
|
+
}
|
|
14685
|
+
if (!spec)
|
|
14686
|
+
return;
|
|
14687
|
+
const provenance = {
|
|
14688
|
+
id: latestId || "styled",
|
|
14689
|
+
description: "Styled plot",
|
|
14690
|
+
timestamp: new Date().toISOString(),
|
|
14691
|
+
geomTypes: []
|
|
14692
|
+
};
|
|
14693
|
+
broadcast(JSON.stringify({ type: "update", spec, provenance }));
|
|
14671
14694
|
} catch {}
|
|
14672
|
-
},
|
|
14695
|
+
}, 300);
|
|
14673
14696
|
});
|
|
14674
14697
|
const server = createServer((req, res) => {
|
|
14675
14698
|
const url = new URL(req.url || "/", `http://localhost:${p}`);
|
|
@@ -15181,6 +15204,12 @@ function connect() {
|
|
|
15181
15204
|
showPlot(data);
|
|
15182
15205
|
updateNav();
|
|
15183
15206
|
updateHistoryHighlight();
|
|
15207
|
+
} else if (data.type === 'update') {
|
|
15208
|
+
// Style/customize change — replace current plot, don't add to history
|
|
15209
|
+
if (currentIdx >= 0 && currentIdx < history.length) {
|
|
15210
|
+
history[currentIdx] = data;
|
|
15211
|
+
}
|
|
15212
|
+
showPlot(data);
|
|
15184
15213
|
}
|
|
15185
15214
|
};
|
|
15186
15215
|
}
|
package/dist/serve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgfH,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CA+J/C"}
|