@prestack/thread-ui 0.0.1
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/CHANGELOG.md +348 -0
- package/dist/attach.d.ts +1 -0
- package/dist/attach.js +1 -0
- package/dist/ui/animations/anm_appear.d.ts +16 -0
- package/dist/ui/animations/anm_appear.js +10 -0
- package/dist/ui/animations/anm_blur_in.d.ts +22 -0
- package/dist/ui/animations/anm_blur_in.js +16 -0
- package/dist/ui/animations/anm_blur_out.d.ts +22 -0
- package/dist/ui/animations/anm_blur_out.js +16 -0
- package/dist/ui/animations/anm_dismiss.d.ts +22 -0
- package/dist/ui/animations/anm_dismiss.js +16 -0
- package/dist/ui/animations/anm_drop.d.ts +22 -0
- package/dist/ui/animations/anm_drop.js +16 -0
- package/dist/ui/animations/anm_fall.d.ts +22 -0
- package/dist/ui/animations/anm_fall.js +16 -0
- package/dist/ui/animations/anm_flash.d.ts +19 -0
- package/dist/ui/animations/anm_flash.js +16 -0
- package/dist/ui/animations/anm_glow.d.ts +16 -0
- package/dist/ui/animations/anm_glow.js +14 -0
- package/dist/ui/animations/anm_lift.d.ts +16 -0
- package/dist/ui/animations/anm_lift.js +14 -0
- package/dist/ui/animations/anm_nudge.d.ts +16 -0
- package/dist/ui/animations/anm_nudge.js +14 -0
- package/dist/ui/animations/anm_pop_in.d.ts +29 -0
- package/dist/ui/animations/anm_pop_in.js +20 -0
- package/dist/ui/animations/anm_pop_out.d.ts +29 -0
- package/dist/ui/animations/anm_pop_out.js +20 -0
- package/dist/ui/animations/anm_press.d.ts +19 -0
- package/dist/ui/animations/anm_press.js +10 -0
- package/dist/ui/animations/anm_pulse.d.ts +20 -0
- package/dist/ui/animations/anm_pulse.js +11 -0
- package/dist/ui/animations/anm_rise.d.ts +22 -0
- package/dist/ui/animations/anm_rise.js +16 -0
- package/dist/ui/animations/anm_shake.d.ts +23 -0
- package/dist/ui/animations/anm_shake.js +11 -0
- package/dist/ui/animations/anm_slide_in_left.d.ts +22 -0
- package/dist/ui/animations/anm_slide_in_left.js +16 -0
- package/dist/ui/animations/anm_slide_in_right.d.ts +22 -0
- package/dist/ui/animations/anm_slide_in_right.js +16 -0
- package/dist/ui/animations/anm_slide_out_left.d.ts +22 -0
- package/dist/ui/animations/anm_slide_out_left.js +16 -0
- package/dist/ui/animations/anm_slide_out_right.d.ts +22 -0
- package/dist/ui/animations/anm_slide_out_right.js +16 -0
- package/dist/ui/animations/anm_spin.d.ts +16 -0
- package/dist/ui/animations/anm_spin.js +10 -0
- package/dist/ui/animations/anm_swell.d.ts +16 -0
- package/dist/ui/animations/anm_swell.js +14 -0
- package/dist/ui/animations/anm_wobble.d.ts +27 -0
- package/dist/ui/animations/anm_wobble.js +22 -0
- package/dist/ui/animations/anm_zoom_in.d.ts +22 -0
- package/dist/ui/animations/anm_zoom_in.js +16 -0
- package/dist/ui/animations/anm_zoom_out.d.ts +22 -0
- package/dist/ui/animations/anm_zoom_out.js +16 -0
- package/dist/ui/animations.d.ts +59 -0
- package/dist/ui/animations.js +227 -0
- package/dist/ui/attach.d.ts +3 -0
- package/dist/ui/attach.js +497 -0
- package/dist/ui/charts.d.ts +32 -0
- package/dist/ui/charts.js +35 -0
- package/dist/ui/checked.d.ts +19 -0
- package/dist/ui/checked.js +3 -0
- package/dist/ui/collector.d.ts +32 -0
- package/dist/ui/collector.js +75 -0
- package/dist/ui/compositions.d.ts +21 -0
- package/dist/ui/compositions.js +305 -0
- package/dist/ui/consent.d.ts +22 -0
- package/dist/ui/consent.js +44 -0
- package/dist/ui/content.d.ts +9 -0
- package/dist/ui/content.js +11 -0
- package/dist/ui/contrast.d.ts +3 -0
- package/dist/ui/contrast.js +23 -0
- package/dist/ui/controls.d.ts +14 -0
- package/dist/ui/controls.js +2 -0
- package/dist/ui/disclosure.d.ts +14 -0
- package/dist/ui/disclosure.js +2 -0
- package/dist/ui/dismiss-layer.d.ts +14 -0
- package/dist/ui/dismiss-layer.js +66 -0
- package/dist/ui/door.d.ts +40 -0
- package/dist/ui/door.js +100 -0
- package/dist/ui/drag.d.ts +82 -0
- package/dist/ui/drag.js +212 -0
- package/dist/ui/elements/accordion.d.ts +12 -0
- package/dist/ui/elements/accordion.js +16 -0
- package/dist/ui/elements/accordion.works.d.ts +22 -0
- package/dist/ui/elements/accordion.works.js +44 -0
- package/dist/ui/elements/aspect-ratio.d.ts +10 -0
- package/dist/ui/elements/aspect-ratio.js +9 -0
- package/dist/ui/elements/aspect-ratio.works.d.ts +2 -0
- package/dist/ui/elements/aspect-ratio.works.js +3 -0
- package/dist/ui/elements/avatar.d.ts +11 -0
- package/dist/ui/elements/avatar.js +10 -0
- package/dist/ui/elements/avatar.works.d.ts +4 -0
- package/dist/ui/elements/avatar.works.js +16 -0
- package/dist/ui/elements/badge.d.ts +11 -0
- package/dist/ui/elements/badge.js +10 -0
- package/dist/ui/elements/badge.works.d.ts +5 -0
- package/dist/ui/elements/badge.works.js +6 -0
- package/dist/ui/elements/bars.d.ts +14 -0
- package/dist/ui/elements/bars.js +17 -0
- package/dist/ui/elements/bars.works.d.ts +12 -0
- package/dist/ui/elements/bars.works.js +20 -0
- package/dist/ui/elements/box.d.ts +12 -0
- package/dist/ui/elements/box.js +11 -0
- package/dist/ui/elements/breadcrumb.d.ts +10 -0
- package/dist/ui/elements/breadcrumb.js +12 -0
- package/dist/ui/elements/breadcrumb.works.d.ts +7 -0
- package/dist/ui/elements/breadcrumb.works.js +21 -0
- package/dist/ui/elements/button.d.ts +17 -0
- package/dist/ui/elements/button.js +16 -0
- package/dist/ui/elements/button.works.d.ts +17 -0
- package/dist/ui/elements/button.works.js +34 -0
- package/dist/ui/elements/column.d.ts +9 -0
- package/dist/ui/elements/column.js +8 -0
- package/dist/ui/elements/consent.d.ts +13 -0
- package/dist/ui/elements/consent.js +21 -0
- package/dist/ui/elements/consent.works.d.ts +41 -0
- package/dist/ui/elements/consent.works.js +79 -0
- package/dist/ui/elements/donut.d.ts +13 -0
- package/dist/ui/elements/donut.js +16 -0
- package/dist/ui/elements/donut.works.d.ts +11 -0
- package/dist/ui/elements/donut.works.js +28 -0
- package/dist/ui/elements/each.d.ts +14 -0
- package/dist/ui/elements/each.js +9 -0
- package/dist/ui/elements/each.works.d.ts +3 -0
- package/dist/ui/elements/each.works.js +68 -0
- package/dist/ui/elements/empty.d.ts +9 -0
- package/dist/ui/elements/empty.js +12 -0
- package/dist/ui/elements/field.d.ts +16 -0
- package/dist/ui/elements/field.js +15 -0
- package/dist/ui/elements/field.works.d.ts +17 -0
- package/dist/ui/elements/field.works.js +45 -0
- package/dist/ui/elements/funnel.d.ts +14 -0
- package/dist/ui/elements/funnel.js +17 -0
- package/dist/ui/elements/funnel.works.d.ts +12 -0
- package/dist/ui/elements/funnel.works.js +23 -0
- package/dist/ui/elements/gauge.d.ts +12 -0
- package/dist/ui/elements/gauge.js +15 -0
- package/dist/ui/elements/gauge.works.d.ts +11 -0
- package/dist/ui/elements/gauge.works.js +31 -0
- package/dist/ui/elements/glyph.d.ts +10 -0
- package/dist/ui/elements/glyph.js +9 -0
- package/dist/ui/elements/glyph.works.d.ts +5 -0
- package/dist/ui/elements/glyph.works.js +16 -0
- package/dist/ui/elements/grid.d.ts +9 -0
- package/dist/ui/elements/grid.js +8 -0
- package/dist/ui/elements/heatmap.d.ts +15 -0
- package/dist/ui/elements/heatmap.js +17 -0
- package/dist/ui/elements/heatmap.works.d.ts +11 -0
- package/dist/ui/elements/heatmap.works.js +11 -0
- package/dist/ui/elements/hit-box.d.ts +19 -0
- package/dist/ui/elements/hit-box.js +15 -0
- package/dist/ui/elements/hit-box.works.d.ts +87 -0
- package/dist/ui/elements/hit-box.works.js +451 -0
- package/dist/ui/elements/image.d.ts +10 -0
- package/dist/ui/elements/image.js +9 -0
- package/dist/ui/elements/line-chart.d.ts +13 -0
- package/dist/ui/elements/line-chart.js +16 -0
- package/dist/ui/elements/line-chart.works.d.ts +12 -0
- package/dist/ui/elements/line-chart.works.js +27 -0
- package/dist/ui/elements/link.d.ts +12 -0
- package/dist/ui/elements/link.js +15 -0
- package/dist/ui/elements/link.works.d.ts +10 -0
- package/dist/ui/elements/link.works.js +15 -0
- package/dist/ui/elements/media.d.ts +11 -0
- package/dist/ui/elements/media.js +22 -0
- package/dist/ui/elements/menu.d.ts +12 -0
- package/dist/ui/elements/menu.js +18 -0
- package/dist/ui/elements/menu.works.d.ts +50 -0
- package/dist/ui/elements/menu.works.js +100 -0
- package/dist/ui/elements/money.d.ts +10 -0
- package/dist/ui/elements/money.js +9 -0
- package/dist/ui/elements/money.works.d.ts +4 -0
- package/dist/ui/elements/money.works.js +4 -0
- package/dist/ui/elements/pagination.d.ts +11 -0
- package/dist/ui/elements/pagination.js +12 -0
- package/dist/ui/elements/pagination.works.d.ts +5 -0
- package/dist/ui/elements/pagination.works.js +15 -0
- package/dist/ui/elements/progress.d.ts +11 -0
- package/dist/ui/elements/progress.js +11 -0
- package/dist/ui/elements/progress.works.d.ts +2 -0
- package/dist/ui/elements/progress.works.js +6 -0
- package/dist/ui/elements/radio-group.d.ts +15 -0
- package/dist/ui/elements/radio-group.js +16 -0
- package/dist/ui/elements/radio-group.works.d.ts +10 -0
- package/dist/ui/elements/radio-group.works.js +22 -0
- package/dist/ui/elements/row.d.ts +9 -0
- package/dist/ui/elements/row.js +8 -0
- package/dist/ui/elements/scatter.d.ts +13 -0
- package/dist/ui/elements/scatter.js +15 -0
- package/dist/ui/elements/scatter.works.d.ts +11 -0
- package/dist/ui/elements/scatter.works.js +24 -0
- package/dist/ui/elements/select.d.ts +13 -0
- package/dist/ui/elements/select.js +11 -0
- package/dist/ui/elements/select.works.d.ts +4 -0
- package/dist/ui/elements/select.works.js +3 -0
- package/dist/ui/elements/separator.d.ts +10 -0
- package/dist/ui/elements/separator.js +9 -0
- package/dist/ui/elements/skeleton.d.ts +8 -0
- package/dist/ui/elements/skeleton.js +9 -0
- package/dist/ui/elements/slider.d.ts +14 -0
- package/dist/ui/elements/slider.js +10 -0
- package/dist/ui/elements/slider.works.d.ts +4 -0
- package/dist/ui/elements/slider.works.js +3 -0
- package/dist/ui/elements/sparkline.d.ts +10 -0
- package/dist/ui/elements/sparkline.js +15 -0
- package/dist/ui/elements/sparkline.works.d.ts +10 -0
- package/dist/ui/elements/sparkline.works.js +19 -0
- package/dist/ui/elements/spinner.d.ts +9 -0
- package/dist/ui/elements/spinner.js +12 -0
- package/dist/ui/elements/stack.d.ts +9 -0
- package/dist/ui/elements/stack.js +8 -0
- package/dist/ui/elements/stat.d.ts +12 -0
- package/dist/ui/elements/stat.js +10 -0
- package/dist/ui/elements/stat.works.d.ts +3 -0
- package/dist/ui/elements/stat.works.js +10 -0
- package/dist/ui/elements/surface.d.ts +9 -0
- package/dist/ui/elements/surface.js +15 -0
- package/dist/ui/elements/surface.works.d.ts +7 -0
- package/dist/ui/elements/surface.works.js +4 -0
- package/dist/ui/elements/table.d.ts +13 -0
- package/dist/ui/elements/table.js +16 -0
- package/dist/ui/elements/table.works.d.ts +11 -0
- package/dist/ui/elements/table.works.js +15 -0
- package/dist/ui/elements/tabs.d.ts +12 -0
- package/dist/ui/elements/tabs.js +16 -0
- package/dist/ui/elements/tabs.works.d.ts +25 -0
- package/dist/ui/elements/tabs.works.js +53 -0
- package/dist/ui/elements/text.d.ts +13 -0
- package/dist/ui/elements/text.js +9 -0
- package/dist/ui/elements/textarea.d.ts +14 -0
- package/dist/ui/elements/textarea.js +11 -0
- package/dist/ui/elements/textarea.works.d.ts +4 -0
- package/dist/ui/elements/textarea.works.js +3 -0
- package/dist/ui/elements/time.d.ts +11 -0
- package/dist/ui/elements/time.js +14 -0
- package/dist/ui/elements/time.works.d.ts +11 -0
- package/dist/ui/elements/time.works.js +16 -0
- package/dist/ui/elements/toggle.d.ts +11 -0
- package/dist/ui/elements/toggle.js +10 -0
- package/dist/ui/elements/toggle.works.d.ts +4 -0
- package/dist/ui/elements/toggle.works.js +3 -0
- package/dist/ui/elements/tooltip.d.ts +12 -0
- package/dist/ui/elements/tooltip.js +15 -0
- package/dist/ui/elements/tooltip.works.d.ts +28 -0
- package/dist/ui/elements/tooltip.works.js +54 -0
- package/dist/ui/elements/value.d.ts +12 -0
- package/dist/ui/elements/value.js +9 -0
- package/dist/ui/elements/value.works.d.ts +4 -0
- package/dist/ui/elements/value.works.js +4 -0
- package/dist/ui/elements.d.ts +1143 -0
- package/dist/ui/elements.js +68 -0
- package/dist/ui/focus-scope.d.ts +7 -0
- package/dist/ui/focus-scope.js +109 -0
- package/dist/ui/fonts.d.ts +103 -0
- package/dist/ui/fonts.js +243 -0
- package/dist/ui/generators/dev.d.ts +2 -0
- package/dist/ui/generators/dev.js +61 -0
- package/dist/ui/generators/elements.d.ts +31 -0
- package/dist/ui/generators/elements.js +520 -0
- package/dist/ui/generators/i18n.d.ts +5 -0
- package/dist/ui/generators/i18n.js +264 -0
- package/dist/ui/generators/icons.d.ts +1 -0
- package/dist/ui/generators/icons.js +187 -0
- package/dist/ui/generators/react.d.ts +26 -0
- package/dist/ui/generators/react.js +218 -0
- package/dist/ui/generators/routes.d.ts +11 -0
- package/dist/ui/generators/routes.js +597 -0
- package/dist/ui/generators/show.d.ts +1 -0
- package/dist/ui/generators/show.js +231 -0
- package/dist/ui/generators/styles.d.ts +1 -0
- package/dist/ui/generators/styles.js +502 -0
- package/dist/ui/generators/variants.d.ts +12 -0
- package/dist/ui/generators/variants.js +162 -0
- package/dist/ui/i18n/catalogs/en.d.ts +172 -0
- package/dist/ui/i18n/catalogs/en.js +148 -0
- package/dist/ui/i18n/format.d.ts +13 -0
- package/dist/ui/i18n/format.js +161 -0
- package/dist/ui/i18n/locales.d.ts +9 -0
- package/dist/ui/i18n/locales.js +20 -0
- package/dist/ui/i18n/parse.d.ts +45 -0
- package/dist/ui/i18n/parse.js +249 -0
- package/dist/ui/i18n/translator.d.ts +10 -0
- package/dist/ui/i18n/translator.js +22 -0
- package/dist/ui/i18n/types.d.ts +33 -0
- package/dist/ui/i18n/types.js +9 -0
- package/dist/ui/icons.d.ts +67 -0
- package/dist/ui/icons.js +249 -0
- package/dist/ui/islands/map.d.ts +33 -0
- package/dist/ui/islands/map.js +44 -0
- package/dist/ui/localizations.d.ts +33 -0
- package/dist/ui/localizations.js +51 -0
- package/dist/ui/makers/message.d.ts +1 -0
- package/dist/ui/makers/message.js +230 -0
- package/dist/ui/material.d.ts +83 -0
- package/dist/ui/material.js +95 -0
- package/dist/ui/materials/mat_bordered.d.ts +22 -0
- package/dist/ui/materials/mat_bordered.js +12 -0
- package/dist/ui/materials/mat_ceramic.d.ts +22 -0
- package/dist/ui/materials/mat_ceramic.js +12 -0
- package/dist/ui/materials/mat_clay.d.ts +22 -0
- package/dist/ui/materials/mat_clay.js +12 -0
- package/dist/ui/materials/mat_elevated.d.ts +32 -0
- package/dist/ui/materials/mat_elevated.js +23 -0
- package/dist/ui/materials/mat_flat.d.ts +50 -0
- package/dist/ui/materials/mat_flat.js +33 -0
- package/dist/ui/materials/mat_glass.d.ts +32 -0
- package/dist/ui/materials/mat_glass.js +19 -0
- package/dist/ui/materials/mat_lit.d.ts +22 -0
- package/dist/ui/materials/mat_lit.js +12 -0
- package/dist/ui/materials/mat_moulded.d.ts +16 -0
- package/dist/ui/materials/mat_moulded.js +10 -0
- package/dist/ui/materials.d.ts +56 -0
- package/dist/ui/materials.js +175 -0
- package/dist/ui/modes.d.ts +25 -0
- package/dist/ui/modes.js +25 -0
- package/dist/ui/navigation.d.ts +3 -0
- package/dist/ui/navigation.js +24 -0
- package/dist/ui/positioning.d.ts +24 -0
- package/dist/ui/positioning.js +48 -0
- package/dist/ui/presented.d.ts +10 -0
- package/dist/ui/presented.js +81 -0
- package/dist/ui/provider.d.ts +31 -0
- package/dist/ui/provider.js +104 -0
- package/dist/ui/render-loop.d.ts +12 -0
- package/dist/ui/render-loop.js +94 -0
- package/dist/ui/roving-focus.d.ts +15 -0
- package/dist/ui/roving-focus.js +143 -0
- package/dist/ui/screens.d.ts +17 -0
- package/dist/ui/screens.js +112 -0
- package/dist/ui/scroll-lock.d.ts +2 -0
- package/dist/ui/scroll-lock.js +24 -0
- package/dist/ui/series.d.ts +9 -0
- package/dist/ui/series.js +67 -0
- package/dist/ui/signals.d.ts +120 -0
- package/dist/ui/signals.js +286 -0
- package/dist/ui/styleguide.d.ts +27 -0
- package/dist/ui/styleguide.js +138 -0
- package/dist/ui/styleguides.d.ts +11 -0
- package/dist/ui/styleguides.js +299 -0
- package/dist/ui/themes.d.ts +5 -0
- package/dist/ui/themes.js +16 -0
- package/dist/ui/token.d.ts +16 -0
- package/dist/ui/token.js +37 -0
- package/dist/ui/tokens/shadow.d.ts +6 -0
- package/dist/ui/tokens/shadow.js +17 -0
- package/dist/ui/tokens.d.ts +180 -0
- package/dist/ui/tokens.js +200 -0
- package/dist/ui/validators.d.ts +37 -0
- package/dist/ui/validators.js +184 -0
- package/dist/ui/variant.d.ts +122 -0
- package/dist/ui/variant.js +201 -0
- package/dist/ui/variants/var_avatar-round.d.ts +23 -0
- package/dist/ui/variants/var_avatar-round.js +13 -0
- package/dist/ui/variants/var_bubble-me.d.ts +21 -0
- package/dist/ui/variants/var_bubble-me.js +13 -0
- package/dist/ui/variants/var_bubble-them.d.ts +18 -0
- package/dist/ui/variants/var_bubble-them.js +12 -0
- package/dist/ui/variants/var_button-border.d.ts +116 -0
- package/dist/ui/variants/var_button-border.js +75 -0
- package/dist/ui/variants/var_button-cta.d.ts +116 -0
- package/dist/ui/variants/var_button-cta.js +75 -0
- package/dist/ui/variants/var_button-destructive-ghost.d.ts +113 -0
- package/dist/ui/variants/var_button-destructive-ghost.js +71 -0
- package/dist/ui/variants/var_button-destructive.d.ts +116 -0
- package/dist/ui/variants/var_button-destructive.js +75 -0
- package/dist/ui/variants/var_button-fill.d.ts +116 -0
- package/dist/ui/variants/var_button-fill.js +75 -0
- package/dist/ui/variants/var_button-ghost.d.ts +113 -0
- package/dist/ui/variants/var_button-ghost.js +71 -0
- package/dist/ui/variants/var_button-glass.d.ts +84 -0
- package/dist/ui/variants/var_button-glass.js +54 -0
- package/dist/ui/variants/var_button-normal.d.ts +116 -0
- package/dist/ui/variants/var_button-normal.js +75 -0
- package/dist/ui/variants/var_button-quiet.d.ts +119 -0
- package/dist/ui/variants/var_button-quiet.js +73 -0
- package/dist/ui/variants/var_card.d.ts +30 -0
- package/dist/ui/variants/var_card.js +16 -0
- package/dist/ui/variants/var_chip.d.ts +18 -0
- package/dist/ui/variants/var_chip.js +12 -0
- package/dist/ui/variants/var_choice.d.ts +26 -0
- package/dist/ui/variants/var_choice.js +14 -0
- package/dist/ui/variants/var_framed.d.ts +11 -0
- package/dist/ui/variants/var_framed.js +9 -0
- package/dist/ui/variants/var_glyph-plain.d.ts +14 -0
- package/dist/ui/variants/var_glyph-plain.js +10 -0
- package/dist/ui/variants/var_input.d.ts +61 -0
- package/dist/ui/variants/var_input.js +42 -0
- package/dist/ui/variants/var_link-inline.d.ts +39 -0
- package/dist/ui/variants/var_link-inline.js +28 -0
- package/dist/ui/variants/var_list-row.d.ts +47 -0
- package/dist/ui/variants/var_list-row.js +33 -0
- package/dist/ui/variants/var_rule.d.ts +11 -0
- package/dist/ui/variants/var_rule.js +9 -0
- package/dist/ui/variants/var_skeleton-block.d.ts +17 -0
- package/dist/ui/variants/var_skeleton-block.js +11 -0
- package/dist/ui/variants/var_spinner-turning.d.ts +17 -0
- package/dist/ui/variants/var_spinner-turning.js +11 -0
- package/dist/ui/variants/var_stat-tile.d.ts +18 -0
- package/dist/ui/variants/var_stat-tile.js +12 -0
- package/dist/ui/variants/var_tab-bar.d.ts +24 -0
- package/dist/ui/variants/var_tab-bar.js +14 -0
- package/dist/ui/variants/var_tap-target.d.ts +33 -0
- package/dist/ui/variants/var_tap-target.js +24 -0
- package/dist/ui/variants.d.ts +174 -0
- package/dist/ui/variants.js +50 -0
- package/dist/ui/wrappers.d.ts +128 -0
- package/dist/ui/wrappers.js +220 -0
- package/package.json +16 -0
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import { dirname, join, relative } from 'node:path';
|
|
11
|
+
import { argv, stderr, stdout } from 'node:process';
|
|
12
|
+
import { pathToFileURL } from 'node:url';
|
|
13
|
+
import ts from 'typescript';
|
|
14
|
+
import { exit, invoked } from "@prestack/thread/core/invoked";
|
|
15
|
+
import { named as packageOf } from "@prestack/thread/core/scope";
|
|
16
|
+
import { findTree, inTree } from "@prestack/thread/core/tree";
|
|
17
|
+
import { nameOf as compositionOf } from "../compositions.js";
|
|
18
|
+
import { PRESENTATIONS } from "../door.js";
|
|
19
|
+
import { PAGE, entryAmong, nameOf, pageAt, presentedIn, routeFor } from "../screens.js";
|
|
20
|
+
import { keyProps } from "./i18n.js";
|
|
21
|
+
const LAYOUT = `app/layout.${'tsx'}`;
|
|
22
|
+
const WORDING = `app/_generated/wording.${'ts'}`;
|
|
23
|
+
const DECLARED = `src/_generated/seams.${'ts'}`;
|
|
24
|
+
const CLIENT = `app/_generated/dispatching.${'ts'}`;
|
|
25
|
+
const DOOR = `app/_generated/door.${'tsx'}`;
|
|
26
|
+
const MAP = `app/_generated/map.${'ts'}`;
|
|
27
|
+
const PROVIDER = `${packageOf('ui')}/provider`;
|
|
28
|
+
const GRAMMAR = `${packageOf('ui')}/islands/map`;
|
|
29
|
+
const MOVES = 'navigateTo';
|
|
30
|
+
function door(knowing, wording, dispatching, moving, presenting) {
|
|
31
|
+
const opening = presenting.length > 0;
|
|
32
|
+
const props = `asking={ASKING}${knowing ? ' actor={actor}' : ''}${dispatching ? ' dispatch={dispatchTo}' : ''}` +
|
|
33
|
+
`${moving ? ' navigateTo={navigateTo}' : ''}${wording ? ' locale={SOURCE} wording={WORDING}' : ''}`;
|
|
34
|
+
return [
|
|
35
|
+
"'use client'",
|
|
36
|
+
'',
|
|
37
|
+
'/* GENERATED by thread — do not edit. It is derived from what this app declares. */',
|
|
38
|
+
'',
|
|
39
|
+
...(moving
|
|
40
|
+
? [`import { useCallback, ${opening ? 'useState, ' : ''}type ReactNode } from 'react'`, "import { useRouter } from 'next/navigation'"]
|
|
41
|
+
: ["import type { ReactNode } from 'react'"]),
|
|
42
|
+
'',
|
|
43
|
+
`import { ThreadUi } from '${PROVIDER}'`,
|
|
44
|
+
'',
|
|
45
|
+
"import { ASKING } from './declared.ts'",
|
|
46
|
+
...(dispatching ? ["import { dispatchTo } from './dispatching.ts'"] : []),
|
|
47
|
+
...(moving ? ["import { MAP } from './map.ts'"] : []),
|
|
48
|
+
...(wording ? ["import { SOURCE, WORDING } from './wording.ts'"] : []),
|
|
49
|
+
...(opening ? ['', ...presenting.map((one) => `import { ${one.name} } from '${reaching(DOOR, one.at)}'`)] : []),
|
|
50
|
+
'',
|
|
51
|
+
'export function Door({',
|
|
52
|
+
...(knowing
|
|
53
|
+
? [' actor,']
|
|
54
|
+
: []),
|
|
55
|
+
' children,',
|
|
56
|
+
'}: {',
|
|
57
|
+
...(knowing
|
|
58
|
+
? [' readonly actor?: { readonly id: string | null; readonly roles: readonly string[]; readonly entitlements: readonly string[] }']
|
|
59
|
+
: []),
|
|
60
|
+
' readonly children: ReactNode',
|
|
61
|
+
'}) {',
|
|
62
|
+
...(moving
|
|
63
|
+
? [
|
|
64
|
+
' const router = useRouter()',
|
|
65
|
+
...(opening ? [' const [presented, setPresented] = useState<string | undefined>(undefined)'] : []),
|
|
66
|
+
' const navigateTo = useCallback(',
|
|
67
|
+
' (screen: string): void => {',
|
|
68
|
+
...(opening
|
|
69
|
+
? [
|
|
70
|
+
' const found = MAP.screens.find((one) => one.id === screen)',
|
|
71
|
+
' if (found === undefined) {',
|
|
72
|
+
' throw new Error(',
|
|
73
|
+
' `thread: \\`${screen}\\` is not a screen this app has, so there is nothing to go to. ` +',
|
|
74
|
+
" `The screens are ${MAP.screens.map((one) => one.id).join(', ')}.`,",
|
|
75
|
+
' )',
|
|
76
|
+
' }',
|
|
77
|
+
' if (found.path === undefined) {',
|
|
78
|
+
' setPresented(screen)',
|
|
79
|
+
' return',
|
|
80
|
+
' }',
|
|
81
|
+
' setPresented(undefined)',
|
|
82
|
+
' router.push(found.path)',
|
|
83
|
+
]
|
|
84
|
+
: [
|
|
85
|
+
' const path = MAP.screens.find((one) => one.id === screen)?.path',
|
|
86
|
+
' if (path === undefined) {',
|
|
87
|
+
' throw new Error(',
|
|
88
|
+
' `thread: \\`${screen}\\` is not a screen this app has, so there is nothing to go to. ` +',
|
|
89
|
+
" `The screens are ${MAP.screens.map((one) => one.id).join(', ')}.`,",
|
|
90
|
+
' )',
|
|
91
|
+
' }',
|
|
92
|
+
' router.push(path)',
|
|
93
|
+
]),
|
|
94
|
+
' },',
|
|
95
|
+
' [router],',
|
|
96
|
+
' )',
|
|
97
|
+
...(opening ? [' const dismiss = useCallback((): void => setPresented(undefined), [])'] : []),
|
|
98
|
+
]
|
|
99
|
+
: []),
|
|
100
|
+
...(opening
|
|
101
|
+
? [
|
|
102
|
+
' return (',
|
|
103
|
+
` <ThreadUi ${props}>`,
|
|
104
|
+
' {children}',
|
|
105
|
+
...presenting.map((one) => ` <${one.name} open={presented === '${one.name}'} onDismiss={dismiss} />`),
|
|
106
|
+
' </ThreadUi>',
|
|
107
|
+
' )',
|
|
108
|
+
]
|
|
109
|
+
: [` return <ThreadUi ${props}>{children}</ThreadUi>`]),
|
|
110
|
+
'}',
|
|
111
|
+
'',
|
|
112
|
+
].join('\n');
|
|
113
|
+
}
|
|
114
|
+
const TYPED = /screen\(\s*'[^']*'\s*,\s*\{[^}]*route:\s*'([^']*)'/;
|
|
115
|
+
export function typedRoute(source) {
|
|
116
|
+
return TYPED.exec(source)?.[1];
|
|
117
|
+
}
|
|
118
|
+
function written(node) {
|
|
119
|
+
if (node === undefined)
|
|
120
|
+
return undefined;
|
|
121
|
+
if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node))
|
|
122
|
+
return node.text;
|
|
123
|
+
if (ts.isJsxExpression(node) || ts.isParenthesizedExpression(node))
|
|
124
|
+
return written(node.expression);
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
function keyed(name) {
|
|
128
|
+
return ts.isIdentifier(name) || ts.isStringLiteral(name) ? name.text : undefined;
|
|
129
|
+
}
|
|
130
|
+
function attribute(held, name) {
|
|
131
|
+
for (const one of held.properties) {
|
|
132
|
+
if (ts.isJsxAttribute(one) && ts.isIdentifier(one.name) && one.name.text === name)
|
|
133
|
+
return one;
|
|
134
|
+
}
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
function property(held, name) {
|
|
138
|
+
for (const one of held.properties) {
|
|
139
|
+
if (ts.isPropertyAssignment(one) && keyed(one.name) === name)
|
|
140
|
+
return one;
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
function moveOf(found, wording) {
|
|
145
|
+
const to = written(found(MOVES));
|
|
146
|
+
let through;
|
|
147
|
+
for (const key of wording) {
|
|
148
|
+
through = written(found(key));
|
|
149
|
+
if (through !== undefined)
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
return { ...(to === undefined ? {} : { to }), ...(through === undefined ? {} : { through }) };
|
|
153
|
+
}
|
|
154
|
+
export function holding(text, at, wording, placeable) {
|
|
155
|
+
const file = ts.createSourceFile(at, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
156
|
+
const moves = [];
|
|
157
|
+
const places = new Set();
|
|
158
|
+
const walk = (node) => {
|
|
159
|
+
if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
|
|
160
|
+
const tag = node.tagName;
|
|
161
|
+
if (ts.isIdentifier(tag) && placeable.has(tag.text))
|
|
162
|
+
places.add(tag.text);
|
|
163
|
+
if (attribute(node.attributes, MOVES) !== undefined) {
|
|
164
|
+
moves.push(moveOf((name) => attribute(node.attributes, name)?.initializer, wording));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (ts.isObjectLiteralExpression(node) && property(node, MOVES) !== undefined) {
|
|
168
|
+
moves.push(moveOf((name) => property(node, name)?.initializer, wording));
|
|
169
|
+
}
|
|
170
|
+
ts.forEachChild(node, walk);
|
|
171
|
+
};
|
|
172
|
+
walk(file);
|
|
173
|
+
return { moves, places: [...places].sort() };
|
|
174
|
+
}
|
|
175
|
+
function wordingFirst(props) {
|
|
176
|
+
const first = ['label', 'labelKey'];
|
|
177
|
+
return [...first.filter((one) => props.includes(one)), ...props.filter((one) => !first.includes(one))];
|
|
178
|
+
}
|
|
179
|
+
function linksOf(at, rows, compositions, routes, wording) {
|
|
180
|
+
const named = new Map();
|
|
181
|
+
for (const row of compositions)
|
|
182
|
+
named.set(compositionOf(row.at), row.at);
|
|
183
|
+
for (const row of rows)
|
|
184
|
+
named.set(nameOf(row.at), row.at);
|
|
185
|
+
const placeable = new Set(named.keys());
|
|
186
|
+
const screens = [...routes.keys()].sort();
|
|
187
|
+
const held = new Map();
|
|
188
|
+
const read = (path) => {
|
|
189
|
+
const kept = held.get(path);
|
|
190
|
+
if (kept !== undefined)
|
|
191
|
+
return kept;
|
|
192
|
+
const file = join(at, path);
|
|
193
|
+
const made = existsSync(file) ? holding(readFileSync(file, 'utf8'), path, wording, placeable) : { moves: [], places: [] };
|
|
194
|
+
held.set(path, made);
|
|
195
|
+
return made;
|
|
196
|
+
};
|
|
197
|
+
const links = [];
|
|
198
|
+
const stated = new Set();
|
|
199
|
+
const wrong = [];
|
|
200
|
+
for (const row of rows) {
|
|
201
|
+
const from = nameOf(row.at);
|
|
202
|
+
const seen = new Set();
|
|
203
|
+
const gather = (path) => {
|
|
204
|
+
if (seen.has(path))
|
|
205
|
+
return;
|
|
206
|
+
seen.add(path);
|
|
207
|
+
const one = read(path);
|
|
208
|
+
for (const move of one.moves) {
|
|
209
|
+
const through = move.through === undefined ? '' : ` through \`${move.through}\``;
|
|
210
|
+
if (move.to === undefined) {
|
|
211
|
+
wrong.push(`${path} moves somebody with a \`${MOVES}\` that is not written out as a screen name, so the map cannot ` +
|
|
212
|
+
`say where ${from} goes${through}. Name the screen — \`${MOVES}="${screens[0] ?? 'Home'}"\`.`);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (!routes.has(move.to)) {
|
|
216
|
+
wrong.push(`${from} goes to \`${move.to}\`${through}, and no screen is called that. The screens are ` +
|
|
217
|
+
`${screens.join(', ')} — declare it with \`thread create screen\`, or name one of those.`);
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const link = { from, to: move.to, ...(move.through === undefined ? {} : { labelKey: move.through }) };
|
|
221
|
+
const key = JSON.stringify(link);
|
|
222
|
+
if (stated.has(key))
|
|
223
|
+
continue;
|
|
224
|
+
stated.add(key);
|
|
225
|
+
links.push(link);
|
|
226
|
+
}
|
|
227
|
+
for (const place of one.places) {
|
|
228
|
+
const where = named.get(place);
|
|
229
|
+
if (where !== undefined)
|
|
230
|
+
gather(where);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
gather(row.at);
|
|
234
|
+
}
|
|
235
|
+
return { links, wrong };
|
|
236
|
+
}
|
|
237
|
+
const quoted = (value) => `'${value.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`;
|
|
238
|
+
function mapModule(map) {
|
|
239
|
+
const screen = (one) => ` { id: ${quoted(one.id)}, nameKey: ${quoted(one.nameKey)}, ` +
|
|
240
|
+
`${one.path === undefined ? '' : `path: ${quoted(one.path)}, `}` +
|
|
241
|
+
`entry: ${String(one.entry)}, shows: [${one.shows.map(quoted).join(', ')}] },`;
|
|
242
|
+
const link = (one) => ` { from: ${quoted(one.from)}, to: ${quoted(one.to)}${one.labelKey === undefined ? '' : `, labelKey: ${quoted(one.labelKey)}`} },`;
|
|
243
|
+
return [
|
|
244
|
+
'/* GENERATED by thread — do not edit. It is derived from the screens, and from every navigateTo they and their compositions hold. */',
|
|
245
|
+
'',
|
|
246
|
+
`import type { MapIsland } from '${GRAMMAR}'`,
|
|
247
|
+
'',
|
|
248
|
+
'export const MAP: MapIsland = {',
|
|
249
|
+
' specVersion: 1,',
|
|
250
|
+
' screens: [',
|
|
251
|
+
...map.screens.map(screen),
|
|
252
|
+
' ],',
|
|
253
|
+
' links: [',
|
|
254
|
+
...map.links.map(link),
|
|
255
|
+
' ],',
|
|
256
|
+
'}',
|
|
257
|
+
'',
|
|
258
|
+
].join('\n');
|
|
259
|
+
}
|
|
260
|
+
function shown(map) {
|
|
261
|
+
return [
|
|
262
|
+
...map.screens.map((one) => one.path === undefined
|
|
263
|
+
? ` ${one.id} has no route — a press opens it where somebody already is`
|
|
264
|
+
: ` ${one.id} answers ${one.path}${one.entry ? ' — the entry, because it is the first page declared' : ''}`),
|
|
265
|
+
...map.links.map((one) => ` ${one.from} → ${one.to}${one.labelKey === undefined ? '' : `, through ${one.labelKey}`}`),
|
|
266
|
+
...map.screens
|
|
267
|
+
.filter((one) => !one.entry && !map.links.some((link) => link.to === one.id))
|
|
268
|
+
.map((one) => one.path === undefined
|
|
269
|
+
? ` ${one.id} — no button goes there, and a screen with no route is reached no other way`
|
|
270
|
+
: ` ${one.id} — no button goes there, so it is reached only by its address ${one.path}`),
|
|
271
|
+
];
|
|
272
|
+
}
|
|
273
|
+
function reaching(file, at) {
|
|
274
|
+
const up = '../'.repeat(file.split('/').length - 1);
|
|
275
|
+
return `${up}${at.replace(/\.tsx?$/, '')}`;
|
|
276
|
+
}
|
|
277
|
+
function page(name, at, route) {
|
|
278
|
+
const from = reaching(pageAt(route), at);
|
|
279
|
+
return [
|
|
280
|
+
'/* GENERATED by thread — do not edit. It follows from the screen\'s name and its place among the pages. */',
|
|
281
|
+
'',
|
|
282
|
+
`import { ${name} } from '${from}'`,
|
|
283
|
+
'',
|
|
284
|
+
'export default function Page() {',
|
|
285
|
+
` return <${name} />`,
|
|
286
|
+
'}',
|
|
287
|
+
'',
|
|
288
|
+
].join('\n');
|
|
289
|
+
}
|
|
290
|
+
function guarding(checker) {
|
|
291
|
+
if (checker === undefined) {
|
|
292
|
+
return [
|
|
293
|
+
"throw new Error('thread: the compiler that checks this tree cannot be found, so nothing here " +
|
|
294
|
+
"can be compiled. Reinstall the framework packages. A check that cannot run is not a check " +
|
|
295
|
+
"that passed.')",
|
|
296
|
+
'',
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
return [
|
|
300
|
+
"import { ungated } from './react.ts'",
|
|
301
|
+
'',
|
|
302
|
+
"const why = ungated(`${process.cwd()}/app/layout.tsx`)",
|
|
303
|
+
'if (why !== null) throw new Error(`thread: ${why}`)',
|
|
304
|
+
'',
|
|
305
|
+
];
|
|
306
|
+
}
|
|
307
|
+
function layout(wording, icons, source, checker, knowing, doored) {
|
|
308
|
+
return [
|
|
309
|
+
'/* GENERATED by thread — do not edit. It is derived from what the other generators produce. */',
|
|
310
|
+
'',
|
|
311
|
+
'/// <reference types="next/types/global" />',
|
|
312
|
+
'',
|
|
313
|
+
...guarding(checker),
|
|
314
|
+
"import type { ReactNode } from 'react'",
|
|
315
|
+
...(doored ? ["import { Door } from './_generated/door.tsx'"] : [`import { ThreadUi } from '${PROVIDER}'`]),
|
|
316
|
+
...(doored ? [] : ["import { ASKING } from './_generated/declared.ts'"]),
|
|
317
|
+
...(knowing
|
|
318
|
+
? ["import { headers } from 'next/headers'", `import { actor } from '../${DECLARED}'`]
|
|
319
|
+
: []),
|
|
320
|
+
"import './_generated/tokens.css'",
|
|
321
|
+
...(icons ? ["import { ThreadIcons } from './_generated/icons.ts'"] : []),
|
|
322
|
+
...(wording && !doored ? ["import { SOURCE, WORDING } from './_generated/wording.ts'"] : []),
|
|
323
|
+
'',
|
|
324
|
+
knowing
|
|
325
|
+
? 'export default async function RootLayout({ children }: { children: ReactNode }) {'
|
|
326
|
+
: 'export default function RootLayout({ children }: { children: ReactNode }) {',
|
|
327
|
+
...(knowing
|
|
328
|
+
? [" const who = await actor(new Request('http://localhost', { headers: await headers() }))"]
|
|
329
|
+
: []),
|
|
330
|
+
' return (',
|
|
331
|
+
` <html lang="${source}">`,
|
|
332
|
+
' <body>',
|
|
333
|
+
...(icons ? [' <ThreadIcons />'] : []),
|
|
334
|
+
doored
|
|
335
|
+
? ` <Door${knowing ? ' actor={who}' : ''}>{children}</Door>`
|
|
336
|
+
: ` <ThreadUi asking={ASKING}${knowing ? ' actor={who}' : ''}${wording ? ' locale={SOURCE} wording={WORDING}' : ''}>{children}</ThreadUi>`,
|
|
337
|
+
' </body>',
|
|
338
|
+
' </html>',
|
|
339
|
+
' )',
|
|
340
|
+
'}',
|
|
341
|
+
'',
|
|
342
|
+
].join('\n');
|
|
343
|
+
}
|
|
344
|
+
const CONFIG = `next.config.${'js'}`;
|
|
345
|
+
const SHADOWS = [`next.config.${'mjs'}`, `next.config.${'ts'}`, `next.config.${'mts'}`];
|
|
346
|
+
function rootFor(at) {
|
|
347
|
+
let real;
|
|
348
|
+
try {
|
|
349
|
+
real = realpathSync(join(at, 'node_modules', packageOf('ui')));
|
|
350
|
+
}
|
|
351
|
+
catch {
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
const here = realpathSync(at);
|
|
355
|
+
if (real.startsWith(`${here}/`))
|
|
356
|
+
return undefined;
|
|
357
|
+
const one = here.split('/');
|
|
358
|
+
const two = real.split('/');
|
|
359
|
+
const shared = [];
|
|
360
|
+
for (let step = 0; step < Math.min(one.length, two.length); step += 1) {
|
|
361
|
+
if (one[step] !== two[step])
|
|
362
|
+
break;
|
|
363
|
+
shared.push(one[step] ?? '');
|
|
364
|
+
}
|
|
365
|
+
const common = shared.join('/');
|
|
366
|
+
return relative(here, common) || '.';
|
|
367
|
+
}
|
|
368
|
+
function loaderFor(at) {
|
|
369
|
+
try {
|
|
370
|
+
return realpathSync(join(at, 'node_modules', packageOf('ui'), 'dist', 'generators', 'react.js'));
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
return undefined;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const DRIVER = /export\s+const\s+driver\s*:[^=\n]*=\s*\[([^\]]*)\]/;
|
|
377
|
+
const QUOTED = /'([^']+)'|"([^"]+)"/g;
|
|
378
|
+
const RELATIVE = /(?:^|[\s;{(])import\s+(?!type\s)(?:[\w*{][^'"]*from\s+)?['"](\.[^'"]+)['"]/g;
|
|
379
|
+
function externalFor(at) {
|
|
380
|
+
const wiring = join(at, DECLARED);
|
|
381
|
+
if (!existsSync(wiring))
|
|
382
|
+
return [];
|
|
383
|
+
const read = (path) => {
|
|
384
|
+
try {
|
|
385
|
+
return readFileSync(path, 'utf8');
|
|
386
|
+
}
|
|
387
|
+
catch {
|
|
388
|
+
return '';
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
const found = new Set();
|
|
392
|
+
const wiredIn = read(wiring);
|
|
393
|
+
const reachable = [...wiredIn.matchAll(RELATIVE)].map(([, one]) => {
|
|
394
|
+
const path = join(dirname(wiring), (one ?? '').replace(/\.tsx?$/, '')) + '.ts';
|
|
395
|
+
return [path, read(path)];
|
|
396
|
+
});
|
|
397
|
+
const SEAM = /export\s+const\s+store\s*:/;
|
|
398
|
+
for (const [where, text] of [[wiring, wiredIn], ...reachable]) {
|
|
399
|
+
const held = DRIVER.exec(text)?.[1];
|
|
400
|
+
if (held === undefined) {
|
|
401
|
+
if (where === wiring || !SEAM.test(text))
|
|
402
|
+
continue;
|
|
403
|
+
stderr.write(`routes: ${relative(at, where)} declares a store and does not say what must stay out of the bundle. ` +
|
|
404
|
+
'A store opens something, and a config written without that entry breaks where the driver is used rather ' +
|
|
405
|
+
"than here. Re-run the command that writes it — if it is older than the `driver` export, that is what is " +
|
|
406
|
+
'missing.\n');
|
|
407
|
+
exit(1);
|
|
408
|
+
}
|
|
409
|
+
for (const [, single, double] of held.matchAll(QUOTED)) {
|
|
410
|
+
const one = single ?? double;
|
|
411
|
+
if (one !== undefined && one !== '')
|
|
412
|
+
found.add(one);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return [...found].sort();
|
|
416
|
+
}
|
|
417
|
+
function builtAs(loader) {
|
|
418
|
+
try {
|
|
419
|
+
const held = JSON.parse(readFileSync(join(dirname(loader), '..', '..', 'package.json'), 'utf8'));
|
|
420
|
+
return held.version ?? 'unknown';
|
|
421
|
+
}
|
|
422
|
+
catch {
|
|
423
|
+
return 'unknown';
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function config(root, loader, external) {
|
|
427
|
+
const turbopack = [
|
|
428
|
+
...(root === undefined ? [] : [` root: join(import.meta.dirname, ${JSON.stringify(root)}),`]),
|
|
429
|
+
...(loader === undefined
|
|
430
|
+
? []
|
|
431
|
+
: [
|
|
432
|
+
' rules: {',
|
|
433
|
+
` '**/*.tsx': { loaders: [{ loader: ${JSON.stringify(loader)}, options: ${JSON.stringify({ built: builtAs(loader) })} }] },`,
|
|
434
|
+
' },',
|
|
435
|
+
]),
|
|
436
|
+
];
|
|
437
|
+
const gate = loader === undefined
|
|
438
|
+
? [
|
|
439
|
+
"throw new Error('thread: the compiler that checks this tree cannot be found, so nothing here " +
|
|
440
|
+
"can be compiled. Reinstall the framework packages. A check that cannot run is not a check " +
|
|
441
|
+
"that passed.')",
|
|
442
|
+
'',
|
|
443
|
+
]
|
|
444
|
+
: [
|
|
445
|
+
`import { ungated } from ${JSON.stringify(loader)}`,
|
|
446
|
+
'',
|
|
447
|
+
'const why = ungated(import.meta.filename)',
|
|
448
|
+
'if (why !== null) throw new Error(`thread: ${why}`)',
|
|
449
|
+
'',
|
|
450
|
+
];
|
|
451
|
+
return [
|
|
452
|
+
'/* GENERATED by thread — do not edit. It is derived from where the packages resolve. */',
|
|
453
|
+
'',
|
|
454
|
+
...(root === undefined ? [] : ["import { join } from 'node:path'", '']),
|
|
455
|
+
...gate,
|
|
456
|
+
'export default {',
|
|
457
|
+
...(turbopack.length === 0 ? [] : [' turbopack: {', ...turbopack, ' },']),
|
|
458
|
+
...(external.length === 0
|
|
459
|
+
? []
|
|
460
|
+
: [` serverExternalPackages: [${external.map((one) => JSON.stringify(one)).join(', ')}],`]),
|
|
461
|
+
' agentRules: false,',
|
|
462
|
+
'}',
|
|
463
|
+
'',
|
|
464
|
+
].join('\n');
|
|
465
|
+
}
|
|
466
|
+
async function run() {
|
|
467
|
+
const tree = findTree();
|
|
468
|
+
const at = tree.at;
|
|
469
|
+
const screensAt = inTree(tree, `screens.${'ts'}`);
|
|
470
|
+
if (!existsSync(screensAt)) {
|
|
471
|
+
stdout.write(`routes: this tree has no ${relative(at, screensAt)}, so it declares no screen and there is no map, page or layout to write or check.\n`);
|
|
472
|
+
return 0;
|
|
473
|
+
}
|
|
474
|
+
const sheet = (await import(__rewriteRelativeImportExtension(pathToFileURL(screensAt).href)));
|
|
475
|
+
if (sheet.SCREEN === undefined) {
|
|
476
|
+
stderr.write('routes: _threads/screens.ts exports no `SCREEN`, so nothing declares a screen here.\n');
|
|
477
|
+
return 1;
|
|
478
|
+
}
|
|
479
|
+
const held = (await import(__rewriteRelativeImportExtension(pathToFileURL(inTree(tree, `localizations.${'ts'}`)).href)).catch(() => ({})));
|
|
480
|
+
const source = held.LOCALIZATION?.holds?.find((one) => one.id === 'source')?.is ?? 'en';
|
|
481
|
+
const placed = (await import(__rewriteRelativeImportExtension(pathToFileURL(inTree(tree, `compositions.${'ts'}`)).href)).catch(() => ({})));
|
|
482
|
+
const compositions = placed.COMPOSITION?.declares ?? [];
|
|
483
|
+
const rows = sheet.SCREEN.declares ?? [];
|
|
484
|
+
const texts = new Map();
|
|
485
|
+
for (const row of rows) {
|
|
486
|
+
const file = join(at, row.at);
|
|
487
|
+
if (!existsSync(file)) {
|
|
488
|
+
stderr.write(`routes: \`${row.id}\` is declared at \`${row.at}\` and the file is not there. Run \`thread screens\`.\n`);
|
|
489
|
+
return 1;
|
|
490
|
+
}
|
|
491
|
+
texts.set(row.id, readFileSync(file, 'utf8'));
|
|
492
|
+
}
|
|
493
|
+
const shownOf = (id) => presentedIn(texts.get(id) ?? '');
|
|
494
|
+
const entry = entryAmong(rows, shownOf);
|
|
495
|
+
const made = [];
|
|
496
|
+
const routes = new Map();
|
|
497
|
+
const screens = [];
|
|
498
|
+
for (const row of rows) {
|
|
499
|
+
const text = texts.get(row.id) ?? '';
|
|
500
|
+
const typed = typedRoute(text);
|
|
501
|
+
if (typed !== undefined) {
|
|
502
|
+
stderr.write(`routes: ${row.at} states \`route: '${typed}'\`, and a route is never typed: the first page an app declares ` +
|
|
503
|
+
'answers `/`, every other page answers its own name, and a sheet has no route. Take `route:` out of the ' +
|
|
504
|
+
'file — `thread create screen edit` rewrites it without one when it is given the body.\n');
|
|
505
|
+
return 1;
|
|
506
|
+
}
|
|
507
|
+
const name = nameOf(row.at);
|
|
508
|
+
const shownAs = shownOf(row.id);
|
|
509
|
+
if (!PRESENTATIONS.includes(shownAs)) {
|
|
510
|
+
stderr.write(`routes: ${row.at} is presented as \`${shownAs}\`, and a presentation is not a free word: it is one of ` +
|
|
511
|
+
`${PRESENTATIONS.join(', ')}, because each carries a settled behaviour for portalling, trapping focus and dismissing, ` +
|
|
512
|
+
'and one that is not among them would compile and behave as none of them. Change the `as:` in that file.\n');
|
|
513
|
+
return 1;
|
|
514
|
+
}
|
|
515
|
+
const route = shownAs === PAGE ? routeFor(row.id, row.id === entry) : undefined;
|
|
516
|
+
routes.set(name, route);
|
|
517
|
+
screens.push({
|
|
518
|
+
id: name,
|
|
519
|
+
nameKey: `screen.${row.id}`,
|
|
520
|
+
...(route === undefined ? {} : { path: route }),
|
|
521
|
+
entry: row.id === entry,
|
|
522
|
+
shows: [],
|
|
523
|
+
});
|
|
524
|
+
if (route === undefined)
|
|
525
|
+
continue;
|
|
526
|
+
const where = pageAt(route);
|
|
527
|
+
const stated = (row.derives ?? []).find((one) => one.id === 'page')?.at;
|
|
528
|
+
if (stated !== where) {
|
|
529
|
+
stderr.write(`routes: \`${row.id}\` answers ${route}, so its page is ${where}, and its row ` +
|
|
530
|
+
`${stated === undefined ? 'derives no page' : `says ${stated}`}. Run \`thread create screen edit\` on it — ` +
|
|
531
|
+
'the row is rewritten from where the screen now lives.\n');
|
|
532
|
+
return 1;
|
|
533
|
+
}
|
|
534
|
+
made.push({ path: where, text: page(name, row.at, route) });
|
|
535
|
+
}
|
|
536
|
+
const { links, wrong } = linksOf(at, rows, compositions, routes, wordingFirst(keyProps(at)));
|
|
537
|
+
if (wrong.length > 0) {
|
|
538
|
+
for (const one of wrong)
|
|
539
|
+
stderr.write(`routes: ${one}\n`);
|
|
540
|
+
return 1;
|
|
541
|
+
}
|
|
542
|
+
const map = { specVersion: 1, screens, links };
|
|
543
|
+
made.push({ path: MAP, text: mapModule(map) });
|
|
544
|
+
made.push({ path: CONFIG, text: config(rootFor(at), loaderFor(at), externalFor(at)) });
|
|
545
|
+
const dispatching = existsSync(join(at, CLIENT));
|
|
546
|
+
const moving = rows.length > 0;
|
|
547
|
+
const doored = dispatching || moving;
|
|
548
|
+
const presenting = rows
|
|
549
|
+
.filter((row) => routes.get(nameOf(row.at)) === undefined)
|
|
550
|
+
.map((row) => ({ name: nameOf(row.at), at: row.at }));
|
|
551
|
+
if (doored)
|
|
552
|
+
made.push({ path: DOOR, text: door(existsSync(join(at, DECLARED)), existsSync(join(at, WORDING)), dispatching, moving, presenting) });
|
|
553
|
+
made.push({
|
|
554
|
+
path: LAYOUT,
|
|
555
|
+
text: layout(existsSync(join(at, WORDING)), existsSync(join(at, 'app/_generated/icons.ts')), source, loaderFor(at), existsSync(join(at, DECLARED)), doored),
|
|
556
|
+
});
|
|
557
|
+
const paged = map.screens.filter((one) => one.path !== undefined).length;
|
|
558
|
+
const counted = `${String(map.screens.length)} screen(s), ${String(paged)} route(s), ${String(map.links.length)} link(s)`;
|
|
559
|
+
if (argv.includes('--check')) {
|
|
560
|
+
for (const one of SHADOWS) {
|
|
561
|
+
if (!existsSync(join(at, one)))
|
|
562
|
+
continue;
|
|
563
|
+
stderr.write(`routes: ${one} sits beside ${CONFIG}, and Next loads ${CONFIG} because it is the first name it ` +
|
|
564
|
+
`looks for. Nothing reads ${one} — an edit to it changes nothing and says nothing. Delete it.\n`);
|
|
565
|
+
return 1;
|
|
566
|
+
}
|
|
567
|
+
for (const one of made) {
|
|
568
|
+
let current = '';
|
|
569
|
+
try {
|
|
570
|
+
current = readFileSync(join(at, one.path), 'utf8');
|
|
571
|
+
}
|
|
572
|
+
catch {
|
|
573
|
+
current = '';
|
|
574
|
+
}
|
|
575
|
+
if (current === one.text)
|
|
576
|
+
continue;
|
|
577
|
+
stderr.write(`routes: ${one.path} is not what the declarations produce. A derived file that differs from its ` +
|
|
578
|
+
'generator is a hand edit wearing a generated name. Run `thread routes` and commit what it writes.\n');
|
|
579
|
+
return 1;
|
|
580
|
+
}
|
|
581
|
+
stdout.write(`routes: ${String(made.length)} file(s) are what the screens produce — ${counted}\n`);
|
|
582
|
+
for (const line of shown(map))
|
|
583
|
+
stdout.write(`${line}\n`);
|
|
584
|
+
return 0;
|
|
585
|
+
}
|
|
586
|
+
for (const one of made) {
|
|
587
|
+
mkdirSync(dirname(join(at, one.path)), { recursive: true });
|
|
588
|
+
writeFileSync(join(at, one.path), one.text, 'utf8');
|
|
589
|
+
}
|
|
590
|
+
stdout.write(`routes: the map — ${counted}\n`);
|
|
591
|
+
for (const line of shown(map))
|
|
592
|
+
stdout.write(`${line}\n`);
|
|
593
|
+
stdout.write(`routes: wrote ${String(paged)} page(s), the map and the layout\n`);
|
|
594
|
+
return 0;
|
|
595
|
+
}
|
|
596
|
+
if (invoked(import.meta.url))
|
|
597
|
+
exit(await run());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function namedBy(id: string): Promise<readonly string[]>;
|