dazscript-framework 0.1.15 → 0.1.17

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.
Files changed (82) hide show
  1. package/README.md +365 -93
  2. package/babel.config.js +33 -33
  3. package/dist/babel/trace-babel-plugin.js +243 -243
  4. package/dist/babel/trace-log-babel-plugin.js +164 -164
  5. package/dist/scripts/install-generator.js +185 -185
  6. package/package.json +72 -70
  7. package/src/common/dz-dump.ts +120 -120
  8. package/src/common/log.ts +56 -56
  9. package/src/common/trace.ts +26 -26
  10. package/src/core/action-decorator.ts +15 -15
  11. package/src/core/base-script.ts +30 -30
  12. package/src/core/custom-action.ts +11 -11
  13. package/src/core/global.ts +4 -4
  14. package/src/dialog/basic-dialog.ts +40 -32
  15. package/src/dialog/builders/button-builder.ts +52 -52
  16. package/src/dialog/builders/checkbox-builder.ts +29 -29
  17. package/src/dialog/builders/color-picker-builder.ts +35 -35
  18. package/src/dialog/builders/combo-box-builder.ts +38 -35
  19. package/src/dialog/builders/combo-edit-builder.ts +35 -35
  20. package/src/dialog/builders/dialog-builder.ts +49 -49
  21. package/src/dialog/builders/groupbox-builder.ts +121 -82
  22. package/src/dialog/builders/label-builder.ts +33 -28
  23. package/src/dialog/builders/layout-builder.ts +59 -59
  24. package/src/dialog/builders/line-edit-builder.ts +124 -119
  25. package/src/dialog/builders/list-box-builder.ts +103 -0
  26. package/src/dialog/builders/list-view-builder.ts +396 -328
  27. package/src/dialog/builders/node-selection-builder.ts +55 -55
  28. package/src/dialog/builders/path-combo-box-builder.ts +24 -24
  29. package/src/dialog/builders/popup-menu-builder.ts +46 -46
  30. package/src/dialog/builders/radio-builder.ts +42 -42
  31. package/src/dialog/builders/slider-builder.ts +39 -22
  32. package/src/dialog/builders/splitter-builder.ts +88 -88
  33. package/src/dialog/builders/tab-builder.ts +120 -106
  34. package/src/dialog/builders/widget-builder.ts +136 -124
  35. package/src/dialog/builders/widgets-builder.ts +140 -135
  36. package/src/dialog/input-dialog.ts +30 -27
  37. package/src/dialog/input-validator.ts +8 -8
  38. package/src/dialog/selection-dialog.ts +47 -0
  39. package/src/dialog/shared.ts +8 -8
  40. package/src/helpers/action-helper.ts +214 -81
  41. package/src/helpers/array-helper.ts +170 -145
  42. package/src/helpers/camera-helper.ts +12 -12
  43. package/src/helpers/custom-action-helper.ts +176 -176
  44. package/src/helpers/directory-helper.ts +14 -0
  45. package/src/helpers/file-helper.ts +90 -90
  46. package/src/helpers/http-helper.ts +190 -0
  47. package/src/helpers/input-helper.ts +18 -18
  48. package/src/helpers/list-view-helper.ts +105 -89
  49. package/src/helpers/menu-helper.ts +28 -28
  50. package/src/helpers/message-box-helper.ts +25 -15
  51. package/src/helpers/node-helper.ts +461 -236
  52. package/src/helpers/number-helper.ts +10 -10
  53. package/src/helpers/numeric-property-helper.ts +91 -91
  54. package/src/helpers/object-helper.ts +2 -2
  55. package/src/helpers/pane-helper.ts +28 -20
  56. package/src/helpers/progress-helper.ts +51 -33
  57. package/src/helpers/property-helper.ts +61 -52
  58. package/src/helpers/record-helper.ts +16 -16
  59. package/src/helpers/scene-helper.ts +144 -94
  60. package/src/helpers/script-helper.ts +15 -15
  61. package/src/helpers/skeleton-helper.ts +26 -26
  62. package/src/helpers/splitter-helper.ts +8 -8
  63. package/src/helpers/string-helper.ts +39 -31
  64. package/src/helpers/surface-helper.ts +5 -5
  65. package/src/helpers/undo-helper.ts +8 -8
  66. package/src/helpers/viewport-helper.ts +21 -8
  67. package/src/lib/delayed.ts +38 -38
  68. package/src/lib/dictionary.ts +3 -0
  69. package/src/lib/frame-keys.ts +67 -67
  70. package/src/lib/guid.ts +2 -2
  71. package/src/lib/menu-item.ts +10 -9
  72. package/src/lib/observable.ts +147 -94
  73. package/src/lib/set.ts +50 -25
  74. package/src/lib/settings.ts +112 -104
  75. package/src/lib/tree-node.ts +149 -145
  76. package/src/samples/config.ts +2 -2
  77. package/src/samples/hello-world.dsa.ts +12 -12
  78. package/src/samples/sample-dialog.dsa.ts +51 -51
  79. package/src/samples/sample-dialog.ts +48 -48
  80. package/src/shared/set-keyboard-shortcut.ts +146 -102
  81. package/tsconfig.json +116 -116
  82. package/webpack.config.js +70 -70
