@slicemachine/adapter-next 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SliceSimulator.cjs +93 -0
- package/dist/SliceSimulator.cjs.map +1 -0
- package/dist/SliceSimulator.d.ts +29 -0
- package/dist/SliceSimulator.js +74 -0
- package/dist/SliceSimulator.js.map +1 -0
- package/dist/hooks/customType-asset-delete.cjs +28 -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 +9 -0
- package/dist/hooks/customType-asset-delete.js.map +1 -0
- package/dist/hooks/customType-asset-read.cjs +31 -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 +12 -0
- package/dist/hooks/customType-asset-read.js.map +1 -0
- package/dist/hooks/customType-asset-update.cjs +31 -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 +11 -0
- package/dist/hooks/customType-asset-update.js.map +1 -0
- package/dist/hooks/customType-create.cjs +41 -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 +21 -0
- package/dist/hooks/customType-create.js.map +1 -0
- package/dist/hooks/customType-delete.cjs +30 -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 +11 -0
- package/dist/hooks/customType-delete.js.map +1 -0
- package/dist/hooks/customType-read.cjs +12 -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 +12 -0
- package/dist/hooks/customType-read.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 +46 -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 +26 -0
- package/dist/hooks/customTypeLibrary-read.js.map +1 -0
- package/dist/hooks/slice-asset-delete.cjs +29 -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 +10 -0
- package/dist/hooks/slice-asset-delete.js.map +1 -0
- package/dist/hooks/slice-asset-read.cjs +32 -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 +13 -0
- package/dist/hooks/slice-asset-read.js.map +1 -0
- package/dist/hooks/slice-asset-update.cjs +32 -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 +12 -0
- package/dist/hooks/slice-asset-update.js.map +1 -0
- package/dist/hooks/slice-create.cjs +119 -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 +99 -0
- package/dist/hooks/slice-create.js.map +1 -0
- package/dist/hooks/slice-delete.cjs +49 -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 +30 -0
- package/dist/hooks/slice-delete.js.map +1 -0
- package/dist/hooks/slice-read.cjs +13 -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 +13 -0
- package/dist/hooks/slice-read.js.map +1 -0
- package/dist/hooks/slice-update.cjs +41 -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 +21 -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 +31 -0
- package/dist/hooks/sliceLibrary-read.js.map +1 -0
- package/dist/hooks/sliceSimulator-setup-read.cjs +217 -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 +198 -0
- package/dist/hooks/sliceSimulator-setup-read.js.map +1 -0
- package/dist/hooks/snippet-read.cjs +96 -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 +77 -0
- package/dist/hooks/snippet-read.js.map +1 -0
- package/dist/index.cjs +6 -698
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -45
- package/dist/index.js +6 -669
- package/dist/index.js.map +1 -1
- package/dist/lib/buildSliceLibraryIndexFileContents.cjs +23 -0
- package/dist/lib/buildSliceLibraryIndexFileContents.cjs.map +1 -0
- package/dist/lib/buildSliceLibraryIndexFileContents.d.ts +10 -0
- package/dist/lib/buildSliceLibraryIndexFileContents.js +23 -0
- package/dist/lib/buildSliceLibraryIndexFileContents.js.map +1 -0
- package/dist/lib/getJSOrTSXFileExtension.cjs +13 -0
- package/dist/lib/getJSOrTSXFileExtension.cjs.map +1 -0
- package/dist/lib/getJSOrTSXFileExtension.d.ts +2 -0
- package/dist/lib/getJSOrTSXFileExtension.js +13 -0
- package/dist/lib/getJSOrTSXFileExtension.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 +28 -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/upsertGlobalContentTypes.cjs +53 -0
- package/dist/lib/upsertGlobalContentTypes.cjs.map +1 -0
- package/dist/lib/upsertGlobalContentTypes.d.ts +12 -0
- package/dist/lib/upsertGlobalContentTypes.js +33 -0
- package/dist/lib/upsertGlobalContentTypes.js.map +1 -0
- package/dist/package.cjs +5 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.js +5 -0
- package/dist/package.js.map +1 -0
- package/dist/plugin.cjs +52 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +52 -0
- package/dist/plugin.js.map +1 -0
- package/dist/types.d.ts +9 -0
- package/package.json +26 -23
- package/src/hooks/customType-asset-delete.ts +16 -0
- package/src/hooks/customType-asset-read.ts +20 -0
- package/src/hooks/customType-asset-update.ts +18 -0
- package/src/hooks/customType-create.ts +5 -20
- package/src/hooks/customType-delete.ts +6 -2
- package/src/hooks/customType-read.ts +5 -1
- package/src/hooks/{customType-library-read.ts → customTypeLibrary-read.ts} +3 -0
- package/src/hooks/slice-asset-delete.ts +19 -0
- package/src/hooks/slice-asset-read.ts +23 -0
- package/src/hooks/slice-asset-update.ts +21 -0
- package/src/hooks/slice-create.ts +14 -21
- package/src/hooks/slice-delete.ts +9 -1
- package/src/hooks/slice-read.ts +5 -1
- package/src/hooks/slice-update.ts +4 -19
- package/src/hooks/{slice-library-read.ts → sliceLibrary-read.ts} +3 -0
- package/src/lib/rejectIfNecessary.ts +16 -0
- package/src/lib/upsertGlobalContentTypes.ts +59 -0
- package/src/plugin.ts +20 -8
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const sliceSimulatorCore = require("@prismicio/slice-simulator-core");
|
|
6
|
+
function _interopNamespace(e) {
|
|
7
|
+
if (e && e.__esModule)
|
|
8
|
+
return e;
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
25
|
+
const coreManager = new sliceSimulatorCore.CoreManager();
|
|
26
|
+
const SliceSimulator = ({
|
|
27
|
+
sliceZone: SliceZoneComp,
|
|
28
|
+
state,
|
|
29
|
+
background,
|
|
30
|
+
zIndex,
|
|
31
|
+
className
|
|
32
|
+
}) => {
|
|
33
|
+
const defaultProps = sliceSimulatorCore.getDefaultProps();
|
|
34
|
+
const [managedState, setManagedState] = React__namespace.useState(() => sliceSimulatorCore.getDefaultManagedState());
|
|
35
|
+
const [slices, setSlices] = React__namespace.useState(() => sliceSimulatorCore.getDefaultSlices());
|
|
36
|
+
const [message, setMessage] = React__namespace.useState(() => sliceSimulatorCore.getDefaultMessage());
|
|
37
|
+
React__namespace.useEffect(() => {
|
|
38
|
+
coreManager.stateManager.on(sliceSimulatorCore.StateManagerEventType.ManagedState, (_managedState) => {
|
|
39
|
+
setManagedState(_managedState);
|
|
40
|
+
}, "simulator-managed-state");
|
|
41
|
+
coreManager.stateManager.on(sliceSimulatorCore.StateManagerEventType.Slices, (_slices) => {
|
|
42
|
+
setSlices(_slices);
|
|
43
|
+
}, "simulator-slices");
|
|
44
|
+
coreManager.stateManager.on(sliceSimulatorCore.StateManagerEventType.Message, (_message) => {
|
|
45
|
+
setMessage(_message);
|
|
46
|
+
}, "simulator-message");
|
|
47
|
+
coreManager.init(state);
|
|
48
|
+
return () => {
|
|
49
|
+
coreManager.stateManager.off(sliceSimulatorCore.StateManagerEventType.ManagedState, "simulator-managed-state");
|
|
50
|
+
coreManager.stateManager.off(sliceSimulatorCore.StateManagerEventType.Slices, "simulator-slices");
|
|
51
|
+
coreManager.stateManager.off(sliceSimulatorCore.StateManagerEventType.Message, "simulator-message");
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
54
|
+
const didMount = React__namespace.useRef(false);
|
|
55
|
+
React__namespace.useEffect(() => {
|
|
56
|
+
if (didMount.current) {
|
|
57
|
+
coreManager.stateManager.reload(state);
|
|
58
|
+
} else {
|
|
59
|
+
didMount.current = true;
|
|
60
|
+
}
|
|
61
|
+
}, [state]);
|
|
62
|
+
return jsxRuntime.jsx("div", {
|
|
63
|
+
className: [sliceSimulatorCore.simulatorClass, className].filter(Boolean).join(" "),
|
|
64
|
+
style: {
|
|
65
|
+
zIndex: typeof zIndex === "undefined" ? defaultProps.zIndex : zIndex != null ? zIndex : void 0,
|
|
66
|
+
position: "fixed",
|
|
67
|
+
top: 0,
|
|
68
|
+
left: 0,
|
|
69
|
+
width: "100%",
|
|
70
|
+
height: "100vh",
|
|
71
|
+
overflow: "auto",
|
|
72
|
+
background: typeof background === "undefined" ? defaultProps.background : background != null ? background : void 0
|
|
73
|
+
},
|
|
74
|
+
children: message ? jsxRuntime.jsx("article", {
|
|
75
|
+
dangerouslySetInnerHTML: {
|
|
76
|
+
__html: message
|
|
77
|
+
}
|
|
78
|
+
}) : slices.length ? jsxRuntime.jsx("div", {
|
|
79
|
+
id: "root",
|
|
80
|
+
className: sliceSimulatorCore.simulatorRootClass,
|
|
81
|
+
style: managedState.status !== sliceSimulatorCore.StateManagerStatus.Loaded ? {
|
|
82
|
+
display: "none"
|
|
83
|
+
} : void 0,
|
|
84
|
+
onClickCapture: sliceSimulatorCore.onClickHandler,
|
|
85
|
+
onSubmitCapture: sliceSimulatorCore.disableEventHandler,
|
|
86
|
+
children: jsxRuntime.jsx(SliceZoneComp, {
|
|
87
|
+
slices
|
|
88
|
+
})
|
|
89
|
+
}) : null
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
exports.SliceSimulator = SliceSimulator;
|
|
93
|
+
//# sourceMappingURL=SliceSimulator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.cjs","sources":["../src/SliceSimulator.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n\tCoreManager,\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n\tStateManagerEventType,\n\tStateManagerStatus,\n\tdisableEventHandler,\n\tgetDefaultManagedState,\n\tgetDefaultMessage,\n\tgetDefaultProps,\n\tgetDefaultSlices,\n\tonClickHandler,\n\tsimulatorClass,\n\tsimulatorRootClass,\n} from \"@prismicio/slice-simulator-core\";\n\nconst coreManager = new CoreManager();\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"];\n};\n\nexport type SliceSimulatorProps = {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t *\n\t * ```tsx\n\t * import { SliceSimulator } from \"@slicemachine/adapter-next\";\n\t * import { SliceZone } from \"@prismicio/react\";\n\t *\n\t * import { components } from \"../slices\";\n\t * import state from \"../.slicemachine/libraries-state.json\";\n\t *\n\t * <SliceSimulator\n\t * \tsliceZone={({ slices }) => (\n\t * \t\t<SliceZone slices={slices} components={components} />\n\t * \t)}\n\t * \tstate={state}\n\t * />;\n\t * ```\n\t */\n\tsliceZone: (props: SliceSimulatorSliceZoneProps) => JSX.Element;\n\tclassName?: string;\n} & BaseSliceSimulatorProps;\n\nexport const SliceSimulator = ({\n\tsliceZone: SliceZoneComp,\n\tstate,\n\tbackground,\n\tzIndex,\n\tclassName,\n}: SliceSimulatorProps): JSX.Element => {\n\tconst defaultProps = getDefaultProps();\n\n\tconst [managedState, setManagedState] = React.useState(() =>\n\t\tgetDefaultManagedState(),\n\t);\n\tconst [slices, setSlices] = React.useState(() => getDefaultSlices());\n\tconst [message, setMessage] = React.useState(() => getDefaultMessage());\n\n\tReact.useEffect(() => {\n\t\tcoreManager.stateManager.on(\n\t\t\tStateManagerEventType.ManagedState,\n\t\t\t(_managedState) => {\n\t\t\t\tsetManagedState(_managedState);\n\t\t\t},\n\t\t\t\"simulator-managed-state\",\n\t\t);\n\t\tcoreManager.stateManager.on(\n\t\t\tStateManagerEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices);\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t);\n\t\tcoreManager.stateManager.on(\n\t\t\tStateManagerEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message);\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t);\n\n\t\tcoreManager.init(state);\n\n\t\treturn () => {\n\t\t\tcoreManager.stateManager.off(\n\t\t\t\tStateManagerEventType.ManagedState,\n\t\t\t\t\"simulator-managed-state\",\n\t\t\t);\n\n\t\t\tcoreManager.stateManager.off(\n\t\t\t\tStateManagerEventType.Slices,\n\t\t\t\t\"simulator-slices\",\n\t\t\t);\n\n\t\t\tcoreManager.stateManager.off(\n\t\t\t\tStateManagerEventType.Message,\n\t\t\t\t\"simulator-message\",\n\t\t\t);\n\t\t};\n\t}, []);\n\n\t// Update state on HMR\n\tconst didMount = React.useRef(false);\n\tReact.useEffect(() => {\n\t\tif (didMount.current) {\n\t\t\tcoreManager.stateManager.reload(state);\n\t\t} else {\n\t\t\tdidMount.current = true;\n\t\t}\n\t}, [state]);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[simulatorClass, className].filter(Boolean).join(\" \")}\n\t\t\tstyle={{\n\t\t\t\tzIndex:\n\t\t\t\t\ttypeof zIndex === \"undefined\"\n\t\t\t\t\t\t? defaultProps.zIndex\n\t\t\t\t\t\t: zIndex ?? undefined,\n\t\t\t\tposition: \"fixed\",\n\t\t\t\ttop: 0,\n\t\t\t\tleft: 0,\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100vh\",\n\t\t\t\toverflow: \"auto\",\n\t\t\t\tbackground:\n\t\t\t\t\ttypeof background === \"undefined\"\n\t\t\t\t\t\t? defaultProps.background\n\t\t\t\t\t\t: background ?? undefined,\n\t\t\t}}\n\t\t>\n\t\t\t{message ? (\n\t\t\t\t<article dangerouslySetInnerHTML={{ __html: message }} />\n\t\t\t) : slices.length ? (\n\t\t\t\t<div\n\t\t\t\t\tid=\"root\"\n\t\t\t\t\tclassName={simulatorRootClass}\n\t\t\t\t\tstyle={\n\t\t\t\t\t\tmanagedState.status !== StateManagerStatus.Loaded\n\t\t\t\t\t\t\t? { display: \"none\" }\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t\tonClickCapture={onClickHandler as unknown as React.MouseEventHandler}\n\t\t\t\t\tonSubmitCapture={\n\t\t\t\t\t\tdisableEventHandler as unknown as React.FormEventHandler\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<SliceZoneComp slices={slices} />\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t);\n};\n"],"names":["coreManager","CoreManager","SliceSimulator","sliceZone","SliceZoneComp","state","background","zIndex","className","defaultProps","getDefaultProps","managedState","setManagedState","React","useState","getDefaultManagedState","slices","setSlices","getDefaultSlices","message","setMessage","getDefaultMessage","useEffect","stateManager","on","StateManagerEventType","ManagedState","_managedState","Slices","_slices","Message","_message","init","off","didMount","useRef","current","reload","_jsx","simulatorClass","filter","Boolean","join","style","undefined","position","top","left","width","height","overflow","children","dangerouslySetInnerHTML","__html","length","id","simulatorRootClass","status","StateManagerStatus","Loaded","display","onClickCapture","onClickHandler","onSubmitCapture","disableEventHandler"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAMA,cAAc,IAAIC,mBAAAA;AA+BjB,MAAMC,iBAAiB,CAAC;AAAA,EAC9BC,WAAWC;AAAAA,EACXC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAS,MAC6B;AACtC,QAAMC,eAAeC,mBAAAA;AAEf,QAAA,CAACC,cAAcC,eAAe,IAAIC,iBAAMC,SAAS,MACtDC,2CAAwB;AAEnB,QAAA,CAACC,QAAQC,SAAS,IAAIJ,iBAAMC,SAAS,MAAMI,qCAAkB;AAC7D,QAAA,CAACC,SAASC,UAAU,IAAIP,iBAAMC,SAAS,MAAMO,sCAAmB;AAEtER,mBAAMS,UAAU,MAAK;AACpBtB,gBAAYuB,aAAaC,GACxBC,mBAAsBC,sBAAAA,cACrBC,CAAiB,kBAAA;AACjBf,sBAAgBe,aAAa;AAAA,OAE9B,yBAAyB;AAE1B3B,gBAAYuB,aAAaC,GACxBC,mBAAsBG,sBAAAA,QACrBC,CAAW,YAAA;AACXZ,gBAAUY,OAAO;AAAA,OAElB,kBAAkB;AAEnB7B,gBAAYuB,aAAaC,GACxBC,mBAAsBK,sBAAAA,SACrBC,CAAY,aAAA;AACZX,iBAAWW,QAAQ;AAAA,OAEpB,mBAAmB;AAGpB/B,gBAAYgC,KAAK3B,KAAK;AAEtB,WAAO,MAAK;AACXL,kBAAYuB,aAAaU,IACxBR,mBAAsBC,sBAAAA,cACtB,yBAAyB;AAG1B1B,kBAAYuB,aAAaU,IACxBR,mBAAsBG,sBAAAA,QACtB,kBAAkB;AAGnB5B,kBAAYuB,aAAaU,IACxBR,mBAAsBK,sBAAAA,SACtB,mBAAmB;AAAA,IAAA;AAAA,EAGtB,GAAG,CAAE,CAAA;AAGCI,QAAAA,WAAWrB,iBAAMsB,OAAO,KAAK;AACnCtB,mBAAMS,UAAU,MAAK;AACpB,QAAIY,SAASE,SAAS;AACTb,kBAAAA,aAAac,OAAOhC,KAAK;AAAA,IAAA,OAC/B;AACN6B,eAASE,UAAU;AAAA,IACnB;AAAA,EAAA,GACC,CAAC/B,KAAK,CAAC;AAEV,SACCiC,WAAAA;IACC9B,WAAW,CAAC+B,mBAAgB/B,gBAAAA,SAAS,EAAEgC,OAAOC,OAAO,EAAEC,KAAK,GAAG;AAAA,IAC/DC,OAAO;AAAA,MACNpC,QACC,OAAOA,WAAW,cACfE,aAAaF,SACbA,0BAAUqC;AAAAA,MACdC,UAAU;AAAA,MACVC,KAAK;AAAA,MACLC,MAAM;AAAA,MACNC,OAAO;AAAA,MACPC,QAAQ;AAAA,MACRC,UAAU;AAAA,MACV5C,YACC,OAAOA,eAAe,cACnBG,aAAaH,aACbA,kCAAcsC;AAAAA,IAClB;AAAA,IAAAO,UAEAhC,UACAmB,WAAAA,IAAA,WAAA;AAAA,MAASc,yBAAyB;AAAA,QAAEC,QAAQlC;AAAAA;IAAa,CAAA,IACtDH,OAAOsC,SACVhB,WAAAA,IAAA,OAAA;AAAA,MACCiB,IAAG;AAAA,MACH/C,WAAWgD,mBAAAA;AAAAA,MACXb,OACChC,aAAa8C,WAAWC,mBAAAA,mBAAmBC,SACxC;AAAA,QAAEC,SAAS;AAAA,MACXhB,IAAAA;AAAAA,MAEJiB,gBAAgBC,mBAAAA;AAAAA,MAChBC,iBACCC,mBAAAA;AAAAA,MAAwDb,UAGzDb,eAAClC;QAAcY;AAAAA,MAAAA,CAAc;AAAA,IACxB,CAAA,IACH;AAAA,EAAA,CACC;AAER;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SliceSimulatorProps as BaseSliceSimulatorProps, SliceSimulatorState } from "@prismicio/slice-simulator-core";
|
|
2
|
+
export declare type SliceSimulatorSliceZoneProps = {
|
|
3
|
+
slices: SliceSimulatorState["slices"];
|
|
4
|
+
};
|
|
5
|
+
export declare type SliceSimulatorProps = {
|
|
6
|
+
/**
|
|
7
|
+
* React component to render simulated Slices.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { SliceSimulator } from "@slicemachine/adapter-next";
|
|
13
|
+
* import { SliceZone } from "@prismicio/react";
|
|
14
|
+
*
|
|
15
|
+
* import { components } from "../slices";
|
|
16
|
+
* import state from "../.slicemachine/libraries-state.json";
|
|
17
|
+
*
|
|
18
|
+
* <SliceSimulator
|
|
19
|
+
* sliceZone={({ slices }) => (
|
|
20
|
+
* <SliceZone slices={slices} components={components} />
|
|
21
|
+
* )}
|
|
22
|
+
* state={state}
|
|
23
|
+
* />;
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
sliceZone: (props: SliceSimulatorSliceZoneProps) => JSX.Element;
|
|
27
|
+
className?: string;
|
|
28
|
+
} & BaseSliceSimulatorProps;
|
|
29
|
+
export declare const SliceSimulator: ({ sliceZone: SliceZoneComp, state, background, zIndex, className, }: SliceSimulatorProps) => JSX.Element;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { CoreManager, getDefaultProps, getDefaultManagedState, getDefaultSlices, getDefaultMessage, StateManagerEventType, simulatorClass, simulatorRootClass, StateManagerStatus, onClickHandler, disableEventHandler } from "@prismicio/slice-simulator-core";
|
|
4
|
+
const coreManager = new CoreManager();
|
|
5
|
+
const SliceSimulator = ({
|
|
6
|
+
sliceZone: SliceZoneComp,
|
|
7
|
+
state,
|
|
8
|
+
background,
|
|
9
|
+
zIndex,
|
|
10
|
+
className
|
|
11
|
+
}) => {
|
|
12
|
+
const defaultProps = getDefaultProps();
|
|
13
|
+
const [managedState, setManagedState] = React.useState(() => getDefaultManagedState());
|
|
14
|
+
const [slices, setSlices] = React.useState(() => getDefaultSlices());
|
|
15
|
+
const [message, setMessage] = React.useState(() => getDefaultMessage());
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
coreManager.stateManager.on(StateManagerEventType.ManagedState, (_managedState) => {
|
|
18
|
+
setManagedState(_managedState);
|
|
19
|
+
}, "simulator-managed-state");
|
|
20
|
+
coreManager.stateManager.on(StateManagerEventType.Slices, (_slices) => {
|
|
21
|
+
setSlices(_slices);
|
|
22
|
+
}, "simulator-slices");
|
|
23
|
+
coreManager.stateManager.on(StateManagerEventType.Message, (_message) => {
|
|
24
|
+
setMessage(_message);
|
|
25
|
+
}, "simulator-message");
|
|
26
|
+
coreManager.init(state);
|
|
27
|
+
return () => {
|
|
28
|
+
coreManager.stateManager.off(StateManagerEventType.ManagedState, "simulator-managed-state");
|
|
29
|
+
coreManager.stateManager.off(StateManagerEventType.Slices, "simulator-slices");
|
|
30
|
+
coreManager.stateManager.off(StateManagerEventType.Message, "simulator-message");
|
|
31
|
+
};
|
|
32
|
+
}, []);
|
|
33
|
+
const didMount = React.useRef(false);
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
if (didMount.current) {
|
|
36
|
+
coreManager.stateManager.reload(state);
|
|
37
|
+
} else {
|
|
38
|
+
didMount.current = true;
|
|
39
|
+
}
|
|
40
|
+
}, [state]);
|
|
41
|
+
return jsx("div", {
|
|
42
|
+
className: [simulatorClass, className].filter(Boolean).join(" "),
|
|
43
|
+
style: {
|
|
44
|
+
zIndex: typeof zIndex === "undefined" ? defaultProps.zIndex : zIndex != null ? zIndex : void 0,
|
|
45
|
+
position: "fixed",
|
|
46
|
+
top: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
width: "100%",
|
|
49
|
+
height: "100vh",
|
|
50
|
+
overflow: "auto",
|
|
51
|
+
background: typeof background === "undefined" ? defaultProps.background : background != null ? background : void 0
|
|
52
|
+
},
|
|
53
|
+
children: message ? jsx("article", {
|
|
54
|
+
dangerouslySetInnerHTML: {
|
|
55
|
+
__html: message
|
|
56
|
+
}
|
|
57
|
+
}) : slices.length ? jsx("div", {
|
|
58
|
+
id: "root",
|
|
59
|
+
className: simulatorRootClass,
|
|
60
|
+
style: managedState.status !== StateManagerStatus.Loaded ? {
|
|
61
|
+
display: "none"
|
|
62
|
+
} : void 0,
|
|
63
|
+
onClickCapture: onClickHandler,
|
|
64
|
+
onSubmitCapture: disableEventHandler,
|
|
65
|
+
children: jsx(SliceZoneComp, {
|
|
66
|
+
slices
|
|
67
|
+
})
|
|
68
|
+
}) : null
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
SliceSimulator
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=SliceSimulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.js","sources":["../src/SliceSimulator.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n\tCoreManager,\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n\tStateManagerEventType,\n\tStateManagerStatus,\n\tdisableEventHandler,\n\tgetDefaultManagedState,\n\tgetDefaultMessage,\n\tgetDefaultProps,\n\tgetDefaultSlices,\n\tonClickHandler,\n\tsimulatorClass,\n\tsimulatorRootClass,\n} from \"@prismicio/slice-simulator-core\";\n\nconst coreManager = new CoreManager();\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"];\n};\n\nexport type SliceSimulatorProps = {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t *\n\t * ```tsx\n\t * import { SliceSimulator } from \"@slicemachine/adapter-next\";\n\t * import { SliceZone } from \"@prismicio/react\";\n\t *\n\t * import { components } from \"../slices\";\n\t * import state from \"../.slicemachine/libraries-state.json\";\n\t *\n\t * <SliceSimulator\n\t * \tsliceZone={({ slices }) => (\n\t * \t\t<SliceZone slices={slices} components={components} />\n\t * \t)}\n\t * \tstate={state}\n\t * />;\n\t * ```\n\t */\n\tsliceZone: (props: SliceSimulatorSliceZoneProps) => JSX.Element;\n\tclassName?: string;\n} & BaseSliceSimulatorProps;\n\nexport const SliceSimulator = ({\n\tsliceZone: SliceZoneComp,\n\tstate,\n\tbackground,\n\tzIndex,\n\tclassName,\n}: SliceSimulatorProps): JSX.Element => {\n\tconst defaultProps = getDefaultProps();\n\n\tconst [managedState, setManagedState] = React.useState(() =>\n\t\tgetDefaultManagedState(),\n\t);\n\tconst [slices, setSlices] = React.useState(() => getDefaultSlices());\n\tconst [message, setMessage] = React.useState(() => getDefaultMessage());\n\n\tReact.useEffect(() => {\n\t\tcoreManager.stateManager.on(\n\t\t\tStateManagerEventType.ManagedState,\n\t\t\t(_managedState) => {\n\t\t\t\tsetManagedState(_managedState);\n\t\t\t},\n\t\t\t\"simulator-managed-state\",\n\t\t);\n\t\tcoreManager.stateManager.on(\n\t\t\tStateManagerEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices);\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t);\n\t\tcoreManager.stateManager.on(\n\t\t\tStateManagerEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message);\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t);\n\n\t\tcoreManager.init(state);\n\n\t\treturn () => {\n\t\t\tcoreManager.stateManager.off(\n\t\t\t\tStateManagerEventType.ManagedState,\n\t\t\t\t\"simulator-managed-state\",\n\t\t\t);\n\n\t\t\tcoreManager.stateManager.off(\n\t\t\t\tStateManagerEventType.Slices,\n\t\t\t\t\"simulator-slices\",\n\t\t\t);\n\n\t\t\tcoreManager.stateManager.off(\n\t\t\t\tStateManagerEventType.Message,\n\t\t\t\t\"simulator-message\",\n\t\t\t);\n\t\t};\n\t}, []);\n\n\t// Update state on HMR\n\tconst didMount = React.useRef(false);\n\tReact.useEffect(() => {\n\t\tif (didMount.current) {\n\t\t\tcoreManager.stateManager.reload(state);\n\t\t} else {\n\t\t\tdidMount.current = true;\n\t\t}\n\t}, [state]);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[simulatorClass, className].filter(Boolean).join(\" \")}\n\t\t\tstyle={{\n\t\t\t\tzIndex:\n\t\t\t\t\ttypeof zIndex === \"undefined\"\n\t\t\t\t\t\t? defaultProps.zIndex\n\t\t\t\t\t\t: zIndex ?? undefined,\n\t\t\t\tposition: \"fixed\",\n\t\t\t\ttop: 0,\n\t\t\t\tleft: 0,\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100vh\",\n\t\t\t\toverflow: \"auto\",\n\t\t\t\tbackground:\n\t\t\t\t\ttypeof background === \"undefined\"\n\t\t\t\t\t\t? defaultProps.background\n\t\t\t\t\t\t: background ?? undefined,\n\t\t\t}}\n\t\t>\n\t\t\t{message ? (\n\t\t\t\t<article dangerouslySetInnerHTML={{ __html: message }} />\n\t\t\t) : slices.length ? (\n\t\t\t\t<div\n\t\t\t\t\tid=\"root\"\n\t\t\t\t\tclassName={simulatorRootClass}\n\t\t\t\t\tstyle={\n\t\t\t\t\t\tmanagedState.status !== StateManagerStatus.Loaded\n\t\t\t\t\t\t\t? { display: \"none\" }\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t\tonClickCapture={onClickHandler as unknown as React.MouseEventHandler}\n\t\t\t\t\tonSubmitCapture={\n\t\t\t\t\t\tdisableEventHandler as unknown as React.FormEventHandler\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<SliceZoneComp slices={slices} />\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t);\n};\n"],"names":["coreManager","CoreManager","SliceSimulator","sliceZone","SliceZoneComp","state","background","zIndex","className","defaultProps","getDefaultProps","managedState","setManagedState","React","useState","getDefaultManagedState","slices","setSlices","getDefaultSlices","message","setMessage","getDefaultMessage","useEffect","stateManager","on","StateManagerEventType","ManagedState","_managedState","Slices","_slices","Message","_message","init","off","didMount","useRef","current","reload","_jsx","simulatorClass","filter","Boolean","join","style","undefined","position","top","left","width","height","overflow","children","dangerouslySetInnerHTML","__html","length","id","simulatorRootClass","status","StateManagerStatus","Loaded","display","onClickCapture","onClickHandler","onSubmitCapture","disableEventHandler"],"mappings":";;;AAiBA,MAAMA,cAAc,IAAIC;AA+BjB,MAAMC,iBAAiB,CAAC;AAAA,EAC9BC,WAAWC;AAAAA,EACXC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAS,MAC6B;AACtC,QAAMC,eAAeC;AAEf,QAAA,CAACC,cAAcC,eAAe,IAAIC,MAAMC,SAAS,MACtDC,wBAAwB;AAEnB,QAAA,CAACC,QAAQC,SAAS,IAAIJ,MAAMC,SAAS,MAAMI,kBAAkB;AAC7D,QAAA,CAACC,SAASC,UAAU,IAAIP,MAAMC,SAAS,MAAMO,mBAAmB;AAEtER,QAAMS,UAAU,MAAK;AACpBtB,gBAAYuB,aAAaC,GACxBC,sBAAsBC,cACrBC,CAAiB,kBAAA;AACjBf,sBAAgBe,aAAa;AAAA,OAE9B,yBAAyB;AAE1B3B,gBAAYuB,aAAaC,GACxBC,sBAAsBG,QACrBC,CAAW,YAAA;AACXZ,gBAAUY,OAAO;AAAA,OAElB,kBAAkB;AAEnB7B,gBAAYuB,aAAaC,GACxBC,sBAAsBK,SACrBC,CAAY,aAAA;AACZX,iBAAWW,QAAQ;AAAA,OAEpB,mBAAmB;AAGpB/B,gBAAYgC,KAAK3B,KAAK;AAEtB,WAAO,MAAK;AACXL,kBAAYuB,aAAaU,IACxBR,sBAAsBC,cACtB,yBAAyB;AAG1B1B,kBAAYuB,aAAaU,IACxBR,sBAAsBG,QACtB,kBAAkB;AAGnB5B,kBAAYuB,aAAaU,IACxBR,sBAAsBK,SACtB,mBAAmB;AAAA,IAAA;AAAA,EAGtB,GAAG,CAAE,CAAA;AAGCI,QAAAA,WAAWrB,MAAMsB,OAAO,KAAK;AACnCtB,QAAMS,UAAU,MAAK;AACpB,QAAIY,SAASE,SAAS;AACTb,kBAAAA,aAAac,OAAOhC,KAAK;AAAA,IAAA,OAC/B;AACN6B,eAASE,UAAU;AAAA,IACnB;AAAA,EAAA,GACC,CAAC/B,KAAK,CAAC;AAEV,SACCiC;IACC9B,WAAW,CAAC+B,gBAAgB/B,SAAS,EAAEgC,OAAOC,OAAO,EAAEC,KAAK,GAAG;AAAA,IAC/DC,OAAO;AAAA,MACNpC,QACC,OAAOA,WAAW,cACfE,aAAaF,SACbA,0BAAUqC;AAAAA,MACdC,UAAU;AAAA,MACVC,KAAK;AAAA,MACLC,MAAM;AAAA,MACNC,OAAO;AAAA,MACPC,QAAQ;AAAA,MACRC,UAAU;AAAA,MACV5C,YACC,OAAOA,eAAe,cACnBG,aAAaH,aACbA,kCAAcsC;AAAAA,IAClB;AAAA,IAAAO,UAEAhC,UACAmB,IAAA,WAAA;AAAA,MAASc,yBAAyB;AAAA,QAAEC,QAAQlC;AAAAA;IAAa,CAAA,IACtDH,OAAOsC,SACVhB,IAAA,OAAA;AAAA,MACCiB,IAAG;AAAA,MACH/C,WAAWgD;AAAAA,MACXb,OACChC,aAAa8C,WAAWC,mBAAmBC,SACxC;AAAA,QAAEC,SAAS;AAAA,MACXhB,IAAAA;AAAAA,MAEJiB,gBAAgBC;AAAAA,MAChBC,iBACCC;AAAAA,MAAwDb,UAGzDb,IAAClC;QAAcY;AAAAA,MAAAA,CAAc;AAAA,IACxB,CAAA,IACH;AAAA,EAAA,CACC;AAER;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
function _interopNamespace(e) {
|
|
5
|
+
if (e && e.__esModule)
|
|
6
|
+
return e;
|
|
7
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
+
if (e) {
|
|
9
|
+
for (const k in e) {
|
|
10
|
+
if (k !== "default") {
|
|
11
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: () => e[k]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespace(fs);
|
|
23
|
+
const customTypeAssetDelete = async (data, context) => {
|
|
24
|
+
const filePath = context.helpers.joinPathFromRoot("customtypes", data.customTypeID, data.assetID);
|
|
25
|
+
await fs__namespace.rm(filePath);
|
|
26
|
+
};
|
|
27
|
+
exports.customTypeAssetDelete = customTypeAssetDelete;
|
|
28
|
+
//# sourceMappingURL=customType-asset-delete.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-asset-delete.cjs","sources":["../../src/hooks/customType-asset-delete.ts"],"sourcesContent":["import type { CustomTypeAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetDelete: CustomTypeAssetDeleteHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\t\"customtypes\",\n\t\tdata.customTypeID,\n\t\tdata.assetID,\n\t);\n\n\tawait fs.rm(filePath);\n};\n"],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAKa,MAAA,wBAET,OAAO,MAAM,YAAW;AACrB,QAAA,WAAW,QAAQ,QAAQ,iBAChC,eACA,KAAK,cACL,KAAK,OAAO;AAGP,QAAAA,cAAG,GAAG,QAAQ;AACrB;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
const customTypeAssetDelete = async (data, context) => {
|
|
3
|
+
const filePath = context.helpers.joinPathFromRoot("customtypes", data.customTypeID, data.assetID);
|
|
4
|
+
await fs.rm(filePath);
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
customTypeAssetDelete
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=customType-asset-delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-asset-delete.js","sources":["../../src/hooks/customType-asset-delete.ts"],"sourcesContent":["import type { CustomTypeAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetDelete: CustomTypeAssetDeleteHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\t\"customtypes\",\n\t\tdata.customTypeID,\n\t\tdata.assetID,\n\t);\n\n\tawait fs.rm(filePath);\n};\n"],"names":[],"mappings":";AAKa,MAAA,wBAET,OAAO,MAAM,YAAW;AACrB,QAAA,WAAW,QAAQ,QAAQ,iBAChC,eACA,KAAK,cACL,KAAK,OAAO;AAGP,QAAA,GAAG,GAAG,QAAQ;AACrB;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
function _interopNamespace(e) {
|
|
5
|
+
if (e && e.__esModule)
|
|
6
|
+
return e;
|
|
7
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
+
if (e) {
|
|
9
|
+
for (const k in e) {
|
|
10
|
+
if (k !== "default") {
|
|
11
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: () => e[k]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespace(fs);
|
|
23
|
+
const customTypeAssetRead = async (data, context) => {
|
|
24
|
+
const filePath = context.helpers.joinPathFromRoot("customtypes", data.customTypeID, data.assetID);
|
|
25
|
+
const assetData = await fs__namespace.readFile(filePath);
|
|
26
|
+
return {
|
|
27
|
+
data: assetData
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
exports.customTypeAssetRead = customTypeAssetRead;
|
|
31
|
+
//# sourceMappingURL=customType-asset-read.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-asset-read.cjs","sources":["../../src/hooks/customType-asset-read.ts"],"sourcesContent":["import type { CustomTypeAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetRead: CustomTypeAssetReadHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\t\"customtypes\",\n\t\tdata.customTypeID,\n\t\tdata.assetID,\n\t);\n\n\tconst assetData = await fs.readFile(filePath);\n\n\treturn {\n\t\tdata: assetData,\n\t};\n};\n"],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAKa,MAAA,sBAET,OAAO,MAAM,YAAW;AACrB,QAAA,WAAW,QAAQ,QAAQ,iBAChC,eACA,KAAK,cACL,KAAK,OAAO;AAGb,QAAM,YAAY,MAAMA,cAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
const customTypeAssetRead = async (data, context) => {
|
|
3
|
+
const filePath = context.helpers.joinPathFromRoot("customtypes", data.customTypeID, data.assetID);
|
|
4
|
+
const assetData = await fs.readFile(filePath);
|
|
5
|
+
return {
|
|
6
|
+
data: assetData
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
customTypeAssetRead
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=customType-asset-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-asset-read.js","sources":["../../src/hooks/customType-asset-read.ts"],"sourcesContent":["import type { CustomTypeAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetRead: CustomTypeAssetReadHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\t\"customtypes\",\n\t\tdata.customTypeID,\n\t\tdata.assetID,\n\t);\n\n\tconst assetData = await fs.readFile(filePath);\n\n\treturn {\n\t\tdata: assetData,\n\t};\n};\n"],"names":[],"mappings":";AAKa,MAAA,sBAET,OAAO,MAAM,YAAW;AACrB,QAAA,WAAW,QAAQ,QAAQ,iBAChC,eACA,KAAK,cACL,KAAK,OAAO;AAGb,QAAM,YAAY,MAAM,GAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
function _interopNamespace(e) {
|
|
6
|
+
if (e && e.__esModule)
|
|
7
|
+
return e;
|
|
8
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
|
+
if (e) {
|
|
10
|
+
for (const k in e) {
|
|
11
|
+
if (k !== "default") {
|
|
12
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: () => e[k]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespace(fs);
|
|
24
|
+
const path__namespace = /* @__PURE__ */ _interopNamespace(path);
|
|
25
|
+
const customTypeAssetUpdate = async (data, context) => {
|
|
26
|
+
const filePath = context.helpers.joinPathFromRoot("customtypes", data.customTypeID, data.asset.id);
|
|
27
|
+
await fs__namespace.mkdir(path__namespace.dirname(filePath), { recursive: true });
|
|
28
|
+
await fs__namespace.writeFile(filePath, data.asset.data);
|
|
29
|
+
};
|
|
30
|
+
exports.customTypeAssetUpdate = customTypeAssetUpdate;
|
|
31
|
+
//# sourceMappingURL=customType-asset-update.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-asset-update.cjs","sources":["../../src/hooks/customType-asset-update.ts"],"sourcesContent":["import type { CustomTypeAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetUpdate: CustomTypeAssetUpdateHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\t\"customtypes\",\n\t\tdata.customTypeID,\n\t\tdata.asset.id,\n\t);\n\n\tawait fs.mkdir(path.dirname(filePath), { recursive: true });\n\tawait fs.writeFile(filePath, data.asset.data);\n};\n"],"names":["fs","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAMa,MAAA,wBAET,OAAO,MAAM,YAAW;AACrB,QAAA,WAAW,QAAQ,QAAQ,iBAChC,eACA,KAAK,cACL,KAAK,MAAM,EAAE;AAGR,QAAAA,cAAG,MAAMC,gBAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAA,CAAM;AAC1D,QAAMD,cAAG,UAAU,UAAU,KAAK,MAAM,IAAI;AAC7C;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
const customTypeAssetUpdate = async (data, context) => {
|
|
4
|
+
const filePath = context.helpers.joinPathFromRoot("customtypes", data.customTypeID, data.asset.id);
|
|
5
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
6
|
+
await fs.writeFile(filePath, data.asset.data);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
customTypeAssetUpdate
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=customType-asset-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-asset-update.js","sources":["../../src/hooks/customType-asset-update.ts"],"sourcesContent":["import type { CustomTypeAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetUpdate: CustomTypeAssetUpdateHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\t\"customtypes\",\n\t\tdata.customTypeID,\n\t\tdata.asset.id,\n\t);\n\n\tawait fs.mkdir(path.dirname(filePath), { recursive: true });\n\tawait fs.writeFile(filePath, data.asset.data);\n};\n"],"names":[],"mappings":";;AAMa,MAAA,wBAET,OAAO,MAAM,YAAW;AACrB,QAAA,WAAW,QAAQ,QAAQ,iBAChC,eACA,KAAK,cACL,KAAK,MAAM,EAAE;AAGR,QAAA,GAAG,MAAM,KAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAA,CAAM;AAC1D,QAAM,GAAG,UAAU,UAAU,KAAK,MAAM,IAAI;AAC7C;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
|
|
6
|
+
function _interopNamespace(e) {
|
|
7
|
+
if (e && e.__esModule)
|
|
8
|
+
return e;
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespace(fs);
|
|
25
|
+
const path__namespace = /* @__PURE__ */ _interopNamespace(path);
|
|
26
|
+
const createModelFile = async ({ dir, data, helpers, options }) => {
|
|
27
|
+
const filePath = path__namespace.join(dir, "index.json");
|
|
28
|
+
let contents = JSON.stringify(data.model);
|
|
29
|
+
if (options.format) {
|
|
30
|
+
contents = await helpers.format(contents, filePath);
|
|
31
|
+
}
|
|
32
|
+
await fs__namespace.writeFile(filePath, contents);
|
|
33
|
+
};
|
|
34
|
+
const customTypeCreate = async (data, context) => {
|
|
35
|
+
const dir = context.helpers.joinPathFromRoot("customtypes", data.model.id);
|
|
36
|
+
await fs__namespace.mkdir(dir, { recursive: true });
|
|
37
|
+
await createModelFile({ dir, data, ...context });
|
|
38
|
+
await upsertGlobalContentTypes.upsertGlobalContentTypes(context);
|
|
39
|
+
};
|
|
40
|
+
exports.customTypeCreate = customTypeCreate;
|
|
41
|
+
//# sourceMappingURL=customType-create.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-create.cjs","sources":["../../src/hooks/customType-create.ts"],"sourcesContent":["import type {\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: CustomTypeCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createModelFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"index.json\");\n\n\tlet contents = JSON.stringify(data.model);\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nexport const customTypeCreate: CustomTypeCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = context.helpers.joinPathFromRoot(\"customtypes\", data.model.id);\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tawait createModelFile({ dir, data, ...context });\n\n\tawait upsertGlobalContentTypes(context);\n};\n"],"names":["path","fs","upsertGlobalContentTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,kBAAkB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AACvE,QAAM,WAAWA,gBAAK,KAAK,KAAK,YAAY;AAE5C,MAAI,WAAW,KAAK,UAAU,KAAK,KAAK;AAExC,MAAI,QAAQ,QAAQ;AACnB,eAAW,MAAM,QAAQ,OAAO,UAAU,QAAQ;AAAA,EAClD;AAEK,QAAAC,cAAG,UAAU,UAAU,QAAQ;AACtC;AAEa,MAAA,mBAAwD,OACpE,MACA,YACG;AACH,QAAM,MAAM,QAAQ,QAAQ,iBAAiB,eAAe,KAAK,MAAM,EAAE;AAEzE,QAAMA,cAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAEvC,QAAM,gBAAgB,EAAE,KAAK,MAAM,GAAG,QAAS,CAAA;AAE/C,QAAMC,yBAAAA,yBAAyB,OAAO;AACvC;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
|
|
4
|
+
const createModelFile = async ({ dir, data, helpers, options }) => {
|
|
5
|
+
const filePath = path.join(dir, "index.json");
|
|
6
|
+
let contents = JSON.stringify(data.model);
|
|
7
|
+
if (options.format) {
|
|
8
|
+
contents = await helpers.format(contents, filePath);
|
|
9
|
+
}
|
|
10
|
+
await fs.writeFile(filePath, contents);
|
|
11
|
+
};
|
|
12
|
+
const customTypeCreate = async (data, context) => {
|
|
13
|
+
const dir = context.helpers.joinPathFromRoot("customtypes", data.model.id);
|
|
14
|
+
await fs.mkdir(dir, { recursive: true });
|
|
15
|
+
await createModelFile({ dir, data, ...context });
|
|
16
|
+
await upsertGlobalContentTypes(context);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
customTypeCreate
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=customType-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-create.js","sources":["../../src/hooks/customType-create.ts"],"sourcesContent":["import type {\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: CustomTypeCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createModelFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"index.json\");\n\n\tlet contents = JSON.stringify(data.model);\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nexport const customTypeCreate: CustomTypeCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = context.helpers.joinPathFromRoot(\"customtypes\", data.model.id);\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tawait createModelFile({ dir, data, ...context });\n\n\tawait upsertGlobalContentTypes(context);\n};\n"],"names":[],"mappings":";;;AAiBA,MAAM,kBAAkB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AACvE,QAAM,WAAW,KAAK,KAAK,KAAK,YAAY;AAE5C,MAAI,WAAW,KAAK,UAAU,KAAK,KAAK;AAExC,MAAI,QAAQ,QAAQ;AACnB,eAAW,MAAM,QAAQ,OAAO,UAAU,QAAQ;AAAA,EAClD;AAEK,QAAA,GAAG,UAAU,UAAU,QAAQ;AACtC;AAEa,MAAA,mBAAwD,OACpE,MACA,YACG;AACH,QAAM,MAAM,QAAQ,QAAQ,iBAAiB,eAAe,KAAK,MAAM,EAAE;AAEzE,QAAM,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAEvC,QAAM,gBAAgB,EAAE,KAAK,MAAM,GAAG,QAAS,CAAA;AAE/C,QAAM,yBAAyB,OAAO;AACvC;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
|
|
5
|
+
function _interopNamespace(e) {
|
|
6
|
+
if (e && e.__esModule)
|
|
7
|
+
return e;
|
|
8
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
|
+
if (e) {
|
|
10
|
+
for (const k in e) {
|
|
11
|
+
if (k !== "default") {
|
|
12
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: () => e[k]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespace(fs);
|
|
24
|
+
const customTypeDelete = async (data, context) => {
|
|
25
|
+
const dir = context.helpers.joinPathFromRoot("customtypes", data.model.id);
|
|
26
|
+
await fs__namespace.rm(dir, { recursive: true });
|
|
27
|
+
await upsertGlobalContentTypes.upsertGlobalContentTypes(context);
|
|
28
|
+
};
|
|
29
|
+
exports.customTypeDelete = customTypeDelete;
|
|
30
|
+
//# sourceMappingURL=customType-delete.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-delete.cjs","sources":["../../src/hooks/customType-delete.ts"],"sourcesContent":["import type { CustomTypeDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeDelete: CustomTypeDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = context.helpers.joinPathFromRoot(\"customtypes\", data.model.id);\n\n\tawait fs.rm(dir, { recursive: true });\n\n\tawait upsertGlobalContentTypes(context);\n};\n"],"names":["fs","upsertGlobalContentTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAOa,MAAA,mBAAwD,OACpE,MACA,YACG;AACH,QAAM,MAAM,QAAQ,QAAQ,iBAAiB,eAAe,KAAK,MAAM,EAAE;AAEzE,QAAMA,cAAG,GAAG,KAAK,EAAE,WAAW,MAAM;AAEpC,QAAMC,yBAAAA,yBAAyB,OAAO;AACvC;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
|
|
3
|
+
const customTypeDelete = async (data, context) => {
|
|
4
|
+
const dir = context.helpers.joinPathFromRoot("customtypes", data.model.id);
|
|
5
|
+
await fs.rm(dir, { recursive: true });
|
|
6
|
+
await upsertGlobalContentTypes(context);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
customTypeDelete
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=customType-delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-delete.js","sources":["../../src/hooks/customType-delete.ts"],"sourcesContent":["import type { CustomTypeDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeDelete: CustomTypeDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = context.helpers.joinPathFromRoot(\"customtypes\", data.model.id);\n\n\tawait fs.rm(dir, { recursive: true });\n\n\tawait upsertGlobalContentTypes(context);\n};\n"],"names":[],"mappings":";;AAOa,MAAA,mBAAwD,OACpE,MACA,YACG;AACH,QAAM,MAAM,QAAQ,QAAQ,iBAAiB,eAAe,KAAK,MAAM,EAAE;AAEzE,QAAM,GAAG,GAAG,KAAK,EAAE,WAAW,MAAM;AAEpC,QAAM,yBAAyB,OAAO;AACvC;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const readJSONFile = require("../lib/readJSONFile.cjs");
|
|
4
|
+
const customTypeRead = async (data, { helpers }) => {
|
|
5
|
+
const filePath = helpers.joinPathFromRoot("customtypes", data.id, "index.json");
|
|
6
|
+
const model = await readJSONFile.readJSONFile(filePath);
|
|
7
|
+
return {
|
|
8
|
+
model
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
exports.customTypeRead = customTypeRead;
|
|
12
|
+
//# sourceMappingURL=customType-read.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-read.cjs","sources":["../../src/hooks/customType-read.ts"],"sourcesContent":["import type { CustomTypeReadHook } from \"@slicemachine/plugin-kit\";\nimport * as prismicT from \"@prismicio/types\";\n\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeRead: CustomTypeReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst filePath = helpers.joinPathFromRoot(\n\t\t\"customtypes\",\n\t\tdata.id,\n\t\t\"index.json\",\n\t);\n\n\tconst model = await readJSONFile<prismicT.CustomTypeModel>(filePath);\n\n\treturn {\n\t\tmodel,\n\t};\n};\n"],"names":["readJSONFile"],"mappings":";;;AAOO,MAAM,iBAAoD,OAChE,MACA,EAAE,cACC;AACH,QAAM,WAAW,QAAQ,iBACxB,eACA,KAAK,IACL,YAAY;AAGP,QAAA,QAAQ,MAAMA,0BAAuC,QAAQ;AAE5D,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { readJSONFile } from "../lib/readJSONFile.js";
|
|
2
|
+
const customTypeRead = async (data, { helpers }) => {
|
|
3
|
+
const filePath = helpers.joinPathFromRoot("customtypes", data.id, "index.json");
|
|
4
|
+
const model = await readJSONFile(filePath);
|
|
5
|
+
return {
|
|
6
|
+
model
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
customTypeRead
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=customType-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-read.js","sources":["../../src/hooks/customType-read.ts"],"sourcesContent":["import type { CustomTypeReadHook } from \"@slicemachine/plugin-kit\";\nimport * as prismicT from \"@prismicio/types\";\n\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeRead: CustomTypeReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst filePath = helpers.joinPathFromRoot(\n\t\t\"customtypes\",\n\t\tdata.id,\n\t\t\"index.json\",\n\t);\n\n\tconst model = await readJSONFile<prismicT.CustomTypeModel>(filePath);\n\n\treturn {\n\t\tmodel,\n\t};\n};\n"],"names":[],"mappings":";AAOO,MAAM,iBAAoD,OAChE,MACA,EAAE,cACC;AACH,QAAM,WAAW,QAAQ,iBACxB,eACA,KAAK,IACL,YAAY;AAGP,QAAA,QAAQ,MAAM,aAAuC,QAAQ;AAE5D,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const customTypeCreate = require("./customType-create.cjs");
|
|
4
|
+
const customTypeUpdate = customTypeCreate.customTypeCreate;
|
|
5
|
+
exports.customTypeUpdate = customTypeUpdate;
|
|
6
|
+
//# sourceMappingURL=customType-update.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-update.cjs","sources":["../../src/hooks/customType-update.ts"],"sourcesContent":["import { customTypeCreate } from \"./customType-create\";\n\nexport const customTypeUpdate = customTypeCreate;\n"],"names":["customTypeCreate"],"mappings":";;;AAEO,MAAM,mBAAmBA,iBAAAA;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const customTypeUpdate: import("@slicemachine/plugin-kit").CustomTypeCreateHook<import("..").PluginOptions>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customType-update.js","sources":["../../src/hooks/customType-update.ts"],"sourcesContent":["import { customTypeCreate } from \"./customType-create\";\n\nexport const customTypeUpdate = customTypeCreate;\n"],"names":[],"mappings":";AAEO,MAAM,mBAAmB;"}
|