@bscotch/gamemaker-project 0.0.0-stage → 1.0.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.
Files changed (55) hide show
  1. package/LICENSE.md +29 -0
  2. package/README.md +138 -2
  3. package/dist/asset.d.ts +114 -0
  4. package/dist/asset.d.ts.map +1 -0
  5. package/dist/asset.js +259 -0
  6. package/dist/asset.js.map +1 -0
  7. package/dist/discovery.d.ts +25 -0
  8. package/dist/discovery.d.ts.map +1 -0
  9. package/dist/discovery.js +33 -0
  10. package/dist/discovery.js.map +1 -0
  11. package/dist/import.d.ts +90 -0
  12. package/dist/import.d.ts.map +1 -0
  13. package/dist/import.js +197 -0
  14. package/dist/import.js.map +1 -0
  15. package/dist/index.d.ts +11 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +10 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/objectEvents.d.ts +36 -0
  20. package/dist/objectEvents.d.ts.map +1 -0
  21. package/dist/objectEvents.js +140 -0
  22. package/dist/objectEvents.js.map +1 -0
  23. package/dist/project.d.ts +187 -0
  24. package/dist/project.d.ts.map +1 -0
  25. package/dist/project.js +732 -0
  26. package/dist/project.js.map +1 -0
  27. package/dist/project.state.d.ts +220 -0
  28. package/dist/project.state.d.ts.map +1 -0
  29. package/dist/project.state.js +718 -0
  30. package/dist/project.state.js.map +1 -0
  31. package/dist/refs.d.ts +20 -0
  32. package/dist/refs.d.ts.map +1 -0
  33. package/dist/refs.js +53 -0
  34. package/dist/refs.js.map +1 -0
  35. package/dist/shaderDefaults.d.ts +3 -0
  36. package/dist/shaderDefaults.d.ts.map +1 -0
  37. package/dist/shaderDefaults.js +32 -0
  38. package/dist/shaderDefaults.js.map +1 -0
  39. package/dist/spine.d.ts +20 -0
  40. package/dist/spine.d.ts.map +1 -0
  41. package/dist/spine.js +47 -0
  42. package/dist/spine.js.map +1 -0
  43. package/dist/spine.types.d.ts +89 -0
  44. package/dist/spine.types.d.ts.map +1 -0
  45. package/dist/spine.types.js +2 -0
  46. package/dist/spine.types.js.map +1 -0
  47. package/dist/transaction.d.ts +91 -0
  48. package/dist/transaction.d.ts.map +1 -0
  49. package/dist/transaction.js +203 -0
  50. package/dist/transaction.js.map +1 -0
  51. package/dist/util.d.ts +56 -0
  52. package/dist/util.d.ts.map +1 -0
  53. package/dist/util.js +163 -0
  54. package/dist/util.js.map +1 -0
  55. package/package.json +45 -3
