@scayle/storefront-devtools 0.2.0-alpha.4 → 0.2.0-alpha.6

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.
Files changed (127) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +234 -111
  3. package/dist/_chunks/{coalesce-D-Q8NzYg.mjs → coalesce-PetLUcf2.mjs} +388 -404
  4. package/dist/_chunks/frame-nav-DctWjxeG.mjs +3 -0
  5. package/dist/group.d.ts +14 -26
  6. package/dist/group.d.ts.map +1 -1
  7. package/dist/index.d.ts +29 -10
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.mjs +80 -116
  10. package/dist/inertia/channel.d.ts +18 -5
  11. package/dist/inertia/channel.d.ts.map +1 -1
  12. package/dist/inertia/client/index.mjs +242 -210
  13. package/dist/inertia/client/messages.d.ts +28 -0
  14. package/dist/inertia/client/messages.d.ts.map +1 -0
  15. package/dist/inertia/client/publish.d.ts +4 -2
  16. package/dist/inertia/client/publish.d.ts.map +1 -1
  17. package/dist/inertia/core/capture.d.ts.map +1 -1
  18. package/dist/inertia/core/correlator.d.ts +16 -0
  19. package/dist/inertia/core/correlator.d.ts.map +1 -1
  20. package/dist/inertia/core/diagnostics.d.ts.map +1 -1
  21. package/dist/inertia/core/diff.d.ts +2 -1
  22. package/dist/inertia/core/diff.d.ts.map +1 -1
  23. package/dist/inertia/core/feature-info.d.ts +9 -5
  24. package/dist/inertia/core/feature-info.d.ts.map +1 -1
  25. package/dist/inertia/core/features.d.ts.map +1 -1
  26. package/dist/inertia/core/history-capture.d.ts.map +1 -1
  27. package/dist/inertia/core/interceptors.d.ts +1 -0
  28. package/dist/inertia/core/interceptors.d.ts.map +1 -1
  29. package/dist/inertia/core/markdown.d.ts.map +1 -1
  30. package/dist/inertia/core/protocol.d.ts +1 -1
  31. package/dist/inertia/core/protocol.d.ts.map +1 -1
  32. package/dist/inertia/core/request-filters.d.ts +19 -0
  33. package/dist/inertia/core/request-filters.d.ts.map +1 -0
  34. package/dist/inertia/core/request-tree.d.ts +6 -3
  35. package/dist/inertia/core/request-tree.d.ts.map +1 -1
  36. package/dist/inertia/core/response.d.ts +3 -2
  37. package/dist/inertia/core/response.d.ts.map +1 -1
  38. package/dist/inertia/core/store.d.ts +1 -0
  39. package/dist/inertia/core/store.d.ts.map +1 -1
  40. package/dist/inertia/core/types.d.ts +2 -2
  41. package/dist/inertia/core/types.d.ts.map +1 -1
  42. package/dist/inertia/core/url.d.ts +12 -0
  43. package/dist/inertia/core/url.d.ts.map +1 -1
  44. package/dist/inject.d.ts +3 -4
  45. package/dist/inject.d.ts.map +1 -1
  46. package/dist/og.d.ts +12 -0
  47. package/dist/og.d.ts.map +1 -0
  48. package/dist/orpc/channel.d.ts +9 -1
  49. package/dist/orpc/channel.d.ts.map +1 -1
  50. package/dist/orpc/client/index.mjs +118 -102
  51. package/dist/orpc/client/publish.d.ts +3 -1
  52. package/dist/orpc/client/publish.d.ts.map +1 -1
  53. package/dist/orpc/core/session.d.ts +1 -8
  54. package/dist/orpc/core/session.d.ts.map +1 -1
  55. package/dist/orpc/core/stats.d.ts +1 -1
  56. package/dist/orpc/core/stats.d.ts.map +1 -1
  57. package/dist/orpc/core/store.d.ts +1 -0
  58. package/dist/orpc/core/store.d.ts.map +1 -1
  59. package/dist/shared/clipboard.d.ts +23 -3
  60. package/dist/shared/clipboard.d.ts.map +1 -1
  61. package/dist/shared/panel-channel.d.ts +27 -1
  62. package/dist/shared/panel-channel.d.ts.map +1 -1
  63. package/dist/shared/prefs.d.ts +49 -0
  64. package/dist/shared/prefs.d.ts.map +1 -0
  65. package/dist/shared/redact.d.ts +6 -3
  66. package/dist/shared/redact.d.ts.map +1 -1
  67. package/dist/shared/safe-clone.d.ts +2 -1
  68. package/dist/shared/safe-clone.d.ts.map +1 -1
  69. package/dist/ui/assets/App-BDAG24ch.js +4 -0
  70. package/dist/ui/assets/App-CBJXphAE.css +1 -0
  71. package/dist/ui/assets/App-CoMIIpFn.js +5 -0
  72. package/dist/ui/assets/App-CrZKW7ZD.js +1 -0
  73. package/dist/ui/assets/App-D9h2xKeA.css +1 -0
  74. package/dist/ui/assets/App-DIxgDJPh.css +1 -0
  75. package/dist/ui/assets/HeadersTab-BAgPi_LJ.css +1 -0
  76. package/dist/ui/assets/HeadersTab-YiDZOc7w.js +1 -0
  77. package/dist/ui/assets/_plugin-vue_export-helper-DnlXueOW.js +2 -0
  78. package/dist/ui/assets/panels-BZNAuOBL.css +1 -0
  79. package/dist/ui/assets/panels-X7JpniLo.js +3 -0
  80. package/dist/ui/assets/store-CmrV1otI.js +1 -0
  81. package/dist/ui/panels/index.html +2 -3
  82. package/package.json +23 -26
  83. package/dist/inertia/plugin.d.ts +0 -13
  84. package/dist/inertia/plugin.d.ts.map +0 -1
  85. package/dist/orpc/plugin.d.ts +0 -13
  86. package/dist/orpc/plugin.d.ts.map +0 -1
  87. package/dist/storefront/plugin.d.ts +0 -11
  88. package/dist/storefront/plugin.d.ts.map +0 -1
  89. package/dist/ui/assets/App-BMyWBnLQ.js +0 -4
  90. package/dist/ui/assets/App-C5-JscO0.css +0 -1
  91. package/dist/ui/assets/App-CCUPtzNx.js +0 -5
  92. package/dist/ui/assets/App-Ct7Za--B.css +0 -1
  93. package/dist/ui/assets/App-Ctfis9Sq.js +0 -1
  94. package/dist/ui/assets/App-jiQKInbo.css +0 -1
  95. package/dist/ui/assets/_plugin-vue_export-helper-BDNMzG2s.js +0 -1
  96. package/dist/ui/assets/channel-D7V7aU79.js +0 -1
  97. package/dist/ui/assets/clipboard-BY7CN-yK.js +0 -1
  98. package/dist/ui/assets/clipboard-BnEeWyfh.css +0 -1
  99. package/dist/ui/assets/css-8QJvnqUH.js +0 -1
  100. package/dist/ui/assets/css-lJZLS6R3.js +0 -1
  101. package/dist/ui/assets/diff-woXpYk--.js +0 -1
  102. package/dist/ui/assets/html-GueGcY0x.js +0 -1
  103. package/dist/ui/assets/html-WzJrCOnD.js +0 -1
  104. package/dist/ui/assets/javascript-BzbQS41l.js +0 -1
  105. package/dist/ui/assets/javascript-CpIGwZ_Y.js +0 -1
  106. package/dist/ui/assets/json-B88Oqtu5.js +0 -1
  107. package/dist/ui/assets/json-C3WlssX3.js +0 -1
  108. package/dist/ui/assets/panel-channel-qxy-vGGq.js +0 -2
  109. package/dist/ui/assets/panels-B4LTsmli.css +0 -1
  110. package/dist/ui/assets/panels-BcOW2Xog.js +0 -2
  111. package/dist/ui/assets/preload-helper-CSlQMSTd.js +0 -2
  112. package/dist/ui/assets/shellscript-CLZ0U2zV.js +0 -1
  113. package/dist/ui/assets/typescript-Bb1J8qyy.js +0 -1
  114. package/dist/ui/assets/typescript-j_1H8WHN.js +0 -1
  115. package/dist/ui/assets/vitesse-dark-BZCL-v6S.js +0 -1
  116. package/dist/ui/assets/vitesse-light-VbXTXTou.js +0 -1
  117. package/dist/ui/assets/vue-B1Tf5CHw.js +0 -1
  118. package/dist/ui/assets/vue-C0gCEhF7.js +0 -155
  119. package/dist/ui/assets/vue-Kq4tvBbL.css +0 -1
  120. package/dist/ui/assets/vue-html-CGMs_6qn.js +0 -1
  121. package/dist/ui/assets/yaml-rwi0_p6S.js +0 -1
  122. package/dist/ui/vue/index.html +0 -15
  123. package/dist/vue-devtools/client/index.mjs +0 -4899
  124. package/dist/vue-devtools/client.d.ts +0 -2
  125. package/dist/vue-devtools/client.d.ts.map +0 -1
  126. package/dist/vue-devtools/plugin.d.ts +0 -15
  127. package/dist/vue-devtools/plugin.d.ts.map +0 -1
