Replace
This commit is contained in:
parent
2f5ad1efe1
commit
5998879e24
457 changed files with 22214 additions and 43695 deletions
|
@ -1,44 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
/*
|
||||
This script will generate content for the code editor's markdown docs. To change
|
||||
the docs, edit the file at `state/code/docs.md`.
|
||||
*/
|
||||
|
||||
const fs = require('fs/promises')
|
||||
const root = process.cwd()
|
||||
|
||||
async function inlineFileContents(path) {
|
||||
console.log(`📄 Inlining contents of ${path}`)
|
||||
const text = await fs.readFile(`${root}${path}`, 'utf-8')
|
||||
return text.replaceAll('`', '\\`')
|
||||
}
|
||||
|
||||
async function copyDocsToDocsContentFile() {
|
||||
console.log('⚙️ Generating docs-content.ts')
|
||||
|
||||
const content =
|
||||
`
|
||||
/* eslint-disable */
|
||||
|
||||
// HEY! DO NOT MODIFY THIS FILE. THE CONTENTS OF THIS FILE
|
||||
// ARE AUTO-GENERATED BY A SCRIPT AT: /scripts/docs-gen.js
|
||||
// ANY CHANGES WILL BE LOST WHEN THE SCRIPT RUNS AGAIN!
|
||||
|
||||
export default {` +
|
||||
`
|
||||
name: "docs-content.ts",
|
||||
content: \`
|
||||
${await inlineFileContents('/state/code/docs.md')}
|
||||
\`}`
|
||||
|
||||
await fs.writeFile(
|
||||
__dirname + '/../components/code-panel/docs-content.ts',
|
||||
content
|
||||
)
|
||||
|
||||
console.log('✅ Process complete')
|
||||
}
|
||||
|
||||
// Kickoff
|
||||
copyDocsToDocsContentFile()
|
|
@ -1,110 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
/*
|
||||
This script will generate TypeScript content for the code editor. It inlines
|
||||
the content of several files into one large string which can be passed to the
|
||||
Monaco editor as an extraLib.
|
||||
|
||||
Important notes:
|
||||
|
||||
- Files must include the "Start Copy Here" comment indicated below.
|
||||
|
||||
- This comment must be placed BELOW any import statements.
|
||||
|
||||
Run the script with `yarn scripts`.
|
||||
*/
|
||||
|
||||
const fs = require('fs/promises')
|
||||
const root = process.cwd()
|
||||
|
||||
async function inlineFileContents(path) {
|
||||
console.log(`📄 Inlining contents of ${path}`)
|
||||
const text = await fs.readFile(`${root}${path}`, 'utf-8')
|
||||
return text
|
||||
.match(
|
||||
/\/\* ----------------- Start Copy Here ---------------- \*\/(.|\n)*$/g
|
||||
)[0]
|
||||
.replaceAll('/* ----------------- Start Copy Here ---------------- */', '')
|
||||
.replaceAll('```', '\\`\\`\\`')
|
||||
.replaceAll('export default', '')
|
||||
.replaceAll('export ', '')
|
||||
.replaceAll('vec.', 'Vec.')
|
||||
}
|
||||
|
||||
async function copyTypesToFile() {
|
||||
console.log('⚙️ Generating types-import.ts')
|
||||
|
||||
const content =
|
||||
`
|
||||
/* eslint-disable */
|
||||
|
||||
// HEY! DO NOT MODIFY THIS FILE. THE CONTENTS OF THIS FILE
|
||||
// ARE AUTO-GENERATED BY A SCRIPT AT: /scripts/type-gen.js
|
||||
// ANY CHANGES WILL BE LOST WHEN THE SCRIPT RUNS AGAIN!
|
||||
|
||||
export default {` +
|
||||
`
|
||||
name: "types.ts",
|
||||
content: \`
|
||||
|
||||
type DeepPartial<T> = {
|
||||
[P in keyof T]?: DeepPartial<T[P]>;
|
||||
};
|
||||
|
||||
${await inlineFileContents('/types.ts')}
|
||||
|
||||
${await inlineFileContents('/types.ts')}
|
||||
|
||||
${await inlineFileContents('/utils/vec.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/utils.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/index.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/dot.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/ellipse.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/line.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/polyline.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/ray.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/arrow.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/draw.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/text.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/rectangle.ts')}
|
||||
|
||||
${await inlineFileContents('/state/code/control.ts')}
|
||||
|
||||
const codeShapes = new Set<CodeShape<any>>()
|
||||
const controls: Record<string, any> = {}
|
||||
const defaultStyle: ShapeStyles = {
|
||||
color: ColorStyle.Black,
|
||||
size: SizeStyle.Medium,
|
||||
isFilled: false,
|
||||
dash: DashStyle.Solid,
|
||||
}
|
||||
const uniqueId = () => ''
|
||||
const codeControls = new Set([])
|
||||
|
||||
declare function createShape(type: ShapeType, shape: Shape): any
|
||||
declare function getShapeUtils<T>(shape: T): any
|
||||
declare function getOrderedShapes(): CodeShape<any>[]
|
||||
|
||||
\`}`
|
||||
|
||||
await fs.writeFile(
|
||||
__dirname + '/../components/code-panel/types-import.ts',
|
||||
content
|
||||
)
|
||||
|
||||
console.log('✅ Process complete')
|
||||
}
|
||||
|
||||
// Kickoff
|
||||
copyTypesToFile()
|
Loading…
Add table
Add a link
Reference in a new issue