@ggterm/core 0.3.4 → 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 +51 -16
- package/dist/init.d.ts.map +1 -1
- 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
|
}
|
|
@@ -15212,7 +15241,7 @@ import { join as join4 } from "path";
|
|
|
15212
15241
|
// src/init.ts
|
|
15213
15242
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, readFileSync as readFileSync2, existsSync as existsSync2, readdirSync as readdirSync2, statSync } from "fs";
|
|
15214
15243
|
import { join as join2, extname } from "path";
|
|
15215
|
-
var SKILLS_VERSION = "0.3.
|
|
15244
|
+
var SKILLS_VERSION = "0.3.4";
|
|
15216
15245
|
var SKILLS = {
|
|
15217
15246
|
"data-load": {
|
|
15218
15247
|
files: {
|
|
@@ -15524,11 +15553,12 @@ spec.height = 400
|
|
|
15524
15553
|
|
|
15525
15554
|
## Workflow
|
|
15526
15555
|
|
|
15527
|
-
1.
|
|
15528
|
-
2.
|
|
15529
|
-
3.
|
|
15530
|
-
4.
|
|
15531
|
-
|
|
15556
|
+
1. Read \`.ggterm/last-plot-vegalite.json\`
|
|
15557
|
+
2. Apply the requested modifications
|
|
15558
|
+
3. Write the updated spec back to \`.ggterm/last-plot-vegalite.json\`
|
|
15559
|
+
4. **DONE** — the live viewer auto-detects the change and displays the customized plot
|
|
15560
|
+
|
|
15561
|
+
**IMPORTANT**: Do NOT re-create the plot with \`npx ggterm-plot\` after customizing. The viewer watches the spec file and auto-updates. Re-running the plot command would overwrite your customizations.
|
|
15532
15562
|
|
|
15533
15563
|
$ARGUMENTS
|
|
15534
15564
|
`
|
|
@@ -15560,9 +15590,12 @@ Apply expert-curated style presets to Vega-Lite specifications for publication-q
|
|
|
15560
15590
|
## Workflow
|
|
15561
15591
|
|
|
15562
15592
|
1. Read \`.ggterm/last-plot-vegalite.json\`
|
|
15563
|
-
2. Apply the requested style preset
|
|
15564
|
-
3. Write the updated spec
|
|
15565
|
-
4.
|
|
15593
|
+
2. Apply the requested style preset (only modify \`config\` — do NOT change \`encoding\`, \`data\`, or \`mark\` structure)
|
|
15594
|
+
3. Write the updated spec back to \`.ggterm/last-plot-vegalite.json\`
|
|
15595
|
+
4. **DONE** — the live viewer auto-detects the change and displays the styled plot
|
|
15596
|
+
5. Inform user they can export with \`/ggterm-publish\`
|
|
15597
|
+
|
|
15598
|
+
**IMPORTANT**: Do NOT re-create the plot with \`npx ggterm-plot\` after styling. The viewer watches the spec file and auto-updates. Re-running the plot command would overwrite your style changes.
|
|
15566
15599
|
|
|
15567
15600
|
## Response Format
|
|
15568
15601
|
|
|
@@ -15768,6 +15801,8 @@ point, line, histogram, boxplot, bar, violin, density, area, ridgeline, heatmap,
|
|
|
15768
15801
|
## Live Viewer
|
|
15769
15802
|
|
|
15770
15803
|
When \`npx ggterm-plot serve\` is running, plots auto-display in the browser/Wave panel as high-resolution interactive Vega-Lite visualizations instead of ASCII art.
|
|
15804
|
+
|
|
15805
|
+
**Style and customize changes also auto-display.** When you modify \`.ggterm/last-plot-vegalite.json\` (via /ggterm-style or /ggterm-customize), the viewer updates automatically. Do NOT re-run \`npx ggterm-plot\` after styling — that would overwrite your changes.
|
|
15771
15806
|
`;
|
|
15772
15807
|
const GGTERM_MARKER = "# ggterm Data Analysis Project";
|
|
15773
15808
|
let shouldWriteClaudeMd = !existsSync2(claudeMdPath);
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsgBH,wBAAgB,UAAU,IAAI,IAAI,CA2JjC"}
|
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"}
|