@cardstack/boxel-cli 0.2.0-unstable.448 → 0.3.0-unstable.13
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/bundled-types/base/-private.d.ts +1 -0
- package/bundled-types/base/address.d.ts +17 -0
- package/bundled-types/base/ai-app-generator.d.ts +14 -0
- package/bundled-types/base/amount-with-currency.d.ts +10 -0
- package/bundled-types/base/avif-image-def.d.ts +12 -0
- package/bundled-types/base/avif-meta-extractor.d.ts +4 -0
- package/bundled-types/base/base64-image.d.ts +25 -0
- package/bundled-types/base/big-integer.d.ts +12 -0
- package/bundled-types/base/boolean.d.ts +14 -0
- package/bundled-types/base/brand-functional-palette.d.ts +16 -0
- package/bundled-types/base/brand-guide.d.ts +26 -0
- package/bundled-types/base/brand-logo.d.ts +29 -0
- package/bundled-types/base/card-api.d.ts +513 -0
- package/bundled-types/base/card-serialization.d.ts +47 -0
- package/bundled-types/base/cards-grid.d.ts +10 -0
- package/bundled-types/base/code-ref.d.ts +14 -0
- package/bundled-types/base/codemirror-editor.d.ts +135 -0
- package/bundled-types/base/color-field/components/advanced-color-picker.d.ts +66 -0
- package/bundled-types/base/color-field/components/color-picker-field.d.ts +22 -0
- package/bundled-types/base/color-field/components/color-wheel-picker.d.ts +44 -0
- package/bundled-types/base/color-field/components/contrast-checker-addon.d.ts +14 -0
- package/bundled-types/base/color-field/components/recent-colors-addon.d.ts +19 -0
- package/bundled-types/base/color-field/components/slider-picker.d.ts +40 -0
- package/bundled-types/base/color-field/components/swatches-picker.d.ts +5 -0
- package/bundled-types/base/color-field/modifiers/setup-element-modifier.d.ts +10 -0
- package/bundled-types/base/color-field/util/color-field-signature.d.ts +9 -0
- package/bundled-types/base/color-field/util/color-utils.d.ts +96 -0
- package/bundled-types/base/color-field/util/css-color-parsers.d.ts +11 -0
- package/bundled-types/base/color.d.ts +10 -0
- package/bundled-types/base/command.d.ts +593 -0
- package/bundled-types/base/commands/search-card-result.d.ts +36 -0
- package/bundled-types/base/components/age.d.ts +22 -0
- package/bundled-types/base/components/business-days.d.ts +16 -0
- package/bundled-types/base/components/card-list.d.ts +25 -0
- package/bundled-types/base/components/cards-grid-layout.d.ts +58 -0
- package/bundled-types/base/components/countdown.d.ts +31 -0
- package/bundled-types/base/components/expiration-warning.d.ts +24 -0
- package/bundled-types/base/components/time-ago.d.ts +24 -0
- package/bundled-types/base/components/time-slots.d.ts +20 -0
- package/bundled-types/base/components/timeline.d.ts +22 -0
- package/bundled-types/base/contains-many-component.d.ts +7 -0
- package/bundled-types/base/coordinate.d.ts +7 -0
- package/bundled-types/base/country.d.ts +23 -0
- package/bundled-types/base/css-value.d.ts +6 -0
- package/bundled-types/base/csv-file-def.d.ts +29 -0
- package/bundled-types/base/currency.d.ts +16 -0
- package/bundled-types/base/date/day.d.ts +9 -0
- package/bundled-types/base/date/month-day.d.ts +10 -0
- package/bundled-types/base/date/month-year.d.ts +9 -0
- package/bundled-types/base/date/month.d.ts +9 -0
- package/bundled-types/base/date/quarter.d.ts +10 -0
- package/bundled-types/base/date/week.d.ts +9 -0
- package/bundled-types/base/date/year.d.ts +9 -0
- package/bundled-types/base/date-range-field.d.ts +12 -0
- package/bundled-types/base/date.d.ts +12 -0
- package/bundled-types/base/datetime-stamp.d.ts +7 -0
- package/bundled-types/base/datetime.d.ts +12 -0
- package/bundled-types/base/default-templates/atom.d.ts +10 -0
- package/bundled-types/base/default-templates/card-info.d.ts +32 -0
- package/bundled-types/base/default-templates/embedded.d.ts +11 -0
- package/bundled-types/base/default-templates/field-edit.d.ts +10 -0
- package/bundled-types/base/default-templates/file-def-edit.d.ts +8 -0
- package/bundled-types/base/default-templates/fitted.d.ts +12 -0
- package/bundled-types/base/default-templates/head.d.ts +13 -0
- package/bundled-types/base/default-templates/image-def-atom.d.ts +8 -0
- package/bundled-types/base/default-templates/image-def-embedded.d.ts +8 -0
- package/bundled-types/base/default-templates/image-def-fitted.d.ts +8 -0
- package/bundled-types/base/default-templates/image-def-isolated.d.ts +8 -0
- package/bundled-types/base/default-templates/isolated-and-edit.d.ts +15 -0
- package/bundled-types/base/default-templates/markdown-fallback.d.ts +19 -0
- package/bundled-types/base/default-templates/markdown.d.ts +60 -0
- package/bundled-types/base/default-templates/missing-template.d.ts +13 -0
- package/bundled-types/base/default-templates/theme-dashboard.d.ts +126 -0
- package/bundled-types/base/detailed-style-reference.d.ts +48 -0
- package/bundled-types/base/email.d.ts +10 -0
- package/bundled-types/base/enum.d.ts +30 -0
- package/bundled-types/base/ethereum-address.d.ts +13 -0
- package/bundled-types/base/field-component.d.ts +65 -0
- package/bundled-types/base/field-support.d.ts +55 -0
- package/bundled-types/base/file-api.d.ts +2 -0
- package/bundled-types/base/file-menu-items.d.ts +4 -0
- package/bundled-types/base/gif-image-def.d.ts +12 -0
- package/bundled-types/base/gif-meta-extractor.d.ts +4 -0
- package/bundled-types/base/gts-file-def.d.ts +7 -0
- package/bundled-types/base/helpers/country.d.ts +3198 -0
- package/bundled-types/base/helpers/sanitized-html.d.ts +2 -0
- package/bundled-types/base/helpers/set-background-image.d.ts +2 -0
- package/bundled-types/base/image-file-def.d.ts +1 -0
- package/bundled-types/base/image.d.ts +8 -0
- package/bundled-types/base/index.d.ts +1 -0
- package/bundled-types/base/join-the-community.d.ts +14 -0
- package/bundled-types/base/jpg-image-def.d.ts +12 -0
- package/bundled-types/base/jpg-meta-extractor.d.ts +4 -0
- package/bundled-types/base/json-file-def.d.ts +23 -0
- package/bundled-types/base/links-to-editor.d.ts +22 -0
- package/bundled-types/base/links-to-many-component.d.ts +7 -0
- package/bundled-types/base/llm-model.d.ts +6 -0
- package/bundled-types/base/markdown-file-def.d.ts +25 -0
- package/bundled-types/base/markdown-helpers.d.ts +26 -0
- package/bundled-types/base/markdown.d.ts +1 -0
- package/bundled-types/base/matrix-event.d.ts +400 -0
- package/bundled-types/base/menu-items.d.ts +21 -0
- package/bundled-types/base/number/components/badge-counter.d.ts +32 -0
- package/bundled-types/base/number/components/badge-metric.d.ts +34 -0
- package/bundled-types/base/number/components/badge-notification.d.ts +38 -0
- package/bundled-types/base/number/components/gauge.d.ts +45 -0
- package/bundled-types/base/number/components/number-input.d.ts +27 -0
- package/bundled-types/base/number/components/progress-bar.d.ts +44 -0
- package/bundled-types/base/number/components/progress-circle.d.ts +41 -0
- package/bundled-types/base/number/components/score.d.ts +41 -0
- package/bundled-types/base/number/components/stat.d.ts +38 -0
- package/bundled-types/base/number/util/index.d.ts +29 -0
- package/bundled-types/base/number.d.ts +52 -0
- package/bundled-types/base/percentage.d.ts +9 -0
- package/bundled-types/base/phone-number.d.ts +25 -0
- package/bundled-types/base/png-image-def.d.ts +12 -0
- package/bundled-types/base/png-meta-extractor.d.ts +4 -0
- package/bundled-types/base/positioned-card.d.ts +7 -0
- package/bundled-types/base/query-field-support.d.ts +6 -0
- package/bundled-types/base/realm-config.d.ts +16 -0
- package/bundled-types/base/realm.d.ts +7 -0
- package/bundled-types/base/resources/command-data.d.ts +43 -0
- package/bundled-types/base/response-field.d.ts +6 -0
- package/bundled-types/base/rich-markdown.d.ts +30 -0
- package/bundled-types/base/shared-state.d.ts +1 -0
- package/bundled-types/base/skill-plus.d.ts +79 -0
- package/bundled-types/base/skill-reference.d.ts +12 -0
- package/bundled-types/base/skill-set.d.ts +18 -0
- package/bundled-types/base/skill.d.ts +21 -0
- package/bundled-types/base/spec.d.ts +108 -0
- package/bundled-types/base/string.d.ts +2 -0
- package/bundled-types/base/structured-theme-variables.d.ts +85 -0
- package/bundled-types/base/structured-theme.d.ts +32 -0
- package/bundled-types/base/style-reference.d.ts +14 -0
- package/bundled-types/base/svg-image-def.d.ts +12 -0
- package/bundled-types/base/svg-meta-extractor.d.ts +12 -0
- package/bundled-types/base/system-card.d.ts +17 -0
- package/bundled-types/base/tag.d.ts +15 -0
- package/bundled-types/base/text-area.d.ts +2 -0
- package/bundled-types/base/text-file-def.d.ts +23 -0
- package/bundled-types/base/text-input-validator.d.ts +13 -0
- package/bundled-types/base/theme.d.ts +2 -0
- package/bundled-types/base/time/duration.d.ts +14 -0
- package/bundled-types/base/time/relative-time.d.ts +10 -0
- package/bundled-types/base/time/time-range.d.ts +11 -0
- package/bundled-types/base/time.d.ts +9 -0
- package/bundled-types/base/ts-file-def.d.ts +26 -0
- package/bundled-types/base/ts-highlight.d.ts +1 -0
- package/bundled-types/base/types/@cardstack/boxel-host/index.d.ts +5 -0
- package/bundled-types/base/types/ember-css-url/index.d.ts +15 -0
- package/bundled-types/base/typography.d.ts +14 -0
- package/bundled-types/base/url.d.ts +13 -0
- package/bundled-types/base/watched-array.d.ts +7 -0
- package/bundled-types/base/webp-image-def.d.ts +12 -0
- package/bundled-types/base/webp-meta-extractor.d.ts +4 -0
- package/bundled-types/base/website.d.ts +8 -0
- package/bundled-types/base/welcome-to-boxel.d.ts +22 -0
- package/bundled-types/boxel-ui/components/accordion/index.gts +50 -0
- package/bundled-types/boxel-ui/components/accordion/item/index.gts +156 -0
- package/bundled-types/boxel-ui/components/accordion/usage.gts +157 -0
- package/bundled-types/boxel-ui/components/add-button/index.gts +46 -0
- package/bundled-types/boxel-ui/components/add-button/usage.gts +54 -0
- package/bundled-types/boxel-ui/components/alert/index.gts +151 -0
- package/bundled-types/boxel-ui/components/alert/usage.gts +66 -0
- package/bundled-types/boxel-ui/components/avatar/index.gts +79 -0
- package/bundled-types/boxel-ui/components/avatar/usage.gts +96 -0
- package/bundled-types/boxel-ui/components/basic-fitted/index.gts +340 -0
- package/bundled-types/boxel-ui/components/basic-fitted/usage.gts +223 -0
- package/bundled-types/boxel-ui/components/button/index.gts +416 -0
- package/bundled-types/boxel-ui/components/button/usage.gts +334 -0
- package/bundled-types/boxel-ui/components/card-container/index.gts +251 -0
- package/bundled-types/boxel-ui/components/card-container/usage.gts +53 -0
- package/bundled-types/boxel-ui/components/card-header/index.gts +473 -0
- package/bundled-types/boxel-ui/components/card-header/usage.gts +295 -0
- package/bundled-types/boxel-ui/components/circle-spinner/index.gts +42 -0
- package/bundled-types/boxel-ui/components/circle-spinner/usage.gts +48 -0
- package/bundled-types/boxel-ui/components/color-palette/index.gts +134 -0
- package/bundled-types/boxel-ui/components/color-palette/usage.gts +69 -0
- package/bundled-types/boxel-ui/components/color-picker/index.gts +125 -0
- package/bundled-types/boxel-ui/components/color-picker/usage.gts +56 -0
- package/bundled-types/boxel-ui/components/container/index.gts +67 -0
- package/bundled-types/boxel-ui/components/container/usage.gts +59 -0
- package/bundled-types/boxel-ui/components/context-button/index.gts +184 -0
- package/bundled-types/boxel-ui/components/context-button/usage.gts +125 -0
- package/bundled-types/boxel-ui/components/copy-button/index.gts +79 -0
- package/bundled-types/boxel-ui/components/copy-button/usage.gts +25 -0
- package/bundled-types/boxel-ui/components/date-range-picker/index.gts +211 -0
- package/bundled-types/boxel-ui/components/date-range-picker/setup.gts +11 -0
- package/bundled-types/boxel-ui/components/date-range-picker/usage.gts +52 -0
- package/bundled-types/boxel-ui/components/drag-and-drop/index.gts +256 -0
- package/bundled-types/boxel-ui/components/drag-and-drop/usage.gts +142 -0
- package/bundled-types/boxel-ui/components/dropdown/index.gts +478 -0
- package/bundled-types/boxel-ui/components/dropdown/trigger/index.gts +70 -0
- package/bundled-types/boxel-ui/components/dropdown/trigger/usage.gts +54 -0
- package/bundled-types/boxel-ui/components/dropdown/usage.gts +119 -0
- package/bundled-types/boxel-ui/components/email-input/index.gts +111 -0
- package/bundled-types/boxel-ui/components/email-input/usage.gts +75 -0
- package/bundled-types/boxel-ui/components/entity-icon-display/index.gts +144 -0
- package/bundled-types/boxel-ui/components/entity-icon-display/usage.gts +54 -0
- package/bundled-types/boxel-ui/components/entity-thumbnail-display/index.gts +148 -0
- package/bundled-types/boxel-ui/components/entity-thumbnail-display/usage.gts +76 -0
- package/bundled-types/boxel-ui/components/field-container/index.gts +150 -0
- package/bundled-types/boxel-ui/components/field-container/usage.gts +188 -0
- package/bundled-types/boxel-ui/components/filter-list/index.gts +255 -0
- package/bundled-types/boxel-ui/components/filter-list/usage.gts +153 -0
- package/bundled-types/boxel-ui/components/fitted-card-container/index.gts +66 -0
- package/bundled-types/boxel-ui/components/fitted-card-container/usage.gts +81 -0
- package/bundled-types/boxel-ui/components/grid-container/grid-item-container/index.gts +37 -0
- package/bundled-types/boxel-ui/components/grid-container/index.gts +116 -0
- package/bundled-types/boxel-ui/components/grid-container/usage.gts +105 -0
- package/bundled-types/boxel-ui/components/header/index.gts +101 -0
- package/bundled-types/boxel-ui/components/header/usage.gts +116 -0
- package/bundled-types/boxel-ui/components/icon-button/index.gts +148 -0
- package/bundled-types/boxel-ui/components/icon-button/usage.gts +249 -0
- package/bundled-types/boxel-ui/components/input/index.gts +560 -0
- package/bundled-types/boxel-ui/components/input/usage.gts +449 -0
- package/bundled-types/boxel-ui/components/input-group/accessories/index.gts +191 -0
- package/bundled-types/boxel-ui/components/input-group/controls/index.gts +54 -0
- package/bundled-types/boxel-ui/components/input-group/index.gts +347 -0
- package/bundled-types/boxel-ui/components/input-group/usage.gts +437 -0
- package/bundled-types/boxel-ui/components/kanban/card.gts +89 -0
- package/bundled-types/boxel-ui/components/kanban/column-header.gts +151 -0
- package/bundled-types/boxel-ui/components/kanban/drag.gts +1007 -0
- package/bundled-types/boxel-ui/components/kanban/engine.ts +247 -0
- package/bundled-types/boxel-ui/components/kanban/ghost.gts +64 -0
- package/bundled-types/boxel-ui/components/kanban/index.gts +16 -0
- package/bundled-types/boxel-ui/components/kanban/modifiers.gts +42 -0
- package/bundled-types/boxel-ui/components/kanban/plane-inner.gts +525 -0
- package/bundled-types/boxel-ui/components/kanban/plane.gts +163 -0
- package/bundled-types/boxel-ui/components/kanban/usage.gts +392 -0
- package/bundled-types/boxel-ui/components/label/index.gts +64 -0
- package/bundled-types/boxel-ui/components/loading-indicator/index.gts +78 -0
- package/bundled-types/boxel-ui/components/loading-indicator/usage.gts +72 -0
- package/bundled-types/boxel-ui/components/menu/index.gts +267 -0
- package/bundled-types/boxel-ui/components/menu/usage.gts +100 -0
- package/bundled-types/boxel-ui/components/message/index.gts +146 -0
- package/bundled-types/boxel-ui/components/message/usage.gts +263 -0
- package/bundled-types/boxel-ui/components/modal/index.gts +159 -0
- package/bundled-types/boxel-ui/components/modal/usage.gts +206 -0
- package/bundled-types/boxel-ui/components/multi-select/after-options.gts +59 -0
- package/bundled-types/boxel-ui/components/multi-select/index.gts +230 -0
- package/bundled-types/boxel-ui/components/multi-select/selected-item.gts +91 -0
- package/bundled-types/boxel-ui/components/multi-select/trigger.gts +190 -0
- package/bundled-types/boxel-ui/components/multi-select/usage.gts +420 -0
- package/bundled-types/boxel-ui/components/phone-input/index.gts +149 -0
- package/bundled-types/boxel-ui/components/phone-input/usage.gts +73 -0
- package/bundled-types/boxel-ui/components/picker/before-options-with-search.gts +340 -0
- package/bundled-types/boxel-ui/components/picker/index.gts +427 -0
- package/bundled-types/boxel-ui/components/picker/option-row.gts +270 -0
- package/bundled-types/boxel-ui/components/picker/selected-item.gts +171 -0
- package/bundled-types/boxel-ui/components/picker/trigger-labeled.gts +216 -0
- package/bundled-types/boxel-ui/components/picker/usage.gts +179 -0
- package/bundled-types/boxel-ui/components/pill/index.gts +231 -0
- package/bundled-types/boxel-ui/components/pill/usage.gts +230 -0
- package/bundled-types/boxel-ui/components/progress-bar/index.gts +124 -0
- package/bundled-types/boxel-ui/components/progress-bar/usage.gts +131 -0
- package/bundled-types/boxel-ui/components/progress-radial/index.gts +95 -0
- package/bundled-types/boxel-ui/components/progress-radial/usage.gts +79 -0
- package/bundled-types/boxel-ui/components/radio-input/index.gts +143 -0
- package/bundled-types/boxel-ui/components/radio-input/item.gts +210 -0
- package/bundled-types/boxel-ui/components/radio-input/usage.gts +303 -0
- package/bundled-types/boxel-ui/components/realm-icon/index.gts +129 -0
- package/bundled-types/boxel-ui/components/realm-icon/usage.gts +62 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/handle.gts +180 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/index.gts +341 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/panel.gts +86 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/usage.gts +350 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/adjust-layout-by-delta.ts +231 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/assert.ts +10 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/calculate-delta-percentage.ts +41 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/calculate-unsafe-default-layout.ts +53 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/compare-layouts.ts +12 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/const.ts +6 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/determine-pivot-indices.ts +15 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-panel-element.ts +10 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-panel-elements-for-group.ts +8 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-panel-group-element.ts +21 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-resize-handle-element-index.ts +14 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-resize-handle-element.ts +12 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-resize-handle-elements-for-group.ts +10 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/fuzzy-layouts-equal.ts +22 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/fuzzy-numbers.ts +21 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/get-resize-event-coordinates.ts +8 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/get-resize-event-cursor-position.ts +10 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/panel-resize-handle-registry.ts +446 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/resize-panel.ts +35 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/types.ts +23 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/validate-panel-group-layout.ts +86 -0
- package/bundled-types/boxel-ui/components/select/index.gts +882 -0
- package/bundled-types/boxel-ui/components/select/trigger.gts +132 -0
- package/bundled-types/boxel-ui/components/select/usage.gts +353 -0
- package/bundled-types/boxel-ui/components/skeleton-placeholder/index.gts +89 -0
- package/bundled-types/boxel-ui/components/skeleton-placeholder/usage.gts +102 -0
- package/bundled-types/boxel-ui/components/sort-dropdown/index.gts +91 -0
- package/bundled-types/boxel-ui/components/sort-dropdown/usage.gts +77 -0
- package/bundled-types/boxel-ui/components/swatch/index.gts +81 -0
- package/bundled-types/boxel-ui/components/swatch/usage.gts +57 -0
- package/bundled-types/boxel-ui/components/switch/index.gts +95 -0
- package/bundled-types/boxel-ui/components/switch/usage.gts +79 -0
- package/bundled-types/boxel-ui/components/tabbed-header/index.gts +141 -0
- package/bundled-types/boxel-ui/components/tabbed-header/usage.gts +103 -0
- package/bundled-types/boxel-ui/components/tag/index.gts +50 -0
- package/bundled-types/boxel-ui/components/tag/usage.gts +89 -0
- package/bundled-types/boxel-ui/components/tag-list/index.gts +85 -0
- package/bundled-types/boxel-ui/components/tag-list/usage.gts +129 -0
- package/bundled-types/boxel-ui/components/tooltip/index.gts +306 -0
- package/bundled-types/boxel-ui/components/tooltip/usage.gts +168 -0
- package/bundled-types/boxel-ui/components/view-selector/index.gts +166 -0
- package/bundled-types/boxel-ui/components/view-selector/usage.gts +149 -0
- package/bundled-types/boxel-ui/components.ts +169 -0
- package/bundled-types/boxel-ui/helpers/add-class-to-svg.ts +8 -0
- package/bundled-types/boxel-ui/helpers/clipboard.ts +21 -0
- package/bundled-types/boxel-ui/helpers/cn.ts +12 -0
- package/bundled-types/boxel-ui/helpers/color-tools.ts +331 -0
- package/bundled-types/boxel-ui/helpers/compact.ts +3 -0
- package/bundled-types/boxel-ui/helpers/contrast-color.ts +32 -0
- package/bundled-types/boxel-ui/helpers/css-var.ts +41 -0
- package/bundled-types/boxel-ui/helpers/currency-format.ts +25 -0
- package/bundled-types/boxel-ui/helpers/dayjs-format.ts +27 -0
- package/bundled-types/boxel-ui/helpers/deterministic-color-from-string.ts +45 -0
- package/bundled-types/boxel-ui/helpers/element.ts +16 -0
- package/bundled-types/boxel-ui/helpers/extract-css-variables.ts +126 -0
- package/bundled-types/boxel-ui/helpers/format-age.ts +72 -0
- package/bundled-types/boxel-ui/helpers/format-countdown.ts +110 -0
- package/bundled-types/boxel-ui/helpers/format-currency.ts +95 -0
- package/bundled-types/boxel-ui/helpers/format-date-time.ts +567 -0
- package/bundled-types/boxel-ui/helpers/format-duration.ts +143 -0
- package/bundled-types/boxel-ui/helpers/format-file-size.ts +49 -0
- package/bundled-types/boxel-ui/helpers/format-list.ts +73 -0
- package/bundled-types/boxel-ui/helpers/format-names.ts +103 -0
- package/bundled-types/boxel-ui/helpers/format-number.ts +140 -0
- package/bundled-types/boxel-ui/helpers/format-ordinal.ts +115 -0
- package/bundled-types/boxel-ui/helpers/format-period.ts +188 -0
- package/bundled-types/boxel-ui/helpers/format-relative-time.ts +789 -0
- package/bundled-types/boxel-ui/helpers/generate-css-variables.ts +47 -0
- package/bundled-types/boxel-ui/helpers/markdown-escape.ts +36 -0
- package/bundled-types/boxel-ui/helpers/math-helpers.ts +18 -0
- package/bundled-types/boxel-ui/helpers/menu-divider.ts +15 -0
- package/bundled-types/boxel-ui/helpers/menu-item.ts +76 -0
- package/bundled-types/boxel-ui/helpers/optional.ts +7 -0
- package/bundled-types/boxel-ui/helpers/pick.ts +11 -0
- package/bundled-types/boxel-ui/helpers/sanitize-html.ts +45 -0
- package/bundled-types/boxel-ui/helpers/string.ts +15 -0
- package/bundled-types/boxel-ui/helpers/theme-css.ts +148 -0
- package/bundled-types/boxel-ui/helpers/truth-helpers.ts +48 -0
- package/bundled-types/boxel-ui/helpers/validate-email-format.ts +138 -0
- package/bundled-types/boxel-ui/helpers/validate-phone-format.ts +201 -0
- package/bundled-types/boxel-ui/helpers.ts +134 -0
- package/bundled-types/boxel-ui/icons/ai-bw.gts +22 -0
- package/bundled-types/boxel-ui/icons/arrow-left.gts +25 -0
- package/bundled-types/boxel-ui/icons/arrow-right.gts +28 -0
- package/bundled-types/boxel-ui/icons/arrow-top-left.gts +22 -0
- package/bundled-types/boxel-ui/icons/arrow-up.gts +25 -0
- package/bundled-types/boxel-ui/icons/atom.gts +26 -0
- package/bundled-types/boxel-ui/icons/boxel-icon-with-text.gts +29 -0
- package/bundled-types/boxel-ui/icons/boxel-icon.gts +34 -0
- package/bundled-types/boxel-ui/icons/card-definition.gts +26 -0
- package/bundled-types/boxel-ui/icons/card-instance.gts +26 -0
- package/bundled-types/boxel-ui/icons/card.gts +24 -0
- package/bundled-types/boxel-ui/icons/cardbot-lg.gts +24 -0
- package/bundled-types/boxel-ui/icons/caret-down.gts +23 -0
- package/bundled-types/boxel-ui/icons/caret-up.gts +23 -0
- package/bundled-types/boxel-ui/icons/check-mark.gts +23 -0
- package/bundled-types/boxel-ui/icons/chevron-right.gts +23 -0
- package/bundled-types/boxel-ui/icons/copy.gts +28 -0
- package/bundled-types/boxel-ui/icons/diagonal-arrow-left-up.gts +21 -0
- package/bundled-types/boxel-ui/icons/download.gts +19 -0
- package/bundled-types/boxel-ui/icons/dropdown-arrow-down.gts +20 -0
- package/bundled-types/boxel-ui/icons/dropdown-arrow-filled.gts +19 -0
- package/bundled-types/boxel-ui/icons/dropdown-arrow-up.gts +20 -0
- package/bundled-types/boxel-ui/icons/edit.gts +14 -0
- package/bundled-types/boxel-ui/icons/embedded.gts +34 -0
- package/bundled-types/boxel-ui/icons/exclamation-circle.gts +26 -0
- package/bundled-types/boxel-ui/icons/exclamation.gts +20 -0
- package/bundled-types/boxel-ui/icons/eye.gts +19 -0
- package/bundled-types/boxel-ui/icons/failure-bordered.gts +26 -0
- package/bundled-types/boxel-ui/icons/field.gts +26 -0
- package/bundled-types/boxel-ui/icons/file-alert.gts +28 -0
- package/bundled-types/boxel-ui/icons/file.gts +27 -0
- package/bundled-types/boxel-ui/icons/fitted.gts +42 -0
- package/bundled-types/boxel-ui/icons/folder.gts +26 -0
- package/bundled-types/boxel-ui/icons/form.gts +38 -0
- package/bundled-types/boxel-ui/icons/four-lines.gts +21 -0
- package/bundled-types/boxel-ui/icons/grid-3x3.gts +26 -0
- package/bundled-types/boxel-ui/icons/group.gts +22 -0
- package/bundled-types/boxel-ui/icons/head.gts +28 -0
- package/bundled-types/boxel-ui/icons/highlight-icon.gts +46 -0
- package/bundled-types/boxel-ui/icons/icon-circle-selected.gts +25 -0
- package/bundled-types/boxel-ui/icons/icon-circle.gts +25 -0
- package/bundled-types/boxel-ui/icons/icon-code.gts +22 -0
- package/bundled-types/boxel-ui/icons/icon-funnel.gts +23 -0
- package/bundled-types/boxel-ui/icons/icon-globe.gts +19 -0
- package/bundled-types/boxel-ui/icons/icon-grid.gts +68 -0
- package/bundled-types/boxel-ui/icons/icon-hexagon.gts +22 -0
- package/bundled-types/boxel-ui/icons/icon-inherit.gts +19 -0
- package/bundled-types/boxel-ui/icons/icon-link.gts +20 -0
- package/bundled-types/boxel-ui/icons/icon-list.gts +40 -0
- package/bundled-types/boxel-ui/icons/icon-minus-circle.gts +26 -0
- package/bundled-types/boxel-ui/icons/icon-pencil-crossed-out.gts +33 -0
- package/bundled-types/boxel-ui/icons/icon-pencil-not-crossed-out.gts +21 -0
- package/bundled-types/boxel-ui/icons/icon-pencil.gts +23 -0
- package/bundled-types/boxel-ui/icons/icon-plus-circle.gts +31 -0
- package/bundled-types/boxel-ui/icons/icon-plus-thin.gts +19 -0
- package/bundled-types/boxel-ui/icons/icon-plus.gts +20 -0
- package/bundled-types/boxel-ui/icons/icon-search-thick.gts +27 -0
- package/bundled-types/boxel-ui/icons/icon-search.gts +25 -0
- package/bundled-types/boxel-ui/icons/icon-table.gts +44 -0
- package/bundled-types/boxel-ui/icons/icon-trash.gts +24 -0
- package/bundled-types/boxel-ui/icons/icon-turn-down-right.gts +18 -0
- package/bundled-types/boxel-ui/icons/icon-x.gts +21 -0
- package/bundled-types/boxel-ui/icons/image-placeholder.gts +30 -0
- package/bundled-types/boxel-ui/icons/isolated.gts +20 -0
- package/bundled-types/boxel-ui/icons/loading-indicator.gts +26 -0
- package/bundled-types/boxel-ui/icons/lock.gts +23 -0
- package/bundled-types/boxel-ui/icons/markdown.gts +19 -0
- package/bundled-types/boxel-ui/icons/profile.gts +23 -0
- package/bundled-types/boxel-ui/icons/publish-site-icon.gts +25 -0
- package/bundled-types/boxel-ui/icons/rows-4.gts +26 -0
- package/bundled-types/boxel-ui/icons/select-all.gts +25 -0
- package/bundled-types/boxel-ui/icons/send.gts +21 -0
- package/bundled-types/boxel-ui/icons/sparkle.gts +21 -0
- package/bundled-types/boxel-ui/icons/star-filled.gts +25 -0
- package/bundled-types/boxel-ui/icons/star-half-fill.gts +27 -0
- package/bundled-types/boxel-ui/icons/star.gts +25 -0
- package/bundled-types/boxel-ui/icons/success-bordered.gts +30 -0
- package/bundled-types/boxel-ui/icons/three-dots-horizontal.gts +21 -0
- package/bundled-types/boxel-ui/icons/triangle-left.gts +23 -0
- package/bundled-types/boxel-ui/icons/triangle-right.gts +23 -0
- package/bundled-types/boxel-ui/icons/types.ts +10 -0
- package/bundled-types/boxel-ui/icons/upload.gts +20 -0
- package/bundled-types/boxel-ui/icons/warning.gts +19 -0
- package/bundled-types/boxel-ui/icons.gts +249 -0
- package/bundled-types/boxel-ui/modifiers/auto-focus.ts +7 -0
- package/bundled-types/boxel-ui/modifiers/set-css-var.ts +24 -0
- package/bundled-types/boxel-ui/modifiers.ts +14 -0
- package/bundled-types/boxel-ui/types/@cardstack/boxel-ui/index.d.ts +3 -0
- package/bundled-types/boxel-ui/types/ember-css-url/index.d.ts +15 -0
- package/bundled-types/boxel-ui/types/ember-draggable-modifiers/index.d.ts +109 -0
- package/bundled-types/boxel-ui/types/ember-draggable-modifiers/utils.d.ts +7 -0
- package/bundled-types/boxel-ui/types/ember-focus-trap/index.d.ts +20 -0
- package/bundled-types/boxel-ui/types/ember-power-calendar/components/index.d.ts +9 -0
- package/bundled-types/boxel-ui/types/ember-resize-modifier/index.d.ts +14 -0
- package/bundled-types/boxel-ui/types/ember-set-body-class/index.d.ts +12 -0
- package/bundled-types/boxel-ui/types/ember-sortable/index.d.ts +52 -0
- package/bundled-types/boxel-ui/types/global.d.ts +7 -0
- package/bundled-types/boxel-ui/usage.ts +112 -0
- package/bundled-types/boxel-ui/utils/date-utils.ts +192 -0
- package/bundled-types/boxel-ui/utils/fitted-formats.ts +161 -0
- package/bundled-types/host-app/app.ts +22 -0
- package/bundled-types/host-app/commands/add-field-to-card-definition.ts +74 -0
- package/bundled-types/host-app/commands/ai-assistant.ts +203 -0
- package/bundled-types/host-app/commands/apply-markdown-edit.ts +203 -0
- package/bundled-types/host-app/commands/apply-search-replace-block.ts +225 -0
- package/bundled-types/host-app/commands/ask-ai.ts +66 -0
- package/bundled-types/host-app/commands/authed-fetch.ts +53 -0
- package/bundled-types/host-app/commands/bot-requests/create-listing-pr-request.ts +77 -0
- package/bundled-types/host-app/commands/bot-requests/send-bot-trigger-event.ts +53 -0
- package/bundled-types/host-app/commands/can-read-realm.ts +34 -0
- package/bundled-types/host-app/commands/cancel-indexing-job.ts +29 -0
- package/bundled-types/host-app/commands/check-correctness.ts +309 -0
- package/bundled-types/host-app/commands/copy-and-edit.ts +311 -0
- package/bundled-types/host-app/commands/copy-card-as-markdown.ts +41 -0
- package/bundled-types/host-app/commands/copy-card-to-stack.ts +70 -0
- package/bundled-types/host-app/commands/copy-card.ts +67 -0
- package/bundled-types/host-app/commands/copy-file-to-realm.ts +82 -0
- package/bundled-types/host-app/commands/copy-source.ts +46 -0
- package/bundled-types/host-app/commands/create-ai-assistant-room.ts +144 -0
- package/bundled-types/host-app/commands/create-and-open-submission-workflow-card.ts +30 -0
- package/bundled-types/host-app/commands/create-specs.ts +422 -0
- package/bundled-types/host-app/commands/create-submission-workflow.ts +172 -0
- package/bundled-types/host-app/commands/evaluate-module.ts +119 -0
- package/bundled-types/host-app/commands/execute-atomic-operations.ts +44 -0
- package/bundled-types/host-app/commands/fetch-card-json.ts +33 -0
- package/bundled-types/host-app/commands/full-reindex-realm.ts +30 -0
- package/bundled-types/host-app/commands/generate-example-cards.ts +298 -0
- package/bundled-types/host-app/commands/generate-readme-spec.ts +116 -0
- package/bundled-types/host-app/commands/generate-theme-example.ts +147 -0
- package/bundled-types/host-app/commands/generate-thumbnail.ts +247 -0
- package/bundled-types/host-app/commands/get-all-realm-metas.ts +38 -0
- package/bundled-types/host-app/commands/get-available-realm-identifiers.ts +29 -0
- package/bundled-types/host-app/commands/get-card-type-schema.ts +59 -0
- package/bundled-types/host-app/commands/get-card.ts +34 -0
- package/bundled-types/host-app/commands/get-catalog-realm-identifiers.ts +29 -0
- package/bundled-types/host-app/commands/get-default-writable-realm.ts +28 -0
- package/bundled-types/host-app/commands/get-events-from-room.ts +70 -0
- package/bundled-types/host-app/commands/get-realm-of-resource-identifier.ts +37 -0
- package/bundled-types/host-app/commands/get-user-system-card.ts +38 -0
- package/bundled-types/host-app/commands/index.ts +590 -0
- package/bundled-types/host-app/commands/instantiate-card.ts +185 -0
- package/bundled-types/host-app/commands/invalidate-realm-identifiers.ts +33 -0
- package/bundled-types/host-app/commands/invite-user-to-room.ts +34 -0
- package/bundled-types/host-app/commands/lint-and-fix.ts +60 -0
- package/bundled-types/host-app/commands/listing-action-build.ts +79 -0
- package/bundled-types/host-app/commands/listing-action-init.ts +106 -0
- package/bundled-types/host-app/commands/listing-create.ts +632 -0
- package/bundled-types/host-app/commands/listing-generate-example.ts +83 -0
- package/bundled-types/host-app/commands/listing-install.ts +227 -0
- package/bundled-types/host-app/commands/listing-remix.ts +150 -0
- package/bundled-types/host-app/commands/listing-update-specs.ts +116 -0
- package/bundled-types/host-app/commands/listing-use.ts +97 -0
- package/bundled-types/host-app/commands/one-shot-llm-request.ts +209 -0
- package/bundled-types/host-app/commands/open-ai-assistant-room.ts +38 -0
- package/bundled-types/host-app/commands/open-create-listing-modal.ts +52 -0
- package/bundled-types/host-app/commands/open-in-interact-mode.ts +36 -0
- package/bundled-types/host-app/commands/open-workspace.ts +38 -0
- package/bundled-types/host-app/commands/patch-card-instance.ts +108 -0
- package/bundled-types/host-app/commands/patch-code.ts +243 -0
- package/bundled-types/host-app/commands/patch-fields.ts +304 -0
- package/bundled-types/host-app/commands/patch-theme.ts +52 -0
- package/bundled-types/host-app/commands/persist-module-inspector-view.ts +41 -0
- package/bundled-types/host-app/commands/populate-with-sample-data.ts +84 -0
- package/bundled-types/host-app/commands/preview-format.ts +52 -0
- package/bundled-types/host-app/commands/read-binary-file.ts +62 -0
- package/bundled-types/host-app/commands/read-card-for-ai-assistant.ts +50 -0
- package/bundled-types/host-app/commands/read-file-for-ai-assistant.ts +46 -0
- package/bundled-types/host-app/commands/read-source.ts +46 -0
- package/bundled-types/host-app/commands/read-text-file.ts +44 -0
- package/bundled-types/host-app/commands/register-bot.ts +42 -0
- package/bundled-types/host-app/commands/reindex-realm.ts +30 -0
- package/bundled-types/host-app/commands/retry-submission-workflow.ts +119 -0
- package/bundled-types/host-app/commands/sanitize-module-list.ts +83 -0
- package/bundled-types/host-app/commands/save-card.ts +44 -0
- package/bundled-types/host-app/commands/screenshot-card.ts +148 -0
- package/bundled-types/host-app/commands/search-and-choose.ts +180 -0
- package/bundled-types/host-app/commands/search-cards.ts +102 -0
- package/bundled-types/host-app/commands/search-google-images.ts +100 -0
- package/bundled-types/host-app/commands/send-ai-assistant-message.ts +122 -0
- package/bundled-types/host-app/commands/send-request-via-proxy.ts +70 -0
- package/bundled-types/host-app/commands/serialize-card.ts +45 -0
- package/bundled-types/host-app/commands/set-active-llm.ts +39 -0
- package/bundled-types/host-app/commands/set-user-system-card.ts +29 -0
- package/bundled-types/host-app/commands/show-card.ts +102 -0
- package/bundled-types/host-app/commands/show-file.ts +39 -0
- package/bundled-types/host-app/commands/store-add.ts +37 -0
- package/bundled-types/host-app/commands/summarize-session.ts +82 -0
- package/bundled-types/host-app/commands/switch-submode.ts +112 -0
- package/bundled-types/host-app/commands/sync-openrouter-models.ts +373 -0
- package/bundled-types/host-app/commands/transform-cards.ts +59 -0
- package/bundled-types/host-app/commands/unregister-bot.ts +29 -0
- package/bundled-types/host-app/commands/update-code-path-with-selection.ts +45 -0
- package/bundled-types/host-app/commands/update-playground-selection.ts +37 -0
- package/bundled-types/host-app/commands/update-room-skills.ts +231 -0
- package/bundled-types/host-app/commands/utils.ts +178 -0
- package/bundled-types/host-app/commands/validate-realm.ts +40 -0
- package/bundled-types/host-app/commands/write-binary-file.ts +142 -0
- package/bundled-types/host-app/commands/write-text-file.ts +104 -0
- package/bundled-types/host-app/components/.gitkeep +0 -0
- package/bundled-types/host-app/components/ai-assistant/action-bar.gts +188 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-button-active-bg.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-button-active-bg@2x.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-button-active-bg@3x.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon-animated.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon-bw.png +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon-bw@2x.png +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon-bw@3x.png +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon@2x.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon@3x.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/apply-button/index.gts +226 -0
- package/bundled-types/host-app/components/ai-assistant/apply-button/usage.gts +81 -0
- package/bundled-types/host-app/components/ai-assistant/attached-file-dropdown-menu.gts +179 -0
- package/bundled-types/host-app/components/ai-assistant/attachment-picker/attach-button.gts +176 -0
- package/bundled-types/host-app/components/ai-assistant/attachment-picker/attached-items.gts +271 -0
- package/bundled-types/host-app/components/ai-assistant/attachment-picker/index.gts +144 -0
- package/bundled-types/host-app/components/ai-assistant/attachment-picker/usage.gts +127 -0
- package/bundled-types/host-app/components/ai-assistant/button.gts +60 -0
- package/bundled-types/host-app/components/ai-assistant/chat-input/index.gts +203 -0
- package/bundled-types/host-app/components/ai-assistant/chat-input/usage.gts +68 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/actions.gts +58 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/apply-code-patch-button.gts +66 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/command-header.gts +115 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/diff-editor-header.gts +209 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/index.gts +228 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/patch-footer.gts +32 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/view-code-button.gts +73 -0
- package/bundled-types/host-app/components/ai-assistant/focus-pill/index.gts +60 -0
- package/bundled-types/host-app/components/ai-assistant/focus-pill/usage.gts +45 -0
- package/bundled-types/host-app/components/ai-assistant/llm-mode-toggle.gts +113 -0
- package/bundled-types/host-app/components/ai-assistant/llm-select.gts +158 -0
- package/bundled-types/host-app/components/ai-assistant/message/aibot-message.gts +374 -0
- package/bundled-types/host-app/components/ai-assistant/message/attachments.gts +153 -0
- package/bundled-types/host-app/components/ai-assistant/message/index.gts +678 -0
- package/bundled-types/host-app/components/ai-assistant/message/meta.gts +66 -0
- package/bundled-types/host-app/components/ai-assistant/message/text-content.gts +32 -0
- package/bundled-types/host-app/components/ai-assistant/message/usage.gts +182 -0
- package/bundled-types/host-app/components/ai-assistant/message/user-message.gts +52 -0
- package/bundled-types/host-app/components/ai-assistant/new-session-button.gts +126 -0
- package/bundled-types/host-app/components/ai-assistant/new-session-settings.gts +180 -0
- package/bundled-types/host-app/components/ai-assistant/new-session.gts +83 -0
- package/bundled-types/host-app/components/ai-assistant/panel-popover.gts +102 -0
- package/bundled-types/host-app/components/ai-assistant/panel.gts +453 -0
- package/bundled-types/host-app/components/ai-assistant/past-session-item.gts +323 -0
- package/bundled-types/host-app/components/ai-assistant/past-sessions.gts +115 -0
- package/bundled-types/host-app/components/ai-assistant/rename-session.gts +144 -0
- package/bundled-types/host-app/components/ai-assistant/restore-file-modal.gts +105 -0
- package/bundled-types/host-app/components/ai-assistant/skill-menu/index.gts +190 -0
- package/bundled-types/host-app/components/ai-assistant/skill-menu/skill-toggle.gts +168 -0
- package/bundled-types/host-app/components/ai-assistant/skill-menu/usage.gts +48 -0
- package/bundled-types/host-app/components/ai-assistant/toast.gts +293 -0
- package/bundled-types/host-app/components/card-catalog/modal.gts +579 -0
- package/bundled-types/host-app/components/card-error.gts +41 -0
- package/bundled-types/host-app/components/card-instance-picker/index.gts +54 -0
- package/bundled-types/host-app/components/card-pill.gts +189 -0
- package/bundled-types/host-app/components/card-prerender.gts +880 -0
- package/bundled-types/host-app/components/card-renderer.gts +84 -0
- package/bundled-types/host-app/components/card-search/constants.ts +76 -0
- package/bundled-types/host-app/components/card-search/item-button.gts +243 -0
- package/bundled-types/host-app/components/card-search/panel.gts +150 -0
- package/bundled-types/host-app/components/card-search/search-bar.gts +218 -0
- package/bundled-types/host-app/components/card-search/search-content.gts +604 -0
- package/bundled-types/host-app/components/card-search/search-result-header.gts +165 -0
- package/bundled-types/host-app/components/card-search/search-result-section.gts +545 -0
- package/bundled-types/host-app/components/card-search/section-header.gts +117 -0
- package/bundled-types/host-app/components/editor/directory.gts +308 -0
- package/bundled-types/host-app/components/editor/file-tree.gts +69 -0
- package/bundled-types/host-app/components/editor/import-module.gts +27 -0
- package/bundled-types/host-app/components/editor/indexed-file-tree.gts +572 -0
- package/bundled-types/host-app/components/editor/recent-files.gts +141 -0
- package/bundled-types/host-app/components/file-pill.gts +206 -0
- package/bundled-types/host-app/components/head-format-preview.gts +781 -0
- package/bundled-types/host-app/components/host-mode/breadcrumb-item.gts +150 -0
- package/bundled-types/host-app/components/host-mode/breadcrumbs.gts +131 -0
- package/bundled-types/host-app/components/host-mode/card.gts +199 -0
- package/bundled-types/host-app/components/host-mode/content.gts +195 -0
- package/bundled-types/host-app/components/host-mode/stack-item.gts +310 -0
- package/bundled-types/host-app/components/host-mode/stack.gts +91 -0
- package/bundled-types/host-app/components/matrix/auth-container.gts +66 -0
- package/bundled-types/host-app/components/matrix/auth.gts +73 -0
- package/bundled-types/host-app/components/matrix/forgot-password.gts +487 -0
- package/bundled-types/host-app/components/matrix/login.gts +241 -0
- package/bundled-types/host-app/components/matrix/register-user.gts +843 -0
- package/bundled-types/host-app/components/matrix/room-message-command.gts +330 -0
- package/bundled-types/host-app/components/matrix/room-message.gts +261 -0
- package/bundled-types/host-app/components/matrix/room.gts +1872 -0
- package/bundled-types/host-app/components/matrix/user-profile.gts +99 -0
- package/bundled-types/host-app/components/modal-container.gts +171 -0
- package/bundled-types/host-app/components/operator-mode/binary-file-info.gts +77 -0
- package/bundled-types/host-app/components/operator-mode/card-adoption-chain.gts +99 -0
- package/bundled-types/host-app/components/operator-mode/card-error-detail.gts +87 -0
- package/bundled-types/host-app/components/operator-mode/card-error.gts +177 -0
- package/bundled-types/host-app/components/operator-mode/card-schema-editor.gts +616 -0
- package/bundled-types/host-app/components/operator-mode/card-url-bar.gts +197 -0
- package/bundled-types/host-app/components/operator-mode/choose-file-modal.gts +562 -0
- package/bundled-types/host-app/components/operator-mode/choose-subscription-plan-modal.gts +517 -0
- package/bundled-types/host-app/components/operator-mode/code-editor.gts +736 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/editor-indicator.gts +128 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/format-chooser.gts +589 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/inner-container.gts +162 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/left-panel-toggle.gts +267 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/module-inspector.gts +836 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/field-chooser-modal.gts +97 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/instance-chooser-dropdown.gts +346 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/playground-background.png +0 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/playground-panel.gts +1274 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/playground-preview.gts +155 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/playground.gts +98 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/spec-search.gts +70 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/schema-editor.gts +205 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/spec-preview-badge.gts +72 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/spec-preview.gts +432 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/toggle-button.gts +72 -0
- package/bundled-types/host-app/components/operator-mode/code-submode.gts +1030 -0
- package/bundled-types/host-app/components/operator-mode/container.gts +270 -0
- package/bundled-types/host-app/components/operator-mode/context-menu-button.gts +95 -0
- package/bundled-types/host-app/components/operator-mode/copy-button.gts +277 -0
- package/bundled-types/host-app/components/operator-mode/create-file-modal.gts +1087 -0
- package/bundled-types/host-app/components/operator-mode/create-listing-modal.gts +513 -0
- package/bundled-types/host-app/components/operator-mode/definition-container/base.gts +222 -0
- package/bundled-types/host-app/components/operator-mode/definition-container/clickable.gts +59 -0
- package/bundled-types/host-app/components/operator-mode/definition-container/divider.gts +48 -0
- package/bundled-types/host-app/components/operator-mode/definition-container/index.gts +108 -0
- package/bundled-types/host-app/components/operator-mode/delete-modal.gts +123 -0
- package/bundled-types/host-app/components/operator-mode/detail-panel-selector.gts +320 -0
- package/bundled-types/host-app/components/operator-mode/detail-panel.gts +834 -0
- package/bundled-types/host-app/components/operator-mode/edit-field-modal.gts +450 -0
- package/bundled-types/host-app/components/operator-mode/error-display.gts +590 -0
- package/bundled-types/host-app/components/operator-mode/host-submode/open-site-popover.gts +127 -0
- package/bundled-types/host-app/components/operator-mode/host-submode/publishing-realm-popover.gts +159 -0
- package/bundled-types/host-app/components/operator-mode/host-submode.gts +373 -0
- package/bundled-types/host-app/components/operator-mode/interact-submode/neighbor-stack-trigger.gts +116 -0
- package/bundled-types/host-app/components/operator-mode/interact-submode.gts +1021 -0
- package/bundled-types/host-app/components/operator-mode/new-file-button.gts +187 -0
- package/bundled-types/host-app/components/operator-mode/operator-mode-overlays.gts +511 -0
- package/bundled-types/host-app/components/operator-mode/overlays.gts +342 -0
- package/bundled-types/host-app/components/operator-mode/preview-panel/fitted-format-gallery.gts +127 -0
- package/bundled-types/host-app/components/operator-mode/preview-panel/index.gts +443 -0
- package/bundled-types/host-app/components/operator-mode/preview-panel/markdown-preview.gts +175 -0
- package/bundled-types/host-app/components/operator-mode/preview-panel/metadata-panel.gts +214 -0
- package/bundled-types/host-app/components/operator-mode/preview-panel/rendered-markdown.gts +718 -0
- package/bundled-types/host-app/components/operator-mode/private-dependency-violation.gts +70 -0
- package/bundled-types/host-app/components/operator-mode/profile/profile-email.gts +686 -0
- package/bundled-types/host-app/components/operator-mode/profile/profile-settings-modal.gts +454 -0
- package/bundled-types/host-app/components/operator-mode/profile/profile-subscription.gts +170 -0
- package/bundled-types/host-app/components/operator-mode/profile-info-popover.gts +263 -0
- package/bundled-types/host-app/components/operator-mode/publish-realm-modal.gts +1529 -0
- package/bundled-types/host-app/components/operator-mode/remove-field-modal.gts +135 -0
- package/bundled-types/host-app/components/operator-mode/send-error-to-ai-assistant.gts +195 -0
- package/bundled-types/host-app/components/operator-mode/stack-item.gts +1341 -0
- package/bundled-types/host-app/components/operator-mode/stack.gts +191 -0
- package/bundled-types/host-app/components/operator-mode/submode-layout.gts +781 -0
- package/bundled-types/host-app/components/operator-mode/syntax-error-display.gts +72 -0
- package/bundled-types/host-app/components/operator-mode/workspace-chooser/add-workspace.gts +282 -0
- package/bundled-types/host-app/components/operator-mode/workspace-chooser/index.gts +299 -0
- package/bundled-types/host-app/components/operator-mode/workspace-chooser/item-container.gts +50 -0
- package/bundled-types/host-app/components/operator-mode/workspace-chooser/workspace-loading-indicator.gts +50 -0
- package/bundled-types/host-app/components/operator-mode/workspace-chooser/workspace.gts +1079 -0
- package/bundled-types/host-app/components/pill-menu/index.gts +281 -0
- package/bundled-types/host-app/components/pill-menu/usage.gts +64 -0
- package/bundled-types/host-app/components/prerendered-card-search.gts +274 -0
- package/bundled-types/host-app/components/realm-dropdown.gts +209 -0
- package/bundled-types/host-app/components/realm-picker/index.gts +142 -0
- package/bundled-types/host-app/components/search-sheet/index.gts +426 -0
- package/bundled-types/host-app/components/search-sheet/usage.gts +99 -0
- package/bundled-types/host-app/components/submode-switcher.gts +260 -0
- package/bundled-types/host-app/components/type-picker/index.gts +111 -0
- package/bundled-types/host-app/components/with-known-realms-loaded.gts +47 -0
- package/bundled-types/host-app/components/with-loaded-realm.gts +39 -0
- package/bundled-types/host-app/components/with-subscription-data.gts +247 -0
- package/bundled-types/host-app/config/environment.ts +66 -0
- package/bundled-types/host-app/deprecation-workflow.js +30 -0
- package/bundled-types/host-app/lib/browser-queue.ts +198 -0
- package/bundled-types/host-app/lib/codemirror-context.ts +1081 -0
- package/bundled-types/host-app/lib/command-definitions.ts +41 -0
- package/bundled-types/host-app/lib/download-realm.ts +9 -0
- package/bundled-types/host-app/lib/example-card-helpers.ts +99 -0
- package/bundled-types/host-app/lib/externals.ts +247 -0
- package/bundled-types/host-app/lib/field-path-parser.ts +520 -0
- package/bundled-types/host-app/lib/file-def-manager.ts +712 -0
- package/bundled-types/host-app/lib/file-upload-state.ts +6 -0
- package/bundled-types/host-app/lib/formatted-message/utils.ts +272 -0
- package/bundled-types/host-app/lib/gc-card-store.ts +1084 -0
- package/bundled-types/host-app/lib/host-base-command.ts +29 -0
- package/bundled-types/host-app/lib/html-component.ts +144 -0
- package/bundled-types/host-app/lib/html-to-markdown.ts +96 -0
- package/bundled-types/host-app/lib/isolated-render.gts +90 -0
- package/bundled-types/host-app/lib/known-file-meta-urls.ts +17 -0
- package/bundled-types/host-app/lib/limited-set.ts +68 -0
- package/bundled-types/host-app/lib/matrix-classes/member.ts +28 -0
- package/bundled-types/host-app/lib/matrix-classes/message-builder.ts +444 -0
- package/bundled-types/host-app/lib/matrix-classes/message-code-patch-result.ts +44 -0
- package/bundled-types/host-app/lib/matrix-classes/message-command.ts +109 -0
- package/bundled-types/host-app/lib/matrix-classes/message.ts +239 -0
- package/bundled-types/host-app/lib/matrix-classes/room.ts +174 -0
- package/bundled-types/host-app/lib/matrix-utils.ts +114 -0
- package/bundled-types/host-app/lib/mutex.ts +62 -0
- package/bundled-types/host-app/lib/prerender-fetch-headers.ts +46 -0
- package/bundled-types/host-app/lib/prerender-util.ts +31 -0
- package/bundled-types/host-app/lib/public-path.ts +1 -0
- package/bundled-types/host-app/lib/random-name.ts +26 -0
- package/bundled-types/host-app/lib/realm-utils.ts +45 -0
- package/bundled-types/host-app/lib/search-cache-key.ts +33 -0
- package/bundled-types/host-app/lib/search-in-flight-key.ts +28 -0
- package/bundled-types/host-app/lib/search-replace-block-parsing.ts +101 -0
- package/bundled-types/host-app/lib/setup-globals.ts +15 -0
- package/bundled-types/host-app/lib/sqlite-adapter.ts +510 -0
- package/bundled-types/host-app/lib/stack-item.ts +164 -0
- package/bundled-types/host-app/lib/utils.ts +84 -0
- package/bundled-types/host-app/lib/window-error-handler.ts +132 -0
- package/bundled-types/host-app/router.ts +31 -0
- package/bundled-types/host-app/services/ai-assistant-panel-service.ts +850 -0
- package/bundled-types/host-app/services/billing-service.ts +208 -0
- package/bundled-types/host-app/services/card-service.ts +373 -0
- package/bundled-types/host-app/services/card-type-service.ts +226 -0
- package/bundled-types/host-app/services/code-semantics-service.ts +297 -0
- package/bundled-types/host-app/services/command-service.ts +975 -0
- package/bundled-types/host-app/services/environment-service.ts +26 -0
- package/bundled-types/host-app/services/error-display.ts +42 -0
- package/bundled-types/host-app/services/file-upload.ts +212 -0
- package/bundled-types/host-app/services/host-mode-service.ts +381 -0
- package/bundled-types/host-app/services/host-mode-state-service.ts +160 -0
- package/bundled-types/host-app/services/loader-service.ts +148 -0
- package/bundled-types/host-app/services/local-indexer.ts +68 -0
- package/bundled-types/host-app/services/local-persistence-service.ts +296 -0
- package/bundled-types/host-app/services/logger-service.ts +13 -0
- package/bundled-types/host-app/services/matrix-sdk-loader.ts +346 -0
- package/bundled-types/host-app/services/matrix-service.ts +2287 -0
- package/bundled-types/host-app/services/message-service.ts +84 -0
- package/bundled-types/host-app/services/module-contents-service.ts +333 -0
- package/bundled-types/host-app/services/monaco-service.ts +333 -0
- package/bundled-types/host-app/services/network.ts +101 -0
- package/bundled-types/host-app/services/operator-mode-state-service.ts +1591 -0
- package/bundled-types/host-app/services/playground-panel-service.ts +236 -0
- package/bundled-types/host-app/services/queue.ts +30 -0
- package/bundled-types/host-app/services/realm-info-service.ts +37 -0
- package/bundled-types/host-app/services/realm-server.ts +1209 -0
- package/bundled-types/host-app/services/realm.ts +1413 -0
- package/bundled-types/host-app/services/recent-cards-service.ts +174 -0
- package/bundled-types/host-app/services/recent-files-service.ts +224 -0
- package/bundled-types/host-app/services/render-error-state.ts +55 -0
- package/bundled-types/host-app/services/render-service.ts +362 -0
- package/bundled-types/host-app/services/render-store.ts +27 -0
- package/bundled-types/host-app/services/reset.ts +19 -0
- package/bundled-types/host-app/services/scroll-position-service.ts +81 -0
- package/bundled-types/host-app/services/spec-panel-service.ts +107 -0
- package/bundled-types/host-app/services/store.ts +2540 -0
- package/bundled-types/host-app/utils/assert-never.ts +3 -0
- package/bundled-types/host-app/utils/auth-error-guard.ts +183 -0
- package/bundled-types/host-app/utils/auth-service-worker-registration.ts +123 -0
- package/bundled-types/host-app/utils/card-search/query-builder.ts +169 -0
- package/bundled-types/host-app/utils/card-search/section-pagination.ts +57 -0
- package/bundled-types/host-app/utils/card-search/sections.ts +240 -0
- package/bundled-types/host-app/utils/card-search/type-filter.ts +124 -0
- package/bundled-types/host-app/utils/card-search/types.ts +11 -0
- package/bundled-types/host-app/utils/card-search/url.ts +23 -0
- package/bundled-types/host-app/utils/clipboard.ts +23 -0
- package/bundled-types/host-app/utils/editor/boxel-formatter.ts +65 -0
- package/bundled-types/host-app/utils/editor/editor-language.ts +88 -0
- package/bundled-types/host-app/utils/editor/monaco-test-waiter.ts +302 -0
- package/bundled-types/host-app/utils/file-def-attributes-extractor.ts +438 -0
- package/bundled-types/host-app/utils/file-name.ts +38 -0
- package/bundled-types/host-app/utils/id-from-card-or-url.ts +11 -0
- package/bundled-types/host-app/utils/lint-formatting.ts +57 -0
- package/bundled-types/host-app/utils/local-storage-keys.ts +28 -0
- package/bundled-types/host-app/utils/normalized-dir-path.ts +3 -0
- package/bundled-types/host-app/utils/prettify-messages.ts +21 -0
- package/bundled-types/host-app/utils/prettify-prompts.ts +21 -0
- package/bundled-types/host-app/utils/realm-index-boilerplate.ts +27 -0
- package/bundled-types/host-app/utils/register-boxel-transition.ts +17 -0
- package/bundled-types/host-app/utils/render-desync-detector.ts +362 -0
- package/bundled-types/host-app/utils/render-error.ts +455 -0
- package/bundled-types/host-app/utils/render-timer-stub.ts +249 -0
- package/bundled-types/host-app/utils/run-while-active.ts +14 -0
- package/bundled-types/host-app/utils/schema-editor.ts +25 -0
- package/bundled-types/host-app/utils/text-suggestion.ts +82 -0
- package/bundled-types/host-app/utils/titleize.ts +10 -0
- package/bundled-types/host-app/utils/uuid.ts +13 -0
- package/bundled-types/host-tests/helpers/adapter.ts +464 -0
- package/bundled-types/host-tests/helpers/base-realm.ts +464 -0
- package/bundled-types/host-tests/helpers/cards/view-card-demo.ts +119 -0
- package/bundled-types/host-tests/helpers/field-test-helpers.gts +54 -0
- package/bundled-types/host-tests/helpers/image-fixture.ts +3 -0
- package/bundled-types/host-tests/helpers/index.gts +2099 -0
- package/bundled-types/host-tests/helpers/indexer.ts +293 -0
- package/bundled-types/host-tests/helpers/interact-submode-setup.gts +551 -0
- package/bundled-types/host-tests/helpers/mock-matrix/_client.ts +1042 -0
- package/bundled-types/host-tests/helpers/mock-matrix/_sdk.ts +71 -0
- package/bundled-types/host-tests/helpers/mock-matrix/_server-state.ts +343 -0
- package/bundled-types/host-tests/helpers/mock-matrix/_sliding-sync.ts +140 -0
- package/bundled-types/host-tests/helpers/mock-matrix/_utils.ts +146 -0
- package/bundled-types/host-tests/helpers/mock-matrix.ts +200 -0
- package/bundled-types/host-tests/helpers/operator-mode-parameters-match.ts +71 -0
- package/bundled-types/host-tests/helpers/operator-mode-state.ts +18 -0
- package/bundled-types/host-tests/helpers/percy-snapshot.ts +228 -0
- package/bundled-types/host-tests/helpers/playground.ts +130 -0
- package/bundled-types/host-tests/helpers/realm-server-mock/index.ts +100 -0
- package/bundled-types/host-tests/helpers/realm-server-mock/routes.ts +617 -0
- package/bundled-types/host-tests/helpers/realm-server-mock/types.ts +24 -0
- package/bundled-types/host-tests/helpers/recent-files-cards.ts +86 -0
- package/bundled-types/host-tests/helpers/render-component.ts +40 -0
- package/bundled-types/host-tests/helpers/setup-qunit.js +164 -0
- package/bundled-types/host-tests/helpers/setup.ts +349 -0
- package/bundled-types/host-tests/helpers/shard-warmup.ts +72 -0
- package/bundled-types/host-tests/helpers/stream.ts +60 -0
- package/bundled-types/host-tests/helpers/test-auth.ts +27 -0
- package/bundled-types/host-tests/helpers/test-realm-registry.ts +23 -0
- package/bundled-types/host-tests/helpers/test-realm-service-worker.ts +92 -0
- package/bundled-types/host-tests/helpers/uncaught-exceptions.ts +16 -0
- package/bundled-types/host-tests/helpers/visit-operator-mode.ts +39 -0
- package/bundled-types/host-types/@cardstack/host/index.d.ts +3 -0
- package/bundled-types/host-types/@joplin/turndown-plugin-gfm/index.d.ts +15 -0
- package/bundled-types/host-types/@sqlite.org/sqlite-wasm/index.d.ts +122 -0
- package/bundled-types/host-types/ember-click-outside/modifiers/on-click-outside.ts +16 -0
- package/bundled-types/host-types/ember-concurrency/helpers/perform.d.ts +3 -0
- package/bundled-types/host-types/ember-css-url/index.d.ts +15 -0
- package/bundled-types/host-types/ember-data/types/registries/model.d.ts +6 -0
- package/bundled-types/host-types/ember-elsewhere/from-elsewhere.d.ts +12 -0
- package/bundled-types/host-types/ember-elsewhere/to-elsewhere.d.ts +16 -0
- package/bundled-types/host-types/ember-focus-trap/index.d.ts +4 -0
- package/bundled-types/host-types/ember-keyboard/modifiers/on-key.d.ts +15 -0
- package/bundled-types/host-types/index.d.ts +6 -0
- package/bundled-types/local-types/eslint-js.d.ts +5 -0
- package/bundled-types/local-types/index.d.ts +115 -0
- package/bundled-types/local-types/marked-gfm-heading-id.d.ts +12 -0
- package/bundled-types/local-types/matrix-js-sdk/index.d.ts +11 -0
- package/bundled-types/local-types/package.json +13 -0
- package/bundled-types/shims/boxel-cli-shims.d.ts +10 -0
- package/dist/index.js +100 -100
- package/package.json +13 -7
- package/src/commands/parse.ts +277 -34
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
import type { HelperLike } from '@glint/template';
|
|
2
|
+
|
|
3
|
+
import type { DateLike, DateUnit, SerialOrigin } from '../utils/date-utils.ts';
|
|
4
|
+
import {
|
|
5
|
+
parseDateValue,
|
|
6
|
+
resolveEffectiveTimeZone,
|
|
7
|
+
} from '../utils/date-utils.ts';
|
|
8
|
+
import type { FormatDateTimeOptions } from './format-date-time.ts';
|
|
9
|
+
|
|
10
|
+
type RelativeSize = 'tiny' | 'short' | 'medium' | 'long';
|
|
11
|
+
type RelativeRound = 'floor' | 'ceil' | 'nearest';
|
|
12
|
+
type RelativeUnit =
|
|
13
|
+
| 'year'
|
|
14
|
+
| 'month'
|
|
15
|
+
| 'week'
|
|
16
|
+
| 'day'
|
|
17
|
+
| 'hour'
|
|
18
|
+
| 'minute'
|
|
19
|
+
| 'second';
|
|
20
|
+
|
|
21
|
+
interface ParseOptions {
|
|
22
|
+
serialOrigin?: SerialOrigin;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface FormatRelativeTimeOptions {
|
|
26
|
+
absoluteOptions?: FormatDateTimeOptions;
|
|
27
|
+
fallback?: string;
|
|
28
|
+
locale?: string;
|
|
29
|
+
now?: Date;
|
|
30
|
+
nowThresholdMs?: number;
|
|
31
|
+
numeric?: 'auto' | 'always';
|
|
32
|
+
parse?: ParseOptions;
|
|
33
|
+
precision?: number;
|
|
34
|
+
round?: RelativeRound;
|
|
35
|
+
size?: RelativeSize;
|
|
36
|
+
switchToAbsoluteAfterMs?: number;
|
|
37
|
+
timeZone?: string;
|
|
38
|
+
unit?: DateUnit;
|
|
39
|
+
unitCeil?: RelativeUnit;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const DAY_IN_MS = 24 * 60 * 60 * 1000;
|
|
43
|
+
const UNIT_IN_MS: Record<RelativeUnit, number> = {
|
|
44
|
+
year: 365 * DAY_IN_MS,
|
|
45
|
+
month: 30 * DAY_IN_MS,
|
|
46
|
+
week: 7 * DAY_IN_MS,
|
|
47
|
+
day: DAY_IN_MS,
|
|
48
|
+
hour: 60 * 60 * 1000,
|
|
49
|
+
minute: 60 * 1000,
|
|
50
|
+
second: 1000,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const UNIT_ORDER: RelativeUnit[] = [
|
|
54
|
+
'year',
|
|
55
|
+
'month',
|
|
56
|
+
'week',
|
|
57
|
+
'day',
|
|
58
|
+
'hour',
|
|
59
|
+
'minute',
|
|
60
|
+
'second',
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const DEFAULT_NOW_THRESHOLD = 30_000;
|
|
64
|
+
|
|
65
|
+
function formatRelativeTimeInternal(
|
|
66
|
+
value: DateLike | null | undefined,
|
|
67
|
+
options: FormatRelativeTimeOptions = {},
|
|
68
|
+
): string {
|
|
69
|
+
const parsed = parseDateValue(value, {
|
|
70
|
+
unit: options.unit,
|
|
71
|
+
serialOrigin: options.parse?.serialOrigin,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (!parsed) {
|
|
75
|
+
return options.fallback ?? '';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const now = options.now ?? new Date();
|
|
79
|
+
const diffMs = parsed.getTime() - now.getTime();
|
|
80
|
+
const absDiffMs = Math.abs(diffMs);
|
|
81
|
+
|
|
82
|
+
if (shouldUseAbsolute(absDiffMs, options.switchToAbsoluteAfterMs)) {
|
|
83
|
+
const effectiveTimeZone = resolveEffectiveTimeZone(options.timeZone);
|
|
84
|
+
const absoluteOptions: FormatDateTimeOptions = {
|
|
85
|
+
locale: options.locale,
|
|
86
|
+
timeZone: effectiveTimeZone,
|
|
87
|
+
...options.absoluteOptions,
|
|
88
|
+
};
|
|
89
|
+
// Avoid runtime circular import by formatting the absolute date locally
|
|
90
|
+
// with Intl.DateTimeFormat using the provided locale/timeZone. We keep
|
|
91
|
+
// this simple because absoluteOptions coming from callers (via
|
|
92
|
+
// formatDateTime) are typically just locale/timeZone in our usage.
|
|
93
|
+
return formatAbsoluteWithIntl(parsed, absoluteOptions);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const nowThreshold = options.nowThresholdMs ?? DEFAULT_NOW_THRESHOLD;
|
|
97
|
+
if (absDiffMs <= nowThreshold) {
|
|
98
|
+
return formatNow(options);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const selection = selectRelativeUnit(absDiffMs, options);
|
|
102
|
+
const size = options.size ?? 'medium';
|
|
103
|
+
|
|
104
|
+
// Use 'long' style for month/year units even when size is 'short' so
|
|
105
|
+
// larger calendar spans are spelled out (e.g. "2 months ago") instead of
|
|
106
|
+
// abbreviated (e.g. "2 mo. ago"). For other units, use the resolved style
|
|
107
|
+
// based on the requested size.
|
|
108
|
+
const styleForUnit: Intl.RelativeTimeFormatStyle | undefined =
|
|
109
|
+
size === 'short' &&
|
|
110
|
+
(selection.unit === 'month' || selection.unit === 'year')
|
|
111
|
+
? 'long'
|
|
112
|
+
: resolveRelativeStyle(size);
|
|
113
|
+
const rtf = new Intl.RelativeTimeFormat(options.locale ?? 'en-US', {
|
|
114
|
+
numeric: options.numeric ?? 'auto',
|
|
115
|
+
style: styleForUnit,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const signedValue = diffMs > 0 ? selection.value : -selection.value;
|
|
119
|
+
// If precision is greater than 1, build a multi-unit string like
|
|
120
|
+
// "2 months, 15 days ago". Default precision is 1 (current behavior).
|
|
121
|
+
const precision = Math.max(1, options.precision ?? 1);
|
|
122
|
+
|
|
123
|
+
// If tiny size requested and precision is 1, return compact single-unit.
|
|
124
|
+
// If precision > 1 and size is tiny, fall through to multi-unit builder
|
|
125
|
+
// which will produce a compact tiny multi-unit using buildTinyMulti.
|
|
126
|
+
if (size === 'tiny' && precision === 1) {
|
|
127
|
+
return formatTiny(selection.value, selection.unit, diffMs > 0);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (precision === 1) {
|
|
131
|
+
return rtf.format(signedValue, selection.unit);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return buildMultiUnitRelativeString(
|
|
135
|
+
absDiffMs,
|
|
136
|
+
diffMs > 0,
|
|
137
|
+
selection.unit,
|
|
138
|
+
precision,
|
|
139
|
+
options,
|
|
140
|
+
styleForUnit,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function buildMultiUnitRelativeString(
|
|
145
|
+
absDiffMs: number,
|
|
146
|
+
isFuture: boolean,
|
|
147
|
+
baseUnit: RelativeUnit,
|
|
148
|
+
precision: number,
|
|
149
|
+
options: FormatRelativeTimeOptions,
|
|
150
|
+
styleForUnit: Intl.RelativeTimeFormatStyle,
|
|
151
|
+
): string {
|
|
152
|
+
const locale = options.locale ?? 'en-US';
|
|
153
|
+
const roundMode = options.round ?? 'floor';
|
|
154
|
+
const roundModeLocal = roundMode;
|
|
155
|
+
|
|
156
|
+
// When showing multiple units, prefer predictable numeric forms.
|
|
157
|
+
// Respect explicit caller choice if provided.
|
|
158
|
+
const numericOption: 'auto' | 'always' =
|
|
159
|
+
options.numeric ?? (precision > 1 ? 'always' : 'auto');
|
|
160
|
+
|
|
161
|
+
// Start from the base unit (as selected by thresholds) and decompose the
|
|
162
|
+
// remainder into smaller units greedily.
|
|
163
|
+
const units: { unit: RelativeUnit; value: number }[] = [];
|
|
164
|
+
let remainderMs = absDiffMs;
|
|
165
|
+
|
|
166
|
+
// For the base unit, prefer the rounded value used by the selector to
|
|
167
|
+
// keep behaviour consistent.
|
|
168
|
+
const startIndex = UNIT_ORDER.indexOf(baseUnit);
|
|
169
|
+
const firstValue = Math.max(
|
|
170
|
+
applyRound(absDiffMs / UNIT_IN_MS[baseUnit], roundModeLocal),
|
|
171
|
+
1,
|
|
172
|
+
);
|
|
173
|
+
units.push({ unit: baseUnit, value: firstValue });
|
|
174
|
+
remainderMs = Math.max(0, remainderMs - firstValue * UNIT_IN_MS[baseUnit]);
|
|
175
|
+
|
|
176
|
+
// Collect subsequent smaller units until we have enough or run out.
|
|
177
|
+
for (
|
|
178
|
+
let i = startIndex + 1;
|
|
179
|
+
i < UNIT_ORDER.length && units.length < precision;
|
|
180
|
+
i++
|
|
181
|
+
) {
|
|
182
|
+
const u = UNIT_ORDER[i] as RelativeUnit;
|
|
183
|
+
// Prefer days over weeks in multi-unit output to match spec:
|
|
184
|
+
// e.g. "2 months, 15 days" rather than "2 months, 2 weeks".
|
|
185
|
+
if (u === 'week') {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
const raw = Math.floor(remainderMs / UNIT_IN_MS[u]);
|
|
189
|
+
if (raw > 0) {
|
|
190
|
+
units.push({ unit: u, value: raw });
|
|
191
|
+
remainderMs -= raw * UNIT_IN_MS[u];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// If size is tiny, provide a compact multi-unit representation using short
|
|
196
|
+
// labels (e.g. "+2d, 10h") so precision+tiny works.
|
|
197
|
+
if ((options.size ?? 'medium') === 'tiny') {
|
|
198
|
+
return buildTinyMulti(units, isFuture);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Build localized component strings for each unit while preserving locale
|
|
202
|
+
// ordering of number/unit (use formatToParts to respect locale rules but
|
|
203
|
+
// strip only detected directional words like "ago"/"in").
|
|
204
|
+
|
|
205
|
+
const rtfForParts = new Intl.RelativeTimeFormat(locale, {
|
|
206
|
+
numeric: numericOption,
|
|
207
|
+
style: styleForUnit,
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Detect directional literals/position for both past and future so we can
|
|
211
|
+
// render the correct direction and strip only those literal tokens from
|
|
212
|
+
// unit components.
|
|
213
|
+
const directionInfo = detectDirectionForLocale(rtfForParts, baseUnit);
|
|
214
|
+
|
|
215
|
+
const components = units.map((u) =>
|
|
216
|
+
formatUnitWithLocale(
|
|
217
|
+
u.value,
|
|
218
|
+
u.unit,
|
|
219
|
+
rtfForParts,
|
|
220
|
+
locale,
|
|
221
|
+
isFuture,
|
|
222
|
+
directionInfo,
|
|
223
|
+
),
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
// Use the appropriate direction info based on whether this is future or past.
|
|
227
|
+
const dir = isFuture ? directionInfo.future : directionInfo.past;
|
|
228
|
+
|
|
229
|
+
const joined = components.join(', ');
|
|
230
|
+
|
|
231
|
+
// Compose by splicing multi-unit into a localized single-unit template.
|
|
232
|
+
// This preserves locale-specific direction words ("ago"/"in"/"hace") and ordering.
|
|
233
|
+
try {
|
|
234
|
+
const unitOne = formatUnitWithLocale(
|
|
235
|
+
1,
|
|
236
|
+
baseUnit,
|
|
237
|
+
rtfForParts,
|
|
238
|
+
locale,
|
|
239
|
+
isFuture,
|
|
240
|
+
directionInfo,
|
|
241
|
+
);
|
|
242
|
+
const template = rtfForParts.format(isFuture ? 1 : -1, baseUnit);
|
|
243
|
+
if (template.includes(unitOne)) {
|
|
244
|
+
// Replace the first occurrence only; keep any surrounding spaces intact.
|
|
245
|
+
const esc = unitOne.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
246
|
+
const result = template.replace(new RegExp(esc), joined).trim();
|
|
247
|
+
if (result) {
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
} catch {
|
|
252
|
+
// fall through if anything unexpected happens
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (dir.position === 'prefix' && dir.text) {
|
|
256
|
+
return `${dir.text} ${joined}`.trim();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (dir.position === 'suffix' && dir.text) {
|
|
260
|
+
return `${joined} ${dir.text}`.trim();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Locale-safe fallback: synthesize direction using formatToParts
|
|
264
|
+
// without hardcoding English tokens. Filter out unit tokens to avoid
|
|
265
|
+
// tails like "second ago".
|
|
266
|
+
try {
|
|
267
|
+
const parts = rtfForParts.formatToParts(isFuture ? 1 : -1, 'second');
|
|
268
|
+
const firstSig = parts.findIndex(
|
|
269
|
+
(p) => p.type === 'integer' || p.type === 'unit',
|
|
270
|
+
);
|
|
271
|
+
const lastSig = parts
|
|
272
|
+
.map((p, idx) => ({ p, idx }))
|
|
273
|
+
.filter(({ p }) => p.type === 'integer' || p.type === 'unit')
|
|
274
|
+
.map(({ idx }) => idx)
|
|
275
|
+
.pop();
|
|
276
|
+
|
|
277
|
+
// Build the set of localized unit tokens we must ignore if they appear
|
|
278
|
+
// as lettered literals in some engines/polyfills (e.g., "second").
|
|
279
|
+
const unitTokens = new Set<string>(
|
|
280
|
+
parts
|
|
281
|
+
.filter(
|
|
282
|
+
(p) =>
|
|
283
|
+
p.type === 'unit' ||
|
|
284
|
+
(p.type === 'literal' && /\p{Letter}/u.test(p.value)),
|
|
285
|
+
)
|
|
286
|
+
.map((p) => p.value.trim().toLowerCase())
|
|
287
|
+
.filter(Boolean),
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
const literalLetters = (arr: Intl.RelativeTimeFormatPart[] = []) => {
|
|
291
|
+
const words = arr
|
|
292
|
+
.filter((p) => p.type === 'literal' && /\p{Letter}/u.test(p.value))
|
|
293
|
+
.map((p) => p.value.trim())
|
|
294
|
+
.filter(Boolean)
|
|
295
|
+
// Drop any token that matches the unit word, e.g., "second"
|
|
296
|
+
.filter((w) => !unitTokens.has(w.toLowerCase()));
|
|
297
|
+
return Array.from(new Set(words)).join(' ').trim();
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const prefix = literalLetters(parts.slice(0, Math.max(0, firstSig)));
|
|
301
|
+
const suffix = literalLetters(parts.slice((lastSig ?? -1) + 1));
|
|
302
|
+
|
|
303
|
+
if (prefix) {
|
|
304
|
+
return `${prefix} ${joined}`.trim();
|
|
305
|
+
}
|
|
306
|
+
if (suffix) {
|
|
307
|
+
return `${joined} ${suffix}`.trim();
|
|
308
|
+
}
|
|
309
|
+
} catch {
|
|
310
|
+
// ignore and fall through
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Final neutral fallback: return joined components without a direction word.
|
|
314
|
+
// (Better than forcing English "ago"/"in".)
|
|
315
|
+
return joined;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function formatUnitWithLocale(
|
|
319
|
+
value: number,
|
|
320
|
+
unit: RelativeUnit,
|
|
321
|
+
rtf: Intl.RelativeTimeFormat,
|
|
322
|
+
locale: string,
|
|
323
|
+
isFuture: boolean,
|
|
324
|
+
directionInfo: {
|
|
325
|
+
future: {
|
|
326
|
+
literals: string[];
|
|
327
|
+
position: 'prefix' | 'suffix' | 'none';
|
|
328
|
+
text: string;
|
|
329
|
+
};
|
|
330
|
+
past: {
|
|
331
|
+
literals: string[];
|
|
332
|
+
position: 'prefix' | 'suffix' | 'none';
|
|
333
|
+
text: string;
|
|
334
|
+
};
|
|
335
|
+
},
|
|
336
|
+
): string {
|
|
337
|
+
// Choose sign consistent with the intended direction so parts reflect the
|
|
338
|
+
// correct number/unit ordering for the locale variant.
|
|
339
|
+
const signedSample = isFuture ? value : -value;
|
|
340
|
+
const parts = rtf.formatToParts(signedSample as any, unit as any);
|
|
341
|
+
|
|
342
|
+
// Build formatted number using Intl.NumberFormat so grouping/locale are
|
|
343
|
+
// respected.
|
|
344
|
+
const nf = new Intl.NumberFormat(locale, { useGrouping: true });
|
|
345
|
+
const formattedNumber = nf.format(value);
|
|
346
|
+
|
|
347
|
+
// Fallback approach: format the full localized string and strip any
|
|
348
|
+
// directional token (prefix/suffix) discovered for this locale. This is
|
|
349
|
+
// more robust across different JS engines which may classify the unit as
|
|
350
|
+
// a 'unit' part or a 'literal'. Using the precomputed parts above we can
|
|
351
|
+
// still build a sane numeric formatting, but prefer the formatted full
|
|
352
|
+
// string to preserve complex locale-specific unit rendering.
|
|
353
|
+
try {
|
|
354
|
+
const full = rtf.format(signedSample as any, unit as any);
|
|
355
|
+
|
|
356
|
+
// Clean localized directional markers from formatted string.
|
|
357
|
+
// Some locales (like 'es-ES') may repeat "hace"/"en" per unit.
|
|
358
|
+
const cleanDirectionalMarkers = (text: string) => {
|
|
359
|
+
const tokens = [
|
|
360
|
+
directionInfo.past?.text,
|
|
361
|
+
directionInfo.future?.text,
|
|
362
|
+
'ago',
|
|
363
|
+
'in',
|
|
364
|
+
'hace',
|
|
365
|
+
'en',
|
|
366
|
+
].filter(Boolean) as string[];
|
|
367
|
+
|
|
368
|
+
let result = text.trim();
|
|
369
|
+
for (const t of tokens) {
|
|
370
|
+
const esc = t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
371
|
+
result = result
|
|
372
|
+
.replace(new RegExp(`^\\s*${esc}\\s*`, 'iu'), '')
|
|
373
|
+
.replace(new RegExp(`\\s*${esc}\\s*$`, 'iu'), '');
|
|
374
|
+
}
|
|
375
|
+
return result.trim();
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const cleaned = cleanDirectionalMarkers(full);
|
|
379
|
+
|
|
380
|
+
// If cleaning produced something non-empty, return it and
|
|
381
|
+
// DO NOT fall through to parts-based assembly (prevents duplication).
|
|
382
|
+
if (cleaned) {
|
|
383
|
+
return cleaned;
|
|
384
|
+
}
|
|
385
|
+
} catch (e) {
|
|
386
|
+
// Ignore and fall back to parts-based assembly below.
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Fallback to parts-based assembly if formatting/stripping above failed.
|
|
390
|
+
let sawNumber = false;
|
|
391
|
+
let sawUnit = false;
|
|
392
|
+
let result = '';
|
|
393
|
+
for (const p of parts) {
|
|
394
|
+
if (
|
|
395
|
+
p.type === 'integer' ||
|
|
396
|
+
p.type === 'fraction' ||
|
|
397
|
+
p.type === 'group' ||
|
|
398
|
+
p.type === 'decimal'
|
|
399
|
+
) {
|
|
400
|
+
if (!sawNumber) {
|
|
401
|
+
result += formattedNumber;
|
|
402
|
+
sawNumber = true;
|
|
403
|
+
}
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (p.type === 'unit' && !sawUnit) {
|
|
408
|
+
if (
|
|
409
|
+
result.length > 0 &&
|
|
410
|
+
!/\s$/.test(result) &&
|
|
411
|
+
!/^[\p{P}\p{S}]/u.test(p.value)
|
|
412
|
+
) {
|
|
413
|
+
result += ' ';
|
|
414
|
+
}
|
|
415
|
+
result += p.value;
|
|
416
|
+
sawUnit = true;
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (p.type === 'literal') {
|
|
421
|
+
// Drop lettered literals (likely direction words) here.
|
|
422
|
+
if (/\p{Letter}/u.test(p.value)) {
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
result += p.value;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (p.type === 'plusSign' || p.type === 'minusSign') {
|
|
429
|
+
result += p.value;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (!result) {
|
|
434
|
+
return `${formattedNumber} ${unit}${value === 1 ? '' : 's'}`;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
return result.trim();
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function detectDirectionForLocale(
|
|
441
|
+
rtf: Intl.RelativeTimeFormat,
|
|
442
|
+
unit: RelativeUnit,
|
|
443
|
+
): {
|
|
444
|
+
future: {
|
|
445
|
+
literals: string[];
|
|
446
|
+
position: 'prefix' | 'suffix' | 'none';
|
|
447
|
+
text: string;
|
|
448
|
+
};
|
|
449
|
+
past: {
|
|
450
|
+
literals: string[];
|
|
451
|
+
position: 'prefix' | 'suffix' | 'none';
|
|
452
|
+
text: string;
|
|
453
|
+
};
|
|
454
|
+
} {
|
|
455
|
+
// Helper to inspect a signed example and extract letter-only literal tokens
|
|
456
|
+
// and whether they appear before or after the main numeric/unit parts.
|
|
457
|
+
// IMPORTANT: Some JS engines/polyfills surface the localized unit word
|
|
458
|
+
// (e.g., "month", "day") as a literal instead of a 'unit' part.
|
|
459
|
+
// We detect and FILTER OUT those unit tokens so we only keep true
|
|
460
|
+
// direction words like "ago"/"in"/"hace"/"en".
|
|
461
|
+
function inspect(signedSample: number): {
|
|
462
|
+
literals: string[];
|
|
463
|
+
position: 'prefix' | 'suffix' | 'none';
|
|
464
|
+
text: string;
|
|
465
|
+
} {
|
|
466
|
+
const parts = rtf.formatToParts(signedSample as any, unit as any);
|
|
467
|
+
|
|
468
|
+
// Collect any visible unit tokens from parts (robust to odd engines).
|
|
469
|
+
const unitTokens = new Set<string>(
|
|
470
|
+
parts
|
|
471
|
+
.filter(
|
|
472
|
+
(p) =>
|
|
473
|
+
p.type === 'unit' ||
|
|
474
|
+
(p.type === 'literal' && /\p{Letter}/u.test(p.value)),
|
|
475
|
+
)
|
|
476
|
+
.map((p) => p.value.trim().toLowerCase())
|
|
477
|
+
.filter((v) => !!v),
|
|
478
|
+
);
|
|
479
|
+
|
|
480
|
+
const firstSignificant = parts.findIndex(
|
|
481
|
+
(p) => p.type === 'integer' || p.type === 'unit',
|
|
482
|
+
);
|
|
483
|
+
const lastSignificant = parts
|
|
484
|
+
.map((p, idx) => ({ p, idx }))
|
|
485
|
+
.filter(({ p }) => p.type === 'integer' || p.type === 'unit')
|
|
486
|
+
.map(({ idx }) => idx)
|
|
487
|
+
.pop();
|
|
488
|
+
|
|
489
|
+
if (firstSignificant === -1 || lastSignificant == null) {
|
|
490
|
+
return { position: 'none' as const, text: '', literals: [] as string[] };
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
const prefixLiterals: string[] = [];
|
|
494
|
+
const suffixLiterals: string[] = [];
|
|
495
|
+
|
|
496
|
+
parts.forEach((p, idx) => {
|
|
497
|
+
if (p.type === 'literal' && /\p{Letter}/u.test(p.value)) {
|
|
498
|
+
const raw = p.value.trim();
|
|
499
|
+
const val = raw;
|
|
500
|
+
const lower = val.toLowerCase();
|
|
501
|
+
// Filter out any literal that is actually the unit token
|
|
502
|
+
// (e.g., "month", "day") to avoid "month ago" / "day ago" tails.
|
|
503
|
+
if (unitTokens.has(lower)) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
if (idx < firstSignificant) {
|
|
507
|
+
prefixLiterals.push(val);
|
|
508
|
+
} else if (idx > (lastSignificant as number)) {
|
|
509
|
+
suffixLiterals.push(val);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
if (prefixLiterals.length === 0 && suffixLiterals.length === 0) {
|
|
515
|
+
return { position: 'none' as const, text: '', literals: [] as string[] };
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (prefixLiterals.length > 0) {
|
|
519
|
+
const text = prefixLiterals.join(' ').trim();
|
|
520
|
+
const literals = Array.from(new Set(prefixLiterals));
|
|
521
|
+
return { position: 'prefix', text, literals };
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const text = suffixLiterals.join(' ').trim();
|
|
525
|
+
const literals = Array.from(new Set(suffixLiterals));
|
|
526
|
+
return { position: 'suffix', text, literals };
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
const past = inspect(-1);
|
|
530
|
+
const future = inspect(1);
|
|
531
|
+
|
|
532
|
+
return { past, future };
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function buildTinyMulti(
|
|
536
|
+
units: { unit: RelativeUnit; value: number }[],
|
|
537
|
+
isFuture: boolean,
|
|
538
|
+
): string {
|
|
539
|
+
if (units.length === 0) {
|
|
540
|
+
return isFuture ? '+0s' : '0s';
|
|
541
|
+
}
|
|
542
|
+
const comps = units.map((u) => `${u.value}${tinyUnitLabel(u.unit)}`);
|
|
543
|
+
const prefix = isFuture ? '+' : '';
|
|
544
|
+
return `${prefix}${comps.join(', ')}`;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function shouldUseAbsolute(
|
|
548
|
+
absDiffMs: number,
|
|
549
|
+
thresholdMs: number | undefined,
|
|
550
|
+
): boolean {
|
|
551
|
+
if (thresholdMs == null) {
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
return absDiffMs >= thresholdMs;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function formatNow(options: FormatRelativeTimeOptions): string {
|
|
559
|
+
if ((options.size ?? 'medium') === 'tiny') {
|
|
560
|
+
return 'now';
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
const rtf = new Intl.RelativeTimeFormat(options.locale ?? 'en-US', {
|
|
564
|
+
numeric: options.numeric ?? 'auto',
|
|
565
|
+
style: resolveRelativeStyle(options.size ?? 'medium'),
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
return rtf.format(0, 'second');
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function selectRelativeUnit(
|
|
572
|
+
absDiffMs: number,
|
|
573
|
+
options: FormatRelativeTimeOptions,
|
|
574
|
+
): { unit: RelativeUnit; value: number } {
|
|
575
|
+
// Use human-friendly thresholds (inspired by Moment.js) so that
|
|
576
|
+
// durations read naturally: seconds, minutes, hours, days, months, years.
|
|
577
|
+
// Respect `unitCeil` by preventing selection of larger units when set.
|
|
578
|
+
const roundMode = options.round ?? 'floor';
|
|
579
|
+
const unitCeilIndex =
|
|
580
|
+
options.unitCeil && UNIT_ORDER.includes(options.unitCeil)
|
|
581
|
+
? UNIT_ORDER.indexOf(options.unitCeil)
|
|
582
|
+
: 0;
|
|
583
|
+
|
|
584
|
+
const seconds = absDiffMs / UNIT_IN_MS.second;
|
|
585
|
+
const minutes = absDiffMs / UNIT_IN_MS.minute;
|
|
586
|
+
const hours = absDiffMs / UNIT_IN_MS.hour;
|
|
587
|
+
const days = absDiffMs / UNIT_IN_MS.day;
|
|
588
|
+
const months = absDiffMs / UNIT_IN_MS.month; // month uses 30*DAY as defined
|
|
589
|
+
const years = absDiffMs / UNIT_IN_MS.year;
|
|
590
|
+
|
|
591
|
+
// Thresholds (tuned for human-friendly display):
|
|
592
|
+
// seconds < 45 -> seconds
|
|
593
|
+
// seconds < 90 -> 1 minute
|
|
594
|
+
// minutes < 45 -> minutes
|
|
595
|
+
// minutes < 90 -> 1 hour
|
|
596
|
+
// hours < 22 -> hours
|
|
597
|
+
// hours < 36 -> 1 day
|
|
598
|
+
// days < 45 -> days
|
|
599
|
+
// days < 345 -> months
|
|
600
|
+
// otherwise years
|
|
601
|
+
|
|
602
|
+
// Helper to ensure we don't pick a unit above unitCeil
|
|
603
|
+
const isAllowed = (unit: RelativeUnit) =>
|
|
604
|
+
UNIT_ORDER.indexOf(unit) >= unitCeilIndex;
|
|
605
|
+
|
|
606
|
+
// If a unitCeil is provided, prefer the largest allowed unit that is
|
|
607
|
+
// >= 1 (after rounding). This guarantees that when callers restrict to
|
|
608
|
+
// a smaller ceiling (e.g. 'minute') we still return a sensible value
|
|
609
|
+
// like '120 minutes ago' for a 2-hour span instead of falling back to
|
|
610
|
+
// seconds due to threshold rules.
|
|
611
|
+
if (options.unitCeil) {
|
|
612
|
+
const allowed = UNIT_ORDER.slice(unitCeilIndex);
|
|
613
|
+
for (const unit of allowed) {
|
|
614
|
+
const raw = absDiffMs / UNIT_IN_MS[unit];
|
|
615
|
+
if (unit !== 'second' && raw < 1) {
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
const rounded = applyRound(raw, roundMode);
|
|
619
|
+
if (rounded === 0 && unit !== 'second') {
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
return { unit, value: Math.max(rounded, 1) };
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
return { unit: 'second', value: 1 };
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
if (seconds < 45 && isAllowed('second')) {
|
|
629
|
+
return {
|
|
630
|
+
unit: 'second',
|
|
631
|
+
value: Math.max(applyRound(seconds, roundMode), 1),
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
if (seconds < 90 && isAllowed('minute')) {
|
|
636
|
+
return { unit: 'minute', value: 1 };
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
if (minutes < 45 && isAllowed('minute')) {
|
|
640
|
+
return {
|
|
641
|
+
unit: 'minute',
|
|
642
|
+
value: Math.max(applyRound(minutes, roundMode), 1),
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
if (minutes < 90 && isAllowed('hour')) {
|
|
647
|
+
return { unit: 'hour', value: 1 };
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
if (hours < 22 && isAllowed('hour')) {
|
|
651
|
+
return { unit: 'hour', value: Math.max(applyRound(hours, roundMode), 1) };
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
if (hours < 36 && isAllowed('day')) {
|
|
655
|
+
return { unit: 'day', value: 1 };
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (days < 45 && isAllowed('day')) {
|
|
659
|
+
return { unit: 'day', value: Math.max(applyRound(days, roundMode), 1) };
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (days < 345 && isAllowed('month')) {
|
|
663
|
+
return { unit: 'month', value: Math.max(applyRound(months, roundMode), 1) };
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (isAllowed('year')) {
|
|
667
|
+
return { unit: 'year', value: Math.max(applyRound(years, roundMode), 1) };
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// Fallback to seconds if nothing else matched / allowed
|
|
671
|
+
return { unit: 'second', value: 1 };
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function formatTiny(
|
|
675
|
+
value: number,
|
|
676
|
+
unit: RelativeUnit,
|
|
677
|
+
isFuture: boolean,
|
|
678
|
+
): string {
|
|
679
|
+
if (value <= 0) {
|
|
680
|
+
return 'now';
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
const label = tinyUnitLabel(unit);
|
|
684
|
+
const prefix = isFuture ? '+' : '';
|
|
685
|
+
return `${prefix}${value}${label}`;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function tinyUnitLabel(unit: RelativeUnit): string {
|
|
689
|
+
switch (unit) {
|
|
690
|
+
case 'year':
|
|
691
|
+
return 'y';
|
|
692
|
+
case 'month':
|
|
693
|
+
return 'mo';
|
|
694
|
+
case 'week':
|
|
695
|
+
return 'w';
|
|
696
|
+
case 'day':
|
|
697
|
+
return 'd';
|
|
698
|
+
case 'hour':
|
|
699
|
+
return 'h';
|
|
700
|
+
case 'minute':
|
|
701
|
+
return 'm';
|
|
702
|
+
case 'second':
|
|
703
|
+
return 's';
|
|
704
|
+
default:
|
|
705
|
+
return '';
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
function resolveRelativeStyle(
|
|
710
|
+
size: RelativeSize,
|
|
711
|
+
): Intl.RelativeTimeFormatStyle {
|
|
712
|
+
switch (size) {
|
|
713
|
+
case 'short':
|
|
714
|
+
return 'short';
|
|
715
|
+
case 'long':
|
|
716
|
+
return 'long';
|
|
717
|
+
case 'tiny':
|
|
718
|
+
return 'narrow';
|
|
719
|
+
case 'medium':
|
|
720
|
+
default:
|
|
721
|
+
return 'long';
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function applyRound(value: number, round: RelativeRound): number {
|
|
726
|
+
switch (round) {
|
|
727
|
+
case 'ceil':
|
|
728
|
+
return Math.ceil(value);
|
|
729
|
+
case 'nearest':
|
|
730
|
+
return Math.round(value);
|
|
731
|
+
case 'floor':
|
|
732
|
+
default:
|
|
733
|
+
return Math.floor(value);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
type FormatRelativeTimeHelperSignature = {
|
|
738
|
+
Args: {
|
|
739
|
+
Named: FormatRelativeTimeOptions;
|
|
740
|
+
Positional: [DateLike | null | undefined];
|
|
741
|
+
};
|
|
742
|
+
Return: string;
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
type FormatRelativeTimeHelper = HelperLike<FormatRelativeTimeHelperSignature> &
|
|
746
|
+
((
|
|
747
|
+
value: DateLike | null | undefined,
|
|
748
|
+
options?: FormatRelativeTimeOptions,
|
|
749
|
+
) => string);
|
|
750
|
+
|
|
751
|
+
export const formatRelativeTime =
|
|
752
|
+
formatRelativeTimeInternal as FormatRelativeTimeHelper;
|
|
753
|
+
|
|
754
|
+
export default formatRelativeTime;
|
|
755
|
+
|
|
756
|
+
function formatAbsoluteWithIntl(date: Date, options: FormatDateTimeOptions) {
|
|
757
|
+
const locale = options.locale ?? 'en-US';
|
|
758
|
+
const timeZone = resolveEffectiveTimeZone(options.timeZone);
|
|
759
|
+
// If the caller provided dateStyle/timeStyle use those so we match
|
|
760
|
+
// `formatDateTime` behavior (e.g. `dateStyle: 'long'` => full month name).
|
|
761
|
+
// Otherwise default to a sensible date-only representation.
|
|
762
|
+
const intlOpts: Intl.DateTimeFormatOptions = { timeZone };
|
|
763
|
+
|
|
764
|
+
if (options.dateStyle || options.timeStyle) {
|
|
765
|
+
if (options.dateStyle) {
|
|
766
|
+
intlOpts.dateStyle = options.dateStyle;
|
|
767
|
+
}
|
|
768
|
+
if (options.timeStyle) {
|
|
769
|
+
intlOpts.timeStyle = options.timeStyle;
|
|
770
|
+
}
|
|
771
|
+
} else {
|
|
772
|
+
// Default to date-only output when no explicit styles were requested.
|
|
773
|
+
intlOpts.year = 'numeric';
|
|
774
|
+
intlOpts.month = 'short';
|
|
775
|
+
intlOpts.day = 'numeric';
|
|
776
|
+
// Include time only when the caller explicitly asked for a datetime kind.
|
|
777
|
+
if ((options as any).kind === 'datetime') {
|
|
778
|
+
intlOpts.hour = 'numeric';
|
|
779
|
+
intlOpts.minute = '2-digit';
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
try {
|
|
784
|
+
return new Intl.DateTimeFormat(locale, intlOpts).format(date);
|
|
785
|
+
} catch {
|
|
786
|
+
// As a final fallback, use toISOString()
|
|
787
|
+
return date.toISOString();
|
|
788
|
+
}
|
|
789
|
+
}
|