@wyxos/vibe 1.6.1 โ†’ 1.6.3

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 CHANGED
@@ -1,26 +1,27 @@
1
- # ๐Ÿ”ท VIBE โ€” Vue Infinite Block Engine
1
+ # VIBE โ€” Vue Infinite Block Engine
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@wyxos/vibe?color=%2300c58e&label=npm)](https://www.npmjs.com/package/@wyxos/vibe)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
  [![Demo](https://img.shields.io/badge/Demo-Live%20Preview-blue?logo=githubpages)](https://wyxos.github.io/vibe/)
6
6
 
7
- A responsive, dynamic, infinite-scroll masonry layout engine for Vue 3.
8
- Built for performance, flexibility, and pixel-perfect layout control.
7
+ A high-performance, responsive masonry layout engine for Vue 3 with built-in infinite scrolling and virtualization.
8
+
9
+ VIBE (Vue Infinite Block Engine) is designed for applications that need to display large datasets in a masonry grid without compromising performance. Unlike other masonry libraries, VIBE leverages virtualization to render only what is visible on the screen, ensuring smooth scrolling even with thousands of items.
9
10
 
10
11
  ---
11
12
 
12
- ## โœ… Features
13
+ ## Features
13
14
 
14
- - Responsive masonry layout that adapts to screen size
15
- - Automatically loads more items as you scroll
16
- - Supports removing and reflowing items with animation
17
- - Keeps scroll position stable after layout updates
18
- - Fully customizable item rendering
19
- - Optimized for large datasets
15
+ - **High Performance Virtualization**: Efficiently renders thousands of items by only mounting elements currently in the viewport.
16
+ - **Responsive Masonry Layout**: Automatically adjusts column counts and layout based on screen width and breakpoints.
17
+ - **Infinite Scrolling**: Seamlessly loads more content as the user scrolls, with built-in support for async data fetching.
18
+ - **Dynamic Updates**: Supports adding, removing, and reflowing items with smooth FLIP animations.
19
+ - **Scroll Position Maintenance**: Keeps the user's scroll position stable when new items are loaded or the layout changes.
20
+ - **Customizable Rendering**: Full control over item markup via scoped slots.
20
21
 
21
22
  ---
22
23
 
23
- ## ๐Ÿ“ฆ Installation
24
+ ## Installation
24
25
 
25
26
  ```bash
26
27
  npm install @wyxos/vibe
@@ -28,16 +29,21 @@ npm install @wyxos/vibe
28
29
 
29
30
  ---
30
31
 
31
- ## ๐Ÿš€ Usage
32
+ ## Usage
32
33
 
33
34
  ```vue
34
35
  <script setup>
35
36
  import { ref } from 'vue'
36
- import { Masonry } from '@wyxos/vibe' // named export
37
- // or if globally registered via `app.use()`, you can skip this import
37
+ import { Masonry } from '@wyxos/vibe'
38
38
 
39
39
  const items = ref([])
40
40
 
41
+ const layout = {
42
+ gutterX: 12,
43
+ gutterY: 12,
44
+ sizes: { base: 1, sm: 2, md: 3, lg: 4 }
45
+ }
46
+
41
47
  async function getNextPage(page) {
42
48
  const response = await fetch(`/api/items?page=${page}`)
43
49
  const data = await response.json()
@@ -49,16 +55,14 @@ npm install @wyxos/vibe
49
55
  </script>
50
56
 
51
57
  <template>
52
- <WyxosMasonry
58
+ <Masonry
53
59
  v-model:items="items"
54
60
  :get-next-page="getNextPage"
55
- :gutter-x="12"
56
- :gutter-y="12"
57
- :sizes="{ base: 1, sm: 2, md: 3, lg: 4 }"
61
+ :layout="layout"
58
62
  >
59
63
  <template #item="{ item, onRemove }">
60
64
  <div class="relative">
61
- <img :src="item.src" class="w-full" />
65
+ <img :src="item.src" class="w-full" alt="Masonry item" />
62
66
  <button
63
67
  class="absolute bottom-2 right-2 bg-red-600 text-white text-xs p-1 rounded"
64
68
  @click="onRemove(item)"
@@ -67,46 +71,51 @@ npm install @wyxos/vibe
67
71
  </button>
68
72
  </div>
69
73
  </template>
70
- </WyxosMasonry>
74
+ </Masonry>
71
75
  </template>
72
76
  ```
73
77
 
74
78
  ---
75
79
 
76
- ## โš™๏ธ Props
80
+ ## Props
77
81
 
78
- | Prop | Type | Required | Description |
79
- |--------------|----------|----------|-----------------------------------------------------------------------------|
80
- | `items` | `Array` | โœ… | Two-way bound item array (each item must include `width`, `height`, `id`) |
81
- | `getNextPage`| `Function(page: Number)` | โœ… | Async function to load the next page โ€” returns `{ items, nextPage }` |
82
- | `loadAtPage` | `Number` | โŒ | Starting page number (default: `1`) |
83
- | `sizes` | `Object` | โŒ | Mobile-first column config (default: Tailwind-style breakpoints) |
84
- | `gutterX` | `Number` | โŒ | Horizontal gutter between items (default: `10`) |
85
- | `gutterY` | `Number` | โŒ | Vertical gutter between items (default: `10`) |
82
+ | Prop | Type | Required | Description |
83
+ |------|------|----------|-------------|
84
+ | `items` | `Array` | Yes | Two-way bound item array. Each item must include `width`, `height`, and `id`. |
85
+ | `getNextPage` | `Function(page: Number)` | Yes | Async function to load the next page. Must return `{ items, nextPage }`. |
86
+ | `layout` | `Object` | No | Configuration object for layout, including sizes and gutters. |
87
+ | `loadAtPage` | `Number` | No | The starting page number (default: `1`). |
88
+
89
+ ### Layout Configuration Example
86
90
 
87
- ### `sizes` example:
88
91
  ```js
89
92
  {
90
- base: 1,
91
- sm: 2,
92
- md: 3,
93
- lg: 4,
94
- xl: 5,
95
- '2xl': 6
93
+ gutterX: 10,
94
+ gutterY: 10,
95
+ sizes: {
96
+ base: 1,
97
+ sm: 2,
98
+ md: 3,
99
+ lg: 4,
100
+ xl: 5,
101
+ '2xl': 6
102
+ }
96
103
  }
97
104
  ```
98
105
 
99
106
  ---
100
107
 
101
- ## ๐Ÿ’ก Slots
108
+ ## Slots
102
109
 
103
- | Slot Name | Props | Description |
104
- |-----------|--------------------------------|-----------------------------------|
105
- | `item` | `{ item, onRemove }` | Custom rendering for each block |
110
+ | Slot Name | Props | Description |
111
+ |-----------|-------|-------------|
112
+ | `item` | `{ item, onRemove }` | Scoped slot for custom rendering of each masonry block. |
106
113
 
107
114
  ---
108
115
 
109
- ## ๐Ÿงช Run Locally
116
+ ## Run Locally
117
+
118
+ To run the demo project locally:
110
119
 
111
120
  ```bash
112
121
  git clone https://github.com/wyxos/vibe
@@ -115,16 +124,16 @@ npm install
115
124
  npm run dev
116
125
  ```
117
126
 
118
- Visit [`http://localhost:5173`](http://localhost:5173)
127
+ Visit `http://localhost:5173` to view the demo.
119
128
 
120
129
  ---
121
130
 
122
- ## ๐ŸŒ Live Demo
131
+ ## Live Demo
123
132
 
124
- ๐Ÿ‘‰ [View Demo on GitHub Pages](https://wyxos.github.io/vibe/)
133
+ [View Live Demo on GitHub Pages](https://wyxos.github.io/vibe/)
125
134
 
126
135
  ---
127
136
 
128
- ## ๐Ÿ“„ License
137
+ ## License
129
138
 
130
139
  MIT ยฉ [@wyxos](https://github.com/wyxos)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wyxos/vibe",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "main": "lib/index.js",
5
5
  "module": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -12,6 +12,9 @@
12
12
  "./vibe.css": "./lib/vibe.css",
13
13
  "./package.json": "./package.json"
14
14
  },
15
+ "bin": {
16
+ "vibe": "./toggle-link.mjs"
17
+ },
15
18
  "type": "module",
16
19
  "files": [
17
20
  "lib",
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readFileSync, writeFileSync } from 'fs';
4
+ import { resolve, dirname, relative } from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import { execSync } from 'child_process';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+
11
+ // Get the vibe package directory
12
+ const vibeDir = resolve(__dirname);
13
+ const vibePackageJson = JSON.parse(readFileSync(resolve(vibeDir, 'package.json'), 'utf-8'));
14
+ const vibeVersion = vibePackageJson.version;
15
+
16
+ // Get the current working directory (where the script is run from)
17
+ const cwd = process.cwd();
18
+ const targetPackageJsonPath = resolve(cwd, 'package.json');
19
+
20
+ try {
21
+ const targetPackageJson = JSON.parse(readFileSync(targetPackageJsonPath, 'utf-8'));
22
+
23
+ // Check if @wyxos/vibe exists in dependencies or devDependencies
24
+ const deps = { ...targetPackageJson.dependencies, ...targetPackageJson.devDependencies };
25
+ const currentVibeRef = deps['@wyxos/vibe'];
26
+
27
+ if (!currentVibeRef) {
28
+ console.error('โŒ @wyxos/vibe not found in package.json dependencies or devDependencies');
29
+ process.exit(1);
30
+ }
31
+
32
+ // Determine if it's a local path or version reference
33
+ const isLocalPath = currentVibeRef.startsWith('file:') || currentVibeRef.startsWith('../') || currentVibeRef.startsWith('./');
34
+
35
+ let newRef;
36
+ let action;
37
+
38
+ if (isLocalPath) {
39
+ // Switch to published version
40
+ newRef = `^${vibeVersion}`;
41
+ action = 'published version';
42
+ } else {
43
+ // Switch to local path
44
+ // Calculate relative path from target to vibe
45
+ const relativePath = relative(cwd, vibeDir).replace(/\\/g, '/');
46
+ newRef = `file:${relativePath}`;
47
+ action = 'local path';
48
+ }
49
+
50
+ // Update package.json
51
+ if (targetPackageJson.dependencies && targetPackageJson.dependencies['@wyxos/vibe']) {
52
+ targetPackageJson.dependencies['@wyxos/vibe'] = newRef;
53
+ }
54
+ if (targetPackageJson.devDependencies && targetPackageJson.devDependencies['@wyxos/vibe']) {
55
+ targetPackageJson.devDependencies['@wyxos/vibe'] = newRef;
56
+ }
57
+
58
+ // Write updated package.json
59
+ writeFileSync(
60
+ targetPackageJsonPath,
61
+ JSON.stringify(targetPackageJson, null, 2) + '\n',
62
+ 'utf-8'
63
+ );
64
+
65
+ console.log(`โœ… Switched @wyxos/vibe to ${action}: ${newRef}`);
66
+
67
+ // If switching to local path, ensure the library is built before installation
68
+ if (action === 'local path') {
69
+ try {
70
+ console.log('๐Ÿ”ง Building local @wyxos/vibe (build:lib)...');
71
+ execSync('npm run build:lib', { cwd: vibeDir, stdio: 'inherit' });
72
+ } catch (e) {
73
+ console.warn('โš ๏ธ Failed to build local @wyxos/vibe. Attempting install anyway.');
74
+ }
75
+ }
76
+
77
+ // Run npm install
78
+ console.log('๐Ÿ“ฆ Running npm install...');
79
+ execSync('npm install', { cwd, stdio: 'inherit' });
80
+
81
+ console.log('โœจ Done!');
82
+
83
+ } catch (error) {
84
+ if (error.code === 'ENOENT') {
85
+ console.error(`โŒ package.json not found in ${cwd}`);
86
+ console.error(' Make sure you run this script from a project directory that uses @wyxos/vibe');
87
+ } else {
88
+ console.error('โŒ Error:', error.message);
89
+ }
90
+ process.exit(1);
91
+ }
92
+