vite-plugin-shopify-theme-islands 1.2.0 → 1.2.2

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.
@@ -4,15 +4,19 @@ description: >
4
4
  Built-in client directives: client:visible (IntersectionObserver, rootMargin),
5
5
  client:media (matchMedia query), client:idle (requestIdleCallback),
6
6
  client:defer (setTimeout delay), client:interaction (mouseenter/touchstart/focusin).
7
- Directives resolve sequentially — visible → media → idle → defer → interaction → custom.
8
- Per-element value overrides. Empty client:media warning. Whitespace-only
9
- client:interaction values warn and fall back to default events.
7
+ Directives resolve sequentially — visible → media → idle → defer →
8
+ interaction → custom. Per-element value overrides. Empty client:media
9
+ warning. Whitespace-only client:interaction values warn and fall back to
10
+ default events. Current directive sequencing and custom-directive latching
11
+ are owned by src/directive-orchestration.ts.
10
12
  type: core
11
13
  library: vite-plugin-shopify-theme-islands
12
- library_version: "1.2.0"
14
+ library_version: "1.2.2"
13
15
  sources:
16
+ - Rees1993/vite-plugin-shopify-theme-islands:src/directive-orchestration.ts
14
17
  - Rees1993/vite-plugin-shopify-theme-islands:src/runtime.ts
15
- - Rees1993/vite-plugin-shopify-theme-islands:src/index.ts
18
+ - Rees1993/vite-plugin-shopify-theme-islands:src/contract.ts
19
+ - Rees1993/vite-plugin-shopify-theme-islands:src/config-policy.ts
16
20
  ---
17
21
 
18
22
  ## Setup
@@ -49,10 +53,7 @@ Directives resolve in a fixed order: `visible → media → idle → defer → i
49
53
  <mega-menu client:visible client:interaction></mega-menu>
50
54
 
51
55
  <!-- Loads when visible AND the media query matches -->
52
- <product-recommendations
53
- client:visible
54
- client:media="(min-width: 768px)"
55
- ></product-recommendations>
56
+ <product-recommendations client:visible client:media="(min-width: 768px)"></product-recommendations>
56
57
  ```
57
58
 
58
59
  Combined directives are AND-latched. The island loads only after every condition resolves. There is no OR mode.
@@ -99,7 +100,7 @@ An empty `client:defer` attribute is NOT zero — it falls back to the configure
99
100
 
100
101
  An empty `client:interaction` attribute uses the configured default events with no warning. A whitespace-only value such as `client:interaction=" "` emits a warning and still falls back to the default events.
101
102
 
102
- Source: src/runtime.ts — interaction token parsing and fallback warning
103
+ Source: src/directive-orchestration.ts — interaction token parsing and fallback warning
103
104
 
104
105
  ### Changing built-in directive defaults globally
105
106
 
