@awesomeness-js/utils 1.1.3 → 1.1.4
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/README.md +1 -3
- package/build/build.js +0 -6
- package/index.js +1 -4
- package/package.json +1 -1
- package/src/build.js +3 -67
- package/types/build.d.ts +1 -4
- package/types/index.d.ts +0 -3
- package/src/utils/writeHotWrapper.js +0 -42
- package/types/clean/thing.d.ts +0 -2
- package/types/hashPassword.d.ts +0 -1
- package/types/utils/shouldIgnore.d.ts +0 -1
- package/types/utils/writeHotWrapper.d.ts +0 -4
- package/types/validatePassword.d.ts +0 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Webpack is a great bundler, but it’s not suited for building a structured expo
|
|
|
36
36
|
✔ **Simple and predictable**—You control how exports are structured.
|
|
37
37
|
✔ **Namespace support**—Uses folder structure to organize functions logically.
|
|
38
38
|
✔ **Minimal setup** — one line to generate your exports
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
|
|
41
41
|
> Uses `chokidar` under the hood for reliable cross-platform file watching.
|
|
42
42
|
|
|
@@ -75,7 +75,6 @@ await build({
|
|
|
75
75
|
dest: './api.js',
|
|
76
76
|
includeComments: true,
|
|
77
77
|
useTabs: true,
|
|
78
|
-
hotModuleReload: true // Enable hot reload for dev
|
|
79
78
|
});
|
|
80
79
|
```
|
|
81
80
|
|
|
@@ -171,5 +170,4 @@ If that makes you hard, you’re in the right place.
|
|
|
171
170
|
✱ disclaimer... *Kinda zero dependencies.*
|
|
172
171
|
Zero **prod** dependencies.
|
|
173
172
|
> dev dependencies:
|
|
174
|
-
> `chokidar` for hot module reloading (HMR)
|
|
175
173
|
> `vitest` for testing
|
package/build/build.js
CHANGED
package/index.js
CHANGED
|
@@ -38,7 +38,6 @@ import _utils_generateImportStatements from './src/utils/generateImportStatement
|
|
|
38
38
|
import _utils_generateNamedExports from './src/utils/generateNamedExports.js';
|
|
39
39
|
import _utils_generateNamespaceCode from './src/utils/generateNamespaceCode.js';
|
|
40
40
|
import _utils_generateNamespaceExportLines from './src/utils/generateNamespaceExportLines.js';
|
|
41
|
-
import _utils_writeHotWrapper from './src/utils/writeHotWrapper.js';
|
|
42
41
|
import _uuid from './src/uuid.js';
|
|
43
42
|
import _validateSchema from './src/validateSchema.js';
|
|
44
43
|
|
|
@@ -86,8 +85,7 @@ export const utils = {
|
|
|
86
85
|
generateImportStatements: _utils_generateImportStatements,
|
|
87
86
|
generateNamedExports: _utils_generateNamedExports,
|
|
88
87
|
generateNamespaceCode: _utils_generateNamespaceCode,
|
|
89
|
-
generateNamespaceExportLines: _utils_generateNamespaceExportLines
|
|
90
|
-
writeHotWrapper: _utils_writeHotWrapper
|
|
88
|
+
generateNamespaceExportLines: _utils_generateNamespaceExportLines
|
|
91
89
|
};
|
|
92
90
|
|
|
93
91
|
|
|
@@ -162,6 +160,5 @@ export default {
|
|
|
162
160
|
generateNamedExports: _utils_generateNamedExports,
|
|
163
161
|
generateNamespaceCode: _utils_generateNamespaceCode,
|
|
164
162
|
generateNamespaceExportLines: _utils_generateNamespaceExportLines,
|
|
165
|
-
writeHotWrapper: _utils_writeHotWrapper,
|
|
166
163
|
},
|
|
167
164
|
};
|
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { writeFileSync } from 'fs';
|
|
14
14
|
import generateFile from './utils/generateFile.js';
|
|
15
|
-
import writeHotWrapper from './utils/writeHotWrapper.js';
|
|
16
15
|
|
|
17
16
|
async function build({
|
|
18
17
|
src = './src',
|
|
@@ -22,9 +21,6 @@ async function build({
|
|
|
22
21
|
includeComments = true,
|
|
23
22
|
dts = false,
|
|
24
23
|
useTabs = true,
|
|
25
|
-
hotModuleReload = false,
|
|
26
|
-
hotCallback = null,
|
|
27
|
-
hotSource = './hot-source.js' // generated only when hot is enabled
|
|
28
24
|
} = {}) {
|
|
29
25
|
|
|
30
26
|
const gen = () => generateFile({
|
|
@@ -36,70 +32,10 @@ async function build({
|
|
|
36
32
|
useTabs
|
|
37
33
|
});
|
|
38
34
|
|
|
39
|
-
const buildHot = () => {
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// 2) ensure index.js is a hot wrapper
|
|
46
|
-
writeHotWrapper({
|
|
47
|
-
dest,
|
|
48
|
-
hotSource
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
console.log(`[build] ensured hot wrapper ${dest}`);
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const buildCold = () => {
|
|
56
|
-
|
|
57
|
-
// single-file classic output (no second file)
|
|
58
|
-
writeFileSync(dest, gen());
|
|
59
|
-
console.log(`[build] wrote ${dest}`);
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
if (hotModuleReload) {
|
|
64
|
-
|
|
65
|
-
buildHot();
|
|
66
|
-
|
|
67
|
-
// watch only src; each change regenerates hot-source.js (wrapper auto-reloads it)
|
|
68
|
-
const chokidar = (await import('chokidar')).default;
|
|
69
|
-
|
|
70
|
-
console.log(`[build] watching ${src} for changes...`);
|
|
71
|
-
const watcher = chokidar.watch(src, {
|
|
72
|
-
ignoreInitial: true,
|
|
73
|
-
ignored: ignore
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
let timeout;
|
|
77
|
-
|
|
78
|
-
watcher.on('all', (_event, file) => {
|
|
79
|
-
|
|
80
|
-
clearTimeout(timeout);
|
|
81
|
-
timeout = setTimeout(() => {
|
|
82
|
-
|
|
83
|
-
console.log(`[build] change detected in ${file}, rebuilding payload...`);
|
|
84
|
-
writeFileSync(hotSource, gen());
|
|
85
|
-
|
|
86
|
-
if(typeof hotCallback === 'function') {
|
|
87
|
-
|
|
88
|
-
hotCallback(file);
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
console.log(`[build] ready.`);
|
|
93
|
-
|
|
94
|
-
}, 50);
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
} else {
|
|
99
|
-
|
|
100
|
-
buildCold();
|
|
101
|
-
|
|
102
|
-
}
|
|
36
|
+
// single-file classic output (no second file)
|
|
37
|
+
writeFileSync(dest, gen());
|
|
38
|
+
console.log(`[build] wrote ${dest}`);
|
|
103
39
|
|
|
104
40
|
return true;
|
|
105
41
|
|
package/types/build.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default build;
|
|
2
|
-
declare function build({ src, dest, exportRoots, ignore, includeComments, dts, useTabs,
|
|
2
|
+
declare function build({ src, dest, exportRoots, ignore, includeComments, dts, useTabs, }?: {
|
|
3
3
|
src?: string;
|
|
4
4
|
dest?: string;
|
|
5
5
|
exportRoots?: boolean;
|
|
@@ -7,7 +7,4 @@ declare function build({ src, dest, exportRoots, ignore, includeComments, dts, u
|
|
|
7
7
|
includeComments?: boolean;
|
|
8
8
|
dts?: boolean;
|
|
9
9
|
useTabs?: boolean;
|
|
10
|
-
hotModuleReload?: boolean;
|
|
11
|
-
hotCallback?: any;
|
|
12
|
-
hotSource?: string;
|
|
13
10
|
}): Promise<boolean>;
|
package/types/index.d.ts
CHANGED
|
@@ -38,7 +38,6 @@ import type _utils_generateImportStatements from './utils/generateImportStatemen
|
|
|
38
38
|
import type _utils_generateNamedExports from './utils/generateNamedExports';
|
|
39
39
|
import type _utils_generateNamespaceCode from './utils/generateNamespaceCode';
|
|
40
40
|
import type _utils_generateNamespaceExportLines from './utils/generateNamespaceExportLines';
|
|
41
|
-
import type _utils_writeHotWrapper from './utils/writeHotWrapper';
|
|
42
41
|
import type _uuid from './uuid';
|
|
43
42
|
import type _validateSchema from './validateSchema';
|
|
44
43
|
|
|
@@ -87,7 +86,6 @@ export declare const utils: {
|
|
|
87
86
|
generateNamedExports: typeof _utils_generateNamedExports;
|
|
88
87
|
generateNamespaceCode: typeof _utils_generateNamespaceCode;
|
|
89
88
|
generateNamespaceExportLines: typeof _utils_generateNamespaceExportLines;
|
|
90
|
-
writeHotWrapper: typeof _utils_writeHotWrapper;
|
|
91
89
|
};
|
|
92
90
|
|
|
93
91
|
|
|
@@ -162,7 +160,6 @@ declare const _default: {
|
|
|
162
160
|
generateNamedExports: typeof _utils_generateNamedExports,
|
|
163
161
|
generateNamespaceCode: typeof _utils_generateNamespaceCode,
|
|
164
162
|
generateNamespaceExportLines: typeof _utils_generateNamespaceExportLines,
|
|
165
|
-
writeHotWrapper: typeof _utils_writeHotWrapper,
|
|
166
163
|
},
|
|
167
164
|
};
|
|
168
165
|
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from 'node:fs';
|
|
2
|
-
|
|
3
|
-
export default function writeHotWrapper({
|
|
4
|
-
dest,
|
|
5
|
-
hotSource
|
|
6
|
-
}) {
|
|
7
|
-
|
|
8
|
-
const wrapper = `// auto-generated wrapper
|
|
9
|
-
import chokidar from 'chokidar';
|
|
10
|
-
import path from 'node:path';
|
|
11
|
-
import { pathToFileURL } from 'node:url';
|
|
12
|
-
|
|
13
|
-
let _default;
|
|
14
|
-
|
|
15
|
-
export { _default as default };
|
|
16
|
-
|
|
17
|
-
const target = path.resolve(${JSON.stringify(hotSource)});
|
|
18
|
-
|
|
19
|
-
async function reload() {
|
|
20
|
-
|
|
21
|
-
const mod = await import(\`\${pathToFileURL(target)}?t=\${Date.now()}\`);
|
|
22
|
-
|
|
23
|
-
_default = mod.default;
|
|
24
|
-
console.log('[hot] reloaded', target);
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
await reload();
|
|
29
|
-
|
|
30
|
-
let t;
|
|
31
|
-
|
|
32
|
-
chokidar.watch(target, { ignoreInitial: true }).on('all', () => {
|
|
33
|
-
|
|
34
|
-
clearTimeout(t);
|
|
35
|
-
t = setTimeout(() => reload().catch(err => console.error('[hot] failed:', err)), 50);
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
|
-
writeFileSync(dest, wrapper);
|
|
41
|
-
|
|
42
|
-
}
|
package/types/clean/thing.d.ts
DELETED
package/types/hashPassword.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function hashPassword(password: any): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function shouldIgnore(filePath: any, ignorePatterns: any): any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function validatePassword(password: any, storedHash: any): boolean;
|