Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions scripts/lib/buildExpressionContainers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const buildExpressionContainers = ({
initializeInstructions,
showAllShowSteps,
skipAlphaConvert,
alphaConvertCallArg,
skipActive,
skipToTheEnd,
hideControls,
Expand All @@ -26,7 +25,6 @@ const buildExpressionContainers = ({
const stepOptions = {
showAllShowSteps,
skipAlphaConvert,
alphaConvertCallArg,
skipActive
}

Expand Down
41 changes: 0 additions & 41 deletions scripts/lib/buildExpressionFromParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import {
isVariableExpressionParams,
isHighlightedVariableExpressionParams,
isFunctionExpressionParams,
isVariableShorthandBinaryParams,
isVariableShorthandUnaryParams,
isVariableShorthandNumberParams,
isMagicalVariableParams,
isConditionalParams,
isVariableShorthandFuncParams,
isQuestionPlusOrMinusOneParams,
Expand All @@ -18,10 +15,8 @@ import {
FunctionExpressionParams,
VariableExpressionParams,
HighlightedVariableExpressionParams,
VariableShorthandBinaryParams,
VariableShorthandNumberParams,
ConditionalExpressionParams,
MagicalVariableParams,
RepeatExpressionParams,
QuestionPlusOrMinusOneParams,
QuestionShorthandNumberAfterConvertParams,
Expand All @@ -32,10 +27,8 @@ import {
StepChild,
StepFunction,
StepVariable,
StepVariableShorthandBinary,
StepVariableShorthandNumber,
StepConditional,
StepMagicalVariable,
RepeatExpression
} from 'src/types/ExpressionTypes'
import { VariableNames } from 'src/types/VariableNames'
Expand Down Expand Up @@ -90,12 +83,6 @@ export default function buildExpressionFromParams(
export default function buildExpressionFromParams(
expressionParams: FunctionExpressionParams
): StepFunction
export default function buildExpressionFromParams(
expressionParams: VariableShorthandBinaryParams
): StepVariableShorthandBinary
export default function buildExpressionFromParams(
expressionParams: MagicalVariableParams
): StepMagicalVariable
export default function buildExpressionFromParams(
expressionParams: VariableShorthandNumberParams
): StepVariableShorthandNumber
Expand Down Expand Up @@ -162,24 +149,6 @@ export default function buildExpressionFromParams(
meta: expressionParams.meta
}
}
} else if (isVariableShorthandBinaryParams(expressionParams)) {
return {
...buildVariableExpression(
'shorthandBinary',
true,
expressionParams.initialHighlight ? 'initialHighlighted' : 'default'
),
shorthandBinary: expressionParams.shorthandBinary
}
} else if (isVariableShorthandUnaryParams(expressionParams)) {
return {
...buildVariableExpression(
expressionParams.name,
true,
expressionParams.initialHighlight ? 'initialHighlighted' : 'default'
),
shorthandUnary: expressionParams.shorthandUnary
}
} else if (isVariableShorthandNumberParams(expressionParams)) {
return {
...buildVariableExpression(
Expand All @@ -188,18 +157,8 @@ export default function buildExpressionFromParams(
expressionParams.initialHighlight ? 'initialHighlighted' : 'default'
),
shorthandNumber: expressionParams.shorthandNumber,
shorthandUnary: expressionParams.shorthandUnary,
shorthandNumberAfterConvert: expressionParams.shorthandNumberAfterConvert
}
} else if (isMagicalVariableParams(expressionParams)) {
return {
...buildVariableExpression(
'magical',
true,
expressionParams.initialHighlight ? 'initialHighlighted' : 'default'
),
magical: expressionParams.magical
}
} else if (isConditionalParams(expressionParams)) {
return {
type: 'conditional',
Expand Down
63 changes: 5 additions & 58 deletions scripts/lib/buildExpressionRunnerConfigFromShorthand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
ExpressionRunnerContextProps,
expressionRunnerContextDefault
} from 'src/types/ExpressionRunnerTypes'
import { HProps } from 'src/types/HTypes'
import { SteppedExpressionContainer } from 'src/types/ExpressionContainerTypes'
import { ExpressionRunnerProps } from 'src/types/ExpressionRunnerTypes'

Expand All @@ -25,36 +24,24 @@ export interface ExpressionRunnerConfig {
hidePriorities: ExpressionRunnerContextProps['hidePriorities']
hideBottomRightBadges: ExpressionRunnerContextProps['hideBottomRightBadges']
hideControls: boolean
explanationsVisibility:
| 'visible'
| 'hidden'
| 'hiddenInitialPausedOnly'
| 'hiddenInitialAndLastPausedOnly'
explanationsVisibility: 'visible' | 'hidden' | 'hiddenInitialPausedOnly'
variableSize: ExpressionRunnerContextProps['variableSize']
initializeInstructions: readonly InitializeInstruction[]
maxStepsAllowed?: number
lastAllowedExpressionState?: ExpressionContainer['previouslyChangedExpressionState']
lastAllowedExpressionStateAfterIterations?: number
containerSize: keyof typeof allMaxWidths
hidePlayButton?: boolean
speed: number
showAllShowSteps?: boolean
skipAlphaConvert?: boolean
alphaConvertCallArg?: boolean
skipActive?: boolean
skipToTheEnd: boolean
hideFuncUnboundBadgeOnExplanation: boolean
highlightOverridesCallArgAndFuncUnboundOnly: boolean
bottomRightBadgeOverrides: ExpressionRunnerContextProps['bottomRightBadgeOverrides']
highlightOverrides: ExpressionRunnerContextProps['highlightOverrides']
caption?: HProps['args']
highlightOverrideActiveAfterStart: boolean
showOnlyFocused: ExpressionRunnerContextProps['showOnlyFocused']
argPriorityAggHighlights: readonly number[]
funcPriorityAggHighlights: readonly number[]
highlightFunctions: boolean
superFastForward: boolean
highlightNumber?: number
convert?: ExpressionRunnerProps['convert']
crossed?: boolean
}
Expand All @@ -77,35 +64,19 @@ const expressionRunnerDefaults = {
highlightOverrides: expressionRunnerContextDefault.highlightOverrides,
highlightOverrideActiveAfterStart:
expressionRunnerContextDefault.highlightOverrideActiveAfterStart,
showOnlyFocused: expressionRunnerContextDefault.showOnlyFocused,
argPriorityAggHighlights: [],
funcPriorityAggHighlights: [],
highlightFunctions: false,
superFastForward: false
highlightFunctions: false
}

const buildInitializeInstructions = ({
nextIteration,
nextIterations,
isDone,
initialState
}: {
nextIteration?: boolean
nextIterations?: number
isDone?: boolean
initialState: ExpressionContainer['previouslyChangedExpressionState']
}): readonly InitializeInstruction[] =>
nextIteration
? [
{
type: 'nextIteration'
},
{
type: 'stepForwardUntilPreviouslyChangedExpressionState',
state: initialState
}
]
: nextIterations
nextIterations
? [
...Array(nextIterations).fill({ type: 'nextIteration' }),
{
Expand Down Expand Up @@ -147,24 +118,18 @@ const buildExpressionRunnerConfigFromShorthand = (
initialState,
isDone,
skipAlphaConvert,
alphaConvertCallArg,
skipActive,
nextIteration,
nextIterations,
showPriorities,
showAllShowSteps,
explanationsVisibility,
caption,
bottomRightBadgeOverrides,
variableSize,
containerSize,
highlightOverrides,
highlightOverrideActiveAfterStart,
highlightOverridesCallArgAndFuncUnboundOnly,
showOnlyFocused,
highlightFunctions,
argPriorityAggHighlights,
funcPriorityAggHighlights,
crossed
} = mergeWithDefault<
typeof config,
Expand All @@ -179,24 +144,18 @@ const buildExpressionRunnerConfigFromShorthand = (
showAllShowSteps,
variableSize,
highlightOverridesCallArgAndFuncUnboundOnly,
showOnlyFocused,
containerSize,
caption,
skipAlphaConvert,
alphaConvertCallArg,
skipActive,
bottomRightBadgeOverrides,
highlightOverrides,
highlightFunctions,
highlightOverrideActiveAfterStart,
initializeInstructions: buildInitializeInstructions({
nextIteration,
nextIterations,
isDone,
initialState
}),
argPriorityAggHighlights,
funcPriorityAggHighlights,
crossed
}
} else if (isExpressionRunnerPlayButtonOnlyConfig(config)) {
Expand All @@ -208,27 +167,22 @@ const buildExpressionRunnerConfigFromShorthand = (
showPriorities,
lastAllowedExpressionState,
lastAllowedExpressionStateAfterIterations,
nextIteration,
nextIterations,
showAllShowSteps,
speed,
skipAlphaConvert,
alphaConvertCallArg,
skipActive,
variableSize,
containerSize,
highlightOverrides,
explanationsVisibility,
superFastForward,
highlightNumber
explanationsVisibility
} = mergeWithDefault<
typeof config,
typeof expressionRunnerPlayButtonOnlyConfigDefault
>(config, expressionRunnerPlayButtonOnlyConfigDefault)

runnerProps = {
speed,
highlightNumber,
initialExpressionContainer,
hidePriorities: !showPriorities,
highlightOverrides,
Expand All @@ -238,18 +192,15 @@ const buildExpressionRunnerConfigFromShorthand = (
variableSize,
containerSize,
skipAlphaConvert,
alphaConvertCallArg,
skipActive,
explanationsVisibility:
explanationsVisibility || 'hiddenInitialPausedOnly',
lastAllowedExpressionState,
lastAllowedExpressionStateAfterIterations,
initializeInstructions: buildInitializeInstructions({
nextIteration,
nextIterations,
initialState
}),
superFastForward
})
}
} else if (isExpressionRunnerSingleStepConfig(config)) {
const {
Expand All @@ -262,9 +213,7 @@ const buildExpressionRunnerConfigFromShorthand = (
showAllShowSteps,
variableSize,
containerSize,
nextIteration,
nextIterations,
alphaConvertCallArg,
skipActive
} = mergeWithDefault<
typeof config,
Expand All @@ -282,10 +231,8 @@ const buildExpressionRunnerConfigFromShorthand = (
lastAllowedExpressionState: finalState,
lastAllowedExpressionStateAfterIterations: nextIterations,
showAllShowSteps,
alphaConvertCallArg,
skipActive,
initializeInstructions: buildInitializeInstructions({
nextIteration,
nextIterations,
initialState
})
Expand Down
Loading