@@ -117,8 +118,7 @@ shopifyThemeIslands({
117
118
  ### Removed elements abort waiting directives silently
118
119
 
119
120
  ```html
120
- <hero-banner client:visible></hero-banner>
121
- <cart-flyout client:interaction></cart-flyout>
121
+ <hero-banner client:visible></hero-banner> <cart-flyout client:interaction></cart-flyout>
122
122
  ```
123
123
 
124
124
  If either element is removed from the DOM before its directive resolves, the runtime cancels that activation attempt and does not dispatch `islands:error`. This is expected teardown behavior, not a load failure.
@@ -141,7 +141,7 @@ Correct:
141
141
 
142
142
  An empty `client:media` value emits a console warning and skips the media check — the island loads immediately. Provide a valid media query string.
143
143
 
144
- Source: src/runtime.ts — `if (query === "")` branch
144
+ Source: src/directive-orchestration.ts — `if (query === "")` branch
145
145
 
146
146
  ### MEDIUM Whitespace-only `client:interaction` value warns and falls back
147
147
 
@@ -163,7 +163,7 @@ Correct:
163
163
 
164
164
  Whitespace-only values are not treated the same as an empty attribute. The runtime warns and falls back to the configured default events.
165
165
 
166
- Source: src/runtime.ts — `interactionAttr.split(/\s+/).filter(Boolean)`
166
+ Source: src/directive-orchestration.ts — `interactionAttr.split(/\s+/).filter(Boolean)`
167
167
 
168
168
  ### HIGH Multiple directives are AND, not OR
169
169
 
@@ -183,7 +183,7 @@ Correct understanding:
183
183
 
184
184
  The runtime awaits each directive sequentially. There is no way to express OR semantics with built-in directives — use a custom directive for that.
185
185
 
186
- Source: src/runtime.ts — loadIsland sequential awaits
186
+ Source: src/directive-orchestration.ts — runBuiltIns() sequential awaits
187
187
 
188
188
  ### MEDIUM `client:defer` without value ≠ immediate load
189
189
 
@@ -203,7 +203,7 @@ Correct:
203
203
 
204
204
  `client:defer` with no value uses the global `defer.delay` default (3000ms). `parseInt("", 10)` produces `NaN`, which the runtime replaces with the configured default.
205
205
 
206
- Source: src/runtime.ts — `const ms = Number.isNaN(raw) ? deferDelay : raw`
206
+ Source: src/directive-orchestration.ts — defer parsing and fallback to directives.defer.delay
207
207
 
208
208
  ### MEDIUM Per-element visible value replaces rootMargin, not adds to it
209
209
 
@@ -223,15 +223,14 @@ Correct:
223
223
 
224
224
  The attribute value is passed directly to `IntersectionObserver` as `rootMargin`, fully replacing the global default.
225
225
 
226
- Source: src/runtime.ts — `await visible(el, visibleAttr || rootMargin, threshold, registry.watchCancellable)`
226
+ Source: src/directive-orchestration.ts — visible attribute value replaces directives.visible.rootMargin
227
227
 
228
228
  ### HIGH Directive attribute typo — island loads without condition
229
229
 
230
230
  Wrong:
231
231
 
232
232
  ```html
233
- <product-form client:visibled></product-form>
234
- <product-form client:Visible></product-form>
233
+ <product-form client:visibled></product-form> <product-form client:Visible></product-form>
235
234
  ```
236
235
 
237
236
  Correct:
@@ -242,7 +241,7 @@ Correct:
242
241
 
243
242
  Directive attributes are case-sensitive. An unrecognised attribute is silently ignored — the island loads immediately as if no directive were set. No warning is emitted. Check for typos if an island activates earlier than expected.
244
243
 
245
- Source: src/runtime.ts — runtime checks exact attribute names from plugin config
244
+ Source: src/directive-orchestration.ts — built-ins read exact configured attribute names
246
245
 
247
246
  ### HIGH Agent uses default attribute name when developer has configured a custom one
248
247
 
@@ -261,4 +260,4 @@ Correct:
261
260
 
262
261
  When `directives.visible.attribute` (or any directive's `attribute` option) is overridden in `vite.config.ts`, all Liquid templates must use the configured name. The default `client:*` names no longer apply. Always read `vite.config.ts` to check for overridden attribute names before writing directives in Liquid.
263
262
 
264
- Source: src/index.ts:DirectivesConfig — `attribute` field per directive; src/runtime.ts reads configured attribute names at runtime
263
+ Source: src/options.ts:DirectivesConfig — `attribute` field per directive; src/runtime.ts reads configured attribute names at runtime
@@ -8,14 +8,17 @@ description: >
8
8
  duration (ms), and attempt (1-based). islands:error detail includes tag,
9
9
  error, and attempt, including custom directive failures and directiveTimeout
10
10
  expiry. disconnect() from the virtual module revive for SPA navigation
11
- teardown.
11
+ teardown, including before DOMContentLoaded — it now prevents init from ever
12
+ starting if called early.
12
13
  type: core
13
14
  library: vite-plugin-shopify-theme-islands
14
- library_version: "1.2.0"
15
+ library_version: "1.2.2"
15
16
  sources:
16
17
  - Rees1993/vite-plugin-shopify-theme-islands:src/events.ts
18
+ - Rees1993/vite-plugin-shopify-theme-islands:src/runtime-surface.ts
17
19
  - Rees1993/vite-plugin-shopify-theme-islands:src/contract.ts
18
20
  - Rees1993/vite-plugin-shopify-theme-islands:src/runtime.ts
21
+ - Rees1993/vite-plugin-shopify-theme-islands:src/revive-module.ts
19
22
  ---
20
23
 
21
24
  ## Setup
@@ -85,7 +88,7 @@ import { disconnect } from "vite-plugin-shopify-theme-islands/revive";
85
88
  disconnect();
86
89
  ```
87
90
 
88
- `disconnect()` stops the MutationObserver and prevents new islands from activating. Call it before SPA page transitions to avoid activating islands from the previous page's DOM.
91
+ `disconnect()` stops the MutationObserver and prevents new islands from activating. If the runtime has not initialized yet because the document is still loading, `disconnect()` also unregisters the pending DOMContentLoaded startup listener so init never runs later. Call it before SPA page transitions to avoid activating islands from the previous page's DOM.
89
92
 
90
93
  ### Raw DOM events (when type augmentation is in scope)
91
94
 
@@ -144,7 +147,7 @@ import { disconnect } from "vite-plugin-shopify-theme-islands/revive";
144
147
 
145
148
  Only the virtual module (`/revive`) exports the `disconnect` bound to the plugin-managed `revive()` instance. Importing from other entry points references a different or nonexistent instance.
146
149
 
147
- Source: src/index.ts — virtual module `export const { disconnect } = _islands(...)`
150
+ Source: src/revive-module.ts — buildReviveModuleSource() emits `export const { disconnect } = _islands(payload)`
148
151
 
149
152
  ### MEDIUM `onIslandError` fires on every retry, not just final failure
150
153
 
@@ -170,7 +173,7 @@ onIslandError(({ tag, error, attempt }) => {
170
173
 
171
174
  With `retry: { retries: 3 }`, a single island can fire `islands:error` up to 4 times before exhausting retries. Use `attempt` to distinguish the initial failure from retries.
172
175
 
173
- Source: src/runtime.ts — `dispatch("islands:error", ...)` inside `.catch()` before retry check
176
+ Source: src/runtime.ts — runtimeSurface.dispatchError(...) inside the loader failure path before retry check
174
177
 
175
178
  ### MEDIUM `islands:error` fires for custom directive failures too
176
179
 
@@ -10,10 +10,12 @@ description: >
10
10
  directive timeout.
11
11
  type: core
12
12
  library: vite-plugin-shopify-theme-islands
13
- library_version: "1.2.0"
13
+ library_version: "1.2.2"
14
14
  sources:
15
15
  - Rees1993/vite-plugin-shopify-theme-islands:src/index.ts
16
16
  - Rees1993/vite-plugin-shopify-theme-islands:src/contract.ts
17
+ - Rees1993/vite-plugin-shopify-theme-islands:src/options.ts
18
+ - Rees1993/vite-plugin-shopify-theme-islands:src/config-policy.ts
17
19
  ---
18
20
 
19
21
  ## Setup
@@ -207,7 +209,7 @@ shopifyThemeIslands({
207
209
 
208
210
  `directives` accepts only `visible`, `idle`, `media`, `defer`, `interaction`, and `custom`. `retry` at `directives.retry` is silently ignored.
209
211
 
210
- Source: src/index.ts — ShopifyThemeIslandsOptions
212
+ Source: src/options.ts — ShopifyThemeIslandsOptions
211
213
 
212
214
  ### HIGH Wrong key name for retry count
213
215
 
@@ -250,4 +252,4 @@ shopifyThemeIslands({
250
252
 
251
253
  `directiveTimeout` is a top-level plugin option, not part of the per-directive config object.
252
254
 
253
- Source: src/index.ts — ShopifyThemeIslandsOptions
255
+ Source: src/options.ts — ShopifyThemeIslandsOptions
@@ -8,7 +8,7 @@ description: >
8
8
  base class, and child island cascade behaviour.
9
9
  type: core
10
10
  library: vite-plugin-shopify-theme-islands
11
- library_version: "1.2.0"
11
+ library_version: "1.2.2"
12
12
  sources:
13
13
  - Rees1993/vite-plugin-shopify-theme-islands:src/island.ts
14
14
  - Rees1993/vite-plugin-shopify-theme-islands:src/discovery.ts