@fugood/bricks-project 2.21.0-beta.14.test11 → 2.21.0-beta.14.test13
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 +51 -2
- package/index.ts +1 -1
- package/package.json +1 -1
- package/tools/preview-main.mjs +3 -0
- package/tools/preview.ts +2 -1
- package/types/bricks.ts +2 -0
- package/types/canvas.ts +1 -0
- package/types/data.ts +19 -8
- package/types/subspace.ts +9 -1
- package/utils/data.ts +27 -1
package/compile/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { templateActionNameMap } from './action-name-map'
|
|
|
7
7
|
import type {
|
|
8
8
|
Application,
|
|
9
9
|
Data,
|
|
10
|
+
DataAssetKind,
|
|
10
11
|
Animation,
|
|
11
12
|
AnimationDef,
|
|
12
13
|
AnimationComposeDef,
|
|
@@ -203,9 +204,37 @@ const compileFrame = (frame: Canvas['items'][number]['frame']) => ({
|
|
|
203
204
|
render_out_of_viewport: frame.renderOutOfViewport,
|
|
204
205
|
})
|
|
205
206
|
|
|
207
|
+
const preloadTypes = [
|
|
208
|
+
'media-resource-image',
|
|
209
|
+
'media-resource-video',
|
|
210
|
+
'media-resource-audio',
|
|
211
|
+
'media-resource-file',
|
|
212
|
+
'lottie-file-uri',
|
|
213
|
+
'ggml-model-asset',
|
|
214
|
+
'gguf-model-asset',
|
|
215
|
+
'binary-asset',
|
|
216
|
+
]
|
|
217
|
+
|
|
206
218
|
const compileKind = (kind: Data['kind']) => {
|
|
207
219
|
const { type, ...rest } = kind || {}
|
|
208
220
|
if (!type) return {}
|
|
221
|
+
if (preloadTypes.includes(type)) {
|
|
222
|
+
const { preload, metadata } = kind as DataAssetKind
|
|
223
|
+
const result: any = { kind: type, ...rest }
|
|
224
|
+
if (preload) {
|
|
225
|
+
result.preload = {
|
|
226
|
+
type: preload.type,
|
|
227
|
+
hashType: preload.hashType,
|
|
228
|
+
}
|
|
229
|
+
if (preload.hashType) result.preload[preload.hashType] = preload.hash
|
|
230
|
+
}
|
|
231
|
+
// Handle metadata
|
|
232
|
+
if (type === 'gguf-model-asset') {
|
|
233
|
+
result._hfRepoInfo = metadata?.hfRepoInfo
|
|
234
|
+
}
|
|
235
|
+
return result
|
|
236
|
+
}
|
|
237
|
+
|
|
209
238
|
return { kind: type, ...rest }
|
|
210
239
|
}
|
|
211
240
|
|
|
@@ -244,13 +273,26 @@ const compileModule = (subspace: Subspace) => {
|
|
|
244
273
|
}
|
|
245
274
|
}
|
|
246
275
|
|
|
247
|
-
export const compile = (app: Application) => {
|
|
276
|
+
export const compile = async (app: Application) => {
|
|
277
|
+
await new Promise((resolve) => setImmediate(resolve, 0))
|
|
248
278
|
const config = {
|
|
249
279
|
title: app.name,
|
|
250
280
|
subspace_map: app.subspaces.reduce((subspaceMap, subspace) => {
|
|
251
281
|
subspaceMap[subspace.id] = {
|
|
252
282
|
title: subspace.title,
|
|
253
283
|
description: subspace.description,
|
|
284
|
+
_expanded: subspace.unexpanded
|
|
285
|
+
? {
|
|
286
|
+
brick: !subspace.unexpanded.brick,
|
|
287
|
+
generator: !subspace.unexpanded.generator,
|
|
288
|
+
canvas: subspace.unexpanded.canvas?.reduce((acc, canvas) => {
|
|
289
|
+
acc[canvas.id] = canvas?.id ? false : true
|
|
290
|
+
return acc
|
|
291
|
+
}, {}),
|
|
292
|
+
property_bank: !subspace.unexpanded.data,
|
|
293
|
+
property_bank_calc: !subspace.unexpanded.dataCalculation,
|
|
294
|
+
}
|
|
295
|
+
: undefined,
|
|
254
296
|
layout: {
|
|
255
297
|
width: subspace.layout?.width,
|
|
256
298
|
height: subspace.layout?.height,
|
|
@@ -387,6 +429,7 @@ export const compile = (app: Application) => {
|
|
|
387
429
|
? { brick_id: (item.item as () => Brick)()?.id }
|
|
388
430
|
: { subspace_id: item.item }),
|
|
389
431
|
frame: compileFrame(item.frame),
|
|
432
|
+
hidden: item.hidden,
|
|
390
433
|
})),
|
|
391
434
|
}
|
|
392
435
|
return map
|
|
@@ -569,7 +612,13 @@ export const compile = (app: Application) => {
|
|
|
569
612
|
const declarationBody = (
|
|
570
613
|
(program.body[0] as ExportNamedDeclaration).declaration as FunctionDeclaration
|
|
571
614
|
)?.body
|
|
572
|
-
code = escodegen.generate(declarationBody
|
|
615
|
+
code = escodegen.generate(declarationBody, {
|
|
616
|
+
format: {
|
|
617
|
+
indent: { style: ' ' },
|
|
618
|
+
semicolons: false,
|
|
619
|
+
},
|
|
620
|
+
comment: true,
|
|
621
|
+
})
|
|
573
622
|
} catch (e) {
|
|
574
623
|
code = scriptCalc.code || ''
|
|
575
624
|
}
|
package/index.ts
CHANGED
package/package.json
CHANGED
package/tools/preview-main.mjs
CHANGED
|
@@ -20,6 +20,7 @@ if (!previewUrl) throw new Error(`Invalid BRICKS_STAGE: ${stage}`)
|
|
|
20
20
|
|
|
21
21
|
app.on('ready', () => {
|
|
22
22
|
const mainWindow = new BrowserWindow({ width: 1280, height: 768 })
|
|
23
|
+
mainWindow.setBackgroundColor('#333')
|
|
23
24
|
mainWindow.loadURL(previewUrl)
|
|
24
25
|
|
|
25
26
|
const sendConfig = () => {
|
|
@@ -35,6 +36,8 @@ app.on('ready', () => {
|
|
|
35
36
|
|
|
36
37
|
mainWindow.webContents.once('dom-ready', sendConfig)
|
|
37
38
|
|
|
39
|
+
mainWindow.on('close', () => app.quit())
|
|
40
|
+
|
|
38
41
|
watchFile(
|
|
39
42
|
`${cwd}/.bricks/build/application-config.json`,
|
|
40
43
|
{
|
package/tools/preview.ts
CHANGED
|
@@ -27,7 +27,7 @@ const compileDebounced = debounce(compile, 500)
|
|
|
27
27
|
|
|
28
28
|
const cwd = process.cwd()
|
|
29
29
|
|
|
30
|
-
watch(`${cwd}/subspaces`, { recursive: true }, async (event, filename) => {
|
|
30
|
+
const watcher = watch(`${cwd}/subspaces`, { recursive: true }, async (event, filename) => {
|
|
31
31
|
console.log(`Detected ${event} in ${filename}`)
|
|
32
32
|
compileDebounced()
|
|
33
33
|
})
|
|
@@ -35,3 +35,4 @@ watch(`${cwd}/subspaces`, { recursive: true }, async (event, filename) => {
|
|
|
35
35
|
const app = await Bun.file(`${cwd}/application.json`).json()
|
|
36
36
|
|
|
37
37
|
await $`BRICKS_STAGE=${app.stage || 'production'} bunx electron ${__dirname}/preview-main.mjs`
|
|
38
|
+
watcher.close()
|
package/types/bricks.ts
CHANGED
|
@@ -2052,6 +2052,7 @@ Default property:
|
|
|
2052
2052
|
| {
|
|
2053
2053
|
title?: string | DataLink
|
|
2054
2054
|
description?: string | DataLink
|
|
2055
|
+
hidden?: boolean | DataLink
|
|
2055
2056
|
brickId?: string | DataLink
|
|
2056
2057
|
brickIdPrefix?: string | DataLink
|
|
2057
2058
|
templateKey?: string | DataLink
|
|
@@ -2089,6 +2090,7 @@ Default property:
|
|
|
2089
2090
|
| {
|
|
2090
2091
|
title?: string | DataLink
|
|
2091
2092
|
description?: string | DataLink
|
|
2093
|
+
hidden?: boolean | DataLink
|
|
2092
2094
|
brickId?: string | DataLink
|
|
2093
2095
|
brickIdPrefix?: string | DataLink
|
|
2094
2096
|
templateKey?: string | DataLink
|
package/types/canvas.ts
CHANGED
package/types/data.ts
CHANGED
|
@@ -47,6 +47,7 @@ export type Data<T = any> = DataDef & {
|
|
|
47
47
|
min?: number
|
|
48
48
|
step?: number
|
|
49
49
|
}
|
|
50
|
+
| DataAssetKind
|
|
50
51
|
| {
|
|
51
52
|
type:
|
|
52
53
|
| 'color'
|
|
@@ -55,18 +56,28 @@ export type Data<T = any> = DataDef & {
|
|
|
55
56
|
| 'rich-text-content'
|
|
56
57
|
| 'sandbox-script'
|
|
57
58
|
| 'llm-prompt'
|
|
58
|
-
| 'media-resource-image'
|
|
59
|
-
| 'media-resource-video'
|
|
60
|
-
| 'media-resource-audio'
|
|
61
|
-
| 'media-resource-file'
|
|
62
|
-
| 'lottie-file-uri'
|
|
63
|
-
| 'ggml-model-asset'
|
|
64
|
-
| 'gguf-model-asset'
|
|
65
|
-
| 'binary-asset'
|
|
66
59
|
}
|
|
67
60
|
value: T
|
|
68
61
|
}
|
|
69
62
|
|
|
63
|
+
export type DataAssetKind = {
|
|
64
|
+
type:
|
|
65
|
+
| 'media-resource-image'
|
|
66
|
+
| 'media-resource-video'
|
|
67
|
+
| 'media-resource-audio'
|
|
68
|
+
| 'media-resource-file'
|
|
69
|
+
| 'lottie-file-uri'
|
|
70
|
+
| 'ggml-model-asset'
|
|
71
|
+
| 'gguf-model-asset'
|
|
72
|
+
| 'binary-asset'
|
|
73
|
+
preload?: {
|
|
74
|
+
type: 'url'
|
|
75
|
+
hashType: 'md5' | 'sha256'
|
|
76
|
+
hash: string
|
|
77
|
+
}
|
|
78
|
+
metadata?: { [key: string]: any }
|
|
79
|
+
}
|
|
80
|
+
|
|
70
81
|
export type DataLink = {
|
|
71
82
|
__typename: 'DataLink'
|
|
72
83
|
data: () => Data
|
package/types/subspace.ts
CHANGED
|
@@ -9,7 +9,14 @@ export type Subspace = {
|
|
|
9
9
|
id: string
|
|
10
10
|
title: string
|
|
11
11
|
description?: string
|
|
12
|
-
|
|
12
|
+
// Unexpanded information in Editor
|
|
13
|
+
unexpanded?: {
|
|
14
|
+
data?: boolean
|
|
15
|
+
dataCalculation?: boolean
|
|
16
|
+
brick?: boolean
|
|
17
|
+
generator?: boolean
|
|
18
|
+
canvas?: Array<Canvas>
|
|
19
|
+
}
|
|
13
20
|
module?: {
|
|
14
21
|
id: string
|
|
15
22
|
version: string
|
|
@@ -25,6 +32,7 @@ export type Subspace = {
|
|
|
25
32
|
version: string
|
|
26
33
|
}>
|
|
27
34
|
}
|
|
35
|
+
localSyncChangeCanvas?: LocalSyncStrategy
|
|
28
36
|
layout: {
|
|
29
37
|
width: number
|
|
30
38
|
height: number
|
package/utils/data.ts
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
|
-
import type { DataLink, Data } from '../types'
|
|
1
|
+
import type { DataLink, Data, Canvas } from '../types'
|
|
2
|
+
import { makeId } from './id'
|
|
2
3
|
|
|
3
4
|
export const linkData: (dataGetter: () => Data) => DataLink = (dataGetter) => ({
|
|
4
5
|
__typename: 'DataLink',
|
|
5
6
|
data: dataGetter,
|
|
6
7
|
})
|
|
7
8
|
|
|
9
|
+
const idOpts = {
|
|
10
|
+
snapshotMode: process.env.BRICKS_SNAPSHOT_MODE === '1',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const createCanvasIdRef: (canvasGetter: () => Canvas) => Data<string> = (canvasGetter) => {
|
|
14
|
+
const data: Data<string> = {
|
|
15
|
+
__typename: 'Data',
|
|
16
|
+
id: makeId('data', idOpts),
|
|
17
|
+
type: 'string',
|
|
18
|
+
routing: 'read-only',
|
|
19
|
+
kind: {
|
|
20
|
+
type: 'auto-generated-item-id',
|
|
21
|
+
idType: 'canvas',
|
|
22
|
+
},
|
|
23
|
+
title: '',
|
|
24
|
+
value: '',
|
|
25
|
+
}
|
|
26
|
+
setImmediate(() => {
|
|
27
|
+
const canvas = canvasGetter()
|
|
28
|
+
data.title = `Canvas ID: ${canvas.title}`
|
|
29
|
+
data.value = canvas.id
|
|
30
|
+
})
|
|
31
|
+
return data
|
|
32
|
+
}
|
|
33
|
+
|
|
8
34
|
type SystemDataName =
|
|
9
35
|
| 'isLocalSyncMainDevice'
|
|
10
36
|
| 'currentCanvasId'
|