cursedbelt 1.0.0 → 2.3.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/dist/client/index.js +1 -1
- package/dist/core/category/index.d.ts.map +1 -1
- package/dist/core/category/index.js +2 -1
- package/dist/core/category/index.js.map +1 -1
- package/dist/core/category/types.js +1 -1
- package/dist/core/category/types.js.map +1 -1
- package/dist/core/file-tree/fileTreeModel.d.ts +49 -0
- package/dist/core/file-tree/fileTreeModel.d.ts.map +1 -1
- package/dist/core/file-tree/fileTreeModel.js +84 -0
- package/dist/core/file-tree/fileTreeModel.js.map +1 -1
- package/dist/core/layout/index.js +1 -1
- package/dist/core/layout/index.js.map +1 -1
- package/dist/core/media/index.js +1 -1
- package/dist/core/media/index.js.map +1 -1
- package/dist/core/media/types.js +1 -1
- package/dist/core/media/types.js.map +1 -1
- package/dist/core/media/uploadLimits.js +1 -1
- package/dist/core/media/uploadLimits.js.map +1 -1
- package/dist/core/sharing/model.d.ts +1 -1
- package/dist/ctgr/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react/activity-bar/ActivityBar.d.ts +17 -0
- package/dist/react/activity-bar/ActivityBar.d.ts.map +1 -1
- package/dist/react/activity-bar/ActivityBar.js.map +1 -1
- package/dist/react/analytics/index.d.ts +1 -1
- package/dist/react/analytics/index.js +1 -1
- package/dist/react/chat/MessageComposer.d.ts.map +1 -1
- package/dist/react/chat/MessageComposer.js +5 -4
- package/dist/react/chat/MessageComposer.js.map +1 -1
- package/dist/react/components/Button.d.ts.map +1 -1
- package/dist/react/components/Button.js +3 -2
- package/dist/react/components/Button.js.map +1 -1
- package/dist/react/components/Checkbox.d.ts +19 -3
- package/dist/react/components/Checkbox.d.ts.map +1 -1
- package/dist/react/components/Checkbox.js +29 -12
- package/dist/react/components/Checkbox.js.map +1 -1
- package/dist/react/components/CodeArea.d.ts.map +1 -1
- package/dist/react/components/CodeArea.js +2 -1
- package/dist/react/components/CodeArea.js.map +1 -1
- package/dist/react/components/Collapsible.d.ts.map +1 -1
- package/dist/react/components/Collapsible.js +2 -1
- package/dist/react/components/Collapsible.js.map +1 -1
- package/dist/react/components/ComboboxField.d.ts.map +1 -1
- package/dist/react/components/ComboboxField.js +3 -2
- package/dist/react/components/ComboboxField.js.map +1 -1
- package/dist/react/components/CopyButton.d.ts.map +1 -1
- package/dist/react/components/CopyButton.js +2 -1
- package/dist/react/components/CopyButton.js.map +1 -1
- package/dist/react/components/DataTable/ColumnChecklist.d.ts.map +1 -1
- package/dist/react/components/DataTable/ColumnChecklist.js +2 -1
- package/dist/react/components/DataTable/ColumnChecklist.js.map +1 -1
- package/dist/react/components/DataTable/Pagination.d.ts.map +1 -1
- package/dist/react/components/DataTable/Pagination.js +2 -1
- package/dist/react/components/DataTable/Pagination.js.map +1 -1
- package/dist/react/components/DataTable/SortHeader.d.ts.map +1 -1
- package/dist/react/components/DataTable/SortHeader.js +2 -1
- package/dist/react/components/DataTable/SortHeader.js.map +1 -1
- package/dist/react/components/DataTable/TableFilterBuilder.d.ts +61 -0
- package/dist/react/components/DataTable/TableFilterBuilder.d.ts.map +1 -0
- package/dist/react/components/DataTable/{FilterBuilder.js → TableFilterBuilder.js} +26 -3
- package/dist/react/components/DataTable/TableFilterBuilder.js.map +1 -0
- package/dist/react/components/DataTable/Toolbar.d.ts +1 -1
- package/dist/react/components/DataTable/Toolbar.js +3 -3
- package/dist/react/components/DataTable/Toolbar.js.map +1 -1
- package/dist/react/components/DataTable/cells/LinkCell.d.ts.map +1 -1
- package/dist/react/components/DataTable/cells/LinkCell.js +2 -1
- package/dist/react/components/DataTable/cells/LinkCell.js.map +1 -1
- package/dist/react/components/DataTable/index.d.ts +1 -1
- package/dist/react/components/DataTable/index.d.ts.map +1 -1
- package/dist/react/components/DataTable/index.js +4 -1
- package/dist/react/components/DataTable/index.js.map +1 -1
- package/dist/react/components/DragHandle.d.ts.map +1 -1
- package/dist/react/components/DragHandle.js +2 -1
- package/dist/react/components/DragHandle.js.map +1 -1
- package/dist/react/components/EmojiField.d.ts.map +1 -1
- package/dist/react/components/EmojiField.js +2 -1
- package/dist/react/components/EmojiField.js.map +1 -1
- package/dist/react/components/EventTimeline.d.ts +3 -2
- package/dist/react/components/EventTimeline.d.ts.map +1 -1
- package/dist/react/components/EventTimeline.js +3 -2
- package/dist/react/components/EventTimeline.js.map +1 -1
- package/dist/react/components/IconButton.d.ts +1 -1
- package/dist/react/components/IconButton.js +1 -1
- package/dist/react/components/InfoHint.d.ts.map +1 -1
- package/dist/react/components/InfoHint.js +5 -4
- package/dist/react/components/InfoHint.js.map +1 -1
- package/dist/react/components/InheritBadge.js +1 -1
- package/dist/react/components/InheritBadge.js.map +1 -1
- package/dist/react/components/InlineEditableText.d.ts.map +1 -1
- package/dist/react/components/InlineEditableText.js +2 -1
- package/dist/react/components/InlineEditableText.js.map +1 -1
- package/dist/react/components/MeterList.d.ts.map +1 -1
- package/dist/react/components/MeterList.js +2 -1
- package/dist/react/components/MeterList.js.map +1 -1
- package/dist/react/components/PathText.d.ts +2 -2
- package/dist/react/components/PathText.d.ts.map +1 -1
- package/dist/react/components/PathText.js +2 -1
- package/dist/react/components/PathText.js.map +1 -1
- package/dist/react/components/RatingField.d.ts.map +1 -1
- package/dist/react/components/RatingField.js +2 -1
- package/dist/react/components/RatingField.js.map +1 -1
- package/dist/react/components/SecretInput.js +3 -2
- package/dist/react/components/SecretInput.js.map +1 -1
- package/dist/react/components/SegmentedControl.d.ts.map +1 -1
- package/dist/react/components/SegmentedControl.js +2 -1
- package/dist/react/components/SegmentedControl.js.map +1 -1
- package/dist/react/components/StarRating.d.ts.map +1 -1
- package/dist/react/components/StarRating.js +9 -5
- package/dist/react/components/StarRating.js.map +1 -1
- package/dist/react/components/StatStrip.d.ts.map +1 -1
- package/dist/react/components/StatStrip.js +2 -1
- package/dist/react/components/StatStrip.js.map +1 -1
- package/dist/react/components/StatTile.d.ts.map +1 -1
- package/dist/react/components/StatTile.js +3 -2
- package/dist/react/components/StatTile.js.map +1 -1
- package/dist/react/components/Tabs.d.ts.map +1 -1
- package/dist/react/components/Tabs.js +2 -1
- package/dist/react/components/Tabs.js.map +1 -1
- package/dist/react/components/TruncatedText.d.ts +2 -1
- package/dist/react/components/TruncatedText.d.ts.map +1 -1
- package/dist/react/components/TruncatedText.js +2 -1
- package/dist/react/components/TruncatedText.js.map +1 -1
- package/dist/react/components/calendar/MonthGrid.d.ts.map +1 -1
- package/dist/react/components/calendar/MonthGrid.js +2 -1
- package/dist/react/components/calendar/MonthGrid.js.map +1 -1
- package/dist/react/components/calendar/WeekView.d.ts.map +1 -1
- package/dist/react/components/calendar/WeekView.js +2 -1
- package/dist/react/components/calendar/WeekView.js.map +1 -1
- package/dist/react/components/revealOnHover.d.ts.map +1 -1
- package/dist/react/components/revealOnHover.js +2 -1
- package/dist/react/components/revealOnHover.js.map +1 -1
- package/dist/react/file-tree/FileTree.d.ts +50 -1
- package/dist/react/file-tree/FileTree.d.ts.map +1 -1
- package/dist/react/file-tree/FileTree.js +234 -6
- package/dist/react/file-tree/FileTree.js.map +1 -1
- package/dist/react/file-tree/fileTree.css +52 -0
- package/dist/react/filter-rail/FilterRail.d.ts.map +1 -1
- package/dist/react/filter-rail/FilterRail.js +5 -4
- package/dist/react/filter-rail/FilterRail.js.map +1 -1
- package/dist/react/folder-tree/FolderTreeRail.d.ts.map +1 -1
- package/dist/react/folder-tree/FolderTreeRail.js +2 -1
- package/dist/react/folder-tree/FolderTreeRail.js.map +1 -1
- package/dist/react/index.d.ts +5 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +5 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/layoutEngine/index.js +1 -1
- package/dist/react/layoutEngine/index.js.map +1 -1
- package/dist/react/lib/field.d.ts.map +1 -1
- package/dist/react/lib/field.js +3 -2
- package/dist/react/lib/field.js.map +1 -1
- package/dist/react/lib/floatingStyles.d.ts.map +1 -1
- package/dist/react/lib/floatingStyles.js +2 -1
- package/dist/react/lib/floatingStyles.js.map +1 -1
- package/dist/react/lib/tapTarget.d.ts +96 -0
- package/dist/react/lib/tapTarget.d.ts.map +1 -0
- package/dist/react/lib/tapTarget.js +96 -0
- package/dist/react/lib/tapTarget.js.map +1 -0
- package/dist/react/media/VideoTrimmer.d.ts +1 -1
- package/dist/react/media/VideoTrimmer.js +1 -1
- package/dist/react/media/denseGallery.css +3 -3
- package/dist/react/media/ffmpegWasm.js +2 -2
- package/dist/react/media/ffmpegWasm.js.map +1 -1
- package/dist/react/media/videoPlayer.css +42 -0
- package/dist/react/namespace/NamespaceTargetCapsule.d.ts +2 -2
- package/dist/react/namespace/NamespaceTargetCapsule.d.ts.map +1 -1
- package/dist/react/nav/BreadcrumbTrail.d.ts.map +1 -1
- package/dist/react/nav/BreadcrumbTrail.js +4 -3
- package/dist/react/nav/BreadcrumbTrail.js.map +1 -1
- package/dist/react/nav/HubTileGrid.d.ts.map +1 -1
- package/dist/react/nav/HubTileGrid.js +2 -1
- package/dist/react/nav/HubTileGrid.js.map +1 -1
- package/dist/react/nav/SideNav.d.ts.map +1 -1
- package/dist/react/nav/SideNav.js +4 -3
- package/dist/react/nav/SideNav.js.map +1 -1
- package/dist/react/nav/SideNavCustomize.d.ts.map +1 -1
- package/dist/react/nav/SideNavCustomize.js +2 -1
- package/dist/react/nav/SideNavCustomize.js.map +1 -1
- package/dist/react/palette/CommandPalette.d.ts.map +1 -1
- package/dist/react/palette/CommandPalette.js +3 -2
- package/dist/react/palette/CommandPalette.js.map +1 -1
- package/dist/server/drivers/pooledControlStores.pg.test.js +1 -0
- package/dist/server/drivers/pooledControlStores.pg.test.js.map +1 -1
- package/dist/server/drivers/pooledIdentityStore.pg.test.js +1 -0
- package/dist/server/drivers/pooledIdentityStore.pg.test.js.map +1 -1
- package/dist/server/drivers/retentionPolicy.pg.test.js +1 -0
- package/dist/server/drivers/retentionPolicy.pg.test.js.map +1 -1
- package/dist/server/guard/argon2Binding.d.ts +1 -1
- package/dist/server/guard/argon2Binding.js +1 -1
- package/dist/server/incidents/store.d.ts +3 -3
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/master-lock/masterLock.d.ts +1 -1
- package/dist/server/media-bun/index.js +1 -1
- package/dist/server/media-bun/index.js.map +1 -1
- package/dist/server/paths/appDataHome.d.ts +20 -0
- package/dist/server/paths/appDataHome.d.ts.map +1 -0
- package/dist/server/paths/appDataHome.js +69 -0
- package/dist/server/paths/appDataHome.js.map +1 -0
- package/dist/server/retention/archive.d.ts +3 -4
- package/dist/server/retention/archive.d.ts.map +1 -1
- package/dist/server/retention/archive.js +20 -15
- package/dist/server/retention/archive.js.map +1 -1
- package/dist/server/retention/index.d.ts +1 -1
- package/dist/server/retention/index.js +1 -1
- package/dist/server/retention/policy.d.ts +2 -2
- package/dist/server/retention/policy.d.ts.map +1 -1
- package/dist/server/retention/policy.js +1 -1
- package/dist/server/retention/store.d.ts.map +1 -1
- package/dist/server/retention/store.js +27 -20
- package/dist/server/retention/store.js.map +1 -1
- package/dist/server/runtime/localHost.d.ts +10 -5
- package/dist/server/runtime/localHost.d.ts.map +1 -1
- package/dist/server/runtime/localHost.js +12 -8
- package/dist/server/runtime/localHost.js.map +1 -1
- package/dist/server/runtime/meterRollup.pg.test.js +1 -0
- package/dist/server/runtime/meterRollup.pg.test.js.map +1 -1
- package/dist/server/runtime/recipe.d.ts +4 -4
- package/dist/server/runtime/retentionJob.pg.test.js +1 -0
- package/dist/server/runtime/retentionJob.pg.test.js.map +1 -1
- package/dist/server/search/pgSearchProvider.pg.test.js +1 -0
- package/dist/server/search/pgSearchProvider.pg.test.js.map +1 -1
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/errors.js +1 -1
- package/dist/styles-static.css +391 -0
- package/dist/styles.css +27 -0
- package/package.json +19 -167
- package/scripts/generateStaticStyles.ts +122 -0
- package/scripts/publicSurface.ts +455 -0
- package/scripts/testTmpRoot.ts +34 -5
- package/src/client/index.ts +1 -1
- package/src/core/category/index.ts +2 -1
- package/src/core/category/types.ts +1 -1
- package/src/core/file-tree/fileTreeModel.spec.ts +134 -0
- package/src/core/file-tree/fileTreeModel.ts +104 -0
- package/src/core/layout/index.ts +1 -1
- package/src/core/media/index.ts +1 -1
- package/src/core/media/types.ts +1 -1
- package/src/core/media/uploadLimits.ts +1 -1
- package/src/core/sharing/model.ts +1 -1
- package/src/ctgr/index.ts +1 -1
- package/src/declaredDepsAreImported.spec.ts +87 -0
- package/src/demoFixture.spec.ts +133 -0
- package/src/index.ts +1 -1
- package/src/lockfileIsTracked.spec.ts +50 -0
- package/src/namedSubpathsResolve.spec.ts +119 -0
- package/src/publicSurface.spec.ts +72 -0
- package/src/react/activity-bar/ActivityBar.tsx +17 -0
- package/src/react/analytics/index.ts +1 -1
- package/src/react/chat/MessageComposer.tsx +5 -4
- package/src/react/components/Button.tsx +3 -2
- package/src/react/components/Checkbox.spec.tsx +51 -0
- package/src/react/components/Checkbox.tsx +68 -26
- package/src/react/components/CodeArea.tsx +2 -1
- package/src/react/components/CodeChip.spec.tsx +2 -2
- package/src/react/components/Collapsible.tsx +2 -1
- package/src/react/components/ComboboxField.tsx +3 -2
- package/src/react/components/CopyButton.tsx +2 -1
- package/src/react/components/CopyableText.spec.tsx +1 -1
- package/src/react/components/DataTable/ColumnChecklist.tsx +2 -1
- package/src/react/components/DataTable/Pagination.tsx +2 -1
- package/src/react/components/DataTable/SortHeader.tsx +2 -1
- package/src/react/components/DataTable/{FilterBuilder.tsx → TableFilterBuilder.tsx} +33 -5
- package/src/react/components/DataTable/Toolbar.tsx +3 -3
- package/src/react/components/DataTable/cells/LinkCell.tsx +2 -1
- package/src/react/components/DataTable/index.ts +8 -1
- package/src/react/components/DragHandle.tsx +2 -1
- package/src/react/components/EmojiField.tsx +2 -1
- package/src/react/components/EventTimeline.tsx +3 -2
- package/src/react/components/FileLocation.spec.tsx +1 -1
- package/src/react/components/IconButton.tsx +1 -1
- package/src/react/components/InfoHint.tsx +5 -4
- package/src/react/components/InheritBadge.tsx +1 -1
- package/src/react/components/InlineEditableText.tsx +2 -1
- package/src/react/components/MeterList.tsx +2 -1
- package/src/react/components/PathText.tsx +4 -3
- package/src/react/components/RatingField.tsx +2 -1
- package/src/react/components/SecretInput.tsx +3 -3
- package/src/react/components/SegmentedControl.tsx +2 -2
- package/src/react/components/StarRating.spec.tsx +2 -2
- package/src/react/components/StarRating.tsx +9 -5
- package/src/react/components/StatStrip.tsx +2 -1
- package/src/react/components/StatTile.tsx +3 -3
- package/src/react/components/Tabs.spec.tsx +3 -2
- package/src/react/components/Tabs.tsx +2 -1
- package/src/react/components/TruncatedText.tsx +2 -1
- package/src/react/components/calendar/MonthGrid.spec.tsx +2 -1
- package/src/react/components/calendar/MonthGrid.tsx +2 -1
- package/src/react/components/calendar/WeekView.tsx +2 -1
- package/src/react/components/revealOnHover.ts +3 -2
- package/src/react/file-tree/FileTree.spec.tsx +248 -0
- package/src/react/file-tree/FileTree.tsx +304 -4
- package/src/react/file-tree/fileTree.css +52 -0
- package/src/react/file-tree/fileTreeGeometry.fixture.json +151 -0
- package/src/react/file-tree/fileTreeGeometry.spec.ts +33 -52
- package/src/react/filter-rail/FilterRail.spec.tsx +2 -1
- package/src/react/filter-rail/FilterRail.tsx +5 -4
- package/src/react/folder-tree/FolderTreeRail.tsx +2 -1
- package/src/react/index.ts +13 -3
- package/src/react/layoutEngine/index.ts +1 -1
- package/src/react/layoutEngine/types.ts +1 -1
- package/src/react/lib/field.ts +4 -2
- package/src/react/lib/floatingStyles.spec.ts +2 -1
- package/src/react/lib/floatingStyles.ts +3 -1
- package/src/react/lib/tapTarget.ts +100 -0
- package/src/react/media/MaskPainter.tsx +2 -2
- package/src/react/media/VideoTrimmer.tsx +1 -1
- package/src/react/media/denseGallery.css +3 -3
- package/src/react/media/ffmpegWasm.ts +2 -2
- package/src/react/media/videoPlayer.css +42 -0
- package/src/react/namespace/NamespaceTargetCapsule.tsx +2 -2
- package/src/react/nav/BreadcrumbTrail.tsx +4 -3
- package/src/react/nav/HubTileGrid.tsx +2 -1
- package/src/react/nav/SideNav.tsx +4 -3
- package/src/react/nav/SideNavCustomize.tsx +2 -1
- package/src/react/palette/CommandPalette.tsx +3 -2
- package/src/server/ctgr.ts +1 -1
- package/src/server/drivers/pooledControlStores.pg.test.ts +1 -0
- package/src/server/drivers/pooledIdentityStore.pg.test.ts +1 -0
- package/src/server/drivers/retentionPolicy.pg.test.ts +1 -0
- package/src/server/guard/argon2Binding.ts +1 -1
- package/src/server/incidents/store.ts +3 -3
- package/src/server/index.ts +1 -1
- package/src/server/master-lock/masterLock.spec.ts +18 -2
- package/src/server/master-lock/masterLock.ts +1 -1
- package/src/server/media-bun/image.spec.ts +1 -0
- package/src/server/media-bun/index.ts +1 -1
- package/src/server/media-bun/video.spec.ts +1 -0
- package/src/server/paths/appDataHome.spec.ts +87 -0
- package/src/server/paths/appDataHome.ts +84 -0
- package/src/server/retention/archive.spec.ts +26 -4
- package/src/server/retention/archive.ts +20 -15
- package/src/server/retention/index.ts +1 -1
- package/src/server/retention/policy.ts +2 -2
- package/src/server/retention/store.spec.ts +38 -10
- package/src/server/retention/store.ts +26 -19
- package/src/server/runtime/localHost.spec.ts +22 -3
- package/src/server/runtime/localHost.ts +12 -9
- package/src/server/runtime/meterRollup.pg.test.ts +1 -0
- package/src/server/runtime/recipe.ts +4 -4
- package/src/server/runtime/retentionJob.pg.test.ts +1 -0
- package/src/server/search/pgSearchProvider.pg.test.ts +1 -0
- package/src/server/storage/binaryServerProcessing.integration.spec.ts +6 -2
- package/src/server/storage/chunked.integration.spec.ts +5 -2
- package/src/server/storage/fileUploadClient-chunked.integration.spec.ts +5 -2
- package/src/server/storage/files/adapter.photo.display.spec.ts +1 -0
- package/src/server/storage/imageThumbnail.spec.ts +1 -0
- package/src/server/storage/transcode.integration.spec.ts +5 -2
- package/src/server/storage/videoProcessor.posterOnly.spec.ts +1 -0
- package/src/shared/errors.ts +1 -1
- package/src/skippedTestsAreAnswered.spec.ts +215 -0
- package/src/styles-static.css +391 -0
- package/src/styles.css +27 -0
- package/src/stylesStaticMatches.spec.ts +134 -0
- package/src/tapTargetStylesheet.spec.ts +150 -0
- package/src/testTmpRoot.spec.ts +102 -0
- package/dist/core/duplicates/index.d.ts +0 -116
- package/dist/core/duplicates/index.d.ts.map +0 -1
- package/dist/core/duplicates/index.js +0 -178
- package/dist/core/duplicates/index.js.map +0 -1
- package/dist/core/namespace/helpers.d.ts +0 -14
- package/dist/core/namespace/helpers.d.ts.map +0 -1
- package/dist/core/namespace/helpers.js +0 -29
- package/dist/core/namespace/helpers.js.map +0 -1
- package/dist/core/namespace/index.d.ts +0 -4
- package/dist/core/namespace/index.d.ts.map +0 -1
- package/dist/core/namespace/index.js +0 -6
- package/dist/core/namespace/index.js.map +0 -1
- package/dist/core/namespace/memoryStore.d.ts +0 -19
- package/dist/core/namespace/memoryStore.d.ts.map +0 -1
- package/dist/core/namespace/memoryStore.js +0 -70
- package/dist/core/namespace/memoryStore.js.map +0 -1
- package/dist/core/namespace/types.d.ts +0 -44
- package/dist/core/namespace/types.d.ts.map +0 -1
- package/dist/core/namespace/types.js +0 -8
- package/dist/core/namespace/types.js.map +0 -1
- package/dist/game/core/DisposeRegistry.d.ts +0 -42
- package/dist/game/core/DisposeRegistry.d.ts.map +0 -1
- package/dist/game/core/DisposeRegistry.js +0 -67
- package/dist/game/core/DisposeRegistry.js.map +0 -1
- package/dist/game/core/drawBudget.d.ts +0 -26
- package/dist/game/core/drawBudget.d.ts.map +0 -1
- package/dist/game/core/drawBudget.js +0 -55
- package/dist/game/core/drawBudget.js.map +0 -1
- package/dist/game/core/fixedTimestep.d.ts +0 -38
- package/dist/game/core/fixedTimestep.d.ts.map +0 -1
- package/dist/game/core/fixedTimestep.js +0 -47
- package/dist/game/core/fixedTimestep.js.map +0 -1
- package/dist/game/core/index.d.ts +0 -9
- package/dist/game/core/index.d.ts.map +0 -1
- package/dist/game/core/index.js +0 -8
- package/dist/game/core/index.js.map +0 -1
- package/dist/game/core/inputCollector.d.ts +0 -82
- package/dist/game/core/inputCollector.d.ts.map +0 -1
- package/dist/game/core/inputCollector.js +0 -176
- package/dist/game/core/inputCollector.js.map +0 -1
- package/dist/game/core/resizeCanvas.d.ts +0 -19
- package/dist/game/core/resizeCanvas.d.ts.map +0 -1
- package/dist/game/core/resizeCanvas.js +0 -29
- package/dist/game/core/resizeCanvas.js.map +0 -1
- package/dist/game/react/index.d.ts +0 -3
- package/dist/game/react/index.d.ts.map +0 -1
- package/dist/game/react/index.js +0 -5
- package/dist/game/react/index.js.map +0 -1
- package/dist/game/react/useGameEngine.d.ts +0 -64
- package/dist/game/react/useGameEngine.d.ts.map +0 -1
- package/dist/game/react/useGameEngine.js +0 -78
- package/dist/game/react/useGameEngine.js.map +0 -1
- package/dist/react/canvas/CanvasNavHUD.d.ts +0 -64
- package/dist/react/canvas/CanvasNavHUD.d.ts.map +0 -1
- package/dist/react/canvas/CanvasNavHUD.js +0 -58
- package/dist/react/canvas/CanvasNavHUD.js.map +0 -1
- package/dist/react/canvas/fitLabel.d.ts +0 -53
- package/dist/react/canvas/fitLabel.d.ts.map +0 -1
- package/dist/react/canvas/fitLabel.js +0 -104
- package/dist/react/canvas/fitLabel.js.map +0 -1
- package/dist/react/canvas/index.d.ts +0 -4
- package/dist/react/canvas/index.d.ts.map +0 -1
- package/dist/react/canvas/index.js +0 -4
- package/dist/react/canvas/index.js.map +0 -1
- package/dist/react/canvas/lod.d.ts +0 -40
- package/dist/react/canvas/lod.d.ts.map +0 -1
- package/dist/react/canvas/lod.js +0 -37
- package/dist/react/canvas/lod.js.map +0 -1
- package/dist/react/components/DataTable/FilterBuilder.d.ts +0 -38
- package/dist/react/components/DataTable/FilterBuilder.d.ts.map +0 -1
- package/dist/react/components/DataTable/FilterBuilder.js.map +0 -1
- package/dist/react/seo/HeadProvider.d.ts +0 -14
- package/dist/react/seo/HeadProvider.d.ts.map +0 -1
- package/dist/react/seo/HeadProvider.js +0 -44
- package/dist/react/seo/HeadProvider.js.map +0 -1
- package/dist/react/seo/applyHeadToDocument.d.ts +0 -3
- package/dist/react/seo/applyHeadToDocument.d.ts.map +0 -1
- package/dist/react/seo/applyHeadToDocument.js +0 -66
- package/dist/react/seo/applyHeadToDocument.js.map +0 -1
- package/dist/react/seo/index.d.ts +0 -3
- package/dist/react/seo/index.d.ts.map +0 -1
- package/dist/react/seo/index.js +0 -7
- package/dist/react/seo/index.js.map +0 -1
- package/dist/react/timeline/ClipView.d.ts +0 -29
- package/dist/react/timeline/ClipView.d.ts.map +0 -1
- package/dist/react/timeline/ClipView.js +0 -53
- package/dist/react/timeline/ClipView.js.map +0 -1
- package/dist/react/timeline/Playhead.d.ts +0 -16
- package/dist/react/timeline/Playhead.d.ts.map +0 -1
- package/dist/react/timeline/Playhead.js +0 -26
- package/dist/react/timeline/Playhead.js.map +0 -1
- package/dist/react/timeline/TimeRuler.d.ts +0 -21
- package/dist/react/timeline/TimeRuler.d.ts.map +0 -1
- package/dist/react/timeline/TimeRuler.js +0 -31
- package/dist/react/timeline/TimeRuler.js.map +0 -1
- package/dist/react/timeline/TimelineSurface.d.ts +0 -29
- package/dist/react/timeline/TimelineSurface.d.ts.map +0 -1
- package/dist/react/timeline/TimelineSurface.js +0 -56
- package/dist/react/timeline/TimelineSurface.js.map +0 -1
- package/dist/react/timeline/TrackLane.d.ts +0 -31
- package/dist/react/timeline/TrackLane.d.ts.map +0 -1
- package/dist/react/timeline/TrackLane.js +0 -32
- package/dist/react/timeline/TrackLane.js.map +0 -1
- package/dist/react/timeline/index.d.ts +0 -6
- package/dist/react/timeline/index.d.ts.map +0 -1
- package/dist/react/timeline/index.js +0 -12
- package/dist/react/timeline/index.js.map +0 -1
- package/dist/server/private-media/index.d.ts +0 -7
- package/dist/server/private-media/index.d.ts.map +0 -1
- package/dist/server/private-media/index.js +0 -13
- package/dist/server/private-media/index.js.map +0 -1
- package/dist/server/seo/index.d.ts +0 -3
- package/dist/server/seo/index.d.ts.map +0 -1
- package/dist/server/seo/index.js +0 -6
- package/dist/server/seo/index.js.map +0 -1
- package/dist/server/seo/mountSeoRoutes.d.ts +0 -9
- package/dist/server/seo/mountSeoRoutes.d.ts.map +0 -1
- package/dist/server/seo/mountSeoRoutes.js +0 -19
- package/dist/server/seo/mountSeoRoutes.js.map +0 -1
- package/dist/server/seo/serveHeadInjectedIndex.d.ts +0 -9
- package/dist/server/seo/serveHeadInjectedIndex.d.ts.map +0 -1
- package/dist/server/seo/serveHeadInjectedIndex.js +0 -20
- package/dist/server/seo/serveHeadInjectedIndex.js.map +0 -1
- package/dist/upload.d.ts +0 -148
- package/dist/upload.d.ts.map +0 -1
- package/dist/upload.js +0 -159
- package/dist/upload.js.map +0 -1
- package/dist/verify/runtime/index.d.ts +0 -16
- package/dist/verify/runtime/index.d.ts.map +0 -1
- package/dist/verify/runtime/index.js +0 -16
- package/dist/verify/runtime/index.js.map +0 -1
- package/scripts/demoCheck.ts +0 -42
- package/src/core/duplicates/index.spec.ts +0 -116
- package/src/core/duplicates/index.ts +0 -203
- package/src/core/namespace/helpers.ts +0 -31
- package/src/core/namespace/index.ts +0 -12
- package/src/core/namespace/memoryStore.ts +0 -77
- package/src/core/namespace/namespace.spec.ts +0 -117
- package/src/core/namespace/types.ts +0 -53
- package/src/game/core/DisposeRegistry.spec.ts +0 -53
- package/src/game/core/DisposeRegistry.ts +0 -70
- package/src/game/core/drawBudget.spec.ts +0 -51
- package/src/game/core/drawBudget.ts +0 -75
- package/src/game/core/fixedTimestep.spec.ts +0 -91
- package/src/game/core/fixedTimestep.ts +0 -79
- package/src/game/core/index.ts +0 -16
- package/src/game/core/inputCollector.spec.ts +0 -29
- package/src/game/core/inputCollector.ts +0 -245
- package/src/game/core/resizeCanvas.ts +0 -31
- package/src/game/react/index.ts +0 -10
- package/src/game/react/useGameEngine.ts +0 -125
- package/src/react/canvas/CanvasNavHUD.spec.tsx +0 -62
- package/src/react/canvas/CanvasNavHUD.tsx +0 -210
- package/src/react/canvas/fitLabel.spec.ts +0 -82
- package/src/react/canvas/fitLabel.ts +0 -150
- package/src/react/canvas/index.ts +0 -15
- package/src/react/canvas/lod.ts +0 -53
- package/src/react/seo/HeadProvider.tsx +0 -67
- package/src/react/seo/applyHeadToDocument.ts +0 -73
- package/src/react/seo/index.ts +0 -12
- package/src/react/seo/seo.spec.tsx +0 -101
- package/src/react/timeline/ClipView.tsx +0 -146
- package/src/react/timeline/Playhead.tsx +0 -63
- package/src/react/timeline/TimeRuler.tsx +0 -85
- package/src/react/timeline/TimelineSurface.tsx +0 -157
- package/src/react/timeline/TrackLane.tsx +0 -87
- package/src/react/timeline/index.ts +0 -12
- package/src/react/timeline/timeline.spec.tsx +0 -175
- package/src/server/private-media/index.ts +0 -45
- package/src/server/seo/index.ts +0 -8
- package/src/server/seo/mountSeoRoutes.ts +0 -37
- package/src/server/seo/seo.spec.ts +0 -128
- package/src/server/seo/serveHeadInjectedIndex.ts +0 -36
- package/src/upload.spec.ts +0 -300
- package/src/upload.ts +0 -288
- package/src/verify/runtime/index.ts +0 -64
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Applies a radial deadzone to a normalized axis value in `[-1, 1]` and rescales the
|
|
3
|
-
* remainder so output still spans the full range past the threshold (no sudden jump
|
|
4
|
-
* at the deadzone edge). Use for gamepad sticks / analog inputs.
|
|
5
|
-
*/
|
|
6
|
-
export function deadzone(value, threshold = 0.15) {
|
|
7
|
-
const magnitude = Math.abs(value);
|
|
8
|
-
if (magnitude <= threshold)
|
|
9
|
-
return 0;
|
|
10
|
-
const sign = value < 0 ? -1 : 1;
|
|
11
|
-
return sign * ((magnitude - threshold) / (1 - threshold));
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Collects raw input state from pointer, keyboard, touch, and gamepad into a single
|
|
15
|
-
* snapshot-able object. Pointer events unify mouse/pen/touch; touch contacts are also
|
|
16
|
-
* surfaced individually in `snapshot().touch`. All listeners attach via the supplied
|
|
17
|
-
* {@link DisposeRegistry}, so they're torn down automatically on engine dispose.
|
|
18
|
-
*
|
|
19
|
-
* Per-game `computeIntent(snapshot)` (mapping raw input → a game-specific action enum)
|
|
20
|
-
* stays in the game — this layer only handles the common collection + deadzone.
|
|
21
|
-
*
|
|
22
|
-
* Browser-only: reads `document`/`window`/`navigator`. Never call from a server file.
|
|
23
|
-
*/
|
|
24
|
-
export function createInputCollector(canvas, registry, opts = {}) {
|
|
25
|
-
const { keyboardTarget = typeof window !== 'undefined' ? window : canvas, gamepadDeadzone = 0.15, preventTouchScroll = true, } = opts;
|
|
26
|
-
const keys = {};
|
|
27
|
-
const activePointers = new Map();
|
|
28
|
-
let primary = { x: 0, y: 0, buttons: 0, id: -1, type: 'mouse' };
|
|
29
|
-
let gamepadIndex = null;
|
|
30
|
-
const pointerDownHandlers = [];
|
|
31
|
-
const pointerUpHandlers = [];
|
|
32
|
-
const keyHandlers = new Map();
|
|
33
|
-
function toLocal(e) {
|
|
34
|
-
const rect = canvas.getBoundingClientRect();
|
|
35
|
-
return {
|
|
36
|
-
x: e.clientX - rect.left,
|
|
37
|
-
y: e.clientY - rect.top,
|
|
38
|
-
buttons: e.buttons,
|
|
39
|
-
id: e.pointerId,
|
|
40
|
-
type: e.pointerType,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
// --- Pointer (unifies mouse, pen, touch) ---
|
|
44
|
-
const onPointerMove = (e) => {
|
|
45
|
-
const p = toLocal(e);
|
|
46
|
-
if (activePointers.has(p.id) || p.type !== 'touch')
|
|
47
|
-
primary = p;
|
|
48
|
-
if (activePointers.has(p.id))
|
|
49
|
-
activePointers.set(p.id, p);
|
|
50
|
-
};
|
|
51
|
-
const onPointerDown = (e) => {
|
|
52
|
-
const p = toLocal(e);
|
|
53
|
-
activePointers.set(p.id, p);
|
|
54
|
-
primary = p;
|
|
55
|
-
for (const fn of pointerDownHandlers)
|
|
56
|
-
fn(p);
|
|
57
|
-
};
|
|
58
|
-
const onPointerUp = (e) => {
|
|
59
|
-
const p = toLocal(e);
|
|
60
|
-
activePointers.delete(p.id);
|
|
61
|
-
primary = { ...p, buttons: 0 };
|
|
62
|
-
for (const fn of pointerUpHandlers)
|
|
63
|
-
fn(p);
|
|
64
|
-
};
|
|
65
|
-
const onPointerCancel = (e) => {
|
|
66
|
-
activePointers.delete(e.pointerId);
|
|
67
|
-
};
|
|
68
|
-
addCanvasListener('pointermove', onPointerMove);
|
|
69
|
-
addCanvasListener('pointerdown', onPointerDown);
|
|
70
|
-
addCanvasListener('pointerup', onPointerUp);
|
|
71
|
-
addCanvasListener('pointercancel', onPointerCancel);
|
|
72
|
-
if (preventTouchScroll) {
|
|
73
|
-
const prev = canvas.style.touchAction;
|
|
74
|
-
canvas.style.touchAction = 'none';
|
|
75
|
-
registry.add(() => {
|
|
76
|
-
canvas.style.touchAction = prev;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
// --- Keyboard (window by default; cleared on blur) ---
|
|
80
|
-
const onKeyDown = (e) => {
|
|
81
|
-
if (keys[e.code])
|
|
82
|
-
return; // ignore auto-repeat
|
|
83
|
-
keys[e.code] = true;
|
|
84
|
-
const handlers = keyHandlers.get(e.code);
|
|
85
|
-
if (handlers)
|
|
86
|
-
for (const fn of handlers)
|
|
87
|
-
fn(true);
|
|
88
|
-
};
|
|
89
|
-
const onKeyUp = (e) => {
|
|
90
|
-
if (!keys[e.code])
|
|
91
|
-
return;
|
|
92
|
-
keys[e.code] = false;
|
|
93
|
-
const handlers = keyHandlers.get(e.code);
|
|
94
|
-
if (handlers)
|
|
95
|
-
for (const fn of handlers)
|
|
96
|
-
fn(false);
|
|
97
|
-
};
|
|
98
|
-
const onBlur = () => {
|
|
99
|
-
for (const code of Object.keys(keys)) {
|
|
100
|
-
if (keys[code]) {
|
|
101
|
-
keys[code] = false;
|
|
102
|
-
const handlers = keyHandlers.get(code);
|
|
103
|
-
if (handlers)
|
|
104
|
-
for (const fn of handlers)
|
|
105
|
-
fn(false);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
addTargetListener(keyboardTarget, 'keydown', onKeyDown);
|
|
110
|
-
addTargetListener(keyboardTarget, 'keyup', onKeyUp);
|
|
111
|
-
if (typeof window !== 'undefined')
|
|
112
|
-
addTargetListener(window, 'blur', onBlur);
|
|
113
|
-
// --- Gamepad (connection is evented; state is polled in snapshot) ---
|
|
114
|
-
if (typeof window !== 'undefined') {
|
|
115
|
-
const onConnect = (e) => {
|
|
116
|
-
gamepadIndex = e.gamepad.index;
|
|
117
|
-
};
|
|
118
|
-
const onDisconnect = (e) => {
|
|
119
|
-
if (e.gamepad.index === gamepadIndex)
|
|
120
|
-
gamepadIndex = null;
|
|
121
|
-
};
|
|
122
|
-
addTargetListener(window, 'gamepadconnected', onConnect);
|
|
123
|
-
addTargetListener(window, 'gamepaddisconnected', onDisconnect);
|
|
124
|
-
}
|
|
125
|
-
function readGamepad() {
|
|
126
|
-
if (typeof navigator === 'undefined' || !navigator.getGamepads)
|
|
127
|
-
return null;
|
|
128
|
-
const pads = navigator.getGamepads();
|
|
129
|
-
const pad = gamepadIndex !== null ? pads[gamepadIndex] : pads.find((p) => p != null);
|
|
130
|
-
if (!pad)
|
|
131
|
-
return null;
|
|
132
|
-
return {
|
|
133
|
-
index: pad.index,
|
|
134
|
-
axes: pad.axes.map((a) => deadzone(a, gamepadDeadzone)),
|
|
135
|
-
buttons: pad.buttons.map((b) => b.value),
|
|
136
|
-
pressed: pad.buttons.map((b) => b.pressed),
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
snapshot() {
|
|
141
|
-
const touch = [];
|
|
142
|
-
for (const p of activePointers.values()) {
|
|
143
|
-
if (p.type === 'touch')
|
|
144
|
-
touch.push({ x: p.x, y: p.y });
|
|
145
|
-
}
|
|
146
|
-
return {
|
|
147
|
-
pointer: { x: primary.x, y: primary.y, buttons: primary.buttons },
|
|
148
|
-
keys: { ...keys },
|
|
149
|
-
touch,
|
|
150
|
-
gamepad: readGamepad(),
|
|
151
|
-
};
|
|
152
|
-
},
|
|
153
|
-
onPointerDown(fn) {
|
|
154
|
-
pointerDownHandlers.push(fn);
|
|
155
|
-
},
|
|
156
|
-
onPointerUp(fn) {
|
|
157
|
-
pointerUpHandlers.push(fn);
|
|
158
|
-
},
|
|
159
|
-
onKey(code, fn) {
|
|
160
|
-
const handlers = keyHandlers.get(code);
|
|
161
|
-
if (handlers)
|
|
162
|
-
handlers.push(fn);
|
|
163
|
-
else
|
|
164
|
-
keyHandlers.set(code, [fn]);
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
function addCanvasListener(type, handler) {
|
|
168
|
-
canvas.addEventListener(type, handler);
|
|
169
|
-
registry.add(() => canvas.removeEventListener(type, handler));
|
|
170
|
-
}
|
|
171
|
-
function addTargetListener(target, type, handler) {
|
|
172
|
-
target.addEventListener(type, handler);
|
|
173
|
-
registry.add(() => target.removeEventListener(type, handler));
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
//# sourceMappingURL=inputCollector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inputCollector.js","sourceRoot":"","sources":["../../../src/game/core/inputCollector.ts"],"names":[],"mappings":"AA8DA;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,SAAS,GAAG,IAAI;IACtD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,SAAS,IAAI,SAAS;QAAE,OAAO,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,IAAI,GAAG,CAAC,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;;;;;GAUG;AACH,MA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C,CAAC;YACvC,IAAI,QAAQ;gBAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;gBAC3B,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;IAEF,SAAS,iBAAiB,CACxB,IAAO,EACP,OAA4C;QAE5C,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAwB,CAAC,CAAC;QACxD,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAwB,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,SAAS,iBAAiB,CACxB,MAA4B,EAC5B,IAAY,EACZ,OAAsB;QAEtB,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resize a canvas's backing-store resolution to match its CSS display size times the
|
|
3
|
-
* device pixel ratio, so rendering is crisp on HiDPI screens without stretching.
|
|
4
|
-
*
|
|
5
|
-
* Call this at the top of the render loop. It only writes `canvas.width/height` when
|
|
6
|
-
* they actually changed (writing them is destructive — it clears the canvas and resets
|
|
7
|
-
* the 2D context state), and returns whether a resize happened so the game can update
|
|
8
|
-
* its viewport/projection only when needed.
|
|
9
|
-
*
|
|
10
|
-
* This is deliberately NOT inside `useGameEngine`: backing-store sizing is game-specific
|
|
11
|
-
* (a WebGL game also calls `gl.viewport`, a 2D game may re-scale the context), so the
|
|
12
|
-
* hook stays renderer-agnostic and the game owns its resize policy.
|
|
13
|
-
*
|
|
14
|
-
* @param canvas - The target canvas.
|
|
15
|
-
* @param dpr - Device pixel ratio (defaults to `window.devicePixelRatio`, min 1).
|
|
16
|
-
* @returns `true` if the backing store was resized this call.
|
|
17
|
-
*/
|
|
18
|
-
export declare function resizeCanvasToDisplaySize(canvas: HTMLCanvasElement, dpr?: number): boolean;
|
|
19
|
-
//# sourceMappingURL=resizeCanvas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resizeCanvas.d.ts","sourceRoot":"","sources":["../../../src/game/core/resizeCanvas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,iBAAiB,EACzB,GAAG,GAAE,MAAyE,GAC7E,OAAO,CAUT"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resize a canvas's backing-store resolution to match its CSS display size times the
|
|
3
|
-
* device pixel ratio, so rendering is crisp on HiDPI screens without stretching.
|
|
4
|
-
*
|
|
5
|
-
* Call this at the top of the render loop. It only writes `canvas.width/height` when
|
|
6
|
-
* they actually changed (writing them is destructive — it clears the canvas and resets
|
|
7
|
-
* the 2D context state), and returns whether a resize happened so the game can update
|
|
8
|
-
* its viewport/projection only when needed.
|
|
9
|
-
*
|
|
10
|
-
* This is deliberately NOT inside `useGameEngine`: backing-store sizing is game-specific
|
|
11
|
-
* (a WebGL game also calls `gl.viewport`, a 2D game may re-scale the context), so the
|
|
12
|
-
* hook stays renderer-agnostic and the game owns its resize policy.
|
|
13
|
-
*
|
|
14
|
-
* @param canvas - The target canvas.
|
|
15
|
-
* @param dpr - Device pixel ratio (defaults to `window.devicePixelRatio`, min 1).
|
|
16
|
-
* @returns `true` if the backing store was resized this call.
|
|
17
|
-
*/
|
|
18
|
-
export function resizeCanvasToDisplaySize(canvas, dpr = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1) {
|
|
19
|
-
const ratio = dpr > 0 ? dpr : 1;
|
|
20
|
-
const width = Math.max(1, Math.round(canvas.clientWidth * ratio));
|
|
21
|
-
const height = Math.max(1, Math.round(canvas.clientHeight * ratio));
|
|
22
|
-
if (canvas.width !== width || canvas.height !== height) {
|
|
23
|
-
canvas.width = width;
|
|
24
|
-
canvas.height = height;
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=resizeCanvas.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resizeCanvas.js","sourceRoot":"","sources":["../../../src/game/core/resizeCanvas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAAyB,EACzB,MAAc,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9E,MAAM,KAAK,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC;IAClE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC;IACpE,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QACvD,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/game/react/index.ts"],"names":[],"mappings":"AAIA,YAAY,EACV,WAAW,EACX,UAAU,EACV,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/game/react/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// cursedbelt/game/react — the browser-only React host hook. Reads `document`/`window`;
|
|
2
|
-
// never import this subpath from a Bun server file. The engine-agnostic core (no React,
|
|
3
|
-
// Bun-safe) lives in `cursedbelt/game`.
|
|
4
|
-
export { useGameEngine } from './useGameEngine';
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/game/react/index.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,wFAAwF;AACxF,wCAAwC;AAOxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { type DependencyList, type RefObject } from 'react';
|
|
2
|
-
import { DisposeRegistry } from '../core/DisposeRegistry';
|
|
3
|
-
/**
|
|
4
|
-
* The handle a {@link GameFactory} returns. The host hook owns its lifecycle:
|
|
5
|
-
* `dispose` runs on true unmount; `pause`/`resume` run on tab hide/show.
|
|
6
|
-
*/
|
|
7
|
-
export interface GameHandle {
|
|
8
|
-
/** Tear down the engine. Called exactly once, on true unmount. */
|
|
9
|
-
dispose(): void;
|
|
10
|
-
/** Optional: called when the tab is hidden (Page Visibility). Cancel your rAF here. */
|
|
11
|
-
pause?(): void;
|
|
12
|
-
/** Optional: called when the tab becomes visible again. Restart your rAF here. */
|
|
13
|
-
resume?(): void;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Creates the engine for a freshly-mounted canvas. Receives a {@link DisposeRegistry}
|
|
17
|
-
* for RAII cleanup — register every listener / rAF id / resource you allocate.
|
|
18
|
-
*
|
|
19
|
-
* MUST be referentially stable: define it at module level or wrap it in `useCallback`.
|
|
20
|
-
* (It's read through a ref, so an unstable identity won't restart the engine — but a
|
|
21
|
-
* stale closure could capture old props. Prefer reading live values through refs.)
|
|
22
|
-
*
|
|
23
|
-
* @returns the handle, or a promise of it (async setup — e.g. loading WASM — is fine).
|
|
24
|
-
*/
|
|
25
|
-
export type GameFactory<THandle extends GameHandle> = (canvas: HTMLCanvasElement, registry: DisposeRegistry) => THandle | Promise<THandle>;
|
|
26
|
-
export interface UseGameEngineResult<THandle extends GameHandle> {
|
|
27
|
-
/** Attach to your `<canvas ref={canvasRef} />`. */
|
|
28
|
-
canvasRef: RefObject<HTMLCanvasElement | null>;
|
|
29
|
-
/**
|
|
30
|
-
* The live handle, available after mount (`null` during SSR/init). This is a ref
|
|
31
|
-
* value, NOT reactive — gate UI that needs it on {@link UseGameEngineResult.isReady}.
|
|
32
|
-
*/
|
|
33
|
-
handle: THandle | null;
|
|
34
|
-
/** `true` once the factory has resolved and the engine is running. */
|
|
35
|
-
isReady: boolean;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Stable game-engine host hook — the architectural fix for the "game froze, can't
|
|
39
|
-
* click out" bug.
|
|
40
|
-
*
|
|
41
|
-
* The bug: a game's lifecycle `useEffect` listed a context-derived value (typically
|
|
42
|
-
* `authRequest` / `saveNow` from `AuthContext`) in its dep array. When that value's
|
|
43
|
-
* identity churned on an unrelated re-render, React tore down and re-ran the effect —
|
|
44
|
-
* disposing the *live* engine mid-session. A guarded setup (`if (engine) return`) then
|
|
45
|
-
* refused to recreate it, leaving a dead canvas with no way out.
|
|
46
|
-
*
|
|
47
|
-
* The fix, by construction: the `factory` is held in a ref and is **never** an effect
|
|
48
|
-
* dependency. The engine starts once on mount and is disposed once on true unmount.
|
|
49
|
-
* AuthContext can re-render as much as it likes — the engine lifecycle is fully
|
|
50
|
-
* decoupled from React's render cycle. Only the explicit `deps` (true restart triggers
|
|
51
|
-
* like a room id or game mode) re-create the engine.
|
|
52
|
-
*
|
|
53
|
-
* Notes:
|
|
54
|
-
* - **Canvas sizing / DPR is game-specific** and intentionally NOT handled here. Call
|
|
55
|
-
* `resizeCanvasToDisplaySize(canvas)` (from `cursedbelt/game`) in your render loop.
|
|
56
|
-
* - **Page Visibility**: the hook calls `handle.pause?()` on hide and `handle.resume?()`
|
|
57
|
-
* on show. Cancel your rAF in `pause` and restart it in `resume`; pair with
|
|
58
|
-
* `createFixedTimestep`'s `maxCatchup` guard so the post-resume delta can't spiral.
|
|
59
|
-
*
|
|
60
|
-
* @param factory Stable engine constructor (module-level or `useCallback`).
|
|
61
|
-
* @param deps True restart triggers (keep small + stable). Default `[]` = mount-once.
|
|
62
|
-
*/
|
|
63
|
-
export declare function useGameEngine<THandle extends GameHandle>(factory: GameFactory<THandle>, deps?: DependencyList): UseGameEngineResult<THandle>;
|
|
64
|
-
//# sourceMappingURL=useGameEngine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGameEngine.d.ts","sourceRoot":"","sources":["../../../src/game/react/useGameEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,kEAAkE;IAClE,OAAO,IAAI,IAAI,CAAC;IAChB,uFAAuF;IACvF,KAAK,CAAC,IAAI,IAAI,CAAC;IACf,kFAAkF;IAClF,MAAM,CAAC,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,CAAC,OAAO,SAAS,UAAU,IAAI,CACpD,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,eAAe,KACtB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC,MAAM,WAAW,mBAAmB,CAAC,OAAO,SAAS,UAAU;IAC7D,mDAAmD;IACnD,SAAS,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC/C;;;OAGG;IACH,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,UAAU,EACtD,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,EAC7B,IAAI,GAAE,cAAmB,GACxB,mBAAmB,CAAC,OAAO,CAAC,CAoD9B"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { DisposeRegistry } from '../core/DisposeRegistry';
|
|
3
|
-
/**
|
|
4
|
-
* Stable game-engine host hook — the architectural fix for the "game froze, can't
|
|
5
|
-
* click out" bug.
|
|
6
|
-
*
|
|
7
|
-
* The bug: a game's lifecycle `useEffect` listed a context-derived value (typically
|
|
8
|
-
* `authRequest` / `saveNow` from `AuthContext`) in its dep array. When that value's
|
|
9
|
-
* identity churned on an unrelated re-render, React tore down and re-ran the effect —
|
|
10
|
-
* disposing the *live* engine mid-session. A guarded setup (`if (engine) return`) then
|
|
11
|
-
* refused to recreate it, leaving a dead canvas with no way out.
|
|
12
|
-
*
|
|
13
|
-
* The fix, by construction: the `factory` is held in a ref and is **never** an effect
|
|
14
|
-
* dependency. The engine starts once on mount and is disposed once on true unmount.
|
|
15
|
-
* AuthContext can re-render as much as it likes — the engine lifecycle is fully
|
|
16
|
-
* decoupled from React's render cycle. Only the explicit `deps` (true restart triggers
|
|
17
|
-
* like a room id or game mode) re-create the engine.
|
|
18
|
-
*
|
|
19
|
-
* Notes:
|
|
20
|
-
* - **Canvas sizing / DPR is game-specific** and intentionally NOT handled here. Call
|
|
21
|
-
* `resizeCanvasToDisplaySize(canvas)` (from `cursedbelt/game`) in your render loop.
|
|
22
|
-
* - **Page Visibility**: the hook calls `handle.pause?()` on hide and `handle.resume?()`
|
|
23
|
-
* on show. Cancel your rAF in `pause` and restart it in `resume`; pair with
|
|
24
|
-
* `createFixedTimestep`'s `maxCatchup` guard so the post-resume delta can't spiral.
|
|
25
|
-
*
|
|
26
|
-
* @param factory Stable engine constructor (module-level or `useCallback`).
|
|
27
|
-
* @param deps True restart triggers (keep small + stable). Default `[]` = mount-once.
|
|
28
|
-
*/
|
|
29
|
-
export function useGameEngine(factory, deps = []) {
|
|
30
|
-
const canvasRef = useRef(null);
|
|
31
|
-
const factoryRef = useRef(factory); // ← intentionally never an effect dependency
|
|
32
|
-
const handleRef = useRef(null);
|
|
33
|
-
const [isReady, setIsReady] = useState(false);
|
|
34
|
-
// Keep the factory ref fresh on every render WITHOUT re-running the engine effect.
|
|
35
|
-
// (Same pattern as a `useEvent` / event-handler ref.)
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
factoryRef.current = factory;
|
|
38
|
-
});
|
|
39
|
-
// NOTE (the freeze fix): `factory` is intentionally NOT a dependency of this effect —
|
|
40
|
-
// it is read through the stable `factoryRef`, so AuthContext churn (or any re-render)
|
|
41
|
-
// can never tear down and restart the live engine. Only `deps` (true restart triggers
|
|
42
|
-
// like a room id) re-create it. The exhaustive-deps lint has nothing to flag precisely
|
|
43
|
-
// because `factory` is never referenced directly here.
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const canvas = canvasRef.current;
|
|
46
|
-
if (!canvas)
|
|
47
|
-
return;
|
|
48
|
-
const registry = new DisposeRegistry();
|
|
49
|
-
let active = true;
|
|
50
|
-
Promise.resolve(factoryRef.current(canvas, registry)).then((handle) => {
|
|
51
|
-
if (!active) {
|
|
52
|
-
// Unmounted before the (possibly async) factory resolved — dispose immediately.
|
|
53
|
-
handle.dispose();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
handleRef.current = handle;
|
|
57
|
-
setIsReady(true);
|
|
58
|
-
const onVisibility = () => {
|
|
59
|
-
if (document.hidden)
|
|
60
|
-
handle.pause?.();
|
|
61
|
-
else
|
|
62
|
-
handle.resume?.();
|
|
63
|
-
};
|
|
64
|
-
document.addEventListener('visibilitychange', onVisibility);
|
|
65
|
-
registry.add(() => document.removeEventListener('visibilitychange', onVisibility));
|
|
66
|
-
});
|
|
67
|
-
return () => {
|
|
68
|
-
active = false;
|
|
69
|
-
registry.disposeAll();
|
|
70
|
-
handleRef.current?.dispose();
|
|
71
|
-
handleRef.current = null;
|
|
72
|
-
setIsReady(false);
|
|
73
|
-
};
|
|
74
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: `deps` is this hook's own pass-through dependency-list parameter (same shape as useEffect's own deps arg), inherently caller-supplied rather than an inline literal; `factory` is intentionally excluded per the freeze-fix note above.
|
|
75
|
-
}, deps);
|
|
76
|
-
return { canvasRef, handle: handleRef.current, isReady };
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=useGameEngine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGameEngine.js","sourceRoot":"","sources":["../../../src/game/react/useGameEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AA0C1D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,aAAa,CAC3B,OAA6B,EAC7B,OAAuB,EAAE;IAEzB,MAAM,SAAS,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;IACzD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,6CAA6C;IACjF,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,mFAAmF;IACnF,sDAAsD;IACtD,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,OAAO,GAAG,OA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AC,CAAC;QACF,mSAAmS;IACrS,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
export interface CanvasRect {
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
}
|
|
7
|
-
export interface CanvasMinimapPoint {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
/** A `--tone-*`/`--chart-*` CSS value. Defaults to the muted foreground. */
|
|
11
|
-
color?: string;
|
|
12
|
-
/** The focus node is drawn larger and on top. */
|
|
13
|
-
focus?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface CanvasNavHUDProps {
|
|
16
|
-
/** "Fit to canvas size" — frame the whole graph. Required: it is the escape
|
|
17
|
-
* hatch from being lost, and a canvas without one is the reported defect. */
|
|
18
|
-
onFit: () => void;
|
|
19
|
-
/** "Centre on the active focus node". Omit only if the canvas has no focus. */
|
|
20
|
-
onCenterFocus?: () => void;
|
|
21
|
-
/** Named in the centre control's hint, so it says WHAT it will centre on. */
|
|
22
|
-
focusLabel?: string;
|
|
23
|
-
/** Current zoom (1 = 100%). Renders the zoom cluster when `onZoomChange` is set. */
|
|
24
|
-
zoom?: number;
|
|
25
|
-
onZoomChange?: (zoom: number) => void;
|
|
26
|
-
/** Zoom bounds for the +/- controls. Default 0.1 – 4. */
|
|
27
|
-
zoomRange?: [number, number];
|
|
28
|
-
/** The whole graph's bounds, in world units. */
|
|
29
|
-
world?: CanvasRect;
|
|
30
|
-
/** What the user can currently see, in the same units. */
|
|
31
|
-
viewport?: CanvasRect;
|
|
32
|
-
/** Optional node dots for the radar. Keep it cheap — sample, don't map 10k nodes. */
|
|
33
|
-
points?: CanvasMinimapPoint[];
|
|
34
|
-
/** Click/drag the radar to jump. Receives world coordinates. */
|
|
35
|
-
onMinimapJump?: (point: {
|
|
36
|
-
x: number;
|
|
37
|
-
y: number;
|
|
38
|
-
}) => void;
|
|
39
|
-
/** Which corner the HUD floats in. Default `bottom-right`. */
|
|
40
|
-
corner?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
41
|
-
className?: string;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The floating navigation HUD every infinite canvas must have.
|
|
45
|
-
*
|
|
46
|
-
* `DESIGN.md` §7: *"Every infinite panning or zooming canvas must include an
|
|
47
|
-
* explicit floating Navigation HUD. The HUD must pack three essential controls: a
|
|
48
|
-
* 'Fit to Canvas Size' trigger, a 'Center Canvas on Active Focus Node' tracking
|
|
49
|
-
* action, and a low-opacity Radar Mini-Map positioned in a viewport corner
|
|
50
|
-
* indicating active coordinate bounds."*
|
|
51
|
-
*
|
|
52
|
-
* Nothing shared implemented any of the three — `HudPill` is a pill, not a HUD —
|
|
53
|
-
* so the family tree, the atlas, the orch lanes and fractals each had a different
|
|
54
|
-
* partial answer or none. This is the one implementation.
|
|
55
|
-
*
|
|
56
|
-
* It is deliberately presentational: it owns no camera. The canvas keeps its own
|
|
57
|
-
* transform and passes `world`/`viewport` in the SAME units, which is the only
|
|
58
|
-
* contract the radar needs and the reason this works for an SVG tree and a WebGL
|
|
59
|
-
* field alike. The controls sit in a `Surface` at `--z-sticky`, above the canvas
|
|
60
|
-
* and below every overlay (`DESIGN.md` §5's containment rule), and every one of
|
|
61
|
-
* them is a real 44×44 target on a coarse pointer via `IconButton`.
|
|
62
|
-
*/
|
|
63
|
-
export declare function CanvasNavHUD({ onFit, onCenterFocus, focusLabel, zoom, onZoomChange, zoomRange, world, viewport, points, onMinimapJump, corner, className, }: CanvasNavHUDProps): import("react").JSX.Element;
|
|
64
|
-
//# sourceMappingURL=CanvasNavHUD.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasNavHUD.d.ts","sourceRoot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GAmBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,aAAa,EACb,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,SAAoB,EACpB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,aAAa,EACb,MAAuB,EACvB,SAAS,GACV,EAAE,iBAAiB,+BAsHnB"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Crosshair, Maximize2, Minus, Plus } from 'lucide-react';
|
|
3
|
-
import { useCallback, useRef } from 'react';
|
|
4
|
-
import { IconButton } from '../components/IconButton';
|
|
5
|
-
import { Surface } from '../components/Surface';
|
|
6
|
-
import { cn } from '../lib/cn';
|
|
7
|
-
const CORNER_CLASS = {
|
|
8
|
-
'top-left': 'top-3 left-3',
|
|
9
|
-
'top-right': 'top-3 right-3',
|
|
10
|
-
'bottom-left': 'bottom-3 left-3',
|
|
11
|
-
'bottom-right': 'bottom-3 right-3',
|
|
12
|
-
};
|
|
13
|
-
const MINIMAP_W = 132;
|
|
14
|
-
const MINIMAP_H = 88;
|
|
15
|
-
/**
|
|
16
|
-
* The floating navigation HUD every infinite canvas must have.
|
|
17
|
-
*
|
|
18
|
-
* `DESIGN.md` §7: *"Every infinite panning or zooming canvas must include an
|
|
19
|
-
* explicit floating Navigation HUD. The HUD must pack three essential controls: a
|
|
20
|
-
* 'Fit to Canvas Size' trigger, a 'Center Canvas on Active Focus Node' tracking
|
|
21
|
-
* action, and a low-opacity Radar Mini-Map positioned in a viewport corner
|
|
22
|
-
* indicating active coordinate bounds."*
|
|
23
|
-
*
|
|
24
|
-
* Nothing shared implemented any of the three — `HudPill` is a pill, not a HUD —
|
|
25
|
-
* so the family tree, the atlas, the orch lanes and fractals each had a different
|
|
26
|
-
* partial answer or none. This is the one implementation.
|
|
27
|
-
*
|
|
28
|
-
* It is deliberately presentational: it owns no camera. The canvas keeps its own
|
|
29
|
-
* transform and passes `world`/`viewport` in the SAME units, which is the only
|
|
30
|
-
* contract the radar needs and the reason this works for an SVG tree and a WebGL
|
|
31
|
-
* field alike. The controls sit in a `Surface` at `--z-sticky`, above the canvas
|
|
32
|
-
* and below every overlay (`DESIGN.md` §5's containment rule), and every one of
|
|
33
|
-
* them is a real 44×44 target on a coarse pointer via `IconButton`.
|
|
34
|
-
*/
|
|
35
|
-
export function CanvasNavHUD({ onFit, onCenterFocus, focusLabel, zoom, onZoomChange, zoomRange = [0.1, 4], world, viewport, points, onMinimapJump, corner = 'bottom-right', className, }) {
|
|
36
|
-
const svgRef = useRef(null);
|
|
37
|
-
const [minZoom, maxZoom] = zoomRange;
|
|
38
|
-
const jump = useCallback((e) => {
|
|
39
|
-
if (!onMinimapJump || !world)
|
|
40
|
-
return;
|
|
41
|
-
const box = svgRef.current?.getBoundingClientRect();
|
|
42
|
-
if (!box || box.width === 0 || box.height === 0)
|
|
43
|
-
return;
|
|
44
|
-
const fx = (e.clientX - box.left) / box.width;
|
|
45
|
-
const fy = (e.clientY - box.top) / box.height;
|
|
46
|
-
onMinimapJump({ x: world.x + fx * world.width, y: world.y + fy * world.height });
|
|
47
|
-
}, [onMinimapJump, world]);
|
|
48
|
-
const showRadar = Boolean(world && world.width > 0 && world.height > 0);
|
|
49
|
-
const scaleX = showRadar ? MINIMAP_W / world.width : 0;
|
|
50
|
-
const scaleY = showRadar ? MINIMAP_H / world.height : 0;
|
|
51
|
-
const toX = (x) => (x - world.x) * scaleX;
|
|
52
|
-
const toY = (y) => (y - world.y) * scaleY;
|
|
53
|
-
return (_jsxs(Surface, { level: 'overlay', pad: 'none', className: cn('pointer-events-auto absolute z-[var(--z-sticky)] flex flex-col gap-2 rounded-lg p-2',
|
|
54
|
-
// Low-opacity by default so it never competes with the graph, full presence
|
|
55
|
-
// the moment the pointer or the keyboard is anywhere near it.
|
|
56
|
-
'opacity-70 transition-opacity duration-[var(--duration-fast)] hover:opacity-100 focus-within:opacity-100', CORNER_CLASS[corner], className), "data-cb-canvas-hud": '', children: [_jsxs("div", { className: 'flex items-center gap-1', children: [_jsx(IconButton, { size: 'sm', label: 'Fit to canvas', onClick: onFit, children: _jsx(Maximize2, {}) }), onCenterFocus ? (_jsx(IconButton, { size: 'sm', label: focusLabel ? `Centre on ${focusLabel}` : 'Centre on the focused item', onClick: onCenterFocus, children: _jsx(Crosshair, {}) })) : null, onZoomChange ? (_jsxs(_Fragment, { children: [_jsx(IconButton, { size: 'sm', label: 'Zoom out', disabled: zoom !== undefined && zoom <= minZoom, onClick: () => onZoomChange(Math.max(minZoom, (zoom ?? 1) / 1.25)), children: _jsx(Minus, {}) }), _jsxs("span", { className: 'min-w-10 text-center text-caption tabular-nums text-muted-foreground', children: [Math.round((zoom ?? 1) * 100), "%"] }), _jsx(IconButton, { size: 'sm', label: 'Zoom in', disabled: zoom !== undefined && zoom >= maxZoom, onClick: () => onZoomChange(Math.min(maxZoom, (zoom ?? 1) * 1.25)), children: _jsx(Plus, {}) })] })) : null] }), showRadar ? (_jsxs("svg", { ref: svgRef, role: onMinimapJump ? 'button' : 'img', "aria-label": onMinimapJump ? 'Radar — click to jump' : 'Radar', tabIndex: onMinimapJump ? 0 : undefined, width: MINIMAP_W, height: MINIMAP_H, viewBox: `0 0 ${MINIMAP_W} ${MINIMAP_H}`, onPointerDown: jump, className: cn('rounded border border-border bg-surface-sunken', onMinimapJump && 'cursor-pointer'), children: [_jsx("title", { children: "Radar" }), (points ?? []).map((p, i) => (_jsx("circle", { cx: toX(p.x), cy: toY(p.y), r: p.focus ? 2.5 : 1.4, fill: p.color ?? 'var(--muted-foreground)', opacity: p.focus ? 1 : 0.55 }, i))), viewport ? (_jsx("rect", { x: toX(viewport.x), y: toY(viewport.y), width: Math.max(2, viewport.width * scaleX), height: Math.max(2, viewport.height * scaleY), fill: 'var(--accent)', fillOpacity: 0.12, stroke: 'var(--accent)', strokeWidth: 1, "data-cb-hud-viewport": '' })) : null] })) : null] }));
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=CanvasNavHUD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasNavHUD.js","sourceRoot":"","sources":["../../../src/react/canvas/CanvasNavHUD.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAA0C,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AA4C/B,MAAM,YAAY,GAA6D;IAC7E,UAAU,EAAE,cAAc;IAC1B,WAAW,EAAE,eAAe;IAC5B,aAAa,EAAE,iBAAiB;IAChC,cAAc,EAAE,kBAAkB;CACnC,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,KAAK,EACL,aAAa,EACb,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,SAAS,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,aAAa,EACb,MAAM,GAAG,cAAc,EACvB,SAAS,GACS;IAClB,MAAM,MAAM,GAAG,MAAM,CAAuB,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAErC,MAAM,IAAI,GAAG,WAAW,CACtB,CAAC,CAAmC,EAAE,EAAE;QACtC,IAAI,CAAC,aAAa,IAAI,CAAC,KAAK;YAAE,OAAO;QACrC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,EAAE,qBAAqB,EAAE,CAAC;QACpD,I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3C,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,EAC7C,IAAI,EAAC,eAAe,EACpB,WAAW,EAAE,IAAI,EACjB,MAAM,EAAC,eAAe,EACtB,WAAW,EAAE,CAAC,0BACO,EAAE,GACvB,CACH,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC,CAAC,CAAC,IAAI,IACA,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fitting a human name into a node box without a harsh cut.
|
|
3
|
-
*
|
|
4
|
-
* `DESIGN.md` §5: *"Node diagrams, map elements, or tree visualizations displaying
|
|
5
|
-
* user identities must never truncate names with harsh, broken text string cuts.
|
|
6
|
-
* Use responsive font scaling, wrap long strings onto a clean second line, or
|
|
7
|
-
* optimize middle-initial stripping to keep names human-readable."*
|
|
8
|
-
*
|
|
9
|
-
* That is three strategies in a stated order, and every canvas in the fleet was
|
|
10
|
-
* improvising one of them (family's `TreeCanvas` does its own; the atlas does
|
|
11
|
-
* none). This is the shared ladder, as a pure function with no DOM, so a `<text>`
|
|
12
|
-
* in SVG, a 2D canvas and an absolutely-positioned `<div>` all fit labels the same
|
|
13
|
-
* way and it can be tested without a browser.
|
|
14
|
-
*
|
|
15
|
-
* @see lodForZoom — below ~50% zoom the answer is not a smaller label, it is a glyph.
|
|
16
|
-
*/
|
|
17
|
-
export type FitStrategy = 'as-is' | 'stripped' | 'wrapped' | 'scaled' | 'initials' | 'overflow';
|
|
18
|
-
export interface FitLabelOptions {
|
|
19
|
-
/** Usable width of the node box, in px. */
|
|
20
|
-
width: number;
|
|
21
|
-
/** The size the label would like to be, in px. */
|
|
22
|
-
fontSize: number;
|
|
23
|
-
/** How many lines the box can hold. Default 2 — the "clean second line". */
|
|
24
|
-
maxLines?: number;
|
|
25
|
-
/** Never scale below this. Default 10px, which is `DESIGN.md` §4's floor minus
|
|
26
|
-
* the two px a canvas label is allowed as a non-body-text glyph label. */
|
|
27
|
-
minFontSize?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Width of `text` at `fontSize`. The default is a linear approximation
|
|
30
|
-
* (0.52em average advance, which is close for a UI sans at these sizes); a
|
|
31
|
-
* caller holding a real `CanvasRenderingContext2D` should pass `measureText`
|
|
32
|
-
* so the fit is exact.
|
|
33
|
-
*/
|
|
34
|
-
measure?: (text: string, fontSize: number) => number;
|
|
35
|
-
}
|
|
36
|
-
export interface FittedLabel {
|
|
37
|
-
/** One entry per rendered line. Never empty. */
|
|
38
|
-
lines: string[];
|
|
39
|
-
/** The size to actually draw at. */
|
|
40
|
-
fontSize: number;
|
|
41
|
-
/** What the ladder had to do — surfaced so a caller can offer the full name in a
|
|
42
|
-
* hint exactly when something was dropped, rather than always or never. */
|
|
43
|
-
strategy: FitStrategy;
|
|
44
|
-
/** True when even the last rung does not fit. Draw a glyph, not an ellipsis. */
|
|
45
|
-
overflow: boolean;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Fit `text` into `width`, in `DESIGN.md` §5's stated order: as-is → drop middle
|
|
49
|
-
* names → wrap onto a second line → scale the type down → first name + last
|
|
50
|
-
* initial → give up and tell the caller to draw a glyph.
|
|
51
|
-
*/
|
|
52
|
-
export declare function fitLabel(text: string, options: FitLabelOptions): FittedLabel;
|
|
53
|
-
//# sourceMappingURL=fitLabel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fitLabel.d.ts","sourceRoot":"","sources":["../../../src/react/canvas/fitLabel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAEhG,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;+EAC2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CACtD;AAED,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB;gFAC4E;IAC5E,QAAQ,EAAE,WAAW,CAAC;IACtB,gFAAgF;IAChF,QAAQ,EAAE,OAAO,CAAC;CACnB;AA4CD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,WAAW,CAoD5E"}
|