mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Implement exported functions without relying on ActiveDoc.docData
Summary: For grist-static, we want to the data engine to be able to call external/exported JS functions directly, rather than via the node 'server' living in another thread which requires synchronous communication hackery. As a step in that direction, this diff changes the exported functions that we care about (guessColInfo and convertFromColumn) to just using the top-level functions instead of relying on fields in ActiveDoc, namely docData. For guessColInfo, this is done by directly passing the small amount of metadata that was previously retrieved from the DocData. For convertFromColumn, disentangling DocData is a lot more complicated, so instead we construct a fresh DocData object using the required metadata tables which are now passed in by the data engine. Test Plan: Existing tests Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3913
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
ValueParser
|
||||
} from 'app/common/ValueParser';
|
||||
import {CellValue, GristObjCode} from 'app/plugin/GristData';
|
||||
import { TableDataActionSet } from "./DocActions";
|
||||
|
||||
|
||||
/**
|
||||
@@ -192,22 +193,26 @@ export function createConverter(formatter: BaseFormatter, parser: ValueParser) {
|
||||
* The higher order function separates docData (passed by ActiveDoc)
|
||||
* from the arguments passed to call_external in Python.
|
||||
*/
|
||||
export function convertFromColumn(docData: DocData) {
|
||||
return function(
|
||||
sourceColRef: number,
|
||||
type: string,
|
||||
widgetOpts: string,
|
||||
visibleColRef: number,
|
||||
values: ReadonlyArray<CellValue>,
|
||||
displayColValues?: ReadonlyArray<CellValue>,
|
||||
): CellValue[] {
|
||||
const formatter = createFullFormatterFromDocData(docData, sourceColRef);
|
||||
const parser = createParserRaw(
|
||||
...createParserOrFormatterArgumentsRaw(docData, type, widgetOpts, visibleColRef)
|
||||
);
|
||||
const converter = createConverter(formatter, parser);
|
||||
return convertValues(converter, values, displayColValues || values);
|
||||
};
|
||||
export function convertFromColumn(
|
||||
metaTables: TableDataActionSet,
|
||||
sourceColRef: number,
|
||||
type: string,
|
||||
widgetOpts: string,
|
||||
visibleColRef: number,
|
||||
values: ReadonlyArray<CellValue>,
|
||||
displayColValues?: ReadonlyArray<CellValue>,
|
||||
): CellValue[] {
|
||||
const docData = new DocData(
|
||||
(_tableId) => { throw new Error("Unexpected DocData fetch"); },
|
||||
metaTables,
|
||||
);
|
||||
|
||||
const formatter = createFullFormatterFromDocData(docData, sourceColRef);
|
||||
const parser = createParserRaw(
|
||||
...createParserOrFormatterArgumentsRaw(docData, type, widgetOpts, visibleColRef)
|
||||
);
|
||||
const converter = createConverter(formatter, parser);
|
||||
return convertValues(converter, values, displayColValues || values);
|
||||
}
|
||||
|
||||
export function convertValues(
|
||||
|
||||
Reference in New Issue
Block a user