@scayle/storefront-devtools 0.2.0-alpha.1

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 (131) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +222 -0
  3. package/dist/_chunks/clipboard-DrVHc2QA.mjs +61 -0
  4. package/dist/_chunks/diff-DzJ5arJj.mjs +169 -0
  5. package/dist/_chunks/panel-uV5ITqhY.mjs +51 -0
  6. package/dist/_chunks/redact-DmIF-iyk.mjs +96 -0
  7. package/dist/_chunks/useStore-Db8RZW8T.mjs +10 -0
  8. package/dist/group.d.ts +42 -0
  9. package/dist/group.d.ts.map +1 -0
  10. package/dist/index.d.ts +23 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.mjs +178 -0
  13. package/dist/inertia/client/index.d.mts +13 -0
  14. package/dist/inertia/client/index.d.ts +7 -0
  15. package/dist/inertia/client/index.d.ts.map +1 -0
  16. package/dist/inertia/client/index.mjs +694 -0
  17. package/dist/inertia/core/capture.d.ts +15 -0
  18. package/dist/inertia/core/capture.d.ts.map +1 -0
  19. package/dist/inertia/core/correlator.d.ts +91 -0
  20. package/dist/inertia/core/correlator.d.ts.map +1 -0
  21. package/dist/inertia/core/diagnostics.d.ts +10 -0
  22. package/dist/inertia/core/diagnostics.d.ts.map +1 -0
  23. package/dist/inertia/core/diff.d.ts +33 -0
  24. package/dist/inertia/core/diff.d.ts.map +1 -0
  25. package/dist/inertia/core/events-tab.d.ts +20 -0
  26. package/dist/inertia/core/events-tab.d.ts.map +1 -0
  27. package/dist/inertia/core/feature-info.d.ts +14 -0
  28. package/dist/inertia/core/feature-info.d.ts.map +1 -0
  29. package/dist/inertia/core/features.d.ts +27 -0
  30. package/dist/inertia/core/features.d.ts.map +1 -0
  31. package/dist/inertia/core/history-capture.d.ts +15 -0
  32. package/dist/inertia/core/history-capture.d.ts.map +1 -0
  33. package/dist/inertia/core/interceptors.d.ts +69 -0
  34. package/dist/inertia/core/interceptors.d.ts.map +1 -0
  35. package/dist/inertia/core/markdown.d.ts +10 -0
  36. package/dist/inertia/core/markdown.d.ts.map +1 -0
  37. package/dist/inertia/core/network.d.ts +34 -0
  38. package/dist/inertia/core/network.d.ts.map +1 -0
  39. package/dist/inertia/core/protocol.d.ts +38 -0
  40. package/dist/inertia/core/protocol.d.ts.map +1 -0
  41. package/dist/inertia/core/request-tree.d.ts +18 -0
  42. package/dist/inertia/core/request-tree.d.ts.map +1 -0
  43. package/dist/inertia/core/response.d.ts +39 -0
  44. package/dist/inertia/core/response.d.ts.map +1 -0
  45. package/dist/inertia/core/session.d.ts +18 -0
  46. package/dist/inertia/core/session.d.ts.map +1 -0
  47. package/dist/inertia/core/store.d.ts +40 -0
  48. package/dist/inertia/core/store.d.ts.map +1 -0
  49. package/dist/inertia/core/types.d.ts +112 -0
  50. package/dist/inertia/core/types.d.ts.map +1 -0
  51. package/dist/inertia/core/url.d.ts +11 -0
  52. package/dist/inertia/core/url.d.ts.map +1 -0
  53. package/dist/inertia/plugin.d.ts +11 -0
  54. package/dist/inertia/plugin.d.ts.map +1 -0
  55. package/dist/inertia/renderer/index.d.mts +16 -0
  56. package/dist/inertia/renderer/index.mjs +771 -0
  57. package/dist/inject.d.ts +12 -0
  58. package/dist/inject.d.ts.map +1 -0
  59. package/dist/orpc/client/index.d.mts +13 -0
  60. package/dist/orpc/client/index.d.ts +7 -0
  61. package/dist/orpc/client/index.d.ts.map +1 -0
  62. package/dist/orpc/client/index.mjs +502 -0
  63. package/dist/orpc/core/capture.d.ts +32 -0
  64. package/dist/orpc/core/capture.d.ts.map +1 -0
  65. package/dist/orpc/core/classify.d.ts +14 -0
  66. package/dist/orpc/core/classify.d.ts.map +1 -0
  67. package/dist/orpc/core/curl.d.ts +11 -0
  68. package/dist/orpc/core/curl.d.ts.map +1 -0
  69. package/dist/orpc/core/markdown.d.ts +12 -0
  70. package/dist/orpc/core/markdown.d.ts.map +1 -0
  71. package/dist/orpc/core/orpc-error.d.ts +18 -0
  72. package/dist/orpc/core/orpc-error.d.ts.map +1 -0
  73. package/dist/orpc/core/serialize.d.ts +12 -0
  74. package/dist/orpc/core/serialize.d.ts.map +1 -0
  75. package/dist/orpc/core/session.d.ts +15 -0
  76. package/dist/orpc/core/session.d.ts.map +1 -0
  77. package/dist/orpc/core/store.d.ts +50 -0
  78. package/dist/orpc/core/store.d.ts.map +1 -0
  79. package/dist/orpc/core/types.d.ts +67 -0
  80. package/dist/orpc/core/types.d.ts.map +1 -0
  81. package/dist/orpc/core/url.d.ts +12 -0
  82. package/dist/orpc/core/url.d.ts.map +1 -0
  83. package/dist/orpc/plugin.d.ts +10 -0
  84. package/dist/orpc/plugin.d.ts.map +1 -0
  85. package/dist/orpc/renderer/index.d.mts +16 -0
  86. package/dist/orpc/renderer/index.mjs +457 -0
  87. package/dist/resource-center/client/index.mjs +21 -0
  88. package/dist/resource-center/client.d.ts +3 -0
  89. package/dist/resource-center/client.d.ts.map +1 -0
  90. package/dist/resource-center/plugin.d.ts +12 -0
  91. package/dist/resource-center/plugin.d.ts.map +1 -0
  92. package/dist/shared/clipboard.d.ts +9 -0
  93. package/dist/shared/clipboard.d.ts.map +1 -0
  94. package/dist/shared/redact.d.ts +27 -0
  95. package/dist/shared/redact.d.ts.map +1 -0
  96. package/dist/shared/safe-clone.d.ts +46 -0
  97. package/dist/shared/safe-clone.d.ts.map +1 -0
  98. package/dist/shared/session-storage.d.ts +18 -0
  99. package/dist/shared/session-storage.d.ts.map +1 -0
  100. package/dist/shared/use-window-store.d.ts +18 -0
  101. package/dist/shared/use-window-store.d.ts.map +1 -0
  102. package/dist/storefront/plugin.d.ts +9 -0
  103. package/dist/storefront/plugin.d.ts.map +1 -0
  104. package/dist/storefront/renderer/index.d.mts +16 -0
  105. package/dist/storefront/renderer/index.mjs +124 -0
  106. package/dist/vue-devtools/client/index.mjs +4912 -0
  107. package/dist/vue-devtools/client.d.ts +2 -0
  108. package/dist/vue-devtools/client.d.ts.map +1 -0
  109. package/dist/vue-devtools/plugin.d.ts +14 -0
  110. package/dist/vue-devtools/plugin.d.ts.map +1 -0
  111. package/dist/vue-devtools/ui/assets/css-8QJvnqUH.js +1 -0
  112. package/dist/vue-devtools/ui/assets/css-CaJ9TzKE.js +1 -0
  113. package/dist/vue-devtools/ui/assets/diff-woXpYk--.js +1 -0
  114. package/dist/vue-devtools/ui/assets/html-BHDw6EPc.js +1 -0
  115. package/dist/vue-devtools/ui/assets/html-GueGcY0x.js +1 -0
  116. package/dist/vue-devtools/ui/assets/index-Dby9TIQH.js +156 -0
  117. package/dist/vue-devtools/ui/assets/index-sSkqWPzY.css +1 -0
  118. package/dist/vue-devtools/ui/assets/javascript-BzbQS41l.js +1 -0
  119. package/dist/vue-devtools/ui/assets/javascript-Yelw-5ZN.js +1 -0
  120. package/dist/vue-devtools/ui/assets/json-B88Oqtu5.js +1 -0
  121. package/dist/vue-devtools/ui/assets/json-CaljABEy.js +1 -0
  122. package/dist/vue-devtools/ui/assets/shellscript-CLZ0U2zV.js +1 -0
  123. package/dist/vue-devtools/ui/assets/typescript-Utq2Cl8c.js +1 -0
  124. package/dist/vue-devtools/ui/assets/typescript-j_1H8WHN.js +1 -0
  125. package/dist/vue-devtools/ui/assets/vitesse-dark-BZCL-v6S.js +1 -0
  126. package/dist/vue-devtools/ui/assets/vitesse-light-VbXTXTou.js +1 -0
  127. package/dist/vue-devtools/ui/assets/vue-B1Tf5CHw.js +1 -0
  128. package/dist/vue-devtools/ui/assets/vue-html-CGMs_6qn.js +1 -0
  129. package/dist/vue-devtools/ui/assets/yaml-rwi0_p6S.js +1 -0
  130. package/dist/vue-devtools/ui/index.html +13 -0
  131. package/package.json +101 -0
