b88a2370b3
Removes `propsForNextShape` and replaces it with the new styles API. Changes in here: - New custom style example - `setProp` is now `setStyle` and takes a `StyleProp` instead of a string - `Editor.props` and `Editor.opacity` are now `Editor.sharedStyles` and `Editor.sharedOpacity` - They return an object that flags mixed vs shared types instead of using null to signal mixed types - `Editor.styles` returns a `SharedStyleMap` - keyed on `StyleProp` instead of `string` - `StateNode.shapeType` is now the shape util rather than just a string. This lets us pull the styles from the shape type directly. - `color` is no longer a core part of the editor set on the shape parent. Individual child shapes have to use color directly. - `propsForNextShape` is now `stylesForNextShape` - `InstanceRecordType` is created at runtime in the same way `ShapeRecordType` is. This is so it can pull style validators out of shape defs for `stylesForNextShape` - Shape type are now defined by their props rather than having separate validators & type defs ### Change Type - [x] `major` — Breaking change ### Test Plan 1. Big time regression testing around styles! 2. Check UI works as intended for all shape/style/tool combos - [x] Unit Tests - [ ] End to end tests ### Release Notes - --------- Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
77 lines
1.9 KiB
TypeScript
77 lines
1.9 KiB
TypeScript
import dotenv from 'dotenv'
|
|
import esbuild from 'esbuild'
|
|
import fs from 'fs'
|
|
import fse from 'fs-extra'
|
|
import path from 'path'
|
|
import { logEnv } from '../../vscode-script-utils/cli'
|
|
import { copyEditor } from '../../vscode-script-utils/helpers'
|
|
import { exists, getDirname } from '../../vscode-script-utils/path'
|
|
|
|
dotenv.config()
|
|
const rootDir = getDirname(import.meta.url, '../')
|
|
const log = logEnv('editor')
|
|
|
|
export async function run() {
|
|
try {
|
|
const targetFolder = `${rootDir}dist/`
|
|
if (await exists(targetFolder)) {
|
|
log({ cmd: 'remove', args: { target: targetFolder } })
|
|
await fs.promises.rm(targetFolder, { recursive: true })
|
|
}
|
|
|
|
await fs.promises.mkdir(targetFolder)
|
|
|
|
const topSource = `${rootDir}public`
|
|
const files = await fs.promises.readdir(topSource)
|
|
for (const file of files) {
|
|
const dest = targetFolder + path.basename(file)
|
|
const source = path.join(topSource, file)
|
|
log({ cmd: 'copy', args: { source, dest } })
|
|
await fse.copy(source, dest)
|
|
}
|
|
const entryPoints = [`${rootDir}src/index.tsx`]
|
|
|
|
log({ cmd: 'esbuild', args: { entryPoints } })
|
|
|
|
const builder = await esbuild.context({
|
|
entryPoints,
|
|
outfile: `${rootDir}/dist/index.js`,
|
|
minify: false,
|
|
bundle: true,
|
|
target: 'es6',
|
|
jsxFactory: 'React.createElement',
|
|
jsxFragment: 'React.Fragment',
|
|
loader: {
|
|
'.woff2': 'dataurl',
|
|
'.woff': 'dataurl',
|
|
'.svg': 'file',
|
|
'.png': 'file',
|
|
'.json': 'file',
|
|
},
|
|
define: {
|
|
'process.env.NODE_ENV': '"development"',
|
|
},
|
|
plugins: [
|
|
{
|
|
name: 'log-builds',
|
|
setup(build) {
|
|
build.onEnd((result) => {
|
|
if (result.errors.length) {
|
|
log({ cmd: 'esbuild:error', args: { err: result.errors } })
|
|
} else {
|
|
copyEditor({ log })
|
|
log({ cmd: 'esbuild:success', args: {} })
|
|
}
|
|
})
|
|
},
|
|
},
|
|
],
|
|
})
|
|
await builder.watch()
|
|
} catch (error) {
|
|
log({ cmd: 'esbuild:error', args: { error } })
|
|
throw error
|
|
}
|
|
}
|
|
|
|
run()
|