@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.
- package/dist/SliceSimulator.cjs +14 -41
- package/dist/SliceSimulator.cjs.map +1 -1
- package/dist/SliceSimulator.js +11 -36
- package/dist/SliceSimulator.js.map +1 -1
- package/dist/_virtual/_commonjsHelpers.cjs +5 -0
- package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
- package/dist/_virtual/_commonjsHelpers.js +5 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/ponyfill.es2018.cjs +5 -0
- package/dist/_virtual/ponyfill.es2018.cjs.map +1 -0
- package/dist/_virtual/ponyfill.es2018.js +5 -0
- package/dist/_virtual/ponyfill.es2018.js.map +1 -0
- package/dist/constants.cjs +5 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/hooks/customType-asset-delete.cjs +3 -5
- package/dist/hooks/customType-asset-delete.cjs.map +1 -1
- package/dist/hooks/customType-asset-delete.js.map +1 -1
- package/dist/hooks/customType-asset-read.cjs +3 -5
- package/dist/hooks/customType-asset-read.cjs.map +1 -1
- package/dist/hooks/customType-asset-read.js.map +1 -1
- package/dist/hooks/customType-asset-update.cjs +4 -6
- package/dist/hooks/customType-asset-update.cjs.map +1 -1
- package/dist/hooks/customType-asset-update.js.map +1 -1
- package/dist/hooks/customType-create.cjs +4 -6
- package/dist/hooks/customType-create.cjs.map +1 -1
- package/dist/hooks/customType-create.js.map +1 -1
- package/dist/hooks/customType-delete.cjs +3 -5
- package/dist/hooks/customType-delete.cjs.map +1 -1
- package/dist/hooks/customType-delete.js.map +1 -1
- package/dist/hooks/customType-read.cjs +1 -1
- package/dist/hooks/customType-read.cjs.map +1 -1
- package/dist/hooks/customType-read.js.map +1 -1
- package/dist/hooks/customType-rename.cjs +1 -1
- package/dist/hooks/customType-rename.cjs.map +1 -1
- package/dist/hooks/customType-rename.js.map +1 -1
- package/dist/hooks/customType-update.cjs +1 -1
- package/dist/hooks/customType-update.cjs.map +1 -1
- package/dist/hooks/customType-update.js.map +1 -1
- package/dist/hooks/customTypeLibrary-read.cjs +4 -6
- package/dist/hooks/customTypeLibrary-read.cjs.map +1 -1
- package/dist/hooks/customTypeLibrary-read.js.map +1 -1
- package/dist/hooks/slice-asset-delete.cjs +3 -5
- package/dist/hooks/slice-asset-delete.cjs.map +1 -1
- package/dist/hooks/slice-asset-delete.js.map +1 -1
- package/dist/hooks/slice-asset-read.cjs +3 -5
- package/dist/hooks/slice-asset-read.cjs.map +1 -1
- package/dist/hooks/slice-asset-read.js.map +1 -1
- package/dist/hooks/slice-asset-update.cjs +4 -6
- package/dist/hooks/slice-asset-update.cjs.map +1 -1
- package/dist/hooks/slice-asset-update.js.map +1 -1
- package/dist/hooks/slice-create.cjs +7 -9
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +3 -3
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/hooks/slice-delete.cjs +3 -5
- package/dist/hooks/slice-delete.cjs.map +1 -1
- package/dist/hooks/slice-delete.js.map +1 -1
- package/dist/hooks/slice-read.cjs +4 -6
- package/dist/hooks/slice-read.cjs.map +1 -1
- package/dist/hooks/slice-read.js.map +1 -1
- package/dist/hooks/slice-rename.cjs +3 -5
- package/dist/hooks/slice-rename.cjs.map +1 -1
- package/dist/hooks/slice-rename.js.map +1 -1
- package/dist/hooks/slice-update.cjs +1 -1
- package/dist/hooks/slice-update.cjs.map +1 -1
- package/dist/hooks/slice-update.js.map +1 -1
- package/dist/hooks/sliceLibrary-read.cjs +4 -6
- package/dist/hooks/sliceLibrary-read.cjs.map +1 -1
- package/dist/hooks/sliceLibrary-read.js.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.cjs +31 -94
- package/dist/hooks/sliceSimulator-setup-read.cjs.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.js +31 -75
- package/dist/hooks/sliceSimulator-setup-read.js.map +1 -1
- package/dist/hooks/snippet-read.cjs +33 -18
- package/dist/hooks/snippet-read.cjs.map +1 -1
- package/dist/hooks/snippet-read.js +30 -13
- package/dist/hooks/snippet-read.js.map +1 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/getJSOrTSXFileExtension.cjs +1 -1
- package/dist/lib/getJSOrTSXFileExtension.cjs.map +1 -1
- package/dist/lib/getJSOrTSXFileExtension.js.map +1 -1
- package/dist/lib/isSharedSliceModel.cjs +3 -5
- package/dist/lib/isSharedSliceModel.cjs.map +1 -1
- package/dist/lib/isSharedSliceModel.js.map +1 -1
- package/dist/lib/pascalCase.cjs +1 -1
- package/dist/lib/pascalCase.cjs.map +1 -1
- package/dist/lib/pascalCase.js.map +1 -1
- package/dist/lib/readJSONFile.cjs +3 -5
- package/dist/lib/readJSONFile.cjs.map +1 -1
- package/dist/lib/readJSONFile.js.map +1 -1
- package/dist/lib/rejectIfNecessary.cjs +1 -1
- package/dist/lib/rejectIfNecessary.cjs.map +1 -1
- package/dist/lib/rejectIfNecessary.js.map +1 -1
- package/dist/lib/updateSliceModelFile.cjs +3 -5
- package/dist/lib/updateSliceModelFile.cjs.map +1 -1
- package/dist/lib/updateSliceModelFile.js.map +1 -1
- package/dist/lib/upsertGlobalContentTypes.cjs +8 -6
- package/dist/lib/upsertGlobalContentTypes.cjs.map +1 -1
- package/dist/lib/upsertGlobalContentTypes.js +4 -0
- package/dist/lib/upsertGlobalContentTypes.js.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +9 -8
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js +6 -3
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -1
- package/dist/node_modules/data-uri-to-buffer/dist/index.cjs +41 -0
- package/dist/node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -0
- package/dist/node_modules/data-uri-to-buffer/dist/index.js +41 -0
- package/dist/node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
- package/dist/node_modules/fetch-blob/file.cjs +55 -0
- package/dist/node_modules/fetch-blob/file.cjs.map +1 -0
- package/dist/node_modules/fetch-blob/file.js +55 -0
- package/dist/node_modules/fetch-blob/file.js.map +1 -0
- package/dist/node_modules/fetch-blob/index.cjs +176 -0
- package/dist/node_modules/fetch-blob/index.cjs.map +1 -0
- package/dist/node_modules/fetch-blob/index.js +176 -0
- package/dist/node_modules/fetch-blob/index.js.map +1 -0
- package/dist/node_modules/fetch-blob/streams.cjs +43 -0
- package/dist/node_modules/fetch-blob/streams.cjs.map +1 -0
- package/dist/node_modules/fetch-blob/streams.js +42 -0
- package/dist/node_modules/fetch-blob/streams.js.map +1 -0
- package/dist/node_modules/formdata-polyfill/esm.min.cjs +115 -0
- package/dist/node_modules/formdata-polyfill/esm.min.cjs.map +1 -0
- package/dist/node_modules/formdata-polyfill/esm.min.js +115 -0
- package/dist/node_modules/formdata-polyfill/esm.min.js.map +1 -0
- package/dist/node_modules/node-domexception/index.cjs +10 -0
- package/dist/node_modules/node-domexception/index.cjs.map +1 -0
- package/dist/node_modules/node-domexception/index.js +9 -0
- package/dist/node_modules/node-domexception/index.js.map +1 -0
- package/dist/node_modules/node-fetch/src/body.cjs +237 -0
- package/dist/node_modules/node-fetch/src/body.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/body.js +237 -0
- package/dist/node_modules/node-fetch/src/body.js.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/abort-error.cjs +10 -0
- package/dist/node_modules/node-fetch/src/errors/abort-error.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/abort-error.js +10 -0
- package/dist/node_modules/node-fetch/src/errors/abort-error.js.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/base.cjs +17 -0
- package/dist/node_modules/node-fetch/src/errors/base.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/base.js +17 -0
- package/dist/node_modules/node-fetch/src/errors/base.js.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.cjs +14 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.js +14 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
- package/dist/node_modules/node-fetch/src/headers.cjs +173 -0
- package/dist/node_modules/node-fetch/src/headers.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/headers.js +173 -0
- package/dist/node_modules/node-fetch/src/headers.js.map +1 -0
- package/dist/node_modules/node-fetch/src/index.cjs +292 -0
- package/dist/node_modules/node-fetch/src/index.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/index.js +298 -0
- package/dist/node_modules/node-fetch/src/index.js.map +1 -0
- package/dist/node_modules/node-fetch/src/request.cjs +193 -0
- package/dist/node_modules/node-fetch/src/request.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/request.js +193 -0
- package/dist/node_modules/node-fetch/src/request.js.map +1 -0
- package/dist/node_modules/node-fetch/src/response.cjs +110 -0
- package/dist/node_modules/node-fetch/src/response.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/response.js +110 -0
- package/dist/node_modules/node-fetch/src/response.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/get-search.cjs +12 -0
- package/dist/node_modules/node-fetch/src/utils/get-search.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/get-search.js +12 -0
- package/dist/node_modules/node-fetch/src/utils/get-search.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/is-redirect.cjs +8 -0
- package/dist/node_modules/node-fetch/src/utils/is-redirect.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/is-redirect.js +8 -0
- package/dist/node_modules/node-fetch/src/utils/is-redirect.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/is.cjs +28 -0
- package/dist/node_modules/node-fetch/src/utils/is.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/is.js +28 -0
- package/dist/node_modules/node-fetch/src/utils/is.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.cjs +350 -0
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.js +350 -0
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/referrer.cjs +149 -0
- package/dist/node_modules/node-fetch/src/utils/referrer.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/referrer.js +149 -0
- package/dist/node_modules/node-fetch/src/utils/referrer.js.map +1 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs +3599 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js +3599 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
- package/dist/package.json.cjs +5 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/{package.js → package.json.js} +1 -1
- package/dist/package.json.js.map +1 -0
- package/dist/plugin.cjs +2 -2
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/package.json +28 -13
- package/src/constants.ts +5 -0
- package/src/hooks/slice-create.ts +3 -3
- package/src/hooks/sliceSimulator-setup-read.ts +37 -76
- package/src/hooks/snippet-read.ts +42 -22
- package/src/index.ts +0 -6
- package/src/lib/upsertGlobalContentTypes.ts +3 -0
- package/src/lib/upsertSliceLibraryIndexFile.ts +11 -6
- package/dist/package.cjs +0 -5
- package/dist/package.cjs.map +0 -1
- package/dist/package.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -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.
|
|
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");
|
package/dist/plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","sources":["
|
|
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";
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["
|
|
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
|
+
"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": "^
|
|
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.
|
|
75
|
+
"@types/react": "^18.0.26",
|
|
61
76
|
"@types/semver": "^7.3.13",
|
|
62
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
63
|
-
"@typescript-eslint/parser": "^5.
|
|
64
|
-
"@vitejs/plugin-react": "^
|
|
65
|
-
"@vitest/coverage-c8": "^0.25.
|
|
66
|
-
"eslint": "^8.
|
|
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.
|
|
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.
|
|
78
|
-
"vite": "^
|
|
79
|
-
"vite-plugin-sdk": "^0.0
|
|
80
|
-
"vitest": "^0.25.
|
|
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",
|
package/src/constants.ts
ADDED
|
@@ -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
|
|
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("
|
|
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 {
|
|
7
|
+
import { source } from "common-tags";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
|
-
import
|
|
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/
|
|
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
|
-
|
|
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
|
|
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:
|
|
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.
|
|
73
|
+
type: SliceSimulatorSetupStepValidationMessageType.Error,
|
|
70
74
|
title: "Missing some dependencies",
|
|
71
|
-
message:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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.
|
|
173
|
+
type: SliceSimulatorSetupStepValidationMessageType.Error,
|
|
203
174
|
title: "An invalid URL was provided",
|
|
204
|
-
message:
|
|
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
|
|
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
|
-
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
if (!ok) {
|
|
184
|
+
if (!res.ok) {
|
|
224
185
|
return {
|
|
225
|
-
type: SliceSimulatorSetupStepValidationMessageType.
|
|
186
|
+
type: SliceSimulatorSetupStepValidationMessageType.Error,
|
|
226
187
|
title: "Unable to connect to simulator page",
|
|
227
|
-
message:
|
|
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 {
|
|
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
|
|
53
|
+
code: await format(
|
|
28
54
|
stripIndent`
|
|
29
55
|
<PrismicLink field={${dotPath(fieldPath)}}>Link</PrismicLink>
|
|
30
56
|
`,
|
|
31
|
-
|
|
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
|
|
67
|
+
code: await format(
|
|
43
68
|
stripIndent`
|
|
44
69
|
<PrismicNextImage field={${dotPath(fieldPath)}} />
|
|
45
70
|
`,
|
|
46
|
-
|
|
47
|
-
{ prettier: prettierOptions },
|
|
71
|
+
helpers,
|
|
48
72
|
),
|
|
49
73
|
},
|
|
50
74
|
{
|
|
51
75
|
label,
|
|
52
76
|
language: "tsx",
|
|
53
|
-
code: await
|
|
77
|
+
code: await format(
|
|
54
78
|
stripIndent`
|
|
55
79
|
<PrismicImage field={${dotPath(fieldPath)}} />
|
|
56
80
|
`,
|
|
57
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
126
|
+
code: await format(
|
|
106
127
|
stripIndent`
|
|
107
128
|
<>{${dotPath(fieldPath)}}</>
|
|
108
129
|
`,
|
|
109
|
-
|
|
110
|
-
{ prettier: prettierOptions },
|
|
130
|
+
helpers,
|
|
111
131
|
),
|
|
112
132
|
};
|
|
113
133
|
}
|
package/src/index.ts
CHANGED
|
@@ -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
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
package/dist/package.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/package.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|