@qzsy/vinext 0.1.84 → 0.1.86

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.
@@ -19,11 +19,11 @@ import "./app-page-response.js";
19
19
  import { parseNextHttpErrorDigest } from "./next-error-digest.js";
20
20
  import { matchPrerenderRouteParamsPayload, readTrustedPrerenderRouteParams, serializePrerenderRouteParamsHeader } from "./prerender-route-params.js";
21
21
  import { getRenderedConcreteUrlPathsForRoute } from "./pregenerated-concrete-paths.js";
22
- import { flattenErrorCauses } from "../utils/error-cause.js";
23
22
  import { pickRootParams, setRootParams } from "../shims/root-params.js";
24
23
  import { createServerActionNotFoundResponse, getServerActionNotFoundMessage } from "./server-action-not-found.js";
25
24
  import { buildPageCacheTags } from "./implicit-tags.js";
26
25
  import { buildPostMwRequestContext } from "./app-post-middleware-context.js";
26
+ import { flattenErrorCauses } from "../utils/error-cause.js";
27
27
  import { finalizeAppRscResponse } from "./app-rsc-response-finalizer.js";
28
28
  import { normalizeRscRequest } from "./app-rsc-request-normalization.js";
29
29
  import { runWithPrerenderWorkUnit } from "./prerender-work-unit-setup.js";
@@ -613,11 +613,15 @@ async function handleServerActionRscRequest(options) {
613
613
  }
614
614
  }
615
615
  } finally {
616
- if (shouldLogAction) actionLogInfo = createServerActionLogInfo({
617
- actionId: options.actionId,
618
- args,
619
- durationMs: Math.round(performance.now() - actionLogStart)
620
- });
616
+ if (shouldLogAction) try {
617
+ actionLogInfo = createServerActionLogInfo({
618
+ actionId: options.actionId,
619
+ args,
620
+ durationMs: Math.round(performance.now() - actionLogStart)
621
+ });
622
+ } catch {
623
+ actionLogInfo = null;
624
+ }
621
625
  options.setHeadersAccessPhase(previousHeadersPhase);
622
626
  if (actionThrew && !actionWasForwarded) rootParamsUsage.transitionToRender();
623
627
  }
@@ -28,6 +28,16 @@ const DEFAULT_ARG_SANITIZE_LIMITS = {
28
28
  maxObjectKeys: 3,
29
29
  maxDepth: 2
30
30
  };
31
+ function isPlainObject(value) {
32
+ const proto = Object.getPrototypeOf(value);
33
+ return proto === Object.prototype || proto === null;
34
+ }
35
+ function describeOpaqueArg(arg) {
36
+ if (Array.isArray(arg)) return `[Array(${arg.length})]`;
37
+ if (typeof FormData !== "undefined" && arg instanceof FormData) return "[FormData]";
38
+ if (typeof Blob !== "undefined" && arg instanceof Blob) return `[${arg.constructor.name}]`;
39
+ return `[${arg.constructor.name}]`;
40
+ }
31
41
  function sanitizeArgForLog(arg, depth = 0, limits = DEFAULT_ARG_SANITIZE_LIMITS) {
32
42
  if (arg === null || arg === void 0) return arg;
33
43
  if (typeof arg === "string") return truncateString(arg, limits.maxStringLength);
@@ -40,14 +50,17 @@ function sanitizeArgForLog(arg, depth = 0, limits = DEFAULT_ARG_SANITIZE_LIMITS)
40
50
  if (arg.length > limits.maxArrayItems) items.push("...");
41
51
  return items;
42
52
  }
43
- if (typeof arg === "object") try {
44
- const entries = Object.entries(arg).slice(0, limits.maxObjectKeys);
45
- const sanitized = {};
46
- for (const [key, value] of entries) sanitized[key] = sanitizeArgForLog(value, depth + 1, limits);
47
- if (Object.keys(arg).length > limits.maxObjectKeys) sanitized["..."] = "...";
48
- return sanitized;
49
- } catch {
50
- return "[Object]";
53
+ if (typeof arg === "object") {
54
+ if (!isPlainObject(arg)) return describeOpaqueArg(arg);
55
+ try {
56
+ const entries = Object.entries(arg).slice(0, limits.maxObjectKeys);
57
+ const sanitized = {};
58
+ for (const [key, value] of entries) sanitized[key] = sanitizeArgForLog(value, depth + 1, limits);
59
+ if (Object.keys(arg).length > limits.maxObjectKeys) sanitized["..."] = "...";
60
+ return sanitized;
61
+ } catch {
62
+ return "[Object]";
63
+ }
51
64
  }
52
65
  try {
53
66
  return truncateString(JSON.stringify(arg), limits.maxStringLength);
@@ -55,6 +68,22 @@ function sanitizeArgForLog(arg, depth = 0, limits = DEFAULT_ARG_SANITIZE_LIMITS)
55
68
  return "[unserializable]";
56
69
  }
57
70
  }