@@ -1,66 +1,43 @@
1
- import { a as e, c as t, i as n, n as r, o as i, s as a, t as o } from "../../_chunks/coalesce-D-Q8NzYg.mjs";
2
- //#region src/inertia/core/features.ts
3
- function s(e) {
1
+ import { a as e, c as t, i as n, n as r, o as i, s as a, t as o } from "../../_chunks/coalesce-PetLUcf2.mjs";
2
+ import { n as s, t as c } from "../../_chunks/frame-nav-DctWjxeG.mjs";
3
+ // src/inertia/core/features.ts
4
+ function l(e) {
4
5
  return typeof e == "object" && !!e && Object.keys(e).length > 0;
5
6
  }
6
- function c(e) {
7
+ function u(e) {
7
8
  let t = [], n = null;
8
- return s(e.deferredProps) ? n = e.deferredProps : s(e.initialDeferredProps) && (n = e.initialDeferredProps), n && t.push({
9
+ return l(e.deferredProps) ? n = e.deferredProps : l(e.initialDeferredProps) && (n = e.initialDeferredProps), n && t.push({
9
10
  type: "deferred",
10
- label: "DEFERRED",
11
11
  details: { groups: n }
12
12
  }), e.mergeProps?.length && t.push({
13
13
  type: "merge",
14
- label: "MERGE",
15
14
  details: { props: e.mergeProps }
16
15
  }), e.prependProps?.length && t.push({
17
16
  type: "prepend",
18
- label: "PREPEND",
19
17
  details: { props: e.prependProps }
20
18
  }), e.deepMergeProps?.length && t.push({
21
19
  type: "deep-merge",
22
- label: "DEEP MERGE",
23
20
  details: { props: e.deepMergeProps }
24
- }), s(e.scrollProps) && t.push({
21
+ }), l(e.scrollProps) && t.push({
25
22
  type: "scroll",
26
- label: "SCROLL",
27
23
  details: { props: e.scrollProps }
28
- }), s(e.onceProps) && t.push({
24
+ }), l(e.onceProps) && t.push({
29
25
  type: "once",
30
- label: "ONCE",
31
26
  details: { props: e.onceProps }
32
- }), e.encryptHistory && t.push({
33
- type: "encrypted",
34
- label: "ENCRYPTED"
35
- }), e.clearHistory && t.push({
36
- type: "clear-history",
37
- label: "CLEAR HISTORY"
38
- }), s(e.flash) && t.push({
27
+ }), e.encryptHistory && t.push({ type: "encrypted" }), e.clearHistory && t.push({ type: "clear-history" }), l(e.flash) && t.push({
39
28
  type: "flash",
40
- label: "FLASH",
41
29
  details: { flash: e.flash }
42
- }), s(e.rememberedState) && t.push({
30
+ }), l(e.rememberedState) && t.push({
43
31
  type: "remember",
44
- label: "REMEMBER",
45
32
  details: { keys: Object.keys(e.rememberedState) }
46
33
  }), t;
47
34
  }
48
- function l(e, t) {
35
+ function d(e, t) {
49
36
  let n = [];
50
- return e.type === "partial" && n.push({
51
- type: "partial",
52
- label: "PARTIAL"
53
- }), n.push(...c(t)), e.type === "prefetch" && n.push({
54
- type: "prefetch",
55
- label: "PREFETCH"
56
- }), !e.events.some((e) => e.name === "inertia:start") && e.startedAt > 0 && e.type !== "client" && n.push({
57
- type: "cached",
58
- label: "CACHED"
59
- }), n;
60
- }
61
- //#endregion
62
- //#region src/inertia/core/url.ts
63
- function u(e) {
37
+ return e.type === "partial" && n.push({ type: "partial" }), n.push(...u(t)), e.type === "prefetch" && n.push({ type: "prefetch" }), !e.events.some((e) => e.name === "inertia:start") && e.startedAt > 0 && e.type !== "client" && n.push({ type: "cached" }), n;
38
+ }
39
+ // src/inertia/core/url.ts
40
+ function f(e) {
64
41
  try {
65
42
  let t = new URL(e, "http://localhost");
66
43
  return t.pathname + t.search;
@@ -68,17 +45,16 @@ function u(e) {
68
45
  return e;
69
46
  }
70
47
  }
71
- //#endregion
72
- //#region src/inertia/core/diagnostics.ts
73
- function d(e) {
74
- return e.type === "redirect" && e.status === 409 ? {
48
+ // src/inertia/core/diagnostics.ts
49
+ function p(e) {
50
+ return e.events.find((e) => e.name === "inertia:location")?.detail.versionChange === !0 ? {
75
51
  id: "version-mismatch",
76
52
  severity: "warning",
77
53
  message: "Asset version mismatch, full page reload",
78
54
  docsUrl: "https://inertiajs.com/the-protocol#asset-versioning"
79
55
  } : null;
80
56
  }
81
- function f(e) {
57
+ function m(e) {
82
58
  return e.interrupted ? {
83
59
  id: "visit-interrupted",
84
60
  severity: "info",
@@ -89,7 +65,7 @@ function f(e) {
89
65
  message: "Visit was cancelled"
90
66
  } : null;
91
67
  }
92
- function p(e) {
68
+ function h(e) {
93
69
  if (e.only?.length && e.page?.props) {
94
70
  let t = Object.keys(e.page.props), n = e.only.filter((e) => !t.includes(e));
95
71
  if (n.length) return {
@@ -101,7 +77,7 @@ function p(e) {
101
77
  }
102
78
  return null;
103
79
  }
104
- function m(e) {
80
+ function g(e) {
105
81
  return e.only && e.only.length > 0 && !e.only.includes("errors") && (e.status === 422 || e.events.some((e) => e.name === "inertia:error")) ? {
106
82
  id: "errors-filtered",
107
83
  severity: "warning",
@@ -109,7 +85,7 @@ function m(e) {
109
85
  docsUrl: "https://inertiajs.com/partial-reloads"
110
86
  } : null;
111
87
  }
112
- function h(e) {
88
+ function _(e) {
113
89
  return e.type === "deferred" && e.error ? {
114
90
  id: "deferred-failed",
115
91
  severity: "error",
@@ -117,7 +93,7 @@ function h(e) {
117
93
  docsUrl: "https://inertiajs.com/deferred-props"
118
94
  } : null;
119
95
  }
120
- function g(e) {
96
+ function ee(e) {
121
97
  if (e.type === "client" && e.method === "REPLACE") return {
122
98
  id: "history-replace",
123
99
  severity: "info",
@@ -126,7 +102,7 @@ function g(e) {
126
102
  };
127
103
  if (e.visitOptions?.replace === !0) {
128
104
  let t = e.previousPage?.url;
129
- return t && u(t) === u(e.url) ? {
105
+ return t && f(t) === f(e.url) ? {
130
106
  id: "history-replace-same-url",
131
107
  severity: "info",
132
108
  message: "History replaced (same URL)",
@@ -140,25 +116,24 @@ function g(e) {
140
116
  }
141
117
  return null;
142
118
  }
143
- var _ = [
144
- d,
145
- f,
119
+ var v = [
146
120
  p,
147
121
  m,
148
122
  h,
149
- g
123
+ g,
124
+ _,
125
+ ee
150
126
  ];
151
- function v(e) {
127
+ function y(e) {
152
128
  let t = [];
153
- for (let n of _) {
129
+ for (let n of v) {
154
130
  let r = n(e);
155
131
  r && t.push(r);
156
132
  }
157
133
  return t;
158
134
  }
159
- //#endregion
160
- //#region src/inertia/core/correlator.ts
161
- var y = 10, b = 2e3, x = class {
135
+ // src/inertia/core/correlator.ts
136
+ var b = 10, x = 2e3, S = 100, C = class {
162
137
  nextVisitId = 1;
163
138
  records = /* @__PURE__ */ new Map();
164
139
  sortedRecords = [];
@@ -182,6 +157,7 @@ var y = 10, b = 2e3, x = class {
182
157
  case "inertia:cancel": return this.handleCancel(e);
183
158
  case "inertia:navigate": return this.handleNavigate(e, n);
184
159
  case "inertia:beforeUpdate": return this.handleBeforeUpdate(e, n);
160
+ case "inertia:location": return this.handleLocation(e, n);
185
161
  default: return this.handleGenericEvent(e, n);
186
162
  }
187
163
  }
@@ -198,8 +174,8 @@ var y = 10, b = 2e3, x = class {
198
174
  return this._evictedCount;
199
175
  }
200
176
  hasRequestWithUrl(e) {
201
- let t = u(e);
202
- return this.sortedRecords.some((e) => u(e.url) === t);
177
+ let t = f(e);
178
+ return this.sortedRecords.some((e) => f(e.url) === t);
203
179
  }
204
180
  processClientVisit(e, t, n) {
205
181
  let r = this.nextVisitId++, i = performance.now(), a = {
@@ -211,7 +187,7 @@ var y = 10, b = 2e3, x = class {
211
187
  finishedAt: i,
212
188
  duration: 0,
213
189
  events: [],
214
- features: c(t),
190
+ features: u(t),
215
191
  diagnostics: [],
216
192
  cancelled: !1,
217
193
  interrupted: !1,
@@ -226,7 +202,7 @@ var y = 10, b = 2e3, x = class {
226
202
  }
227
203
  linkNetworkTiming(e) {
228
204
  let t = this.findNetworkMatch(e);
229
- return t ? (t.network = e, t) : (this.pendingNetwork.push(e), this.pendingNetwork.length > y && this.pendingNetwork.shift(), null);
205
+ return t ? (t.network = e, t) : (this.pendingNetwork.push(e), this.pendingNetwork.length > b && this.pendingNetwork.shift(), null);
230
206
  }
231
207
  attachRequestHeaders(e, t) {
232
208
  let n = this.recordByInertiaVisitId.get(e);
@@ -234,7 +210,7 @@ var y = 10, b = 2e3, x = class {
234
210
  }
235
211
  attachResponseData(e, t) {
236
212
  let n = this.recordByInertiaVisitId.get(e);
237
- return n ? (n.responseHeaders = t.headers, n.responseProps = t.props, n) : null;
213
+ return n ? (t.status !== void 0 && (n.status = t.status), n.responseHeaders = t.headers, n.responseProps = t.props, n) : null;
238
214
  }
239
215
  drainPendingNetwork(e) {
240
216
  let t = this.pendingNetwork.findLastIndex((t) => this.networkMatchesVisit(t, e));
@@ -244,7 +220,7 @@ var y = 10, b = 2e3, x = class {
244
220
  return this.sortedRecords.findLast((t) => !t.network && this.networkMatchesVisit(e, t)) ?? null;
245
221
  }
246
222
  networkMatchesVisit(e, t) {
247
- return !(u(e.url) !== u(t.url) || e.startedAt < t.startedAt - b || t.finishedAt && e.startedAt > t.finishedAt + b);
223
+ return !(f(e.url) !== f(t.url) || e.startedAt < t.startedAt - x || t.finishedAt && e.startedAt > t.finishedAt + x);
248
224
  }
249
225
  handleBefore(e, t, n) {
250
226
  let r = this.extractVisit(t), i = this.visitFingerprint(r);
@@ -284,27 +260,27 @@ var y = 10, b = 2e3, x = class {
284
260
  return this.pendingPrefetch = null, this.createPrefetchRecord(n, t.event, e, t.timestamp);
285
261
  }
286
262
  let r = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
287
- return r && r.events.push(e), r;
263
+ return r && this.pushEvent(r, e), r;
288
264
  }
289
265
  handleFinish(e, t, n) {
290
266
  let r = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
291
267
  if (!r) return null;
292
- r.events.push(e), r.finishedAt = n, r.duration = n - r.startedAt;
268
+ this.pushEvent(r, e), r.finishedAt = n, r.duration = n - r.startedAt;
293
269
  let i = this.extractVisit(t);
294
- if (i && (r.completed = !!i.completed, r.cancelled = !!i.cancelled, r.interrupted = !!i.interrupted), r.network || this.drainPendingNetwork(r), r.type === "deferred" && (!r.page && this.lastPage && (r.page = this.lastPage, r.features = l(r, this.lastPage)), !r.previousPage && r.parentVisitId)) {
270
+ if (i && (r.completed = !!i.completed, r.cancelled = !!i.cancelled, r.interrupted = !!i.interrupted), r.network || this.drainPendingNetwork(r), r.type === "deferred" && (!r.page && this.lastPage && (r.page = this.lastPage, r.features = d(r, this.lastPage)), !r.previousPage && r.parentVisitId)) {
295
271
  let e = this.records.get(r.parentVisitId);
296
272
  e?.page && (r.previousPage = e.page);
297
273
  }
298
- return r.diagnostics = v(r), r;
274
+ return r.diagnostics = y(r), r;
299
275
  }
300
276
  handleCancel(e) {
301
277
  let t = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
302
- return t ? (t.events.push(e), t.cancelled = !0, t) : null;
278
+ return t ? (this.pushEvent(t, e), t.cancelled = !0, t) : null;
303
279
  }
304
280
  handleNavigate(e, t) {
305
281
  let n = t.page;
306
- n && (this.lastPage = n);
307
- let r = this.resolveByActiveId();
282
+ if (n && (this.lastPage = n), t.type === "history" && t.visitId === void 0) return null;
283
+ let r = this.resolveByActiveId(t);
308
284
  if (!r && n) {
309
285
  let t = this.nextVisitId++;
310
286
  r = {
@@ -325,32 +301,32 @@ var y = 10, b = 2e3, x = class {
325
301
  }, this.insertRecord(r), this.activeVisitId = t;
326
302
  for (let e of this.records.values()) e.type === "deferred" && e.parentVisitId === void 0 && (e.parentVisitId = t, e.previousPage = n);
327
303
  }
328
- return r ? (r.events.push(e), n && (r.page = n, r.features = l(r, n)), r.finishedAt || (r.finishedAt = e.timestamp, r.duration = e.timestamp - r.startedAt, r.completed = !0), r.diagnostics = v(r), r) : null;
304
+ return r ? (this.pushEvent(r, e), n && (r.page = n, r.features = d(r, n)), r.finishedAt || (r.finishedAt = e.timestamp, r.duration = e.timestamp - r.startedAt, r.completed = !0), r.diagnostics = y(r), r) : null;
329
305
  }
330
306
  handleBeforeUpdate(e, t) {
331
307
  let n = this.resolveByActiveId();
332
308
  if (!n) return null;
333
- n.events.push(e);
309
+ this.pushEvent(n, e);
334
310
  let r = t.page;
335
311
  if (r) {
336
312
  if (this.lastPage) for (let e of this.records.values()) e.type === "deferred" && !e.page && (e.previousPage = this.lastPage);
337
- this.lastPage = r, n.page || (n.page = r, n.features = l(n, r));
313
+ this.lastPage = r, n.page || (n.page = r, n.features = d(n, r));
338
314
  }
339
315
  return n;
340
316
  }
317
+ handleLocation(e, t) {
318
+ let n = this.resolveByActiveId();
319
+ return n ? (this.pushEvent(n, e), n.type = "redirect", n.status = 409, typeof t.url == "string" && (n.redirectUrl = t.url), n.diagnostics = y(n), n) : null;
320
+ }
341
321
  handleGenericEvent(e, t) {
342
- let n = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
322
+ let n = this.resolveByFingerprint(e) ?? this.resolveByActiveId(t);
343
323
  if (!n) return null;
344
- if (n.events.push(e), e.name === "inertia:error") n.error = t.errors;
324
+ if (this.pushEvent(n, e), e.name === "inertia:error") n.error = t.errors;
345
325
  else if (e.name === "inertia:httpException") {
346
326
  let e = t.response;
347
- if (e && (n.status = e.status, n.status === 409)) {
348
- n.type = "redirect";
349
- let t = e.headers;
350
- t && (n.redirectUrl = t["x-inertia-location"] ?? t["x-inertia-redirect"]);
351
- }
327
+ e && (n.status = e.status);
352
328
  } else e.name === "inertia:networkError" && (n.error = t.error);
353
- return n.diagnostics = v(n), n;
329
+ return n.diagnostics = y(n), n;
354
330
  }
355
331
  createPrefetchRecord(e, t, n, r) {
356
332
  let i = this.nextVisitId++, a = {
@@ -362,10 +338,7 @@ var y = 10, b = 2e3, x = class {
362
338
  except: e.except?.length ? e.except : void 0,
363
339
  startedAt: r,
364
340
  events: [t, n],
365
- features: [{
366
- type: "prefetch",
367
- label: "PREFETCH"
368
- }],
341
+ features: [{ type: "prefetch" }],
369
342
  diagnostics: [],
370
343
  cancelled: !1,
371
344
  interrupted: !1,
@@ -400,9 +373,20 @@ var y = 10, b = 2e3, x = class {
400
373
  }
401
374
  return this.records.get(r[0]) ?? null;
402
375
  }
403
- resolveByActiveId() {
376
+ resolveByActiveId(e) {
377
+ let t = e?.visitId;
378
+ if (typeof t == "string") {
379
+ let e = this.recordByInertiaVisitId.get(t);
380
+ if (e) return e;
381
+ }
404
382
  return this.activeVisitId === null ? null : this.records.get(this.activeVisitId) ?? null;
405
383
  }
384
+ pushEvent(e, t) {
385
+ if (e.events.push(t), e.events.length > S) {
386
+ let t = e.events.findIndex((e) => e.name === "inertia:progress");
387
+ t !== -1 && e.events.splice(t, 1);
388
+ }
389
+ }
406
390
  insertRecord(e) {
407
391
  this.records.set(e.visitId, e);
408
392
  let t = this.sortedRecords.length - 1;
@@ -435,7 +419,7 @@ var y = 10, b = 2e3, x = class {
435
419
  "interrupted",
436
420
  "prefetch"
437
421
  ]), n = {};
438
- for (let [r, i] of Object.entries(e)) t.has(r) || i !== !1 && i != null && (Array.isArray(i) && i.length === 0 || (typeof i != "object" || !i || Array.isArray(i) || Object.keys(i).length !== 0) && (n[r] = i));
422
+ for (let [r, i] of Object.entries(e)) t.has(r) || i !== !1 && i != null && (Array.isArray(i) && i.length === 0 || (typeof i != "object" || Array.isArray(i) || Object.keys(i).length !== 0) && (n[r] = i));
439
423
  return Object.keys(n).length > 0 ? n : void 0;
440
424
  }
441
425
  classifyVisitType(e) {
@@ -454,8 +438,8 @@ var y = 10, b = 2e3, x = class {
454
438
  findNestingParentVisitId(e) {
455
439
  return this.sortedRecords.findLast((t) => (e === void 0 || t.url === e) && t.type !== "deferred" && t.type !== "prefetch")?.visitId;
456
440
  }
457
- }, S = t("inertia-devtools-session");
458
- function C(e) {
441
+ }, w = t("inertia-devtools-session");
442
+ function T(e) {
459
443
  return {
460
444
  visitId: e.visitId,
461
445
  type: e.type,
@@ -464,21 +448,20 @@ function C(e) {
464
448
  status: e.status
465
449
  };
466
450
  }
467
- function w(e) {
468
- S.save({
451
+ function E(e) {
452
+ w.save({
469
453
  savedAt: Date.now(),
470
- requests: e.map(C)
454
+ requests: e.map(T)
471
455
  });
472
456
  }
473
- function T() {
474
- return S.load();
457
+ function te() {
458
+ return w.load();
475
459
  }
476
- function E() {
477
- S.clear();
460
+ function ne() {
461
+ w.clear();
478
462
  }
479
- //#endregion
480
- //#region src/inertia/core/store.ts
481
- var D = class {
463
+ // src/inertia/core/store.ts
464
+ var D = { redactKey: n }, O = class {
482
465
  correlator;
483
466
  subscribers = /* @__PURE__ */ new Set();
484
467
  nextEventId = 1;
@@ -487,7 +470,7 @@ var D = class {
487
470
  previousSession = null;
488
471
  saveTimer;
489
472
  constructor() {
490
- this.correlator = new x(), this.previousSession = T();
473
+ this.correlator = new C(), this.previousSession = te();
491
474
  }
492
475
  get requests() {
493
476
  return this.correlator.getRequests().slice();
@@ -521,25 +504,31 @@ var D = class {
521
504
  }
522
505
  captureEvent(e, t) {
523
506
  if (this._paused || !(t instanceof CustomEvent)) return;
524
- let n = a(t.detail), r = {
507
+ let n = a(t.detail, D), r = t.detail?.errors;
508
+ e === "inertia:error" && r !== void 0 && (n.errors = i(r));
509
+ let o = {
525
510
  id: this.nextEventId++,
526
511
  name: e,
527
512
  timestamp: performance.now(),
528
513
  detail: n
529
514
  };
530
- this.correlator.processEvent(r), this.notify();
515
+ this.correlator.processEvent(o), this.notify();
531
516
  }
532
517
  captureNetworkTiming(e) {
533
518
  this._paused || (this.correlator.linkNetworkTiming(e), this.notify());
534
519
  }
535
- captureInterceptedRequest(e, t) {
536
- this._paused || (this.correlator.attachRequestHeaders(e, t), this.notify());
520
+ captureInterceptedRequest(t, n) {
521
+ this._paused || (this.correlator.attachRequestHeaders(t, e(n)), this.notify());
537
522
  }
538
- captureInterceptedResponse(e, t) {
539
- this._paused || (this.correlator.attachResponseData(e, t), this.notify());
523
+ captureInterceptedResponse(t, n) {
524
+ this._paused || (this.correlator.attachResponseData(t, {
525
+ status: n.status,
526
+ headers: e(n.headers),
527
+ props: n.props ? i(n.props, D) : void 0
528
+ }), this.notify());
540
529
  }
541
530
  captureClientVisit(e, t, n) {
542
- this._paused || (this.correlator.processClientVisit(e, t, n), this.notify());
531
+ this._paused || (this.correlator.processClientVisit(e, i(t, D), n), this.notify());
543
532
  }
544
533
  subscribe(e) {
545
534
  return this.subscribers.add(e), () => {
@@ -550,7 +539,7 @@ var D = class {
550
539
  this._paused = e, this.notify();
551
540
  }
552
541
  clear() {
553
- this.correlator.clear(), this.nextEventId = 1, E(), this.previousSession = null, this.notify();
542
+ this.correlator.clear(), this.nextEventId = 1, ne(), this.previousSession = null, this.notify();
554
543
  }
555
544
  notify() {
556
545
  this.tick++;
@@ -560,9 +549,9 @@ var D = class {
560
549
  } catch (e) {
561
550
  console.warn("[storefront-devtools] Subscriber error:", e);
562
551
  }
563
- clearTimeout(this.saveTimer), this.saveTimer = setTimeout(() => w(this.requests), 1e3);
552
+ clearTimeout(this.saveTimer), this.saveTimer = setTimeout(() => E(this.requests), 1e3);
564
553
  }
565
- }, O = [
554
+ }, k = [
566
555
  "inertia:before",
567
556
  "inertia:start",
568
557
  "inertia:progress",
@@ -575,14 +564,14 @@ var D = class {
575
564
  "inertia:beforeUpdate",
576
565
  "inertia:navigate",
577
566
  "inertia:flash",
567
+ "inertia:location",
578
568
  "inertia:prefetching",
579
569
  "inertia:prefetched"
580
570
  ];
581
- //#endregion
582
- //#region src/inertia/core/capture.ts
583
- function k(e) {
571
+ // src/inertia/core/capture.ts
572
+ function A(e) {
584
573
  let t = [];
585
- for (let n of O) {
574
+ for (let n of k) {
586
575
  let r = (t) => {
587
576
  try {
588
577
  e.captureEvent(n, t);
@@ -596,15 +585,14 @@ function k(e) {
596
585
  t.forEach((e) => e());
597
586
  };
598
587
  }
599
- //#endregion
600
- //#region src/inertia/core/diff.ts
601
- function A(e) {
588
+ // src/inertia/core/diff.ts
589
+ function j(e) {
602
590
  return typeof e == "object" && !!e && !Array.isArray(e);
603
591
  }
604
- function j(e, t) {
605
- return M(e, t, /* @__PURE__ */ new WeakSet());
592
+ function M(e, t) {
593
+ return N(e, t, /* @__PURE__ */ new WeakSet());
606
594
  }
607
- function M(e, t, n) {
595
+ function N(e, t, n) {
608
596
  if (e === t) return !0;
609
597
  if (e === null || t === null || typeof e != typeof t) return !1;
610
598
  if (typeof e == "object") {
@@ -612,19 +600,18 @@ function M(e, t, n) {
612
600
  n.add(e), n.add(t);
613
601
  }
614
602
  try {
615
- if (Array.isArray(e) && Array.isArray(t)) return e.length === t.length && e.every((e, r) => M(e, t[r], n));
616
- if (A(e) && A(t)) {
603
+ if (Array.isArray(e) && Array.isArray(t)) return e.length === t.length && e.every((e, r) => N(e, t[r], n));
604
+ if (j(e) && j(t)) {
617
605
  let r = Object.keys(e), i = Object.keys(t);
618
- return r.length === i.length && r.every((r) => M(e[r], t[r], n));
606
+ return r.length === i.length && r.every((r) => N(e[r], t[r], n));
619
607
  }
620
608
  return !1;
621
609
  } finally {
622
610
  typeof e == "object" && (n.delete(e), n.delete(t));
623
611
  }
624
612
  }
625
- //#endregion
626
- //#region src/inertia/core/history-capture.ts
627
- function N(e) {
613
+ // src/inertia/core/history-capture.ts
614
+ function P(e) {
628
615
  if (typeof e != "object" || !e) return null;
629
616
  let t = e;
630
617
  if (!("page" in t)) return null;
@@ -633,63 +620,61 @@ function N(e) {
633
620
  let n = t.page;
634
621
  return typeof n.component != "string" || typeof n.props != "object" ? null : t.page;
635
622
  }
636
- function P(e, t) {
637
- return e.url !== t.url || e.component !== t.component || !j(e.props, t.props) || !j(e.flash, t.flash);
623
+ function F(e, t) {
624
+ return e.url !== t.url || e.component !== t.component || !M(e.props, t.props) || !M(e.flash, t.flash);
625
+ }
626
+ function I(e) {
627
+ let t = e.detail?.visit;
628
+ return t?.prefetch || typeof t?.id != "string" ? void 0 : t.id;
638
629
  }
639
- function F(e) {
630
+ function L(e) {
640
631
  if (typeof window > "u") return () => {};
641
- let t = history.pushState.bind(history), n = history.replaceState.bind(history), r = 0, i = (e) => {
642
- e.detail?.visit?.prefetch || r++;
643
- }, a = (e) => {
644
- let t = e.detail?.visit;
645
- t && (t.cancelled || t.interrupted) && r > 0 && r--;
632
+ let t = history.pushState.bind(history), r = history.replaceState.bind(history), a = /* @__PURE__ */ new Set(), o = (e) => {
633
+ let t = I(e);
634
+ t !== void 0 && (a.add(t), queueMicrotask(() => {
635
+ e.defaultPrevented && a.delete(t);
636
+ }));
637
+ }, s = (e) => {
638
+ let t = I(e);
639
+ t !== void 0 && a.delete(t);
646
640
  };
647
- document.addEventListener("inertia:before", i), document.addEventListener("inertia:finish", a);
648
- function o(t, n, r) {
641
+ document.addEventListener("inertia:before", o), document.addEventListener("inertia:finish", s);
642
+ function c(t, n, r) {
649
643
  try {
650
644
  e.captureClientVisit(t === "pushState" ? "push" : "replace", n, r);
651
645
  } catch (e) {
652
646
  console.error("[storefront-devtools] Error in history capture", e);
653
647
  }
654
648
  }
655
- function s(t, n) {
649
+ function l(t, n) {
650
+ let r = a.size > 0;
656
651
  setTimeout(() => {
657
- let r = e.currentPage;
658
- r && P(n, r) && o(t, r, n);
652
+ let i = e.currentPage;
653
+ i && F(n, i) && (r || c(t, i, n));
659
654
  }, 0);
660
655
  }
661
- function c(t, n) {
662
- let i = N(n);
663
- if (!i) return;
664
- let a = e.currentPage;
665
- if (a) {
666
- if (i === "encrypted") {
667
- if (r > 0) {
668
- r--;
669
- return;
670
- }
671
- s(t, a);
672
- } else {
673
- if (r > 0) {
674
- r--;
675
- return;
676
- }
677
- if (!P(a, i)) return;
678
- o(t, i, a);
679
- }
656
+ function u(t, r) {
657
+ let o = P(r);
658
+ if (!o) return;
659
+ let s = e.currentPage;
660
+ if (!s) return;
661
+ if (o === "encrypted") {
662
+ l(t, s);
663
+ return;
680
664
  }
665
+ let u = i(o, { redactKey: n });
666
+ F(s, u) && (a.size > 0 || c(t, u, s));
681
667
  }
682
668
  return history.pushState = function(e, n, r) {
683
- t(e, n, r), c("pushState", e);
684
- }, history.replaceState = function(e, t, r) {
685
- n(e, t, r), c("replaceState", e);
669
+ t(e, n, r), u("pushState", e);
670
+ }, history.replaceState = function(e, t, n) {
671
+ r(e, t, n), u("replaceState", e);
686
672
  }, () => {
687
- history.pushState = t, history.replaceState = n, document.removeEventListener("inertia:before", i), document.removeEventListener("inertia:finish", a);
673
+ history.pushState = t, history.replaceState = r, document.removeEventListener("inertia:before", o), document.removeEventListener("inertia:finish", s);
688
674
  };
689
675
  }
690
- //#endregion
691
- //#region src/inertia/core/network.ts
692
- function I(e, t) {
676
+ // src/inertia/core/network.ts
677
+ function R(e, t) {
693
678
  if (typeof PerformanceObserver > "u") return () => {};
694
679
  let n = new PerformanceObserver((n) => {
695
680
  for (let r of n.getEntries()) {
@@ -712,15 +697,14 @@ function I(e, t) {
712
697
  buffered: !1
713
698
  }), () => n.disconnect();
714
699
  }
715
- //#endregion
716
- //#region src/inertia/core/interceptors.ts
717
- function L(e) {
700
+ // src/inertia/core/interceptors.ts
701
+ function z(e) {
718
702
  if (!e) return {};
719
703
  let t = {};
720
704
  for (let [n, r] of Object.entries(e)) t[n.toLowerCase()] = String(r);
721
705
  return t;
722
706
  }
723
- function R(e) {
707
+ function B(e) {
724
708
  let t = typeof e == "string" ? (() => {
725
709
  try {
726
710
  return JSON.parse(e);
@@ -730,63 +714,75 @@ function R(e) {
730
714
  })() : e;
731
715
  if (typeof t == "object" && t && "props" in t && typeof t.props == "object" && t.props !== null) return t.props;
732
716
  }
733
- var z = 100, B = 1e4;
734
- function V(t, r) {
735
- let a = t.onVisitRequest((t, n) => {
717
+ var V = 100, H = 1e4;
718
+ function U(e, t) {
719
+ let n = e.onVisitRequest((e, n) => {
736
720
  try {
737
- let i = L(n.headers);
738
- r.captureInterceptedRequest(t.id, e(i));
721
+ let r = z(n.headers);
722
+ t.captureInterceptedRequest(e.id, r);
739
723
  } catch (e) {
740
724
  console.error("[storefront-devtools] Error capturing intercepted request", e);
741
725
  }
742
726
  return n;
743
- }), o = t.onVisitResponse((t, a) => {
727
+ }), r = e.onVisitResponse((e, n) => {
744
728
  try {
745
- let o = L(a.headers), s = R(a.data);
746
- r.captureInterceptedResponse(t.id, {
747
- headers: e(o),
748
- props: s ? i(s, { redactKey: n }) : void 0
729
+ let r = z(n.headers);
730
+ t.captureInterceptedResponse(e.id, {
731
+ status: n.status,
732
+ headers: r,
733
+ props: B(n.data)
749
734
  });
750
735
  } catch (e) {
751
736
  console.error("[storefront-devtools] Error capturing intercepted response", e);
752
737
  }
753
- return a;
738
+ return n;
754
739
  });
755
740
  return () => {
756
- a(), o();
741
+ n(), r();
757
742
  };
758
743
  }
759
- function H(e) {
744
+ function W(e) {
760
745
  if (typeof window > "u") return () => {};
761
- if (window.__inertia_interceptors__) return V(window.__inertia_interceptors__, e);
746
+ if (window.__inertia_interceptors__) return U(window.__inertia_interceptors__, e);
762
747
  let t, n = Date.now(), r = setInterval(() => {
763
- window.__inertia_interceptors__ ? (clearInterval(r), t = V(window.__inertia_interceptors__, e)) : Date.now() - n > B && clearInterval(r);
764
- }, z);
748
+ window.__inertia_interceptors__ ? (clearInterval(r), t = U(window.__inertia_interceptors__, e)) : Date.now() - n > H && clearInterval(r);
749
+ }, V);
765
750
  return () => {
766
751
  clearInterval(r), t?.();
767
752
  };
768
753
  }
769
- //#endregion
770
- //#region src/inertia/channel.ts
771
- var U = "storefront-devtools:inertia", W = "storefront-devtools:storefront";
772
- //#endregion
773
- //#region src/inertia/client/publish.ts
774
- function G(e) {
775
- let { requests: t, currentPage: n, evictedCount: r, paused: i } = e.getState();
754
+ // src/inertia/channel.ts
755
+ var G = "storefront-devtools:inertia", K = "storefront-devtools:storefront";
756
+ // src/inertia/client/publish.ts
757
+ function q(e) {
776
758
  return {
777
- requests: t,
778
- currentPage: n,
779
- evictedCount: r,
780
- paused: i,
759
+ visitId: e.visitId,
760
+ parentVisitId: e.parentVisitId,
761
+ type: e.type,
762
+ method: e.method,
763
+ url: e.url,
764
+ finishedAt: e.finishedAt,
765
+ duration: e.duration,
766
+ status: e.status,
767
+ diagnosticCount: e.diagnostics.length
768
+ };
769
+ }
770
+ function J(e) {
771
+ let { requests: t, evictedCount: n, paused: r } = e.getState();
772
+ return {
773
+ requests: t.map(q),
774
+ evictedCount: n,
775
+ paused: r,
781
776
  previousSession: e.previousSessionRequests
782
777
  };
783
778
  }
784
- function K(e, t = {}) {
779
+ function Y(e, t = {}) {
785
780
  let n = r({
786
781
  ...t,
787
- name: U,
782
+ name: G,
788
783
  functions: {
789
- getState: { handler: () => G(e) },
784
+ getState: { handler: () => J(e) },
785
+ getRequest: { handler: (t) => e.getRequest(t) ?? null },
790
786
  clear: {
791
787
  type: "action",
792
788
  handler: () => e.clear()
@@ -799,29 +795,65 @@ function K(e, t = {}) {
799
795
  events: {}
800
796
  }), i = () => ({ currentPage: e.currentPage }), a = r({
801
797
  ...t,
802
- name: W,
798
+ name: K,
803
799
  functions: { getState: { handler: i } },
804
800
  events: {}
805
801
  });
806
802
  n.events.on("panel:connected", () => {
807
- n.emit("state", G(e));
803
+ n.emit("state", J(e));
808
804
  }), a.events.on("panel:connected", () => {
809
805
  a.emit("state", i());
810
806
  });
811
807
  let s = e.currentPage;
812
808
  return e.subscribe(o(() => {
813
- n.emit("state", G(e)), e.currentPage !== s && (s = e.currentPage, a.emit("state", i()));
809
+ n.panels.length > 0 && n.emit("state", J(e)), e.currentPage !== s && (s = e.currentPage, a.emit("state", i()));
814
810
  }, 16)), {
815
811
  inertia: n,
816
812
  storefront: a
817
813
  };
818
814
  }
819
- //#endregion
820
- //#region src/inertia/client/index.ts
821
- var q = Symbol.for("@scayle/storefront-devtools/inertia"), J = globalThis;
822
- if (typeof window < "u" && typeof document < "u" && !J[q]) {
823
- J[q] = !0;
824
- let e = new D();
825
- k(e), F(e), I((t) => e.isInertiaRequestUrl(t), (t) => e.captureNetworkTiming(t)), H(e), K(e);
815
+ // src/inertia/client/messages.ts
816
+ var X = "__DEVFRAME_HUB_CLIENT_CONTEXT__", Z = `${s}:${c}`;
817
+ function re() {
818
+ let e = globalThis[X];
819
+ if (!e?.rpc.isTrusted) return;
820
+ let t = e.docks.entries.some((e) => e.id === Z);
821
+ return {
822
+ rpc: e.rpc,
823
+ inertiaDockId: t ? Z : s
824
+ };
825
+ }
826
+ function ie(e, t, n) {
827
+ let r = new URL(e.url, "http://localhost").pathname, i = t.docsUrl ? `\n${t.docsUrl}` : "";
828
+ return {
829
+ message: "Inertia.js",
830
+ description: `${t.message}\n${e.method} ${r}\nRule: ${t.id}${i}`,
831
+ level: t.severity === "error" ? "error" : "warn",
832
+ category: "inertia",
833
+ labels: [t.id],
834
+ notify: !0,
835
+ actions: [{
836
+ id: "open-inertia",
837
+ label: "Open Inertia Panel",
838
+ kind: "activate",
839
+ activate: { dockId: n }
840
+ }]
841
+ };
842
+ }
843
+ function ae(e) {
844
+ let t = /* @__PURE__ */ new Set();
845
+ return e.subscribe(o(() => {
846
+ let n = re();
847
+ if (n) for (let r of e.getState().requests) for (let e of r.diagnostics) {
848
+ let i = `${r.startedAt}:${r.visitId}:${e.id}`;
849
+ e.severity === "info" || t.has(i) || (t.add(i), n.rpc.call("hub:messages:add", ie(r, e, n.inertiaDockId)).catch(() => {}));
850
+ }
851
+ }, 16));
852
+ }
853
+ // src/inertia/client/index.ts
854
+ var Q = Symbol.for("@scayle/storefront-devtools/inertia"), $ = globalThis;
855
+ if (typeof window < "u" && typeof document < "u" && !$[Q]) {
856
+ $[Q] = !0;
857
+ let e = new O();
858
+ A(e), L(e), R((t) => e.isInertiaRequestUrl(t), (t) => e.captureNetworkTiming(t)), W(e), Y(e), ae(e);
826
859
  }
827
- //#endregion