@slicemachine/adapter-next 0.3.85-beta.1 → 0.3.85-beta.3

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 (220) hide show
  1. package/dist/_node_modules/lru-cache/index.cjs +267 -0
  2. package/dist/_node_modules/lru-cache/index.cjs.map +1 -0
  3. package/dist/_node_modules/lru-cache/index.js +267 -0
  4. package/dist/_node_modules/lru-cache/index.js.map +1 -0
  5. package/dist/_node_modules/yallist/iterator.cjs +18 -0
  6. package/dist/_node_modules/yallist/iterator.cjs.map +1 -0
  7. package/dist/_node_modules/yallist/iterator.js +18 -0
  8. package/dist/_node_modules/yallist/iterator.js.map +1 -0
  9. package/dist/_node_modules/yallist/yallist.cjs +367 -0
  10. package/dist/_node_modules/yallist/yallist.cjs.map +1 -0
  11. package/dist/_node_modules/yallist/yallist.js +367 -0
  12. package/dist/_node_modules/yallist/yallist.js.map +1 -0
  13. package/dist/_virtual/_commonjsHelpers.cjs +7 -0
  14. package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
  15. package/dist/_virtual/_commonjsHelpers.js +7 -0
  16. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  17. package/dist/_virtual/re.cjs +5 -0
  18. package/dist/_virtual/re.cjs.map +1 -0
  19. package/dist/_virtual/re.js +5 -0
  20. package/dist/_virtual/re.js.map +1 -0
  21. package/dist/hooks/project-init.cjs +5 -1
  22. package/dist/hooks/project-init.cjs.map +1 -1
  23. package/dist/hooks/project-init.js +5 -1
  24. package/dist/hooks/project-init.js.map +1 -1
  25. package/dist/lib/getNextJSVersion.cjs +34 -0
  26. package/dist/lib/getNextJSVersion.cjs.map +1 -0
  27. package/dist/lib/getNextJSVersion.d.ts +1 -0
  28. package/dist/lib/getNextJSVersion.js +12 -0
  29. package/dist/lib/getNextJSVersion.js.map +1 -0
  30. package/dist/lib/requireResolve.cjs +16 -0
  31. package/dist/lib/requireResolve.cjs.map +1 -0
  32. package/dist/lib/requireResolve.d.ts +10 -0
  33. package/dist/lib/requireResolve.js +16 -0
  34. package/dist/lib/requireResolve.js.map +1 -0
  35. package/dist/packages/adapter-next/_node_modules/semver/classes/comparator.cjs +122 -0
  36. package/dist/packages/adapter-next/_node_modules/semver/classes/comparator.cjs.map +1 -0
  37. package/dist/packages/adapter-next/_node_modules/semver/classes/comparator.js +122 -0
  38. package/dist/packages/adapter-next/_node_modules/semver/classes/comparator.js.map +1 -0
  39. package/dist/packages/adapter-next/_node_modules/semver/classes/range.cjs +373 -0
  40. package/dist/packages/adapter-next/_node_modules/semver/classes/range.cjs.map +1 -0
  41. package/dist/packages/adapter-next/_node_modules/semver/classes/range.js +373 -0
  42. package/dist/packages/adapter-next/_node_modules/semver/classes/range.js.map +1 -0
  43. package/dist/packages/adapter-next/_node_modules/semver/classes/semver.cjs +243 -0
  44. package/dist/packages/adapter-next/_node_modules/semver/classes/semver.cjs.map +1 -0
  45. package/dist/packages/adapter-next/_node_modules/semver/classes/semver.js +243 -0
  46. package/dist/packages/adapter-next/_node_modules/semver/classes/semver.js.map +1 -0
  47. package/dist/packages/adapter-next/_node_modules/semver/functions/clean.cjs +11 -0
  48. package/dist/packages/adapter-next/_node_modules/semver/functions/clean.cjs.map +1 -0
  49. package/dist/packages/adapter-next/_node_modules/semver/functions/clean.js +11 -0
  50. package/dist/packages/adapter-next/_node_modules/semver/functions/clean.js.map +1 -0
  51. package/dist/packages/adapter-next/_node_modules/semver/functions/cmp.cjs +53 -0
  52. package/dist/packages/adapter-next/_node_modules/semver/functions/cmp.cjs.map +1 -0
  53. package/dist/packages/adapter-next/_node_modules/semver/functions/cmp.js +53 -0
  54. package/dist/packages/adapter-next/_node_modules/semver/functions/cmp.js.map +1 -0
  55. package/dist/packages/adapter-next/_node_modules/semver/functions/coerce.cjs +40 -0
  56. package/dist/packages/adapter-next/_node_modules/semver/functions/coerce.cjs.map +1 -0
  57. package/dist/packages/adapter-next/_node_modules/semver/functions/coerce.js +40 -0
  58. package/dist/packages/adapter-next/_node_modules/semver/functions/coerce.js.map +1 -0
  59. package/dist/packages/adapter-next/_node_modules/semver/functions/compare-build.cjs +12 -0
  60. package/dist/packages/adapter-next/_node_modules/semver/functions/compare-build.cjs.map +1 -0
  61. package/dist/packages/adapter-next/_node_modules/semver/functions/compare-build.js +12 -0
  62. package/dist/packages/adapter-next/_node_modules/semver/functions/compare-build.js.map +1 -0
  63. package/dist/packages/adapter-next/_node_modules/semver/functions/compare-loose.cjs +8 -0
  64. package/dist/packages/adapter-next/_node_modules/semver/functions/compare-loose.cjs.map +1 -0
  65. package/dist/packages/adapter-next/_node_modules/semver/functions/compare-loose.js +8 -0
  66. package/dist/packages/adapter-next/_node_modules/semver/functions/compare-loose.js.map +1 -0
  67. package/dist/packages/adapter-next/_node_modules/semver/functions/compare.cjs +8 -0
  68. package/dist/packages/adapter-next/_node_modules/semver/functions/compare.cjs.map +1 -0
  69. package/dist/packages/adapter-next/_node_modules/semver/functions/compare.js +8 -0
  70. package/dist/packages/adapter-next/_node_modules/semver/functions/compare.js.map +1 -0
  71. package/dist/packages/adapter-next/_node_modules/semver/functions/diff.cjs +39 -0
  72. package/dist/packages/adapter-next/_node_modules/semver/functions/diff.cjs.map +1 -0
  73. package/dist/packages/adapter-next/_node_modules/semver/functions/diff.js +39 -0
  74. package/dist/packages/adapter-next/_node_modules/semver/functions/diff.js.map +1 -0
  75. package/dist/packages/adapter-next/_node_modules/semver/functions/eq.cjs +8 -0
  76. package/dist/packages/adapter-next/_node_modules/semver/functions/eq.cjs.map +1 -0
  77. package/dist/packages/adapter-next/_node_modules/semver/functions/eq.js +8 -0
  78. package/dist/packages/adapter-next/_node_modules/semver/functions/eq.js.map +1 -0
  79. package/dist/packages/adapter-next/_node_modules/semver/functions/gt.cjs +8 -0
  80. package/dist/packages/adapter-next/_node_modules/semver/functions/gt.cjs.map +1 -0
  81. package/dist/packages/adapter-next/_node_modules/semver/functions/gt.js +8 -0
  82. package/dist/packages/adapter-next/_node_modules/semver/functions/gt.js.map +1 -0
  83. package/dist/packages/adapter-next/_node_modules/semver/functions/gte.cjs +8 -0
  84. package/dist/packages/adapter-next/_node_modules/semver/functions/gte.cjs.map +1 -0
  85. package/dist/packages/adapter-next/_node_modules/semver/functions/gte.js +8 -0
  86. package/dist/packages/adapter-next/_node_modules/semver/functions/gte.js.map +1 -0
  87. package/dist/packages/adapter-next/_node_modules/semver/functions/inc.cjs +22 -0
  88. package/dist/packages/adapter-next/_node_modules/semver/functions/inc.cjs.map +1 -0
  89. package/dist/packages/adapter-next/_node_modules/semver/functions/inc.js +22 -0
  90. package/dist/packages/adapter-next/_node_modules/semver/functions/inc.js.map +1 -0
  91. package/dist/packages/adapter-next/_node_modules/semver/functions/lt.cjs +8 -0
  92. package/dist/packages/adapter-next/_node_modules/semver/functions/lt.cjs.map +1 -0
  93. package/dist/packages/adapter-next/_node_modules/semver/functions/lt.js +8 -0
  94. package/dist/packages/adapter-next/_node_modules/semver/functions/lt.js.map +1 -0
  95. package/dist/packages/adapter-next/_node_modules/semver/functions/lte.cjs +8 -0
  96. package/dist/packages/adapter-next/_node_modules/semver/functions/lte.cjs.map +1 -0
  97. package/dist/packages/adapter-next/_node_modules/semver/functions/lte.js +8 -0
  98. package/dist/packages/adapter-next/_node_modules/semver/functions/lte.js.map +1 -0
  99. package/dist/packages/adapter-next/_node_modules/semver/functions/major.cjs +8 -0
  100. package/dist/packages/adapter-next/_node_modules/semver/functions/major.cjs.map +1 -0
  101. package/dist/packages/adapter-next/_node_modules/semver/functions/major.js +8 -0
  102. package/dist/packages/adapter-next/_node_modules/semver/functions/major.js.map +1 -0
  103. package/dist/packages/adapter-next/_node_modules/semver/functions/minor.cjs +8 -0
  104. package/dist/packages/adapter-next/_node_modules/semver/functions/minor.cjs.map +1 -0
  105. package/dist/packages/adapter-next/_node_modules/semver/functions/minor.js +8 -0
  106. package/dist/packages/adapter-next/_node_modules/semver/functions/minor.js.map +1 -0
  107. package/dist/packages/adapter-next/_node_modules/semver/functions/neq.cjs +8 -0
  108. package/dist/packages/adapter-next/_node_modules/semver/functions/neq.cjs.map +1 -0
  109. package/dist/packages/adapter-next/_node_modules/semver/functions/neq.js +8 -0
  110. package/dist/packages/adapter-next/_node_modules/semver/functions/neq.js.map +1 -0
  111. package/dist/packages/adapter-next/_node_modules/semver/functions/parse.cjs +20 -0
  112. package/dist/packages/adapter-next/_node_modules/semver/functions/parse.cjs.map +1 -0
  113. package/dist/packages/adapter-next/_node_modules/semver/functions/parse.js +20 -0
  114. package/dist/packages/adapter-next/_node_modules/semver/functions/parse.js.map +1 -0
  115. package/dist/packages/adapter-next/_node_modules/semver/functions/patch.cjs +8 -0
  116. package/dist/packages/adapter-next/_node_modules/semver/functions/patch.cjs.map +1 -0
  117. package/dist/packages/adapter-next/_node_modules/semver/functions/patch.js +8 -0
  118. package/dist/packages/adapter-next/_node_modules/semver/functions/patch.js.map +1 -0
  119. package/dist/packages/adapter-next/_node_modules/semver/functions/prerelease.cjs +11 -0
  120. package/dist/packages/adapter-next/_node_modules/semver/functions/prerelease.cjs.map +1 -0
  121. package/dist/packages/adapter-next/_node_modules/semver/functions/prerelease.js +11 -0
  122. package/dist/packages/adapter-next/_node_modules/semver/functions/prerelease.js.map +1 -0
  123. package/dist/packages/adapter-next/_node_modules/semver/functions/rcompare.cjs +8 -0
  124. package/dist/packages/adapter-next/_node_modules/semver/functions/rcompare.cjs.map +1 -0
  125. package/dist/packages/adapter-next/_node_modules/semver/functions/rcompare.js +8 -0
  126. package/dist/packages/adapter-next/_node_modules/semver/functions/rcompare.js.map +1 -0
  127. package/dist/packages/adapter-next/_node_modules/semver/functions/rsort.cjs +8 -0
  128. package/dist/packages/adapter-next/_node_modules/semver/functions/rsort.cjs.map +1 -0
  129. package/dist/packages/adapter-next/_node_modules/semver/functions/rsort.js +8 -0
  130. package/dist/packages/adapter-next/_node_modules/semver/functions/rsort.js.map +1 -0
  131. package/dist/packages/adapter-next/_node_modules/semver/functions/satisfies.cjs +15 -0
  132. package/dist/packages/adapter-next/_node_modules/semver/functions/satisfies.cjs.map +1 -0
  133. package/dist/packages/adapter-next/_node_modules/semver/functions/satisfies.js +15 -0
  134. package/dist/packages/adapter-next/_node_modules/semver/functions/satisfies.js.map +1 -0
  135. package/dist/packages/adapter-next/_node_modules/semver/functions/sort.cjs +8 -0
  136. package/dist/packages/adapter-next/_node_modules/semver/functions/sort.cjs.map +1 -0
  137. package/dist/packages/adapter-next/_node_modules/semver/functions/sort.js +8 -0
  138. package/dist/packages/adapter-next/_node_modules/semver/functions/sort.js.map +1 -0
  139. package/dist/packages/adapter-next/_node_modules/semver/functions/valid.cjs +11 -0
  140. package/dist/packages/adapter-next/_node_modules/semver/functions/valid.cjs.map +1 -0
  141. package/dist/packages/adapter-next/_node_modules/semver/functions/valid.js +11 -0
  142. package/dist/packages/adapter-next/_node_modules/semver/functions/valid.js.map +1 -0
  143. package/dist/packages/adapter-next/_node_modules/semver/index.cjs +134 -0
  144. package/dist/packages/adapter-next/_node_modules/semver/index.cjs.map +1 -0
  145. package/dist/packages/adapter-next/_node_modules/semver/index.js +135 -0
  146. package/dist/packages/adapter-next/_node_modules/semver/index.js.map +1 -0
  147. package/dist/packages/adapter-next/_node_modules/semver/internal/constants.cjs +27 -0
  148. package/dist/packages/adapter-next/_node_modules/semver/internal/constants.cjs.map +1 -0
  149. package/dist/packages/adapter-next/_node_modules/semver/internal/constants.js +27 -0
  150. package/dist/packages/adapter-next/_node_modules/semver/internal/constants.js.map +1 -0
  151. package/dist/packages/adapter-next/_node_modules/semver/internal/debug.cjs +7 -0
  152. package/dist/packages/adapter-next/_node_modules/semver/internal/debug.cjs.map +1 -0
  153. package/dist/packages/adapter-next/_node_modules/semver/internal/debug.js +7 -0
  154. package/dist/packages/adapter-next/_node_modules/semver/internal/debug.js.map +1 -0
  155. package/dist/packages/adapter-next/_node_modules/semver/internal/identifiers.cjs +19 -0
  156. package/dist/packages/adapter-next/_node_modules/semver/internal/identifiers.cjs.map +1 -0
  157. package/dist/packages/adapter-next/_node_modules/semver/internal/identifiers.js +19 -0
  158. package/dist/packages/adapter-next/_node_modules/semver/internal/identifiers.js.map +1 -0
  159. package/dist/packages/adapter-next/_node_modules/semver/internal/parse-options.cjs +16 -0
  160. package/dist/packages/adapter-next/_node_modules/semver/internal/parse-options.cjs.map +1 -0
  161. package/dist/packages/adapter-next/_node_modules/semver/internal/parse-options.js +16 -0
  162. package/dist/packages/adapter-next/_node_modules/semver/internal/parse-options.js.map +1 -0
  163. package/dist/packages/adapter-next/_node_modules/semver/internal/re.cjs +67 -0
  164. package/dist/packages/adapter-next/_node_modules/semver/internal/re.cjs.map +1 -0
  165. package/dist/packages/adapter-next/_node_modules/semver/internal/re.js +67 -0
  166. package/dist/packages/adapter-next/_node_modules/semver/internal/re.js.map +1 -0
  167. package/dist/packages/adapter-next/_node_modules/semver/ranges/gtr.cjs +8 -0
  168. package/dist/packages/adapter-next/_node_modules/semver/ranges/gtr.cjs.map +1 -0
  169. package/dist/packages/adapter-next/_node_modules/semver/ranges/gtr.js +8 -0
  170. package/dist/packages/adapter-next/_node_modules/semver/ranges/gtr.js.map +1 -0
  171. package/dist/packages/adapter-next/_node_modules/semver/ranges/intersects.cjs +12 -0
  172. package/dist/packages/adapter-next/_node_modules/semver/ranges/intersects.cjs.map +1 -0
  173. package/dist/packages/adapter-next/_node_modules/semver/ranges/intersects.js +12 -0
  174. package/dist/packages/adapter-next/_node_modules/semver/ranges/intersects.js.map +1 -0
  175. package/dist/packages/adapter-next/_node_modules/semver/ranges/ltr.cjs +8 -0
  176. package/dist/packages/adapter-next/_node_modules/semver/ranges/ltr.cjs.map +1 -0
  177. package/dist/packages/adapter-next/_node_modules/semver/ranges/ltr.js +8 -0
  178. package/dist/packages/adapter-next/_node_modules/semver/ranges/ltr.js.map +1 -0
  179. package/dist/packages/adapter-next/_node_modules/semver/ranges/max-satisfying.cjs +28 -0
  180. package/dist/packages/adapter-next/_node_modules/semver/ranges/max-satisfying.cjs.map +1 -0
  181. package/dist/packages/adapter-next/_node_modules/semver/ranges/max-satisfying.js +28 -0
  182. package/dist/packages/adapter-next/_node_modules/semver/ranges/max-satisfying.js.map +1 -0
  183. package/dist/packages/adapter-next/_node_modules/semver/ranges/min-satisfying.cjs +28 -0
  184. package/dist/packages/adapter-next/_node_modules/semver/ranges/min-satisfying.cjs.map +1 -0
  185. package/dist/packages/adapter-next/_node_modules/semver/ranges/min-satisfying.js +28 -0
  186. package/dist/packages/adapter-next/_node_modules/semver/ranges/min-satisfying.js.map +1 -0
  187. package/dist/packages/adapter-next/_node_modules/semver/ranges/min-version.cjs +57 -0
  188. package/dist/packages/adapter-next/_node_modules/semver/ranges/min-version.cjs.map +1 -0
  189. package/dist/packages/adapter-next/_node_modules/semver/ranges/min-version.js +57 -0
  190. package/dist/packages/adapter-next/_node_modules/semver/ranges/min-version.js.map +1 -0
  191. package/dist/packages/adapter-next/_node_modules/semver/ranges/outside.cjs +74 -0
  192. package/dist/packages/adapter-next/_node_modules/semver/ranges/outside.cjs.map +1 -0
  193. package/dist/packages/adapter-next/_node_modules/semver/ranges/outside.js +74 -0
  194. package/dist/packages/adapter-next/_node_modules/semver/ranges/outside.js.map +1 -0
  195. package/dist/packages/adapter-next/_node_modules/semver/ranges/simplify.cjs +49 -0
  196. package/dist/packages/adapter-next/_node_modules/semver/ranges/simplify.cjs.map +1 -0
  197. package/dist/packages/adapter-next/_node_modules/semver/ranges/simplify.js +49 -0
  198. package/dist/packages/adapter-next/_node_modules/semver/ranges/simplify.js.map +1 -0
  199. package/dist/packages/adapter-next/_node_modules/semver/ranges/subset.cjs +163 -0
  200. package/dist/packages/adapter-next/_node_modules/semver/ranges/subset.cjs.map +1 -0
  201. package/dist/packages/adapter-next/_node_modules/semver/ranges/subset.js +163 -0
  202. package/dist/packages/adapter-next/_node_modules/semver/ranges/subset.js.map +1 -0
  203. package/dist/packages/adapter-next/_node_modules/semver/ranges/to-comparators.cjs +8 -0
  204. package/dist/packages/adapter-next/_node_modules/semver/ranges/to-comparators.cjs.map +1 -0
  205. package/dist/packages/adapter-next/_node_modules/semver/ranges/to-comparators.js +8 -0
  206. package/dist/packages/adapter-next/_node_modules/semver/ranges/to-comparators.js.map +1 -0
  207. package/dist/packages/adapter-next/_node_modules/semver/ranges/valid.cjs +14 -0
  208. package/dist/packages/adapter-next/_node_modules/semver/ranges/valid.cjs.map +1 -0
  209. package/dist/packages/adapter-next/_node_modules/semver/ranges/valid.js +14 -0
  210. package/dist/packages/adapter-next/_node_modules/semver/ranges/valid.js.map +1 -0
  211. package/dist/plugin.cjs +1 -1
  212. package/dist/plugin.js +1 -1
  213. package/package.json +6 -6
  214. package/src/hooks/project-init.ts +6 -1
  215. package/src/lib/getNextJSVersion.ts +16 -0
  216. package/src/lib/requireResolve.ts +30 -0
  217. /package/dist/{package.json.cjs → packages/adapter-next/package.json.cjs} +0 -0
  218. /package/dist/{package.json.cjs.map → packages/adapter-next/package.json.cjs.map} +0 -0
  219. /package/dist/{package.json.js → packages/adapter-next/package.json.js} +0 -0
  220. /package/dist/{package.json.js.map → packages/adapter-next/package.json.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"project-init.js","sources":["../../../src/hooks/project-init.ts"],"sourcesContent":["import type {\n\tProjectInitHook,\n\tProjectInitHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\n\nimport { buildSrcPath } from \"../lib/buildSrcPath\";\nimport { checkHasAppRouter } from \"../lib/checkHasAppRouter\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\nimport { PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME } from \"../constants\";\n\ntype InstallDependenciesArgs = {\n\tinstallDependencies: ProjectInitHookData[\"installDependencies\"];\n};\n\nconst installDependencies = async ({\n\tinstallDependencies,\n}: InstallDependenciesArgs) => {\n\tawait installDependencies({\n\t\tdependencies: {\n\t\t\t\"@prismicio/client\": \"latest\",\n\t\t\t\"@prismicio/react\": \"latest\",\n\t\t\t\"@prismicio/next\": \"latest\",\n\t\t},\n\t});\n};\n\ntype CreatePrismicIOFileArgs = SliceMachineContext<PluginOptions>;\n\nconst createPrismicIOFile = async ({\n\thelpers,\n\toptions,\n}: CreatePrismicIOFileArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: `prismicio.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet importsContents: string;\n\tlet createClientContents: string;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\timportsContents = source`\n\t\t\t\timport {\n\t\t\t\t\tcreateClient as baseCreateClient,\n\t\t\t\t\ttype ClientConfig,\n\t\t\t\t\ttype Route,\n\t\t\t\t} from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = (config: ClientConfig = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\tfetchOptions:\n\t\t\t\t\t\t\tprocess.env.NODE_ENV === 'production'\n\t\t\t\t\t\t\t\t? { next: { tags: ['prismic'] }, cache: 'force-cache' }\n\t\t\t\t\t\t\t\t: { next: { revalidate: 5 } },\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param {import(\"@prismicio/client\").ClientConfig} config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = (config = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\tfetchOptions:\n\t\t\t\t\t\t\tprocess.env.NODE_ENV === 'production'\n\t\t\t\t\t\t\t\t? { next: { tags: ['prismic'] }, cache: 'force-cache' }\n\t\t\t\t\t\t\t\t: { next: { revalidate: 5 } },\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient, type Routes } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews, type CreateClientConfig } from \"@prismicio/next/pages\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = ({ previewData, req, ...config }: CreateClientConfig = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client, previewData, req });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next/pages\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param {import(\"@prismicio/next/pages\").CreateClientConfig} config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = ({ previewData, req, ...config } = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client, previewData, req });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t}\n\n\tlet contents: string;\n\n\tif (isTypeScriptProject) {\n\t\tcontents = source`\n\t\t\t${importsContents}\n\n\t\t\t/**\n\t\t\t * The project's Prismic repository name.\n\t\t\t */\n\t\t\texport const repositoryName =\n\t\t\t\tprocess.env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;\n\n\t\t\t/**\n\t\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t\t *\n\t\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t\t */\n\t\t\t// TODO: Update the routes array to match your project's route structure.\n\t\t\tconst routes: Route[] = [\n\t\t\t\t// Examples:\n\t\t\t\t// { type: \"homepage\", path: \"/\" },\n\t\t\t\t// { type: \"page\", path: \"/:uid\" },\n\t\t\t];\n\n\t\t\t${createClientContents}\n\t\t`;\n\t} else {\n\t\tcontents = source`\n\t\t\t${importsContents}\n\n\t\t\t/**\n\t\t\t * The project's Prismic repository name.\n\t\t\t */\n\t\t\texport const repositoryName =\n\t\t\t\tprocess.env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;\n\n\t\t\t/**\n\t\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t\t *\n\t\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t\t *\n\t\t\t * @type {import(\"@prismicio/client\").Route[]}\n\t\t\t */\n\t\t\t// TODO: Update the routes array to match your project's route structure.\n\t\t\tconst routes = [\n\t\t\t\t// Examples:\n\t\t\t\t// { type: \"homepage\", path: \"/\" },\n\t\t\t\t// { type: \"page\", path: \"/:uid\" },\n\t\t\t];\n\n\t\t\t${createClientContents}\n\t\t`;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\ntype CreateSliceSimulatorPageArgs = SliceMachineContext<PluginOptions>;\n\nconst createSliceSimulatorPage = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tconst extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/slice-simulator/page.${extension}`\n\t\t\t: `pages/slice-simulator.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport {\n\t\t\t\t\tSliceSimulator,\n\t\t\t\t\tSliceSimulatorParams,\n\t\t\t\t\tgetSlices,\n\t\t\t\t} from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\timport { components } from \"../../slices\";\n\n\t\t\t\texport default async function SliceSimulatorPage({\n\t\t\t\t\tsearchParams,\n\t\t\t\t}: SliceSimulatorParams) {\n\t\t\t\t\tconst { state } = await searchParams\n\t\t\t\t\tconst slices = getSlices(state);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SliceSimulator>\n\t\t\t\t\t\t\t<SliceZone slices={slices} components={components} />\n\t\t\t\t\t\t</SliceSimulator>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport {\n\t\t\t\t\tSliceSimulator,\n\t\t\t\t\tgetSlices,\n\t\t\t\t} from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\timport { components } from \"../../slices\";\n\n\t\t\t\texport default async function SliceSimulatorPage({ searchParams }) {\n\t\t\t\t\tconst { state } = await searchParams\n\t\t\t\t\tconst slices = getSlices(state);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SliceSimulator>\n\t\t\t\t\t\t\t<SliceZone slices={slices} components={components} />\n\t\t\t\t\t\t</SliceSimulator>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tcontents = source`\n\t\t\timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\timport { components } from \"../slices\";\n\n\t\t\texport default function SliceSimulatorPage() {\n\t\t\t\treturn (\n\t\t\t\t\t<SliceSimulator\n\t\t\t\t\t\tsliceZone={(props) => <SliceZone {...props} components={components} />}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t`;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createPreviewRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/api/preview/route.${extension}`\n\t\t\t: `pages/api/preview.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents: string;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextRequest } from \"next/server\";\n\t\t\t\timport { redirectToPreviewURL } from \"@prismicio/next\";\n\n\t\t\t\timport { createClient } from \"../../../prismicio\";\n\n\t\t\t\texport async function GET(request: NextRequest) {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\treturn await redirectToPreviewURL({ client, request });\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { redirectToPreviewURL } from \"@prismicio/next\";\n\n\t\t\t\timport { createClient } from \"../../../prismicio\";\n\n\t\t\t\texport async function GET(request) {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\treturn await redirectToPreviewURL({ client, request });\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextApiRequest, NextApiResponse } from \"next\";\n\t\t\t\timport { setPreviewData, redirectToPreviewURL } from \"@prismicio/next/pages\";\n\n\t\t\t\timport { createClient } from \"../../prismicio\";\n\n\t\t\t\texport default async function handler(req: NextApiRequest, res: NextApiResponse) {\n\t\t\t\t\tconst client = createClient({ req });\n\n\t\t\t\t\tsetPreviewData({ req, res });\n\n\t\t\t\t\treturn await redirectToPreviewURL({ req, res, client });\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { setPreviewData, redirectToPreviewURL } from \"@prismicio/next/pages\";\n\n\t\t\t\timport { createClient } from \"../../prismicio\";\n\n\t\t\t\texport default async function handler(req, res) {\n\t\t\t\t\tconst client = createClient({ req });\n\n\t\t\t\t\tsetPreviewData({ req, res });\n\n\t\t\t\t\treturn await redirectToPreviewURL({ req, res, client });\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createExitPreviewRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/api/exit-preview/route.${extension}`\n\t\t\t: `pages/api/exit-preview.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents: string;\n\n\tif (hasAppRouter) {\n\t\tcontents = source`\n\t\t\timport { exitPreview } from \"@prismicio/next\";\n\n\t\t\texport function GET() {\n\t\t\t\treturn exitPreview();\n\t\t\t}\n\t\t`;\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextApiRequest, NextApiResponse } from \"next\";\n\t\t\t\timport { exitPreview } from \"@prismicio/next/pages\";\n\n\t\t\t\texport default function handler(req: NextApiRequest, res: NextApiResponse) {\n\t\t\t\t\treturn exitPreview({ req, res });\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { exitPreview } from \"@prismicio/next/pages\";\n\n\t\t\t\texport default function handler(req, res) {\n\t\t\t\t\treturn exitPreview({ req, res });\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst modifySliceMachineConfig = async ({\n\thelpers,\n\toptions,\n\tactions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst project = await helpers.getProject();\n\n\t// Add Slice Simulator URL.\n\tproject.config.localSliceSimulatorURL ||=\n\t\t\"http://localhost:3000/slice-simulator\";\n\n\t// Nest the default Slice Library in the src directory if it exists and\n\t// is empty.\n\tif (\n\t\thasSrcDirectory &&\n\t\tproject.config.libraries &&\n\t\tJSON.stringify(project.config.libraries) === JSON.stringify([\"./slices\"])\n\t) {\n\t\tconst sliceLibrary = await actions.readSliceLibrary({\n\t\t\tlibraryID: project.config.libraries[0],\n\t\t});\n\n\t\tif (sliceLibrary.sliceIDs.length < 1) {\n\t\t\tproject.config.libraries = [\"./src/slices\"];\n\t\t}\n\t}\n\n\tawait helpers.updateSliceMachineConfig(project.config, {\n\t\tformat: options.format,\n\t});\n};\n\nconst createRevalidateRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tif (!hasAppRouter) {\n\t\treturn;\n\t}\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: `app/api/revalidate/route.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\timport { NextResponse } from \"next/server\";\n\t\timport { revalidateTag } from \"next/cache\";\n\n\t\texport async function POST() {\n\t\t\trevalidateTag(\"prismic\");\n\n\t\t\treturn NextResponse.json({ revalidated: true, now: Date.now() });\n\t\t}\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst upsertSliceLibraryIndexFiles = async (\n\tcontext: SliceMachineContext<PluginOptions>,\n) => {\n\t// We must use the `getProject()` helper to get the latest version of\n\t// the project config. The config may have been modified in\n\t// `modifySliceMachineConfig()` and will not be relfected in\n\t// `context.project`.\n\t// TODO: Automatically update the plugin runner's in-memory `project`\n\t// object when `updateSliceMachineConfig()` is called.\n\tconst project = await context.helpers.getProject();\n\n\tif (!project.config.libraries) {\n\t\treturn;\n\t}\n\n\tawait Promise.all(\n\t\tproject.config.libraries.map(async (libraryID) => {\n\t\t\tawait upsertSliceLibraryIndexFile({ libraryID, ...context });\n\t\t}),\n\t);\n};\n\nexport const projectInit: ProjectInitHook<PluginOptions> = async (\n\t{ installDependencies: _installDependencies },\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tinstallDependencies({ installDependencies: _installDependencies }),\n\t\t\tmodifySliceMachineConfig(context),\n\t\t\tcreatePrismicIOFile(context),\n\t\t\tcreateSliceSimulatorPage(context),\n\t\t\tcreatePreviewRoute(context),\n\t\t\tcreateExitPreviewRoute(context),\n\t\t\tcreateRevalidateRoute(context),\n\t\t]),\n\t);\n\n\t// This must happen after `modifySliceMachineConfig()` since the\n\t// location of the default Slice library may change.\n\tawait upsertSliceLibraryIndexFiles(context);\n};\n"],"names":["installDependencies"],"mappings":";;;;;;;;;AAyBA,MAAM,sBAAsB,OAAO,EAClC,qBAAAA,2BAC6B;AAC7B,QAAMA,qBAAoB;AAAA,IACzB,cAAc;AAAA,MACb,qBAAqB;AAAA,MACrB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,IAAA;AAAA,EACnB,CACD;AACF;AAIA,MAAM,sBAAsB,OAAO,EAClC,SACA,cAC6B;AAC7B,QAAM,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AACD,QAAM,kBAAkB,MAAM,oBAAoB;AAAA,IACjD,UAAU;AAAA,IACV;AAAA,EAAA,CACA;AACD,QAAM,eAAe,MAAM,kBAAkB,EAAE,SAAS;AAExD,QAAM,YAAY,MAAM,mBAAmB,EAAE,SAAS,SAAS;AAC/D,QAAM,WAAW,MAAM,aAAa;AAAA,IACnC,UAAU,aAAa,SAAS;AAAA,IAChC;AAAA,EAAA,CACA;AAED,MAAI,MAAM,oBAAoB,EAAE,UAAU,QAAA,CAAS,GAAG;AACrD;AAAA,EACD;AAEA,MAAI;AACJ,MAAI;AAEJ,MAAI,cAAc;AACjB,QAAI,qBAAqB;AACxB,wBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAOC,kBAAkB,OAAO,GAAG;AAAA;AAG/C,6BAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAsBxB,OAAO;AACN,wBAAkB;AAAA;AAAA;AAAA,sBAGC,kBAAkB,OAAO,GAAG;AAAA;AAG/C,6BAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AA,CACA;AACF;AAEA,MAAM,+BAA+B,OACpC,YACG;AAOH,QAAM,UAAU,MAAM,QAAQ,QAAQ,WAAA;AAEtC,MAAI,CAAC,QAAQ,OAAO,WAAW;AAC9B;AAAA,EACD;AAEA,QAAM,QAAQ,IACb,QAAQ,OAAO,UAAU,IAAI,OAAO,cAAa;AAChD,UAAM,4BAA4B,EAAE,WAAW,GAAG,SAAS;AAAA,EAC5D,CAAC,CAAC;AAEJ;AAEO,MAAM,cAA8C,OAC1D,EAAE,qBAAqB,qBAAA,GACvB,YACG;AACH,oBACC,MAAM,QAAQ,WAAW;AAAA,IACxB,oBAAoB,EAAE,qBAAqB,sBAAsB;AAAA,IACjE,yBAAyB,OAAO;AAAA,IAChC,oBAAoB,OAAO;AAAA,IAC3B,yBAAyB,OAAO;AAAA,IAChC,mBAAmB,OAAO;AAAA,IAC1B,uBAAuB,OAAO;AAAA,IAC9B,sBAAsB,OAAO;AAAA,EAAA,CAC7B,CAAC;AAKH,QAAM,6BAA6B,OAAO;AAC3C;"}
