fumadocs-openapi 10.10.1 → 10.10.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 (125) hide show
  1. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/bundle.js +239 -0
  2. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +187 -0
  3. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +136 -0
  4. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js +41 -0
  5. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +124 -0
  6. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parse.js +109 -0
  7. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +30 -0
  8. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/json.js +46 -0
  9. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +36 -0
  10. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/yaml.js +49 -0
  11. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.js +242 -0
  12. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.js +247 -0
  13. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.js +210 -0
  14. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolve-external.js +100 -0
  15. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js +41 -0
  16. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +112 -0
  17. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js +8 -0
  18. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js +146 -0
  19. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +5 -0
  20. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/maybe.js +18 -0
  21. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/next.js +11 -0
  22. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/plugins.js +99 -0
  23. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/schema-resources.js +30 -0
  24. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js +315 -0
  25. package/dist/utils/document/process.js +7 -12
  26. package/package.json +6 -9
  27. package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/general/create-limiter.js +0 -43
  28. package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/object/is-object.js +0 -27
  29. package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/object/prevent-pollution.js +0 -33
  30. package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/queue/queue.js +0 -106
  31. package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/string/generate-hash.js +0 -120
  32. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/bundle.js +0 -357
  33. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/fetch-urls/index.js +0 -73
  34. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/node.js +0 -3
  35. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/parse-yaml/index.js +0 -1
  36. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/read-files/index.js +0 -51
  37. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/value-generator.js +0 -102
  38. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/convert-to-local-ref.js +0 -24
  39. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/escape-json-pointer.js +0 -11
  40. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-schemas.js +0 -44
  41. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-segments-from-path.js +0 -10
  42. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-value-by-path.js +0 -42
  43. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-file-path.js +0 -23
  44. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-http-url.js +0 -23
  45. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-json-object.js +0 -28
  46. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-yaml.js +0 -21
  47. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/normalize.js +0 -33
  48. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/resolve-reference-path.js +0 -30
  49. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/set-value-at-path.js +0 -70
  50. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/to-relative-path.js +0 -33
  51. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/unescape-json-pointer.js +0 -12
  52. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +0 -19
  53. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +0 -430
  54. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-collection.js +0 -50
  55. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-doc.js +0 -39
  56. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-node.js +0 -85
  57. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-scalar.js +0 -57
  58. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/composer.js +0 -193
  59. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-map.js +0 -82
  60. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +0 -174
  61. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +0 -40
  62. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-end.js +0 -36
  63. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +0 -153
  64. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +0 -203
  65. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-props.js +0 -105
  66. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-contains-newline.js +0 -27
  67. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +0 -25
  68. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +0 -10
  69. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-map-includes.js +0 -10
  70. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/Document.js +0 -277
  71. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/anchors.js +0 -62
  72. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/applyReviver.js +0 -38
  73. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/createNode.js +0 -61
  74. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/directives.js +0 -163
  75. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/errors.js +0 -48
  76. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/index.js +0 -16
  77. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/log.js +0 -6
  78. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Alias.js +0 -92
  79. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Collection.js +0 -117
  80. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Node.js +0 -32
  81. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Pair.js +0 -29
  82. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Scalar.js +0 -24
  83. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/YAMLMap.js +0 -106
  84. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +0 -104
  85. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +0 -49
  86. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/identity.js +0 -33
  87. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/toJS.js +0 -35
  88. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst-scalar.js +0 -3
  89. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst-visit.js +0 -89
  90. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst.js +0 -40
  91. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/lexer.js +0 -529
  92. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/line-counter.js +0 -45
  93. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/parser.js +0 -859
  94. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/public-api.js +0 -44
  95. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/Schema.js +0 -27
  96. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/map.js +0 -16
  97. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/null.js +0 -13
  98. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/seq.js +0 -16
  99. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/string.js +0 -14
  100. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/bool.js +0 -17
  101. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/float.js +0 -38
  102. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/int.js +0 -37
  103. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/schema.js +0 -23
  104. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/json/schema.js +0 -61
  105. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/tags.js +0 -81
  106. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +0 -52
  107. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +0 -24
  108. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +0 -41
  109. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +0 -70
  110. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +0 -39
  111. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +0 -60
  112. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +0 -56
  113. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +0 -39
  114. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +0 -65
  115. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +0 -79
  116. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +0 -111
  117. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringify.js +0 -105
  118. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +0 -116
  119. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyComment.js +0 -16
  120. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +0 -59
  121. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +0 -19
  122. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyPair.js +0 -95
  123. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyString.js +0 -222
  124. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/visit.js +0 -187
  125. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/index.js +0 -16
