@marimo-team/islands 0.16.1 → 0.16.3
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/{ConnectedDataExplorerComponent-DyqLQGPc.js → ConnectedDataExplorerComponent-CareOso9.js} +2 -2
- package/dist/{ImageComparisonComponent-CQDGJfUA.js → ImageComparisonComponent-I_Z738Uj.js} +1 -1
- package/dist/{_baseUniq-B2Nna6Kt.js → _baseUniq-D-Kb4EU4.js} +1 -1
- package/dist/{any-language-editor-D-wq0tOG.js → any-language-editor-BRWmYor8.js} +1 -1
- package/dist/{architectureDiagram-W76B3OCA-C6tdnMBf.js → architectureDiagram-W76B3OCA-bZJcJYGH.js} +4 -4
- package/dist/assets/{worker-B0C57BK8.js → worker-DMlIUTIq.js} +18 -17
- package/dist/{blockDiagram-QIGZ2CNN-IagL8LCN.js → blockDiagram-QIGZ2CNN-DyXjO8fR.js} +5 -5
- package/dist/{c4Diagram-FPNF74CW-D3_lIWUP.js → c4Diagram-FPNF74CW-Bfs9ui2r.js} +2 -2
- package/dist/{channel-DCJI_DKk.js → channel-CMup9X3Z.js} +1 -1
- package/dist/{chunk-4BX2VUAB-B2DrODwN.js → chunk-4BX2VUAB-CW-ni6M_.js} +1 -1
- package/dist/{chunk-55IACEB6-BUWDsQ-t.js → chunk-55IACEB6-Bj-Indya.js} +1 -1
- package/dist/{chunk-FMBD7UC4-BExPNFv1.js → chunk-FMBD7UC4-9IC8qSSk.js} +1 -1
- package/dist/{chunk-K7UQS3LO-Cixi-Yko.js → chunk-K7UQS3LO-aapkEuWN.js} +4 -4
- package/dist/{chunk-QN33PNHL-B83MtvER.js → chunk-QN33PNHL-Bo5dJ5T5.js} +1 -1
- package/dist/{chunk-QZHKN3VN-CXvbu85X.js → chunk-QZHKN3VN-BkMzjJYY.js} +1 -1
- package/dist/{chunk-TVAH2DTR-CpiumCHg.js → chunk-TVAH2DTR-Wqy_C_Rn.js} +3 -3
- package/dist/{chunk-TZMSLE5B-DIzaZjcI.js → chunk-TZMSLE5B-DjBmEAUz.js} +1 -1
- package/dist/{classDiagram-v2-RKCZMP56-DyN5HPdk.js → classDiagram-KNZD7YFC-DUsaN1O4.js} +2 -2
- package/dist/{classDiagram-KNZD7YFC-DyN5HPdk.js → classDiagram-v2-RKCZMP56-DUsaN1O4.js} +2 -2
- package/dist/{clone-DrJYap2i.js → clone-Dkt_7KOK.js} +1 -1
- package/dist/{cose-bilkent-S5V4N54A-D39b4WrQ.js → cose-bilkent-S5V4N54A-ClBuGZWI.js} +2 -2
- package/dist/{dagre-5GWH7T2D-BLjRxDpS.js → dagre-5GWH7T2D-BzmDIGaM.js} +6 -6
- package/dist/{data-grid-overlay-editor-DTALqerV.js → data-grid-overlay-editor-NiU9Ea77.js} +2 -2
- package/dist/{diagram-N5W7TBWH-MM8AIKGR.js → diagram-N5W7TBWH-BlO1yw_g.js} +5 -5
- package/dist/{diagram-QEK2KX5R-BZGarWuJ.js → diagram-QEK2KX5R-BvK83LUx.js} +3 -3
- package/dist/{diagram-S2PKOQOG-CnPinN9Q.js → diagram-S2PKOQOG-DvBzRYd7.js} +3 -3
- package/dist/{dockerfile-U8DnCJ4X.js → dockerfile-CPQG2tLO.js} +1 -1
- package/dist/{erDiagram-AWTI2OKA-CvDVbxOO.js → erDiagram-AWTI2OKA-Doy9FRTX.js} +4 -4
- package/dist/{flowDiagram-PVAE7QVJ-C2uuBTZS.js → flowDiagram-PVAE7QVJ-D_tX_HU1.js} +5 -5
- package/dist/{ganttDiagram-OWAHRB6G-BEff10RF.js → ganttDiagram-OWAHRB6G-CV03BHVY.js} +4 -4
- package/dist/{gitGraphDiagram-NY62KEGX-wggu0kb2.js → gitGraphDiagram-NY62KEGX-w3szEguZ.js} +4 -4
- package/dist/{glide-data-editor-Bqh5_dzJ.js → glide-data-editor-akznFrmp.js} +3 -3
- package/dist/{graph-DKpp_wzf.js → graph-CjrrDHdT.js} +3 -3
- package/dist/index-CIJJs0Tu.js +40382 -0
- package/dist/{index-DzJ_YPCG.js → index-DMo6cbcV.js} +3 -3
- package/dist/{index-4XruEJkp.js → index-DlV2CtJb.js} +1 -1
- package/dist/{index-DdfF_cLK.js → index-Y-Vbae6Z.js} +1 -1
- package/dist/{infoDiagram-STP46IZ2-DF7KW-Op.js → infoDiagram-STP46IZ2-BcBV2j75.js} +2 -2
- package/dist/{journeyDiagram-BIP6EPQ6-B_jmhmqd.js → journeyDiagram-BIP6EPQ6-BTGMSgvB.js} +3 -3
- package/dist/{kanban-definition-6OIFK2YF-B-M9FTyw.js → kanban-definition-6OIFK2YF-aopNqZ1Y.js} +2 -2
- package/dist/{layout-C4oVYZZD.js → layout-Dvo9pb_w.js} +4 -4
- package/dist/{linear-C-HCGr0T.js → linear-CHnELER9.js} +1 -1
- package/dist/{main-B9x2-9f2.js → main-kLZGkzVQ.js} +41787 -40423
- package/dist/main.js +1 -1
- package/dist/{mermaid-BE4cM3Qs.js → mermaid-DgM4_4bD.js} +30 -30
- package/dist/{min-DTpHJ698.js → min-cX4DuL_n.js} +2 -2
- package/dist/{mindmap-definition-Q6HEUPPD-Cpd-hO1E.js → mindmap-definition-Q6HEUPPD-DZjbYryy.js} +3 -3
- package/dist/{number-overlay-editor-CvURA2Ud.js → number-overlay-editor-8MpIObf7.js} +2 -2
- package/dist/{pieDiagram-ADFJNKIX-D9f_f6fn.js → pieDiagram-ADFJNKIX-D6L1IYAc.js} +3 -3
- package/dist/{quadrantDiagram-LMRXKWRM-DgllE7xw.js → quadrantDiagram-LMRXKWRM-nOyuc3Bf.js} +2 -2
- package/dist/{react-plotly-BU-JRJSi.js → react-plotly-ChkfYiVe.js} +1 -1
- package/dist/{requirementDiagram-4UW4RH46-Dk_G8eUb.js → requirementDiagram-4UW4RH46-OVV8wsju.js} +3 -3
- package/dist/{sankeyDiagram-GR3RE2ED-BhLIhDc1.js → sankeyDiagram-GR3RE2ED-qZHMdnE_.js} +1 -1
- package/dist/{sequenceDiagram-C3RYC4MD-DHoZdMFJ.js → sequenceDiagram-C3RYC4MD-D0bOqf-t.js} +3 -3
- package/dist/{slides-component-DXAgdf7K.js → slides-component-CNzLDdA3.js} +1 -1
- package/dist/{stateDiagram-KXAO66HF-C1Ie-7Xf.js → stateDiagram-KXAO66HF-CFNCnNJS.js} +4 -4
- package/dist/{stateDiagram-v2-UMBNRL4Z--CRuIHtM.js → stateDiagram-v2-UMBNRL4Z-CnIh27m8.js} +2 -2
- package/dist/style.css +1 -1
- package/dist/{time-yQjlGPwa.js → time-Z7CJSfOW.js} +2 -2
- package/dist/{timeline-definition-XQNQX7LJ-D_PjxB1B.js → timeline-definition-XQNQX7LJ-BYLMfrvK.js} +1 -1
- package/dist/{treemap-75Q7IDZK--NYqQjUZ.js → treemap-75Q7IDZK-BEh1HacP.js} +5 -5
- package/dist/{vega-component-CCUOMM5K.js → vega-component-iMjXd3tD.js} +2 -2
- package/dist/{xychartDiagram-6GGTOJPD-WLKsEnzs.js → xychartDiagram-6GGTOJPD-Bmi13ZSG.js} +2 -2
- package/package.json +8 -8
- package/src/__mocks__/common.ts +5 -3
- package/src/__mocks__/notebook.ts +2 -2
- package/src/__mocks__/requests.ts +1 -0
- package/src/__tests__/main.test.tsx +2 -2
- package/src/components/ai/ai-provider-icon.tsx +2 -0
- package/src/components/app-config/ai-config.tsx +32 -1
- package/src/components/app-config/common.tsx +2 -2
- package/src/components/app-config/user-config-form.tsx +26 -0
- package/src/components/audio/audio-recorder.tsx +0 -1
- package/src/components/chat/acp/blocks.tsx +2 -2
- package/src/components/chat/acp/thread.tsx +3 -5
- package/src/components/chat/acp/utils.ts +5 -5
- package/src/components/chat/chat-panel.tsx +1 -1
- package/src/components/data-table/__tests__/columns.test.tsx +38 -0
- package/src/components/data-table/__tests__/data-table.test.tsx +2 -2
- package/src/components/data-table/cell-hover-template/feature.ts +1 -1
- package/src/components/data-table/cell-hover-template/types.ts +1 -1
- package/src/components/data-table/charts/__tests__/altair-generator.test.ts +1 -1
- package/src/components/data-table/charts/chart-spec/tooltips.ts +3 -3
- package/src/components/data-table/charts/components/chart-items.tsx +1 -1
- package/src/components/data-table/charts/components/form-fields.tsx +2 -2
- package/src/components/data-table/charts/constants.ts +1 -1
- package/src/components/data-table/column-explorer-panel/column-explorer.tsx +1 -1
- package/src/components/data-table/column-summary/chart-spec-model.tsx +2 -2
- package/src/components/data-table/columns.tsx +22 -3
- package/src/components/data-table/data-table.tsx +35 -3
- package/src/components/data-table/date-popover.tsx +1 -1
- package/src/components/data-table/download-actions.tsx +1 -1
- package/src/components/data-table/range-focus/__tests__/utils.test.ts +5 -5
- package/src/components/data-table/renderers.tsx +22 -13
- package/src/components/data-table/row-viewer-panel/row-viewer.tsx +1 -1
- package/src/components/data-table/schemas.ts +16 -0
- package/src/components/data-table/types.ts +4 -3
- package/src/components/datasources/column-preview.tsx +9 -6
- package/src/components/debugger/debugger-code.tsx +1 -1
- package/src/components/dependency-graph/custom-node.tsx +15 -6
- package/src/components/dependency-graph/dependency-graph-minimap.tsx +2 -2
- package/src/components/dependency-graph/dependency-graph-tree.tsx +2 -2
- package/src/components/dependency-graph/dependency-graph.tsx +1 -1
- package/src/components/dependency-graph/elements.ts +7 -7
- package/src/components/dependency-graph/utils/changes.ts +4 -4
- package/src/components/editor/Cell.tsx +7 -1
- package/src/components/editor/ai/transport/chat-transport.tsx +1 -1
- package/src/components/editor/chrome/panels/outline/useActiveOutline.tsx +1 -1
- package/src/components/editor/chrome/panels/packages-panel.tsx +1 -1
- package/src/components/editor/columns/storage.ts +1 -1
- package/src/components/editor/database/__tests__/__snapshots__/as-code.test.ts.snap +36 -0
- package/src/components/editor/database/__tests__/as-code.test.ts +30 -7
- package/src/components/editor/database/add-database-form.tsx +11 -0
- package/src/components/editor/database/as-code.ts +104 -5
- package/src/components/editor/database/schemas.ts +36 -18
- package/src/components/editor/errors/auto-fix.tsx +12 -2
- package/src/components/editor/errors/sql-validation-errors.tsx +40 -0
- package/src/components/editor/navigation/clipboard.ts +2 -2
- package/src/components/editor/output/ConsoleOutput.tsx +14 -2
- package/src/components/editor/output/JsonOutput.tsx +1 -1
- package/src/components/editor/output/MarimoErrorOutput.tsx +60 -1
- package/src/components/editor/output/MarimoTracebackOutput.tsx +17 -2
- package/src/components/editor/renderers/grid-layout/types.ts +2 -2
- package/src/components/editor/renderers/plugins.ts +1 -1
- package/src/components/editor/renderers/types.ts +1 -1
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +7 -7
- package/src/components/forms/form.tsx +5 -5
- package/src/components/ui/links.tsx +1 -0
- package/src/core/ai/__tests__/model-registry.test.ts +0 -10
- package/src/core/ai/context/providers/cell-output.ts +1 -18
- package/src/core/ai/context/providers/error.ts +2 -2
- package/src/core/ai/ids/ids.ts +1 -0
- package/src/core/ai/model-registry.ts +2 -1
- package/src/core/cells/cells.ts +5 -5
- package/src/core/cells/logs.ts +1 -1
- package/src/core/cells/types.ts +1 -1
- package/src/core/codemirror/__tests__/format.test.ts +6 -0
- package/src/core/codemirror/cells/traceback-decorations.ts +1 -1
- package/src/core/codemirror/editing/commands.ts +2 -2
- package/src/core/codemirror/find-replace/navigate.ts +1 -1
- package/src/core/codemirror/language/__tests__/extension.test.ts +24 -0
- package/src/core/codemirror/language/__tests__/sql-validation.test.ts +133 -0
- package/src/core/codemirror/language/__tests__/sql.test.ts +764 -79
- package/src/core/codemirror/language/languages/markdown.ts +4 -1
- package/src/core/codemirror/language/languages/sql/banner-validation-errors.ts +85 -0
- package/src/core/codemirror/language/languages/sql/completion-builder.ts +160 -0
- package/src/core/codemirror/language/languages/sql/completion-sources.tsx +9 -3
- package/src/core/codemirror/language/languages/sql/completion-store.ts +46 -50
- package/src/core/codemirror/language/languages/sql/renderers.tsx +485 -0
- package/src/core/codemirror/language/languages/sql/sql-mode.ts +20 -0
- package/src/core/codemirror/language/languages/sql/sql.ts +218 -4
- package/src/core/codemirror/language/languages/sql/utils.ts +4 -1
- package/src/core/codemirror/language/panel/panel.tsx +8 -2
- package/src/core/codemirror/language/panel/sql.tsx +86 -4
- package/src/core/codemirror/language/utils/ast.ts +3 -3
- package/src/core/codemirror/lsp/federated-lsp.ts +4 -4
- package/src/core/codemirror/lsp/lens.ts +4 -4
- package/src/core/codemirror/lsp/notebook-lsp.ts +1 -1
- package/src/core/codemirror/lsp/types.ts +1 -1
- package/src/core/codemirror/markdown/completions.ts +1 -1
- package/src/core/codemirror/reactive-references/analyzer.ts +2 -2
- package/src/core/codemirror/rtc/loro/awareness.ts +1 -1
- package/src/core/config/config-schema.ts +1 -0
- package/src/core/config/feature-flag.tsx +6 -2
- package/src/core/datasets/request-registry.ts +24 -1
- package/src/core/dom/events.ts +1 -1
- package/src/core/dom/outline.ts +2 -2
- package/src/core/dom/uiregistry.ts +2 -8
- package/src/core/errors/__tests__/errors.test.ts +22 -4
- package/src/core/errors/errors.ts +29 -1
- package/src/core/errors/state.ts +1 -1
- package/src/core/islands/bridge.ts +1 -0
- package/src/core/islands/main.ts +3 -2
- package/src/core/islands/parse.ts +1 -3
- package/src/core/kernel/messages.ts +2 -1
- package/src/core/network/CachingRequestRegistry.ts +74 -0
- package/src/core/network/DeferredRequestRegistry.ts +3 -1
- package/src/core/network/__tests__/CachingRequestRegistry.test.ts +73 -0
- package/src/core/network/requests-network.ts +7 -0
- package/src/core/network/requests-static.ts +1 -0
- package/src/core/network/requests-toasting.ts +1 -0
- package/src/core/network/types.ts +3 -1
- package/src/core/variables/state.ts +2 -2
- package/src/core/wasm/__tests__/state.test.ts +1 -1
- package/src/core/wasm/bridge.ts +5 -0
- package/src/core/websocket/useMarimoWebSocket.tsx +9 -2
- package/src/custom.d.ts +1 -1
- package/src/hooks/useCellRenderCount.ts +1 -0
- package/src/hooks/useResizeHandle.ts +4 -1
- package/src/plugins/core/RenderHTML.tsx +1 -2
- package/src/plugins/core/registerReactComponent.tsx +23 -19
- package/src/plugins/impl/DataTablePlugin.tsx +18 -6
- package/src/plugins/impl/FileUploadPlugin.tsx +1 -1
- package/src/plugins/impl/RefreshPlugin.tsx +1 -1
- package/src/plugins/impl/SliderPlugin.tsx +4 -0
- package/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx +27 -9
- package/src/plugins/impl/anywidget/__tests__/AnyWidgetPlugin.test.tsx +58 -2
- package/src/plugins/impl/anywidget/__tests__/model.test.ts +3 -4
- package/src/plugins/impl/anywidget/model.ts +2 -3
- package/src/plugins/impl/data-editor/types.ts +1 -1
- package/src/plugins/impl/data-explorer/components/query-form.tsx +1 -1
- package/src/plugins/impl/data-frames/DataFramePlugin.tsx +17 -5
- package/src/plugins/impl/data-frames/types.ts +1 -1
- package/src/plugins/impl/panel/PanelPlugin.tsx +2 -2
- package/src/plugins/impl/plotly/PlotlyPlugin.tsx +3 -3
- package/src/plugins/impl/vega/__tests__/loader.test.ts +2 -2
- package/src/plugins/impl/vega/loader.ts +1 -1
- package/src/plugins/impl/vega/vega-component.tsx +1 -1
- package/src/plugins/impl/vega/vega-loader.ts +2 -2
- package/src/plugins/layout/NavigationMenuPlugin.tsx +1 -1
- package/src/plugins/layout/RoutesPlugin.tsx +1 -2
- package/src/plugins/plugins.ts +2 -2
- package/src/stories/dataframe.stories.tsx +2 -0
- package/src/utils/Logger.ts +1 -1
- package/src/utils/__tests__/data-views.test.ts +30 -68
- package/src/utils/__tests__/dom.test.ts +167 -0
- package/src/utils/__tests__/id-tree.test.ts +49 -1
- package/src/utils/__tests__/storage.test.ts +1 -1
- package/src/utils/__tests__/traceback.test.ts +13 -2
- package/src/utils/arrays.ts +1 -1
- package/src/utils/createReducer.ts +1 -5
- package/src/utils/data-views.ts +6 -19
- package/src/utils/dom.ts +55 -0
- package/src/utils/edit-distance.ts +1 -1
- package/src/utils/fileToBase64.ts +1 -1
- package/src/utils/id-tree.tsx +20 -18
- package/src/utils/json/base64.ts +13 -0
- package/src/utils/json/json-parser.ts +2 -2
- package/src/utils/lru.ts +4 -0
- package/src/utils/mergeRefs.ts +1 -1
- package/src/utils/objects.ts +3 -3
- package/src/utils/pluralize.ts +1 -1
- package/src/utils/routes.ts +2 -2
- package/src/utils/sets.ts +1 -1
- package/src/utils/traceback.ts +45 -15
- package/src/utils/tracer.ts +11 -9
- package/dist/index-DW0BCGJE.js +0 -40315
- package/src/__tests__/lru.test.ts +0 -74
package/src/utils/id-tree.tsx
CHANGED
|
@@ -25,9 +25,9 @@ export type CellIndex = number & { __brand?: "CellIndex" };
|
|
|
25
25
|
export class TreeNode<T> {
|
|
26
26
|
public value: T;
|
|
27
27
|
public isCollapsed: boolean;
|
|
28
|
-
public children:
|
|
28
|
+
public children: TreeNode<T>[];
|
|
29
29
|
|
|
30
|
-
constructor(value: T, isCollapsed: boolean, children:
|
|
30
|
+
constructor(value: T, isCollapsed: boolean, children: TreeNode<T>[]) {
|
|
31
31
|
this.value = value;
|
|
32
32
|
this.isCollapsed = isCollapsed;
|
|
33
33
|
this.children = children;
|
|
@@ -77,15 +77,17 @@ export class TreeNode<T> {
|
|
|
77
77
|
@Memoize()
|
|
78
78
|
get inOrderIds(): T[] {
|
|
79
79
|
const result: T[] = [];
|
|
80
|
-
const queue = [...this.children];
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const node = queue.shift()!;
|
|
81
|
+
// Use depth-first traversal to preserve logical document order
|
|
82
|
+
const traverse = (node: TreeNode<T>) => {
|
|
85
83
|
result.push(node.value);
|
|
84
|
+
for (const child of node.children) {
|
|
85
|
+
traverse(child);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
for (const child of this.children) {
|
|
90
|
+
traverse(child);
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
return result;
|
|
@@ -106,10 +108,10 @@ export class TreeNode<T> {
|
|
|
106
108
|
let uniqueId = 0;
|
|
107
109
|
|
|
108
110
|
export class CollapsibleTree<T> {
|
|
109
|
-
public readonly nodes:
|
|
111
|
+
public readonly nodes: TreeNode<T>[];
|
|
110
112
|
public readonly id: CellColumnId;
|
|
111
113
|
|
|
112
|
-
private constructor(nodes:
|
|
114
|
+
private constructor(nodes: TreeNode<T>[], id: CellColumnId) {
|
|
113
115
|
this.nodes = nodes;
|
|
114
116
|
this.id = id;
|
|
115
117
|
}
|
|
@@ -160,7 +162,7 @@ export class CollapsibleTree<T> {
|
|
|
160
162
|
return newTree;
|
|
161
163
|
}
|
|
162
164
|
|
|
163
|
-
withNodes(nodes:
|
|
165
|
+
withNodes(nodes: TreeNode<T>[]): CollapsibleTree<T> {
|
|
164
166
|
return new CollapsibleTree(nodes, this.id);
|
|
165
167
|
}
|
|
166
168
|
|
|
@@ -305,7 +307,7 @@ export class CollapsibleTree<T> {
|
|
|
305
307
|
* Does not collapse the children of already collapsed nodes
|
|
306
308
|
*/
|
|
307
309
|
collapseAll(
|
|
308
|
-
collapseRanges:
|
|
310
|
+
collapseRanges: ({ id: T; until: T | undefined } | null)[],
|
|
309
311
|
): CollapsibleTree<T> {
|
|
310
312
|
const nodes = [...this.nodes];
|
|
311
313
|
if (collapseRanges.length === 0) {
|
|
@@ -539,7 +541,7 @@ export class CollapsibleTree<T> {
|
|
|
539
541
|
*/
|
|
540
542
|
find(id: T): T[] {
|
|
541
543
|
// We need to recursively find the node
|
|
542
|
-
function findNode(nodes:
|
|
544
|
+
function findNode(nodes: TreeNode<T>[], path: T[]): T[] {
|
|
543
545
|
for (const node of nodes) {
|
|
544
546
|
if (node.value === id) {
|
|
545
547
|
return [...path, id];
|
|
@@ -585,7 +587,7 @@ export class CollapsibleTree<T> {
|
|
|
585
587
|
toString(): string {
|
|
586
588
|
let depth = 0;
|
|
587
589
|
let result = "";
|
|
588
|
-
const asString = (nodes:
|
|
590
|
+
const asString = (nodes: TreeNode<T>[]) => {
|
|
589
591
|
for (const node of nodes) {
|
|
590
592
|
result += `${" ".repeat(depth * 2)}${node.toString()}\n`;
|
|
591
593
|
depth += 1;
|
|
@@ -599,9 +601,9 @@ export class CollapsibleTree<T> {
|
|
|
599
601
|
}
|
|
600
602
|
|
|
601
603
|
export class MultiColumn<T> {
|
|
602
|
-
private readonly columns:
|
|
604
|
+
private readonly columns: readonly CollapsibleTree<T>[];
|
|
603
605
|
|
|
604
|
-
constructor(columns:
|
|
606
|
+
constructor(columns: readonly CollapsibleTree<T>[]) {
|
|
605
607
|
this.columns = columns;
|
|
606
608
|
|
|
607
609
|
// Ensure there is always at least one column
|
|
@@ -662,7 +664,7 @@ export class MultiColumn<T> {
|
|
|
662
664
|
}
|
|
663
665
|
|
|
664
666
|
static fromIdsAndColumns<T>(
|
|
665
|
-
idAndColumns:
|
|
667
|
+
idAndColumns: [T, number | undefined | null][],
|
|
666
668
|
): MultiColumn<T> {
|
|
667
669
|
// If column is undefined, use the previous column
|
|
668
670
|
// Ensure there is always at least one column
|
|
@@ -744,7 +746,7 @@ export class MultiColumn<T> {
|
|
|
744
746
|
return this.columns.length === 1;
|
|
745
747
|
}
|
|
746
748
|
|
|
747
|
-
getColumns():
|
|
749
|
+
getColumns(): readonly CollapsibleTree<T>[] {
|
|
748
750
|
return this.columns;
|
|
749
751
|
}
|
|
750
752
|
|
package/src/utils/json/base64.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/* Copyright 2024 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import type { OperationMessageData } from "@/core/kernel/messages";
|
|
2
4
|
import type { TypedString } from "../typed";
|
|
3
5
|
|
|
4
6
|
export type JsonString<T = unknown> = TypedString<"Json"> & {
|
|
@@ -52,3 +54,14 @@ export function extractBase64FromDataURL(str: DataURLString): Base64String {
|
|
|
52
54
|
export function byteStringToBinary(bytes: ByteString): Uint8Array {
|
|
53
55
|
return Uint8Array.from(bytes, (c) => c.charCodeAt(0));
|
|
54
56
|
}
|
|
57
|
+
|
|
58
|
+
export function safeExtractSetUIElementMessageBuffers(
|
|
59
|
+
op: OperationMessageData<"send-ui-element-message">,
|
|
60
|
+
): readonly DataView[] {
|
|
61
|
+
// @ts-expect-error - TypeScript doesn't know that these strings are actually base64 strings
|
|
62
|
+
const strs: Base64String[] = op.buffers ?? [];
|
|
63
|
+
return strs.map((str) => {
|
|
64
|
+
const bytes = byteStringToBinary(typedAtob(str));
|
|
65
|
+
return new DataView(bytes.buffer);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -34,7 +34,7 @@ export function jsonParseWithSpecialChar<T = unknown>(
|
|
|
34
34
|
/(?<=\s|^|\[|,|:)(NaN|-Infinity|Infinity)(?=(?:[^"'\\]*(\\.|'([^'\\]*\\.)*[^'\\]*'|"([^"\\]*\\.)*[^"\\]*"))*[^"']*$)/g,
|
|
35
35
|
`"${CHAR}$1${CHAR}"`,
|
|
36
36
|
);
|
|
37
|
-
return JSON.parse(value, (
|
|
37
|
+
return JSON.parse(value, (_key, v) => {
|
|
38
38
|
if (typeof v !== "string") {
|
|
39
39
|
return v;
|
|
40
40
|
}
|
|
@@ -54,7 +54,7 @@ export function jsonParseWithSpecialChar<T = unknown>(
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export function jsonToTSV(json:
|
|
57
|
+
export function jsonToTSV(json: Record<string, unknown>[]) {
|
|
58
58
|
if (json.length === 0) {
|
|
59
59
|
return "";
|
|
60
60
|
}
|
package/src/utils/lru.ts
CHANGED
package/src/utils/mergeRefs.ts
CHANGED
package/src/utils/objects.ts
CHANGED
|
@@ -17,14 +17,14 @@ export const Objects = {
|
|
|
17
17
|
/**
|
|
18
18
|
* Type-safe Object.fromEntries
|
|
19
19
|
*/
|
|
20
|
-
fromEntries<K extends string | number, V>(obj:
|
|
20
|
+
fromEntries<K extends string | number, V>(obj: [K, V][]): Record<K, V> {
|
|
21
21
|
return Object.fromEntries(obj) as Record<K, V>;
|
|
22
22
|
},
|
|
23
23
|
/**
|
|
24
24
|
* Type-safe Object.entries
|
|
25
25
|
*/
|
|
26
|
-
entries<K extends string | number, V>(obj: Record<K, V>):
|
|
27
|
-
return Object.entries(obj) as
|
|
26
|
+
entries<K extends string | number, V>(obj: Record<K, V>): [K, V][] {
|
|
27
|
+
return Object.entries(obj) as [K, V][];
|
|
28
28
|
},
|
|
29
29
|
/**
|
|
30
30
|
* Type-safe Object.keys
|
package/src/utils/pluralize.ts
CHANGED
package/src/utils/routes.ts
CHANGED
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
} from "path-to-regexp";
|
|
9
9
|
|
|
10
10
|
export class TinyRouter {
|
|
11
|
-
private routes:
|
|
11
|
+
private routes: {
|
|
12
12
|
template: string;
|
|
13
13
|
pathFunction: MatchFunction<ParamData>;
|
|
14
|
-
}
|
|
14
|
+
}[];
|
|
15
15
|
|
|
16
16
|
constructor(templates: string[]) {
|
|
17
17
|
this.routes = templates.map((template) => {
|
package/src/utils/sets.ts
CHANGED
package/src/utils/traceback.ts
CHANGED
|
@@ -28,13 +28,38 @@ export const elementContainsMarimoCellFile = (domNode: Element) => {
|
|
|
28
28
|
);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
export type TracebackInfo =
|
|
32
|
+
| {
|
|
33
|
+
kind: "file";
|
|
34
|
+
filePath: string;
|
|
35
|
+
lineNumber: number;
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
kind: "cell";
|
|
39
|
+
cellId: CellId;
|
|
40
|
+
lineNumber: number;
|
|
41
|
+
};
|
|
35
42
|
|
|
36
43
|
/**
|
|
37
44
|
* Extract the cell id and line number from a traceback DOM node.
|
|
45
|
+
*
|
|
46
|
+
* Example transformation:
|
|
47
|
+
*
|
|
48
|
+
* File <span class="nb">"/tmp/marimo_<number>/__marimo__cell_<CellId>.py"</span>
|
|
49
|
+
* , line <span class="n">1</span>...
|
|
50
|
+
*
|
|
51
|
+
* becomes
|
|
52
|
+
*
|
|
53
|
+
* { kind: "cell", cellId: <CellID>, lineNumber: 1 }
|
|
54
|
+
*
|
|
55
|
+
* or for files:
|
|
56
|
+
*
|
|
57
|
+
* File <span class="nb">"/path/to/file.py"</span>
|
|
58
|
+
* , line <span class="n">42</span>...
|
|
59
|
+
*
|
|
60
|
+
* becomes
|
|
61
|
+
*
|
|
62
|
+
* { kind: "file", filePath: "/path/to/file.py", lineNumber: 42 }
|
|
38
63
|
*/
|
|
39
64
|
export function getTracebackInfo(domNode: DOMNode): TracebackInfo | null {
|
|
40
65
|
// The traceback can be manipulated either in output render or in the pygments
|
|
@@ -57,7 +82,7 @@ export function getTracebackInfo(domNode: DOMNode): TracebackInfo | null {
|
|
|
57
82
|
if (
|
|
58
83
|
domNode instanceof Element &&
|
|
59
84
|
domNode.firstChild instanceof Text &&
|
|
60
|
-
|
|
85
|
+
matchesSelector(domNode, "span.nb")
|
|
61
86
|
) {
|
|
62
87
|
const nextSibling = domNode.next;
|
|
63
88
|
if (nextSibling && nextSibling instanceof Text) {
|
|
@@ -68,14 +93,22 @@ export function getTracebackInfo(domNode: DOMNode): TracebackInfo | null {
|
|
|
68
93
|
lineSibling.firstChild instanceof Text &&
|
|
69
94
|
matchesSelector(lineSibling, "span.m")
|
|
70
95
|
) {
|
|
71
|
-
const cellId = /__marimo__cell_(\w+)_/.exec(
|
|
72
|
-
domNode.firstChild.nodeValue,
|
|
73
|
-
)?.[1];
|
|
74
96
|
const lineNumber = Number.parseInt(
|
|
75
97
|
lineSibling.firstChild.nodeValue || "0",
|
|
98
|
+
10,
|
|
76
99
|
);
|
|
77
|
-
if (
|
|
78
|
-
|
|
100
|
+
if (domNode.firstChild.nodeValue?.includes("__marimo__")) {
|
|
101
|
+
const cellId = /__marimo__cell_(\w+)_/.exec(
|
|
102
|
+
domNode.firstChild.nodeValue,
|
|
103
|
+
)?.[1] as CellId;
|
|
104
|
+
if (cellId && lineNumber) {
|
|
105
|
+
return { kind: "cell", cellId, lineNumber };
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
const filePath = /"(.+?)"/.exec(domNode.firstChild.nodeValue)?.[1];
|
|
109
|
+
if (filePath && lineNumber) {
|
|
110
|
+
return { kind: "file", filePath, lineNumber };
|
|
111
|
+
}
|
|
79
112
|
}
|
|
80
113
|
}
|
|
81
114
|
}
|
|
@@ -92,11 +125,8 @@ export function extractAllTracebackInfo(traceback: string): TracebackInfo[] {
|
|
|
92
125
|
replace: (domNode) => {
|
|
93
126
|
const info = getTracebackInfo(domNode);
|
|
94
127
|
if (info) {
|
|
95
|
-
infos.push(
|
|
96
|
-
|
|
97
|
-
lineNumber: info.lineNumber,
|
|
98
|
-
});
|
|
99
|
-
return `${info.cellId}:${info.lineNumber}`;
|
|
128
|
+
infos.push(info);
|
|
129
|
+
return "dummy";
|
|
100
130
|
}
|
|
101
131
|
},
|
|
102
132
|
});
|
package/src/utils/tracer.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/* Copyright 2024 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
/* eslint-disable no-console */
|
|
4
3
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
+
/** biome-ignore-all lint/suspicious/noConsole: for debugging */
|
|
5
|
+
|
|
6
|
+
import { Logger } from "./Logger";
|
|
5
7
|
|
|
6
8
|
type SpanStatus = "ok" | "error";
|
|
7
9
|
|
|
@@ -88,19 +90,19 @@ export class Tracer {
|
|
|
88
90
|
s.startTime < span.endTime,
|
|
89
91
|
);
|
|
90
92
|
if (childSpans.length > 0) {
|
|
91
|
-
|
|
93
|
+
Logger.log("Child Spans:");
|
|
92
94
|
childSpans.forEach((childSpan) => {
|
|
93
|
-
|
|
95
|
+
Logger.log(` - ${childSpan.name}`);
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
|
-
|
|
98
|
+
Logger.log(`Start Time: ${new Date(span.startTime).toISOString()}`);
|
|
97
99
|
if (span.endTime) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
Logger.log(`End Time: ${new Date(span.endTime).toISOString()}`);
|
|
101
|
+
Logger.log(`Duration: ${span.endTime - span.startTime}ms`);
|
|
100
102
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
Logger.log(`Status: ${span.status}`);
|
|
104
|
+
Logger.log(`Attributes: ${JSON.stringify(span.attributes)}`);
|
|
105
|
+
Logger.log("---");
|
|
104
106
|
});
|
|
105
107
|
}
|
|
106
108
|
}
|