adofai 3.0.1 → 3.2.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/README.md +111 -111
- package/dist/src/effectProcessor.js +37 -2
- package/dist/src/events/AddDecoration.d.ts +8 -7
- package/dist/src/events/AddObject.d.ts +5 -4
- package/dist/src/events/AddText.d.ts +5 -4
- package/dist/src/events/AnimateTrack.d.ts +3 -2
- package/dist/src/events/AutoPlayTiles.d.ts +2 -1
- package/dist/src/events/Bookmark.d.ts +2 -1
- package/dist/src/events/ChangeTrack.d.ts +2 -1
- package/dist/src/events/CustomBackground.d.ts +9 -8
- package/dist/src/events/Flash.d.ts +2 -1
- package/dist/src/events/FreeRoam.d.ts +4 -3
- package/dist/src/events/FreeRoamRemove.d.ts +2 -1
- package/dist/src/events/FreeRoamTwirl.d.ts +2 -1
- package/dist/src/events/Hide.d.ts +5 -4
- package/dist/src/events/MoveCamera.d.ts +4 -3
- package/dist/src/events/MoveDecorations.d.ts +5 -4
- package/dist/src/events/MoveTrack.d.ts +3 -2
- package/dist/src/events/Pause.d.ts +2 -1
- package/dist/src/events/PlaySound.d.ts +3 -2
- package/dist/src/events/PositionTrack.d.ts +3 -2
- package/dist/src/events/ScaleMargin.d.ts +2 -1
- package/dist/src/events/ScalePlanets.d.ts +2 -1
- package/dist/src/events/ScaleRadius.d.ts +2 -1
- package/dist/src/events/SetConditionalEvents.d.ts +2 -1
- package/dist/src/events/SetFilter.d.ts +2 -1
- package/dist/src/events/SetFilterAdvanced.d.ts +2 -1
- package/dist/src/events/SetFloorIcon.d.ts +2 -1
- package/dist/src/events/SetFrameRate.d.ts +2 -1
- package/dist/src/events/SetHitsound.d.ts +3 -2
- package/dist/src/events/SetHoldSound.d.ts +2 -1
- package/dist/src/events/SetInputEvent.d.ts +4 -3
- package/dist/src/events/SetObject.d.ts +3 -2
- package/dist/src/events/SetParticle.d.ts +2 -1
- package/dist/src/events/SetText.d.ts +3 -2
- package/dist/src/format.js +3 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +2 -1
- package/dist/src/parser/LargeFileParser.d.ts +20 -0
- package/dist/src/parser/LargeFileParser.js +382 -0
- package/dist/src/parser.d.ts +2 -1
- package/dist/src/parser.js +2 -1
- package/dist/src/pathdata.js +3 -1
- package/dist/src/presets.js +8 -5
- package/dist/src/types.d.ts +104 -0
- package/dist/src/types.js +34 -0
- package/dist/umd/index.js +1 -1
- package/package.json +97 -92
- package/dist/src/parser/ArrayBufferParser copy.d.ts +0 -9
- package/dist/src/parser/ArrayBufferParser copy.js +0 -98
- package/dist/src/parser/BufferParser copy.d.ts +0 -9
- package/dist/src/parser/BufferParser copy.js +0 -92
- package/dist/src/parser/BufferParserX.d.ts +0 -23
- package/dist/src/parser/BufferParserX.js +0 -77
- package/dist/src/parser/FileParser.d.ts +0 -9
- package/dist/src/parser/FileParser.js +0 -30
- package/dist/src/structure/format copy.d.ts +0 -8
- package/dist/src/structure/format copy.js +0 -44
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AdofaiEvent } from '../structure/interfaces';
|
|
2
|
+
import type { FilterType } from '../types';
|
|
2
3
|
export interface SetFilterAdvanced extends AdofaiEvent {
|
|
3
4
|
eventType: 'SetFilterAdvanced';
|
|
4
|
-
filterType?:
|
|
5
|
+
filterType?: FilterType;
|
|
5
6
|
intensity?: number;
|
|
6
7
|
duration?: number;
|
|
7
8
|
easing?: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AdofaiEvent } from '../structure/interfaces';
|
|
2
|
+
import type { ABoolean } from '../types';
|
|
2
3
|
export interface SetFloorIcon extends AdofaiEvent {
|
|
3
4
|
eventType: 'SetFloorIcon';
|
|
4
5
|
floorIcon?: string;
|
|
5
|
-
editorOnly?:
|
|
6
|
+
editorOnly?: ABoolean;
|
|
6
7
|
angleOffset?: number;
|
|
7
8
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AdofaiEvent } from '../structure/interfaces';
|
|
2
|
+
import type { ABoolean } from '../types';
|
|
2
3
|
export interface SetFrameRate extends AdofaiEvent {
|
|
3
4
|
eventType: 'SetFrameRate';
|
|
4
5
|
frameRate?: number;
|
|
5
|
-
editorOnly?:
|
|
6
|
+
editorOnly?: ABoolean;
|
|
6
7
|
angleOffset?: number;
|
|
7
8
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AdofaiEvent } from '../structure/interfaces';
|
|
2
|
+
import type { HitsoundType, ABoolean } from '../types';
|
|
2
3
|
export interface SetHitsound extends AdofaiEvent {
|
|
3
4
|
eventType: 'SetHitsound';
|
|
4
|
-
hitsound?:
|
|
5
|
+
hitsound?: HitsoundType;
|
|
5
6
|
hitsoundVolume?: number;
|
|
6
7
|
customHitsound?: string;
|
|
7
|
-
ease?:
|
|
8
|
+
ease?: ABoolean;
|
|
8
9
|
angleOffset?: number;
|
|
9
10
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AdofaiEvent } from '../structure/interfaces';
|
|
2
|
+
import type { HoldMidSoundTimingRelativeTo } from '../types';
|
|
2
3
|
export interface SetHoldSound extends AdofaiEvent {
|
|
3
4
|
eventType: 'SetHoldSound';
|
|
4
5
|
holdStartSound?: string;
|
|
@@ -6,7 +7,7 @@ export interface SetHoldSound extends AdofaiEvent {
|
|
|
6
7
|
holdMidSound?: string;
|
|
7
8
|
holdMidSoundVolume?: number;
|
|
8
9
|
holdMidSoundTiming?: number;
|
|
9
|
-
holdMidSoundTimingRelativeTo?:
|
|
10
|
+
holdMidSoundTimingRelativeTo?: HoldMidSoundTimingRelativeTo;
|
|
10
11
|
holdEndSound?: string;
|
|
11
12
|
holdEndSoundVolume?: number;
|
|
12
13
|
angleOffset?: number;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AdofaiEvent } from '../structure/interfaces';
|
|
2
|
+
import type { InputEventState, InputEventTarget, ABoolean } from '../types';
|
|
2
3
|
export interface SetInputEvent extends AdofaiEvent {
|
|
3
4
|
eventType: 'SetInputEvent';
|
|
4
5
|
inputAction?: string;
|
|
5
|
-
inputEventState?:
|
|
6
|
-
inputEventTarget?:
|
|
7
|
-
editorOnly?:
|
|
6
|
+
inputEventState?: InputEventState;
|
|
7
|
+
inputEventTarget?: InputEventTarget;
|
|
8
|
+
editorOnly?: ABoolean;
|
|
8
9
|
angleOffset?: number;
|
|
9
10
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AdofaiEvent } from '../structure/interfaces';
|
|
2
|
+
import type { Vec2 } from '../types';
|
|
2
3
|
export interface SetObject extends AdofaiEvent {
|
|
3
4
|
eventType: 'SetObject';
|
|
4
5
|
tag?: string;
|
|
5
6
|
duration?: number;
|
|
6
|
-
positionOffset?:
|
|
7
|
+
positionOffset?: Vec2;
|
|
7
8
|
rotationOffset?: number;
|
|
8
|
-
scale?:
|
|
9
|
+
scale?: Vec2;
|
|
9
10
|
opacity?: number;
|
|
10
11
|
color?: string;
|
|
11
12
|
colorTo?: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AdofaiEvent } from '../structure/interfaces';
|
|
2
|
+
import type { Vec2 } from '../types';
|
|
2
3
|
export interface SetParticle extends AdofaiEvent {
|
|
3
4
|
eventType: 'SetParticle';
|
|
4
5
|
tag?: string;
|
|
5
6
|
duration?: number;
|
|
6
|
-
positionOffset?:
|
|
7
|
+
positionOffset?: Vec2;
|
|
7
8
|
rotationOffset?: number;
|
|
8
9
|
scale?: number;
|
|
9
10
|
opacity?: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AdofaiEvent } from '../structure/interfaces';
|
|
2
|
+
import type { Vec2 } from '../types';
|
|
2
3
|
export interface SetText extends AdofaiEvent {
|
|
3
4
|
eventType: 'SetText';
|
|
4
5
|
decText?: string;
|
|
@@ -11,8 +12,8 @@ export interface SetText extends AdofaiEvent {
|
|
|
11
12
|
fadeIn?: number;
|
|
12
13
|
fadeOut?: number;
|
|
13
14
|
easing?: string;
|
|
14
|
-
positionOffset?:
|
|
15
|
+
positionOffset?: Vec2;
|
|
15
16
|
rotationOffset?: number;
|
|
16
|
-
scale?:
|
|
17
|
+
scale?: Vec2;
|
|
17
18
|
opacity?: number;
|
|
18
19
|
}
|
package/dist/src/format.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
3
|
/**
|
|
2
4
|
* @param {object} obj - JSON Object
|
|
3
5
|
* @param {number} indent - No usage
|
|
@@ -41,4 +43,4 @@ function formatAsSingleLine(obj) {
|
|
|
41
43
|
const entries = keys.map(key => JSON.stringify(key) + ': ' + formatAsSingleLine(obj[key])).join(', ');
|
|
42
44
|
return '{' + entries + '}';
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
exports.default = exportAsADOFAI;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ import * as Parsers from './parser';
|
|
|
3
3
|
import Level, * as Structure from './structure';
|
|
4
4
|
import * as Presets from './filter/presets';
|
|
5
5
|
import * as Events from './events';
|
|
6
|
-
|
|
6
|
+
import * as Types from './types';
|
|
7
|
+
export { pathData, Parsers, Level, Structure, Presets, Events, Types };
|
package/dist/src/index.js
CHANGED
|
@@ -3,4 +3,5 @@ import * as Parsers from './parser';
|
|
|
3
3
|
import Level, * as Structure from './structure';
|
|
4
4
|
import * as Presets from './filter/presets';
|
|
5
5
|
import * as Events from './events';
|
|
6
|
-
|
|
6
|
+
import * as Types from './types';
|
|
7
|
+
export { pathData, Parsers, Level, Structure, Presets, Events, Types };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface LargeFileParseResult {
|
|
2
|
+
settings?: any;
|
|
3
|
+
angleData?: number[];
|
|
4
|
+
pathData?: string;
|
|
5
|
+
actions?: any[];
|
|
6
|
+
decorations?: any[];
|
|
7
|
+
}
|
|
8
|
+
export interface LargeFileParserOptions {
|
|
9
|
+
skipLargeActions?: boolean;
|
|
10
|
+
maxActions?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class LargeFileParser {
|
|
13
|
+
private onProgress?;
|
|
14
|
+
private skipLargeActions;
|
|
15
|
+
private maxActions;
|
|
16
|
+
constructor(onProgress?: (stage: string, percent: number) => void, options?: LargeFileParserOptions);
|
|
17
|
+
parse(input: ArrayBuffer): LargeFileParseResult;
|
|
18
|
+
stringify(obj: any): string;
|
|
19
|
+
}
|
|
20
|
+
export default LargeFileParser;
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
const BOM = new Uint8Array([0xef, 0xbb, 0xbf]);
|
|
2
|
+
function findAllPropertiesAtRoot(buffer) {
|
|
3
|
+
const result = new Map();
|
|
4
|
+
let depth = 0;
|
|
5
|
+
let inString = false;
|
|
6
|
+
let escapeNext = false;
|
|
7
|
+
let propertyName = '';
|
|
8
|
+
let propertyNameStart = -1;
|
|
9
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
10
|
+
const byte = buffer[i];
|
|
11
|
+
if (escapeNext) {
|
|
12
|
+
escapeNext = false;
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (byte === 92) {
|
|
16
|
+
escapeNext = true;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (byte === 34) {
|
|
20
|
+
if (inString) {
|
|
21
|
+
inString = false;
|
|
22
|
+
if (depth === 1 && propertyNameStart !== -1) {
|
|
23
|
+
const decoder = new TextDecoder('utf-8');
|
|
24
|
+
propertyName = decoder.decode(buffer.slice(propertyNameStart, i));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
inString = true;
|
|
29
|
+
propertyNameStart = i + 1;
|
|
30
|
+
}
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (!inString) {
|
|
34
|
+
if (byte === 123) {
|
|
35
|
+
depth++;
|
|
36
|
+
}
|
|
37
|
+
else if (byte === 125) {
|
|
38
|
+
depth--;
|
|
39
|
+
}
|
|
40
|
+
else if (byte === 58 && depth === 1 && propertyName) {
|
|
41
|
+
let pos = i + 1;
|
|
42
|
+
while (pos < buffer.length && (buffer[pos] === 32 || buffer[pos] === 9 || buffer[pos] === 10 || buffer[pos] === 13)) {
|
|
43
|
+
pos++;
|
|
44
|
+
}
|
|
45
|
+
result.set(propertyName, pos);
|
|
46
|
+
propertyName = '';
|
|
47
|
+
propertyNameStart = -1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
function findValueEnd(buffer, startPos) {
|
|
54
|
+
if (startPos >= buffer.length)
|
|
55
|
+
return -1;
|
|
56
|
+
const firstChar = buffer[startPos];
|
|
57
|
+
if (firstChar === 34) {
|
|
58
|
+
let i = startPos + 1;
|
|
59
|
+
let escapeNext = false;
|
|
60
|
+
while (i < buffer.length) {
|
|
61
|
+
if (escapeNext) {
|
|
62
|
+
escapeNext = false;
|
|
63
|
+
i++;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (buffer[i] === 92) {
|
|
67
|
+
escapeNext = true;
|
|
68
|
+
i++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (buffer[i] === 34)
|
|
72
|
+
return i + 1;
|
|
73
|
+
i++;
|
|
74
|
+
}
|
|
75
|
+
return -1;
|
|
76
|
+
}
|
|
77
|
+
if (firstChar === 91 || firstChar === 123) {
|
|
78
|
+
const closeChar = firstChar === 91 ? 93 : 125;
|
|
79
|
+
let depth = 0;
|
|
80
|
+
let i = startPos;
|
|
81
|
+
let inString = false;
|
|
82
|
+
let escapeNext = false;
|
|
83
|
+
while (i < buffer.length) {
|
|
84
|
+
if (escapeNext) {
|
|
85
|
+
escapeNext = false;
|
|
86
|
+
i++;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (buffer[i] === 92) {
|
|
90
|
+
escapeNext = true;
|
|
91
|
+
i++;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (buffer[i] === 34) {
|
|
95
|
+
inString = !inString;
|
|
96
|
+
i++;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (!inString) {
|
|
100
|
+
if (buffer[i] === firstChar) {
|
|
101
|
+
depth++;
|
|
102
|
+
}
|
|
103
|
+
else if (buffer[i] === closeChar) {
|
|
104
|
+
depth--;
|
|
105
|
+
if (depth === 0)
|
|
106
|
+
return i + 1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
i++;
|
|
110
|
+
}
|
|
111
|
+
return -1;
|
|
112
|
+
}
|
|
113
|
+
let i = startPos;
|
|
114
|
+
while (i < buffer.length) {
|
|
115
|
+
const byte = buffer[i];
|
|
116
|
+
if (byte === 44 || byte === 125 || byte === 93 || byte === 32 || byte === 9 || byte === 10 || byte === 13) {
|
|
117
|
+
return i;
|
|
118
|
+
}
|
|
119
|
+
i++;
|
|
120
|
+
}
|
|
121
|
+
return i;
|
|
122
|
+
}
|
|
123
|
+
function extractValueAsString(buffer, startPos, endPos) {
|
|
124
|
+
const decoder = new TextDecoder('utf-8');
|
|
125
|
+
return decoder.decode(buffer.slice(startPos, endPos));
|
|
126
|
+
}
|
|
127
|
+
function parseNumberArrayIncremental(buffer, startPos, onProgress) {
|
|
128
|
+
if (startPos >= buffer.length || buffer[startPos] !== 91)
|
|
129
|
+
return null;
|
|
130
|
+
const values = [];
|
|
131
|
+
let i = startPos + 1;
|
|
132
|
+
let currentValue = '';
|
|
133
|
+
let depth = 1;
|
|
134
|
+
let inString = false;
|
|
135
|
+
let escapeNext = false;
|
|
136
|
+
let lastWasComma = false;
|
|
137
|
+
const totalLength = buffer.length;
|
|
138
|
+
while (i < buffer.length) {
|
|
139
|
+
const byte = buffer[i];
|
|
140
|
+
if (escapeNext) {
|
|
141
|
+
escapeNext = false;
|
|
142
|
+
i++;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (byte === 92) {
|
|
146
|
+
escapeNext = true;
|
|
147
|
+
i++;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (byte === 34) {
|
|
151
|
+
inString = !inString;
|
|
152
|
+
i++;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (!inString) {
|
|
156
|
+
if (byte === 91) {
|
|
157
|
+
depth++;
|
|
158
|
+
i++;
|
|
159
|
+
lastWasComma = false;
|
|
160
|
+
}
|
|
161
|
+
else if (byte === 93) {
|
|
162
|
+
depth--;
|
|
163
|
+
if (depth === 0) {
|
|
164
|
+
if (currentValue.trim() && !lastWasComma) {
|
|
165
|
+
const num = Number(currentValue.trim());
|
|
166
|
+
if (!isNaN(num))
|
|
167
|
+
values.push(num);
|
|
168
|
+
}
|
|
169
|
+
return { values, endPos: i + 1 };
|
|
170
|
+
}
|
|
171
|
+
i++;
|
|
172
|
+
lastWasComma = false;
|
|
173
|
+
}
|
|
174
|
+
else if (byte === 44) {
|
|
175
|
+
if (currentValue.trim() && !lastWasComma) {
|
|
176
|
+
const num = Number(currentValue.trim());
|
|
177
|
+
if (!isNaN(num))
|
|
178
|
+
values.push(num);
|
|
179
|
+
}
|
|
180
|
+
currentValue = '';
|
|
181
|
+
lastWasComma = true;
|
|
182
|
+
i++;
|
|
183
|
+
}
|
|
184
|
+
else if ((byte >= 48 && byte <= 57) || byte === 45 || byte === 46) {
|
|
185
|
+
currentValue += String.fromCharCode(byte);
|
|
186
|
+
lastWasComma = false;
|
|
187
|
+
i++;
|
|
188
|
+
}
|
|
189
|
+
else if (byte === 32 || byte === 9 || byte === 10 || byte === 13) {
|
|
190
|
+
i++;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
i++;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
i++;
|
|
198
|
+
}
|
|
199
|
+
if (onProgress && i % 5000000 === 0) {
|
|
200
|
+
onProgress(Math.round((i / totalLength) * 100));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return { values, endPos: i };
|
|
204
|
+
}
|
|
205
|
+
function parseObjectArrayIncremental(buffer, startPos, onProgress, maxObjects) {
|
|
206
|
+
if (startPos >= buffer.length || buffer[startPos] !== 91)
|
|
207
|
+
return null;
|
|
208
|
+
const values = [];
|
|
209
|
+
let i = startPos + 1;
|
|
210
|
+
let depth = 1;
|
|
211
|
+
let inString = false;
|
|
212
|
+
let escapeNext = false;
|
|
213
|
+
let objectStart = -1;
|
|
214
|
+
const totalLength = buffer.length;
|
|
215
|
+
let objectCount = 0;
|
|
216
|
+
while (i < buffer.length && (buffer[i] === 32 || buffer[i] === 9 || buffer[i] === 10 || buffer[i] === 13)) {
|
|
217
|
+
i++;
|
|
218
|
+
}
|
|
219
|
+
if (buffer[i] === 93) {
|
|
220
|
+
return { values: [], endPos: i + 1 };
|
|
221
|
+
}
|
|
222
|
+
while (i < buffer.length) {
|
|
223
|
+
const byte = buffer[i];
|
|
224
|
+
if (escapeNext) {
|
|
225
|
+
escapeNext = false;
|
|
226
|
+
i++;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (byte === 92) {
|
|
230
|
+
escapeNext = true;
|
|
231
|
+
i++;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (byte === 34) {
|
|
235
|
+
inString = !inString;
|
|
236
|
+
i++;
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (!inString) {
|
|
240
|
+
if (byte === 123) {
|
|
241
|
+
if (depth === 1 && objectStart === -1)
|
|
242
|
+
objectStart = i;
|
|
243
|
+
depth++;
|
|
244
|
+
i++;
|
|
245
|
+
}
|
|
246
|
+
else if (byte === 125) {
|
|
247
|
+
depth--;
|
|
248
|
+
if (depth === 1 && objectStart !== -1) {
|
|
249
|
+
try {
|
|
250
|
+
const obj = JSON.parse(extractValueAsString(buffer, objectStart, i + 1));
|
|
251
|
+
values.push(obj);
|
|
252
|
+
objectCount++;
|
|
253
|
+
if (maxObjects && objectCount >= maxObjects) {
|
|
254
|
+
let searchPos = i + 1;
|
|
255
|
+
while (searchPos < buffer.length && buffer[searchPos] !== 93)
|
|
256
|
+
searchPos++;
|
|
257
|
+
return { values, endPos: searchPos + 1 };
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (e) { /* skip malformed objects */ }
|
|
261
|
+
objectStart = -1;
|
|
262
|
+
if (onProgress && objectCount % 50000 === 0) {
|
|
263
|
+
onProgress(Math.round((i / totalLength) * 100));
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
i++;
|
|
267
|
+
}
|
|
268
|
+
else if (byte === 91) {
|
|
269
|
+
depth++;
|
|
270
|
+
i++;
|
|
271
|
+
}
|
|
272
|
+
else if (byte === 93) {
|
|
273
|
+
depth--;
|
|
274
|
+
if (depth === 0)
|
|
275
|
+
return { values, endPos: i + 1 };
|
|
276
|
+
i++;
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
i++;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
i++;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return { values, endPos: i };
|
|
287
|
+
}
|
|
288
|
+
export class LargeFileParser {
|
|
289
|
+
constructor(onProgress, options) {
|
|
290
|
+
var _a, _b;
|
|
291
|
+
this.skipLargeActions = false;
|
|
292
|
+
this.maxActions = 0;
|
|
293
|
+
this.onProgress = onProgress;
|
|
294
|
+
if (options) {
|
|
295
|
+
this.skipLargeActions = (_a = options.skipLargeActions) !== null && _a !== void 0 ? _a : false;
|
|
296
|
+
this.maxActions = (_b = options.maxActions) !== null && _b !== void 0 ? _b : 0;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
parse(input) {
|
|
300
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
301
|
+
let view = new Uint8Array(input);
|
|
302
|
+
if (view.length >= 3 && view[0] === BOM[0] && view[1] === BOM[1] && view[2] === BOM[2]) {
|
|
303
|
+
view = view.subarray(3);
|
|
304
|
+
}
|
|
305
|
+
(_a = this.onProgress) === null || _a === void 0 ? void 0 : _a.call(this, 'scanning', 5);
|
|
306
|
+
const properties = findAllPropertiesAtRoot(view);
|
|
307
|
+
const angleDataPos = (_b = properties.get('angleData')) !== null && _b !== void 0 ? _b : -1;
|
|
308
|
+
const pathDataPos = (_c = properties.get('pathData')) !== null && _c !== void 0 ? _c : -1;
|
|
309
|
+
const settingsPos = (_d = properties.get('settings')) !== null && _d !== void 0 ? _d : -1;
|
|
310
|
+
const actionsPos = (_e = properties.get('actions')) !== null && _e !== void 0 ? _e : -1;
|
|
311
|
+
const decorationsPos = (_f = properties.get('decorations')) !== null && _f !== void 0 ? _f : -1;
|
|
312
|
+
const result = {};
|
|
313
|
+
if (settingsPos !== -1) {
|
|
314
|
+
(_g = this.onProgress) === null || _g === void 0 ? void 0 : _g.call(this, 'parsing_settings', 10);
|
|
315
|
+
const settingsEnd = findValueEnd(view, settingsPos);
|
|
316
|
+
if (settingsEnd !== -1) {
|
|
317
|
+
try {
|
|
318
|
+
result.settings = JSON.parse(extractValueAsString(view, settingsPos, settingsEnd));
|
|
319
|
+
}
|
|
320
|
+
catch (e) {
|
|
321
|
+
result.settings = {};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (angleDataPos !== -1) {
|
|
326
|
+
(_h = this.onProgress) === null || _h === void 0 ? void 0 : _h.call(this, 'parsing_angleData', 15);
|
|
327
|
+
const angleResult = parseNumberArrayIncremental(view, angleDataPos, (p) => {
|
|
328
|
+
var _a;
|
|
329
|
+
(_a = this.onProgress) === null || _a === void 0 ? void 0 : _a.call(this, 'parsing_angleData', 15 + p * 0.25);
|
|
330
|
+
});
|
|
331
|
+
if (angleResult) {
|
|
332
|
+
result.angleData = angleResult.values;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (pathDataPos !== -1) {
|
|
336
|
+
const pathEnd = findValueEnd(view, pathDataPos);
|
|
337
|
+
if (pathEnd !== -1) {
|
|
338
|
+
const pathStr = extractValueAsString(view, pathDataPos, pathEnd);
|
|
339
|
+
result.pathData = pathStr.slice(1, -1);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (actionsPos !== -1) {
|
|
343
|
+
const actionsEnd = findValueEnd(view, actionsPos);
|
|
344
|
+
const actionsSize = actionsEnd - actionsPos;
|
|
345
|
+
(_j = this.onProgress) === null || _j === void 0 ? void 0 : _j.call(this, 'parsing_actions', 50);
|
|
346
|
+
if (actionsSize > 100 * 1024 * 1024 && this.skipLargeActions) {
|
|
347
|
+
result.actions = [];
|
|
348
|
+
}
|
|
349
|
+
else if (actionsSize > 50 * 1024 * 1024) {
|
|
350
|
+
const actionsResult = parseObjectArrayIncremental(view, actionsPos, (p) => { var _a; return (_a = this.onProgress) === null || _a === void 0 ? void 0 : _a.call(this, 'parsing_actions', 50 + p * 0.45); }, this.maxActions || undefined);
|
|
351
|
+
if (actionsResult)
|
|
352
|
+
result.actions = actionsResult.values;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
try {
|
|
356
|
+
result.actions = JSON.parse(extractValueAsString(view, actionsPos, actionsEnd));
|
|
357
|
+
}
|
|
358
|
+
catch (e) {
|
|
359
|
+
result.actions = [];
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (decorationsPos !== -1) {
|
|
364
|
+
(_k = this.onProgress) === null || _k === void 0 ? void 0 : _k.call(this, 'parsing_decorations', 95);
|
|
365
|
+
const decorationsEnd = findValueEnd(view, decorationsPos);
|
|
366
|
+
if (decorationsEnd !== -1) {
|
|
367
|
+
try {
|
|
368
|
+
result.decorations = JSON.parse(extractValueAsString(view, decorationsPos, decorationsEnd));
|
|
369
|
+
}
|
|
370
|
+
catch (e) {
|
|
371
|
+
result.decorations = [];
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
(_l = this.onProgress) === null || _l === void 0 ? void 0 : _l.call(this, 'complete', 100);
|
|
376
|
+
return result;
|
|
377
|
+
}
|
|
378
|
+
stringify(obj) {
|
|
379
|
+
return JSON.stringify(obj);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
export default LargeFileParser;
|
package/dist/src/parser.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ import Parser from "./parser/index";
|
|
|
2
2
|
import BufferParser from './parser/BufferParser';
|
|
3
3
|
import ArrayBufferParser from "./parser/ArrayBufferParser";
|
|
4
4
|
import StringParser from "./parser/StringParser";
|
|
5
|
-
|
|
5
|
+
import LargeFileParser from "./parser/LargeFileParser";
|
|
6
|
+
export { StringParser, BufferParser, ArrayBufferParser, LargeFileParser };
|
|
6
7
|
export default Parser;
|
package/dist/src/parser.js
CHANGED
|
@@ -2,5 +2,6 @@ import Parser from "./parser/index";
|
|
|
2
2
|
import BufferParser from './parser/BufferParser';
|
|
3
3
|
import ArrayBufferParser from "./parser/ArrayBufferParser";
|
|
4
4
|
import StringParser from "./parser/StringParser";
|
|
5
|
-
|
|
5
|
+
import LargeFileParser from "./parser/LargeFileParser";
|
|
6
|
+
export { StringParser, BufferParser, ArrayBufferParser, LargeFileParser };
|
|
6
7
|
export default Parser;
|
package/dist/src/pathdata.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
3
|
const pathDataTable = { "R": 0, "p": 15, "J": 30, "E": 45, "T": 60, "o": 75, "U": 90, "q": 105, "G": 120, "Q": 135, "H": 150, "W": 165, "L": 180, "x": 195, "N": 210, "Z": 225, "F": 240, "V": 255, "D": 270, "Y": 285, "B": 300, "C": 315, "M": 330, "A": 345, "5": 555, "6": 666, "7": 777, "8": 888, "!": 999 };
|
|
2
4
|
/**
|
|
3
5
|
* @param {string} pathdata - PathData from ADOFAI
|
|
@@ -8,7 +10,7 @@ function parseToangleData(pathdata) {
|
|
|
8
10
|
let result = pt.map(t => pathDataTable[t]);
|
|
9
11
|
return result;
|
|
10
12
|
}
|
|
11
|
-
|
|
13
|
+
exports.default = {
|
|
12
14
|
pathDataTable,
|
|
13
15
|
parseToangleData
|
|
14
16
|
};
|
package/dist/src/presets.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.preset_inner_no_deco = exports.preset_noeffect_completely = exports.preset_nomovecamera = exports.preset_noholds = exports.preset_noeffect = void 0;
|
|
4
|
+
exports.preset_noeffect = {
|
|
2
5
|
type: 'exclude', events: [
|
|
3
6
|
'Flash',
|
|
4
7
|
'SetFilter',
|
|
@@ -11,17 +14,17 @@ export const preset_noeffect = {
|
|
|
11
14
|
'ShakeScreen'
|
|
12
15
|
]
|
|
13
16
|
};
|
|
14
|
-
|
|
17
|
+
exports.preset_noholds = {
|
|
15
18
|
type: 'exclude', events: [
|
|
16
19
|
'Hold',
|
|
17
20
|
]
|
|
18
21
|
};
|
|
19
|
-
|
|
22
|
+
exports.preset_nomovecamera = {
|
|
20
23
|
type: 'exclude', events: [
|
|
21
24
|
'MoveCamera',
|
|
22
25
|
]
|
|
23
26
|
};
|
|
24
|
-
|
|
27
|
+
exports.preset_noeffect_completely = {
|
|
25
28
|
type: 'exclude', events: [
|
|
26
29
|
"AddDecoration",
|
|
27
30
|
"AddText",
|
|
@@ -65,7 +68,7 @@ export const preset_noeffect_completely = {
|
|
|
65
68
|
"ScaleRadius"
|
|
66
69
|
]
|
|
67
70
|
};
|
|
68
|
-
|
|
71
|
+
exports.preset_inner_no_deco = {
|
|
69
72
|
type: "special", events: [
|
|
70
73
|
"MoveDecorations",
|
|
71
74
|
"SetText",
|