@akohn/dashql-react 0.0.20-dev.675.gf906d82d4 → 0.0.20-dev.873.gb84ef9086

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.
Files changed (37) hide show
  1. package/NOTICE +53 -1
  2. package/README.md +5 -3
  3. package/dist/components/data_table/data_table.d.ts +0 -1
  4. package/dist/components/data_table/data_table.js +4 -9
  5. package/dist/components/data_table/data_table_cell_header_plots.d.ts +1 -3
  6. package/dist/components/data_table/data_table_cell_header_plots.js +4 -6
  7. package/dist/components/data_table/histogram_brush.d.ts +0 -1
  8. package/dist/components/data_table/histogram_brush.js +3 -5
  9. package/dist/components/data_table/histogram_cell.d.ts +0 -2
  10. package/dist/components/data_table/histogram_cell.js +1 -2
  11. package/dist/components/name_input.d.ts +1 -0
  12. package/dist/components/name_input.js +13 -1
  13. package/dist/components/query_history_viewer.d.ts +1 -3
  14. package/dist/components/query_history_viewer.js +7 -4
  15. package/dist/components/query_profile/profile_execution_controller.d.ts +0 -2
  16. package/dist/components/query_profile/profile_execution_controller.js +0 -12
  17. package/dist/components/query_profile/query_profile_view.d.ts +1 -9
  18. package/dist/components/query_profile/query_profile_view.js +19 -27
  19. package/dist/components/vegalite_chart.d.ts +0 -2
  20. package/dist/components/vegalite_chart.js +1 -3
  21. package/dist/components/vegalite_view.d.ts +0 -1
  22. package/dist/components/vegalite_view.js +9 -18
  23. package/dist/components/visualization/vegalite_preview.d.ts +1 -1
  24. package/dist/components/visualization/visualization_dispatch.d.ts +0 -1
  25. package/dist/components/visualization/visualization_dispatch.js +0 -1
  26. package/dist/components/visualization/visualization_panel.d.ts +1 -1
  27. package/dist/components/visualization/visualization_panel.js +0 -1
  28. package/dist/hooks.d.ts +2 -1
  29. package/dist/hooks.js +4 -1
  30. package/dist/logger.d.ts +2 -2
  31. package/dist/logger.js +8 -1
  32. package/dist/models/script_model.js +4 -14
  33. package/dist/platform/embedded_database_provider.d.ts +1 -1
  34. package/dist/platform/page_runtime.d.ts +1 -1
  35. package/dist/vegalite/vegalite_image.d.ts +0 -2
  36. package/dist/vegalite/vegalite_image.js +1 -1
  37. package/package.json +372 -16
