@veryfront/ext-content-mdx 0.1.1189 → 0.1.1191

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 (86) hide show
  1. package/esm/deno.d.ts +5 -0
  2. package/esm/deno.js +13 -5
  3. package/esm/src/errors/error-registry/agent.d.ts +2 -0
  4. package/esm/src/errors/error-registry/agent.d.ts.map +1 -1
  5. package/esm/src/errors/error-registry/agent.js +8 -0
  6. package/esm/src/errors/error-registry/module.d.ts +4 -0
  7. package/esm/src/errors/error-registry/module.d.ts.map +1 -1
  8. package/esm/src/errors/error-registry/module.js +16 -0
  9. package/esm/src/errors/error-registry/server.d.ts +6 -0
  10. package/esm/src/errors/error-registry/server.d.ts.map +1 -1
  11. package/esm/src/errors/error-registry/server.js +18 -0
  12. package/esm/src/errors/error-registry.d.ts +5 -0
  13. package/esm/src/errors/error-registry.d.ts.map +1 -1
  14. package/esm/src/errors/types.d.ts.map +1 -1
  15. package/esm/src/errors/types.js +5 -2
  16. package/esm/src/extensions/websocket/node-websocket-server-provider.d.ts +4 -4
  17. package/esm/src/extensions/websocket/node-websocket-server-provider.d.ts.map +1 -1
  18. package/esm/src/extensions/websocket/node-websocket-server-provider.js +4 -4
  19. package/esm/src/platform/adapters/file-snapshot-error.d.ts +7 -0
  20. package/esm/src/platform/adapters/file-snapshot-error.d.ts.map +1 -1
  21. package/esm/src/platform/adapters/file-snapshot-error.js +13 -0
  22. package/esm/src/platform/adapters/path-containment.d.ts +9 -0
  23. package/esm/src/platform/adapters/path-containment.d.ts.map +1 -0
  24. package/esm/src/platform/adapters/path-containment.js +13 -0
  25. package/esm/src/platform/adapters/runtime/shared/native-snapshot-identity.d.ts +13 -0
  26. package/esm/src/platform/adapters/runtime/shared/native-snapshot-identity.d.ts.map +1 -0
  27. package/esm/src/platform/adapters/runtime/shared/native-snapshot-identity.js +12 -0
  28. package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.d.ts +7 -0
  29. package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.d.ts.map +1 -1
  30. package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.js +62 -18
  31. package/esm/src/platform/compat/error-introspection.d.ts +12 -1
  32. package/esm/src/platform/compat/error-introspection.d.ts.map +1 -1
  33. package/esm/src/platform/compat/error-introspection.js +40 -5
  34. package/esm/src/platform/compat/path/basic-operations.d.ts.map +1 -1
  35. package/esm/src/platform/compat/path/basic-operations.js +6 -2
  36. package/esm/src/platform/compat/path/portable.d.ts.map +1 -1
  37. package/esm/src/platform/compat/path/portable.js +98 -54
  38. package/esm/src/platform/compat/path/resolution.d.ts.map +1 -1
  39. package/esm/src/platform/compat/path/resolution.js +14 -5
  40. package/esm/src/platform/compat/primordials/array.d.ts +8 -0
  41. package/esm/src/platform/compat/primordials/array.d.ts.map +1 -0
  42. package/esm/src/platform/compat/primordials/array.js +33 -0
  43. package/esm/src/transforms/import-rewriter/url-builder.d.ts.map +1 -1
  44. package/esm/src/transforms/import-rewriter/url-builder.js +40 -14
  45. package/esm/src/utils/base64url.d.ts.map +1 -1
  46. package/esm/src/utils/base64url.js +10 -4
  47. package/esm/src/utils/bundle-manifest.d.ts +19 -1
  48. package/esm/src/utils/bundle-manifest.d.ts.map +1 -1
  49. package/esm/src/utils/bundle-manifest.js +124 -27
  50. package/esm/src/utils/constants/limits.d.ts +3 -1
  51. package/esm/src/utils/constants/limits.d.ts.map +1 -1
  52. package/esm/src/utils/constants/limits.js +3 -1
  53. package/esm/src/utils/hash-utils.d.ts.map +1 -1
  54. package/esm/src/utils/hash-utils.js +32 -6
  55. package/esm/src/utils/id.d.ts +16 -0
  56. package/esm/src/utils/id.d.ts.map +1 -0
  57. package/esm/src/utils/id.js +69 -0
  58. package/esm/src/utils/import-lockfile.d.ts +52 -1
  59. package/esm/src/utils/import-lockfile.d.ts.map +1 -1
  60. package/esm/src/utils/import-lockfile.js +1042 -58
  61. package/esm/src/utils/index.d.ts +1 -1
  62. package/esm/src/utils/index.d.ts.map +1 -1
  63. package/esm/src/utils/index.js +1 -1
  64. package/esm/src/utils/logger/logger.d.ts +1 -0
  65. package/esm/src/utils/logger/logger.d.ts.map +1 -1
  66. package/esm/src/utils/logger/logger.js +359 -78
  67. package/esm/src/utils/logger/redact.d.ts +4 -2
  68. package/esm/src/utils/logger/redact.d.ts.map +1 -1
  69. package/esm/src/utils/logger/redact.js +300 -112
  70. package/esm/src/utils/logger/serialization.d.ts +3 -0
  71. package/esm/src/utils/logger/serialization.d.ts.map +1 -0
  72. package/esm/src/utils/logger/serialization.js +81 -0
  73. package/esm/src/utils/memoize.d.ts +1 -1
  74. package/esm/src/utils/memoize.d.ts.map +1 -1
  75. package/esm/src/utils/memoize.js +16 -5
  76. package/esm/src/utils/path-utils.d.ts.map +1 -1
  77. package/esm/src/utils/path-utils.js +4 -2
  78. package/esm/src/utils/sleep.d.ts +8 -0
  79. package/esm/src/utils/sleep.d.ts.map +1 -1
  80. package/esm/src/utils/sleep.js +11 -2
  81. package/esm/src/utils/timer.d.ts +10 -0
  82. package/esm/src/utils/timer.d.ts.map +1 -0
  83. package/esm/src/utils/timer.js +19 -0
  84. package/esm/src/utils/version-constant.d.ts +1 -1
  85. package/esm/src/utils/version-constant.js +1 -1
  86. package/package.json +2 -2
