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,53 +1,53 @@
1
- import { Observable } from '@dsf/lib/observable';
2
- import { WidgetBuilderBase, createWidget } from './widget-builder';
3
- import { WidgetBuilderContext } from './widgets-builder';
4
-
5
- export class ButtonBuilder extends WidgetBuilderBase<DzPushButton> {
6
- constructor(context: WidgetBuilderContext) {
7
- super(createWidget(context).build(DzPushButton))
8
- }
9
-
10
- text(text: string): this {
11
- this.widget.text = text
12
- return this
13
- }
14
-
15
- toggle(bind: Observable<boolean>): this {
16
- this.widget.setCheckable(true)
17
- this.widget.checked = bind.value
18
- this.widget.toggled.scriptConnect((value) => {
19
- bind.value = value
20
- })
21
- bind.connect((value) => {
22
- this.widget.checked = value
23
- })
24
- return this
25
- }
26
-
27
- clicked(then: Observable<void> | ((button: DzPushButton) => void)): this {
28
- if (then instanceof Observable) {
29
- this.widget.clicked.scriptConnect(() => {
30
- then.trigger()
31
- })
32
- }
33
- else {
34
- this.widget.clicked.scriptConnect(() => {
35
- then?.(this.widget)
36
- })
37
- }
38
- return this
39
- }
40
-
41
- icon(image: string | Pixmap): this {
42
- this.widget.pixmap = typeof image === 'string'
43
- ? new Pixmap(image)
44
- : image
45
- return this
46
- }
47
-
48
- build(then?: (button: DzPushButton) => void): DzPushButton {
49
- if (!this.widget.text && this.widget.pixmap) this.widget.collapseEmptySpace = true
50
- then?.(this.widget)
51
- return this.widget
52
- }
1
+ import { Observable } from '@dsf/lib/observable';
2
+ import { WidgetBuilderBase, createWidget } from './widget-builder';
3
+ import { WidgetBuilderContext } from './widgets-builder';
4
+
5
+ export class ButtonBuilder extends WidgetBuilderBase<DzPushButton> {
6
+ constructor(context: WidgetBuilderContext) {
7
+ super(createWidget(context).build(DzPushButton))
8
+ }
9
+
10
+ text(text: string): this {
11
+ this.widget.text = text
12
+ return this
13
+ }
14
+
15
+ toggle(bind: Observable<boolean>): this {
16
+ this.widget.setCheckable(true)
17
+ this.widget.checked = bind.value
18
+ this.widget.toggled.scriptConnect((value) => {
19
+ bind.value = value
20
+ })
21
+ bind.connect((value) => {
22
+ this.widget.checked = value
23
+ })
24
+ return this
25
+ }
26
+
27
+ clicked(then: Observable<void> | ((button: DzPushButton) => void)): this {
28
+ if (then instanceof Observable) {
29
+ this.widget.clicked.scriptConnect(() => {
30
+ then.trigger()
31
+ })
32
+ }
33
+ else {
34
+ this.widget.clicked.scriptConnect(() => {
35
+ then?.(this.widget)
36
+ })
37
+ }
38
+ return this
39
+ }
40
+
41
+ icon(image: string | Pixmap): this {
42
+ this.widget.pixmap = typeof image === 'string'
43
+ ? new Pixmap(image)
44
+ : image
45
+ return this
46
+ }
47
+
48
+ build(then?: (button: DzPushButton) => void): DzPushButton {
49
+ if (!this.widget.text && this.widget.pixmap) this.widget.collapseEmptySpace = true
50
+ then?.(this.widget)
51
+ return this.widget
52
+ }
53
53
  }
@@ -1,30 +1,30 @@
1
- import { Observable } from '@dsf/lib/observable';
2
- import { WidgetBuilderBase, createWidget } from './widget-builder';
3
- import { WidgetBuilderContext } from './widgets-builder';
4
-
5
- export default class CheckBoxBuilder extends WidgetBuilderBase<DzCheckBox> {
6
- constructor(context: WidgetBuilderContext) {
7
- super(createWidget(context).build(DzCheckBox))
8
- }
9
-
10
- label(text: string): this {
11
- this.widget.text = text ?? ''
12
- return this
13
- }
14
-
15
- value(property: Observable<boolean>): this {
16
- this.widget.checked = property.value
17
- property.connect((value) => {
18
- this.widget.checked = value
19
- })
20
- this.widget.toggled.scriptConnect((value) => {
21
- property.value = value
22
- })
23
- return this
24
- }
25
-
26
- build(): DzCheckBox {
27
- return this.widget
28
- }
29
-
1
+ import { Observable } from '@dsf/lib/observable';
2
+ import { WidgetBuilderBase, createWidget } from './widget-builder';
3
+ import { WidgetBuilderContext } from './widgets-builder';
4
+
5
+ export default class CheckBoxBuilder extends WidgetBuilderBase<DzCheckBox> {
6
+ constructor(context: WidgetBuilderContext) {
7
+ super(createWidget(context).build(DzCheckBox))
8
+ }
9
+
10
+ label(text: string): this {
11
+ this.widget.text = text ?? ''
12
+ return this
13
+ }
14
+
15
+ value(property: Observable<boolean>): this {
16
+ this.widget.checked = property.value
17
+ property.connect((value) => {
18
+ this.widget.checked = value
19
+ })
20
+ this.widget.toggled.scriptConnect((value) => {
21
+ property.value = value
22
+ })
23
+ return this
24
+ }
25
+
26
+ build(): DzCheckBox {
27
+ return this.widget
28
+ }
29
+
30
30
  }
@@ -1,36 +1,36 @@
1
- import { WidgetBuilderBase, createWidget } from './widget-builder';
2
- import { WidgetBuilderContext } from './widgets-builder';
3
-
4
- export default class ColorPickerBuilder extends WidgetBuilderBase<DzColorWgt> {
5
- private _value?: Color
6
- private _minWidth: number
7
- private _parent: DzWidget | DzLayout | null = null;
8
-
9
- constructor(private readonly context: WidgetBuilderContext) {
10
- super(null)
11
- }
12
-
13
- value(color: Color): this {
14
- this._value = color
15
- return this
16
- }
17
-
18
- minWidth(width: number): this {
19
- this._minWidth = width
20
- return this
21
- }
22
-
23
- parent(parent: DzWidget | DzLayout): this {
24
- this._parent = parent
25
- return this
26
- }
27
-
28
- override build(): DzColorWgt {
29
- let widget = createWidget(this.context).parent(this._parent ?? this.context.parent).build(DzColorWgt)
30
-
31
- if (this._value) widget.value = this._value
32
- widget.minWidth = this._minWidth
33
-
34
- return widget;
35
- }
1
+ import { WidgetBuilderBase, createWidget } from './widget-builder';
2
+ import { WidgetBuilderContext } from './widgets-builder';
3
+
4
+ export default class ColorPickerBuilder extends WidgetBuilderBase<DzColorWgt> {
5
+ private _value?: Color
6
+ private _minWidth: number
7
+ private _parent: DzWidget | DzLayout | null = null;
8
+
9
+ constructor(private readonly context: WidgetBuilderContext) {
10
+ super(null)
11
+ }
12
+
13
+ value(color: Color): this {
14
+ this._value = color
15
+ return this
16
+ }
17
+
18
+ minWidth(width: number): this {
19
+ this._minWidth = width
20
+ return this
21
+ }
22
+
23
+ parent(parent: DzWidget | DzLayout): this {
24
+ this._parent = parent
25
+ return this
26
+ }
27
+
28
+ override build(): DzColorWgt {
29
+ let widget = createWidget(this.context).parent(this._parent ?? this.context.parent).build(DzColorWgt)
30
+
31
+ if (this._value) widget.value = this._value
32
+ widget.minWidth = this._minWidth
33
+
34
+ return widget;
35
+ }
36
36
  }
@@ -1,36 +1,39 @@
1
- import { Observable } from '@dsf/lib/observable';
2
- import { WidgetBuilderBase, createWidget } from './widget-builder';
3
- import { WidgetBuilderContext } from './widgets-builder';
4
-
5
- export class ComboBoxBuilder extends WidgetBuilderBase<DzComboBox> {
6
- items(items: string[]): this {
7
- items.forEach((item, idx) => {
8
- if (!item)
9
- this.widget.insertSeparator(idx)
10
- else
11
- this.widget.insertItem(idx, item)
12
- });
13
- return this
14
- }
15
-
16
- selected(bind: Observable<string>): this {
17
- this.widget.currentText = bind.value
18
- bind.connect((text) => {
19
- if (this.widget.findText(text) >= 0)
20
- this.widget.currentText = text
21
- })
22
- this.widget.textChanged.scriptConnect((text) => {
23
- bind.value = text
24
- })
25
- return this
26
- }
27
-
28
- constructor(context: WidgetBuilderContext) {
29
- super(createWidget(context).build(DzComboBox))
30
- }
31
-
32
- build(then?: (comboBox: DzComboBox) => void) {
33
- then?.(this.widget)
34
- return this.widget
35
- }
1
+ import { Observable } from '@dsf/lib/observable';
2
+ import { WidgetBuilderBase, createWidget } from './widget-builder';
3
+ import { WidgetBuilderContext } from './widgets-builder';
4
+
5
+ export class ComboBoxBuilder extends WidgetBuilderBase<DzComboBox> {
6
+ constructor(context: WidgetBuilderContext) {
7
+ super(createWidget(context).build(DzComboBox))
8
+ }
9
+
10
+ items(items: string[]): this {
11
+ items.forEach((item, idx) => {
12
+ if (!item)
13
+ this.widget.insertSeparator(idx)
14
+ else
15
+ this.widget.insertItem(idx, item)
16
+ });
17
+ return this
18
+ }
19
+
20
+ selected(bind: Observable<string>): this {
21
+ if (bind.value && this.widget.findText(bind.value) >= 0) {
22
+ this.widget.currentText = bind.value
23
+ }
24
+ bind.connect((text) => {
25
+ if (this.widget.findText(text) >= 0) {
26
+ this.widget.currentText = text
27
+ }
28
+ })
29
+ this.widget.textChanged.scriptConnect((text) => {
30
+ bind.value = text
31
+ })
32
+ return this
33
+ }
34
+
35
+ build(then?: (comboBox: DzComboBox) => void) {
36
+ then?.(this.widget)
37
+ return this.widget
38
+ }
36
39
  }
@@ -1,36 +1,36 @@
1
- import { Observable } from '@dsf/lib/observable';
2
- import { WidgetBuilderBase, createWidget } from './widget-builder';
3
- import { WidgetBuilderContext } from './widgets-builder';
4
-
5
- export class ComboEditBuilder extends WidgetBuilderBase<DzComboEdit> {
6
- constructor(context: WidgetBuilderContext) {
7
- super(createWidget(context).build(DzComboEdit));
8
- }
9
-
10
- items(items: string[]): this {
11
- this.widget.insertItems(0, items)
12
- return this
13
- }
14
-
15
- changed(bind: Observable<string>): this {
16
- this.widget.text = bind.value
17
- this.widget.itemChanged.scriptConnect((text) => {
18
- bind.value = text
19
- })
20
- bind.connect((text) => {
21
- this.widget.text = text
22
- })
23
- return this
24
- }
25
-
26
- edited(bind: Observable<string>): this {
27
- this.widget.text = bind.value
28
- this.widget.textEdited.scriptConnect((text) => {
29
- bind.value = text
30
- })
31
- bind.connect((text) => {
32
- this.widget.text = text
33
- })
34
- return this
35
- }
1
+ import { Observable } from '@dsf/lib/observable';
2
+ import { WidgetBuilderBase, createWidget } from './widget-builder';
3
+ import { WidgetBuilderContext } from './widgets-builder';
4
+
5
+ export class ComboEditBuilder extends WidgetBuilderBase<DzComboEdit> {
6
+ constructor(context: WidgetBuilderContext) {
7
+ super(createWidget(context).build(DzComboEdit));
8
+ }
9
+
10
+ items(items: string[]): this {
11
+ this.widget.insertItems(0, items)
12
+ return this
13
+ }
14
+
15
+ changed(bind: Observable<string>): this {
16
+ this.widget.text = bind.value
17
+ this.widget.itemChanged.scriptConnect((text) => {
18
+ bind.value = text
19
+ })
20
+ bind.connect((text) => {
21
+ this.widget.text = text
22
+ })
23
+ return this
24
+ }
25
+
26
+ edited(bind: Observable<string>): this {
27
+ this.widget.text = bind.value
28
+ this.widget.textEdited.scriptConnect((text) => {
29
+ bind.value = text
30
+ })
31
+ bind.connect((text) => {
32
+ this.widget.text = text
33
+ })
34
+ return this
35
+ }
36
36
  }
@@ -1,49 +1,49 @@
1
- import { DialogProperties } from '../shared';
2
- import { WidgetBuilderContext, WidgetsBuilder } from './widgets-builder';
3
-
4
- export class DialogBuilder extends WidgetsBuilder {
5
- public properties: DialogProperties
6
-
7
- constructor(private title: string, private id?: string) {
8
- super(new WidgetBuilderContext(new DzBasicDialog()))
9
- this.properties = new DialogProperties()
10
- }
11
-
12
- options(properties: DialogProperties) {
13
- this.properties = properties
14
- }
15
-
16
- build(setup: () => void): DzBasicDialog {
17
- this.init()
18
- setup()
19
- this.resize()
20
- return this.context.dialog
21
- }
22
-
23
- private init() {
24
- this.context.dialog.caption = this.title
25
- let dialogWidget = this.context.dialog.getWidget()
26
- var key = (this.id ?? this.context.dialog.caption).replace(/ /g, "") + "Dlg"
27
- dialogWidget.objectName = key
28
- }
29
-
30
- private resize() {
31
- let dialogWidget = this.context.dialog.getWidget();
32
- let sizeHint = dialogWidget.minimumSizeHint;
33
- let height = this.properties.height ?? sizeHint.height;
34
- this.context.dialog.minHeight = sizeHint.height;
35
- this.context.dialog.height = height;
36
-
37
- if (this.properties.width) this.context.dialog.width = this.properties.width;
38
-
39
- if (this.properties.resizable === true) {
40
- this.context.dialog.sizeGripEnabled = true;
41
- }
42
- else {
43
- if (this.properties.width)
44
- this.context.dialog.setFixedWidth(this.properties.width);
45
- this.context.dialog.setFixedHeight(height);
46
- }
47
- }
48
- }
49
-
1
+ import { DialogProperties } from '../shared';
2
+ import { WidgetBuilderContext, WidgetsBuilder } from './widgets-builder';
3
+
4
+ export class DialogBuilder extends WidgetsBuilder {
5
+ public properties: DialogProperties
6
+
7
+ constructor(private title: string, private id?: string) {
8
+ super(new WidgetBuilderContext(new DzBasicDialog()))
9
+ this.properties = new DialogProperties()
10
+ }
11
+
12
+ options(properties: DialogProperties) {
13
+ this.properties = properties
14
+ }
15
+
16
+ build(setup: () => void): DzBasicDialog {
17
+ this.init()
18
+ setup()
19
+ this.resize()
20
+ return this.context.dialog
21
+ }
22
+
23
+ private init() {
24
+ this.context.dialog.caption = this.title
25
+ let dialogWidget = this.context.dialog.getWidget()
26
+ var key = (this.id ?? this.context.dialog.caption).replace(/ /g, "") + "Dlg"
27
+ dialogWidget.objectName = key
28
+ }
29
+
30
+ private resize() {
31
+ let dialogWidget = this.context.dialog.getWidget();
32
+ let sizeHint = dialogWidget.minimumSizeHint;
33
+ let height = this.properties.height ?? sizeHint.height;
34
+ this.context.dialog.minHeight = sizeHint.height;
35
+ this.context.dialog.height = height;
36
+
37
+ if (this.properties.width) this.context.dialog.width = this.properties.width;
38
+
39
+ if (this.properties.resizable === true) {
40
+ this.context.dialog.sizeGripEnabled = true;
41
+ }
42
+ else {
43
+ if (this.properties.width)
44
+ this.context.dialog.setFixedWidth(this.properties.width);
45
+ this.context.dialog.setFixedHeight(height);
46
+ }
47
+ }
48
+ }
49
+