@fugood/bricks-project 2.21.0 → 2.22.0-beta.0
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/action-name-map.ts +20 -0
- package/compile/index.ts +14 -2
- package/index.ts +1 -0
- package/package.json +2 -2
- package/types/bricks.ts +134 -746
- package/types/common.ts +5 -6
- package/types/generators.ts +340 -1683
- package/types/system.ts +169 -70
- package/utils/event-props.ts +733 -0
|
@@ -62,6 +62,26 @@ export const templateActionNameMap = {
|
|
|
62
62
|
height: 'TAKE_SCREENSHOT_HEIGHT',
|
|
63
63
|
saveProperty: 'TAKE_SCREENSHOT_SAVE_PROPERTY',
|
|
64
64
|
},
|
|
65
|
+
STORAGE_SET: {
|
|
66
|
+
storageType: 'STORAGE_TYPE',
|
|
67
|
+
storageScope: 'STORAGE_SCOPE',
|
|
68
|
+
storageKey: 'STORAGE_KEY',
|
|
69
|
+
storageValue: 'STORAGE_VALUE',
|
|
70
|
+
},
|
|
71
|
+
STORAGE_RETRIEVE: {
|
|
72
|
+
storageType: 'STORAGE_TYPE',
|
|
73
|
+
storageScope: 'STORAGE_SCOPE',
|
|
74
|
+
storageKey: 'STORAGE_KEY',
|
|
75
|
+
result: 'STORAGE_RETRIEVE_RESULT',
|
|
76
|
+
defaultValue: 'STORAGE_RETRIEVE_DEFAULT_VALUE',
|
|
77
|
+
skipIfNotFound: 'STORAGE_RETRIEVE_SKIP_IF_NOT_FOUND',
|
|
78
|
+
},
|
|
79
|
+
STORAGE_DELETE: {
|
|
80
|
+
storageType: 'STORAGE_TYPE',
|
|
81
|
+
storageScope: 'STORAGE_SCOPE',
|
|
82
|
+
storageKey: 'STORAGE_KEY',
|
|
83
|
+
all: 'STORAGE_DELETE_ALL',
|
|
84
|
+
},
|
|
65
85
|
CHANNEL_SUBSCRIBE: {
|
|
66
86
|
key: 'CHANNEL_SUBSCRIBE_KEY',
|
|
67
87
|
type: 'CHANNEL_SUBSCRIBE_TYPE',
|
package/compile/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { ExportNamedDeclaration, FunctionDeclaration } from 'acorn'
|
|
|
4
4
|
import escodegen from 'escodegen'
|
|
5
5
|
import { generateCalulationMap } from './util'
|
|
6
6
|
import { templateActionNameMap } from './action-name-map'
|
|
7
|
+
import { templateEventPropsMap } from '../utils/event-props'
|
|
7
8
|
import type {
|
|
8
9
|
Application,
|
|
9
10
|
Data,
|
|
@@ -52,6 +53,17 @@ const compileProperty = (property, errorReference: string, result = {}) => {
|
|
|
52
53
|
return property
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
const compileEventActionValue = (templateKey, eventKey, value, errorReference) => {
|
|
57
|
+
const tmplEventProperties = templateEventPropsMap[templateKey]
|
|
58
|
+
const props = tmplEventProperties?.[eventKey]
|
|
59
|
+
if (!props) return compileProperty(value, errorReference)
|
|
60
|
+
if (props.includes(value)) return value
|
|
61
|
+
if (value?.startsWith(templateKey)) {
|
|
62
|
+
console.warn(`[Warning] Value start with template key but there is no event property: ${value} ${errorReference}`)
|
|
63
|
+
}
|
|
64
|
+
return compileProperty(value, errorReference)
|
|
65
|
+
}
|
|
66
|
+
|
|
55
67
|
const convertOutletKey = (templateKey: string, key: string) => {
|
|
56
68
|
return `${templateKey}_${_.snakeCase(key).toUpperCase()}`
|
|
57
69
|
}
|
|
@@ -128,7 +140,7 @@ const compileEvents = (
|
|
|
128
140
|
? compileActionParam(handlerTemplateKey, action.__actionName, input)
|
|
129
141
|
: input,
|
|
130
142
|
[camelCase ? 'resultFromSender' : 'result_from_sender']:
|
|
131
|
-
mapping ||
|
|
143
|
+
mapping || compileEventActionValue(handlerTemplateKey, key, value, errorReference),
|
|
132
144
|
}
|
|
133
145
|
if (mapping) param[camelCase ? 'resultDataMapping' : 'result_data_mapping'] = true
|
|
134
146
|
parameterList.push(param)
|
|
@@ -140,7 +152,7 @@ const compileEvents = (
|
|
|
140
152
|
const param = {
|
|
141
153
|
[camelCase ? 'inputToReceiver' : 'input_to_receiver']: input().id,
|
|
142
154
|
[camelCase ? 'resultFromSender' : 'result_from_sender']:
|
|
143
|
-
mapping ||
|
|
155
|
+
mapping || compileEventActionValue(handlerTemplateKey, key, value, errorReference),
|
|
144
156
|
}
|
|
145
157
|
if (mapping) param[camelCase ? 'resultDataMapping' : 'result_data_mapping'] = true
|
|
146
158
|
parameterList.push(param)
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/bricks-project",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0-beta.0",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node scripts/build.js"
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
"lodash": "^4.17.4",
|
|
14
14
|
"uuid": "^8.3.1"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "43f9ee596a089c0e7fa511c0d9d25251cde09d5f"
|
|
17
17
|
}
|