Fix light bulb errors (also add a dev mode to build script)
This commit is contained in:
parent
fbd05e4dd0
commit
d6ba5609e8
9
build.js
9
build.js
|
@ -5,15 +5,17 @@ import * as fs from 'fs'
|
|||
|
||||
const serve = process.env.ESBUILD_SERVE === '1'
|
||||
const baseurl = process.env.ESBUILD_BASEURL || ''
|
||||
const nodeEnv = process.env.NODE_ENV
|
||||
const isProd = nodeEnv !== 'development'
|
||||
|
||||
console.log(`Building with baseurl ${baseurl}`)
|
||||
|
||||
const ctx = await esbuild.context({
|
||||
entryPoints: ['src/index.ts'],
|
||||
minify: true,
|
||||
minify: isProd,
|
||||
bundle: true,
|
||||
metafile: true,
|
||||
splitting: true,
|
||||
splitting: isProd,
|
||||
outdir: 'dist',
|
||||
format: 'esm',
|
||||
target: ['es2020'],
|
||||
|
@ -23,7 +25,8 @@ const ctx = await esbuild.context({
|
|||
'.svg': 'file'
|
||||
},
|
||||
define: {
|
||||
'process.env.BASEURL': JSON.stringify(baseurl)
|
||||
'process.env.BASEURL': JSON.stringify(baseurl),
|
||||
'process.env.NODE_ENV': JSON.stringify(nodeEnv)
|
||||
},
|
||||
plugins: [
|
||||
htmlPlugin({
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "ESBUILD_SERVE=1 node ./build.js",
|
||||
"dev": "NODE_ENV=development ESBUILD_SERVE=1 node ./build.js",
|
||||
"build": "node ./build.js",
|
||||
"check": "tsc"
|
||||
},
|
||||
|
|
|
@ -33,7 +33,11 @@ async function main() {
|
|||
}
|
||||
}
|
||||
|
||||
new EventSource('/esbuild').addEventListener('change', () => location.reload())
|
||||
if (process.env.BASEURL === 'development') {
|
||||
new EventSource('/esbuild').addEventListener('change', () =>
|
||||
location.reload()
|
||||
)
|
||||
}
|
||||
|
||||
// Call entry
|
||||
main().catch((error) => {
|
||||
|
|
|
@ -24,7 +24,7 @@ export class ExecutionQueue<T> {
|
|||
private current: Promise<T> | null
|
||||
|
||||
/**
|
||||
* Wheather the tasks should continue beeing executed
|
||||
* Whether the tasks should continue being executed
|
||||
*/
|
||||
public active = true
|
||||
|
||||
|
@ -58,7 +58,7 @@ export class ExecutionQueue<T> {
|
|||
if (task) {
|
||||
this.current = task.execute()
|
||||
|
||||
this.current.then(result => {
|
||||
this.current.then((result) => {
|
||||
task.output.next(result)
|
||||
|
||||
if (this.active) {
|
||||
|
|
|
@ -24,7 +24,7 @@ const lightTemplate: PartialTemplate = {
|
|||
activation: `
|
||||
const { main, active } = context.colors
|
||||
|
||||
context.color(context.getBinary(2) ? active : main)
|
||||
context.color(context.getBinary(0) ? active : main)
|
||||
`
|
||||
},
|
||||
integration: {
|
||||
|
|
|
@ -295,8 +295,9 @@ export class Gate {
|
|||
props: Property[] = this.template.properties.data,
|
||||
target: GateProps = this.props,
|
||||
path: string[] = []
|
||||
) {
|
||||
): boolean {
|
||||
// We don't want to update until every prop has been created
|
||||
let shouldUpdate = false
|
||||
let lockUpdates = true
|
||||
|
||||
if (this.template.properties.enabled) {
|
||||
|
@ -304,7 +305,7 @@ export class Gate {
|
|||
if (isGroup(prop)) {
|
||||
const { groupName } = prop
|
||||
target[groupName] = {} as GateProps
|
||||
this.assignProps(
|
||||
shouldUpdate ||= this.assignProps(
|
||||
typeof source[groupName] === 'object'
|
||||
? (source[groupName] as PropsSave)
|
||||
: {},
|
||||
|
@ -312,11 +313,9 @@ export class Gate {
|
|||
target[groupName] as GateProps,
|
||||
[...path, groupName]
|
||||
)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
} else {
|
||||
const { name, base, needsUpdate } = prop
|
||||
shouldUpdate ||= needsUpdate || false
|
||||
|
||||
const subject = new BehaviorSubject(
|
||||
source.hasOwnProperty(name) ? source[name] : base
|
||||
|
@ -339,9 +338,13 @@ export class Gate {
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lockUpdates = false
|
||||
this.update()
|
||||
|
||||
if (path.length === 0 && shouldUpdate) this.update()
|
||||
|
||||
return shouldUpdate
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { GateTemplate, Property, RawProp } from './types/GateTemplate'
|
||||
import { GateTemplate, RawProp } from './types/GateTemplate'
|
||||
import { categories } from '../saving/data/categories'
|
||||
import { getRendererSafely } from '../logic-gates/helpers/getRendererSafely'
|
||||
|
||||
export const DefaultGateTemplate: GateTemplate = {
|
||||
metadata: {
|
||||
|
|
Loading…
Reference in a new issue