@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
@@ -1,130 +1,130 @@
1
- import { FixedNumber } from './types/utility.js';
2
- const escapable =
3
- // eslint-disable-next-line no-control-regex, no-misleading-character-class
4
- /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
5
- const meta = {
6
- // table of character substitutions
7
- '\b': '\\b',
8
- '\t': '\\t',
9
- '\n': '\\n',
10
- '\f': '\\f',
11
- '\r': '\\r',
12
- '"': '\\"',
13
- '\\': '\\\\',
14
- };
15
- const eol = `\r\n`; // GMS2 writes Windows-style line endings.
16
- function quote(string) {
17
- // If the string contains no control characters, no quote characters, and no
18
- // backslash characters, then we can safely slap some quotes around it.
19
- // Otherwise we must also replace the offending characters with safe escape
20
- // sequences.
21
- escapable.lastIndex = 0;
22
- return escapable.test(string)
23
- ? '"' +
24
- string.replace(escapable, function (a) {
25
- const c = meta[a];
26
- return typeof c === 'string'
27
- ? c
28
- : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
29
- }) +
30
- '"'
31
- : '"' + string + '"';
32
- }
33
- /**
34
- * Jsonify, with GameMaker-like JSON and allowing for BigInts.
35
- * Based on {@link https://github.com/sidorares/json-bigint/blob/master/lib/stringify.js json-bigint}
36
- */
37
- export function stringifyYy(yyData) {
38
- let gap = '';
39
- let level = 0; // Level 1 are root elements
40
- const indent = ' ';
41
- function stringify(key, holder, pointer = []) {
42
- // Produce a string from holder[key].
43
- let value = holder[key];
44
- if (key !== '') {
45
- pointer.push(key);
46
- }
47
- const mind = gap;
48
- const startingLevel = level;
49
- if (value instanceof FixedNumber) {
50
- return value.toFixed(value.digits);
51
- }
52
- // If the value has a toJSON method, call it to obtain a replacement value.
53
- value = value?.toJSON?.(key) ?? value;
54
- // What happens next depends on the value's type.
55
- switch (typeof value) {
56
- case 'string':
57
- return quote(value);
58
- case 'number':
59
- case 'boolean':
60
- case 'bigint':
61
- // If the value is a boolean or null, convert it to a string. Note:
62
- // typeof null does not produce 'null'. The case is included here in
63
- // the remote chance that this gets fixed someday.
64
- return String(value);
65
- // If the type is 'object', we might be dealing with an object or an array or
66
- // null.
67
- case 'object': {
68
- // Due to a specification blunder in ECMAScript, typeof null is 'object',
69
- // so watch out for that case.
70
- if (!value) {
71
- return 'null';
72
- }
73
- // Make an array to hold the partial results of stringifying this object value.
74
- gap += indent;
75
- level++;
76
- // Is the value an array?
77
- if (Array.isArray(value)) {
78
- // Stringify every element. Use null as a placeholder
79
- // for non-JSON values.
80
- const jsonifiedValues = value.map((_, i) => stringify(i, value, [...pointer]) || 'null');
81
- // Join all of the elements together, separated with commas, and wrap them in
82
- // brackets.
83
- const v = jsonifiedValues.length === 0
84
- ? '[]'
85
- : `[${eol}` +
86
- gap +
87
- jsonifiedValues.join(`,${eol}` + gap) +
88
- `,${eol}` +
89
- mind +
90
- ']';
91
- gap = mind;
92
- level = startingLevel;
93
- return v;
94
- }
95
- const includeGaps = level <= 2;
96
- const partial = [];
97
- Object.keys(value).forEach(function (k) {
98
- const v = stringify(k, value, [...pointer]);
99
- if (v) {
100
- partial.push(quote(k) + (includeGaps ? ': ' : ':') + v);
101
- }
102
- });
103
- // Join all of the member texts together, separated with commas,
104
- // and wrap them in braces.
105
- const v = partial.length === 0
106
- ? '{}'
107
- : includeGaps
108
- ? `{${eol}` +
109
- gap +
110
- partial.join(`,${eol}` + gap) +
111
- `,${eol}` +
112
- mind +
113
- '}'
114
- : '{' + partial.join(',') + ',}';
115
- gap = mind;
116
- level = startingLevel;
117
- return v;
118
- }
119
- }
120
- return;
121
- }
122
- // If there is a replacer, it must be a function or an array.
123
- // Otherwise, throw an error.
124
- // Make a fake root object containing our value under the key of ''.
125
- // Return the result of stringifying the value.
126
- return stringify('', {
127
- '': yyData,
128
- }, []);
129
- }
1
+ import { FixedNumber } from './types/utility.js';
2
+ const escapable =
3
+ // eslint-disable-next-line no-control-regex, no-misleading-character-class
4
+ /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
5
+ const meta = {
6
+ // table of character substitutions
7
+ '\b': '\\b',
8
+ '\t': '\\t',
9
+ '\n': '\\n',
10
+ '\f': '\\f',
11
+ '\r': '\\r',
12
+ '"': '\\"',
13
+ '\\': '\\\\',
14
+ };
15
+ const eol = `\r\n`; // GMS2 writes Windows-style line endings.
16
+ function quote(string) {
17
+ // If the string contains no control characters, no quote characters, and no
18
+ // backslash characters, then we can safely slap some quotes around it.
19
+ // Otherwise we must also replace the offending characters with safe escape
20
+ // sequences.
21
+ escapable.lastIndex = 0;
22
+ return escapable.test(string)
23
+ ? '"' +
24
+ string.replace(escapable, function (a) {
25
+ const c = meta[a];
26
+ return typeof c === 'string'
27
+ ? c
28
+ : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
29
+ }) +
30
+ '"'
31
+ : '"' + string + '"';
32
+ }
33
+ /**
34
+ * Jsonify, with GameMaker-like JSON and allowing for BigInts.
35
+ * Based on {@link https://github.com/sidorares/json-bigint/blob/master/lib/stringify.js json-bigint}
36
+ */
37
+ export function stringifyYy(yyData) {
38
+ let gap = '';
39
+ let level = 0; // Level 1 are root elements
40
+ const indent = ' ';
41
+ function stringify(key, holder, pointer = []) {
42
+ // Produce a string from holder[key].
43
+ let value = holder[key];
44
+ if (key !== '') {
45
+ pointer.push(key);
46
+ }
47
+ const mind = gap;
48
+ const startingLevel = level;
49
+ if (value instanceof FixedNumber) {
50
+ return value.toFixed(value.digits);
51
+ }
52
+ // If the value has a toJSON method, call it to obtain a replacement value.
53
+ value = value?.toJSON?.(key) ?? value;
54
+ // What happens next depends on the value's type.
55
+ switch (typeof value) {
56
+ case 'string':
57
+ return quote(value);
58
+ case 'number':
59
+ case 'boolean':
60
+ case 'bigint':
61
+ // If the value is a boolean or null, convert it to a string. Note:
62
+ // typeof null does not produce 'null'. The case is included here in
63
+ // the remote chance that this gets fixed someday.
64
+ return String(value);
65
+ // If the type is 'object', we might be dealing with an object or an array or
66
+ // null.
67
+ case 'object': {
68
+ // Due to a specification blunder in ECMAScript, typeof null is 'object',
69
+ // so watch out for that case.
70
+ if (!value) {
71
+ return 'null';
72
+ }
73
+ // Make an array to hold the partial results of stringifying this object value.
74
+ gap += indent;
75
+ level++;
76
+ // Is the value an array?
77
+ if (Array.isArray(value)) {
78
+ // Stringify every element. Use null as a placeholder
79
+ // for non-JSON values.
80
+ const jsonifiedValues = value.map((_, i) => stringify(i, value, [...pointer]) || 'null');
81
+ // Join all of the elements together, separated with commas, and wrap them in
82
+ // brackets.
83
+ const v = jsonifiedValues.length === 0
84
+ ? '[]'
85
+ : `[${eol}` +
86
+ gap +
87
+ jsonifiedValues.join(`,${eol}` + gap) +
88
+ `,${eol}` +
89
+ mind +
90
+ ']';
91
+ gap = mind;
92
+ level = startingLevel;
93
+ return v;
94
+ }
95
+ const includeGaps = level <= 2;
96
+ const partial = [];
97
+ Object.keys(value).forEach(function (k) {
98
+ const v = stringify(k, value, [...pointer]);
99
+ if (v) {
100
+ partial.push(quote(k) + (includeGaps ? ': ' : ':') + v);
101
+ }
102
+ });
103
+ // Join all of the member texts together, separated with commas,
104
+ // and wrap them in braces.
105
+ const v = partial.length === 0
106
+ ? '{}'
107
+ : includeGaps
108
+ ? `{${eol}` +
109
+ gap +
110
+ partial.join(`,${eol}` + gap) +
111
+ `,${eol}` +
112
+ mind +
113
+ '}'
114
+ : '{' + partial.join(',') + ',}';
115
+ gap = mind;
116
+ level = startingLevel;
117
+ return v;
118
+ }
119
+ }
120
+ return;
121
+ }
122
+ // If there is a replacer, it must be a function or an array.
123
+ // Otherwise, throw an error.
124
+ // Make a fake root object containing our value under the key of ''.
125
+ // Return the result of stringifying the value.
126
+ return stringify('', {
127
+ '': yyData,
128
+ }, []);
129
+ }
130
130
  //# sourceMappingURL=Yy.stringify.js.map
