paralayer 1.11.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 +10 -10
- package/dist/paralayer.d.ts +1 -1
- package/dist/paralayer.js +10 -10
- package/package.json +3 -9
- package/src/paralayer.ts +14 -13
package/dist/bin.js
CHANGED
|
@@ -5,7 +5,7 @@ import minimist from "minimist";
|
|
|
5
5
|
|
|
6
6
|
// src/paralayer.ts
|
|
7
7
|
import { watch } from "chokidar";
|
|
8
|
-
import { Queue, Unit, safe } from "dropcap/utils";
|
|
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 {
|
|
@@ -32,8 +32,8 @@ var Paralayer = class extends Unit {
|
|
|
32
32
|
await this.ready$.promise;
|
|
33
33
|
await this.queue.add(() => this.build());
|
|
34
34
|
if (!this.options.watch) await this.watcher.close();
|
|
35
|
-
const
|
|
36
|
-
return await readFile(
|
|
35
|
+
const defineJsPath = join(this.options.output, "define.js");
|
|
36
|
+
return await readFile(defineJsPath, "utf-8");
|
|
37
37
|
}
|
|
38
38
|
// ---------------------------------------------------------------------------
|
|
39
39
|
// HANDLERS
|
|
@@ -98,16 +98,16 @@ var Paralayer = class extends Unit {
|
|
|
98
98
|
await rm(indexFile);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
await this.write(
|
|
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(
|
|
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
|
-
|
|
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);
|
|
@@ -198,8 +198,8 @@ var Paralayer = class extends Unit {
|
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
async function paralayer(options) {
|
|
201
|
-
const
|
|
202
|
-
return
|
|
201
|
+
const defineLayersJs = await new Paralayer(options).start();
|
|
202
|
+
return defineLayersJs;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
// src/bin.ts
|
package/dist/paralayer.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ declare class Paralayer extends Unit {
|
|
|
34
34
|
private extractExportedClassNames;
|
|
35
35
|
private generateLayerContent;
|
|
36
36
|
private generateIndexContent;
|
|
37
|
-
private
|
|
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
2
|
import { watch } from "chokidar";
|
|
3
|
-
import { Queue, Unit, safe } from "dropcap/utils";
|
|
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 {
|
|
@@ -27,8 +27,8 @@ var Paralayer = class extends Unit {
|
|
|
27
27
|
await this.ready$.promise;
|
|
28
28
|
await this.queue.add(() => this.build());
|
|
29
29
|
if (!this.options.watch) await this.watcher.close();
|
|
30
|
-
const
|
|
31
|
-
return await readFile(
|
|
30
|
+
const defineJsPath = join(this.options.output, "define.js");
|
|
31
|
+
return await readFile(defineJsPath, "utf-8");
|
|
32
32
|
}
|
|
33
33
|
// ---------------------------------------------------------------------------
|
|
34
34
|
// HANDLERS
|
|
@@ -93,16 +93,16 @@ var Paralayer = class extends Unit {
|
|
|
93
93
|
await rm(indexFile);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
await this.write(
|
|
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(
|
|
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
|
-
|
|
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);
|
|
@@ -193,8 +193,8 @@ var Paralayer = class extends Unit {
|
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
195
|
async function paralayer(options) {
|
|
196
|
-
const
|
|
197
|
-
return
|
|
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.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "imkost",
|
|
@@ -19,14 +19,8 @@
|
|
|
19
19
|
"paralayer": "./src/bin.js"
|
|
20
20
|
},
|
|
21
21
|
"exports": {
|
|
22
|
-
".":
|
|
23
|
-
|
|
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",
|
package/src/paralayer.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { watch, type FSWatcher } from 'chokidar'
|
|
2
|
-
import { Queue, Unit, safe } from 'dropcap/utils'
|
|
2
|
+
import { Queue, Unit, is, safe } from 'dropcap/utils'
|
|
3
3
|
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises'
|
|
4
4
|
import { basename, extname, join, relative } from 'node:path'
|
|
5
5
|
|
|
@@ -52,9 +52,9 @@ export class Paralayer extends Unit {
|
|
|
52
52
|
await this.queue.add(() => this.build())
|
|
53
53
|
if (!this.options.watch) await this.watcher.close()
|
|
54
54
|
|
|
55
|
-
// Return content of
|
|
56
|
-
const
|
|
57
|
-
return await readFile(
|
|
55
|
+
// Return content of define.js
|
|
56
|
+
const defineJsPath = join(this.options.output, 'define.js')
|
|
57
|
+
return await readFile(defineJsPath, 'utf-8')
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// ---------------------------------------------------------------------------
|
|
@@ -153,10 +153,10 @@ export class Paralayer extends Unit {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
// Generate
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
await this.write(
|
|
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)
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
// ---------------------------------------------------------------------------
|
|
@@ -166,9 +166,10 @@ export class Paralayer extends Unit {
|
|
|
166
166
|
private extractExportedClassNames(content: string) {
|
|
167
167
|
if (content.includes('paralayer-ignore')) return []
|
|
168
168
|
return content
|
|
169
|
-
.split(
|
|
169
|
+
.split(/^export class /m)
|
|
170
170
|
.slice(1)
|
|
171
|
-
.map(part => part.split(' ')[0]
|
|
171
|
+
.map(part => part.split(' ')[0]?.split('<')[0])
|
|
172
|
+
.filter(is.present)
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
private generateLayerContent(layer: string, layerPaths: string[]) {
|
|
@@ -234,7 +235,7 @@ export class Paralayer extends Unit {
|
|
|
234
235
|
return [...imports].join('\n')
|
|
235
236
|
}
|
|
236
237
|
|
|
237
|
-
private
|
|
238
|
+
private generateDefineContent(allLayers: string[]) {
|
|
238
239
|
const layers = allLayers.toSorted((layer1, layer2) => {
|
|
239
240
|
if (layer1.length !== layer2.length) return layer1.length - layer2.length
|
|
240
241
|
return layer1.localeCompare(layer2)
|
|
@@ -283,8 +284,8 @@ export class Paralayer extends Unit {
|
|
|
283
284
|
}
|
|
284
285
|
|
|
285
286
|
export async function paralayer(options: Options) {
|
|
286
|
-
const
|
|
287
|
-
return
|
|
287
|
+
const defineLayersJs = await new Paralayer(options).start()
|
|
288
|
+
return defineLayersJs
|
|
288
289
|
}
|
|
289
290
|
|
|
290
291
|
export default paralayer
|