@tanrei/web 0.0.0-stage → 0.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +58 -0
- package/README.md +9743 -2
- package/custom-elements.json +86072 -0
- package/dist/THIRD_PARTY_LICENSES.md +136 -0
- package/dist/accordion.css +812 -0
- package/dist/app-shell.css +493 -0
- package/dist/avatar.css +80 -0
- package/dist/breadcrumbs.css +511 -0
- package/dist/callout.css +65 -0
- package/dist/code.css +595 -0
- package/dist/components/accordion/accordion.d.ts +197 -0
- package/dist/components/accordion/accordion.js +763 -0
- package/dist/components/accordion/accordion.js.map +1 -0
- package/dist/components/app-bar/app-bar.d.ts +107 -0
- package/dist/components/app-bar/app-bar.js +295 -0
- package/dist/components/app-bar/app-bar.js.map +1 -0
- package/dist/components/app-bar/app-bar.styles.d.ts +12 -0
- package/dist/components/app-bar/app-bar.styles.js +223 -0
- package/dist/components/app-bar/app-bar.styles.js.map +1 -0
- package/dist/components/app-shell/app-shell.d.ts +220 -0
- package/dist/components/app-shell/app-shell.js +677 -0
- package/dist/components/app-shell/app-shell.js.map +1 -0
- package/dist/components/avatar/avatar.d.ts +162 -0
- package/dist/components/avatar/avatar.js +390 -0
- package/dist/components/avatar/avatar.js.map +1 -0
- package/dist/components/avatar/avatar.styles.d.ts +9 -0
- package/dist/components/avatar/avatar.styles.js +258 -0
- package/dist/components/avatar/avatar.styles.js.map +1 -0
- package/dist/components/badge/badge.d.ts +59 -0
- package/dist/components/badge/badge.js +176 -0
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/badge/badge.styles.d.ts +1 -0
- package/dist/components/badge/badge.styles.js +106 -0
- package/dist/components/badge/badge.styles.js.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.d.ts +207 -0
- package/dist/components/bottom-sheet/bottom-sheet.js +724 -0
- package/dist/components/bottom-sheet/bottom-sheet.js.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.styles.d.ts +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.styles.js +393 -0
- package/dist/components/bottom-sheet/bottom-sheet.styles.js.map +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +176 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +638 -0
- package/dist/components/breadcrumbs/breadcrumbs.js.map +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.styles.d.ts +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.styles.js +225 -0
- package/dist/components/breadcrumbs/breadcrumbs.styles.js.map +1 -0
- package/dist/components/button/button.d.ts +280 -0
- package/dist/components/button/button.js +530 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/button.styles.d.ts +20 -0
- package/dist/components/button/button.styles.js +328 -0
- package/dist/components/button/button.styles.js.map +1 -0
- package/dist/components/button-group/button-group.d.ts +124 -0
- package/dist/components/button-group/button-group.js +287 -0
- package/dist/components/button-group/button-group.js.map +1 -0
- package/dist/components/button-group/button-group.styles.d.ts +1 -0
- package/dist/components/button-group/button-group.styles.js +220 -0
- package/dist/components/button-group/button-group.styles.js.map +1 -0
- package/dist/components/button-with-menu/button-with-menu.d.ts +224 -0
- package/dist/components/button-with-menu/button-with-menu.js +635 -0
- package/dist/components/button-with-menu/button-with-menu.js.map +1 -0
- package/dist/components/button-with-menu/button-with-menu.styles.d.ts +15 -0
- package/dist/components/button-with-menu/button-with-menu.styles.js +418 -0
- package/dist/components/button-with-menu/button-with-menu.styles.js.map +1 -0
- package/dist/components/calendar/calendar.d.ts +380 -0
- package/dist/components/calendar/calendar.js +1619 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/calendar/calendar.styles.d.ts +11 -0
- package/dist/components/calendar/calendar.styles.js +412 -0
- package/dist/components/calendar/calendar.styles.js.map +1 -0
- package/dist/components/callout/callout.d.ts +157 -0
- package/dist/components/callout/callout.js +436 -0
- package/dist/components/callout/callout.js.map +1 -0
- package/dist/components/callout/callout.styles.d.ts +13 -0
- package/dist/components/callout/callout.styles.js +383 -0
- package/dist/components/callout/callout.styles.js.map +1 -0
- package/dist/components/card/card.d.ts +108 -0
- package/dist/components/card/card.js +235 -0
- package/dist/components/card/card.js.map +1 -0
- package/dist/components/card/card.styles.d.ts +9 -0
- package/dist/components/card/card.styles.js +170 -0
- package/dist/components/card/card.styles.js.map +1 -0
- package/dist/components/carousel/carousel-geometry.d.ts +178 -0
- package/dist/components/carousel/carousel-geometry.js +356 -0
- package/dist/components/carousel/carousel-geometry.js.map +1 -0
- package/dist/components/carousel/carousel.d.ts +401 -0
- package/dist/components/carousel/carousel.js +1352 -0
- package/dist/components/carousel/carousel.js.map +1 -0
- package/dist/components/carousel/carousel.styles.d.ts +4 -0
- package/dist/components/carousel/carousel.styles.js +475 -0
- package/dist/components/carousel/carousel.styles.js.map +1 -0
- package/dist/components/chat-composer/chat-composer.d.ts +482 -0
- package/dist/components/chat-composer/chat-composer.js +1374 -0
- package/dist/components/chat-composer/chat-composer.js.map +1 -0
- package/dist/components/chat-composer/chat-composer.styles.d.ts +9 -0
- package/dist/components/chat-composer/chat-composer.styles.js +308 -0
- package/dist/components/chat-composer/chat-composer.styles.js.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +135 -0
- package/dist/components/checkbox/checkbox.js +296 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +13 -0
- package/dist/components/checkbox/checkbox.styles.js +226 -0
- package/dist/components/checkbox/checkbox.styles.js.map +1 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts +199 -0
- package/dist/components/checkbox-group/checkbox-group.js +500 -0
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -0
- package/dist/components/chip/chip.d.ts +176 -0
- package/dist/components/chip/chip.js +376 -0
- package/dist/components/chip/chip.js.map +1 -0
- package/dist/components/chip/chip.styles.d.ts +10 -0
- package/dist/components/chip/chip.styles.js +465 -0
- package/dist/components/chip/chip.styles.js.map +1 -0
- package/dist/components/chip-field/chip-field.d.ts +315 -0
- package/dist/components/chip-field/chip-field.js +887 -0
- package/dist/components/chip-field/chip-field.js.map +1 -0
- package/dist/components/code-block/code-block.before.d.ts +2 -0
- package/dist/components/code-block/code-block.before.js +193 -0
- package/dist/components/code-block/code-block.before.js.map +1 -0
- package/dist/components/code-block/code-block.d.ts +268 -0
- package/dist/components/code-block/code-block.js +1009 -0
- package/dist/components/code-block/code-block.js.map +1 -0
- package/dist/components/code-block/code-block.light.d.ts +50 -0
- package/dist/components/code-block/code-block.light.js +287 -0
- package/dist/components/code-block/code-block.light.js.map +1 -0
- package/dist/components/code-block/code-block.lines.d.ts +49 -0
- package/dist/components/code-block/code-block.lines.js +75 -0
- package/dist/components/code-block/code-block.lines.js.map +1 -0
- package/dist/components/code-block/code-block.styles.d.ts +8 -0
- package/dist/components/code-block/code-block.styles.js +212 -0
- package/dist/components/code-block/code-block.styles.js.map +1 -0
- package/dist/components/color-field/color-field.d.ts +120 -0
- package/dist/components/color-field/color-field.js +182 -0
- package/dist/components/color-field/color-field.js.map +1 -0
- package/dist/components/color-input/color-input.d.ts +302 -0
- package/dist/components/color-input/color-input.js +748 -0
- package/dist/components/color-input/color-input.js.map +1 -0
- package/dist/components/color-input/color-input.styles.d.ts +22 -0
- package/dist/components/color-input/color-input.styles.js +373 -0
- package/dist/components/color-input/color-input.styles.js.map +1 -0
- package/dist/components/color-input/color-text.d.ts +48 -0
- package/dist/components/color-input/color-text.js +77 -0
- package/dist/components/color-input/color-text.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +387 -0
- package/dist/components/combobox/combobox.js +1108 -0
- package/dist/components/combobox/combobox.js.map +1 -0
- package/dist/components/combobox/combobox.styles.d.ts +26 -0
- package/dist/components/combobox/combobox.styles.js +497 -0
- package/dist/components/combobox/combobox.styles.js.map +1 -0
- package/dist/components/combobox-field/combobox-field.d.ts +159 -0
- package/dist/components/combobox-field/combobox-field.js +280 -0
- package/dist/components/combobox-field/combobox-field.js.map +1 -0
- package/dist/components/copy-button/copy-button.d.ts +112 -0
- package/dist/components/copy-button/copy-button.js +237 -0
- package/dist/components/copy-button/copy-button.js.map +1 -0
- package/dist/components/copy-button/copy-button.styles.d.ts +1 -0
- package/dist/components/copy-button/copy-button.styles.js +62 -0
- package/dist/components/copy-button/copy-button.styles.js.map +1 -0
- package/dist/components/date-time-picker/date-time-picker.d.ts +603 -0
- package/dist/components/date-time-picker/date-time-picker.js +2537 -0
- package/dist/components/date-time-picker/date-time-picker.js.map +1 -0
- package/dist/components/date-time-picker/date-time-picker.styles.d.ts +1 -0
- package/dist/components/date-time-picker/date-time-picker.styles.js +842 -0
- package/dist/components/date-time-picker/date-time-picker.styles.js.map +1 -0
- package/dist/components/description-list/description-list.d.ts +133 -0
- package/dist/components/description-list/description-list.js +395 -0
- package/dist/components/description-list/description-list.js.map +1 -0
- package/dist/components/dialog/dialog.d.ts +140 -0
- package/dist/components/dialog/dialog.js +440 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.styles.js +306 -0
- package/dist/components/dialog/dialog.styles.js.map +1 -0
- package/dist/components/divider/divider.d.ts +112 -0
- package/dist/components/divider/divider.js +331 -0
- package/dist/components/divider/divider.js.map +1 -0
- package/dist/components/divider/divider.styles.d.ts +6 -0
- package/dist/components/divider/divider.styles.js +183 -0
- package/dist/components/divider/divider.styles.js.map +1 -0
- package/dist/components/embedded-text-input/embedded-text-input.d.ts +246 -0
- package/dist/components/embedded-text-input/embedded-text-input.js +673 -0
- package/dist/components/embedded-text-input/embedded-text-input.js.map +1 -0
- package/dist/components/embedded-text-input/embedded-text-input.styles.d.ts +1 -0
- package/dist/components/embedded-text-input/embedded-text-input.styles.js +204 -0
- package/dist/components/embedded-text-input/embedded-text-input.styles.js.map +1 -0
- package/dist/components/empty-state/empty-state.d.ts +132 -0
- package/dist/components/empty-state/empty-state.js +333 -0
- package/dist/components/empty-state/empty-state.js.map +1 -0
- package/dist/components/empty-state/empty-state.styles.d.ts +11 -0
- package/dist/components/empty-state/empty-state.styles.js +218 -0
- package/dist/components/empty-state/empty-state.styles.js.map +1 -0
- package/dist/components/fab-menu/fab-menu.d.ts +240 -0
- package/dist/components/fab-menu/fab-menu.js +605 -0
- package/dist/components/fab-menu/fab-menu.js.map +1 -0
- package/dist/components/fab-menu/fab-menu.styles.d.ts +21 -0
- package/dist/components/fab-menu/fab-menu.styles.js +427 -0
- package/dist/components/fab-menu/fab-menu.styles.js.map +1 -0
- package/dist/components/field/field.d.ts +165 -0
- package/dist/components/field/field.js +399 -0
- package/dist/components/field/field.js.map +1 -0
- package/dist/components/field/field.styles.d.ts +2 -0
- package/dist/components/field/field.styles.js +177 -0
- package/dist/components/field/field.styles.js.map +1 -0
- package/dist/components/field-group/field-group.d.ts +122 -0
- package/dist/components/field-group/field-group.js +246 -0
- package/dist/components/field-group/field-group.js.map +1 -0
- package/dist/components/field-group/field-group.styles.d.ts +7 -0
- package/dist/components/field-group/field-group.styles.js +28 -0
- package/dist/components/field-group/field-group.styles.js.map +1 -0
- package/dist/components/figure/figure.d.ts +152 -0
- package/dist/components/figure/figure.js +435 -0
- package/dist/components/figure/figure.js.map +1 -0
- package/dist/components/file-item/file-item.d.ts +232 -0
- package/dist/components/file-item/file-item.js +665 -0
- package/dist/components/file-item/file-item.js.map +1 -0
- package/dist/components/file-item/file-item.styles.d.ts +2 -0
- package/dist/components/file-item/file-item.styles.js +582 -0
- package/dist/components/file-item/file-item.styles.js.map +1 -0
- package/dist/components/file-picker/file-picker.d.ts +221 -0
- package/dist/components/file-picker/file-picker.js +588 -0
- package/dist/components/file-picker/file-picker.js.map +1 -0
- package/dist/components/file-picker/file-picker.styles.d.ts +2 -0
- package/dist/components/file-picker/file-picker.styles.js +303 -0
- package/dist/components/file-picker/file-picker.styles.js.map +1 -0
- package/dist/components/file-upload/file-upload.d.ts +353 -0
- package/dist/components/file-upload/file-upload.js +939 -0
- package/dist/components/file-upload/file-upload.js.map +1 -0
- package/dist/components/file-upload/file-upload.styles.d.ts +1 -0
- package/dist/components/file-upload/file-upload.styles.js +91 -0
- package/dist/components/file-upload/file-upload.styles.js.map +1 -0
- package/dist/components/image-preview/image-preview.d.ts +336 -0
- package/dist/components/image-preview/image-preview.js +1510 -0
- package/dist/components/image-preview/image-preview.js.map +1 -0
- package/dist/components/image-preview/image-preview.styles.d.ts +1 -0
- package/dist/components/image-preview/image-preview.styles.js +418 -0
- package/dist/components/image-preview/image-preview.styles.js.map +1 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.d.ts +94 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.js +285 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.styles.d.ts +11 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.styles.js +155 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.styles.js.map +1 -0
- package/dist/components/link-card/link-card.d.ts +156 -0
- package/dist/components/link-card/link-card.js +713 -0
- package/dist/components/link-card/link-card.js.map +1 -0
- package/dist/components/list/list.d.ts +430 -0
- package/dist/components/list/list.js +1230 -0
- package/dist/components/list/list.js.map +1 -0
- package/dist/components/list/list.styles.d.ts +3 -0
- package/dist/components/list/list.styles.js +334 -0
- package/dist/components/list/list.styles.js.map +1 -0
- package/dist/components/loading-indicator/loading-indicator.d.ts +83 -0
- package/dist/components/loading-indicator/loading-indicator.js +195 -0
- package/dist/components/loading-indicator/loading-indicator.js.map +1 -0
- package/dist/components/loading-indicator/loading-indicator.styles.d.ts +6 -0
- package/dist/components/loading-indicator/loading-indicator.styles.js +124 -0
- package/dist/components/loading-indicator/loading-indicator.styles.js.map +1 -0
- package/dist/components/main-action-button/main-action-button.d.ts +95 -0
- package/dist/components/main-action-button/main-action-button.js +202 -0
- package/dist/components/main-action-button/main-action-button.js.map +1 -0
- package/dist/components/main-action-button/main-action-button.styles.d.ts +10 -0
- package/dist/components/main-action-button/main-action-button.styles.js +285 -0
- package/dist/components/main-action-button/main-action-button.styles.js.map +1 -0
- package/dist/components/menu/menu.d.ts +813 -0
- package/dist/components/menu/menu.js +2061 -0
- package/dist/components/menu/menu.js.map +1 -0
- package/dist/components/menu/menu.styles.d.ts +18 -0
- package/dist/components/menu/menu.styles.js +587 -0
- package/dist/components/menu/menu.styles.js.map +1 -0
- package/dist/components/menubar/menubar.d.ts +477 -0
- package/dist/components/menubar/menubar.js +1677 -0
- package/dist/components/menubar/menubar.js.map +1 -0
- package/dist/components/menubar/menubar.styles.d.ts +43 -0
- package/dist/components/menubar/menubar.styles.js +379 -0
- package/dist/components/menubar/menubar.styles.js.map +1 -0
- package/dist/components/navigation-bar/navigation-bar.d.ts +239 -0
- package/dist/components/navigation-bar/navigation-bar.js +544 -0
- package/dist/components/navigation-bar/navigation-bar.js.map +1 -0
- package/dist/components/navigation-bar/navigation-bar.styles.d.ts +21 -0
- package/dist/components/navigation-bar/navigation-bar.styles.js +320 -0
- package/dist/components/navigation-bar/navigation-bar.styles.js.map +1 -0
- package/dist/components/navigation-drawer/navigation-drawer.d.ts +627 -0
- package/dist/components/navigation-drawer/navigation-drawer.js +1917 -0
- package/dist/components/navigation-drawer/navigation-drawer.js.map +1 -0
- package/dist/components/navigation-drawer/navigation-drawer.styles.d.ts +40 -0
- package/dist/components/navigation-drawer/navigation-drawer.styles.js +934 -0
- package/dist/components/navigation-drawer/navigation-drawer.styles.js.map +1 -0
- package/dist/components/number-field/number-field.d.ts +147 -0
- package/dist/components/number-field/number-field.js +252 -0
- package/dist/components/number-field/number-field.js.map +1 -0
- package/dist/components/number-input/number-input.d.ts +347 -0
- package/dist/components/number-input/number-input.js +929 -0
- package/dist/components/number-input/number-input.js.map +1 -0
- package/dist/components/number-input/number-input.styles.d.ts +22 -0
- package/dist/components/number-input/number-input.styles.js +395 -0
- package/dist/components/number-input/number-input.styles.js.map +1 -0
- package/dist/components/number-input/number-text.d.ts +74 -0
- package/dist/components/number-input/number-text.js +230 -0
- package/dist/components/number-input/number-text.js.map +1 -0
- package/dist/components/one-time-code-field/one-time-code-field.d.ts +94 -0
- package/dist/components/one-time-code-field/one-time-code-field.js +135 -0
- package/dist/components/one-time-code-field/one-time-code-field.js.map +1 -0
- package/dist/components/one-time-code-input/code-text.d.ts +51 -0
- package/dist/components/one-time-code-input/code-text.js +145 -0
- package/dist/components/one-time-code-input/code-text.js.map +1 -0
- package/dist/components/one-time-code-input/one-time-code-input.d.ts +219 -0
- package/dist/components/one-time-code-input/one-time-code-input.js +710 -0
- package/dist/components/one-time-code-input/one-time-code-input.js.map +1 -0
- package/dist/components/one-time-code-input/one-time-code-input.styles.d.ts +8 -0
- package/dist/components/one-time-code-input/one-time-code-input.styles.js +323 -0
- package/dist/components/one-time-code-input/one-time-code-input.styles.js.map +1 -0
- package/dist/components/option/option.d.ts +51 -0
- package/dist/components/option/option.js +75 -0
- package/dist/components/option/option.js.map +1 -0
- package/dist/components/page-header/page-header.d.ts +97 -0
- package/dist/components/page-header/page-header.js +258 -0
- package/dist/components/page-header/page-header.js.map +1 -0
- package/dist/components/popover/popover.d.ts +217 -0
- package/dist/components/popover/popover.js +616 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/popover/popover.styles.d.ts +8 -0
- package/dist/components/popover/popover.styles.js +299 -0
- package/dist/components/popover/popover.styles.js.map +1 -0
- package/dist/components/progress-indicator/progress-indicator.d.ts +76 -0
- package/dist/components/progress-indicator/progress-indicator.js +165 -0
- package/dist/components/progress-indicator/progress-indicator.js.map +1 -0
- package/dist/components/progress-indicator/progress-indicator.styles.d.ts +7 -0
- package/dist/components/progress-indicator/progress-indicator.styles.js +271 -0
- package/dist/components/progress-indicator/progress-indicator.styles.js.map +1 -0
- package/dist/components/radio-button/radio-button.d.ts +149 -0
- package/dist/components/radio-button/radio-button.js +370 -0
- package/dist/components/radio-button/radio-button.js.map +1 -0
- package/dist/components/radio-button/radio-button.styles.d.ts +8 -0
- package/dist/components/radio-button/radio-button.styles.js +190 -0
- package/dist/components/radio-button/radio-button.styles.js.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +188 -0
- package/dist/components/radio-group/radio-group.js +380 -0
- package/dist/components/radio-group/radio-group.js.map +1 -0
- package/dist/components/search/search.d.ts +569 -0
- package/dist/components/search/search.js +1801 -0
- package/dist/components/search/search.js.map +1 -0
- package/dist/components/search/search.styles.d.ts +15 -0
- package/dist/components/search/search.styles.js +967 -0
- package/dist/components/search/search.styles.js.map +1 -0
- package/dist/components/segmented-button/segmented-button.d.ts +183 -0
- package/dist/components/segmented-button/segmented-button.js +483 -0
- package/dist/components/segmented-button/segmented-button.js.map +1 -0
- package/dist/components/segmented-button/segmented-button.styles.d.ts +19 -0
- package/dist/components/segmented-button/segmented-button.styles.js +400 -0
- package/dist/components/segmented-button/segmented-button.styles.js.map +1 -0
- package/dist/components/select/select.d.ts +259 -0
- package/dist/components/select/select.js +702 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/select/select.styles.d.ts +27 -0
- package/dist/components/select/select.styles.js +359 -0
- package/dist/components/select/select.styles.js.map +1 -0
- package/dist/components/select-field/select-field.d.ts +141 -0
- package/dist/components/select-field/select-field.js +234 -0
- package/dist/components/select-field/select-field.js.map +1 -0
- package/dist/components/side-sheet/side-sheet.d.ts +190 -0
- package/dist/components/side-sheet/side-sheet.js +592 -0
- package/dist/components/side-sheet/side-sheet.js.map +1 -0
- package/dist/components/side-sheet/side-sheet.styles.d.ts +9 -0
- package/dist/components/side-sheet/side-sheet.styles.js +352 -0
- package/dist/components/side-sheet/side-sheet.styles.js.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +157 -0
- package/dist/components/skeleton/skeleton.js +550 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/slider/slider.d.ts +235 -0
- package/dist/components/slider/slider.js +792 -0
- package/dist/components/slider/slider.js.map +1 -0
- package/dist/components/slider/slider.styles.d.ts +6 -0
- package/dist/components/slider/slider.styles.js +492 -0
- package/dist/components/slider/slider.styles.js.map +1 -0
- package/dist/components/slider-field/slider-field.d.ts +150 -0
- package/dist/components/slider-field/slider-field.js +269 -0
- package/dist/components/slider-field/slider-field.js.map +1 -0
- package/dist/components/snackbar/snackbar.d.ts +237 -0
- package/dist/components/snackbar/snackbar.js +607 -0
- package/dist/components/snackbar/snackbar.js.map +1 -0
- package/dist/components/snackbar/snackbar.styles.d.ts +10 -0
- package/dist/components/snackbar/snackbar.styles.js +510 -0
- package/dist/components/snackbar/snackbar.styles.js.map +1 -0
- package/dist/components/switch/switch.d.ts +161 -0
- package/dist/components/switch/switch.js +470 -0
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/switch/switch.styles.d.ts +3 -0
- package/dist/components/switch/switch.styles.js +440 -0
- package/dist/components/switch/switch.styles.js.map +1 -0
- package/dist/components/tab-view/tab-view.d.ts +303 -0
- package/dist/components/tab-view/tab-view.js +917 -0
- package/dist/components/tab-view/tab-view.js.map +1 -0
- package/dist/components/tab-view/tab-view.styles.d.ts +19 -0
- package/dist/components/tab-view/tab-view.styles.js +85 -0
- package/dist/components/tab-view/tab-view.styles.js.map +1 -0
- package/dist/components/table/table.d.ts +386 -0
- package/dist/components/table/table.js +1320 -0
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts +227 -0
- package/dist/components/table-of-contents/table-of-contents.js +963 -0
- package/dist/components/table-of-contents/table-of-contents.js.map +1 -0
- package/dist/components/table-of-contents/table-of-contents.styles.d.ts +1 -0
- package/dist/components/table-of-contents/table-of-contents.styles.js +243 -0
- package/dist/components/table-of-contents/table-of-contents.styles.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +800 -0
- package/dist/components/tabs/tabs.js +2183 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/tabs/tabs.styles.d.ts +47 -0
- package/dist/components/tabs/tabs.styles.js +595 -0
- package/dist/components/tabs/tabs.styles.js.map +1 -0
- package/dist/components/tag/tag.d.ts +77 -0
- package/dist/components/tag/tag.js +143 -0
- package/dist/components/tag/tag.js.map +1 -0
- package/dist/components/tag/tag.styles.d.ts +13 -0
- package/dist/components/tag/tag.styles.js +215 -0
- package/dist/components/tag/tag.styles.js.map +1 -0
- package/dist/components/tag-group/tag-group.d.ts +110 -0
- package/dist/components/tag-group/tag-group.js +298 -0
- package/dist/components/tag-group/tag-group.js.map +1 -0
- package/dist/components/tag-group/tag-group.styles.d.ts +8 -0
- package/dist/components/tag-group/tag-group.styles.js +66 -0
- package/dist/components/tag-group/tag-group.styles.js.map +1 -0
- package/dist/components/text-field/text-field.d.ts +159 -0
- package/dist/components/text-field/text-field.js +272 -0
- package/dist/components/text-field/text-field.js.map +1 -0
- package/dist/components/text-input/text-input-segments.d.ts +93 -0
- package/dist/components/text-input/text-input-segments.js +233 -0
- package/dist/components/text-input/text-input-segments.js.map +1 -0
- package/dist/components/text-input/text-input.d.ts +683 -0
- package/dist/components/text-input/text-input.js +2120 -0
- package/dist/components/text-input/text-input.js.map +1 -0
- package/dist/components/text-input/text-input.styles.d.ts +27 -0
- package/dist/components/text-input/text-input.styles.js +1071 -0
- package/dist/components/text-input/text-input.styles.js.map +1 -0
- package/dist/components/toolbar/toolbar.d.ts +123 -0
- package/dist/components/toolbar/toolbar.js +336 -0
- package/dist/components/toolbar/toolbar.js.map +1 -0
- package/dist/components/toolbar/toolbar.styles.d.ts +10 -0
- package/dist/components/toolbar/toolbar.styles.js +156 -0
- package/dist/components/toolbar/toolbar.styles.js.map +1 -0
- package/dist/components/tooltip/tooltip-placement.d.ts +22 -0
- package/dist/components/tooltip/tooltip-placement.js +15 -0
- package/dist/components/tooltip/tooltip-placement.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +267 -0
- package/dist/components/tooltip/tooltip.js +902 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/components/tooltip/tooltip.styles.d.ts +7 -0
- package/dist/components/tooltip/tooltip.styles.js +240 -0
- package/dist/components/tooltip/tooltip.styles.js.map +1 -0
- package/dist/components/tree-view/tree-view.d.ts +264 -0
- package/dist/components/tree-view/tree-view.js +1228 -0
- package/dist/components/tree-view/tree-view.js.map +1 -0
- package/dist/description-list.css +337 -0
- package/dist/empty-state.css +70 -0
- package/dist/figure.css +381 -0
- package/dist/generated/icon-sets.d.ts +9 -0
- package/dist/generated/icon-sets.js +18 -0
- package/dist/generated/icon-sets.js.map +1 -0
- package/dist/generated/words.d.ts +161 -0
- package/dist/generated/words.js +91 -0
- package/dist/generated/words.js.map +1 -0
- package/dist/highlight/grammars/css.d.ts +3 -0
- package/dist/highlight/grammars/css.js +56 -0
- package/dist/highlight/grammars/css.js.map +1 -0
- package/dist/highlight/grammars/dart.d.ts +3 -0
- package/dist/highlight/grammars/dart.js +53 -0
- package/dist/highlight/grammars/dart.js.map +1 -0
- package/dist/highlight/grammars/javascript.d.ts +4 -0
- package/dist/highlight/grammars/javascript.js +119 -0
- package/dist/highlight/grammars/javascript.js.map +1 -0
- package/dist/highlight/grammars/json.d.ts +3 -0
- package/dist/highlight/grammars/json.js +19 -0
- package/dist/highlight/grammars/json.js.map +1 -0
- package/dist/highlight/grammars/kotlin.d.ts +3 -0
- package/dist/highlight/grammars/kotlin.js +46 -0
- package/dist/highlight/grammars/kotlin.js.map +1 -0
- package/dist/highlight/grammars/markup.d.ts +3 -0
- package/dist/highlight/grammars/markup.js +45 -0
- package/dist/highlight/grammars/markup.js.map +1 -0
- package/dist/highlight/grammars/shared.d.ts +25 -0
- package/dist/highlight/grammars/shared.js +37 -0
- package/dist/highlight/grammars/shared.js.map +1 -0
- package/dist/highlight/grammars/shell.d.ts +3 -0
- package/dist/highlight/grammars/shell.js +48 -0
- package/dist/highlight/grammars/shell.js.map +1 -0
- package/dist/highlight/grammars/swift.d.ts +3 -0
- package/dist/highlight/grammars/swift.js +46 -0
- package/dist/highlight/grammars/swift.js.map +1 -0
- package/dist/highlight/grammars/typescript.d.ts +2 -0
- package/dist/highlight/grammars/typescript.js +5 -0
- package/dist/highlight/grammars/typescript.js.map +1 -0
- package/dist/highlight/index.d.ts +104 -0
- package/dist/highlight/index.js +331 -0
- package/dist/highlight/index.js.map +1 -0
- package/dist/icons.css +107 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +10 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/link-card.css +678 -0
- package/dist/link.css +728 -0
- package/dist/link.d.ts +21 -0
- package/dist/link.js +594 -0
- package/dist/link.js.map +1 -0
- package/dist/links/index.d.ts +136 -0
- package/dist/links/index.js +404 -0
- package/dist/links/index.js.map +1 -0
- package/dist/links/node/address.js +154 -0
- package/dist/links/node/cli.js +102 -0
- package/dist/links/node/fetcher.js +267 -0
- package/dist/links/node/head.js +278 -0
- package/dist/links/node/index.d.ts +164 -0
- package/dist/links/node/index.js +26 -0
- package/dist/links/node/links.js +275 -0
- package/dist/links/node/lock.js +86 -0
- package/dist/links/node/mark.js +71 -0
- package/dist/links/node/options.js +120 -0
- package/dist/links/node/pictures.js +265 -0
- package/dist/links/node/refresh.js +28 -0
- package/dist/menu.css +97 -0
- package/dist/menubar.css +69 -0
- package/dist/page-header.css +324 -0
- package/dist/pagination.css +410 -0
- package/dist/pagination.d.ts +6 -0
- package/dist/pagination.js +256 -0
- package/dist/pagination.js.map +1 -0
- package/dist/primitives/actions.d.ts +75 -0
- package/dist/primitives/actions.js +142 -0
- package/dist/primitives/actions.js.map +1 -0
- package/dist/primitives/after-click.d.ts +8 -0
- package/dist/primitives/after-click.js +21 -0
- package/dist/primitives/after-click.js.map +1 -0
- package/dist/primitives/anchored.d.ts +134 -0
- package/dist/primitives/anchored.js +425 -0
- package/dist/primitives/anchored.js.map +1 -0
- package/dist/primitives/arc.d.ts +13 -0
- package/dist/primitives/arc.js +49 -0
- package/dist/primitives/arc.js.map +1 -0
- package/dist/primitives/arrow.d.ts +47 -0
- package/dist/primitives/arrow.js +159 -0
- package/dist/primitives/arrow.js.map +1 -0
- package/dist/primitives/auto-height.d.ts +56 -0
- package/dist/primitives/auto-height.js +150 -0
- package/dist/primitives/auto-height.js.map +1 -0
- package/dist/primitives/autofocus.d.ts +11 -0
- package/dist/primitives/autofocus.js +26 -0
- package/dist/primitives/autofocus.js.map +1 -0
- package/dist/primitives/availability.d.ts +32 -0
- package/dist/primitives/availability.js +122 -0
- package/dist/primitives/availability.js.map +1 -0
- package/dist/primitives/axes.d.ts +45 -0
- package/dist/primitives/axes.js +72 -0
- package/dist/primitives/axes.js.map +1 -0
- package/dist/primitives/behavior.d.ts +14 -0
- package/dist/primitives/behavior.js +19 -0
- package/dist/primitives/behavior.js.map +1 -0
- package/dist/primitives/calendar-date.d.ts +79 -0
- package/dist/primitives/calendar-date.js +135 -0
- package/dist/primitives/calendar-date.js.map +1 -0
- package/dist/primitives/composed.d.ts +144 -0
- package/dist/primitives/composed.js +303 -0
- package/dist/primitives/composed.js.map +1 -0
- package/dist/primitives/default-button.d.ts +49 -0
- package/dist/primitives/default-button.js +270 -0
- package/dist/primitives/default-button.js.map +1 -0
- package/dist/primitives/description.d.ts +18 -0
- package/dist/primitives/description.js +18 -0
- package/dist/primitives/description.js.map +1 -0
- package/dist/primitives/destination.d.ts +259 -0
- package/dist/primitives/destination.js +651 -0
- package/dist/primitives/destination.js.map +1 -0
- package/dist/primitives/direction.d.ts +23 -0
- package/dist/primitives/direction.js +90 -0
- package/dist/primitives/direction.js.map +1 -0
- package/dist/primitives/disabled-while-focused.d.ts +46 -0
- package/dist/primitives/disabled-while-focused.js +126 -0
- package/dist/primitives/disabled-while-focused.js.map +1 -0
- package/dist/primitives/disclosure.d.ts +9 -0
- package/dist/primitives/disclosure.js +15 -0
- package/dist/primitives/disclosure.js.map +1 -0
- package/dist/primitives/dismiss.d.ts +88 -0
- package/dist/primitives/dismiss.js +232 -0
- package/dist/primitives/dismiss.js.map +1 -0
- package/dist/primitives/field-frame.d.ts +166 -0
- package/dist/primitives/field-frame.js +358 -0
- package/dist/primitives/field-frame.js.map +1 -0
- package/dist/primitives/field-group-frame.d.ts +59 -0
- package/dist/primitives/field-group-frame.js +174 -0
- package/dist/primitives/field-group-frame.js.map +1 -0
- package/dist/primitives/field-trigger.d.ts +117 -0
- package/dist/primitives/field-trigger.js +387 -0
- package/dist/primitives/field-trigger.js.map +1 -0
- package/dist/primitives/field.d.ts +186 -0
- package/dist/primitives/field.js +349 -0
- package/dist/primitives/field.js.map +1 -0
- package/dist/primitives/file-format.d.ts +23 -0
- package/dist/primitives/file-format.js +185 -0
- package/dist/primitives/file-format.js.map +1 -0
- package/dist/primitives/file-item-holder.d.ts +45 -0
- package/dist/primitives/file-item-holder.js +39 -0
- package/dist/primitives/file-item-holder.js.map +1 -0
- package/dist/primitives/focus-order.d.ts +11 -0
- package/dist/primitives/focus-order.js +11 -0
- package/dist/primitives/focus-order.js.map +1 -0
- package/dist/primitives/focus-ring.d.ts +76 -0
- package/dist/primitives/focus-ring.js +230 -0
- package/dist/primitives/focus-ring.js.map +1 -0
- package/dist/primitives/follow.d.ts +65 -0
- package/dist/primitives/follow.js +283 -0
- package/dist/primitives/follow.js.map +1 -0
- package/dist/primitives/form-disabled.d.ts +20 -0
- package/dist/primitives/form-disabled.js +46 -0
- package/dist/primitives/form-disabled.js.map +1 -0
- package/dist/primitives/form-says.d.ts +33 -0
- package/dist/primitives/form-says.js +45 -0
- package/dist/primitives/form-says.js.map +1 -0
- package/dist/primitives/forward.d.ts +13 -0
- package/dist/primitives/forward.js +28 -0
- package/dist/primitives/forward.js.map +1 -0
- package/dist/primitives/glyph-mirror.d.ts +77 -0
- package/dist/primitives/glyph-mirror.js +211 -0
- package/dist/primitives/glyph-mirror.js.map +1 -0
- package/dist/primitives/glyph-pending.d.ts +17 -0
- package/dist/primitives/glyph-pending.js +91 -0
- package/dist/primitives/glyph-pending.js.map +1 -0
- package/dist/primitives/glyph.d.ts +53 -0
- package/dist/primitives/glyph.js +161 -0
- package/dist/primitives/glyph.js.map +1 -0
- package/dist/primitives/group-item.d.ts +128 -0
- package/dist/primitives/group-item.js +334 -0
- package/dist/primitives/group-item.js.map +1 -0
- package/dist/primitives/hidden.d.ts +2 -0
- package/dist/primitives/hidden.js +23 -0
- package/dist/primitives/hidden.js.map +1 -0
- package/dist/primitives/host-aria.d.ts +8 -0
- package/dist/primitives/host-aria.js +18 -0
- package/dist/primitives/host-aria.js.map +1 -0
- package/dist/primitives/index.d.ts +59 -0
- package/dist/primitives/index.js +189 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/indicator-drag.d.ts +90 -0
- package/dist/primitives/indicator-drag.js +207 -0
- package/dist/primitives/indicator-drag.js.map +1 -0
- package/dist/primitives/interactive.d.ts +13 -0
- package/dist/primitives/interactive.js +67 -0
- package/dist/primitives/interactive.js.map +1 -0
- package/dist/primitives/item-row.d.ts +34 -0
- package/dist/primitives/item-row.js +76 -0
- package/dist/primitives/item-row.js.map +1 -0
- package/dist/primitives/item-update.d.ts +2 -0
- package/dist/primitives/item-update.js +12 -0
- package/dist/primitives/item-update.js.map +1 -0
- package/dist/primitives/kept-length.d.ts +34 -0
- package/dist/primitives/kept-length.js +154 -0
- package/dist/primitives/kept-length.js.map +1 -0
- package/dist/primitives/keyboard-convention.d.ts +30 -0
- package/dist/primitives/keyboard-convention.js +88 -0
- package/dist/primitives/keyboard-convention.js.map +1 -0
- package/dist/primitives/label-lines.d.ts +12 -0
- package/dist/primitives/label-lines.js +34 -0
- package/dist/primitives/label-lines.js.map +1 -0
- package/dist/primitives/layout-scale.d.ts +18 -0
- package/dist/primitives/layout-scale.js +35 -0
- package/dist/primitives/layout-scale.js.map +1 -0
- package/dist/primitives/link.d.ts +147 -0
- package/dist/primitives/link.js +204 -0
- package/dist/primitives/link.js.map +1 -0
- package/dist/primitives/locale-date.d.ts +132 -0
- package/dist/primitives/locale-date.js +508 -0
- package/dist/primitives/locale-date.js.map +1 -0
- package/dist/primitives/missing-value.d.ts +16 -0
- package/dist/primitives/missing-value.js +31 -0
- package/dist/primitives/missing-value.js.map +1 -0
- package/dist/primitives/modal.d.ts +38 -0
- package/dist/primitives/modal.js +175 -0
- package/dist/primitives/modal.js.map +1 -0
- package/dist/primitives/native-text.d.ts +51 -0
- package/dist/primitives/native-text.js +77 -0
- package/dist/primitives/native-text.js.map +1 -0
- package/dist/primitives/natural-height.d.ts +21 -0
- package/dist/primitives/natural-height.js +36 -0
- package/dist/primitives/natural-height.js.map +1 -0
- package/dist/primitives/option-list.d.ts +314 -0
- package/dist/primitives/option-list.js +1098 -0
- package/dist/primitives/option-list.js.map +1 -0
- package/dist/primitives/overlay-focus.d.ts +48 -0
- package/dist/primitives/overlay-focus.js +152 -0
- package/dist/primitives/overlay-focus.js.map +1 -0
- package/dist/primitives/placement.d.ts +131 -0
- package/dist/primitives/placement.js +144 -0
- package/dist/primitives/placement.js.map +1 -0
- package/dist/primitives/places.d.ts +44 -0
- package/dist/primitives/places.js +98 -0
- package/dist/primitives/places.js.map +1 -0
- package/dist/primitives/press.d.ts +90 -0
- package/dist/primitives/press.js +153 -0
- package/dist/primitives/press.js.map +1 -0
- package/dist/primitives/report.d.ts +17 -0
- package/dist/primitives/report.js +34 -0
- package/dist/primitives/report.js.map +1 -0
- package/dist/primitives/ripple.d.ts +40 -0
- package/dist/primitives/ripple.js +70 -0
- package/dist/primitives/ripple.js.map +1 -0
- package/dist/primitives/roving.d.ts +41 -0
- package/dist/primitives/roving.js +71 -0
- package/dist/primitives/roving.js.map +1 -0
- package/dist/primitives/selection.d.ts +134 -0
- package/dist/primitives/selection.js +287 -0
- package/dist/primitives/selection.js.map +1 -0
- package/dist/primitives/separation.d.ts +28 -0
- package/dist/primitives/separation.js +96 -0
- package/dist/primitives/separation.js.map +1 -0
- package/dist/primitives/shared-choice.d.ts +33 -0
- package/dist/primitives/shared-choice.js +110 -0
- package/dist/primitives/shared-choice.js.map +1 -0
- package/dist/primitives/sheet.d.ts +63 -0
- package/dist/primitives/sheet.js +139 -0
- package/dist/primitives/sheet.js.map +1 -0
- package/dist/primitives/sheets.d.ts +8 -0
- package/dist/primitives/sheets.js +96 -0
- package/dist/primitives/sheets.js.map +1 -0
- package/dist/primitives/states.d.ts +33 -0
- package/dist/primitives/states.js +30 -0
- package/dist/primitives/states.js.map +1 -0
- package/dist/primitives/system-watch.d.ts +9 -0
- package/dist/primitives/system-watch.js +29 -0
- package/dist/primitives/system-watch.js.map +1 -0
- package/dist/primitives/target.d.ts +21 -0
- package/dist/primitives/target.js +79 -0
- package/dist/primitives/target.js.map +1 -0
- package/dist/primitives/values.d.ts +6 -0
- package/dist/primitives/values.js +22 -0
- package/dist/primitives/values.js.map +1 -0
- package/dist/primitives/visibility.d.ts +12 -0
- package/dist/primitives/visibility.js +50 -0
- package/dist/primitives/visibility.js.map +1 -0
- package/dist/primitives/words.d.ts +81 -0
- package/dist/primitives/words.js +236 -0
- package/dist/primitives/words.js.map +1 -0
- package/dist/prose.css +1917 -0
- package/dist/registry.d.ts +182 -0
- package/dist/registry.js +2 -0
- package/dist/registry.js.map +1 -0
- package/dist/shape.css +21 -0
- package/dist/skeleton.css +428 -0
- package/dist/steps.css +231 -0
- package/dist/steps.d.ts +6 -0
- package/dist/steps.js +156 -0
- package/dist/steps.js.map +1 -0
- package/dist/styles/icons.d.ts +62 -0
- package/dist/styles/icons.js +237 -0
- package/dist/styles/icons.js.map +1 -0
- package/dist/styles/product-text.d.ts +66 -0
- package/dist/styles/product-text.js +114 -0
- package/dist/styles/product-text.js.map +1 -0
- package/dist/styles/registered-properties.d.ts +6 -0
- package/dist/styles/registered-properties.js +68 -0
- package/dist/styles/registered-properties.js.map +1 -0
- package/dist/styles/shape.d.ts +59 -0
- package/dist/styles/shape.js +95 -0
- package/dist/styles/shape.js.map +1 -0
- package/dist/systems/cupertino.css +8793 -0
- package/dist/systems/m3-expressive-like.css +8786 -0
- package/dist/systems/m3-like.css +8748 -0
- package/dist/table-of-contents.css +482 -0
- package/dist/table.css +902 -0
- package/dist/tanrei.bundle.js +26644 -0
- package/dist/tanrei.bundle.js.map +7 -0
- package/dist/text.css +104 -0
- package/dist/timeline.css +410 -0
- package/dist/timeline.d.ts +6 -0
- package/dist/timeline.js +176 -0
- package/dist/timeline.js.map +1 -0
- package/dist/tokens.css +8801 -0
- package/dist/tree-view.css +797 -0
- package/dist/words.d.ts +2 -0
- package/dist/words.js +6 -0
- package/dist/words.js.map +1 -0
- package/package.json +132 -3
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// resolveLinkData() and resolveSiteIcons() (REQUIREMENTS.md, LKD-14 to LKD-30), over the one fetcher, the one lock file
|
|
2
|
+
// and the one directory of pictures. The functions here take the fetcher's seam as their last argument; the public
|
|
3
|
+
// ones (index.js) are these with the seam fixed to PRODUCTION.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { isExternal } from '../index.js';
|
|
7
|
+
import { withoutWww } from './address.js';
|
|
8
|
+
import { readAddress } from './fetcher.js';
|
|
9
|
+
import { decodePage, fieldsOf, headIsComplete } from './head.js';
|
|
10
|
+
import { orderedLink, readLock, writeLock } from './lock.js';
|
|
11
|
+
import { readOptions, sayOnce } from './options.js';
|
|
12
|
+
import { groundFor, pngInsideIcon, readPngPixels, reencode, sizeIsKept, sniffPicture, storePicture, storedPictureIsWhole } from './pictures.js';
|
|
13
|
+
|
|
14
|
+
const NEEDS_IMAGE_STEP =
|
|
15
|
+
'pictures and site icons need the site\'s image step: nothing a destination serves is written until options.transform has decoded it and encoded it anew, so no picture and no icon was read. Give options.transform (and run the refresh command), or set options.pictures to "none"';
|
|
16
|
+
const REMOTE_PICTURES = 'options.pictures is "remote": pictures and icons stay at their destinations, and every reader\'s browser will ask those destinations for them';
|
|
17
|
+
|
|
18
|
+
const day = (date) => date.toISOString().slice(0, 10);
|
|
19
|
+
const sameWords = (a, b) => JSON.stringify(orderedLink({ ...a, read: undefined })) === JSON.stringify(orderedLink({ ...b, read: undefined }));
|
|
20
|
+
|
|
21
|
+
async function readPage(address, env) {
|
|
22
|
+
const { settings } = env;
|
|
23
|
+
const page = await readAddress(address, { kind: 'page', limit: settings.limits.markup, complete: headIsComplete }, { options: settings, internals: env.internals });
|
|
24
|
+
if (!page.ok) return page;
|
|
25
|
+
return { ok: true, url: page.url, fields: fieldsOf(decodePage(page.bytes, page.contentType), { from: page.url.href, asked: address, limits: settings.limits, iconSide: settings.iconSize }) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** LKD-18 to LKD-22 for a page's picture: its record for the lock file, or the reason it was dropped. */
|
|
29
|
+
async function keepImage(address, env) {
|
|
30
|
+
const { settings } = env;
|
|
31
|
+
const got = await readAddress(address, { kind: 'picture', limit: settings.limits.picture }, { options: settings, internals: env.internals });
|
|
32
|
+
if (!got.ok) return { reason: got.reason };
|
|
33
|
+
const found = sniffPicture(got.bytes);
|
|
34
|
+
if (!found) return { reason: 'not-a-picture' };
|
|
35
|
+
if (!sizeIsKept(found, settings.limits.pixels)) return { reason: 'picture-too-large' };
|
|
36
|
+
const made = await reencode(got.bytes, { type: found.type, width: found.width, height: found.height, role: 'image' }, { transform: settings.transform, pixels: settings.limits.pixels, limit: settings.limits.picture });
|
|
37
|
+
if (made.reason) return { reason: made.reason };
|
|
38
|
+
const { file, digest } = storePicture(made.bytes, made.found.extension, settings.pictureDirectory);
|
|
39
|
+
return { record: { file, digest, width: made.found.width, height: made.found.height, type: made.found.type } };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** LKD-29 and LKD-30: an origin's icon read, re-encoded as the small PNG and stored; its record, or the reason. */
|
|
43
|
+
async function keepIcon(address, env) {
|
|
44
|
+
const { settings } = env;
|
|
45
|
+
const got = await readAddress(address, { kind: 'icon', limit: settings.limits.icon }, { options: settings, internals: env.internals });
|
|
46
|
+
if (!got.ok) return { reason: got.reason };
|
|
47
|
+
const found = sniffPicture(got.bytes, { icon: true, side: settings.iconSize });
|
|
48
|
+
if (!found) return { reason: 'not-a-picture' };
|
|
49
|
+
if (!sizeIsKept(found, settings.limits.pixels)) return { reason: 'picture-too-large' };
|
|
50
|
+
// An icon file that holds its chosen picture as a PNG gives the image step that PNG; otherwise the file as it is.
|
|
51
|
+
const inner = found.type === 'image/x-icon' ? pngInsideIcon(got.bytes, found) : null;
|
|
52
|
+
const given = inner ?? got.bytes;
|
|
53
|
+
const described = inner ? sniffPicture(inner) : found;
|
|
54
|
+
const info = { type: described.type, width: described.width, height: described.height, role: 'siteIcon', size: settings.iconSize };
|
|
55
|
+
const make = async (extra) => {
|
|
56
|
+
const made = await reencode(given, { ...info, ...extra }, { transform: settings.transform, pixels: settings.limits.pixels, limit: settings.limits.icon });
|
|
57
|
+
if (made.reason) return made;
|
|
58
|
+
// LKD-30: a small PNG of the side asked for, and nothing else.
|
|
59
|
+
return made.found.type === 'image/png' && made.found.width === settings.iconSize && made.found.height === settings.iconSize ? made : { reason: 'image-step-failed' };
|
|
60
|
+
};
|
|
61
|
+
let made = await make({});
|
|
62
|
+
if (made.reason) return { reason: made.reason };
|
|
63
|
+
const pixels = readPngPixels(made.bytes);
|
|
64
|
+
const ground = pixels ? groundFor(pixels.rgba) : null;
|
|
65
|
+
if (ground) {
|
|
66
|
+
made = await make({ ground: settings.iconGround[ground] });
|
|
67
|
+
if (made.reason) return { reason: made.reason };
|
|
68
|
+
}
|
|
69
|
+
const { file, digest } = storePicture(made.bytes, 'png', settings.pictureDirectory);
|
|
70
|
+
return { record: { ok: true, file, digest, width: made.found.width, height: made.found.height, type: 'image/png' } };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const ICONS_BEING_READ = new Map();
|
|
74
|
+
const ICONS_READ_AGAIN = new Map();
|
|
75
|
+
|
|
76
|
+
/** A new run of the refresh command in the same process reads every icon again, once. */
|
|
77
|
+
export function beginRun(lock) {
|
|
78
|
+
ICONS_READ_AGAIN.delete(lock);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Makes sure the lock file has an entry for an origin's icon, reading it where the mode says so (LKD-29): once for an
|
|
83
|
+
* origin, whichever function asks first. `page` is a page of that origin whose head has just been read, where there
|
|
84
|
+
* is one; without it the page at the origin's root is read.
|
|
85
|
+
*/
|
|
86
|
+
function ensureIcon(origin, page, env) {
|
|
87
|
+
const { settings } = env;
|
|
88
|
+
const key = `${settings.lock}\n${origin}`;
|
|
89
|
+
const running = ICONS_BEING_READ.get(key);
|
|
90
|
+
if (running) return running;
|
|
91
|
+
const again = ICONS_READ_AGAIN.get(settings.lock) ?? ICONS_READ_AGAIN.set(settings.lock, new Set()).get(settings.lock);
|
|
92
|
+
const recorded = readLock(settings.lock).icons[origin];
|
|
93
|
+
const reads = settings.mode === 'refresh' ? !again.has(origin) : settings.mode === 'update' && !recorded;
|
|
94
|
+
if (!reads || settings.pictures === 'none') return Promise.resolve();
|
|
95
|
+
if (settings.pictures === 'store' && !settings.transform) {
|
|
96
|
+
sayOnce(settings, NEEDS_IMAGE_STEP);
|
|
97
|
+
return Promise.resolve();
|
|
98
|
+
}
|
|
99
|
+
const work = (async () => {
|
|
100
|
+
let candidate = page?.icon;
|
|
101
|
+
if (!page) {
|
|
102
|
+
const root = await readPage(`${origin}/`, env);
|
|
103
|
+
if (root.ok && withoutWww(root.url.hostname) === withoutWww(new URL(origin).hostname)) candidate = root.fields.icon;
|
|
104
|
+
}
|
|
105
|
+
const address = candidate ?? `${origin}/favicon.ico`;
|
|
106
|
+
let entry;
|
|
107
|
+
if (settings.pictures === 'remote') {
|
|
108
|
+
sayOnce(settings, REMOTE_PICTURES);
|
|
109
|
+
entry = { ok: true, remote: address };
|
|
110
|
+
} else {
|
|
111
|
+
const kept = await keepIcon(address, env);
|
|
112
|
+
entry = kept.record ?? { ok: false, reason: kept.reason };
|
|
113
|
+
}
|
|
114
|
+
again.add(origin);
|
|
115
|
+
writeLock(settings.lock, (data) => {
|
|
116
|
+
data.icons[origin] = entry;
|
|
117
|
+
});
|
|
118
|
+
})().finally(() => ICONS_BEING_READ.delete(key));
|
|
119
|
+
ICONS_BEING_READ.set(key, work);
|
|
120
|
+
return work;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** An icon's entry as an answer: `{ src, width, height, type }`, or nothing — and why, once, where that is a failure. */
|
|
124
|
+
function iconAnswer(origin, env, { saysMissing }) {
|
|
125
|
+
const { settings } = env;
|
|
126
|
+
const entry = readLock(settings.lock).icons[origin];
|
|
127
|
+
if (settings.pictures === 'none') return undefined;
|
|
128
|
+
if (!entry) {
|
|
129
|
+
if (saysMissing) sayOnce(settings, `${origin}: site icon: not-in-lock`);
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
if (!entry.ok) {
|
|
133
|
+
sayOnce(settings, `${origin}: site icon: ${entry.reason}`);
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
if (entry.remote !== undefined) return settings.pictures === 'remote' ? { src: entry.remote, width: 0, height: 0, type: '' } : undefined;
|
|
137
|
+
if (settings.pictures !== 'store') return undefined;
|
|
138
|
+
if (!storedPictureIsWhole(entry.file, entry.digest, settings.pictureDirectory)) {
|
|
139
|
+
sayOnce(settings, `${origin}: site icon: its file is missing from the picture directory, or is not the file that was recorded`); // LKD-26
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
const src = settings.iconOutput === 'data' ? `data:image/png;base64,${fs.readFileSync(path.join(settings.pictureDirectory, entry.file)).toString('base64')}` : settings.picturePath(entry.file);
|
|
143
|
+
return { src, width: entry.width, height: entry.height, type: entry.type };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function imageAnswer(href, record, env) {
|
|
147
|
+
const { settings } = env;
|
|
148
|
+
if (!record || settings.pictures === 'none') return undefined;
|
|
149
|
+
if (record.remote !== undefined) return settings.pictures === 'remote' ? { src: record.remote, width: 0, height: 0, type: '' } : undefined;
|
|
150
|
+
if (settings.pictures !== 'store') return undefined;
|
|
151
|
+
if (!storedPictureIsWhole(record.file, record.digest, settings.pictureDirectory)) {
|
|
152
|
+
sayOnce(settings, `${href}: picture: its file is missing from the picture directory, or is not the file that was recorded`); // LKD-26
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
return { src: settings.picturePath(record.file), width: record.width, height: record.height, type: record.type };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const originOf = (href) => {
|
|
159
|
+
try {
|
|
160
|
+
return new URL(href).origin;
|
|
161
|
+
} catch {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/** A link's entry as the result (LKD-27): the data with its pictures joined, or the address and the reason. */
|
|
167
|
+
function linkAnswer(href, entry, env) {
|
|
168
|
+
const { settings } = env;
|
|
169
|
+
if (!entry || !entry.ok) {
|
|
170
|
+
const reason = entry ? entry.reason : 'not-in-lock';
|
|
171
|
+
sayOnce(settings, `${href}: ${reason}`); // LKD-28: the address and the reason, and nothing a destination sent
|
|
172
|
+
return { ok: false, href, reason };
|
|
173
|
+
}
|
|
174
|
+
const data = { href, title: entry.title };
|
|
175
|
+
if (entry.description !== undefined) data.description = entry.description;
|
|
176
|
+
if (entry.siteName !== undefined) data.siteName = entry.siteName;
|
|
177
|
+
const image = imageAnswer(href, entry.image, env);
|
|
178
|
+
if (image) data.image = image;
|
|
179
|
+
const origin = originOf(href);
|
|
180
|
+
const siteIcon = origin ? iconAnswer(origin, env, { saysMissing: false }) : undefined;
|
|
181
|
+
if (siteIcon) data.siteIcon = siteIcon;
|
|
182
|
+
data.external = isExternal(href, { site: settings.site }) ? 'on' : 'off';
|
|
183
|
+
data.read = entry.read;
|
|
184
|
+
return { ok: true, data };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Reads one address anew: its entry for the lock file. The origin's icon is recorded beside it. */
|
|
188
|
+
async function readLink(href, env) {
|
|
189
|
+
const { settings } = env;
|
|
190
|
+
const page = await readPage(href, env);
|
|
191
|
+
if (!page.ok) return { ok: false, reason: page.reason };
|
|
192
|
+
const { fields } = page;
|
|
193
|
+
if (fields.title === undefined) return { ok: false, reason: 'no-title' };
|
|
194
|
+
const entry = { ok: true, title: fields.title, description: fields.description, siteName: fields.siteName, read: day(env.internals.now()) };
|
|
195
|
+
if (fields.image !== undefined && settings.pictures === 'remote') {
|
|
196
|
+
sayOnce(settings, REMOTE_PICTURES);
|
|
197
|
+
entry.image = { remote: fields.image };
|
|
198
|
+
} else if (fields.image !== undefined && settings.pictures === 'store') {
|
|
199
|
+
if (!settings.transform) sayOnce(settings, NEEDS_IMAGE_STEP);
|
|
200
|
+
else {
|
|
201
|
+
const kept = await keepImage(fields.image, env);
|
|
202
|
+
if (kept.record) entry.image = kept.record;
|
|
203
|
+
else sayOnce(settings, `${href}: picture: ${kept.reason}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const origin = originOf(href);
|
|
207
|
+
// The page's own icon is its origin's only while the page was read from that host: a forwarder's is its own.
|
|
208
|
+
const ofThisHost = withoutWww(page.url.hostname) === withoutWww(new URL(href).hostname);
|
|
209
|
+
if (origin) await ensureIcon(origin, ofThisHost ? { icon: fields.icon } : undefined, env);
|
|
210
|
+
return entry;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const LINKS_BEING_READ = new Map();
|
|
214
|
+
|
|
215
|
+
/** resolveLinkData(), with the fetcher's seam as an argument. */
|
|
216
|
+
export async function resolveLinkDataWith(href, options, internals) {
|
|
217
|
+
const settings = readOptions(options);
|
|
218
|
+
if (typeof href !== 'string') throw new TypeError('links: resolveLinkData(href, options) takes the address as a string');
|
|
219
|
+
const env = { settings, internals };
|
|
220
|
+
const recorded = readLock(settings.lock).links[href];
|
|
221
|
+
// LKD-24: frozen answers from the lock file alone; update reads only what has no entry; refresh reads again.
|
|
222
|
+
const reads = settings.mode === 'refresh' || (settings.mode === 'update' && !recorded);
|
|
223
|
+
if (!reads) return linkAnswer(href, recorded, env);
|
|
224
|
+
const key = `${settings.lock}\n${href}`;
|
|
225
|
+
let work = LINKS_BEING_READ.get(key);
|
|
226
|
+
if (!work) {
|
|
227
|
+
work = (async () => {
|
|
228
|
+
let entry;
|
|
229
|
+
try {
|
|
230
|
+
entry = await readLink(href, env);
|
|
231
|
+
} catch (error) {
|
|
232
|
+
// LKD-2: whatever a network or a destination did, it is an answer. What the site's own files do is not.
|
|
233
|
+
if (error instanceof TypeError && String(error.message).startsWith('links: ')) throw error;
|
|
234
|
+
entry = { ok: false, reason: 'unreachable' };
|
|
235
|
+
}
|
|
236
|
+
writeLock(settings.lock, (data) => {
|
|
237
|
+
// LKD-23: an address read again to the same words keeps the day it was first read, so the file does not change.
|
|
238
|
+
const before = data.links[href];
|
|
239
|
+
if (before?.ok && entry.ok && sameWords(before, entry)) entry.read = before.read;
|
|
240
|
+
data.links[href] = entry;
|
|
241
|
+
});
|
|
242
|
+
})().finally(() => LINKS_BEING_READ.delete(key));
|
|
243
|
+
LINKS_BEING_READ.set(key, work);
|
|
244
|
+
}
|
|
245
|
+
await work;
|
|
246
|
+
return linkAnswer(href, readLock(settings.lock).links[href], env);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** resolveSiteIcons(), with the fetcher's seam as an argument. */
|
|
250
|
+
export async function resolveSiteIconsWith(origins, options, internals) {
|
|
251
|
+
const settings = readOptions(options);
|
|
252
|
+
if (!Array.isArray(origins) || !origins.every((origin) => typeof origin === 'string')) throw new TypeError('links: resolveSiteIcons(origins, options) takes a list of origins ("https://example.org")');
|
|
253
|
+
const env = { settings, internals };
|
|
254
|
+
const wanted = [...new Set(origins.map((origin) => originOf(origin) ?? origin))];
|
|
255
|
+
const out = {};
|
|
256
|
+
await Promise.all(
|
|
257
|
+
wanted.map(async (origin) => {
|
|
258
|
+
if (!/^https:\/\//.test(origin)) {
|
|
259
|
+
sayOnce(settings, `${origin}: site icon: address-refused`);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
await ensureIcon(origin, undefined, env);
|
|
264
|
+
} catch (error) {
|
|
265
|
+
if (error instanceof TypeError && String(error.message).startsWith('links: ')) throw error;
|
|
266
|
+
writeLock(settings.lock, (data) => {
|
|
267
|
+
data.icons[origin] = { ok: false, reason: 'unreachable' };
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
const icon = iconAnswer(origin, env, { saysMissing: true });
|
|
271
|
+
if (icon) out[origin] = { src: icon.src, width: icon.width, height: icon.height };
|
|
272
|
+
}),
|
|
273
|
+
);
|
|
274
|
+
return Object.fromEntries(Object.keys(out).sort().map((origin) => [origin, out[origin]]));
|
|
275
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// The lock file (REQUIREMENTS.md, LKD-23 to LKD-26): everything the helper has read, in one file the site commits.
|
|
2
|
+
// Its entries and their keys are in a fixed order and nothing in it changes from one run to the next, so reading the
|
|
3
|
+
// same addresses twice writes the same bytes.
|
|
4
|
+
//
|
|
5
|
+
// { "version": 1,
|
|
6
|
+
// "links": { "<address asked about>": { "ok": true, "title", "description"?, "siteName"?, "image"?, "read" }
|
|
7
|
+
// | { "ok": false, "reason" } },
|
|
8
|
+
// "icons": { "<origin>": { "ok": true, "file", "digest", "width", "height", "type" }
|
|
9
|
+
// | { "ok": true, "remote" } | { "ok": false, "reason" } } }
|
|
10
|
+
//
|
|
11
|
+
// A stored picture is `{ "file", "digest", "width", "height", "type" }`; one left at its destination is `{ "remote" }`.
|
|
12
|
+
// A file's address is not recorded: it is the site's `picturePath` of the file's name, asked when an entry is answered.
|
|
13
|
+
import fs from 'node:fs';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
|
|
16
|
+
export const LOCK_VERSION = 1;
|
|
17
|
+
const LINK_KEYS = ['ok', 'reason', 'title', 'description', 'siteName', 'image', 'read'];
|
|
18
|
+
const ICON_KEYS = ['ok', 'reason', 'remote', 'file', 'digest', 'width', 'height', 'type'];
|
|
19
|
+
const PICTURE_KEYS = ['remote', 'file', 'digest', 'width', 'height', 'type'];
|
|
20
|
+
|
|
21
|
+
const ordered = (value, keys) => Object.fromEntries(keys.filter((key) => value[key] !== undefined).map((key) => [key, key === 'image' ? ordered(value[key], PICTURE_KEYS) : value[key]]));
|
|
22
|
+
/** A link's entry with its keys in the file's order: two entries are the same entry exactly when these are equal. */
|
|
23
|
+
export const orderedLink = (entry) => ordered(entry, LINK_KEYS);
|
|
24
|
+
const byKey = (entries, keys) =>
|
|
25
|
+
Object.fromEntries(
|
|
26
|
+
Object.keys(entries)
|
|
27
|
+
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
|
|
28
|
+
.map((key) => [key, ordered(entries[key], keys)]),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
/** The file's text for what was read: the same text for the same entries, whatever order they were read in. */
|
|
32
|
+
export function lockText(data) {
|
|
33
|
+
return `${JSON.stringify({ version: LOCK_VERSION, links: byKey(data.links, LINK_KEYS), icons: byKey(data.icons, ICON_KEYS) }, null, 2)}\n`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
37
|
+
|
|
38
|
+
function parse(text, file) {
|
|
39
|
+
let data;
|
|
40
|
+
try {
|
|
41
|
+
data = JSON.parse(text);
|
|
42
|
+
} catch {
|
|
43
|
+
data = null;
|
|
44
|
+
}
|
|
45
|
+
const entriesAreRead = (entries) => isRecord(entries) && Object.values(entries).every((entry) => isRecord(entry) && typeof entry.ok === 'boolean');
|
|
46
|
+
if (!isRecord(data) || data.version !== LOCK_VERSION || !entriesAreRead(data.links) || !entriesAreRead(data.icons)) {
|
|
47
|
+
// The lock file is the site's own, named by an option: one that cannot be read is an option that cannot be read.
|
|
48
|
+
throw new TypeError(`links: ${file} is not a lock file this version of the helper wrote (version ${LOCK_VERSION}); restore it, or delete it and run the refresh command`);
|
|
49
|
+
}
|
|
50
|
+
// Without a prototype, so that an address named like a property of every object is an address like any other.
|
|
51
|
+
return { links: Object.assign(Object.create(null), data.links), icons: Object.assign(Object.create(null), data.icons) };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const OPEN = new Map();
|
|
55
|
+
|
|
56
|
+
/** The lock file's entries as they are on disk now. Reading it writes nothing; a file that does not exist is empty. */
|
|
57
|
+
export function readLock(file) {
|
|
58
|
+
let text;
|
|
59
|
+
try {
|
|
60
|
+
text = fs.readFileSync(file, 'utf8');
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (error?.code !== 'ENOENT') throw new TypeError(`links: ${file} cannot be read (${error?.code ?? 'unknown'})`);
|
|
63
|
+
text = null;
|
|
64
|
+
}
|
|
65
|
+
const held = OPEN.get(file);
|
|
66
|
+
if (held && held.text === text) return held.data;
|
|
67
|
+
const data = text === null ? { links: Object.create(null), icons: Object.create(null) } : parse(text, file);
|
|
68
|
+
OPEN.set(file, { text, data });
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Changes the lock file: `change` is given the entries and edits them; the file is written — whole, under another
|
|
74
|
+
* name first — only when its text differs. Synchronous, so two addresses read at once cannot lose each other's entry.
|
|
75
|
+
*/
|
|
76
|
+
export function writeLock(file, change) {
|
|
77
|
+
const data = readLock(file);
|
|
78
|
+
change(data);
|
|
79
|
+
const text = lockText(data);
|
|
80
|
+
if (OPEN.get(file).text === text) return;
|
|
81
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
82
|
+
const draft = `${file}.${process.pid}.tmp`;
|
|
83
|
+
fs.writeFileSync(draft, text);
|
|
84
|
+
fs.renameSync(draft, file);
|
|
85
|
+
OPEN.set(file, { text, data });
|
|
86
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// markExternalLinks() (REQUIREMENTS.md, LKD-31): the marks of an external link, written where the page is made, so
|
|
2
|
+
// that nothing moves after the first paint. It walks the element tree the product's own renderer already has and
|
|
3
|
+
// parses nothing; it opens no connection and writes no file.
|
|
4
|
+
import { isExternal } from '../index.js';
|
|
5
|
+
|
|
6
|
+
const KEYS = new Set(['site', 'base', 'description', 'icons']);
|
|
7
|
+
const fail = (message) => {
|
|
8
|
+
throw new TypeError(`links: ${message}`);
|
|
9
|
+
};
|
|
10
|
+
/** A property under its attribute's name, or under the name an element tree gives the same attribute. */
|
|
11
|
+
const NAMES = {
|
|
12
|
+
'data-external': ['data-external', 'dataExternal'],
|
|
13
|
+
'aria-description': ['aria-description', 'ariaDescription'],
|
|
14
|
+
'aria-describedby': ['aria-describedby', 'ariaDescribedBy'],
|
|
15
|
+
download: ['download'],
|
|
16
|
+
class: ['class', 'className'],
|
|
17
|
+
};
|
|
18
|
+
const read = (properties, name) => NAMES[name].map((key) => properties[key]).find((value) => value !== undefined && value !== null && value !== false);
|
|
19
|
+
const words = (value) => (Array.isArray(value) ? value.join(' ') : String(value ?? '')).trim();
|
|
20
|
+
const SITE_ICON = 'tanrei-link-site-icon';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Marks every external anchor of a tree: `data-external="true"`, the description where the anchor has none, and the
|
|
24
|
+
* site's icon as its first child where one is recorded for its origin. An anchor that already carries `data-external`
|
|
25
|
+
* is left as it is. The tree is the one given, changed in place and returned.
|
|
26
|
+
*
|
|
27
|
+
* The tree is of elements `{ type: 'element', tagName, properties, children }`. What is written is written under the
|
|
28
|
+
* attributes' own names (`data-external`, `aria-description`, `class`, `referrerpolicy`).
|
|
29
|
+
*/
|
|
30
|
+
export function markExternalLinks(tree, options) {
|
|
31
|
+
if (typeof tree === 'string') fail('markExternalLinks(tree, options) walks a tree of elements and parses nothing: give it the tree your renderer has, not markup');
|
|
32
|
+
if (tree === null || typeof tree !== 'object') fail('markExternalLinks(tree, options) takes a tree of elements');
|
|
33
|
+
if (options === null || typeof options !== 'object') fail('markExternalLinks(tree, options) takes { site } at least');
|
|
34
|
+
for (const key of Object.keys(options)) if (!KEYS.has(key)) fail(`options.${key} is not an option of markExternalLinks`);
|
|
35
|
+
const { site, description, icons = {} } = options;
|
|
36
|
+
if (!Array.isArray(site) || site.length === 0 || !site.every((origin) => typeof origin === 'string')) fail('options.site is the list of the product\'s own origins, at least one');
|
|
37
|
+
if (options.base !== undefined && typeof options.base !== 'string') fail('options.base is the address of the page the tree is of');
|
|
38
|
+
if (description !== undefined && typeof description !== 'string') fail('options.description is the words that say a link leaves the site');
|
|
39
|
+
if (icons === null || typeof icons !== 'object') fail('options.icons is what resolveSiteIcons() answered');
|
|
40
|
+
// Where the page's own address is not known a path is not read, and is not external (isExternal()).
|
|
41
|
+
const { base } = options;
|
|
42
|
+
const visit = (node) => {
|
|
43
|
+
if (node === null || typeof node !== 'object') return;
|
|
44
|
+
if (node.type === 'element' && node.tagName === 'a') mark(node);
|
|
45
|
+
if (Array.isArray(node.children)) for (const child of node.children) visit(child);
|
|
46
|
+
};
|
|
47
|
+
const mark = (anchor) => {
|
|
48
|
+
const properties = (anchor.properties ??= {});
|
|
49
|
+
const href = properties.href;
|
|
50
|
+
if (typeof href !== 'string' || read(properties, 'data-external') !== undefined) return;
|
|
51
|
+
if (!isExternal(href, { base, site, download: read(properties, 'download') !== undefined })) return;
|
|
52
|
+
properties['data-external'] = 'true';
|
|
53
|
+
if (description && !words(read(properties, 'aria-description')) && !words(read(properties, 'aria-describedby'))) properties['aria-description'] = description;
|
|
54
|
+
let origin;
|
|
55
|
+
try {
|
|
56
|
+
origin = new URL(href, base).origin;
|
|
57
|
+
} catch {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const icon = Object.hasOwn(icons, origin) ? icons[origin] : undefined;
|
|
61
|
+
const children = (anchor.children ??= []);
|
|
62
|
+
const first = children[0];
|
|
63
|
+
const has = first?.type === 'element' && first.tagName === 'img' && words(read(first.properties ?? {}, 'class')).split(/\s+/).includes(SITE_ICON);
|
|
64
|
+
if (!icon || typeof icon.src !== 'string' || has) return;
|
|
65
|
+
const picture = { class: SITE_ICON, src: icon.src, alt: '', loading: 'lazy', decoding: 'async', referrerpolicy: 'no-referrer' };
|
|
66
|
+
if (icon.width > 0 && icon.height > 0) Object.assign(picture, { width: icon.width, height: icon.height });
|
|
67
|
+
children.unshift({ type: 'element', tagName: 'img', properties: picture, children: [] });
|
|
68
|
+
};
|
|
69
|
+
visit(tree);
|
|
70
|
+
return tree;
|
|
71
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// The options of the links helper, read once and strictly (REQUIREMENTS.md, LKD-2: the helper throws only for options
|
|
2
|
+
// it cannot read). A key that is not an option is refused too — so nothing can be handed to the fetcher under a name
|
|
3
|
+
// of its own, and a misspelled limit is not silently the default.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { DEFAULT_LIMITS } from './fetcher.js';
|
|
7
|
+
|
|
8
|
+
const KEYS = new Set([
|
|
9
|
+
'site',
|
|
10
|
+
'lock',
|
|
11
|
+
'mode',
|
|
12
|
+
'allow',
|
|
13
|
+
'deny',
|
|
14
|
+
'redirects',
|
|
15
|
+
'pictures',
|
|
16
|
+
'pictureDirectory',
|
|
17
|
+
'picturePath',
|
|
18
|
+
'transform',
|
|
19
|
+
'userAgent',
|
|
20
|
+
'limits',
|
|
21
|
+
'report',
|
|
22
|
+
'iconSize',
|
|
23
|
+
'iconOutput',
|
|
24
|
+
'iconGround',
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const fail = (message) => {
|
|
28
|
+
throw new TypeError(`links: ${message}`);
|
|
29
|
+
};
|
|
30
|
+
const hosts = (value, name) => {
|
|
31
|
+
if (value === undefined) return undefined;
|
|
32
|
+
if (!Array.isArray(value) || !value.every((host) => typeof host === 'string' && /^(\*\.)?[^\s/:*@]+$/.test(host))) fail(`options.${name} is a list of hosts ("example.com", "*.example.com")`);
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
const choice = (value, name, values) => {
|
|
36
|
+
if (value === undefined) return values[0];
|
|
37
|
+
if (!values.includes(value)) fail(`options.${name} is one of ${values.map((entry) => `"${entry}"`).join(', ')}`);
|
|
38
|
+
return value;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** How the build introduces itself where the options give no words: the package's own name and version. */
|
|
42
|
+
function ownName() {
|
|
43
|
+
try {
|
|
44
|
+
const manifest = JSON.parse(fs.readFileSync(new URL('../../../package.json', import.meta.url), 'utf8'));
|
|
45
|
+
return `${manifest.name}/${manifest.version} (links; reads a page's head where a site is built)`;
|
|
46
|
+
} catch {
|
|
47
|
+
return 'links (reads a page\'s head where a site is built)';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const toStandardError = (message) => {
|
|
52
|
+
process.stderr.write(`links: ${message}\n`);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** The options as the module uses them, or a TypeError that says which one cannot be read. */
|
|
56
|
+
export function readOptions(options) {
|
|
57
|
+
if (options === null || typeof options !== 'object' || Array.isArray(options)) fail('the options are an object: at least { site, lock }');
|
|
58
|
+
for (const key of Object.keys(options)) if (!KEYS.has(key)) fail(`options.${key} is not an option of the links helper`);
|
|
59
|
+
// The one `site` option (LKD-31): the entries isExternal() reads — an origin, a host, a host with a leading `*.`.
|
|
60
|
+
const site = options.site;
|
|
61
|
+
if (!Array.isArray(site) || site.length === 0 || !site.every((entry) => typeof entry === 'string' && entry.trim() !== '')) fail('options.site is the list of the product\'s own origins, at least one ("https://docs.example")');
|
|
62
|
+
if (typeof options.lock !== 'string' || options.lock === '') fail('options.lock is the path of the lock file (link-data.lock.json)');
|
|
63
|
+
const pictures = choice(options.pictures, 'pictures', ['store', 'remote', 'none']);
|
|
64
|
+
if (pictures === 'store' && (typeof options.pictureDirectory !== 'string' || options.pictureDirectory === '')) fail('options.pictureDirectory is where stored pictures are written; it is required while options.pictures is "store"');
|
|
65
|
+
if (options.pictureDirectory !== undefined && typeof options.pictureDirectory !== 'string') fail('options.pictureDirectory is a path');
|
|
66
|
+
for (const name of ['picturePath', 'transform', 'report']) if (options[name] !== undefined && typeof options[name] !== 'function') fail(`options.${name} is a function`);
|
|
67
|
+
if (options.userAgent !== undefined && (typeof options.userAgent !== 'string' || /[^\x20-\x7e]/.test(options.userAgent) || options.userAgent.trim() === '')) fail('options.userAgent is a line of printable ASCII');
|
|
68
|
+
const limits = { ...DEFAULT_LIMITS };
|
|
69
|
+
if (options.limits !== undefined) {
|
|
70
|
+
if (options.limits === null || typeof options.limits !== 'object') fail('options.limits is an object');
|
|
71
|
+
for (const [name, value] of Object.entries(options.limits)) {
|
|
72
|
+
if (!Object.hasOwn(DEFAULT_LIMITS, name)) fail(`options.limits.${name} is not a limit of the links helper`);
|
|
73
|
+
if (value === undefined) continue;
|
|
74
|
+
if (!Number.isFinite(value) || value < (name === 'redirects' ? 0 : 1) || !Number.isInteger(value)) fail(`options.limits.${name} is a whole number${name === 'redirects' ? ', 0 or more' : ' above 0'}`);
|
|
75
|
+
limits[name] = value;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const iconSize = options.iconSize ?? 32;
|
|
79
|
+
if (!Number.isInteger(iconSize) || iconSize < 1 || iconSize > 512) fail('options.iconSize is the side of a stored site icon in pixels, 1 to 512');
|
|
80
|
+
const ground = options.iconGround ?? {};
|
|
81
|
+
if (ground === null || typeof ground !== 'object' || Object.keys(ground).some((key) => key !== 'light' && key !== 'dark') || Object.values(ground).some((value) => typeof value !== 'string')) fail('options.iconGround is { light, dark }: the two plain grounds, as the image step reads a color');
|
|
82
|
+
const directory = options.pictureDirectory === undefined ? undefined : path.resolve(options.pictureDirectory);
|
|
83
|
+
return Object.freeze({
|
|
84
|
+
site: Object.freeze([...site]),
|
|
85
|
+
lock: path.resolve(options.lock),
|
|
86
|
+
mode: choice(options.mode, 'mode', ['frozen', 'update', 'refresh']),
|
|
87
|
+
allow: hosts(options.allow, 'allow'),
|
|
88
|
+
deny: hosts(options.deny, 'deny') ?? [],
|
|
89
|
+
redirects: hosts(options.redirects, 'redirects') ?? [],
|
|
90
|
+
pictures,
|
|
91
|
+
pictureDirectory: directory,
|
|
92
|
+
picturePath: options.picturePath ?? ((file) => `/${path.basename(directory ?? '')}/${file}`),
|
|
93
|
+
transform: options.transform,
|
|
94
|
+
userAgent: options.userAgent ?? ownName(),
|
|
95
|
+
limits: Object.freeze(limits),
|
|
96
|
+
report: options.report ?? toStandardError,
|
|
97
|
+
iconSize,
|
|
98
|
+
iconOutput: choice(options.iconOutput, 'iconOutput', ['file', 'data']),
|
|
99
|
+
iconGround: { light: ground.light ?? '#ffffff', dark: ground.dark ?? '#000000' },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const SAID = new WeakMap();
|
|
104
|
+
|
|
105
|
+
/** LKD-28: a line of the report, said once for each `report` function however often it is found again. */
|
|
106
|
+
export function sayOnce(settings, message) {
|
|
107
|
+
const said = SAID.get(settings.report) ?? SAID.set(settings.report, new Set()).get(settings.report);
|
|
108
|
+
if (said.has(message)) return;
|
|
109
|
+
said.add(message);
|
|
110
|
+
try {
|
|
111
|
+
settings.report(message);
|
|
112
|
+
} catch {
|
|
113
|
+
// a report that fails is not the helper's failure, and never a failed build
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** For the command a person runs, which reports each run anew. */
|
|
118
|
+
export function forgetWhatWasSaid(report) {
|
|
119
|
+
SAID.delete(report);
|
|
120
|
+
}
|