@tomorrowevening/theatre-studio 1.0.5 → 1.0.6
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/index.js +105 -56
- package/package.json +1 -1
- package/dist/IDBStorage.js +0 -19
- package/dist/PaneManager.js +0 -112
- package/dist/Scrub.js +0 -134
- package/dist/Studio.js +0 -405
- package/dist/StudioBundle.js +0 -21
- package/dist/StudioStore/StudioStore.js +0 -163
- package/dist/StudioStore/createTransactionPrivateApi.js +0 -204
- package/dist/StudioStore/generateDiskStateRevision.js +0 -4
- package/dist/StudioStore/persistStateOfStudio.js +0 -61
- package/dist/TheatreStudio.js +0 -154
- package/dist/UI/UI.js +0 -65
- package/dist/UI/UINonSSRBits.js +0 -60
- package/dist/UIRoot/PanelsRoot.js +0 -19
- package/dist/UIRoot/PointerCapturing.js +0 -96
- package/dist/UIRoot/ProvideTheme.js +0 -9
- package/dist/UIRoot/UIRoot.js +0 -79
- package/dist/UIRoot/useKeyboardShortcuts.js +0 -158
- package/dist/checkForUpdates.js +0 -86
- package/dist/css.js +0 -116
- package/dist/getStudio.js +0 -10
- package/dist/notify.js +0 -328
- package/dist/panels/BasePanel/BasePanel.js +0 -74
- package/dist/panels/BasePanel/ExtensionPaneWrapper.js +0 -138
- package/dist/panels/BasePanel/PanelDragZone.js +0 -88
- package/dist/panels/BasePanel/PanelResizeHandle.js +0 -184
- package/dist/panels/BasePanel/PanelResizers.js +0 -14
- package/dist/panels/BasePanel/PanelWrapper.js +0 -34
- package/dist/panels/BasePanel/common.js +0 -52
- package/dist/panels/DetailPanel/DetailPanel.js +0 -146
- package/dist/panels/DetailPanel/DeterminePropEditorForDetail/DetailCompoundPropEditor.js +0 -169
- package/dist/panels/DetailPanel/DeterminePropEditorForDetail/DetailSimplePropEditor.js +0 -22
- package/dist/panels/DetailPanel/DeterminePropEditorForDetail/SingleRowPropEditor.js +0 -89
- package/dist/panels/DetailPanel/DeterminePropEditorForDetail/getDetailRowHighlightBackground.js +0 -7
- package/dist/panels/DetailPanel/DeterminePropEditorForDetail/rowIndentationFormulaCSS.js +0 -1
- package/dist/panels/DetailPanel/DeterminePropEditorForDetail.js +0 -28
- package/dist/panels/DetailPanel/EmptyState.js +0 -36
- package/dist/panels/DetailPanel/ObjectDetails.js +0 -52
- package/dist/panels/DetailPanel/ProjectDetails/StateConflictRow.js +0 -86
- package/dist/panels/DetailPanel/ProjectDetails.js +0 -98
- package/dist/panels/OutlinePanel/BaseItem.js +0 -136
- package/dist/panels/OutlinePanel/ObjectsList/ObjectItem.js +0 -14
- package/dist/panels/OutlinePanel/ObjectsList/ObjectsList.js +0 -85
- package/dist/panels/OutlinePanel/OutlinePanel.js +0 -73
- package/dist/panels/OutlinePanel/ProjectsList/ProjectListItem.js +0 -38
- package/dist/panels/OutlinePanel/ProjectsList/ProjectsList.js +0 -22
- package/dist/panels/OutlinePanel/SheetsList/SheetInstanceItem.js +0 -36
- package/dist/panels/OutlinePanel/SheetsList/SheetItem.js +0 -23
- package/dist/panels/OutlinePanel/SheetsList/SheetsList.js +0 -15
- package/dist/panels/OutlinePanel/outlinePanelUtils.js +0 -23
- package/dist/panels/SequenceEditorPanel/DopeSheet/DopeSheet.js +0 -21
- package/dist/panels/SequenceEditorPanel/DopeSheet/Left/AnyCompositeRow.js +0 -74
- package/dist/panels/SequenceEditorPanel/DopeSheet/Left/Left.js +0 -25
- package/dist/panels/SequenceEditorPanel/DopeSheet/Left/PrimitivePropRow.js +0 -97
- package/dist/panels/SequenceEditorPanel/DopeSheet/Left/PropWithChildrenRow.js +0 -15
- package/dist/panels/SequenceEditorPanel/DopeSheet/Left/SheetObjectRow.js +0 -19
- package/dist/panels/SequenceEditorPanel/DopeSheet/Left/SheetRow.js +0 -20
- package/dist/panels/SequenceEditorPanel/DopeSheet/Left/usePropHighlightMouseEnter.js +0 -33
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregateKeyframeEditor/AggregateKeyframeConnector.js +0 -187
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregateKeyframeEditor/AggregateKeyframeDot.js +0 -158
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregateKeyframeEditor/AggregateKeyframeEditor.js +0 -32
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregateKeyframeEditor/AggregateKeyframeVisualDot.js +0 -61
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregateKeyframeEditor/iif.js +0 -3
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregateKeyframeEditor/useAggregateKeyframeEditorUtils.js +0 -73
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregatedKeyframeTrack.js +0 -407
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/BasicKeyframedTrack.js +0 -108
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/BasicKeyframeConnector.js +0 -185
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/CurveEditorPopover/CurveEditorPopover.js +0 -397
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/CurveEditorPopover/CurveSegmentEditor.js +0 -136
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/CurveEditorPopover/EasingOption.js +0 -52
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/CurveEditorPopover/SVGCurveSegment.js +0 -43
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/CurveEditorPopover/colors.js +0 -3
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/CurveEditorPopover/shared.js +0 -84
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/CurveEditorPopover/useFreezableMemo.js +0 -16
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/CurveEditorPopover/useUIOptionGrid.js +0 -82
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/DeterminePropEditorForSingleKeyframe.js +0 -93
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/SingleKeyframeDot.js +0 -254
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/SingleKeyframeEditor.js +0 -22
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/useSingleKeyframeInlineEditorPopover.js +0 -11
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/useTempTransactionEditingTools.js +0 -43
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/DopeSheetBackground.js +0 -24
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/DopeSheetSelectionView.js +0 -272
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/FocusRangeCurtains.js +0 -88
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/HorizontallyScrollableArea.js +0 -215
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/KeyframeSnapTarget.js +0 -55
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/LengthIndicator/LengthEditorPopover.js +0 -69
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/LengthIndicator/LengthIndicator.js +0 -217
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/PrimitivePropRow.js +0 -25
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/PropWithChildrenRow.js +0 -18
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/Right.js +0 -30
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/Row.js +0 -50
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/SheetObjectRow.js +0 -14
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/SheetRow.js +0 -14
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/collectAggregateKeyframes.js +0 -92
- package/dist/panels/SequenceEditorPanel/DopeSheet/Right/keyframeRowUI/ConnectorLine.js +0 -62
- package/dist/panels/SequenceEditorPanel/DopeSheet/selections.js +0 -149
- package/dist/panels/SequenceEditorPanel/DopeSheet/setCollapsedSheetObjectOrCompoundProp.js +0 -10
- package/dist/panels/SequenceEditorPanel/FrameGrid/FrameGrid.js +0 -92
- package/dist/panels/SequenceEditorPanel/FrameGrid/StampsGrid.js +0 -99
- package/dist/panels/SequenceEditorPanel/FrameGrid/createGrid.js +0 -49
- package/dist/panels/SequenceEditorPanel/FrameStampPositionProvider.js +0 -189
- package/dist/panels/SequenceEditorPanel/GraphEditor/BasicKeyframedTrack/BasicKeyframedTrack.js +0 -91
- package/dist/panels/SequenceEditorPanel/GraphEditor/BasicKeyframedTrack/KeyframeEditor/Curve.js +0 -87
- package/dist/panels/SequenceEditorPanel/GraphEditor/BasicKeyframedTrack/KeyframeEditor/CurveHandle.js +0 -186
- package/dist/panels/SequenceEditorPanel/GraphEditor/BasicKeyframedTrack/KeyframeEditor/GraphEditorDotNonScalar.js +0 -162
- package/dist/panels/SequenceEditorPanel/GraphEditor/BasicKeyframedTrack/KeyframeEditor/GraphEditorDotScalar.js +0 -209
- package/dist/panels/SequenceEditorPanel/GraphEditor/BasicKeyframedTrack/KeyframeEditor/GraphEditorNonScalarDash.js +0 -23
- package/dist/panels/SequenceEditorPanel/GraphEditor/BasicKeyframedTrack/KeyframeEditor/KeyframeEditor.js +0 -30
- package/dist/panels/SequenceEditorPanel/GraphEditor/GraphEditor.js +0 -73
- package/dist/panels/SequenceEditorPanel/GraphEditor/PrimitivePropGraph.js +0 -20
- package/dist/panels/SequenceEditorPanel/GraphEditorToggle.js +0 -59
- package/dist/panels/SequenceEditorPanel/RightOverlay/DopeSnap.js +0 -36
- package/dist/panels/SequenceEditorPanel/RightOverlay/DopeSnapHitZoneUI.js +0 -57
- package/dist/panels/SequenceEditorPanel/RightOverlay/FocusRangeZone/FocusRangeStrip.js +0 -233
- package/dist/panels/SequenceEditorPanel/RightOverlay/FocusRangeZone/FocusRangeThumb.js +0 -217
- package/dist/panels/SequenceEditorPanel/RightOverlay/FocusRangeZone/FocusRangeZone.js +0 -181
- package/dist/panels/SequenceEditorPanel/RightOverlay/FrameStamp.js +0 -65
- package/dist/panels/SequenceEditorPanel/RightOverlay/HorizontalScrollbar.js +0 -235
- package/dist/panels/SequenceEditorPanel/RightOverlay/Markers/MarkerDot.js +0 -184
- package/dist/panels/SequenceEditorPanel/RightOverlay/Markers/MarkerEditorPopover.js +0 -65
- package/dist/panels/SequenceEditorPanel/RightOverlay/Markers/Markers.js +0 -13
- package/dist/panels/SequenceEditorPanel/RightOverlay/Playhead.js +0 -265
- package/dist/panels/SequenceEditorPanel/RightOverlay/PlayheadPositionPopover.js +0 -64
- package/dist/panels/SequenceEditorPanel/RightOverlay/RightOverlay.js +0 -35
- package/dist/panels/SequenceEditorPanel/RightOverlay/TopStrip.js +0 -31
- package/dist/panels/SequenceEditorPanel/SequenceEditorPanel.js +0 -179
- package/dist/panels/SequenceEditorPanel/VerticalScrollContainer.js +0 -42
- package/dist/panels/SequenceEditorPanel/layout/layout.js +0 -166
- package/dist/panels/SequenceEditorPanel/layout/tree.js +0 -139
- package/dist/panels/SequenceEditorPanel/whatPropIsHighlighted.js +0 -58
- package/dist/propEditors/DefaultValueIndicator.js +0 -64
- package/dist/propEditors/NextPrevKeyframeCursors.js +0 -135
- package/dist/propEditors/getNearbyKeyframesOfTrack.js +0 -46
- package/dist/propEditors/simpleEditors/BooleanPropEditor.js +0 -17
- package/dist/propEditors/simpleEditors/FilePropEditor.js +0 -118
- package/dist/propEditors/simpleEditors/ISimplePropEditorReactProps.js +0 -1
- package/dist/propEditors/simpleEditors/ImagePropEditor.js +0 -126
- package/dist/propEditors/simpleEditors/NumberPropEditor.js +0 -9
- package/dist/propEditors/simpleEditors/RgbaPropEditor.js +0 -73
- package/dist/propEditors/simpleEditors/StringLiteralPropEditor.js +0 -10
- package/dist/propEditors/simpleEditors/StringPropEditor.js +0 -6
- package/dist/propEditors/simpleEditors/simplePropEditorByPropType.js +0 -16
- package/dist/propEditors/useEditingToolsForCompoundProp.js +0 -228
- package/dist/propEditors/useEditingToolsForSimpleProp.js +0 -229
- package/dist/propEditors/utils/IEditingTools.js +0 -1
- package/dist/propEditors/utils/PropConfigForType.js +0 -1
- package/dist/propEditors/utils/getPropTypeByPointer.js +0 -48
- package/dist/propEditors/utils/propNameTextCSS.js +0 -7
- package/dist/selectors.js +0 -63
- package/dist/store/index.js +0 -184
- package/dist/store/stateEditors.js +0 -774
- package/dist/store/types/ahistoric.js +0 -1
- package/dist/store/types/ephemeral.js +0 -1
- package/dist/store/types/historic.js +0 -1
- package/dist/store/types/index.js +0 -3
- package/dist/toolbars/ExtensionToolbar/ExtensionToolbar.js +0 -51
- package/dist/toolbars/ExtensionToolbar/Toolset.js +0 -27
- package/dist/toolbars/ExtensionToolbar/tools/ExtensionFlyoutMenu.js +0 -51
- package/dist/toolbars/ExtensionToolbar/tools/IconButton.js +0 -16
- package/dist/toolbars/ExtensionToolbar/tools/Switch.js +0 -20
- package/dist/toolbars/GlobalToolbar.js +0 -142
- package/dist/toolbars/MoreMenu/MoreMenu.js +0 -133
- package/dist/toolbars/PinButton.js +0 -26
- package/dist/uiComponents/DetailPanelButton.js +0 -21
- package/dist/uiComponents/PointerEventsHandler.js +0 -80
- package/dist/uiComponents/Popover/ArrowContext.js +0 -3
- package/dist/uiComponents/Popover/BasicPopover.js +0 -35
- package/dist/uiComponents/Popover/BasicTooltip.js +0 -10
- package/dist/uiComponents/Popover/ErrorTooltip.js +0 -9
- package/dist/uiComponents/Popover/MinimalTooltip.js +0 -6
- package/dist/uiComponents/Popover/PopoverArrow.js +0 -38
- package/dist/uiComponents/Popover/TooltipContext.js +0 -46
- package/dist/uiComponents/Popover/TooltipWrapper.js +0 -103
- package/dist/uiComponents/Popover/usePopover.js +0 -132
- package/dist/uiComponents/Popover/useTooltip.js +0 -33
- package/dist/uiComponents/RoomToClick.js +0 -10
- package/dist/uiComponents/SVGIcon.js +0 -19
- package/dist/uiComponents/ShowMousePosition.js +0 -30
- package/dist/uiComponents/colorPicker/components/EditingProvider.js +0 -15
- package/dist/uiComponents/colorPicker/components/RgbaColorPicker.js +0 -31
- package/dist/uiComponents/colorPicker/components/common/Alpha.js +0 -54
- package/dist/uiComponents/colorPicker/components/common/AlphaColorPicker.js +0 -28
- package/dist/uiComponents/colorPicker/components/common/Hue.js +0 -41
- package/dist/uiComponents/colorPicker/components/common/Interactive.js +0 -142
- package/dist/uiComponents/colorPicker/components/common/Pointer.js +0 -39
- package/dist/uiComponents/colorPicker/components/common/Saturation.js +0 -44
- package/dist/uiComponents/colorPicker/hooks/useColorManipulation.js +0 -77
- package/dist/uiComponents/colorPicker/hooks/useEventCallback.js +0 -10
- package/dist/uiComponents/colorPicker/hooks/useIsomorphicLayoutEffect.js +0 -5
- package/dist/uiComponents/colorPicker/index.js +0 -1
- package/dist/uiComponents/colorPicker/types.js +0 -1
- package/dist/uiComponents/colorPicker/utils/clamp.js +0 -6
- package/dist/uiComponents/colorPicker/utils/compare.js +0 -25
- package/dist/uiComponents/colorPicker/utils/convert.js +0 -165
- package/dist/uiComponents/colorPicker/utils/round.js +0 -3
- package/dist/uiComponents/colorPicker/utils/validate.js +0 -10
- package/dist/uiComponents/createCursorLock.js +0 -2
- package/dist/uiComponents/form/BasicCheckbox.js +0 -5
- package/dist/uiComponents/form/BasicNumberInput.js +0 -261
- package/dist/uiComponents/form/BasicSelect.js +0 -58
- package/dist/uiComponents/form/BasicStringInput.js +0 -151
- package/dist/uiComponents/form/BasicSwitch.js +0 -60
- package/dist/uiComponents/icons/AddImage.js +0 -6
- package/dist/uiComponents/icons/ArrowClockwise.js +0 -6
- package/dist/uiComponents/icons/ArrowsOutCardinal.js +0 -6
- package/dist/uiComponents/icons/Bell.js +0 -6
- package/dist/uiComponents/icons/Camera.js +0 -7
- package/dist/uiComponents/icons/ChevronDown.js +0 -6
- package/dist/uiComponents/icons/ChevronLeft.js +0 -6
- package/dist/uiComponents/icons/ChevronRight.js +0 -6
- package/dist/uiComponents/icons/Cube.js +0 -6
- package/dist/uiComponents/icons/CubeFull.js +0 -6
- package/dist/uiComponents/icons/CubeHalf.js +0 -6
- package/dist/uiComponents/icons/CubeRendered.js +0 -7
- package/dist/uiComponents/icons/Details.js +0 -6
- package/dist/uiComponents/icons/DoubleChevronLeft.js +0 -6
- package/dist/uiComponents/icons/DoubleChevronRight.js +0 -6
- package/dist/uiComponents/icons/Ellipsis.js +0 -6
- package/dist/uiComponents/icons/EllipsisFill.js +0 -6
- package/dist/uiComponents/icons/GlobeSimple.js +0 -6
- package/dist/uiComponents/icons/Outline.js +0 -6
- package/dist/uiComponents/icons/Package.js +0 -6
- package/dist/uiComponents/icons/Resize.js +0 -7
- package/dist/uiComponents/icons/Trash.js +0 -6
- package/dist/uiComponents/icons/index.js +0 -20
- package/dist/uiComponents/isSafari.js +0 -2
- package/dist/uiComponents/onPointerOutside.js +0 -19
- package/dist/uiComponents/selects/BasicSelect.js +0 -24
- package/dist/uiComponents/simpleContextMenu/ContextMenu/BaseMenu.js +0 -40
- package/dist/uiComponents/simpleContextMenu/ContextMenu/ContextMenu.js +0 -87
- package/dist/uiComponents/simpleContextMenu/ContextMenu/Item.js +0 -37
- package/dist/uiComponents/simpleContextMenu/useContextMenu.js +0 -20
- package/dist/uiComponents/simpleContextMenu/useRequestContextMenu.js +0 -22
- package/dist/uiComponents/toolbar/ToolbarDropdownSelect.js +0 -7
- package/dist/uiComponents/toolbar/ToolbarIconButton.js +0 -74
- package/dist/uiComponents/toolbar/ToolbarSwitchSelect.js +0 -12
- package/dist/uiComponents/toolbar/ToolbarSwitchSelectContainer.js +0 -9
- package/dist/uiComponents/useBoundingClientRect.js +0 -13
- package/dist/uiComponents/useDebugRefreshEvery.js +0 -19
- package/dist/uiComponents/useDrag.js +0 -199
- package/dist/uiComponents/useHotspot.js +0 -30
- package/dist/uiComponents/useHover.js +0 -23
- package/dist/uiComponents/useHoverWithoutDescendants.js +0 -33
- package/dist/uiComponents/useKeyDown.js +0 -9
- package/dist/uiComponents/useKeyDownCallback.js +0 -28
- package/dist/uiComponents/useLockSet.js +0 -17
- package/dist/uiComponents/useLogger.js +0 -16
- package/dist/uiComponents/useOnClickOutside.js +0 -25
- package/dist/uiComponents/useOnKeyDown.js +0 -12
- package/dist/uiComponents/usePresence.js +0 -156
- package/dist/uiComponents/useValToAtom.js +0 -11
- package/dist/utils/absoluteDims.js +0 -7
- package/dist/utils/contextualWebComponents.js +0 -44
- package/dist/utils/copyToClipboard.js +0 -28
- package/dist/utils/derive-utils.js +0 -61
- package/dist/utils/devStringify.js +0 -20
- package/dist/utils/invariant.js +0 -79
- package/dist/utils/isMac.js +0 -2
- package/dist/utils/keyboardUtils.js +0 -23
- package/dist/utils/mousePositionD.js +0 -18
- package/dist/utils/redux/actionCreator.js +0 -15
- package/dist/utils/redux/actionCreator.test.js +0 -35
- package/dist/utils/redux/actionReducersBundle.js +0 -18
- package/dist/utils/redux/atomFromReduxStore.js +0 -11
- package/dist/utils/redux/configureStore.js +0 -18
- package/dist/utils/redux/pointerFriendlySelector.js +0 -8
- package/dist/utils/redux/withHistory/withBatchActions.js +0 -13
- package/dist/utils/redux/withHistory/withHistory.js +0 -157
- package/dist/utils/renderInPortalInContext.js +0 -38
- package/dist/utils/selectClosestHTMLAncestor.js +0 -13
- package/dist/utils/tightJsonStringify.js +0 -27
- package/dist/utils/tightJsonStringify.test.js +0 -25
- package/dist/utils/useRefAndState.js +0 -32
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { isPrism, prism, val } from '@tomorrowevening/theatre-dataverse';
|
|
2
|
-
import { usePrismInstance } from '@tomorrowevening/theatre-react';
|
|
3
|
-
import React, { useMemo, useRef } from 'react';
|
|
4
|
-
import { invariant } from './invariant';
|
|
5
|
-
function deriveAllD(obj) {
|
|
6
|
-
return prism(() => {
|
|
7
|
-
if (Array.isArray(obj)) {
|
|
8
|
-
const values = new Array(obj.length);
|
|
9
|
-
for (let i = 0; i < obj.length; i++) {
|
|
10
|
-
values[i] = obj[i].getValue();
|
|
11
|
-
}
|
|
12
|
-
return values;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
const values = {};
|
|
16
|
-
for (const k in obj) {
|
|
17
|
-
values[k] = val(obj[k]);
|
|
18
|
-
}
|
|
19
|
-
return values;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Wrap up the component to enable it to take derivable properties.
|
|
25
|
-
* Invoked similarly to `React.memo`.
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* This is an experimental interface for wrapping components in a version
|
|
29
|
-
* which allows you to pass in derivations for any of the properties that
|
|
30
|
-
* previously took only values.
|
|
31
|
-
*/
|
|
32
|
-
export function deriver(Component) {
|
|
33
|
-
const finalComp = React.memo(React.forwardRef(function deriverRender(props, ref) {
|
|
34
|
-
let observableArr = [];
|
|
35
|
-
const observables = {};
|
|
36
|
-
const normalProps = {
|
|
37
|
-
ref,
|
|
38
|
-
};
|
|
39
|
-
for (const key in props) {
|
|
40
|
-
const value = props[key];
|
|
41
|
-
if (isPrism(value)) {
|
|
42
|
-
observableArr.push(value);
|
|
43
|
-
observables[key] = value;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
normalProps[key] = value;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const initialCount = useRef(observableArr.length);
|
|
50
|
-
invariant(initialCount.current === observableArr.length, `expect same number of observable props on every invocation of deriver wrapped component.`, { initial: initialCount.current, count: observableArr.length });
|
|
51
|
-
const allD = useMemo(() => deriveAllD(observables), observableArr);
|
|
52
|
-
const observedPropState = usePrismInstance(allD);
|
|
53
|
-
return (observedPropState &&
|
|
54
|
-
React.createElement(Component, {
|
|
55
|
-
...normalProps,
|
|
56
|
-
...observedPropState,
|
|
57
|
-
}));
|
|
58
|
-
}));
|
|
59
|
-
finalComp.displayName = `deriver(${Component.displayName})`;
|
|
60
|
-
return finalComp;
|
|
61
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { tightJsonStringify } from './tightJsonStringify';
|
|
2
|
-
/**
|
|
3
|
-
* Stringifies any value given. If an object is given and `indentJSON` is true,
|
|
4
|
-
* then a developer-readable, command line friendly (not too spaced out, but with
|
|
5
|
-
* enough whitespace to be readable).
|
|
6
|
-
*/
|
|
7
|
-
export function devStringify(input, indentJSON = true) {
|
|
8
|
-
try {
|
|
9
|
-
return typeof input === 'string'
|
|
10
|
-
? input
|
|
11
|
-
: typeof input === 'function' || input instanceof Error
|
|
12
|
-
? input.toString()
|
|
13
|
-
: indentJSON
|
|
14
|
-
? tightJsonStringify(input)
|
|
15
|
-
: JSON.stringify(input);
|
|
16
|
-
}
|
|
17
|
-
catch (err) {
|
|
18
|
-
return input?.name || String(input);
|
|
19
|
-
}
|
|
20
|
-
}
|
package/dist/utils/invariant.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { devStringify } from './devStringify';
|
|
2
|
-
/**
|
|
3
|
-
* invariants are like `expect` from jest or another testing library but
|
|
4
|
-
* for use in implementations and not just tests. If the `condition` passed
|
|
5
|
-
* to `invariant` is falsy then `message`, and optionally `found`, are thrown as a
|
|
6
|
-
* {@link InvariantError} which has a developer-readable and command line friendly
|
|
7
|
-
* stack trace and error message.
|
|
8
|
-
*/
|
|
9
|
-
export function invariant(shouldBeTruthy, message, butFoundInstead) {
|
|
10
|
-
if (!shouldBeTruthy) {
|
|
11
|
-
const isFoundArgGiven = arguments.length > 2;
|
|
12
|
-
if (isFoundArgGiven) {
|
|
13
|
-
invariantThrow(message, butFoundInstead);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
invariantThrow(message);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Throws an error message with a developer-readable and command line friendly
|
|
22
|
-
* string of the argument `butFoundInstead`.
|
|
23
|
-
*
|
|
24
|
-
* Also see {@link invariant}, which accepts a condition.
|
|
25
|
-
*/
|
|
26
|
-
export function invariantThrow(message, butFoundInstead) {
|
|
27
|
-
const isFoundArgGiven = arguments.length > 1;
|
|
28
|
-
const prefix = devStringify(typeof message === 'function' ? message() : message);
|
|
29
|
-
const suffix = isFoundArgGiven
|
|
30
|
-
? `\nInstead found: ${devStringify(butFoundInstead)}`
|
|
31
|
-
: '';
|
|
32
|
-
throw new InvariantError(`Invariant: ${prefix}${suffix}`, butFoundInstead);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Enable exhaustive checking
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```ts
|
|
39
|
-
* function a(x: 'a' | 'b') {
|
|
40
|
-
* if (x === 'a') {
|
|
41
|
-
*
|
|
42
|
-
* } else if (x === 'b') {
|
|
43
|
-
*
|
|
44
|
-
* } else {
|
|
45
|
-
* invariantUnreachable(x)
|
|
46
|
-
* }
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export function invariantUnreachable(x) {
|
|
51
|
-
invariantThrow('invariantUnreachable encountered value which was supposed to be never', x);
|
|
52
|
-
}
|
|
53
|
-
// regexes to remove lines from thrown error stacktraces
|
|
54
|
-
const AT_NODE_INTERNAL_RE = /^\s*at.+node:internal.+/gm;
|
|
55
|
-
const AT_INVARIANT_RE = /^\s*(at|[^@]+@) (?:Object\.)?invariant.+/gm;
|
|
56
|
-
const AT_TEST_HELPERS_RE = /^\s*(at|[^@]+@).+test\-helpers.+/gm;
|
|
57
|
-
// const AT_WEB_MODULES = /^\s*(at|[^@]+@).+(web_modules|\-[a-f0-9]{8}\.js).*/gm
|
|
58
|
-
const AT_ASSORTED_HELPERS_RE = /^\s*(at|[^@]+@).+(debounce|invariant|iif)\.[tj]s.*/gm;
|
|
59
|
-
/**
|
|
60
|
-
* `InvariantError` removes lines from the `Error.stack` stack trace string
|
|
61
|
-
* which cleans up the stack trace, making it more developer friendly to read.
|
|
62
|
-
*/
|
|
63
|
-
class InvariantError extends Error {
|
|
64
|
-
found;
|
|
65
|
-
constructor(message, found) {
|
|
66
|
-
super(message);
|
|
67
|
-
if (found !== undefined) {
|
|
68
|
-
this.found = found;
|
|
69
|
-
}
|
|
70
|
-
// const before = this.stack
|
|
71
|
-
// prettier-ignore
|
|
72
|
-
this.stack = this.stack
|
|
73
|
-
?.replace(AT_INVARIANT_RE, "")
|
|
74
|
-
.replace(AT_ASSORTED_HELPERS_RE, "")
|
|
75
|
-
.replace(AT_TEST_HELPERS_RE, "")
|
|
76
|
-
.replace(AT_NODE_INTERNAL_RE, "");
|
|
77
|
-
// console.error({ before, after: this.stack })
|
|
78
|
-
}
|
|
79
|
-
}
|
package/dist/utils/isMac.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { isMac } from './isMac';
|
|
2
|
-
/**
|
|
3
|
-
* On mac, it checks Cmd, on windows, ctrl
|
|
4
|
-
*/
|
|
5
|
-
export const cmdIsDown = (e) => {
|
|
6
|
-
if (isMac) {
|
|
7
|
-
return e.metaKey === true;
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
return e.ctrlKey === true;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* On mac, it checks for ctrl, on windows, Win
|
|
15
|
-
*/
|
|
16
|
-
export const ctrlIsDown = (e) => {
|
|
17
|
-
if (isMac) {
|
|
18
|
-
return e.ctrlKey === true;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return e.metaKey === true;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { prism } from '@tomorrowevening/theatre-dataverse';
|
|
2
|
-
/**
|
|
3
|
-
* A prism that holds the current mouse position.
|
|
4
|
-
*/
|
|
5
|
-
const mousePositionD = prism(() => {
|
|
6
|
-
const [pos, setPos] = prism.state('pos', null);
|
|
7
|
-
prism.effect('setupListeners', () => {
|
|
8
|
-
const handleMouseMove = (e) => {
|
|
9
|
-
setPos(e);
|
|
10
|
-
};
|
|
11
|
-
document.addEventListener('mousemove', handleMouseMove);
|
|
12
|
-
return () => {
|
|
13
|
-
document.removeEventListener('mousemove', handleMouseMove);
|
|
14
|
-
};
|
|
15
|
-
}, []);
|
|
16
|
-
return pos;
|
|
17
|
-
});
|
|
18
|
-
export default mousePositionD;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
function identity(a) {
|
|
2
|
-
return a;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* This is basically the same as `{createAction}` from 'redux-actions',
|
|
6
|
-
* only that you can query the type of the action from the resulting
|
|
7
|
-
* action creator.
|
|
8
|
-
*/
|
|
9
|
-
const actionCreator = (actionType, transformer = identity) => {
|
|
10
|
-
const originalActionCreator = (payload) => ({ type: actionType, payload: transformer(payload) });
|
|
11
|
-
originalActionCreator.type = actionType;
|
|
12
|
-
originalActionCreator.is = (o) => o && o.type && o.type === actionType;
|
|
13
|
-
return originalActionCreator;
|
|
14
|
-
};
|
|
15
|
-
export default actionCreator;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import actionCreator from '@tomorrowevening/theatre-studio/utils/redux/actionCreator';
|
|
2
|
-
describe('@tomorrowevening/theatre-studio/utils/redux/actionCreator()', () => {
|
|
3
|
-
const actionType = 'Bootstrap';
|
|
4
|
-
const payload = { a: 1, b: 2 };
|
|
5
|
-
let creator = actionCreator(actionType);
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
creator = actionCreator(actionType);
|
|
8
|
-
});
|
|
9
|
-
describe('output action', () => {
|
|
10
|
-
it('should maintain the same type and payload', () => {
|
|
11
|
-
const output = creator(payload);
|
|
12
|
-
expect(output.type).toEqual(actionType);
|
|
13
|
-
expect(output.payload).toEqual(payload);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
describe('the action creator', () => {
|
|
17
|
-
it('should have a reference to the original action type', () => {
|
|
18
|
-
expect(creator.type).toEqual(actionType);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
/* eslint-disable unused-imports/no-unused-vars-ts */
|
|
22
|
-
function typeTests() {
|
|
23
|
-
const creator = actionCreator(actionType);
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
let a = creator.type;
|
|
26
|
-
// $FlowExpectError
|
|
27
|
-
a = creator.type;
|
|
28
|
-
const action = creator(payload);
|
|
29
|
-
a = action.payload.a;
|
|
30
|
-
// $FlowExpectError
|
|
31
|
-
a = action.payload.a;
|
|
32
|
-
a = action.payload;
|
|
33
|
-
}
|
|
34
|
-
/* eslint-enable unused-imports/no-unused-vars-ts */
|
|
35
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import mapValues from 'lodash-es/mapValues';
|
|
2
|
-
const actionReducersBundle = (ctx) => (reducers) => {
|
|
3
|
-
const actions = mapValues(reducers, (_, actionType) => {
|
|
4
|
-
return (payload) => ({ type: actionType, payload });
|
|
5
|
-
});
|
|
6
|
-
const reducer = (prevState, action) => {
|
|
7
|
-
const { type } = action;
|
|
8
|
-
const innerReducer = reducers[type];
|
|
9
|
-
if (!innerReducer) {
|
|
10
|
-
ctx.logger.error(`Unkown action type '${type}'`);
|
|
11
|
-
return prevState;
|
|
12
|
-
}
|
|
13
|
-
const newState = innerReducer(prevState, action);
|
|
14
|
-
return newState;
|
|
15
|
-
};
|
|
16
|
-
return { actions, reducer };
|
|
17
|
-
};
|
|
18
|
-
export default actionReducersBundle;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Atom } from '@tomorrowevening/theatre-dataverse';
|
|
2
|
-
export default function atomFromReduxStore(store) {
|
|
3
|
-
let lastState = store.getState();
|
|
4
|
-
const a = new Atom(lastState);
|
|
5
|
-
store.subscribe(() => {
|
|
6
|
-
const newState = store.getState();
|
|
7
|
-
a.set(newState);
|
|
8
|
-
lastState = newState;
|
|
9
|
-
});
|
|
10
|
-
return a;
|
|
11
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import identity from 'lodash-es/identity';
|
|
2
|
-
import { compose, createStore } from 'redux';
|
|
3
|
-
export default function configureStore(conf) {
|
|
4
|
-
// const middlewares: $FixMe[] = []
|
|
5
|
-
const enhancers = [];
|
|
6
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7
|
-
const devtoolsEnhancer = process.env.NODE_ENV !== 'production' &&
|
|
8
|
-
typeof window === 'object' &&
|
|
9
|
-
window.__REDUX_DEVTOOLS_EXTENSION__
|
|
10
|
-
? window.__REDUX_DEVTOOLS_EXTENSION__(conf.devtoolsOptions)
|
|
11
|
-
: identity;
|
|
12
|
-
enhancers.push(devtoolsEnhancer);
|
|
13
|
-
}
|
|
14
|
-
// enhancers.unshift(applyMiddleware(...middlewares))
|
|
15
|
-
const enhancer = compose(...enhancers);
|
|
16
|
-
const store = createStore(conf.rootReducer, undefined, enhancer);
|
|
17
|
-
return store;
|
|
18
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import actionCreator from '@tomorrowevening/theatre-studio/utils/redux/actionCreator';
|
|
2
|
-
export const batchedAction = actionCreator('@@batched', (actions) => actions);
|
|
3
|
-
const withBatchedActions = (reducer) => {
|
|
4
|
-
return (prevState, action) => {
|
|
5
|
-
if (batchedAction.is(action)) {
|
|
6
|
-
return action.payload.reduce((stateSoFar, a) => reducer(stateSoFar, a), prevState);
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
return reducer(prevState, action);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export default withBatchedActions;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import actionCreator from '@tomorrowevening/theatre-studio/utils/redux/actionCreator';
|
|
2
|
-
import jiff from 'jiff';
|
|
3
|
-
import patch from 'json-touch-patch';
|
|
4
|
-
import last from 'lodash-es/last';
|
|
5
|
-
import { v4 as makeUUID } from 'uuid';
|
|
6
|
-
export const historicActions = {
|
|
7
|
-
/**
|
|
8
|
-
* This action causes the reducer to replace the history it has tracked,
|
|
9
|
-
* with a new history. This is useful for persisting and re-hydrating the
|
|
10
|
-
* entire history to/from a persistent storage.
|
|
11
|
-
*/
|
|
12
|
-
replaceHistory: actionCreator('@history/replaceHistory'),
|
|
13
|
-
/**
|
|
14
|
-
* This action causes the reducer to start the history from scratch. This is useful
|
|
15
|
-
* for testing and development where you want to explicitly provide a state to the
|
|
16
|
-
* store.
|
|
17
|
-
*/
|
|
18
|
-
startHistoryFromScratch: actionCreator('@history/startHistoryFromScratch'),
|
|
19
|
-
undo: actionCreator('@history/undo'),
|
|
20
|
-
redo: actionCreator('@history/redo'),
|
|
21
|
-
};
|
|
22
|
-
export const isHistoricAction = (a) => {
|
|
23
|
-
return Object.entries(historicActions).some(([, actionCreator]) => actionCreator.is(a));
|
|
24
|
-
};
|
|
25
|
-
//
|
|
26
|
-
const unknownAction = { type: '@history/unknownAction', payload: '' };
|
|
27
|
-
const defaultConfig = {
|
|
28
|
-
maxNumberOfCommits: 100,
|
|
29
|
-
};
|
|
30
|
-
export const withHistory = (innerReducer, config = defaultConfig) => {
|
|
31
|
-
const cachedEmptyHistory = createEmptyHistory(innerReducer(undefined, unknownAction));
|
|
32
|
-
return function historicReducer(state, action) {
|
|
33
|
-
if (historicActions.startHistoryFromScratch.is(action)) {
|
|
34
|
-
return createEmptyHistory(innerReducer(undefined, action.payload));
|
|
35
|
-
}
|
|
36
|
-
else if (historicActions.replaceHistory.is(action)) {
|
|
37
|
-
return action.payload;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
if (historicActions.undo.is(action)) {
|
|
41
|
-
return state ? undo(state) : cachedEmptyHistory;
|
|
42
|
-
}
|
|
43
|
-
else if (historicActions.redo.is(action)) {
|
|
44
|
-
return state ? redo(state) : cachedEmptyHistory;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
if (state) {
|
|
48
|
-
return pushCommit(state, innerReducer(state.innerState, action), config);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return createEmptyHistory(innerReducer(undefined, action));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
function createEmptyHistory(innerState) {
|
|
58
|
-
return {
|
|
59
|
-
currentCommitHash: undefined,
|
|
60
|
-
commitsByHash: {},
|
|
61
|
-
listOfCommitHashes: [],
|
|
62
|
-
innerState: innerState,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function pushCommit(prevHistory, newInnerState, config) {
|
|
66
|
-
if (newInnerState === prevHistory.innerState)
|
|
67
|
-
return prevHistory;
|
|
68
|
-
const commit = createCommit(prevHistory.innerState, newInnerState);
|
|
69
|
-
if (commit.forwardDiff.length === 0) {
|
|
70
|
-
return prevHistory;
|
|
71
|
-
}
|
|
72
|
-
const prevLastCommitHash = last(prevHistory.listOfCommitHashes);
|
|
73
|
-
const newHistory = {
|
|
74
|
-
currentCommitHash: commit.hash,
|
|
75
|
-
commitsByHash: { ...prevHistory.commitsByHash },
|
|
76
|
-
listOfCommitHashes: [...prevHistory.listOfCommitHashes],
|
|
77
|
-
innerState: newInnerState,
|
|
78
|
-
};
|
|
79
|
-
/*
|
|
80
|
-
* If we have undo-ed a few commits, and are now committing st which means we should discard
|
|
81
|
-
* the re-doable commits
|
|
82
|
-
* History: C C C C C C
|
|
83
|
-
* ^ <- currentCommitHash
|
|
84
|
-
*/
|
|
85
|
-
if (prevHistory.currentCommitHash !== prevLastCommitHash) {
|
|
86
|
-
const indexOfCurrentCommitHash = prevHistory.listOfCommitHashes.findIndex((v) => v === prevHistory.currentCommitHash);
|
|
87
|
-
const listOfCommitHashesToDiscard = prevHistory.listOfCommitHashes.slice(indexOfCurrentCommitHash + 1);
|
|
88
|
-
listOfCommitHashesToDiscard.forEach((hash) => {
|
|
89
|
-
delete newHistory.commitsByHash[hash];
|
|
90
|
-
});
|
|
91
|
-
newHistory.listOfCommitHashes.splice(indexOfCurrentCommitHash + 1, newHistory.listOfCommitHashes.length);
|
|
92
|
-
}
|
|
93
|
-
newHistory.listOfCommitHashes.push(commit.hash);
|
|
94
|
-
newHistory.commitsByHash[commit.hash] = commit;
|
|
95
|
-
if (newHistory.listOfCommitHashes.length > config.maxNumberOfCommits) {
|
|
96
|
-
const numberOfCommitsToDiscard = newHistory.listOfCommitHashes.length - config.maxNumberOfCommits;
|
|
97
|
-
const listOfCommitHashesToDiscard = newHistory.listOfCommitHashes.slice(0, numberOfCommitsToDiscard);
|
|
98
|
-
listOfCommitHashesToDiscard.forEach((hash) => {
|
|
99
|
-
delete newHistory.commitsByHash[hash];
|
|
100
|
-
});
|
|
101
|
-
newHistory.listOfCommitHashes.splice(0, numberOfCommitsToDiscard);
|
|
102
|
-
}
|
|
103
|
-
return newHistory;
|
|
104
|
-
}
|
|
105
|
-
function createCommit(oldSnapshot, newSnapshot) {
|
|
106
|
-
const forwardDiff = jiff.diff(oldSnapshot, newSnapshot, { invertible: false });
|
|
107
|
-
const backwardDiff = jiff.diff(newSnapshot, oldSnapshot, { invertible: false });
|
|
108
|
-
const timestamp = Date.now();
|
|
109
|
-
const commitHash = makeUUID();
|
|
110
|
-
const commit = {
|
|
111
|
-
forwardDiff,
|
|
112
|
-
backwardDiff,
|
|
113
|
-
timestamp,
|
|
114
|
-
hash: commitHash,
|
|
115
|
-
};
|
|
116
|
-
return commit;
|
|
117
|
-
}
|
|
118
|
-
function undo(prevHistory) {
|
|
119
|
-
if (prevHistory.currentCommitHash === undefined) {
|
|
120
|
-
return prevHistory;
|
|
121
|
-
}
|
|
122
|
-
const indexOfCurrentCommitHash = prevHistory.listOfCommitHashes.findIndex((v) => v === prevHistory.currentCommitHash);
|
|
123
|
-
if (indexOfCurrentCommitHash === -1) {
|
|
124
|
-
throw new Error('This should never happen');
|
|
125
|
-
}
|
|
126
|
-
const currentCommit = prevHistory.commitsByHash[prevHistory.currentCommitHash];
|
|
127
|
-
const newInnerState = patch(prevHistory.innerState, currentCommit.backwardDiff);
|
|
128
|
-
const indexOfNewCommitHash = indexOfCurrentCommitHash - 1;
|
|
129
|
-
const newCommitHash = indexOfNewCommitHash === -1
|
|
130
|
-
? undefined
|
|
131
|
-
: prevHistory.listOfCommitHashes[indexOfNewCommitHash];
|
|
132
|
-
const newHistory = {
|
|
133
|
-
...prevHistory,
|
|
134
|
-
currentCommitHash: newCommitHash,
|
|
135
|
-
innerState: newInnerState,
|
|
136
|
-
};
|
|
137
|
-
return newHistory;
|
|
138
|
-
}
|
|
139
|
-
function redo(prevHistory) {
|
|
140
|
-
if (prevHistory.listOfCommitHashes.length === 0) {
|
|
141
|
-
return prevHistory;
|
|
142
|
-
}
|
|
143
|
-
const indexOfCurrentCommitHash = prevHistory.listOfCommitHashes.findIndex((v) => v === prevHistory.currentCommitHash);
|
|
144
|
-
if (indexOfCurrentCommitHash === prevHistory.listOfCommitHashes.length - 1) {
|
|
145
|
-
return prevHistory;
|
|
146
|
-
}
|
|
147
|
-
const indexOfNewCommitHash = indexOfCurrentCommitHash + 1;
|
|
148
|
-
const newCommitHash = prevHistory.listOfCommitHashes[indexOfNewCommitHash];
|
|
149
|
-
const currentCommit = prevHistory.commitsByHash[newCommitHash];
|
|
150
|
-
const newInnerState = patch(prevHistory.innerState, currentCommit.forwardDiff);
|
|
151
|
-
const newHistory = {
|
|
152
|
-
...prevHistory,
|
|
153
|
-
currentCommitHash: newCommitHash,
|
|
154
|
-
innerState: newInnerState,
|
|
155
|
-
};
|
|
156
|
-
return newHistory;
|
|
157
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Atom } from '@tomorrowevening/theatre-dataverse';
|
|
2
|
-
import { useVal } from '@tomorrowevening/theatre-react';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { createPortal } from 'react-dom';
|
|
5
|
-
const theAtom = new Atom({
|
|
6
|
-
set: {},
|
|
7
|
-
byId: {},
|
|
8
|
-
});
|
|
9
|
-
let lastId = 1;
|
|
10
|
-
export const getMounter = () => {
|
|
11
|
-
const id = lastId++;
|
|
12
|
-
function mountOrRender(comp, props, portalNode) {
|
|
13
|
-
theAtom.reduce((s) => {
|
|
14
|
-
return {
|
|
15
|
-
byId: { ...s.byId, [id]: { comp, props, portalNode } },
|
|
16
|
-
set: { ...s.set, [id]: true },
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function unmount() {
|
|
21
|
-
theAtom.reduce((s) => {
|
|
22
|
-
const set = { ...s.set };
|
|
23
|
-
const byId = { ...s.byId };
|
|
24
|
-
delete set[id];
|
|
25
|
-
return { byId, set };
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return { mountOrRender, unmount };
|
|
29
|
-
};
|
|
30
|
-
export const MountAll = () => {
|
|
31
|
-
const ids = Object.keys(useVal(theAtom.pointer.set));
|
|
32
|
-
return (React.createElement(React.Fragment, null, ids.map((id) => (React.createElement(Mount, { key: 'id-' + id, id: id })))));
|
|
33
|
-
};
|
|
34
|
-
const Mount = ({ id }) => {
|
|
35
|
-
const { comp, portalNode, props } = useVal(theAtom.pointer.byId[id]);
|
|
36
|
-
const Comp = comp;
|
|
37
|
-
return createPortal(React.createElement(Comp, { ...props }), portalNode);
|
|
38
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Traverse upwards from the current element to find the first element that matches the selector.
|
|
3
|
-
*/
|
|
4
|
-
export function selectClosestHTMLAncestor(start, selector) {
|
|
5
|
-
if (start == null)
|
|
6
|
-
return null;
|
|
7
|
-
if (start instanceof Element && start.matches(selector)) {
|
|
8
|
-
return start;
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
return selectClosestHTMLAncestor(start.parentElement, selector);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stringifies an object in a developer-readable, command line friendly way
|
|
3
|
-
* (not too spaced out, but with enough whitespace to be readable).
|
|
4
|
-
*
|
|
5
|
-
* e.g.
|
|
6
|
-
* ```ts
|
|
7
|
-
* tightJsonStringify({a:1, b: {c: [1, 2, {d: 4}], e: 8}})
|
|
8
|
-
* ```
|
|
9
|
-
* becomes
|
|
10
|
-
* ```json
|
|
11
|
-
* { "a": 1,
|
|
12
|
-
* "b": {
|
|
13
|
-
* "c": [
|
|
14
|
-
* 1,
|
|
15
|
-
* 2,
|
|
16
|
-
* { "d": 4 } ],
|
|
17
|
-
* "e": 8 } }
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* Also, see the examples in [`./tightJsonStringify.test.ts`](./tightJsonStringify.test.ts)
|
|
21
|
-
*/
|
|
22
|
-
export function tightJsonStringify(obj, replacer) {
|
|
23
|
-
return JSON.stringify(obj, replacer, 2)
|
|
24
|
-
.replace(/^([\{\[])\n (\s+)/, '$1$2')
|
|
25
|
-
.replace(/(\n[ ]+[\{\[])\n\s+/g, '$1 ')
|
|
26
|
-
.replace(/\n\s*([\]\}])/g, ' $1');
|
|
27
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { tightJsonStringify } from './tightJsonStringify';
|
|
2
|
-
describe('tightJsonStringify', () => {
|
|
3
|
-
it('matches a series of expectations', () => {
|
|
4
|
-
expect(tightJsonStringify({ a: 1, b: 2, c: { y: 4, z: 745 } }))
|
|
5
|
-
.toMatchInlineSnapshot(`
|
|
6
|
-
"{ "a": 1,
|
|
7
|
-
"b": 2,
|
|
8
|
-
"c": {
|
|
9
|
-
"y": 4,
|
|
10
|
-
"z": 745 } }"
|
|
11
|
-
`);
|
|
12
|
-
expect(tightJsonStringify(true)).toMatchInlineSnapshot(`"true"`);
|
|
13
|
-
expect(tightJsonStringify('Already a string')).toMatchInlineSnapshot(`""Already a string""`);
|
|
14
|
-
expect(tightJsonStringify({ a: 1, b: { c: [1, 2, { d: 4 }], e: 8 } }))
|
|
15
|
-
.toMatchInlineSnapshot(`
|
|
16
|
-
"{ "a": 1,
|
|
17
|
-
"b": {
|
|
18
|
-
"c": [
|
|
19
|
-
1,
|
|
20
|
-
2,
|
|
21
|
-
{ "d": 4 } ],
|
|
22
|
-
"e": 8 } }"
|
|
23
|
-
`);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Combines useRef() and useState().
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* Usage:
|
|
7
|
-
* ```ts
|
|
8
|
-
* const [ref, val] = useRefAndState<HTMLDivElement | null>(null)
|
|
9
|
-
*
|
|
10
|
-
* useEffect(() => {
|
|
11
|
-
* val.addEventListener(...)
|
|
12
|
-
* }, [val])
|
|
13
|
-
*
|
|
14
|
-
* return <div ref={ref}></div>
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export default function useRefAndState(initialValue) {
|
|
18
|
-
const ref = useMemo(() => {
|
|
19
|
-
let current = initialValue;
|
|
20
|
-
return {
|
|
21
|
-
get current() {
|
|
22
|
-
return current;
|
|
23
|
-
},
|
|
24
|
-
set current(v) {
|
|
25
|
-
current = v;
|
|
26
|
-
setState(v);
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}, []);
|
|
30
|
-
const [state, setState] = useState(() => initialValue);
|
|
31
|
-
return [ref, state];
|
|
32
|
-
}
|