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
Show all changes
31 commits
Select commit Hold shift + click to select a range
35d5342
Remove more dependencies from AER
chibicode Jun 18, 2019
638f98d
Create expressionRunnersConfig.ts
chibicode Jun 19, 2019
9f6f291
Add missing lines
chibicode Jun 19, 2019
543083c
Simplify runner names
chibicode Jun 19, 2019
8720239
Merge branch 'master' into precompute
chibicode Jun 19, 2019
c5e3105
Move ExpressionRunnerTypes
chibicode Jun 19, 2019
ca437f6
Merge branch 'master' into precompute
chibicode Jun 19, 2019
47dbef0
csDescriptionPreface
chibicode Jun 19, 2019
c8114a7
Set up config
chibicode Jun 19, 2019
c28c3ab
Rename to expressionRunnerShorthandConfig
chibicode Jun 19, 2019
8494b14
Update tsconfig.json
chibicode Jun 19, 2019
e9c9ee0
Temp commit
chibicode Jun 19, 2019
ab80815
Start convertConfig
chibicode Jun 19, 2019
40bcb79
Temp commit
chibicode Jun 19, 2019
7c33099
Merge branch 'master' into precompute
chibicode Jun 20, 2019
faa1a44
Merge branch 'master' into precompute
chibicode Jun 20, 2019
9ba557f
Remove deprecated
chibicode Jun 20, 2019
82320cb
Merge branch 'master' into precompute
chibicode Jun 20, 2019
ce0b771
Remove pairSimpleConfig
chibicode Jun 20, 2019
cf6622e
Implement buildExpressionRunnerConfigFromShorthand
chibicode Jun 20, 2019
fce0afc
Remove startIndex and resetIndex
chibicode Jun 20, 2019
451c2c5
Remove stepForwardUntilContainerState
chibicode Jun 20, 2019
b8d7862
Implement buildExpressionContainers
chibicode Jun 20, 2019
c92929e
Remove unused ExpressionContainerStates
chibicode Jun 20, 2019
f9a1178
Add precompute script
chibicode Jun 20, 2019
23dd395
Fix mergeWithDefault
chibicode Jun 20, 2019
70b5da4
Implement precompute
chibicode Jun 20, 2019
382a401
Add ExpressionRunnerPrecomputedParams
chibicode Jun 21, 2019
edaf7ea
Typo on props
chibicode Jun 21, 2019
309b984
Implement ExpressionRunnerPrecomputed
chibicode Jun 21, 2019
4039f74
Precompute runners
chibicode Jun 21, 2019
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
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
"option": "watch",
"problemMatcher": ["$tsc-watch"],
"runOptions": { "runOn": "folderOpen" }
},
{
"type": "typescript",
"tsconfig": "tsconfig.scripts.json",
"option": "watch",
"problemMatcher": ["$tsc-watch"],
"runOptions": { "runOn": "folderOpen" }
}
]
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"contents": "ts-node --project tsconfig.scripts.json ./scripts/generateContentsBundle.ts",
"sitemap": "ts-node --project tsconfig.scripts.json -r tsconfig-paths/register ./scripts/generateSitemap.ts",
"contents:watch": "ts-node --project tsconfig.scripts.json ./scripts/generateContentsBundle.ts watch",
"precompute": "ts-node --project tsconfig.scripts.json -r tsconfig-paths/register ./scripts/precomputeExpressionContainers.ts",
"tsc": "tsc",
"eslint": "eslint --ext .js,.ts,.tsx .",
"eslint:fix": "eslint --ext .js,.ts,.tsx --fix .",
Expand All @@ -39,6 +40,7 @@
"devDependencies": {
"@svgr/cli": "^4.3.0",
"@types/color": "^3.0.0",
"@types/fs-extra": "^7.0.0",
"@types/glob": "^7.1.1",
"@types/jest": "^24.0.13",
"@types/lodash": "^4.14.134",
Expand All @@ -65,6 +67,7 @@
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.13.0",
"eslint-plugin-react-hooks": "^1.6.0",
"fs-extra": "^8.0.1",
"glob": "^7.1.4",
"jest": "^24.8.0",
"prettier": "^1.18.2",
Expand Down
7 changes: 3 additions & 4 deletions scripts/generateContentsBundle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chokidar from 'chokidar'
import glob from 'glob'
import fs from 'fs'
import prettier from 'prettier'
import prettierFormat from 'scripts/lib/prettierFormat'

const regenerate = (path?: string) => {
glob(
Expand Down Expand Up @@ -34,14 +34,13 @@ const regenerate = (path?: string) => {
)
.join(',\n')

const fileContents = prettier.format(
const fileContents = prettierFormat(
`// WARNING: Do not modify this file - it's generated automatically.
${importString}

export default {
${bundleObjectString}
}`,
{ semi: false, singleQuote: true, parser: 'typescript' }
}`
)

fs.writeFile('./src/lib/contentsBundle.tsx', fileContents, err => {
Expand Down
7 changes: 3 additions & 4 deletions scripts/generateEmojisBundle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chokidar from 'chokidar'
import glob from 'glob'
import fs from 'fs'
import prettier from 'prettier'
import prettierFormat from 'scripts/lib/prettierFormat'
import { exec } from 'child_process'

const regenerate = () => {
Expand Down Expand Up @@ -29,14 +29,13 @@ const regenerate = () => {
.map(name => `'${name}': ${toComponentName(name)}`)
.join(',\n')

const fileContents = prettier.format(
const fileContents = prettierFormat(
`// WARNING: Do not modify this file - it's generated automatically.
${importString}

export default {
${bundleObjectString}
}`,
{ semi: false, singleQuote: true, parser: 'typescript' }
}`
)

fs.writeFile('./src/lib/emojisBundle.tsx', fileContents, err => {
Expand Down
109 changes: 109 additions & 0 deletions scripts/lib/buildExpressionContainers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { ExpressionRunnerConfig } from 'scripts/lib/buildExpressionRunnerConfigFromShorthand'
import { isContainerWithState } from 'src/lib/expressionContainerGuards'
import stepExpressionContainer from 'src/lib/stepExpressionContainer'
import { ExpressionContainer } from 'src/types/ExpressionContainerTypes'

const buildExpressionContainers = ({
expressionContainer,
initializeInstructions,
showAllShowSteps,
skipAlphaConvert,
skipToTheEnd,
hideControls,
lastAllowedExpressionState,
lastAllowedExpressionStateAfterIterations,
hidePlayButton
}: ExpressionRunnerConfig): readonly ExpressionContainer[] => {
let currentExpressionContainer = expressionContainer
let results: ExpressionContainer[] = []
const stepOptions = { showAllShowSteps, skipAlphaConvert }

initializeInstructions.forEach(initializeInstruction => {
if (
initializeInstruction.type ===
'stepForwardUntilPreviouslyChangedExpressionState'
) {
while (
currentExpressionContainer.previouslyChangedExpressionState !==
initializeInstruction.state &&
!isContainerWithState(currentExpressionContainer, 'done')
) {
currentExpressionContainer = stepExpressionContainer(
currentExpressionContainer,
stepOptions
)
}
} else if (initializeInstruction.type === 'nextIteration') {
if (!isContainerWithState(currentExpressionContainer, 'done')) {
currentExpressionContainer = stepExpressionContainer(
currentExpressionContainer,
stepOptions
)
while (
currentExpressionContainer.previouslyChangedExpressionState !==
'default' &&
!isContainerWithState(currentExpressionContainer, 'done')
) {
currentExpressionContainer = stepExpressionContainer(
currentExpressionContainer,
stepOptions
)
}
}
} else {
while (!isContainerWithState(currentExpressionContainer, 'done')) {
currentExpressionContainer = stepExpressionContainer(
currentExpressionContainer,
stepOptions
)
}
}
})

results.push(currentExpressionContainer)

if (hideControls) {
return results
}

if (skipToTheEnd) {
while (!isContainerWithState(currentExpressionContainer, 'done')) {
currentExpressionContainer = stepExpressionContainer(
currentExpressionContainer,
stepOptions
)
}
results.push(currentExpressionContainer)
return results
}

let becameDefaultCount = 0
while (!isContainerWithState(currentExpressionContainer, 'done')) {
currentExpressionContainer = stepExpressionContainer(
currentExpressionContainer,
stepOptions
)
results.push(currentExpressionContainer)

if (hidePlayButton) {
break
}

if (
lastAllowedExpressionState &&
lastAllowedExpressionState ===
expressionContainer.previouslyChangedExpressionState &&
(lastAllowedExpressionStateAfterIterations || 0) <= becameDefaultCount
) {
break
}

if (expressionContainer.previouslyChangedExpressionState === 'default') {
becameDefaultCount += 1
}
}

return results
}

export default buildExpressionContainers
Loading