1
+ {"version":3,"file":"project-init.js","sources":["../../../src/hooks/project-init.ts"],"sourcesContent":["import type {\n\tProjectInitHook,\n\tProjectInitHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\nimport semver from \"semver\";\n\nimport { buildSrcPath } from \"../lib/buildSrcPath\";\nimport { checkHasAppRouter } from \"../lib/checkHasAppRouter\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\nimport { PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME } from \"../constants\";\nimport { getNextJSVersion } from \"../lib/getNextJSVersion\";\n\ntype InstallDependenciesArgs = {\n\tinstallDependencies: ProjectInitHookData[\"installDependencies\"];\n};\n\nconst installDependencies = async ({\n\tinstallDependencies,\n}: InstallDependenciesArgs) => {\n\tawait installDependencies({\n\t\tdependencies: {\n\t\t\t\"@prismicio/client\": \"latest\",\n\t\t\t\"@prismicio/react\": \"latest\",\n\t\t\t\"@prismicio/next\": \"latest\",\n\t\t},\n\t});\n};\n\ntype CreatePrismicIOFileArgs = SliceMachineContext<PluginOptions>;\n\nconst createPrismicIOFile = async ({\n\thelpers,\n\toptions,\n}: CreatePrismicIOFileArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: `prismicio.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet importsContents: string;\n\tlet createClientContents: string;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\timportsContents = source`\n\t\t\t\timport {\n\t\t\t\t\tcreateClient as baseCreateClient,\n\t\t\t\t\ttype ClientConfig,\n\t\t\t\t\ttype Route,\n\t\t\t\t} from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = (config: ClientConfig = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\tfetchOptions:\n\t\t\t\t\t\t\tprocess.env.NODE_ENV === 'production'\n\t\t\t\t\t\t\t\t? { next: { tags: ['prismic'] }, cache: 'force-cache' }\n\t\t\t\t\t\t\t\t: { next: { revalidate: 5 } },\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param {import(\"@prismicio/client\").ClientConfig} config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = (config = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\tfetchOptions:\n\t\t\t\t\t\t\tprocess.env.NODE_ENV === 'production'\n\t\t\t\t\t\t\t\t? { next: { tags: ['prismic'] }, cache: 'force-cache' }\n\t\t\t\t\t\t\t\t: { next: { revalidate: 5 } },\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient, type Routes } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews, type CreateClientConfig } from \"@prismicio/next/pages\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = ({ previewData, req, ...config }: CreateClientConfig = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client, previewData, req });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next/pages\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param {import(\"@prismicio/next/pages\").CreateClientConfig} config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = ({ previewData, req, ...config } = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client, previewData, req });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t}\n\n\tlet contents: string;\n\n\tif (isTypeScriptProject) {\n\t\tcontents = source`\n\t\t\t${importsContents}\n\n\t\t\t/**\n\t\t\t * The project's Prismic repository name.\n\t\t\t */\n\t\t\texport const repositoryName =\n\t\t\t\tprocess.env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;\n\n\t\t\t/**\n\t\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t\t *\n\t\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t\t */\n\t\t\t// TODO: Update the routes array to match your project's route structure.\n\t\t\tconst routes: Route[] = [\n\t\t\t\t// Examples:\n\t\t\t\t// { type: \"homepage\", path: \"/\" },\n\t\t\t\t// { type: \"page\", path: \"/:uid\" },\n\t\t\t];\n\n\t\t\t${createClientContents}\n\t\t`;\n\t} else {\n\t\tcontents = source`\n\t\t\t${importsContents}\n\n\t\t\t/**\n\t\t\t * The project's Prismic repository name.\n\t\t\t */\n\t\t\texport const repositoryName =\n\t\t\t\tprocess.env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;\n\n\t\t\t/**\n\t\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t\t *\n\t\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t\t *\n\t\t\t * @type {import(\"@prismicio/client\").Route[]}\n\t\t\t */\n\t\t\t// TODO: Update the routes array to match your project's route structure.\n\t\t\tconst routes = [\n\t\t\t\t// Examples:\n\t\t\t\t// { type: \"homepage\", path: \"/\" },\n\t\t\t\t// { type: \"page\", path: \"/:uid\" },\n\t\t\t];\n\n\t\t\t${createClientContents}\n\t\t`;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\ntype CreateSliceSimulatorPageArgs = SliceMachineContext<PluginOptions>;\n\nconst createSliceSimulatorPage = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tconst extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/slice-simulator/page.${extension}`\n\t\t\t: `pages/slice-simulator.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport {\n\t\t\t\t\tSliceSimulator,\n\t\t\t\t\tSliceSimulatorParams,\n\t\t\t\t\tgetSlices,\n\t\t\t\t} from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\timport { components } from \"../../slices\";\n\n\t\t\t\texport default async function SliceSimulatorPage({\n\t\t\t\t\tsearchParams,\n\t\t\t\t}: SliceSimulatorParams) {\n\t\t\t\t\tconst { state } = await searchParams\n\t\t\t\t\tconst slices = getSlices(state);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SliceSimulator>\n\t\t\t\t\t\t\t<SliceZone slices={slices} components={components} />\n\t\t\t\t\t\t</SliceSimulator>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport {\n\t\t\t\t\tSliceSimulator,\n\t\t\t\t\tgetSlices,\n\t\t\t\t} from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\timport { components } from \"../../slices\";\n\n\t\t\t\texport default async function SliceSimulatorPage({ searchParams }) {\n\t\t\t\t\tconst { state } = await searchParams\n\t\t\t\t\tconst slices = getSlices(state);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SliceSimulator>\n\t\t\t\t\t\t\t<SliceZone slices={slices} components={components} />\n\t\t\t\t\t\t</SliceSimulator>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tcontents = source`\n\t\t\timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\timport { components } from \"../slices\";\n\n\t\t\texport default function SliceSimulatorPage() {\n\t\t\t\treturn (\n\t\t\t\t\t<SliceSimulator\n\t\t\t\t\t\tsliceZone={(props) => <SliceZone {...props} components={components} />}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t`;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createPreviewRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/api/preview/route.${extension}`\n\t\t\t: `pages/api/preview.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents: string;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextRequest } from \"next/server\";\n\t\t\t\timport { redirectToPreviewURL } from \"@prismicio/next\";\n\n\t\t\t\timport { createClient } from \"../../../prismicio\";\n\n\t\t\t\texport async function GET(request: NextRequest) {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\treturn await redirectToPreviewURL({ client, request });\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { redirectToPreviewURL } from \"@prismicio/next\";\n\n\t\t\t\timport { createClient } from \"../../../prismicio\";\n\n\t\t\t\texport async function GET(request) {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\treturn await redirectToPreviewURL({ client, request });\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextApiRequest, NextApiResponse } from \"next\";\n\t\t\t\timport { setPreviewData, redirectToPreviewURL } from \"@prismicio/next/pages\";\n\n\t\t\t\timport { createClient } from \"../../prismicio\";\n\n\t\t\t\texport default async function handler(req: NextApiRequest, res: NextApiResponse) {\n\t\t\t\t\tconst client = createClient({ req });\n\n\t\t\t\t\tsetPreviewData({ req, res });\n\n\t\t\t\t\treturn await redirectToPreviewURL({ req, res, client });\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { setPreviewData, redirectToPreviewURL } from \"@prismicio/next/pages\";\n\n\t\t\t\timport { createClient } from \"../../prismicio\";\n\n\t\t\t\texport default async function handler(req, res) {\n\t\t\t\t\tconst client = createClient({ req });\n\n\t\t\t\t\tsetPreviewData({ req, res });\n\n\t\t\t\t\treturn await redirectToPreviewURL({ req, res, client });\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createExitPreviewRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/api/exit-preview/route.${extension}`\n\t\t\t: `pages/api/exit-preview.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents: string;\n\n\tif (hasAppRouter) {\n\t\tcontents = source`\n\t\t\timport { exitPreview } from \"@prismicio/next\";\n\n\t\t\texport function GET() {\n\t\t\t\treturn exitPreview();\n\t\t\t}\n\t\t`;\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextApiRequest, NextApiResponse } from \"next\";\n\t\t\t\timport { exitPreview } from \"@prismicio/next/pages\";\n\n\t\t\t\texport default function handler(req: NextApiRequest, res: NextApiResponse) {\n\t\t\t\t\treturn exitPreview({ req, res });\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { exitPreview } from \"@prismicio/next/pages\";\n\n\t\t\t\texport default function handler(req, res) {\n\t\t\t\t\treturn exitPreview({ req, res });\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst modifySliceMachineConfig = async ({\n\thelpers,\n\toptions,\n\tactions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst project = await helpers.getProject();\n\n\t// Add Slice Simulator URL.\n\tproject.config.localSliceSimulatorURL ||=\n\t\t\"http://localhost:3000/slice-simulator\";\n\n\t// Nest the default Slice Library in the src directory if it exists and\n\t// is empty.\n\tif (\n\t\thasSrcDirectory &&\n\t\tproject.config.libraries &&\n\t\tJSON.stringify(project.config.libraries) === JSON.stringify([\"./slices\"])\n\t) {\n\t\tconst sliceLibrary = await actions.readSliceLibrary({\n\t\t\tlibraryID: project.config.libraries[0],\n\t\t});\n\n\t\tif (sliceLibrary.sliceIDs.length < 1) {\n\t\t\tproject.config.libraries = [\"./src/slices\"];\n\t\t}\n\t}\n\n\tawait helpers.updateSliceMachineConfig(project.config, {\n\t\tformat: options.format,\n\t});\n};\n\nconst createRevalidateRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tif (!hasAppRouter) {\n\t\treturn;\n\t}\n\n\tconst nextJSVersion = await getNextJSVersion();\n\tconst supportsCacheLife = semver.gte(nextJSVersion, \"16.0.0-beta.0\");\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: `app/api/revalidate/route.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\timport { NextResponse } from \"next/server\";\n\t\timport { revalidateTag } from \"next/cache\";\n\n\t\texport async function POST() {\n\t\t\trevalidateTag(\"prismic\"${supportsCacheLife ? ', \"max\"' : \"\"});\n\n\t\t\treturn NextResponse.json({ revalidated: true, now: Date.now() });\n\t\t}\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst upsertSliceLibraryIndexFiles = async (\n\tcontext: SliceMachineContext<PluginOptions>,\n) => {\n\t// We must use the `getProject()` helper to get the latest version of\n\t// the project config. The config may have been modified in\n\t// `modifySliceMachineConfig()` and will not be relfected in\n\t// `context.project`.\n\t// TODO: Automatically update the plugin runner's in-memory `project`\n\t// object when `updateSliceMachineConfig()` is called.\n\tconst project = await context.helpers.getProject();\n\n\tif (!project.config.libraries) {\n\t\treturn;\n\t}\n\n\tawait Promise.all(\n\t\tproject.config.libraries.map(async (libraryID) => {\n\t\t\tawait upsertSliceLibraryIndexFile({ libraryID, ...context });\n\t\t}),\n\t);\n};\n\nexport const projectInit: ProjectInitHook<PluginOptions> = async (\n\t{ installDependencies: _installDependencies },\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tinstallDependencies({ installDependencies: _installDependencies }),\n\t\t\tmodifySliceMachineConfig(context),\n\t\t\tcreatePrismicIOFile(context),\n\t\t\tcreateSliceSimulatorPage(context),\n\t\t\tcreatePreviewRoute(context),\n\t\t\tcreateExitPreviewRoute(context),\n\t\t\tcreateRevalidateRoute(context),\n\t\t]),\n\t);\n\n\t// This must happen after `modifySliceMachineConfig()` since the\n\t// location of the default Slice library may change.\n\tawait upsertSliceLibraryIndexFiles(context);\n};\n"],"names":["installDependencies"],"mappings":";;;;;;;;;;;AA2BA,MAAM,sBAAsB,OAAO,EAClC,qBAAAA,2BAC6B;AAC7B,QAAMA,qBAAoB;AAAA,IACzB,cAAc;AAAA,MACb,qBAAqB;AAAA,MACrB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,IAAA;AAAA,EACnB,CACD;AACF;AAIA,MAAM,sBAAsB,OAAO,EAClC,SACA,cAC6B;AAC7B,QAAM,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AACD,QAAM,kBAAkB,MAAM,oBAAoB;AAAA,IACjD,UAAU;AAAA,IACV;AAAA,EAAA,CACA;AACD,QAAM,eAAe,MAAM,kBAAkB,EAAE,SAAS;AAExD,QAAM,YAAY,MAAM,mBAAmB,EAAE,SAAS,SAAS;AAC/D,QAAM,WAAW,MAAM,aAAa;AAAA,IACnC,UAAU,aAAa,SAAS;AAAA,IAChC;AAAA,EAAA,CACA;AAED,MAAI,MAAM,oBAAoB,EAAE,UAAU,QAAA,CAAS,GAAG;AACrD;AAAA,EACD;AAEA,MAAI;AACJ,MAAI;AAEJ,MAAI,cAAc;AACjB,QAAI,qBAAqB;AACxB,wBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAOC,kBAAkB,OAAO,GAAG;AAAA;AAG/C,6BAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAsBxB,OAAO;AACN,wBAAkB;AAAA;AAAA;AAAA,sBAGC,kBAA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AU,QAAA,CAAS,GAAG;AACrD;AAAA,EACD;AAEA,QAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,4BAKU,oBAAoB,YAAY,EAAE;AAAA;AAAA;AAAA;AAAA;AAM7D,QAAM,iBAAiB;AAAA,IACtB;AAAA,IACA;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,EAAA,CACA;AACF;AAEA,MAAM,+BAA+B,OACpC,YACG;AAOH,QAAM,UAAU,MAAM,QAAQ,QAAQ,WAAA;AAEtC,MAAI,CAAC,QAAQ,OAAO,WAAW;AAC9B;AAAA,EACD;AAEA,QAAM,QAAQ,IACb,QAAQ,OAAO,UAAU,IAAI,OAAO,cAAa;AAChD,UAAM,4BAA4B,EAAE,WAAW,GAAG,SAAS;AAAA,EAC5D,CAAC,CAAC;AAEJ;AAEO,MAAM,cAA8C,OAC1D,EAAE,qBAAqB,qBAAA,GACvB,YACG;AACH,oBACC,MAAM,QAAQ,WAAW;AAAA,IACxB,oBAAoB,EAAE,qBAAqB,sBAAsB;AAAA,IACjE,yBAAyB,OAAO;AAAA,IAChC,oBAAoB,OAAO;AAAA,IAC3B,yBAAyB,OAAO;AAAA,IAChC,mBAAmB,OAAO;AAAA,IAC1B,uBAAuB,OAAO;AAAA,IAC9B,sBAAsB,OAAO;AAAA,EAAA,CAC7B,CAAC;AAKH,QAAM,6BAA6B,OAAO;AAC3C;"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
+ const path = require("node:path");
26
+ const requireResolve = require("./requireResolve.cjs");
27
+ const getNextJSVersion = async () => {
28
+ const { readFile } = await import("node:fs/promises");
29
+ const packageJSONPath = requireResolve.requireResolve("next/package.json", path.join(process.cwd(), "package.json"));
30
+ const { version } = JSON.parse(await readFile(packageJSONPath, "utf8"));
31
+ return version;
32
+ };
33
+ exports.getNextJSVersion = getNextJSVersion;
34
+ //# sourceMappingURL=getNextJSVersion.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNextJSVersion.cjs","sources":["../../../src/lib/getNextJSVersion.ts"],"sourcesContent":["import { join } from \"node:path\";\n\nimport { requireResolve } from \"./requireResolve\";\n\nexport const getNextJSVersion = async (): Promise<string> => {\n\t// A dynamic import lets us easily mock the module.\n\tconst { readFile } = await import(\"node:fs/promises\");\n\n\tconst packageJSONPath = requireResolve(\n\t\t\"next/package.json\",\n\t\tjoin(process.cwd(), \"package.json\"),\n\t);\n\tconst { version } = JSON.parse(await readFile(packageJSONPath, \"utf8\"));\n\n\treturn version;\n};\n"],"names":["requireResolve","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,mBAAmB,YAA4B;AAE3D,QAAM,EAAE,SAAA,IAAa,MAAM,OAAO,kBAAkB;AAEpD,QAAM,kBAAkBA,eAAAA,eACvB,qBACAC,KAAAA,KAAK,QAAQ,IAAA,GAAO,cAAc,CAAC;AAEpC,QAAM,EAAE,YAAY,KAAK,MAAM,MAAM,SAAS,iBAAiB,MAAM,CAAC;AAEtE,SAAO;AACR;;"}
@@ -0,0 +1 @@
1
+ export declare const getNextJSVersion: () => Promise<string>;
@@ -0,0 +1,12 @@
1
+ import { join } from "node:path";
2
+ import { requireResolve } from "./requireResolve.js";
3
+ const getNextJSVersion = async () => {
4
+ const { readFile } = await import("node:fs/promises");
5
+ const packageJSONPath = requireResolve("next/package.json", join(process.cwd(), "package.json"));
6
+ const { version } = JSON.parse(await readFile(packageJSONPath, "utf8"));
7
+ return version;
8
+ };
9
+ export {
10
+ getNextJSVersion
11
+ };
12
+ //# sourceMappingURL=getNextJSVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNextJSVersion.js","sources":["../../../src/lib/getNextJSVersion.ts"],"sourcesContent":["import { join } from \"node:path\";\n\nimport { requireResolve } from \"./requireResolve\";\n\nexport const getNextJSVersion = async (): Promise<string> => {\n\t// A dynamic import lets us easily mock the module.\n\tconst { readFile } = await import(\"node:fs/promises\");\n\n\tconst packageJSONPath = requireResolve(\n\t\t\"next/package.json\",\n\t\tjoin(process.cwd(), \"package.json\"),\n\t);\n\tconst { version } = JSON.parse(await readFile(packageJSONPath, \"utf8\"));\n\n\treturn version;\n};\n"],"names":[],"mappings":";;AAIO,MAAM,mBAAmB,YAA4B;AAE3D,QAAM,EAAE,SAAA,IAAa,MAAM,OAAO,kBAAkB;AAEpD,QAAM,kBAAkB,eACvB,qBACA,KAAK,QAAQ,IAAA,GAAO,cAAc,CAAC;AAEpC,QAAM,EAAE,YAAY,KAAK,MAAM,MAAM,SAAS,iBAAiB,MAAM,CAAC;AAEtE,SAAO;AACR;"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const _module = require("node:module");
4
+ const requireResolve = (id, from) => {
5
+ let resolvedID = id;
6
+ if (process.versions.pnp && "findPnpApi" in _module && typeof _module.findPnpApi === "function") {
7
+ const pnpApi = _module.findPnpApi(from);
8
+ if (pnpApi) {
9
+ resolvedID = pnpApi.resolveRequest(id, from);
10
+ }
11
+ }
12
+ const require2 = _module.createRequire(from);
13
+ return require2.resolve(resolvedID);
14
+ };
15
+ exports.requireResolve = requireResolve;
16
+ //# sourceMappingURL=requireResolve.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireResolve.cjs","sources":["../../../src/lib/requireResolve.ts"],"sourcesContent":["import _module, { createRequire } from \"node:module\";\n\n/**\n * Resolves a module path with `createRequire().resolve()` with Yarn PnP\n * support.\n *\n * @param id - Module to resolve.\n * @param from - Location to resolve the module from.\n *\n * @returns - Resolved module path.\n */\nexport const requireResolve = (id: string, from: string): string => {\n\tlet resolvedID = id;\n\n\t// Support Yarn PnP\n\tif (\n\t\tprocess.versions.pnp &&\n\t\t\"findPnpApi\" in _module &&\n\t\ttypeof _module.findPnpApi === \"function\"\n\t) {\n\t\tconst pnpApi = _module.findPnpApi(from);\n\t\tif (pnpApi) {\n\t\t\tresolvedID = pnpApi.resolveRequest(id, from);\n\t\t}\n\t}\n\n\tconst require = createRequire(from);\n\n\treturn require.resolve(resolvedID);\n};\n"],"names":["require","createRequire"],"mappings":";;;AAWO,MAAM,iBAAiB,CAAC,IAAY,SAAwB;AAClE,MAAI,aAAa;AAGjB,MACC,QAAQ,SAAS,OACjB,gBAAgB,WAChB,OAAO,QAAQ,eAAe,YAC7B;AACD,UAAM,SAAS,QAAQ,WAAW,IAAI;AACtC,QAAI,QAAQ;AACX,mBAAa,OAAO,eAAe,IAAI,IAAI;AAAA,IAC5C;AAAA,EACD;AAEA,QAAMA,WAAUC,QAAAA,cAAc,IAAI;AAElC,SAAOD,SAAQ,QAAQ,UAAU;AAClC;;"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Resolves a module path with `createRequire().resolve()` with Yarn PnP
3
+ * support.
4
+ *
5
+ * @param id - Module to resolve.
6
+ * @param from - Location to resolve the module from.
7
+ *
8
+ * @returns - Resolved module path.
9
+ */
10
+ export declare const requireResolve: (id: string, from: string) => string;
@@ -0,0 +1,16 @@
1
+ import _module, { createRequire } from "node:module";
2
+ const requireResolve = (id, from) => {
3
+ let resolvedID = id;
4
+ if (process.versions.pnp && "findPnpApi" in _module && typeof _module.findPnpApi === "function") {
5
+ const pnpApi = _module.findPnpApi(from);
6
+ if (pnpApi) {
7
+ resolvedID = pnpApi.resolveRequest(id, from);
8
+ }
9
+ }
10
+ const require2 = createRequire(from);
11
+ return require2.resolve(resolvedID);
12
+ };
13
+ export {
14
+ requireResolve
15
+ };
16
+ //# sourceMappingURL=requireResolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireResolve.js","sources":["../../../src/lib/requireResolve.ts"],"sourcesContent":["import _module, { createRequire } from \"node:module\";\n\n/**\n * Resolves a module path with `createRequire().resolve()` with Yarn PnP\n * support.\n *\n * @param id - Module to resolve.\n * @param from - Location to resolve the module from.\n *\n * @returns - Resolved module path.\n */\nexport const requireResolve = (id: string, from: string): string => {\n\tlet resolvedID = id;\n\n\t// Support Yarn PnP\n\tif (\n\t\tprocess.versions.pnp &&\n\t\t\"findPnpApi\" in _module &&\n\t\ttypeof _module.findPnpApi === \"function\"\n\t) {\n\t\tconst pnpApi = _module.findPnpApi(from);\n\t\tif (pnpApi) {\n\t\t\tresolvedID = pnpApi.resolveRequest(id, from);\n\t\t}\n\t}\n\n\tconst require = createRequire(from);\n\n\treturn require.resolve(resolvedID);\n};\n"],"names":["require"],"mappings":";AAWO,MAAM,iBAAiB,CAAC,IAAY,SAAwB;AAClE,MAAI,aAAa;AAGjB,MACC,QAAQ,SAAS,OACjB,gBAAgB,WAChB,OAAO,QAAQ,eAAe,YAC7B;AACD,UAAM,SAAS,QAAQ,WAAW,IAAI;AACtC,QAAI,QAAQ;AACX,mBAAa,OAAO,eAAe,IAAI,IAAI;AAAA,IAC5C;AAAA,EACD;AAEA,QAAMA,WAAU,cAAc,IAAI;AAElC,SAAOA,SAAQ,QAAQ,UAAU;AAClC;"}
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const parseOptions = require("../internal/parse-options.cjs");
4
+ const re = require("../internal/re.cjs");
5
+ const cmp = require("../functions/cmp.cjs");
6
+ const debug = require("../internal/debug.cjs");
7
+ const semver = require("./semver.cjs");
8
+ const range = require("./range.cjs");
9
+ var comparator;
10
+ var hasRequiredComparator;
11
+ function requireComparator() {
12
+ if (hasRequiredComparator) return comparator;
13
+ hasRequiredComparator = 1;
14
+ const ANY = Symbol("SemVer ANY");
15
+ class Comparator {
16
+ static get ANY() {
17
+ return ANY;
18
+ }
19
+ constructor(comp, options) {
20
+ options = parseOptions$1(options);
21
+ if (comp instanceof Comparator) {
22
+ if (comp.loose === !!options.loose) {
23
+ return comp;
24
+ } else {
25
+ comp = comp.value;
26
+ }
27
+ }
28
+ debug$1("comparator", comp, options);
29
+ this.options = options;
30
+ this.loose = !!options.loose;
31
+ this.parse(comp);
32
+ if (this.semver === ANY) {
33
+ this.value = "";
34
+ } else {
35
+ this.value = this.operator + this.semver.version;
36
+ }
37
+ debug$1("comp", this);
38
+ }
39
+ parse(comp) {
40
+ const r = this.options.loose ? re$1[t.COMPARATORLOOSE] : re$1[t.COMPARATOR];
41
+ const m = comp.match(r);
42
+ if (!m) {
43
+ throw new TypeError(`Invalid comparator: ${comp}`);
44
+ }
45
+ this.operator = m[1] !== void 0 ? m[1] : "";
46
+ if (this.operator === "=") {
47
+ this.operator = "";
48
+ }
49
+ if (!m[2]) {
50
+ this.semver = ANY;
51
+ } else {
52
+ this.semver = new SemVer(m[2], this.options.loose);
53
+ }
54
+ }
55
+ toString() {
56
+ return this.value;
57
+ }
58
+ test(version) {
59
+ debug$1("Comparator.test", version, this.options.loose);
60
+ if (this.semver === ANY || version === ANY) {
61
+ return true;
62
+ }
63
+ if (typeof version === "string") {
64
+ try {
65
+ version = new SemVer(version, this.options);
66
+ } catch (er) {
67
+ return false;
68
+ }
69
+ }
70
+ return cmp$1(version, this.operator, this.semver, this.options);
71
+ }
72
+ intersects(comp, options) {
73
+ if (!(comp instanceof Comparator)) {
74
+ throw new TypeError("a Comparator is required");
75
+ }
76
+ if (this.operator === "") {
77
+ if (this.value === "") {
78
+ return true;
79
+ }
80
+ return new Range(comp.value, options).test(this.value);
81
+ } else if (comp.operator === "") {
82
+ if (comp.value === "") {
83
+ return true;
84
+ }
85
+ return new Range(this.value, options).test(comp.semver);
86
+ }
87
+ options = parseOptions$1(options);
88
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
89
+ return false;
90
+ }
91
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
92
+ return false;
93
+ }
94
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
95
+ return true;
96
+ }
97
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
98
+ return true;
99
+ }
100
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
101
+ return true;
102
+ }
103
+ if (cmp$1(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
104
+ return true;
105
+ }
106
+ if (cmp$1(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
107
+ return true;
108
+ }
109
+ return false;
110
+ }
111
+ }
112
+ comparator = Comparator;
113
+ const parseOptions$1 = parseOptions.parseOptions_1;
114
+ const { re: re$1, t } = re.reExports;
115
+ const cmp$1 = cmp.cmp_1;
116
+ const debug$1 = debug.debug_1;
117
+ const SemVer = semver.semver;
118
+ const Range = range.__require();
119
+ return comparator;
120
+ }
121
+ exports.__require = requireComparator;
122
+ //# sourceMappingURL=comparator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparator.cjs","sources":["../../../../../../node_modules/semver/classes/comparator.js"],"sourcesContent":["const ANY = Symbol('SemVer ANY')\n// hoisted class for cyclic dependency\nclass Comparator {\n static get ANY () {\n return ANY\n }\n\n constructor (comp, options) {\n options = parseOptions(options)\n\n if (comp instanceof Comparator) {\n if (comp.loose === !!options.loose) {\n return comp\n } else {\n comp = comp.value\n }\n }\n\n debug('comparator', comp, options)\n this.options = options\n this.loose = !!options.loose\n this.parse(comp)\n\n if (this.semver === ANY) {\n this.value = ''\n } else {\n this.value = this.operator + this.semver.version\n }\n\n debug('comp', this)\n }\n\n parse (comp) {\n const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]\n const m = comp.match(r)\n\n if (!m) {\n throw new TypeError(`Invalid comparator: ${comp}`)\n }\n\n this.operator = m[1] !== undefined ? m[1] : ''\n if (this.operator === '=') {\n this.operator = ''\n }\n\n // if it literally is just '>' or '' then allow anything.\n if (!m[2]) {\n this.semver = ANY\n } else {\n this.semver = new SemVer(m[2], this.options.loose)\n }\n }\n\n toString () {\n return this.value\n }\n\n test (version) {\n debug('Comparator.test', version, this.options.loose)\n\n if (this.semver === ANY || version === ANY) {\n return true\n }\n\n if (typeof version === 'string') {\n try {\n version = new SemVer(version, this.options)\n } catch (er) {\n return false\n }\n }\n\n return cmp(version, this.operator, this.semver, this.options)\n }\n\n intersects (comp, options) {\n if (!(comp instanceof Comparator)) {\n throw new TypeError('a Comparator is required')\n }\n\n if (this.operator === '') {\n if (this.value === '') {\n return true\n }\n return new Range(comp.value, options).test(this.value)\n } else if (comp.operator === '') {\n if (comp.value === '') {\n return true\n }\n return new Range(this.value, options).test(comp.semver)\n }\n\n options = parseOptions(options)\n\n // Special cases where nothing can possibly be lower\n if (options.includePrerelease &&\n (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {\n return false\n }\n if (!options.includePrerelease &&\n (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {\n return false\n }\n\n // Same direction increasing (> or >=)\n if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {\n return true\n }\n // Same direction decreasing (< or <=)\n if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {\n return true\n }\n // same SemVer and both sides are inclusive (<= or >=)\n if (\n (this.semver.version === comp.semver.version) &&\n this.operator.includes('=') && comp.operator.includes('=')) {\n return true\n }\n // opposite directions less than\n if (cmp(this.semver, '<', comp.semver, options) &&\n this.operator.startsWith('>') && comp.operator.startsWith('<')) {\n return true\n }\n // opposite directions greater than\n if (cmp(this.semver, '>', comp.semver, options) &&\n this.operator.startsWith('<') && comp.operator.startsWith('>')) {\n return true\n }\n return false\n }\n}\n\nmodule.exports = Comparator\n\nconst parseOptions = require('../internal/parse-options')\nconst { re, t } = require('../internal/re')\nconst cmp = require('../functions/cmp')\nconst debug = require('../internal/debug')\nconst SemVer = require('./semver')\nconst Range = require('./range')\n"],"names":["parseOptions","debug","re","cmp","require$$0","require$$1","require$$2","require$$3","require$$4","require$$5"],"mappings":";;;;;;;;;;;;;AAAA,QAAM,MAAM,OAAO,YAAY;AAAA,EAE/B,MAAM,WAAW;AAAA,IACf,WAAW,MAAO;AAChB,aAAO;AAAA,IACX;AAAA,IAEE,YAAa,MAAM,SAAS;AAC1B,gBAAUA,eAAa,OAAO;AAE9B,UAAI,gBAAgB,YAAY;AAC9B,YAAI,KAAK,UAAU,CAAC,CAAC,QAAQ,OAAO;AAClC,iBAAO;AAAA,QACf,OAAa;AACL,iBAAO,KAAK;AAAA,QACpB;AAAA,MACA;AAEIC,cAAM,cAAc,MAAM,OAAO;AACjC,WAAK,UAAU;AACf,WAAK,QAAQ,CAAC,CAAC,QAAQ;AACvB,WAAK,MAAM,IAAI;AAEf,UAAI,KAAK,WAAW,KAAK;AACvB,aAAK,QAAQ;AAAA,MACnB,OAAW;AACL,aAAK,QAAQ,KAAK,WAAW,KAAK,OAAO;AAAA,MAC/C;AAEIA,cAAM,QAAQ,IAAI;AAAA,IACtB;AAAA,IAEE,MAAO,MAAM;AACX,YAAM,IAAI,KAAK,QA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,OAAO,OAAO,EAAE,KAAK,KAAK,MAAM;AAAA,MAC5D;AAEI,gBAAUH,eAAa,OAAO;AAG9B,UAAI,QAAQ,sBACT,KAAK,UAAU,cAAc,KAAK,UAAU,aAAa;AAC1D,eAAO;AAAA,MACb;AACI,UAAI,CAAC,QAAQ,sBACV,KAAK,MAAM,WAAW,QAAQ,KAAK,KAAK,MAAM,WAAW,QAAQ,IAAI;AACtE,eAAO;AAAA,MACb;AAGI,UAAI,KAAK,SAAS,WAAW,GAAG,KAAK,KAAK,SAAS,WAAW,GAAG,GAAG;AAClE,eAAO;AAAA,MACb;AAEI,UAAI,KAAK,SAAS,WAAW,GAAG,KAAK,KAAK,SAAS,WAAW,GAAG,GAAG;AAClE,eAAO;AAAA,MACb;AAEI,UACG,KAAK,OAAO,YAAY,KAAK,OAAO,WACrC,KAAK,SAAS,SAAS,GAAG,KAAK,KAAK,SAAS,SAAS,GAAG,GAAG;AAC5D,eAAO;AAAA,MACb;AAEI,UAAIG,MAAI,KAAK,QAAQ,KAAK,KAAK,QAAQ,OAAO,KAC5C,KAAK,SAAS,WAAW,GAAG,KAAK,KAAK,SAAS,WAAW,GAAG,GAAG;AAChE,eAAO;AAAA,MACb;AAEI,UAAIA,MAAI,KAAK,QAAQ,KAAK,KAAK,QAAQ,OAAO,KAC5C,KAAK,SAAS,WAAW,GAAG,KAAK,KAAK,SAAS,WAAW,GAAG,GAAG;AAChE,eAAO;AAAA,MACb;AACI,aAAO;AAAA,IACX;AAAA;AAGA,eAAiB;AAEjB,QAAMH,iBAAeI,aAAAA;AACrB,QAAM,EAAA,IAAEF,MAAI,MAAMG,GAAAA;AAClB,QAAMF,QAAMG,IAAAA;AACZ,QAAML,UAAQM,MAAAA;AACd,QAAM,SAASC,OAAAA;AACf,QAAM,QAAQC,MAAAA,UAAA;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,122 @@
1
+ import { p as parseOptions_1 } from "../internal/parse-options.js";
2
+ import { r as reExports } from "../internal/re.js";
3
+ import { c as cmp_1 } from "../functions/cmp.js";
4
+ import { d as debug_1 } from "../internal/debug.js";
5
+ import { s as semver } from "./semver.js";
6
+ import { __require as requireRange } from "./range.js";
7
+ var comparator;
8
+ var hasRequiredComparator;
9
+ function requireComparator() {
10
+ if (hasRequiredComparator) return comparator;
11
+ hasRequiredComparator = 1;
12
+ const ANY = Symbol("SemVer ANY");
13
+ class Comparator {
14
+ static get ANY() {
15
+ return ANY;
16
+ }
17
+ constructor(comp, options) {
18
+ options = parseOptions(options);
19
+ if (comp instanceof Comparator) {
20
+ if (comp.loose === !!options.loose) {
21
+ return comp;
22
+ } else {
23
+ comp = comp.value;
24
+ }
25
+ }
26
+ debug("comparator", comp, options);
27
+ this.options = options;
28
+ this.loose = !!options.loose;
29
+ this.parse(comp);
30
+ if (this.semver === ANY) {
31
+ this.value = "";
32
+ } else {
33
+ this.value = this.operator + this.semver.version;
34
+ }
35
+ debug("comp", this);
36
+ }
37
+ parse(comp) {
38
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
39
+ const m = comp.match(r);
40
+ if (!m) {
41
+ throw new TypeError(`Invalid comparator: ${comp}`);
42
+ }
43
+ this.operator = m[1] !== void 0 ? m[1] : "";
44
+ if (this.operator === "=") {
45
+ this.operator = "";
46
+ }
47
+ if (!m[2]) {
48
+ this.semver = ANY;
49
+ } else {
50
+ this.semver = new SemVer(m[2], this.options.loose);
51
+ }
52
+ }
53
+ toString() {
54
+ return this.value;
55
+ }
56
+ test(version) {
57
+ debug("Comparator.test", version, this.options.loose);
58
+ if (this.semver === ANY || version === ANY) {
59
+ return true;
60
+ }
61
+ if (typeof version === "string") {
62
+ try {
63
+ version = new SemVer(version, this.options);
64
+ } catch (er) {
65
+ return false;
66
+ }
67
+ }
68
+ return cmp(version, this.operator, this.semver, this.options);
69
+ }
70
+ intersects(comp, options) {
71
+ if (!(comp instanceof Comparator)) {
72
+ throw new TypeError("a Comparator is required");
73
+ }
74
+ if (this.operator === "") {
75
+ if (this.value === "") {
76
+ return true;
77
+ }
78
+ return new Range(comp.value, options).test(this.value);
79
+ } else if (comp.operator === "") {
80
+ if (comp.value === "") {
81
+ return true;
82
+ }
83
+ return new Range(this.value, options).test(comp.semver);
84
+ }
85
+ options = parseOptions(options);
86
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
87
+ return false;
88
+ }
89
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
90
+ return false;
91
+ }
92
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
93
+ return true;
94
+ }
95
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
96
+ return true;
97
+ }
98
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
99
+ return true;
100
+ }
101
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
102
+ return true;
103
+ }
104
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
105
+ return true;
106
+ }
107
+ return false;
108
+ }
109
+ }
110
+ comparator = Comparator;
111
+ const parseOptions = parseOptions_1;
112
+ const { re, t } = reExports;
113
+ const cmp = cmp_1;
114
+ const debug = debug_1;
115
+ const SemVer = semver;
116
+ const Range = requireRange();
117
+ return comparator;
118
+ }
119
+ export {
120
+ requireComparator as __require
121
+ };
122
+ //# sourceMappingURL=comparator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparator.js","sources":["../../../../../../node_modules/semver/classes/comparator.js"],"sourcesContent":["const ANY = Symbol('SemVer ANY')\n// hoisted class for cyclic dependency\nclass Comparator {\n static get ANY () {\n return ANY\n }\n\n constructor (comp, options) {\n options = parseOptions(options)\n\n if (comp instanceof Comparator) {\n if (comp.loose === !!options.loose) {\n return comp\n } else {\n comp = comp.value\n }\n }\n\n debug('comparator', comp, options)\n this.options = options\n this.loose = !!options.loose\n this.parse(comp)\n\n if (this.semver === ANY) {\n this.value = ''\n } else {\n this.value = this.operator + this.semver.version\n }\n\n debug('comp', this)\n }\n\n parse (comp) {\n const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]\n const m = comp.match(r)\n\n if (!m) {\n throw new TypeError(`Invalid comparator: ${comp}`)\n }\n\n this.operator = m[1] !== undefined ? m[1] : ''\n if (this.operator === '=') {\n this.operator = ''\n }\n\n // if it literally is just '>' or '' then allow anything.\n if (!m[2]) {\n this.semver = ANY\n } else {\n this.semver = new SemVer(m[2], this.options.loose)\n }\n }\n\n toString () {\n return this.value\n }\n\n test (version) {\n debug('Comparator.test', version, this.options.loose)\n\n if (this.semver === ANY || version === ANY) {\n return true\n }\n\n if (typeof version === 'string') {\n try {\n version = new SemVer(version, this.options)\n } catch (er) {\n return false\n }\n }\n\n return cmp(version, this.operator, this.semver, this.options)\n }\n\n intersects (comp, options) {\n if (!(comp instanceof Comparator)) {\n throw new TypeError('a Comparator is required')\n }\n\n if (this.operator === '') {\n if (this.value === '') {\n return true\n }\n return new Range(comp.value, options).test(this.value)\n } else if (comp.operator === '') {\n if (comp.value === '') {\n return true\n }\n return new Range(this.value, options).test(comp.semver)\n }\n\n options = parseOptions(options)\n\n // Special cases where nothing can possibly be lower\n if (options.includePrerelease &&\n (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {\n return false\n }\n if (!options.includePrerelease &&\n (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {\n return false\n }\n\n // Same direction increasing (> or >=)\n if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {\n return true\n }\n // Same direction decreasing (< or <=)\n if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {\n return true\n }\n // same SemVer and both sides are inclusive (<= or >=)\n if (\n (this.semver.version === comp.semver.version) &&\n this.operator.includes('=') && comp.operator.includes('=')) {\n return true\n }\n // opposite directions less than\n if (cmp(this.semver, '<', comp.semver, options) &&\n this.operator.startsWith('>') && comp.operator.startsWith('<')) {\n return true\n }\n // opposite directions greater than\n if (cmp(this.semver, '>', comp.semver, options) &&\n this.operator.startsWith('<') && comp.operator.startsWith('>')) {\n return true\n }\n return false\n }\n}\n\nmodule.exports = Comparator\n\nconst parseOptions = require('../internal/parse-options')\nconst { re, t } = require('../internal/re')\nconst cmp = require('../functions/cmp')\nconst debug = require('../internal/debug')\nconst SemVer = require('./semver')\nconst Range = require('./range')\n"],"names":["require$$0","require$$1","require$$2","require$$3","require$$4","require$$5"],"mappings":";;;;;;;;;;;AAAA,QAAM,MAAM,OAAO,YAAY;AAAA,EAE/B,MAAM,WAAW;AAAA,IACf,WAAW,MAAO;AAChB,aAAO;AAAA,IACX;AAAA,IAEE,YAAa,MAAM,SAAS;AAC1B,gBAAU,aAAa,OAAO;AAE9B,UAAI,gBAAgB,YAAY;AAC9B,YAAI,KAAK,UAAU,CAAC,CAAC,QAAQ,OAAO;AAClC,iBAAO;AAAA,QACf,OAAa;AACL,iBAAO,KAAK;AAAA,QACpB;AAAA,MACA;AAEI,YAAM,cAAc,MAAM,OAAO;AACjC,WAAK,UAAU;AACf,WAAK,QAAQ,CAAC,CAAC,QAAQ;AACvB,WAAK,MAAM,IAAI;AAEf,UAAI,KAAK,WAAW,KAAK;AACvB,aAAK,QAAQ;AAAA,MACnB,OAAW;AACL,aAAK,QAAQ,KAAK,WAAW,KAAK,OAAO;AAAA,MAC/C;AAEI,YAAM,QAAQ,IAAI;AAAA,IACtB;AAAA,IAEE,MAAO,MAAM;AACX,YAAM,IAAI,KAAK,QAAQ,QAAQ,GAAG,EAAE,eAAe,IAAI,GAAG,EAAE,UAAU;AACtE,YAAM,IAAI,KAAK,MAAM,CAAC;AAEtB,UAAI,CAAC,GAAG;AACN,cAAM,IAAI,UAAU,uBAAuB,IAAI,EAAE;AAAA,MACvD;AAEI,WAAK,WAAW,EAAE,CAAC,MAAM,SAAY,EAAE,CAAC,IAAI;AAC5C,UAAI,KAAK,aAAa,KAAK;AACzB,a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