paralayer 1.10.0 → 1.12.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
@@ -4,8 +4,8 @@
4
4
  import minimist from "minimist";
5
5
 
6
6
  // src/paralayer.ts
7
- import { Queue, Unit, safe } from "@eposlabs/utils";
8
7
  import { watch } from "chokidar";
8
+ import { Queue, Unit, is, safe } from "dropcap/utils";
9
9
  import { mkdir, readFile, rm, writeFile } from "fs/promises";
10
10
  import { basename, extname, join, relative } from "path";
11
11
  var Paralayer = class extends Unit {
@@ -30,10 +30,10 @@ var Paralayer = class extends Unit {
30
30
  this.watcher.on("all", this.onAll);
31
31
  this.watcher.on("ready", this.onReady);
32
32
  await this.ready$.promise;
33
- await this.queue.run(() => this.build());
33
+ await this.queue.add(() => this.build());
34
34
  if (!this.options.watch) await this.watcher.close();
35
- const setupJsPath = join(this.options.output, "setup.js");
36
- return await readFile(setupJsPath, "utf-8");
35
+ const defineJsPath = join(this.options.output, "define.js");
36
+ return await readFile(defineJsPath, "utf-8");
37
37
  }
38
38
  // ---------------------------------------------------------------------------
39
39
  // HANDLERS
@@ -49,11 +49,11 @@ var Paralayer = class extends Unit {
49
49
  }
50
50
  if (event === "unlink") {
51
51
  delete this.files[path];
52
- await this.queue.run(() => this.build());
52
+ await this.queue.add(() => this.build());
53
53
  }
54
54
  if (event === "add" || event === "change") {
55
55
  this.files[path] = null;
56
- await this.queue.run(() => this.build());
56
+ await this.queue.add(() => this.build());
57
57
  }
58
58
  };
59
59
  onReady = async () => {
@@ -98,16 +98,16 @@ var Paralayer = class extends Unit {
98
98
  await rm(indexFile);
99
99
  }
100
100
  }
101
- const setupFile = join(this.options.output, "setup.js");
102
- const setupContent = this.generateSetupContent(allLayers);
103
- await this.write(setupFile, setupContent);
101
+ const defineFile = join(this.options.output, "define.js");
102
+ const defineContent = this.generateDefineContent(allLayers);
103
+ await this.write(defineFile, defineContent);
104
104
  }
105
105
  // ---------------------------------------------------------------------------
106
106
  // HELPERS
107
107
  // ---------------------------------------------------------------------------
108
108
  extractExportedClassNames(content) {
109
109
  if (content.includes("paralayer-ignore")) return [];
110
- return content.split("export class ").slice(1).map((part) => part.split(" ")[0].split("<")[0]);
110
+ return content.split(/^export class /m).slice(1).map((part) => part.split(" ")[0]?.split("<")[0]).filter(is.present);
111
111
  }
112
112
  generateLayerContent(layer, layerPaths) {
113
113
  const layerName = this.getLayerName(layer, "camel");
@@ -158,7 +158,7 @@ var Paralayer = class extends Unit {
158
158
  }
159
159
  return [...imports].join("\n");
160
160
  }
