@fugood/bricks-project 2.21.0-beta.17-1 → 2.21.0-beta.18-1
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 +5 -4
- package/compile/index.ts +10 -3
- package/package.json +1 -1
- package/types/bricks.ts +101 -10
- package/types/common.ts +12 -0
package/api/instance.ts
CHANGED
|
@@ -51,10 +51,11 @@ export const pullApp = async (stage: Stage, appId: string) => {
|
|
|
51
51
|
const app = data.application
|
|
52
52
|
if (!app) throw new Error('App not found')
|
|
53
53
|
if (app.lock.enabled) throw new Error('App is locked')
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
// TODO: Uncomment it on leaving experimental
|
|
55
|
+
// if (!app.dev_ref.is_dev)
|
|
56
|
+
// throw new Error(
|
|
57
|
+
// 'Currently BRICKS Project is experimental, please use the fork version of the app',
|
|
58
|
+
// )
|
|
58
59
|
return app
|
|
59
60
|
}
|
|
60
61
|
|
package/compile/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
Generator,
|
|
27
27
|
Canvas,
|
|
28
28
|
Subspace,
|
|
29
|
+
EventActionForItem,
|
|
29
30
|
} from '../types'
|
|
30
31
|
|
|
31
32
|
const compileProperty = (property, errorReference: string, result = {}) => {
|
|
@@ -91,7 +92,7 @@ const compileActionParam = (templateKey: string, actionName: string, paramName:
|
|
|
91
92
|
|
|
92
93
|
const compileEvents = (
|
|
93
94
|
templateKey: string,
|
|
94
|
-
eventMap: { [key: string]: Array<
|
|
95
|
+
eventMap: { [key: string]: Array<any> },
|
|
95
96
|
options = { camelCase: false, errorReference: '' },
|
|
96
97
|
) => {
|
|
97
98
|
const { camelCase, errorReference } = options
|
|
@@ -106,8 +107,14 @@ const compileEvents = (
|
|
|
106
107
|
else handlerKey = handler.toUpperCase()
|
|
107
108
|
if (handlerKey === 'SYSTEM') handlerTemplateKey = 'SYSTEM'
|
|
108
109
|
} else if (typeof handler === 'function') {
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
let instance = handler()
|
|
111
|
+
if (instance?.id) {
|
|
112
|
+
instance = instance as { id: string }
|
|
113
|
+
handlerKey = instance?.id
|
|
114
|
+
} else if (instance?.brickId) {
|
|
115
|
+
instance = instance as { brickId: string; templateKey: string }
|
|
116
|
+
handlerKey = instance.brickId
|
|
117
|
+
}
|
|
111
118
|
handlerTemplateKey = instance?.templateKey
|
|
112
119
|
}
|
|
113
120
|
if (!handlerKey) throw new Error(`Invalid handler: ${handler} ${errorReference}`)
|
package/package.json
CHANGED
package/types/bricks.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
|
|
2
2
|
import type { Data, DataLink } from './data'
|
|
3
3
|
import type { Animation, AnimationBasicEvents } from './animation'
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
Brick,
|
|
6
|
+
EventAction,
|
|
7
|
+
EventActionForItem,
|
|
8
|
+
ActionWithDataParams,
|
|
9
|
+
ActionWithParams,
|
|
10
|
+
Action,
|
|
11
|
+
} from './common'
|
|
5
12
|
|
|
6
13
|
interface BrickBasicProperty {
|
|
7
14
|
/* The brick opacity (0 ~ 1) */
|
|
@@ -62,6 +69,12 @@ interface BrickBasicEvents {
|
|
|
62
69
|
standby?: Array<EventAction>
|
|
63
70
|
}
|
|
64
71
|
|
|
72
|
+
interface BrickBasicEventsForItem {
|
|
73
|
+
showStart?: Array<EventActionForItem>
|
|
74
|
+
switchUpdate?: Array<EventActionForItem>
|
|
75
|
+
standby?: Array<EventActionForItem>
|
|
76
|
+
}
|
|
77
|
+
|
|
65
78
|
interface BrickRectDef {
|
|
66
79
|
/*
|
|
67
80
|
Default property:
|
|
@@ -2080,7 +2093,46 @@ Default property:
|
|
|
2080
2093
|
standbyOpacity?: number | DataLink
|
|
2081
2094
|
standbyDelay?: number | DataLink
|
|
2082
2095
|
standbyDelayRandom?: number | DataLink
|
|
2083
|
-
standbyEasing?:
|
|
2096
|
+
standbyEasing?:
|
|
2097
|
+
| DataLink
|
|
2098
|
+
| {
|
|
2099
|
+
default?:
|
|
2100
|
+
| DataLink
|
|
2101
|
+
| {
|
|
2102
|
+
method?: string | DataLink
|
|
2103
|
+
duration?: number | DataLink
|
|
2104
|
+
}
|
|
2105
|
+
x?:
|
|
2106
|
+
| DataLink
|
|
2107
|
+
| {
|
|
2108
|
+
method?: string | DataLink
|
|
2109
|
+
duration?: number | DataLink
|
|
2110
|
+
}
|
|
2111
|
+
y?:
|
|
2112
|
+
| DataLink
|
|
2113
|
+
| {
|
|
2114
|
+
method?: string | DataLink
|
|
2115
|
+
duration?: number | DataLink
|
|
2116
|
+
}
|
|
2117
|
+
width?:
|
|
2118
|
+
| DataLink
|
|
2119
|
+
| {
|
|
2120
|
+
method?: string | DataLink
|
|
2121
|
+
duration?: number | DataLink
|
|
2122
|
+
}
|
|
2123
|
+
height?:
|
|
2124
|
+
| DataLink
|
|
2125
|
+
| {
|
|
2126
|
+
method?: string | DataLink
|
|
2127
|
+
duration?: number | DataLink
|
|
2128
|
+
}
|
|
2129
|
+
opacity?:
|
|
2130
|
+
| DataLink
|
|
2131
|
+
| {
|
|
2132
|
+
method?: string | DataLink
|
|
2133
|
+
duration?: number | DataLink
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2084
2136
|
showingDelay?: number | DataLink
|
|
2085
2137
|
renderOutOfViewport?: boolean | DataLink
|
|
2086
2138
|
}
|
|
@@ -2118,7 +2170,46 @@ Default property:
|
|
|
2118
2170
|
standbyOpacity?: number | DataLink
|
|
2119
2171
|
standbyDelay?: number | DataLink
|
|
2120
2172
|
standbyDelayRandom?: number | DataLink
|
|
2121
|
-
standbyEasing?:
|
|
2173
|
+
standbyEasing?:
|
|
2174
|
+
| DataLink
|
|
2175
|
+
| {
|
|
2176
|
+
default?:
|
|
2177
|
+
| DataLink
|
|
2178
|
+
| {
|
|
2179
|
+
method?: string | DataLink
|
|
2180
|
+
duration?: number | DataLink
|
|
2181
|
+
}
|
|
2182
|
+
x?:
|
|
2183
|
+
| DataLink
|
|
2184
|
+
| {
|
|
2185
|
+
method?: string | DataLink
|
|
2186
|
+
duration?: number | DataLink
|
|
2187
|
+
}
|
|
2188
|
+
y?:
|
|
2189
|
+
| DataLink
|
|
2190
|
+
| {
|
|
2191
|
+
method?: string | DataLink
|
|
2192
|
+
duration?: number | DataLink
|
|
2193
|
+
}
|
|
2194
|
+
width?:
|
|
2195
|
+
| DataLink
|
|
2196
|
+
| {
|
|
2197
|
+
method?: string | DataLink
|
|
2198
|
+
duration?: number | DataLink
|
|
2199
|
+
}
|
|
2200
|
+
height?:
|
|
2201
|
+
| DataLink
|
|
2202
|
+
| {
|
|
2203
|
+
method?: string | DataLink
|
|
2204
|
+
duration?: number | DataLink
|
|
2205
|
+
}
|
|
2206
|
+
opacity?:
|
|
2207
|
+
| DataLink
|
|
2208
|
+
| {
|
|
2209
|
+
method?: string | DataLink
|
|
2210
|
+
duration?: number | DataLink
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2122
2213
|
showingDelay?: number | DataLink
|
|
2123
2214
|
renderOutOfViewport?: boolean | DataLink
|
|
2124
2215
|
}
|
|
@@ -2127,10 +2218,10 @@ Default property:
|
|
|
2127
2218
|
}
|
|
2128
2219
|
>
|
|
2129
2220
|
| DataLink
|
|
2130
|
-
events?:
|
|
2221
|
+
events?: BrickBasicEventsForItem & {
|
|
2131
2222
|
/* Event on page render finished */
|
|
2132
2223
|
onPageRender?: Array<
|
|
2133
|
-
|
|
2224
|
+
EventActionForItem & {
|
|
2134
2225
|
eventPropertyMapping?: {
|
|
2135
2226
|
pageIndex: {
|
|
2136
2227
|
type: 'number'
|
|
@@ -2145,7 +2236,7 @@ Default property:
|
|
|
2145
2236
|
>
|
|
2146
2237
|
/* Event on page change. */
|
|
2147
2238
|
onPageChange?: Array<
|
|
2148
|
-
|
|
2239
|
+
EventActionForItem & {
|
|
2149
2240
|
eventPropertyMapping?: {
|
|
2150
2241
|
pageIndex: {
|
|
2151
2242
|
type: 'number'
|
|
@@ -2160,7 +2251,7 @@ Default property:
|
|
|
2160
2251
|
>
|
|
2161
2252
|
/* Event on page index out of bound. */
|
|
2162
2253
|
onPageOutOfBound?: Array<
|
|
2163
|
-
|
|
2254
|
+
EventActionForItem & {
|
|
2164
2255
|
eventPropertyMapping?: {
|
|
2165
2256
|
pageIndex: {
|
|
2166
2257
|
type: 'number'
|
|
@@ -2175,7 +2266,7 @@ Default property:
|
|
|
2175
2266
|
>
|
|
2176
2267
|
/* Event on into `detail` mode */
|
|
2177
2268
|
onIntoDetailMode?: Array<
|
|
2178
|
-
|
|
2269
|
+
EventActionForItem & {
|
|
2179
2270
|
eventPropertyMapping?: {
|
|
2180
2271
|
pageIndex: {
|
|
2181
2272
|
type: 'number'
|
|
@@ -2194,7 +2285,7 @@ Default property:
|
|
|
2194
2285
|
>
|
|
2195
2286
|
/* Event on into `list` mode. */
|
|
2196
2287
|
onIntoListMode?: Array<
|
|
2197
|
-
|
|
2288
|
+
EventActionForItem & {
|
|
2198
2289
|
eventPropertyMapping?: {
|
|
2199
2290
|
pageIndex: {
|
|
2200
2291
|
type: 'number'
|
|
@@ -2209,7 +2300,7 @@ Default property:
|
|
|
2209
2300
|
>
|
|
2210
2301
|
/* Event on render error */
|
|
2211
2302
|
onError?: Array<
|
|
2212
|
-
|
|
2303
|
+
EventActionForItem & {
|
|
2213
2304
|
eventPropertyMapping?: {
|
|
2214
2305
|
errorMessage: {
|
|
2215
2306
|
type: 'string'
|
package/types/common.ts
CHANGED
|
@@ -68,6 +68,18 @@ export type EventAction = {
|
|
|
68
68
|
eventPropertyMapping?: object
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
export type EventActionForItem = {
|
|
72
|
+
handler:
|
|
73
|
+
| 'system'
|
|
74
|
+
| (() => Brick | Generator | { brickId: string; templateKey: string })
|
|
75
|
+
| SubspaceID
|
|
76
|
+
| ItemBrickID
|
|
77
|
+
action: Action
|
|
78
|
+
waitAsync?: boolean
|
|
79
|
+
// Event Property Definition mapping to params (use path to replace)
|
|
80
|
+
eventPropertyMapping?: object
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
export type ApplicationFont = {
|
|
72
84
|
name: string
|
|
73
85
|
url: string
|