shopify-theme-devtools 1.0.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/LICENSE +22 -0
- package/README.md +174 -0
- package/dist/theme-devtools.css +0 -0
- package/dist/theme-devtools.js +1836 -0
- package/package.json +61 -0
- package/src/liquid/theme-devtools-bridge.liquid +445 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Shopify Theme Devtools
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/shopify-theme-devtools)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
In-browser devtools panel for Shopify theme development. Inspect Liquid context, metafields, theme settings, cart state, and sections while working on storefront previews.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- đĻ **Object Inspector** â Tree-based viewer for Liquid objects (`cart`, `product`, `customer`, `shop`, etc.)
|
|
13
|
+
- đˇī¸ **Metafields Explorer** â Browse product, collection, shop metafields with type indicators
|
|
14
|
+
- đ¨ **Theme Settings** â View all theme settings organized by group with validation
|
|
15
|
+
- đ **Section Highlighter** â List all sections, click to highlight and scroll into view
|
|
16
|
+
- đ **Cart Toolkit** â Live cart state, change tracking, diff visualization, and actions
|
|
17
|
+
- đ **Copy as Liquid** â Click any property to copy its Liquid access path
|
|
18
|
+
- â¨ī¸ **Keyboard Shortcut** â `Cmd+Shift+D` to toggle panel
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### Option 1: npm + CDN (Recommended)
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install shopify-theme-devtools
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
After building, the JS bundle is available at:
|
|
29
|
+
- jsDelivr: `https://cdn.jsdelivr.net/npm/shopify-theme-devtools@latest/dist/theme-devtools.js`
|
|
30
|
+
- unpkg: `https://unpkg.com/shopify-theme-devtools@latest/dist/theme-devtools.js`
|
|
31
|
+
|
|
32
|
+
### Option 2: Manual Download
|
|
33
|
+
|
|
34
|
+
Download the latest release from [GitHub Releases](https://github.com/yourusername/shopify-theme-devtools/releases) and upload to your CDN.
|
|
35
|
+
|
|
36
|
+
## Setup in Shopify Theme
|
|
37
|
+
|
|
38
|
+
### 1. Add the Liquid Snippet
|
|
39
|
+
|
|
40
|
+
Copy the snippet to your theme's `snippets/` folder:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# From npm package
|
|
44
|
+
cp node_modules/shopify-theme-devtools/src/liquid/theme-devtools-bridge.liquid snippets/
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or copy manually from `src/liquid/theme-devtools-bridge.liquid`.
|
|
48
|
+
|
|
49
|
+
### 2. Configure the Snippet
|
|
50
|
+
|
|
51
|
+
Edit `snippets/theme-devtools-bridge.liquid`:
|
|
52
|
+
|
|
53
|
+
```liquid
|
|
54
|
+
{%- assign devtools_local = false -%} {# Set to true for local development #}
|
|
55
|
+
{%- assign devtools_cdn_base = 'https://cdn.jsdelivr.net/npm/shopify-theme-devtools@latest/dist' -%}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Optional:** Configure metafield namespaces and theme settings to expose:
|
|
59
|
+
|
|
60
|
+
```liquid
|
|
61
|
+
{%- assign devtools_metafield_namespaces = 'custom,global,my_fields' | split: ',' -%}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 3. Render in Theme
|
|
65
|
+
|
|
66
|
+
Add to `layout/theme.liquid` before `</body>`:
|
|
67
|
+
|
|
68
|
+
```liquid
|
|
69
|
+
{% render 'theme-devtools-bridge' %}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The devtools **only render on development/preview themes** (`theme.role == 'development'` or `theme.role == 'unpublished'`), so it's safe to leave in production code.
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
### Keyboard Shortcut
|
|
77
|
+
|
|
78
|
+
`Cmd+Shift+D` (Mac) / `Ctrl+Shift+D` (Windows) â Toggle panel visibility
|
|
79
|
+
|
|
80
|
+
### Tabs
|
|
81
|
+
|
|
82
|
+
| Tab | Description |
|
|
83
|
+
|-----|-------------|
|
|
84
|
+
| đĻ **Objects** | Inspect Liquid objects (shop, product, collection, customer, etc.) |
|
|
85
|
+
| đˇī¸ **Metafields** | Browse metafields by resource â namespace â key |
|
|
86
|
+
| đ¨ **Settings** | View theme settings and section settings |
|
|
87
|
+
| đ **Sections** | List and highlight rendered sections |
|
|
88
|
+
| đ **Cart** | Live cart state with edit capabilities |
|
|
89
|
+
| âšī¸ **Info** | Theme, template, request, and localization info |
|
|
90
|
+
|
|
91
|
+
### Copying Liquid Paths
|
|
92
|
+
|
|
93
|
+
Click any property key to copy its Liquid path:
|
|
94
|
+
- Object property â `{{ product.title }}`
|
|
95
|
+
- Metafield â `{{ product.metafields.custom.sizing_chart }}`
|
|
96
|
+
- Setting â `{{ settings.colors_accent_1 }}`
|
|
97
|
+
|
|
98
|
+
## Local Development
|
|
99
|
+
|
|
100
|
+
### Prerequisites
|
|
101
|
+
|
|
102
|
+
- Node.js 18+
|
|
103
|
+
- npm
|
|
104
|
+
|
|
105
|
+
### Setup
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
git clone https://github.com/yourusername/shopify-theme-devtools.git
|
|
109
|
+
cd shopify-theme-devtools
|
|
110
|
+
npm install
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Commands
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Development server with HMR (http://localhost:9999)
|
|
117
|
+
npm run dev
|
|
118
|
+
|
|
119
|
+
# Production build
|
|
120
|
+
npm run build
|
|
121
|
+
|
|
122
|
+
# Preview production build
|
|
123
|
+
npm run preview
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Local Development Workflow
|
|
127
|
+
|
|
128
|
+
1. Run `npm run dev` to start Vite dev server
|
|
129
|
+
2. Set `devtools_local = true` in your theme's snippet
|
|
130
|
+
3. Run `shopify theme dev` in your theme directory
|
|
131
|
+
4. Changes to JS files hot-reload automatically
|
|
132
|
+
|
|
133
|
+
## Project Structure
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
src/
|
|
137
|
+
âââ scripts/
|
|
138
|
+
â âââ components/ # Lit web components
|
|
139
|
+
â â âââ panels/ # Panel components (objects, metafields, settings, etc.)
|
|
140
|
+
â â âââ object-inspector.js
|
|
141
|
+
â â âââ theme-devtools.js
|
|
142
|
+
â âââ services/ # Context parser, Cart API, Section highlighter
|
|
143
|
+
â âââ main.js # Entry point
|
|
144
|
+
âââ styles/
|
|
145
|
+
â âââ main.css
|
|
146
|
+
âââ liquid/
|
|
147
|
+
âââ theme-devtools-bridge.liquid
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Technical Details
|
|
151
|
+
|
|
152
|
+
- **Lit Web Components** â Modern, reactive UI components
|
|
153
|
+
- **Shadow DOM** â Isolates devtools CSS from theme styles
|
|
154
|
+
- **Cart Tracking** â Ajax interception + polling fallback
|
|
155
|
+
- **Section Detection** â `[id^="shopify-section-"]` + `[data-section-id]`
|
|
156
|
+
- **~50KB** â Minified bundle size
|
|
157
|
+
|
|
158
|
+
## Browser Support
|
|
159
|
+
|
|
160
|
+
Chrome 80+, Firefox 78+, Safari 14+, Edge 80+
|
|
161
|
+
|
|
162
|
+
## Contributing
|
|
163
|
+
|
|
164
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
[MIT](LICENSE) Š Your Name
|
|
169
|
+
|
|
170
|
+
## Related
|
|
171
|
+
|
|
172
|
+
- [Shopify Theme Development](https://shopify.dev/themes)
|
|
173
|
+
- [Liquid Reference](https://shopify.dev/docs/api/liquid)
|
|
174
|
+
- [Theme Check](https://github.com/Shopify/theme-check)
|
|
File without changes
|