161
- generateSetupContent(allLayers) {
161
+ generateDefineContent(allLayers) {
162
162
  const layers = allLayers.toSorted((layer1, layer2) => {
163
163
  if (layer1.length !== layer2.length) return layer1.length - layer2.length;
164
164
  return layer1.localeCompare(layer2);
@@ -180,7 +180,7 @@ var Paralayer = class extends Unit {
180
180
  const LayerName = layer.split(".").map(this.capitalize).join("");
181
181
  if (style === "camel") return this.decapitalize(LayerName);
182
182
  if (style === "Pascal") return LayerName;
183
- throw this.never;
183
+ throw this.never();
184
184
  }
185
185
  capitalize(string) {
186
186
  return string.charAt(0).toUpperCase() + string.slice(1);
@@ -198,8 +198,8 @@ var Paralayer = class extends Unit {
198
198
  }
199
199
  };
200
200
  async function paralayer(options) {
201
- const setupLayersJs = await new Paralayer(options).start();
202
- return setupLayersJs;
201
+ const defineLayersJs = await new Paralayer(options).start();
202
+ return defineLayersJs;
203
203
  }
204
204
 
205
205
  // src/bin.ts
@@ -1,4 +1,4 @@
1
- import { Unit } from '@eposlabs/utils';
1
+ import { Unit } from 'dropcap/utils';
2
2
 
3
3
  type DirPath = string;
4
4
  type File = {
@@ -34,7 +34,7 @@ declare class Paralayer extends Unit {
34
34
  private extractExportedClassNames;
35
35
  private generateLayerContent;
36
36
  private generateIndexContent;
37
- private generateSetupContent;
37
+ private generateDefineContent;
38
38
  private getLayer;
39
39
  private getLayerName;
40
40
  private capitalize;
package/dist/paralayer.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/paralayer.ts
2
- import { Queue, Unit, safe } from "@eposlabs/utils";
3
2
  import { watch } from "chokidar";
3
+ import { Queue, Unit, is, safe } from "dropcap/utils";
4
4
  import { mkdir, readFile, rm, writeFile } from "fs/promises";
5
5
  import { basename, extname, join, relative } from "path";
6
6
  var Paralayer = class extends Unit {
@@ -25,10 +25,10 @@ var Paralayer = class extends Unit {
25
25
  this.watcher.on("all", this.onAll);
26
26
  this.watcher.on("ready", this.onReady);
27
27
  await this.ready$.promise;
28
- await this.queue.run(() => this.build());
28
+ await this.queue.add(() => this.build());
29
29
  if (!this.options.watch) await this.watcher.close();
30
- const setupJsPath = join(this.options.output, "setup.js");
31
- return await readFile(setupJsPath, "utf-8");
30
+ const defineJsPath = join(this.options.output, "define.js");
31
+ return await readFile(defineJsPath, "utf-8");
32
32
  }
33
33
  // ---------------------------------------------------------------------------
34
34
  // HANDLERS
@@ -44,11 +44,11 @@ var Paralayer = class extends Unit {
44
44
  }
45
45
  if (event === "unlink") {
46
46
  delete this.files[path];
47
- await this.queue.run(() => this.build());
47
+ await this.queue.add(() => this.build());
48
48
  }
49
49
  if (event === "add" || event === "change") {
50
50
  this.files[path] = null;
51
- await this.queue.run(() => this.build());
51
+ await this.queue.add(() => this.build());
52
52
  }
53
53
  };
54
54
  onReady = async () => {
@@ -93,16 +93,16 @@ var Paralayer = class extends Unit {
93
93
  await rm(indexFile);
94
94
  }
95
95
  }
96
- const setupFile = join(this.options.output, "setup.js");
97
- const setupContent = this.generateSetupContent(allLayers);
98
- await this.write(setupFile, setupContent);
96
+ const defineFile = join(this.options.output, "define.js");
97
+ const defineContent = this.generateDefineContent(allLayers);
98
+ await this.write(defineFile, defineContent);
99
99
  }
100
100
  // ---------------------------------------------------------------------------
101
101
  // HELPERS
102
102
  // ---------------------------------------------------------------------------
103
103
  extractExportedClassNames(content) {
104
104
  if (content.includes("paralayer-ignore")) return [];
105
- return content.split("export class ").slice(1).map((part) => part.split(" ")[0].split("<")[0]);
105
+ return content.split(/^export class /m).slice(1).map((part) => part.split(" ")[0]?.split("<")[0]).filter(is.present);
106
106
  }
107
107
  generateLayerContent(layer, layerPaths) {
108
108
  const layerName = this.getLayerName(layer, "camel");
@@ -153,7 +153,7 @@ var Paralayer = class extends Unit {
153
153
  }
154
154
  return [...imports].join("\n");
155
155
  }
156
- generateSetupContent(allLayers) {
156
+ generateDefineContent(allLayers) {
157
157
  const layers = allLayers.toSorted((layer1, layer2) => {
158
158
  if (layer1.length !== layer2.length) return layer1.length - layer2.length;
159
159
  return layer1.localeCompare(layer2);
@@ -175,7 +175,7 @@ var Paralayer = class extends Unit {
175
175
  const LayerName = layer.split(".").map(this.capitalize).join("");
176
176
  if (style === "camel") return this.decapitalize(LayerName);
177
177
  if (style === "Pascal") return LayerName;
178
- throw this.never;
178
+ throw this.never();
179
179
  }
180
180
  capitalize(string) {
181
181
  return string.charAt(0).toUpperCase() + string.slice(1);
@@ -193,8 +193,8 @@ var Paralayer = class extends Unit {
193
193
  }
194
194
  };
195
195
  async function paralayer(options) {
196
- const setupLayersJs = await new Paralayer(options).start();
197
- return setupLayersJs;
196
+ const defineLayersJs = await new Paralayer(options).start();
197
+ return defineLayersJs;
198
198
  }
199
199
  var paralayer_default = paralayer;
200
200
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paralayer",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "imkost",
@@ -19,22 +19,16 @@
19
19
  "paralayer": "./src/bin.js"
20
20
  },
21
21
  "exports": {
22
- ".": {
23
- "source": "./src/paralayer.ts",
24
- "import": "./dist/paralayer.js",
25
- "types": "./dist/paralayer.d.ts"
26
- },
27
- "./ts": {
28
- "import": "./src/paralayer.ts"
29
- }
22
+ ".": "./dist/paralayer.js",
23
+ "./ts": "./src/paralayer.ts"
30
24
  },
31
25
  "files": [
32
26
  "src",
33
27
  "dist"
34
28
  ],
35
29
  "dependencies": {
36
- "@eposlabs/utils": "^1.10.0",
37
- "chokidar": "^4.0.3",
30
+ "chokidar": "^5.0.0",
31
+ "dropcap": "^1.0.0",
38
32
  "minimist": "^1.2.8"
39
33
  },
40
34
  "devDependencies": {
package/src/paralayer.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { Queue, Unit, safe } from '@eposlabs/utils'
2
- import type { FSWatcher } from 'chokidar'
3
- import { watch } from 'chokidar'
1
+ import { watch, type FSWatcher } from 'chokidar'
2
+ import { Queue, Unit, is, safe } from 'dropcap/utils'
4
3
  import { mkdir, readFile, rm, writeFile } from 'node:fs/promises'
5
4
  import { basename, extname, join, relative } from 'node:path'
6
5
 
@@ -50,12 +49,12 @@ export class Paralayer extends Unit {
50
49
  this.watcher.on('ready', this.onReady)
51
50
 
52
51
  await this.ready$.promise
53
- await this.queue.run(() => this.build())
52
+ await this.queue.add(() => this.build())
54
53
  if (!this.options.watch) await this.watcher.close()
55
54
 
56
- // Return content of setup.js
57
- const setupJsPath = join(this.options.output, 'setup.js')
58
- return await readFile(setupJsPath, 'utf-8')
55
+ // Return content of define.js
56
+ const defineJsPath = join(this.options.output, 'define.js')
57
+ return await readFile(defineJsPath, 'utf-8')
59
58
  }
60
59
 
61
60
  // ---------------------------------------------------------------------------
@@ -82,13 +81,13 @@ export class Paralayer extends Unit {
82
81
  // File removed? -> Remove and rebuild
83
82
  if (event === 'unlink') {
84
83
  delete this.files[path]
85
- await this.queue.run(() => this.build())
84
+ await this.queue.add(() => this.build())
86
85
  }
87
86
 
88
87
  // File added/changed? -> Reset its content and rebuild
89
88
  if (event === 'add' || event === 'change') {
90
89
  this.files[path] = null
91
- await this.queue.run(() => this.build())
90
+ await this.queue.add(() => this.build())
92
91
  }
93
92
  }
94
93
 
@@ -154,10 +153,10 @@ export class Paralayer extends Unit {
154
153
  }
155
154
  }
156
155
 
157
- // Generate setup.js file
158
- const setupFile = join(this.options.output, 'setup.js')
159
- const setupContent = this.generateSetupContent(allLayers)
160
- await this.write(setupFile, setupContent)
156
+ // Generate define.js file
157
+ const defineFile = join(this.options.output, 'define.js')
158
+ const defineContent = this.generateDefineContent(allLayers)
159
+ await this.write(defineFile, defineContent)
161
160
  }
162
161
 
163
162
  // ---------------------------------------------------------------------------
@@ -167,9 +166,10 @@ export class Paralayer extends Unit {
167
166
  private extractExportedClassNames(content: string) {
168
167
  if (content.includes('paralayer-ignore')) return []
169
168
  return content
170
- .split('export class ')
169
+ .split(/^export class /m)
171
170
  .slice(1)
172
- .map(part => part.split(' ')[0].split('<')[0])
171
+ .map(part => part.split(' ')[0]?.split('<')[0])
172
+ .filter(is.present)
173
173
  }
174
174
 
175
175
  private generateLayerContent(layer: string, layerPaths: string[]) {
@@ -235,7 +235,7 @@ export class Paralayer extends Unit {
235
235
  return [...imports].join('\n')
236
236
  }
237
237
 
238
- private generateSetupContent(allLayers: string[]) {
238
+ private generateDefineContent(allLayers: string[]) {
239
239
  const layers = allLayers.toSorted((layer1, layer2) => {
240
240
  if (layer1.length !== layer2.length) return layer1.length - layer2.length
241
241
  return layer1.localeCompare(layer2)
@@ -261,7 +261,7 @@ export class Paralayer extends Unit {
261
261
  const LayerName = layer.split('.').map(this.capitalize).join('')
262
262
  if (style === 'camel') return this.decapitalize(LayerName)
263
263
  if (style === 'Pascal') return LayerName
264
- throw this.never
264
+ throw this.never()
265
265
  }
266
266
 
267
267
  private capitalize(string: string) {
@@ -284,8 +284,8 @@ export class Paralayer extends Unit {
284
284
  }
285
285
 
286
286
  export async function paralayer(options: Options) {
287
- const setupLayersJs = await new Paralayer(options).start()
288
- return setupLayersJs
287
+ const defineLayersJs = await new Paralayer(options).start()
288
+ return defineLayersJs
289
289
  }
290
290
 
291
291
  export default paralayer