fragment-tools 0.1.15 → 0.1.16
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/bin/index.js
CHANGED
|
@@ -28,6 +28,7 @@ prog.command('run [entry]', '', { default: true })
|
|
|
28
28
|
.option('--outDir', 'Build output directory')
|
|
29
29
|
.option('--emptyOutDir', 'Empty outDir before static build')
|
|
30
30
|
.option('--base', 'Base public path when served in production', undefined)
|
|
31
|
+
.option('--prompts', 'Enable interactive prompts', true)
|
|
31
32
|
.action((entry, options) => {
|
|
32
33
|
if (options.new) {
|
|
33
34
|
return create(entry, {
|
|
@@ -41,6 +42,7 @@ prog.command('run [entry]', '', { default: true })
|
|
|
41
42
|
outDir: options.outDir,
|
|
42
43
|
emptyOutDir: options.emptyOutDir,
|
|
43
44
|
base: options.base,
|
|
45
|
+
prompts: options.prompts,
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -66,6 +68,7 @@ prog.command('build [entry]')
|
|
|
66
68
|
.option('--emptyOutDir', 'Empty outDir before building for production')
|
|
67
69
|
.option('--base', 'Base public path', undefined)
|
|
68
70
|
.option('-dev, --development', 'Enable development mode', false)
|
|
71
|
+
.option('--prompts', 'Enable interactive prompts', true)
|
|
69
72
|
.action((entry, options) => {
|
|
70
73
|
build(entry, options);
|
|
71
74
|
});
|
package/package.json
CHANGED
package/src/cli/build.js
CHANGED
|
@@ -17,12 +17,15 @@ import hotShaderReplacement from './plugins/hot-shader-replacement.js';
|
|
|
17
17
|
* @param {string} options.outDir
|
|
18
18
|
* @param {boolean} options.emptyOutDir
|
|
19
19
|
* @param {boolean} options.development
|
|
20
|
+
* @param {boolean} [options.prompts=true]
|
|
20
21
|
*/
|
|
21
22
|
export async function build(entry, options) {
|
|
22
23
|
const cwd = process.cwd();
|
|
23
24
|
const command = 'build';
|
|
24
25
|
const prefix = log.prefix(command);
|
|
25
26
|
|
|
27
|
+
const { prompts = true } = options;
|
|
28
|
+
|
|
26
29
|
try {
|
|
27
30
|
const entries = await getEntries(entry, cwd, command, prefix);
|
|
28
31
|
|
|
@@ -30,15 +33,19 @@ export async function build(entry, options) {
|
|
|
30
33
|
|
|
31
34
|
log.message(`${magenta(entry)}\n`, prefix);
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
placeholder: '.',
|
|
36
|
-
hint: '(hit Enter to use current directory)',
|
|
37
|
-
initialValue:
|
|
38
|
-
options.outDir ?? entries[0].split(path.extname(entries[0]))[0],
|
|
39
|
-
});
|
|
36
|
+
let outDir =
|
|
37
|
+
options.outDir ?? entries[0].split(path.extname(entries[0]))[0];
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
if (prompts) {
|
|
40
|
+
outDir = await p.text({
|
|
41
|
+
message: 'Output directory:',
|
|
42
|
+
placeholder: '.',
|
|
43
|
+
hint: '(hit Enter to use current directory)',
|
|
44
|
+
initialValue: outDir,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
handleCancelledPrompt(outDir, prefix);
|
|
48
|
+
}
|
|
42
49
|
|
|
43
50
|
let outDirPath = path.join(cwd, outDir);
|
|
44
51
|
|
|
@@ -52,24 +59,30 @@ export async function build(entry, options) {
|
|
|
52
59
|
if (files.length > 0) {
|
|
53
60
|
log.warn(`${outDirPath} is not an empty folder.\n`);
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
if (prompts) {
|
|
63
|
+
emptyOutDir = await p.confirm({
|
|
64
|
+
message: 'Empty folder before building?',
|
|
65
|
+
active: 'Yes',
|
|
66
|
+
inactive: 'No',
|
|
67
|
+
initialValue: emptyOutDir,
|
|
68
|
+
});
|
|
61
69
|
|
|
62
|
-
|
|
70
|
+
handleCancelledPrompt(emptyOutDir, prefix);
|
|
71
|
+
}
|
|
63
72
|
}
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
let base = options.base;
|
|
75
|
+
|
|
76
|
+
if (prompts) {
|
|
77
|
+
base = await p.text({
|
|
78
|
+
message: 'Base public path:',
|
|
79
|
+
placeholder: `/`,
|
|
80
|
+
hint: '(Hit Enter to validate)',
|
|
81
|
+
initialValue: base,
|
|
82
|
+
});
|
|
71
83
|
|
|
72
|
-
|
|
84
|
+
handleCancelledPrompt(base, prefix);
|
|
85
|
+
}
|
|
73
86
|
|
|
74
87
|
if (entries.length > 0) {
|
|
75
88
|
log.message(
|
|
@@ -17,7 +17,7 @@ let shader;
|
|
|
17
17
|
* @param {number} params.height
|
|
18
18
|
* @param {number} params.pixelRatio
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export function setup({ p, width, height }) {
|
|
21
21
|
shader = p.createShader(
|
|
22
22
|
/* glsl */ `
|
|
23
23
|
attribute vec3 aPosition;
|
|
@@ -39,7 +39,7 @@ void main() {
|
|
|
39
39
|
`,
|
|
40
40
|
fragmentShader,
|
|
41
41
|
);
|
|
42
|
-
}
|
|
42
|
+
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* @param {object} params
|
|
@@ -57,7 +57,7 @@ export let onResizePreview = ({ id, width, height, pixelRatio }) => {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
export let onDestroyPreview = ({ id }) => {
|
|
60
|
-
const previewIndex = previews.
|
|
60
|
+
const previewIndex = previews.findIndex((preview) => preview.id === id);
|
|
61
61
|
const preview = previews[previewIndex];
|
|
62
62
|
|
|
63
63
|
if (preview) {
|
|
@@ -31,7 +31,7 @@ export let onResizePreview = ({ id, width, height, pixelRatio }) => {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export let onDestroyPreview = ({ id }) => {
|
|
34
|
-
const previewIndex = previews.
|
|
34
|
+
const previewIndex = previews.findIndex((p) => p.id === id);
|
|
35
35
|
const preview = previews[previewIndex];
|
|
36
36
|
|
|
37
37
|
if (preview) {
|
|
@@ -182,6 +182,8 @@
|
|
|
182
182
|
async function createSketch(key) {
|
|
183
183
|
_created = false;
|
|
184
184
|
|
|
185
|
+
sketch?.dispose?.();
|
|
186
|
+
|
|
185
187
|
sketch = $sketches[key];
|
|
186
188
|
|
|
187
189
|
if (!key || !sketch) {
|
|
@@ -458,7 +460,7 @@
|
|
|
458
460
|
elapsed += dt;
|
|
459
461
|
|
|
460
462
|
if (!$sync) {
|
|
461
|
-
if (elapsed >= (1 / framerate) * 1000) {
|
|
463
|
+
if (elapsed >= (1 / framerate) * 1000 && _created) {
|
|
462
464
|
elapsed = 0;
|
|
463
465
|
_renderSketch();
|
|
464
466
|
}
|