package/dist/cli.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.js CHANGED
@@ -1,17 +1,17 @@
1
- import { ok } from 'assert';
2
- import { Yy } from './Yy.js';
3
- const [command, ...args] = process.argv.slice(2);
4
- if (command === 'diff') {
5
- const [firstYyFile, secondYyFile] = args;
6
- ok(firstYyFile, 'First Yy file must be specified');
7
- ok(secondYyFile, 'Second Yy file must be specified');
8
- const firstYy = Yy.readSync(firstYyFile);
9
- const secondYy = Yy.readSync(secondYyFile);
10
- const diff = Yy.diff(firstYy, secondYy);
11
- console.log(JSON.stringify(diff, null, 2));
12
- }
13
- else {
14
- console.error(`Unknown command: ${command}`);
15
- process.exit(1);
16
- }
1
+ import { ok } from 'assert';
2
+ import { Yy } from './Yy.js';
3
+ const [command, ...args] = process.argv.slice(2);
4
+ if (command === 'diff') {
5
+ const [firstYyFile, secondYyFile] = args;
6
+ ok(firstYyFile, 'First Yy file must be specified');
7
+ ok(secondYyFile, 'Second Yy file must be specified');
8
+ const firstYy = Yy.readSync(firstYyFile);
9
+ const secondYy = Yy.readSync(secondYyFile);
10
+ const diff = Yy.diff(firstYy, secondYy);
11
+ console.log(JSON.stringify(diff, null, 2));
12
+ }
13
+ else {
14
+ console.error(`Unknown command: ${command}`);
15
+ process.exit(1);
16
+ }
17
17
  //# sourceMappingURL=cli.js.map
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export * from './types/YyBase.js';
2
- export * from './types/YyObject.js';
3
- export * from './types/Yyp.js';
4
- export * from './types/YyRoom.js';
5
- export * from './types/YyScript.js';
6
- export * from './types/YySound.js';
7
- export * from './types/YySprite.js';
8
- export { Yy } from './Yy.js';
1
+ export * from './types/YyBase.js';
2
+ export * from './types/YyObject.js';
3
+ export * from './types/Yyp.js';
4
+ export * from './types/YyRoom.js';
5
+ export * from './types/YyScript.js';
6
+ export * from './types/YySound.js';
7
+ export * from './types/YySprite.js';
8
+ export { Yy } from './Yy.js';
9
9
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- export * from './types/YyBase.js';
2
- export * from './types/YyObject.js';
3
- export * from './types/Yyp.js';
4
- export * from './types/YyRoom.js';
5
- export * from './types/YyScript.js';
6
- export * from './types/YySound.js';
7
- export * from './types/YySprite.js';
8
- export { Yy } from './Yy.js';
1
+ export * from './types/YyBase.js';
2
+ export * from './types/YyObject.js';
3
+ export * from './types/Yyp.js';
4
+ export * from './types/YyRoom.js';
5
+ export * from './types/YyScript.js';
6
+ export * from './types/YySound.js';
7
+ export * from './types/YySprite.js';
8
+ export { Yy } from './Yy.js';
9
9
  //# sourceMappingURL=index.js.map
