@fugood/bricks-project 2.21.0-beta.14.test3 → 2.21.0-beta.14.test5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/compile/index.ts CHANGED
@@ -4,6 +4,7 @@ import escodegen from 'escodegen'
4
4
  import {
5
5
  Application,
6
6
  Data,
7
+ Animation,
7
8
  AnimationDef,
8
9
  AnimationComposeDef,
9
10
  EventAction,
package/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './types'
1
+ export type * from './types'
2
2
 
3
- import { DataLink, Data } from './types'
3
+ import type { DataLink, Data } from './types'
4
4
 
5
5
  export { makeId } from './uuid'
6
6
 
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@fugood/bricks-project",
3
- "version": "2.21.0-beta.14.test3",
3
+ "version": "2.21.0-beta.14.test5",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "build": "node scripts/build.js"
7
7
  },
8
8
  "dependencies": {
9
+ "@types/escodegen": "^0.0.10",
10
+ "@types/lodash": "^4.17.12",
9
11
  "acorn": "^8.13.0",
10
12
  "escodegen": "^2.1.0",
11
13
  "lodash": "^4.17.4",
@@ -0,0 +1,48 @@
1
+ import { app, BrowserWindow } from 'electron'
2
+ import { readFile } from 'fs/promises'
3
+ import { watchFile } from 'fs'
4
+
5
+ let config = JSON.parse(await readFile(process.cwd() + '/.bricks/build/application-config.json'))
6
+
7
+ const stage = process.env.BRICKS_STAGE || 'production'
8
+
9
+ const previewUrlMap = {
10
+ production: 'https://control.bricks.tools/applicationPreview.html',
11
+ beta: 'https://control-beta.bricks.tools/applicationPreview.html',
12
+ dev: 'http://localhost:3006/dev-applicationPreview.html',
13
+ }
14
+
15
+ const previewUrl = previewUrlMap[stage]
16
+ if (!previewUrl) throw new Error(`Invalid BRICKS_STAGE: ${stage}`)
17
+
18
+ app.on('ready', () => {
19
+ const mainWindow = new BrowserWindow({ width: 1280, height: 768 })
20
+ mainWindow.loadURL(previewUrl)
21
+
22
+ const sendConfig = () => {
23
+ const payload = {
24
+ type: 'config',
25
+ configFile: { _originTitle: 'Test', ...config, title: Math.random().toString() },
26
+ workspace: { billing: { lock: {}, plan: 'free' } },
27
+ }
28
+ mainWindow.webContents.executeJavaScript(
29
+ `window.postMessage(JSON.stringify(${JSON.stringify(payload)}))`,
30
+ )
31
+ }
32
+
33
+ mainWindow.webContents.once('dom-ready', sendConfig)
34
+
35
+ watchFile(
36
+ process.cwd() + '/.bricks/build/application-config.json',
37
+ {
38
+ bigint: false,
39
+ persistent: true,
40
+ interval: 1000,
41
+ },
42
+ async () => {
43
+ console.log('Detected config changed')
44
+ config = JSON.parse(await readFile(process.cwd() + '/.bricks/build/application-config.json'))
45
+ sendConfig()
46
+ },
47
+ )
48
+ })
@@ -0,0 +1,20 @@
1
+ import { $, main } from 'bun'
2
+ import { watch, readFile } from 'fs'
3
+ import { debounce } from 'lodash'
4
+
5
+ const app = await Bun.file(process.cwd() + '/application.json').json()
6
+
7
+ const compile = debounce(async () => {
8
+ await $`bun compile`
9
+ }, 500)
10
+
11
+ watch(
12
+ process.cwd() + '/subspaces',
13
+ { recursive: true },
14
+ async (event, filename) => {
15
+ console.log(`Detected ${event} in ${filename}`)
16
+ compile()
17
+ },
18
+ )
19
+
20
+ await $`BRICKS_STAGE=${app.stage || 'production'} bunx electron ${__dirname}/preview-main.mjs`
package/types/canvas.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Easing } from './animation'
2
- import { Data, DataLink } from './data'
3
- import { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
4
- import { Brick, SubspaceID, EventAction } from './common'
1
+ import type { Easing } from './animation'
2
+ import type { Data, DataLink } from './data'
3
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
4
+ import type { Brick, SubspaceID, EventAction } from './common'
5
5
 
6
6
  type StandbyEasing = {
7
7
  method: Easing
@@ -1,4 +1,4 @@
1
- import { Data } from './data'
1
+ import type { Data } from './data'
2
2
 
3
3
  export interface DataCalculation {
4
4
  __typename: string
package/types/data.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SubspaceID, EventAction, LocalSyncStrategy } from './common'
1
+ import type { SubspaceID, EventAction, LocalSyncStrategy } from './common'
2
2
 
3
3
  interface DataDef {
4
4
  events?: {
@@ -1,6 +1,12 @@
1
- import { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
2
- import { Data, DataLink } from './data'
3
- import { Generator, EventAction, ActionWithDataParams, ActionWithParams, Action } from './common'
1
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
2
+ import type { Data, DataLink } from './data'
3
+ import type {
4
+ Generator,
5
+ EventAction,
6
+ ActionWithDataParams,
7
+ ActionWithParams,
8
+ Action,
9
+ } from './common'
4
10
 
5
11
  /* Start the tick */
6
12
  export type GeneratorTickAction_ = Action & {
package/types/system.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Action, ActionWithDataParams, ActionWithParams, Brick, Generator } from './common'
2
- import { Canvas } from './canvas'
3
- import { Data, DataLink } from './data'
1
+ import type { Action, ActionWithDataParams, ActionWithParams, Brick, Generator } from './common'
2
+ import type { Animation } from './animation'
3
+ import type { Canvas } from './canvas'
4
+ import type { Data, DataLink } from './data'
4
5
 
5
6
  /* Change Data value */
6
7
  export type SystemActionPropertyBank = ActionWithDataParams & {