feat: add remix mode for spark table rolling
Introduces a `remix` option that allows each data column in a spark table to be rolled independently. This is enabled via a `remix=true` attribute in the directive's extra attributes. Also refactors spark table scanning by moving markdown parsing logic from the frontend to a new CLI-side `spark-scanner.ts` utility, improving separation of concerns.
This commit is contained in:
@@ -128,7 +128,8 @@ export const JournalInput: Component = () => {
|
||||
const key = (parsed.payload as { key: string }).key;
|
||||
const match = comp.data.sparkTables.find((s) => s.slug === key);
|
||||
const csvPath = match?.csvPath ?? "";
|
||||
const p = await resolveSparkPayload({ key, csvPath });
|
||||
const remix = match?.remix ?? false;
|
||||
const p = await resolveSparkPayload({ key, csvPath, remix });
|
||||
const result = sendMessage("spark", p);
|
||||
const r = unwrap(result);
|
||||
finish(r.ok, r.err);
|
||||
|
||||
@@ -54,6 +54,7 @@ export interface SparkTableCompletion {
|
||||
filePath: string;
|
||||
csvPath: string;
|
||||
headers: string[];
|
||||
remix: boolean;
|
||||
}
|
||||
|
||||
export interface JournalCompletions {
|
||||
|
||||
@@ -70,10 +70,12 @@ export type SparkPayload = z.infer<typeof schema>;
|
||||
*
|
||||
* `key` is the combined slug (pageName-columnSlug).
|
||||
* `csvPath` is the resolved .csv file path from completions.
|
||||
* `remix` controls whether each column gets an independent roll.
|
||||
*/
|
||||
export async function resolveSparkPayload(raw: {
|
||||
key: string;
|
||||
csvPath: string;
|
||||
remix: boolean;
|
||||
}): Promise<SparkPayload> {
|
||||
let csv: string;
|
||||
try {
|
||||
@@ -89,7 +91,7 @@ export async function resolveSparkPayload(raw: {
|
||||
);
|
||||
}
|
||||
|
||||
const sparkResult = rollSparkTable(meta);
|
||||
const sparkResult = rollSparkTable(meta, { remix: raw.remix });
|
||||
const firstRoll = rollFormula(meta.notation);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user