@@ -0,0 +1,69 @@
1
+ /** ID generation utilities (16-char alphanumeric with optional prefix) */
2
+ import * as dntShim from "../../_dnt.shims.js";
3
+ const ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
4
+ const MAX_UNBIASED_BYTE = Math.floor(256 / ALPHABET.length) * ALPHABET.length;
5
+ const MAX_ID_SIZE = 1_024;
6
+ function requireIdSize(size) {
7
+ if (!Number.isSafeInteger(size) || size <= 0 || size > MAX_ID_SIZE) {
8
+ throw new RangeError(`ID size must be an integer between 1 and ${MAX_ID_SIZE}`);
9
+ }
10
+ return size;
11
+ }
12
+ function randomString(length) {
13
+ requireIdSize(length);
14
+ let result = "";
15
+ while (result.length < length) {
16
+ const remaining = length - result.length;
17
+ const batchSize = Math.min(65_536, Math.max(32, Math.ceil((remaining * 256) / MAX_UNBIASED_BYTE)));
18
+ const bytes = new Uint8Array(batchSize);
19
+ dntShim.crypto.getRandomValues(bytes);
20
+ // Iterate the allocated batch directly. A project can replace the ambient
21
+ // typed-array iterator after framework modules load; ID generation must not
22
+ // execute or depend on that mutable hook.
23
+ for (let index = 0; index < batchSize; index++) {
24
+ const byte = bytes[index] ?? 0;
25
+ if (byte >= MAX_UNBIASED_BYTE)
26
+ continue;
27
+ result += ALPHABET[byte % ALPHABET.length];
28
+ if (result.length === length)
29
+ break;
30
+ }
31
+ }
32
+ return result;
33
+ }
34
+ /** Generate a secure RFC 4122 version 4 UUID across browser Crypto implementations. */
35
+ export function generateUuid(cryptoImpl = typeof dntShim.crypto !== "undefined"
36
+ ? dntShim.crypto
37
+ : undefined) {
38
+ if (typeof cryptoImpl?.randomUUID === "function") {
39
+ return cryptoImpl.randomUUID();
40
+ }
41
+ if (typeof cryptoImpl?.getRandomValues !== "function") {
42
+ throw new Error("Web Crypto with getRandomValues is required to generate a secure UUID.");
43
+ }
44
+ const bytes = cryptoImpl.getRandomValues(new Uint8Array(16));
45
+ bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;
46
+ bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;
47
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
48
+ return [
49
+ hex.slice(0, 8),
50
+ hex.slice(8, 12),
51
+ hex.slice(12, 16),
52
+ hex.slice(16, 20),
53
+ hex.slice(20),
54
+ ].join("-");
55
+ }
56
+ /** Generate a unique ID with optional prefix (e.g., "msg-a1B2c3D4e5F6g7H8") */
57
+ export function generateId(prefix) {
58
+ const id = randomString(16);
59
+ return prefix ? `${prefix}-${id}` : id;
60
+ }
61
+ /** Create an ID generator with fixed prefix and optional configuration */
62
+ export function createIdGenerator(options) {
63
+ const { prefix, separator = "-", size = 16 } = options;
64
+ requireIdSize(size);
65
+ return function generate() {
66
+ const id = randomString(size);
67
+ return prefix ? `${prefix}${separator}${id}` : id;
68
+ };
69
+ }
@@ -12,7 +12,15 @@ export declare function createEmptyLockfile(): LockfileData;
12
12
  /** Compute integrity. */
