fragment-tools 0.2.4 → 0.2.5
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/package.json
CHANGED
|
@@ -19,11 +19,15 @@
|
|
|
19
19
|
sketchesManager.loadAll(sketches);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
let prefix = $derived(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
let prefix = $derived.by(() => {
|
|
23
|
+
const { keys } = sketchesManager;
|
|
24
|
+
|
|
25
|
+
if (keys.length === 1) {
|
|
26
|
+
return `${sketchesManager.sketches[keys[0]].name ?? getFilename(sketchesManager.keys[0])} | `;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return '';
|
|
30
|
+
});
|
|
27
31
|
let title = $derived(`${prefix}fragment`);
|
|
28
32
|
</script>
|
|
29
33
|
|
|
@@ -304,6 +304,7 @@ class Rendering {
|
|
|
304
304
|
export let rendering = new Rendering();
|
|
305
305
|
|
|
306
306
|
export class Render {
|
|
307
|
+
loading = $state(false);
|
|
307
308
|
loaded = $state(false);
|
|
308
309
|
errored = $state(false);
|
|
309
310
|
paused = $state(false);
|
|
@@ -340,10 +341,11 @@ export class Render {
|
|
|
340
341
|
$effect(() => {
|
|
341
342
|
const { width, height, pixelRatio } = rendering;
|
|
342
343
|
|
|
343
|
-
if (!this.loaded) {
|
|
344
|
+
if (!this.loaded && !this.loading) {
|
|
344
345
|
this.width = width;
|
|
345
346
|
this.height = height;
|
|
346
347
|
this.pixelRatio = pixelRatio;
|
|
348
|
+
|
|
347
349
|
this.init();
|
|
348
350
|
}
|
|
349
351
|
});
|
|
@@ -477,6 +479,8 @@ export class Render {
|
|
|
477
479
|
this.init = async () => {
|
|
478
480
|
if (this.errored) return;
|
|
479
481
|
|
|
482
|
+
this.loading = true;
|
|
483
|
+
|
|
480
484
|
clearError(this.sketch.key);
|
|
481
485
|
this.mountParams = this.renderer?.onMountPreview?.(this.params);
|
|
482
486
|
if (this.mountParams && this.mountParams.canvas !== this.canvas) {
|
|
@@ -500,6 +504,7 @@ export class Render {
|
|
|
500
504
|
this.update(this.time);
|
|
501
505
|
});
|
|
502
506
|
|
|
507
|
+
this.loading = false;
|
|
503
508
|
this.loaded = true;
|
|
504
509
|
} catch (error) {
|
|
505
510
|
console.error(error);
|
|
@@ -703,11 +708,17 @@ export class Render {
|
|
|
703
708
|
this.removeShaderUpdateListener();
|
|
704
709
|
|
|
705
710
|
const { id, sketch } = this;
|
|
706
|
-
clearError(sketch.key);
|
|
707
711
|
|
|
708
712
|
this.renderer?.onDestroyPreview?.({ id });
|
|
709
713
|
this.destroyCanvas(this.canvas);
|
|
710
|
-
|
|
714
|
+
|
|
715
|
+
try {
|
|
716
|
+
sketch?.instance?.dispose?.();
|
|
717
|
+
} catch (error) {
|
|
718
|
+
console.error(error);
|
|
719
|
+
displayError(error, sketch.key);
|
|
720
|
+
this.errored = true;
|
|
721
|
+
}
|
|
711
722
|
|
|
712
723
|
cancelAnimationFrame(this.raf);
|
|
713
724
|
this.raf = null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { clearErrors } from '../state/errors.svelte';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
let { error } = $props();
|
|
5
5
|
|
|
6
6
|
export function getLineAndColNumber(stack) {
|
|
7
7
|
const match = stack.match(/(:([0-9]+)\:([0-9]+))/);
|
|
@@ -16,30 +16,34 @@
|
|
|
16
16
|
return { lineNumber, colNumber };
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
19
|
+
let stackLines = $derived(
|
|
20
|
+
error.stack
|
|
21
|
+
? error.stack
|
|
22
|
+
.split('\n')
|
|
23
|
+
.filter((line, i, s) => (s.length === 1 ? true : i !== 0))
|
|
24
|
+
.filter((line) => !line.includes('/app/'))
|
|
25
|
+
.map((line) => {
|
|
26
|
+
// remove path to file in URL
|
|
27
|
+
line = line.replace(
|
|
28
|
+
`${window.location.origin}/@fs${__CWD__}/`,
|
|
29
|
+
'',
|
|
30
|
+
);
|
|
31
|
+
// remove vite injected params in URL
|
|
32
|
+
line = line.replace(/\?.+?\:/g, ':');
|
|
33
|
+
|
|
34
|
+
return line;
|
|
35
|
+
})
|
|
36
|
+
: null,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
let extract = $derived(
|
|
40
|
+
error.source
|
|
41
|
+
? error.source.split('\n').map((text, index) => ({
|
|
42
|
+
text,
|
|
43
|
+
highlighted: text.includes(`> ${error.lineNumber}:`),
|
|
44
|
+
}))
|
|
45
|
+
: [],
|
|
46
|
+
);
|
|
43
47
|
</script>
|
|
44
48
|
|
|
45
49
|
<div class="error-overlay" on:click={() => clearErrors()}>
|