@marimo-team/islands 0.19.10-dev11 → 0.19.10-dev13
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/main.js
CHANGED
|
@@ -73304,7 +73304,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
73304
73304
|
return Logger.warn("Failed to get version from mount config"), null;
|
|
73305
73305
|
}
|
|
73306
73306
|
}
|
|
73307
|
-
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.10-
|
|
73307
|
+
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.10-dev13"), showCodeInRunModeAtom = atom(true);
|
|
73308
73308
|
atom(null);
|
|
73309
73309
|
var import_compiler_runtime$88 = require_compiler_runtime();
|
|
73310
73310
|
function useKeydownOnElement(e, r) {
|
package/package.json
CHANGED
|
@@ -140,6 +140,24 @@ def _(
|
|
|
140
140
|
expect(extractCells(input)).toEqual(["x = a + b + c"]);
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
+
it("preserves return statements inside nested functions", () => {
|
|
144
|
+
const input = `
|
|
145
|
+
@app.cell
|
|
146
|
+
def _(mo, px):
|
|
147
|
+
def make_fig():
|
|
148
|
+
data = {'category': ['foo', 'bar'], 'value': [10, 20]}
|
|
149
|
+
fig = px.bar(data, x='category', y='value')
|
|
150
|
+
return fig
|
|
151
|
+
|
|
152
|
+
fig = make_fig()
|
|
153
|
+
mo.ui.plotly(fig)
|
|
154
|
+
return
|
|
155
|
+
`;
|
|
156
|
+
expect(extractCells(input)).toEqual([
|
|
157
|
+
"def make_fig():\n data = {'category': ['foo', 'bar'], 'value': [10, 20]}\n fig = px.bar(data, x='category', y='value')\n return fig\n\nfig = make_fig()\nmo.ui.plotly(fig)",
|
|
158
|
+
]);
|
|
159
|
+
});
|
|
160
|
+
|
|
143
161
|
it("handles cells with config", () => {
|
|
144
162
|
const input = `
|
|
145
163
|
@app.cell(hide_code=True, column=2)
|
|
@@ -42,6 +42,7 @@ export function extractCells(text: string): string[] {
|
|
|
42
42
|
let inMultilineArgs = false;
|
|
43
43
|
let inMultilineReturn = false;
|
|
44
44
|
let parenCount = 0;
|
|
45
|
+
let cellBaseIndent: number | null = null;
|
|
45
46
|
|
|
46
47
|
// Pre-compile regex patterns
|
|
47
48
|
const leadingParenRegex = /\(/g;
|
|
@@ -55,19 +56,16 @@ export function extractCells(text: string): string[] {
|
|
|
55
56
|
);
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
function getIndent(line: string): number {
|
|
60
|
+
const match = line.match(/^\s*/);
|
|
61
|
+
return match ? match[0].length : 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
function finalizeCellIfNeeded() {
|
|
59
65
|
if (currentCell.length === 0) {
|
|
60
66
|
return;
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
// Remove trailing returns
|
|
64
|
-
while (
|
|
65
|
-
currentCell.length > 0 &&
|
|
66
|
-
currentCell[currentCell.length - 1].trim().startsWith("return")
|
|
67
|
-
) {
|
|
68
|
-
currentCell.pop();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
69
|
// Only add non-empty cells
|
|
72
70
|
if (currentCell.some((l) => l.trim() !== "")) {
|
|
73
71
|
cells.push(dedent(currentCell.join("\n")));
|
|
@@ -88,6 +86,7 @@ export function extractCells(text: string): string[] {
|
|
|
88
86
|
finalizeCellIfNeeded();
|
|
89
87
|
inCell = true;
|
|
90
88
|
skipLines = 1; // Skip the def line
|
|
89
|
+
cellBaseIndent = null;
|
|
91
90
|
continue;
|
|
92
91
|
}
|
|
93
92
|
|
|
@@ -125,8 +124,13 @@ export function extractCells(text: string): string[] {
|
|
|
125
124
|
continue;
|
|
126
125
|
}
|
|
127
126
|
|
|
128
|
-
//
|
|
129
|
-
if (trimmed
|
|
127
|
+
// Detect base indentation of cell body from first content line
|
|
128
|
+
if (cellBaseIndent === null && trimmed) {
|
|
129
|
+
cellBaseIndent = getIndent(line);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Handle return statements — only strip cell-level returns
|
|
133
|
+
if (trimmed.startsWith("return") && getIndent(line) === cellBaseIndent) {
|
|
130
134
|
if (trimmed.includes("(") && !trimmed.endsWith(")")) {
|
|
131
135
|
inMultilineReturn = true;
|
|
132
136
|
parenCount = countParens(trimmed);
|