13
13
  export declare function computeIntegrity(content: string): Promise<string>;
14
14
  export declare function verifyIntegrity(content: string, integrity: string): Promise<boolean>;
15
- /** Public API contract for lockfile manager. */
15
+ /**
16
+ * Public API contract for lockfile manager.
17
+ *
18
+ * Reads and updates fail closed with `lockfile-format-mismatch` for an
19
+ * unsupported format and `lockfile-read-error` for unreadable or malformed
20
+ * data, so an older Veryfront build cannot overwrite unrecognized lockfile
21
+ * data. `clear()` is the explicit destructive recovery operation and does not
22
+ * parse the file before removing it.
23
+ */
16
24
  export interface LockfileManager {
17
25
  read(): Promise<LockfileData | null>;
18
26
  write(data: LockfileData): Promise<void>;
@@ -23,13 +31,56 @@ export interface LockfileManager {
23
31
  flush(): Promise<void>;
24
32
  }
25
33
  export type FSAdapter = {
34
+ /**
35
+ * Authoritative queue identity for adapters that access the same backing
36
+ * filesystem. Separate adapter objects must share this key to coordinate all
37
+ * lockfile access, regardless of their optional canonicalization support.
38
+ */
39
+ readonly coordinationKey?: string;
26
40
  readFile(path: string): Promise<string>;
27
41
  writeFile(path: string, content: string): Promise<void>;
42
+ /**
43
+ * Atomically replace `to` with the file at `from` (same-directory rename).
44
+ * When present, lockfile writes stage a temp file and rename it into place,
45
+ * so a crash mid-write can never leave a truncated lockfile behind.
46
+ */
47
+ rename?(from: string, to: string): Promise<void>;
28
48
  exists(path: string): Promise<boolean>;
29
49
  remove?(path: string): Promise<void>;
50
+ /**
51
+ * Resolve an existing project path to its stable backing identity.
52
+ * Coordination through realPath is per-adapter-instance (or per shared
53
+ * coordinationKey domain): two separate adapter instances without a shared
54
+ * coordinationKey never serialize with each other through realPath alone,
55
+ * even when both implementations agree on the canonical path.
56
+ */
57
+ realPath?(path: string): Promise<string>;
30
58
  };
31
59
  /** Create lockfile manager. */
32
60
  export declare function createLockfileManager(projectDir: string, fsAdapter?: FSAdapter): LockfileManager;
61
+ /**
62
+ * Read a lockfile entry on a build or dev-server hot path.
63
+ *
64
+ * A lockfile written by a newer Veryfront build (`lockfile-format-mismatch`)
65
+ * keeps failing loudly: proceeding around data the running build cannot
66
+ * understand is exactly the overwrite hazard this module guards against. An
67
+ * unreadable or malformed lockfile (`lockfile-read-error`) instead degrades to
68
+ * a cache miss so builds keep working from fresh fetches; a warning naming
69
+ * the lockfile and the `veryfront lock --clear` remedy is logged once per
70
+ * manager instead of once per import.
71
+ */
72
+ export declare function getLockfileEntryForBuild(lockfile: LockfileManager, url: string): Promise<LockfileEntry | null>;
73
+ /**
74
+ * Persist a lockfile entry from a build or dev-server hot path.
75
+ *
76
+ * Mirrors {@link getLockfileEntryForBuild}: when the on-disk lockfile is
77
+ * unreadable or malformed (`lockfile-read-error`), the file is left untouched
78
+ * for `veryfront lock --clear` and the entry is simply not recorded, so a
79
+ * successful refetch still serves the build. Returns whether the entry was
80
+ * staged; callers should only `flush()` after a `true` result. A newer-format
81
+ * lockfile (`lockfile-format-mismatch`) keeps failing loudly.
82
+ */
83
+ export declare function setLockfileEntryForBuild(lockfile: LockfileManager, url: string, entry: LockfileEntry): Promise<boolean>;
33
84
  export interface FetchWithLockOptions {
34
85
  lockfile: LockfileManager;
35
86
  url: string;
@@ -1 +1 @@
1
- {"version":3,"file":"import-lockfile.d.ts","sourceRoot":"","sources":["../../../src/src/utils/import-lockfile.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,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