@oicana/node 0.1.0-alpha.6 → 0.1.0-alpha.7

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.
@@ -6,7 +6,7 @@ import type { BlobWithMetadata } from './inputs/index.js';
6
6
  *
7
7
  * The zip file is loaded during the instance creation and cached afterward.
8
8
  */
9
- export declare class Template {
9
+ export declare class Template implements Disposable {
10
10
  private readonly template;
11
11
  /**
12
12
  * Register a template with the given template file
@@ -45,6 +45,15 @@ export declare class Template {
45
45
  * @param compilationOptions
46
46
  */
47
47
  compile(jsonInputs: Map<string, string>, blobInputs: Map<string, BlobWithMetadata>, exportOptions: ExportFormat, compilationOptions: CompilationMode): Uint8Array;
48
+ /**
49
+ * Release resources associated with this template.
50
+ * After calling dispose(), this template instance should not be used.
51
+ */
52
+ dispose(): void;
53
+ /**
54
+ * Enables use with the `using` keyword for automatic resource cleanup.
55
+ */
56
+ [Symbol.dispose](): void;
48
57
  private convertBlobWithMetadata;
49
58
  private mapCompilationMode;
50
59
  }
package/dist/Template.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import { compileTemplate, exportDocument, registerTemplate, removeDocument, } from '@oicana/node-native';
2
+ import { compileTemplate, exportDocument, registerTemplate, removeDocument, removeWorld, } from '@oicana/node-native';
3
3
  import { CompilationMode } from './CompilationMode.js';
4
4
  /**
5
5
  * A template
@@ -37,6 +37,19 @@ export class Template {
37
37
  removeDocument(document);
38
38
  }
39
39
  }
40
+ /**
41
+ * Release resources associated with this template.
42
+ * After calling dispose(), this template instance should not be used.
43
+ */
44
+ dispose() {
45
+ removeWorld(this.template);
46
+ }
47
+ /**
48
+ * Enables use with the `using` keyword for automatic resource cleanup.
49
+ */
50
+ [Symbol.dispose]() {
51
+ this.dispose();
52
+ }
40
53
  convertBlobWithMetadata(blobInputs) {
41
54
  return Object.fromEntries(Array.from(blobInputs.entries(), ([key, value]) => {
42
55
  const nativeValue = {
@@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C,WAAW,CACvB,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAChD,MAAM,WAAW,GAAG;gBAClB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;aACnE,CAAC;YACF,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAC5B,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IAEO,kBAAkB,CAAC,IAAqB;QAC9C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,eAAe,CAAC,WAAW;gBAC9B,iDAAyC;YAC3C,KAAK,eAAe,CAAC,UAAU;gBAC7B,gDAAwC;QAC5C,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oicana/node",
3
3
  "author": "Oicana <hello@oicana.com>",
4
- "version": "0.1.0-alpha.6",
4
+ "version": "0.1.0-alpha.7",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "readme": "README.md",
@@ -22,7 +22,7 @@
22
22
  "lint": "biome ci"
23
23
  },
24
24
  "dependencies": {
25
- "@oicana/node-native": "0.1.0-alpha.6"
25
+ "@oicana/node-native": "0.1.0-alpha.7"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@biomejs/biome": "2.2.4",
package/src/Template.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  CompilationMode as NativeCompilationMode,
7
7
  registerTemplate,
8
8
  removeDocument,
9
+ removeWorld,
9
10
  } from '@oicana/node-native';
10
11
  import { CompilationMode } from './CompilationMode.js';
11
12
  import type { ExportFormat } from './ExportFormat.js';
@@ -16,7 +17,7 @@ import type { BlobWithMetadata } from './inputs/index.js';
16
17
  *
17
18
  * The zip file is loaded during the instance creation and cached afterward.
18
19
  */
19
- export class Template {
20
+ export class Template implements Disposable {
20
21
  private readonly template: string;
21
22
 
22
23
  /**
@@ -137,6 +138,21 @@ export class Template {
137
138
  }
138
139
  }
139
140
 
141
+ /**
142
+ * Release resources associated with this template.
143
+ * After calling dispose(), this template instance should not be used.
144
+ */
145
+ public dispose(): void {
146
+ removeWorld(this.template);
147
+ }
148
+
149
+ /**
150
+ * Enables use with the `using` keyword for automatic resource cleanup.
151
+ */
152
+ [Symbol.dispose](): void {
153
+ this.dispose();
154
+ }
155
+
140
156
  private convertBlobWithMetadata(
141
157
  blobInputs: Map<string, BlobWithMetadata>,
142
158
  ): Record<string, BlobWithMetadataNative> {