@htmlplus/element 2.10.0 → 2.11.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/bundlers/vite.d.ts
CHANGED
package/bundlers/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { transformer } from '../transformer/index.js';
|
|
3
3
|
export const htmlplus = (...plugins) => {
|
|
4
|
-
const { start, run, finish } = transformer(...plugins);
|
|
4
|
+
const { global, start, run, finish, write } = transformer(...plugins);
|
|
5
5
|
return {
|
|
6
6
|
name: 'htmlplus',
|
|
7
7
|
async buildStart() {
|
|
@@ -20,6 +20,33 @@ export const htmlplus = (...plugins) => {
|
|
|
20
20
|
},
|
|
21
21
|
async buildEnd() {
|
|
22
22
|
await finish();
|
|
23
|
+
},
|
|
24
|
+
async writeBundle(options, bundles) {
|
|
25
|
+
// TODO
|
|
26
|
+
try {
|
|
27
|
+
for (const context of global.contexts) {
|
|
28
|
+
for (const key in bundles) {
|
|
29
|
+
if (!Object.hasOwnProperty.call(bundles, key))
|
|
30
|
+
continue;
|
|
31
|
+
const bundle = bundles[key];
|
|
32
|
+
if (!bundle.facadeModuleId.startsWith(context.filePath))
|
|
33
|
+
continue;
|
|
34
|
+
const modules = bundle['modules'];
|
|
35
|
+
for (const key in modules) {
|
|
36
|
+
if (!Object.hasOwnProperty.call(modules, key))
|
|
37
|
+
continue;
|
|
38
|
+
const module = modules[key];
|
|
39
|
+
if (!key.startsWith(context.stylePath || ''))
|
|
40
|
+
continue;
|
|
41
|
+
context.styleContentTransformed = module.code;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch { }
|
|
49
|
+
await write();
|
|
23
50
|
}
|
|
24
51
|
};
|
|
25
52
|
};
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ export const DOCUMENT_OPTIONS = {
|
|
|
10
10
|
export const document = (options) => {
|
|
11
11
|
const name = 'document';
|
|
12
12
|
options = Object.assign({}, DOCUMENT_OPTIONS, options);
|
|
13
|
-
const
|
|
13
|
+
const write = (global) => {
|
|
14
14
|
const json = {
|
|
15
15
|
elements: []
|
|
16
16
|
};
|
|
@@ -164,7 +164,18 @@ export const document = (options) => {
|
|
|
164
164
|
const [first, second] = section.split(/\n/);
|
|
165
165
|
const description = first.replace('*/', '').trim();
|
|
166
166
|
const name = second.split(':')[0].trim();
|
|
167
|
-
const
|
|
167
|
+
const initializerDefault = second.split(':').slice(1).join(':').replace(';', '').trim();
|
|
168
|
+
// TODO
|
|
169
|
+
const initializerTransformed = context.styleContentTransformed
|
|
170
|
+
?.split(name)
|
|
171
|
+
?.at(1)
|
|
172
|
+
?.split(':')
|
|
173
|
+
?.filter((section) => !!section)
|
|
174
|
+
?.at(0)
|
|
175
|
+
?.split(/;|}/)
|
|
176
|
+
?.at(0)
|
|
177
|
+
?.trim();
|
|
178
|
+
const initializer = initializerTransformed || initializerDefault;
|
|
168
179
|
return {
|
|
169
180
|
description,
|
|
170
181
|
initializer,
|
|
@@ -191,5 +202,5 @@ export const document = (options) => {
|
|
|
191
202
|
fs.ensureDirSync(dirname);
|
|
192
203
|
fs.writeJSONSync(options.destination, json, { encoding: 'utf8', spaces: 2 });
|
|
193
204
|
};
|
|
194
|
-
return { name,
|
|
205
|
+
return { name, write };
|
|
195
206
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { TransformerPlugin, TransformerPluginContext } from './transformer.types.js';
|
|
1
|
+
import { TransformerPlugin, TransformerPluginContext, TransformerPluginGlobal } from './transformer.types.js';
|
|
2
2
|
export declare const transformer: (...plugins: TransformerPlugin[]) => {
|
|
3
|
+
global: TransformerPluginGlobal;
|
|
3
4
|
start: () => Promise<void>;
|
|
4
5
|
run: (filePath: string) => Promise<TransformerPluginContext>;
|
|
5
6
|
finish: () => Promise<void>;
|
|
7
|
+
write: () => Promise<void>;
|
|
6
8
|
};
|
|
@@ -67,5 +67,12 @@ export const transformer = (...plugins) => {
|
|
|
67
67
|
log(`Plugins finished successfully.`, true);
|
|
68
68
|
log(`Finished.`, true);
|
|
69
69
|
};
|
|
70
|
-
|
|
70
|
+
const write = async () => {
|
|
71
|
+
for (const plugin of plugins) {
|
|
72
|
+
if (!plugin.write)
|
|
73
|
+
continue;
|
|
74
|
+
global = (await plugin.write(global)) || global;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
return { global, start, run, finish, write };
|
|
71
78
|
};
|
|
@@ -30,6 +30,7 @@ export interface TransformerPluginContext {
|
|
|
30
30
|
readmeName?: string;
|
|
31
31
|
readmePath?: string;
|
|
32
32
|
styleContent?: string;
|
|
33
|
+
styleContentTransformed?: string;
|
|
33
34
|
styleExtension?: string;
|
|
34
35
|
styleName?: string;
|
|
35
36
|
stylePath?: string;
|
|
@@ -46,5 +47,6 @@ export interface TransformerPlugin {
|
|
|
46
47
|
start?: (global: TransformerPluginGlobal) => Return<TransformerPluginGlobal>;
|
|
47
48
|
run?: (context: TransformerPluginContext, global: TransformerPluginGlobal) => Return<TransformerPluginContext>;
|
|
48
49
|
finish?: (global: TransformerPluginGlobal) => Return<TransformerPluginGlobal>;
|
|
50
|
+
write?: (global: TransformerPluginGlobal) => Return<TransformerPluginGlobal>;
|
|
49
51
|
}
|
|
50
52
|
export {};
|