@fugood/bricks-project 2.24.0-beta.28 → 2.24.0-beta.30
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 +26 -20
- package/compile/util.ts +2 -0
- package/package.json +2 -2
- package/types/subspace.ts +2 -0
package/compile/index.ts
CHANGED
|
@@ -91,6 +91,25 @@ const compileProperty = (property, errorReference: string, result = {}) => {
|
|
|
91
91
|
return property
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
const compileScriptCalculationCode = (code = '') => {
|
|
95
|
+
try {
|
|
96
|
+
const program = parseAST(code, { sourceType: 'module', ecmaVersion: 2020 })
|
|
97
|
+
// export function main() { ... }
|
|
98
|
+
const declarationBody = (
|
|
99
|
+
(program.body[0] as ExportNamedDeclaration).declaration as FunctionDeclaration
|
|
100
|
+
)?.body
|
|
101
|
+
return escodegen.generate(declarationBody, {
|
|
102
|
+
format: {
|
|
103
|
+
indent: { style: ' ' },
|
|
104
|
+
semicolons: false,
|
|
105
|
+
},
|
|
106
|
+
comment: true,
|
|
107
|
+
})
|
|
108
|
+
} catch {
|
|
109
|
+
return code || ''
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
94
113
|
const compileEventActionValue = (templateKey, eventKey, value, errorReference) => {
|
|
95
114
|
const tmplEventProperties = templateEventPropsMap[templateKey]
|
|
96
115
|
const props = tmplEventProperties?.[eventKey]
|
|
@@ -524,6 +543,8 @@ export const compile = async (app: Application) => {
|
|
|
524
543
|
title: subspace.title,
|
|
525
544
|
description: subspace.description,
|
|
526
545
|
hide_short_ref: subspace.hideShortRef,
|
|
546
|
+
unused: subspace.unused,
|
|
547
|
+
portal: subspace.portal,
|
|
527
548
|
_expanded: subspace.unexpanded
|
|
528
549
|
? {
|
|
529
550
|
brick: !subspace.unexpanded.brick,
|
|
@@ -1105,25 +1126,10 @@ export const compile = async (app: Application) => {
|
|
|
1105
1126
|
const scriptCalc = dataCalc as DataCalculationScript
|
|
1106
1127
|
calc.type = 'script'
|
|
1107
1128
|
|
|
1108
|
-
|
|
1109
|
-
try {
|
|
1110
|
-
const program = parseAST(scriptCalc.code, { sourceType: 'module', ecmaVersion: 2020 })
|
|
1111
|
-
// export function main() { ... }
|
|
1112
|
-
const declarationBody = (
|
|
1113
|
-
(program.body[0] as ExportNamedDeclaration).declaration as FunctionDeclaration
|
|
1114
|
-
)?.body
|
|
1115
|
-
code = escodegen.generate(declarationBody, {
|
|
1116
|
-
format: {
|
|
1117
|
-
indent: { style: ' ' },
|
|
1118
|
-
semicolons: false,
|
|
1119
|
-
},
|
|
1120
|
-
comment: true,
|
|
1121
|
-
})
|
|
1122
|
-
} catch {
|
|
1123
|
-
code = scriptCalc.code || ''
|
|
1124
|
-
}
|
|
1129
|
+
const code = compileScriptCalculationCode(scriptCalc.code)
|
|
1125
1130
|
calc.script_config = {
|
|
1126
|
-
|
|
1131
|
+
title: scriptCalc.title ?? '',
|
|
1132
|
+
note: scriptCalc.note ?? '',
|
|
1127
1133
|
code,
|
|
1128
1134
|
enable_async: scriptCalc.enableAsync,
|
|
1129
1135
|
trigger_mode: scriptCalc.triggerMode,
|
|
@@ -1151,7 +1157,7 @@ export const compile = async (app: Application) => {
|
|
|
1151
1157
|
'PROPERTY_BANK_DATA_NODE',
|
|
1152
1158
|
`(data calc: ${dataCalcId}, script output, subspace: ${subspaceId})`,
|
|
1153
1159
|
)
|
|
1154
|
-
:
|
|
1160
|
+
: null,
|
|
1155
1161
|
outputs: scriptCalc.outputs.reduce((acc, output) => {
|
|
1156
1162
|
if (!acc[output.key]) acc[output.key] = []
|
|
1157
1163
|
const outputId = assertEntryId(
|
|
@@ -1168,7 +1174,7 @@ export const compile = async (app: Application) => {
|
|
|
1168
1174
|
'PROPERTY_BANK_DATA_NODE',
|
|
1169
1175
|
`(data calc: ${dataCalcId}, script error output, subspace: ${subspaceId})`,
|
|
1170
1176
|
)
|
|
1171
|
-
:
|
|
1177
|
+
: null,
|
|
1172
1178
|
}
|
|
1173
1179
|
|
|
1174
1180
|
Object.assign(
|
package/compile/util.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/bricks-project",
|
|
3
|
-
"version": "2.24.0-beta.
|
|
3
|
+
"version": "2.24.0-beta.30",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"typecheck": "tsc --noEmit",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"oxfmt": "^0.36.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "6474b26f34cfe28cc399208005384ee39cbb3b5a"
|
|
28
28
|
}
|
package/types/subspace.ts
CHANGED