shopify-theme-devtools 2.0.0 → 2.2.0

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
@@ -4,39 +4,135 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
5
  [![jsDelivr hits](https://img.shields.io/jsdelivr/npm/hm/shopify-theme-devtools)](https://www.jsdelivr.com/package/npm/shopify-theme-devtools)
6
6
 
7
- A powerful in-browser developer tools panel for Shopify theme development. Inspect Liquid objects, metafields, cart state, detect Liquid errors, debug network requests, and much more — all without leaving the browser.
7
+ A powerful in-browser developer tools panel for Shopify theme development. Inspect Liquid objects, evaluate expressions, explore metafields, manipulate cart state, detect Liquid errors, and much more — all without leaving the browser.
8
8
 
9
9
  ## Features
10
10
 
11
- - **Liquid Object Inspector** — Browse `shop`, `product`, `collection`, `customer`, `cart` and more with deep search
12
- - **Metafields Viewer** — Explore metafields across all resources and namespaces
13
- - **Live Cart State** — Real-time cart updates with add/remove/clear actions
14
- - **Liquid Error Detection** — Automatically detects `Liquid error`, Drop objects, missing snippets/assets
15
- - **Network Monitor** — Captures failed fetch/XHR requests
16
- - **Console Capture** — Intercepts `console.log`, `console.table`, `console.group` with persistence
17
- - **SEO Inspector** — Meta tags, Open Graph, structured data
18
- - **Analytics Viewer** — Google Analytics, Facebook Pixel tracking codes
19
- - **Storage Inspector** — localStorage, sessionStorage, and cookies
20
- - **Localization** — Markets, currencies, languages, and country data
11
+ ### Core Panels
21
12
 
22
- ## Quick Start
13
+ - **Objects Inspector** — Browse `shop`, `product`, `collection`, `customer`, `cart` and more with deep search and collapsible tree view
14
+ - **Metafields Viewer** — Explore metafields across all resources and namespaces with type labels
15
+ - **Cart Panel** — Real-time cart state with add/remove/quantity controls, cart history with restore, and attribute editing
16
+ - **Console** — Chrome DevTools-style console with Liquid expression evaluator, and autocomplete
17
+ - **Localization** — Markets, currencies, languages, and country data with quick switcher
18
+ - **SEO Inspector** — Meta tags, Open Graph, Twitter Cards, and structured data (JSON-LD) validation
19
+ - **Analytics Viewer** — Detects Google Analytics, Facebook Pixel, and other tracking codes
20
+ - **Storage Inspector** — Browse and edit localStorage, sessionStorage, and cookies
21
+ - **Apps Panel** — Lists installed Shopify apps detected on the page
22
+ - **Info Panel** — Theme details, template info, and request metadata
23
23
 
24
- **1. Add the snippet to your theme**
24
+ ### Objects Inspector
25
25
 
26
- Copy the Liquid bridge to your theme's snippets folder:
26
+ Browse and search through all Liquid objects with a collapsible tree view. Click any key to copy its Liquid path.
27
+
28
+ ![Objects Inspector](screenshots/object-inspector.gif)
29
+
30
+ ### Console Panel
31
+
32
+ A powerful Liquid debugger combining error detection and expression evaluation.
33
+
34
+ ![Console Panel](screenshots/console-panel.gif)
35
+
36
+ **Liquid Error Detection:**
37
+ - **Liquid Errors** — Detects `Liquid error:` and `Liquid syntax error:` messages in page content
38
+ - **Drop Object Leaks** — Finds raw Drop objects rendered on page (`ProductDrop`, `#<ProductDrop:0x...>`)
39
+ - **Asset Errors** — Missing snippets, images, and asset files
40
+ - **Schema Errors** — Invalid JSON in section schemas
41
+ - **JSON Filter Errors** — Detects `{"error":"..."}` output from failed `| json` filters
42
+ - **Form Errors** — Missing product/customer objects for forms
43
+ - **Smart Hints** — Context-aware fix suggestions for each error type
44
+
45
+ **Expression Evaluator:**
46
+
47
+ ### Cart Snapshots
48
+
49
+ Track cart state changes over time and restore any previous snapshot with a single click.
50
+
51
+ ![Cart Snapshots](screenshots/cart-snapshots.gif)
52
+
53
+ ### Console Expression Evaluator
54
+
55
+ The Console panel includes an interactive expression evaluator for testing Liquid paths:
27
56
 
28
57
  ```
29
- snippets/theme-devtools-bridge.liquid
58
+ > product.title
59
+ "Classic Cotton T-Shirt"
60
+
61
+ > product.variants[0].price | money
62
+ "$29.99"
63
+
64
+ > cart.items | size
65
+ 3
66
+
67
+ > shop.name | upcase
68
+ "MY AWESOME STORE"
30
69
  ```
31
70
 
32
- You can find it in [`src/liquid/theme-devtools-bridge.liquid`](src/liquid/theme-devtools-bridge.liquid) or install via npm:
71
+ **Features:**
72
+ - **Autocomplete** — Suggests paths as you type with Tab completion
73
+ - **Liquid Filters** — Supports `upcase`, `downcase`, `money`, `size`, `first`, `last`, and 50+ filters
74
+ - **Array Access** — Navigate arrays with bracket notation: `product.variants[0].title`
75
+ - **Live Data** — Uses current cart and product data, not stale page load values
76
+ - **Command History** — Use arrow keys to navigate previous expressions
77
+
78
+ ### Cart Panel
79
+
80
+ - **Live Updates** — Cart state updates in real-time as items are added/removed
81
+ - **Quantity Controls** — Adjust item quantities directly
82
+ - **Cart History** — View previous cart states with timestamps and restore any snapshot
83
+ - **Attribute Editor** — Modify cart attributes and notes
84
+ - **Diff View** — See what changed between cart states
85
+
86
+ ### Liquid Error Detection
87
+
88
+ Automatically scans the page for common Liquid issues:
89
+
90
+ - `Liquid error:` and `Liquid syntax error:` messages
91
+ - Drop object leaks (`#<ProductDrop:0x...>`)
92
+ - Missing snippets and assets
93
+ - Schema validation errors
94
+ - Deprecation warnings
95
+
96
+ ### Network Panel
97
+
98
+ Captures and inspects Shopify API requests with powerful debugging tools:
99
+
100
+ - **Request Logging** — Auto-captures cart, product, collection, search, and GraphQL requests
101
+ - **Request Editor** — Edit and resend requests with modified method, URL, headers, and body
102
+ - **Replay** — Re-execute any captured request with one click
103
+ - **Cart State Diff** — See exactly what changed in the cart after mutations (items added/removed/changed)
104
+ - **Copy as cURL/Fetch** — Export requests for debugging or sharing
105
+ - **Persistence** — Last 32 requests are saved to localStorage and restored on reload
106
+ - **GraphQL Prettifier** — Syntax-highlighted, formatted GraphQL queries
107
+ - **Error Diagnosis** — Smart suggestions for common cart and API errors (out of stock, invalid variants, quantity limits)
108
+
109
+ ### Tab Customization
110
+
111
+ Customize your devtools layout like Chrome DevTools:
112
+
113
+ - **Right-click any tab** to show/hide it
114
+ - **Drag tabs** to reorder them
115
+ - **Preferences tab** cannot be hidden (ensures you can always restore tabs)
116
+ - **"Reset to Defaults"** restores original tab order and visibility
117
+ - Hidden tabs are completely unloaded from DOM (saves memory/CPU)
118
+
119
+ ## Quick Start
120
+
121
+ ### 1. Add the snippet to your theme
122
+
123
+ Copy the Liquid bridge to your theme's snippets folder:
33
124
 
34
125
  ```bash
35
- npm install shopify-theme-devtools
36
- # Then copy node_modules/shopify-theme-devtools/src/liquid/theme-devtools-bridge.liquid to your snippets/
126
+ # Option A: Download directly
127
+ curl -o snippets/theme-devtools-bridge.liquid \
128
+ https://raw.githubusercontent.com/yakohere/shopify-theme-devtools/main/src/liquid/theme-devtools-bridge.liquid
129
+
130
+ # Option B: Copy manually from GitHub
131
+ # Visit: https://github.com/yakohere/shopify-theme-devtools/blob/main/src/liquid/theme-devtools-bridge.liquid
132
+ # Click "Raw" and save the file to your theme's snippets/ folder
37
133
  ```
38
134
 
39
- **2. Include in your layout**
135
+ ### 2. Include in your layout
40
136
 
41
137
  Add this line to `layout/theme.liquid` just before `</body>`:
42
138
 
@@ -44,84 +140,156 @@ Add this line to `layout/theme.liquid` just before `</body>`:
44
140
  {% render 'theme-devtools-bridge' %}
45
141
  ```
46
142
 
47
- **3. You're done!**
143
+ ### 3. You're done!
48
144
 
49
- The devtools panel will automatically appear on unpublished/development themes. It's safe to commit — it won't render on your live published theme.
145
+ The devtools panel automatically appears on **unpublished/development themes only**. It's safe to commit — it won't render on your live published theme.
50
146
 
51
- ## Usage
147
+ ## Keyboard Shortcuts
52
148
 
53
149
  | Action | Shortcut |
54
150
  |--------|----------|
55
151
  | Toggle Panel | `Cmd+Shift+D` (Mac) / `Ctrl+Shift+D` (Windows) |
56
- | Copy Liquid Path | Click any property key |
152
+ | Copy Liquid Path | Click any property key in Objects panel |
153
+ | Evaluate Expression | `Enter` in Console input |
154
+ | Autocomplete | `Tab` in Console input |
155
+ | Command History | `↑` / `↓` in Console input |
156
+ | Show/Hide Tabs | Right-click any tab |
157
+ | Reorder Tabs | Drag and drop tabs |
57
158
 
58
- ### Panels
159
+ ## Panel Reference
59
160
 
60
161
  | Panel | Description |
61
162
  |-------|-------------|
62
- | **Objects** | Inspect Liquid objects with deep search filtering |
63
- | **Metafields** | Browse metafields by resource and namespace |
64
- | **Cart** | Live cart state with manipulation actions |
65
- | **Locale** | Markets, currencies, languages |
66
- | **Analytics** | Tracking codes and analytics data |
67
- | **SEO** | Meta tags, Open Graph, structured data |
68
- | **Apps** | Installed Shopify apps |
69
- | **Console** | Captured logs with Liquid error detection |
70
- | **Cookies** | Browser cookies viewer |
71
- | **Storage** | localStorage & sessionStorage inspector |
72
- | **Info** | Theme, template, and request metadata |
73
-
74
- ## Console Panel Features
75
-
76
- The Console panel goes beyond basic logging:
77
-
78
- - **Liquid Error Detection** — Scans the DOM for `Liquid error`, `Liquid syntax error`, Drop objects (`#<ProductDrop:0x...>`), and schema errors
79
- - **Network Errors** — Captures failed fetch and XHR requests with status, timing, and URL
80
- - **Log Persistence** — Logs persist across page navigations within a session
81
- - **`console.table` Support** — Renders tables properly
82
- - **`console.group` Support** — Collapsible log groups
83
- - **Smart Grouping** — Deduplicates repeated errors with counts
163
+ | **Objects** | Inspect all Liquid objects with search and tree navigation |
164
+ | **Metafields** | Browse metafields by resource (product, collection, shop, etc.) |
165
+ | **Cart** | Live cart state, history snapshots, and manipulation tools |
166
+ | **Locale** | Markets, currencies, languages with locale switching |
167
+ | **Analytics** | Detected tracking codes and analytics configuration |
168
+ | **SEO** | Meta tags, Open Graph, Twitter Cards, JSON-LD structured data |
169
+ | **Apps** | Installed Shopify apps detected on the page |
170
+ | **Network** | API request monitor with edit/replay, cart diffs, and error diagnosis |
171
+ | **Console** | Logs, errors, and Liquid expression evaluator |
172
+ | **Cookies** | Browser cookies with expiration and flags |
173
+ | **Storage** | localStorage and sessionStorage key-value pairs |
174
+ | **Info** | Theme info, template details, request metadata |
175
+ | **Preferences** | Panel position, theme (dark/light), font scale, shortcuts |
84
176
 
85
177
  ## Configuration
86
178
 
87
- By default, the devtools load from jsDelivr CDN. For local development:
179
+ ### Local Development
180
+
181
+ For local development with hot reload:
182
+
183
+ 1. Edit the bridge snippet to enable local mode:
88
184
 
89
185
  ```liquid
90
186
  {%- assign devtools_local = true -%}
91
- {% render 'theme-devtools-bridge' %}
92
187
  ```
93
188
 
94
- Then run the dev server:
189
+ 2. Run the dev server:
95
190
 
96
191
  ```bash
97
192
  npm run dev # Starts at localhost:9999
98
193
  ```
99
194
 
195
+ ### Metafields Schema
196
+
197
+ To show all defined metafields (not just ones with values), paste your theme's `metafields.json` content into the bridge snippet:
198
+
199
+ ```liquid
200
+ {%- capture devtools_metafields_schema -%}
201
+ {
202
+ "product": [
203
+ { "namespace": "custom", "key": "care_instructions", "type": "single_line_text_field" }
204
+ ]
205
+ }
206
+ {%- endcapture -%}
207
+ ```
208
+
209
+ ### Theme Settings
210
+
211
+ Configure which theme settings to expose by editing the `devtools_settings_config` in the bridge snippet:
212
+
213
+ ```liquid
214
+ {%- capture devtools_settings_config -%}
215
+ colors_accent_1|color|Accent 1|colors
216
+ type_header_font|font_picker|Header font|typography
217
+ page_width|range|Page width|layout
218
+ {%- endcapture -%}
219
+ ```
220
+
100
221
  ## Development
101
222
 
102
223
  ```bash
103
224
  # Install dependencies
104
225
  npm install
105
226
 
106
- # Start dev server (localhost:9999)
227
+ # Start dev server with hot reload (localhost:9999)
107
228
  npm run dev
108
229
 
109
230
  # Build for production
110
231
  npm run build
232
+
233
+ # Preview production build
234
+ npm run preview
235
+ ```
236
+
237
+ ### Project Structure
238
+
239
+ ```
240
+ src/
241
+ ├── liquid/
242
+ │ └── theme-devtools-bridge.liquid # Liquid snippet for themes
243
+ ├── scripts/
244
+ │ ├── components/
245
+ │ │ ├── theme-devtools.js # Main component with tab management
246
+ │ │ ├── object-inspector.js # Tree view inspector
247
+ │ │ └── panels/ # Panel components
248
+ │ ├── services/
249
+ │ │ ├── cart.js # Cart API with history
250
+ │ │ ├── product.js # Product API (variants/images)
251
+ │ │ ├── context.js # Liquid context parser
252
+ │ │ ├── expression-evaluator.js # Liquid expression engine
253
+ │ │ ├── network-interceptor.js # Fetch/XHR interceptor with persistence
254
+ │ │ └── settings.js # User preferences
255
+ │ └── styles/
256
+ │ └── theme.js # CSS variables and themes
257
+ └── styles/
258
+ └── main.css
111
259
  ```
112
260
 
113
261
  ## How It Works
114
262
 
115
- 1. The Liquid bridge snippet extracts context (objects, metafields, settings) and injects it as JSON
116
- 2. The JavaScript bundle reads this context and renders the devtools panel
117
- 3. Only renders on unpublished themes (checks `theme.role != 'main'`)
118
- 4. Uses Shadow DOM for style isolation won't affect your theme styles
263
+ 1. **Context Extraction** — The Liquid bridge renders theme objects, metafields, and settings as a JSON blob
264
+ 2. **Async Data Loading** Product variants/images and cart data are fetched via Shopify's JSON APIs for live data
265
+ 3. **Expression Evaluation** Uses [LiquidJS](https://liquidjs.com/) to evaluate Liquid expressions with Shopify-specific filters
266
+ 4. **Shadow DOM Isolation** All styles are scoped to prevent conflicts with theme CSS
267
+ 5. **Session Persistence** — Logs, cart history, and preferences persist across page navigations
268
+
269
+ ### Security
270
+
271
+ - Only renders on unpublished themes (`theme.role != 'main'`)
272
+ - Customer emails are partially masked
273
+ - No data is sent to external servers
274
+ - All processing happens client-side
119
275
 
120
276
  ## Tech Stack
121
277
 
122
278
  - [Lit](https://lit.dev/) — Lightweight Web Components
279
+ - [LiquidJS](https://liquidjs.com/) — Liquid template engine
123
280
  - [Vite](https://vitejs.dev/) — Fast build tooling
124
- - Single IIFE bundle (~48KB gzipped)
281
+ - Single IIFE bundle (~55KB gzipped)
282
+
283
+ ## Browser Support
284
+
285
+ - Chrome 90+
286
+ - Firefox 90+
287
+ - Safari 14+
288
+ - Edge 90+
289
+
290
+ ## Contributing
291
+
292
+ Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
125
293
 
126
294
  ## License
127
295