@slicemachine/adapter-next 0.0.3 → 0.0.4

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 (210) hide show
  1. package/dist/SliceSimulator.cjs +14 -41
  2. package/dist/SliceSimulator.cjs.map +1 -1
  3. package/dist/SliceSimulator.js +11 -36
  4. package/dist/SliceSimulator.js.map +1 -1
  5. package/dist/_virtual/_commonjsHelpers.cjs +5 -0
  6. package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
  7. package/dist/_virtual/_commonjsHelpers.js +5 -0
  8. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  9. package/dist/_virtual/ponyfill.es2018.cjs +5 -0
  10. package/dist/_virtual/ponyfill.es2018.cjs.map +1 -0
  11. package/dist/_virtual/ponyfill.es2018.js +5 -0
  12. package/dist/_virtual/ponyfill.es2018.js.map +1 -0
  13. package/dist/constants.cjs +5 -0
  14. package/dist/constants.cjs.map +1 -0
  15. package/dist/constants.d.ts +4 -0
  16. package/dist/constants.js +5 -0
  17. package/dist/constants.js.map +1 -0
  18. package/dist/hooks/customType-asset-delete.cjs +3 -5
  19. package/dist/hooks/customType-asset-delete.cjs.map +1 -1
  20. package/dist/hooks/customType-asset-delete.js.map +1 -1
  21. package/dist/hooks/customType-asset-read.cjs +3 -5
  22. package/dist/hooks/customType-asset-read.cjs.map +1 -1
  23. package/dist/hooks/customType-asset-read.js.map +1 -1
  24. package/dist/hooks/customType-asset-update.cjs +4 -6
  25. package/dist/hooks/customType-asset-update.cjs.map +1 -1
  26. package/dist/hooks/customType-asset-update.js.map +1 -1
  27. package/dist/hooks/customType-create.cjs +4 -6
  28. package/dist/hooks/customType-create.cjs.map +1 -1
  29. package/dist/hooks/customType-create.js.map +1 -1
  30. package/dist/hooks/customType-delete.cjs +3 -5
  31. package/dist/hooks/customType-delete.cjs.map +1 -1
  32. package/dist/hooks/customType-delete.js.map +1 -1
  33. package/dist/hooks/customType-read.cjs +1 -1
  34. package/dist/hooks/customType-read.cjs.map +1 -1
  35. package/dist/hooks/customType-read.js.map +1 -1
  36. package/dist/hooks/customType-rename.cjs +1 -1
  37. package/dist/hooks/customType-rename.cjs.map +1 -1
  38. package/dist/hooks/customType-rename.js.map +1 -1
  39. package/dist/hooks/customType-update.cjs +1 -1
  40. package/dist/hooks/customType-update.cjs.map +1 -1
  41. package/dist/hooks/customType-update.js.map +1 -1
  42. package/dist/hooks/customTypeLibrary-read.cjs +4 -6
  43. package/dist/hooks/customTypeLibrary-read.cjs.map +1 -1
  44. package/dist/hooks/customTypeLibrary-read.js.map +1 -1
  45. package/dist/hooks/slice-asset-delete.cjs +3 -5
  46. package/dist/hooks/slice-asset-delete.cjs.map +1 -1
  47. package/dist/hooks/slice-asset-delete.js.map +1 -1
  48. package/dist/hooks/slice-asset-read.cjs +3 -5
  49. package/dist/hooks/slice-asset-read.cjs.map +1 -1
  50. package/dist/hooks/slice-asset-read.js.map +1 -1
  51. package/dist/hooks/slice-asset-update.cjs +4 -6
  52. package/dist/hooks/slice-asset-update.cjs.map +1 -1
  53. package/dist/hooks/slice-asset-update.js.map +1 -1
  54. package/dist/hooks/slice-create.cjs +7 -9
  55. package/dist/hooks/slice-create.cjs.map +1 -1
  56. package/dist/hooks/slice-create.js +3 -3
  57. package/dist/hooks/slice-create.js.map +1 -1
  58. package/dist/hooks/slice-delete.cjs +3 -5
  59. package/dist/hooks/slice-delete.cjs.map +1 -1
  60. package/dist/hooks/slice-delete.js.map +1 -1
  61. package/dist/hooks/slice-read.cjs +4 -6
  62. package/dist/hooks/slice-read.cjs.map +1 -1
  63. package/dist/hooks/slice-read.js.map +1 -1
  64. package/dist/hooks/slice-rename.cjs +3 -5
  65. package/dist/hooks/slice-rename.cjs.map +1 -1
  66. package/dist/hooks/slice-rename.js.map +1 -1
  67. package/dist/hooks/slice-update.cjs +1 -1
  68. package/dist/hooks/slice-update.cjs.map +1 -1
  69. package/dist/hooks/slice-update.js.map +1 -1
  70. package/dist/hooks/sliceLibrary-read.cjs +4 -6
  71. package/dist/hooks/sliceLibrary-read.cjs.map +1 -1
  72. package/dist/hooks/sliceLibrary-read.js.map +1 -1
  73. package/dist/hooks/sliceSimulator-setup-read.cjs +31 -94
  74. package/dist/hooks/sliceSimulator-setup-read.cjs.map +1 -1
  75. package/dist/hooks/sliceSimulator-setup-read.js +31 -75
  76. package/dist/hooks/sliceSimulator-setup-read.js.map +1 -1
  77. package/dist/hooks/snippet-read.cjs +33 -18
  78. package/dist/hooks/snippet-read.cjs.map +1 -1
  79. package/dist/hooks/snippet-read.js +30 -13
  80. package/dist/hooks/snippet-read.js.map +1 -1
  81. package/dist/index.cjs +0 -2
  82. package/dist/index.cjs.map +1 -1
  83. package/dist/index.d.ts +0 -2
  84. package/dist/index.js +0 -2
  85. package/dist/index.js.map +1 -1
  86. package/dist/lib/getJSOrTSXFileExtension.cjs +1 -1
  87. package/dist/lib/getJSOrTSXFileExtension.cjs.map +1 -1
  88. package/dist/lib/getJSOrTSXFileExtension.js.map +1 -1
  89. package/dist/lib/isSharedSliceModel.cjs +3 -5
  90. package/dist/lib/isSharedSliceModel.cjs.map +1 -1
  91. package/dist/lib/isSharedSliceModel.js.map +1 -1
  92. package/dist/lib/pascalCase.cjs +1 -1
  93. package/dist/lib/pascalCase.cjs.map +1 -1
  94. package/dist/lib/pascalCase.js.map +1 -1
  95. package/dist/lib/readJSONFile.cjs +3 -5
  96. package/dist/lib/readJSONFile.cjs.map +1 -1
  97. package/dist/lib/readJSONFile.js.map +1 -1
  98. package/dist/lib/rejectIfNecessary.cjs +1 -1
  99. package/dist/lib/rejectIfNecessary.cjs.map +1 -1
  100. package/dist/lib/rejectIfNecessary.js.map +1 -1
  101. package/dist/lib/updateSliceModelFile.cjs +3 -5
  102. package/dist/lib/updateSliceModelFile.cjs.map +1 -1
  103. package/dist/lib/updateSliceModelFile.js.map +1 -1
  104. package/dist/lib/upsertGlobalContentTypes.cjs +8 -6
  105. package/dist/lib/upsertGlobalContentTypes.cjs.map +1 -1
  106. package/dist/lib/upsertGlobalContentTypes.js +4 -0
  107. package/dist/lib/upsertGlobalContentTypes.js.map +1 -1
  108. package/dist/lib/upsertSliceLibraryIndexFile.cjs +9 -8
  109. package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
  110. package/dist/lib/upsertSliceLibraryIndexFile.js +6 -3
  111. package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -1
  112. package/dist/node_modules/data-uri-to-buffer/dist/index.cjs +41 -0
  113. package/dist/node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -0
  114. package/dist/node_modules/data-uri-to-buffer/dist/index.js +41 -0
  115. package/dist/node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
  116. package/dist/node_modules/fetch-blob/file.cjs +55 -0
  117. package/dist/node_modules/fetch-blob/file.cjs.map +1 -0
  118. package/dist/node_modules/fetch-blob/file.js +55 -0
  119. package/dist/node_modules/fetch-blob/file.js.map +1 -0
  120. package/dist/node_modules/fetch-blob/index.cjs +176 -0
  121. package/dist/node_modules/fetch-blob/index.cjs.map +1 -0
  122. package/dist/node_modules/fetch-blob/index.js +176 -0
  123. package/dist/node_modules/fetch-blob/index.js.map +1 -0
  124. package/dist/node_modules/fetch-blob/streams.cjs +43 -0
  125. package/dist/node_modules/fetch-blob/streams.cjs.map +1 -0
  126. package/dist/node_modules/fetch-blob/streams.js +42 -0
  127. package/dist/node_modules/fetch-blob/streams.js.map +1 -0
  128. package/dist/node_modules/formdata-polyfill/esm.min.cjs +115 -0
  129. package/dist/node_modules/formdata-polyfill/esm.min.cjs.map +1 -0
  130. package/dist/node_modules/formdata-polyfill/esm.min.js +115 -0
  131. package/dist/node_modules/formdata-polyfill/esm.min.js.map +1 -0
  132. package/dist/node_modules/node-domexception/index.cjs +10 -0
  133. package/dist/node_modules/node-domexception/index.cjs.map +1 -0
  134. package/dist/node_modules/node-domexception/index.js +9 -0
  135. package/dist/node_modules/node-domexception/index.js.map +1 -0
  136. package/dist/node_modules/node-fetch/src/body.cjs +237 -0
  137. package/dist/node_modules/node-fetch/src/body.cjs.map +1 -0
  138. package/dist/node_modules/node-fetch/src/body.js +237 -0
  139. package/dist/node_modules/node-fetch/src/body.js.map +1 -0
  140. package/dist/node_modules/node-fetch/src/errors/abort-error.cjs +10 -0
  141. package/dist/node_modules/node-fetch/src/errors/abort-error.cjs.map +1 -0
  142. package/dist/node_modules/node-fetch/src/errors/abort-error.js +10 -0
  143. package/dist/node_modules/node-fetch/src/errors/abort-error.js.map +1 -0
  144. package/dist/node_modules/node-fetch/src/errors/base.cjs +17 -0
  145. package/dist/node_modules/node-fetch/src/errors/base.cjs.map +1 -0
  146. package/dist/node_modules/node-fetch/src/errors/base.js +17 -0
  147. package/dist/node_modules/node-fetch/src/errors/base.js.map +1 -0
  148. package/dist/node_modules/node-fetch/src/errors/fetch-error.cjs +14 -0
  149. package/dist/node_modules/node-fetch/src/errors/fetch-error.cjs.map +1 -0
  150. package/dist/node_modules/node-fetch/src/errors/fetch-error.js +14 -0
  151. package/dist/node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
  152. package/dist/node_modules/node-fetch/src/headers.cjs +173 -0
  153. package/dist/node_modules/node-fetch/src/headers.cjs.map +1 -0
  154. package/dist/node_modules/node-fetch/src/headers.js +173 -0
  155. package/dist/node_modules/node-fetch/src/headers.js.map +1 -0
  156. package/dist/node_modules/node-fetch/src/index.cjs +292 -0
  157. package/dist/node_modules/node-fetch/src/index.cjs.map +1 -0
  158. package/dist/node_modules/node-fetch/src/index.js +298 -0
  159. package/dist/node_modules/node-fetch/src/index.js.map +1 -0
  160. package/dist/node_modules/node-fetch/src/request.cjs +193 -0
  161. package/dist/node_modules/node-fetch/src/request.cjs.map +1 -0
  162. package/dist/node_modules/node-fetch/src/request.js +193 -0
  163. package/dist/node_modules/node-fetch/src/request.js.map +1 -0
  164. package/dist/node_modules/node-fetch/src/response.cjs +110 -0
  165. package/dist/node_modules/node-fetch/src/response.cjs.map +1 -0
  166. package/dist/node_modules/node-fetch/src/response.js +110 -0
  167. package/dist/node_modules/node-fetch/src/response.js.map +1 -0
  168. package/dist/node_modules/node-fetch/src/utils/get-search.cjs +12 -0
  169. package/dist/node_modules/node-fetch/src/utils/get-search.cjs.map +1 -0
  170. package/dist/node_modules/node-fetch/src/utils/get-search.js +12 -0
  171. package/dist/node_modules/node-fetch/src/utils/get-search.js.map +1 -0
  172. package/dist/node_modules/node-fetch/src/utils/is-redirect.cjs +8 -0
  173. package/dist/node_modules/node-fetch/src/utils/is-redirect.cjs.map +1 -0
  174. package/dist/node_modules/node-fetch/src/utils/is-redirect.js +8 -0
  175. package/dist/node_modules/node-fetch/src/utils/is-redirect.js.map +1 -0
  176. package/dist/node_modules/node-fetch/src/utils/is.cjs +28 -0
  177. package/dist/node_modules/node-fetch/src/utils/is.cjs.map +1 -0
  178. package/dist/node_modules/node-fetch/src/utils/is.js +28 -0
  179. package/dist/node_modules/node-fetch/src/utils/is.js.map +1 -0
  180. package/dist/node_modules/node-fetch/src/utils/multipart-parser.cjs +350 -0
  181. package/dist/node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -0
  182. package/dist/node_modules/node-fetch/src/utils/multipart-parser.js +350 -0
  183. package/dist/node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -0
  184. package/dist/node_modules/node-fetch/src/utils/referrer.cjs +149 -0
  185. package/dist/node_modules/node-fetch/src/utils/referrer.cjs.map +1 -0
  186. package/dist/node_modules/node-fetch/src/utils/referrer.js +149 -0
  187. package/dist/node_modules/node-fetch/src/utils/referrer.js.map +1 -0
  188. package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs +3599 -0
  189. package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -0
  190. package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js +3599 -0
  191. package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
  192. package/dist/package.json.cjs +5 -0
  193. package/dist/package.json.cjs.map +1 -0
  194. package/dist/{package.js → package.json.js} +1 -1
  195. package/dist/package.json.js.map +1 -0
  196. package/dist/plugin.cjs +2 -2
  197. package/dist/plugin.cjs.map +1 -1
  198. package/dist/plugin.js +1 -1
  199. package/dist/plugin.js.map +1 -1
  200. package/package.json +28 -13
  201. package/src/constants.ts +5 -0
  202. package/src/hooks/slice-create.ts +3 -3
  203. package/src/hooks/sliceSimulator-setup-read.ts +37 -76
  204. package/src/hooks/snippet-read.ts +42 -22
  205. package/src/index.ts +0 -6
  206. package/src/lib/upsertGlobalContentTypes.ts +3 -0
  207. package/src/lib/upsertSliceLibraryIndexFile.ts +11 -6
  208. package/dist/package.cjs +0 -5
  209. package/dist/package.cjs.map +0 -1
  210. package/dist/package.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const name = "@slicemachine/adapter-next";
