@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
@@ -0,0 +1,14 @@
1
+ import { SliceMachineContext } from "@slicemachine/plugin-kit";
2
+
3
+ import { PluginOptions } from "../types";
4
+
5
+ type BuildSliceLibraryDirectoryPathArgs = {
6
+ libraryID: string;
7
+ helpers: SliceMachineContext<PluginOptions>["helpers"];
8
+ };
9
+
10
+ export const buildSliceLibraryDirectoryPath = (
11
+ args: BuildSliceLibraryDirectoryPathArgs,
12
+ ): string => {
13
+ return args.helpers.joinPathFromRoot(args.libraryID);
14
+ };
@@ -0,0 +1,17 @@
1
+ import { SliceMachineContext } from "@slicemachine/plugin-kit";
2
+
3
+ import { PluginOptions } from "../types";
4
+ import { checkPathExists } from "./checkPathExists";
5
+
6
+ type CheckIsTypeScriptProjectArgs = {
7
+ helpers: SliceMachineContext<PluginOptions>["helpers"];
8
+ options: SliceMachineContext<PluginOptions>["options"];
9
+ };
10
+
11
+ export const checkIsTypeScriptProject = async (
12
+ args: CheckIsTypeScriptProjectArgs,
13
+ ): Promise<boolean> => {
14
+ const tsConfigPath = args.helpers.joinPathFromRoot("tsconfig.json");
15
+
16
+ return args.options.typescript ?? (await checkPathExists(tsConfigPath));
17
+ };
@@ -0,0 +1,12 @@
1
+ import * as fs from "node:fs/promises";
2
+ import { PathLike } from "node:fs";
3
+
4
+ export const checkPathExists = async (path: PathLike): Promise<boolean> => {
5
+ try {
6
+ await fs.access(path);
7
+
8
+ return true;
9
+ } catch {
10
+ return false;
11
+ }
12
+ };
@@ -0,0 +1,14 @@
1
+ import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
+
3
+ export const isSharedSliceModel = (
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
5
+ input: any,
6
+ ): input is SharedSlice => {
7
+ return (
8
+ typeof input === "object" &&
9
+ input !== null &&
10
+ "type" in input &&
11
+ input.type === "SharedSlice" &&
12
+ typeof input.id === "string"
13
+ );
14
+ };
@@ -0,0 +1,12 @@
1
+ import { pascalCase as basePascalCase } from "pascal-case";
2
+
3
+ /**
4
+ * Converts a string to a Pascal cased string.
5
+ *
6
+ * @param input - String to convert into a Pascal cased string.
7
+ *
8
+ * @returns Pascal cased string version of `input`.
9
+ */
10
+ export const pascalCase = (...input: (string | undefined)[]): string => {
11
+ return basePascalCase(input.filter(Boolean).join(" "));
12
+ };
@@ -0,0 +1,7 @@
1
+ import * as fs from "node:fs/promises";
2
+
3
+ export const readJSONFile = async <T = unknown>(path: string): Promise<T> => {
4
+ const contents = await fs.readFile(path, "utf8");
5
+
6
+ return JSON.parse(contents);
7
+ };
@@ -0,0 +1,16 @@
1
+ export const rejectIfNecessary = <
2
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
+ TPromiseSettledResults extends readonly PromiseSettledResult<any>[],
4
+ >(
5
+ promiseSettledResults: TPromiseSettledResults,
6
+ ): void => {
7
+ const rejectedReasons = promiseSettledResults
8
+ .filter(
9
+ (result): result is PromiseRejectedResult => result.status === "rejected",
10
+ )
11
+ .map((result) => result.reason);
12
+
13
+ if (rejectedReasons.length > 0) {
14
+ throw rejectedReasons[0];
15
+ }
16
+ };
@@ -0,0 +1,33 @@
1
+ import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
+ import { SliceMachineContext } from "@slicemachine/plugin-kit";
3
+ import * as fs from "node:fs/promises";
4
+ import * as path from "node:path";
5
+
6
+ import type { PluginOptions } from "../types";
7
+
8
+ import { buildSliceDirectoryPath } from "./buildSliceDirectoryPath";
9
+
10
+ type UpdateSliceModelFileArgs = {
11
+ libraryID: string;
12
+ model: SharedSlice;
13
+ } & SliceMachineContext<PluginOptions>;
14
+
15
+ export const updateSliceModelFile = async ({
16
+ libraryID,
17
+ model,
18
+ helpers,
19
+ options,
20
+ }: UpdateSliceModelFileArgs): Promise<void> => {
21
+ const filePath = path.join(
22
+ buildSliceDirectoryPath({ libraryID, model, helpers }),
23
+ "model.json",
24
+ );
25
+
26
+ let contents = JSON.stringify(model);
27
+
28
+ if (options.format) {
29
+ contents = await helpers.format(contents, filePath);
30
+ }
31
+
32
+ await fs.writeFile(filePath, contents);
33
+ };
@@ -0,0 +1,62 @@
1
+ import type { SliceMachineContext } from "@slicemachine/plugin-kit";
2
+ import { generateTypes } from "prismic-ts-codegen";
3
+ import * as fs from "node:fs/promises";
4
+ import * as path from "node:path";
5
+
6
+ import type { PluginOptions } from "../types";
7
+ import { NON_EDITABLE_FILE_BANNER } from "../constants";
8
+
9
+ /**
10
+ * Arguments for `upsertGlobalContentTypes()`.
11
+ */
12
+ type UpsertGlobalTypesArgs = Pick<
13
+ SliceMachineContext<PluginOptions>,
14
+ "actions" | "helpers" | "options"
15
+ >;
16
+
17
+ /**
18
+ * Creates a globally accessible TypeScript file containing types representing
19
+ * the Prismic repository's content.
20
+ */
21
+ export const upsertGlobalContentTypes = async ({
22
+ actions,
23
+ helpers,
24
+ options,
25
+ }: UpsertGlobalTypesArgs): Promise<void> => {
26
+ const filePath = helpers.joinPathFromRoot("prismicio.d.ts");
27
+
28
+ const [customTypeModelDescriptors, sharedSliceModelDescriptors] =
29
+ await Promise.all([
30
+ actions.readAllCustomTypeModels(),
31
+ actions.readAllSliceModels(),
32
+ ]);
33
+
34
+ const customTypeModels = customTypeModelDescriptors.map(
35
+ (customTypeModelDescriptors) => {
36
+ return customTypeModelDescriptors.model;
37
+ },
38
+ );
39
+ const sharedSliceModels = sharedSliceModelDescriptors.map(
40
+ (sharedSliceModelDescriptors) => {
41
+ return sharedSliceModelDescriptors.model;
42
+ },
43
+ );
44
+
45
+ let contents = generateTypes({
46
+ customTypeModels,
47
+ sharedSliceModels,
48
+ clientIntegration: {
49
+ includeCreateClientInterface: true,
50
+ includeContentNamespace: true,
51
+ },
52
+ });
53
+
54
+ contents = `${NON_EDITABLE_FILE_BANNER}\n\n${contents}`;
55
+
56
+ if (options.format) {
57
+ contents = await helpers.format(contents, filePath);
58
+ }
59
+
60
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
61
+ await fs.writeFile(filePath, contents);
62
+ };
@@ -0,0 +1,90 @@
1
+ import { SliceMachineContext } from "@slicemachine/plugin-kit";
2
+ import { stripIndent } from "common-tags";
3
+ import * as fs from "node:fs/promises";
4
+ import * as path from "node:path";
5
+ import { NON_EDITABLE_FILE_BANNER } from "../constants";
6
+
7
+ import { PluginOptions } from "../types";
8
+
9
+ import { checkIsTypeScriptProject } from "./checkIsTypeScriptProject";
10
+ import { pascalCase } from "./pascalCase";
11
+ import { buildSliceLibraryDirectoryPath } from "./buildSliceLibraryDirectoryPath";
12
+
13
+ type UpsertSliceLibraryIndexFileArgs = {
14
+ libraryID: string;
15
+ } & SliceMachineContext<PluginOptions>;
16
+
17
+ export const upsertSliceLibraryIndexFile = async (
18
+ args: UpsertSliceLibraryIndexFileArgs,
19
+ ): Promise<void> => {
20
+ const isTypeScriptProject = await checkIsTypeScriptProject({
21
+ helpers: args.helpers,
22
+ options: args.options,
23
+ });
24
+
25
+ const filePath = path.join(
26
+ buildSliceLibraryDirectoryPath({
27
+ libraryID: args.libraryID,
28
+ helpers: args.helpers,
29
+ }),
30
+ isTypeScriptProject ? "index.ts" : "index.js",
31
+ );
32
+
33
+ const slices = await args.actions.readAllSliceModelsForLibrary({
34
+ libraryID: args.libraryID,
35
+ });
36
+
37
+ let contents: string;
38
+
39
+ if (args.options.lazyLoadSlices) {
40
+ contents = stripIndent`
41
+ ${NON_EDITABLE_FILE_BANNER}
42
+
43
+ import { defineAsyncComponent } from "vue";
44
+ import { defineSliceZoneComponents } from "@prismicio/vue";
45
+
46
+ export const components = defineSliceZoneComponents({
47
+ ${slices
48
+ .map((slice) => {
49
+ const id = slice.model.id;
50
+ const dirName = pascalCase(slice.model.name);
51
+
52
+ return `${id}: defineAsyncComponent(() => import("./${dirName}/index.vue"))`;
53
+ })
54
+ .join(",\n")}
55
+ });
56
+ `;
57
+ } else {
58
+ contents = stripIndent`
59
+ ${NON_EDITABLE_FILE_BANNER}
60
+
61
+ import { defineSliceZoneComponents } from "@prismicio/vue";
62
+
63
+ ${slices
64
+ .map((slice) => {
65
+ const componentName = pascalCase(slice.model.name);
66
+ const dirName = pascalCase(slice.model.name);
67
+
68
+ return `import ${componentName} from "./${dirName}/index.vue";`;
69
+ })
70
+ .join("\n")}
71
+
72
+ export const components = defineSliceZoneComponents({
73
+ ${slices
74
+ .map((slice) => {
75
+ const id = slice.model.id;
76
+ const componentName = pascalCase(slice.model.name);
77
+
78
+ return `${id}: ${componentName}`;
79
+ })
80
+ .join(",\n")}
81
+ });
82
+ `;
83
+ }
84
+
85
+ if (args.options.format) {
86
+ contents = await args.helpers.format(contents, filePath);
87
+ }
88
+
89
+ await fs.writeFile(filePath, contents);
90
+ };
package/src/plugin.ts ADDED
@@ -0,0 +1,63 @@
1
+ import { defineSliceMachinePlugin } from "@slicemachine/plugin-kit";
2
+
3
+ import { name as pkgName } from "../package.json";
4
+ import { PluginOptions } from "./types";
5
+
6
+ import { projectInit } from "./hooks/project-init";
7
+ import { customTypeAssetDelete } from "./hooks/customType-asset-delete";
8
+ import { customTypeAssetRead } from "./hooks/customType-asset-read";
9
+ import { customTypeAssetUpdate } from "./hooks/customType-asset-update";
10
+ import { customTypeCreate } from "./hooks/customType-create";
11
+ import { customTypeDelete } from "./hooks/customType-delete";
12
+ import { customTypeLibraryRead } from "./hooks/customTypeLibrary-read";
13
+ import { customTypeRead } from "./hooks/customType-read";
14
+ import { customTypeRename } from "./hooks/customType-rename";
15
+ import { customTypeUpdate } from "./hooks/customType-update";
16
+ import { sliceAssetDelete } from "./hooks/slice-asset-delete";
17
+ import { sliceAssetRead } from "./hooks/slice-asset-read";
18
+ import { sliceAssetUpdate } from "./hooks/slice-asset-update";
19
+ import { sliceCreate } from "./hooks/slice-create";
20
+ import { sliceDelete } from "./hooks/slice-delete";
21
+ import { sliceLibraryRead } from "./hooks/sliceLibrary-read";
22
+ import { sliceRead } from "./hooks/slice-read";
23
+ import { sliceRename } from "./hooks/slice-rename";
24
+ import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read";
25
+ import { sliceUpdate } from "./hooks/slice-update";
26
+ import { snippetRead } from "./hooks/snippet-read";
27
+
28
+ export const plugin = defineSliceMachinePlugin<PluginOptions>({
29
+ meta: {
30
+ name: pkgName,
31
+ },
32
+ defaultOptions: {
33
+ format: true,
34
+ lazyLoadSlices: true,
35
+ },
36
+ setup({ hook }) {
37
+ hook("project:init", projectInit);
38
+
39
+ hook("slice:create", sliceCreate);
40
+ hook("slice:update", sliceUpdate);
41
+ hook("slice:rename", sliceRename);
42
+ hook("slice:delete", sliceDelete);
43
+ hook("slice:read", sliceRead);
44
+ hook("slice:asset:update", sliceAssetUpdate);
45
+ hook("slice:asset:delete", sliceAssetDelete);
46
+ hook("slice:asset:read", sliceAssetRead);
47
+ hook("slice-library:read", sliceLibraryRead);
48
+
49
+ hook("custom-type:create", customTypeCreate);
50
+ hook("custom-type:update", customTypeUpdate);
51
+ hook("custom-type:rename", customTypeRename);
52
+ hook("custom-type:delete", customTypeDelete);
53
+ hook("custom-type:read", customTypeRead);
54
+ hook("custom-type:asset:update", customTypeAssetUpdate);
55
+ hook("custom-type:asset:delete", customTypeAssetDelete);
56
+ hook("custom-type:asset:read", customTypeAssetRead);
57
+ hook("custom-type-library:read", customTypeLibraryRead);
58
+
59
+ hook("snippet:read", snippetRead);
60
+
61
+ hook("slice-simulator:setup:read", sliceSimulatorSetupRead);
62
+ },
63
+ });
@@ -0,0 +1,157 @@
1
+ import {
2
+ defineComponent,
3
+ ref,
4
+ onMounted,
5
+ h,
6
+ PropType,
7
+ VNodeArrayChildren,
8
+ AllowedComponentProps,
9
+ ComponentCustomProps,
10
+ VNodeProps,
11
+ onUnmounted,
12
+ } from "vue";
13
+
14
+ import {
15
+ getDefaultProps,
16
+ getDefaultManagedState,
17
+ getDefaultSlices,
18
+ getDefaultMessage,
19
+ onClickHandler,
20
+ disableEventHandler,
21
+ simulatorClass,
22
+ simulatorRootClass,
23
+ SliceSimulatorProps as BaseSliceSimulatorProps,
24
+ StateManagerEventType,
25
+ StateManagerStatus,
26
+ CoreManager,
27
+ } from "@prismicio/slice-simulator-core";
28
+
29
+ export type SliceSimulatorProps = Omit<BaseSliceSimulatorProps, "state">;
30
+
31
+ const coreManager = new CoreManager();
32
+
33
+ export const SliceSimulatorImpl = /*#__PURE__*/ defineComponent({
34
+ name: "SliceSimulator",
35
+ props: {
36
+ zIndex: {
37
+ type: Number as PropType<Required<SliceSimulatorProps["zIndex"]>>,
38
+ default: getDefaultProps().zIndex,
39
+ required: false,
40
+ },
41
+ background: {
42
+ type: String as PropType<Required<SliceSimulatorProps["background"]>>,
43
+ default: getDefaultProps().background,
44
+ required: false,
45
+ },
46
+ },
47
+ setup(props, { slots }) {
48
+ const managedState = ref(getDefaultManagedState());
49
+ const slices = ref(getDefaultSlices());
50
+ const message = ref(getDefaultMessage());
51
+
52
+ onMounted(() => {
53
+ coreManager.stateManager.on(
54
+ StateManagerEventType.ManagedState,
55
+ (_managedState) => {
56
+ managedState.value = _managedState;
57
+ },
58
+ "simulator-managed-state",
59
+ );
60
+ coreManager.stateManager.on(
61
+ StateManagerEventType.Slices,
62
+ (_slices) => {
63
+ slices.value = _slices;
64
+ },
65
+ "simulator-slices",
66
+ );
67
+ coreManager.stateManager.on(
68
+ StateManagerEventType.Message,
69
+ (_message) => {
70
+ message.value = _message;
71
+ },
72
+ "simulator-message",
73
+ );
74
+
75
+ coreManager.init(getDefaultProps().state);
76
+ });
77
+
78
+ onUnmounted(() => {
79
+ coreManager.stateManager.off(
80
+ StateManagerEventType.ManagedState,
81
+ "simulator-managed-state",
82
+ );
83
+
84
+ coreManager.stateManager.off(
85
+ StateManagerEventType.Slices,
86
+ "simulator-slices",
87
+ );
88
+
89
+ coreManager.stateManager.off(
90
+ StateManagerEventType.Message,
91
+ "simulator-message",
92
+ );
93
+ });
94
+
95
+ return () => {
96
+ const children: VNodeArrayChildren = [];
97
+
98
+ if (message.value) {
99
+ children.push(
100
+ h("article", {
101
+ innerHTML: message.value,
102
+ }),
103
+ );
104
+ } else if (slices.value.length && slots.default) {
105
+ children.push(
106
+ h(
107
+ "div",
108
+ {
109
+ id: "root",
110
+ class: simulatorRootClass,
111
+ style:
112
+ managedState.value.status !== StateManagerStatus.Loaded
113
+ ? { display: "none" }
114
+ : undefined,
115
+ onClickCapture: onClickHandler,
116
+ onSubmitCapture: disableEventHandler,
117
+ },
118
+ [
119
+ slots.default({
120
+ slices: slices.value,
121
+ }),
122
+ ],
123
+ ),
124
+ );
125
+ }
126
+
127
+ return h(
128
+ "div",
129
+ {
130
+ class: simulatorClass,
131
+ style: {
132
+ zIndex: props.zIndex,
133
+ position: "fixed",
134
+ top: 0,
135
+ left: 0,
136
+ width: "100%",
137
+ height: "100vh",
138
+ overflow: "auto",
139
+ background: props.background,
140
+ },
141
+ },
142
+ children,
143
+ );
144
+ };
145
+ },
146
+ });
147
+
148
+ // export the public type for h/tsx inference
149
+ // also to avoid inline import() in generated d.ts files
150
+ export const SliceSimulator = SliceSimulatorImpl as unknown as {
151
+ new (): {
152
+ $props: AllowedComponentProps &
153
+ ComponentCustomProps &
154
+ VNodeProps &
155
+ SliceSimulatorProps;
156
+ };
157
+ };
@@ -0,0 +1,2 @@
1
+ export { SliceSimulator } from "./SliceSimulator";
2
+ export type { SliceSimulatorProps } from "./SliceSimulator";
package/src/types.ts ADDED
@@ -0,0 +1,5 @@
1
+ export type PluginOptions = {
2
+ format?: boolean;
3
+ lazyLoadSlices?: boolean;
4
+ typescript?: boolean;
5
+ };