71
+ /** Snapshot args without spreading lazy Flight arrays or throwing on bad payloads. */
72
+ function safeArgsSnapshotForLog(args) {
73
+ let length;
74
+ try {
75
+ length = args.length;
76
+ } catch {
77
+ return ["(args unavailable)"];
78
+ }
79
+ const snapshot = [];
80
+ for (let index = 0; index < length; index++) try {
81
+ snapshot.push(sanitizeArgForLog(args[index]));
82
+ } catch {
83
+ snapshot.push("(arg unavailable)");
84
+ }
85
+ return snapshot;
86
+ }
58
87
  function sanitizeArgsForLog(args, limits = DEFAULT_ARG_SANITIZE_LIMITS) {
59
88
  return args.map((arg) => sanitizeArgForLog(arg, 0, limits));
60
89
  }
@@ -203,12 +232,20 @@ function createServerActionLogInfo(options) {
203
232
  if (!isDevServerActionLoggingEnabled()) return null;
204
233
  const meta = resolveServerActionLogMeta(options.actionId);
205
234
  if (!meta) return null;
206
- const args = Array.isArray(options.args) ? options.args : [options.args];
207
- return {
208
- ...meta,
209
- args: sanitizeArgsForLog([...args]),
210
- duration: options.durationMs
211
- };
235
+ try {
236
+ const args = Array.isArray(options.args) ? options.args : [options.args];
237
+ return {
238
+ ...meta,
239
+ args: safeArgsSnapshotForLog(args),
240
+ duration: options.durationMs
241
+ };
242
+ } catch {
243
+ return {
244
+ ...meta,
245
+ args: ["(args unavailable)"],
246
+ duration: options.durationMs
247
+ };
248
+ }
212
249
  }
213
250
  //#endregion
214
251
  export { applyServerActionLogHeader, createServerActionLogInfo, formatActionArgs, isDevServerActionLoggingEnabled, parseServerActionLogHeader, resolveServerActionLogMeta, serializeServerActionLogHeader };
@@ -273,7 +273,7 @@ function prefetchUrl(href, mode, priority = "low") {
273
273
  cacheForNavigation: autoPrefetch.cacheForNavigation,
274
274
  optimisticRouteShell: isOptimisticRouteShellPrefetch
275
275
  });
276
- } else if (HAS_PAGES_ROUTER && window.__NEXT_DATA__) {
276
+ } else if (HAS_PAGES_ROUTER && getBrowserNextData()) {
277
277
  const dataTarget = resolvePagesDataNavigationTarget(fullHref, __basePath);
278
278
  if (dataTarget) prefetchPagesData(dataTarget);
279
279
  else {
@@ -348,6 +348,10 @@ function getSharedObserver() {
348
348
  }, { rootMargin: "250px" });
349
349
  return sharedObserver;
350
350
  }
351
+ function getBrowserNextData() {
352
+ if (typeof window === "undefined") return void 0;
353
+ return window.__NEXT_DATA__;
354
+ }
351
355
  function getDefaultLocale() {
352
356
  if (typeof window !== "undefined") return window.__VINEXT_DEFAULT_LOCALE__;
353
357
  return getI18nContext()?.defaultLocale;
@@ -361,7 +365,7 @@ function getCurrentLocale() {
361
365
  return getI18nContext()?.locale;
362
366
  }
363
367
  function getDomainLocales() {
364
- if (typeof window !== "undefined") return window.__NEXT_DATA__?.domainLocales;
368
+ if (typeof window !== "undefined") return getBrowserNextData()?.domainLocales;
365
369
  return getI18nContext()?.domainLocales;
366
370
  }
367
371
  function getCurrentHostname() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qzsy/vinext",
3
- "version": "0.1.84",
3
+ "version": "0.1.86",
4
4
  "description": "Run Next.js apps on Vite. Drop-in replacement for the next CLI.",
5
5
  "license": "MIT",
6
6
  "repository": {