@slicemachine/adapter-next 0.0.9 → 0.0.11
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/hooks/command-init.cjs +196 -0
- package/dist/hooks/command-init.cjs.map +1 -0
- package/dist/hooks/command-init.d.ts +3 -0
- package/dist/hooks/command-init.js +178 -0
- package/dist/hooks/command-init.js.map +1 -0
- package/dist/hooks/slice-create.cjs +8 -3
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +8 -3
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.cjs +12 -2
- package/dist/hooks/sliceSimulator-setup-read.cjs.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.js +12 -2
- package/dist/hooks/sliceSimulator-setup-read.js.map +1 -1
- 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/getJSOrTSXFileExtension.cjs +8 -3
- package/dist/lib/getJSOrTSXFileExtension.cjs.map +1 -1
- package/dist/lib/getJSOrTSXFileExtension.d.ts +7 -1
- package/dist/lib/getJSOrTSXFileExtension.js +8 -3
- package/dist/lib/getJSOrTSXFileExtension.js.map +1 -1
- package/dist/lib/rejectIfNecessary.cjs.map +1 -1
- package/dist/lib/rejectIfNecessary.js.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +37 -11
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js +37 -11
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -1
- package/dist/node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -1
- package/dist/node_modules/data-uri-to-buffer/dist/index.js.map +1 -1
- package/dist/node_modules/fetch-blob/file.cjs +6 -0
- package/dist/node_modules/fetch-blob/file.cjs.map +1 -1
- package/dist/node_modules/fetch-blob/file.js +6 -0
- package/dist/node_modules/fetch-blob/file.js.map +1 -1
- package/dist/node_modules/fetch-blob/index.cjs +48 -2
- package/dist/node_modules/fetch-blob/index.cjs.map +1 -1
- package/dist/node_modules/fetch-blob/index.js +48 -2
- package/dist/node_modules/fetch-blob/index.js.map +1 -1
- package/dist/node_modules/fetch-blob/streams.cjs.map +1 -1
- package/dist/node_modules/fetch-blob/streams.js.map +1 -1
- package/dist/node_modules/formdata-polyfill/esm.min.cjs.map +1 -1
- package/dist/node_modules/formdata-polyfill/esm.min.js.map +1 -1
- package/dist/node_modules/node-domexception/index.cjs.map +1 -1
- package/dist/node_modules/node-domexception/index.js.map +1 -1
- package/dist/node_modules/node-fetch/src/body.cjs +25 -0
- package/dist/node_modules/node-fetch/src/body.cjs.map +1 -1
- package/dist/node_modules/node-fetch/src/body.js +25 -0
- package/dist/node_modules/node-fetch/src/body.js.map +1 -1
- package/dist/node_modules/node-fetch/src/errors/base.cjs.map +1 -1
- package/dist/node_modules/node-fetch/src/errors/base.js.map +1 -1
- package/dist/node_modules/node-fetch/src/errors/fetch-error.cjs +5 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.cjs.map +1 -1
- package/dist/node_modules/node-fetch/src/errors/fetch-error.js +5 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.js.map +1 -1
- package/dist/node_modules/node-fetch/src/headers.cjs +17 -0
- package/dist/node_modules/node-fetch/src/headers.cjs.map +1 -1
- package/dist/node_modules/node-fetch/src/headers.js +17 -0
- package/dist/node_modules/node-fetch/src/headers.js.map +1 -1
- package/dist/node_modules/node-fetch/src/index.cjs.map +1 -1
- package/dist/node_modules/node-fetch/src/index.js.map +1 -1
- package/dist/node_modules/node-fetch/src/request.cjs +13 -0
- package/dist/node_modules/node-fetch/src/request.cjs.map +1 -1
- package/dist/node_modules/node-fetch/src/request.js +13 -0
- package/dist/node_modules/node-fetch/src/request.js.map +1 -1
- package/dist/node_modules/node-fetch/src/response.cjs +13 -0
- package/dist/node_modules/node-fetch/src/response.cjs.map +1 -1
- package/dist/node_modules/node-fetch/src/response.js +13 -0
- package/dist/node_modules/node-fetch/src/response.js.map +1 -1
- package/dist/node_modules/node-fetch/src/utils/get-search.cjs.map +1 -1
- package/dist/node_modules/node-fetch/src/utils/get-search.js.map +1 -1
- package/dist/node_modules/node-fetch/src/utils/is.cjs.map +1 -1
- package/dist/node_modules/node-fetch/src/utils/is.js.map +1 -1
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.cjs +6 -0
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -1
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.js +6 -0
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -1
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs +223 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -1
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js +223 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -1
- package/dist/plugin.cjs +4 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +4 -1
- package/dist/plugin.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +15 -15
- package/src/hooks/command-init.ts +227 -0
- package/src/hooks/slice-create.ts +12 -3
- package/src/hooks/sliceSimulator-setup-read.ts +11 -2
- package/src/lib/checkIsTypeScriptProject.ts +17 -0
- package/src/lib/checkPathExists.ts +12 -0
- package/src/lib/getJSOrTSXFileExtension.ts +18 -5
- package/src/lib/upsertSliceLibraryIndexFile.ts +44 -10
- package/src/plugin.ts +4 -0
- package/src/types.ts +1 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { source } from "common-tags";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fetch from "../node_modules/node-fetch/src/index.js";
|
|
4
|
+
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
|
|
4
5
|
import { getJSOrTSXFileExtension } from "../lib/getJSOrTSXFileExtension.js";
|
|
5
6
|
const REQUIRED_DEPENDENCIES = [
|
|
6
7
|
"@prismicio/react",
|
|
@@ -12,6 +13,8 @@ const createStep1 = async ({ project, helpers }) => {
|
|
|
12
13
|
return {
|
|
13
14
|
title: "Install packages",
|
|
14
15
|
description: "The simulator requires some dependencies.",
|
|
16
|
+
// TODO: Create a plugin runner helper to provide the correct
|
|
17
|
+
// package manager
|
|
15
18
|
body: source`
|
|
16
19
|
The simulator requires extra dependencies. Run the following command to install them.
|
|
17
20
|
|
|
@@ -51,10 +54,17 @@ const createStep1 = async ({ project, helpers }) => {
|
|
|
51
54
|
};
|
|
52
55
|
};
|
|
53
56
|
const createStep2 = async ({ helpers, options }) => {
|
|
54
|
-
const fileName = `slice-simulator.${getJSOrTSXFileExtension(
|
|
57
|
+
const fileName = `slice-simulator.${await getJSOrTSXFileExtension({
|
|
58
|
+
helpers,
|
|
59
|
+
options
|
|
60
|
+
})}`;
|
|
55
61
|
const filePath = helpers.joinPathFromRoot("pages", fileName);
|
|
56
62
|
let fileContents;
|
|
57
|
-
|
|
63
|
+
const isTypeScriptProject = await checkIsTypeScriptProject({
|
|
64
|
+
helpers,
|
|
65
|
+
options
|
|
66
|
+
});
|
|
67
|
+
if (isTypeScriptProject) {
|
|
58
68
|
fileContents = await helpers.format(source`
|
|
59
69
|
import { SliceSimulator } from "@slicemachine/adapter-next/simulator";
|
|
60
70
|
import { SliceZone } from "@prismicio/react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliceSimulator-setup-read.js","sources":["../../../src/hooks/sliceSimulator-setup-read.ts"],"sourcesContent":["import type {\n\tSliceMachineContext,\n\tSliceSimulatorSetupReadHook,\n\tSliceSimulatorSetupStep,\n} from \"@slicemachine/plugin-kit\";\nimport { source } from \"common-tags\";\nimport { createRequire } from \"node:module\";\nimport fetch from \"node-fetch\";\n\nimport { getJSOrTSXFileExtension } from \"../lib/getJSOrTSXFileExtension\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst REQUIRED_DEPENDENCIES = [\n\t\"@prismicio/react\",\n\t\"@prismicio/client\",\n\t\"@prismicio/helpers\",\n];\n\ntype Args = SliceMachineContext<PluginOptions>;\n\nconst createStep1 = async ({\n\tproject,\n\thelpers,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst require = createRequire(project.root);\n\n\treturn {\n\t\ttitle: \"Install packages\",\n\t\tdescription: \"The simulator requires some dependencies.\",\n\t\t// TODO: Create a plugin runner helper to provide the correct\n\t\t// package manager\n\t\tbody: source`\n\t\t\tThe simulator requires extra dependencies. Run the following command to install them.\n\n\t\t\t~~~sh\n\t\t\tnpm install --save ${REQUIRED_DEPENDENCIES.join(\" \")}\n\t\t\t~~~\n\t\t`,\n\t\tvalidate: async () => {\n\t\t\tconst missingDependencies: string[] = [];\n\n\t\t\tfor (const dependency of REQUIRED_DEPENDENCIES) {\n\t\t\t\ttry {\n\t\t\t\t\t// `require.resolve()` is preferred\n\t\t\t\t\t// over `import()` because we don't\n\t\t\t\t\t// want to load the module. Loading a\n\t\t\t\t\t// module could introduce side-effects.\n\t\t\t\t\trequire.resolve(dependency, {\n\t\t\t\t\t\tpaths: [helpers.joinPathFromRoot(\"node_modules\")],\n\t\t\t\t\t});\n\t\t\t\t} catch {\n\t\t\t\t\tmissingDependencies.push(dependency);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingDependencies.length >= REQUIRED_DEPENDENCIES.length) {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"Missing all dependencies\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tInstall the required dependencies to continue.\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (missingDependencies.length > 0) {\n\t\t\t\tconst formattedMissingDependencies = missingDependencies\n\t\t\t\t\t.map((missingDependency) => `\\`${missingDependency}\\``)\n\t\t\t\t\t.join(\", \");\n\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"Missing some dependencies\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tThe following dependencies are missing: ${formattedMissingDependencies}\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t};\n};\n\nconst createStep2 = async ({\n\thelpers,\n\toptions,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst fileName = `slice-simulator.${getJSOrTSXFileExtension(
|
|
1
|
+
{"version":3,"file":"sliceSimulator-setup-read.js","sources":["../../../src/hooks/sliceSimulator-setup-read.ts"],"sourcesContent":["import type {\n\tSliceMachineContext,\n\tSliceSimulatorSetupReadHook,\n\tSliceSimulatorSetupStep,\n} from \"@slicemachine/plugin-kit\";\nimport { source } from \"common-tags\";\nimport { createRequire } from \"node:module\";\nimport fetch from \"node-fetch\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSOrTSXFileExtension } from \"../lib/getJSOrTSXFileExtension\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst REQUIRED_DEPENDENCIES = [\n\t\"@prismicio/react\",\n\t\"@prismicio/client\",\n\t\"@prismicio/helpers\",\n];\n\ntype Args = SliceMachineContext<PluginOptions>;\n\nconst createStep1 = async ({\n\tproject,\n\thelpers,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst require = createRequire(project.root);\n\n\treturn {\n\t\ttitle: \"Install packages\",\n\t\tdescription: \"The simulator requires some dependencies.\",\n\t\t// TODO: Create a plugin runner helper to provide the correct\n\t\t// package manager\n\t\tbody: source`\n\t\t\tThe simulator requires extra dependencies. Run the following command to install them.\n\n\t\t\t~~~sh\n\t\t\tnpm install --save ${REQUIRED_DEPENDENCIES.join(\" \")}\n\t\t\t~~~\n\t\t`,\n\t\tvalidate: async () => {\n\t\t\tconst missingDependencies: string[] = [];\n\n\t\t\tfor (const dependency of REQUIRED_DEPENDENCIES) {\n\t\t\t\ttry {\n\t\t\t\t\t// `require.resolve()` is preferred\n\t\t\t\t\t// over `import()` because we don't\n\t\t\t\t\t// want to load the module. Loading a\n\t\t\t\t\t// module could introduce side-effects.\n\t\t\t\t\trequire.resolve(dependency, {\n\t\t\t\t\t\tpaths: [helpers.joinPathFromRoot(\"node_modules\")],\n\t\t\t\t\t});\n\t\t\t\t} catch {\n\t\t\t\t\tmissingDependencies.push(dependency);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingDependencies.length >= REQUIRED_DEPENDENCIES.length) {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"Missing all dependencies\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tInstall the required dependencies to continue.\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (missingDependencies.length > 0) {\n\t\t\t\tconst formattedMissingDependencies = missingDependencies\n\t\t\t\t\t.map((missingDependency) => `\\`${missingDependency}\\``)\n\t\t\t\t\t.join(\", \");\n\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"Missing some dependencies\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tThe following dependencies are missing: ${formattedMissingDependencies}\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t};\n};\n\nconst createStep2 = async ({\n\thelpers,\n\toptions,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst fileName = `slice-simulator.${await getJSOrTSXFileExtension({\n\t\thelpers,\n\t\toptions,\n\t})}`;\n\tconst filePath = helpers.joinPathFromRoot(\"pages\", fileName);\n\n\tlet fileContents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\tfileContents = await helpers.format(\n\t\t\tsource`\n\t\t\t\timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\timport { components } from \"../slices\";\n\n\t\t\t\texport default function SliceSimulatorPage(): JSX.Element {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SliceSimulator\n\t\t\t\t\t\t\tsliceZone={(props) => <SliceZone {...props} components={components} />}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t`,\n\t\t\tfilePath,\n\t\t\t{\n\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t},\n\t\t);\n\t} else {\n\t\tfileContents = await helpers.format(\n\t\t\tsource`\n\t\t\t\timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\timport { components } from \"../slices\";\n\n\t\t\t\texport default function SliceSimulatorPage() {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SliceSimulator\n\t\t\t\t\t\t\tsliceZone={(props) => <SliceZone {...props} components={components} />}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t`,\n\t\t\tfilePath,\n\t\t\t{\n\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t},\n\t\t);\n\t}\n\n\treturn {\n\t\ttitle: \"Create a page for the simulator\",\n\t\tdescription: `In your \\`pages\\` directory, create a file called \\`${fileName}\\` containing this code.`,\n\t\tbody: source`\n\t\t\tIn your \\`pages\\` directory, create a file called \\`${fileName}\\` and add the following code. This route will be used to simulate and develop your components.\n\n\t\t\t~~~tsx\n\t\t\t${fileContents}\n\t\t\t~~~\n\t\t`,\n\t};\n};\n\nconst createStep3 = async ({\n\thelpers,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst filePath = helpers.joinPathFromRoot(\"slicemachine.config.json\");\n\tconst fileContents = await helpers.format(\n\t\tsource`\n\t\t\t{\n\t\t\t\t\"localSliceSimulatorURL\": \"http://localhost:3000/slice-simulator\"\n\t\t\t}\n\t\t`,\n\t\tfilePath,\n\t\t{\n\t\t\tincludeNewlineAtEnd: false,\n\t\t},\n\t);\n\n\treturn {\n\t\ttitle: \"Update `slicemachine.config.json`\",\n\t\tdescription: `Update your \\`slicemachine.config.json\\` file with a \\`localSliceSimulatorURL\\` property pointing to your \\`/slice-simulator\\` page.`,\n\t\tbody: source`\n\t\t\tUpdate your \\`slicemachine.config.json\\` file with a \\`localSliceSimulatorURL\\` property pointing to your \\`/slice-simulator\\` page.\n\n\t\t\t~~~json\n\t\t\t${fileContents}\n\t\t\t~~~\n\t\t`,\n\t\tvalidate: async () => {\n\t\t\tconst project = await helpers.getProject();\n\n\t\t\tif (!(\"localSliceSimulatorURL\" in project.config)) {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"Missing `localSliceSimulatorURL` property\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tA \\`localSliceSimulatorURL\\` property was not found in your \\`slicemachine.config.json\\` file.\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Test if the URL is valid.\n\t\t\ttry {\n\t\t\t\tif (project.config.localSliceSimulatorURL) {\n\t\t\t\t\tnew URL(project.config.localSliceSimulatorURL);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"Undefined Slice Simulator URL\");\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"An invalid URL was provided\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tThe \\`localSliceSimulatorURL\\` property should be of the shape \\`http://localhost:PORT/PATH\\`. See the codeblock for an example.\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Check if the URL is accessible.\n\t\t\tconst res = await fetch(project.config.localSliceSimulatorURL);\n\n\t\t\tif (!res.ok) {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"Unable to connect to simulator page\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tCheck that the \\`localSliceSimulatorURL\\` property in \\`slicemachine.config.json\\` is correct and try again. See the [troubleshooting page](https://prismic.io/docs/technologies/setup-slice-simulator-nextjs) for more details.\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t};\n};\n\nexport const sliceSimulatorSetupRead: SliceSimulatorSetupReadHook<\n\tPluginOptions\n> = async (_data, context) => {\n\treturn Promise.all([\n\t\tcreateStep1(context),\n\t\tcreateStep2(context),\n\t\tcreateStep3(context),\n\t]);\n};\n"],"names":["require"],"mappings":";;;;;AAcA,MAAM,wBAAwB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;;AAKD,MAAM,cAAc,OAAO,EAC1B,SACA,cAC4C;AACtC,QAAAA,WAAU,cAAc,QAAQ,IAAI;AAEnC,SAAA;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA;AAAA;AAAA,IAGb,MAAM;AAAA;AAAA;AAAA;AAAA,wBAIgB,sBAAsB,KAAK,GAAG;AAAA;AAAA;AAAA,IAGpD,UAAU,YAAW;AACpB,YAAM,sBAAgC,CAAA;AAEtC,iBAAW,cAAc,uBAAuB;AAC3C,YAAA;AAKH,UAAAA,SAAQ,QAAQ,YAAY;AAAA,YAC3B,OAAO,CAAC,QAAQ,iBAAiB,cAAc,CAAC;AAAA,UAAA,CAChD;AAAA,QAAA,QACA;AACD,8BAAoB,KAAK,UAAU;AAAA,QACnC;AAAA,MACD;AAEG,UAAA,oBAAoB,UAAU,sBAAsB,QAAQ;AACxD,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA;AAAA;AAAA,QAAA;AAAA,MAIV;AAEG,UAAA,oBAAoB,SAAS,GAAG;AAC7B,cAAA,+BAA+B,oBACnC,IAAI,CAAC,sBAAsB,KAAK,qBAAqB,EACrD,KAAK,IAAI;AAEJ,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA,gDACkC;AAAA;AAAA,QAAA;AAAA,MAG5C;AAAA,IACF;AAAA,EAAA;AAEF;AAEA,MAAM,cAAc,OAAO,EAC1B,SACA,cAC4C;AACtC,QAAA,WAAW,mBAAmB,MAAM,wBAAwB;AAAA,IACjE;AAAA,IACA;AAAA,EACA,CAAA;AACD,QAAM,WAAW,QAAQ,iBAAiB,SAAS,QAAQ;AAEvD,MAAA;AAEE,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,qBAAqB;AACT,mBAAA,MAAM,QAAQ,OAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAcA,UACA;AAAA,MACC,qBAAqB;AAAA,IAAA,CACrB;AAAA,EAAA,OAEI;AACS,mBAAA,MAAM,QAAQ,OAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAcA,UACA;AAAA,MACC,qBAAqB;AAAA,IAAA,CACrB;AAAA,EAEF;AAEM,SAAA;AAAA,IACN,OAAO;AAAA,IACP,aAAa,uDAAuD;AAAA,IACpE,MAAM;AAAA,yDACiD;AAAA;AAAA;AAAA,KAGpD;AAAA;AAAA;AAAA,EAAA;AAIL;AAEA,MAAM,cAAc,OAAO,EAC1B,cAC4C;AACtC,QAAA,WAAW,QAAQ,iBAAiB,0BAA0B;AAC9D,QAAA,eAAe,MAAM,QAAQ,OAClC;AAAA;AAAA;AAAA;AAAA,KAKA,UACA;AAAA,IACC,qBAAqB;AAAA,EAAA,CACrB;AAGK,SAAA;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA;AAAA;AAAA;AAAA,KAIH;AAAA;AAAA;AAAA,IAGH,UAAU,YAAW;AACd,YAAA,UAAU,MAAM,QAAQ;AAE1B,UAAA,EAAE,4BAA4B,QAAQ,SAAS;AAC3C,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA;AAAA;AAAA,QAAA;AAAA,MAIV;AAGG,UAAA;AACC,YAAA,QAAQ,OAAO,wBAAwB;AACtC,cAAA,IAAI,QAAQ,OAAO,sBAAsB;AAAA,QAAA,OACvC;AACA,gBAAA,IAAI,MAAM,+BAA+B;AAAA,QAC/C;AAAA,MAAA,QACA;AACM,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA;AAAA;AAAA,QAAA;AAAA,MAIV;AAGD,YAAM,MAAM,MAAM,MAAM,QAAQ,OAAO,sBAAsB;AAEzD,UAAA,CAAC,IAAI,IAAI;AACL,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA;AAAA;AAAA,QAAA;AAAA,MAIV;AAAA,IACF;AAAA,EAAA;AAEF;AAEa,MAAA,0BAET,OAAO,OAAO,YAAW;AAC5B,SAAO,QAAQ,IAAI;AAAA,IAClB,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,EAAA,CACnB;AACF;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const checkPathExists = require("./checkPathExists.cjs");
|
|
4
|
+
const checkIsTypeScriptProject = async (args) => {
|
|
5
|
+
const tsConfigPath = args.helpers.joinPathFromRoot("tsconfig.json");
|
|
6
|
+
return args.options.typescript ?? await checkPathExists.checkPathExists(tsConfigPath);
|
|
7
|
+
};
|
|
8
|
+
exports.checkIsTypeScriptProject = checkIsTypeScriptProject;
|
|
9
|
+
//# sourceMappingURL=checkIsTypeScriptProject.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkIsTypeScriptProject.cjs","sources":["../../../src/lib/checkIsTypeScriptProject.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\n\nimport { PluginOptions } from \"../types\";\nimport { checkPathExists } from \"./checkPathExists\";\n\ntype CheckIsTypeScriptProjectArgs = {\n\thelpers: SliceMachineContext<PluginOptions>[\"helpers\"];\n\toptions: SliceMachineContext<PluginOptions>[\"options\"];\n};\n\nexport const checkIsTypeScriptProject = async (\n\targs: CheckIsTypeScriptProjectArgs,\n): Promise<boolean> => {\n\tconst tsConfigPath = args.helpers.joinPathFromRoot(\"tsconfig.json\");\n\n\treturn args.options.typescript ?? (await checkPathExists(tsConfigPath));\n};\n"],"names":["checkPathExists"],"mappings":";;;AAUa,MAAA,2BAA2B,OACvC,SACqB;AACrB,QAAM,eAAe,KAAK,QAAQ,iBAAiB,eAAe;AAElE,SAAO,KAAK,QAAQ,cAAe,MAAMA,gCAAgB,YAAY;AACtE;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
+
import { PluginOptions } from "../types";
|
|
3
|
+
type CheckIsTypeScriptProjectArgs = {
|
|
4
|
+
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
5
|
+
options: SliceMachineContext<PluginOptions>["options"];
|
|
6
|
+
};
|
|
7
|
+
export declare const checkIsTypeScriptProject: (args: CheckIsTypeScriptProjectArgs) => Promise<boolean>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { checkPathExists } from "./checkPathExists.js";
|
|
2
|
+
const checkIsTypeScriptProject = async (args) => {
|
|
3
|
+
const tsConfigPath = args.helpers.joinPathFromRoot("tsconfig.json");
|
|
4
|
+
return args.options.typescript ?? await checkPathExists(tsConfigPath);
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
checkIsTypeScriptProject
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=checkIsTypeScriptProject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkIsTypeScriptProject.js","sources":["../../../src/lib/checkIsTypeScriptProject.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\n\nimport { PluginOptions } from \"../types\";\nimport { checkPathExists } from \"./checkPathExists\";\n\ntype CheckIsTypeScriptProjectArgs = {\n\thelpers: SliceMachineContext<PluginOptions>[\"helpers\"];\n\toptions: SliceMachineContext<PluginOptions>[\"options\"];\n};\n\nexport const checkIsTypeScriptProject = async (\n\targs: CheckIsTypeScriptProjectArgs,\n): Promise<boolean> => {\n\tconst tsConfigPath = args.helpers.joinPathFromRoot(\"tsconfig.json\");\n\n\treturn args.options.typescript ?? (await checkPathExists(tsConfigPath));\n};\n"],"names":[],"mappings":";AAUa,MAAA,2BAA2B,OACvC,SACqB;AACrB,QAAM,eAAe,KAAK,QAAQ,iBAAiB,eAAe;AAElE,SAAO,KAAK,QAAQ,cAAe,MAAM,gBAAgB,YAAY;AACtE;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
function _interopNamespaceDefault(e) {
|
|
5
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
6
|
+
if (e) {
|
|
7
|
+
for (const k in e) {
|
|
8
|
+
if (k !== "default") {
|
|
9
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
10
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: () => e[k]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
n.default = e;
|
|
18
|
+
return Object.freeze(n);
|
|
19
|
+
}
|
|
20
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
21
|
+
const checkPathExists = async (path) => {
|
|
22
|
+
try {
|
|
23
|
+
await fs__namespace.access(path);
|
|
24
|
+
return true;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.checkPathExists = checkPathExists;
|
|
30
|
+
//# sourceMappingURL=checkPathExists.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkPathExists.cjs","sources":["../../../src/lib/checkPathExists.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport { PathLike } from \"node:fs\";\n\nexport const checkPathExists = async (path: PathLike): Promise<boolean> => {\n\ttry {\n\t\tawait fs.access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n"],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGa,MAAA,kBAAkB,OAAO,SAAoC;AACrE,MAAA;AACG,UAAAA,cAAG,OAAO,IAAI;AAEb,WAAA;AAAA,EAAA,QACN;AACM,WAAA;AAAA,EACP;AACF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkPathExists.js","sources":["../../../src/lib/checkPathExists.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport { PathLike } from \"node:fs\";\n\nexport const checkPathExists = async (path: PathLike): Promise<boolean> => {\n\ttry {\n\t\tawait fs.access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n"],"names":[],"mappings":";AAGa,MAAA,kBAAkB,OAAO,SAAoC;AACrE,MAAA;AACG,UAAA,GAAG,OAAO,IAAI;AAEb,WAAA;AAAA,EAAA,QACN;AACM,WAAA;AAAA,EACP;AACF;"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const checkIsTypeScriptProject = require("./checkIsTypeScriptProject.cjs");
|
|
4
|
+
const getJSOrTSXFileExtension = async (args) => {
|
|
5
|
+
const isTypeScriptProject = await checkIsTypeScriptProject.checkIsTypeScriptProject({
|
|
6
|
+
helpers: args.helpers,
|
|
7
|
+
options: args.options
|
|
8
|
+
});
|
|
9
|
+
if (isTypeScriptProject) {
|
|
5
10
|
return "tsx";
|
|
6
|
-
} else if (
|
|
11
|
+
} else if (args.options.jsxExtension) {
|
|
7
12
|
return "jsx";
|
|
8
13
|
} else {
|
|
9
14
|
return "js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getJSOrTSXFileExtension.cjs","sources":["../../../src/lib/getJSOrTSXFileExtension.ts"],"sourcesContent":["import type { PluginOptions } from \"../types\";\n\nexport const getJSOrTSXFileExtension = (\n\
|
|
1
|
+
{"version":3,"file":"getJSOrTSXFileExtension.cjs","sources":["../../../src/lib/getJSOrTSXFileExtension.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"./checkIsTypeScriptProject\";\n\ntype GetJSOrTSXFileExtensionArgs = {\n\thelpers: SliceMachineContext<PluginOptions>[\"helpers\"];\n\toptions: SliceMachineContext<PluginOptions>[\"options\"];\n};\n\nexport const getJSOrTSXFileExtension = async (\n\targs: GetJSOrTSXFileExtensionArgs,\n): Promise<string> => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers: args.helpers,\n\t\toptions: args.options,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\treturn \"tsx\";\n\t} else if (args.options.jsxExtension) {\n\t\treturn \"jsx\";\n\t} else {\n\t\treturn \"js\";\n\t}\n};\n"],"names":["checkIsTypeScriptProject"],"mappings":";;;AAUa,MAAA,0BAA0B,OACtC,SACoB;AACd,QAAA,sBAAsB,MAAMA,kDAAyB;AAAA,IAC1D,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,qBAAqB;AACjB,WAAA;AAAA,EAAA,WACG,KAAK,QAAQ,cAAc;AAC9B,WAAA;AAAA,EAAA,OACD;AACC,WAAA;AAAA,EACP;AACF;;"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
1
2
|
import type { PluginOptions } from "../types";
|
|
2
|
-
|
|
3
|
+
type GetJSOrTSXFileExtensionArgs = {
|
|
4
|
+
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
5
|
+
options: SliceMachineContext<PluginOptions>["options"];
|
|
6
|
+
};
|
|
7
|
+
export declare const getJSOrTSXFileExtension: (args: GetJSOrTSXFileExtensionArgs) => Promise<string>;
|
|
8
|
+
export {};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { checkIsTypeScriptProject } from "./checkIsTypeScriptProject.js";
|
|
2
|
+
const getJSOrTSXFileExtension = async (args) => {
|
|
3
|
+
const isTypeScriptProject = await checkIsTypeScriptProject({
|
|
4
|
+
helpers: args.helpers,
|
|
5
|
+
options: args.options
|
|
6
|
+
});
|
|
7
|
+
if (isTypeScriptProject) {
|
|
3
8
|
return "tsx";
|
|
4
|
-
} else if (
|
|
9
|
+
} else if (args.options.jsxExtension) {
|
|
5
10
|
return "jsx";
|
|
6
11
|
} else {
|
|
7
12
|
return "js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getJSOrTSXFileExtension.js","sources":["../../../src/lib/getJSOrTSXFileExtension.ts"],"sourcesContent":["import type { PluginOptions } from \"../types\";\n\nexport const getJSOrTSXFileExtension = (\n\
|
|
1
|
+
{"version":3,"file":"getJSOrTSXFileExtension.js","sources":["../../../src/lib/getJSOrTSXFileExtension.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"./checkIsTypeScriptProject\";\n\ntype GetJSOrTSXFileExtensionArgs = {\n\thelpers: SliceMachineContext<PluginOptions>[\"helpers\"];\n\toptions: SliceMachineContext<PluginOptions>[\"options\"];\n};\n\nexport const getJSOrTSXFileExtension = async (\n\targs: GetJSOrTSXFileExtensionArgs,\n): Promise<string> => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers: args.helpers,\n\t\toptions: args.options,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\treturn \"tsx\";\n\t} else if (args.options.jsxExtension) {\n\t\treturn \"jsx\";\n\t} else {\n\t\treturn \"js\";\n\t}\n};\n"],"names":[],"mappings":";AAUa,MAAA,0BAA0B,OACtC,SACoB;AACd,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,qBAAqB;AACjB,WAAA;AAAA,EAAA,WACG,KAAK,QAAQ,cAAc;AAC9B,WAAA;AAAA,EAAA,OACD;AACC,WAAA;AAAA,EACP;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rejectIfNecessary.cjs","sources":["../../../src/lib/rejectIfNecessary.ts"],"sourcesContent":["export const rejectIfNecessary = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTPromiseSettledResults extends readonly PromiseSettledResult<any>[],\n>(\n\tpromiseSettledResults: TPromiseSettledResults,\n): void => {\n\tconst rejectedReasons = promiseSettledResults\n\t\t.filter(\n\t\t\t(result): result is PromiseRejectedResult => result.status === \"rejected\",\n\t\t)\n\t\t.map((result) => result.reason);\n\n\tif (rejectedReasons.length > 0) {\n\t\tthrow rejectedReasons[0];\n\t}\n};\n"],"names":[],"mappings":";;AAAa,MAAA,oBAAoB,CAIhC,0BACS;AACT,QAAM,kBAAkB,sBACtB,OACA,CAAC,WAA4C,OAAO,WAAW,UAAU,EAEzE,IAAI,CAAC,WAAW,OAAO,MAAM;AAE3B,MAAA,gBAAgB,SAAS,GAAG;AAC/B,UAAM,gBAAgB;AAAA,
|
|
1
|
+
{"version":3,"file":"rejectIfNecessary.cjs","sources":["../../../src/lib/rejectIfNecessary.ts"],"sourcesContent":["export const rejectIfNecessary = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTPromiseSettledResults extends readonly PromiseSettledResult<any>[],\n>(\n\tpromiseSettledResults: TPromiseSettledResults,\n): void => {\n\tconst rejectedReasons = promiseSettledResults\n\t\t.filter(\n\t\t\t(result): result is PromiseRejectedResult => result.status === \"rejected\",\n\t\t)\n\t\t.map((result) => result.reason);\n\n\tif (rejectedReasons.length > 0) {\n\t\tthrow rejectedReasons[0];\n\t}\n};\n"],"names":[],"mappings":";;AAAa,MAAA,oBAAoB,CAIhC,0BACS;AACT,QAAM,kBAAkB,sBACtB,OACA,CAAC,WAA4C,OAAO,WAAW,UAAU,EAEzE,IAAI,CAAC,WAAW,OAAO,MAAM;AAE3B,MAAA,gBAAgB,SAAS,GAAG;AAC/B,UAAM,gBAAgB,CAAC;AAAA,EACvB;AACF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rejectIfNecessary.js","sources":["../../../src/lib/rejectIfNecessary.ts"],"sourcesContent":["export const rejectIfNecessary = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTPromiseSettledResults extends readonly PromiseSettledResult<any>[],\n>(\n\tpromiseSettledResults: TPromiseSettledResults,\n): void => {\n\tconst rejectedReasons = promiseSettledResults\n\t\t.filter(\n\t\t\t(result): result is PromiseRejectedResult => result.status === \"rejected\",\n\t\t)\n\t\t.map((result) => result.reason);\n\n\tif (rejectedReasons.length > 0) {\n\t\tthrow rejectedReasons[0];\n\t}\n};\n"],"names":[],"mappings":"AAAa,MAAA,oBAAoB,CAIhC,0BACS;AACT,QAAM,kBAAkB,sBACtB,OACA,CAAC,WAA4C,OAAO,WAAW,UAAU,EAEzE,IAAI,CAAC,WAAW,OAAO,MAAM;AAE3B,MAAA,gBAAgB,SAAS,GAAG;AAC/B,UAAM,gBAAgB;AAAA,
|
|
1
|
+
{"version":3,"file":"rejectIfNecessary.js","sources":["../../../src/lib/rejectIfNecessary.ts"],"sourcesContent":["export const rejectIfNecessary = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTPromiseSettledResults extends readonly PromiseSettledResult<any>[],\n>(\n\tpromiseSettledResults: TPromiseSettledResults,\n): void => {\n\tconst rejectedReasons = promiseSettledResults\n\t\t.filter(\n\t\t\t(result): result is PromiseRejectedResult => result.status === \"rejected\",\n\t\t)\n\t\t.map((result) => result.reason);\n\n\tif (rejectedReasons.length > 0) {\n\t\tthrow rejectedReasons[0];\n\t}\n};\n"],"names":[],"mappings":"AAAa,MAAA,oBAAoB,CAIhC,0BACS;AACT,QAAM,kBAAkB,sBACtB,OACA,CAAC,WAA4C,OAAO,WAAW,UAAU,EAEzE,IAAI,CAAC,WAAW,OAAO,MAAM;AAE3B,MAAA,gBAAgB,SAAS,GAAG;AAC/B,UAAM,gBAAgB,CAAC;AAAA,EACvB;AACF;"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const commonTags = require("common-tags");
|
|
4
4
|
const fs = require("node:fs/promises");
|
|
5
5
|
const constants = require("../constants.cjs");
|
|
6
|
+
const checkIsTypeScriptProject = require("./checkIsTypeScriptProject.cjs");
|
|
6
7
|
const pascalCase = require("./pascalCase.cjs");
|
|
7
8
|
function _interopNamespaceDefault(e) {
|
|
8
9
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -22,23 +23,48 @@ function _interopNamespaceDefault(e) {
|
|
|
22
23
|
}
|
|
23
24
|
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
24
25
|
const upsertSliceLibraryIndexFile = async (args) => {
|
|
25
|
-
const
|
|
26
|
+
const isTypeScriptProject = await checkIsTypeScriptProject.checkIsTypeScriptProject({
|
|
27
|
+
helpers: args.helpers,
|
|
28
|
+
options: args.options
|
|
29
|
+
});
|
|
30
|
+
const filePath = args.helpers.joinPathFromRoot(args.libraryID, isTypeScriptProject ? "index.ts" : "index.js");
|
|
26
31
|
const slices = await args.actions.readAllSliceModelsForLibrary({
|
|
27
32
|
libraryID: args.libraryID
|
|
28
33
|
});
|
|
29
|
-
let contents
|
|
30
|
-
|
|
34
|
+
let contents;
|
|
35
|
+
if (args.options.lazyLoadSlices) {
|
|
36
|
+
contents = commonTags.stripIndent`
|
|
37
|
+
${constants.NON_EDITABLE_FILE_BANNER}
|
|
38
|
+
|
|
39
|
+
import dynamic from 'next/dynamic'
|
|
31
40
|
|
|
32
|
-
|
|
41
|
+
export const components = {
|
|
42
|
+
${slices.map((slice) => {
|
|
43
|
+
const id = slice.model.id;
|
|
44
|
+
const dirName = pascalCase.pascalCase(slice.model.name);
|
|
45
|
+
return `${id}: dynamic(() => import('./${dirName}'))`;
|
|
46
|
+
}).join(",\n")}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
} else {
|
|
50
|
+
contents = commonTags.stripIndent`
|
|
51
|
+
${constants.NON_EDITABLE_FILE_BANNER}
|
|
33
52
|
|
|
34
|
-
export const components = {
|
|
35
53
|
${slices.map((slice) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
const componentName = pascalCase.pascalCase(slice.model.name);
|
|
55
|
+
const dirName = pascalCase.pascalCase(slice.model.name);
|
|
56
|
+
return `import ${componentName} from "./${dirName}";`;
|
|
57
|
+
}).join("\n")}
|
|
58
|
+
|
|
59
|
+
export const components = {
|
|
60
|
+
${slices.map((slice) => {
|
|
61
|
+
const id = slice.model.id;
|
|
62
|
+
const componentName = pascalCase.pascalCase(slice.model.name);
|
|
63
|
+
return `${id}: ${componentName},`;
|
|
64
|
+
}).join("\n")}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
42
68
|
if (args.options.format) {
|
|
43
69
|
contents = await args.helpers.format(contents, filePath);
|
|
44
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertSliceLibraryIndexFile.cjs","sources":["../../../src/lib/upsertSliceLibraryIndexFile.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport { NON_EDITABLE_FILE_BANNER } from \"../constants\";\n\nimport { PluginOptions } from \"../types\";\n\nimport { pascalCase } from \"./pascalCase\";\n\ntype UpsertSliceLibraryIndexFileArgs = {\n\tlibraryID: string;\n} & SliceMachineContext<PluginOptions>;\n\nexport const upsertSliceLibraryIndexFile = async (\n\targs: UpsertSliceLibraryIndexFileArgs,\n): Promise<void> => {\n\tconst filePath = args.helpers.joinPathFromRoot(\n\t\targs.libraryID,\n\t\
|
|
1
|
+
{"version":3,"file":"upsertSliceLibraryIndexFile.cjs","sources":["../../../src/lib/upsertSliceLibraryIndexFile.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport { NON_EDITABLE_FILE_BANNER } from \"../constants\";\n\nimport { PluginOptions } from \"../types\";\n\nimport { checkIsTypeScriptProject } from \"./checkIsTypeScriptProject\";\nimport { pascalCase } from \"./pascalCase\";\n\ntype UpsertSliceLibraryIndexFileArgs = {\n\tlibraryID: string;\n} & SliceMachineContext<PluginOptions>;\n\nexport const upsertSliceLibraryIndexFile = async (\n\targs: UpsertSliceLibraryIndexFileArgs,\n): Promise<void> => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers: args.helpers,\n\t\toptions: args.options,\n\t});\n\n\tconst filePath = args.helpers.joinPathFromRoot(\n\t\targs.libraryID,\n\t\tisTypeScriptProject ? \"index.ts\" : \"index.js\",\n\t);\n\n\tconst slices = await args.actions.readAllSliceModelsForLibrary({\n\t\tlibraryID: args.libraryID,\n\t});\n\n\tlet contents: string;\n\n\tif (args.options.lazyLoadSlices) {\n\t\tcontents = stripIndent`\n\t\t\t${NON_EDITABLE_FILE_BANNER}\n\n\t\t\timport dynamic from 'next/dynamic'\n\n\t\t\texport const components = {\n\t\t\t\t${slices\n\t\t\t\t\t.map((slice) => {\n\t\t\t\t\t\tconst id = slice.model.id;\n\t\t\t\t\t\tconst dirName = pascalCase(slice.model.name);\n\n\t\t\t\t\t\treturn `${id}: dynamic(() => import('./${dirName}'))`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\",\\n\")}\n\t\t\t}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t${NON_EDITABLE_FILE_BANNER}\n\n\t\t\t${slices\n\t\t\t\t.map((slice) => {\n\t\t\t\t\tconst componentName = pascalCase(slice.model.name);\n\t\t\t\t\tconst dirName = pascalCase(slice.model.name);\n\n\t\t\t\t\treturn `import ${componentName} from \"./${dirName}\";`;\n\t\t\t\t})\n\t\t\t\t.join(\"\\n\")}\n\n\t\t\texport const components = {\n\t\t\t\t${slices\n\t\t\t\t\t.map((slice) => {\n\t\t\t\t\t\tconst id = slice.model.id;\n\t\t\t\t\t\tconst componentName = pascalCase(slice.model.name);\n\n\t\t\t\t\t\treturn `${id}: ${componentName},`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\")}\n\t\t\t}\n\t\t`;\n\t}\n\n\tif (args.options.format) {\n\t\tcontents = await args.helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n"],"names":["checkIsTypeScriptProject","stripIndent","NON_EDITABLE_FILE_BANNER","pascalCase","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAca,MAAA,8BAA8B,OAC1C,SACkB;AACZ,QAAA,sBAAsB,MAAMA,kDAAyB;AAAA,IAC1D,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,EAAA,CACd;AAEK,QAAA,WAAW,KAAK,QAAQ,iBAC7B,KAAK,WACL,sBAAsB,aAAa,UAAU;AAG9C,QAAM,SAAS,MAAM,KAAK,QAAQ,6BAA6B;AAAA,IAC9D,WAAW,KAAK;AAAA,EAAA,CAChB;AAEG,MAAA;AAEA,MAAA,KAAK,QAAQ,gBAAgB;AACrB,eAAAC,WAAAA;AAAAA,KACRC;;;;;MAKC,OACA,IAAI,CAAC,UAAS;AACR,YAAA,KAAK,MAAM,MAAM;AACvB,YAAM,UAAUC,WAAA,WAAW,MAAM,MAAM,IAAI;AAE3C,aAAO,GAAG,+BAA+B;AAAA,IAAA,CACzC,EACA,KAAK,KAAK;AAAA;AAAA;AAAA,EAAA,OAGR;AACK,eAAAF,WAAAA;AAAAA,KACRC;;KAEA,OACA,IAAI,CAAC,UAAS;AACd,YAAM,gBAAgBC,WAAA,WAAW,MAAM,MAAM,IAAI;AACjD,YAAM,UAAUA,WAAA,WAAW,MAAM,MAAM,IAAI;AAE3C,aAAO,UAAU,yBAAyB;AAAA,IAAA,CAC1C,EACA,KAAK,IAAI;AAAA;AAAA;AAAA,MAGR,OACA,IAAI,CAAC,UAAS;AACR,YAAA,KAAK,MAAM,MAAM;AACvB,YAAM,gBAAgBA,WAAA,WAAW,MAAM,MAAM,IAAI;AAEjD,aAAO,GAAG,OAAO;AAAA,IAAA,CACjB,EACA,KAAK,IAAI;AAAA;AAAA;AAAA,EAGb;AAEG,MAAA,KAAK,QAAQ,QAAQ;AACxB,eAAW,MAAM,KAAK,QAAQ,OAAO,UAAU,QAAQ;AAAA,EACvD;AAEK,QAAAC,cAAG,UAAU,UAAU,QAAQ;AACtC;;"}
|
|
@@ -1,25 +1,51 @@
|
|
|
1
1
|
import { stripIndent } from "common-tags";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import { NON_EDITABLE_FILE_BANNER } from "../constants.js";
|
|
4
|
+
import { checkIsTypeScriptProject } from "./checkIsTypeScriptProject.js";
|
|
4
5
|
import { pascalCase } from "./pascalCase.js";
|
|
5
6
|
const upsertSliceLibraryIndexFile = async (args) => {
|
|
6
|
-
const
|
|
7
|
+
const isTypeScriptProject = await checkIsTypeScriptProject({
|
|
8
|
+
helpers: args.helpers,
|
|
9
|
+
options: args.options
|
|
10
|
+
});
|
|
11
|
+
const filePath = args.helpers.joinPathFromRoot(args.libraryID, isTypeScriptProject ? "index.ts" : "index.js");
|
|
7
12
|
const slices = await args.actions.readAllSliceModelsForLibrary({
|
|
8
13
|
libraryID: args.libraryID
|
|
9
14
|
});
|
|
10
|
-
let contents
|
|
11
|
-
|
|
15
|
+
let contents;
|
|
16
|
+
if (args.options.lazyLoadSlices) {
|
|
17
|
+
contents = stripIndent`
|
|
18
|
+
${NON_EDITABLE_FILE_BANNER}
|
|
19
|
+
|
|
20
|
+
import dynamic from 'next/dynamic'
|
|
12
21
|
|
|
13
|
-
|
|
22
|
+
export const components = {
|
|
23
|
+
${slices.map((slice) => {
|
|
24
|
+
const id = slice.model.id;
|
|
25
|
+
const dirName = pascalCase(slice.model.name);
|
|
26
|
+
return `${id}: dynamic(() => import('./${dirName}'))`;
|
|
27
|
+
}).join(",\n")}
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
} else {
|
|
31
|
+
contents = stripIndent`
|
|
32
|
+
${NON_EDITABLE_FILE_BANNER}
|
|
14
33
|
|
|
15
|
-
export const components = {
|
|
16
34
|
${slices.map((slice) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
const componentName = pascalCase(slice.model.name);
|
|
36
|
+
const dirName = pascalCase(slice.model.name);
|
|
37
|
+
return `import ${componentName} from "./${dirName}";`;
|
|
38
|
+
}).join("\n")}
|
|
39
|
+
|
|
40
|
+
export const components = {
|
|
41
|
+
${slices.map((slice) => {
|
|
42
|
+
const id = slice.model.id;
|
|
43
|
+
const componentName = pascalCase(slice.model.name);
|
|
44
|
+
return `${id}: ${componentName},`;
|
|
45
|
+
}).join("\n")}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
23
49
|
if (args.options.format) {
|
|
24
50
|
contents = await args.helpers.format(contents, filePath);
|
|
25
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertSliceLibraryIndexFile.js","sources":["../../../src/lib/upsertSliceLibraryIndexFile.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport { NON_EDITABLE_FILE_BANNER } from \"../constants\";\n\nimport { PluginOptions } from \"../types\";\n\nimport { pascalCase } from \"./pascalCase\";\n\ntype UpsertSliceLibraryIndexFileArgs = {\n\tlibraryID: string;\n} & SliceMachineContext<PluginOptions>;\n\nexport const upsertSliceLibraryIndexFile = async (\n\targs: UpsertSliceLibraryIndexFileArgs,\n): Promise<void> => {\n\tconst filePath = args.helpers.joinPathFromRoot(\n\t\targs.libraryID,\n\t\
|
|
1
|
+
{"version":3,"file":"upsertSliceLibraryIndexFile.js","sources":["../../../src/lib/upsertSliceLibraryIndexFile.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport { NON_EDITABLE_FILE_BANNER } from \"../constants\";\n\nimport { PluginOptions } from \"../types\";\n\nimport { checkIsTypeScriptProject } from \"./checkIsTypeScriptProject\";\nimport { pascalCase } from \"./pascalCase\";\n\ntype UpsertSliceLibraryIndexFileArgs = {\n\tlibraryID: string;\n} & SliceMachineContext<PluginOptions>;\n\nexport const upsertSliceLibraryIndexFile = async (\n\targs: UpsertSliceLibraryIndexFileArgs,\n): Promise<void> => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers: args.helpers,\n\t\toptions: args.options,\n\t});\n\n\tconst filePath = args.helpers.joinPathFromRoot(\n\t\targs.libraryID,\n\t\tisTypeScriptProject ? \"index.ts\" : \"index.js\",\n\t);\n\n\tconst slices = await args.actions.readAllSliceModelsForLibrary({\n\t\tlibraryID: args.libraryID,\n\t});\n\n\tlet contents: string;\n\n\tif (args.options.lazyLoadSlices) {\n\t\tcontents = stripIndent`\n\t\t\t${NON_EDITABLE_FILE_BANNER}\n\n\t\t\timport dynamic from 'next/dynamic'\n\n\t\t\texport const components = {\n\t\t\t\t${slices\n\t\t\t\t\t.map((slice) => {\n\t\t\t\t\t\tconst id = slice.model.id;\n\t\t\t\t\t\tconst dirName = pascalCase(slice.model.name);\n\n\t\t\t\t\t\treturn `${id}: dynamic(() => import('./${dirName}'))`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\",\\n\")}\n\t\t\t}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t${NON_EDITABLE_FILE_BANNER}\n\n\t\t\t${slices\n\t\t\t\t.map((slice) => {\n\t\t\t\t\tconst componentName = pascalCase(slice.model.name);\n\t\t\t\t\tconst dirName = pascalCase(slice.model.name);\n\n\t\t\t\t\treturn `import ${componentName} from \"./${dirName}\";`;\n\t\t\t\t})\n\t\t\t\t.join(\"\\n\")}\n\n\t\t\texport const components = {\n\t\t\t\t${slices\n\t\t\t\t\t.map((slice) => {\n\t\t\t\t\t\tconst id = slice.model.id;\n\t\t\t\t\t\tconst componentName = pascalCase(slice.model.name);\n\n\t\t\t\t\t\treturn `${id}: ${componentName},`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\")}\n\t\t\t}\n\t\t`;\n\t}\n\n\tif (args.options.format) {\n\t\tcontents = await args.helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n"],"names":[],"mappings":";;;;;AAca,MAAA,8BAA8B,OAC1C,SACkB;AACZ,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,EAAA,CACd;AAEK,QAAA,WAAW,KAAK,QAAQ,iBAC7B,KAAK,WACL,sBAAsB,aAAa,UAAU;AAG9C,QAAM,SAAS,MAAM,KAAK,QAAQ,6BAA6B;AAAA,IAC9D,WAAW,KAAK;AAAA,EAAA,CAChB;AAEG,MAAA;AAEA,MAAA,KAAK,QAAQ,gBAAgB;AACrB,eAAA;AAAA,KACR;AAAA;AAAA;AAAA;AAAA;AAAA,MAKC,OACA,IAAI,CAAC,UAAS;AACR,YAAA,KAAK,MAAM,MAAM;AACvB,YAAM,UAAU,WAAW,MAAM,MAAM,IAAI;AAE3C,aAAO,GAAG,+BAA+B;AAAA,IAAA,CACzC,EACA,KAAK,KAAK;AAAA;AAAA;AAAA,EAAA,OAGR;AACK,eAAA;AAAA,KACR;AAAA;AAAA,KAEA,OACA,IAAI,CAAC,UAAS;AACd,YAAM,gBAAgB,WAAW,MAAM,MAAM,IAAI;AACjD,YAAM,UAAU,WAAW,MAAM,MAAM,IAAI;AAE3C,aAAO,UAAU,yBAAyB;AAAA,IAAA,CAC1C,EACA,KAAK,IAAI;AAAA;AAAA;AAAA,MAGR,OACA,IAAI,CAAC,UAAS;AACR,YAAA,KAAK,MAAM,MAAM;AACvB,YAAM,gBAAgB,WAAW,MAAM,MAAM,IAAI;AAEjD,aAAO,GAAG,OAAO;AAAA,IAAA,CACjB,EACA,KAAK,IAAI;AAAA;AAAA;AAAA,EAGb;AAEG,MAAA,KAAK,QAAQ,QAAQ;AACxB,eAAW,MAAM,KAAK,QAAQ,OAAO,UAAU,QAAQ;AAAA,EACvD;AAEK,QAAA,GAAG,UAAU,UAAU,QAAQ;AACtC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../node_modules/data-uri-to-buffer/dist/index.js"],"sourcesContent":["/**\n * Returns a `Buffer` instance from the given data URI `uri`.\n *\n * @param {String} uri Data URI to turn into a Buffer instance\n * @returns {Buffer} Buffer instance from Data URI\n * @api public\n */\nexport function dataUriToBuffer(uri) {\n if (!/^data:/i.test(uri)) {\n throw new TypeError('`uri` does not appear to be a Data URI (must begin with \"data:\")');\n }\n // strip newlines\n uri = uri.replace(/\\r?\\n/g, '');\n // split the URI up into the \"metadata\" and the \"data\" portions\n const firstComma = uri.indexOf(',');\n if (firstComma === -1 || firstComma <= 4) {\n throw new TypeError('malformed data: URI');\n }\n // remove the \"data:\" scheme and parse the metadata\n const meta = uri.substring(5, firstComma).split(';');\n let charset = '';\n let base64 = false;\n const type = meta[0] || 'text/plain';\n let typeFull = type;\n for (let i = 1; i < meta.length; i++) {\n if (meta[i] === 'base64') {\n base64 = true;\n }\n else {\n typeFull += `;${meta[i]}`;\n if (meta[i].indexOf('charset=') === 0) {\n charset = meta[i].substring(8);\n }\n }\n }\n // defaults to US-ASCII only if type is not provided\n if (!meta[0] && !charset.length) {\n typeFull += ';charset=US-ASCII';\n charset = 'US-ASCII';\n }\n // get the encoded data portion and decode URI-encoded chars\n const encoding = base64 ? 'base64' : 'ascii';\n const data = unescape(uri.substring(firstComma + 1));\n const buffer = Buffer.from(data, encoding);\n // set `.type` and `.typeFull` properties to MIME type\n buffer.type = type;\n buffer.typeFull = typeFull;\n // set the `.charset` property\n buffer.charset = charset;\n return buffer;\n}\nexport default dataUriToBuffer;\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;AAOO,SAAS,gBAAgB,KAAK;AACjC,MAAI,CAAC,UAAU,KAAK,GAAG,GAAG;AACtB,UAAM,IAAI,UAAU,kEAAkE;AAAA,EACzF;AAED,QAAM,IAAI,QAAQ,UAAU,EAAE;AAE9B,QAAM,aAAa,IAAI,QAAQ,GAAG;AAClC,MAAI,eAAe,MAAM,cAAc,GAAG;AACtC,UAAM,IAAI,UAAU,qBAAqB;AAAA,EAC5C;AAED,QAAM,OAAO,IAAI,UAAU,GAAG,UAAU,EAAE,MAAM,GAAG;AACnD,MAAI,UAAU;AACd,MAAI,SAAS;AACb,QAAM,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../node_modules/data-uri-to-buffer/dist/index.js"],"sourcesContent":["/**\n * Returns a `Buffer` instance from the given data URI `uri`.\n *\n * @param {String} uri Data URI to turn into a Buffer instance\n * @returns {Buffer} Buffer instance from Data URI\n * @api public\n */\nexport function dataUriToBuffer(uri) {\n if (!/^data:/i.test(uri)) {\n throw new TypeError('`uri` does not appear to be a Data URI (must begin with \"data:\")');\n }\n // strip newlines\n uri = uri.replace(/\\r?\\n/g, '');\n // split the URI up into the \"metadata\" and the \"data\" portions\n const firstComma = uri.indexOf(',');\n if (firstComma === -1 || firstComma <= 4) {\n throw new TypeError('malformed data: URI');\n }\n // remove the \"data:\" scheme and parse the metadata\n const meta = uri.substring(5, firstComma).split(';');\n let charset = '';\n let base64 = false;\n const type = meta[0] || 'text/plain';\n let typeFull = type;\n for (let i = 1; i < meta.length; i++) {\n if (meta[i] === 'base64') {\n base64 = true;\n }\n else {\n typeFull += `;${meta[i]}`;\n if (meta[i].indexOf('charset=') === 0) {\n charset = meta[i].substring(8);\n }\n }\n }\n // defaults to US-ASCII only if type is not provided\n if (!meta[0] && !charset.length) {\n typeFull += ';charset=US-ASCII';\n charset = 'US-ASCII';\n }\n // get the encoded data portion and decode URI-encoded chars\n const encoding = base64 ? 'base64' : 'ascii';\n const data = unescape(uri.substring(firstComma + 1));\n const buffer = Buffer.from(data, encoding);\n // set `.type` and `.typeFull` properties to MIME type\n buffer.type = type;\n buffer.typeFull = typeFull;\n // set the `.charset` property\n buffer.charset = charset;\n return buffer;\n}\nexport default dataUriToBuffer;\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;AAOO,SAAS,gBAAgB,KAAK;AACjC,MAAI,CAAC,UAAU,KAAK,GAAG,GAAG;AACtB,UAAM,IAAI,UAAU,kEAAkE;AAAA,EACzF;AAED,QAAM,IAAI,QAAQ,UAAU,EAAE;AAE9B,QAAM,aAAa,IAAI,QAAQ,GAAG;AAClC,MAAI,eAAe,MAAM,cAAc,GAAG;AACtC,UAAM,IAAI,UAAU,qBAAqB;AAAA,EAC5C;AAED,QAAM,OAAO,IAAI,UAAU,GAAG,UAAU,EAAE,MAAM,GAAG;AACnD,MAAI,UAAU;AACd,MAAI,SAAS;AACb,QAAM,OAAO,KAAK,CAAC,KAAK;AACxB,MAAI,WAAW;AACf,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AAClC,QAAI,KAAK,CAAC,MAAM,UAAU;AACtB,eAAS;AAAA,IACZ,OACI;AACD,kBAAY,IAAI,KAAK,CAAC;AACtB,UAAI,KAAK,CAAC,EAAE,QAAQ,UAAU,MAAM,GAAG;AACnC,kBAAU,KAAK,CAAC,EAAE,UAAU,CAAC;AAAA,MAChC;AAAA,IACJ;AAAA,EACJ;AAED,MAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,QAAQ;AAC7B,gBAAY;AACZ,cAAU;AAAA,EACb;AAED,QAAM,WAAW,SAAS,WAAW;AACrC,QAAM,OAAO,SAAS,IAAI,UAAU,aAAa,CAAC,CAAC;AACnD,QAAM,SAAS,OAAO,KAAK,MAAM,QAAQ;AAEzC,SAAO,OAAO;AACd,SAAO,WAAW;AAElB,SAAO,UAAU;AACjB,SAAO;AACX;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../node_modules/data-uri-to-buffer/dist/index.js"],"sourcesContent":["/**\n * Returns a `Buffer` instance from the given data URI `uri`.\n *\n * @param {String} uri Data URI to turn into a Buffer instance\n * @returns {Buffer} Buffer instance from Data URI\n * @api public\n */\nexport function dataUriToBuffer(uri) {\n if (!/^data:/i.test(uri)) {\n throw new TypeError('`uri` does not appear to be a Data URI (must begin with \"data:\")');\n }\n // strip newlines\n uri = uri.replace(/\\r?\\n/g, '');\n // split the URI up into the \"metadata\" and the \"data\" portions\n const firstComma = uri.indexOf(',');\n if (firstComma === -1 || firstComma <= 4) {\n throw new TypeError('malformed data: URI');\n }\n // remove the \"data:\" scheme and parse the metadata\n const meta = uri.substring(5, firstComma).split(';');\n let charset = '';\n let base64 = false;\n const type = meta[0] || 'text/plain';\n let typeFull = type;\n for (let i = 1; i < meta.length; i++) {\n if (meta[i] === 'base64') {\n base64 = true;\n }\n else {\n typeFull += `;${meta[i]}`;\n if (meta[i].indexOf('charset=') === 0) {\n charset = meta[i].substring(8);\n }\n }\n }\n // defaults to US-ASCII only if type is not provided\n if (!meta[0] && !charset.length) {\n typeFull += ';charset=US-ASCII';\n charset = 'US-ASCII';\n }\n // get the encoded data portion and decode URI-encoded chars\n const encoding = base64 ? 'base64' : 'ascii';\n const data = unescape(uri.substring(firstComma + 1));\n const buffer = Buffer.from(data, encoding);\n // set `.type` and `.typeFull` properties to MIME type\n buffer.type = type;\n buffer.typeFull = typeFull;\n // set the `.charset` property\n buffer.charset = charset;\n return buffer;\n}\nexport default dataUriToBuffer;\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":"AAOO,SAAS,gBAAgB,KAAK;AACjC,MAAI,CAAC,UAAU,KAAK,GAAG,GAAG;AACtB,UAAM,IAAI,UAAU,kEAAkE;AAAA,EACzF;AAED,QAAM,IAAI,QAAQ,UAAU,EAAE;AAE9B,QAAM,aAAa,IAAI,QAAQ,GAAG;AAClC,MAAI,eAAe,MAAM,cAAc,GAAG;AACtC,UAAM,IAAI,UAAU,qBAAqB;AAAA,EAC5C;AAED,QAAM,OAAO,IAAI,UAAU,GAAG,UAAU,EAAE,MAAM,GAAG;AACnD,MAAI,UAAU;AACd,MAAI,SAAS;AACb,QAAM,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../node_modules/data-uri-to-buffer/dist/index.js"],"sourcesContent":["/**\n * Returns a `Buffer` instance from the given data URI `uri`.\n *\n * @param {String} uri Data URI to turn into a Buffer instance\n * @returns {Buffer} Buffer instance from Data URI\n * @api public\n */\nexport function dataUriToBuffer(uri) {\n if (!/^data:/i.test(uri)) {\n throw new TypeError('`uri` does not appear to be a Data URI (must begin with \"data:\")');\n }\n // strip newlines\n uri = uri.replace(/\\r?\\n/g, '');\n // split the URI up into the \"metadata\" and the \"data\" portions\n const firstComma = uri.indexOf(',');\n if (firstComma === -1 || firstComma <= 4) {\n throw new TypeError('malformed data: URI');\n }\n // remove the \"data:\" scheme and parse the metadata\n const meta = uri.substring(5, firstComma).split(';');\n let charset = '';\n let base64 = false;\n const type = meta[0] || 'text/plain';\n let typeFull = type;\n for (let i = 1; i < meta.length; i++) {\n if (meta[i] === 'base64') {\n base64 = true;\n }\n else {\n typeFull += `;${meta[i]}`;\n if (meta[i].indexOf('charset=') === 0) {\n charset = meta[i].substring(8);\n }\n }\n }\n // defaults to US-ASCII only if type is not provided\n if (!meta[0] && !charset.length) {\n typeFull += ';charset=US-ASCII';\n charset = 'US-ASCII';\n }\n // get the encoded data portion and decode URI-encoded chars\n const encoding = base64 ? 'base64' : 'ascii';\n const data = unescape(uri.substring(firstComma + 1));\n const buffer = Buffer.from(data, encoding);\n // set `.type` and `.typeFull` properties to MIME type\n buffer.type = type;\n buffer.typeFull = typeFull;\n // set the `.charset` property\n buffer.charset = charset;\n return buffer;\n}\nexport default dataUriToBuffer;\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":"AAOO,SAAS,gBAAgB,KAAK;AACjC,MAAI,CAAC,UAAU,KAAK,GAAG,GAAG;AACtB,UAAM,IAAI,UAAU,kEAAkE;AAAA,EACzF;AAED,QAAM,IAAI,QAAQ,UAAU,EAAE;AAE9B,QAAM,aAAa,IAAI,QAAQ,GAAG;AAClC,MAAI,eAAe,MAAM,cAAc,GAAG;AACtC,UAAM,IAAI,UAAU,qBAAqB;AAAA,EAC5C;AAED,QAAM,OAAO,IAAI,UAAU,GAAG,UAAU,EAAE,MAAM,GAAG;AACnD,MAAI,UAAU;AACd,MAAI,SAAS;AACb,QAAM,OAAO,KAAK,CAAC,KAAK;AACxB,MAAI,WAAW;AACf,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AAClC,QAAI,KAAK,CAAC,MAAM,UAAU;AACtB,eAAS;AAAA,IACZ,OACI;AACD,kBAAY,IAAI,KAAK,CAAC;AACtB,UAAI,KAAK,CAAC,EAAE,QAAQ,UAAU,MAAM,GAAG;AACnC,kBAAU,KAAK,CAAC,EAAE,UAAU,CAAC;AAAA,MAChC;AAAA,IACJ;AAAA,EACJ;AAED,MAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,QAAQ;AAC7B,gBAAY;AACZ,cAAU;AAAA,EACb;AAED,QAAM,WAAW,SAAS,WAAW;AACrC,QAAM,OAAO,SAAS,IAAI,UAAU,aAAa,CAAC,CAAC;AACnD,QAAM,SAAS,OAAO,KAAK,MAAM,QAAQ;AAEzC,SAAO,OAAO;AACd,SAAO,WAAW;AAElB,SAAO,UAAU;AACjB,SAAO;AACX;"}
|
|
@@ -21,6 +21,12 @@ var _lastModified, _name, _a;
|
|
|
21
21
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
22
22
|
const index = require("./index.cjs");
|
|
23
23
|
const _File = (_a = class extends index.default {
|
|
24
|
+
/**
|
|
25
|
+
* @param {*[]} fileBits
|
|
26
|
+
* @param {string} fileName
|
|
27
|
+
* @param {{lastModified?: number, type?: string}} options
|
|
28
|
+
*/
|
|
29
|
+
// @ts-ignore
|
|
24
30
|
constructor(fileBits, fileName, options = {}) {
|
|
25
31
|
if (arguments.length < 2) {
|
|
26
32
|
throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.cjs","sources":["../../../node_modules/fetch-blob/file.js"],"sourcesContent":["import Blob from './index.js'\n\nconst _File = class File extends Blob {\n #lastModified = 0\n #name = ''\n\n /**\n * @param {*[]} fileBits\n * @param {string} fileName\n * @param {{lastModified?: number, type?: string}} options\n */// @ts-ignore\n constructor (fileBits, fileName, options = {}) {\n if (arguments.length < 2) {\n throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`)\n }\n super(fileBits, options)\n\n if (options === null) options = {}\n\n // Simulate WebIDL type casting for NaN value in lastModified option.\n const lastModified = options.lastModified === undefined ? Date.now() : Number(options.lastModified)\n if (!Number.isNaN(lastModified)) {\n this.#lastModified = lastModified\n }\n\n this.#name = String(fileName)\n }\n\n get name () {\n return this.#name\n }\n\n get lastModified () {\n return this.#lastModified\n }\n\n get [Symbol.toStringTag] () {\n return 'File'\n }\n\n static [Symbol.hasInstance] (object) {\n return !!object && object instanceof Blob &&\n /^(File)$/.test(object[Symbol.toStringTag])\n }\n}\n\n/** @type {typeof globalThis.File} */// @ts-ignore\nexport const File = _File\nexport default File\n"],"names":["Blob"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,SAAQ,mBAAmBA,cAAK;AAAA,EASpC,YAAa,UAAU,UAAU,UAAU,CAAA,GAAI;AAC7C,QAAI,UAAU,SAAS,GAAG;AACxB,YAAM,IAAI,UAAU,8DAA8D,UAAU,iBAAiB;AAAA,IAC9G;AACD,UAAM,UAAU,OAAO;AAZzB,sCAAgB;AAChB,8BAAQ;AAaN,QAAI,YAAY;AAAM,gBAAU,CAAE;AAGlC,UAAM,eAAe,QAAQ,iBAAiB,SAAY,KAAK,QAAQ,OAAO,QAAQ,YAAY;AAClG,QAAI,CAAC,OAAO,MAAM,YAAY,GAAG;AAC/B,yBAAK,eAAgB;AAAA,IACtB;AAED,uBAAK,OAAQ,OAAO,QAAQ;AAAA,EAC7B;AAAA,EAED,IAAI,OAAQ;AACV,WAAO,mBAAK;AAAA,EACb;AAAA,EAED,IAAI,eAAgB;AAClB,WAAO,mBAAK;AAAA,EACb;AAAA,EAED,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"file.cjs","sources":["../../../node_modules/fetch-blob/file.js"],"sourcesContent":["import Blob from './index.js'\n\nconst _File = class File extends Blob {\n #lastModified = 0\n #name = ''\n\n /**\n * @param {*[]} fileBits\n * @param {string} fileName\n * @param {{lastModified?: number, type?: string}} options\n */// @ts-ignore\n constructor (fileBits, fileName, options = {}) {\n if (arguments.length < 2) {\n throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`)\n }\n super(fileBits, options)\n\n if (options === null) options = {}\n\n // Simulate WebIDL type casting for NaN value in lastModified option.\n const lastModified = options.lastModified === undefined ? Date.now() : Number(options.lastModified)\n if (!Number.isNaN(lastModified)) {\n this.#lastModified = lastModified\n }\n\n this.#name = String(fileName)\n }\n\n get name () {\n return this.#name\n }\n\n get lastModified () {\n return this.#lastModified\n }\n\n get [Symbol.toStringTag] () {\n return 'File'\n }\n\n static [Symbol.hasInstance] (object) {\n return !!object && object instanceof Blob &&\n /^(File)$/.test(object[Symbol.toStringTag])\n }\n}\n\n/** @type {typeof globalThis.File} */// @ts-ignore\nexport const File = _File\nexport default File\n"],"names":["Blob"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,SAAQ,mBAAmBA,cAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpC,YAAa,UAAU,UAAU,UAAU,CAAA,GAAI;AAC7C,QAAI,UAAU,SAAS,GAAG;AACxB,YAAM,IAAI,UAAU,8DAA8D,UAAU,iBAAiB;AAAA,IAC9G;AACD,UAAM,UAAU,OAAO;AAZzB,sCAAgB;AAChB,8BAAQ;AAaN,QAAI,YAAY;AAAM,gBAAU,CAAE;AAGlC,UAAM,eAAe,QAAQ,iBAAiB,SAAY,KAAK,QAAQ,OAAO,QAAQ,YAAY;AAClG,QAAI,CAAC,OAAO,MAAM,YAAY,GAAG;AAC/B,yBAAK,eAAgB;AAAA,IACtB;AAED,uBAAK,OAAQ,OAAO,QAAQ;AAAA,EAC7B;AAAA,EAED,IAAI,OAAQ;AACV,WAAO,mBAAK;AAAA,EACb;AAAA,EAED,IAAI,eAAgB;AAClB,WAAO,mBAAK;AAAA,EACb;AAAA,EAED,KAAK,OAAO,WAAW,IAAK;AAC1B,WAAO;AAAA,EACR;AAAA,EAED,QAAQ,OAAO,WAAW,EAAG,QAAQ;AACnC,WAAO,CAAC,CAAC,UAAU,kBAAkBA,MAAI,WACvC,WAAW,KAAK,OAAO,OAAO,WAAW,CAAC;AAAA,EAC7C;AACH,GAzCE,+BACA,uBAFY;AA6CF,MAAC,OAAO;;;"}
|
|
@@ -19,6 +19,12 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
19
19
|
var _lastModified, _name, _a;
|
|
20
20
|
import Blob from "./index.js";
|
|
21
21
|
const _File = (_a = class extends Blob {
|
|
22
|
+
/**
|
|
23
|
+
* @param {*[]} fileBits
|
|
24
|
+
* @param {string} fileName
|
|
25
|
+
* @param {{lastModified?: number, type?: string}} options
|
|
26
|
+
*/
|
|
27
|
+
// @ts-ignore
|
|
22
28
|
constructor(fileBits, fileName, options = {}) {
|
|
23
29
|
if (arguments.length < 2) {
|
|
24
30
|
throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sources":["../../../node_modules/fetch-blob/file.js"],"sourcesContent":["import Blob from './index.js'\n\nconst _File = class File extends Blob {\n #lastModified = 0\n #name = ''\n\n /**\n * @param {*[]} fileBits\n * @param {string} fileName\n * @param {{lastModified?: number, type?: string}} options\n */// @ts-ignore\n constructor (fileBits, fileName, options = {}) {\n if (arguments.length < 2) {\n throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`)\n }\n super(fileBits, options)\n\n if (options === null) options = {}\n\n // Simulate WebIDL type casting for NaN value in lastModified option.\n const lastModified = options.lastModified === undefined ? Date.now() : Number(options.lastModified)\n if (!Number.isNaN(lastModified)) {\n this.#lastModified = lastModified\n }\n\n this.#name = String(fileName)\n }\n\n get name () {\n return this.#name\n }\n\n get lastModified () {\n return this.#lastModified\n }\n\n get [Symbol.toStringTag] () {\n return 'File'\n }\n\n static [Symbol.hasInstance] (object) {\n return !!object && object instanceof Blob &&\n /^(File)$/.test(object[Symbol.toStringTag])\n }\n}\n\n/** @type {typeof globalThis.File} */// @ts-ignore\nexport const File = _File\nexport default File\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,SAAQ,mBAAmB,KAAK;AAAA,EASpC,YAAa,UAAU,UAAU,UAAU,CAAA,GAAI;AAC7C,QAAI,UAAU,SAAS,GAAG;AACxB,YAAM,IAAI,UAAU,8DAA8D,UAAU,iBAAiB;AAAA,IAC9G;AACD,UAAM,UAAU,OAAO;AAZzB,sCAAgB;AAChB,8BAAQ;AAaN,QAAI,YAAY;AAAM,gBAAU,CAAE;AAGlC,UAAM,eAAe,QAAQ,iBAAiB,SAAY,KAAK,QAAQ,OAAO,QAAQ,YAAY;AAClG,QAAI,CAAC,OAAO,MAAM,YAAY,GAAG;AAC/B,yBAAK,eAAgB;AAAA,IACtB;AAED,uBAAK,OAAQ,OAAO,QAAQ;AAAA,EAC7B;AAAA,EAED,IAAI,OAAQ;AACV,WAAO,mBAAK;AAAA,EACb;AAAA,EAED,IAAI,eAAgB;AAClB,WAAO,mBAAK;AAAA,EACb;AAAA,EAED,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"file.js","sources":["../../../node_modules/fetch-blob/file.js"],"sourcesContent":["import Blob from './index.js'\n\nconst _File = class File extends Blob {\n #lastModified = 0\n #name = ''\n\n /**\n * @param {*[]} fileBits\n * @param {string} fileName\n * @param {{lastModified?: number, type?: string}} options\n */// @ts-ignore\n constructor (fileBits, fileName, options = {}) {\n if (arguments.length < 2) {\n throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`)\n }\n super(fileBits, options)\n\n if (options === null) options = {}\n\n // Simulate WebIDL type casting for NaN value in lastModified option.\n const lastModified = options.lastModified === undefined ? Date.now() : Number(options.lastModified)\n if (!Number.isNaN(lastModified)) {\n this.#lastModified = lastModified\n }\n\n this.#name = String(fileName)\n }\n\n get name () {\n return this.#name\n }\n\n get lastModified () {\n return this.#lastModified\n }\n\n get [Symbol.toStringTag] () {\n return 'File'\n }\n\n static [Symbol.hasInstance] (object) {\n return !!object && object instanceof Blob &&\n /^(File)$/.test(object[Symbol.toStringTag])\n }\n}\n\n/** @type {typeof globalThis.File} */// @ts-ignore\nexport const File = _File\nexport default File\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,SAAQ,mBAAmB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpC,YAAa,UAAU,UAAU,UAAU,CAAA,GAAI;AAC7C,QAAI,UAAU,SAAS,GAAG;AACxB,YAAM,IAAI,UAAU,8DAA8D,UAAU,iBAAiB;AAAA,IAC9G;AACD,UAAM,UAAU,OAAO;AAZzB,sCAAgB;AAChB,8BAAQ;AAaN,QAAI,YAAY;AAAM,gBAAU,CAAE;AAGlC,UAAM,eAAe,QAAQ,iBAAiB,SAAY,KAAK,QAAQ,OAAO,QAAQ,YAAY;AAClG,QAAI,CAAC,OAAO,MAAM,YAAY,GAAG;AAC/B,yBAAK,eAAgB;AAAA,IACtB;AAED,uBAAK,OAAQ,OAAO,QAAQ;AAAA,EAC7B;AAAA,EAED,IAAI,OAAQ;AACV,WAAO,mBAAK;AAAA,EACb;AAAA,EAED,IAAI,eAAgB;AAClB,WAAO,mBAAK;AAAA,EACb;AAAA,EAED,KAAK,OAAO,WAAW,IAAK;AAC1B,WAAO;AAAA,EACR;AAAA,EAED,QAAQ,OAAO,WAAW,EAAG,QAAQ;AACnC,WAAO,CAAC,CAAC,UAAU,kBAAkB,QACnC,WAAW,KAAK,OAAO,OAAO,WAAW,CAAC;AAAA,EAC7C;AACH,GAzCE,+BACA,uBAFY;AA6CF,MAAC,OAAO;"}
|