@scayle/storefront-devtools 0.2.0-alpha.1 → 0.2.0-alpha.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.
Files changed (106) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +113 -83
  3. package/dist/_chunks/coalesce-cmmfn4qq.mjs +1585 -0
  4. package/dist/group.d.ts +29 -21
  5. package/dist/group.d.ts.map +1 -1
  6. package/dist/index.d.ts +4 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.mjs +40 -65
  9. package/dist/inertia/channel.d.ts +54 -0
  10. package/dist/inertia/channel.d.ts.map +1 -0
  11. package/dist/inertia/client/index.d.ts +1 -6
  12. package/dist/inertia/client/index.d.ts.map +1 -1
  13. package/dist/inertia/client/index.mjs +246 -109
  14. package/dist/inertia/client/publish.d.ts +24 -0
  15. package/dist/inertia/client/publish.d.ts.map +1 -0
  16. package/dist/inertia/core/network.d.ts +1 -1
  17. package/dist/inertia/core/network.d.ts.map +1 -1
  18. package/dist/inertia/core/response.d.ts +3 -3
  19. package/dist/inertia/core/response.d.ts.map +1 -1
  20. package/dist/inertia/plugin.d.ts +8 -6
  21. package/dist/inertia/plugin.d.ts.map +1 -1
  22. package/dist/orpc/channel.d.ts +29 -0
  23. package/dist/orpc/channel.d.ts.map +1 -0
  24. package/dist/orpc/client/index.d.ts +1 -6
  25. package/dist/orpc/client/index.d.ts.map +1 -1
  26. package/dist/orpc/client/index.mjs +152 -137
  27. package/dist/orpc/client/publish.d.ts +15 -0
  28. package/dist/orpc/client/publish.d.ts.map +1 -0
  29. package/dist/orpc/core/serialize.d.ts +1 -1
  30. package/dist/orpc/core/stats.d.ts +10 -0
  31. package/dist/orpc/core/stats.d.ts.map +1 -0
  32. package/dist/orpc/core/store.d.ts +1 -2
  33. package/dist/orpc/core/store.d.ts.map +1 -1
  34. package/dist/orpc/plugin.d.ts +8 -5
  35. package/dist/orpc/plugin.d.ts.map +1 -1
  36. package/dist/shared/clipboard.d.ts +2 -3
  37. package/dist/shared/clipboard.d.ts.map +1 -1
  38. package/dist/shared/coalesce.d.ts +14 -0
  39. package/dist/shared/coalesce.d.ts.map +1 -0
  40. package/dist/shared/panel-channel.d.ts +49 -0
  41. package/dist/shared/panel-channel.d.ts.map +1 -0
  42. package/dist/shared/publish-options.d.ts +13 -0
  43. package/dist/shared/publish-options.d.ts.map +1 -0
  44. package/dist/shared/safe-clone.d.ts +2 -1
  45. package/dist/shared/safe-clone.d.ts.map +1 -1
  46. package/dist/storefront/plugin.d.ts +6 -4
  47. package/dist/storefront/plugin.d.ts.map +1 -1
  48. package/dist/ui/assets/App-BlEKD1MK.js +4 -0
  49. package/dist/ui/assets/App-C1rr07m5.js +1 -0
  50. package/dist/ui/assets/App-C5-JscO0.css +1 -0
  51. package/dist/ui/assets/App-M0iU7c4p.css +1 -0
  52. package/dist/ui/assets/App-VElUrn9P.js +5 -0
  53. package/dist/ui/assets/App-jiQKInbo.css +1 -0
  54. package/dist/ui/assets/_plugin-vue_export-helper-BDNMzG2s.js +1 -0
  55. package/dist/ui/assets/channel-D7V7aU79.js +1 -0
  56. package/dist/ui/assets/clipboard-BnEeWyfh.css +1 -0
  57. package/dist/ui/assets/clipboard-n-T06WI3.js +1 -0
  58. package/dist/ui/assets/panel-channel-DjMENemf.js +2 -0
  59. package/dist/ui/assets/panels-B4LTsmli.css +1 -0
  60. package/dist/ui/assets/panels-BLV_p6Kz.js +2 -0
  61. package/dist/ui/assets/preload-helper-J6bGWMBq.js +2 -0
  62. package/dist/{vue-devtools/ui/assets/index-Dby9TIQH.js → ui/assets/vue-BAMMushd.js} +19 -20
  63. package/dist/{vue-devtools/ui/assets/index-sSkqWPzY.css → ui/assets/vue-Kq4tvBbL.css} +1 -1
  64. package/dist/ui/panels/index.html +15 -0
  65. package/dist/{vue-devtools/ui → ui/vue}/index.html +4 -2
  66. package/dist/vue-devtools/client/index.mjs +0 -1
  67. package/dist/vue-devtools/plugin.d.ts +10 -9
  68. package/dist/vue-devtools/plugin.d.ts.map +1 -1
  69. package/package.json +11 -29
  70. package/dist/_chunks/clipboard-DrVHc2QA.mjs +0 -61
  71. package/dist/_chunks/diff-DzJ5arJj.mjs +0 -169
  72. package/dist/_chunks/panel-uV5ITqhY.mjs +0 -51
  73. package/dist/_chunks/redact-DmIF-iyk.mjs +0 -96
  74. package/dist/_chunks/useStore-Db8RZW8T.mjs +0 -10
  75. package/dist/inertia/client/index.d.mts +0 -13
  76. package/dist/inertia/renderer/index.d.mts +0 -16
  77. package/dist/inertia/renderer/index.mjs +0 -771
  78. package/dist/orpc/client/index.d.mts +0 -13
  79. package/dist/orpc/renderer/index.d.mts +0 -16
  80. package/dist/orpc/renderer/index.mjs +0 -457
  81. package/dist/resource-center/client/index.mjs +0 -21
  82. package/dist/resource-center/client.d.ts +0 -3
  83. package/dist/resource-center/client.d.ts.map +0 -1
  84. package/dist/resource-center/plugin.d.ts +0 -12
  85. package/dist/resource-center/plugin.d.ts.map +0 -1
  86. package/dist/shared/use-window-store.d.ts +0 -18
  87. package/dist/shared/use-window-store.d.ts.map +0 -1
  88. package/dist/storefront/renderer/index.d.mts +0 -16
  89. package/dist/storefront/renderer/index.mjs +0 -124
  90. /package/dist/{vue-devtools/ui → ui}/assets/css-8QJvnqUH.js +0 -0
  91. /package/dist/{vue-devtools/ui → ui}/assets/css-CaJ9TzKE.js +0 -0
  92. /package/dist/{vue-devtools/ui → ui}/assets/diff-woXpYk--.js +0 -0
  93. /package/dist/{vue-devtools/ui → ui}/assets/html-BHDw6EPc.js +0 -0
  94. /package/dist/{vue-devtools/ui → ui}/assets/html-GueGcY0x.js +0 -0
  95. /package/dist/{vue-devtools/ui → ui}/assets/javascript-BzbQS41l.js +0 -0
  96. /package/dist/{vue-devtools/ui → ui}/assets/javascript-Yelw-5ZN.js +0 -0
  97. /package/dist/{vue-devtools/ui → ui}/assets/json-B88Oqtu5.js +0 -0
  98. /package/dist/{vue-devtools/ui → ui}/assets/json-CaljABEy.js +0 -0
  99. /package/dist/{vue-devtools/ui → ui}/assets/shellscript-CLZ0U2zV.js +0 -0
  100. /package/dist/{vue-devtools/ui → ui}/assets/typescript-Utq2Cl8c.js +0 -0
  101. /package/dist/{vue-devtools/ui → ui}/assets/typescript-j_1H8WHN.js +0 -0
  102. /package/dist/{vue-devtools/ui → ui}/assets/vitesse-dark-BZCL-v6S.js +0 -0
  103. /package/dist/{vue-devtools/ui → ui}/assets/vitesse-light-VbXTXTou.js +0 -0
  104. /package/dist/{vue-devtools/ui → ui}/assets/vue-B1Tf5CHw.js +0 -0
  105. /package/dist/{vue-devtools/ui → ui}/assets/vue-html-CGMs_6qn.js +0 -0
  106. /package/dist/{vue-devtools/ui → ui}/assets/yaml-rwi0_p6S.js +0 -0
