@bergetai/ui 0.14.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -46
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/components/alert/Alert.cjs +31 -0
- package/dist/components/alert/Alert.cjs.map +1 -0
- package/dist/components/alert/Alert.d.cts +14 -0
- package/dist/components/alert/Alert.d.cts.map +1 -0
- package/dist/components/alert/Alert.d.mts +14 -0
- package/dist/components/alert/Alert.d.mts.map +1 -0
- package/dist/components/alert/Alert.mjs +27 -0
- package/dist/components/alert/Alert.mjs.map +1 -0
- package/dist/components/alert/index.d.cts +3 -0
- package/dist/components/alert/index.d.mts +3 -0
- package/dist/components/alert-dialog/AlertDialog.cjs +95 -0
- package/dist/components/alert-dialog/AlertDialog.cjs.map +1 -0
- package/dist/components/alert-dialog/AlertDialog.d.cts +46 -0
- package/dist/components/alert-dialog/AlertDialog.d.cts.map +1 -0
- package/dist/components/alert-dialog/AlertDialog.d.mts +46 -0
- package/dist/components/alert-dialog/AlertDialog.d.mts.map +1 -0
- package/dist/components/alert-dialog/AlertDialog.mjs +83 -0
- package/dist/components/alert-dialog/AlertDialog.mjs.map +1 -0
- package/dist/components/alert-dialog/index.d.cts +2 -0
- package/dist/components/alert-dialog/index.d.mts +2 -0
- package/dist/components/badge/Badge.cjs +57 -0
- package/dist/components/badge/Badge.cjs.map +1 -0
- package/dist/components/badge/Badge.d.cts +16 -0
- package/dist/components/badge/Badge.d.cts.map +1 -0
- package/dist/components/badge/Badge.d.mts +16 -0
- package/dist/components/badge/Badge.d.mts.map +1 -0
- package/dist/components/badge/Badge.mjs +55 -0
- package/dist/components/badge/Badge.mjs.map +1 -0
- package/dist/components/badge/index.d.cts +2 -0
- package/dist/components/badge/index.d.mts +2 -0
- package/dist/components/berget-logo/BergetLogo.cjs +87 -0
- package/dist/components/berget-logo/BergetLogo.cjs.map +1 -0
- package/dist/components/berget-logo/BergetLogo.d.cts +14 -0
- package/dist/components/berget-logo/BergetLogo.d.cts.map +1 -0
- package/dist/components/berget-logo/BergetLogo.d.mts +14 -0
- package/dist/components/berget-logo/BergetLogo.d.mts.map +1 -0
- package/dist/components/berget-logo/BergetLogo.mjs +85 -0
- package/dist/components/berget-logo/BergetLogo.mjs.map +1 -0
- package/dist/components/berget-logo/index.d.cts +2 -0
- package/dist/components/berget-logo/index.d.mts +2 -0
- package/dist/components/box/Box.cjs +67 -0
- package/dist/components/box/Box.cjs.map +1 -0
- package/dist/components/box/Box.d.cts +21 -0
- package/dist/components/box/Box.d.cts.map +1 -0
- package/dist/components/box/Box.d.mts +21 -0
- package/dist/components/box/Box.d.mts.map +1 -0
- package/dist/components/box/Box.mjs +64 -0
- package/dist/components/box/Box.mjs.map +1 -0
- package/dist/components/box/index.d.cts +2 -0
- package/dist/components/box/index.d.mts +2 -0
- package/dist/components/button/Button.cjs +75 -0
- package/dist/components/button/Button.cjs.map +1 -0
- package/dist/components/button/Button.d.cts +19 -0
- package/dist/components/button/Button.d.cts.map +1 -0
- package/dist/components/button/Button.d.mts +19 -0
- package/dist/components/button/Button.d.mts.map +1 -0
- package/dist/components/button/Button.mjs +74 -0
- package/dist/components/button/Button.mjs.map +1 -0
- package/dist/components/button/index.d.cts +3 -0
- package/dist/components/button/index.d.mts +3 -0
- package/dist/components/card/Card.cjs +36 -0
- package/dist/components/card/Card.cjs.map +1 -0
- package/dist/components/card/Card.d.cts +15 -0
- package/dist/components/card/Card.d.cts.map +1 -0
- package/dist/components/card/Card.d.mts +15 -0
- package/dist/components/card/Card.d.mts.map +1 -0
- package/dist/components/card/Card.mjs +28 -0
- package/dist/components/card/Card.mjs.map +1 -0
- package/dist/components/card/index.d.cts +3 -0
- package/dist/components/card/index.d.mts +3 -0
- package/dist/components/checkbox/Checkbox.cjs +87 -0
- package/dist/components/checkbox/Checkbox.cjs.map +1 -0
- package/dist/components/checkbox/Checkbox.d.cts +18 -0
- package/dist/components/checkbox/Checkbox.d.cts.map +1 -0
- package/dist/components/checkbox/Checkbox.d.mts +18 -0
- package/dist/components/checkbox/Checkbox.d.mts.map +1 -0
- package/dist/components/checkbox/Checkbox.mjs +84 -0
- package/dist/components/checkbox/Checkbox.mjs.map +1 -0
- package/dist/components/checkbox/index.d.cts +2 -0
- package/dist/components/checkbox/index.d.mts +2 -0
- package/dist/components/code-block/CodeBlock.cjs +58 -0
- package/dist/components/code-block/CodeBlock.cjs.map +1 -0
- package/dist/components/code-block/CodeBlock.d.cts +10 -0
- package/dist/components/code-block/CodeBlock.d.cts.map +1 -0
- package/dist/components/code-block/CodeBlock.d.mts +10 -0
- package/dist/components/code-block/CodeBlock.d.mts.map +1 -0
- package/dist/components/code-block/CodeBlock.mjs +58 -0
- package/dist/components/code-block/CodeBlock.mjs.map +1 -0
- package/dist/components/container/Container.cjs +50 -0
- package/dist/components/container/Container.cjs.map +1 -0
- package/dist/components/container/Container.d.cts +17 -0
- package/dist/components/container/Container.d.cts.map +1 -0
- package/dist/components/container/Container.d.mts +17 -0
- package/dist/components/container/Container.d.mts.map +1 -0
- package/dist/components/container/Container.mjs +47 -0
- package/dist/components/container/Container.mjs.map +1 -0
- package/dist/components/container/index.d.cts +2 -0
- package/dist/components/container/index.d.mts +2 -0
- package/dist/components/country-select/CountrySelect.cjs +95 -0
- package/dist/components/country-select/CountrySelect.cjs.map +1 -0
- package/dist/components/country-select/CountrySelect.d.cts +16 -0
- package/dist/components/country-select/CountrySelect.d.cts.map +1 -0
- package/dist/components/country-select/CountrySelect.d.mts +16 -0
- package/dist/components/country-select/CountrySelect.d.mts.map +1 -0
- package/dist/components/country-select/CountrySelect.mjs +93 -0
- package/dist/components/country-select/CountrySelect.mjs.map +1 -0
- package/dist/components/country-select/countries.cjs +409 -0
- package/dist/components/country-select/countries.cjs.map +1 -0
- package/dist/components/country-select/countries.d.cts +17 -0
- package/dist/components/country-select/countries.d.cts.map +1 -0
- package/dist/components/country-select/countries.d.mts +17 -0
- package/dist/components/country-select/countries.d.mts.map +1 -0
- package/dist/components/country-select/countries.mjs +405 -0
- package/dist/components/country-select/countries.mjs.map +1 -0
- package/dist/components/country-select/index.d.cts +3 -0
- package/dist/components/country-select/index.d.mts +3 -0
- package/dist/components/dialog/Dialog.cjs +85 -0
- package/dist/components/dialog/Dialog.cjs.map +1 -0
- package/dist/components/dialog/Dialog.d.cts +35 -0
- package/dist/components/dialog/Dialog.d.cts.map +1 -0
- package/dist/components/dialog/Dialog.d.mts +35 -0
- package/dist/components/dialog/Dialog.d.mts.map +1 -0
- package/dist/components/dialog/Dialog.mjs +74 -0
- package/dist/components/dialog/Dialog.mjs.map +1 -0
- package/dist/components/dialog/index.d.cts +2 -0
- package/dist/components/dialog/index.d.mts +2 -0
- package/dist/components/divider/Divider.cjs +72 -0
- package/dist/components/divider/Divider.cjs.map +1 -0
- package/dist/components/divider/Divider.mjs +70 -0
- package/dist/components/divider/Divider.mjs.map +1 -0
- package/dist/components/dropdown-menu/DropdownMenu.cjs +101 -0
- package/dist/components/dropdown-menu/DropdownMenu.cjs.map +1 -0
- package/dist/components/dropdown-menu/DropdownMenu.d.cts +62 -0
- package/dist/components/dropdown-menu/DropdownMenu.d.cts.map +1 -0
- package/dist/components/dropdown-menu/DropdownMenu.d.mts +62 -0
- package/dist/components/dropdown-menu/DropdownMenu.d.mts.map +1 -0
- package/dist/components/dropdown-menu/DropdownMenu.mjs +85 -0
- package/dist/components/dropdown-menu/DropdownMenu.mjs.map +1 -0
- package/dist/components/dropdown-menu/index.d.cts +3 -0
- package/dist/components/dropdown-menu/index.d.mts +3 -0
- package/dist/components/empty/Empty.cjs +51 -0
- package/dist/components/empty/Empty.cjs.map +1 -0
- package/dist/components/empty/Empty.d.cts +17 -0
- package/dist/components/empty/Empty.d.cts.map +1 -0
- package/dist/components/empty/Empty.d.mts +17 -0
- package/dist/components/empty/Empty.d.mts.map +1 -0
- package/dist/components/empty/Empty.mjs +44 -0
- package/dist/components/empty/Empty.mjs.map +1 -0
- package/dist/components/empty/index.d.cts +3 -0
- package/dist/components/empty/index.d.mts +3 -0
- package/dist/components/field/index.d.cts +2 -0
- package/dist/components/field/index.d.mts +2 -0
- package/dist/components/fog-illustration/FogIllustration.cjs +342 -0
- package/dist/components/fog-illustration/FogIllustration.cjs.map +1 -0
- package/dist/components/fog-illustration/FogIllustration.d.cts +35 -0
- package/dist/components/fog-illustration/FogIllustration.d.cts.map +1 -0
- package/dist/components/fog-illustration/FogIllustration.d.mts +35 -0
- package/dist/components/fog-illustration/FogIllustration.d.mts.map +1 -0
- package/dist/components/fog-illustration/FogIllustration.mjs +341 -0
- package/dist/components/fog-illustration/FogIllustration.mjs.map +1 -0
- package/dist/components/grid/Grid.cjs +51 -0
- package/dist/components/grid/Grid.cjs.map +1 -0
- package/dist/components/grid/Grid.d.cts +25 -0
- package/dist/components/grid/Grid.d.cts.map +1 -0
- package/dist/components/grid/Grid.d.mts +25 -0
- package/dist/components/grid/Grid.d.mts.map +1 -0
- package/dist/components/grid/Grid.mjs +48 -0
- package/dist/components/grid/Grid.mjs.map +1 -0
- package/dist/components/grid/index.d.cts +2 -0
- package/dist/components/grid/index.d.mts +2 -0
- package/dist/components/icon/Icon.cjs +30 -0
- package/dist/components/icon/Icon.cjs.map +1 -0
- package/dist/components/icon/Icon.d.cts +14 -0
- package/dist/components/icon/Icon.d.cts.map +1 -0
- package/dist/components/icon/Icon.d.mts +14 -0
- package/dist/components/icon/Icon.d.mts.map +1 -0
- package/dist/components/icon/Icon.mjs +28 -0
- package/dist/components/icon/Icon.mjs.map +1 -0
- package/dist/components/icon/index.d.cts +2 -0
- package/dist/components/icon/index.d.mts +2 -0
- package/dist/components/input/index.d.cts +2 -0
- package/dist/components/input/index.d.mts +2 -0
- package/dist/components/item/Item.cjs +65 -0
- package/dist/components/item/Item.cjs.map +1 -0
- package/dist/components/item/Item.d.cts +24 -0
- package/dist/components/item/Item.d.cts.map +1 -0
- package/dist/components/item/Item.d.mts +24 -0
- package/dist/components/item/Item.d.mts.map +1 -0
- package/dist/components/item/Item.mjs +54 -0
- package/dist/components/item/Item.mjs.map +1 -0
- package/dist/components/item/index.d.cts +3 -0
- package/dist/components/item/index.d.mts +3 -0
- package/dist/components/label/index.d.cts +2 -0
- package/dist/components/label/index.d.mts +2 -0
- package/dist/components/language-select/LanguageSelect.cjs +48 -0
- package/dist/components/language-select/LanguageSelect.cjs.map +1 -0
- package/dist/components/language-select/LanguageSelect.d.cts +17 -0
- package/dist/components/language-select/LanguageSelect.d.cts.map +1 -0
- package/dist/components/language-select/LanguageSelect.d.mts +17 -0
- package/dist/components/language-select/LanguageSelect.d.mts.map +1 -0
- package/dist/components/language-select/LanguageSelect.mjs +46 -0
- package/dist/components/language-select/LanguageSelect.mjs.map +1 -0
- package/dist/components/language-select/index.d.cts +2 -0
- package/dist/components/language-select/index.d.mts +2 -0
- package/dist/components/link/Link.cjs +71 -0
- package/dist/components/link/Link.cjs.map +1 -0
- package/dist/components/link/Link.d.cts +18 -0
- package/dist/components/link/Link.d.cts.map +1 -0
- package/dist/components/link/Link.d.mts +18 -0
- package/dist/components/link/Link.d.mts.map +1 -0
- package/dist/components/link/Link.mjs +68 -0
- package/dist/components/link/Link.mjs.map +1 -0
- package/dist/components/link/index.d.cts +2 -0
- package/dist/components/link/index.d.mts +2 -0
- package/dist/components/list/List.cjs +71 -0
- package/dist/components/list/List.cjs.map +1 -0
- package/dist/components/list/List.d.cts +24 -0
- package/dist/components/list/List.d.cts.map +1 -0
- package/dist/components/list/List.d.mts +24 -0
- package/dist/components/list/List.d.mts.map +1 -0
- package/dist/components/list/List.mjs +66 -0
- package/dist/components/list/List.mjs.map +1 -0
- package/dist/components/list/index.d.cts +2 -0
- package/dist/components/list/index.d.mts +2 -0
- package/dist/components/model-card/ModelCard.cjs +108 -0
- package/dist/components/model-card/ModelCard.cjs.map +1 -0
- package/dist/components/model-card/ModelCard.d.cts +58 -0
- package/dist/components/model-card/ModelCard.d.cts.map +1 -0
- package/dist/components/model-card/ModelCard.d.mts +58 -0
- package/dist/components/model-card/ModelCard.d.mts.map +1 -0
- package/dist/components/model-card/ModelCard.mjs +106 -0
- package/dist/components/model-card/ModelCard.mjs.map +1 -0
- package/dist/components/model-card/index.d.cts +3 -0
- package/dist/components/model-card/index.d.mts +3 -0
- package/dist/components/model-logo/ModelLogo.cjs +98 -0
- package/dist/components/model-logo/ModelLogo.cjs.map +1 -0
- package/dist/components/model-logo/ModelLogo.d.cts +32 -0
- package/dist/components/model-logo/ModelLogo.d.cts.map +1 -0
- package/dist/components/model-logo/ModelLogo.d.mts +32 -0
- package/dist/components/model-logo/ModelLogo.d.mts.map +1 -0
- package/dist/components/model-logo/ModelLogo.mjs +95 -0
- package/dist/components/model-logo/ModelLogo.mjs.map +1 -0
- package/dist/components/model-logo/index.d.cts +2 -0
- package/dist/components/model-logo/index.d.mts +2 -0
- package/dist/components/navigation-menu/NavigationMenu.cjs +65 -0
- package/dist/components/navigation-menu/NavigationMenu.cjs.map +1 -0
- package/dist/components/navigation-menu/NavigationMenu.d.cts +11 -0
- package/dist/components/navigation-menu/NavigationMenu.d.cts.map +1 -0
- package/dist/components/navigation-menu/NavigationMenu.d.mts +11 -0
- package/dist/components/navigation-menu/NavigationMenu.d.mts.map +1 -0
- package/dist/components/navigation-menu/NavigationMenu.mjs +57 -0
- package/dist/components/navigation-menu/NavigationMenu.mjs.map +1 -0
- package/dist/components/navigation-menu/index.d.cts +3 -0
- package/dist/components/navigation-menu/index.d.mts +3 -0
- package/dist/components/neural-flow/NeuralFlow.cjs +1038 -0
- package/dist/components/neural-flow/NeuralFlow.cjs.map +1 -0
- package/dist/components/neural-flow/NeuralFlow.d.cts +47 -0
- package/dist/components/neural-flow/NeuralFlow.d.cts.map +1 -0
- package/dist/components/neural-flow/NeuralFlow.d.mts +47 -0
- package/dist/components/neural-flow/NeuralFlow.d.mts.map +1 -0
- package/dist/components/neural-flow/NeuralFlow.mjs +1032 -0
- package/dist/components/neural-flow/NeuralFlow.mjs.map +1 -0
- package/dist/components/neural-flow/index.d.cts +2 -0
- package/dist/components/neural-flow/index.d.mts +2 -0
- package/dist/components/neural-flow/mnist-samples.cjs +73 -0
- package/dist/components/neural-flow/mnist-samples.cjs.map +1 -0
- package/dist/components/neural-flow/mnist-samples.mjs +73 -0
- package/dist/components/neural-flow/mnist-samples.mjs.map +1 -0
- package/dist/components/neural-flow/sparse-weights.cjs +21 -0
- package/dist/components/neural-flow/sparse-weights.cjs.map +1 -0
- package/dist/components/neural-flow/sparse-weights.mjs +21 -0
- package/dist/components/neural-flow/sparse-weights.mjs.map +1 -0
- package/dist/components/progress/Progress.cjs +25 -0
- package/dist/components/progress/Progress.cjs.map +1 -0
- package/dist/components/progress/Progress.d.cts +8 -0
- package/dist/components/progress/Progress.d.cts.map +1 -0
- package/dist/components/progress/Progress.d.mts +8 -0
- package/dist/components/progress/Progress.d.mts.map +1 -0
- package/dist/components/progress/Progress.mjs +19 -0
- package/dist/components/progress/Progress.mjs.map +1 -0
- package/dist/components/progress/index.d.cts +3 -0
- package/dist/components/progress/index.d.mts +3 -0
- package/dist/components/search-input/SearchInput.cjs +28 -0
- package/dist/components/search-input/SearchInput.cjs.map +1 -0
- package/dist/components/search-input/SearchInput.d.cts +10 -0
- package/dist/components/search-input/SearchInput.d.cts.map +1 -0
- package/dist/components/search-input/SearchInput.d.mts +10 -0
- package/dist/components/search-input/SearchInput.d.mts.map +1 -0
- package/dist/components/search-input/SearchInput.mjs +26 -0
- package/dist/components/search-input/SearchInput.mjs.map +1 -0
- package/dist/components/search-input/index.d.cts +2 -0
- package/dist/components/search-input/index.d.mts +2 -0
- package/dist/components/select/index.d.cts +2 -0
- package/dist/components/select/index.d.mts +2 -0
- package/dist/components/sidebar/Sidebar.cjs +203 -0
- package/dist/components/sidebar/Sidebar.cjs.map +1 -0
- package/dist/components/sidebar/Sidebar.d.cts +69 -0
- package/dist/components/sidebar/Sidebar.d.cts.map +1 -0
- package/dist/components/sidebar/Sidebar.d.mts +69 -0
- package/dist/components/sidebar/Sidebar.d.mts.map +1 -0
- package/dist/components/sidebar/Sidebar.mjs +150 -0
- package/dist/components/sidebar/Sidebar.mjs.map +1 -0
- package/dist/components/sidebar/index.d.cts +3 -0
- package/dist/components/sidebar/index.d.mts +3 -0
- package/dist/components/skeleton/Skeleton.cjs +20 -0
- package/dist/components/skeleton/Skeleton.cjs.map +1 -0
- package/dist/components/skeleton/Skeleton.d.cts +7 -0
- package/dist/components/skeleton/Skeleton.d.cts.map +1 -0
- package/dist/components/skeleton/Skeleton.d.mts +7 -0
- package/dist/components/skeleton/Skeleton.d.mts.map +1 -0
- package/dist/components/skeleton/Skeleton.mjs +18 -0
- package/dist/components/skeleton/Skeleton.mjs.map +1 -0
- package/dist/components/skeleton/index.d.cts +2 -0
- package/dist/components/skeleton/index.d.mts +2 -0
- package/dist/components/switch/Switch.cjs +85 -0
- package/dist/components/switch/Switch.cjs.map +1 -0
- package/dist/components/switch/Switch.d.cts +21 -0
- package/dist/components/switch/Switch.d.cts.map +1 -0
- package/dist/components/switch/Switch.d.mts +21 -0
- package/dist/components/switch/Switch.d.mts.map +1 -0
- package/dist/components/switch/Switch.mjs +81 -0
- package/dist/components/switch/Switch.mjs.map +1 -0
- package/dist/components/switch/index.d.cts +2 -0
- package/dist/components/switch/index.d.mts +2 -0
- package/dist/components/table/Table.cjs +67 -0
- package/dist/components/table/Table.cjs.map +1 -0
- package/dist/components/table/Table.d.cts +13 -0
- package/dist/components/table/Table.d.cts.map +1 -0
- package/dist/components/table/Table.d.mts +13 -0
- package/dist/components/table/Table.d.mts.map +1 -0
- package/dist/components/table/Table.mjs +58 -0
- package/dist/components/table/Table.mjs.map +1 -0
- package/dist/components/table/index.d.cts +2 -0
- package/dist/components/table/index.d.mts +2 -0
- package/dist/components/text-area/index.d.cts +2 -0
- package/dist/components/text-area/index.d.mts +2 -0
- package/dist/components/theme-provider/ThemeProvider.cjs +81 -0
- package/dist/components/theme-provider/ThemeProvider.cjs.map +1 -0
- package/dist/components/theme-provider/ThemeProvider.d.cts +21 -0
- package/dist/components/theme-provider/ThemeProvider.d.cts.map +1 -0
- package/dist/components/theme-provider/ThemeProvider.d.mts +21 -0
- package/dist/components/theme-provider/ThemeProvider.d.mts.map +1 -0
- package/dist/components/theme-provider/ThemeProvider.mjs +78 -0
- package/dist/components/theme-provider/ThemeProvider.mjs.map +1 -0
- package/dist/components/theme-provider/ThemeToggle.cjs +56 -0
- package/dist/components/theme-provider/ThemeToggle.cjs.map +1 -0
- package/dist/components/theme-provider/ThemeToggle.d.cts +12 -0
- package/dist/components/theme-provider/ThemeToggle.d.cts.map +1 -0
- package/dist/components/theme-provider/ThemeToggle.d.mts +12 -0
- package/dist/components/theme-provider/ThemeToggle.d.mts.map +1 -0
- package/dist/components/theme-provider/ThemeToggle.mjs +54 -0
- package/dist/components/theme-provider/ThemeToggle.mjs.map +1 -0
- package/dist/components/theme-provider/index.d.cts +3 -0
- package/dist/components/theme-provider/index.d.mts +3 -0
- package/dist/components/tooltip/Tooltip.cjs +28 -0
- package/dist/components/tooltip/Tooltip.cjs.map +1 -0
- package/dist/components/tooltip/Tooltip.d.cts +14 -0
- package/dist/components/tooltip/Tooltip.d.cts.map +1 -0
- package/dist/components/tooltip/Tooltip.d.mts +14 -0
- package/dist/components/tooltip/Tooltip.d.mts.map +1 -0
- package/dist/components/tooltip/Tooltip.mjs +23 -0
- package/dist/components/tooltip/Tooltip.mjs.map +1 -0
- package/dist/components/tooltip/index.d.cts +3 -0
- package/dist/components/tooltip/index.d.mts +3 -0
- package/dist/components/typography/Typography.cjs +69 -0
- package/dist/components/typography/Typography.cjs.map +1 -0
- package/dist/components/typography/Typography.d.cts +14 -0
- package/dist/components/typography/Typography.d.cts.map +1 -0
- package/dist/components/typography/Typography.d.mts +14 -0
- package/dist/components/typography/Typography.d.mts.map +1 -0
- package/dist/components/typography/Typography.mjs +67 -0
- package/dist/components/typography/Typography.mjs.map +1 -0
- package/dist/components/typography/index.d.cts +2 -0
- package/dist/components/typography/index.d.mts +2 -0
- package/dist/components/window-frame/WindowFrame.cjs +47 -0
- package/dist/components/window-frame/WindowFrame.cjs.map +1 -0
- package/dist/components/window-frame/WindowFrame.d.cts +19 -0
- package/dist/components/window-frame/WindowFrame.d.cts.map +1 -0
- package/dist/components/window-frame/WindowFrame.d.mts +19 -0
- package/dist/components/window-frame/WindowFrame.d.mts.map +1 -0
- package/dist/components/window-frame/WindowFrame.mjs +46 -0
- package/dist/components/window-frame/WindowFrame.mjs.map +1 -0
- package/dist/components/window-frame/index.d.cts +2 -0
- package/dist/components/window-frame/index.d.mts +2 -0
- package/dist/hooks/use-mobile.cjs +23 -0
- package/dist/hooks/use-mobile.cjs.map +1 -0
- package/dist/hooks/use-mobile.mjs +21 -0
- package/dist/hooks/use-mobile.mjs.map +1 -0
- package/dist/index.cjs +235 -5936
- package/dist/index.d.cts +90 -840
- package/dist/index.d.mts +90 -0
- package/dist/index.mjs +52 -0
- package/dist/lib/shiki-theme.cjs +10 -0
- package/dist/lib/shiki-theme.cjs.map +1 -0
- package/dist/lib/shiki-theme.d.cts +4 -0
- package/dist/lib/shiki-theme.d.cts.map +1 -0
- package/dist/lib/shiki-theme.d.mts +4 -0
- package/dist/lib/shiki-theme.d.mts.map +1 -0
- package/dist/lib/shiki-theme.mjs +11 -0
- package/dist/lib/shiki-theme.mjs.map +1 -0
- package/dist/lib/shiki.cjs +31 -0
- package/dist/lib/shiki.cjs.map +1 -0
- package/dist/lib/shiki.d.cts +6 -0
- package/dist/lib/shiki.d.cts.map +1 -0
- package/dist/lib/shiki.d.mts +6 -0
- package/dist/lib/shiki.d.mts.map +1 -0
- package/dist/lib/shiki.mjs +30 -0
- package/dist/lib/shiki.mjs.map +1 -0
- package/dist/lib/terminal.d.cts +12 -0
- package/dist/lib/terminal.d.cts.map +1 -0
- package/dist/lib/terminal.d.mts +12 -0
- package/dist/lib/terminal.d.mts.map +1 -0
- package/dist/lib/utils.cjs +43 -0
- package/dist/lib/utils.cjs.map +1 -0
- package/dist/lib/utils.mjs +41 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/dist/neural-flow.cjs +3 -1015
- package/dist/neural-flow.d.cts +3 -47
- package/dist/neural-flow.d.mts +3 -0
- package/dist/neural-flow.mjs +1 -0
- package/dist/primitives/alert.cjs +43 -0
- package/dist/primitives/alert.cjs.map +1 -0
- package/dist/primitives/alert.d.cts +8 -0
- package/dist/primitives/alert.d.cts.map +1 -0
- package/dist/primitives/alert.d.mts +8 -0
- package/dist/primitives/alert.d.mts.map +1 -0
- package/dist/primitives/alert.mjs +39 -0
- package/dist/primitives/alert.mjs.map +1 -0
- package/dist/primitives/button.cjs +48 -0
- package/dist/primitives/button.cjs.map +1 -0
- package/dist/primitives/button.d.cts +11 -0
- package/dist/primitives/button.d.cts.map +1 -0
- package/dist/primitives/button.d.mts +11 -0
- package/dist/primitives/button.d.mts.map +1 -0
- package/dist/primitives/button.mjs +47 -0
- package/dist/primitives/button.mjs.map +1 -0
- package/dist/primitives/card.cjs +67 -0
- package/dist/primitives/card.cjs.map +1 -0
- package/dist/primitives/card.d.cts +11 -0
- package/dist/primitives/card.d.cts.map +1 -0
- package/dist/primitives/card.d.mts +11 -0
- package/dist/primitives/card.d.mts.map +1 -0
- package/dist/primitives/card.mjs +59 -0
- package/dist/primitives/card.mjs.map +1 -0
- package/dist/primitives/checkbox.cjs +22 -0
- package/dist/primitives/checkbox.cjs.map +1 -0
- package/dist/primitives/checkbox.mjs +22 -0
- package/dist/primitives/checkbox.mjs.map +1 -0
- package/dist/primitives/command.cjs +69 -0
- package/dist/primitives/command.cjs.map +1 -0
- package/dist/primitives/command.mjs +62 -0
- package/dist/primitives/command.mjs.map +1 -0
- package/dist/primitives/dropdown-menu.cjs +155 -0
- package/dist/primitives/dropdown-menu.cjs.map +1 -0
- package/dist/primitives/dropdown-menu.d.cts +30 -0
- package/dist/primitives/dropdown-menu.d.cts.map +1 -0
- package/dist/primitives/dropdown-menu.d.mts +30 -0
- package/dist/primitives/dropdown-menu.d.mts.map +1 -0
- package/dist/primitives/dropdown-menu.mjs +139 -0
- package/dist/primitives/dropdown-menu.mjs.map +1 -0
- package/dist/primitives/empty.cjs +67 -0
- package/dist/primitives/empty.cjs.map +1 -0
- package/dist/primitives/empty.d.cts +8 -0
- package/dist/primitives/empty.d.cts.map +1 -0
- package/dist/primitives/empty.d.mts +8 -0
- package/dist/primitives/empty.d.mts.map +1 -0
- package/dist/primitives/empty.mjs +62 -0
- package/dist/primitives/empty.mjs.map +1 -0
- package/dist/primitives/field.cjs +121 -0
- package/dist/primitives/field.cjs.map +1 -0
- package/dist/primitives/field.d.cts +27 -0
- package/dist/primitives/field.d.cts.map +1 -0
- package/dist/primitives/field.d.mts +27 -0
- package/dist/primitives/field.d.mts.map +1 -0
- package/dist/primitives/field.mjs +112 -0
- package/dist/primitives/field.mjs.map +1 -0
- package/dist/primitives/input-group.cjs +52 -0
- package/dist/primitives/input-group.cjs.map +1 -0
- package/dist/primitives/input-group.mjs +49 -0
- package/dist/primitives/input-group.mjs.map +1 -0
- package/dist/primitives/input.cjs +20 -0
- package/dist/primitives/input.cjs.map +1 -0
- package/dist/primitives/input.d.cts +6 -0
- package/dist/primitives/input.d.cts.map +1 -0
- package/dist/primitives/input.d.mts +6 -0
- package/dist/primitives/input.d.mts.map +1 -0
- package/dist/primitives/input.mjs +18 -0
- package/dist/primitives/input.mjs.map +1 -0
- package/dist/primitives/item.cjs +135 -0
- package/dist/primitives/item.cjs.map +1 -0
- package/dist/primitives/item.d.cts +18 -0
- package/dist/primitives/item.d.cts.map +1 -0
- package/dist/primitives/item.d.mts +18 -0
- package/dist/primitives/item.d.mts.map +1 -0
- package/dist/primitives/item.mjs +124 -0
- package/dist/primitives/item.mjs.map +1 -0
- package/dist/primitives/label.cjs +18 -0
- package/dist/primitives/label.cjs.map +1 -0
- package/dist/primitives/label.d.cts +6 -0
- package/dist/primitives/label.d.cts.map +1 -0
- package/dist/primitives/label.d.mts +6 -0
- package/dist/primitives/label.d.mts.map +1 -0
- package/dist/primitives/label.mjs +16 -0
- package/dist/primitives/label.mjs.map +1 -0
- package/dist/primitives/navigation-menu.cjs +44 -0
- package/dist/primitives/navigation-menu.cjs.map +1 -0
- package/dist/primitives/navigation-menu.d.cts +9 -0
- package/dist/primitives/navigation-menu.d.cts.map +1 -0
- package/dist/primitives/navigation-menu.d.mts +9 -0
- package/dist/primitives/navigation-menu.d.mts.map +1 -0
- package/dist/primitives/navigation-menu.mjs +41 -0
- package/dist/primitives/navigation-menu.mjs.map +1 -0
- package/dist/primitives/popover.cjs +40 -0
- package/dist/primitives/popover.cjs.map +1 -0
- package/dist/primitives/popover.mjs +36 -0
- package/dist/primitives/popover.mjs.map +1 -0
- package/dist/primitives/progress.cjs +50 -0
- package/dist/primitives/progress.cjs.map +1 -0
- package/dist/primitives/progress.d.cts +10 -0
- package/dist/primitives/progress.d.cts.map +1 -0
- package/dist/primitives/progress.d.mts +10 -0
- package/dist/primitives/progress.d.mts.map +1 -0
- package/dist/primitives/progress.mjs +46 -0
- package/dist/primitives/progress.mjs.map +1 -0
- package/dist/primitives/select.cjs +111 -0
- package/dist/primitives/select.cjs.map +1 -0
- package/dist/primitives/select.d.cts +18 -0
- package/dist/primitives/select.d.cts.map +1 -0
- package/dist/primitives/select.d.mts +18 -0
- package/dist/primitives/select.d.mts.map +1 -0
- package/dist/primitives/select.mjs +100 -0
- package/dist/primitives/select.mjs.map +1 -0
- package/dist/primitives/separator.cjs +17 -0
- package/dist/primitives/separator.cjs.map +1 -0
- package/dist/primitives/separator.d.cts +6 -0
- package/dist/primitives/separator.d.cts.map +1 -0
- package/dist/primitives/separator.d.mts +6 -0
- package/dist/primitives/separator.d.mts.map +1 -0
- package/dist/primitives/separator.mjs +17 -0
- package/dist/primitives/separator.mjs.map +1 -0
- package/dist/primitives/sheet.cjs +78 -0
- package/dist/primitives/sheet.cjs.map +1 -0
- package/dist/primitives/sheet.mjs +72 -0
- package/dist/primitives/sheet.mjs.map +1 -0
- package/dist/primitives/sidebar.cjs +413 -0
- package/dist/primitives/sidebar.cjs.map +1 -0
- package/dist/primitives/sidebar.d.cts +66 -0
- package/dist/primitives/sidebar.d.cts.map +1 -0
- package/dist/primitives/sidebar.d.mts +66 -0
- package/dist/primitives/sidebar.d.mts.map +1 -0
- package/dist/primitives/sidebar.mjs +388 -0
- package/dist/primitives/sidebar.mjs.map +1 -0
- package/dist/primitives/skeleton.cjs +15 -0
- package/dist/primitives/skeleton.cjs.map +1 -0
- package/dist/primitives/skeleton.mjs +15 -0
- package/dist/primitives/skeleton.mjs.map +1 -0
- package/dist/primitives/table.cjs +78 -0
- package/dist/primitives/table.cjs.map +1 -0
- package/dist/primitives/table.mjs +69 -0
- package/dist/primitives/table.mjs.map +1 -0
- package/dist/primitives/textarea.cjs +18 -0
- package/dist/primitives/textarea.cjs.map +1 -0
- package/dist/primitives/textarea.d.cts +6 -0
- package/dist/primitives/textarea.d.cts.map +1 -0
- package/dist/primitives/textarea.d.mts +6 -0
- package/dist/primitives/textarea.d.mts.map +1 -0
- package/dist/primitives/textarea.mjs +16 -0
- package/dist/primitives/textarea.mjs.map +1 -0
- package/dist/primitives/tooltip.cjs +46 -0
- package/dist/primitives/tooltip.cjs.map +1 -0
- package/dist/primitives/tooltip.d.cts +9 -0
- package/dist/primitives/tooltip.d.cts.map +1 -0
- package/dist/primitives/tooltip.d.mts +9 -0
- package/dist/primitives/tooltip.d.mts.map +1 -0
- package/dist/primitives/tooltip.mjs +43 -0
- package/dist/primitives/tooltip.mjs.map +1 -0
- package/dist/shiki.cjs +6 -80
- package/dist/shiki.d.cts +3 -10
- package/dist/shiki.d.mts +3 -0
- package/dist/shiki.mjs +3 -0
- package/dist/styles/index.css +11 -0
- package/package.json +19 -13
- package/dist/chunk-3LBFYXI6.js +0 -42
- package/dist/chunk-3LBFYXI6.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -840
- package/dist/index.js +0 -5681
- package/dist/index.js.map +0 -1
- package/dist/neural-flow.cjs.map +0 -1
- package/dist/neural-flow.d.ts +0 -47
- package/dist/neural-flow.js +0 -978
- package/dist/neural-flow.js.map +0 -1
- package/dist/shiki.cjs.map +0 -1
- package/dist/shiki.d.ts +0 -10
- package/dist/shiki.js +0 -11
- package/dist/shiki.js.map +0 -1
|
@@ -0,0 +1,1032 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { MNIST_SAMPLES } from "./mnist-samples.mjs";
|
|
3
|
+
import { SPARSE_WEIGHTS } from "./sparse-weights.mjs";
|
|
4
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Canvas, useFrame, useThree } from "@react-three/fiber";
|
|
7
|
+
import * as THREE from "three";
|
|
8
|
+
//#region src/components/neural-flow/NeuralFlow.tsx
|
|
9
|
+
/**
|
|
10
|
+
* NeuralFlow — AI inference, rendered live.
|
|
11
|
+
*
|
|
12
|
+
* An MLP in the shape of a classic MNIST classifier (784-256-128-64-10)
|
|
13
|
+
* floats in the Berget green, layer plane after plane receding into the
|
|
14
|
+
* depth. Tokens — signal packets — travel edge to edge through the net;
|
|
15
|
+
* every hop a weight attenuates them (they fade) or amplifies them
|
|
16
|
+
* (they swell bright), until a sample rolls the whole way through and
|
|
17
|
+
* the predicted output node blooms white-green. A CPU sim drives the
|
|
18
|
+
* state (1.2k nodes, ~1.8k live tokens is trivial arithmetic per
|
|
19
|
+
* frame); three.js only paints points, lines and a fog plane — which
|
|
20
|
+
* keeps this Safari-safe with zero float-FBO involvement.
|
|
21
|
+
*
|
|
22
|
+
* Props: every visual knob is a plain number prop read each frame —
|
|
23
|
+
* exposure, focus/blurK depth-of-field, sim speed (a true timeline:
|
|
24
|
+
* 0 pauses pixel-for-pixel, 0.2 is dream's pace), token intensity and
|
|
25
|
+
* camera drift. Reduced motion paints one deterministic still.
|
|
26
|
+
*/
|
|
27
|
+
const LAYER_SIZES = [
|
|
28
|
+
784,
|
|
29
|
+
256,
|
|
30
|
+
128,
|
|
31
|
+
64,
|
|
32
|
+
10
|
|
33
|
+
];
|
|
34
|
+
const LAYER_GRID = [
|
|
35
|
+
[28, 28],
|
|
36
|
+
[16, 16],
|
|
37
|
+
[16, 8],
|
|
38
|
+
[8, 8],
|
|
39
|
+
[10, 1]
|
|
40
|
+
];
|
|
41
|
+
const LAYER_X = 1.35;
|
|
42
|
+
const CELL = .05;
|
|
43
|
+
const TOKEN_POOL = 1800;
|
|
44
|
+
const SAMPLE_INTERVAL = 6.5;
|
|
45
|
+
const SAMPLE_WINDOW = 2.6;
|
|
46
|
+
const SAMPLE_RATE = 420;
|
|
47
|
+
const TRICKLE_RATE = 40;
|
|
48
|
+
const CLASSES = 10;
|
|
49
|
+
/** Classic 5x7 numerals — the actual "images" the net sees per class. */
|
|
50
|
+
const DIGITS = [
|
|
51
|
+
[
|
|
52
|
+
".###.",
|
|
53
|
+
"#...#",
|
|
54
|
+
"#..##",
|
|
55
|
+
"#.#.#",
|
|
56
|
+
"##..#",
|
|
57
|
+
"#...#",
|
|
58
|
+
".###."
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
"..#..",
|
|
62
|
+
".##..",
|
|
63
|
+
"..#..",
|
|
64
|
+
"..#..",
|
|
65
|
+
"..#..",
|
|
66
|
+
"..#..",
|
|
67
|
+
"#####"
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
".###.",
|
|
71
|
+
"#...#",
|
|
72
|
+
"....#",
|
|
73
|
+
"...#.",
|
|
74
|
+
"..#..",
|
|
75
|
+
".#...",
|
|
76
|
+
"#####"
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"#####",
|
|
80
|
+
"...#.",
|
|
81
|
+
"..#..",
|
|
82
|
+
"...#.",
|
|
83
|
+
"....#",
|
|
84
|
+
"#...#",
|
|
85
|
+
".###."
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
"...#.",
|
|
89
|
+
"..##.",
|
|
90
|
+
".#.#.",
|
|
91
|
+
"#..#.",
|
|
92
|
+
"#####",
|
|
93
|
+
"...#.",
|
|
94
|
+
"...#."
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
"#####",
|
|
98
|
+
"#....",
|
|
99
|
+
"####.",
|
|
100
|
+
"....#",
|
|
101
|
+
"....#",
|
|
102
|
+
"#...#",
|
|
103
|
+
".###."
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
"..##.",
|
|
107
|
+
".#...",
|
|
108
|
+
"#....",
|
|
109
|
+
"####.",
|
|
110
|
+
"#...#",
|
|
111
|
+
"#...#",
|
|
112
|
+
".###."
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
"#####",
|
|
116
|
+
"....#",
|
|
117
|
+
"...#.",
|
|
118
|
+
"..#..",
|
|
119
|
+
".#...",
|
|
120
|
+
".#...",
|
|
121
|
+
".#..."
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
".###.",
|
|
125
|
+
"#...#",
|
|
126
|
+
"#...#",
|
|
127
|
+
".###.",
|
|
128
|
+
"#...#",
|
|
129
|
+
"#...#",
|
|
130
|
+
".###."
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
".###.",
|
|
134
|
+
"#...#",
|
|
135
|
+
"#...#",
|
|
136
|
+
".####",
|
|
137
|
+
"....#",
|
|
138
|
+
"...#.",
|
|
139
|
+
".##.."
|
|
140
|
+
]
|
|
141
|
+
];
|
|
142
|
+
const PALETTE = {
|
|
143
|
+
deep: [
|
|
144
|
+
.027,
|
|
145
|
+
.235,
|
|
146
|
+
.2
|
|
147
|
+
],
|
|
148
|
+
mid: [
|
|
149
|
+
.051,
|
|
150
|
+
.42,
|
|
151
|
+
.322
|
|
152
|
+
],
|
|
153
|
+
crest: [
|
|
154
|
+
.137,
|
|
155
|
+
.627,
|
|
156
|
+
.36
|
|
157
|
+
],
|
|
158
|
+
slate: [
|
|
159
|
+
.12,
|
|
160
|
+
.17,
|
|
161
|
+
.19
|
|
162
|
+
],
|
|
163
|
+
white: [
|
|
164
|
+
.85,
|
|
165
|
+
1,
|
|
166
|
+
.9
|
|
167
|
+
]
|
|
168
|
+
};
|
|
169
|
+
/** The dark well behind the fog plane, in brand tokens — the gradient
|
|
170
|
+
the raw canvas painted under itself. Requires the package's
|
|
171
|
+
styles (dist/styles/index.css), like every themed component here. */
|
|
172
|
+
const BACKDROP = "radial-gradient(120% 95% at 28% 58%, var(--berget-brand-moss-900) 0%, var(--berget-brand-moss-950) 55%, var(--berget-brand-granite-950) 100%)";
|
|
173
|
+
function mulberry32(seed) {
|
|
174
|
+
let a = seed >>> 0;
|
|
175
|
+
return () => {
|
|
176
|
+
a |= 0;
|
|
177
|
+
a = a + 1831565813 | 0;
|
|
178
|
+
let t = Math.imul(a ^ a >>> 15, 1 | a);
|
|
179
|
+
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
180
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function buildNetwork(seed, orientation) {
|
|
184
|
+
const rng = mulberry32(seed);
|
|
185
|
+
const nodeCount = LAYER_SIZES.reduce((a, b) => a + b, 0);
|
|
186
|
+
const positions = new Float32Array(nodeCount * 3);
|
|
187
|
+
const layerStart = [];
|
|
188
|
+
let flat = 0;
|
|
189
|
+
LAYER_SIZES.forEach((size, li) => {
|
|
190
|
+
layerStart.push(flat);
|
|
191
|
+
const [rows, cols] = LAYER_GRID[li];
|
|
192
|
+
for (let i = 0; i < size; i++) {
|
|
193
|
+
const r = Math.floor(i / cols);
|
|
194
|
+
const c = i % cols;
|
|
195
|
+
const o = flat * 3;
|
|
196
|
+
if (orientation === "vertical") {
|
|
197
|
+
positions[o] = (c - (cols - 1) / 2) * CELL;
|
|
198
|
+
positions[o + 1] = li * LAYER_X;
|
|
199
|
+
positions[o + 2] = (r - (rows - 1) / 2) * CELL;
|
|
200
|
+
} else {
|
|
201
|
+
positions[o] = li * LAYER_X;
|
|
202
|
+
positions[o + 1] = (r - (rows - 1) / 2) * CELL;
|
|
203
|
+
positions[o + 2] = (c - (cols - 1) / 2) * CELL;
|
|
204
|
+
}
|
|
205
|
+
flat++;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
const fanIn = [
|
|
209
|
+
0,
|
|
210
|
+
9,
|
|
211
|
+
10,
|
|
212
|
+
10,
|
|
213
|
+
7
|
|
214
|
+
];
|
|
215
|
+
const inEdges = [];
|
|
216
|
+
for (let i = 0; i < nodeCount; i++) inEdges.push([]);
|
|
217
|
+
for (let li = 1; li < LAYER_SIZES.length; li++) {
|
|
218
|
+
const srcBase = layerStart[li - 1];
|
|
219
|
+
const dstBase = layerStart[li];
|
|
220
|
+
for (let d = 0; d < LAYER_SIZES[li]; d++) {
|
|
221
|
+
const k = fanIn[li];
|
|
222
|
+
for (let e = 0; e < k; e++) {
|
|
223
|
+
const src = srcBase + Math.floor(rng() * LAYER_SIZES[li - 1]);
|
|
224
|
+
const w = rng() < .85 ? .75 + .9 * rng() : -(.35 + .35 * rng());
|
|
225
|
+
inEdges[dstBase + d].push({
|
|
226
|
+
src,
|
|
227
|
+
w
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const out = [];
|
|
233
|
+
for (let i = 0; i < nodeCount; i++) out.push({
|
|
234
|
+
dst: [],
|
|
235
|
+
w: []
|
|
236
|
+
});
|
|
237
|
+
let edgeCount = 0;
|
|
238
|
+
for (let d = 0; d < nodeCount; d++) edgeCount += inEdges[d].length;
|
|
239
|
+
const edgePositions = new Float32Array(edgeCount * 2 * 3);
|
|
240
|
+
const edgeWeights = new Float32Array(edgeCount * 2);
|
|
241
|
+
let eo = 0;
|
|
242
|
+
for (let d = 0; d < nodeCount; d++) for (const e of inEdges[d]) {
|
|
243
|
+
out[e.src].dst.push(d);
|
|
244
|
+
out[e.src].w.push(e.w);
|
|
245
|
+
edgePositions[eo * 6] = positions[e.src * 3];
|
|
246
|
+
edgePositions[eo * 6 + 1] = positions[e.src * 3 + 1];
|
|
247
|
+
edgePositions[eo * 6 + 2] = positions[e.src * 3 + 2];
|
|
248
|
+
edgePositions[eo * 6 + 3] = positions[d * 3];
|
|
249
|
+
edgePositions[eo * 6 + 4] = positions[d * 3 + 1];
|
|
250
|
+
edgePositions[eo * 6 + 5] = positions[d * 3 + 2];
|
|
251
|
+
const a = Math.min(1, Math.abs(e.w) * 1.6);
|
|
252
|
+
edgeWeights[eo * 2] = a;
|
|
253
|
+
edgeWeights[eo * 2 + 1] = a;
|
|
254
|
+
eo++;
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
positions,
|
|
258
|
+
nodeCount,
|
|
259
|
+
layerStart,
|
|
260
|
+
out,
|
|
261
|
+
inEdges,
|
|
262
|
+
edgePositions,
|
|
263
|
+
edgeWeights,
|
|
264
|
+
edgeCount
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
var FlowSim = class {
|
|
268
|
+
constructor(seed = 1337, orientation = "horizontal", blobs = glyphBlobs(), images = [], trained = decodeWeights()) {
|
|
269
|
+
this.predictedClass = 0;
|
|
270
|
+
this.rng = mulberry32(12648430);
|
|
271
|
+
this.tokens = [];
|
|
272
|
+
this.time = 0;
|
|
273
|
+
this.nextSample = .8;
|
|
274
|
+
this.sampleUntil = -10;
|
|
275
|
+
this.sampleClass = 0;
|
|
276
|
+
this.sampleVariant = 0;
|
|
277
|
+
this.emitAcc = 0;
|
|
278
|
+
this.net = buildNetwork(seed, orientation);
|
|
279
|
+
attachWeights(this.net, trained);
|
|
280
|
+
this.blobs = blobs;
|
|
281
|
+
this.images = images;
|
|
282
|
+
this.trained = trained;
|
|
283
|
+
this.energy = new Float32Array(this.net.nodeCount);
|
|
284
|
+
this.act = new Float32Array(this.net.nodeCount);
|
|
285
|
+
this.nodeAttr = new Float32Array(this.net.nodeCount);
|
|
286
|
+
this.tokenPos = new Float32Array(TOKEN_POOL * 3);
|
|
287
|
+
this.tokenGain = new Float32Array(TOKEN_POOL);
|
|
288
|
+
for (let i = 0; i < TOKEN_POOL; i++) this.tokens.push(null);
|
|
289
|
+
}
|
|
290
|
+
get network() {
|
|
291
|
+
return this.net;
|
|
292
|
+
}
|
|
293
|
+
/** Advance the whole inference world by dt seconds (clamped internally). */
|
|
294
|
+
step(dt, intensity) {
|
|
295
|
+
dt = Math.min(dt, .12);
|
|
296
|
+
this.time += dt;
|
|
297
|
+
const decay = Math.pow(.42, dt);
|
|
298
|
+
const inDecay = Math.pow(.6, dt);
|
|
299
|
+
const outDecay = Math.pow(.3, dt);
|
|
300
|
+
const inEnd = this.net.layerStart[1];
|
|
301
|
+
const outStart = this.net.layerStart[LAYER_SIZES.length - 1];
|
|
302
|
+
for (let i = 0; i < this.act.length; i++) this.act[i] = this.act[i] * (i >= outStart ? outDecay : i < inEnd ? inDecay : decay);
|
|
303
|
+
if (this.time >= this.nextSample) {
|
|
304
|
+
this.sampleClass = Math.floor(this.rng() * CLASSES);
|
|
305
|
+
const variants = this.blobs[this.sampleClass];
|
|
306
|
+
this.sampleVariant = Math.floor(this.rng() * variants.length);
|
|
307
|
+
this.sampleUntil = this.time + SAMPLE_WINDOW;
|
|
308
|
+
this.nextSample = this.time + SAMPLE_INTERVAL;
|
|
309
|
+
const { predicted, energy } = forwardPass(this.net, this.trained, this.imageOf(this.sampleClass, this.sampleVariant));
|
|
310
|
+
this.predictedClass = predicted;
|
|
311
|
+
this.energy = energy;
|
|
312
|
+
}
|
|
313
|
+
const fade = Math.pow(.55, dt);
|
|
314
|
+
if (this.time > this.sampleUntil) for (let i = 0; i < this.energy.length; i++) this.energy[i] = this.energy[i] * fade;
|
|
315
|
+
const inSample = this.time < this.sampleUntil;
|
|
316
|
+
const rate = (inSample ? SAMPLE_RATE : TRICKLE_RATE) * intensity;
|
|
317
|
+
this.emitAcc += rate * dt;
|
|
318
|
+
while (this.emitAcc >= 1) {
|
|
319
|
+
this.emitAcc -= 1;
|
|
320
|
+
this.inject(inSample);
|
|
321
|
+
}
|
|
322
|
+
for (let i = 0; i < TOKEN_POOL; i++) {
|
|
323
|
+
const tok = this.tokens[i];
|
|
324
|
+
if (!tok) continue;
|
|
325
|
+
tok.t += tok.rate * dt;
|
|
326
|
+
const p = this.net.positions;
|
|
327
|
+
const s3 = tok.src * 3;
|
|
328
|
+
const d3 = tok.dst * 3;
|
|
329
|
+
const t = Math.min(tok.t, 1);
|
|
330
|
+
tok.pos = [
|
|
331
|
+
p[s3] + (p[d3] - p[s3]) * t,
|
|
332
|
+
p[s3 + 1] + (p[d3 + 1] - p[s3 + 1]) * t,
|
|
333
|
+
p[s3 + 2] + (p[d3 + 2] - p[s3 + 2]) * t
|
|
334
|
+
];
|
|
335
|
+
if (tok.t < 1) continue;
|
|
336
|
+
const isFinal = tok.layer === LAYER_SIZES.length - 2;
|
|
337
|
+
let pulse = tok.gain * .55;
|
|
338
|
+
if (isFinal) {
|
|
339
|
+
if (tok.dst - this.net.layerStart[LAYER_SIZES.length - 1] === this.predictedClass) pulse *= 3.8;
|
|
340
|
+
}
|
|
341
|
+
this.act[tok.dst] = Math.min(2, Math.max(-2, this.act[tok.dst] + pulse));
|
|
342
|
+
const energyHere = this.energy[tok.dst];
|
|
343
|
+
if (inSample && !isFinal && energyHere < .1 && this.rng() < .7) {
|
|
344
|
+
this.tokens[i] = null;
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
const gain = Math.min(.25 + 1.6 * energyHere, 2.4);
|
|
348
|
+
if (isFinal) {
|
|
349
|
+
this.tokens[i] = null;
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
const outs = this.net.out[tok.dst];
|
|
353
|
+
if (outs.dst.length === 0) {
|
|
354
|
+
this.tokens[i] = null;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
const pick = Math.floor(this.rng() * outs.dst.length);
|
|
358
|
+
tok.src = tok.dst;
|
|
359
|
+
tok.dst = outs.dst[pick];
|
|
360
|
+
tok.w = outs.w[pick];
|
|
361
|
+
tok.layer += 1;
|
|
362
|
+
tok.t = 0;
|
|
363
|
+
const len = edgeLen(this.net.positions, tok.src, tok.dst);
|
|
364
|
+
tok.rate = 1.35 / Math.max(len, .05) * (.75 + this.rng() * .5);
|
|
365
|
+
tok.gain = gain;
|
|
366
|
+
}
|
|
367
|
+
for (let i = 0; i < this.act.length; i++) this.nodeAttr[i] = this.act[i];
|
|
368
|
+
}
|
|
369
|
+
/** The 784-vector for a class variant: real image if we have one,
|
|
370
|
+
otherwise intensities derived from the blob shape. */
|
|
371
|
+
imageOf(cls, variant) {
|
|
372
|
+
const list = this.images[cls];
|
|
373
|
+
if (list && list.length > 0) return list[Math.min(variant, list.length - 1)];
|
|
374
|
+
const img = /* @__PURE__ */ new Float32Array(784);
|
|
375
|
+
const blob = this.blobs[cls][Math.min(variant, this.blobs[cls].length - 1)];
|
|
376
|
+
for (const c of blob) img[c.i] = Math.min(1, c.w + .25);
|
|
377
|
+
return img;
|
|
378
|
+
}
|
|
379
|
+
inject(fromBlob) {
|
|
380
|
+
const slot = this.tokens.indexOf(null);
|
|
381
|
+
if (slot < 0) return;
|
|
382
|
+
const rng = this.rng;
|
|
383
|
+
let src;
|
|
384
|
+
if (fromBlob) {
|
|
385
|
+
const variants = this.blobs[this.sampleClass];
|
|
386
|
+
const blob = variants[Math.min(this.sampleVariant, variants.length - 1)];
|
|
387
|
+
src = pickWeightedBlob(blob, rng());
|
|
388
|
+
} else src = Math.floor(rng() * LAYER_SIZES[0]);
|
|
389
|
+
const outs = this.net.out[src];
|
|
390
|
+
if (outs.dst.length === 0) return;
|
|
391
|
+
const pick = Math.floor(rng() * outs.dst.length);
|
|
392
|
+
const len = edgeLen(this.net.positions, src, outs.dst[pick]);
|
|
393
|
+
this.tokens[slot] = {
|
|
394
|
+
src,
|
|
395
|
+
dst: outs.dst[pick],
|
|
396
|
+
w: outs.w[pick],
|
|
397
|
+
layer: 0,
|
|
398
|
+
t: 0,
|
|
399
|
+
rate: 1.35 / Math.max(len, .05) * (.75 + rng() * .5),
|
|
400
|
+
gain: fromBlob ? 1 : .6,
|
|
401
|
+
pos: [
|
|
402
|
+
0,
|
|
403
|
+
0,
|
|
404
|
+
0
|
|
405
|
+
]
|
|
406
|
+
};
|
|
407
|
+
this.act[src] = Math.min(2, this.act[src] + (fromBlob ? .9 : .12));
|
|
408
|
+
}
|
|
409
|
+
/** Write live token rows into the point buffers (dead rows stay 0). */
|
|
410
|
+
writeTokenBuffers() {
|
|
411
|
+
for (let i = 0; i < TOKEN_POOL; i++) {
|
|
412
|
+
const tok = this.tokens[i];
|
|
413
|
+
const o = i * 3;
|
|
414
|
+
if (!tok) {
|
|
415
|
+
this.tokenGain[i] = 0;
|
|
416
|
+
this.tokenPos[o] = 0;
|
|
417
|
+
this.tokenPos[o + 1] = 0;
|
|
418
|
+
this.tokenPos[o + 2] = 0;
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
this.tokenPos[o] = tok.pos[0];
|
|
422
|
+
this.tokenPos[o + 1] = tok.pos[1];
|
|
423
|
+
this.tokenPos[o + 2] = tok.pos[2];
|
|
424
|
+
this.tokenGain[i] = tok.gain;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
/** Procedural 5x7-glyph digits — fallback when no samples are given. */
|
|
429
|
+
function glyphBlobs() {
|
|
430
|
+
const rng = mulberry32(857623);
|
|
431
|
+
const all = [];
|
|
432
|
+
for (let cls = 0; cls < CLASSES; cls++) {
|
|
433
|
+
const field = /* @__PURE__ */ new Float32Array(784);
|
|
434
|
+
const glyph = DIGITS[cls];
|
|
435
|
+
const dx = 4 + Math.floor(rng() * 3);
|
|
436
|
+
const dy = Math.floor(rng() * 3) - 1;
|
|
437
|
+
for (let gr = 0; gr < 7; gr++) {
|
|
438
|
+
const row = glyph[gr];
|
|
439
|
+
for (let gc = 0; gc < 5; gc++) {
|
|
440
|
+
if (row[gc] !== "#") continue;
|
|
441
|
+
for (let k = 0; k < 4; k++) for (let l = 0; l < 4; l++) {
|
|
442
|
+
const r = gr * 4 + l + dy;
|
|
443
|
+
const c = gc * 4 + k + dx;
|
|
444
|
+
if (r < 28 && c < 28) field[r * 28 + c] = 1;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
const blob = [];
|
|
449
|
+
for (let i = 0; i < 784; i++) if (field[i] > 0) blob.push({
|
|
450
|
+
i,
|
|
451
|
+
w: 1
|
|
452
|
+
});
|
|
453
|
+
for (let k = 0; k < 8; k++) blob.push({
|
|
454
|
+
i: Math.floor(rng() * 784),
|
|
455
|
+
w: .15
|
|
456
|
+
});
|
|
457
|
+
all.push([blob]);
|
|
458
|
+
}
|
|
459
|
+
return all;
|
|
460
|
+
}
|
|
461
|
+
/** Decode base64url into raw bytes — shared by weights and samples. */
|
|
462
|
+
function decodeB64(b64) {
|
|
463
|
+
const bin = atob(b64.replace(/-/g, "+").replace(/_/g, "/"));
|
|
464
|
+
const buf = new Uint8Array(bin.length);
|
|
465
|
+
for (let i = 0; i < bin.length; i++) buf[i] = bin.charCodeAt(i);
|
|
466
|
+
return buf;
|
|
467
|
+
}
|
|
468
|
+
/** Decode packed FP32 little-endian base64url into a Float32Array. */
|
|
469
|
+
function decodeF32(b64) {
|
|
470
|
+
return new Float32Array(decodeB64(b64).buffer);
|
|
471
|
+
}
|
|
472
|
+
/** The trained sparse weight set (see train-sparse.py). */
|
|
473
|
+
function decodeWeights() {
|
|
474
|
+
return {
|
|
475
|
+
w: [
|
|
476
|
+
decodeF32(SPARSE_WEIGHTS.weights1),
|
|
477
|
+
decodeF32(SPARSE_WEIGHTS.weights2),
|
|
478
|
+
decodeF32(SPARSE_WEIGHTS.weights3),
|
|
479
|
+
decodeF32(SPARSE_WEIGHTS.weights4)
|
|
480
|
+
],
|
|
481
|
+
b: [
|
|
482
|
+
decodeF32(SPARSE_WEIGHTS.biases1),
|
|
483
|
+
decodeF32(SPARSE_WEIGHTS.biases2),
|
|
484
|
+
decodeF32(SPARSE_WEIGHTS.biases3),
|
|
485
|
+
decodeF32(SPARSE_WEIGHTS.biases4)
|
|
486
|
+
]
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Splice trained weights into the visible net: every rendered edge
|
|
491
|
+
* gets its trained value, the edge-alpha map follows |w|, and `out`
|
|
492
|
+
* is rebuilt with the trained magnitudes for the hop visuals.
|
|
493
|
+
*/
|
|
494
|
+
function attachWeights(net, trained) {
|
|
495
|
+
const layerStart = net.layerStart;
|
|
496
|
+
for (let li = 1; li < 5; li++) {
|
|
497
|
+
const base = layerStart[li];
|
|
498
|
+
const w = trained.w[li - 1];
|
|
499
|
+
let eo = 0;
|
|
500
|
+
const nextBase = li < 4 ? layerStart[li + 1] : net.nodeCount;
|
|
501
|
+
for (let dlocal = 0; dlocal < nextBase - base; dlocal++) {
|
|
502
|
+
const dst = base + dlocal;
|
|
503
|
+
const list = net.inEdges[dst];
|
|
504
|
+
for (const e of list) {
|
|
505
|
+
e.w = w[eo];
|
|
506
|
+
eo++;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (eo !== w.length) throw new Error(`layer ${li}: expected ${w.length} edges, got ${eo}`);
|
|
510
|
+
}
|
|
511
|
+
for (const o of net.out) {
|
|
512
|
+
o.dst.length = 0;
|
|
513
|
+
o.w.length = 0;
|
|
514
|
+
}
|
|
515
|
+
let eo = 0;
|
|
516
|
+
for (let d = 0; d < net.nodeCount; d++) for (const e of net.inEdges[d]) {
|
|
517
|
+
net.out[e.src].dst.push(d);
|
|
518
|
+
net.out[e.src].w.push(e.w);
|
|
519
|
+
net.edgeWeights[eo * 2] = Math.min(1, Math.abs(e.w) * 1.7);
|
|
520
|
+
net.edgeWeights[eo * 2 + 1] = Math.min(1, Math.abs(e.w) * 1.7);
|
|
521
|
+
eo++;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
/** Real forward pass through the visible, trained edges. */
|
|
525
|
+
function forwardPass(net, trained, img) {
|
|
526
|
+
const act = new Float32Array(net.nodeCount);
|
|
527
|
+
act.set(img);
|
|
528
|
+
const layerStart = net.layerStart;
|
|
529
|
+
for (let li = 1; li < 5; li++) {
|
|
530
|
+
const base = layerStart[li];
|
|
531
|
+
const size = LAYER_SIZES[li];
|
|
532
|
+
const bias = trained.b[li - 1];
|
|
533
|
+
for (let dl = 0; dl < size; dl++) {
|
|
534
|
+
let z = bias[dl];
|
|
535
|
+
for (const e of net.inEdges[base + dl]) z += act[e.src] * e.w;
|
|
536
|
+
act[base + dl] = li < 4 ? Math.max(z, 0) : z;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
const energy = new Float32Array(act.length);
|
|
540
|
+
for (let li = 0; li < 5; li++) {
|
|
541
|
+
const base = layerStart[li];
|
|
542
|
+
const size = LAYER_SIZES[li];
|
|
543
|
+
let max = 1e-4;
|
|
544
|
+
for (let i = base; i < base + size; i++) max = Math.max(max, act[i]);
|
|
545
|
+
for (let i = base; i < base + size; i++) energy[i] = Math.max(act[i], 0) / max;
|
|
546
|
+
}
|
|
547
|
+
const outBase = layerStart[4];
|
|
548
|
+
let predicted = 0;
|
|
549
|
+
let top = -1e9;
|
|
550
|
+
for (let c = 0; c < CLASSES; c++) if (act[outBase + c] > top) {
|
|
551
|
+
top = act[outBase + c];
|
|
552
|
+
predicted = c;
|
|
553
|
+
}
|
|
554
|
+
return {
|
|
555
|
+
predicted,
|
|
556
|
+
energy
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function decodeAll(samples) {
|
|
560
|
+
const blobs = [];
|
|
561
|
+
const images = [];
|
|
562
|
+
for (let c = 0; c < CLASSES; c++) {
|
|
563
|
+
const cellList = [];
|
|
564
|
+
const imgList = [];
|
|
565
|
+
for (const b64 of samples[c] ?? []) {
|
|
566
|
+
const buf = decodeB64(b64);
|
|
567
|
+
const cells = [];
|
|
568
|
+
const img = /* @__PURE__ */ new Float32Array(784);
|
|
569
|
+
for (let n = 0; n < 784; n++) {
|
|
570
|
+
const byte = buf[n >> 1];
|
|
571
|
+
const v = n & 1 ? byte & 15 : byte >> 4;
|
|
572
|
+
if (v >= 5) cells.push({
|
|
573
|
+
i: n,
|
|
574
|
+
w: (v - 4) / 11
|
|
575
|
+
});
|
|
576
|
+
img[n] = v / 15;
|
|
577
|
+
}
|
|
578
|
+
cellList.push(cells);
|
|
579
|
+
imgList.push(img);
|
|
580
|
+
}
|
|
581
|
+
blobs.push(cellList);
|
|
582
|
+
images.push(imgList);
|
|
583
|
+
}
|
|
584
|
+
return {
|
|
585
|
+
blobs,
|
|
586
|
+
images
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
function pickWeightedBlob(blob, r) {
|
|
590
|
+
let total = 0;
|
|
591
|
+
for (const c of blob) total += c.w;
|
|
592
|
+
let acc = r * total;
|
|
593
|
+
for (const c of blob) {
|
|
594
|
+
acc -= c.w;
|
|
595
|
+
if (acc <= 0) return c.i;
|
|
596
|
+
}
|
|
597
|
+
return blob[blob.length - 1].i;
|
|
598
|
+
}
|
|
599
|
+
function edgeLen(p, a, b) {
|
|
600
|
+
const a3 = a * 3;
|
|
601
|
+
const b3 = b * 3;
|
|
602
|
+
const dx = p[b3] - p[a3];
|
|
603
|
+
const dy = p[b3 + 1] - p[a3 + 1];
|
|
604
|
+
const dz = p[b3 + 2] - p[a3 + 2];
|
|
605
|
+
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
606
|
+
}
|
|
607
|
+
const POINT_VERT = `
|
|
608
|
+
attribute float aAct; // node activation, or token gain for tokens
|
|
609
|
+
uniform float uHeightPx, uFovTan, uDpr, uFocusDist, uBlurK;
|
|
610
|
+
uniform float uBaseSize;
|
|
611
|
+
varying float vAct;
|
|
612
|
+
varying float vFade;
|
|
613
|
+
void main() {
|
|
614
|
+
vec4 mv = modelViewMatrix * vec4(position, 1.0);
|
|
615
|
+
float dist = max(-mv.z, 0.001);
|
|
616
|
+
vAct = aAct;
|
|
617
|
+
float a = max(aAct, 0.0);
|
|
618
|
+
float worldSize = uBaseSize * (1.0 + clamp(a, 0.0, 2.0) * 0.9);
|
|
619
|
+
// uHeightPx is the drawing-buffer height (already device px), so the
|
|
620
|
+
// world-size term needs no uDpr; the pixel-space defocus offset does.
|
|
621
|
+
float px = worldSize * (uHeightPx * 0.5) / (uFovTan * dist);
|
|
622
|
+
float dz = dist - uFocusDist;
|
|
623
|
+
px += (dz < 0.0 ? -dz * 0.55 : dz * 0.8) * uBlurK * uDpr;
|
|
624
|
+
gl_PointSize = min(px, 90.0 * uDpr);
|
|
625
|
+
vFade = clamp(1.0 - abs(dz) * 0.16, 0.25, 1.0);
|
|
626
|
+
gl_Position = projectionMatrix * mv;
|
|
627
|
+
}
|
|
628
|
+
`;
|
|
629
|
+
const NODE_FRAG = `
|
|
630
|
+
uniform float uExposure;
|
|
631
|
+
varying float vAct;
|
|
632
|
+
varying float vFade;
|
|
633
|
+
const vec3 DEEP = vec3(${PALETTE.deep.join(",")});
|
|
634
|
+
const vec3 MID = vec3(${PALETTE.mid.join(",")});
|
|
635
|
+
const vec3 CREST = vec3(${PALETTE.crest.join(",")});
|
|
636
|
+
const vec3 SLATE = vec3(${PALETTE.slate.join(",")});
|
|
637
|
+
const vec3 WHITE = vec3(${PALETTE.white.join(",")});
|
|
638
|
+
void main() {
|
|
639
|
+
float d = length(gl_PointCoord - 0.5) * 2.0;
|
|
640
|
+
float disc = smoothstep(1.0, 0.35, d);
|
|
641
|
+
if (disc < 0.01) discard;
|
|
642
|
+
float a = vAct;
|
|
643
|
+
vec3 col;
|
|
644
|
+
float glow;
|
|
645
|
+
if (a >= 0.0) {
|
|
646
|
+
col = mix(MID, CREST, clamp(a, 0.0, 1.0));
|
|
647
|
+
// Overdriven nodes bloom toward the brand's crystal white-green.
|
|
648
|
+
float bloom = smoothstep(1.05, 1.9, a);
|
|
649
|
+
col = mix(col, WHITE, bloom);
|
|
650
|
+
glow = 0.36 + 0.64 * clamp(a, 0.0, 1.0) + bloom * 0.9;
|
|
651
|
+
} else {
|
|
652
|
+
col = mix(DEEP, SLATE, clamp(-a, 0.0, 1.0));
|
|
653
|
+
glow = 0.16 + 0.25 * clamp(-a, 0.0, 1.0);
|
|
654
|
+
}
|
|
655
|
+
gl_FragColor = vec4(col * uExposure, disc * 0.62 * glow * vFade);
|
|
656
|
+
}
|
|
657
|
+
`;
|
|
658
|
+
const TOKEN_FRAG = `
|
|
659
|
+
uniform float uExposure;
|
|
660
|
+
varying float vAct;
|
|
661
|
+
varying float vFade;
|
|
662
|
+
const vec3 CREST = vec3(${PALETTE.crest.join(",")});
|
|
663
|
+
const vec3 WHITE = vec3(${PALETTE.white.join(",")});
|
|
664
|
+
void main() {
|
|
665
|
+
float g = vAct;
|
|
666
|
+
if (g < 0.004) discard;
|
|
667
|
+
float d = length(gl_PointCoord - 0.5) * 2.0;
|
|
668
|
+
float core = smoothstep(0.55, 0.05, d);
|
|
669
|
+
float halo = smoothstep(1.0, 0.3, d) * 0.45;
|
|
670
|
+
if (core + halo < 0.01) discard;
|
|
671
|
+
// Amplified tokens run hot toward white-green.
|
|
672
|
+
vec3 col = mix(CREST, WHITE, smoothstep(1.1, 2.1, g));
|
|
673
|
+
float b = (0.35 + 0.65 * clamp(g, 0.0, 1.6)) * (core + halo);
|
|
674
|
+
gl_FragColor = vec4(col * uExposure, b * 0.78 * vFade);
|
|
675
|
+
}
|
|
676
|
+
`;
|
|
677
|
+
const EDGE_VERT = `
|
|
678
|
+
attribute float aEdgeW;
|
|
679
|
+
varying float vW;
|
|
680
|
+
void main() {
|
|
681
|
+
vW = aEdgeW;
|
|
682
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
683
|
+
}
|
|
684
|
+
`;
|
|
685
|
+
const EDGE_FRAG = `
|
|
686
|
+
varying float vW;
|
|
687
|
+
const vec3 DEEP = vec3(${PALETTE.crest.join(",")});
|
|
688
|
+
void main() {
|
|
689
|
+
gl_FragColor = vec4(DEEP, 0.02 + 0.05 * vW);
|
|
690
|
+
}
|
|
691
|
+
`;
|
|
692
|
+
const FOG_VERT = `
|
|
693
|
+
varying vec2 vUv;
|
|
694
|
+
void main() {
|
|
695
|
+
vUv = uv;
|
|
696
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
697
|
+
}
|
|
698
|
+
`;
|
|
699
|
+
const FOG_FRAG = `
|
|
700
|
+
uniform float uTime;
|
|
701
|
+
varying vec2 vUv;
|
|
702
|
+
|
|
703
|
+
float hash(vec2 p) {
|
|
704
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
|
705
|
+
}
|
|
706
|
+
float noise(vec2 p) {
|
|
707
|
+
vec2 i = floor(p);
|
|
708
|
+
vec2 f = fract(p);
|
|
709
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
710
|
+
return mix(
|
|
711
|
+
mix(hash(i), hash(i + vec2(1, 0)), f.x),
|
|
712
|
+
mix(hash(i + vec2(0, 1)), hash(i + vec2(1, 1)), f.x),
|
|
713
|
+
f.y
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
void main() {
|
|
718
|
+
vec2 c = vUv - 0.5;
|
|
719
|
+
float r = length(c) * 2.0;
|
|
720
|
+
// Soft brand-green well behind the stack, vignetted to darkness.
|
|
721
|
+
vec3 col = vec3(0.012, 0.05, 0.04) * max(1.0 - r, 0.0);
|
|
722
|
+
col += vec3(0.01, 0.06, 0.045) * max(1.5 - r * 1.25, 0.0);
|
|
723
|
+
// Slow drifting wisps crossing in front of the black.
|
|
724
|
+
float w = noise(vec2(vUv.x * 3.0 - uTime * 0.02, vUv.y * 6.0 + uTime * 0.013));
|
|
725
|
+
w = pow(w, 3.0) * 0.5;
|
|
726
|
+
col += vec3(0.05, 0.11, 0.09) * w * (1.0 - smoothstep(0.6, 1.2, r));
|
|
727
|
+
gl_FragColor = vec4(col, 1.0);
|
|
728
|
+
}
|
|
729
|
+
`;
|
|
730
|
+
const DEFAULT_KNOBS = {
|
|
731
|
+
zoom: 1,
|
|
732
|
+
exposure: 1.45,
|
|
733
|
+
focus: 8,
|
|
734
|
+
blurK: 4,
|
|
735
|
+
speed: 1,
|
|
736
|
+
intensity: 1,
|
|
737
|
+
drift: 1,
|
|
738
|
+
spin: .02
|
|
739
|
+
};
|
|
740
|
+
const BASE_FOV = 36;
|
|
741
|
+
function camFor(orientation) {
|
|
742
|
+
return orientation === "vertical" ? {
|
|
743
|
+
base: new THREE.Vector3(.7, 3.5, 9.6),
|
|
744
|
+
target: new THREE.Vector3(0, 2.45, 0),
|
|
745
|
+
center: new THREE.Vector3(0, 2.7, 0),
|
|
746
|
+
fogSize: [13, 15],
|
|
747
|
+
fogPos: new THREE.Vector3(1.5, 2.7, -6.5),
|
|
748
|
+
fogRot: 0
|
|
749
|
+
} : {
|
|
750
|
+
base: new THREE.Vector3(-.9, .88, 6.1),
|
|
751
|
+
target: new THREE.Vector3(2.35, -.08, -.2),
|
|
752
|
+
center: new THREE.Vector3(2.7, 0, 0),
|
|
753
|
+
fogSize: [14, 8],
|
|
754
|
+
fogPos: new THREE.Vector3(7.2, 0, 0),
|
|
755
|
+
fogRot: -Math.PI / 2
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
function SceneContent({ knobs: knobsRef, orientation, blobs, images }) {
|
|
759
|
+
const { invalidate } = useThree();
|
|
760
|
+
const trained = useMemo(() => decodeWeights(), []);
|
|
761
|
+
const sim = useMemo(() => new FlowSim(1337, orientation, blobs, images, trained), [
|
|
762
|
+
orientation,
|
|
763
|
+
blobs,
|
|
764
|
+
images,
|
|
765
|
+
trained
|
|
766
|
+
]);
|
|
767
|
+
const camCfg = useMemo(() => camFor(orientation), [orientation]);
|
|
768
|
+
const fogPlane = useMemo(() => new THREE.PlaneGeometry(camCfg.fogSize[0], camCfg.fogSize[1]), [camCfg]);
|
|
769
|
+
const geos = useMemo(() => {
|
|
770
|
+
const net = sim.network;
|
|
771
|
+
const nodes = new THREE.BufferGeometry();
|
|
772
|
+
nodes.setAttribute("position", new THREE.BufferAttribute(net.positions, 3));
|
|
773
|
+
const actAttr = new THREE.BufferAttribute(sim.nodeAttr, 1);
|
|
774
|
+
actAttr.setUsage(THREE.DynamicDrawUsage);
|
|
775
|
+
nodes.setAttribute("aAct", actAttr);
|
|
776
|
+
const tokens = new THREE.BufferGeometry();
|
|
777
|
+
const posAttr = new THREE.BufferAttribute(sim.tokenPos, 3);
|
|
778
|
+
posAttr.setUsage(THREE.DynamicDrawUsage);
|
|
779
|
+
tokens.setAttribute("position", posAttr);
|
|
780
|
+
const gainAttr = new THREE.BufferAttribute(sim.tokenGain, 1);
|
|
781
|
+
gainAttr.setUsage(THREE.DynamicDrawUsage);
|
|
782
|
+
tokens.setAttribute("aAct", gainAttr);
|
|
783
|
+
const b = 6;
|
|
784
|
+
nodes.boundingSphere = new THREE.Sphere(camCfg.center.clone(), b);
|
|
785
|
+
tokens.boundingSphere = new THREE.Sphere(camCfg.center.clone(), b);
|
|
786
|
+
const edges = new THREE.BufferGeometry();
|
|
787
|
+
edges.setAttribute("position", new THREE.BufferAttribute(net.edgePositions, 3));
|
|
788
|
+
edges.setAttribute("aEdgeW", new THREE.BufferAttribute(net.edgeWeights, 1));
|
|
789
|
+
edges.boundingSphere = new THREE.Sphere(camCfg.center.clone(), b);
|
|
790
|
+
return [
|
|
791
|
+
nodes,
|
|
792
|
+
tokens,
|
|
793
|
+
edges
|
|
794
|
+
];
|
|
795
|
+
}, [sim, camCfg]);
|
|
796
|
+
const nodeMat = useMemo(() => makePointMaterial(), []);
|
|
797
|
+
const tokenMat = useMemo(() => makeTokenMaterial(), []);
|
|
798
|
+
const edgeMat = useMemo(() => new THREE.ShaderMaterial({
|
|
799
|
+
vertexShader: EDGE_VERT,
|
|
800
|
+
fragmentShader: EDGE_FRAG,
|
|
801
|
+
transparent: true,
|
|
802
|
+
depthWrite: false,
|
|
803
|
+
blending: THREE.AdditiveBlending,
|
|
804
|
+
uniforms: {}
|
|
805
|
+
}), []);
|
|
806
|
+
const fogMat = useMemo(() => new THREE.ShaderMaterial({
|
|
807
|
+
vertexShader: FOG_VERT,
|
|
808
|
+
fragmentShader: FOG_FRAG,
|
|
809
|
+
depthWrite: false,
|
|
810
|
+
blending: THREE.NoBlending,
|
|
811
|
+
uniforms: { uTime: { value: 0 } }
|
|
812
|
+
}), []);
|
|
813
|
+
useEffect(() => () => {
|
|
814
|
+
for (const g of geos) g.dispose();
|
|
815
|
+
fogPlane.dispose();
|
|
816
|
+
nodeMat.dispose();
|
|
817
|
+
tokenMat.dispose();
|
|
818
|
+
edgeMat.dispose();
|
|
819
|
+
fogMat.dispose();
|
|
820
|
+
}, [
|
|
821
|
+
geos,
|
|
822
|
+
fogPlane,
|
|
823
|
+
nodeMat,
|
|
824
|
+
tokenMat,
|
|
825
|
+
edgeMat,
|
|
826
|
+
fogMat
|
|
827
|
+
]);
|
|
828
|
+
const worldTimeRef = useRef(0);
|
|
829
|
+
const lastElapsedRef = useRef(0);
|
|
830
|
+
const warmedSimRef = useRef(null);
|
|
831
|
+
const spinRef = useRef(null);
|
|
832
|
+
useFrame((state) => {
|
|
833
|
+
const speed = reduced() ? 0 : knobsRef.current.speed;
|
|
834
|
+
const dt = Math.min(state.clock.elapsedTime - lastElapsedRef.current, .25);
|
|
835
|
+
lastElapsedRef.current = state.clock.elapsedTime;
|
|
836
|
+
worldTimeRef.current += dt * Math.max(speed, 0);
|
|
837
|
+
const t = reduced() ? 8 : worldTimeRef.current;
|
|
838
|
+
const justWarmed = warmedSimRef.current !== sim;
|
|
839
|
+
if (justWarmed) {
|
|
840
|
+
for (let i = 0; i < 120; i++) sim.step(1 / 30, 1);
|
|
841
|
+
warmedSimRef.current = sim;
|
|
842
|
+
} else if (!reduced()) sim.step(dt * Math.max(speed, 0), knobsRef.current.intensity);
|
|
843
|
+
sim.writeTokenBuffers();
|
|
844
|
+
for (const [geo, attr] of [
|
|
845
|
+
[geos[0], "aAct"],
|
|
846
|
+
[geos[1], "position"],
|
|
847
|
+
[geos[1], "aAct"]
|
|
848
|
+
]) {
|
|
849
|
+
const a = geo.getAttribute(attr);
|
|
850
|
+
a.needsUpdate = true;
|
|
851
|
+
}
|
|
852
|
+
const cam = state.camera;
|
|
853
|
+
const fov = BASE_FOV / Math.max(knobsRef.current.zoom, .05);
|
|
854
|
+
if (Math.abs(cam.fov - fov) > .01) {
|
|
855
|
+
cam.fov = fov;
|
|
856
|
+
cam.updateProjectionMatrix();
|
|
857
|
+
}
|
|
858
|
+
const drift = knobsRef.current.drift;
|
|
859
|
+
cam.position.set(camCfg.base.x + Math.sin(t * .11) * .16 * drift, camCfg.base.y + Math.sin(t * .073 + 2) * .09 * drift, camCfg.base.z + Math.cos(t * .091) * .16 * drift);
|
|
860
|
+
cam.lookAt(camCfg.target);
|
|
861
|
+
const height = state.gl.domElement.height;
|
|
862
|
+
const fovTan = Math.tan(THREE.MathUtils.degToRad(cam.fov * .5));
|
|
863
|
+
for (const m of [nodeMat, tokenMat]) {
|
|
864
|
+
m.uniforms.uHeightPx.value = height;
|
|
865
|
+
m.uniforms.uFovTan.value = fovTan;
|
|
866
|
+
m.uniforms.uDpr.value = state.gl.getPixelRatio();
|
|
867
|
+
m.uniforms.uFocusDist.value = knobsRef.current.focus;
|
|
868
|
+
m.uniforms.uBlurK.value = knobsRef.current.blurK;
|
|
869
|
+
m.uniforms.uExposure.value = knobsRef.current.exposure;
|
|
870
|
+
}
|
|
871
|
+
if (spinRef.current) spinRef.current.rotation.y = t * knobsRef.current.spin;
|
|
872
|
+
fogMat.uniforms.uTime.value = t;
|
|
873
|
+
if (!reduced() || justWarmed) invalidate();
|
|
874
|
+
});
|
|
875
|
+
return /* @__PURE__ */ jsxs("group", { children: [/* @__PURE__ */ jsx("mesh", {
|
|
876
|
+
geometry: fogPlane,
|
|
877
|
+
material: fogMat,
|
|
878
|
+
position: camCfg.fogPos.toArray(),
|
|
879
|
+
rotation: [
|
|
880
|
+
0,
|
|
881
|
+
camCfg.fogRot,
|
|
882
|
+
0
|
|
883
|
+
],
|
|
884
|
+
renderOrder: 0
|
|
885
|
+
}, orientation), /* @__PURE__ */ jsx("group", {
|
|
886
|
+
ref: spinRef,
|
|
887
|
+
position: camCfg.center.toArray(),
|
|
888
|
+
children: /* @__PURE__ */ jsxs("group", {
|
|
889
|
+
position: camCfg.center.clone().negate().toArray(),
|
|
890
|
+
children: [
|
|
891
|
+
/* @__PURE__ */ jsx("lineSegments", {
|
|
892
|
+
geometry: geos[2],
|
|
893
|
+
material: edgeMat,
|
|
894
|
+
renderOrder: 1
|
|
895
|
+
}),
|
|
896
|
+
/* @__PURE__ */ jsx("points", {
|
|
897
|
+
geometry: geos[0],
|
|
898
|
+
material: nodeMat,
|
|
899
|
+
renderOrder: 2
|
|
900
|
+
}),
|
|
901
|
+
/* @__PURE__ */ jsx("points", {
|
|
902
|
+
geometry: geos[1],
|
|
903
|
+
material: tokenMat,
|
|
904
|
+
renderOrder: 3
|
|
905
|
+
})
|
|
906
|
+
]
|
|
907
|
+
})
|
|
908
|
+
})] });
|
|
909
|
+
}
|
|
910
|
+
function makePointMaterial() {
|
|
911
|
+
return new THREE.ShaderMaterial({
|
|
912
|
+
vertexShader: POINT_VERT,
|
|
913
|
+
fragmentShader: NODE_FRAG,
|
|
914
|
+
transparent: true,
|
|
915
|
+
depthWrite: false,
|
|
916
|
+
blending: THREE.AdditiveBlending,
|
|
917
|
+
uniforms: {
|
|
918
|
+
uHeightPx: { value: 600 },
|
|
919
|
+
uFovTan: { value: .3 },
|
|
920
|
+
uDpr: { value: 1 },
|
|
921
|
+
uFocusDist: { value: 8 },
|
|
922
|
+
uBlurK: { value: 4 },
|
|
923
|
+
uBaseSize: { value: .025 },
|
|
924
|
+
uExposure: { value: 1.45 }
|
|
925
|
+
}
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
function makeTokenMaterial() {
|
|
929
|
+
return new THREE.ShaderMaterial({
|
|
930
|
+
vertexShader: POINT_VERT,
|
|
931
|
+
fragmentShader: TOKEN_FRAG,
|
|
932
|
+
transparent: true,
|
|
933
|
+
depthWrite: false,
|
|
934
|
+
blending: THREE.AdditiveBlending,
|
|
935
|
+
uniforms: {
|
|
936
|
+
uHeightPx: { value: 600 },
|
|
937
|
+
uFovTan: { value: .3 },
|
|
938
|
+
uDpr: { value: 1 },
|
|
939
|
+
uFocusDist: { value: 8 },
|
|
940
|
+
uBlurK: { value: 4 },
|
|
941
|
+
uBaseSize: { value: .011 },
|
|
942
|
+
uExposure: { value: 1.35 }
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
function reduced() {
|
|
947
|
+
return typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
948
|
+
}
|
|
949
|
+
const NeuralFlow = ({ className, style, orientation = "horizontal", inputSamples, zoom, exposure, focus, blurK, speed, intensity, drift, spin }) => {
|
|
950
|
+
const noAtob = typeof atob === "undefined";
|
|
951
|
+
const { blobs, images } = useMemo(() => {
|
|
952
|
+
const src = inputSamples === void 0 ? MNIST_SAMPLES : inputSamples;
|
|
953
|
+
if (noAtob || Object.keys(src).length === 0) return {
|
|
954
|
+
blobs: glyphBlobs(),
|
|
955
|
+
images: []
|
|
956
|
+
};
|
|
957
|
+
const decoded = decodeAll(src);
|
|
958
|
+
return decoded.blobs.every((v) => v.length > 0) ? decoded : {
|
|
959
|
+
blobs: glyphBlobs(),
|
|
960
|
+
images: []
|
|
961
|
+
};
|
|
962
|
+
}, [inputSamples, noAtob]);
|
|
963
|
+
const knobs = useRef({ ...DEFAULT_KNOBS });
|
|
964
|
+
useEffect(() => {
|
|
965
|
+
knobs.current = {
|
|
966
|
+
zoom: zoom ?? DEFAULT_KNOBS.zoom,
|
|
967
|
+
exposure: exposure ?? DEFAULT_KNOBS.exposure,
|
|
968
|
+
focus: focus ?? DEFAULT_KNOBS.focus,
|
|
969
|
+
blurK: blurK ?? DEFAULT_KNOBS.blurK,
|
|
970
|
+
speed: speed ?? DEFAULT_KNOBS.speed,
|
|
971
|
+
intensity: intensity ?? DEFAULT_KNOBS.intensity,
|
|
972
|
+
drift: drift ?? DEFAULT_KNOBS.drift,
|
|
973
|
+
spin: spin ?? DEFAULT_KNOBS.spin
|
|
974
|
+
};
|
|
975
|
+
}, [
|
|
976
|
+
zoom,
|
|
977
|
+
exposure,
|
|
978
|
+
focus,
|
|
979
|
+
blurK,
|
|
980
|
+
speed,
|
|
981
|
+
intensity,
|
|
982
|
+
drift,
|
|
983
|
+
spin
|
|
984
|
+
]);
|
|
985
|
+
if (noAtob) return /* @__PURE__ */ jsx("div", {
|
|
986
|
+
"aria-hidden": "true",
|
|
987
|
+
className,
|
|
988
|
+
style: {
|
|
989
|
+
...style,
|
|
990
|
+
position: "absolute",
|
|
991
|
+
inset: 0,
|
|
992
|
+
background: BACKDROP
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
return /* @__PURE__ */ jsx("div", {
|
|
996
|
+
className,
|
|
997
|
+
style: {
|
|
998
|
+
...style,
|
|
999
|
+
position: "absolute",
|
|
1000
|
+
inset: 0,
|
|
1001
|
+
background: BACKDROP
|
|
1002
|
+
},
|
|
1003
|
+
children: /* @__PURE__ */ jsx(Canvas, {
|
|
1004
|
+
"aria-hidden": "true",
|
|
1005
|
+
dpr: [1, 2],
|
|
1006
|
+
frameloop: reduced() ? "demand" : "always",
|
|
1007
|
+
camera: {
|
|
1008
|
+
position: camFor(orientation).base.toArray(),
|
|
1009
|
+
fov: BASE_FOV
|
|
1010
|
+
},
|
|
1011
|
+
gl: {
|
|
1012
|
+
alpha: false,
|
|
1013
|
+
antialias: true,
|
|
1014
|
+
powerPreference: "high-performance",
|
|
1015
|
+
preserveDrawingBuffer: true
|
|
1016
|
+
},
|
|
1017
|
+
onCreated: ({ gl }) => {
|
|
1018
|
+
gl.setClearColor(67590, 1);
|
|
1019
|
+
},
|
|
1020
|
+
children: /* @__PURE__ */ jsx(SceneContent, {
|
|
1021
|
+
knobs,
|
|
1022
|
+
orientation,
|
|
1023
|
+
blobs,
|
|
1024
|
+
images
|
|
1025
|
+
})
|
|
1026
|
+
})
|
|
1027
|
+
});
|
|
1028
|
+
};
|
|
1029
|
+
//#endregion
|
|
1030
|
+
export { FlowSim, NeuralFlow, decodeAll, decodeWeights, forwardPass };
|
|
1031
|
+
|
|
1032
|
+
//# sourceMappingURL=NeuralFlow.mjs.map
|