@@ -1,47 +1,47 @@
1
- import { z } from 'zod';
2
- export type YyBase = z.infer<typeof yyBaseSchema>;
3
- export declare const yyBaseSchema: z.ZodObject<{
4
- ConfigValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>>>;
5
- name: z.ZodString;
6
- resourceType: z.ZodString;
7
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
8
- /**
9
- * Parent folder
10
- */
11
- parent: z.ZodDefault<z.ZodObject<{
12
- /** Folder's 'name' field */
13
- name: z.ZodString;
14
- /** Folder's 'folderPath' field */
15
- path: z.ZodString;
16
- }, "strip", z.ZodTypeAny, {
17
- path: string;
18
- name: string;
19
- }, {
20
- path: string;
21
- name: string;
22
- }>>;
23
- resourceVersion: z.ZodDefault<z.ZodString>;
24
- }, "strip", z.ZodTypeAny, {
25
- ConfigValues?: Record<string, Record<string, string>> | undefined;
26
- tags?: string[] | undefined;
27
- name: string;
28
- resourceType: string;
29
- parent: {
30
- path: string;
31
- name: string;
32
- };
33
- resourceVersion: string;
34
- }, {
35
- ConfigValues?: Record<string, Record<string, string>> | undefined;
36
- tags?: string[] | undefined;
37
- parent?: {
38
- path: string;
39
- name: string;
40
- } | undefined;
41
- resourceVersion?: string | undefined;
42
- name: string;
43
- resourceType: string;
44
- }>;
45
- export type YyResourceType = typeof yyResourceTypes[number];
46
- export declare const yyResourceTypes: readonly ["animcurves", "extensions", "fonts", "notes", "objects", "paths", "rooms", "scripts", "sequences", "shaders", "sounds", "sprites", "tilesets", "timelines"];
1
+ import { z } from 'zod';
2
+ export type YyBase = z.infer<typeof yyBaseSchema>;
3
+ export declare const yyBaseSchema: z.ZodObject<{
4
+ ConfigValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>>>;
5
+ name: z.ZodString;
6
+ resourceType: z.ZodString;
7
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
8
+ /**
9
+ * Parent folder
10
+ */
11
+ parent: z.ZodDefault<z.ZodObject<{
12
+ /** Folder's 'name' field */
13
+ name: z.ZodString;
14
+ /** Folder's 'folderPath' field */
15
+ path: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ path: string;
18
+ name: string;
19
+ }, {
20
+ path: string;
21
+ name: string;
22
+ }>>;
23
+ resourceVersion: z.ZodDefault<z.ZodString>;
24
+ }, z.UnknownKeysParam, z.ZodTypeAny, {
25
+ name: string;
26
+ resourceType: string;
27
+ parent: {
28
+ path: string;
29
+ name: string;
30
+ };
31
+ resourceVersion: string;
32
+ ConfigValues?: Record<string, Record<string, string>> | undefined;
33
+ tags?: string[] | undefined;
34
+ }, {
35
+ name: string;
36
+ resourceType: string;
37
+ ConfigValues?: Record<string, Record<string, string>> | undefined;
38
+ tags?: string[] | undefined;
39
+ parent?: {
40
+ path: string;
41
+ name: string;
42
+ } | undefined;
43
+ resourceVersion?: string | undefined;
44
+ }>;
45
+ export type YyResourceType = typeof yyResourceTypes[number];
46
+ export declare const yyResourceTypes: readonly ["animcurves", "extensions", "fonts", "notes", "objects", "paths", "rooms", "scripts", "sequences", "shaders", "sounds", "sprites", "tilesets", "timelines"];
47
47
  //# sourceMappingURL=YyBase.d.ts.map