@@ -1,7 +1,66 @@
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
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-cmmfn4qq.mjs";
2
+ //#region src/inertia/core/features.ts
3
+ function s(e) {
4
+ return typeof e == "object" && !!e && Object.keys(e).length > 0;
5
+ }
4
6
  function c(e) {
7
+ let t = [], n = null;
8
+ return s(e.deferredProps) ? n = e.deferredProps : s(e.initialDeferredProps) && (n = e.initialDeferredProps), n && t.push({
9
+ type: "deferred",
10
+ label: "DEFERRED",
11
+ details: { groups: n }
12
+ }), e.mergeProps?.length && t.push({
13
+ type: "merge",
14
+ label: "MERGE",
15
+ details: { props: e.mergeProps }
16
+ }), e.prependProps?.length && t.push({
17
+ type: "prepend",
18
+ label: "PREPEND",
19
+ details: { props: e.prependProps }
20
+ }), e.deepMergeProps?.length && t.push({
21
+ type: "deep-merge",
22
+ label: "DEEP MERGE",
23
+ details: { props: e.deepMergeProps }
24
+ }), s(e.scrollProps) && t.push({
25
+ type: "scroll",
26
+ label: "SCROLL",
27
+ details: { props: e.scrollProps }
28
+ }), s(e.onceProps) && t.push({
29
+ type: "once",
30
+ label: "ONCE",
31
+ 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({
39
+ type: "flash",
40
+ label: "FLASH",
41
+ details: { flash: e.flash }
42
+ }), s(e.rememberedState) && t.push({
43
+ type: "remember",
44
+ label: "REMEMBER",
45
+ details: { keys: Object.keys(e.rememberedState) }
46
+ }), t;
47
+ }
48
+ function l(e, t) {
49
+ 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) {
5
64
  try {
6
65
  let t = new URL(e, "http://localhost");
7
66
  return t.pathname + t.search;
@@ -11,7 +70,7 @@ function c(e) {
11
70
  }
12
71
  //#endregion
13
72
  //#region src/inertia/core/diagnostics.ts
14
- function l(e) {
73
+ function d(e) {
15
74
  return e.type === "redirect" && e.status === 409 ? {
16
75
  id: "version-mismatch",
17
76
  severity: "warning",
@@ -19,7 +78,7 @@ function l(e) {
19
78
  docsUrl: "https://inertiajs.com/the-protocol#asset-versioning"
20
79
  } : null;
21
80
  }
22
- function u(e) {
81
+ function f(e) {
23
82
  return e.interrupted ? {
24
83
  id: "visit-interrupted",
25
84
  severity: "info",
@@ -30,7 +89,7 @@ function u(e) {
30
89
  message: "Visit was cancelled"
31
90
  } : null;
32
91
  }
33
- function d(e) {
92
+ function p(e) {
34
93
  if (e.only?.length && e.page?.props) {
35
94
  let t = Object.keys(e.page.props), n = e.only.filter((e) => !t.includes(e));
36
95
  if (n.length) return {
@@ -42,7 +101,7 @@ function d(e) {
42
101
  }
43
102
  return null;
44
103
  }
45
- function f(e) {
104
+ function m(e) {
46
105
  return e.only && e.only.length > 0 && !e.only.includes("errors") && (e.status === 422 || e.events.some((e) => e.name === "inertia:error")) ? {
47
106
  id: "errors-filtered",
48
107
  severity: "warning",
@@ -50,7 +109,7 @@ function f(e) {
50
109
  docsUrl: "https://inertiajs.com/partial-reloads"
51
110
  } : null;
52
111
  }
53
- function p(e) {
112
+ function h(e) {
54
113
  return e.type === "deferred" && e.error ? {
55
114
  id: "deferred-failed",
56
115
  severity: "error",
@@ -58,7 +117,7 @@ function p(e) {
58
117
  docsUrl: "https://inertiajs.com/deferred-props"
59
118
  } : null;
60
119
  }
61
- function m(e) {
120
+ function g(e) {
62
121
  if (e.type === "client" && e.method === "REPLACE") return {
63
122
  id: "history-replace",
64
123
  severity: "info",
@@ -67,7 +126,7 @@ function m(e) {
67
126
  };
68
127
  if (e.visitOptions?.replace === !0) {
69
128
  let t = e.previousPage?.url;
70
- return t && c(t) === c(e.url) ? {
129
+ return t && u(t) === u(e.url) ? {
71
130
  id: "history-replace-same-url",
72
131
  severity: "info",
73
132
  message: "History replaced (same URL)",
@@ -81,17 +140,17 @@ function m(e) {
81
140
  }
82
141
  return null;
83
142
  }
84
- var h = [
85
- l,
86
- u,
143
+ var _ = [
87
144
  d,
88
145
  f,
89
146
  p,
90
- m
147
+ m,
148
+ h,
149
+ g
91
150
  ];
92
- function g(e) {
151
+ function v(e) {
93
152
  let t = [];
94
- for (let n of h) {
153
+ for (let n of _) {
95
154
  let r = n(e);
96
155
  r && t.push(r);
97
156
  }
@@ -99,7 +158,7 @@ function g(e) {
99
158
  }
100
159
  //#endregion
101
160
  //#region src/inertia/core/correlator.ts
102
- var _ = 10, v = 2e3, y = class {
161
+ var y = 10, b = 2e3, x = class {
103
162
  nextVisitId = 1;
104
163
  records = /* @__PURE__ */ new Map();
105
164
  sortedRecords = [];
@@ -139,35 +198,35 @@ var _ = 10, v = 2e3, y = class {
139
198
  return this._evictedCount;
140
199
  }
141
200
  hasRequestWithUrl(e) {
142
- let t = c(e);
143
- return this.sortedRecords.some((e) => c(e.url) === t);
201
+ let t = u(e);
202
+ return this.sortedRecords.some((e) => u(e.url) === t);
144
203
  }
145
- processClientVisit(t, n, r) {
146
- let i = this.nextVisitId++, a = performance.now(), o = {
147
- visitId: i,
204
+ processClientVisit(e, t, n) {
205
+ let r = this.nextVisitId++, i = performance.now(), a = {
206
+ visitId: r,
148
207
  type: "client",
149
- method: t === "push" ? "PUSH" : "REPLACE",
150
- url: n.url ?? "/",
151
- startedAt: a,
152
- finishedAt: a,
208
+ method: e === "push" ? "PUSH" : "REPLACE",
209
+ url: t.url ?? "/",
210
+ startedAt: i,
211
+ finishedAt: i,
153
212
  duration: 0,
154
213
  events: [],
155
- features: e(n),
214
+ features: c(t),
156
215
  diagnostics: [],
157
216
  cancelled: !1,
158
217
  interrupted: !1,
159
218
  completed: !0,
160
- page: n,
161
- previousPage: r
219
+ page: t,
220
+ previousPage: n
162
221
  };
163
- return this.insertRecord(o), this.lastPage = n, this.activeVisitId = i, o;
222
+ return this.insertRecord(a), this.lastPage = t, this.activeVisitId = r, a;
164
223
  }
165
224
  clear() {
166
225
  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
226
  }
168
227
  linkNetworkTiming(e) {
169
228
  let t = this.findNetworkMatch(e);
170
- return t ? (t.network = e, t) : (this.pendingNetwork.push(e), this.pendingNetwork.length > _ && this.pendingNetwork.shift(), null);
229
+ return t ? (t.network = e, t) : (this.pendingNetwork.push(e), this.pendingNetwork.length > y && this.pendingNetwork.shift(), null);
171
230
  }
172
231
  attachRequestHeaders(e, t) {
173
232
  let n = this.recordByInertiaVisitId.get(e);
@@ -185,7 +244,7 @@ var _ = 10, v = 2e3, y = class {
185
244
  return this.sortedRecords.findLast((t) => !t.network && this.networkMatchesVisit(e, t)) ?? null;
186
245
  }
187
246
  networkMatchesVisit(e, t) {
188
- return !(c(e.url) !== c(t.url) || e.startedAt < t.startedAt - v || t.finishedAt && e.startedAt > t.finishedAt + v);
247
+ return !(u(e.url) !== u(t.url) || e.startedAt < t.startedAt - b || t.finishedAt && e.startedAt > t.finishedAt + b);
189
248
  }
190
249
  handleBefore(e, t, n) {
191
250
  let r = this.extractVisit(t), i = this.visitFingerprint(r);
@@ -227,32 +286,32 @@ var _ = 10, v = 2e3, y = class {
227
286
  let r = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
228
287
  return r && r.events.push(e), r;
229
288
  }
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);
289
+ handleFinish(e, t, n) {
290
+ let r = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
291
+ if (!r) return null;
292
+ r.events.push(e), r.finishedAt = n, r.duration = n - r.startedAt;
293
+ 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)) {
295
+ let e = this.records.get(r.parentVisitId);
296
+ e?.page && (r.previousPage = e.page);
238
297
  }
239
- return i.diagnostics = g(i), i;
298
+ return r.diagnostics = v(r), r;
240
299
  }
241
300
  handleCancel(e) {
242
301
  let t = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
243
302
  return t ? (t.events.push(e), t.cancelled = !0, t) : null;
244
303
  }
245
- handleNavigate(e, n) {
246
- let r = n.page;
247
- r && (this.lastPage = r);
248
- let i = this.resolveByActiveId();
249
- if (!i && r) {
304
+ handleNavigate(e, t) {
305
+ let n = t.page;
306
+ n && (this.lastPage = n);
307
+ let r = this.resolveByActiveId();
308
+ if (!r && n) {
250
309
  let t = this.nextVisitId++;
251
- i = {
310
+ r = {
252
311
  visitId: t,
253
312
  type: "full",
254
313
  method: "GET",
255
- url: r.url ?? "/",
314
+ url: n.url ?? "/",
256
315
  startedAt: 0,
257
316
  finishedAt: e.timestamp,
258
317
  duration: 0,
@@ -262,22 +321,22 @@ var _ = 10, v = 2e3, y = class {
262
321
  cancelled: !1,
263
322
  interrupted: !1,
264
323
  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);
324
+ page: n
325
+ }, this.insertRecord(r), this.activeVisitId = t;
326
+ for (let e of this.records.values()) e.type === "deferred" && e.parentVisitId === void 0 && (e.parentVisitId = t, e.previousPage = n);
268
327
  }
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;
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;
270
329
  }
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) {
330
+ handleBeforeUpdate(e, t) {
331
+ let n = this.resolveByActiveId();
332
+ if (!n) return null;
333
+ n.events.push(e);
334
+ let r = t.page;
335
+ if (r) {
277
336
  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));
337
+ this.lastPage = r, n.page || (n.page = r, n.features = l(n, r));
279
338
  }
280
- return r;
339
+ return n;
281
340
  }
282
341
  handleGenericEvent(e, t) {
283
342
  let n = this.resolveByFingerprint(e) ?? this.resolveByActiveId();
@@ -291,7 +350,7 @@ var _ = 10, v = 2e3, y = class {
291
350
  t && (n.redirectUrl = t["x-inertia-location"] ?? t["x-inertia-redirect"]);
292
351
  }
293
352
  } else e.name === "inertia:networkError" && (n.error = t.error);
294
- return n.diagnostics = g(n), n;
353
+ return n.diagnostics = v(n), n;
295
354
  }
296
355
  createPrefetchRecord(e, t, n, r) {
297
356
  let i = this.nextVisitId++, a = {
@@ -395,8 +454,8 @@ var _ = 10, v = 2e3, y = class {
395
454
  findNestingParentVisitId(e) {
396
455
  return this.sortedRecords.findLast((t) => (e === void 0 || t.url === e) && t.type !== "deferred" && t.type !== "prefetch")?.visitId;
397
456
  }
398
- }, b = o("inertia-devtools-session");
399
- function x(e) {
457
+ }, S = t("inertia-devtools-session");
458
+ function C(e) {
400
459
  return {
401
460
  visitId: e.visitId,
402
461
  type: e.type,
@@ -405,21 +464,21 @@ function x(e) {
405
464
  status: e.status
406
465
  };
407
466
  }
408
- function S(e) {
409
- b.save({
467
+ function w(e) {
468
+ S.save({
410
469
  savedAt: Date.now(),
411
- requests: e.map(x)
470
+ requests: e.map(C)
412
471
  });
413
472
  }
414
- function C() {
415
- return b.load();
473
+ function T() {
474
+ return S.load();
416
475
  }
417
- function w() {
418
- b.clear();
476
+ function E() {
477
+ S.clear();
419
478
  }
420
479
  //#endregion
421
480
  //#region src/inertia/core/store.ts
422
- var T = class {
481
+ var D = class {
423
482
  correlator;
424
483
  subscribers = /* @__PURE__ */ new Set();
425
484
  nextEventId = 1;
@@ -428,7 +487,7 @@ var T = class {
428
487
  previousSession = null;
429
488
  saveTimer;
430
489
  constructor() {
431
- this.correlator = new y(), this.previousSession = C();
490
+ this.correlator = new x(), this.previousSession = T();
432
491
  }
433
492
  get requests() {
434
493
  return this.correlator.getRequests().slice();
@@ -462,13 +521,13 @@ var T = class {
462
521
  }
463
522
  captureEvent(e, t) {
464
523
  if (this._paused || !(t instanceof CustomEvent)) return;
465
- let n = r(t.detail), i = {
524
+ let n = a(t.detail), r = {
466
525
  id: this.nextEventId++,
467
526
  name: e,
468
527
  timestamp: performance.now(),
469
528
  detail: n
470
529
  };
471
- this.correlator.processEvent(i), this.notify();
530
+ this.correlator.processEvent(r), this.notify();
472
531
  }
473
532
  captureNetworkTiming(e) {
474
533
  this._paused || (this.correlator.linkNetworkTiming(e), this.notify());
@@ -491,7 +550,7 @@ var T = class {
491
550
  this._paused = e, this.notify();
492
551
  }
493
552
  clear() {
494
- this.correlator.clear(), this.nextEventId = 1, w(), this.previousSession = null, this.notify();
553
+ this.correlator.clear(), this.nextEventId = 1, E(), this.previousSession = null, this.notify();
495
554
  }
496
555
  notify() {
497
556
  this.tick++;
@@ -501,9 +560,9 @@ var T = class {
501
560
  } catch (e) {
502
561
  console.warn("[storefront-devtools] Subscriber error:", e);
503
562
  }
504
- clearTimeout(this.saveTimer), this.saveTimer = setTimeout(() => S(this.requests), 1e3);
563
+ clearTimeout(this.saveTimer), this.saveTimer = setTimeout(() => w(this.requests), 1e3);
505
564
  }
506
- }, E = [
565
+ }, O = [
507
566
  "inertia:before",
508
567
  "inertia:start",
509
568
  "inertia:progress",
@@ -521,9 +580,9 @@ var T = class {
521
580
  ];
522
581
  //#endregion
523
582
  //#region src/inertia/core/capture.ts
524
- function D(e) {
583
+ function k(e) {
525
584
  let t = [];
526
- for (let n of E) {
585
+ for (let n of O) {
527
586
  let r = (t) => {
528
587
  try {
529
588
  e.captureEvent(n, t);
@@ -538,8 +597,34 @@ function D(e) {
538
597
  };
539
598
  }
540
599
  //#endregion
600
+ //#region src/inertia/core/diff.ts
601
+ function A(e) {
602
+ return typeof e == "object" && !!e && !Array.isArray(e);
603
+ }
604
+ function j(e, t) {
605
+ return M(e, t, /* @__PURE__ */ new WeakSet());
606
+ }
607
+ function M(e, t, n) {
608
+ if (e === t) return !0;
609
+ if (e === null || t === null || typeof e != typeof t) return !1;
610
+ if (typeof e == "object") {
611
+ if (n.has(e) || n.has(t)) return !1;
612
+ n.add(e), n.add(t);
613
+ }
614
+ 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)) {
617
+ let r = Object.keys(e), i = Object.keys(t);
618
+ return r.length === i.length && r.every((r) => M(e[r], t[r], n));
619
+ }
620
+ return !1;
621
+ } finally {
622
+ typeof e == "object" && (n.delete(e), n.delete(t));
623
+ }
624
+ }
625
+ //#endregion
541
626
  //#region src/inertia/core/history-capture.ts
542
- function O(e) {
627
+ function N(e) {
543
628
  if (typeof e != "object" || !e) return null;
544
629
  let t = e;
545
630
  if (!("page" in t)) return null;
@@ -548,10 +633,10 @@ function O(e) {
548
633
  let n = t.page;
549
634
  return typeof n.component != "string" || typeof n.props != "object" ? null : t.page;
550
635
  }
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);
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);
553
638
  }
554
- function A(e) {
639
+ function F(e) {
555
640
  if (typeof window > "u") return () => {};
556
641
  let t = history.pushState.bind(history), n = history.replaceState.bind(history), r = 0, i = (e) => {
557
642
  e.detail?.visit?.prefetch || r++;
@@ -570,11 +655,11 @@ function A(e) {
570
655
  function s(t, n) {
571
656
  setTimeout(() => {
572
657
  let r = e.currentPage;
573
- r && k(n, r) && o(t, r, n);
658
+ r && P(n, r) && o(t, r, n);
574
659
  }, 0);
575
660
  }
576
661
  function c(t, n) {
577
- let i = O(n);
662
+ let i = N(n);
578
663
  if (!i) return;
579
664
  let a = e.currentPage;
580
665
  if (a) {
@@ -589,7 +674,7 @@ function A(e) {
589
674
  r--;
590
675
  return;
591
676
  }
592
- if (!k(a, i)) return;
677
+ if (!P(a, i)) return;
593
678
  o(t, i, a);
594
679
  }
595
680
  }
@@ -604,7 +689,7 @@ function A(e) {
604
689
  }
605
690
  //#endregion
606
691
  //#region src/inertia/core/network.ts
607
- function j(e, t) {
692
+ function I(e, t) {
608
693
  if (typeof PerformanceObserver > "u") return () => {};
609
694
  let n = new PerformanceObserver((n) => {
610
695
  for (let r of n.getEntries()) {
@@ -629,13 +714,13 @@ function j(e, t) {
629
714
  }
630
715
  //#endregion
631
716
  //#region src/inertia/core/interceptors.ts
632
- function M(e) {
717
+ function L(e) {
633
718
  if (!e) return {};
634
719
  let t = {};
635
720
  for (let [n, r] of Object.entries(e)) t[n.toLowerCase()] = String(r);
636
721
  return t;
637
722
  }
638
- function N(e) {
723
+ function R(e) {
639
724
  let t = typeof e == "string" ? (() => {
640
725
  try {
641
726
  return JSON.parse(e);
@@ -645,50 +730,102 @@ function N(e) {
645
730
  })() : e;
646
731
  if (typeof t == "object" && t && "props" in t && typeof t.props == "object" && t.props !== null) return t.props;
647
732
  }
648
- var P = 100, F = 1e4;
649
- function I(e, t) {
650
- let n = e.onVisitRequest((e, n) => {
733
+ var z = 100, B = 1e4;
734
+ function V(t, r) {
735
+ let a = t.onVisitRequest((t, n) => {
651
736
  try {
652
- let r = M(n.headers);
653
- t.captureInterceptedRequest(e.id, s(r));
737
+ let i = L(n.headers);
738
+ r.captureInterceptedRequest(t.id, e(i));
654
739
  } catch (e) {
655
740
  console.error("[storefront-devtools] Error capturing intercepted request", e);
656
741
  }
657
742
  return n;
658
- }), r = e.onVisitResponse((e, n) => {
743
+ }), o = t.onVisitResponse((t, a) => {
659
744
  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
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
664
749
  });
665
750
  } catch (e) {
666
751
  console.error("[storefront-devtools] Error capturing intercepted response", e);
667
752
  }
668
- return n;
753
+ return a;
669
754
  });
670
755
  return () => {
671
- n(), r();
756
+ a(), o();
672
757
  };
673
758
  }
674
- function L(e) {
759
+ function H(e) {
675
760
  if (typeof window > "u") return () => {};
676
- if (window.__inertia_interceptors__) return I(window.__inertia_interceptors__, e);
761
+ if (window.__inertia_interceptors__) return V(window.__inertia_interceptors__, e);
677
762
  let t, n = Date.now(), r = setInterval(() => {
678
763
  if (window.__inertia_interceptors__) {
679
- clearInterval(r), t = I(window.__inertia_interceptors__, e);
764
+ clearInterval(r), t = V(window.__inertia_interceptors__, e);
680
765
  return;
681
766
  }
682
- Date.now() - n > F && clearInterval(r);
683
- }, P);
767
+ Date.now() - n > B && clearInterval(r);
768
+ }, z);
684
769
  return () => {
685
770
  clearInterval(r), t?.();
686
771
  };
687
772
  }
688
773
  //#endregion
774
+ //#region src/inertia/channel.ts
775
+ var U = "storefront-devtools:inertia", W = "storefront-devtools:storefront";
776
+ //#endregion
777
+ //#region src/inertia/client/publish.ts
778
+ function G(e) {
779
+ let { requests: t, currentPage: n, evictedCount: r, paused: i } = e.getState();
780
+ return {
781
+ requests: t,
782
+ currentPage: n,
783
+ evictedCount: r,
784
+ paused: i,
785
+ previousSession: e.previousSessionRequests
786
+ };
787
+ }
788
+ function K(e, t = {}) {
789
+ let n = r({
790
+ ...t,
791
+ name: U,
792
+ functions: {
793
+ getState: { handler: () => G(e) },
794
+ clear: {
795
+ type: "action",
796
+ handler: () => e.clear()
797
+ },
798
+ setPaused: {
799
+ type: "action",
800
+ handler: (t) => e.setPaused(t)
801
+ }
802
+ },
803
+ events: {}
804
+ }), i = () => ({ currentPage: e.currentPage }), a = r({
805
+ ...t,
806
+ name: W,
807
+ functions: { getState: { handler: i } },
808
+ events: {}
809
+ });
810
+ n.events.on("panel:connected", () => {
811
+ n.emit("state", G(e));
812
+ }), a.events.on("panel:connected", () => {
813
+ a.emit("state", i());
814
+ });
815
+ let s = e.currentPage;
816
+ return e.subscribe(o(() => {
817
+ n.emit("state", G(e)), e.currentPage !== s && (s = e.currentPage, a.emit("state", i()));
818
+ }, 16)), {
819
+ inertia: n,
820
+ storefront: a
821
+ };
822
+ }
823
+ //#endregion
689
824
  //#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);
825
+ var q = Symbol.for("@scayle/storefront-devtools/inertia"), J = globalThis;
826
+ if (typeof window < "u" && typeof document < "u" && !J[q]) {
827
+ J[q] = !0;
828
+ let e = new D();
829
+ k(e), F(e), I((t) => e.isInertiaRequestUrl(t), (t) => e.captureNetworkTiming(t)), H(e), K(e);
693
830
  }
694
831
  //#endregion
@@ -0,0 +1,24 @@
1
+ import { PageScriptChannel } from 'devframe/in-page-channel';
2
+ import { PublishOptions } from '../../shared/publish-options';
3
+ import { DevToolsStore } from '../core/store';
4
+ import { InertiaChannelProtocol, StorefrontChannelProtocol } from '../channel';
5
+ /** The page-script endpoints {@link publishInertiaState} creates. */
6
+ export interface InertiaChannels {
7
+ /** Serves the Inertia panel. */
8
+ inertia: PageScriptChannel<InertiaChannelProtocol>;
9
+ /** Serves the Storefront context panel. */
10
+ storefront: PageScriptChannel<StorefrontChannelProtocol>;
11
+ }
12
+ /**
13
+ * Serves the Inertia capture to the Inertia and Storefront context panels over
14
+ * in-page channels. The Inertia page script calls it once at startup. Each
15
+ * panel gets the current snapshot when it connects. After that, store updates
16
+ * go out as coalesced `state` snapshots, and the Storefront channel only sends
17
+ * when the current page changes.
18
+ *
19
+ * @param store - The Inertia capture store to publish.
20
+ * @param options - Endpoint options, used by tests to skip the window handshake.
21
+ * @returns Both page-script endpoints.
22
+ */
23
+ export declare function publishInertiaState(store: DevToolsStore, options?: PublishOptions): InertiaChannels;
24
+ //# sourceMappingURL=publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/inertia/client/publish.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAGjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,OAAO,KAAK,EACV,sBAAsB,EAEtB,yBAAyB,EAE1B,MAAM,YAAY,CAAA;AAEnB,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,OAAO,EAAE,iBAAiB,CAAC,sBAAsB,CAAC,CAAA;IAClD,2CAA2C;IAC3C,UAAU,EAAE,iBAAiB,CAAC,yBAAyB,CAAC,CAAA;CACzD;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,cAAmB,GAC3B,eAAe,CAiDjB"}
@@ -14,7 +14,7 @@ export interface NetworkTiming {
14
14
  startedAt: number;
15
15
  /** Request end, `startTime + duration`. */
16
16
  finishedAt: number;
17
- /** Bytes transferred over the wire. `0` when served from cache. */
17
+ /** Bytes transferred over the network. `0` when served from cache. */
18
18
  transferSize?: number;
19
19
  }
20
20
  /** Receives one {@link NetworkTiming} per matched Inertia resource entry. */
@@ -1 +1 @@
1
- {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/inertia/core/network.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAA;IAChB,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAA;IACjB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,6EAA6E;AAC7E,MAAM,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAA;AAEnE;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,EACtC,QAAQ,EAAE,qBAAqB,GAC9B,MAAM,IAAI,CAqCZ"}
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/inertia/core/network.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAA;IAChB,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAA;IACjB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,6EAA6E;AAC7E,MAAM,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAA;AAEnE;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,EACtC,QAAQ,EAAE,qBAAqB,GAC9B,MAAM,IAAI,CAqCZ"}