@@ -125,17 +125,15 @@ function VegaLiteView(props) {
125
125
  React.useEffect(() => {
126
126
  crossFilterUpdaterRef.current?.update(crossFilterMask);
127
127
  }, [crossFilterMask]);
128
- const scale = props.scale != null && props.scale > 0 ? props.scale : 1;
129
- const width = props.width != null ? Math.round(props.width / scale) : null;
130
- const height = props.height != null ? Math.round(props.height / scale) : null;
128
+ const width = props.width ?? null;
129
+ const height = props.height ?? null;
131
130
  React.useEffect(() => {
132
131
  const el = containerRef.current;
133
- if (!el || !spec || !rows) return;
132
+ if (!el || !rows || crossFilterBinding == null) return;
134
133
  let disposed = false;
135
134
  let finalizeView = null;
136
135
  let stableScaleDomains = [];
137
- const baseSpec = crossFilterBinding?.spec ?? (props.hideLegend ? stripLegends(spec) : spec);
138
- const runtimeSpec = { ...withViewEncodings(baseSpec) };
136
+ const runtimeSpec = { ...withViewEncodings(crossFilterBinding.spec) };
139
137
  runtimeSpec.width = width != null ? width : "container";
140
138
  runtimeSpec.height = height != null ? height : "container";
141
139
  runtimeSpec.autosize = {
@@ -173,11 +171,9 @@ function VegaLiteView(props) {
173
171
  return;
174
172
  }
175
173
  finalizeView = () => result.view.finalize();
176
- if (crossFilterBinding != null) {
177
- const updater = new VegaCrossFilterUpdater(result.view, crossFilterBinding.sourceDatasetName, rows, crossFilterBinding.maskDatasetName, crossFilterBinding.maskActiveSignalName, (e) => setError(e instanceof Error ? e.message : String(e)), stableScaleDomains);
178
- crossFilterUpdaterRef.current = updater;
179
- updater.update(crossFilterMaskRef.current);
180
- }
174
+ const updater = new VegaCrossFilterUpdater(result.view, crossFilterBinding.sourceDatasetName, rows, crossFilterBinding.maskDatasetName, crossFilterBinding.maskActiveSignalName, (e) => setError(e instanceof Error ? e.message : String(e)), stableScaleDomains);
175
+ crossFilterUpdaterRef.current = updater;
176
+ updater.update(crossFilterMaskRef.current);
181
177
  setError(null);
182
178
  }).catch((e) => {
183
179
  setError(e instanceof Error ? e.message : String(e));
@@ -190,13 +186,10 @@ function VegaLiteView(props) {
190
186
  if (el) el.replaceChildren();
191
187
  };
192
188
  }, [
193
- spec,
194
189
  rows,
195
190
  crossFilterBinding,
196
191
  width,
197
192
  height,
198
- scale,
199
- props.hideLegend,
200
193
  props.config,
201
194
  dependencies,
202
195
  colorScheme,
@@ -218,11 +211,9 @@ function VegaLiteView(props) {
218
211
  query: props.model?.query ?? null,
219
212
  rows: chartRows
220
213
  });
221
- const chartStyle = width != null || height != null || scale !== 1 ? {
214
+ const chartStyle = width != null || height != null ? {
222
215
  width: width ?? void 0,
223
- height: height ?? void 0,
224
- transform: scale !== 1 ? `scale(${scale})` : void 0,
225
- transformOrigin: scale !== 1 ? "top left" : void 0
216
+ height: height ?? void 0
226
217
  } : void 0;
227
218
  return /* @__PURE__ */ jsxs("div", {
228
219
  className: props.className ?? "dashql_root_vG43rg",
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { type VegaLiteViewProps } from '../vegalite_view.js';
3
3
  export declare const VEGALITE_PREVIEW_INSET = 8;
4
- export type VegaLitePreviewProps = Omit<VegaLiteViewProps, 'width' | 'height' | 'scale' | 'hideLegend' | 'config' | 'className'> & {
4
+ export type VegaLitePreviewProps = Omit<VegaLiteViewProps, 'width' | 'height' | 'hideLegend' | 'config' | 'className'> & {
5
5
  width: number;
6
6
  height: number;
7
7
  };
@@ -6,7 +6,6 @@ export interface VisualizationDispatchProps {
6
6
  visualizeQuery: ResolvedVisualizeQuery | null;
7
7
  width?: number;
8
8
  height?: number;
9
- scale?: number;
10
9
  hideLegend?: boolean;
11
10
  preview?: boolean;
12
11
  table: () => React.ReactNode;
@@ -24,7 +24,6 @@ function VisualizationDispatch(props) {
24
24
  vegaLiteSpec: vq.vegaLiteSpec,
25
25
  width: props.width,
26
26
  height: props.height,
27
- scale: props.scale,
28
27
  hideLegend: props.hideLegend
29
28
  });
30
29
  case "markdown": return /* @__PURE__ */ jsx(MarkdownView, {
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type { ResolvedVisualizeQuery } from '@akohn/dashql/platform/workbook/script_types';
3
3
  import { type VisualizationDispatchProps } from './visualization_dispatch.js';
4
- export interface VisualizationPanelProps extends Omit<VisualizationDispatchProps, 'visualizeQuery' | 'scale'> {
4
+ export interface VisualizationPanelProps extends Omit<VisualizationDispatchProps, 'visualizeQuery' | 'hideLegend'> {
5
5
  visualizeQuery: ResolvedVisualizeQuery;
6
6
  width?: number;
7
7
  height?: number;
@@ -27,7 +27,6 @@ function VisualizationPanel(props) {
27
27
  visualizeQuery: vq,
28
28
  width: props.width,
29
29
  height: props.height == null ? void 0 : Math.max(0, props.height - (showHeader ? HEADER_HEIGHT : 0)),
30
- hideLegend: props.hideLegend,
31
30
  preview: props.preview,
32
31
  table: props.table
33
32
  })
package/dist/hooks.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type * as arrow from 'apache-arrow';
3
3
  import type * as core from '@akohn/dashql';
4
- import type { Runtime, Settled } from '@akohn/dashql/runtime/runtime';
4
+ import type { Runtime, Settled } from '@akohn/dashql/runtime';
5
5
  import type { StoreView } from '@akohn/dashql/runtime/store/runtime_store';
6
6
  import type { ConnectionState } from '@akohn/dashql/platform/connections/connection_state';
7
7
  import type { EmbeddedClientContext, EmbeddedComputeDatabase } from '@akohn/dashql/platform/embedded_database';
@@ -54,6 +54,7 @@ export type TableComputationState = {
54
54
  export declare function useTableComputation(load: (() => Promise<arrow.Table>) | null, clientContext?: EmbeddedClientContext | null): TableComputationState;
55
55
  export interface WorkbookExecutionOptions {
56
56
  inputs?: readonly string[];
57
+ targets?: readonly number[];
57
58
  }
58
59
  export declare function useComputeReady(): boolean;
59
60
  export declare function useComputeDatabase(): EmbeddedComputeDatabase | null;
package/dist/hooks.js CHANGED
@@ -270,7 +270,10 @@ function useWorkbookExecution(workbookId) {
270
270
  workbookId,
271
271
  error: stringifyError(error)
272
272
  }, "workbook_execution");
273
- runtime.runWorkbook(workbookId, { inputs: options?.inputs == null ? void 0 : [...options.inputs] }).then((result) => {
273
+ runtime.runWorkbook(workbookId, {
274
+ inputs: options?.inputs == null ? void 0 : [...options.inputs],
275
+ targets: options?.targets == null ? void 0 : [...options.targets]
276
+ }).then((result) => {
274
277
  const failure = result.outcome.failure;
275
278
  if (failure != null && failure.kind === "error" && failure.queryId == null) failed(result.error);
276
279
  }, failed);
package/dist/logger.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
- import type { Logger } from '@akohn/dashql/platform/logger/logger';
3
- export declare const LoggerContext: React.Context<Logger | null>;
2
+ import { Logger } from '@akohn/dashql/platform/logger/logger';
3
+ export declare const LoggerContext: React.Context<Logger>;
4
4
  export declare function useLogger(): Logger;
package/dist/logger.js CHANGED
@@ -1,5 +1,12 @@
1
1
  import * as React from "react";
2
- var LoggerContext = React.createContext(null);
2
+ import { Logger } from "@akohn/dashql/platform/logger/logger";
3
+ var DroppingLogger = class extends Logger {
4
+ destroy() {}
5
+ flushPendingRecords() {
6
+ this.pendingRecords = [];
7
+ }
8
+ };
9
+ var LoggerContext = React.createContext(new DroppingLogger());
3
10
  function useLogger() {
4
11
  return React.useContext(LoggerContext);
5
12
  }
@@ -1,27 +1,16 @@
1
- import { useDispatch, useOptionalRuntime, useScript, useViewSelector } from "../hooks.js";
1
+ import { useDispatch, useOptionalRuntime, useScript, useScriptRun, useViewSelector } from "../hooks.js";
2
2
  import { useQueryModel } from "./query_model.js";
3
3
  import * as React from "react";
4
- import { stringifyError } from "@akohn/dashql/platform/logger/logger";
5
4
  function useScriptModel(workbookId, scriptKey) {
6
5
  const runtime = useOptionalRuntime();
6
+ const runScript = useScriptRun();
7
7
  const script = useScript(scriptKey);
8
8
  const query = useQueryModel(script?.latestQueryId ?? null);
9
9
  const runActive = useViewSelector("run", workbookId, (run) => run?.state?.busy === true || run?.held != null);
10
10
  const dispatch = useDispatch({ workbook: workbookId });
11
11
  const key = script?.scriptKey ?? null;
12
12
  const operations = React.useMemo(() => key == null ? null : {
13
- run: async (options) => {
14
- if (runtime == null) return;
15
- try {
16
- await runtime.runScript(workbookId, key, { refresh: options?.refresh });
17
- } catch (error) {
18
- runtime.logger.warn("Workbook script run failed", {
19
- workbookId,
20
- scriptKey: key.toString(),
21
- error: stringifyError(error)
22
- }, "workbook_execution");
23
- }
24
- },
13
+ run: async (options) => await runScript?.(workbookId, key, options),
25
14
  cancel: async () => await runtime?.cancelScript(workbookId, key),
26
15
  setText: (text) => dispatch({
27
16
  kind: "setScriptText",
@@ -48,6 +37,7 @@ function useScriptModel(workbookId, scriptKey) {
48
37
  }).settled
49
38
  }, [
50
39
  runtime,
40
+ runScript,
51
41
  workbookId,
52
42
  key,
53
43
  dispatch
@@ -15,5 +15,5 @@ interface Props {
15
15
  children?: React.ReactNode;
16
16
  }
17
17
  export declare function EmbeddedDatabaseProvider(props: Props): React.FunctionComponentElement<React.ProviderProps<EmbeddedDatabase | null>>;
18
- export declare function useEmbeddedDatabaseSetup(): EmbeddedDatabaseSetupFn;
18
+ export declare function useEmbeddedDatabaseSetup(): EmbeddedDatabaseSetupFn | null;
19
19
  export declare function useEmbeddedDatabaseTermination(): () => Promise<void>;
@@ -1,3 +1,3 @@
1
- import type { Runtime } from '@akohn/dashql/runtime/runtime';
1
+ import type { Runtime } from '@akohn/dashql/runtime';
2
2
  export declare function usePageRuntime(create: () => Runtime): Runtime;
3
3
  export declare function flushRuntimeStorage(runtime: Runtime, closing: boolean): Promise<void>;
@@ -1,12 +1,10 @@
1
1
  import type { TopLevelSpec } from 'vega-lite';
2
2
  import { CHART_IMAGE_HEIGHT, CHART_IMAGE_SCALE, CHART_IMAGE_WIDTH } from '@akohn/dashql/platform/workbook/chart_config';
3
- import { type VegaModules } from './vegalite_loader.js';
4
3
  export { CHART_IMAGE_HEIGHT, CHART_IMAGE_SCALE, CHART_IMAGE_WIDTH };
5
4
  export interface ChartImageOptions {
6
5
  width?: number;
7
6
  height?: number;
8
7
  scale?: number;
9
- loader?: () => Promise<VegaModules>;
10
8
  }
11
9
  export interface ChartImage {
12
10
  png: Uint8Array;
@@ -3,7 +3,7 @@ import { createVegaLiteConfig, resolveChartColors } from "./vegalite_theme.js";
3
3
  import { CHART_IMAGE_HEIGHT, CHART_IMAGE_SCALE, CHART_IMAGE_WIDTH, chartImageConfig, chartImageSpec } from "@akohn/dashql/platform/workbook/chart_config";
4
4
  var VEGA_LOG_LEVEL_ERROR = 1;
5
5
  async function renderVegaLitePng(spec, rows, options = {}) {
6
- const { vega, vegaLite, expressionInterpreter } = await (options.loader ?? loadVega)();
6
+ const { vega, vegaLite, expressionInterpreter } = await loadVega();
7
7
  const sizedSpec = chartImageSpec(spec, rows, options.width ?? CHART_IMAGE_WIDTH, options.height ?? CHART_IMAGE_HEIGHT);
8
8
  const compiled = vegaLite.compile(sizedSpec, { config: chartImageConfig(createVegaLiteConfig(resolveChartColors("light"))) }).spec;
9
9
  const view = new vega.View(vega.parse(compiled, void 0, { ast: true }), {