@yaks/ui 0.0.0-stage → 0.2.36
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/Address.css +9 -0
- package/Address.js +32 -0
- package/Address.js.map +1 -0
- package/Address.ts +35 -0
- package/Annotated.css +17 -0
- package/Annotated.js +27 -0
- package/Annotated.js.map +1 -0
- package/Annotated.ts +32 -0
- package/AppShell.css +133 -0
- package/AppShell.js +90 -0
- package/AppShell.js.map +1 -0
- package/AppShell.ts +75 -0
- package/At.css +16 -0
- package/At.js +28 -0
- package/At.js.map +1 -0
- package/At.ts +37 -0
- package/Attachments.css +110 -0
- package/Attachments.js +119 -0
- package/Attachments.js.map +1 -0
- package/Attachments.ts +158 -0
- package/Badge.css +41 -0
- package/Badge.js +49 -0
- package/Badge.js.map +1 -0
- package/Badge.ts +38 -0
- package/Body.css +61 -0
- package/Body.js +103 -0
- package/Body.js.map +1 -0
- package/Body.ts +144 -0
- package/Button.css +121 -0
- package/Button.js +161 -0
- package/Button.js.map +1 -0
- package/Button.ts +92 -0
- package/Card.css +173 -0
- package/Card.js +165 -0
- package/Card.js.map +1 -0
- package/Card.ts +185 -0
- package/Cards.css +16 -0
- package/Cards.js +36 -0
- package/Cards.js.map +1 -0
- package/Cards.ts +64 -0
- package/Catalog.css +53 -0
- package/Catalog.js +55 -0
- package/Catalog.js.map +1 -0
- package/Catalog.ts +77 -0
- package/Chart.css +55 -0
- package/Chart.js +54 -0
- package/Chart.js.map +1 -0
- package/Chart.ts +62 -0
- package/Check.css +27 -0
- package/Check.js +77 -0
- package/Check.js.map +1 -0
- package/Check.ts +109 -0
- package/Chip.css +64 -0
- package/Chip.js +100 -0
- package/Chip.js.map +1 -0
- package/Chip.ts +66 -0
- package/Chips.css +10 -0
- package/Chips.js +41 -0
- package/Chips.js.map +1 -0
- package/Chips.ts +49 -0
- package/Choices.css +59 -0
- package/Choices.js +56 -0
- package/Choices.js.map +1 -0
- package/Choices.ts +73 -0
- package/Combobox.js +115 -0
- package/Combobox.js.map +1 -0
- package/Combobox.ts +230 -0
- package/Composer.css +247 -0
- package/Composer.js +222 -0
- package/Composer.js.map +1 -0
- package/Composer.ts +249 -0
- package/Contents.css +87 -0
- package/Contents.js +85 -0
- package/Contents.js.map +1 -0
- package/Contents.ts +117 -0
- package/Copy.css +28 -0
- package/Copy.js +62 -0
- package/Copy.js.map +1 -0
- package/Copy.ts +76 -0
- package/Doc.css +29 -0
- package/Doc.js +46 -0
- package/Doc.js.map +1 -0
- package/Doc.ts +64 -0
- package/Dock.css +157 -0
- package/Dock.js +229 -0
- package/Dock.js.map +1 -0
- package/Dock.ts +234 -0
- package/Dot.css +132 -0
- package/Dot.js +91 -0
- package/Dot.js.map +1 -0
- package/Dot.ts +72 -0
- package/Drop.css +133 -0
- package/Drop.js +148 -0
- package/Drop.js.map +1 -0
- package/Drop.ts +162 -0
- package/Edit.css +32 -0
- package/Edit.js +77 -0
- package/Edit.js.map +1 -0
- package/Edit.ts +72 -0
- package/Empty.css +32 -0
- package/Empty.js +45 -0
- package/Empty.js.map +1 -0
- package/Empty.ts +61 -0
- package/ErrorNotice.css +107 -0
- package/ErrorNotice.js +127 -0
- package/ErrorNotice.js.map +1 -0
- package/ErrorNotice.ts +133 -0
- package/Field.css +42 -0
- package/Field.js +186 -0
- package/Field.js.map +1 -0
- package/Field.ts +251 -0
- package/Form.css +95 -0
- package/Form.js +158 -0
- package/Form.js.map +1 -0
- package/Form.ts +212 -0
- package/Gallery.css +42 -0
- package/Gallery.js +57 -0
- package/Gallery.js.map +1 -0
- package/Gallery.ts +89 -0
- package/Group.css +8 -0
- package/Group.js +25 -0
- package/Group.js.map +1 -0
- package/Group.ts +40 -0
- package/Head.css +108 -0
- package/Head.js +124 -0
- package/Head.js.map +1 -0
- package/Head.ts +161 -0
- package/Icon.css +14 -0
- package/Icon.js +79 -0
- package/Icon.js.map +1 -0
- package/Icon.ts +78 -0
- package/IconButton.css +32 -0
- package/IconButton.js +74 -0
- package/IconButton.js.map +1 -0
- package/IconButton.ts +55 -0
- package/Id.css +29 -0
- package/Id.js +42 -0
- package/Id.js.map +1 -0
- package/Id.ts +31 -0
- package/Identity.css +122 -0
- package/Identity.js +88 -0
- package/Identity.js.map +1 -0
- package/Identity.ts +100 -0
- package/Index.css +68 -0
- package/Index.js +66 -0
- package/Index.js.map +1 -0
- package/Index.ts +63 -0
- package/LICENSE +202 -0
- package/Layer.css +82 -0
- package/Layer.js +86 -0
- package/Layer.js.map +1 -0
- package/Layer.ts +85 -0
- package/Lightbox.css +86 -0
- package/Lightbox.js +69 -0
- package/Lightbox.js.map +1 -0
- package/Lightbox.ts +79 -0
- package/Loading.css +22 -0
- package/Loading.js +75 -0
- package/Loading.js.map +1 -0
- package/Loading.ts +87 -0
- package/Logo.css +32 -0
- package/Logo.js +69 -0
- package/Logo.js.map +1 -0
- package/Logo.ts +81 -0
- package/Match.css +7 -0
- package/Match.js +51 -0
- package/Match.js.map +1 -0
- package/Match.ts +53 -0
- package/Menu.css +202 -0
- package/Menu.js +197 -0
- package/Menu.js.map +1 -0
- package/Menu.ts +233 -0
- package/Meter.css +49 -0
- package/Meter.js +149 -0
- package/Meter.js.map +1 -0
- package/Meter.ts +126 -0
- package/Metrics.css +43 -0
- package/Metrics.js +72 -0
- package/Metrics.js.map +1 -0
- package/Metrics.ts +66 -0
- package/Modal.css +94 -0
- package/Modal.js +114 -0
- package/Modal.js.map +1 -0
- package/Modal.ts +149 -0
- package/ModalDOM.css +23 -0
- package/More.css +135 -0
- package/More.js +135 -0
- package/More.js.map +1 -0
- package/More.ts +157 -0
- package/Notes.css +51 -0
- package/Notes.js +64 -0
- package/Notes.js.map +1 -0
- package/Notes.ts +95 -0
- package/Notice.css +30 -0
- package/Notice.js +50 -0
- package/Notice.js.map +1 -0
- package/Notice.ts +40 -0
- package/Overlay.css +8 -0
- package/Overlay.js +25 -0
- package/Overlay.js.map +1 -0
- package/Overlay.ts +33 -0
- package/Pager.css +33 -0
- package/Pager.js +44 -0
- package/Pager.js.map +1 -0
- package/Pager.ts +56 -0
- package/Pairs.css +50 -0
- package/Pairs.js +45 -0
- package/Pairs.js.map +1 -0
- package/Pairs.ts +88 -0
- package/Palette.css +77 -0
- package/Palette.js +41 -0
- package/Palette.js.map +1 -0
- package/Palette.ts +44 -0
- package/Panes.css +68 -0
- package/Panes.js +100 -0
- package/Panes.js.map +1 -0
- package/Panes.ts +97 -0
- package/Passage.css +58 -0
- package/Passage.js +80 -0
- package/Passage.js.map +1 -0
- package/Passage.ts +112 -0
- package/Peek.css +75 -0
- package/Peek.js +51 -0
- package/Peek.js.map +1 -0
- package/Peek.ts +74 -0
- package/Pills.css +127 -0
- package/Pills.js +119 -0
- package/Pills.js.map +1 -0
- package/Pills.ts +131 -0
- package/Plan.css +73 -0
- package/Plan.js +62 -0
- package/Plan.js.map +1 -0
- package/Plan.ts +80 -0
- package/Popover.css +47 -0
- package/Popover.js +62 -0
- package/Popover.js.map +1 -0
- package/Popover.ts +80 -0
- package/Preview.css +89 -0
- package/Preview.js +84 -0
- package/Preview.js.map +1 -0
- package/Preview.ts +98 -0
- package/Prop.css +117 -0
- package/Prop.js +94 -0
- package/Prop.js.map +1 -0
- package/Prop.ts +91 -0
- package/Quote.css +55 -0
- package/Quote.js +79 -0
- package/Quote.js.map +1 -0
- package/Quote.ts +85 -0
- package/README.md +596 -2
- package/Report.css +76 -0
- package/Report.js +105 -0
- package/Report.js.map +1 -0
- package/Report.ts +118 -0
- package/Rows.css +289 -0
- package/Rows.js +265 -0
- package/Rows.js.map +1 -0
- package/Rows.ts +337 -0
- package/Save.css +112 -0
- package/Save.js +100 -0
- package/Save.js.map +1 -0
- package/Save.ts +102 -0
- package/Section.css +52 -0
- package/Section.js +73 -0
- package/Section.js.map +1 -0
- package/Section.ts +86 -0
- package/Select.css +140 -0
- package/Select.js +208 -0
- package/Select.js.map +1 -0
- package/Select.ts +238 -0
- package/Shell.css +292 -0
- package/Shell.js +197 -0
- package/Shell.js.map +1 -0
- package/Shell.ts +193 -0
- package/SideNav.css +105 -0
- package/SideNav.js +197 -0
- package/SideNav.js.map +1 -0
- package/SideNav.ts +189 -0
- package/Skip.css +11 -0
- package/Skip.js +18 -0
- package/Skip.js.map +1 -0
- package/Skip.ts +16 -0
- package/Spark.css +14 -0
- package/Spark.js +84 -0
- package/Spark.js.map +1 -0
- package/Spark.ts +67 -0
- package/Stack.css +13 -0
- package/Stack.js +20 -0
- package/Stack.js.map +1 -0
- package/Stack.ts +31 -0
- package/Stamp.css +11 -0
- package/Stamp.js +40 -0
- package/Stamp.js.map +1 -0
- package/Stamp.ts +62 -0
- package/State.css +10 -0
- package/State.js +38 -0
- package/State.js.map +1 -0
- package/State.ts +38 -0
- package/Surface.css +139 -0
- package/Surface.js +79 -0
- package/Surface.js.map +1 -0
- package/Surface.ts +55 -0
- package/Table.css +147 -0
- package/Table.js +289 -0
- package/Table.js.map +1 -0
- package/Table.ts +343 -0
- package/Tabs.css +100 -0
- package/Tabs.js +108 -0
- package/Tabs.js.map +1 -0
- package/Tabs.ts +111 -0
- package/Tile.css +164 -0
- package/Tile.js +211 -0
- package/Tile.js.map +1 -0
- package/Tile.ts +174 -0
- package/Time.css +5 -0
- package/Time.js +80 -0
- package/Time.js.map +1 -0
- package/Time.ts +105 -0
- package/Timeline.css +35 -0
- package/Timeline.js +55 -0
- package/Timeline.js.map +1 -0
- package/Timeline.ts +84 -0
- package/Tip.css +18 -0
- package/Tip.js +24 -0
- package/Tip.js.map +1 -0
- package/Tip.ts +29 -0
- package/Toast.css +25 -0
- package/Toast.js +32 -0
- package/Toast.js.map +1 -0
- package/Toast.ts +34 -0
- package/Toolbar.css +66 -0
- package/Toolbar.js +58 -0
- package/Toolbar.js.map +1 -0
- package/Toolbar.ts +68 -0
- package/Transcript.css +221 -0
- package/Transcript.js +254 -0
- package/Transcript.js.map +1 -0
- package/Transcript.ts +296 -0
- package/Turns.css +49 -0
- package/Turns.js +58 -0
- package/Turns.js.map +1 -0
- package/Turns.ts +67 -0
- package/Value.css +33 -0
- package/Value.js +60 -0
- package/Value.js.map +1 -0
- package/Value.ts +48 -0
- package/_dist/Address.d.ts +3 -0
- package/_dist/Address.d.ts.map +1 -0
- package/_dist/Annotated.d.ts +3 -0
- package/_dist/Annotated.d.ts.map +1 -0
- package/_dist/AppShell.d.ts +3 -0
- package/_dist/AppShell.d.ts.map +1 -0
- package/_dist/At.d.ts +14 -0
- package/_dist/At.d.ts.map +1 -0
- package/_dist/Attachments.d.ts +6 -0
- package/_dist/Attachments.d.ts.map +1 -0
- package/_dist/Badge.d.ts +19 -0
- package/_dist/Badge.d.ts.map +1 -0
- package/_dist/Body.d.ts +5 -0
- package/_dist/Body.d.ts.map +1 -0
- package/_dist/Button.d.ts +18 -0
- package/_dist/Button.d.ts.map +1 -0
- package/_dist/Card.d.ts +28 -0
- package/_dist/Card.d.ts.map +1 -0
- package/_dist/Cards.d.ts +15 -0
- package/_dist/Cards.d.ts.map +1 -0
- package/_dist/Catalog.d.ts +3 -0
- package/_dist/Catalog.d.ts.map +1 -0
- package/_dist/Chart.d.ts +5 -0
- package/_dist/Chart.d.ts.map +1 -0
- package/_dist/Check.d.ts +17 -0
- package/_dist/Check.d.ts.map +1 -0
- package/_dist/Chip.d.ts +22 -0
- package/_dist/Chip.d.ts.map +1 -0
- package/_dist/Chips.d.ts +15 -0
- package/_dist/Chips.d.ts.map +1 -0
- package/_dist/Choices.d.ts +3 -0
- package/_dist/Choices.d.ts.map +1 -0
- package/_dist/Combobox.d.ts +55 -0
- package/_dist/Combobox.d.ts.map +1 -0
- package/_dist/Composer.d.ts +15 -0
- package/_dist/Composer.d.ts.map +1 -0
- package/_dist/Contents.d.ts +20 -0
- package/_dist/Contents.d.ts.map +1 -0
- package/_dist/Copy.d.ts +24 -0
- package/_dist/Copy.d.ts.map +1 -0
- package/_dist/Doc.d.ts +3 -0
- package/_dist/Doc.d.ts.map +1 -0
- package/_dist/Dock.d.ts +29 -0
- package/_dist/Dock.d.ts.map +1 -0
- package/_dist/Dot.d.ts +16 -0
- package/_dist/Dot.d.ts.map +1 -0
- package/_dist/Drop.d.ts +27 -0
- package/_dist/Drop.d.ts.map +1 -0
- package/_dist/Edit.d.ts +3 -0
- package/_dist/Edit.d.ts.map +1 -0
- package/_dist/Empty.d.ts +16 -0
- package/_dist/Empty.d.ts.map +1 -0
- package/_dist/ErrorNotice.d.ts +16 -0
- package/_dist/ErrorNotice.d.ts.map +1 -0
- package/_dist/Field.d.ts +53 -0
- package/_dist/Field.d.ts.map +1 -0
- package/_dist/Form.d.ts +44 -0
- package/_dist/Form.d.ts.map +1 -0
- package/_dist/Gallery.d.ts +3 -0
- package/_dist/Gallery.d.ts.map +1 -0
- package/_dist/Group.d.ts +14 -0
- package/_dist/Group.d.ts.map +1 -0
- package/_dist/Head.d.ts +13 -0
- package/_dist/Head.d.ts.map +1 -0
- package/_dist/Icon.d.ts +23 -0
- package/_dist/Icon.d.ts.map +1 -0
- package/_dist/IconButton.d.ts +8 -0
- package/_dist/IconButton.d.ts.map +1 -0
- package/_dist/Id.d.ts +3 -0
- package/_dist/Id.d.ts.map +1 -0
- package/_dist/Identity.d.ts +15 -0
- package/_dist/Identity.d.ts.map +1 -0
- package/_dist/Index.d.ts +3 -0
- package/_dist/Index.d.ts.map +1 -0
- package/_dist/Layer.d.ts +8 -0
- package/_dist/Layer.d.ts.map +1 -0
- package/_dist/Lightbox.d.ts +27 -0
- package/_dist/Lightbox.d.ts.map +1 -0
- package/_dist/Loading.d.ts +24 -0
- package/_dist/Loading.d.ts.map +1 -0
- package/_dist/Logo.d.ts +26 -0
- package/_dist/Logo.d.ts.map +1 -0
- package/_dist/Match.d.ts +5 -0
- package/_dist/Match.d.ts.map +1 -0
- package/_dist/Menu.d.ts +23 -0
- package/_dist/Menu.d.ts.map +1 -0
- package/_dist/Meter.d.ts +10 -0
- package/_dist/Meter.d.ts.map +1 -0
- package/_dist/Metrics.d.ts +3 -0
- package/_dist/Metrics.d.ts.map +1 -0
- package/_dist/Modal.d.ts +32 -0
- package/_dist/Modal.d.ts.map +1 -0
- package/_dist/More.d.ts +29 -0
- package/_dist/More.d.ts.map +1 -0
- package/_dist/Notes.d.ts +3 -0
- package/_dist/Notes.d.ts.map +1 -0
- package/_dist/Notice.d.ts +15 -0
- package/_dist/Notice.d.ts.map +1 -0
- package/_dist/Overlay.d.ts +3 -0
- package/_dist/Overlay.d.ts.map +1 -0
- package/_dist/Pager.d.ts +3 -0
- package/_dist/Pager.d.ts.map +1 -0
- package/_dist/Pairs.d.ts +3 -0
- package/_dist/Pairs.d.ts.map +1 -0
- package/_dist/Palette.d.ts +3 -0
- package/_dist/Palette.d.ts.map +1 -0
- package/_dist/Panes.d.ts +3 -0
- package/_dist/Panes.d.ts.map +1 -0
- package/_dist/Passage.d.ts +3 -0
- package/_dist/Passage.d.ts.map +1 -0
- package/_dist/Peek.d.ts +3 -0
- package/_dist/Peek.d.ts.map +1 -0
- package/_dist/Pills.d.ts +3 -0
- package/_dist/Pills.d.ts.map +1 -0
- package/_dist/Plan.d.ts +4 -0
- package/_dist/Plan.d.ts.map +1 -0
- package/_dist/Popover.d.ts +3 -0
- package/_dist/Popover.d.ts.map +1 -0
- package/_dist/Preview.d.ts +8 -0
- package/_dist/Preview.d.ts.map +1 -0
- package/_dist/Prop.d.ts +7 -0
- package/_dist/Prop.d.ts.map +1 -0
- package/_dist/Quote.d.ts +3 -0
- package/_dist/Quote.d.ts.map +1 -0
- package/_dist/Report.d.ts +8 -0
- package/_dist/Report.d.ts.map +1 -0
- package/_dist/Rows.d.ts +36 -0
- package/_dist/Rows.d.ts.map +1 -0
- package/_dist/Save.d.ts +4 -0
- package/_dist/Save.d.ts.map +1 -0
- package/_dist/Section.d.ts +3 -0
- package/_dist/Section.d.ts.map +1 -0
- package/_dist/Select.d.ts +29 -0
- package/_dist/Select.d.ts.map +1 -0
- package/_dist/Shell.d.ts +3 -0
- package/_dist/Shell.d.ts.map +1 -0
- package/_dist/SideNav.d.ts +31 -0
- package/_dist/SideNav.d.ts.map +1 -0
- package/_dist/Skip.d.ts +3 -0
- package/_dist/Skip.d.ts.map +1 -0
- package/_dist/Spark.d.ts +9 -0
- package/_dist/Spark.d.ts.map +1 -0
- package/_dist/Stack.d.ts +11 -0
- package/_dist/Stack.d.ts.map +1 -0
- package/_dist/Stamp.d.ts +3 -0
- package/_dist/Stamp.d.ts.map +1 -0
- package/_dist/State.d.ts +16 -0
- package/_dist/State.d.ts.map +1 -0
- package/_dist/Surface.d.ts +7 -0
- package/_dist/Surface.d.ts.map +1 -0
- package/_dist/Table.d.ts +10 -0
- package/_dist/Table.d.ts.map +1 -0
- package/_dist/Tabs.d.ts +30 -0
- package/_dist/Tabs.d.ts.map +1 -0
- package/_dist/Tile.d.ts +3 -0
- package/_dist/Tile.d.ts.map +1 -0
- package/_dist/Time.d.ts +24 -0
- package/_dist/Time.d.ts.map +1 -0
- package/_dist/Timeline.d.ts +3 -0
- package/_dist/Timeline.d.ts.map +1 -0
- package/_dist/Tip.d.ts +3 -0
- package/_dist/Tip.d.ts.map +1 -0
- package/_dist/Toast.d.ts +5 -0
- package/_dist/Toast.d.ts.map +1 -0
- package/_dist/Toolbar.d.ts +3 -0
- package/_dist/Toolbar.d.ts.map +1 -0
- package/_dist/Transcript.d.ts +35 -0
- package/_dist/Transcript.d.ts.map +1 -0
- package/_dist/Turns.d.ts +3 -0
- package/_dist/Turns.d.ts.map +1 -0
- package/_dist/Value.d.ts +3 -0
- package/_dist/Value.d.ts.map +1 -0
- package/_dist/ahead.d.ts +41 -0
- package/_dist/ahead.d.ts.map +1 -0
- package/_dist/chart-marks.d.ts +75 -0
- package/_dist/chart-marks.d.ts.map +1 -0
- package/_dist/clock.d.ts +4 -0
- package/_dist/clock.d.ts.map +1 -0
- package/_dist/contents-browser.d.ts +29 -0
- package/_dist/contents-browser.d.ts.map +1 -0
- package/_dist/contributions.d.ts +5 -0
- package/_dist/contributions.d.ts.map +1 -0
- package/_dist/copy-browser.d.ts +4 -0
- package/_dist/copy-browser.d.ts.map +1 -0
- package/_dist/el.d.ts +58 -0
- package/_dist/el.d.ts.map +1 -0
- package/_dist/everforest.d.ts +8 -0
- package/_dist/everforest.d.ts.map +1 -0
- package/_dist/float.d.ts +55 -0
- package/_dist/float.d.ts.map +1 -0
- package/_dist/gouache.d.ts +9 -0
- package/_dist/gouache.d.ts.map +1 -0
- package/_dist/guide.d.ts +38 -0
- package/_dist/guide.d.ts.map +1 -0
- package/_dist/halved.d.ts +3 -0
- package/_dist/halved.d.ts.map +1 -0
- package/_dist/history.d.ts +15 -0
- package/_dist/history.d.ts.map +1 -0
- package/_dist/interaction.d.ts +15 -0
- package/_dist/interaction.d.ts.map +1 -0
- package/_dist/kit.d.ts +30 -0
- package/_dist/kit.d.ts.map +1 -0
- package/_dist/ledger.d.ts +3 -0
- package/_dist/ledger.d.ts.map +1 -0
- package/_dist/linen.d.ts +8 -0
- package/_dist/linen.d.ts.map +1 -0
- package/_dist/menus-browser.d.ts +2 -0
- package/_dist/menus-browser.d.ts.map +1 -0
- package/_dist/menus.d.ts +6 -0
- package/_dist/menus.d.ts.map +1 -0
- package/_dist/mod.d.ts +47 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/modal-browser.d.ts +2 -0
- package/_dist/modal-browser.d.ts.map +1 -0
- package/_dist/modal-head.d.ts +43 -0
- package/_dist/modal-head.d.ts.map +1 -0
- package/_dist/navigate.d.ts +170 -0
- package/_dist/navigate.d.ts.map +1 -0
- package/_dist/overlays.d.ts +16 -0
- package/_dist/overlays.d.ts.map +1 -0
- package/_dist/palette-browser.d.ts +3 -0
- package/_dist/palette-browser.d.ts.map +1 -0
- package/_dist/panes-browser.d.ts +4 -0
- package/_dist/panes-browser.d.ts.map +1 -0
- package/_dist/paper.d.ts +6 -0
- package/_dist/paper.d.ts.map +1 -0
- package/_dist/parts.d.ts +102 -0
- package/_dist/parts.d.ts.map +1 -0
- package/_dist/pencil.d.ts +6 -0
- package/_dist/pencil.d.ts.map +1 -0
- package/_dist/placement.d.ts +12 -0
- package/_dist/placement.d.ts.map +1 -0
- package/_dist/relative.d.ts +41 -0
- package/_dist/relative.d.ts.map +1 -0
- package/_dist/rosepine.d.ts +8 -0
- package/_dist/rosepine.d.ts.map +1 -0
- package/_dist/routes.d.ts +20 -0
- package/_dist/routes.d.ts.map +1 -0
- package/_dist/sheet.d.ts +44 -0
- package/_dist/sheet.d.ts.map +1 -0
- package/_dist/slide.d.ts +4 -0
- package/_dist/slide.d.ts.map +1 -0
- package/_dist/stock.d.ts +21 -0
- package/_dist/stock.d.ts.map +1 -0
- package/_dist/store.d.ts +2 -0
- package/_dist/store.d.ts.map +1 -0
- package/_dist/theme.d.ts +102 -0
- package/_dist/theme.d.ts.map +1 -0
- package/_dist/ui.d.ts +2 -0
- package/_dist/ui.d.ts.map +1 -0
- package/_dist/video-cover.d.ts +3 -0
- package/_dist/video-cover.d.ts.map +1 -0
- package/_dist/viewport.d.ts +14 -0
- package/_dist/viewport.d.ts.map +1 -0
- package/_dist/wear.d.ts +5 -0
- package/_dist/wear.d.ts.map +1 -0
- package/ahead.js +81 -0
- package/ahead.js.map +1 -0
- package/ahead.ts +102 -0
- package/base.css +220 -0
- package/base.js +129 -0
- package/base.js.map +1 -0
- package/base.ts +127 -0
- package/chart-marks.js +156 -0
- package/chart-marks.js.map +1 -0
- package/chart-marks.ts +221 -0
- package/clock.js +41 -0
- package/clock.js.map +1 -0
- package/clock.ts +39 -0
- package/contents-browser.js +122 -0
- package/contents-browser.js.map +1 -0
- package/contents-browser.ts +135 -0
- package/contributions.js +28 -0
- package/contributions.js.map +1 -0
- package/contributions.ts +21 -0
- package/copy-browser.js +39 -0
- package/copy-browser.js.map +1 -0
- package/copy-browser.ts +44 -0
- package/deno.json +1 -0
- package/derived.css +64 -0
- package/el.js +176 -0
- package/el.js.map +1 -0
- package/el.ts +240 -0
- package/everforest.css +65 -0
- package/everforest.js +54 -0
- package/everforest.js.map +1 -0
- package/everforest.ts +52 -0
- package/float.js +182 -0
- package/float.js.map +1 -0
- package/float.ts +222 -0
- package/gouache.css +62 -0
- package/gouache.js +54 -0
- package/gouache.js.map +1 -0
- package/gouache.ts +52 -0
- package/guide.js +124 -0
- package/guide.js.map +1 -0
- package/guide.ts +222 -0
- package/halved.js +88 -0
- package/halved.js.map +1 -0
- package/halved.ts +102 -0
- package/history.js +11 -0
- package/history.js.map +1 -0
- package/history.ts +22 -0
- package/interaction.js +23 -0
- package/interaction.js.map +1 -0
- package/interaction.ts +43 -0
- package/kit.js +345 -0
- package/kit.js.map +1 -0
- package/kit.ts +408 -0
- package/ledger/Button.css +22 -0
- package/ledger/Head.css +72 -0
- package/ledger/Tabs.css +19 -0
- package/ledger/Tile.css +12 -0
- package/ledger.js +52 -0
- package/ledger.js.map +1 -0
- package/ledger.ts +34 -0
- package/linen.css +71 -0
- package/linen.js +54 -0
- package/linen.js.map +1 -0
- package/linen.ts +52 -0
- package/lucide.d.ts +4 -0
- package/menus-browser.js +72 -0
- package/menus-browser.js.map +1 -0
- package/menus-browser.ts +75 -0
- package/menus.js +84 -0
- package/menus.js.map +1 -0
- package/menus.ts +90 -0
- package/mod.js +46 -0
- package/mod.js.map +1 -0
- package/mod.ts +78 -0
- package/modal-browser.js +29 -0
- package/modal-browser.js.map +1 -0
- package/modal-browser.ts +31 -0
- package/modal-head.js +75 -0
- package/modal-head.js.map +1 -0
- package/modal-head.ts +81 -0
- package/navigate.js +934 -0
- package/navigate.js.map +1 -0
- package/navigate.ts +1177 -0
- package/overlays.js +177 -0
- package/overlays.js.map +1 -0
- package/overlays.ts +257 -0
- package/package.json +280 -4
- package/palette-browser.js +52 -0
- package/palette-browser.js.map +1 -0
- package/palette-browser.ts +54 -0
- package/panes-browser.js +40 -0
- package/panes-browser.js.map +1 -0
- package/panes-browser.ts +59 -0
- package/paper/base.css +28 -0
- package/paper/grain.css +18 -0
- package/paper.js +14 -0
- package/paper.js.map +1 -0
- package/paper.ts +16 -0
- package/parts.js +102 -0
- package/parts.js.map +1 -0
- package/parts.ts +117 -0
- package/pencil/Address.css +5 -0
- package/pencil/At.css +14 -0
- package/pencil/Body.css +10 -0
- package/pencil/Button.css +81 -0
- package/pencil/Card.css +175 -0
- package/pencil/Chart.css +31 -0
- package/pencil/Check.css +66 -0
- package/pencil/Chip.css +100 -0
- package/pencil/Chips.css +6 -0
- package/pencil/Copy.css +33 -0
- package/pencil/Drop.css +145 -0
- package/pencil/Empty.css +48 -0
- package/pencil/Field.css +42 -0
- package/pencil/Form.css +88 -0
- package/pencil/Loading.css +14 -0
- package/pencil/Menu.css +26 -0
- package/pencil/More.css +41 -0
- package/pencil/Report.css +11 -0
- package/pencil/Rows.css +48 -0
- package/pencil/SideNav.css +173 -0
- package/pencil/State.css +28 -0
- package/pencil/Surface.css +69 -0
- package/pencil/Tabs.css +137 -0
- package/pencil/base.css +19 -0
- package/pencil/paper.webp +0 -0
- package/pencil/pencil.svg +181 -0
- package/pencil.js +81 -0
- package/pencil.js.map +1 -0
- package/pencil.ts +34 -0
- package/placement.js +62 -0
- package/placement.js.map +1 -0
- package/placement.ts +93 -0
- package/relative.js +150 -0
- package/relative.js.map +1 -0
- package/relative.ts +186 -0
- package/resizes.js +23 -0
- package/resizes.js.map +1 -0
- package/resizes.ts +37 -0
- package/rosepine.css +59 -0
- package/rosepine.js +54 -0
- package/rosepine.js.map +1 -0
- package/rosepine.ts +52 -0
- package/routes.js +136 -0
- package/routes.js.map +1 -0
- package/routes.ts +190 -0
- package/sheet.js +7 -0
- package/sheet.js.map +1 -0
- package/sheet.ts +72 -0
- package/slide.js +37 -0
- package/slide.js.map +1 -0
- package/slide.ts +41 -0
- package/stock.js +38 -0
- package/stock.js.map +1 -0
- package/stock.ts +54 -0
- package/store.js +6 -0
- package/store.js.map +1 -0
- package/store.ts +14 -0
- package/theme.js +21 -0
- package/theme.js.map +1 -0
- package/theme.ts +159 -0
- package/ui.js +2 -0
- package/ui.js.map +1 -0
- package/ui.ts +2 -0
- package/video-cover.js +55 -0
- package/video-cover.js.map +1 -0
- package/video-cover.ts +72 -0
- package/viewport.js +56 -0
- package/viewport.js.map +1 -0
- package/viewport.ts +61 -0
- package/wear-build.ts +12 -0
- package/wear.js +40 -0
- package/wear.js.map +1 -0
- package/wear.ts +65 -0
package/navigate.js
ADDED
|
@@ -0,0 +1,934 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moving between a site's server-drawn pages without loading a new document.
|
|
3
|
+
* A link to a page of the same origin is fetched, and the page it answers is
|
|
4
|
+
* laid over the one on screen (`morph`): a node that stands in both pages
|
|
5
|
+
* keeps its place, its listeners and its loaded image, and only what differs
|
|
6
|
+
* is changed. The sidebar and the header of a shell stay as they were, and an
|
|
7
|
+
* image beside a link never loads again.
|
|
8
|
+
*
|
|
9
|
+
* A page takes part by loading the navigator in a script marked
|
|
10
|
+
* `data-navigate` (`TAKES`, `start`); a link to a page that
|
|
11
|
+
* does not load it, a failed fetch or an answer that is not HTML is followed
|
|
12
|
+
* as the browser would follow it, and so is one whose swap fails.
|
|
13
|
+
*
|
|
14
|
+
* What scripts do across a swap:
|
|
15
|
+
*
|
|
16
|
+
* - A script with a `src` runs once in the document's life, the first time a
|
|
17
|
+
* page names it. One that binds elements as it loads binds what each swap
|
|
18
|
+
* brings on `yak-page` too, once an element (`arrived`), and once
|
|
19
|
+
* across the copies of it pages from different releases name (`hold`).
|
|
20
|
+
* - A script written into the page is the page's own: it runs after every
|
|
21
|
+
* swap that lands on its page. Before each swap the document hears
|
|
22
|
+
* `yak-leave`, and such a script takes back there what it set going (a
|
|
23
|
+
* listener on the window, a timer), most simply by adding its listeners
|
|
24
|
+
* with a signal it aborts then (`leaving`).
|
|
25
|
+
* - A script marked `data-stays` holds its page (a socket, a mounted app)
|
|
26
|
+
* and cannot be taken back: a page holding one is left by loading the next.
|
|
27
|
+
* It still draws in place what it draws itself (`DRAW`), since it is not
|
|
28
|
+
* left.
|
|
29
|
+
*
|
|
30
|
+
* A region a script draws for the whole tab rather than for one page (an
|
|
31
|
+
* overlay over every page) is marked `data-kept` (`KEPT`): where the next page
|
|
32
|
+
* has it too, by its id, a swap leaves it as it stands, open, typed in and
|
|
33
|
+
* drawn, and its script goes on drawing it.
|
|
34
|
+
*
|
|
35
|
+
* @module
|
|
36
|
+
*/ import { slideIn } from "./slide.js";
|
|
37
|
+
import { system } from "@yaks/fp";
|
|
38
|
+
import { rayOf } from "@yaks/trace/browser";
|
|
39
|
+
import { result } from "./interaction.js";
|
|
40
|
+
import { AHEAD, lookingAhead, WARM, warmer } from "./ahead.js";
|
|
41
|
+
export { AHEAD, lookingAhead, WARM };
|
|
42
|
+
/** The mark on the script that loads the navigator: a page wearing it
|
|
43
|
+
* takes part. */ export let TAKES = 'data-navigate';
|
|
44
|
+
/** The mark on a region a script draws across pages, which a swap leaves
|
|
45
|
+
* as it is where the next page has it too. */ export let KEPT = 'data-kept';
|
|
46
|
+
/** Heard on the document before a swap, by the page it takes away. */ export let LEAVE = 'yak-leave';
|
|
47
|
+
/** Heard on the document after a swap, by the page it brought. */ export let PAGE = 'yak-page';
|
|
48
|
+
let ELEMENT = 1;
|
|
49
|
+
let TEXT = 3;
|
|
50
|
+
let COMMENT = 8;
|
|
51
|
+
let el = (n)=>n.nodeType == ELEMENT ? n : null;
|
|
52
|
+
// What makes a node the same node in both pages, where something does: its
|
|
53
|
+
// id, its `data-key`, the address an image, script, video, sound, frame, link
|
|
54
|
+
// or anchor names. A video kept by its address goes on playing where the
|
|
55
|
+
// nodes before it changed.
|
|
56
|
+
let SOURCED = new Set([
|
|
57
|
+
'img',
|
|
58
|
+
'script',
|
|
59
|
+
'video',
|
|
60
|
+
'audio',
|
|
61
|
+
'iframe'
|
|
62
|
+
]);
|
|
63
|
+
let keyOf = (n)=>{
|
|
64
|
+
let e = el(n);
|
|
65
|
+
if (!e) return null;
|
|
66
|
+
let tag = e.localName;
|
|
67
|
+
if (e.id) return `${tag}#${e.id}`;
|
|
68
|
+
let key = e.getAttribute('data-key');
|
|
69
|
+
if (key != null) return `${tag}[${key}]`;
|
|
70
|
+
let at = SOURCED.has(tag) ? e.getAttribute('src') : tag == 'a' || tag == 'link' ? e.getAttribute('href') : null;
|
|
71
|
+
return at ? `${tag} ${e.getAttribute('rel') ?? ''} ${at}` : null;
|
|
72
|
+
};
|
|
73
|
+
let alike = (a, b)=>a.nodeType == b.nodeType && (a.nodeType != ELEMENT || a.localName == b.localName);
|
|
74
|
+
let size = (n)=>{
|
|
75
|
+
let count = 1;
|
|
76
|
+
for (let c of n.childNodes)count += size(c);
|
|
77
|
+
return count;
|
|
78
|
+
};
|
|
79
|
+
// A form control whose value the page sends: set as the property too, since
|
|
80
|
+
// the attribute alone no longer moves what a control shows once it is drawn.
|
|
81
|
+
let control = (a, b)=>{
|
|
82
|
+
let input = a;
|
|
83
|
+
if (a.localName == 'input') {
|
|
84
|
+
let value = b.getAttribute('value');
|
|
85
|
+
if (value != a.getAttribute('value')) input.value = value ?? '';
|
|
86
|
+
let checked = b.hasAttribute('checked');
|
|
87
|
+
if (checked != a.hasAttribute('checked')) input.checked = checked;
|
|
88
|
+
}
|
|
89
|
+
if (a.localName == 'option') {
|
|
90
|
+
let selected = b.hasAttribute('selected');
|
|
91
|
+
if (selected != a.hasAttribute('selected')) {
|
|
92
|
+
;
|
|
93
|
+
a.selected = selected;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (a.localName == 'textarea' && a.textContent != b.textContent) {
|
|
97
|
+
;
|
|
98
|
+
a.value = b.textContent ?? '';
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
let attributes = (a, b, o)=>{
|
|
102
|
+
control(a, b);
|
|
103
|
+
for (let { name } of [
|
|
104
|
+
...a.attributes
|
|
105
|
+
]){
|
|
106
|
+
if (!b.hasAttribute(name) && !o.keeps?.(a, name)) a.removeAttribute(name);
|
|
107
|
+
}
|
|
108
|
+
for (let { name, value } of [
|
|
109
|
+
...b.attributes
|
|
110
|
+
]){
|
|
111
|
+
if (a.getAttribute(name) != value) a.setAttribute(name, value);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/** Make `was` the same as `next` in place, keeping every node of `was` that
|
|
115
|
+
* stands in `next` (by `keyOf`, else by its kind at its place), and answer
|
|
116
|
+
* what was kept, made and dropped. Nodes are made in `was`'s document. */ /// import { parseHTML } from 'linkedom'
|
|
117
|
+
/// let { document } = parseHTML('<ul><li id="a">A</li><li>B</li></ul>')
|
|
118
|
+
/// let next = parseHTML('<ul><li id="a">A</li><li>C</li></ul>').document
|
|
119
|
+
/// let a = document.getElementById('a')
|
|
120
|
+
/// morph(document.querySelector('ul'), next.querySelector('ul'))
|
|
121
|
+
/// document.querySelector('ul').outerHTML -> '<ul><li id="a">A</li><li>C</li></ul>'
|
|
122
|
+
/// document.getElementById('a') == a -> true
|
|
123
|
+
export let morph = (was, next, o = {}, tally = {
|
|
124
|
+
kept: 0,
|
|
125
|
+
made: 0,
|
|
126
|
+
dropped: 0
|
|
127
|
+
})=>{
|
|
128
|
+
if (was.nodeType == TEXT || was.nodeType == COMMENT) {
|
|
129
|
+
if (was.nodeValue != next.nodeValue) was.nodeValue = next.nodeValue;
|
|
130
|
+
tally.kept++;
|
|
131
|
+
return tally;
|
|
132
|
+
}
|
|
133
|
+
let a = el(was), b = el(next);
|
|
134
|
+
if (a && b) {
|
|
135
|
+
if (a.isEqualNode(b)) {
|
|
136
|
+
tally.kept += size(a);
|
|
137
|
+
return tally;
|
|
138
|
+
}
|
|
139
|
+
attributes(a, b, o);
|
|
140
|
+
if (a.localName == 'script') {
|
|
141
|
+
if (!b.hasAttribute('src')) a.textContent = b.textContent;
|
|
142
|
+
tally.kept++;
|
|
143
|
+
return tally;
|
|
144
|
+
}
|
|
145
|
+
if (a.localName == 'template') {
|
|
146
|
+
if (a.innerHTML != b.innerHTML) a.innerHTML = b.innerHTML;
|
|
147
|
+
tally.kept++;
|
|
148
|
+
return tally;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
tally.kept++;
|
|
152
|
+
children(was, next, o, tally);
|
|
153
|
+
return tally;
|
|
154
|
+
};
|
|
155
|
+
let children = (was, next, o, tally)=>{
|
|
156
|
+
let doc = was.ownerDocument ?? was;
|
|
157
|
+
let old = [
|
|
158
|
+
...was.childNodes
|
|
159
|
+
];
|
|
160
|
+
let keyed = new Map();
|
|
161
|
+
for (let n of old){
|
|
162
|
+
let key = keyOf(n);
|
|
163
|
+
if (key && !keyed.has(key)) keyed.set(key, n);
|
|
164
|
+
}
|
|
165
|
+
let used = new Set();
|
|
166
|
+
let at = 0;
|
|
167
|
+
let pairs = [];
|
|
168
|
+
let wanted = [
|
|
169
|
+
...next.childNodes
|
|
170
|
+
].map((n)=>{
|
|
171
|
+
let key = keyOf(n);
|
|
172
|
+
let match;
|
|
173
|
+
if (key) {
|
|
174
|
+
match = keyed.get(key);
|
|
175
|
+
if (match && (used.has(match) || !alike(match, n))) match = undefined;
|
|
176
|
+
} else {
|
|
177
|
+
while(at < old.length && (used.has(old[at]) || keyOf(old[at])))at++;
|
|
178
|
+
if (at < old.length && alike(old[at], n)) match = old[at++];
|
|
179
|
+
}
|
|
180
|
+
if (!match) {
|
|
181
|
+
let made = doc.importNode(n, true);
|
|
182
|
+
tally.made += size(made);
|
|
183
|
+
return made;
|
|
184
|
+
}
|
|
185
|
+
used.add(match);
|
|
186
|
+
pairs.push([
|
|
187
|
+
match,
|
|
188
|
+
n
|
|
189
|
+
]);
|
|
190
|
+
return match;
|
|
191
|
+
});
|
|
192
|
+
let ref = was.firstChild;
|
|
193
|
+
for (let n of wanted){
|
|
194
|
+
while(ref && !used.has(ref))ref = ref.nextSibling;
|
|
195
|
+
if (n == ref) ref = ref.nextSibling;
|
|
196
|
+
else was.insertBefore(n, ref);
|
|
197
|
+
}
|
|
198
|
+
for (let n of old){
|
|
199
|
+
if (used.has(n) || o.leave?.(n)) continue;
|
|
200
|
+
tally.dropped += size(n);
|
|
201
|
+
n.parentNode?.removeChild(n);
|
|
202
|
+
}
|
|
203
|
+
for (let [a, b] of pairs){
|
|
204
|
+
if (kept(a, b)) tally.kept += size(a);
|
|
205
|
+
else morph(a, b, o, tally);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
// A region both pages mark as a script's own: left as it stands.
|
|
209
|
+
let kept = (a, b)=>!!el(a)?.hasAttribute(KEPT) && !!el(b)?.hasAttribute(KEPT);
|
|
210
|
+
// What a head keeps of the page before: what a script or the browser put
|
|
211
|
+
// there and a later page has no word on.
|
|
212
|
+
let leaveInHead = (n)=>{
|
|
213
|
+
let e = el(n);
|
|
214
|
+
if (!e) return false;
|
|
215
|
+
let rel = e.getAttribute('rel') ?? '';
|
|
216
|
+
return e.localName == 'script' && e.hasAttribute('src') || e.localName == 'style' || e.localName == 'link' && /stylesheet|preload|modulepreload/.test(rel);
|
|
217
|
+
};
|
|
218
|
+
let RUNS = /^(|module|text\/javascript|application\/javascript)$/;
|
|
219
|
+
/** The scripts of a document that run, as nodes. */ let scripts = (doc)=>[
|
|
220
|
+
...doc.querySelectorAll('script')
|
|
221
|
+
].filter((s)=>RUNS.test(s.getAttribute('type') ?? ''));
|
|
222
|
+
/** Where a script's `src` leads, whole, or null for one written in. */ let source = (s, base)=>{
|
|
223
|
+
let src = s.getAttribute('src');
|
|
224
|
+
return src ? new URL(src, base).href : null;
|
|
225
|
+
};
|
|
226
|
+
/** A script that runs: a new element in place of one the parser wrote,
|
|
227
|
+
* which a document never runs once it was parsed elsewhere. */ export let rerun = (s)=>{
|
|
228
|
+
let doc = s.ownerDocument;
|
|
229
|
+
let fresh = doc.createElement('script');
|
|
230
|
+
for (let { name, value } of [
|
|
231
|
+
...s.attributes
|
|
232
|
+
])fresh.setAttribute(name, value);
|
|
233
|
+
fresh.textContent = s.textContent;
|
|
234
|
+
if (fresh.hasAttribute('src')) fresh.async = false;
|
|
235
|
+
s.replaceWith(fresh);
|
|
236
|
+
};
|
|
237
|
+
/** A page's scripts that hold it (`data-stays`): one standing means the
|
|
238
|
+
* page is left by loading the next. */ export let stays = (doc)=>!!doc.querySelector('script[data-stays]');
|
|
239
|
+
/**
|
|
240
|
+
* Lay the page `next` over `doc`: its head and its body changed in place
|
|
241
|
+
* (`morph`), the scripts it names for the first time run, and every script
|
|
242
|
+
* written into it run again. `ran` holds the addresses of the scripts that
|
|
243
|
+
* have run in `doc`, and gains those run now; `run` runs one; `base` is the
|
|
244
|
+
* address relative ones are read against.
|
|
245
|
+
*/ export let swap = (doc, next, ran, run = rerun, base = doc.baseURI)=>{
|
|
246
|
+
let before = new Set(scripts(doc));
|
|
247
|
+
attributes(doc.documentElement, next.documentElement, {});
|
|
248
|
+
let tally = morph(doc.head, next.head, {
|
|
249
|
+
leave: leaveInHead
|
|
250
|
+
});
|
|
251
|
+
morph(doc.body, next.body, {}, tally);
|
|
252
|
+
for (let s of scripts(doc)){
|
|
253
|
+
let src = source(s, base);
|
|
254
|
+
if (src && (before.has(s) || ran.has(src))) continue;
|
|
255
|
+
if (src) ran.add(src);
|
|
256
|
+
run(s);
|
|
257
|
+
}
|
|
258
|
+
return tally;
|
|
259
|
+
};
|
|
260
|
+
/** The scripts with a `src` a document has run, read against `base`. */ export let sources = (doc, base = doc.baseURI)=>new Set(scripts(doc).map((s)=>source(s, base)).filter((s)=>s != null));
|
|
261
|
+
// What each element is bound as, and how to let it go, across every copy of
|
|
262
|
+
// a script the document runs: kept on the element, so each copy sees them.
|
|
263
|
+
let BOUND = Symbol.for('@yaks/ui/navigate bound');
|
|
264
|
+
/**
|
|
265
|
+
* Bind `e` as `name` once, across every copy of a script its document runs.
|
|
266
|
+
* A script's file is named by its content, so a swap to a page a newer
|
|
267
|
+
* release drew runs that release's copy of it beside the one already
|
|
268
|
+
* running, over the elements the swap left in place: two bindings of one
|
|
269
|
+
* element answer each event twice and draw over each other. The newer copy
|
|
270
|
+
* takes the element over where the older answered how to let go (`bind`'s
|
|
271
|
+
* answer), and otherwise leaves it to the older. Answers whether `bind` ran.
|
|
272
|
+
*/ export let hold = (e, name, bind)=>{
|
|
273
|
+
let held = e[BOUND] ??= new Map();
|
|
274
|
+
if (held.has(name)) {
|
|
275
|
+
let stop = held.get(name);
|
|
276
|
+
if (!stop) return false;
|
|
277
|
+
stop();
|
|
278
|
+
}
|
|
279
|
+
held.set(name, bind());
|
|
280
|
+
return true;
|
|
281
|
+
};
|
|
282
|
+
/** Run `bind` over the document now and over every page a swap brings,
|
|
283
|
+
* each element once, across every copy of the script (`hold`): `of`
|
|
284
|
+
* selects them. For a script with a `src`, which runs once. */ export let arrived = (of, bind, doc = document)=>{
|
|
285
|
+
let each = ()=>{
|
|
286
|
+
for (let e of doc.querySelectorAll(of))hold(e, of, ()=>void bind(e));
|
|
287
|
+
};
|
|
288
|
+
each();
|
|
289
|
+
doc.addEventListener(PAGE, each);
|
|
290
|
+
};
|
|
291
|
+
/** A signal aborted when the page leaves (`yak-leave`), for a script written
|
|
292
|
+
* into a page to add its listeners with. */ export let leaving = (doc = document)=>{
|
|
293
|
+
let leave = new AbortController();
|
|
294
|
+
doc.addEventListener(LEAVE, ()=>leave.abort(), {
|
|
295
|
+
once: true
|
|
296
|
+
});
|
|
297
|
+
return leave.signal;
|
|
298
|
+
};
|
|
299
|
+
/** Heard on the document before a press or Back fetches anything, its detail
|
|
300
|
+
* a `Drawing`: a page that can show `to` itself, from what the tab holds,
|
|
301
|
+
* sets `draw` to do so. The navigator then moves the address and the focus
|
|
302
|
+
* as it would for a page it fetched, and fetches nothing. The page stays the
|
|
303
|
+
* page: nothing leaves, no script runs again, and it keeps where it was
|
|
304
|
+
* scrolled; the document hears `SHOWN` in place of `PAGE`. */ export let DRAW = 'yak-draw';
|
|
305
|
+
/** Heard on the document once a press or Back was drawn in place (`DRAW`),
|
|
306
|
+
* its detail a `Swapped`. */ export let SHOWN = 'yak-shown';
|
|
307
|
+
/** A client that can put an HTML answer at its Content-Location. */ export let NAVIGATE = 'x-yak-navigate';
|
|
308
|
+
/** How long a page held stays good enough to draw without asking for it
|
|
309
|
+
* again, in milliseconds, and how many pages are held. */ export let FRESH = 10_000;
|
|
310
|
+
export let HELD = 24;
|
|
311
|
+
/** How long a pointer stays over a link before its page is asked for. */ export let INTENT = 60;
|
|
312
|
+
/** The mark on a link whose page is kept ready: asked for ahead (`AHEAD`) as
|
|
313
|
+
* soon as the page holding the link is drawn and the browser is idle, and
|
|
314
|
+
* held, so a press on it draws at once and asks for it again after. For a
|
|
315
|
+
* page its server is slow to answer, where a finger's touch gives too little
|
|
316
|
+
* head start. */ export let READY = 'data-ready';
|
|
317
|
+
/** A menu link whose page is held while the browser is idle, after READY
|
|
318
|
+
* links. */ export let HOLD = 'data-hold';
|
|
319
|
+
// Bound the work a long sidebar can start in the background.
|
|
320
|
+
let HOLDS = 10;
|
|
321
|
+
/** The header on an answer to a look ahead (`AHEAD`) that left out what
|
|
322
|
+
* opening the page does (marking what it shows read): the page is asked for
|
|
323
|
+
* again once it is opened. */ export let AGAIN = 'x-yak-again';
|
|
324
|
+
let VISIT = 'yak-visit';
|
|
325
|
+
/** Open a proposed page with the document's navigator. Check that the person
|
|
326
|
+
* is still ready for it when the destination is drawn. */ export let visit = (doc, to, allowed, view, accepts)=>{
|
|
327
|
+
let asked = {
|
|
328
|
+
to,
|
|
329
|
+
allowed,
|
|
330
|
+
view,
|
|
331
|
+
accepts
|
|
332
|
+
};
|
|
333
|
+
tell(doc, VISIT, asked);
|
|
334
|
+
return asked.result ?? Promise.resolve('navigator unavailable');
|
|
335
|
+
};
|
|
336
|
+
/** Heard on the document as a click sets out for a page it does not hold,
|
|
337
|
+
* its detail when (`{ began }`): the frame drawn then is the click's first. */ export let GOING = 'yak-going';
|
|
338
|
+
// Where a page's content is: what its skip link names, else its `main`.
|
|
339
|
+
let content = (doc)=>{
|
|
340
|
+
let to = doc.querySelector('a.Skip[href^="#"]')?.getAttribute('href');
|
|
341
|
+
return (to && to.length > 1 ? doc.getElementById(to.slice(1)) : null) ?? doc.querySelector('main');
|
|
342
|
+
};
|
|
343
|
+
let page = (url)=>url.pathname + url.search;
|
|
344
|
+
// Resolve against the current address even when the document has a base.
|
|
345
|
+
let closeLayer = (location, to)=>{
|
|
346
|
+
if (location.hash && location.hash != to.hash) {
|
|
347
|
+
location.replace(new URL('#', location.href).href);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
// An event told to the whole document, made by its own window.
|
|
351
|
+
let tell = (doc, type, detail)=>{
|
|
352
|
+
let view = doc.defaultView ?? globalThis;
|
|
353
|
+
doc.dispatchEvent(new view.CustomEvent(type, {
|
|
354
|
+
bubbles: true,
|
|
355
|
+
detail
|
|
356
|
+
}));
|
|
357
|
+
};
|
|
358
|
+
// Links the navigator can follow are same-origin page links in this tab.
|
|
359
|
+
let destination = (link, base, here)=>{
|
|
360
|
+
if (link.hasAttribute('download') || link.target && link.target != '_self') {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
let to = new URL(link.getAttribute('href'), base);
|
|
364
|
+
if (to.origin != new URL(base).origin) return null;
|
|
365
|
+
if (page(to) == here && (to.hash || to.href.endsWith('#'))) return null;
|
|
366
|
+
return to;
|
|
367
|
+
};
|
|
368
|
+
let followed = (e, base, here, readyOnly = false, follows)=>{
|
|
369
|
+
let link = e.target?.closest?.('a[href]');
|
|
370
|
+
let m = e;
|
|
371
|
+
if (!link || e.defaultPrevented || m.button > 0 || m.metaKey || m.ctrlKey || m.shiftKey || m.altKey || readyOnly && !link.hasAttribute(READY) || follows?.(link) === false) return null;
|
|
372
|
+
return destination(link, base, here);
|
|
373
|
+
};
|
|
374
|
+
let enterable = (answer)=>answer.status >= 200 && answer.status < 300 && !answer.again && !!answer.page.querySelector(`script[${TAKES}]`);
|
|
375
|
+
/** The mark on a link saying what the page it opens is called, and on a
|
|
376
|
+
* page the title that says what the page is: a click waiting for its page
|
|
377
|
+
* writes the one into the other at once (`going`). */ export let NAMES = 'data-names';
|
|
378
|
+
export let TITLE = 'data-title';
|
|
379
|
+
// What a click shows in its own frame while its page is on its way, from
|
|
380
|
+
// what the page holds: a layer the address opened (a phone's menu) closes,
|
|
381
|
+
// the link pressed takes the current link's marks in its list (its
|
|
382
|
+
// `aria-current` and the classes it wears for it), the page's title says
|
|
383
|
+
// the name the link gives its page (`NAMES`), and the content waits
|
|
384
|
+
// (`aria-busy`). The page, once laid over, says it all again.
|
|
385
|
+
let going = (win, link, to)=>{
|
|
386
|
+
let doc = win.document;
|
|
387
|
+
closeLayer(win.location, to);
|
|
388
|
+
let was = link.closest('nav')?.querySelector('a[aria-current="page"]');
|
|
389
|
+
if (was && was != link) {
|
|
390
|
+
let marks = [
|
|
391
|
+
...was.classList
|
|
392
|
+
].filter((c)=>!link.classList.contains(c));
|
|
393
|
+
was.classList.remove(...marks);
|
|
394
|
+
was.removeAttribute('aria-current');
|
|
395
|
+
link.classList.add(...marks);
|
|
396
|
+
link.setAttribute('aria-current', 'page');
|
|
397
|
+
}
|
|
398
|
+
let names = link.getAttribute(NAMES);
|
|
399
|
+
let title = names && doc.querySelector(`[${TITLE}]`);
|
|
400
|
+
if (title) title.textContent = names;
|
|
401
|
+
content(doc)?.setAttribute('aria-busy', 'true');
|
|
402
|
+
};
|
|
403
|
+
/** The mark on a template holding the frame the pages under a path share,
|
|
404
|
+
* its value the path (`/admin`), or several space-separated paths. The
|
|
405
|
+
* template holds what those pages show before their own content, such as a
|
|
406
|
+
* heading over an empty body. A press on a link
|
|
407
|
+
* to one of them whose page has not come yet, held or not, puts the frame
|
|
408
|
+
* in place of what stands beside the template, in the press's own frame,
|
|
409
|
+
* its titles (`TITLE`) saying what the link names its page (`NAMES`), and
|
|
410
|
+
* lays the page over it when it comes. */ export let FRAME = 'data-frame';
|
|
411
|
+
// The frame of the page at `to`, where the page on screen holds one.
|
|
412
|
+
let frameOf = (doc, to)=>[
|
|
413
|
+
...doc.querySelectorAll(`template[${FRAME}]`)
|
|
414
|
+
].find((t)=>{
|
|
415
|
+
return t.getAttribute(FRAME).split(/\s+/).some((under)=>under && (to.pathname == under || to.pathname.startsWith(`${under}/`)));
|
|
416
|
+
});
|
|
417
|
+
// Put `frame` in place of what stands beside it, titled `names`.
|
|
418
|
+
let framed = (frame, names)=>{
|
|
419
|
+
let region = frame.parentElement;
|
|
420
|
+
let made = frame.content.cloneNode(true);
|
|
421
|
+
if (names != null) {
|
|
422
|
+
for (let title of made.querySelectorAll(`[${TITLE}]`)){
|
|
423
|
+
title.textContent = names;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
let frames = [
|
|
427
|
+
...region.children
|
|
428
|
+
].filter((e)=>e.matches(`template[${FRAME}]`));
|
|
429
|
+
let tally = {
|
|
430
|
+
kept: frames.length,
|
|
431
|
+
made: made.childNodes.length,
|
|
432
|
+
dropped: region.childNodes.length - frames.length
|
|
433
|
+
};
|
|
434
|
+
// Another press or Back may need a different frame before this page comes.
|
|
435
|
+
region.replaceChildren(...frames, made);
|
|
436
|
+
return tally;
|
|
437
|
+
};
|
|
438
|
+
/**
|
|
439
|
+
* Follow the links of `win`'s pages in place: a click on a link to another
|
|
440
|
+
* page of the same origin, and Back and Forward between such pages, `swap`
|
|
441
|
+
* it in. The new page's content (`content`) starts at its top and takes the
|
|
442
|
+
* focus, as a new document would. Answers `go`, which visits an address the
|
|
443
|
+
* same way.
|
|
444
|
+
*
|
|
445
|
+
* A page is drawn in the frame of the click when it is held: opened before
|
|
446
|
+
* (the `HELD` opened last), or fetched ahead, one at a time, as a pointer
|
|
447
|
+
* rests on its link, presses it, a finger touches it or the keyboard comes
|
|
448
|
+
* to it (`AHEAD`), and let go of if the pointer moves on before it arrives.
|
|
449
|
+
* A held page older than `FRESH`, or one whose answer asked (`AGAIN`), is
|
|
450
|
+
* asked for again once drawn, and laid over what was drawn where it
|
|
451
|
+
* changed. A click on a page not held draws what it can of that page at
|
|
452
|
+
* once, from what the page holds (`going`), and its frame where the page
|
|
453
|
+
* holds one (`FRAME`), and the rest when it comes.
|
|
454
|
+
* Links marked `READY` or `HOLD` are asked for as the browser idles.
|
|
455
|
+
* A page with its own document scripts can supply `enter` to open only its
|
|
456
|
+
* READY links this way, keeping that document's ordinary links with the
|
|
457
|
+
* browser. Each usable answer stands until a refresh replaces it or the
|
|
458
|
+
* server no longer serves the page.
|
|
459
|
+
* A page that draws the address itself (`DRAW`) is drawn in place, with no
|
|
460
|
+
* fetch. Sending a form makes every held page old: still drawn at once, and
|
|
461
|
+
* asked for again.
|
|
462
|
+
*/ export let start = (win, history, now = ()=>performance.now(), after = system.after)=>{
|
|
463
|
+
let doc = win.document;
|
|
464
|
+
let ran = sources(doc, win.location.href);
|
|
465
|
+
let here = page(win.location);
|
|
466
|
+
let turn = 0;
|
|
467
|
+
let pages = new Map();
|
|
468
|
+
let warmLink = warmer(win, now, FRESH, HELD);
|
|
469
|
+
// Back and Forward have already moved the address: the page loads there.
|
|
470
|
+
let load = (to, pop = false)=>pop ? win.location.replace(to.href) : win.location.assign(to.href);
|
|
471
|
+
let fetched = async (to, ahead, signal, denied)=>{
|
|
472
|
+
let answer = await win.fetch(to.href, {
|
|
473
|
+
headers: {
|
|
474
|
+
accept: 'text/html',
|
|
475
|
+
[NAVIGATE]: '1',
|
|
476
|
+
...ahead ? {
|
|
477
|
+
[AHEAD]: 'prefetch'
|
|
478
|
+
} : {}
|
|
479
|
+
},
|
|
480
|
+
credentials: 'same-origin',
|
|
481
|
+
signal
|
|
482
|
+
}).catch(()=>null);
|
|
483
|
+
if (!answer) return null;
|
|
484
|
+
if ([
|
|
485
|
+
401,
|
|
486
|
+
403,
|
|
487
|
+
404,
|
|
488
|
+
410
|
|
489
|
+
].includes(answer.status)) denied();
|
|
490
|
+
if (!answer.headers.get('content-type')?.includes('text/html')) return null;
|
|
491
|
+
let url = new URL(answer.url || to.href);
|
|
492
|
+
if (url.origin != to.origin) return null;
|
|
493
|
+
let location = answer.ok && answer.headers.get('content-location');
|
|
494
|
+
let at = location && URL.parse(location, url);
|
|
495
|
+
if (at && at.origin == url.origin) url = at;
|
|
496
|
+
let text = await answer.text().catch(()=>null);
|
|
497
|
+
if (text == null) return null;
|
|
498
|
+
let received = now();
|
|
499
|
+
let page = new win.DOMParser().parseFromString(text, 'text/html');
|
|
500
|
+
let again = answer.headers.has(AGAIN);
|
|
501
|
+
let held = {
|
|
502
|
+
text,
|
|
503
|
+
page,
|
|
504
|
+
url: url.href,
|
|
505
|
+
again,
|
|
506
|
+
status: answer.status,
|
|
507
|
+
received,
|
|
508
|
+
ray: rayOf(answer.headers.get('cf-ray'))
|
|
509
|
+
};
|
|
510
|
+
if (!signal.aborted && win.prepare && enterable(held)) {
|
|
511
|
+
try {
|
|
512
|
+
win.prepare(page, url);
|
|
513
|
+
} catch (error) {
|
|
514
|
+
globalThis.reportError?.(error);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return held;
|
|
518
|
+
};
|
|
519
|
+
let keep = (key, held)=>{
|
|
520
|
+
pages.delete(key);
|
|
521
|
+
pages.set(key, held);
|
|
522
|
+
for (let old of pages.keys()){
|
|
523
|
+
if (pages.size <= HELD) break;
|
|
524
|
+
pages.delete(old);
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
let ask = (to, ahead = false, previous)=>{
|
|
528
|
+
let key = page(to);
|
|
529
|
+
let stop = new AbortController();
|
|
530
|
+
let held = {
|
|
531
|
+
answer: fetched(to, ahead, stop.signal, ()=>{
|
|
532
|
+
if (previous && pages.get(key) == previous) pages.delete(key);
|
|
533
|
+
}),
|
|
534
|
+
at: now(),
|
|
535
|
+
ahead,
|
|
536
|
+
stop
|
|
537
|
+
};
|
|
538
|
+
if (!previous) keep(key, held);
|
|
539
|
+
held.answer.then((answer)=>{
|
|
540
|
+
if (answer) held.received = answer;
|
|
541
|
+
if (pages.get(key) != (previous ?? held)) return;
|
|
542
|
+
if (!previous) {
|
|
543
|
+
if (!answer) pages.delete(key);
|
|
544
|
+
} else if (answer && enterable(answer)) {
|
|
545
|
+
keep(key, held);
|
|
546
|
+
} else if (answer && answer.status >= 200 && answer.status < 300) {
|
|
547
|
+
pages.delete(key);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
return held;
|
|
551
|
+
};
|
|
552
|
+
let fresh = (held)=>!!held && now() - held.at < FRESH;
|
|
553
|
+
// Put the page at `at` on screen by `change`, as a new document comes: the
|
|
554
|
+
// page leaving hears it, the address moves, the content starts at its top
|
|
555
|
+
// and takes the focus, and the page that came hears it; false where it
|
|
556
|
+
// cannot be. A page drawn in place (`DRAW`) leaves nothing and keeps its
|
|
557
|
+
// scroll.
|
|
558
|
+
let land = (at, change, from, began, wait, pop, focusAfterPaint = false)=>{
|
|
559
|
+
let lap = now();
|
|
560
|
+
let fetched = from != 'drawn';
|
|
561
|
+
let first = from != 'fresh';
|
|
562
|
+
let tally;
|
|
563
|
+
try {
|
|
564
|
+
if (fetched) tell(doc, LEAVE);
|
|
565
|
+
// The focus, which moves to the content below, lets go first. A focused
|
|
566
|
+
// node the change removes (the pressed link) makes the browser restyle
|
|
567
|
+
// the whole page there and then to move the focus off it: 40–75 ms of
|
|
568
|
+
// a press on a page of 4,000 elements.
|
|
569
|
+
if (first && !pop) doc.activeElement?.blur?.();
|
|
570
|
+
tally = change();
|
|
571
|
+
} catch (error) {
|
|
572
|
+
// A page half laid over is no page: the next loads as a document, and
|
|
573
|
+
// the reporter hears why (M-37965).
|
|
574
|
+
globalThis.reportError?.(error);
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
// A layer the old address opened (`#menu`, shown by `:target`) closes,
|
|
578
|
+
// as it would on a new document: writing history leaves `:target` be.
|
|
579
|
+
if (first) closeLayer(win.location, at);
|
|
580
|
+
if (first && !pop) {
|
|
581
|
+
history.write({
|
|
582
|
+
path: at.pathname + at.search + at.hash,
|
|
583
|
+
state: null
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
here = page(at);
|
|
587
|
+
if (first && !pop) {
|
|
588
|
+
let target = at.hash && doc.getElementById(decodeURIComponent(at.hash.slice(1)));
|
|
589
|
+
let main = content(doc);
|
|
590
|
+
if (target) target.scrollIntoView();
|
|
591
|
+
else if (fetched) {
|
|
592
|
+
win.scrollTo({
|
|
593
|
+
top: 0,
|
|
594
|
+
left: 0,
|
|
595
|
+
behavior: 'instant'
|
|
596
|
+
});
|
|
597
|
+
if (main) main.scrollTop = 0;
|
|
598
|
+
}
|
|
599
|
+
let view = doc.defaultView;
|
|
600
|
+
if (main && focusAfterPaint && view?.requestAnimationFrame) {
|
|
601
|
+
let focused = doc.activeElement;
|
|
602
|
+
let mine = turn;
|
|
603
|
+
view.requestAnimationFrame(()=>view.setTimeout(()=>{
|
|
604
|
+
let active = doc.activeElement;
|
|
605
|
+
if (mine == turn && main.isConnected && (active == focused || active == doc.body || !active)) {
|
|
606
|
+
main.focus({
|
|
607
|
+
preventScroll: true
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
}));
|
|
611
|
+
} else main?.focus?.({
|
|
612
|
+
preventScroll: true
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
let end = now();
|
|
616
|
+
let phases = {
|
|
617
|
+
wait,
|
|
618
|
+
swap: end - lap
|
|
619
|
+
};
|
|
620
|
+
let detail = {
|
|
621
|
+
ms: end - began,
|
|
622
|
+
began,
|
|
623
|
+
phases,
|
|
624
|
+
from,
|
|
625
|
+
tally,
|
|
626
|
+
url: at.href
|
|
627
|
+
};
|
|
628
|
+
tell(doc, fetched ? PAGE : SHOWN, detail);
|
|
629
|
+
readying();
|
|
630
|
+
return true;
|
|
631
|
+
};
|
|
632
|
+
// Draw `answer` as the page at `to`; false where it cannot be.
|
|
633
|
+
let draw = (to, answer, from, began, wait, pop, visit)=>{
|
|
634
|
+
if (!answer.page.querySelector(`script[${TAKES}]`)) return false;
|
|
635
|
+
let at = new URL(answer.url);
|
|
636
|
+
at.hash = to.hash;
|
|
637
|
+
let change = ()=>swap(doc, answer.page, ran, rerun, at.href);
|
|
638
|
+
let drawn = land(at, change, from, began, wait, pop);
|
|
639
|
+
if (drawn && visit) slideIn(visit.view());
|
|
640
|
+
return drawn;
|
|
641
|
+
};
|
|
642
|
+
// The page at `to` laid over its frame as it comes, pressed at `began`, or
|
|
643
|
+
// loaded where it cannot be; left be where another press came since.
|
|
644
|
+
let laid = async (to, using, began, mine)=>{
|
|
645
|
+
let answer = await using.answer;
|
|
646
|
+
if (mine != turn) return;
|
|
647
|
+
let wait = answer ? Math.max(0, answer.received - began) : 0;
|
|
648
|
+
if (!answer || !draw(to, answer, 'fresh', began, wait, true)) {
|
|
649
|
+
load(answer ? new URL(answer.url) : to, true);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
// How the page on screen draws `to` itself, where it can (`DRAW`).
|
|
653
|
+
let drawing = (to, from)=>{
|
|
654
|
+
let asked = {
|
|
655
|
+
to,
|
|
656
|
+
from
|
|
657
|
+
};
|
|
658
|
+
tell(doc, DRAW, asked);
|
|
659
|
+
let own = asked.draw;
|
|
660
|
+
return own && {
|
|
661
|
+
change: ()=>(own(), {
|
|
662
|
+
kept: 0,
|
|
663
|
+
made: 0,
|
|
664
|
+
dropped: 0
|
|
665
|
+
}),
|
|
666
|
+
focusAfterPaint: asked.focusAfterPaint
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
let go = async (to, pop = false, pressed, began = now(), own = drawing(to), names)=>{
|
|
670
|
+
let mine = ++turn;
|
|
671
|
+
if (own && land(new URL(to), own.change, 'drawn', began, 0, pop, own.focusAfterPaint)) {
|
|
672
|
+
return pressed?.drawn(0);
|
|
673
|
+
}
|
|
674
|
+
if (stays(doc)) {
|
|
675
|
+
pressed?.leaving();
|
|
676
|
+
return load(to, pop);
|
|
677
|
+
}
|
|
678
|
+
let held = pages.get(page(to));
|
|
679
|
+
if (win.enter && !held) {
|
|
680
|
+
pressed?.leaving();
|
|
681
|
+
return load(to, pop);
|
|
682
|
+
}
|
|
683
|
+
let from = held?.received ? 'held' : 'fetch';
|
|
684
|
+
// Taken up before anything moves the focus, which lets go of a look
|
|
685
|
+
// ahead nobody took up (`left`).
|
|
686
|
+
let using = held ?? ask(to);
|
|
687
|
+
using.used = true;
|
|
688
|
+
// Its frame now, and the page laid over it as it comes, the address
|
|
689
|
+
// already moved.
|
|
690
|
+
let frame = !win.enter && !held?.received && frameOf(doc, to);
|
|
691
|
+
if (frame && land(new URL(to), ()=>framed(frame, names), 'framed', began, 0, pop)) {
|
|
692
|
+
pressed?.drawn(0);
|
|
693
|
+
return laid(to, using, began, mine);
|
|
694
|
+
}
|
|
695
|
+
let answer = await using.answer;
|
|
696
|
+
if (mine != turn) return pressed?.cancel();
|
|
697
|
+
let wait = answer ? Math.max(0, answer.received - began) : 0;
|
|
698
|
+
if (win.enter && answer && enterable(answer)) {
|
|
699
|
+
let at = new URL(answer.url);
|
|
700
|
+
at.hash = to.hash;
|
|
701
|
+
history.write({
|
|
702
|
+
path: page(at) + at.hash,
|
|
703
|
+
state: null
|
|
704
|
+
});
|
|
705
|
+
try {
|
|
706
|
+
closed = true;
|
|
707
|
+
stopRefresh?.();
|
|
708
|
+
return win.enter(answer.text, {
|
|
709
|
+
url: at.href,
|
|
710
|
+
from,
|
|
711
|
+
began,
|
|
712
|
+
wait,
|
|
713
|
+
drawn: pressed && (()=>pressed.drawn(wait, answer.ray))
|
|
714
|
+
});
|
|
715
|
+
} catch (error) {
|
|
716
|
+
globalThis.reportError?.(error);
|
|
717
|
+
pressed?.leaving();
|
|
718
|
+
return load(at, true);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
if (win.enter || !answer || !draw(to, answer, from, began, wait, pop)) {
|
|
722
|
+
pressed?.leaving();
|
|
723
|
+
return load(answer ? new URL(answer.url) : to, pop);
|
|
724
|
+
}
|
|
725
|
+
pressed?.drawn(wait, answer.ray);
|
|
726
|
+
if (!held || fresh(held) && !(held.ahead && answer.again)) return;
|
|
727
|
+
let again = now();
|
|
728
|
+
let newer = await ask(to).answer;
|
|
729
|
+
if (mine != turn || !newer || newer.text == answer.text) return;
|
|
730
|
+
if (!draw(to, newer, 'fresh', again, now() - again, true)) {
|
|
731
|
+
load(new URL(newer.url), true);
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
doc.addEventListener(VISIT, (event)=>{
|
|
735
|
+
let asked = event.detail;
|
|
736
|
+
let { to, allowed, view, accepts } = asked;
|
|
737
|
+
let ready = ()=>allowed() && !stays(doc);
|
|
738
|
+
asked.result = (async ()=>{
|
|
739
|
+
if (to.origin != win.location.origin) return 'different origin';
|
|
740
|
+
if (!allowed()) return 'deferred';
|
|
741
|
+
if (to.href == win.location.href) return 'opened';
|
|
742
|
+
let began = now();
|
|
743
|
+
let show = (own, wait)=>{
|
|
744
|
+
let shown = land(to, own.change, 'drawn', began, wait, false);
|
|
745
|
+
if (shown) slideIn(view());
|
|
746
|
+
return shown ? 'opened' : 'page could not be drawn';
|
|
747
|
+
};
|
|
748
|
+
// A page that draws `to` itself is not left, so nothing holds it.
|
|
749
|
+
let own = drawing(to);
|
|
750
|
+
if (own) {
|
|
751
|
+
turn++;
|
|
752
|
+
return show(own, 0);
|
|
753
|
+
}
|
|
754
|
+
if (!ready()) return 'deferred';
|
|
755
|
+
let mine = ++turn;
|
|
756
|
+
let held = pages.get(page(to));
|
|
757
|
+
let using = held ?? ask(to);
|
|
758
|
+
using.used = true;
|
|
759
|
+
let answer = await using.answer;
|
|
760
|
+
if (mine != turn) return 'superseded';
|
|
761
|
+
if (!ready()) return 'deferred';
|
|
762
|
+
if (held && (!answer || !enterable(answer) || accepts?.(answer.page) === false)) {
|
|
763
|
+
using = ask(to);
|
|
764
|
+
using.used = true;
|
|
765
|
+
answer = await using.answer;
|
|
766
|
+
}
|
|
767
|
+
if (mine != turn) return 'superseded';
|
|
768
|
+
if (!ready()) return 'deferred';
|
|
769
|
+
if (!answer) return 'no page response';
|
|
770
|
+
if (answer.status < 200 || answer.status >= 300) {
|
|
771
|
+
return `HTTP ${answer.status}`;
|
|
772
|
+
}
|
|
773
|
+
if (!enterable(answer)) return 'page cannot be opened in place';
|
|
774
|
+
if (accepts?.(answer.page) === false) {
|
|
775
|
+
if (pages.get(page(to)) == using) pages.delete(page(to));
|
|
776
|
+
return 'destination absent from page';
|
|
777
|
+
}
|
|
778
|
+
let wait = now() - began;
|
|
779
|
+
own = drawing(to, answer.page);
|
|
780
|
+
if (own) return show(own, wait);
|
|
781
|
+
return draw(to, answer, 'fetch', began, wait, false, asked) ? 'opened' : 'page could not be drawn';
|
|
782
|
+
})();
|
|
783
|
+
});
|
|
784
|
+
let readyLinks = ()=>{
|
|
785
|
+
let linked = (mark)=>[
|
|
786
|
+
...doc.querySelectorAll(`a[${mark}][href]`)
|
|
787
|
+
].filter((link)=>!link.closest('[hidden]'));
|
|
788
|
+
let targets = new Map();
|
|
789
|
+
let add = (mark, most)=>{
|
|
790
|
+
for (let link of linked(mark)){
|
|
791
|
+
if (most <= 0) break;
|
|
792
|
+
let to = destination(link, win.location.href, here);
|
|
793
|
+
if (!to) continue;
|
|
794
|
+
let key = page(to);
|
|
795
|
+
if (key == here || targets.has(key) || drawing(to)) continue;
|
|
796
|
+
targets.set(key, to);
|
|
797
|
+
most--;
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
add(READY, Infinity);
|
|
801
|
+
if (!win.enter) {
|
|
802
|
+
add(HOLD, HOLDS);
|
|
803
|
+
for (let link of linked(WARM).slice(0, HOLDS))warmLink(link);
|
|
804
|
+
}
|
|
805
|
+
return targets;
|
|
806
|
+
};
|
|
807
|
+
let closed = false, warming = false;
|
|
808
|
+
let stopRefresh;
|
|
809
|
+
let visible = ()=>doc.visibilityState != 'hidden';
|
|
810
|
+
let warm = async ()=>{
|
|
811
|
+
let from;
|
|
812
|
+
do {
|
|
813
|
+
from = here;
|
|
814
|
+
if (closed || stays(doc) || !visible()) break;
|
|
815
|
+
for (let [key, to] of readyLinks()){
|
|
816
|
+
if (closed || from != here || stays(doc) || !visible()) break;
|
|
817
|
+
if (drawing(to)) continue;
|
|
818
|
+
let held = pages.get(key);
|
|
819
|
+
if (!held || win.enter && held.received && !fresh(held)) {
|
|
820
|
+
await ask(to, true, held).answer;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}while (from != here)
|
|
824
|
+
warming = false;
|
|
825
|
+
if (win.enter && !closed && visible() && doc.querySelector(`a[${READY}][href]`)) {
|
|
826
|
+
stopRefresh = after(FRESH, readying);
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
let readying = ()=>{
|
|
830
|
+
if (closed || warming) return;
|
|
831
|
+
stopRefresh?.();
|
|
832
|
+
warming = true;
|
|
833
|
+
if (win.enter) void warm();
|
|
834
|
+
else if (win.requestIdleCallback) win.requestIdleCallback(()=>void warm());
|
|
835
|
+
else after(0, ()=>void warm());
|
|
836
|
+
};
|
|
837
|
+
doc.addEventListener('visibilitychange', ()=>{
|
|
838
|
+
if (!visible()) stopRefresh?.();
|
|
839
|
+
else readying();
|
|
840
|
+
});
|
|
841
|
+
win.addEventListener('pageshow', (e)=>{
|
|
842
|
+
if (e.persisted) readying();
|
|
843
|
+
});
|
|
844
|
+
if (win.enter || doc.readyState == 'complete') readying();
|
|
845
|
+
else {
|
|
846
|
+
// The page's other modules register its in-place views as it loads.
|
|
847
|
+
doc.addEventListener('DOMContentLoaded', readying, {
|
|
848
|
+
once: true
|
|
849
|
+
});
|
|
850
|
+
win.addEventListener('load', readying, {
|
|
851
|
+
once: true
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
// The one page being looked ahead at, which a pointer moving on, or
|
|
855
|
+
// another look ahead, lets go of unless a click took it up.
|
|
856
|
+
let looking;
|
|
857
|
+
let drop = ()=>{
|
|
858
|
+
if (!looking) return;
|
|
859
|
+
let { key, held } = looking;
|
|
860
|
+
looking = undefined;
|
|
861
|
+
if (held.used) return;
|
|
862
|
+
held.stop.abort();
|
|
863
|
+
if (pages.get(key) == held) pages.delete(key);
|
|
864
|
+
};
|
|
865
|
+
let ahead = (e)=>{
|
|
866
|
+
let link = e.target?.closest?.(`a[${WARM}][href]`);
|
|
867
|
+
if (link && !e.defaultPrevented) warmLink(link);
|
|
868
|
+
let to = followed(e, win.location.href, here, !!win.enter, win.follows);
|
|
869
|
+
if (!to || pages.has(page(to)) || drawing(to)) return;
|
|
870
|
+
drop();
|
|
871
|
+
let key = page(to), held = ask(to, true);
|
|
872
|
+
looking = {
|
|
873
|
+
key,
|
|
874
|
+
held
|
|
875
|
+
};
|
|
876
|
+
held.answer.then(()=>looking?.held == held && (looking = undefined));
|
|
877
|
+
};
|
|
878
|
+
// A pointer passing over a link on its way elsewhere does not ask for it;
|
|
879
|
+
// one that stays `INTENT` milliseconds, or presses, does.
|
|
880
|
+
let hovering;
|
|
881
|
+
win.addEventListener('pointerover', (e)=>{
|
|
882
|
+
if (e.pointerType != 'mouse') return;
|
|
883
|
+
clearTimeout(hovering);
|
|
884
|
+
hovering = setTimeout(()=>ahead(e), INTENT);
|
|
885
|
+
});
|
|
886
|
+
// Leaving the link (or the keyboard leaving it) before its page came.
|
|
887
|
+
let left = (e)=>{
|
|
888
|
+
let link = e.target?.closest?.('a[href]');
|
|
889
|
+
let into = e.relatedTarget;
|
|
890
|
+
if (!link || into && link.contains(into)) return;
|
|
891
|
+
clearTimeout(hovering);
|
|
892
|
+
let to = new URL(link.getAttribute('href'), win.location.href);
|
|
893
|
+
if (looking?.key == page(to)) drop();
|
|
894
|
+
};
|
|
895
|
+
win.addEventListener('pointerout', (e)=>{
|
|
896
|
+
if (e.pointerType == 'mouse') left(e);
|
|
897
|
+
});
|
|
898
|
+
win.addEventListener('focusout', left);
|
|
899
|
+
// A touch the browser takes for a scroll is no press.
|
|
900
|
+
win.addEventListener('pointercancel', left);
|
|
901
|
+
win.addEventListener('focusin', ahead);
|
|
902
|
+
win.addEventListener('mousedown', ahead);
|
|
903
|
+
win.addEventListener('touchstart', ahead, {
|
|
904
|
+
passive: true
|
|
905
|
+
});
|
|
906
|
+
win.addEventListener('submit', ()=>{
|
|
907
|
+
for (let held of pages.values())held.at = -Infinity;
|
|
908
|
+
});
|
|
909
|
+
win.addEventListener('click', (e)=>{
|
|
910
|
+
let began = Math.min(now(), e.timeStamp);
|
|
911
|
+
let to = followed(e, win.location.href, here, !!win.enter, win.follows);
|
|
912
|
+
if (!to) return;
|
|
913
|
+
let pressed = result(doc, e);
|
|
914
|
+
e.preventDefault();
|
|
915
|
+
let own = drawing(to);
|
|
916
|
+
let link = e.target.closest('a[href]');
|
|
917
|
+
if (!own && !pages.get(page(to))?.received) {
|
|
918
|
+
going(win, link, to);
|
|
919
|
+
tell(doc, GOING, {
|
|
920
|
+
began
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
go(to, false, pressed, began, own, link.getAttribute(NAMES));
|
|
924
|
+
});
|
|
925
|
+
if (!win.enter) {
|
|
926
|
+
history.listen(({ path })=>{
|
|
927
|
+
let to = new URL(path, win.location.href);
|
|
928
|
+
if (page(to) == here) return;
|
|
929
|
+
go(to, true);
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
return go;
|
|
933
|
+
};
|
|
934
|
+
//# sourceMappingURL=navigate.js.map
|