@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.
- package/LICENSE +202 -0
- package/README.md +98 -0
- 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 +61 -0
- package/dist/_node_modules/fetch-blob/file.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/file.js +61 -0
- package/dist/_node_modules/fetch-blob/file.js.map +1 -0
- package/dist/_node_modules/fetch-blob/index.cjs +223 -0
- package/dist/_node_modules/fetch-blob/index.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/index.js +223 -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 +116 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.cjs.map +1 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.js +116 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.js.map +1 -0
- package/dist/_node_modules/node-domexception/index.cjs +11 -0
- package/dist/_node_modules/node-domexception/index.cjs.map +1 -0
- package/dist/_node_modules/node-domexception/index.js +10 -0
- package/dist/_node_modules/node-domexception/index.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/body.cjs +262 -0
- package/dist/_node_modules/node-fetch/src/body.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/body.js +262 -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 +19 -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 +19 -0
- package/dist/_node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/headers.cjs +190 -0
- package/dist/_node_modules/node-fetch/src/headers.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/headers.js +190 -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 +292 -0
- package/dist/_node_modules/node-fetch/src/index.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/request.cjs +206 -0
- package/dist/_node_modules/node-fetch/src/request.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/request.js +206 -0
- package/dist/_node_modules/node-fetch/src/request.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/response.cjs +122 -0
- package/dist/_node_modules/node-fetch/src/response.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/response.js +123 -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 +356 -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 +356 -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 +3822 -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 +3822 -0
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
- 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 +13 -0
- package/dist/_virtual/ponyfill.es2018.cjs.map +1 -0
- package/dist/_virtual/ponyfill.es2018.js +14 -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 +31 -0
- package/dist/hooks/customType-asset-delete.cjs.map +1 -0
- package/dist/hooks/customType-asset-delete.d.ts +3 -0
- package/dist/hooks/customType-asset-delete.js +14 -0
- package/dist/hooks/customType-asset-delete.js.map +1 -0
- package/dist/hooks/customType-asset-read.cjs +34 -0
- package/dist/hooks/customType-asset-read.cjs.map +1 -0
- package/dist/hooks/customType-asset-read.d.ts +3 -0
- package/dist/hooks/customType-asset-read.js +17 -0
- package/dist/hooks/customType-asset-read.js.map +1 -0
- package/dist/hooks/customType-asset-update.cjs +34 -0
- package/dist/hooks/customType-asset-update.cjs.map +1 -0
- package/dist/hooks/customType-asset-update.d.ts +3 -0
- package/dist/hooks/customType-asset-update.js +16 -0
- package/dist/hooks/customType-asset-update.js.map +1 -0
- package/dist/hooks/customType-create.cjs +43 -0
- package/dist/hooks/customType-create.cjs.map +1 -0
- package/dist/hooks/customType-create.d.ts +3 -0
- package/dist/hooks/customType-create.js +25 -0
- package/dist/hooks/customType-create.js.map +1 -0
- package/dist/hooks/customType-delete.cjs +32 -0
- package/dist/hooks/customType-delete.cjs.map +1 -0
- package/dist/hooks/customType-delete.d.ts +3 -0
- package/dist/hooks/customType-delete.js +15 -0
- package/dist/hooks/customType-delete.js.map +1 -0
- package/dist/hooks/customType-read.cjs +31 -0
- package/dist/hooks/customType-read.cjs.map +1 -0
- package/dist/hooks/customType-read.d.ts +3 -0
- package/dist/hooks/customType-read.js +14 -0
- package/dist/hooks/customType-read.js.map +1 -0
- package/dist/hooks/customType-rename.cjs +6 -0
- package/dist/hooks/customType-rename.cjs.map +1 -0
- package/dist/hooks/customType-rename.d.ts +1 -0
- package/dist/hooks/customType-rename.js +6 -0
- package/dist/hooks/customType-rename.js.map +1 -0
- package/dist/hooks/customType-update.cjs +6 -0
- package/dist/hooks/customType-update.cjs.map +1 -0
- package/dist/hooks/customType-update.d.ts +1 -0
- package/dist/hooks/customType-update.js +6 -0
- package/dist/hooks/customType-update.js.map +1 -0
- package/dist/hooks/customTypeLibrary-read.cjs +53 -0
- package/dist/hooks/customTypeLibrary-read.cjs.map +1 -0
- package/dist/hooks/customTypeLibrary-read.d.ts +3 -0
- package/dist/hooks/customTypeLibrary-read.js +35 -0
- package/dist/hooks/customTypeLibrary-read.js.map +1 -0
- package/dist/hooks/project-init.cjs +112 -0
- package/dist/hooks/project-init.cjs.map +1 -0
- package/dist/hooks/project-init.d.ts +3 -0
- package/dist/hooks/project-init.js +94 -0
- package/dist/hooks/project-init.js.map +1 -0
- package/dist/hooks/slice-asset-delete.cjs +33 -0
- package/dist/hooks/slice-asset-delete.cjs.map +1 -0
- package/dist/hooks/slice-asset-delete.d.ts +3 -0
- package/dist/hooks/slice-asset-delete.js +16 -0
- package/dist/hooks/slice-asset-delete.js.map +1 -0
- package/dist/hooks/slice-asset-read.cjs +36 -0
- package/dist/hooks/slice-asset-read.cjs.map +1 -0
- package/dist/hooks/slice-asset-read.d.ts +3 -0
- package/dist/hooks/slice-asset-read.js +19 -0
- package/dist/hooks/slice-asset-read.js.map +1 -0
- package/dist/hooks/slice-asset-update.cjs +36 -0
- package/dist/hooks/slice-asset-update.cjs.map +1 -0
- package/dist/hooks/slice-asset-update.d.ts +3 -0
- package/dist/hooks/slice-asset-update.js +18 -0
- package/dist/hooks/slice-asset-update.js.map +1 -0
- package/dist/hooks/slice-create.cjs +77 -0
- package/dist/hooks/slice-create.cjs.map +1 -0
- package/dist/hooks/slice-create.d.ts +3 -0
- package/dist/hooks/slice-create.js +59 -0
- package/dist/hooks/slice-create.js.map +1 -0
- package/dist/hooks/slice-delete.cjs +41 -0
- package/dist/hooks/slice-delete.cjs.map +1 -0
- package/dist/hooks/slice-delete.d.ts +3 -0
- package/dist/hooks/slice-delete.js +24 -0
- package/dist/hooks/slice-delete.js.map +1 -0
- package/dist/hooks/slice-read.cjs +62 -0
- package/dist/hooks/slice-read.cjs.map +1 -0
- package/dist/hooks/slice-read.d.ts +3 -0
- package/dist/hooks/slice-read.js +44 -0
- package/dist/hooks/slice-read.js.map +1 -0
- package/dist/hooks/slice-rename.cjs +51 -0
- package/dist/hooks/slice-rename.cjs.map +1 -0
- package/dist/hooks/slice-rename.d.ts +3 -0
- package/dist/hooks/slice-rename.js +34 -0
- package/dist/hooks/slice-rename.js.map +1 -0
- package/dist/hooks/slice-update.cjs +14 -0
- package/dist/hooks/slice-update.cjs.map +1 -0
- package/dist/hooks/slice-update.d.ts +3 -0
- package/dist/hooks/slice-update.js +14 -0
- package/dist/hooks/slice-update.js.map +1 -0
- package/dist/hooks/sliceLibrary-read.cjs +52 -0
- package/dist/hooks/sliceLibrary-read.cjs.map +1 -0
- package/dist/hooks/sliceLibrary-read.d.ts +3 -0
- package/dist/hooks/sliceLibrary-read.js +34 -0
- package/dist/hooks/sliceLibrary-read.js.map +1 -0
- package/dist/hooks/sliceSimulator-setup-read.cjs +150 -0
- package/dist/hooks/sliceSimulator-setup-read.cjs.map +1 -0
- package/dist/hooks/sliceSimulator-setup-read.d.ts +3 -0
- package/dist/hooks/sliceSimulator-setup-read.js +150 -0
- package/dist/hooks/sliceSimulator-setup-read.js.map +1 -0
- package/dist/hooks/snippet-read.cjs +101 -0
- package/dist/hooks/snippet-read.cjs.map +1 -0
- package/dist/hooks/snippet-read.d.ts +3 -0
- package/dist/hooks/snippet-read.js +101 -0
- package/dist/hooks/snippet-read.js.map +1 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/buildCustomTypeAssetPath.cjs +29 -0
- package/dist/lib/buildCustomTypeAssetPath.cjs.map +1 -0
- package/dist/lib/buildCustomTypeAssetPath.d.ts +9 -0
- package/dist/lib/buildCustomTypeAssetPath.js +12 -0
- package/dist/lib/buildCustomTypeAssetPath.js.map +1 -0
- package/dist/lib/buildCustomTypeDirectoryPath.cjs +26 -0
- package/dist/lib/buildCustomTypeDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildCustomTypeDirectoryPath.d.ts +8 -0
- package/dist/lib/buildCustomTypeDirectoryPath.js +9 -0
- package/dist/lib/buildCustomTypeDirectoryPath.js.map +1 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs +7 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.d.ts +7 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.js +7 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.js.map +1 -0
- package/dist/lib/buildSliceAssetPath.cjs +34 -0
- package/dist/lib/buildSliceAssetPath.cjs.map +1 -0
- package/dist/lib/buildSliceAssetPath.d.ts +11 -0
- package/dist/lib/buildSliceAssetPath.js +17 -0
- package/dist/lib/buildSliceAssetPath.js.map +1 -0
- package/dist/lib/buildSliceDirectoryPath.cjs +30 -0
- package/dist/lib/buildSliceDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildSliceDirectoryPath.d.ts +10 -0
- package/dist/lib/buildSliceDirectoryPath.js +13 -0
- package/dist/lib/buildSliceDirectoryPath.js.map +1 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.cjs +7 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.d.ts +8 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.js +7 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.js.map +1 -0
- package/dist/lib/checkIsTypeScriptProject.cjs +9 -0
- package/dist/lib/checkIsTypeScriptProject.cjs.map +1 -0
- package/dist/lib/checkIsTypeScriptProject.d.ts +8 -0
- package/dist/lib/checkIsTypeScriptProject.js +9 -0
- package/dist/lib/checkIsTypeScriptProject.js.map +1 -0
- package/dist/lib/checkPathExists.cjs +30 -0
- package/dist/lib/checkPathExists.cjs.map +1 -0
- package/dist/lib/checkPathExists.d.ts +2 -0
- package/dist/lib/checkPathExists.js +13 -0
- package/dist/lib/checkPathExists.js.map +1 -0
- package/dist/lib/isSharedSliceModel.cjs +7 -0
- package/dist/lib/isSharedSliceModel.cjs.map +1 -0
- package/dist/lib/isSharedSliceModel.d.ts +335 -0
- package/dist/lib/isSharedSliceModel.js +7 -0
- package/dist/lib/isSharedSliceModel.js.map +1 -0
- package/dist/lib/pascalCase.cjs +8 -0
- package/dist/lib/pascalCase.cjs.map +1 -0
- package/dist/lib/pascalCase.d.ts +8 -0
- package/dist/lib/pascalCase.js +8 -0
- package/dist/lib/pascalCase.js.map +1 -0
- package/dist/lib/readJSONFile.cjs +26 -0
- package/dist/lib/readJSONFile.cjs.map +1 -0
- package/dist/lib/readJSONFile.d.ts +1 -0
- package/dist/lib/readJSONFile.js +9 -0
- package/dist/lib/readJSONFile.js.map +1 -0
- package/dist/lib/rejectIfNecessary.cjs +10 -0
- package/dist/lib/rejectIfNecessary.cjs.map +1 -0
- package/dist/lib/rejectIfNecessary.d.ts +1 -0
- package/dist/lib/rejectIfNecessary.js +10 -0
- package/dist/lib/rejectIfNecessary.js.map +1 -0
- package/dist/lib/updateSliceModelFile.cjs +33 -0
- package/dist/lib/updateSliceModelFile.cjs.map +1 -0
- package/dist/lib/updateSliceModelFile.d.ts +9 -0
- package/dist/lib/updateSliceModelFile.js +15 -0
- package/dist/lib/updateSliceModelFile.js.map +1 -0
- package/dist/lib/upsertGlobalContentTypes.cjs +55 -0
- package/dist/lib/upsertGlobalContentTypes.cjs.map +1 -0
- package/dist/lib/upsertGlobalContentTypes.d.ts +12 -0
- package/dist/lib/upsertGlobalContentTypes.js +37 -0
- package/dist/lib/upsertGlobalContentTypes.js.map +1 -0
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +83 -0
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -0
- package/dist/lib/upsertSliceLibraryIndexFile.d.ts +7 -0
- package/dist/lib/upsertSliceLibraryIndexFile.js +65 -0
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -0
- package/dist/packages/adapter-nuxt/package.json.cjs +5 -0
- package/dist/packages/adapter-nuxt/package.json.cjs.map +1 -0
- package/dist/packages/adapter-nuxt/package.json.js +5 -0
- package/dist/packages/adapter-nuxt/package.json.js.map +1 -0
- package/dist/plugin.cjs +59 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +59 -0
- package/dist/plugin.js.map +1 -0
- package/dist/simulator/SliceSimulator.cjs +79 -0
- package/dist/simulator/SliceSimulator.cjs.map +1 -0
- package/dist/simulator/SliceSimulator.d.ts +34 -0
- package/dist/simulator/SliceSimulator.js +79 -0
- package/dist/simulator/SliceSimulator.js.map +1 -0
- package/dist/simulator/index.d.ts +2 -0
- package/dist/simulator.cjs +5 -0
- package/dist/simulator.cjs.map +1 -0
- package/dist/simulator.js +5 -0
- package/dist/simulator.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/package.json +107 -0
- package/src/constants.ts +5 -0
- package/src/hooks/customType-asset-delete.ts +18 -0
- package/src/hooks/customType-asset-read.ts +22 -0
- package/src/hooks/customType-asset-update.ts +20 -0
- package/src/hooks/customType-create.ts +45 -0
- package/src/hooks/customType-delete.ts +21 -0
- package/src/hooks/customType-read.ts +24 -0
- package/src/hooks/customType-rename.ts +3 -0
- package/src/hooks/customType-update.ts +3 -0
- package/src/hooks/customTypeLibrary-read.ts +53 -0
- package/src/hooks/project-init.ts +163 -0
- package/src/hooks/slice-asset-delete.ts +21 -0
- package/src/hooks/slice-asset-read.ts +25 -0
- package/src/hooks/slice-asset-update.ts +23 -0
- package/src/hooks/slice-create.ts +115 -0
- package/src/hooks/slice-delete.ts +41 -0
- package/src/hooks/slice-read.ts +69 -0
- package/src/hooks/slice-rename.ts +46 -0
- package/src/hooks/slice-update.ts +19 -0
- package/src/hooks/sliceLibrary-read.ts +48 -0
- package/src/hooks/sliceSimulator-setup-read.ts +209 -0
- package/src/hooks/snippet-read.ts +145 -0
- package/src/index.ts +4 -0
- package/src/lib/buildCustomTypeAssetPath.ts +24 -0
- package/src/lib/buildCustomTypeDirectoryPath.ts +20 -0
- package/src/lib/buildCustomTypeLibraryDirectoryPath.ts +13 -0
- package/src/lib/buildSliceAssetPath.ts +32 -0
- package/src/lib/buildSliceDirectoryPath.ts +26 -0
- package/src/lib/buildSliceLibraryDirectoryPath.ts +14 -0
- package/src/lib/checkIsTypeScriptProject.ts +17 -0
- package/src/lib/checkPathExists.ts +12 -0
- package/src/lib/isSharedSliceModel.ts +14 -0
- package/src/lib/pascalCase.ts +12 -0
- package/src/lib/readJSONFile.ts +7 -0
- package/src/lib/rejectIfNecessary.ts +16 -0
- package/src/lib/updateSliceModelFile.ts +33 -0
- package/src/lib/upsertGlobalContentTypes.ts +62 -0
- package/src/lib/upsertSliceLibraryIndexFile.ts +90 -0
- package/src/plugin.ts +63 -0
- package/src/simulator/SliceSimulator.ts +157 -0
- package/src/simulator/index.ts +2 -0
- 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,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,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
|
+
};
|