@@ -1,38 +1,38 @@
1
- // Generated by ts-to-zod
2
- import { z } from 'zod';
3
- import { unstable } from './utility.js';
4
- export const yyBaseSchema = unstable({
5
- ConfigValues: z.record(z.record(z.string())).optional(),
6
- name: z.string(),
7
- resourceType: z.string(),
8
- tags: z.array(z.string()).optional(),
9
- /**
10
- * Parent folder
11
- */
12
- parent: z
13
- .object({
14
- /** Folder's 'name' field */
15
- name: z.string(),
16
- /** Folder's 'folderPath' field */
17
- path: z.string(),
18
- })
19
- .default({ name: 'NEW', path: 'folders/NEW.yy' }),
20
- resourceVersion: z.string().default('1.0'),
21
- });
22
- export const yyResourceTypes = [
23
- 'animcurves',
24
- 'extensions',
25
- 'fonts',
26
- 'notes',
27
- 'objects',
28
- 'paths',
29
- 'rooms',
30
- 'scripts',
31
- 'sequences',
32
- 'shaders',
33
- 'sounds',
34
- 'sprites',
35
- 'tilesets',
36
- 'timelines',
37
- ];
1
+ // Generated by ts-to-zod
2
+ import { z } from 'zod';
3
+ import { unstable } from './utility.js';
4
+ export const yyBaseSchema = unstable({
5
+ ConfigValues: z.record(z.record(z.string())).optional(),
6
+ name: z.string(),
7
+ resourceType: z.string(),
8
+ tags: z.array(z.string()).optional(),
9
+ /**
10
+ * Parent folder
11
+ */
12
+ parent: z
13
+ .object({
14
+ /** Folder's 'name' field */
15
+ name: z.string(),
16
+ /** Folder's 'folderPath' field */
17
+ path: z.string(),
18
+ })
19
+ .default({ name: 'NEW', path: 'folders/NEW.yy' }),
20
+ resourceVersion: z.string().default('1.0'),
21
+ });
22
+ export const yyResourceTypes = [
23
+ 'animcurves',
24
+ 'extensions',
25
+ 'fonts',
26
+ 'notes',
27
+ 'objects',
28
+ 'paths',
29
+ 'rooms',
30
+ 'scripts',
31
+ 'sequences',
32
+ 'shaders',
33
+ 'sounds',
34
+ 'sprites',
35
+ 'tilesets',
36
+ 'timelines',
37
+ ];
38
38
  //# sourceMappingURL=YyBase.js.map