dazscript-framework 0.1.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/babel/babel.config.js +33 -0
- package/babel/trace-babel-plugin.js +243 -0
- package/babel/trace-log-babel-plugin.js +164 -0
- package/common/core.ts +2 -0
- package/common/log.ts +57 -0
- package/common/trace.ts +26 -0
- package/core/action-decorator.ts +16 -0
- package/dialog/basic-dialog.ts +32 -0
- package/dialog/builders/button-builder.ts +53 -0
- package/dialog/builders/checkbox-builder.ts +30 -0
- package/dialog/builders/combo-box-builder.ts +36 -0
- package/dialog/builders/combo-edit-builder.ts +36 -0
- package/dialog/builders/dialog-builder.ts +49 -0
- package/dialog/builders/groupbox-builder.ts +73 -0
- package/dialog/builders/label-builder.ts +18 -0
- package/dialog/builders/layout-builder.ts +46 -0
- package/dialog/builders/line-edit-builder.ts +118 -0
- package/dialog/builders/list-view-builder.ts +327 -0
- package/dialog/builders/node-selection-builder.ts +44 -0
- package/dialog/builders/popup-menu-builder.ts +47 -0
- package/dialog/builders/radio-builder.ts +43 -0
- package/dialog/builders/splitter-builder.ts +90 -0
- package/dialog/builders/tab-builder.ts +106 -0
- package/dialog/builders/widget-builder.ts +109 -0
- package/dialog/builders/widgets-builder.ts +119 -0
- package/dialog/input-dialog.ts +28 -0
- package/dialog/input-validator.ts +9 -0
- package/dialog/shared.ts +8 -0
- package/helpers/action-helper.ts +81 -0
- package/helpers/array-helper.ts +145 -0
- package/helpers/camera-helper.ts +14 -0
- package/helpers/custom-action-helper.ts +176 -0
- package/helpers/file-helper.ts +90 -0
- package/helpers/input-helper.ts +19 -0
- package/helpers/list-view-helper.ts +89 -0
- package/helpers/menu-helper.ts +29 -0
- package/helpers/message-box-helper.ts +16 -0
- package/helpers/node-helper.ts +216 -0
- package/helpers/number-helper.ts +11 -0
- package/helpers/numeric-property-helper.ts +92 -0
- package/helpers/object-helper.ts +3 -0
- package/helpers/pane-helper.ts +21 -0
- package/helpers/progress-helper.ts +34 -0
- package/helpers/property-helper.ts +53 -0
- package/helpers/record-helper.ts +16 -0
- package/helpers/scene-helper.ts +96 -0
- package/helpers/script-helper.ts +16 -0
- package/helpers/skeleton-helper.ts +27 -0
- package/helpers/splitter-helper.ts +9 -0
- package/helpers/string-helper.ts +28 -0
- package/helpers/surface-helper.ts +6 -0
- package/helpers/undo-helper.ts +7 -0
- package/helpers/viewport-helper.ts +9 -0
- package/lib/delayed.ts +39 -0
- package/lib/dz-dump.ts +121 -0
- package/lib/global.ts +5 -0
- package/lib/guid.ts +3 -0
- package/lib/observable.ts +94 -0
- package/lib/set.ts +25 -0
- package/lib/settings.ts +104 -0
- package/models/custom-action.ts +12 -0
- package/models/frame-keys.ts +68 -0
- package/package.json +48 -0
- package/shared/base-script.ts +30 -0
- package/shared/install-generator.js +185 -0
- package/shared/set-keyboard-shortcut.ts +103 -0
- package/webpack.config.js +48 -0
package/lib/delayed.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class Delayed {
|
|
2
|
+
private minDelay: number;
|
|
3
|
+
private maxDelay: number;
|
|
4
|
+
private timeout: any;
|
|
5
|
+
private action: () => void;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Perform an action delayed
|
|
9
|
+
* @param action action to delay
|
|
10
|
+
* @param minDelay min delay in milliseconds
|
|
11
|
+
* @param maxDelay max delay in milliseconds
|
|
12
|
+
*/
|
|
13
|
+
constructor(action: () => void, minDelay = 100, maxDelay = 500) {
|
|
14
|
+
this.action = action;
|
|
15
|
+
this.minDelay = minDelay;
|
|
16
|
+
this.maxDelay = maxDelay;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public trigger() {
|
|
20
|
+
if (this.timeout === undefined) {
|
|
21
|
+
this.timeout = new DzTimer();
|
|
22
|
+
this.timeout.timeout.connect(() => {
|
|
23
|
+
this.action();
|
|
24
|
+
this.reset();
|
|
25
|
+
});
|
|
26
|
+
this.timeout.start(this.maxDelay);
|
|
27
|
+
} else {
|
|
28
|
+
this.timeout.stop();
|
|
29
|
+
this.timeout.start(this.minDelay);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private reset() {
|
|
34
|
+
if (this.timeout !== undefined) {
|
|
35
|
+
this.timeout.stop();
|
|
36
|
+
this.timeout = undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/lib/dz-dump.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { any } from '@dsf/helpers/array-helper';
|
|
2
|
+
import { contains, count, remove } from '@dsf/helpers/string-helper';
|
|
3
|
+
|
|
4
|
+
function isUpperCase(myString: string) {
|
|
5
|
+
return (myString === myString.toUpperCase());
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var lines = [];
|
|
9
|
+
function processLine(x: string): void {
|
|
10
|
+
x = remove(x, "*");
|
|
11
|
+
x = x.replace("const ", "");
|
|
12
|
+
x = x.replace(/\(([a-zA-Z0-9]*),/, "(#{arg}:$1,");
|
|
13
|
+
x = x.replace(/,([a-zA-Z0-9]*)\)/, ", #{arg}:$1)");
|
|
14
|
+
x = x.replace(/,([a-zA-Z0-9]\w*)/g, ", #{arg}:$1");
|
|
15
|
+
while (contains(x, "#{arg}")) {
|
|
16
|
+
var n = count(x, "#{arg}") - 1;
|
|
17
|
+
x = x.replace(new RegExp('#{arg}(?!.*#{arg})'), `p${n}`);
|
|
18
|
+
}
|
|
19
|
+
x = x.replace(/(int|float)/g, "number");
|
|
20
|
+
x = x.replace(/(bool)/g, "boolean");
|
|
21
|
+
x = x.replace(/(QString)/g, "string");
|
|
22
|
+
x = x.replace(/(QPonumber)/g, "number");
|
|
23
|
+
x = x.replace(/\((\w*\))/, "(p0:$1");
|
|
24
|
+
x = x.replace(/\((\w*\))/, "(p0:$1");
|
|
25
|
+
x = x.replace("p0:)", ")");
|
|
26
|
+
lines.push(" " + x + ": any;");
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Keep track of classes avoiding duplicates
|
|
30
|
+
var classesFound = {};
|
|
31
|
+
|
|
32
|
+
export function dz_dump(obj: any) {
|
|
33
|
+
if (!obj || obj === null) {
|
|
34
|
+
print('null object');
|
|
35
|
+
App.flushLogBuffer()
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var className = null;
|
|
40
|
+
var enumerations = [];
|
|
41
|
+
var properties = [];
|
|
42
|
+
var functions = [];
|
|
43
|
+
var signals = [];
|
|
44
|
+
|
|
45
|
+
// is DAZ object?
|
|
46
|
+
if (obj["className"]) {
|
|
47
|
+
className = obj.className();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// already seen? leave
|
|
51
|
+
if (classesFound[className]) return;
|
|
52
|
+
|
|
53
|
+
for (var name in obj) {
|
|
54
|
+
var o = obj[name];
|
|
55
|
+
if (typeof o == "function") {
|
|
56
|
+
if (any(["Changed", "Requested", "Renamed", "Clicked", "Pressed"], x => contains(name, x)))
|
|
57
|
+
signals.push(name);
|
|
58
|
+
else
|
|
59
|
+
functions.push(name);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (isUpperCase(name[0]))
|
|
63
|
+
enumerations.push(name);
|
|
64
|
+
else
|
|
65
|
+
properties.push(name);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
properties.sort();
|
|
69
|
+
functions.sort();
|
|
70
|
+
signals.sort();
|
|
71
|
+
|
|
72
|
+
lines.push("");
|
|
73
|
+
lines.push("/**");
|
|
74
|
+
lines.push(" * class " + className);
|
|
75
|
+
lines.push(" */");
|
|
76
|
+
lines.push("declare class " + className + " {");
|
|
77
|
+
|
|
78
|
+
if (enumerations.length > 0) {
|
|
79
|
+
lines.push("");
|
|
80
|
+
lines.push(" //#region Enumerations");
|
|
81
|
+
enumerations.forEach(function (x) {
|
|
82
|
+
lines.push(" static " + x + ": " + typeof obj[x] + "; // " + (obj[x]));
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
lines.push(" //#endregion");
|
|
86
|
+
lines.push("");
|
|
87
|
+
lines.push(" // Properties");
|
|
88
|
+
|
|
89
|
+
properties.forEach(function (x) {
|
|
90
|
+
lines.push(" " + x + ": " + typeof obj[x] + "; // " + (obj[x]));
|
|
91
|
+
});
|
|
92
|
+
lines.push("");
|
|
93
|
+
lines.push(" // Methods");
|
|
94
|
+
|
|
95
|
+
// Process LineFunctions
|
|
96
|
+
functions.forEach(processLine);
|
|
97
|
+
|
|
98
|
+
// Process Signals
|
|
99
|
+
if (signals.length > 0) {
|
|
100
|
+
lines.push("");
|
|
101
|
+
lines.push(" // Signals");
|
|
102
|
+
signals.forEach(processLine);
|
|
103
|
+
}
|
|
104
|
+
lines.push("}");
|
|
105
|
+
|
|
106
|
+
classesFound[className] = lines.join('\r\n');
|
|
107
|
+
|
|
108
|
+
// output classes found
|
|
109
|
+
for (var name in classesFound) {
|
|
110
|
+
print(classesFound[name]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// =======================================
|
|
116
|
+
// =======================================
|
|
117
|
+
// =======================================
|
|
118
|
+
//dump(new DzERCLink());
|
|
119
|
+
// =======================================
|
|
120
|
+
// =======================================
|
|
121
|
+
// =======================================
|
package/lib/global.ts
ADDED
package/lib/guid.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export class Observable<T> {
|
|
2
|
+
protected _value: T;
|
|
3
|
+
private _beforeChange: (previous: T, current: T) => T
|
|
4
|
+
private _onChange: Array<(value: T) => void> = []
|
|
5
|
+
private _afterChange: (previous: T, current: T) => T
|
|
6
|
+
private _paused: boolean
|
|
7
|
+
|
|
8
|
+
constructor(value?: T, onChange?: (value: T) => void) {
|
|
9
|
+
this.value = value;
|
|
10
|
+
if (onChange)
|
|
11
|
+
this._onChange.push(onChange);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get value(): T {
|
|
15
|
+
return this._value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
set value(value: T) {
|
|
19
|
+
let previous = this._value
|
|
20
|
+
this._value = this._beforeChange?.(this._value, value) ?? value
|
|
21
|
+
if (!this._paused) this.trigger()
|
|
22
|
+
this._value = this._afterChange?.(previous, this._value) ?? this._value
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
connect(onChange: (value: T) => void): this {
|
|
26
|
+
if (this._onChange.indexOf(onChange) === -1) {
|
|
27
|
+
this._onChange.push(onChange)
|
|
28
|
+
}
|
|
29
|
+
return this
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
intercept(beforeChange: (previous: T, current: T) => T, afterChange?: (previous: T, current: T) => T): this {
|
|
33
|
+
this._beforeChange = beforeChange
|
|
34
|
+
this._afterChange = afterChange
|
|
35
|
+
return this
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
disconnect(onChange: (value: T) => void) {
|
|
39
|
+
const index = this._onChange.indexOf(onChange);
|
|
40
|
+
if (index > -1) {
|
|
41
|
+
this._onChange.splice(index, 1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
trigger(): void {
|
|
46
|
+
if (!this._paused)
|
|
47
|
+
this._onChange.forEach(callback => callback(this._value));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
pause(callback?: () => void): void {
|
|
51
|
+
this._paused = true
|
|
52
|
+
callback?.()
|
|
53
|
+
this.resume()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
resume(): void {
|
|
57
|
+
this._paused = false
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
toJSON() {
|
|
61
|
+
return this._value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export class BooleanObservable extends Observable<boolean> {
|
|
66
|
+
private combined: BooleanObservable[] = []
|
|
67
|
+
|
|
68
|
+
combine(...observables: BooleanObservable[]): this {
|
|
69
|
+
observables.forEach((obs) => {
|
|
70
|
+
this.combined.push(obs)
|
|
71
|
+
obs.connect(_ => {
|
|
72
|
+
this._value = this.combined.every(b => b.value)
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
return this
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
// export class ObservableNumber extends Observable<number> {
|
|
81
|
+
// setMax(max: number): this {
|
|
82
|
+
// this.connect((value) => {
|
|
83
|
+
// if (value > max) value = max
|
|
84
|
+
// })
|
|
85
|
+
// return this
|
|
86
|
+
// }
|
|
87
|
+
|
|
88
|
+
// setMin(min: number): this {
|
|
89
|
+
// this.connect((value) => {
|
|
90
|
+
// if (value < min) value = min
|
|
91
|
+
// })
|
|
92
|
+
// return this
|
|
93
|
+
// }
|
|
94
|
+
// }
|
package/lib/set.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default class CustomSet<T> {
|
|
2
|
+
private items: Record<string, T> = {};
|
|
3
|
+
|
|
4
|
+
add(item: T): void {
|
|
5
|
+
const key = this.getKey(item);
|
|
6
|
+
this.items[key] = item;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
has(item: T): boolean {
|
|
10
|
+
const key = this.getKey(item);
|
|
11
|
+
return key in this.items;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private getKey(item: T): string {
|
|
15
|
+
if (typeof item === 'object') {
|
|
16
|
+
// For object items, use a unique identifier (e.g., JSON string) as the key
|
|
17
|
+
return JSON.stringify(item);
|
|
18
|
+
}
|
|
19
|
+
return String(item);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
values(): T[] {
|
|
23
|
+
return Object.values(this.items);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/lib/settings.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Observable } from './observable';
|
|
2
|
+
|
|
3
|
+
export class AppSettings {
|
|
4
|
+
private appSettings: DzAppSettings
|
|
5
|
+
private _settingsPath: string
|
|
6
|
+
private _appDataPath: string
|
|
7
|
+
get appDataPath(): string {
|
|
8
|
+
return this._appDataPath
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
constructor(settingsPath: string, appDataPath?: string) {
|
|
12
|
+
this._settingsPath = settingsPath
|
|
13
|
+
this.setPaths({ settingsPath: settingsPath, appDataPath: appDataPath ?? settingsPath })
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
setPaths(paths: { settingsPath?: string, appDataPath?: string }) {
|
|
17
|
+
if (!paths.settingsPath && !paths.appDataPath) return
|
|
18
|
+
if (paths.settingsPath) {
|
|
19
|
+
this._settingsPath = paths.settingsPath
|
|
20
|
+
this.appSettings = new DzAppSettings(paths.settingsPath)
|
|
21
|
+
}
|
|
22
|
+
if (paths.appDataPath) {
|
|
23
|
+
this._appDataPath = `${App.getAppDataPath()}/${paths.appDataPath}`
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
forPath(path: string, ...paths: string[]): DzAppSettings {
|
|
28
|
+
let target = [this._settingsPath, path, ...paths].join('/')
|
|
29
|
+
return new DzAppSettings(target)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
protected getInt(name: keyof this, value: number): number {
|
|
33
|
+
return this.appSettings.getIntValue(String(name), value);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected setInt(name: keyof this, value: number) {
|
|
37
|
+
this.appSettings.setIntValue(String(name), value)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected getFloat(name: keyof this, value: number): number {
|
|
41
|
+
return this.appSettings.getFloatValue(String(name), value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected setFloat(name: keyof this, value: number) {
|
|
45
|
+
this.appSettings.setFloatValue(String(name), value)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected getBool(name: keyof this, defaultValue: boolean): boolean {
|
|
49
|
+
return this.appSettings.getBoolValue(String(name), defaultValue);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected setBool(name: keyof this, value: boolean): void {
|
|
53
|
+
this.appSettings.setBoolValue(String(name), value)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
protected getString(name: keyof this, defaultValue: string): string {
|
|
57
|
+
return this.appSettings.getStringValue(String(name), defaultValue)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected setString(name: keyof this, value: string): void {
|
|
61
|
+
this.appSettings.setStringValue(String(name), value)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected getArray(name: keyof this, defaultValue: string[]): string[] {
|
|
65
|
+
return this.appSettings.getStringValue(String(name), defaultValue.join(',')).split(',')
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// protected setArray(name: keyof this, value: string[]): void {
|
|
69
|
+
// this.appSettings.setStringValue(String(name), value.join(','))
|
|
70
|
+
// }
|
|
71
|
+
|
|
72
|
+
// protected getJson<T>(name: keyof this, defaultValue: T): T {
|
|
73
|
+
// return JSON.parse(this.getString(name, JSON.stringify(defaultValue)))
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
// protected setJson<T>(name: keyof this, value: T): void {
|
|
77
|
+
// this.setString(name, JSON.stringify(value))
|
|
78
|
+
// }
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
bindBoolean(name: keyof this, defaultValue: boolean = false): Observable<boolean> {
|
|
82
|
+
return new Observable(this.getBool(name, defaultValue), (value) => this.setBool(name, value))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
bindString(name: keyof this, defaultValue: string = ''): Observable<string> {
|
|
86
|
+
return new Observable(this.getString(name, defaultValue), (value) => this.setString(name, value))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
bindInt(name: keyof this, defaultValue: number): Observable<number> {
|
|
90
|
+
return new Observable(this.getInt(name, defaultValue), (value) => this.setInt(name, value))
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
bindFloat(name: keyof this, defaultValue: number): Observable<number> {
|
|
94
|
+
return new Observable(this.getFloat(name, defaultValue), (value) => this.setFloat(name, value))
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// bindArray(name: keyof this, defaultValue: string[] = []): Observable<string[]> {
|
|
98
|
+
// return new Observable(this.getArray(name, defaultValue), (value) => this.setArray(name, value))
|
|
99
|
+
// }
|
|
100
|
+
|
|
101
|
+
// bindJson<T>(name: keyof this, defaultValue: T): Observable<T> {
|
|
102
|
+
// return new Observable(this.getJson(name, defaultValue), (value) => this.setJson(name, value))
|
|
103
|
+
// }
|
|
104
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { find } from '@dsf/helpers/array-helper';
|
|
2
|
+
|
|
3
|
+
export class PropertyKey {
|
|
4
|
+
index: number
|
|
5
|
+
frame: number = 0
|
|
6
|
+
time: DzTime
|
|
7
|
+
value: number
|
|
8
|
+
|
|
9
|
+
toJSON(): Object {
|
|
10
|
+
return {
|
|
11
|
+
index: this.index,
|
|
12
|
+
time: this.time.valueOf(),
|
|
13
|
+
frame: this.frame,
|
|
14
|
+
value: this.value,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class PropertyKeys {
|
|
20
|
+
constructor(private _items: PropertyKey[]) {
|
|
21
|
+
if (!this._items) this._items = [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
forEach(callback: (key: PropertyKey) => any) {
|
|
25
|
+
this._items.forEach(key => {
|
|
26
|
+
callback(key);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get items(): PropertyKey[] {
|
|
31
|
+
return this._items;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get first(): PropertyKey | null {
|
|
35
|
+
return this._items[0]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get length(): number {
|
|
39
|
+
return this._items.length;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get current(): PropertyKey {
|
|
43
|
+
return find(this._items, k => k.time.valueOf() == Scene.getTime().valueOf())
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get previous(): PropertyKey {
|
|
47
|
+
return find(this._items.sort((a, b) => b.index - a.index), k => k.time.valueOf() < Scene.getTime().valueOf())
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get next(): PropertyKey {
|
|
51
|
+
return find(this._items, k => k.time.valueOf() > Scene.getTime().valueOf())
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Given the animation frame number or time, return the property key
|
|
56
|
+
* @param frameorTime frame number or time
|
|
57
|
+
* @returns the property key
|
|
58
|
+
*/
|
|
59
|
+
at(frameorTime: number | DzTime): PropertyKey | null {
|
|
60
|
+
return typeof frameorTime === 'number'
|
|
61
|
+
? find(this._items, k => k.frame === frameorTime)
|
|
62
|
+
: find(this._items, k => k.time === frameorTime)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
any(): boolean {
|
|
66
|
+
return this.items.length > 0
|
|
67
|
+
}
|
|
68
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dazscript-framework",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"author": "Freddy Diaz",
|
|
5
|
+
"license": "MPL-2.0",
|
|
6
|
+
"description": "",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"daz3d",
|
|
9
|
+
"daz studio",
|
|
10
|
+
"daz script",
|
|
11
|
+
"dson",
|
|
12
|
+
"dsa",
|
|
13
|
+
"dse"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
"./webpack": "./webpack.config.js",
|
|
17
|
+
"./babel": "./babel/babel.config.js"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/fjdiazt/dazscript-framework"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@babel/core": "^7.23.2",
|
|
25
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
26
|
+
"@babel/plugin-proposal-decorators": "^7.23.2",
|
|
27
|
+
"@babel/plugin-transform-arrow-functions": "^7.22.5",
|
|
28
|
+
"@babel/plugin-transform-block-scoping": "^7.23.0",
|
|
29
|
+
"@babel/preset-env": "^7.23.2",
|
|
30
|
+
"@babel/preset-typescript": "^7.23.2",
|
|
31
|
+
"@babel/types": "^7.23.0",
|
|
32
|
+
"babel-core": "^6.26.3",
|
|
33
|
+
"babel-loader": "^9.1.3",
|
|
34
|
+
"babel-loader-exclude-node-modules-except": "^1.2.1",
|
|
35
|
+
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
36
|
+
"babel-plugin-transform-typescript-metadata": "^0.3.2",
|
|
37
|
+
"commander": "^11.1.0",
|
|
38
|
+
"cross-env": "^7.0.3",
|
|
39
|
+
"dazscript-types": "^0.1.0",
|
|
40
|
+
"glob": "^7.2.0",
|
|
41
|
+
"ts-file-parser": "^0.0.21",
|
|
42
|
+
"ts-loader": "^9.5.0",
|
|
43
|
+
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
|
44
|
+
"typescript": "^5.2.2",
|
|
45
|
+
"webpack": "^5.88.2",
|
|
46
|
+
"webpack-cli": "^5.1.4"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { debug, error, raise } from '@dsf/common/log';
|
|
2
|
+
import { acceptUndo } from '@dsf/helpers/undo-helper';
|
|
3
|
+
|
|
4
|
+
export abstract class BaseScript {
|
|
5
|
+
protected readonly scriptName: string
|
|
6
|
+
protected anounceExecution: boolean = true
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
this.scriptName = (<any>this.constructor).name;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
protected abstract run(): void
|
|
13
|
+
|
|
14
|
+
exec() {
|
|
15
|
+
if (this.anounceExecution) {
|
|
16
|
+
debug(`=== Running script "${this.scriptName}" ===`)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
this.run()
|
|
21
|
+
} catch (err) {
|
|
22
|
+
error(`There was an error while running the script "${this.scriptName}"`)
|
|
23
|
+
raise(err)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
protected acceptUndo(callback: () => void) {
|
|
28
|
+
acceptUndo(this.scriptName, callback);
|
|
29
|
+
}
|
|
30
|
+
}
|