@marimo-team/frontend 0.25.3-dev3 → 0.25.3-dev31
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/assets/{CellStatus-BP2mavAq.js → CellStatus-wFCGHpDX.js} +1 -1
- package/dist/assets/{ConnectedDataExplorerComponent-t8fH_TNc.js → ConnectedDataExplorerComponent-DMdJT25t.js} +1 -1
- package/dist/assets/{ErrorBoundary-Gl5nCA8C.js → ErrorBoundary-D1ozl9e0.js} +2 -2
- package/dist/assets/JsonOutput-Dqg7qwkl.js +11 -0
- package/dist/assets/{LazyAnyLanguageCodeMirror-CKcCbG2G.js → LazyAnyLanguageCodeMirror-B4fCknq1.js} +2 -2
- package/dist/assets/MarimoErrorOutput-BYSTEwo1.js +10 -0
- package/dist/assets/{RenderHTML-BbOqmHy3.js → RenderHTML-B18UiW8r.js} +1 -1
- package/dist/assets/{RunButton-CK3LhnP5.js → RunButton-CWvRnb98.js} +1 -1
- package/dist/assets/{add-cell-with-ai-8UBC0xwR.js → add-cell-with-ai-C4pN_ho7.js} +13 -13
- package/dist/assets/{add-connection-dialog-DXQnd6eB.js → add-connection-dialog-BErVOfUV.js} +2 -2
- package/dist/assets/{agent-panel-D7kMZLG-.js → agent-panel-QQDTP8Vb.js} +5 -5
- package/dist/assets/ai-model-dropdown-D5Fe5GS-.js +13 -0
- package/dist/assets/{any-language-editor-BLCAD3yx.js → any-language-editor-BdTWdMCI.js} +1 -1
- package/dist/assets/{app-config-button-BKEG4x9u.js → app-config-button-DBHN-U2l.js} +1 -1
- package/dist/assets/{blob-D5nfNHOo.js → blob-DY_W1wFZ.js} +1 -1
- package/dist/assets/{cell-editor-ADVfycpN.js → cell-editor-CCFDuQIT.js} +9 -9
- package/dist/assets/{cell-link-LSth_8hT.js → cell-link-BOqoitvE.js} +1 -1
- package/dist/assets/{cells-BRkCaSsh.js → cells-CN1I_0eH.js} +31 -31
- package/dist/assets/{chat-display-Dnagy4Nv.js → chat-display-D1_UV6v7.js} +1 -1
- package/dist/assets/{chat-panel-DQ6HkWEF.js → chat-panel-C4OJDIt6.js} +2 -2
- package/dist/assets/{chat-ui-Df8Vcj6n.js → chat-ui-wuDYPZ-w.js} +1 -1
- package/dist/assets/code-visibility-CnU9xZw7.js +1 -0
- package/dist/assets/coerce-DWjFeXOY.js +1 -0
- package/dist/assets/{column-preview-Cm2D6vyX.js → column-preview-z4bqk4HW.js} +1 -1
- package/dist/assets/command-palette-TblDi15Q.js +1 -0
- package/dist/assets/{common-Cu6CDbuw.js → common-Cbk0KIh7.js} +1 -1
- package/dist/assets/{components-CGw16R_N.js → components-C88UxBXz.js} +1 -1
- package/dist/assets/{components-CP_UoFtT.js → components-CskjK6xZ.js} +1 -1
- package/dist/assets/{components-CXfO-F47.js → components-YBmtV0p6.js} +1 -1
- package/dist/assets/{config-VPSq73n8.js → config-CA1V-wjh.js} +1 -1
- package/dist/assets/config-DEzFV5-l.js +1 -0
- package/dist/assets/config-MaHeMC9o.js +104 -0
- package/dist/assets/{datasource-Cq6x_5ML.js → datasource-DZJ6qqVI.js} +1 -1
- package/dist/assets/{dates-BbFQ2oE4.js → dates-CfmdTL6B.js} +1 -1
- package/dist/assets/{dependency-graph-panel--Kgtktcw.js → dependency-graph-panel-DeZ66gIo.js} +1 -1
- package/dist/assets/{documentation-panel-BHmbeznw.js → documentation-panel-Tl5G1cPt.js} +1 -1
- package/dist/assets/{download-DCJXy66H.js → download-s8iwxGDb.js} +1 -1
- package/dist/assets/edit-page-CjoAJvyN.js +9 -0
- package/dist/assets/{error-banner-Cd69vvyX.js → error-banner-COZ7SfYV.js} +1 -1
- package/dist/assets/{error-entries-Dk3VZ-OK.js → error-entries-D11Bn1Hk.js} +1 -1
- package/dist/assets/{error-panel-BPRYmC5J.js → error-panel-kfxFDscu.js} +1 -1
- package/dist/assets/{errors-DCrsa1nH.js → errors-CNsgAw6m.js} +1 -1
- package/dist/assets/feedback-button-3bZHpuSh.js +1 -0
- package/dist/assets/{feedback-button-Bik2-e33.js → feedback-button-DVABjD9Y.js} +2 -2
- package/dist/assets/{file-explorer-panel-BEEK5lcl.js → file-explorer-panel-CvmK-rEU.js} +1 -1
- package/dist/assets/{file-name-input-Cdc-TVqO.js → file-name-input-DAj9a3RQ.js} +1 -1
- package/dist/assets/{floating-outline-XD9FAV-f.js → floating-outline-DDavqWJx.js} +1 -1
- package/dist/assets/{formats-yZ06h1Pl.js → formats-BkelUASr.js} +1 -1
- package/dist/assets/{gallery-page-Dm6mGwBi.js → gallery-page-xP6VqDyd.js} +1 -1
- package/dist/assets/{ganttDiagram-EL5Y4UJY-2n7Ig5Jm.js → ganttDiagram-EL5Y4UJY-CYqkCfFG.js} +1 -1
- package/dist/assets/{glide-data-editor-J9CAb70d.js → glide-data-editor-32vBJJf8.js} +1 -1
- package/dist/assets/{home-page-DMHnsRxm.js → home-page-CvGzjVr4.js} +1 -1
- package/dist/assets/hooks-C1_gQ8kr.js +1 -0
- package/dist/assets/index-6b4mf8Ai.css +2 -0
- package/dist/assets/index-Dtv0HH-7.js +30 -0
- package/dist/assets/{layout-DmcNEu3P.js → layout-BccvBeZy.js} +5 -5
- package/dist/assets/linear-Bma8J3iM.js +1 -0
- package/dist/assets/{logs-panel-ABM16htT.js → logs-panel-BhXo1sVJ.js} +1 -1
- package/dist/assets/{markdown-renderer-BG3sp2rs.js → markdown-renderer-D2dafr8r.js} +1 -1
- package/dist/assets/{mermaid-a3xYymTy.js → mermaid-D2FUGQeW.js} +2 -2
- package/dist/assets/{name-cell-input-BgEBmqyL.js → name-cell-input-SHvgfcBR.js} +1 -1
- package/dist/assets/{outline-panel-DCXQ3_F6.js → outline-panel-CpY3FH-u.js} +1 -1
- package/dist/assets/{packages-panel-BMGOmZkR.js → packages-panel-oZ0qZBec.js} +1 -1
- package/dist/assets/{panel-accordion-state-C1sdPp0m.js → panel-accordion-state-ChFIY2WQ.js} +1 -1
- package/dist/assets/panels-91ywfwgc.js +4 -0
- package/dist/assets/precisionRound-BxlUs8G4.js +1 -0
- package/dist/assets/{process-output-D0KGq04R.js → process-output-Dvq4b2kJ.js} +1 -1
- package/dist/assets/{quadrantDiagram-AXDQQJYC-yBhCDI7E.js → quadrantDiagram-AXDQQJYC-D9KH5Zge.js} +1 -1
- package/dist/assets/react-vega-BTNeboR2.js +189 -0
- package/dist/assets/{readonly-code-display-Do50PHI8.js → readonly-code-display-C1eH5BDP.js} +1 -1
- package/dist/assets/{readonly-python-code-DCSMIsTX.js → readonly-python-code-BaElyj-4.js} +1 -1
- package/dist/assets/{renderShortcut-BkVJQ_Zh.js → renderShortcut-C1JwYcqW.js} +1 -1
- package/dist/assets/{reveal-component-ltaepAqw.js → reveal-component-FCuqfC5H.js} +3 -3
- package/dist/assets/{run-page-DF3c5cDk.js → run-page-CbyMlRt1.js} +1 -1
- package/dist/assets/{runtime-details-state-CSPobEdR.js → runtime-details-state-Bpn67vTN.js} +1 -1
- package/dist/assets/{schemas-Dv42wLFq.js → schemas-ChRqMOTL.js} +1 -1
- package/dist/assets/{scratchpad-panel-Dwd6W5PE.js → scratchpad-panel-OF9_e0l_.js} +1 -1
- package/dist/assets/{secrets-panel-Bctbtkrp.js → secrets-panel-D7KN4tVs.js} +1 -1
- package/dist/assets/session-panel-CExxjkjV.js +1 -0
- package/dist/assets/{snippets-panel-Bh1oTw4m.js → snippets-panel-DfRtTFJ-.js} +1 -1
- package/dist/assets/state-BUqF6L9e.js +3 -0
- package/dist/assets/{state-XsPO8hNi.js → state-CHojzKpZ.js} +1 -1
- package/dist/assets/{terminal-Ck_vK-34.js → terminal--4gDbK7q.js} +3 -3
- package/dist/assets/{time-MgToa8VM.js → time-DswSXBDk.js} +1 -1
- package/dist/assets/tooltip-BsSdc1NQ.js +61 -0
- package/dist/assets/{tracing-Di6pUmX8.js → tracing-BnfAB-BH.js} +1 -1
- package/dist/assets/{tracing-panel-PeRXHD8_.js → tracing-panel-DNabsbtA.js} +2 -2
- package/dist/assets/{tree-actions-GM5E_bUs.js → tree-actions-BXvnBv45.js} +1 -1
- package/dist/assets/{useAddCell-GR7eEQrT.js → useAddCell-6ECZ0xPG.js} +1 -1
- package/dist/assets/{useBoolean-BDD6_xQQ.js → useBoolean-BvAx9Qrr.js} +1 -1
- package/dist/assets/{useCellActionButton-B-9eG5z_.js → useCellActionButton-Djyiwayj.js} +1 -1
- package/dist/assets/{useDeleteCell-2_bMClHd.js → useDeleteCell-KX6SEwki.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-k3C3M18S.js → useDependencyPanelTab-B8ke9iTY.js} +1 -1
- package/dist/assets/{useInstallPackage-iX1eufdl.js → useInstallPackage-C9-icL78.js} +1 -1
- package/dist/assets/useNotebookActions-CluLEhAd.js +1 -0
- package/dist/assets/{useRunCells-B2vUhREg.js → useRunCells-B847kPLO.js} +1 -1
- package/dist/assets/{useSplitCell-DEb03htp.js → useSplitCell-CnvTmIw7.js} +1 -1
- package/dist/assets/{useTheme-COhSHkCj.js → useTheme-n8Dj1zH7.js} +1 -1
- package/dist/assets/{vega-component-CnadTgoE.js → vega-component-DAkdRNSF.js} +1 -1
- package/dist/assets/{vega-embed-container-DJPNkHPb.js → vega-embed-container-CxuIHhsS.js} +1 -1
- package/dist/assets/vega-loader.browser-Bu25TKax.js +6 -0
- package/dist/assets/{xychartDiagram-S5SC5T6Z-KbGzG6-u.js → xychartDiagram-S5SC5T6Z-CeRnBS5e.js} +1 -1
- package/dist/index.html +44 -45
- package/package.json +4 -2
- package/src/__tests__/fixtures/{pair-preview.ts → pair-config.ts} +3 -2
- package/src/__tests__/mount.test.ts +28 -8
- package/src/components/data-table/__tests__/context-menu.test.ts +176 -0
- package/src/components/data-table/__tests__/date-filter-inputs.test.tsx +24 -1
- package/src/components/data-table/__tests__/export-actions.test.tsx +329 -6
- package/src/components/data-table/context-menu.tsx +125 -26
- package/src/components/data-table/date-filter-inputs.tsx +15 -42
- package/src/components/data-table/export-actions.tsx +192 -116
- package/src/components/data-table/schemas.ts +14 -36
- package/src/components/data-table/utils.ts +18 -0
- package/src/components/editor/Output.tsx +9 -2
- package/src/components/editor/__tests__/dynamic-favicon.test.tsx +111 -18
- package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +80 -252
- package/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx +186 -34
- package/src/components/editor/actions/pair-with-agent-commands.ts +42 -51
- package/src/components/editor/actions/pair-with-agent-modal.tsx +96 -36
- package/src/components/editor/chrome/panels/error-panel.tsx +1 -0
- package/src/components/editor/chrome/wrapper/__tests__/attachment-status.test.tsx +366 -0
- package/src/components/editor/chrome/wrapper/footer-item.tsx +32 -24
- package/src/components/editor/chrome/wrapper/footer-items/attachment-status.tsx +237 -0
- package/src/components/editor/chrome/wrapper/footer.tsx +2 -0
- package/src/components/editor/controls/__tests__/command-palette.test.tsx +53 -0
- package/src/components/editor/controls/command-palette.tsx +22 -10
- package/src/components/editor/dynamic-favicon.tsx +21 -40
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +537 -0
- package/src/components/editor/errors/send-error-report-button.tsx +69 -0
- package/src/components/editor/output/MarimoErrorOutput.tsx +21 -5
- package/src/components/editor/output/MarimoTracebackOutput.tsx +35 -20
- package/src/components/editor/output/__tests__/ansi-reduce.test.ts +18 -0
- package/src/components/editor/output/ansi-reduce.ts +6 -0
- package/src/core/attachments/__tests__/toast.test.tsx +58 -0
- package/src/core/attachments/state.ts +18 -0
- package/src/core/attachments/toast.ts +15 -0
- package/src/core/cells/__tests__/cells.test.ts +52 -0
- package/src/core/cells/__tests__/error-report.test.ts +139 -0
- package/src/core/cells/__tests__/notebook-outline.test.ts +113 -0
- package/src/core/cells/__tests__/session.test.ts +50 -1
- package/src/core/cells/cells.ts +2 -1
- package/src/core/cells/error-report.ts +63 -0
- package/src/core/cells/session.ts +28 -1
- package/src/core/config/pair.ts +5 -3
- package/src/core/edit-app.tsx +2 -2
- package/src/core/host/AGENTS.md +5 -0
- package/src/core/host/__tests__/attachments.test.ts +57 -0
- package/src/core/host/__tests__/document.test.ts +124 -0
- package/src/core/host/__tests__/events.test.ts +46 -0
- package/src/core/host/__tests__/fixtures.ts +39 -0
- package/src/core/host/__tests__/notebook-client.test.ts +433 -0
- package/src/core/host/__tests__/protocol.test.ts +15 -0
- package/src/core/host/__tests__/stream.test.ts +209 -0
- package/src/core/host/connection.ts +81 -0
- package/src/core/host/events.ts +61 -0
- package/src/core/host/notebook-client.ts +290 -0
- package/src/core/host/protocol.ts +11 -6
- package/src/core/host/resources/attachments.ts +19 -0
- package/src/core/host/resources/document.ts +101 -0
- package/src/core/host/resources/resource.ts +47 -0
- package/src/core/host/stream.ts +211 -0
- package/src/core/network/connection.ts +4 -2
- package/src/core/run-app.tsx +2 -2
- package/src/core/runtime/__tests__/runtime.test.ts +55 -11
- package/src/core/runtime/runtime.ts +15 -1
- package/src/core/runtime/types.ts +2 -0
- package/src/core/websocket/__tests__/{useMarimoKernelConnection.test.ts → connection-state.test.ts} +15 -17
- package/src/core/websocket/__tests__/{useWebSocket.test.ts → createConnectionTransport.test.ts} +1 -1
- package/src/core/websocket/__tests__/useNotebookClient.hook.test.tsx +170 -0
- package/src/core/websocket/__tests__/{useMarimoKernelConnection.hook.test.tsx → useNotebookSession.hook.test.tsx} +181 -65
- package/src/core/websocket/connection-state.ts +70 -0
- package/src/core/websocket/state.ts +7 -0
- package/src/core/websocket/transports/__tests__/sse.test.ts +1 -4
- package/src/core/websocket/transports/create.ts +31 -0
- package/src/core/websocket/transports/transport.ts +12 -23
- package/src/core/websocket/types.ts +9 -39
- package/src/core/websocket/useNotebookClient.ts +88 -0
- package/src/core/websocket/{useMarimoKernelConnection.tsx → useNotebookSession.tsx} +59 -225
- package/src/mount.tsx +7 -3
- package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +84 -0
- package/src/utils/__tests__/dates.test.ts +116 -0
- package/src/utils/dates.ts +94 -0
- package/src/utils/once.ts +19 -19
- package/dist/assets/JsonOutput-D6HIIsCb.js +0 -11
- package/dist/assets/MarimoErrorOutput-D60XkCny.js +0 -6
- package/dist/assets/ai-model-dropdown-B0z6-zhp.js +0 -5
- package/dist/assets/api-BeC_VSGv.js +0 -1
- package/dist/assets/code-visibility-B-_GvwR5.js +0 -1
- package/dist/assets/coerce-CpE6kUdX.js +0 -1
- package/dist/assets/command-palette-DTSQ7gOC.js +0 -1
- package/dist/assets/config-BOKzA3tF.js +0 -1
- package/dist/assets/config-DX8Y2WbJ.js +0 -1
- package/dist/assets/edit-page-ChcSgpke.js +0 -9
- package/dist/assets/feedback-button-B2gKC5cn.js +0 -1
- package/dist/assets/hooks-93IwHd2u.js +0 -1
- package/dist/assets/index-Bcdzex-3.css +0 -2
- package/dist/assets/index-s-M1OXjs.js +0 -29
- package/dist/assets/linear-0eij_aAG.js +0 -1
- package/dist/assets/pair-CaQyK6En.js +0 -1
- package/dist/assets/panels-CxVG8-v2.js +0 -4
- package/dist/assets/precisionRound-Bq_nmf5u.js +0 -1
- package/dist/assets/react-vega-C3rYGtP6.js +0 -189
- package/dist/assets/session-panel-VdDhEBa-.js +0 -1
- package/dist/assets/state-_Qai_QyX.js +0 -3
- package/dist/assets/tooltip-mT3CGest.js +0 -61
- package/dist/assets/useNotebookActions-NHN6A-cN.js +0 -1
- package/dist/assets/vega-loader.browser-CLRkNgm7.js +0 -6
- package/src/core/websocket/useWebSocket.tsx +0 -88
package/src/utils/dates.ts
CHANGED
|
@@ -165,6 +165,44 @@ export function dateToLocalISOTime(d: Date): string {
|
|
|
165
165
|
return `${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Parse a time string into a Date anchored at the Unix epoch day. Supports
|
|
170
|
+
* the backend's wire format (`HH:MM:SS`, as produced by `dateToLocalISOTime`)
|
|
171
|
+
* as well as looser pasted text: optional seconds, optional milliseconds,
|
|
172
|
+
* and an optional `am`/`pm` suffix (e.g. `"14:30"`, `"2:30 PM"`,
|
|
173
|
+
* `"14:30:00.123"`).
|
|
174
|
+
*/
|
|
175
|
+
export function parseTimeToDate(value: string): Date | undefined {
|
|
176
|
+
const match = /^(\d{1,2}):(\d{2})(?::(\d{2}))?(?:\.(\d+))?\s*(am|pm)?$/i.exec(
|
|
177
|
+
value.trim(),
|
|
178
|
+
);
|
|
179
|
+
if (!match) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
const [, hStr, mStr, sStr, msStr, ampm] = match;
|
|
183
|
+
let hour = Number.parseInt(hStr, 10);
|
|
184
|
+
const minute = Number.parseInt(mStr, 10);
|
|
185
|
+
const second = sStr ? Number.parseInt(sStr, 10) : 0;
|
|
186
|
+
const ms = msStr ? Number.parseInt(msStr.padEnd(3, "0").slice(0, 3), 10) : 0;
|
|
187
|
+
if (minute > 59 || second > 59) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
if (ampm) {
|
|
191
|
+
if (hour < 1 || hour > 12) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
const isPm = ampm.toLowerCase() === "pm";
|
|
195
|
+
if (hour === 12) {
|
|
196
|
+
hour = isPm ? 12 : 0;
|
|
197
|
+
} else if (isPm) {
|
|
198
|
+
hour += 12;
|
|
199
|
+
}
|
|
200
|
+
} else if (hour > 23) {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
return new Date(1970, 0, 1, hour, minute, second, ms);
|
|
204
|
+
}
|
|
205
|
+
|
|
168
206
|
/**
|
|
169
207
|
* Format a Date as `YYYY-MM-DDTHH:MM:SS` (no timezone suffix) using local
|
|
170
208
|
* fields. See `dateToLocalISODate` for the rationale on local vs UTC.
|
|
@@ -173,6 +211,62 @@ export function dateToLocalISODateTime(d: Date): string {
|
|
|
173
211
|
return `${dateToLocalISODate(d)}T${dateToLocalISOTime(d)}`;
|
|
174
212
|
}
|
|
175
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Parse a `YYYY-MM-DD` string into a Date anchored at local midnight.
|
|
216
|
+
*
|
|
217
|
+
* Unlike `new Date("YYYY-MM-DD")`, which the spec parses as UTC midnight,
|
|
218
|
+
* this treats the string as a calendar date in the viewer's own timezone.
|
|
219
|
+
* Returns undefined if the string doesn't match, or encodes a calendar
|
|
220
|
+
* date that doesn't exist (e.g. month 13, Feb 30), since `Date` would
|
|
221
|
+
* otherwise silently roll those over into a different date.
|
|
222
|
+
*/
|
|
223
|
+
export function parseLocalISODate(value: string): Date | undefined {
|
|
224
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
|
225
|
+
if (!match) {
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
const [, yStr, mStr, dStr] = match;
|
|
229
|
+
const year = Number.parseInt(yStr, 10);
|
|
230
|
+
const month = Number.parseInt(mStr, 10);
|
|
231
|
+
const day = Number.parseInt(dStr, 10);
|
|
232
|
+
const date = new Date(year, month - 1, day);
|
|
233
|
+
if (
|
|
234
|
+
date.getFullYear() !== year ||
|
|
235
|
+
date.getMonth() !== month - 1 ||
|
|
236
|
+
date.getDate() !== day
|
|
237
|
+
) {
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
return date;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Parse an ISO-ish `YYYY-MM-DD[T ]HH:MM[:SS[.sss]][Z|+HH:MM]` datetime string
|
|
245
|
+
* as wall-clock local time, ignoring any trailing `Z` or UTC offset.
|
|
246
|
+
*
|
|
247
|
+
* This keeps pasted datetimes consistent with the date/time pickers' local-
|
|
248
|
+
* time basis: pasting `2024-01-15T08:30:00Z` displays `08:30` instead of
|
|
249
|
+
* being shifted by the viewer's timezone.
|
|
250
|
+
*/
|
|
251
|
+
export function parseLocalISODateTime(value: string): Date | undefined {
|
|
252
|
+
const match =
|
|
253
|
+
/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/.exec(
|
|
254
|
+
value.trim(),
|
|
255
|
+
);
|
|
256
|
+
if (!match) {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
const [, yStr, moStr, dStr, hStr, miStr, sStr] = match;
|
|
260
|
+
return new Date(
|
|
261
|
+
Number.parseInt(yStr, 10),
|
|
262
|
+
Number.parseInt(moStr, 10) - 1,
|
|
263
|
+
Number.parseInt(dStr, 10),
|
|
264
|
+
Number.parseInt(hStr, 10),
|
|
265
|
+
Number.parseInt(miStr, 10),
|
|
266
|
+
sStr ? Number.parseInt(sStr, 10) : 0,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
176
270
|
export const supportedDateFormats = ["yyyy", "yyyy-MM", "yyyy-MM-dd"] as const;
|
|
177
271
|
export type DateFormat = (typeof supportedDateFormats)[number];
|
|
178
272
|
|
package/src/utils/once.ts
CHANGED
|
@@ -2,36 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayShallowEquals } from "./arrays";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
export function once<
|
|
7
|
-
|
|
5
|
+
export function once<F extends (...args: never[]) => unknown>(fn: F): F;
|
|
6
|
+
export function once<Args extends unknown[], Result, This>(
|
|
7
|
+
fn: (this: This, ...args: Args) => Result,
|
|
8
|
+
): (this: This, ...args: Args) => Result {
|
|
9
|
+
let result: Result;
|
|
8
10
|
let called = false;
|
|
9
|
-
return function (
|
|
10
|
-
this: ThisParameterType<T>,
|
|
11
|
-
...args: Parameters<T>
|
|
12
|
-
): ReturnType<T> {
|
|
11
|
+
return function (this: This, ...args: Args): Result {
|
|
13
12
|
if (!called) {
|
|
14
13
|
called = true;
|
|
15
|
-
result = fn.apply(this, args)
|
|
14
|
+
result = fn.apply(this, args);
|
|
16
15
|
}
|
|
17
16
|
return result;
|
|
18
|
-
}
|
|
17
|
+
};
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
export function memoizeLastValue<F extends (...args: never[]) => unknown>(
|
|
21
|
+
fn: F,
|
|
22
|
+
): F;
|
|
23
|
+
export function memoizeLastValue<Args extends unknown[], Result, This>(
|
|
24
|
+
fn: (this: This, ...args: Args) => Result,
|
|
25
|
+
): (this: This, ...args: Args) => Result {
|
|
26
|
+
let result: Result;
|
|
27
|
+
let lastArgs: Args | undefined;
|
|
25
28
|
let lastError: unknown;
|
|
26
29
|
let hasError = false;
|
|
27
30
|
|
|
28
|
-
return function (
|
|
29
|
-
this: ThisParameterType<T>,
|
|
30
|
-
...args: Parameters<T>
|
|
31
|
-
): ReturnType<T> {
|
|
31
|
+
return function (this: This, ...args: Args): Result {
|
|
32
32
|
if (lastArgs === undefined || !arrayShallowEquals(args, lastArgs)) {
|
|
33
33
|
try {
|
|
34
|
-
result = fn.apply(this, args)
|
|
34
|
+
result = fn.apply(this, args);
|
|
35
35
|
hasError = false;
|
|
36
36
|
lastError = undefined;
|
|
37
37
|
} catch (error) {
|
|
@@ -45,5 +45,5 @@ export function memoizeLastValue<T extends (...args: any[]) => any>(fn: T): T {
|
|
|
45
45
|
throw lastError;
|
|
46
46
|
}
|
|
47
47
|
return result;
|
|
48
|
-
}
|
|
48
|
+
};
|
|
49
49
|
}
|