Skip to content

Commit a7c51ba

Browse files
authored
Merge pull request #401 from Weaverse/june-2025
2 parents 480dfc1 + 1911690 commit a7c51ba

12 files changed

Lines changed: 5915 additions & 267 deletions

File tree

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup Biome
2626
uses: biomejs/setup-biome@v2
2727
with:
28-
version: 2.0.0-beta.6 # todo: change to stable if stable version is released
28+
version: 2
2929
- name: Run Biome
3030
run: biome ci .
3131

.lefthook/pre-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ call_lefthook()
5757
elif mise exec -- lefthook -h >/dev/null 2>&1
5858
then
5959
mise exec -- lefthook "$@"
60+
elif devbox run lefthook -h >/dev/null 2>&1
61+
then
62+
devbox run lefthook "$@"
6063
else
6164
echo "Can't find lefthook in PATH"
6265
fi

.lefthook/prepare-commit-msg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ call_lefthook()
5757
elif mise exec -- lefthook -h >/dev/null 2>&1
5858
then
5959
mise exec -- lefthook "$@"
60+
elif devbox run lefthook -h >/dev/null 2>&1
61+
then
62+
devbox run lefthook "$@"
6063
else
6164
echo "Can't find lefthook in PATH"
6265
fi

biome.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.0.0-beta.6/schema.json",
2+
"root": true,
3+
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
34
"extends": ["./packages/biome/biome.json"],
45
"vcs": {
56
"enabled": true,
@@ -15,7 +16,8 @@
1516
"!**/build/**",
1617
"!**/.turbo/**",
1718
"!**/templates/**",
18-
"!**/package-lock.json"
19+
"!**/package-lock.json",
20+
"!**/app/styles/app.css"
1921
]
2022
},
2123
"linter": {

docs/guides/third-party-integration.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ published: true
1010
# Third-party Integration
1111

1212
## Table of Contents
13+
1314
- [Third-party Integration](#third-party-integration)
1415
- [Table of Contents](#table-of-contents)
1516
- [Introduction](#introduction)
@@ -165,19 +166,20 @@ For third-party services that offer a REST or GraphQL API, Weaverse's loader pat
165166
```tsx
166167
// app/sections/api-widget/index.tsx
167168
import type { ComponentLoaderArgs } from '@weaverse/hydrogen'
169+
168170
import { createSchema } from '@weaverse/hydrogen'
169171
import { forwardRef } from 'react'
170172
import { Section, type SectionProps } from '~/components/section'
171-
173+
172174
type ApiWidgetData = {
173175
resourceId: string
174176
itemsToShow: number
175177
}
176-
178+
177179
export const loader = async ({ weaverse, data }: ComponentLoaderArgs<ApiWidgetData>) => {
178180
const { fetchWithCache, env, storefront } = weaverse
179181
const { resourceId, itemsToShow = 5 } = data
180-
182+
181183
if (!resourceId) return { items: [] }
182184

183185
try {
@@ -197,13 +199,13 @@ import { forwardRef } from 'react'
197199
return { items: [], error: true }
198200
}
199201
}
200-
202+
201203
type ApiWidgetProps = SectionProps<Awaited<ReturnType<typeof loader>>> & ApiWidgetData
202-
204+
203205
const ApiWidget = forwardRef<HTMLElement, ApiWidgetProps>((props, ref) => {
204206
const { loaderData, resourceId, itemsToShow, ...rest } = props
205207
const { items, error } = loaderData || { items: [] }
206-
208+
207209
if (error) {
208210
return (
209211
<Section ref={ref} {...rest}>
@@ -227,9 +229,9 @@ import { forwardRef } from 'react'
227229
</Section>
228230
)
229231
})
230-
232+
231233
export default ApiWidget
232-
234+
233235
export let schema = createSchema({
234236
type: 'api-widget',
235237
title: 'API Widget',
@@ -260,6 +262,7 @@ import { forwardRef } from 'react'
260262
}
261263
]
262264
})
265+
263266
```
264267

265268
## Data Fetching Patterns
@@ -283,6 +286,7 @@ export const loader = async ({ weaverse, data }: ComponentLoaderArgs<WidgetData>
283286
```
284287

285288
Benefits:
289+
286290
- API keys remain secure on the server
287291
- Reduced JavaScript bundle size
288292
- Better performance for initial page load
@@ -320,6 +324,7 @@ export function AnalyticsClient({ trackingId }) {
320324
```
321325

322326
Use this approach when:
327+
323328
- The integration requires browser-specific APIs
324329
- The third-party service needs to track user interactions
325330
- The widget needs to be initialized after the page loads
@@ -367,6 +372,7 @@ function ClientInteractivity({ initialData, settings }) {
367372
```
368373

369374
This pattern is ideal for:
375+
370376
- Review systems that need initial content rendered server-side but allow client-side submissions
371377
- Interactive widgets that need to show initial data quickly but then become interactive
372378
- Progressive enhancement scenarios
@@ -468,6 +474,7 @@ export let schema = createSchema({
468474
```
469475

470476
The implementation:
477+
471478
1. Defines a schema with an API key input that triggers revalidation when changed
472479
2. Uses a loader to securely fetch reviews from the Ali Reviews API
473480
3. Structures the component to render Ali Review data
@@ -540,6 +547,7 @@ export default ReviewIndex;
540547
```
541548

542549
This approach:
550+
543551
1. Leverages existing Hydrogen route data instead of making additional API calls
544552
2. Separates the display components from the data fetching logic
545553
3. Optimizes performance by reusing already fetched data
@@ -815,6 +823,7 @@ Common issues and their solutions:
815823
- Look for rate limiting or quota issues
816824

817825
Solution:
826+
818827
```tsx
819828
try {
820829
// Make your API call here
@@ -836,6 +845,7 @@ Common issues and their solutions:
836845
- Ensure your component handles the absence of data gracefully
837846

838847
Solution:
848+
839849
```tsx
840850
const Widget = forwardRef((props, ref) => {
841851
const { loaderData } = props
@@ -859,6 +869,7 @@ Common issues and their solutions:
859869
- Use client components with careful boundaries
860870

861871
Solution:
872+
862873
```tsx
863874
'use client'
864875
import { useEffect, useState } from 'react'

docs/guides/weaverse-component.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ published: true
1212
Weaverse Components are the building blocks of your Hydrogen theme. They combine React's component model with Weaverse's powerful schema system to create customizable, performant sections for your storefront. This guide provides a comprehensive overview of how to create, configure, and optimize Weaverse components.
1313

1414
## Table of Contents
15+
1516
- [Getting Started](#getting-started)
1617
- [Core Concepts](#core-concepts)
1718
- [Component Structure](#component-structure)
@@ -290,13 +291,15 @@ export let schema = createSchema({
290291
## Component Types
291292

292293
### 1. Content Sections
294+
293295
- Hero sections (images, videos)
294296
- Text blocks and rich content
295297
- Media galleries and sliders
296298
- Feature sections
297299
- Testimonial sections
298300

299301
### 2. E-commerce Components
302+
300303
- Product displays
301304
- Collection grids
302305
- Related products
@@ -305,6 +308,7 @@ export let schema = createSchema({
305308
- Checkout components
306309

307310
### 3. Interactive Elements
311+
308312
- Forms and newsletters
309313
- Reviews and testimonials
310314
- Maps and location displays
@@ -745,12 +749,14 @@ export async function loader({ context }: ComponentLoaderArgs) {
745749
```
746750

747751
**Weaverse's `fetchWithCache`** is a convenient utility that simplifies cached data fetching from external APIs:
752+
748753
- Available through `context.weaverse.fetchWithCache`
749754
- Automatically handles JSON parsing
750755
- Applies the specified caching strategy
751756
- Provides a cleaner syntax compared to Hydrogen's native `fetchSync`
752757

753758
Hydrogen provides several caching strategies out of the box:
759+
754760
- `CacheNone()`: No caching, always fetches fresh data
755761
- `CacheShort()`: Short-term caching (a few minutes)
756762
- `CacheLong()`: Long-term caching (1 day by default)
@@ -1287,4 +1293,3 @@ Remember that great components are:
12871293
- **Maintainable**: They follow clean code principles and are well-documented
12881294

12891295
As you build your Weaverse components, focus on creating a consistent user experience while enabling flexibility and customization through the schema system.
1290-

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"ci": "biome ci --changed"
2525
},
2626
"devDependencies": {
27-
"@biomejs/biome": "^2.0.0-beta.6",
27+
"@biomejs/biome": "^2.0.0",
2828
"@changesets/cli": "^2.29.4",
2929
"@types/node": "24.0.0",
3030
"@types/react": "19.1.7",

packages/biome/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @weaverse/biome
22

3+
## 1.3.0
4+
5+
### Minor Changes
6+
7+
- update biome to v2
8+
39
## 1.2.4
410

511
### Patch Changes

packages/biome/biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": false,
3-
"$schema": "https://biomejs.dev/schemas/2.0.0-beta.6/schema.json",
3+
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
44
"linter": {
55
"rules": {
66
"style": {

packages/biome/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@weaverse/biome",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "Biome configuration for Weaverse",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"
@@ -20,7 +20,7 @@
2020
},
2121
"homepage": "https://github.com/Weaverse/weaverse#readme",
2222
"dependencies": {
23-
"@biomejs/biome": "2.0.0-beta.6"
23+
"@biomejs/biome": "^2.0.0"
2424
},
2525
"files": [
2626
"biome.json"

0 commit comments

Comments
 (0)