@@ -0,0 +1,694 @@
1
+ import { i as e, r as t, t as n } from "../../_chunks/diff-DzJ5arJj.mjs";
2
+ import { a as r, i, n as a, o, r as s } from "../../_chunks/redact-DmIF-iyk.mjs";
3
+ //#region src/inertia/core/url.ts
4
+ function c(e) {
5
+ try {
6
+ let t = new URL(e, "http://localhost");
7
+ return t.pathname + t.search;
8
+ } catch {
9
+ return e;
10
+ }
11
+ }
12
+ //#endregion
13
+ //#region src/inertia/core/diagnostics.ts
14
+ function l(e) {
15
+ return e.type === "redirect" && e.status === 409 ? {
16
+ id: "version-mismatch",
17
+ severity: "warning",
18
+ message: "Asset version mismatch, full page reload",
19
+ docsUrl: "https://inertiajs.com/the-protocol#asset-versioning"
20
+ } : null;
21
+ }
22
+ function u(e) {
23
+ return e.interrupted ? {
24
+ id: "visit-interrupted",
25
+ severity: "info",
26
+ message: "Interrupted by a newer visit"
27
+ } : e.cancelled ? {
28
+ id: "visit-cancelled",
29
+ severity: "info",
30
+ message: "Visit was cancelled"
31
+ } : null;
32
+ }
33
+ function d(e) {
34
+ if (e.only?.length && e.page?.props) {
35
+ let t = Object.keys(e.page.props), n = e.only.filter((e) => !t.includes(e));
36
+ if (n.length) return {
37
+ id: "partial-prop-missing",
38
+ severity: "warning",
39
+ message: `Partial reload: '${n.join("', '")}' requested but missing from response`,
40
+ docsUrl: "https://inertiajs.com/partial-reloads"
41
+ };
42
+ }
43
+ return null;
44
+ }
45
+ function f(e) {
46
+ return e.only && e.only.length > 0 && !e.only.includes("errors") && (e.status === 422 || e.events.some((e) => e.name === "inertia:error")) ? {
47
+ id: "errors-filtered",
48
+ severity: "warning",
49
+ message: "Validation errors may be filtered: 'only' option doesn't include 'errors'",
50
+ docsUrl: "https://inertiajs.com/partial-reloads"
51
+ } : null;
52
+ }
53
+ function p(e) {
54
+ return e.type === "deferred" && e.error ? {
55
+ id: "deferred-failed",
56
+ severity: "error",
57
+ message: "Deferred props failed to load",
58
+ docsUrl: "https://inertiajs.com/deferred-props"
59
+ } : null;
60
+ }
61
+ function m(e) {
62
+ if (e.type === "client" && e.method === "REPLACE") return {
63
+ id: "history-replace",
64
+ severity: "info",
65
+ message: "History replaced (same URL)",
66
+ docsUrl: "https://inertiajs.com/manual-visits#browser-history"
67
+ };
68
+ if (e.visitOptions?.replace === !0) {
69
+ let t = e.previousPage?.url;
70
+ return t && c(t) === c(e.url) ? {
71
+ id: "history-replace-same-url",
72
+ severity: "info",
73
+ message: "History replaced (same URL)",
74
+ docsUrl: "https://inertiajs.com/manual-visits#browser-history"
75
+ } : {
76
+ id: "history-replace",
77
+ severity: "info",
78
+ message: "History replace mode",
79
+ docsUrl: "https://inertiajs.com/manual-visits#browser-history"
80
+ };
81
+ }
82
+ return null;
83
+ }
84
+ var h = [
85
+ l,
86
+ u,
87
+ d,
88
+ f,
89
+ p,
90
+ m
91
+ ];
92
+ function g(e) {
93
+ let t = [];
94
+ for (let n of h) {
95
+ let r = n(e);
96
+ r && t.push(r);
97
+ }
98
+ return t;
99
+ }
100
+ //#endregion
101
+ //#region src/inertia/core/correlator.ts
102
+ var _ = 10, v = 2e3, y = class {
103
+ nextVisitId = 1;
104
+ records = /* @__PURE__ */ new Map();
105
+ sortedRecords = [];
106
+ maxRecords;
107
+ fingerprintMap = /* @__PURE__ */ new Map();
108
+ recordByInertiaVisitId = /* @__PURE__ */ new Map();
109
+ pendingPrefetch = null;
110
+ activeVisitId = null;
111
+ lastPage = null;
112
+ pendingNetwork = [];
113
+ _evictedCount = 0;
114
+ constructor(e = 200) {
115
+ this.maxRecords = e;
116
+ }
117
+ processEvent(e) {
118
+ let { name: t, detail: n, timestamp: r } = e;
119
+ switch (t) {
120
+ case "inertia:before": return this.handleBefore(e, n, r);
121
+ case "inertia:start": return this.handleStart(e, n);
122
+ case "inertia:finish": return this.handleFinish(e, n, r);
123
+ case "inertia:cancel": return this.handleCancel(e);
124
+ case "inertia:navigate": return this.handleNavigate(e, n);
125
+ case "inertia:beforeUpdate": return this.handleBeforeUpdate(e, n);
126
+ default: return this.handleGenericEvent(e, n);
127
+ }
128
+ }
129
+ getRequests() {
130
+ return this.sortedRecords;
131
+ }
132
+ getRequest(e) {
133
+ return this.records.get(e);
134
+ }
135
+ getCurrentPage() {
136
+ return this.lastPage;
137
+ }
138
+ get evictedCount() {
139
+ return this._evictedCount;
140
+ }
141
+ hasRequestWithUrl(e) {
142
+ let t = c(e);
143
+ return this.sortedRecords.some((e) => c(e.url) === t);
144
+ }
145
+ processClientVisit(t, n, r) {
146
+ let i = this.nextVisitId++, a = performance.now(), o = {
147
+ visitId: i,
148
+ type: "client",
149
+ method: t === "push" ? "PUSH" : "REPLACE",
150
+ url: n.url ?? "/",
151
+ startedAt: a,
152
+ finishedAt: a,
153
+ duration: 0,
154
+ events: [],
155
+ features: e(n),
156
+ diagnostics: [],
157
+ cancelled: !1,
158
+ interrupted: !1,
159
+ completed: !0,
160
+ page: n,
161
+ previousPage: r
162
+ };
163
+ return this.insertRecord(o), this.lastPage = n, this.activeVisitId = i, o;
164
+ }
165
+ clear() {
166
+ this.records.clear(), this.sortedRecords = [], this.fingerprintMap.clear(), this.recordByInertiaVisitId.clear(), this.pendingPrefetch = null, this.pendingNetwork = [], this._evictedCount = 0, this.activeVisitId = null, this.nextVisitId = 1;
167
+ }
168
+ linkNetworkTiming(e) {
169
+ let t = this.findNetworkMatch(e);
170
+ return t ? (t.network = e, t) : (this.pendingNetwork.push(e), this.pendingNetwork.length > _ && this.pendingNetwork.shift(), null);
171
+ }
172
+ attachRequestHeaders(e, t) {
173
+ let n = this.recordByInertiaVisitId.get(e);
174
+ return n ? (n.headers = t, n) : null;
175
+ }
176
+ attachResponseData(e, t) {
177
+ let n = this.recordByInertiaVisitId.get(e);
178
+ return n ? (n.responseHeaders = t.headers, n.responseProps = t.props, n) : null;
179
+ }
180
+ drainPendingNetwork(e) {
181
+ let t = this.pendingNetwork.findLastIndex((t) => this.networkMatchesVisit(t, e));
182
+ t !== -1 && (e.network = this.pendingNetwork[t], this.pendingNetwork.splice(t, 1));
183
+ }
184
+ findNetworkMatch(e) {
185
+ return this.sortedRecords.findLast((t) => !t.network && this.networkMatchesVisit(e, t)) ?? null;
186
+ }
187
+ networkMatchesVisit(e, t) {
188
+ return !(c(e.url) !== c(t.url) || e.startedAt < t.startedAt - v || t.finishedAt && e.startedAt > t.finishedAt + v);
189
+ }
190
+ handleBefore(e, t, n) {
191
+ let r = this.extractVisit(t), i = this.visitFingerprint(r);
192
+ if (r && r.prefetch) return this.pendingPrefetch = {
193
+ event: e,
194
+ timestamp: n,
195
+ url: this.extractUrl(r),
196
+ fingerprint: i
197
+ }, null;
198
+ let a = this.nextVisitId++, o = (r?.method ?? "GET").toUpperCase(), s = this.extractUrl(r), c = r != null && this.isDeferredReload(r), l = c ? "deferred" : this.classifyVisitType(r), u;
199
+ c ? u = this.findNestingParentVisitId(s) : l === "partial" && (u = this.findNestingParentVisitId());
200
+ let d = r?.only?.length ? r.only : void 0, f = r?.except?.length ? r.except : void 0, p = r ? this.extractVisitOptions(r) : void 0, m = {
201
+ visitId: a,
202
+ parentVisitId: u,
203
+ type: l,
204
+ method: o,
205
+ url: s,
206
+ only: d,
207
+ except: f,
208
+ startedAt: n,
209
+ events: [e],
210
+ features: [],
211
+ diagnostics: [],
212
+ cancelled: !1,
213
+ interrupted: !1,
214
+ completed: !1,
215
+ previousPage: this.lastPage ?? void 0,
216
+ visitOptions: p,
217
+ inertiaVisitId: r?.id
218
+ };
219
+ return this.insertRecord(m), this.pushFingerprint(i, a), r?.id && this.recordByInertiaVisitId.set(r.id, m), c || (this.activeVisitId = a), m;
220
+ }
221
+ handleStart(e, t) {
222
+ let n = this.extractVisit(t);
223
+ if (this.pendingPrefetch && n && this.visitFingerprint(n) === this.pendingPrefetch.fingerprint) {
224
+ let t = this.pendingPrefetch;
225
+ return this.pendingPrefetch = null, this.createPrefetchRecord(n, t.event, e, t.timestamp);
226
+ }
227
+ let r = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
228
+ return r && r.events.push(e), r;
229
+ }
230
+ handleFinish(e, n, r) {
231
+ let i = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
232
+ if (!i) return null;
233
+ i.events.push(e), i.finishedAt = r, i.duration = r - i.startedAt;
234
+ let a = this.extractVisit(n);
235
+ if (a && (i.completed = !!a.completed, i.cancelled = !!a.cancelled, i.interrupted = !!a.interrupted), i.network || this.drainPendingNetwork(i), i.type === "deferred" && (!i.page && this.lastPage && (i.page = this.lastPage, i.features = t(i, this.lastPage)), !i.previousPage && i.parentVisitId)) {
236
+ let e = this.records.get(i.parentVisitId);
237
+ e?.page && (i.previousPage = e.page);
238
+ }
239
+ return i.diagnostics = g(i), i;
240
+ }
241
+ handleCancel(e) {
242
+ let t = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
243
+ return t ? (t.events.push(e), t.cancelled = !0, t) : null;
244
+ }
245
+ handleNavigate(e, n) {
246
+ let r = n.page;
247
+ r && (this.lastPage = r);
248
+ let i = this.resolveByActiveId();
249
+ if (!i && r) {
250
+ let t = this.nextVisitId++;
251
+ i = {
252
+ visitId: t,
253
+ type: "full",
254
+ method: "GET",
255
+ url: r.url ?? "/",
256
+ startedAt: 0,
257
+ finishedAt: e.timestamp,
258
+ duration: 0,
259
+ events: [],
260
+ features: [],
261
+ diagnostics: [],
262
+ cancelled: !1,
263
+ interrupted: !1,
264
+ completed: !0,
265
+ page: r
266
+ }, this.insertRecord(i), this.activeVisitId = t;
267
+ for (let e of this.records.values()) e.type === "deferred" && e.parentVisitId === void 0 && (e.parentVisitId = t, e.previousPage = r);
268
+ }
269
+ return i ? (i.events.push(e), r && (i.page = r, i.features = t(i, r)), i.finishedAt || (i.finishedAt = e.timestamp, i.duration = e.timestamp - i.startedAt, i.completed = !0), i.diagnostics = g(i), i) : null;
270
+ }
271
+ handleBeforeUpdate(e, n) {
272
+ let r = this.resolveByActiveId();
273
+ if (!r) return null;
274
+ r.events.push(e);
275
+ let i = n.page;
276
+ if (i) {
277
+ if (this.lastPage) for (let e of this.records.values()) e.type === "deferred" && !e.page && (e.previousPage = this.lastPage);
278
+ this.lastPage = i, r.page || (r.page = i, r.features = t(r, i));
279
+ }
280
+ return r;
281
+ }
282
+ handleGenericEvent(e, t) {
283
+ let n = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
284
+ if (!n) return null;
285
+ if (n.events.push(e), e.name === "inertia:error") n.error = t.errors;
286
+ else if (e.name === "inertia:httpException") {
287
+ let e = t.response;
288
+ if (e && (n.status = e.status, n.status === 409)) {
289
+ n.type = "redirect";
290
+ let t = e.headers;
291
+ t && (n.redirectUrl = t["x-inertia-location"] ?? t["x-inertia-redirect"]);
292
+ }
293
+ } else e.name === "inertia:networkError" && (n.error = t.error);
294
+ return n.diagnostics = g(n), n;
295
+ }
296
+ createPrefetchRecord(e, t, n, r) {
297
+ let i = this.nextVisitId++, a = {
298
+ visitId: i,
299
+ type: "prefetch",
300
+ method: (e.method ?? "GET").toUpperCase(),
301
+ url: this.extractUrl(e),
302
+ only: e.only?.length ? e.only : void 0,
303
+ except: e.except?.length ? e.except : void 0,
304
+ startedAt: r,
305
+ events: [t, n],
306
+ features: [{
307
+ type: "prefetch",
308
+ label: "PREFETCH"
309
+ }],
310
+ diagnostics: [],
311
+ cancelled: !1,
312
+ interrupted: !1,
313
+ completed: !1
314
+ };
315
+ return this.insertRecord(a), this.pushFingerprint(this.visitFingerprint(e), i), this.activeVisitId = i, a;
316
+ }
317
+ visitFingerprint(e) {
318
+ return e ? `${this.extractUrl(e)}|${(e.method ?? "GET").toUpperCase()}|${JSON.stringify(e.only ?? [])}|${JSON.stringify(e.except ?? [])}|${e.deferredProps ? "d" : ""}|${e.prefetch ? "p" : ""}` : "(no-visit)";
319
+ }
320
+ pushFingerprint(e, t) {
321
+ let n = this.fingerprintMap.get(e);
322
+ n ? n.push(t) : this.fingerprintMap.set(e, [t]);
323
+ }
324
+ removeFromFingerprintMap(e) {
325
+ for (let [t, n] of this.fingerprintMap) {
326
+ let r = n.indexOf(e);
327
+ if (r !== -1) {
328
+ n.splice(r, 1), n.length === 0 && this.fingerprintMap.delete(t);
329
+ return;
330
+ }
331
+ }
332
+ }
333
+ resolveByFingerprint(e) {
334
+ let t = this.extractVisit(e.detail);
335
+ if (!t) return null;
336
+ let n = this.visitFingerprint(t), r = this.fingerprintMap.get(n);
337
+ if (!r || r.length === 0) return null;
338
+ if (e.name === "inertia:finish") {
339
+ let e = r.shift();
340
+ return r.length === 0 && this.fingerprintMap.delete(n), this.records.get(e) ?? null;
341
+ }
342
+ return this.records.get(r[0]) ?? null;
343
+ }
344
+ resolveByActiveId() {
345
+ return this.activeVisitId === null ? null : this.records.get(this.activeVisitId) ?? null;
346
+ }
347
+ insertRecord(e) {
348
+ this.records.set(e.visitId, e);
349
+ let t = this.sortedRecords.length - 1;
350
+ for (; t >= 0 && (this.sortedRecords[t].startedAt > e.startedAt || this.sortedRecords[t].startedAt === e.startedAt && this.sortedRecords[t].visitId > e.visitId);) t--;
351
+ this.sortedRecords.splice(t + 1, 0, e), this.sortedRecords.length > this.maxRecords && this.evictOldest();
352
+ }
353
+ evictOldest() {
354
+ let e = this.sortedRecords.findIndex((e) => e.finishedAt != null), [t] = this.sortedRecords.splice(e === -1 ? 0 : e, 1);
355
+ t && (this.records.delete(t.visitId), this.removeFromFingerprintMap(t.visitId), this.removeFromInertiaVisitIdMap(t), this._evictedCount++);
356
+ }
357
+ removeFromInertiaVisitIdMap(e) {
358
+ e.inertiaVisitId && this.recordByInertiaVisitId.delete(e.inertiaVisitId);
359
+ }
360
+ extractVisit(e) {
361
+ let t = e.visit;
362
+ if (typeof t == "object" && t) return t;
363
+ }
364
+ extractVisitOptions(e) {
365
+ let t = /* @__PURE__ */ new Set([
366
+ "method",
367
+ "url",
368
+ "href",
369
+ "cancelToken",
370
+ "signal",
371
+ "only",
372
+ "except",
373
+ "deferredProps",
374
+ "completed",
375
+ "cancelled",
376
+ "interrupted",
377
+ "prefetch"
378
+ ]), n = {};
379
+ 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));
380
+ return Object.keys(n).length > 0 ? n : void 0;
381
+ }
382
+ classifyVisitType(e) {
383
+ if (!e) return "full";
384
+ let t = e.only, n = e.except;
385
+ return t && t.length > 0 || n && n.length > 0 ? "partial" : e.prefetch ? "prefetch" : "full";
386
+ }
387
+ extractUrl(e) {
388
+ if (!e) return "(unknown)";
389
+ let t = e.url;
390
+ return t instanceof URL ? t.pathname + t.search : typeof t == "string" ? t : "(unknown)";
391
+ }
392
+ isDeferredReload(e) {
393
+ return e.deferredProps === !0;
394
+ }
395
+ findNestingParentVisitId(e) {
396
+ return this.sortedRecords.findLast((t) => (e === void 0 || t.url === e) && t.type !== "deferred" && t.type !== "prefetch")?.visitId;
397
+ }
398
+ }, b = o("inertia-devtools-session");
399
+ function x(e) {
400
+ return {
401
+ visitId: e.visitId,
402
+ type: e.type,
403
+ method: e.method,
404
+ url: e.url,
405
+ status: e.status
406
+ };
407
+ }
408
+ function S(e) {
409
+ b.save({
410
+ savedAt: Date.now(),
411
+ requests: e.map(x)
412
+ });
413
+ }
414
+ function C() {
415
+ return b.load();
416
+ }
417
+ function w() {
418
+ b.clear();
419
+ }
420
+ //#endregion
421
+ //#region src/inertia/core/store.ts
422
+ var T = class {
423
+ correlator;
424
+ subscribers = /* @__PURE__ */ new Set();
425
+ nextEventId = 1;
426
+ tick = 0;
427
+ _paused = !1;
428
+ previousSession = null;
429
+ saveTimer;
430
+ constructor() {
431
+ this.correlator = new y(), this.previousSession = C();
432
+ }
433
+ get requests() {
434
+ return this.correlator.getRequests().slice();
435
+ }
436
+ get currentPage() {
437
+ return this.correlator.getCurrentPage();
438
+ }
439
+ getRequest(e) {
440
+ return this.correlator.getRequest(e);
441
+ }
442
+ isInertiaRequestUrl(e) {
443
+ return this.correlator.hasRequestWithUrl(e);
444
+ }
445
+ get evictedCount() {
446
+ return this.correlator.evictedCount;
447
+ }
448
+ get paused() {
449
+ return this._paused;
450
+ }
451
+ get previousSessionRequests() {
452
+ return this.previousSession?.requests ?? [];
453
+ }
454
+ getState() {
455
+ return {
456
+ requests: this.requests,
457
+ currentPage: this.currentPage,
458
+ evictedCount: this.evictedCount,
459
+ paused: this._paused,
460
+ tick: this.tick
461
+ };
462
+ }
463
+ captureEvent(e, t) {
464
+ if (this._paused || !(t instanceof CustomEvent)) return;
465
+ let n = r(t.detail), i = {
466
+ id: this.nextEventId++,
467
+ name: e,
468
+ timestamp: performance.now(),
469
+ detail: n
470
+ };
471
+ this.correlator.processEvent(i), this.notify();
472
+ }
473
+ captureNetworkTiming(e) {
474
+ this._paused || (this.correlator.linkNetworkTiming(e), this.notify());
475
+ }
476
+ captureInterceptedRequest(e, t) {
477
+ this._paused || (this.correlator.attachRequestHeaders(e, t), this.notify());
478
+ }
479
+ captureInterceptedResponse(e, t) {
480
+ this._paused || (this.correlator.attachResponseData(e, t), this.notify());
481
+ }
482
+ captureClientVisit(e, t, n) {
483
+ this._paused || (this.correlator.processClientVisit(e, t, n), this.notify());
484
+ }
485
+ subscribe(e) {
486
+ return this.subscribers.add(e), () => {
487
+ this.subscribers.delete(e);
488
+ };
489
+ }
490
+ setPaused(e) {
491
+ this._paused = e, this.notify();
492
+ }
493
+ clear() {
494
+ this.correlator.clear(), this.nextEventId = 1, w(), this.previousSession = null, this.notify();
495
+ }
496
+ notify() {
497
+ this.tick++;
498
+ let e = this.getState();
499
+ for (let t of this.subscribers) try {
500
+ t(e);
501
+ } catch (e) {
502
+ console.warn("[storefront-devtools] Subscriber error:", e);
503
+ }
504
+ clearTimeout(this.saveTimer), this.saveTimer = setTimeout(() => S(this.requests), 1e3);
505
+ }
506
+ }, E = [
507
+ "inertia:before",
508
+ "inertia:start",
509
+ "inertia:progress",
510
+ "inertia:success",
511
+ "inertia:error",
512
+ "inertia:httpException",
513
+ "inertia:networkError",
514
+ "inertia:finish",
515
+ "inertia:cancel",
516
+ "inertia:beforeUpdate",
517
+ "inertia:navigate",
518
+ "inertia:flash",
519
+ "inertia:prefetching",
520
+ "inertia:prefetched"
521
+ ];
522
+ //#endregion
523
+ //#region src/inertia/core/capture.ts
524
+ function D(e) {
525
+ let t = [];
526
+ for (let n of E) {
527
+ let r = (t) => {
528
+ try {
529
+ e.captureEvent(n, t);
530
+ } catch (e) {
531
+ console.error("[storefront-devtools] Error capturing event", e);
532
+ }
533
+ };
534
+ document.addEventListener(n, r), t.push(() => document.removeEventListener(n, r));
535
+ }
536
+ return () => {
537
+ t.forEach((e) => e());
538
+ };
539
+ }
540
+ //#endregion
541
+ //#region src/inertia/core/history-capture.ts
542
+ function O(e) {
543
+ if (typeof e != "object" || !e) return null;
544
+ let t = e;
545
+ if (!("page" in t)) return null;
546
+ if (t.page instanceof ArrayBuffer) return "encrypted";
547
+ if (typeof t.page != "object" || t.page == null) return null;
548
+ let n = t.page;
549
+ return typeof n.component != "string" || typeof n.props != "object" ? null : t.page;
550
+ }
551
+ function k(e, t) {
552
+ return e.url !== t.url || e.component !== t.component || !n(e.props, t.props) || !n(e.flash, t.flash);
553
+ }
554
+ function A(e) {
555
+ if (typeof window > "u") return () => {};
556
+ let t = history.pushState.bind(history), n = history.replaceState.bind(history), r = 0, i = (e) => {
557
+ e.detail?.visit?.prefetch || r++;
558
+ }, a = (e) => {
559
+ let t = e.detail?.visit;
560
+ t && (t.cancelled || t.interrupted) && r > 0 && r--;
561
+ };
562
+ document.addEventListener("inertia:before", i), document.addEventListener("inertia:finish", a);
563
+ function o(t, n, r) {
564
+ try {
565
+ e.captureClientVisit(t === "pushState" ? "push" : "replace", n, r);
566
+ } catch (e) {
567
+ console.error("[storefront-devtools] Error in history capture", e);
568
+ }
569
+ }
570
+ function s(t, n) {
571
+ setTimeout(() => {
572
+ let r = e.currentPage;
573
+ r && k(n, r) && o(t, r, n);
574
+ }, 0);
575
+ }
576
+ function c(t, n) {
577
+ let i = O(n);
578
+ if (!i) return;
579
+ let a = e.currentPage;
580
+ if (a) {
581
+ if (i === "encrypted") {
582
+ if (r > 0) {
583
+ r--;
584
+ return;
585
+ }
586
+ s(t, a);
587
+ } else {
588
+ if (r > 0) {
589
+ r--;
590
+ return;
591
+ }
592
+ if (!k(a, i)) return;
593
+ o(t, i, a);
594
+ }
595
+ }
596
+ }
597
+ return history.pushState = function(e, n, r) {
598
+ t(e, n, r), c("pushState", e);
599
+ }, history.replaceState = function(e, t, r) {
600
+ n(e, t, r), c("replaceState", e);
601
+ }, () => {
602
+ history.pushState = t, history.replaceState = n, document.removeEventListener("inertia:before", i), document.removeEventListener("inertia:finish", a);
603
+ };
604
+ }
605
+ //#endregion
606
+ //#region src/inertia/core/network.ts
607
+ function j(e, t) {
608
+ if (typeof PerformanceObserver > "u") return () => {};
609
+ let n = new PerformanceObserver((n) => {
610
+ for (let r of n.getEntries()) {
611
+ let n = r;
612
+ if ((n.initiatorType === "xmlhttprequest" || n.initiatorType === "fetch") && e(n.name)) try {
613
+ t({
614
+ url: n.name,
615
+ duration: n.duration,
616
+ startedAt: n.startTime,
617
+ finishedAt: n.startTime + n.duration,
618
+ transferSize: n.transferSize
619
+ });
620
+ } catch (e) {
621
+ console.error("[storefront-devtools] Error processing network timing", e);
622
+ }
623
+ }
624
+ });
625
+ return n.observe({
626
+ type: "resource",
627
+ buffered: !1
628
+ }), () => n.disconnect();
629
+ }
630
+ //#endregion
631
+ //#region src/inertia/core/interceptors.ts
632
+ function M(e) {
633
+ if (!e) return {};
634
+ let t = {};
635
+ for (let [n, r] of Object.entries(e)) t[n.toLowerCase()] = String(r);
636
+ return t;
637
+ }
638
+ function N(e) {
639
+ let t = typeof e == "string" ? (() => {
640
+ try {
641
+ return JSON.parse(e);
642
+ } catch {
643
+ return;
644
+ }
645
+ })() : e;
646
+ if (typeof t == "object" && t && "props" in t && typeof t.props == "object" && t.props !== null) return t.props;
647
+ }
648
+ var P = 100, F = 1e4;
649
+ function I(e, t) {
650
+ let n = e.onVisitRequest((e, n) => {
651
+ try {
652
+ let r = M(n.headers);
653
+ t.captureInterceptedRequest(e.id, s(r));
654
+ } catch (e) {
655
+ console.error("[storefront-devtools] Error capturing intercepted request", e);
656
+ }
657
+ return n;
658
+ }), r = e.onVisitResponse((e, n) => {
659
+ try {
660
+ let r = M(n.headers), o = N(n.data);
661
+ t.captureInterceptedResponse(e.id, {
662
+ headers: s(r),
663
+ props: o ? i(o, { redactKey: a }) : void 0
664
+ });
665
+ } catch (e) {
666
+ console.error("[storefront-devtools] Error capturing intercepted response", e);
667
+ }
668
+ return n;
669
+ });
670
+ return () => {
671
+ n(), r();
672
+ };
673
+ }
674
+ function L(e) {
675
+ if (typeof window > "u") return () => {};
676
+ if (window.__inertia_interceptors__) return I(window.__inertia_interceptors__, e);
677
+ let t, n = Date.now(), r = setInterval(() => {
678
+ if (window.__inertia_interceptors__) {
679
+ clearInterval(r), t = I(window.__inertia_interceptors__, e);
680
+ return;
681
+ }
682
+ Date.now() - n > F && clearInterval(r);
683
+ }, P);
684
+ return () => {
685
+ clearInterval(r), t?.();
686
+ };
687
+ }
688
+ //#endregion
689
+ //#region src/inertia/client/index.ts
690
+ if (typeof window < "u" && typeof document < "u" && !window.__STOREFRONT_DEVTOOLS_STORE__) {
691
+ let e = new T();
692
+ window.__STOREFRONT_DEVTOOLS_STORE__ = e, D(e), A(e), j((t) => e.isInertiaRequestUrl(t), (t) => e.captureNetworkTiming(t)), L(e);
693
+ }
694
+ //#endregion
@@ -0,0 +1,15 @@
1
+ import { DevToolsStore } from './store';
2
+ import { StopFunction } from './types';
3
+ /**
4
+ * Subscribes to all Inertia DOM events and feeds them into the store.
5
+ * Every handler is wrapped in try/catch so the devtools can never crash the
6
+ * host app.
7
+ *
8
+ * Prefetch requests fire the standard lifecycle (before, start, finish) too,
9
+ * with `visit.prefetch = true`; the correlator classifies them from that flag.
10
+ *
11
+ * @param store - The devtools store that receives each captured event.
12
+ * @returns A function that unsubscribes all listeners.
13
+ */
14
+ export declare function startCapture(store: DevToolsStore): StopFunction;
15
+ //# sourceMappingURL=capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../../src/inertia/core/capture.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,CAkB/D"}