@@ -1,243 +1,243 @@
1
- const t = require('@babel/types');
2
- const path = require('path');
3
- let globalEnable = true;
4
- let enabled = false;
5
-
6
- function isTraceDecorator(node) {
7
- return false; // Your existing isTraceDecorator logic
8
- }
9
-
10
- function isTraceComment(node) {
11
- return false; // Your existing isTraceComment logic
12
- }
13
-
14
- function createConsoleLogStatement(
15
- location,
16
- filename,
17
- lineNumber,
18
- functionName,
19
- parameters
20
- ) {
21
- const filenameWithoutPath = path.basename(filename);
22
- let logMessage = `[TRACE] ${location}: ${filenameWithoutPath}(${lineNumber}): ${functionName}`;
23
-
24
- if (parameters.length > 0) {
25
- logMessage += `(${parameters.join(', ')})`;
26
- } else {
27
- logMessage += '()';
28
- }
29
-
30
- return t.blockStatement([
31
- t.expressionStatement(
32
- t.callExpression(
33
- t.memberExpression(t.identifier('App'), t.identifier('debug')),
34
- [t.stringLiteral(logMessage)]
35
- )
36
- ),
37
- t.expressionStatement(
38
- t.callExpression(
39
- t.memberExpression(t.identifier('App'), t.identifier('flushLogBuffer')),
40
- []
41
- )
42
- ),
43
- ]);
44
- }
45
-
46
- function processFunction(enabled, path, state) {
47
- const filename = state.file.opts.filename || 'unknown';
48
- const lineNumber = path.node.loc?.start?.line || 'unknown';
49
- const functionName = path.node.id ? path.node.id.name : 'anonymous';
50
- const parameters = path.node.params.map((param) => param.name);
51
-
52
- if (!enabled || functionName === 'anonymous' || lineNumber === 'unknown')
53
- return;
54
-
55
- const enteringLogStatement = createConsoleLogStatement(
56
- 'Entering',
57
- filename,
58
- lineNumber,
59
- functionName,
60
- parameters
61
- );
62
- const exitingLogStatement = createConsoleLogStatement(
63
- 'Exiting',
64
- filename,
65
- lineNumber,
66
- functionName,
67
- parameters
68
- );
69
-
70
- // Process the return statements within the function body
71
- path.get('body').traverse({
72
- ReturnStatement(returnPath) {
73
- returnPath.insertBefore(exitingLogStatement);
74
- },
75
- });
76
-
77
- if (enteringLogStatement) {
78
- if (t.isBlockStatement(path.node.body)) {
79
- path.node.body.body.unshift(enteringLogStatement);
80
- } else {
81
- path.node.body = t.blockStatement([enteringLogStatement, path.node.body]);
82
- }
83
- }
84
- }
85
-
86
- function processAssignmentExpression(path, state) {
87
- const filename = state.file.opts.filename || 'unknown';
88
- const lineNumber = path.node.loc?.start?.line || 'unknown';
89
- let functionName = 'anonymous'; // Default value for function name
90
- const parameters = [];
91
-
92
- if (!enabled || lineNumber === 'unknown') return;
93
-
94
- if (t.isMemberExpression(path.node.left)) {
95
- functionName = path.node.left.property.name;
96
- }
97
-
98
- const enteringLogStatement = createConsoleLogStatement(
99
- 'Entering',
100
- filename,
101
- lineNumber,
102
- functionName,
103
- parameters
104
- );
105
- const exitingLogStatement = createConsoleLogStatement(
106
- 'Exiting',
107
- filename,
108
- lineNumber,
109
- functionName,
110
- parameters
111
- );
112
-
113
- // Process the return statements within the function body
114
- path.get('right').traverse({
115
- ReturnStatement(returnPath) {
116
- returnPath.insertBefore(exitingLogStatement);
117
- },
118
- });
119
-
120
- if (
121
- t.isFunctionExpression(path.node.right) ||
122
- t.isArrowFunctionExpression(path.node.right)
123
- ) {
124
- // Handle the case where the right-hand side is a function expression or arrow function expression
125
- if (t.isBlockStatement(path.node.right.body)) {
126
- path.node.right.body.body.unshift(enteringLogStatement);
127
- path.node.right.body.body.push(exitingLogStatement);
128
- } else {
129
- path.node.right.body = t.blockStatement([
130
- enteringLogStatement,
131
- t.returnStatement(path.node.right.body),
132
- exitingLogStatement,
133
- ]);
134
- }
135
- }
136
- }
137
-
138
- function processVariableDeclaration(path, state) {
139
- const filename = state.file.opts.filename || 'unknown';
140
- const lineNumber = path.node.loc?.start?.line || 'unknown';
141
-
142
- path.node.declarations.forEach((declarator) => {
143
- if (
144
- t.isFunctionExpression(declarator.init) ||
145
- t.isArrowFunctionExpression(declarator.init)
146
- ) {
147
- const functionName = declarator.id.name;
148
- const parameters = declarator.init.params.map((param) => param.name);
149
-
150
- if (!enabled || lineNumber === 'unknown') return;
151
-
152
- const enteringLogStatement = createConsoleLogStatement(
153
- 'Entering',
154
- filename,
155
- lineNumber,
156
- functionName,
157
- parameters
158
- );
159
- const exitingLogStatement = createConsoleLogStatement(
160
- 'Exiting',
161
- filename,
162
- lineNumber,
163
- functionName,
164
- parameters
165
- );
166
-
167
- // Ensure the Exiting statement is added to the end of the function body
168
- if (t.isBlockStatement(declarator.init.body)) {
169
- declarator.init.body.body.push(exitingLogStatement);
170
- } else {
171
- declarator.init.body = t.blockStatement([
172
- declarator.init.body,
173
- exitingLogStatement,
174
- ]);
175
- }
176
-
177
- // Process the return statements within the function body
178
- declarator.init.body.body.forEach((statement, index) => {
179
- if (t.isReturnStatement(statement)) {
180
- // Add Exiting statement before the return statement
181
- declarator.init.body.body.splice(index, 0, exitingLogStatement);
182
- }
183
- });
184
-
185
- // Add the Entering statement at the beginning of the function body
186
- if (t.isBlockStatement(declarator.init.body)) {
187
- declarator.init.body.body.unshift(enteringLogStatement);
188
- } else {
189
- declarator.init.body = t.blockStatement([
190
- enteringLogStatement,
191
- t.returnStatement(declarator.init.body),
192
- ]);
193
- }
194
- }
195
- });
196
- }
197
-
198
- module.exports = function () {
199
- let declarationFound = false;
200
-
201
- return {
202
- pre() {
203
- if (this.opts && typeof this.opts.default === 'boolean') {
204
- enabled = globalEnable = this.opts.default;
205
- }
206
- enabled = globalEnable;
207
- declarationFound = false;
208
- },
209
- visitor: {
210
- VariableDeclaration(path, state) {
211
- const declarations = path.node.declarations;
212
- const traceDeclaration = declarations.find(
213
- (declaration) => declaration.id.name === 'TRACE'
214
- );
215
-
216
- if (!declarationFound) {
217
- if (traceDeclaration) {
218
- enabled = traceDeclaration.init
219
- ? traceDeclaration.init.value
220
- : false;
221
- declarationFound = true;
222
- } else {
223
- enabled = globalEnable;
224
- }
225
- }
226
-
227
- processVariableDeclaration(path, state);
228
- },
229
- FunctionDeclaration(path, state) {
230
- //processFunction(path, state);
231
- },
232
- FunctionExpression(path, state) {
233
- processFunction(enabled, path, state);
234
- },
235
- ArrowFunctionExpression(path, state) {
236
- //processFunction(path, state);
237
- },
238
- AssignmentExpression(path, state) {
239
- processAssignmentExpression(path, state);
240
- },
241
- },
242
- };
243
- };
1
+ const t = require('@babel/types');
2
+ const path = require('path');
3
+ let globalEnable = true;
4
+ let enabled = false;
5
+
6
+ function isTraceDecorator(node) {
7
+ return false; // Your existing isTraceDecorator logic
8
+ }
9
+
10
+ function isTraceComment(node) {
11
+ return false; // Your existing isTraceComment logic
12
+ }
13
+
14
+ function createConsoleLogStatement(
15
+ location,
16
+ filename,
17
+ lineNumber,
18
+ functionName,
19
+ parameters
20
+ ) {
21
+ const filenameWithoutPath = path.basename(filename);
22
+ let logMessage = `[TRACE] ${location}: ${filenameWithoutPath}(${lineNumber}): ${functionName}`;
23
+
24
+ if (parameters.length > 0) {
25
+ logMessage += `(${parameters.join(', ')})`;
26
+ } else {
27
+ logMessage += '()';
28
+ }
29
+
30
+ return t.blockStatement([
31
+ t.expressionStatement(
32
+ t.callExpression(
33
+ t.memberExpression(t.identifier('App'), t.identifier('debug')),
34
+ [t.stringLiteral(logMessage)]
35
+ )
36
+ ),
37
+ t.expressionStatement(
38
+ t.callExpression(
39
+ t.memberExpression(t.identifier('App'), t.identifier('flushLogBuffer')),
40
+ []
41
+ )
42
+ ),
43
+ ]);
44
+ }
45
+
46
+ function processFunction(enabled, path, state) {
47
+ const filename = state.file.opts.filename || 'unknown';
48
+ const lineNumber = path.node.loc?.start?.line || 'unknown';
49
+ const functionName = path.node.id ? path.node.id.name : 'anonymous';
50
+ const parameters = path.node.params.map((param) => param.name);
51
+
52
+ if (!enabled || functionName === 'anonymous' || lineNumber === 'unknown')
53
+ return;
54
+
55
+ const enteringLogStatement = createConsoleLogStatement(
56
+ 'Entering',
57
+ filename,
58
+ lineNumber,
59
+ functionName,
60
+ parameters
61
+ );
62
+ const exitingLogStatement = createConsoleLogStatement(
63
+ 'Exiting',
64
+ filename,
65
+ lineNumber,
66
+ functionName,
67
+ parameters
68
+ );
69
+
70
+ // Process the return statements within the function body
71
+ path.get('body').traverse({
72
+ ReturnStatement(returnPath) {
73
+ returnPath.insertBefore(exitingLogStatement);
74
+ },
75
+ });
76
+
77
+ if (enteringLogStatement) {
78
+ if (t.isBlockStatement(path.node.body)) {
79
+ path.node.body.body.unshift(enteringLogStatement);
80
+ } else {
81
+ path.node.body = t.blockStatement([enteringLogStatement, path.node.body]);
82
+ }
83
+ }
84
+ }
85
+
86
+ function processAssignmentExpression(path, state) {
87
+ const filename = state.file.opts.filename || 'unknown';
88
+ const lineNumber = path.node.loc?.start?.line || 'unknown';
89
+ let functionName = 'anonymous'; // Default value for function name
90
+ const parameters = [];
91
+
92
+ if (!enabled || lineNumber === 'unknown') return;
93
+
94
+ if (t.isMemberExpression(path.node.left)) {
95
+ functionName = path.node.left.property.name;
96
+ }
97
+
98
+ const enteringLogStatement = createConsoleLogStatement(
99
+ 'Entering',
100
+ filename,
101
+ lineNumber,
102
+ functionName,
103
+ parameters
104
+ );
105
+ const exitingLogStatement = createConsoleLogStatement(
106
+ 'Exiting',
107
+ filename,
108
+ lineNumber,
109
+ functionName,
110
+ parameters
111
+ );
112
+
113
+ // Process the return statements within the function body
114
+ path.get('right').traverse({
115
+ ReturnStatement(returnPath) {
116
+ returnPath.insertBefore(exitingLogStatement);
117
+ },
118
+ });
119
+
120
+ if (
121
+ t.isFunctionExpression(path.node.right) ||
122
+ t.isArrowFunctionExpression(path.node.right)
123
+ ) {
124
+ // Handle the case where the right-hand side is a function expression or arrow function expression
125
+ if (t.isBlockStatement(path.node.right.body)) {
126
+ path.node.right.body.body.unshift(enteringLogStatement);
127
+ path.node.right.body.body.push(exitingLogStatement);
128
+ } else {
129
+ path.node.right.body = t.blockStatement([
130
+ enteringLogStatement,
131
+ t.returnStatement(path.node.right.body),
132
+ exitingLogStatement,
133
+ ]);
134
+ }
135
+ }
136
+ }
137
+
138
+ function processVariableDeclaration(path, state) {
139
+ const filename = state.file.opts.filename || 'unknown';
140
+ const lineNumber = path.node.loc?.start?.line || 'unknown';
141
+
142
+ path.node.declarations.forEach((declarator) => {
143
+ if (
144
+ t.isFunctionExpression(declarator.init) ||
145
+ t.isArrowFunctionExpression(declarator.init)
146
+ ) {
147
+ const functionName = declarator.id.name;
148
+ const parameters = declarator.init.params.map((param) => param.name);
149
+
150
+ if (!enabled || lineNumber === 'unknown') return;
151
+
152
+ const enteringLogStatement = createConsoleLogStatement(
153
+ 'Entering',
154
+ filename,
155
+ lineNumber,
156
+ functionName,
157
+ parameters
158
+ );
159
+ const exitingLogStatement = createConsoleLogStatement(
160
+ 'Exiting',
161
+ filename,
162
+ lineNumber,
163
+ functionName,
164
+ parameters
165
+ );
166
+
167
+ // Ensure the Exiting statement is added to the end of the function body
168
+ if (t.isBlockStatement(declarator.init.body)) {
169
+ declarator.init.body.body.push(exitingLogStatement);
170
+ } else {
171
+ declarator.init.body = t.blockStatement([
172
+ declarator.init.body,
173
+ exitingLogStatement,
174
+ ]);
175
+ }
176
+
177
+ // Process the return statements within the function body
178
+ declarator.init.body.body.forEach((statement, index) => {
179
+ if (t.isReturnStatement(statement)) {
180
+ // Add Exiting statement before the return statement
181
+ declarator.init.body.body.splice(index, 0, exitingLogStatement);
182
+ }
183
+ });
184
+
185
+ // Add the Entering statement at the beginning of the function body
186
+ if (t.isBlockStatement(declarator.init.body)) {
187
+ declarator.init.body.body.unshift(enteringLogStatement);
188
+ } else {
189
+ declarator.init.body = t.blockStatement([
190
+ enteringLogStatement,
191
+ t.returnStatement(declarator.init.body),
192
+ ]);
193
+ }
194
+ }
195
+ });
196
+ }
197
+
198
+ module.exports = function () {
199
+ let declarationFound = false;
200
+
201
+ return {
202
+ pre() {
203
+ if (this.opts && typeof this.opts.default === 'boolean') {
204
+ enabled = globalEnable = this.opts.default;
205
+ }
206
+ enabled = globalEnable;
207
+ declarationFound = false;
208
+ },
209
+ visitor: {
210
+ VariableDeclaration(path, state) {
211
+ const declarations = path.node.declarations;
212
+ const traceDeclaration = declarations.find(
213
+ (declaration) => declaration.id.name === 'TRACE'
214
+ );
215
+
216
+ if (!declarationFound) {
217
+ if (traceDeclaration) {
218
+ enabled = traceDeclaration.init
219
+ ? traceDeclaration.init.value
220
+ : false;
221
+ declarationFound = true;
222
+ } else {
223
+ enabled = globalEnable;
224
+ }
225
+ }
226
+
227
+ processVariableDeclaration(path, state);
228
+ },
229
+ FunctionDeclaration(path, state) {
230
+ //processFunction(path, state);
231
+ },
232
+ FunctionExpression(path, state) {
233
+ processFunction(enabled, path, state);
234
+ },
235
+ ArrowFunctionExpression(path, state) {
236
+ //processFunction(path, state);
237
+ },
238
+ AssignmentExpression(path, state) {
239
+ processAssignmentExpression(path, state);
240
+ },
241
+ },
242
+ };
243
+ };