paralayer 1.9.0 → 1.10.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.
package/dist/bin.js CHANGED
@@ -32,8 +32,6 @@ var Paralayer = class extends Unit {
32
32
  await this.ready$.promise;
33
33
  await this.queue.run(() => this.build());
34
34
  if (!this.options.watch) await this.watcher.close();
35
- }
36
- async readSetupJs() {
37
35
  const setupJsPath = join(this.options.output, "setup.js");
38
36
  return await readFile(setupJsPath, "utf-8");
39
37
  }
@@ -133,7 +131,7 @@ var Paralayer = class extends Unit {
133
131
  }
134
132
  const globals = [
135
133
  `declare global {`,
136
- ` var ${layerName}: ${LayerName}`,
134
+ ` const ${layerName}: ${LayerName}`,
137
135
  ``,
138
136
  ` interface ${LayerName} ${extendPascal}{`,
139
137
  ...allNames.map((name) => ` ${name}: typeof ${name}`),
@@ -200,9 +198,8 @@ var Paralayer = class extends Unit {
200
198
  }
201
199
  };
202
200
  async function paralayer(options) {
203
- const pl = new Paralayer(options);
204
- await pl.start();
205
- return await pl.readSetupJs();
201
+ const setupLayersJs = await new Paralayer(options).start();
202
+ return setupLayersJs;
206
203
  }
207
204
 
208
205
  // src/bin.ts
@@ -13,7 +13,7 @@ type Options = {
13
13
  globalize?: boolean;
14
14
  /** If provided, other layers will extend this layer. */
15
15
  globalLayerName?: string | null;
16
- /** If a file name does not have layer tags, default layer name will be used. */
16
+ /** If a file name does not have any layer tags, default layer name will be used. */
17
17
  defaultLayerName?: string | null;
18
18
  };
19
19
  declare class Paralayer extends Unit {
@@ -27,8 +27,7 @@ declare class Paralayer extends Unit {
27
27
  private previousLayers;
28
28
  private watcher;
29
29
  constructor(options: Options);
30
- start(): Promise<void>;
31
- readSetupJs(): Promise<string>;
30
+ start(): Promise<string | undefined>;
32
31
  private onAll;
33
32
  private onReady;
34
33
  private build;
@@ -43,6 +42,6 @@ declare class Paralayer extends Unit {
43
42
  private isTopLayer;
44
43
  private write;
45
44
  }
46
- declare function paralayer(options: Options): Promise<string>;
45
+ declare function paralayer(options: Options): Promise<string | undefined>;
47
46
 
48
47
  export { type DirPath, type File, type Options, Paralayer, paralayer as default, paralayer };
package/dist/paralayer.js CHANGED
@@ -27,8 +27,6 @@ var Paralayer = class extends Unit {
27
27
  await this.ready$.promise;
28
28
  await this.queue.run(() => this.build());
29
29
  if (!this.options.watch) await this.watcher.close();
30
- }
31
- async readSetupJs() {
32
30
  const setupJsPath = join(this.options.output, "setup.js");
33
31
  return await readFile(setupJsPath, "utf-8");
34
32
  }
@@ -128,7 +126,7 @@ var Paralayer = class extends Unit {
128
126
  }
129
127
  const globals = [
130
128
  `declare global {`,
131
- ` var ${layerName}: ${LayerName}`,
129
+ ` const ${layerName}: ${LayerName}`,
132
130
  ``,
133
131
  ` interface ${LayerName} ${extendPascal}{`,
134
132
  ...allNames.map((name) => ` ${name}: typeof ${name}`),
@@ -195,9 +193,8 @@ var Paralayer = class extends Unit {
195
193
  }
196
194
  };
197
195
  async function paralayer(options) {
198
- const pl = new Paralayer(options);
199
- await pl.start();
200
- return await pl.readSetupJs();
196
+ const setupLayersJs = await new Paralayer(options).start();
197
+ return setupLayersJs;
201
198
  }
202
199
  var paralayer_default = paralayer;
203
200
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paralayer",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "imkost",
@@ -23,6 +23,9 @@
23
23
  "source": "./src/paralayer.ts",
24
24
  "import": "./dist/paralayer.js",
25
25
  "types": "./dist/paralayer.d.ts"
26
+ },
27
+ "./ts": {
28
+ "import": "./src/paralayer.ts"
26
29
  }
27
30
  },
28
31
  "files": [
@@ -30,7 +33,7 @@
30
33
  "dist"
31
34
  ],
32
35
  "dependencies": {
33
- "@eposlabs/utils": "^1.9.0",
36
+ "@eposlabs/utils": "^1.10.0",
34
37
  "chokidar": "^4.0.3",
35
38
  "minimist": "^1.2.8"
36
39
  },
package/src/paralayer.ts CHANGED
@@ -19,7 +19,7 @@ export type Options = {
19
19
  globalize?: boolean
20
20
  /** If provided, other layers will extend this layer. */
21
21
  globalLayerName?: string | null
22
- /** If a file name does not have layer tags, default layer name will be used. */
22
+ /** If a file name does not have any layer tags, default layer name will be used. */
23
23
  defaultLayerName?: string | null
24
24
  }
25
25
 
@@ -52,9 +52,8 @@ export class Paralayer extends Unit {
52
52
  await this.ready$.promise
53
53
  await this.queue.run(() => this.build())
54
54
  if (!this.options.watch) await this.watcher.close()
55
- }
56
55
 
57
- async readSetupJs() {
56
+ // Return content of setup.js
58
57
  const setupJsPath = join(this.options.output, 'setup.js')
59
58
  return await readFile(setupJsPath, 'utf-8')
60
59
  }
@@ -201,7 +200,7 @@ export class Paralayer extends Unit {
201
200
 
202
201
  const globals = [
203
202
  `declare global {`,
204
- ` var ${layerName}: ${LayerName}`,
203
+ ` const ${layerName}: ${LayerName}`,
205
204
  ``,
206
205
  ` interface ${LayerName} ${extendPascal}{`,
207
206
  ...allNames.map(name => ` ${name}: typeof ${name}`),
@@ -285,9 +284,8 @@ export class Paralayer extends Unit {
285
284
  }
286
285
 
287
286
  export async function paralayer(options: Options) {
288
- const pl = new Paralayer(options)
289
- await pl.start()
290
- return await pl.readSetupJs()
287
+ const setupLayersJs = await new Paralayer(options).start()
288
+ return setupLayersJs
291
289
  }
292
290
 
293
291
  export default paralayer