@bscotch/yy 0.6.1 → 0.6.2

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 (42) hide show
  1. package/LICENSE.md +23 -0
  2. package/dist/Yy.d.ts +6859 -6829
  3. package/dist/Yy.d.ts.map +1 -1
  4. package/dist/Yy.js +247 -246
  5. package/dist/Yy.js.map +1 -1
  6. package/dist/Yy.parse.d.ts +5 -5
  7. package/dist/Yy.parse.js +240 -240
  8. package/dist/Yy.stringify.d.ts +6 -6
  9. package/dist/Yy.stringify.js +129 -129
  10. package/dist/cli.d.ts +1 -1
  11. package/dist/cli.js +16 -16
  12. package/dist/index.d.ts +8 -8
  13. package/dist/index.js +8 -8
  14. package/dist/types/YyBase.d.ts +46 -46
  15. package/dist/types/YyBase.js +37 -37
  16. package/dist/types/YyObject.d.ts +454 -462
  17. package/dist/types/YyObject.d.ts.map +1 -1
  18. package/dist/types/YyObject.js +108 -108
  19. package/dist/types/YyRoom.d.ts +1474 -1507
  20. package/dist/types/YyRoom.d.ts.map +1 -1
  21. package/dist/types/YyRoom.js +155 -155
  22. package/dist/types/YyScript.d.ts +45 -47
  23. package/dist/types/YyScript.d.ts.map +1 -1
  24. package/dist/types/YyScript.js +8 -8
  25. package/dist/types/YySound.d.ts +107 -115
  26. package/dist/types/YySound.d.ts.map +1 -1
  27. package/dist/types/YySound.js +61 -61
  28. package/dist/types/YySprite.d.ts +5438 -5446
  29. package/dist/types/YySprite.d.ts.map +1 -1
  30. package/dist/types/YySprite.js +417 -417
  31. package/dist/types/YySprite.lib.d.ts +221 -215
  32. package/dist/types/YySprite.lib.d.ts.map +1 -1
  33. package/dist/types/YySprite.lib.js +35 -35
  34. package/dist/types/Yyp.d.ts +604 -604
  35. package/dist/types/Yyp.js +101 -101
  36. package/dist/types/utility.d.ts +64 -64
  37. package/dist/types/utility.js +104 -104
  38. package/package.json +16 -11
  39. package/dist/Schema.d.ts +0 -1
  40. package/dist/Schema.d.ts.map +0 -1
  41. package/dist/Schema.js +0 -2
  42. package/dist/Schema.js.map +0 -1
