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 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
+ [![npm version](https://img.shields.io/npm/v/shopify-theme-devtools.svg)](https://www.npmjs.com/package/shopify-theme-devtools)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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
+ ![Theme Devtools Screenshot](https://via.placeholder.com/800x400?text=Theme+Devtools+Screenshot)
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