@@ -0,0 +1,203 @@
1
+ import { Yy, yypFolderSchema } from '@bscotch/yy';
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { folderPathToPosix, folderPathToYy, hash, key, listFilesRecursively, splitPath, toPosix, } from "./util.js";
5
+ /**
6
+ * A set of changes to a project, applied as one unit.
7
+ *
8
+ * Transactions run one at a time. Each one reads the yyp and any yy files
9
+ * it changes *fresh from disk*, so changes made outside the project (by
10
+ * GameMaker, git, etc.) are never overwritten with stale data.
11
+ *
12
+ * yy/yyp changes are staged and written on commit (yy files first, then the
13
+ * yyp, so the yyp never lists an asset whose yy file doesn't exist yet).
14
+ * Other files are written immediately.
15
+ */
16
+ export class ProjectTransaction {
17
+ _yyp;
18
+ yys = new Map();
19
+ staged = new Set();
20
+ rollbacks = [];
21
+ afterCommits = [];
22
+ /** Absolute paths of every file this transaction created, changed or deleted */
23
+ touched = new Set();
24
+ host;
25
+ constructor(host) {
26
+ this.host = host;
27
+ }
28
+ /** The project's yyp, read fresh from disk. Changes are written on commit. */
29
+ async yyp() {
30
+ this._yyp ||= await this.host.readYypFresh();
31
+ return this._yyp;
32
+ }
33
+ /** `true` if {@link yyp} was used, meaning the yyp may need to be written */
34
+ get usesYyp() {
35
+ return !!this._yyp;
36
+ }
37
+ /**
38
+ * Ensure an asset-tree folder (and its parents) exist in the yyp,
39
+ * returning the `parent` value for assets in it. An empty path means the
40
+ * project root.
41
+ */
42
+ async ensureFolder(folder) {
43
+ const parts = splitPath(folder);
44
+ const yyp = await this.yyp();
45
+ if (!parts.length) {
46
+ return { name: yyp.name, path: path.basename(this.host.yypPath) };
47
+ }
48
+ let current = '';
49
+ let name = '';
50
+ for (const part of parts) {
51
+ current = current ? `${current}/${part}` : part;
52
+ const folderPath = folderPathToYy(current);
53
+ const existing = yyp.Folders.find((f) => key(f.folderPath) === key(folderPath));
54
+ if (existing) {
55
+ // Keep the existing casing
56
+ current = folderPathToPosix(existing.folderPath);
57
+ name = existing.name;
58
+ }
59
+ else {
60
+ yyp.Folders.push(yypFolderSchema.parse({ folderPath, name: part }));
61
+ name = part;
62
+ }
63
+ }
64
+ return { name, path: folderPathToYy(current) };
65
+ }
66
+ /** An asset's yy data, read fresh from disk. Stage changes with {@link stageYy}. */
67
+ async yy(asset) {
68
+ return await this.yyAt(asset.yyPath, asset.kind);
69
+ }
70
+ /** The yy data at a path, read fresh from disk (or as already staged) */
71
+ async yyAt(file, kind) {
72
+ const k = key(file);
73
+ let entry = this.yys.get(k);
74
+ if (!entry) {
75
+ const text = await fs.readFile(file, 'utf8');
76
+ entry = { path: file, kind, data: this.host.parseYy(text, kind) };
77
+ this.yys.set(k, entry);
78
+ }
79
+ return entry.data;
80
+ }
81
+ /** Stage yy data to be written on commit */
82
+ stageYy(file, kind, data) {
83
+ const k = key(file);
84
+ this.yys.set(k, { path: file, kind, data });
85
+ this.staged.add(k);
86
+ }
87
+ /** The staged yy files, in the order they were staged */
88
+ get stagedYys() {
89
+ return [...this.staged].map((k) => this.yys.get(k));
90
+ }
91
+ /** Write a file now (creating directories as needed) */
92
+ async writeFile(file, content) {
93
+ await fs.mkdir(path.dirname(file), { recursive: true });
94
+ await fs.writeFile(file, content);
95
+ this.host.recordSelfWrite(file, content);
96
+ this.touched.add(file);
97
+ }
98
+ /** Copy a file now */
99
+ async copyFile(from, to) {
100
+ await this.writeFile(to, await fs.readFile(from));
101
+ }
102
+ /**
103
+ * Copy a directory's files into a new directory now, optionally renaming
104
+ * them. `rename` receives and returns POSIX paths relative to the
105
+ * directories. The new directory is removed if the transaction fails.
106
+ */
107
+ async copyDir(from, to, rename = (r) => r) {
108
+ this.onRollback(() => fs.rm(to, { recursive: true, force: true }));
109
+ for (const file of await listFilesRecursively(from)) {
110
+ const relative = rename(toPosix(path.relative(from, file)));
111
+ await this.copyFile(file, path.join(to, relative));
112
+ }
113
+ }
114
+ /** Rename (move) a file or directory now. Undone if the transaction fails. */
115
+ async rename(from, to) {
116
+ const files = await listFilesRecursively(from);
117
+ await fs.mkdir(path.dirname(to), { recursive: true });
118
+ await fs.rename(from, to);
119
+ this.onRollback(() => fs.rename(to, from));
120
+ for (const file of files) {
121
+ const moved = path.join(to, path.relative(from, file));
122
+ this.host.recordSelfWrite(file, null);
123
+ this.host.recordSelfWrite(moved, await fs.readFile(moved));
124
+ this.touched.add(file);
125
+ this.touched.add(moved);
126
+ }
127
+ if (!files.length) {
128
+ this.touched.add(from);
129
+ this.touched.add(to);
130
+ }
131
+ }
132
+ /** Delete a file or directory, after a successful commit */
133
+ deleteOnCommit(target) {
134
+ this.afterCommits.push(async () => {
135
+ for (const file of await listFilesRecursively(target)) {
136
+ this.host.recordSelfWrite(file, null);
137
+ this.touched.add(file);
138
+ }
139
+ this.host.recordSelfWrite(target, null);
140
+ this.touched.add(target);
141
+ await fs.rm(target, { recursive: true, force: true, maxRetries: 5 });
142
+ });
143
+ }
144
+ /** Register an action to undo a change if the transaction fails */
145
+ onRollback(undo) {
146
+ this.rollbacks.push(undo);
147
+ }
148
+ /** @internal Write staged changes. Called by the project. */
149
+ async commit() {
150
+ const format = this._yyp;
151
+ for (const { path: file, kind, data } of this.stagedYys) {
152
+ if (await writeIfChanged(file, Yy.stringify(data, kind, format))) {
153
+ this.touched.add(file);
154
+ }
155
+ }
156
+ if (this._yyp) {
157
+ const text = Yy.stringify(this._yyp, 'project');
158
+ if (await writeIfChanged(this.host.yypPath, text)) {
159
+ this.touched.add(this.host.yypPath);
160
+ }
161
+ }
162
+ const errors = [];
163
+ for (const action of this.afterCommits) {
164
+ try {
165
+ await action();
166
+ }
167
+ catch (err) {
168
+ errors.push(err);
169
+ }
170
+ }
171
+ return { errors };
172
+ }
173
+ /** @internal Undo what can be undone. Called by the project. */
174
+ async rollback() {
175
+ const errors = [];
176
+ for (const undo of [...this.rollbacks].reverse()) {
177
+ try {
178
+ await undo();
179
+ }
180
+ catch (err) {
181
+ errors.push(err);
182
+ }
183
+ }
184
+ return { errors };
185
+ }
186
+ }
187
+ async function writeIfChanged(file, text) {
188
+ try {
189
+ if ((await fs.readFile(file, 'utf8')) === text)
190
+ return false;
191
+ }
192
+ catch {
193
+ // Doesn't exist yet
194
+ }
195
+ await fs.mkdir(path.dirname(file), { recursive: true });
196
+ await fs.writeFile(file, text);
197
+ return true;
198
+ }
199
+ /** @internal */
200
+ export function contentHash(content) {
201
+ return content === null ? null : hash(content);
202
+ }
203
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,eAAe,EAAyB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,IAAI,EACJ,GAAG,EACH,oBAAoB,EACpB,SAAS,EACT,OAAO,GACR,MAAM,WAAW,CAAC;AA0BnB;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAkB;IACnB,IAAI,CAAO;IACF,GAAG,GAAG,IAAI,GAAG,EAAoB,CAAC;IAClC,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IAC3B,SAAS,GAA+B,EAAE,CAAC;IAC3C,YAAY,GAA+B,EAAE,CAAC;IACjE,gFAAgF;IACvE,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5B,IAAI,CAAkB;IAE/B,YAAY,IAAqB;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,C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AC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,oBAAoB;IACtB,CAAC;IACD,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,WAAW,CAAC,OAA+B;IACzD,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC"}
package/dist/util.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ export declare class GameMakerProjectError extends Error {
2
+ constructor(message: string, options?: {
3
+ cause?: unknown;
4
+ });
5
+ }
6
+ export declare function assert(condition: unknown, message: string): asserts condition;
7
+ export declare function isValidIdentifier(name: string): boolean;
8
+ export declare function assertIsValidIdentifier(name: string): void;
9
+ /**
10
+ * Normalize an asset-folder path, given either in POSIX form (`my/folder`) or
11
+ * in the form used in yy files (`folders/my/folder.yy`), to POSIX form.
12
+ */
13
+ export declare function folderPathToPosix(folderPath: string): string;
14
+ /** Convert a POSIX-style folder path to the yy form: `folders/my/folder.yy` */
15
+ export declare function folderPathToYy(folderPath: string): string;
16
+ /** Split a folder or asset path (POSIX or Windows separators) into parts. */
17
+ export declare function splitPath(p: string | string[]): string[];
18
+ export declare function toPosix(p: string): string;
19
+ /** Lowercased key used for case-insensitive lookups */
20
+ export declare function key(name: string): string;
21
+ export declare function exists(p: string): Promise<boolean>;
22
+ export declare function isDirectory(p: string): Promise<boolean>;
23
+ /** List the names of a directory's entries, or `[]` if it doesn't exist */
24
+ export declare function listDir(dir: string): Promise<string[]>;
25
+ /** Recursively list all files (not directories) under a directory */
26
+ export declare function listFilesRecursively(dir: string): Promise<string[]>;
27
+ /**
28
+ * Find the entry in `dir` whose name matches `name` case-insensitively,
29
+ * preferring an exact match. */
30
+ export declare function findCaseInsensitive(dir: string, name: string): Promise<string | undefined>;
31
+ export declare function hash(content: string | Buffer): string;
32
+ /**
33
+ * Read just enough of a PNG file to get its dimensions,
34
+ * throwing if it isn't a PNG.
35
+ */
36
+ export declare function getPngSize(file: string): Promise<{
37
+ width: number;
38
+ height: number;
39
+ }>;
40
+ /** Run `fn` over `items` with at most `limit` running at once. */
41
+ export declare function mapConcurrent<T, R>(items: readonly T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]>;
42
+ export declare function sleep(ms: number): Promise<void>;
43
+ /**
44
+ * Runs async tasks one at a time, in the order they were queued.
45
+ * A failing task does not prevent later tasks from running.
46
+ */
47
+ export declare class SerialQueue {
48
+ protected tail: Promise<unknown>;
49
+ protected pending: number;
50
+ run<T>(task: () => Promise<T>): Promise<T>;
51
+ /** `true` if a task is running or waiting to run */
52
+ get busy(): boolean;
53
+ /** Resolves once every task queued so far has settled */
54
+ idle(): Promise<void>;
55
+ }
56
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAKA,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AAED,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAE7E;AAID,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAK1D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAM5D;AAED,+EAA+E;AAC/E,wBAAgB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AAE,CAAC,CAcd;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;GAGG;AACH,qBAAa,WAAW;IACtB,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrD,SAAS,CAAC,OAAO,SAAK;IAEtB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAW1C,oDAAoD;IACpD,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,yDAAyD;IACnD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
package/dist/util.js ADDED
@@ -0,0 +1,163 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { constants } from 'node:fs';
3
+ import fs from 'node:fs/promises';
4
+ import path from 'node:path';
5
+ export class GameMakerProjectError extends Error {
6
+ constructor(message, options) {
7
+ super(message, options);
8
+ this.name = 'GameMakerProjectError';
9
+ }
10
+ }
11
+ export function assert(condition, message) {
12
+ if (!condition)
13
+ throw new GameMakerProjectError(message);
14
+ }
15
+ const identifierPattern = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
16
+ export function isValidIdentifier(name) {
17
+ return identifierPattern.test(name);
18
+ }
19
+ export function assertIsValidIdentifier(name) {
20
+ assert(isValidIdentifier(name), `"${name}" is not a valid GameMaker identifier`);
21
+ }
22
+ /**
23
+ * Normalize an asset-folder path, given either in POSIX form (`my/folder`) or
24
+ * in the form used in yy files (`folders/my/folder.yy`), to POSIX form.
25
+ */
26
+ export function folderPathToPosix(folderPath) {
27
+ return folderPath
28
+ .replace(/[\\/]+/g, '/')
29
+ .replace(/^\//, '')
30
+ .replace(/\/$/, '')
31
+ .replace(/^folders\/(.*)\.yy$/, '$1');
32
+ }
33
+ /** Convert a POSIX-style folder path to the yy form: `folders/my/folder.yy` */
34
+ export function folderPathToYy(folderPath) {
35
+ return `folders/${folderPathToPosix(folderPath)}.yy`;
36
+ }
37
+ /** Split a folder or asset path (POSIX or Windows separators) into parts. */
38
+ export function splitPath(p) {
39
+ return (Array.isArray(p) ? p : p.split(/[/\\]+/)).filter(Boolean);
40
+ }
41
+ export function toPosix(p) {
42
+ return p.replace(/\\/g, '/');
43
+ }
44
+ /** Lowercased key used for case-insensitive lookups */
45
+ export function key(name) {
46
+ return name.toLowerCase();
47
+ }
48
+ export async function exists(p) {
49
+ try {
50
+ await fs.access(p, constants.F_OK);
51
+ return true;
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ }
57
+ export async function isDirectory(p) {
58
+ try {
59
+ return (await fs.stat(p)).isDirectory();
60
+ }
61
+ catch {
62
+ return false;
63
+ }
64
+ }
65
+ /** List the names of a directory's entries, or `[]` if it doesn't exist */
66
+ export async function listDir(dir) {
67
+ try {
68
+ return await fs.readdir(dir);
69
+ }
70
+ catch {
71
+ return [];
72
+ }
73
+ }
74
+ /** Recursively list all files (not directories) under a directory */
75
+ export async function listFilesRecursively(dir) {
76
+ const files = [];
77
+ let entries;
78
+ try {
79
+ entries = await fs.readdir(dir, { withFileTypes: true, recursive: true });
80
+ }
81
+ catch {
82
+ return files;
83
+ }
84
+ for (const entry of entries) {
85
+ if (entry.isFile())
86
+ files.push(path.join(entry.parentPath, entry.name));
87
+ }
88
+ return files.sort();
89
+ }
90
+ /**
91
+ * Find the entry in `dir` whose name matches `name` case-insensitively,
92
+ * preferring an exact match. */
93
+ export async function findCaseInsensitive(dir, name) {
94
+ const entries = await listDir(dir);
95
+ const match = entries.find((e) => e === name) ||
96
+ entries.find((e) => key(e) === key(name));
97
+ return match && path.join(dir, match);
98
+ }
99
+ export function hash(content) {
100
+ return createHash('sha1').update(content).digest('hex');
101
+ }
102
+ /**
103
+ * Read just enough of a PNG file to get its dimensions,
104
+ * throwing if it isn't a PNG.
105
+ */
106
+ export async function getPngSize(file) {
107
+ const fd = await fs.open(file, 'r');
108
+ try {
109
+ const buf = Buffer.alloc(24);
110
+ await fd.read(buf, 0, 24, 0);
111
+ assert(buf.toString('latin1', 1, 4) === 'PNG', `Expected a PNG file: ${file}`);
112
+ const size = { width: buf.readUInt32BE(16), height: buf.readUInt32BE(20) };
113
+ assert(size.width > 0 && size.height > 0, `Invalid PNG size: ${file}`);
114
+ return size;
115
+ }
116
+ finally {
117
+ await fd.close();
118
+ }
119
+ }
120
+ /** Run `fn` over `items` with at most `limit` running at once. */
121
+ export async function mapConcurrent(items, limit, fn) {
122
+ const results = new Array(items.length);
123
+ let next = 0;
124
+ const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
125
+ while (next < items.length) {
126
+ const i = next++;
127
+ results[i] = await fn(items[i]);
128
+ }
129
+ });
130
+ await Promise.all(workers);
131
+ return results;
132
+ }
133
+ export function sleep(ms) {
134
+ return new Promise((resolve) => setTimeout(resolve, ms));
135
+ }
136
+ /**
137
+ * Runs async tasks one at a time, in the order they were queued.
138
+ * A failing task does not prevent later tasks from running.
139
+ */
140
+ export class SerialQueue {
141
+ tail = Promise.resolve();
142
+ pending = 0;
143
+ run(task) {
144
+ this.pending++;
145
+ const result = this.tail.then(task);
146
+ this.tail = result
147
+ .catch(() => undefined)
148
+ .finally(() => {
149
+ this.pending--;
150
+ });
151
+ return result;
152
+ }
153
+ /** `true` if a task is running or waiting to run */
154
+ get busy() {
155
+ return this.pending > 0;
156
+ }
157
+ /** Resolves once every task queued so far has settled */
158
+ async idle() {
159
+ while (this.pending)
160
+ await this.tail;
161
+ }
162
+ }
163
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,OAAO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EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,WAAW;IACZ,IAAI,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3C,OAAO,GAAG,CAAC,CAAC;IAEtB,GAAG,CAAI,IAAsB;QAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,MAAM;aACf,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;aACtB,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACL,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,oDAAoD;IACpD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,yDAAyD;IACzD,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,CAAC,IAAI,CAAC;IACvC,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "@bscotch/gamemaker-project",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Read and safely modify GameMaker project files (yyp/yy), with disk as the source of truth.",
5
+ "keywords": [
6
+ "gamemaker",
7
+ "yyp",
8
+ "yy",
9
+ "project",
10
+ "stitch"
11
+ ],
12
+ "homepage": "https://github.com/bscotch/stitch/tree/develop/packages/gamemaker-project#readme",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/bscotch/stitch.git",
16
+ "directory": "packages/gamemaker-project"
17
+ },
18
+ "license": "MIT",
19
+ "author": "Adam Coster (https://www.bscotch.net/about#adam-coster)",
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ }
26
+ },
27
+ "main": "dist/index.js",
28
+ "types": "dist/index.d.ts",
29
+ "dependencies": {
30
+ "@bscotch/stitch-config": "0.7.1",
31
+ "@bscotch/yy": "3.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "typescript": "6.0.3"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "engines": {
40
+ "node": ">=22"
41
+ },
42
+ "scripts": {
43
+ "build": "tsc --build",
44
+ "clean": "node ../../scripts/clean.mjs build dist \"*.tsbuildinfo\" \"**/*.tsbuildinfo\"",
45
+ "test": "node --test --test-concurrency=1 --test-timeout=120000 \"src/**/*.test.ts\"",
46
+ "watch": "tsc --build --watch"
47
+ }
6
48
  }