@satisfactory-dev/docs.json.ts 0.8.0 → 0.9.1

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.
@@ -21,6 +21,7 @@ export declare class DocsTsGenerator {
21
21
  private readonly cache_path;
22
22
  private readonly docs_path;
23
23
  readonly ajv: Ajv;
24
+ readonly types_from_module: string | undefined;
24
25
  static readonly PERF_EARLY_RETURN = "Early Return of Docs.json";
25
26
  static readonly PERF_FAILURE = "Failure to load Docs.json";
26
27
  static readonly PERF_FILE_PARSED = "Docs.json contents parsed";
@@ -30,10 +31,11 @@ export declare class DocsTsGenerator {
30
31
  static readonly PERF_VALIDATION_FINISHED = "Docs.json validation finished";
31
32
  static readonly PERF_VALIDATION_PRECOMPILE = "Docs.json validation pre-compilation started";
32
33
  static readonly PERF_VALIDATION_STARTED = "Docs.json validation started";
33
- constructor({ ajv, docs_path, cache_path, }: {
34
+ constructor({ ajv, docs_path, cache_path, types_from_module, }: {
34
35
  ajv: Ajv;
35
36
  docs_path: string | DocsData;
36
37
  cache_path?: string;
38
+ types_from_module?: string;
37
39
  });
38
40
  definition($ref: string): Promise<SchemaObject>;
39
41
  get(): Promise<DocsData>;
@@ -28,6 +28,7 @@ export class DocsTsGenerator {
28
28
  cache_path;
29
29
  docs_path;
30
30
  ajv;
31
+ types_from_module;
31
32
  static PERF_EARLY_RETURN = 'Early Return of Docs.json';
32
33
  static PERF_FAILURE = 'Failure to load Docs.json';
33
34
  static PERF_FILE_PARSED = 'Docs.json contents parsed';
@@ -43,10 +44,11 @@ export class DocsTsGenerator {
43
44
  // raw JSON or path to UTF-16LE encoded Docs.json
44
45
  docs_path,
45
46
  // optional cache folder path for cacheable resources
46
- cache_path = undefined, }) {
47
+ cache_path = undefined, types_from_module = undefined, }) {
47
48
  this.ajv = ajv;
48
49
  this.docs_path = docs_path;
49
50
  this.cache_path = cache_path;
51
+ this.types_from_module = types_from_module;
50
52
  }
51
53
  async definition($ref) {
52
54
  const schema = await this.schema();
@@ -202,8 +202,12 @@ export class TypeDefinitionWriter {
202
202
  }, 'Error printing node!');
203
203
  }
204
204
  }
205
- await writeFile(file_name, await format_code(node_strings
206
- .join('\n\n')));
205
+ let code = await format_code(node_strings
206
+ .join('\n\n'));
207
+ if (this.docs.types_from_module) {
208
+ code = code.replace(/} from '(?:\.\.\/)+(classes|common|utils)\//g, `} from '${this.docs.types_from_module}/$1`);
209
+ }
210
+ await writeFile(file_name, code);
207
211
  }
208
212
  performance.measure(`${this.constructor.name}.write() actually write files`, `${this.constructor.name}.write() start`);
209
213
  performance.mark(`${this.constructor.name}.write() start`);
package/package.json CHANGED
@@ -36,5 +36,5 @@
36
36
  "typescript": "~5.5.2",
37
37
  "typescript-eslint": "^7.3.1"
38
38
  },
39
- "version": "0.8.0"
39
+ "version": "0.9.1"
40
40
  }