@@ -1,120 +0,0 @@
1
- //#region ../../node_modules/.pnpm/@scalar+helpers@0.8.0/node_modules/@scalar/helpers/dist/string/generate-hash.js
2
- /**
3
- * MurmurHash3 implementation
4
- *
5
- * Generate a hash from a string using the MurmurHash3 algorithm
6
- * Provides 64-bit hash output with excellent speed and distribution
7
- *
8
- * We had to move away from xxhash-wasm since it was causing issues with content security policy (CSP) violations.
9
- *
10
- * We cannot use crypto.subtle because it is only available in secure contexts (HTTPS) or on localhost.
11
- *
12
- * @param input - The string to hash
13
- * @returns The 64-bit hash of the input string as a 16-character hex string
14
- */
15
- const generateHash = (input) => {
16
- const seed = 0;
17
- let h1 = seed;
18
- let h2 = seed;
19
- const len = input.length;
20
- const remainder = len & 15;
21
- const bytes = len - remainder;
22
- const c1 = 2277735313;
23
- const c2 = 1291169091;
24
- const c3 = 1390208809;
25
- const c4 = 944331445;
26
- for (let i = 0; i < bytes; i += 16) {
27
- let k1 = input.charCodeAt(i) & 255 | (input.charCodeAt(i + 1) & 255) << 8 | (input.charCodeAt(i + 2) & 255) << 16 | (input.charCodeAt(i + 3) & 255) << 24;
28
- let k2 = input.charCodeAt(i + 4) & 255 | (input.charCodeAt(i + 5) & 255) << 8 | (input.charCodeAt(i + 6) & 255) << 16 | (input.charCodeAt(i + 7) & 255) << 24;
29
- let k3 = input.charCodeAt(i + 8) & 255 | (input.charCodeAt(i + 9) & 255) << 8 | (input.charCodeAt(i + 10) & 255) << 16 | (input.charCodeAt(i + 11) & 255) << 24;
30
- let k4 = input.charCodeAt(i + 12) & 255 | (input.charCodeAt(i + 13) & 255) << 8 | (input.charCodeAt(i + 14) & 255) << 16 | (input.charCodeAt(i + 15) & 255) << 24;
31
- k1 = Math.imul(k1, c1);
32
- k1 = k1 << 15 | k1 >>> 17;
33
- k1 = Math.imul(k1, c2);
34
- h1 ^= k1;
35
- h1 = h1 << 13 | h1 >>> 19;
36
- h1 = Math.imul(h1, 5) + 3864292196;
37
- k2 = Math.imul(k2, c2);
38
- k2 = k2 << 16 | k2 >>> 16;
39
- k2 = Math.imul(k2, c3);
40
- h2 ^= k2;
41
- h2 = h2 << 17 | h2 >>> 15;
42
- h2 = Math.imul(h2, 5) + 461845907;
43
- k3 = Math.imul(k3, c3);
44
- k3 = k3 << 17 | k3 >>> 15;
45
- k3 = Math.imul(k3, c4);
46
- h1 ^= k3;
47
- h1 = h1 << 15 | h1 >>> 17;
48
- h1 = Math.imul(h1, 5) + 1390208809;
49
- k4 = Math.imul(k4, c4);
50
- k4 = k4 << 18 | k4 >>> 14;
51
- k4 = Math.imul(k4, c1);
52
- h2 ^= k4;
53
- h2 = h2 << 13 | h2 >>> 19;
54
- h2 = Math.imul(h2, 5) + 944331445;
55
- }
56
- if (remainder > 0) {
57
- let k1 = 0;
58
- let k2 = 0;
59
- let k3 = 0;
60
- let k4 = 0;
61
- if (remainder >= 15) k4 ^= (input.charCodeAt(bytes + 14) & 255) << 16;
62
- if (remainder >= 14) k4 ^= (input.charCodeAt(bytes + 13) & 255) << 8;
63
- if (remainder >= 13) {
64
- k4 ^= input.charCodeAt(bytes + 12) & 255;
65
- k4 = Math.imul(k4, c4);
66
- k4 = k4 << 18 | k4 >>> 14;
67
- k4 = Math.imul(k4, c1);
68
- h2 ^= k4;
69
- }
70
- if (remainder >= 12) k3 ^= (input.charCodeAt(bytes + 11) & 255) << 24;
71
- if (remainder >= 11) k3 ^= (input.charCodeAt(bytes + 10) & 255) << 16;
72
- if (remainder >= 10) k3 ^= (input.charCodeAt(bytes + 9) & 255) << 8;
73
- if (remainder >= 9) {
74
- k3 ^= input.charCodeAt(bytes + 8) & 255;
75
- k3 = Math.imul(k3, c3);
76
- k3 = k3 << 17 | k3 >>> 15;
77
- k3 = Math.imul(k3, c4);
78
- h1 ^= k3;
79
- }
80
- if (remainder >= 8) k2 ^= (input.charCodeAt(bytes + 7) & 255) << 24;
81
- if (remainder >= 7) k2 ^= (input.charCodeAt(bytes + 6) & 255) << 16;
82
- if (remainder >= 6) k2 ^= (input.charCodeAt(bytes + 5) & 255) << 8;
83
- if (remainder >= 5) {
84
- k2 ^= input.charCodeAt(bytes + 4) & 255;
85
- k2 = Math.imul(k2, c2);
86
- k2 = k2 << 16 | k2 >>> 16;
87
- k2 = Math.imul(k2, c3);
88
- h2 ^= k2;
89
- }
90
- if (remainder >= 4) k1 ^= (input.charCodeAt(bytes + 3) & 255) << 24;
91
- if (remainder >= 3) k1 ^= (input.charCodeAt(bytes + 2) & 255) << 16;
92
- if (remainder >= 2) k1 ^= (input.charCodeAt(bytes + 1) & 255) << 8;
93
- if (remainder >= 1) {
94
- k1 ^= input.charCodeAt(bytes) & 255;
95
- k1 = Math.imul(k1, c1);
96
- k1 = k1 << 15 | k1 >>> 17;
97
- k1 = Math.imul(k1, c2);
98
- h1 ^= k1;
99
- }
100
- }
101
- h1 ^= len;
102
- h2 ^= len;
103
- h1 += h2;
104
- h2 += h1;
105
- h1 ^= h1 >>> 16;
106
- h1 = Math.imul(h1, 2246822507);
107
- h1 ^= h1 >>> 13;
108
- h1 = Math.imul(h1, 3266489909);
109
- h1 ^= h1 >>> 16;
110
- h2 ^= h2 >>> 16;
111
- h2 = Math.imul(h2, 2246822507);
112
- h2 ^= h2 >>> 13;
113
- h2 = Math.imul(h2, 3266489909);
114
- h2 ^= h2 >>> 16;
115
- h1 += h2;
116
- h2 += h1;
117
- return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
118
- };
119
- //#endregion
120
- export { generateHash };
@@ -1,357 +0,0 @@
1
- import { isObject } from "../../../../../../@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/object/is-object.js";
2
- import { convertToLocalRef } from "../helpers/convert-to-local-ref.js";
3
- import { getId, getSchemas } from "../helpers/get-schemas.js";
4
- import { getValueByPath } from "../helpers/get-value-by-path.js";
5
- import { isHttpUrl } from "../helpers/is-http-url.js";
6
- import { isFilePath } from "../helpers/is-file-path.js";
7
- import { resolveReferencePath } from "../helpers/resolve-reference-path.js";
8
- import { getSegmentsFromPath } from "../helpers/get-segments-from-path.js";
9
- import { setValueAtPath } from "../helpers/set-value-at-path.js";
10
- import { toRelativePath } from "../helpers/to-relative-path.js";
11
- import { escapeJsonPointer } from "../helpers/escape-json-pointer.js";
12
- import { getHash, uniqueValueGeneratorFactory } from "./value-generator.js";
13
- //#region ../../node_modules/.pnpm/@scalar+json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/bundle.js
14
- /** Type guard to check if a value is an object with a $ref property */
15
- const hasRef = (value) => isObject(value) && "$ref" in value && typeof value["$ref"] === "string";
16
- /**
17
- * Checks if a string is a local reference (starts with #)
18
- * @param value - The reference string to check
19
- * @returns true if the string is a local reference, false otherwise
20
- * @example
21
- * ```ts
22
- * isLocalRef('#/components/schemas/User') // true
23
- * isLocalRef('https://example.com/schema.json') // false
24
- * isLocalRef('./local-schema.json') // false
25
- * ```
26
- */
27
- function isLocalRef(value) {
28
- return value.startsWith("#");
29
- }
30
- /**
31
- * Resolves a string by finding and executing the appropriate plugin.
32
- * @param value - The string to resolve (URL, file path, etc)
33
- * @param plugins - Array of plugins that can handle different types of strings
34
- * @returns A promise that resolves to either the content or an error result
35
- * @example
36
- * // Using a URL plugin
37
- * await resolveContents('https://example.com/schema.json', [urlPlugin])
38
- * // Using a file plugin
39
- * await resolveContents('./schemas/user.json', [filePlugin])
40
- * // No matching plugin returns { ok: false }
41
- * await resolveContents('#/components/schemas/User', [urlPlugin, filePlugin])
42
- */
43
- function resolveContents(value, plugins) {
44
- const plugin = plugins.find((p) => p.validate(value));
45
- if (plugin) return plugin.exec(value);
46
- return Promise.resolve({ ok: false });
47
- }
48
- /**
49
- * Prefixes an internal JSON reference with a given path prefix.
50
- * Takes a local reference (starting with #) and prepends the provided prefix segments.
51
- *
52
- * @param input - The internal reference string to prefix (must start with #)
53
- * @param prefix - Array of path segments to prepend to the reference
54
- * @returns The prefixed reference string
55
- * @throws Error if input is not a local reference
56
- * @example
57
- * prefixInternalRef('#/components/schemas/User', ['definitions'])
58
- * // Returns: '#/definitions/components/schemas/User'
59
- */
60
- function prefixInternalRef(input, prefix) {
61
- if (!isLocalRef(input)) throw "Please provide an internal ref";
62
- return `#/${prefix.map(escapeJsonPointer).join("/")}${input.substring(1)}`;
63
- }
64
- /**
65
- * Updates internal references in an object by adding a prefix to their paths.
66
- * Recursively traverses the input object and modifies any local $ref references
67
- * by prepending the given prefix to their paths. This is used when embedding external
68
- * documents to maintain correct reference paths relative to the main document.
69
- *
70
- * @param input - The object to update references in
71
- * @param prefix - Array of path segments to prepend to internal reference paths
72
- * @returns void
73
- * @example
74
- * ```ts
75
- * const input = {
76
- * foo: {
77
- * $ref: '#/components/schemas/User'
78
- * }
79
- * }
80
- * prefixInternalRefRecursive(input, ['definitions'])
81
- * // Result:
82
- * // {
83
- * // foo: {
84
- * // $ref: '#/definitions/components/schemas/User'
85
- * // }
86
- * // }
87
- * ```
88
- */
89
- function prefixInternalRefRecursive(input, prefix) {
90
- if (Array.isArray(input)) {
91
- input.forEach((el) => prefixInternalRefRecursive(el, prefix));
92
- return;
93
- }
94
- if (!isObject(input)) return;
95
- Object.values(input).forEach((el) => prefixInternalRefRecursive(el, prefix));
96
- if (typeof input === "object" && "$ref" in input && typeof input["$ref"] === "string") {
97
- const ref = input["$ref"];
98
- if (!isLocalRef(ref)) return;
99
- input["$ref"] = prefixInternalRef(ref, prefix);
100
- }
101
- }
102
- /**
103
- * Resolves and copies referenced values from a source document to a target document.
104
- * This function traverses the document and copies referenced values to the target document,
105
- * while tracking processed references to avoid duplicates. It only processes references
106
- * that belong to the same external document.
107
- *
108
- * @param targetDocument - The document to copy referenced values to
109
- * @param sourceDocument - The source document containing the references
110
- * @param referencePath - The JSON pointer path to the reference
111
- * @param externalRefsKey - The key used for external references (e.g. 'x-ext')
112
- * @param documentKey - The key identifying the external document
113
- * @param bundleLocalRefs - Also bundles the local refs
114
- * @param processedNodes - Set of already processed nodes to prevent duplicates
115
- * @example
116
- * ```ts
117
- * const source = {
118
- * components: {
119
- * schemas: {
120
- * User: {
121
- * $ref: '#/x-ext/users~1schema/definitions/Person'
122
- * }
123
- * }
124
- * }
125
- * }
126
- *
127
- * const target = {}
128
- * resolveAndCopyReferences(
129
- * target,
130
- * source,
131
- * '/components/schemas/User',
132
- * 'x-ext',
133
- * 'users/schema'
134
- * )
135
- * // Result: target will contain the User schema with resolved references
136
- * ```
137
- */
138
- const resolveAndCopyReferences = (targetDocument, sourceDocument, referencePath, externalRefsKey, documentKey, bundleLocalRefs = false, processedNodes = /* @__PURE__ */ new Set()) => {
139
- const referencedValue = getValueByPath(sourceDocument, getSegmentsFromPath(referencePath)).value;
140
- if (processedNodes.has(referencedValue)) return;
141
- processedNodes.add(referencedValue);
142
- setValueAtPath(targetDocument, referencePath, referencedValue);
143
- const traverse = (node) => {
144
- if (!node || typeof node !== "object") return;
145
- if ("$ref" in node && typeof node["$ref"] === "string") {
146
- if (node["$ref"].startsWith(`#/${externalRefsKey}/${escapeJsonPointer(documentKey)}`)) resolveAndCopyReferences(targetDocument, sourceDocument, node["$ref"].substring(1), externalRefsKey, documentKey, bundleLocalRefs, processedNodes);
147
- else if (bundleLocalRefs) resolveAndCopyReferences(targetDocument, sourceDocument, node["$ref"].substring(1), externalRefsKey, documentKey, bundleLocalRefs, processedNodes);
148
- }
149
- for (const value of Object.values(node)) traverse(value);
150
- };
151
- traverse(referencedValue);
152
- };
153
- /**
154
- * Extension keys used for bundling external references in OpenAPI documents.
155
- * These custom extensions help maintain the structure and traceability of bundled documents.
156
- */
157
- const extensions = {
158
- /**
159
- * Custom OpenAPI extension key used to store external references.
160
- * This key will contain all bundled external documents.
161
- * The x-ext key is used to maintain a clean separation between the main
162
- * OpenAPI document and its bundled external references.
163
- */
164
- externalDocuments: "x-ext",
165
- /**
166
- * Custom OpenAPI extension key used to maintain a mapping between
167
- * hashed keys and their original URLs in x-ext.
168
- * This mapping is essential for tracking the source of bundled references
169
- */
170
- externalDocumentsMappings: "x-ext-urls"
171
- };
172
- /**
173
- * Bundles an OpenAPI specification by resolving all external references.
174
- * This function traverses the input object recursively and embeds external $ref
175
- * references into an x-ext section. External references can be URLs or local files.
176
- * The original $refs are updated to point to their embedded content in the x-ext section.
177
- * If the input is an object, it will be modified in place by adding an x-ext
178
- * property to store resolved external references.
179
- *
180
- * @param input - The OpenAPI specification to bundle. Can be either an object or string.
181
- * If a string is provided, it will be resolved using the provided plugins.
182
- * If no plugin can process the input, the onReferenceError hook will be invoked
183
- * and an error will be emitted to the console.
184
- * @param config - Configuration object containing plugins and options for bundling OpenAPI specifications
185
- * @returns A promise that resolves to the bundled specification with all references embedded
186
- * @example
187
- * // Example with object input
188
- * const spec = {
189
- * paths: {
190
- * '/users': {
191
- * $ref: 'https://example.com/schemas/users.yaml'
192
- * }
193
- * }
194
- * }
195
- *
196
- * const bundled = await bundle(spec, {
197
- * plugins: [fetchUrls()],
198
- * treeShake: true,
199
- * urlMap: true,
200
- * hooks: {
201
- * onResolveStart: (ref) => console.log('Resolving:', ref.$ref),
202
- * onResolveSuccess: (ref) => console.log('Resolved:', ref.$ref),
203
- * onResolveError: (ref) => console.log('Failed to resolve:', ref.$ref)
204
- * }
205
- * })
206
- * // Result:
207
- * // {
208
- * // paths: {
209
- * // '/users': {
210
- * // $ref: '#/x-ext/abc123'
211
- * // }
212
- * // },
213
- * // 'x-ext': {
214
- * // 'abc123': {
215
- * // // Resolved content from users.yaml
216
- * // }
217
- * // },
218
- * // 'x-ext-urls': {
219
- * // 'https://example.com/schemas/users.yaml': 'abc123'
220
- * // }
221
- * // }
222
- *
223
- * // Example with URL input
224
- * const bundledFromUrl = await bundle('https://example.com/openapi.yaml', {
225
- * plugins: [fetchUrls()],
226
- * treeShake: true,
227
- * urlMap: true,
228
- * hooks: {
229
- * onResolveStart: (ref) => console.log('Resolving:', ref.$ref),
230
- * onResolveSuccess: (ref) => console.log('Resolved:', ref.$ref),
231
- * onResolveError: (ref) => console.log('Failed to resolve:', ref.$ref)
232
- * }
233
- * })
234
- * // The function will first fetch the OpenAPI spec from the URL,
235
- * // then bundle all its external references into the x-ext section
236
- */
237
- async function bundle(input, config) {
238
- config.externalDocumentsKey = config.externalDocumentsKey ?? extensions.externalDocuments;
239
- config.externalDocumentsMappingsKey = config.externalDocumentsMappingsKey ?? extensions.externalDocumentsMappings;
240
- const cache = config.cache ?? /* @__PURE__ */ new Map();
241
- const loaderPlugins = config.plugins.filter((it) => it.type === "loader");
242
- const lifecyclePlugin = config.plugins.filter((it) => it.type === "lifecycle");
243
- /**
244
- * Resolves the input value by either returning it directly if it's not a string,
245
- * or attempting to resolve it using the provided plugins if it is a string.
246
- * @returns The resolved input data or throws an error if resolution fails
247
- */
248
- const resolveInput = async () => {
249
- if (typeof input !== "string") return input;
250
- const result = await resolveContents(input, loaderPlugins);
251
- if (result.ok && typeof result.data === "object") return result.data;
252
- throw new Error("Failed to resolve input: Please provide a valid string value or pass a loader to process the input");
253
- };
254
- const rawSpecification = await resolveInput();
255
- const documentRoot = config.root ?? rawSpecification;
256
- const schemas = getSchemas(documentRoot);
257
- const isPartialBundling = config.root !== void 0 && config.root !== rawSpecification || config.depth !== void 0;
258
- const processedNodes = config.visitedNodes ?? /* @__PURE__ */ new Set();
259
- const getDefaultOrigin = () => {
260
- const id = getId(documentRoot);
261
- if (id) return id;
262
- if (config.origin) return config.origin;
263
- if (typeof input !== "string") return "/";
264
- if (isHttpUrl(input) || isFilePath(input)) return input;
265
- return "/";
266
- };
267
- const defaultOrigin = getDefaultOrigin();
268
- if (documentRoot[config.externalDocumentsMappingsKey] === void 0) documentRoot[config.externalDocumentsMappingsKey] = {};
269
- const { generate } = uniqueValueGeneratorFactory(config.compress ?? getHash, documentRoot[config.externalDocumentsMappingsKey]);
270
- /**
271
- * Executes lifecycle hooks defined both in the bundler configuration and any extended lifecycle plugins.
272
- * This utility function ensures that all relevant hooks for a given event type are called in order:
273
- * - First, the hook directly provided via the config (if present)
274
- * - Then, all matching hooks from registered lifecycle plugins (if present)
275
- *
276
- * Hooks are awaited in sequence for the given event type and argument list.
277
- *
278
- * @param type The hook event type, corresponding to a key of Config['hooks'].
279
- * @param args Arguments to pass to the hook function, matching HookFn<T>.
280
- */
281
- const executeHooks = async (type, ...args) => {
282
- const hook = config.hooks?.[type];
283
- if (hook) await hook(...args);
284
- for (const plugin of lifecyclePlugin) {
285
- const pluginHook = plugin[type];
286
- if (pluginHook) await pluginHook(...args);
287
- }
288
- };
289
- const bundler = async (root, origin = defaultOrigin, isChunkParent = false, depth = 0, currentPath = [], parent = null) => {
290
- if (config.depth !== void 0 && depth > config.depth) return;
291
- if (!isObject(root) && !Array.isArray(root)) return;
292
- if (processedNodes.has(root)) return;
293
- processedNodes.add(root);
294
- const context = {
295
- path: currentPath,
296
- resolutionCache: cache,
297
- parentNode: parent,
298
- rootNode: documentRoot,
299
- loaders: loaderPlugins
300
- };
301
- await executeHooks("onBeforeNodeProcess", root, context);
302
- const id = getId(root);
303
- if (hasRef(root)) {
304
- const ref = root["$ref"];
305
- const isChunk = "$global" in root && typeof root["$global"] === "boolean" && root["$global"];
306
- const localRef = convertToLocalRef(ref, id ?? origin, schemas);
307
- if (localRef !== void 0) {
308
- if (isPartialBundling) {
309
- const segments = getSegmentsFromPath(`/${localRef}`);
310
- const parent = segments.length > 0 ? getValueByPath(documentRoot, segments.slice(0, -1)).value : void 0;
311
- const targetValue = getValueByPath(documentRoot, segments);
312
- await bundler(targetValue.value, targetValue.context, isChunkParent, depth + 1, segments, parent);
313
- }
314
- await executeHooks("onAfterNodeProcess", root, context);
315
- return;
316
- }
317
- const [prefix, path = ""] = ref.split("#", 2);
318
- const resolvedPath = resolveReferencePath(id ?? origin, prefix);
319
- const relativePath = toRelativePath(resolvedPath, defaultOrigin);
320
- const compressedPath = await generate(relativePath);
321
- const seen = cache.has(relativePath);
322
- if (!seen) cache.set(relativePath, resolveContents(resolvedPath, loaderPlugins));
323
- await executeHooks("onResolveStart", root);
324
- const result = await cache.get(relativePath);
325
- if (result.ok) {
326
- if (!seen) {
327
- if (!isChunk) prefixInternalRefRecursive(result.data, [extensions.externalDocuments, compressedPath]);
328
- await bundler(result.data, isChunk ? origin : resolvedPath, isChunk, depth + 1, [
329
- config.externalDocumentsKey,
330
- compressedPath,
331
- documentRoot[config.externalDocumentsMappingsKey]
332
- ]);
333
- setValueAtPath(documentRoot, `/${config.externalDocumentsMappingsKey}/${escapeJsonPointer(compressedPath)}`, relativePath);
334
- }
335
- if (config.treeShake === true) resolveAndCopyReferences(documentRoot, { [config.externalDocumentsKey]: { [compressedPath]: result.data } }, prefixInternalRef(`#${path}`, [config.externalDocumentsKey, compressedPath]).substring(1), config.externalDocumentsKey, compressedPath);
336
- else if (!seen) setValueAtPath(documentRoot, `/${config.externalDocumentsKey}/${compressedPath}`, result.data);
337
- root.$ref = prefixInternalRef(`#${path}`, [config.externalDocumentsKey, compressedPath]);
338
- await executeHooks("onResolveSuccess", root);
339
- await executeHooks("onAfterNodeProcess", root, context);
340
- return;
341
- }
342
- await executeHooks("onResolveError", root);
343
- await executeHooks("onAfterNodeProcess", root, context);
344
- return console.warn(`Failed to resolve external reference "${resolvedPath}". The reference may be invalid, inaccessible, or missing a loader for this type of reference.`);
345
- }
346
- for (const key in root) {
347
- if (key === config.externalDocumentsKey || key === config.externalDocumentsMappingsKey) continue;
348
- await bundler(root[key], id ?? origin, isChunkParent, depth + 1, [...currentPath, key], root);
349
- }
350
- await executeHooks("onAfterNodeProcess", root, context);
351
- };
352
- await bundler(rawSpecification);
353
- if (!config.urlMap && !isPartialBundling) delete documentRoot[config.externalDocumentsMappingsKey];
354
- return rawSpecification;
355
- }
356
- //#endregion
357
- export { bundle };
@@ -1,73 +0,0 @@
1
- import { isHttpUrl } from "../../../helpers/is-http-url.js";
2
- import { createLimiter } from "../../../../../../../../@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/general/create-limiter.js";
3
- import { normalize } from "../../../helpers/normalize.js";
4
- //#region ../../node_modules/.pnpm/@scalar+json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/fetch-urls/index.js
5
- /**
6
- * Safely checks for host from a URL
7
- * Needed because we cannot create a URL from a relative remote URL ex: examples/openapi.json
8
- */
9
- const getHost = (url) => {
10
- try {
11
- return new URL(url).host;
12
- } catch {
13
- return null;
14
- }
15
- };
16
- /**
17
- * Fetches and normalizes data from a remote URL
18
- * @param url - The URL to fetch data from
19
- * @returns A promise that resolves to either the normalized data or an error result
20
- * @example
21
- * ```ts
22
- * const result = await fetchUrl('https://api.example.com/data.json')
23
- * if (result.ok) {
24
- * console.log(result.data) // The normalized data
25
- * } else {
26
- * console.log('Failed to fetch data')
27
- * }
28
- * ```
29
- */
30
- async function fetchUrl(url, limiter, config) {
31
- try {
32
- const host = getHost(url);
33
- const headers = config?.headers?.find((a) => a.domains.find((d) => d === host) !== void 0)?.headers;
34
- const exec = config?.fetch ?? fetch;
35
- const result = await limiter(() => exec(url, { headers }));
36
- if (result.ok) {
37
- const body = await result.text();
38
- return {
39
- ok: true,
40
- data: normalize(body),
41
- raw: body
42
- };
43
- }
44
- const contentType = result.headers.get("Content-Type") ?? "";
45
- if (["text/html", "application/xml"].includes(contentType)) console.warn(`[WARN] We only support JSON/YAML formats, received ${contentType}`);
46
- console.warn(`[WARN] Fetch failed with status ${result.status} ${result.statusText} for URL: ${url}`);
47
- return { ok: false };
48
- } catch {
49
- console.warn(`[WARN] Failed to parse JSON/YAML from URL: ${url}`);
50
- return { ok: false };
51
- }
52
- }
53
- /**
54
- * Creates a plugin for handling remote URL references.
55
- * This plugin validates and fetches data from HTTP/HTTPS URLs.
56
- *
57
- * @returns A plugin object with validate and exec functions
58
- * @example
59
- * const urlPlugin = fetchUrls()
60
- * if (urlPlugin.validate('https://example.com/schema.json')) {
61
- * const result = await urlPlugin.exec('https://example.com/schema.json')
62
- * }
63
- */
64
- function fetchUrls(config) {
65
- const limiter = config?.limit ? createLimiter(config.limit) : (fn) => fn();
66
- return {
67
- type: "loader",
68
- validate: isHttpUrl,
69
- exec: (value) => fetchUrl(value, limiter, config)
70
- };
71
- }
72
- //#endregion
73
- export { fetchUrls };
@@ -1,3 +0,0 @@
1
- import "./fetch-urls/index.js";
2
- import "./parse-yaml/index.js";
3
- import "./read-files/index.js";
@@ -1 +0,0 @@
1
- import "../../../../../../../../yaml@2.9.0/node_modules/yaml/browser/index.js";
@@ -1,51 +0,0 @@
1
- import { isFilePath } from "../../../helpers/is-file-path.js";
2
- import { normalize } from "../../../helpers/normalize.js";
3
- //#region ../../node_modules/.pnpm/@scalar+json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/read-files/index.js
4
- /**
5
- * Reads and normalizes data from a local file
6
- * @param path - The file path to read from
7
- * @returns A promise that resolves to either the normalized data or an error result
8
- * @example
9
- * ```ts
10
- * const result = await readFile('./schemas/user.json')
11
- * if (result.ok) {
12
- * console.log(result.data) // The normalized data
13
- * } else {
14
- * console.log('Failed to read file')
15
- * }
16
- * ```
17
- */
18
- async function readFile(path) {
19
- const fs = typeof window === "undefined" ? await import("node:fs/promises") : void 0;
20
- if (fs === void 0) throw "Can not use readFiles plugin outside of a node environment";
21
- try {
22
- const fileContents = await fs.readFile(path, { encoding: "utf-8" });
23
- return {
24
- ok: true,
25
- data: normalize(fileContents),
26
- raw: fileContents
27
- };
28
- } catch {
29
- return { ok: false };
30
- }
31
- }
32
- /**
33
- * Creates a plugin for handling local file references.
34
- * This plugin validates and reads data from local filesystem paths.
35
- *
36
- * @returns A plugin object with validate and exec functions
37
- * @example
38
- * const filePlugin = readFiles()
39
- * if (filePlugin.validate('./local-schema.json')) {
40
- * const result = await filePlugin.exec('./local-schema.json')
41
- * }
42
- */
43
- function readFiles() {
44
- return {
45
- type: "loader",
46
- validate: isFilePath,
47
- exec: readFile
48
- };
49
- }
50
- //#endregion
51
- export { readFiles };