@slicemachine/adapter-nuxt 0.0.2-dev-plugins-m3.0

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 (343) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +98 -0
  3. package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs +41 -0
  4. package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -0
  5. package/dist/_node_modules/data-uri-to-buffer/dist/index.js +41 -0
  6. package/dist/_node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
  7. package/dist/_node_modules/fetch-blob/file.cjs +61 -0
  8. package/dist/_node_modules/fetch-blob/file.cjs.map +1 -0
  9. package/dist/_node_modules/fetch-blob/file.js +61 -0
  10. package/dist/_node_modules/fetch-blob/file.js.map +1 -0
  11. package/dist/_node_modules/fetch-blob/index.cjs +223 -0
  12. package/dist/_node_modules/fetch-blob/index.cjs.map +1 -0
  13. package/dist/_node_modules/fetch-blob/index.js +223 -0
  14. package/dist/_node_modules/fetch-blob/index.js.map +1 -0
  15. package/dist/_node_modules/fetch-blob/streams.cjs +43 -0
  16. package/dist/_node_modules/fetch-blob/streams.cjs.map +1 -0
  17. package/dist/_node_modules/fetch-blob/streams.js +42 -0
  18. package/dist/_node_modules/fetch-blob/streams.js.map +1 -0
  19. package/dist/_node_modules/formdata-polyfill/esm.min.cjs +116 -0
  20. package/dist/_node_modules/formdata-polyfill/esm.min.cjs.map +1 -0
  21. package/dist/_node_modules/formdata-polyfill/esm.min.js +116 -0
  22. package/dist/_node_modules/formdata-polyfill/esm.min.js.map +1 -0
  23. package/dist/_node_modules/node-domexception/index.cjs +11 -0
  24. package/dist/_node_modules/node-domexception/index.cjs.map +1 -0
  25. package/dist/_node_modules/node-domexception/index.js +10 -0
  26. package/dist/_node_modules/node-domexception/index.js.map +1 -0
  27. package/dist/_node_modules/node-fetch/src/body.cjs +262 -0
  28. package/dist/_node_modules/node-fetch/src/body.cjs.map +1 -0
  29. package/dist/_node_modules/node-fetch/src/body.js +262 -0
  30. package/dist/_node_modules/node-fetch/src/body.js.map +1 -0
  31. package/dist/_node_modules/node-fetch/src/errors/abort-error.cjs +10 -0
  32. package/dist/_node_modules/node-fetch/src/errors/abort-error.cjs.map +1 -0
  33. package/dist/_node_modules/node-fetch/src/errors/abort-error.js +10 -0
  34. package/dist/_node_modules/node-fetch/src/errors/abort-error.js.map +1 -0
  35. package/dist/_node_modules/node-fetch/src/errors/base.cjs +17 -0
  36. package/dist/_node_modules/node-fetch/src/errors/base.cjs.map +1 -0
  37. package/dist/_node_modules/node-fetch/src/errors/base.js +17 -0
  38. package/dist/_node_modules/node-fetch/src/errors/base.js.map +1 -0
  39. package/dist/_node_modules/node-fetch/src/errors/fetch-error.cjs +19 -0
  40. package/dist/_node_modules/node-fetch/src/errors/fetch-error.cjs.map +1 -0
  41. package/dist/_node_modules/node-fetch/src/errors/fetch-error.js +19 -0
  42. package/dist/_node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
  43. package/dist/_node_modules/node-fetch/src/headers.cjs +190 -0
  44. package/dist/_node_modules/node-fetch/src/headers.cjs.map +1 -0
  45. package/dist/_node_modules/node-fetch/src/headers.js +190 -0
  46. package/dist/_node_modules/node-fetch/src/headers.js.map +1 -0
  47. package/dist/_node_modules/node-fetch/src/index.cjs +292 -0
  48. package/dist/_node_modules/node-fetch/src/index.cjs.map +1 -0
  49. package/dist/_node_modules/node-fetch/src/index.js +292 -0
  50. package/dist/_node_modules/node-fetch/src/index.js.map +1 -0
  51. package/dist/_node_modules/node-fetch/src/request.cjs +206 -0
  52. package/dist/_node_modules/node-fetch/src/request.cjs.map +1 -0
  53. package/dist/_node_modules/node-fetch/src/request.js +206 -0
  54. package/dist/_node_modules/node-fetch/src/request.js.map +1 -0
  55. package/dist/_node_modules/node-fetch/src/response.cjs +122 -0
  56. package/dist/_node_modules/node-fetch/src/response.cjs.map +1 -0
  57. package/dist/_node_modules/node-fetch/src/response.js +123 -0
  58. package/dist/_node_modules/node-fetch/src/response.js.map +1 -0
  59. package/dist/_node_modules/node-fetch/src/utils/get-search.cjs +12 -0
  60. package/dist/_node_modules/node-fetch/src/utils/get-search.cjs.map +1 -0
  61. package/dist/_node_modules/node-fetch/src/utils/get-search.js +12 -0
  62. package/dist/_node_modules/node-fetch/src/utils/get-search.js.map +1 -0
  63. package/dist/_node_modules/node-fetch/src/utils/is-redirect.cjs +8 -0
  64. package/dist/_node_modules/node-fetch/src/utils/is-redirect.cjs.map +1 -0
  65. package/dist/_node_modules/node-fetch/src/utils/is-redirect.js +8 -0
  66. package/dist/_node_modules/node-fetch/src/utils/is-redirect.js.map +1 -0
  67. package/dist/_node_modules/node-fetch/src/utils/is.cjs +28 -0
  68. package/dist/_node_modules/node-fetch/src/utils/is.cjs.map +1 -0
  69. package/dist/_node_modules/node-fetch/src/utils/is.js +28 -0
  70. package/dist/_node_modules/node-fetch/src/utils/is.js.map +1 -0
  71. package/dist/_node_modules/node-fetch/src/utils/multipart-parser.cjs +356 -0
  72. package/dist/_node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -0
  73. package/dist/_node_modules/node-fetch/src/utils/multipart-parser.js +356 -0
  74. package/dist/_node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -0
  75. package/dist/_node_modules/node-fetch/src/utils/referrer.cjs +149 -0
  76. package/dist/_node_modules/node-fetch/src/utils/referrer.cjs.map +1 -0
  77. package/dist/_node_modules/node-fetch/src/utils/referrer.js +149 -0
  78. package/dist/_node_modules/node-fetch/src/utils/referrer.js.map +1 -0
  79. package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs +3822 -0
  80. package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -0
  81. package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js +3822 -0
  82. package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
  83. package/dist/_virtual/_commonjsHelpers.cjs +5 -0
  84. package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
  85. package/dist/_virtual/_commonjsHelpers.js +5 -0
  86. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  87. package/dist/_virtual/ponyfill.es2018.cjs +13 -0
  88. package/dist/_virtual/ponyfill.es2018.cjs.map +1 -0
  89. package/dist/_virtual/ponyfill.es2018.js +14 -0
  90. package/dist/_virtual/ponyfill.es2018.js.map +1 -0
  91. package/dist/constants.cjs +5 -0
  92. package/dist/constants.cjs.map +1 -0
  93. package/dist/constants.d.ts +4 -0
  94. package/dist/constants.js +5 -0
  95. package/dist/constants.js.map +1 -0
  96. package/dist/hooks/customType-asset-delete.cjs +31 -0
  97. package/dist/hooks/customType-asset-delete.cjs.map +1 -0
  98. package/dist/hooks/customType-asset-delete.d.ts +3 -0
  99. package/dist/hooks/customType-asset-delete.js +14 -0
  100. package/dist/hooks/customType-asset-delete.js.map +1 -0
  101. package/dist/hooks/customType-asset-read.cjs +34 -0
  102. package/dist/hooks/customType-asset-read.cjs.map +1 -0
  103. package/dist/hooks/customType-asset-read.d.ts +3 -0
  104. package/dist/hooks/customType-asset-read.js +17 -0
  105. package/dist/hooks/customType-asset-read.js.map +1 -0
  106. package/dist/hooks/customType-asset-update.cjs +34 -0
  107. package/dist/hooks/customType-asset-update.cjs.map +1 -0
  108. package/dist/hooks/customType-asset-update.d.ts +3 -0
  109. package/dist/hooks/customType-asset-update.js +16 -0
  110. package/dist/hooks/customType-asset-update.js.map +1 -0
  111. package/dist/hooks/customType-create.cjs +43 -0
  112. package/dist/hooks/customType-create.cjs.map +1 -0
  113. package/dist/hooks/customType-create.d.ts +3 -0
  114. package/dist/hooks/customType-create.js +25 -0
  115. package/dist/hooks/customType-create.js.map +1 -0
  116. package/dist/hooks/customType-delete.cjs +32 -0
  117. package/dist/hooks/customType-delete.cjs.map +1 -0
  118. package/dist/hooks/customType-delete.d.ts +3 -0
  119. package/dist/hooks/customType-delete.js +15 -0
  120. package/dist/hooks/customType-delete.js.map +1 -0
  121. package/dist/hooks/customType-read.cjs +31 -0
  122. package/dist/hooks/customType-read.cjs.map +1 -0
  123. package/dist/hooks/customType-read.d.ts +3 -0
  124. package/dist/hooks/customType-read.js +14 -0
  125. package/dist/hooks/customType-read.js.map +1 -0
  126. package/dist/hooks/customType-rename.cjs +6 -0
  127. package/dist/hooks/customType-rename.cjs.map +1 -0
  128. package/dist/hooks/customType-rename.d.ts +1 -0
  129. package/dist/hooks/customType-rename.js +6 -0
  130. package/dist/hooks/customType-rename.js.map +1 -0
  131. package/dist/hooks/customType-update.cjs +6 -0
  132. package/dist/hooks/customType-update.cjs.map +1 -0
  133. package/dist/hooks/customType-update.d.ts +1 -0
  134. package/dist/hooks/customType-update.js +6 -0
  135. package/dist/hooks/customType-update.js.map +1 -0
  136. package/dist/hooks/customTypeLibrary-read.cjs +53 -0
  137. package/dist/hooks/customTypeLibrary-read.cjs.map +1 -0
  138. package/dist/hooks/customTypeLibrary-read.d.ts +3 -0
  139. package/dist/hooks/customTypeLibrary-read.js +35 -0
  140. package/dist/hooks/customTypeLibrary-read.js.map +1 -0
  141. package/dist/hooks/project-init.cjs +112 -0
  142. package/dist/hooks/project-init.cjs.map +1 -0
  143. package/dist/hooks/project-init.d.ts +3 -0
  144. package/dist/hooks/project-init.js +94 -0
  145. package/dist/hooks/project-init.js.map +1 -0
  146. package/dist/hooks/slice-asset-delete.cjs +33 -0
  147. package/dist/hooks/slice-asset-delete.cjs.map +1 -0
  148. package/dist/hooks/slice-asset-delete.d.ts +3 -0
  149. package/dist/hooks/slice-asset-delete.js +16 -0
  150. package/dist/hooks/slice-asset-delete.js.map +1 -0
  151. package/dist/hooks/slice-asset-read.cjs +36 -0
  152. package/dist/hooks/slice-asset-read.cjs.map +1 -0
  153. package/dist/hooks/slice-asset-read.d.ts +3 -0
  154. package/dist/hooks/slice-asset-read.js +19 -0
  155. package/dist/hooks/slice-asset-read.js.map +1 -0
  156. package/dist/hooks/slice-asset-update.cjs +36 -0
  157. package/dist/hooks/slice-asset-update.cjs.map +1 -0
  158. package/dist/hooks/slice-asset-update.d.ts +3 -0
  159. package/dist/hooks/slice-asset-update.js +18 -0
  160. package/dist/hooks/slice-asset-update.js.map +1 -0
  161. package/dist/hooks/slice-create.cjs +77 -0
  162. package/dist/hooks/slice-create.cjs.map +1 -0
  163. package/dist/hooks/slice-create.d.ts +3 -0
  164. package/dist/hooks/slice-create.js +59 -0
  165. package/dist/hooks/slice-create.js.map +1 -0
  166. package/dist/hooks/slice-delete.cjs +41 -0
  167. package/dist/hooks/slice-delete.cjs.map +1 -0
  168. package/dist/hooks/slice-delete.d.ts +3 -0
  169. package/dist/hooks/slice-delete.js +24 -0
  170. package/dist/hooks/slice-delete.js.map +1 -0
  171. package/dist/hooks/slice-read.cjs +62 -0
  172. package/dist/hooks/slice-read.cjs.map +1 -0
  173. package/dist/hooks/slice-read.d.ts +3 -0
  174. package/dist/hooks/slice-read.js +44 -0
  175. package/dist/hooks/slice-read.js.map +1 -0
  176. package/dist/hooks/slice-rename.cjs +51 -0
  177. package/dist/hooks/slice-rename.cjs.map +1 -0
  178. package/dist/hooks/slice-rename.d.ts +3 -0
  179. package/dist/hooks/slice-rename.js +34 -0
  180. package/dist/hooks/slice-rename.js.map +1 -0
  181. package/dist/hooks/slice-update.cjs +14 -0
  182. package/dist/hooks/slice-update.cjs.map +1 -0
  183. package/dist/hooks/slice-update.d.ts +3 -0
  184. package/dist/hooks/slice-update.js +14 -0
  185. package/dist/hooks/slice-update.js.map +1 -0
  186. package/dist/hooks/sliceLibrary-read.cjs +52 -0
  187. package/dist/hooks/sliceLibrary-read.cjs.map +1 -0
  188. package/dist/hooks/sliceLibrary-read.d.ts +3 -0
  189. package/dist/hooks/sliceLibrary-read.js +34 -0
  190. package/dist/hooks/sliceLibrary-read.js.map +1 -0
  191. package/dist/hooks/sliceSimulator-setup-read.cjs +150 -0
  192. package/dist/hooks/sliceSimulator-setup-read.cjs.map +1 -0
  193. package/dist/hooks/sliceSimulator-setup-read.d.ts +3 -0
  194. package/dist/hooks/sliceSimulator-setup-read.js +150 -0
  195. package/dist/hooks/sliceSimulator-setup-read.js.map +1 -0
  196. package/dist/hooks/snippet-read.cjs +101 -0
  197. package/dist/hooks/snippet-read.cjs.map +1 -0
  198. package/dist/hooks/snippet-read.d.ts +3 -0
  199. package/dist/hooks/snippet-read.js +101 -0
  200. package/dist/hooks/snippet-read.js.map +1 -0
  201. package/dist/index.cjs +4 -0
  202. package/dist/index.cjs.map +1 -0
  203. package/dist/index.d.ts +3 -0
  204. package/dist/index.js +5 -0
  205. package/dist/index.js.map +1 -0
  206. package/dist/lib/buildCustomTypeAssetPath.cjs +29 -0
  207. package/dist/lib/buildCustomTypeAssetPath.cjs.map +1 -0
  208. package/dist/lib/buildCustomTypeAssetPath.d.ts +9 -0
  209. package/dist/lib/buildCustomTypeAssetPath.js +12 -0
  210. package/dist/lib/buildCustomTypeAssetPath.js.map +1 -0
  211. package/dist/lib/buildCustomTypeDirectoryPath.cjs +26 -0
  212. package/dist/lib/buildCustomTypeDirectoryPath.cjs.map +1 -0
  213. package/dist/lib/buildCustomTypeDirectoryPath.d.ts +8 -0
  214. package/dist/lib/buildCustomTypeDirectoryPath.js +9 -0
  215. package/dist/lib/buildCustomTypeDirectoryPath.js.map +1 -0
  216. package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs +7 -0
  217. package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs.map +1 -0
  218. package/dist/lib/buildCustomTypeLibraryDirectoryPath.d.ts +7 -0
  219. package/dist/lib/buildCustomTypeLibraryDirectoryPath.js +7 -0
  220. package/dist/lib/buildCustomTypeLibraryDirectoryPath.js.map +1 -0
  221. package/dist/lib/buildSliceAssetPath.cjs +34 -0
  222. package/dist/lib/buildSliceAssetPath.cjs.map +1 -0
  223. package/dist/lib/buildSliceAssetPath.d.ts +11 -0
  224. package/dist/lib/buildSliceAssetPath.js +17 -0
  225. package/dist/lib/buildSliceAssetPath.js.map +1 -0
  226. package/dist/lib/buildSliceDirectoryPath.cjs +30 -0
  227. package/dist/lib/buildSliceDirectoryPath.cjs.map +1 -0
  228. package/dist/lib/buildSliceDirectoryPath.d.ts +10 -0
  229. package/dist/lib/buildSliceDirectoryPath.js +13 -0
  230. package/dist/lib/buildSliceDirectoryPath.js.map +1 -0
  231. package/dist/lib/buildSliceLibraryDirectoryPath.cjs +7 -0
  232. package/dist/lib/buildSliceLibraryDirectoryPath.cjs.map +1 -0
  233. package/dist/lib/buildSliceLibraryDirectoryPath.d.ts +8 -0
  234. package/dist/lib/buildSliceLibraryDirectoryPath.js +7 -0
  235. package/dist/lib/buildSliceLibraryDirectoryPath.js.map +1 -0
  236. package/dist/lib/checkIsTypeScriptProject.cjs +9 -0
  237. package/dist/lib/checkIsTypeScriptProject.cjs.map +1 -0
  238. package/dist/lib/checkIsTypeScriptProject.d.ts +8 -0
  239. package/dist/lib/checkIsTypeScriptProject.js +9 -0
  240. package/dist/lib/checkIsTypeScriptProject.js.map +1 -0
  241. package/dist/lib/checkPathExists.cjs +30 -0
  242. package/dist/lib/checkPathExists.cjs.map +1 -0
  243. package/dist/lib/checkPathExists.d.ts +2 -0
  244. package/dist/lib/checkPathExists.js +13 -0
  245. package/dist/lib/checkPathExists.js.map +1 -0
  246. package/dist/lib/isSharedSliceModel.cjs +7 -0
  247. package/dist/lib/isSharedSliceModel.cjs.map +1 -0
  248. package/dist/lib/isSharedSliceModel.d.ts +335 -0
  249. package/dist/lib/isSharedSliceModel.js +7 -0
  250. package/dist/lib/isSharedSliceModel.js.map +1 -0
  251. package/dist/lib/pascalCase.cjs +8 -0
  252. package/dist/lib/pascalCase.cjs.map +1 -0
  253. package/dist/lib/pascalCase.d.ts +8 -0
  254. package/dist/lib/pascalCase.js +8 -0
  255. package/dist/lib/pascalCase.js.map +1 -0
  256. package/dist/lib/readJSONFile.cjs +26 -0
  257. package/dist/lib/readJSONFile.cjs.map +1 -0
  258. package/dist/lib/readJSONFile.d.ts +1 -0
  259. package/dist/lib/readJSONFile.js +9 -0
  260. package/dist/lib/readJSONFile.js.map +1 -0
  261. package/dist/lib/rejectIfNecessary.cjs +10 -0
  262. package/dist/lib/rejectIfNecessary.cjs.map +1 -0
  263. package/dist/lib/rejectIfNecessary.d.ts +1 -0
  264. package/dist/lib/rejectIfNecessary.js +10 -0
  265. package/dist/lib/rejectIfNecessary.js.map +1 -0
  266. package/dist/lib/updateSliceModelFile.cjs +33 -0
  267. package/dist/lib/updateSliceModelFile.cjs.map +1 -0
  268. package/dist/lib/updateSliceModelFile.d.ts +9 -0
  269. package/dist/lib/updateSliceModelFile.js +15 -0
  270. package/dist/lib/updateSliceModelFile.js.map +1 -0
  271. package/dist/lib/upsertGlobalContentTypes.cjs +55 -0
  272. package/dist/lib/upsertGlobalContentTypes.cjs.map +1 -0
  273. package/dist/lib/upsertGlobalContentTypes.d.ts +12 -0
  274. package/dist/lib/upsertGlobalContentTypes.js +37 -0
  275. package/dist/lib/upsertGlobalContentTypes.js.map +1 -0
  276. package/dist/lib/upsertSliceLibraryIndexFile.cjs +83 -0
  277. package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -0
  278. package/dist/lib/upsertSliceLibraryIndexFile.d.ts +7 -0
  279. package/dist/lib/upsertSliceLibraryIndexFile.js +65 -0
  280. package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -0
  281. package/dist/packages/adapter-nuxt/package.json.cjs +5 -0
  282. package/dist/packages/adapter-nuxt/package.json.cjs.map +1 -0
  283. package/dist/packages/adapter-nuxt/package.json.js +5 -0
  284. package/dist/packages/adapter-nuxt/package.json.js.map +1 -0
  285. package/dist/plugin.cjs +59 -0
  286. package/dist/plugin.cjs.map +1 -0
  287. package/dist/plugin.d.ts +2 -0
  288. package/dist/plugin.js +59 -0
  289. package/dist/plugin.js.map +1 -0
  290. package/dist/simulator/SliceSimulator.cjs +79 -0
  291. package/dist/simulator/SliceSimulator.cjs.map +1 -0
  292. package/dist/simulator/SliceSimulator.d.ts +34 -0
  293. package/dist/simulator/SliceSimulator.js +79 -0
  294. package/dist/simulator/SliceSimulator.js.map +1 -0
  295. package/dist/simulator/index.d.ts +2 -0
  296. package/dist/simulator.cjs +5 -0
  297. package/dist/simulator.cjs.map +1 -0
  298. package/dist/simulator.js +5 -0
  299. package/dist/simulator.js.map +1 -0
  300. package/dist/types.d.ts +5 -0
  301. package/package.json +107 -0
  302. package/src/constants.ts +5 -0
  303. package/src/hooks/customType-asset-delete.ts +18 -0
  304. package/src/hooks/customType-asset-read.ts +22 -0
  305. package/src/hooks/customType-asset-update.ts +20 -0
  306. package/src/hooks/customType-create.ts +45 -0
  307. package/src/hooks/customType-delete.ts +21 -0
  308. package/src/hooks/customType-read.ts +24 -0
  309. package/src/hooks/customType-rename.ts +3 -0
  310. package/src/hooks/customType-update.ts +3 -0
  311. package/src/hooks/customTypeLibrary-read.ts +53 -0
  312. package/src/hooks/project-init.ts +163 -0
  313. package/src/hooks/slice-asset-delete.ts +21 -0
  314. package/src/hooks/slice-asset-read.ts +25 -0
  315. package/src/hooks/slice-asset-update.ts +23 -0
  316. package/src/hooks/slice-create.ts +115 -0
  317. package/src/hooks/slice-delete.ts +41 -0
  318. package/src/hooks/slice-read.ts +69 -0
  319. package/src/hooks/slice-rename.ts +46 -0
  320. package/src/hooks/slice-update.ts +19 -0
  321. package/src/hooks/sliceLibrary-read.ts +48 -0
  322. package/src/hooks/sliceSimulator-setup-read.ts +209 -0
  323. package/src/hooks/snippet-read.ts +145 -0
  324. package/src/index.ts +4 -0
  325. package/src/lib/buildCustomTypeAssetPath.ts +24 -0
  326. package/src/lib/buildCustomTypeDirectoryPath.ts +20 -0
  327. package/src/lib/buildCustomTypeLibraryDirectoryPath.ts +13 -0
  328. package/src/lib/buildSliceAssetPath.ts +32 -0
  329. package/src/lib/buildSliceDirectoryPath.ts +26 -0
  330. package/src/lib/buildSliceLibraryDirectoryPath.ts +14 -0
  331. package/src/lib/checkIsTypeScriptProject.ts +17 -0
  332. package/src/lib/checkPathExists.ts +12 -0
  333. package/src/lib/isSharedSliceModel.ts +14 -0
  334. package/src/lib/pascalCase.ts +12 -0
  335. package/src/lib/readJSONFile.ts +7 -0
  336. package/src/lib/rejectIfNecessary.ts +16 -0
  337. package/src/lib/updateSliceModelFile.ts +33 -0
  338. package/src/lib/upsertGlobalContentTypes.ts +62 -0
  339. package/src/lib/upsertSliceLibraryIndexFile.ts +90 -0
  340. package/src/plugin.ts +63 -0
  341. package/src/simulator/SliceSimulator.ts +157 -0
  342. package/src/simulator/index.ts +2 -0
  343. package/src/types.ts +5 -0