4
+ exports.name = name;
5
+ //# sourceMappingURL=package.json.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -2,4 +2,4 @@ const name = "@slicemachine/adapter-next";
2
2
  export {
3
3
  name
4
4
  };
5
- //# sourceMappingURL=package.js.map
5
+ //# sourceMappingURL=package.json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/dist/plugin.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const pluginKit = require("@slicemachine/plugin-kit");
4
- const _package = require("./package.cjs");
4
+ const _package = require("./package.json.cjs");
5
5
  const customTypeAssetDelete = require("./hooks/customType-asset-delete.cjs");
6
6
  const customTypeAssetRead = require("./hooks/customType-asset-read.cjs");
7
7
  const customTypeAssetUpdate = require("./hooks/customType-asset-update.cjs");
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","sources":["../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\n\t\thook(\"slice-library:read\", sliceLibraryRead);\n\n\t\thook(\"custom-type:create\", customTypeCreate);\n\t\thook(\"custom-type:update\", customTypeUpdate);\n\t\thook(\"custom-type:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\n\t\thook(\"custom-type-library:read\", customTypeLibraryRead);\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":["defineSliceMachinePlugin","pkgName","sliceCreate","sliceUpdate","sliceRename","sliceDelete","sliceRead","sliceAssetUpdate","sliceAssetDelete","sliceAssetRead","sliceLibraryRead","customTypeCreate","customTypeUpdate","customTypeRename","customTypeDelete","customTypeRead","customTypeAssetUpdate","customTypeAssetDelete","customTypeAssetRead","customTypeLibraryRead","snippetRead","sliceSimulatorSetupRead"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BO,MAAM,SAASA,UAAAA,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL,MAAMC,SAAA;AAAA,EACN;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,EACR;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,cAAcC,UAAAA,SAAS;AAC5B,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,oBAAoBC,eAAAA,cAAc;AACvC,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAE3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,oBAAoBC,eAAAA,cAAc;AACvC,SAAK,4BAA4BC,sBAAAA,qBAAqB;AACtD,SAAK,4BAA4BC,sBAAAA,qBAAqB;AACtD,SAAK,0BAA0BC,oBAAAA,mBAAmB;AAClD,SAAK,4BAA4BC,sBAAAA,qBAAqB;AAEtD,SAAK,gBAAgBC,YAAAA,WAAW;AAEhC,SAAK,8BAA8BC,wBAAAA,uBAAuB;AAAA,EAC3D;AACA,CAAA;;"}
1
+ {"version":3,"file":"plugin.cjs","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\n\t\thook(\"slice-library:read\", sliceLibraryRead);\n\n\t\thook(\"custom-type:create\", customTypeCreate);\n\t\thook(\"custom-type:update\", customTypeUpdate);\n\t\thook(\"custom-type:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\n\t\thook(\"custom-type-library:read\", customTypeLibraryRead);\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":["defineSliceMachinePlugin","pkgName","sliceCreate","sliceUpdate","sliceRename","sliceDelete","sliceRead","sliceAssetUpdate","sliceAssetDelete","sliceAssetRead","sliceLibraryRead","customTypeCreate","customTypeUpdate","customTypeRename","customTypeDelete","customTypeRead","customTypeAssetUpdate","customTypeAssetDelete","customTypeAssetRead","customTypeLibraryRead","snippetRead","sliceSimulatorSetupRead"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BO,MAAM,SAASA,UAAAA,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL,MAAMC,SAAA;AAAA,EACN;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,EACR;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,cAAcC,UAAAA,SAAS;AAC5B,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,oBAAoBC,eAAAA,cAAc;AACvC,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAE3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,oBAAoBC,eAAAA,cAAc;AACvC,SAAK,4BAA4BC,sBAAAA,qBAAqB;AACtD,SAAK,4BAA4BC,sBAAAA,qBAAqB;AACtD,SAAK,0BAA0BC,oBAAAA,mBAAmB;AAClD,SAAK,4BAA4BC,sBAAAA,qBAAqB;AAEtD,SAAK,gBAAgBC,YAAAA,WAAW;AAEhC,SAAK,8BAA8BC,wBAAAA,uBAAuB;AAAA,EAC3D;AACA,CAAA;;"}
package/dist/plugin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineSliceMachinePlugin } from "@slicemachine/plugin-kit";
2
- import { name } from "./package.js";
2
+ import { name } from "./package.json.js";
3
3
  import { customTypeAssetDelete } from "./hooks/customType-asset-delete.js";
4
4
  import { customTypeAssetRead } from "./hooks/customType-asset-read.js";
5
5
  import { customTypeAssetUpdate } from "./hooks/customType-asset-update.js";
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\n\t\thook(\"slice-library:read\", sliceLibraryRead);\n\n\t\thook(\"custom-type:create\", customTypeCreate);\n\t\thook(\"custom-type:update\", customTypeUpdate);\n\t\thook(\"custom-type:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\n\t\thook(\"custom-type-library:read\", customTypeLibraryRead);\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0BO,MAAM,SAAS,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL;AAAA,EACA;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,EACR;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,cAAc,SAAS;AAC5B,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,sBAAsB,gBAAgB;AAE3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,0BAA0B,mBAAmB;AAClD,SAAK,4BAA4B,qBAAqB;AAEtD,SAAK,gBAAgB,WAAW;AAEhC,SAAK,8BAA8B,uBAAuB;AAAA,EAC3D;AACA,CAAA;"}
1
+ {"version":3,"file":"plugin.js","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\n\t\thook(\"slice-library:read\", sliceLibraryRead);\n\n\t\thook(\"custom-type:create\", customTypeCreate);\n\t\thook(\"custom-type:update\", customTypeUpdate);\n\t\thook(\"custom-type:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\n\t\thook(\"custom-type-library:read\", customTypeLibraryRead);\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0BO,MAAM,SAAS,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL;AAAA,EACA;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,EACR;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,cAAc,SAAS;AAC5B,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,sBAAsB,gBAAgB;AAE3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,0BAA0B,mBAAmB;AAClD,SAAK,4BAA4B,qBAAqB;AAEtD,SAAK,gBAAgB,WAAW;AAEhC,SAAK,8BAA8B,uBAAuB;AAAA,EAC3D;AACA,CAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/adapter-next",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Slice Machine adapter for Next.js.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -18,11 +18,25 @@
18
18
  "require": "./dist/index.cjs",
19
19
  "import": "./dist/index.js"
20
20
  },
21
+ "./SliceSimulator": {
22
+ "require": "./dist/SliceSimulator.cjs",
23
+ "import": "./dist/SliceSimulator.js"
24
+ },
21
25
  "./package.json": "./package.json"
22
26
  },
23
27
  "main": "dist/index.cjs",
24
28
  "module": "dist/index.js",
25
29
  "types": "dist/index.d.ts",
30
+ "typesVersions": {
31
+ "*": {
32
+ "*": [
33
+ "dist/index.d.ts"
34
+ ],
35
+ "SliceSimulator": [
36
+ "dist/SliceSimulator.d.ts"
37
+ ]
38
+ }
39
+ },
26
40
  "files": [
27
41
  "dist",
28
42
  "src"
@@ -47,7 +61,8 @@
47
61
  "@prismicio/types": "^0.2.4",
48
62
  "@slicemachine/plugin-kit": "^0.1.7",
49
63
  "common-tags": "^1.8.2",
50
- "fs-extra": "^10.1.0",
64
+ "fs-extra": "^11.1.0",
65
+ "node-fetch": "^3.3.0",
51
66
  "pascal-case": "^3.1.2",
52
67
  "prismic-ts-codegen": "^0.1.5"
53
68
  },
@@ -57,27 +72,27 @@
57
72
  "@types/common-tags": "^1.8.1",
58
73
  "@types/fs-extra": "^9.0.13",
59
74
  "@types/prettier": "^2.7.1",
60
- "@types/react": "^18.0.25",
75
+ "@types/react": "^18.0.26",
61
76
  "@types/semver": "^7.3.13",
62
- "@typescript-eslint/eslint-plugin": "^5.44.0",
63
- "@typescript-eslint/parser": "^5.44.0",
64
- "@vitejs/plugin-react": "^2.2.0",
65
- "@vitest/coverage-c8": "^0.25.2",
66
- "eslint": "^8.28.0",
77
+ "@typescript-eslint/eslint-plugin": "^5.46.1",
78
+ "@typescript-eslint/parser": "^5.46.1",
79
+ "@vitejs/plugin-react": "^3.0.0",
80
+ "@vitest/coverage-c8": "^0.25.8",
81
+ "eslint": "^8.29.0",
67
82
  "eslint-config-prettier": "^8.5.0",
68
83
  "eslint-plugin-prettier": "^4.2.1",
69
84
  "eslint-plugin-tsdoc": "^0.2.17",
70
85
  "npm-run-all": "^4.1.5",
71
- "prettier": "^2.7.1",
86
+ "prettier": "^2.8.1",
72
87
  "prettier-plugin-jsdoc": "^0.4.2",
73
88
  "react": "^18.2.0",
74
89
  "size-limit": "^8.1.0",
75
90
  "standard-version": "^9.5.0",
76
91
  "ts-morph": "^17.0.1",
77
- "typescript": "^4.9.3",
78
- "vite": "^3.2.4",
79
- "vite-plugin-sdk": "^0.0.6",
80
- "vitest": "^0.25.2"
92
+ "typescript": "^4.9.4",
93
+ "vite": "^4.0.1",
94
+ "vite-plugin-sdk": "^0.1.0",
95
+ "vitest": "^0.25.8"
81
96
  },
82
97
  "peerDependencies": {
83
98
  "next": "^11 || ^12 || ^13",
@@ -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.";
@@ -41,13 +41,13 @@ const createComponentFile = async ({ dir, data, helpers, options }: Args) => {
41
41
 
42
42
  if (options.typescript) {
43
43
  contents = stripIndent`
44
+ import { Content } from "@prismicio/client";
44
45
  import { SliceComponentProps } from "@prismicio/react";
45
- import { ${pascalName}Slice } from "./types";
46
46
 
47
47
  /**
48
48
  * Props for \`${pascalName}\`.
49
49
  */
50
- export type ${pascalName}Props = SliceComponentProps<${pascalName}Slice>;
50
+ export type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;
51
51
 
52
52
  /**
53
53
  * Component for "${model.name}" Slices.
@@ -68,7 +68,7 @@ const createComponentFile = async ({ dir, data, helpers, options }: Args) => {
68
68
  } else {
69
69
  contents = stripIndent`
70
70
  /**
71
- * @typedef {import("./types").${pascalName}Slice} ${pascalName}Slice
71
+ * @typedef {import("@prismicio/client").Content.${pascalName}Slice} ${pascalName}Slice
72
72
  * @typedef {import("@prismicio/react").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props
73
73
  * @param {${pascalName}Props}
74
74
  */
@@ -4,9 +4,9 @@ import type {
4
4
  SliceSimulatorSetupStep,
5
5
  } from "@slicemachine/plugin-kit";
6
6
  import { SliceSimulatorSetupStepValidationMessageType } from "@slicemachine/plugin-kit";
7
- import { stripIndent } from "common-tags";
7
+ import { source } from "common-tags";
8
8
  import { createRequire } from "node:module";
9
- import * as http from "node:http";
9
+ import fetch from "node-fetch";
10
10
 
11
11
  import { getJSOrTSXFileExtension } from "../lib/getJSOrTSXFileExtension";
12
12
 
@@ -14,8 +14,7 @@ import type { PluginOptions } from "../types";
14
14
 
15
15
  const REQUIRED_DEPENDENCIES = [
16
16
  "@prismicio/react",
17
- "@prismicio/slice-simulator-react",
18
- "@prismicio/client@latest",
17
+ "@prismicio/client",
19
18
  "@prismicio/helpers",
20
19
  ];
21
20
 
@@ -23,16 +22,19 @@ type Args = SliceMachineContext<PluginOptions>;
23
22
 
24
23
  const createStep1 = async ({
25
24
  project,
25
+ helpers,
26
26
  }: Args): Promise<SliceSimulatorSetupStep> => {
27
27
  const require = createRequire(project.root);
28
28
 
29
29
  return {
30
30
  title: "Install packages",
31
- body: stripIndent`
31
+ // TODO: Create a plugin runner helper to provide the correct
32
+ // package manager
33
+ body: source`
32
34
  The simulator requires extra dependencies. Run the following command to install them.
33
35
 
34
36
  ~~~sh
35
- npm install --save @prismicio/react @prismicio/slice-simulator-react @prismicio/client@latest @prismicio/helpers
37
+ npm install --save ${REQUIRED_DEPENDENCIES.join(" ")}
36
38
  ~~~
37
39
  `,
38
40
  validate: async () => {
@@ -44,7 +46,9 @@ const createStep1 = async ({
44
46
  // over `import()` because we don't
45
47
  // want to load the module. Loading a
46
48
  // module could introduce side-effects.
47
- require.resolve(dependency);
49
+ require.resolve(dependency, {
50
+ paths: [helpers.joinPathFromRoot("node_modules")],
51
+ });
48
52
  } catch {
49
53
  missingDependencies.push(dependency);
50
54
  }
@@ -54,7 +58,7 @@ const createStep1 = async ({
54
58
  return {
55
59
  type: SliceSimulatorSetupStepValidationMessageType.Error,
56
60
  title: "Missing all dependencies",
57
- message: stripIndent`
61
+ message: source`
58
62
  Install the required dependencies to continue.
59
63
  `,
60
64
  };
@@ -66,9 +70,9 @@ const createStep1 = async ({
66
70
  .join(", ");
67
71
 
68
72
  return {
69
- type: SliceSimulatorSetupStepValidationMessageType.Warning,
73
+ type: SliceSimulatorSetupStepValidationMessageType.Error,
70
74
  title: "Missing some dependencies",
71
- message: stripIndent`
75
+ message: source`
72
76
  The following dependencies are missing: ${formattedMissingDependencies}
73
77
  `,
74
78
  };
@@ -81,47 +85,18 @@ const createStep2 = async ({
81
85
  helpers,
82
86
  options,
83
87
  }: Args): Promise<SliceSimulatorSetupStep> => {
84
- const fileName = `slice-simulator.${getJSOrTSXFileExtension}`;
88
+ const fileName = `slice-simulator.${getJSOrTSXFileExtension(options)}`;
85
89
  const filePath = helpers.joinPathFromRoot("pages", fileName);
86
90
 
87
- let fileContents: string;
88
-
89
- if (options.typescript) {
90
- fileContents = stripIndent`
91
- import { GetStaticProps } from "next/types";
92
- import { SliceSimulator } from "@prismicio/slice-simulator-react";
93
- import { SliceZone } from "@prismicio/react";
94
-
95
- import state from "../.slicemachine/libraries-state.json";
96
- import { components } from "../slices";
97
-
98
- const SliceSimulatorPage = () => {
99
- return (
100
- <SliceSimulator
101
- sliceZone={(props) => <SliceZone {...props} components={components} />}
102
- state={state}
103
- />
104
- );
105
- };
106
-
107
- export default SliceSimulatorPage;
108
-
109
- export const getStaticProps: GetStaticProps = () => {
110
- return {
111
- // Exclude this page from production builds.
112
- notFound: process.env.NODE_ENV === "production",
113
- };
114
- };
115
- `;
116
- } else {
117
- fileContents = stripIndent`
91
+ const fileContents = await helpers.format(
92
+ source`
118
93
  import { SliceSimulator } from "@prismicio/slice-simulator-react";
119
94
  import { SliceZone } from "@prismicio/react";
120
95
 
121
96
  import state from "../.slicemachine/libraries-state.json";
122
97
  import { components } from "../slices";
123
98
 
124
- const SliceSimulatorPage = () => {
99
+ export default function SliceSimulatorPage() {
125
100
  return (
126
101
  <SliceSimulator
127
102
  sliceZone={(props) => <SliceZone {...props} components={components} />}
@@ -129,23 +104,16 @@ const createStep2 = async ({
129
104
  />
130
105
  );
131
106
  };
132
-
133
- export default SliceSimulatorPage;
134
-
135
- export const getStaticProps= () => {
136
- return {
137
- // Exclude this page from production builds.
138
- notFound: process.env.NODE_ENV === "production",
139
- };
140
- };
141
- `;
142
- }
143
-
144
- fileContents = await helpers.format(fileContents, filePath);
107
+ `,
108
+ filePath,
109
+ {
110
+ includeNewlineAtEnd: false,
111
+ },
112
+ );
145
113
 
146
114
  return {
147
115
  title: "Create a page for the simulator",
148
- body: stripIndent`
116
+ body: source`
149
117
  In your \`pages\` directory, create a file called \`${fileName}\` and add the following code. This route will be used to simulate and develop your components.
150
118
 
151
119
  ~~~tsx
@@ -160,17 +128,20 @@ const createStep3 = async ({
160
128
  }: Args): Promise<SliceSimulatorSetupStep> => {
161
129
  const filePath = helpers.joinPathFromRoot("sm.json");
162
130
  const fileContents = await helpers.format(
163
- `
131
+ source`
164
132
  {
165
133
  "localSliceSimulatorURL": "http://localhost:3000/slice-simulator"
166
134
  }
167
135
  `,
168
136
  filePath,
137
+ {
138
+ includeNewlineAtEnd: false,
139
+ },
169
140
  );
170
141
 
171
142
  return {
172
143
  title: "Update `sm.json`",
173
- body: stripIndent`
144
+ body: source`
174
145
  Update your \`sm.json\` file with a \`localSliceSimulatorURL\` property pointing to your \`slice-simulator\` page.
175
146
 
176
147
  ~~~json
@@ -184,7 +155,7 @@ const createStep3 = async ({
184
155
  return {
185
156
  type: SliceSimulatorSetupStepValidationMessageType.Error,
186
157
  title: "Missing `localSliceSimulatorURL` property",
187
- message: stripIndent`
158
+ message: source`
188
159
  A \`localSliceSimulatorURL\` property was not found in your \`sm.json\` file.
189
160
  `,
190
161
  };
@@ -199,32 +170,22 @@ const createStep3 = async ({
199
170
  }
200
171
  } catch {
201
172
  return {
202
- type: SliceSimulatorSetupStepValidationMessageType.Warning,
173
+ type: SliceSimulatorSetupStepValidationMessageType.Error,
203
174
  title: "An invalid URL was provided",
204
- message: stripIndent`
175
+ message: source`
205
176
  The \`localSliceSimulatorURL\` property should be of the shape \`http://localhost:PORT/PATH\`. See the codeblock for an example.
206
177
  `,
207
178
  };
208
179
  }
209
180
 
210
181
  // Check if the URL is accessible.
211
- const ok = await new Promise<boolean>((resolve) => {
212
- if (project.config.localSliceSimulatorURL) {
213
- http.get(project.config.localSliceSimulatorURL, (res) => {
214
- if (res.statusCode) {
215
- resolve(res.statusCode >= 200 && res.statusCode < 300);
216
- }
217
- });
218
- }
182
+ const res = await fetch(project.config.localSliceSimulatorURL);
219
183
 
220
- resolve(false);
221
- });
222
-
223
- if (!ok) {
184
+ if (!res.ok) {
224
185
  return {
225
- type: SliceSimulatorSetupStepValidationMessageType.Warning,
186
+ type: SliceSimulatorSetupStepValidationMessageType.Error,
226
187
  title: "Unable to connect to simulator page",
227
- message: stripIndent`
188
+ message: source`
228
189
  Check that the \`localSliceSimulatorURL\` property in \`sm.json\` is correct and try again. See the [troubleshooting page](https://prismic.io/docs/technologies/setup-slice-simulator-nextjs) for more details.
229
190
  `,
230
191
  };
@@ -1,16 +1,29 @@
1
- import type { SnippetReadHook } from "@slicemachine/plugin-kit";
1
+ import type {
2
+ SliceMachineHelpers,
3
+ SnippetReadHook,
4
+ } from "@slicemachine/plugin-kit";
2
5
  import * as prismicT from "@prismicio/types";
3
6
  import { stripIndent } from "common-tags";
4
- import type { Config as PrettierConfig } from "prettier";
5
7
 
6
8
  import type { PluginOptions } from "../types";
7
9
 
8
- const prettierOptions: PrettierConfig = { parser: "typescript" };
9
-
10
10
  const dotPath = (segments: string[]): string => {
11
11
  return segments.join(".");
12
12
  };
13
13
 
14
+ const format = async (input: string, helpers: SliceMachineHelpers) => {
15
+ const formattedInput = await helpers.format(input, undefined, {
16
+ includeNewlineAtEnd: false,
17
+ prettier: {
18
+ parser: "typescript",
19
+ },
20
+ });
21
+
22
+ return formattedInput.endsWith(";")
23
+ ? formattedInput.substring(0, formattedInput.length - 1)
24
+ : formattedInput;
25
+ };
26
+
14
27
  export const snippetRead: SnippetReadHook<PluginOptions> = async (
15
28
  data,
16
29
  { helpers },
@@ -20,16 +33,28 @@ export const snippetRead: SnippetReadHook<PluginOptions> = async (
20
33
  const label = "React";
21
34
 
22
35
  switch (data.model.type) {
36
+ case prismicT.CustomTypeModelFieldType.StructuredText: {
37
+ return {
38
+ label,
39
+ language: "tsx",
40
+ code: await format(
41
+ stripIndent`
42
+ <PrismicRichText field={${dotPath(fieldPath)}} />
43
+ `,
44
+ helpers,
45
+ ),
46
+ };
47
+ }
48
+
23
49
  case prismicT.CustomTypeModelFieldType.Link: {
24
50
  return {
25
51
  label,
26
52
  language: "tsx",
27
- code: await helpers.format(
53
+ code: await format(
28
54
  stripIndent`
29
55
  <PrismicLink field={${dotPath(fieldPath)}}>Link</PrismicLink>
30
56
  `,
31
- undefined,
32
- { prettier: prettierOptions },
57
+ helpers,
33
58
  ),
34
59
  };
35
60
  }
@@ -39,37 +64,34 @@ export const snippetRead: SnippetReadHook<PluginOptions> = async (
39
64
  {
40
65
  label: `${label} (next/image)`,
41
66
  language: "tsx",
42
- code: await helpers.format(
67
+ code: await format(
43
68
  stripIndent`
44
69
  <PrismicNextImage field={${dotPath(fieldPath)}} />
45
70
  `,
46
- undefined,
47
- { prettier: prettierOptions },
71
+ helpers,
48
72
  ),
49
73
  },
50
74
  {
51
75
  label,
52
76
  language: "tsx",
53
- code: await helpers.format(
77
+ code: await format(
54
78
  stripIndent`
55
79
  <PrismicImage field={${dotPath(fieldPath)}} />
56
80
  `,
57
- undefined,
58
- { prettier: prettierOptions },
81
+ helpers,
59
82
  ),
60
83
  },
61
84
  ];
62
85
  }
63
86
 
64
87
  case prismicT.CustomTypeModelFieldType.Group: {
65
- const code = await helpers.format(
88
+ const code = await format(
66
89
  stripIndent`
67
90
  <>{${dotPath(fieldPath)}.map(item => (
68
91
  <>{/* Render content for item */}</>
69
92
  ))}</>
70
93
  `,
71
- undefined,
72
- { prettier: prettierOptions },
94
+ helpers,
73
95
  );
74
96
 
75
97
  return {
@@ -80,15 +102,14 @@ export const snippetRead: SnippetReadHook<PluginOptions> = async (
80
102
  }
81
103
 
82
104
  case prismicT.CustomTypeModelFieldType.Slices: {
83
- const code = await helpers.format(
105
+ const code = await format(
84
106
  stripIndent`
85
107
  <SliceZone
86
108
  slices={${dotPath(fieldPath)}}
87
109
  components={components}
88
110
  />
89
111
  `,
90
- undefined,
91
- { prettier: prettierOptions },
112
+ helpers,
92
113
  );
93
114
 
94
115
  return {
@@ -102,12 +123,11 @@ export const snippetRead: SnippetReadHook<PluginOptions> = async (
102
123
  return {
103
124
  label,
104
125
  language: "tsx",
105
- code: await helpers.format(
126
+ code: await format(
106
127
  stripIndent`
107
128
  <>{${dotPath(fieldPath)}}</>
108
129
  `,
109
- undefined,
110
- { prettier: prettierOptions },
130
+ helpers,
111
131
  ),
112
132
  };
113
133
  }
package/src/index.ts CHANGED
@@ -2,9 +2,3 @@ import { plugin } from "./plugin";
2
2
  export default plugin;
3
3
 
4
4
  export type { PluginOptions } from "./types";
5
-
6
- export { SliceSimulator } from "./SliceSimulator";
7
- export type {
8
- SliceSimulatorProps,
9
- SliceSimulatorSliceZoneProps,
10
- } from "./SliceSimulator";
@@ -4,6 +4,7 @@ import * as fs from "node:fs/promises";
4
4
  import * as path from "node:path";
5
5
 
6
6
  import type { PluginOptions } from "../types";
7
+ import { NON_EDITABLE_FILE_BANNER } from "../constants";
7
8
 
8
9
  /**
9
10
  * Arguments for `upsertGlobalContentTypes()`.
@@ -50,6 +51,8 @@ export const upsertGlobalContentTypes = async ({
50
51
  },
51
52
  });
52
53
 
54
+ contents = `${NON_EDITABLE_FILE_BANNER}\n\n${contents}`;
55
+
53
56
  if (options.format) {
54
57
  contents = await helpers.format(contents, filePath);
55
58
  }
@@ -1,6 +1,7 @@
1
1
  import { SliceMachineContext } from "@slicemachine/plugin-kit";
2
2
  import { stripIndent } from "common-tags";
3
3
  import * as fs from "node:fs/promises";
4
+ import { NON_EDITABLE_FILE_BANNER } from "../constants";
4
5
 
5
6
  import { PluginOptions } from "../types";
6
7
 
@@ -23,15 +24,19 @@ export const upsertSliceLibraryIndexFile = async (
23
24
  });
24
25
 
25
26
  let contents = stripIndent`
27
+ ${NON_EDITABLE_FILE_BANNER}
28
+
26
29
  import dynamic from 'next/dynamic'
27
30
 
28
31
  export const components = {
29
- ${slices.map((slice) => {
30
- const id = slice.model.id;
31
- const fileName = pascalCase(slice.model.name);
32
-
33
- return `${id}: dynamic(() => import('./${fileName}')),`;
34
- })}
32
+ ${slices
33
+ .map((slice) => {
34
+ const id = slice.model.id;
35
+ const dirName = pascalCase(slice.model.name);
36
+
37
+ return `${id}: dynamic(() => import('./${dirName}'))`;
38
+ })
39
+ .join(",\n")}
35
40
  }
36
41
  `;
37
42
 
package/dist/package.cjs DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const name = "@slicemachine/adapter-next";
4
- exports.name = name;
5
- //# sourceMappingURL=package.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}