@fugood/bricks-project 2.21.0-beta.14.test7 → 2.21.0-beta.14.test9

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/api/instance.ts CHANGED
@@ -6,7 +6,7 @@ const apiUrlMap = {
6
6
 
7
7
  const workspaceToken = process.env.BRICKS_WORKSPACE_TOKEN
8
8
 
9
- type Stage = 'production' | 'beta' | 'dev'
9
+ type Stage = 'production' | 'beta' | 'development'
10
10
 
11
11
  const doGQL = async (stage: Stage, query: string, variables: Record<string, any>) => {
12
12
  if (!workspaceToken) throw new Error('env BRICKS_WORKSPACE_TOKEN is not set')
package/compile/index.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import _ from 'lodash'
2
- import { parse as parseAST, ExportNamedDeclaration, FunctionDeclaration } from 'acorn'
2
+ import { parse as parseAST } from 'acorn'
3
+ import type { ExportNamedDeclaration, FunctionDeclaration } from 'acorn'
3
4
  import escodegen from 'escodegen'
4
- import {
5
+ import { generateCalulationMap } from './util'
6
+ import { templateActionNameMap } from './action-name-map'
7
+ import type {
5
8
  Application,
6
9
  Data,
7
10
  Animation,
@@ -23,8 +26,6 @@ import {
23
26
  Canvas,
24
27
  Subspace,
25
28
  } from '../types'
26
- import { generateCalulationMap } from './util'
27
- import { templateActionNameMap } from './action-name-map'
28
29
 
29
30
  const compileProperty = (property, result = {}) => {
30
31
  if (Array.isArray(property)) {
@@ -295,17 +296,23 @@ export const compile = (app: Application) => {
295
296
  eventMap: compileEvents(itemBrick.templateKey, itemBrick.eventMap || {}, {
296
297
  camelCase: true,
297
298
  }),
298
- stateGroup: itemBrick.stateGroup.map((stateGroup) => ({
299
- ...stateGroup,
300
- animation: compileAnimations(itemBrick.templateKey, stateGroup.animation || {}),
301
- commented: stateGroup.disabled,
302
- conds: compileSwitchConds(itemBrick.templateKey, stateGroup.conds || []),
303
- property: compileProperty(stateGroup.property),
304
- outlet: compileOutlets(itemBrick.templateKey, stateGroup.outlets || {}),
305
- eventMap: compileEvents(itemBrick.templateKey, stateGroup.eventMap || {}, {
306
- camelCase: true,
307
- }),
308
- })),
299
+ stateGroup: itemBrick.stateGroup.reduce((acc, stateGroup) => {
300
+ acc[stateGroup.id] = {
301
+ title: stateGroup.title,
302
+ description: stateGroup.description,
303
+ override: stateGroup.override,
304
+ break: stateGroup.break,
305
+ commented: stateGroup.disabled,
306
+ conds: compileSwitchConds(itemBrick.templateKey, stateGroup.conds || []),
307
+ property: compileProperty(stateGroup.property),
308
+ animation: compileAnimations(itemBrick.templateKey, stateGroup.animation || {}),
309
+ outlet: compileOutlets(itemBrick.templateKey, stateGroup.outlets || {}),
310
+ eventMap: compileEvents(itemBrick.templateKey, stateGroup.eventMap || {}, {
311
+ camelCase: true,
312
+ }),
313
+ }
314
+ return acc
315
+ }, {}),
309
316
  })
310
317
  if (Array.isArray(brickItems.brickList)) {
311
318
  const brickList = (brickItems.brickList || []).map(buildList)
@@ -592,7 +599,7 @@ export const compile = (app: Application) => {
592
599
  map[dataCalc.id] = calc
593
600
  return map
594
601
  }, {}),
595
- action_map: subspace.actions || {},
602
+ action_map: subspace.actions || undefined,
596
603
  event_map: compileEvents('', subspace.events || {}),
597
604
  routing: subspace.dataRouting.reduce((acc, data) => {
598
605
  acc[data.id] = { enabled_routing: true }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fugood/bricks-project",
3
- "version": "2.21.0-beta.14.test7",
3
+ "version": "2.21.0-beta.14.test9",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "build": "node scripts/build.js"
package/types/bricks.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
2
- import { Data, DataLink } from './data'
3
- import { Animation, AnimationBasicEvents } from './animation'
4
- import { Brick, EventAction, ActionWithDataParams, ActionWithParams, Action } from './common'
1
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
2
+ import type { Data, DataLink } from './data'
3
+ import type { Animation, AnimationBasicEvents } from './animation'
4
+ import type { Brick, EventAction, ActionWithDataParams, ActionWithParams, Action } from './common'
5
5
 
6
6
  interface BrickBasicProperty {
7
7
  /* The brick opacity (0 ~ 1) */
package/types/common.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { SwitchDef } from './switch'
2
- import { Data } from './data'
3
- import { Subspace } from './subspace'
1
+ import type { SwitchDef } from './switch'
2
+ import type { Data } from './data'
3
+ import type { Subspace } from './subspace'
4
4
 
5
5
  export interface Brick {
6
6
  __typename: 'Brick'
package/types/subspace.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Brick, Generator, LocalSyncStrategy, EventAction, SubspaceID } from './common'
2
- import { Animation } from './animation'
3
- import { Canvas } from './canvas'
4
- import { Data } from './data'
5
- import { DataCalculation } from './data-calc'
1
+ import type { Brick, Generator, LocalSyncStrategy, EventAction, SubspaceID } from './common'
2
+ import type { Animation } from './animation'
3
+ import type { Canvas } from './canvas'
4
+ import type { Data } from './data'
5
+ import type { DataCalculation } from './data-calc'
6
6
 
7
7
  export type Subspace = {
8
8
  __typename: 'Subspace'
package/types/switch.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Canvas } from './canvas'
2
- import { Data } from './data'
1
+ import type { Canvas } from './canvas'
2
+ import type { Data } from './data'
3
3
  export type SwitchCondInnerStateCurrentCanvas = {
4
4
  __typename: 'SwitchCondInnerStateCurrentCanvas'
5
5
  value: () => Canvas