package/package.json ADDED
@@ -0,0 +1,107 @@
1
+ {
2
+ "name": "@slicemachine/adapter-nuxt",
3
+ "version": "0.0.2-dev-plugins-m3.0",
4
+ "description": "Slice Machine adapter for Nuxt 3.",
5
+ "keywords": [
6
+ "typescript",
7
+ "prismic"
8
+ ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "ssh://git@github.com/prismicio/slice-machine.git",
12
+ "directory": "packages/adapter-nuxt"
13
+ },
14
+ "license": "Apache-2.0",
15
+ "author": "Prismic <contact@prismic.io> (https://prismic.io)",
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "require": "./dist/index.cjs",
20
+ "import": "./dist/index.js"
21
+ },
22
+ "./simulator": {
23
+ "require": "./dist/simulator.cjs",
24
+ "import": "./dist/simulator.js"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "main": "dist/index.cjs",
29
+ "module": "dist/index.js",
30
+ "types": "dist/index.d.ts",
31
+ "typesVersions": {
32
+ "*": {
33
+ "*": [
34
+ "dist/index.d.ts"
35
+ ],
36
+ "simulator": [
37
+ "dist/simulator/index.d.ts"
38
+ ]
39
+ }
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "src"
44
+ ],
45
+ "scripts": {
46
+ "build": "vite build",
47
+ "dev": "vite build --watch",
48
+ "format": "prettier --write .",
49
+ "lint": "eslint --ext .js,.ts .",
50
+ "prepublishOnly": "npm run build",
51
+ "size": "size-limit",
52
+ "test": "npm run lint && npm run types && npm run unit && npm run build && npm run size",
53
+ "types": "tsc --noEmit",
54
+ "unit": "vitest run --coverage",
55
+ "unit:watch": "vitest watch",
56
+ "depcheck": "depcheck --config=.depcheckrc",
57
+ "audit": "better-npm-audit audit -l high -p"
58
+ },
59
+ "dependencies": {
60
+ "@prismicio/slice-simulator-core": "^0.2.7",
61
+ "@prismicio/types-internal": "2.0.0-alpha.9",
62
+ "@slicemachine/plugin-kit": "0.1.8-dev-plugins-m3.0",
63
+ "common-tags": "^1.8.2",
64
+ "fs-extra": "^11.1.0",
65
+ "magicast": "^0.2.1",
66
+ "node-fetch": "^3.3.1",
67
+ "pascal-case": "^3.1.2",
68
+ "prismic-ts-codegen": "^0.1.5"
69
+ },
70
+ "devDependencies": {
71
+ "@prismicio/mock": "^0.2.0",
72
+ "@size-limit/preset-small-lib": "^8.2.4",
73
+ "@types/common-tags": "^1.8.1",
74
+ "@types/fs-extra": "^11.0.1",
75
+ "@types/prettier": "^2.7.2",
76
+ "@types/semver": "^7.3.13",
77
+ "@typescript-eslint/eslint-plugin": "^5.55.0",
78
+ "@typescript-eslint/parser": "^5.55.0",
79
+ "@vitest/coverage-c8": "^0.27.3",
80
+ "better-npm-audit": "^3.7.3",
81
+ "depcheck": "^1.4.3",
82
+ "eslint": "^8.37.0",
83
+ "eslint-config-prettier": "^8.7.0",
84
+ "eslint-plugin-prettier": "^4.2.1",
85
+ "eslint-plugin-tsdoc": "^0.2.17",
86
+ "nuxt": "^3.3.3",
87
+ "prettier": "^2.8.4",
88
+ "prettier-plugin-jsdoc": "^0.4.2",
89
+ "size-limit": "^8.2.4",
90
+ "ts-morph": "^17.0.1",
91
+ "typescript": "^4.9.5",
92
+ "vite": "^4.1.4",
93
+ "vite-plugin-sdk": "^0.1.1",
94
+ "vitest": "^0.27.3",
95
+ "vue": "^3.2.47"
96
+ },
97
+ "peerDependencies": {
98
+ "nuxt": "^3.0.0"
99
+ },
100
+ "engines": {
101
+ "node": ">=14.15.0"
102
+ },
103
+ "publishConfig": {
104
+ "access": "public"
105
+ },
106
+ "gitHead": "9223acb43eebf3f0e1731090b48c44ebd96f4aae"
107
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Banner text added to files that should not be edited by users.
3
+ */
4
+ export const NON_EDITABLE_FILE_BANNER =
5
+ "// Code generated by Slice Machine. DO NOT EDIT.";
@@ -0,0 +1,18 @@
1
+ import type { CustomTypeAssetDeleteHook } from "@slicemachine/plugin-kit";
2
+ import * as fs from "node:fs/promises";
3
+
4
+ import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath";
5
+
6
+ import type { PluginOptions } from "../types";
7
+
8
+ export const customTypeAssetDelete: CustomTypeAssetDeleteHook<
9
+ PluginOptions
10
+ > = async (data, context) => {
11
+ const filePath = buildCustomTypeAssetPath({
12
+ customTypeID: data.customTypeID,
13
+ assetID: data.assetID,
14
+ helpers: context.helpers,
15
+ });
16
+
17
+ await fs.rm(filePath);
18
+ };
@@ -0,0 +1,22 @@
1
+ import type { CustomTypeAssetReadHook } from "@slicemachine/plugin-kit";
2
+ import * as fs from "node:fs/promises";
3
+
4
+ import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath";
5
+
6
+ import type { PluginOptions } from "../types";
7
+
8
+ export const customTypeAssetRead: CustomTypeAssetReadHook<
9
+ PluginOptions
10
+ > = async (data, context) => {
11
+ const filePath = buildCustomTypeAssetPath({
12
+ customTypeID: data.customTypeID,
13
+ assetID: data.assetID,
14
+ helpers: context.helpers,
15
+ });
16
+
17
+ const assetData = await fs.readFile(filePath);
18
+
19
+ return {
20
+ data: assetData,
21
+ };
22
+ };
@@ -0,0 +1,20 @@
1
+ import type { CustomTypeAssetUpdateHook } from "@slicemachine/plugin-kit";
2
+ import * as fs from "node:fs/promises";
3
+ import * as path from "node:path";
4
+
5
+ import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath";
6
+
7
+ import type { PluginOptions } from "../types";
8
+
9
+ export const customTypeAssetUpdate: CustomTypeAssetUpdateHook<
10
+ PluginOptions
11
+ > = async (data, context) => {
12
+ const filePath = buildCustomTypeAssetPath({
13
+ customTypeID: data.customTypeID,
14
+ assetID: data.asset.id,
15
+ helpers: context.helpers,
16
+ });
17
+
18
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
19
+ await fs.writeFile(filePath, data.asset.data);
20
+ };
@@ -0,0 +1,45 @@
1
+ import type {
2
+ CustomTypeCreateHook,
3
+ CustomTypeCreateHookData,
4
+ SliceMachineContext,
5
+ } from "@slicemachine/plugin-kit";
6
+ import * as fs from "node:fs/promises";
7
+ import * as path from "node:path";
8
+
9
+ import { buildCustomTypeDirectoryPath } from "../lib/buildCustomTypeDirectoryPath";
10
+ import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
11
+
12
+ import type { PluginOptions } from "../types";
13
+
14
+ type Args = {
15
+ dir: string;
16
+ data: CustomTypeCreateHookData;
17
+ } & SliceMachineContext<PluginOptions>;
18
+
19
+ const createModelFile = async ({ dir, data, helpers, options }: Args) => {
20
+ const filePath = path.join(dir, "index.json");
21
+
22
+ let contents = JSON.stringify(data.model);
23
+
24
+ if (options.format) {
25
+ contents = await helpers.format(contents, filePath);
26
+ }
27
+
28
+ await fs.writeFile(filePath, contents);
29
+ };
30
+
31
+ export const customTypeCreate: CustomTypeCreateHook<PluginOptions> = async (
32
+ data,
33
+ context,
34
+ ) => {
35
+ const dir = buildCustomTypeDirectoryPath({
36
+ customTypeID: data.model.id,
37
+ helpers: context.helpers,
38
+ });
39
+
40
+ await fs.mkdir(dir, { recursive: true });
41
+
42
+ await createModelFile({ dir, data, ...context });
43
+
44
+ await upsertGlobalContentTypes(context);
45
+ };
@@ -0,0 +1,21 @@
1
+ import type { CustomTypeDeleteHook } from "@slicemachine/plugin-kit";
2
+ import * as fs from "node:fs/promises";
3
+
4
+ import { buildCustomTypeDirectoryPath } from "../lib/buildCustomTypeDirectoryPath";
5
+ import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
6
+
7
+ import type { PluginOptions } from "../types";
8
+
9
+ export const customTypeDelete: CustomTypeDeleteHook<PluginOptions> = async (
10
+ data,
11
+ context,
12
+ ) => {
13
+ const dir = buildCustomTypeDirectoryPath({
14
+ customTypeID: data.model.id,
15
+ helpers: context.helpers,
16
+ });
17
+
18
+ await fs.rm(dir, { recursive: true });
19
+
20
+ await upsertGlobalContentTypes(context);
21
+ };
@@ -0,0 +1,24 @@
1
+ import type { CustomTypeReadHook } from "@slicemachine/plugin-kit";
2
+ import type { CustomType } from "@prismicio/types-internal/lib/customtypes";
3
+ import * as path from "node:path";
4
+
5
+ import { buildCustomTypeDirectoryPath } from "../lib/buildCustomTypeDirectoryPath";
6
+ import { readJSONFile } from "../lib/readJSONFile";
7
+
8
+ import type { PluginOptions } from "../types";
9
+
10
+ export const customTypeRead: CustomTypeReadHook<PluginOptions> = async (
11
+ data,
12
+ { helpers },
13
+ ) => {
14
+ const filePath = path.join(
15
+ buildCustomTypeDirectoryPath({ customTypeID: data.id, helpers }),
16
+ "index.json",
17
+ );
18
+
19
+ const model = await readJSONFile<CustomType>(filePath);
20
+
21
+ return {
22
+ model,
23
+ };
24
+ };
@@ -0,0 +1,3 @@
1
+ import { customTypeCreate } from "./customType-create";
2
+
3
+ export const customTypeRename = customTypeCreate;
@@ -0,0 +1,3 @@
1
+ import { customTypeCreate } from "./customType-create";
2
+
3
+ export const customTypeUpdate = customTypeCreate;
@@ -0,0 +1,53 @@
1
+ import type { CustomTypeLibraryReadHook } from "@slicemachine/plugin-kit";
2
+ import type { CustomType } from "@prismicio/types-internal/lib/customtypes";
3
+ import * as fs from "node:fs/promises";
4
+ import * as path from "node:path";
5
+
6
+ import { buildCustomTypeLibraryDirectoryPath } from "../lib/buildCustomTypeLibraryDirectoryPath";
7
+ import { readJSONFile } from "../lib/readJSONFile";
8
+
9
+ import type { PluginOptions } from "../types";
10
+
11
+ const isCustomTypeModel = (
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ input: any,
14
+ ): input is CustomType => {
15
+ return typeof input === "object" && input !== null && "json" in input;
16
+ };
17
+
18
+ export const customTypeLibraryRead: CustomTypeLibraryReadHook<
19
+ PluginOptions
20
+ > = async (_data, { helpers }) => {
21
+ const dirPath = buildCustomTypeLibraryDirectoryPath({ helpers });
22
+
23
+ // Ensure the directory exists.
24
+ await fs.mkdir(dirPath, { recursive: true });
25
+
26
+ const childDirs = await fs.readdir(dirPath);
27
+
28
+ const ids: string[] = [];
29
+ await Promise.all(
30
+ childDirs.map(async (childDir) => {
31
+ const childDirContents = await fs.readdir(path.join(dirPath, childDir), {
32
+ withFileTypes: true,
33
+ });
34
+ const isCustomTypeDir = childDirContents.some((entry) => {
35
+ return entry.isFile() && entry.name === "index.json";
36
+ });
37
+
38
+ if (isCustomTypeDir) {
39
+ const modelPath = path.join(dirPath, childDir, "index.json");
40
+
41
+ const modelContents = await readJSONFile(modelPath);
42
+
43
+ if (isCustomTypeModel(modelContents)) {
44
+ ids.push(modelContents.id);
45
+ }
46
+ }
47
+ }),
48
+ );
49
+
50
+ return {
51
+ ids: ids.sort(),
52
+ };
53
+ };
@@ -0,0 +1,163 @@
1
+ import * as fs from "node:fs/promises";
2
+ import * as path from "node:path";
3
+ import type {
4
+ ProjectInitHook,
5
+ ProjectInitHookData,
6
+ SliceMachineContext,
7
+ } from "@slicemachine/plugin-kit";
8
+ import { stripIndent } from "common-tags";
9
+ import { loadFile, writeFile, type ASTNode } from "magicast";
10
+
11
+ import { checkPathExists } from "../lib/checkPathExists";
12
+ import { rejectIfNecessary } from "../lib/rejectIfNecessary";
13
+ import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
14
+
15
+ import type { PluginOptions } from "../types";
16
+
17
+ const NUXT_PRISMIC = "@nuxtjs/prismic";
18
+
19
+ type InstallDependenciesArgs = {
20
+ installDependencies: ProjectInitHookData["installDependencies"];
21
+ };
22
+
23
+ const installDependencies = async ({
24
+ installDependencies,
25
+ }: InstallDependenciesArgs) => {
26
+ try {
27
+ await installDependencies({
28
+ dependencies: {
29
+ [NUXT_PRISMIC]: "^3.0.0",
30
+ },
31
+ dev: true,
32
+ });
33
+ } catch (error) {
34
+ // TODO: Remove when latest is published and documented
35
+ // Fallback to RC if latest is still not available
36
+ await installDependencies({
37
+ dependencies: {
38
+ [NUXT_PRISMIC]: "rc",
39
+ },
40
+ dev: true,
41
+ });
42
+ }
43
+ };
44
+
45
+ type ConfigurePrismicModuleArgs = SliceMachineContext<PluginOptions>;
46
+
47
+ const configurePrismicModule = async ({
48
+ helpers,
49
+ project,
50
+ }: ConfigurePrismicModuleArgs) => {
51
+ let nuxtConfigPath = helpers.joinPathFromRoot("nuxt.config.js");
52
+
53
+ if (!(await checkPathExists(nuxtConfigPath))) {
54
+ nuxtConfigPath = helpers.joinPathFromRoot("nuxt.config.ts");
55
+
56
+ // nuxt.config.* not found
57
+ if (!(await checkPathExists(nuxtConfigPath))) {
58
+ return;
59
+ }
60
+ }
61
+
62
+ const mod = await loadFile(nuxtConfigPath);
63
+ const config =
64
+ mod.exports.default.$type === "function-call"
65
+ ? mod.exports.default.$args[0]
66
+ : mod.exports.default;
67
+
68
+ // Register Prismic module
69
+ let hasInlinedConfiguration = false;
70
+ const hasPrismicModuleRegistered = (config.modules || []).find(
71
+ (registration: string | [string, unknown]) => {
72
+ if (typeof registration === "string") {
73
+ return registration === NUXT_PRISMIC;
74
+ } else if (Array.isArray(registration)) {
75
+ hasInlinedConfiguration = !!registration[1];
76
+
77
+ return registration[0] === NUXT_PRISMIC;
78
+ }
79
+
80
+ return false;
81
+ },
82
+ );
83
+
84
+ if (!hasPrismicModuleRegistered) {
85
+ config.modules ||= [];
86
+ config.modules.push(NUXT_PRISMIC);
87
+ }
88
+
89
+ // Append Prismic module configuration
90
+ const endpoint = project.config.repositoryName;
91
+ if (!hasInlinedConfiguration) {
92
+ config.prismic ||= {};
93
+ config.prismic.endpoint = endpoint;
94
+ }
95
+
96
+ await writeFile(mod as unknown as ASTNode, nuxtConfigPath);
97
+ };
98
+
99
+ type CreateSliceSimulatorPageArgs = SliceMachineContext<PluginOptions>;
100
+
101
+ const createSliceSimulatorPage = async ({
102
+ helpers,
103
+ options,
104
+ }: CreateSliceSimulatorPageArgs) => {
105
+ const isTypeScriptProject = await checkIsTypeScriptProject({
106
+ helpers,
107
+ options,
108
+ });
109
+
110
+ const srcPagesDirectoryExists = await checkPathExists(
111
+ helpers.joinPathFromRoot("src/pages"),
112
+ );
113
+
114
+ const filePath = helpers.joinPathFromRoot(
115
+ srcPagesDirectoryExists ? "src/pages" : "pages",
116
+ "slice-simulator.vue",
117
+ );
118
+
119
+ if (await checkPathExists(filePath)) {
120
+ return;
121
+ }
122
+
123
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
124
+
125
+ const scriptAttributes = ["setup"];
126
+ if (isTypeScriptProject) {
127
+ scriptAttributes.push('lang="ts"');
128
+ }
129
+
130
+ let contents = stripIndent`
131
+ <template>
132
+ <SliceSimulator #default="{ slices }">
133
+ <SliceZone :slices="slices" :components="components" />
134
+ </SliceSimulator>
135
+ </template>
136
+
137
+ <script ${scriptAttributes.join(" ")}>
138
+ import { SliceSimulator } from "@slicemachine/adapter-nuxt/simulator";
139
+ import { components } from "~/slices";
140
+ </script>
141
+ `;
142
+
143
+ if (options.format) {
144
+ contents = await helpers.format(contents, filePath, {
145
+ prettier: { parser: "vue" },
146
+ });
147
+ }
148
+
149
+ await fs.writeFile(filePath, contents);
150
+ };
151
+
152
+ export const projectInit: ProjectInitHook<PluginOptions> = async (
153
+ { installDependencies: _installDependencies },
154
+ context,
155
+ ) => {
156
+ rejectIfNecessary(
157
+ await Promise.allSettled([
158
+ await installDependencies({ installDependencies: _installDependencies }),
159
+ await configurePrismicModule(context),
160
+ await createSliceSimulatorPage(context),
161
+ ]),
162
+ );
163
+ };
@@ -0,0 +1,21 @@
1
+ import type { SliceAssetDeleteHook } from "@slicemachine/plugin-kit";
2
+ import * as fs from "node:fs/promises";
3
+
4
+ import { buildSliceAssetPath } from "../lib/buildSliceAssetPath";
5
+
6
+ import type { PluginOptions } from "../types";
7
+
8
+ export const sliceAssetDelete: SliceAssetDeleteHook<PluginOptions> = async (
9
+ data,
10
+ context,
11
+ ) => {
12
+ const filePath = await buildSliceAssetPath({
13
+ libraryID: data.libraryID,
14
+ sliceID: data.sliceID,
15
+ assetID: data.assetID,
16
+ helpers: context.helpers,
17
+ actions: context.actions,
18
+ });
19
+
20
+ await fs.rm(filePath);
21
+ };
@@ -0,0 +1,25 @@
1
+ import type { SliceAssetReadHook } from "@slicemachine/plugin-kit";
2
+ import * as fs from "node:fs/promises";
3
+
4
+ import { buildSliceAssetPath } from "../lib/buildSliceAssetPath";
5
+
6
+ import type { PluginOptions } from "../types";
7
+
8
+ export const sliceAssetRead: SliceAssetReadHook<PluginOptions> = async (
9
+ data,
10
+ context,
11
+ ) => {
12
+ const filePath = await buildSliceAssetPath({
13
+ libraryID: data.libraryID,
14
+ sliceID: data.sliceID,
15
+ assetID: data.assetID,
16
+ helpers: context.helpers,
17
+ actions: context.actions,
18
+ });
19
+
20
+ const assetData = await fs.readFile(filePath);
21
+
22
+ return {
23
+ data: assetData,
24
+ };
25
+ };
@@ -0,0 +1,23 @@
1
+ import type { SliceAssetUpdateHook } from "@slicemachine/plugin-kit";
2
+ import * as fs from "node:fs/promises";
3
+ import * as path from "node:path";
4
+
5
+ import { buildSliceAssetPath } from "../lib/buildSliceAssetPath";
6
+
7
+ import type { PluginOptions } from "../types";
8
+
9
+ export const sliceAssetUpdate: SliceAssetUpdateHook<PluginOptions> = async (
10
+ data,
11
+ context,
12
+ ) => {
13
+ const filePath = await buildSliceAssetPath({
14
+ libraryID: data.libraryID,
15
+ sliceID: data.sliceID,
16
+ assetID: data.asset.id,
17
+ helpers: context.helpers,
18
+ actions: context.actions,
19
+ });
20
+
21
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
22
+ await fs.writeFile(filePath, data.asset.data);
23
+ };
@@ -0,0 +1,115 @@
1
+ import type {
2
+ SliceCreateHook,
3
+ SliceCreateHookData,
4
+ SliceMachineContext,
5
+ } from "@slicemachine/plugin-kit";
6
+ import { stripIndent } from "common-tags";
7
+ import * as fs from "node:fs/promises";
8
+ import * as path from "node:path";
9
+
10
+ import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath";
11
+ import { rejectIfNecessary } from "../lib/rejectIfNecessary";
12
+ import { updateSliceModelFile } from "../lib/updateSliceModelFile";
13
+ import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
14
+ import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile";
15
+ import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
16
+ import { pascalCase } from "../lib/pascalCase";
17
+
18
+ import type { PluginOptions } from "../types";
19
+
20
+ type Args = {
21
+ dir: string;
22
+ data: SliceCreateHookData;
23
+ } & SliceMachineContext<PluginOptions>;
24
+
25
+ const createComponentFile = async ({ dir, data, helpers, options }: Args) => {
26
+ const filePath = path.join(dir, "index.vue");
27
+ const model = data.model;
28
+ const pascalName = pascalCase(model.name);
29
+
30
+ let contents: string;
31
+
32
+ const isTypeScriptProject = await checkIsTypeScriptProject({
33
+ helpers,
34
+ options,
35
+ });
36
+
37
+ if (isTypeScriptProject) {
38
+ contents = stripIndent`
39
+ <template>
40
+ <section
41
+ :data-slice-type="slice.slice_type"
42
+ :data-slice-variation="slice.variation"
43
+ >
44
+ Placeholder component for ${model.id} (variation: {{ slice.variation }}) Slices
45
+ </section>
46
+ </template>
47
+
48
+ <script setup lang="ts">
49
+ import { Content } from "@prismicio/client";
50
+
51
+ // The array passed to \`getSliceComponentProps\` is purely optional.
52
+ // Consider it as a visual hint for you when templating your slice.
53
+ defineProps(getSliceComponentProps<Content.${pascalName}Slice>(
54
+ ["slice", "index", "slices", "context"]
55
+ ));
56
+ </script>
57
+ `;
58
+ } else {
59
+ contents = stripIndent`
60
+ <template>
61
+ <section
62
+ :data-slice-type="slice.slice_type"
63
+ :data-slice-variation="slice.variation"
64
+ >
65
+ Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices
66
+ </section>
67
+ </template>
68
+
69
+ <script setup>
70
+ // The array passed to \`getSliceComponentProps\` is purely optional.
71
+ // Consider it as a visual hint for you when templating your slice.
72
+ defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
73
+ </script>
74
+ `;
75
+ }
76
+
77
+ if (options.format) {
78
+ contents = await helpers.format(contents, filePath, {
79
+ prettier: { parser: "vue" },
80
+ });
81
+ }
82
+
83
+ await fs.writeFile(filePath, contents);
84
+ };
85
+
86
+ export const sliceCreate: SliceCreateHook<PluginOptions> = async (
87
+ data,
88
+ context,
89
+ ) => {
90
+ const dir = buildSliceDirectoryPath({
91
+ libraryID: data.libraryID,
92
+ model: data.model,
93
+ helpers: context.helpers,
94
+ });
95
+
96
+ await fs.mkdir(dir, { recursive: true });
97
+
98
+ rejectIfNecessary(
99
+ await Promise.allSettled([
100
+ updateSliceModelFile({
101
+ libraryID: data.libraryID,
102
+ model: data.model,
103
+ ...context,
104
+ }),
105
+ createComponentFile({ dir, data, ...context }),
106
+ ]),
107
+ );
108
+
109
+ rejectIfNecessary(
110
+ await Promise.allSettled([
111
+ upsertGlobalContentTypes(context),
112
+ upsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),
113
+ ]),
114
+ );
115
+ };