package/dist/Yy.parse.js CHANGED
@@ -1,241 +1,241 @@
1
- /**
2
- * @file Modified from public domain code: https://github.com/sidorares/json-bigint/blob/master/lib/parse.js
3
- */
4
- const suspectProtoRx = /(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/;
5
- const suspectConstructorRx = /(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;
6
- const escapee = {
7
- '"': '"',
8
- '\\': '\\',
9
- '/': '/',
10
- b: '\b',
11
- f: '\f',
12
- n: '\n',
13
- r: '\r',
14
- t: '\t',
15
- };
16
- export function parseYy(source, schema) {
17
- // Clear trailing commas
18
- source = source.replace(/,(\s*[}\]])/g, '$1');
19
- /** Index of the current character */
20
- let at = 0;
21
- /** The current character */
22
- let ch = ' ';
23
- const text = source;
24
- function error(m) {
25
- throw {
26
- name: 'SyntaxError',
27
- message: m,
28
- at: at,
29
- text: text,
30
- };
31
- }
32
- function next(c) {
33
- // If a c parameter is provided, verify that it matches the current character.
34
- if (c && c !== ch) {
35
- error("Expected '" + c + "' instead of '" + ch + "'");
36
- }
37
- // Get the next character. When there are no more characters,
38
- // return the empty string.
39
- ch = text.charAt(at);
40
- at += 1;
41
- return ch;
42
- }
43
- function number() {
44
- // Parse a number value.
45
- let str = '';
46
- if (ch === '-') {
47
- str = '-';
48
- next('-');
49
- }
50
- while (ch >= '0' && ch <= '9') {
51
- str += ch;
52
- next();
53
- }
54
- if (ch === '.') {
55
- str += '.';
56
- while (next() && ch >= '0' && ch <= '9') {
57
- str += ch;
58
- }
59
- }
60
- if (ch === 'e' || ch === 'E') {
61
- str += ch;
62
- next();
63
- if (ch === '-' || ch === '+') {
64
- str += ch;
65
- next();
66
- }
67
- while (ch >= '0' && ch <= '9') {
68
- str += ch;
69
- next();
70
- }
71
- }
72
- // Store as a BigInt if
73
- // 1. it's an integer, and
74
- // 2. it's too big to store as a vanilla number.
75
- // (BigInts can only be parsed from purely-numeric strings)
76
- const num = +str;
77
- if (!str.includes('.')) {
78
- const asBigInt = BigInt(str);
79
- if (asBigInt > Number.MAX_SAFE_INTEGER) {
80
- return asBigInt;
81
- }
82
- }
83
- return num;
84
- }
85
- function string() {
86
- // Parse a string value.
87
- let hex, i, string = '', uffff;
88
- // When parsing for string values, we must look for " and \ characters.
89
- if (ch === '"') {
90
- let startAt = at;
91
- while (next()) {
92
- if (ch === '"') {
93
- if (at - 1 > startAt)
94
- string += text.substring(startAt, at - 1);
95
- next();
96
- return string;
97
- }
98
- if (ch === '\\') {
99
- if (at - 1 > startAt)
100
- string += text.substring(startAt, at - 1);
101
- next();
102
- if (ch === 'u') {
103
- uffff = 0;
104
- for (i = 0; i < 4; i += 1) {
105
- hex = parseInt(next(), 16);
106
- if (!isFinite(hex)) {
107
- break;
108
- }
109
- uffff = uffff * 16 + hex;
110
- }
111
- string += String.fromCharCode(uffff);
112
- }
113
- else if (typeof escapee[ch] === 'string') {
114
- string += escapee[ch];
115
- }
116
- else {
117
- break;
118
- }
119
- startAt = at;
120
- }
121
- }
122
- }
123
- error('Bad string');
124
- }
125
- function white() {
126
- // Skip whitespace.
127
- while (ch && ch <= ' ') {
128
- next();
129
- }
130
- }
131
- function word() {
132
- // true, false, or null.
133
- switch (ch) {
134
- case 't':
135
- next('t');
136
- next('r');
137
- next('u');
138
- next('e');
139
- return true;
140
- case 'f':
141
- next('f');
142
- next('a');
143
- next('l');
144
- next('s');
145
- next('e');
146
- return false;
147
- case 'n':
148
- next('n');
149
- next('u');
150
- next('l');
151
- next('l');
152
- return null;
153
- }
154
- error("Unexpected '" + ch + "'");
155
- }
156
- function value() {
157
- // Parse a JSON value. It could be an object, an array, a string, a number,
158
- // or a word.
159
- white();
160
- switch (ch) {
161
- case '{':
162
- return object();
163
- case '[':
164
- return array();
165
- case '"':
166
- return string();
167
- case '-':
168
- return number();
169
- default:
170
- return ch >= '0' && ch <= '9' ? number() : word();
171
- }
172
- }
173
- function array() {
174
- // Parse an array value.
175
- const array = [];
176
- if (ch === '[') {
177
- next('[');
178
- white();
179
- if (ch === ']') {
180
- next(']');
181
- return array; // empty array
182
- }
183
- while (ch) {
184
- array.push(value());
185
- white();
186
- if (ch === ']') {
187
- next(']');
188
- return array;
189
- }
190
- next(',');
191
- white();
192
- }
193
- }
194
- error('Bad array');
195
- }
196
- function object() {
197
- // Parse an object value.
198
- let key;
199
- const obj = {};
200
- if (ch === '{') {
201
- next('{');
202
- white();
203
- if (ch === '}') {
204
- next('}');
205
- return obj; // empty object
206
- }
207
- while (ch) {
208
- key = string();
209
- white();
210
- next(':');
211
- if (Object.hasOwnProperty.call(obj, key)) {
212
- error('Duplicate key "' + key + '"');
213
- }
214
- if (suspectProtoRx.test(key) === true) {
215
- error('Object contains forbidden prototype property');
216
- }
217
- else if (suspectConstructorRx.test(key) === true) {
218
- error('Object contains forbidden constructor property');
219
- }
220
- else {
221
- obj[key] = value();
222
- }
223
- white();
224
- if (ch === '}') {
225
- next('}');
226
- return obj;
227
- }
228
- next(',');
229
- white();
230
- }
231
- }
232
- error('Bad object');
233
- }
234
- const result = value();
235
- white();
236
- if (ch) {
237
- error('Syntax error');
238
- }
239
- return schema ? schema.parse(result) : result;
240
- }
1
+ /**
2
+ * @file Modified from public domain code: https://github.com/sidorares/json-bigint/blob/master/lib/parse.js
3
+ */
4
+ const suspectProtoRx = /(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/;
5
+ const suspectConstructorRx = /(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;
6
+ const escapee = {
7
+ '"': '"',
8
+ '\\': '\\',
9
+ '/': '/',
10
+ b: '\b',
11
+ f: '\f',
12
+ n: '\n',
13
+ r: '\r',
14
+ t: '\t',
15
+ };
16
+ export function parseYy(source, schema) {
17
+ // Clear trailing commas
18
+ source = source.replace(/,(\s*[}\]])/g, '$1');
19
+ /** Index of the current character */
20
+ let at = 0;
21
+ /** The current character */
22
+ let ch = ' ';
23
+ const text = source;
24
+ function error(m) {
25
+ throw {
26
+ name: 'SyntaxError',
27
+ message: m,
28
+ at: at,
29
+ text: text,
30
+ };
31
+ }
32
+ function next(c) {
33
+ // If a c parameter is provided, verify that it matches the current character.
34
+ if (c && c !== ch) {
35
+ error("Expected '" + c + "' instead of '" + ch + "'");
36
+ }
37
+ // Get the next character. When there are no more characters,
38
+ // return the empty string.
39
+ ch = text.charAt(at);
40
+ at += 1;
41
+ return ch;
42
+ }
43
+ function number() {
44
+ // Parse a number value.
45
+ let str = '';
46
+ if (ch === '-') {
47
+ str = '-';
48
+ next('-');
49
+ }
50
+ while (ch >= '0' && ch <= '9') {
51
+ str += ch;
52
+ next();
53
+ }
54
+ if (ch === '.') {
55
+ str += '.';
56
+ while (next() && ch >= '0' && ch <= '9') {
57
+ str += ch;
58
+ }
59
+ }
60
+ if (ch === 'e' || ch === 'E') {
61
+ str += ch;
62
+ next();
63
+ if (ch === '-' || ch === '+') {
64
+ str += ch;
65
+ next();
66
+ }
67
+ while (ch >= '0' && ch <= '9') {
68
+ str += ch;
69
+ next();
70
+ }
71
+ }
72
+ // Store as a BigInt if
73
+ // 1. it's an integer, and
74
+ // 2. it's too big to store as a vanilla number.
75
+ // (BigInts can only be parsed from purely-numeric strings)
76
+ const num = +str;
77
+ if (!str.includes('.')) {
78
+ const asBigInt = BigInt(str);
79
+ if (asBigInt > Number.MAX_SAFE_INTEGER) {
80
+ return asBigInt;
81
+ }
82
+ }
83
+ return num;
84
+ }
85
+ function string() {
86
+ // Parse a string value.
87
+ let hex, i, string = '', uffff;
88
+ // When parsing for string values, we must look for " and \ characters.
89
+ if (ch === '"') {
90
+ let startAt = at;
91
+ while (next()) {
92
+ if (ch === '"') {
93
+ if (at - 1 > startAt)
94
+ string += text.substring(startAt, at - 1);
95
+ next();
96
+ return string;
97
+ }
98
+ if (ch === '\\') {
99
+ if (at - 1 > startAt)
100
+ string += text.substring(startAt, at - 1);
101
+ next();
102
+ if (ch === 'u') {
103
+ uffff = 0;
104
+ for (i = 0; i < 4; i += 1) {
105
+ hex = parseInt(next(), 16);
106
+ if (!isFinite(hex)) {
107
+ break;
108
+ }
109
+ uffff = uffff * 16 + hex;
110
+ }
111
+ string += String.fromCharCode(uffff);
112
+ }
113
+ else if (typeof escapee[ch] === 'string') {
114
+ string += escapee[ch];
115
+ }
116
+ else {
117
+ break;
118
+ }
119
+ startAt = at;
120
+ }
121
+ }
122
+ }
123
+ error('Bad string');
124
+ }
125
+ function white() {
126
+ // Skip whitespace.
127
+ while (ch && ch <= ' ') {
128
+ next();
129
+ }
130
+ }
131
+ function word() {
132
+ // true, false, or null.
133
+ switch (ch) {
134
+ case 't':
135
+ next('t');
136
+ next('r');
137
+ next('u');
138
+ next('e');
139
+ return true;
140
+ case 'f':
141
+ next('f');
142
+ next('a');
143
+ next('l');
144
+ next('s');
145
+ next('e');
146
+ return false;
147
+ case 'n':
148
+ next('n');
149
+ next('u');
150
+ next('l');
151
+ next('l');
152
+ return null;
153
+ }
154
+ error("Unexpected '" + ch + "'");
155
+ }
156
+ function value() {
157
+ // Parse a JSON value. It could be an object, an array, a string, a number,
158
+ // or a word.
159
+ white();
160
+ switch (ch) {
161
+ case '{':
162
+ return object();
163
+ case '[':
164
+ return array();
165
+ case '"':
166
+ return string();
167
+ case '-':
168
+ return number();
169
+ default:
170
+ return ch >= '0' && ch <= '9' ? number() : word();
171
+ }
172
+ }
173
+ function array() {
174
+ // Parse an array value.
175
+ const array = [];
176
+ if (ch === '[') {
177
+ next('[');
178
+ white();
179
+ if (ch === ']') {
180
+ next(']');
181
+ return array; // empty array
182
+ }
183
+ while (ch) {
184
+ array.push(value());
185
+ white();
186
+ if (ch === ']') {
187
+ next(']');
188
+ return array;
189
+ }
190
+ next(',');
191
+ white();
192
+ }
193
+ }
194
+ error('Bad array');
195
+ }
196
+ function object() {
197
+ // Parse an object value.
198
+ let key;
199
+ const obj = {};
200
+ if (ch === '{') {
201
+ next('{');
202
+ white();
203
+ if (ch === '}') {
204
+ next('}');
205
+ return obj; // empty object
206
+ }
207
+ while (ch) {
208
+ key = string();
209
+ white();
210
+ next(':');
211
+ if (Object.hasOwnProperty.call(obj, key)) {
212
+ error('Duplicate key "' + key + '"');
213
+ }
214
+ if (suspectProtoRx.test(key) === true) {
215
+ error('Object contains forbidden prototype property');
216
+ }
217
+ else if (suspectConstructorRx.test(key) === true) {
218
+ error('Object contains forbidden constructor property');
219
+ }
220
+ else {
221
+ obj[key] = value();
222
+ }
223
+ white();
224
+ if (ch === '}') {
225
+ next('}');
226
+ return obj;
227
+ }
228
+ next(',');
229
+ white();
230
+ }
231
+ }
232
+ error('Bad object');
233
+ }
234
+ const result = value();
235
+ white();
236
+ if (ch) {
237
+ error('Syntax error');
238
+ }
239
+ return schema ? schema.parse(result) : result;
240
+ }
241
241
  //# sourceMappingURL=Yy.parse.js.map
@@ -1,7 +1,7 @@
1
- export type AnyExceptPromise<T> = T extends Promise<any> ? never : T;
2
- /**
3
- * Jsonify, with GameMaker-like JSON and allowing for BigInts.
4
- * Based on {@link https://github.com/sidorares/json-bigint/blob/master/lib/stringify.js json-bigint}
5
- */
6
- export declare function stringifyYy(yyData: any): string;
1
+ export type AnyExceptPromise<T> = T extends Promise<any> ? never : T;
2
+ /**
3
+ * Jsonify, with GameMaker-like JSON and allowing for BigInts.
4
+ * Based on {@link https://github.com/sidorares/json-bigint/blob/master/lib/stringify.js json-bigint}
5
+ */
6
+ export declare function stringifyYy(yyData: any): string;
7
7
  //# sourceMappingURL=Yy.stringify.d.ts.map