@gigo-ui/components 1.0.0-release → 1.0.1
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 +158 -132
- package/dist/components/chaos/BlackHoleSink.svelte +81 -0
- package/dist/components/chaos/BlackHoleSink.svelte.d.ts +16 -0
- package/dist/components/chaos/GigoCompactor.svelte +103 -0
- package/dist/components/chaos/GigoCompactor.svelte.d.ts +16 -0
- package/dist/components/chaos/PixelDissolve.svelte +81 -0
- package/dist/components/chaos/PixelDissolve.svelte.d.ts +16 -0
- package/dist/components/chaos/ShatterPane.svelte +84 -0
- package/dist/components/chaos/ShatterPane.svelte.d.ts +16 -0
- package/dist/components/chaos/internal/BlackHoleEngine.svelte +167 -0
- package/dist/components/chaos/internal/BlackHoleEngine.svelte.d.ts +11 -0
- package/dist/components/chaos/internal/CompactorEngine.svelte +195 -0
- package/dist/components/chaos/internal/CompactorEngine.svelte.d.ts +11 -0
- package/dist/components/chaos/internal/PixelDissolveEngine.svelte +168 -0
- package/dist/components/chaos/internal/PixelDissolveEngine.svelte.d.ts +11 -0
- package/dist/components/chaos/internal/ShatterEngine.svelte +208 -0
- package/dist/components/chaos/internal/ShatterEngine.svelte.d.ts +11 -0
- package/dist/docs/component-data.js +8 -0
- package/dist/docs/components/chaos/black-hole-sink.d.ts +2 -0
- package/dist/docs/components/chaos/black-hole-sink.js +71 -0
- package/dist/docs/components/chaos/gigo-compactor.d.ts +2 -0
- package/dist/docs/components/chaos/gigo-compactor.js +71 -0
- package/dist/docs/components/chaos/pixel-dissolve.d.ts +2 -0
- package/dist/docs/components/chaos/pixel-dissolve.js +71 -0
- package/dist/docs/components/chaos/shatter-pane.d.ts +2 -0
- package/dist/docs/components/chaos/shatter-pane.js +71 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -0
- package/dist/styles/globals.css +3 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/utils/destruction-engine.d.ts +26 -0
- package/dist/utils/destruction-engine.js +75 -0
- package/package.json +73 -66
package/README.md
CHANGED
|
@@ -1,132 +1,158 @@
|
|
|
1
|
-
# 🌀 @gigo-ui/components
|
|
2
|
-
|
|
3
|
-
### _High-Performance Components for Low-Performance Experiences._
|
|
4
|
-
|
|
5
|
-
[](https://svelte.dev)
|
|
6
|
-
[](https://svelte.dev)
|
|
7
|
-
[](https://www.typescriptlang.org/)
|
|
8
|
-
[](https://tailwindcss.com/)
|
|
9
|
-
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
|
|
11
|
-
A Svelte 5 component library of intentionally terrible UI patterns. Every component is production-quality code implementing the worst UX ideas imaginable.
|
|
12
|
-
|
|
13
|
-
Built with modern runes (`$state`, `$derived`, `$effect`, `$bindable`), TypeScript, and Tailwind CSS 4.
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Install
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
pnpm add @gigo-ui/components
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
|
82
|
-
|
|
|
83
|
-
| **
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
1
|
+
# 🌀 @gigo-ui/components
|
|
2
|
+
|
|
3
|
+
### _High-Performance Components for Low-Performance Experiences._
|
|
4
|
+
|
|
5
|
+
[](https://svelte.dev)
|
|
6
|
+
[](https://svelte.dev)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://tailwindcss.com/)
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
|
|
11
|
+
A Svelte 5 component library of intentionally terrible UI patterns. Every component is production-quality code implementing the worst UX ideas imaginable.
|
|
12
|
+
|
|
13
|
+
Built with modern runes (`$state`, `$derived`, `$effect`, `$bindable`), TypeScript, and Tailwind CSS 4.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @gigo-ui/components
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Styles (Required)
|
|
24
|
+
|
|
25
|
+
Import the package stylesheet once near your app root:
|
|
26
|
+
|
|
27
|
+
```svelte
|
|
28
|
+
<script lang="ts">
|
|
29
|
+
import '@gigo-ui/components/globals.css';
|
|
30
|
+
</script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The stylesheet includes Tailwind v4 directives and `@source` scanning for this package, so utility classes used inside components are generated in consumer builds.
|
|
34
|
+
|
|
35
|
+
To customize theme tokens, override variables after importing the package CSS:
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
/* app.css */
|
|
39
|
+
@import "@gigo-ui/components/globals.css";
|
|
40
|
+
|
|
41
|
+
:root {
|
|
42
|
+
--primary: #2563eb;
|
|
43
|
+
--background: #ffffff;
|
|
44
|
+
--foreground: #111827;
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
```svelte
|
|
51
|
+
<script lang="ts">
|
|
52
|
+
import '@gigo-ui/components/globals.css';
|
|
53
|
+
import { ShatterPane, CatchSubmit } from '@gigo-ui/components';
|
|
54
|
+
|
|
55
|
+
let broken = $state(false);
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<ShatterPane bind:isShattered={broken}>
|
|
59
|
+
<div class="card">
|
|
60
|
+
<h2>Fragile Content</h2>
|
|
61
|
+
<CatchSubmit label="Submit" />
|
|
62
|
+
</div>
|
|
63
|
+
</ShatterPane>
|
|
64
|
+
|
|
65
|
+
<button onclick={() => broken = true}>Break it</button>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Components
|
|
71
|
+
|
|
72
|
+
### 🌪 Chaos (Destruction Overlays)
|
|
73
|
+
|
|
74
|
+
Wrap any component. One function call and it's physically destroyed.
|
|
75
|
+
|
|
76
|
+
| Component | Effect | Engine |
|
|
77
|
+
| :---------------- | :------------------------------- | :------------------------------------- |
|
|
78
|
+
| **GigoCompactor** | Voxel crush implosion | Three.js InstancedMesh + Rapier3D WASM |
|
|
79
|
+
| **ShatterPane** | Voronoi glass fracture | Canvas2D + physics sim |
|
|
80
|
+
| **PixelDissolve** | Per-pixel wave contagion | Canvas2D particle system |
|
|
81
|
+
| **BlackHoleSink** | Gravitational singularity | Canvas2D warp + accretion glow |
|
|
82
|
+
| **ChaosButton** | Button with random chaos effects | CSS transforms |
|
|
83
|
+
| **ChaosForm** | Form that fights back | DOM manipulation |
|
|
84
|
+
|
|
85
|
+
### 😈 BadUI (Hostile Interactions)
|
|
86
|
+
|
|
87
|
+
Technically functional. Emotionally devastating.
|
|
88
|
+
|
|
89
|
+
| Component | What it does |
|
|
90
|
+
| :------------------- | :---------------------------------------- |
|
|
91
|
+
| **RotaryDial** | Rotary phone dial for number input |
|
|
92
|
+
| **GravityInput** | Characters fall with gravity as you type |
|
|
93
|
+
| **PasswordPeekhole** | Tiny draggable circle to view password |
|
|
94
|
+
| **ProgressDoom** | Progress bar that regresses randomly |
|
|
95
|
+
| **CatchSubmit** | Submit button that runs from your cursor |
|
|
96
|
+
| **SliderPhone** | Single slider for entering phone numbers |
|
|
97
|
+
| **GhostCard** | Cards that vanish and reappear corrupted |
|
|
98
|
+
| **DropdownCalc** | Dropdown menus for basic arithmetic |
|
|
99
|
+
| **VolumeSlider** | Deliberately confusing volume control |
|
|
100
|
+
| **ColorPickerWrong** | Color picker that picks the wrong color |
|
|
101
|
+
| **TermsSidescroll** | Terms of service in a horizontal scroller |
|
|
102
|
+
|
|
103
|
+
### 🛠 Standard (The Bait)
|
|
104
|
+
|
|
105
|
+
Normal, usable components to lull users into a false sense of security.
|
|
106
|
+
|
|
107
|
+
| Component | Purpose |
|
|
108
|
+
| :------------- | :-------------- |
|
|
109
|
+
| **Button** | Standard button |
|
|
110
|
+
| **Card** | Content card |
|
|
111
|
+
| **Carousel** | Image carousel |
|
|
112
|
+
| **Form** | Form container |
|
|
113
|
+
| **Input** | Text input |
|
|
114
|
+
| **Modal** | Dialog overlay |
|
|
115
|
+
| **Navigation** | Nav component |
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Breaker Overlays
|
|
120
|
+
|
|
121
|
+
The destruction overlays are the flagship feature. They snapshot any wrapped content, then destroy it with real physics:
|
|
122
|
+
|
|
123
|
+
```svelte
|
|
124
|
+
<script lang="ts">
|
|
125
|
+
import { GigoCompactor } from '@gigo-ui/components';
|
|
126
|
+
|
|
127
|
+
let compactor: GigoCompactor;
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
<GigoCompactor bind:this={compactor} cols={20} rows={20} intensity={8}>
|
|
131
|
+
<div class="card">This will be voxelized</div>
|
|
132
|
+
</GigoCompactor>
|
|
133
|
+
|
|
134
|
+
<button onclick={() => compactor.crush()}>Crush</button>
|
|
135
|
+
<button onclick={() => compactor.restore()}>Restore</button>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Each overlay lazy-loads its engine only when triggered. Three.js, Rapier WASM, and html-to-image are all dynamically imported — zero cost until destruction begins.
|
|
139
|
+
|
|
140
|
+
| Overlay | Method | Prop | Size |
|
|
141
|
+
| :------------ | :------------------------- | :------------ | :-------------------- |
|
|
142
|
+
| GigoCompactor | `crush()` / `restore()` | `isGarbage` | ~180KB (Three+Rapier) |
|
|
143
|
+
| ShatterPane | `shatter()` / `restore()` | `isShattered` | ~2KB |
|
|
144
|
+
| PixelDissolve | `dissolve()` / `restore()` | `isDead` | ~2KB |
|
|
145
|
+
| BlackHoleSink | `consume()` / `restore()` | `isConsumed` | ~2KB |
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Requirements
|
|
150
|
+
|
|
151
|
+
- Svelte 5.0+
|
|
152
|
+
- SvelteKit 2.0+
|
|
153
|
+
- Tailwind CSS 4.0+
|
|
154
|
+
- TypeScript 5.0+
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<!-- Black hole wrapper — singularity + accretion engine -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import { captureSnapshot } from '../../utils/destruction-engine.js';
|
|
5
|
+
|
|
6
|
+
export interface BlackHoleSinkProps {
|
|
7
|
+
isConsumed?: boolean;
|
|
8
|
+
resolution?: number;
|
|
9
|
+
intensity?: number;
|
|
10
|
+
glowColor?: string;
|
|
11
|
+
debugMode?: boolean;
|
|
12
|
+
class?: string;
|
|
13
|
+
children: Snippet;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
isConsumed = $bindable(false),
|
|
18
|
+
resolution = 4,
|
|
19
|
+
intensity = 7,
|
|
20
|
+
glowColor = 'rgba(255,120,0,0.7)',
|
|
21
|
+
debugMode = false,
|
|
22
|
+
class: className = '',
|
|
23
|
+
children,
|
|
24
|
+
}: BlackHoleSinkProps = $props();
|
|
25
|
+
|
|
26
|
+
let wrapper: HTMLDivElement | undefined = $state();
|
|
27
|
+
let snapshotData: string | null = $state(null);
|
|
28
|
+
let snapshotRect: DOMRect | null = $state(null);
|
|
29
|
+
let isCapturing = $state(false);
|
|
30
|
+
let EngineComponent: any = $state(null);
|
|
31
|
+
let hidden = $state(false);
|
|
32
|
+
|
|
33
|
+
$effect(() => {
|
|
34
|
+
if (isConsumed && !snapshotData && !isCapturing && wrapper) doCapture();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
async function doCapture() {
|
|
38
|
+
if (!wrapper || isCapturing) return;
|
|
39
|
+
isCapturing = true;
|
|
40
|
+
try {
|
|
41
|
+
const result = await captureSnapshot(wrapper);
|
|
42
|
+
snapshotRect = result.rect;
|
|
43
|
+
snapshotData = result.dataURL;
|
|
44
|
+
hidden = true;
|
|
45
|
+
const mod = await import('./internal/BlackHoleEngine.svelte');
|
|
46
|
+
EngineComponent = mod.default;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
if (debugMode) console.error('[BlackHoleSink] capture failed', err);
|
|
49
|
+
hidden = false;
|
|
50
|
+
} finally {
|
|
51
|
+
isCapturing = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function consume() { if (wrapper) { isConsumed = true; doCapture(); } }
|
|
56
|
+
export function restore() {
|
|
57
|
+
isConsumed = false;
|
|
58
|
+
hidden = false; snapshotData = null; snapshotRect = null; EngineComponent = null;
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div
|
|
63
|
+
bind:this={wrapper}
|
|
64
|
+
class={className}
|
|
65
|
+
style:visibility={hidden ? 'hidden' : 'visible'}
|
|
66
|
+
data-gigo-blackhole="true"
|
|
67
|
+
>
|
|
68
|
+
{@render children()}
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
{#if EngineComponent && snapshotData && snapshotRect}
|
|
72
|
+
{@const Engine = EngineComponent}
|
|
73
|
+
<Engine
|
|
74
|
+
snapshot={snapshotData}
|
|
75
|
+
rect={snapshotRect}
|
|
76
|
+
{resolution}
|
|
77
|
+
{intensity}
|
|
78
|
+
{glowColor}
|
|
79
|
+
{debugMode}
|
|
80
|
+
/>
|
|
81
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface BlackHoleSinkProps {
|
|
3
|
+
isConsumed?: boolean;
|
|
4
|
+
resolution?: number;
|
|
5
|
+
intensity?: number;
|
|
6
|
+
glowColor?: string;
|
|
7
|
+
debugMode?: boolean;
|
|
8
|
+
class?: string;
|
|
9
|
+
children: Snippet;
|
|
10
|
+
}
|
|
11
|
+
declare const BlackHoleSink: import("svelte").Component<BlackHoleSinkProps, {
|
|
12
|
+
consume: () => void;
|
|
13
|
+
restore: () => void;
|
|
14
|
+
}, "isConsumed">;
|
|
15
|
+
type BlackHoleSink = ReturnType<typeof BlackHoleSink>;
|
|
16
|
+
export default BlackHoleSink;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { onDestroy } from 'svelte';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import { captureSnapshot } from '../../utils/destruction-engine.js';
|
|
6
|
+
|
|
7
|
+
export interface GigoCompactorProps {
|
|
8
|
+
isGarbage?: boolean;
|
|
9
|
+
cols?: number;
|
|
10
|
+
rows?: number;
|
|
11
|
+
intensity?: number; // 0–10
|
|
12
|
+
debugMode?: boolean;
|
|
13
|
+
class?: string;
|
|
14
|
+
children: Snippet;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
isGarbage = $bindable(false),
|
|
19
|
+
cols = 20,
|
|
20
|
+
rows = 20,
|
|
21
|
+
intensity = 7,
|
|
22
|
+
debugMode = false,
|
|
23
|
+
class: className = '',
|
|
24
|
+
children,
|
|
25
|
+
}: GigoCompactorProps = $props();
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
let wrapper: HTMLDivElement | undefined = $state();
|
|
29
|
+
let snapshotData: string | null = $state(null);
|
|
30
|
+
let snapshotRect: DOMRect | null = $state(null);
|
|
31
|
+
let isCapturing = $state(false);
|
|
32
|
+
let EngineComponent: any = $state(null);
|
|
33
|
+
let hidden = $state(false);
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
$effect(() => {
|
|
37
|
+
if (isGarbage && !snapshotData && !isCapturing && wrapper) {
|
|
38
|
+
doCapture();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
async function doCapture() {
|
|
43
|
+
if (!wrapper || isCapturing) return;
|
|
44
|
+
isCapturing = true;
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const result = await captureSnapshot(wrapper);
|
|
48
|
+
snapshotRect = result.rect;
|
|
49
|
+
snapshotData = result.dataURL;
|
|
50
|
+
hidden = true; // preserve layout, hide original
|
|
51
|
+
|
|
52
|
+
// Lazy-load the engine only now
|
|
53
|
+
const mod = await import('./internal/CompactorEngine.svelte');
|
|
54
|
+
EngineComponent = mod.default;
|
|
55
|
+
} catch (err) {
|
|
56
|
+
if (debugMode) console.error('[GigoCompactor] capture failed', err);
|
|
57
|
+
// fail-safe: show original again
|
|
58
|
+
hidden = false;
|
|
59
|
+
} finally {
|
|
60
|
+
isCapturing = false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function crush() { if (wrapper) { isGarbage = true; doCapture(); } }
|
|
65
|
+
export function restore() {
|
|
66
|
+
isGarbage = false;
|
|
67
|
+
hidden = false; snapshotData = null; snapshotRect = null; EngineComponent = null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onDestroy(() => {
|
|
71
|
+
restore()
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<!-- Original slot content — hidden once physics takes over -->
|
|
76
|
+
<div
|
|
77
|
+
bind:this={wrapper}
|
|
78
|
+
class={className}
|
|
79
|
+
style:visibility={hidden ? 'hidden' : 'visible'}
|
|
80
|
+
data-gigo-compactor="true"
|
|
81
|
+
>
|
|
82
|
+
{@render children()}
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
{#if debugMode}
|
|
86
|
+
<div class="
|
|
87
|
+
fixed inset-0 pointer-events-none z-10000
|
|
88
|
+
ring-2 ring-offset-[-2px] ring-red-500/60
|
|
89
|
+
"></div>
|
|
90
|
+
{/if}
|
|
91
|
+
|
|
92
|
+
<!-- Physics engine — mounted lazily after snapshot is ready -->
|
|
93
|
+
{#if EngineComponent && snapshotData && snapshotRect}
|
|
94
|
+
{@const Engine = EngineComponent}
|
|
95
|
+
<Engine
|
|
96
|
+
snapshot={snapshotData}
|
|
97
|
+
rect={snapshotRect}
|
|
98
|
+
{cols}
|
|
99
|
+
{rows}
|
|
100
|
+
{intensity}
|
|
101
|
+
{debugMode}
|
|
102
|
+
/>
|
|
103
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface GigoCompactorProps {
|
|
3
|
+
isGarbage?: boolean;
|
|
4
|
+
cols?: number;
|
|
5
|
+
rows?: number;
|
|
6
|
+
intensity?: number;
|
|
7
|
+
debugMode?: boolean;
|
|
8
|
+
class?: string;
|
|
9
|
+
children: Snippet;
|
|
10
|
+
}
|
|
11
|
+
declare const GigoCompactor: import("svelte").Component<GigoCompactorProps, {
|
|
12
|
+
crush: () => void;
|
|
13
|
+
restore: () => void;
|
|
14
|
+
}, "isGarbage">;
|
|
15
|
+
type GigoCompactor = ReturnType<typeof GigoCompactor>;
|
|
16
|
+
export default GigoCompactor;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<!-- Pixel dissolve wrapper — wave contagion engine -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import { captureSnapshot } from '../../utils/destruction-engine.js';
|
|
5
|
+
|
|
6
|
+
export interface PixelDissolveProps {
|
|
7
|
+
isDead?: boolean;
|
|
8
|
+
resolution?: number;
|
|
9
|
+
waveSeed?: number;
|
|
10
|
+
intensity?: number;
|
|
11
|
+
debugMode?: boolean;
|
|
12
|
+
class?: string;
|
|
13
|
+
children: Snippet;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
isDead = $bindable(false),
|
|
18
|
+
resolution = 3,
|
|
19
|
+
waveSeed = 8,
|
|
20
|
+
intensity = 7,
|
|
21
|
+
debugMode = false,
|
|
22
|
+
class: className = '',
|
|
23
|
+
children,
|
|
24
|
+
}: PixelDissolveProps = $props();
|
|
25
|
+
|
|
26
|
+
let wrapper: HTMLDivElement | undefined = $state();
|
|
27
|
+
let snapshotData: string | null = $state(null);
|
|
28
|
+
let snapshotRect: DOMRect | null = $state(null);
|
|
29
|
+
let isCapturing = $state(false);
|
|
30
|
+
let EngineComponent: any = $state(null);
|
|
31
|
+
let hidden = $state(false);
|
|
32
|
+
|
|
33
|
+
$effect(() => {
|
|
34
|
+
if (isDead && !snapshotData && !isCapturing && wrapper) doCapture();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
async function doCapture() {
|
|
38
|
+
if (!wrapper || isCapturing) return;
|
|
39
|
+
isCapturing = true;
|
|
40
|
+
try {
|
|
41
|
+
const result = await captureSnapshot(wrapper);
|
|
42
|
+
snapshotRect = result.rect;
|
|
43
|
+
snapshotData = result.dataURL;
|
|
44
|
+
hidden = true;
|
|
45
|
+
const mod = await import('./internal/PixelDissolveEngine.svelte');
|
|
46
|
+
EngineComponent = mod.default;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
if (debugMode) console.error('[PixelDissolve] capture failed', err);
|
|
49
|
+
hidden = false;
|
|
50
|
+
} finally {
|
|
51
|
+
isCapturing = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function dissolve() { if (wrapper) { isDead = true; doCapture(); } }
|
|
56
|
+
export function restore() {
|
|
57
|
+
isDead = false;
|
|
58
|
+
hidden = false; snapshotData = null; snapshotRect = null; EngineComponent = null;
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div
|
|
63
|
+
bind:this={wrapper}
|
|
64
|
+
class={className}
|
|
65
|
+
style:visibility={hidden ? 'hidden' : 'visible'}
|
|
66
|
+
data-gigo-dissolve="true"
|
|
67
|
+
>
|
|
68
|
+
{@render children()}
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
{#if EngineComponent && snapshotData && snapshotRect}
|
|
72
|
+
{@const Engine = EngineComponent}
|
|
73
|
+
<Engine
|
|
74
|
+
snapshot={snapshotData}
|
|
75
|
+
rect={snapshotRect}
|
|
76
|
+
{resolution}
|
|
77
|
+
{waveSeed}
|
|
78
|
+
{intensity}
|
|
79
|
+
{debugMode}
|
|
80
|
+
/>
|
|
81
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface PixelDissolveProps {
|
|
3
|
+
isDead?: boolean;
|
|
4
|
+
resolution?: number;
|
|
5
|
+
waveSeed?: number;
|
|
6
|
+
intensity?: number;
|
|
7
|
+
debugMode?: boolean;
|
|
8
|
+
class?: string;
|
|
9
|
+
children: Snippet;
|
|
10
|
+
}
|
|
11
|
+
declare const PixelDissolve: import("svelte").Component<PixelDissolveProps, {
|
|
12
|
+
dissolve: () => void;
|
|
13
|
+
restore: () => void;
|
|
14
|
+
}, "isDead">;
|
|
15
|
+
type PixelDissolve = ReturnType<typeof PixelDissolve>;
|
|
16
|
+
export default PixelDissolve;
|