@slicemachine/plugin-kit 0.4.77-beta.9 → 0.4.78-alpha.jp-fix-cr-modal-rules-of-hooks.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../../node_modules/p-limit/index.js"],"sourcesContent":["import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue: () => {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n"],"names":["Queue"],"mappings":";;AAEe,SAAS,OAAO,aAAa;AAC3C,MAAI,GAAG,OAAO,UAAU,WAAW,KAAK,gBAAgB,OAAO,sBAAsB,cAAc,IAAI;AACtG,UAAM,IAAI,UAAU,qDAAqD;AAAA,EACzE;AAED,QAAM,QAAQ,IAAIA;AAClB,MAAI,cAAc;AAElB,QAAM,OAAO,MAAM;AAClB;AAEA,QAAI,MAAM,OAAO,GAAG;AACnB,YAAM,QAAO;IACb;AAAA,EACH;AAEC,QAAM,MAAM,OAAO,IAAI,SAAS,SAAS;AACxC;AAEA,UAAM,UAAU,YAAY,GAAG,GAAG,IAAI,GAAC;AAEvC,YAAQ,MAAM;AAEd,QAAI;AACH,YAAM;AAAA,IACN,QAAC;AAAA,IAAQ;AAEV;EACF;AAEC,QAAM,UAAU,CAAC,IAAI,SAAS,SAAS;AACtC,UAAM,QAAQ,IAAI,KAAK,QAAW,IAAI,SAAS,IAAI,CAAC;AAEpD,KAAC,YAAY;AAKZ,YAAM,QAAQ;AAEd,UAAI,cAAc,eAAe,MAAM,OAAO,GAAG;AAChD,cAAM,QAAO;MACb;AAAA,IACJ;EACA;AAEC,QAAM,YAAY,CAAC,OAAO,SAAS,IAAI,QAAQ,aAAW;AACzD,YAAQ,IAAI,SAAS,IAAI;AAAA,EAC3B,CAAE;AAED,SAAO,iBAAiB,WAAW;AAAA,IAClC,aAAa;AAAA,MACZ,KAAK,MAAM;AAAA,IACX;AAAA,IACD,cAAc;AAAA,MACb,KAAK,MAAM,MAAM;AAAA,IACjB;AAAA,IACD,YAAY;AAAA,MACX,OAAO,MAAM;AACZ,cAAM,MAAK;AAAA,MACX;AAAA,IACD;AAAA,EACH,CAAE;AAED,SAAO;AACR;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../../node_modules/p-limit/index.js"],"sourcesContent":["import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue: () => {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n"],"names":["Queue"],"mappings":";;AAEe,SAAS,OAAO,aAAa;AAC3C,MAAI,GAAG,OAAO,UAAU,WAAW,KAAK,gBAAgB,OAAO,sBAAsB,cAAc,IAAI;AACtG,UAAM,IAAI,UAAU,qDAAqD;AAAA,EACzE;AAED,QAAM,QAAQ,IAAIA;AAClB,MAAI,cAAc;AAElB,QAAM,OAAO,MAAM;AAClB;AAEA,QAAI,MAAM,OAAO,GAAG;AACnB,YAAM,QAAO;IACb;AAAA,EACH;AAEC,QAAM,MAAM,OAAO,IAAI,SAAS,SAAS;AACxC;AAEA,UAAM,UAAU,YAAY,GAAG,GAAG,IAAI,GAAC;AAEvC,YAAQ,MAAM;AAEd,QAAI;AACH,YAAM;AAAA,IACN,QAAO;AAAA,IAAE;AAEV;EACF;AAEC,QAAM,UAAU,CAAC,IAAI,SAAS,SAAS;AACtC,UAAM,QAAQ,IAAI,KAAK,QAAW,IAAI,SAAS,IAAI,CAAC;AAEpD,KAAC,YAAY;AAKZ,YAAM,QAAQ;AAEd,UAAI,cAAc,eAAe,MAAM,OAAO,GAAG;AAChD,cAAM,QAAO;MACb;AAAA,IACJ;EACA;AAEC,QAAM,YAAY,CAAC,OAAO,SAAS,IAAI,QAAQ,aAAW;AACzD,YAAQ,IAAI,SAAS,IAAI;AAAA,EAC3B,CAAE;AAED,SAAO,iBAAiB,WAAW;AAAA,IAClC,aAAa;AAAA,MACZ,KAAK,MAAM;AAAA,IACX;AAAA,IACD,cAAc;AAAA,MACb,KAAK,MAAM,MAAM;AAAA,IACjB;AAAA,IACD,YAAY;AAAA,MACX,OAAO,MAAM;AACZ,cAAM,MAAK;AAAA,MACX;AAAA,IACD;AAAA,EACH,CAAE;AAED,SAAO;AACR;;","x_google_ignoreList":[0]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../node_modules/p-limit/index.js"],"sourcesContent":["import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue: () => {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n"],"names":[],"mappings":";AAEe,SAAS,OAAO,aAAa;AAC3C,MAAI,GAAG,OAAO,UAAU,WAAW,KAAK,gBAAgB,OAAO,sBAAsB,cAAc,IAAI;AACtG,UAAM,IAAI,UAAU,qDAAqD;AAAA,EACzE;AAED,QAAM,QAAQ,IAAI;AAClB,MAAI,cAAc;AAElB,QAAM,OAAO,MAAM;AAClB;AAEA,QAAI,MAAM,OAAO,GAAG;AACnB,YAAM,QAAO;IACb;AAAA,EACH;AAEC,QAAM,MAAM,OAAO,IAAI,SAAS,SAAS;AACxC;AAEA,UAAM,UAAU,YAAY,GAAG,GAAG,IAAI,GAAC;AAEvC,YAAQ,MAAM;AAEd,QAAI;AACH,YAAM;AAAA,IACN,QAAC;AAAA,IAAQ;AAEV;EACF;AAEC,QAAM,UAAU,CAAC,IAAI,SAAS,SAAS;AACtC,UAAM,QAAQ,IAAI,KAAK,QAAW,IAAI,SAAS,IAAI,CAAC;AAEpD,KAAC,YAAY;AAKZ,YAAM,QAAQ;AAEd,UAAI,cAAc,eAAe,MAAM,OAAO,GAAG;AAChD,cAAM,QAAO;MACb;AAAA,IACJ;EACA;AAEC,QAAM,YAAY,CAAC,OAAO,SAAS,IAAI,QAAQ,aAAW;AACzD,YAAQ,IAAI,SAAS,IAAI;AAAA,EAC3B,CAAE;AAED,SAAO,iBAAiB,WAAW;AAAA,IAClC,aAAa;AAAA,MACZ,KAAK,MAAM;AAAA,IACX;AAAA,IACD,cAAc;AAAA,MACb,KAAK,MAAM,MAAM;AAAA,IACjB;AAAA,IACD,YAAY;AAAA,MACX,OAAO,MAAM;AACZ,cAAM,MAAK;AAAA,MACX;AAAA,IACD;AAAA,EACH,CAAE;AAED,SAAO;AACR;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.js","sources":["../../../../../node_modules/p-limit/index.js"],"sourcesContent":["import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue: () => {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n"],"names":[],"mappings":";AAEe,SAAS,OAAO,aAAa;AAC3C,MAAI,GAAG,OAAO,UAAU,WAAW,KAAK,gBAAgB,OAAO,sBAAsB,cAAc,IAAI;AACtG,UAAM,IAAI,UAAU,qDAAqD;AAAA,EACzE;AAED,QAAM,QAAQ,IAAI;AAClB,MAAI,cAAc;AAElB,QAAM,OAAO,MAAM;AAClB;AAEA,QAAI,MAAM,OAAO,GAAG;AACnB,YAAM,QAAO;IACb;AAAA,EACH;AAEC,QAAM,MAAM,OAAO,IAAI,SAAS,SAAS;AACxC;AAEA,UAAM,UAAU,YAAY,GAAG,GAAG,IAAI,GAAC;AAEvC,YAAQ,MAAM;AAEd,QAAI;AACH,YAAM;AAAA,IACN,QAAO;AAAA,IAAE;AAEV;EACF;AAEC,QAAM,UAAU,CAAC,IAAI,SAAS,SAAS;AACtC,UAAM,QAAQ,IAAI,KAAK,QAAW,IAAI,SAAS,IAAI,CAAC;AAEpD,KAAC,YAAY;AAKZ,YAAM,QAAQ;AAEd,UAAI,cAAc,eAAe,MAAM,OAAO,GAAG;AAChD,cAAM,QAAO;MACb;AAAA,IACJ;EACA;AAEC,QAAM,YAAY,CAAC,OAAO,SAAS,IAAI,QAAQ,aAAW;AACzD,YAAQ,IAAI,SAAS,IAAI;AAAA,EAC3B,CAAE;AAED,SAAO,iBAAiB,WAAW;AAAA,IAClC,aAAa;AAAA,MACZ,KAAK,MAAM;AAAA,IACX;AAAA,IACD,cAAc;AAAA,MACb,KAAK,MAAM,MAAM;AAAA,IACjB;AAAA,IACD,YAAY;AAAA,MACX,OAAO,MAAM;AACZ,cAAM,MAAK;AAAA,MACX;AAAA,IACD;AAAA,EACH,CAAE;AAED,SAAO;AACR;","x_google_ignoreList":[0]}
@@ -1 +1 @@
1
- {"version":3,"file":"createSliceMachineActions.cjs","sources":["../../src/createSliceMachineActions.ts"],"sourcesContent":["import { HookSystem } from \"./lib/HookSystem\";\nimport { SliceMachineHooks, SliceMachineProject } from \"./types\";\n\nimport { CustomTypeLibraryReadHookReturnType } from \"./hooks/customTypeLibrary-read\";\nimport {\n\tCustomTypeReadHookData,\n\tCustomTypeReadHookReturnType,\n} from \"./hooks/customType-read\";\nimport {\n\tSliceLibraryReadHookData,\n\tSliceLibraryReadHookReturnType,\n} from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookData, SliceReadHookReturnType } from \"./hooks/slice-read\";\n\nexport type ReadAllSliceModelsActionArgs<\n\tTWithMetadata extends boolean = false,\n> = {\n\twithMetadata?: TWithMetadata;\n};\n\nexport type ReadAllSliceModelsActionReturnType = (SliceReadHookReturnType & {\n\tlibraryID: string;\n})[];\n\nexport type ReadAllSliceModelsForLibraryActionArgs = {\n\tlibraryID: string;\n};\n\n/**\n * Creates Slice Machine actions.\n *\n * @internal\n */\nexport const createSliceMachineActions = (\n\tproject: SliceMachineProject,\n\thookSystem: HookSystem<SliceMachineHooks>,\n): SliceMachineActions => {\n\treturn new SliceMachineActions(project, hookSystem);\n};\n\n/**\n * Slice Machine actions shared to plugins and hooks.\n */\nexport class SliceMachineActions {\n\t/**\n\t * The Slice Machine project's metadata.\n\t *\n\t * @internal\n\t */\n\tprivate _project: SliceMachineProject;\n\t/**\n\t * The actions' hook system used to internally trigger hook calls.\n\t *\n\t * @internal\n\t */\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\n\tconstructor(\n\t\tproject: SliceMachineProject,\n\t\thookSystem: HookSystem<SliceMachineHooks>,\n\t) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t}\n\n\treadAllSliceModels =\n\t\tasync (): Promise<ReadAllSliceModelsActionReturnType> => {\n\t\t\tconst libraryIDs = this._project.config.libraries || [];\n\n\t\t\treturn (\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tlibraryIDs.map(async (libraryID) => {\n\t\t\t\t\t\tconst models = await this.readAllSliceModelsForLibrary({\n\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn models.map((model) => {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t...model,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t).flat();\n\t\t};\n\n\treadAllSliceModelsForLibrary = async (\n\t\targs: ReadAllSliceModelsForLibraryActionArgs,\n\t): Promise<SliceReadHookReturnType[]> => {\n\t\tconst { sliceIDs } = await this.readSliceLibrary({\n\t\t\tlibraryID: args.libraryID,\n\t\t});\n\n\t\treturn await Promise.all(\n\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\treturn await this.readSliceModel({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID,\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t};\n\n\treadSliceModel = async (\n\t\targs: SliceReadHookData,\n\t): Promise<SliceReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [model],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"slice:read\", {\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (!model) {\n\t\t\tthrow new Error(\n\t\t\t\t`Slice \\`${args.sliceID}\\` not found in the \\`${args.libraryID}\\` library.`,\n\t\t\t\t{ cause },\n\t\t\t);\n\t\t}\n\n\t\treturn model;\n\t};\n\n\treadSliceLibrary = async (\n\t\targs: SliceLibraryReadHookData,\n\t): Promise<SliceLibraryReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [library],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"slice-library:read\", {\n\t\t\tlibraryID: args.libraryID,\n\t\t});\n\n\t\tif (!library) {\n\t\t\tthrow new Error(`Slice library \\`${args.libraryID}\\` not found.`, {\n\t\t\t\tcause,\n\t\t\t});\n\t\t}\n\n\t\treturn library;\n\t};\n\n\treadAllCustomTypeModels = async (): Promise<\n\t\tCustomTypeReadHookReturnType[]\n\t> => {\n\t\tconst { ids } = await this.readCustomTypeLibrary();\n\n\t\treturn await Promise.all(\n\t\t\tids.map(async (id) => {\n\t\t\t\treturn this.readCustomTypeModel({ id });\n\t\t\t}),\n\t\t);\n\t};\n\n\treadCustomTypeModel = async (\n\t\targs: CustomTypeReadHookData,\n\t): Promise<CustomTypeReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [model],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"custom-type:read\", {\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (!model) {\n\t\t\tthrow new Error(`Custom type \\`${args.id}\\` not found.`, { cause });\n\t\t}\n\n\t\treturn model;\n\t};\n\n\treadCustomTypeLibrary =\n\t\tasync (): Promise<CustomTypeLibraryReadHookReturnType> => {\n\t\t\tconst {\n\t\t\t\tdata: [library],\n\t\t\t\terrors: [cause],\n\t\t\t} = await this._hookSystem.callHook(\n\t\t\t\t\"custom-type-library:read\",\n\t\t\t\tundefined,\n\t\t\t);\n\n\t\t\tif (!library) {\n\t\t\t\tthrow new Error(`Couldn't read custom type library.`, {\n\t\t\t\t\tcause,\n\t\t\t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SAC4C;AAC5C,YAAM,EACL,MAAM,CAAC,OAAO,GACd,QAAQ,CAAC,KAAK,EAAA,IACX,MAAM,KAAK,YAAY,SAAS,sBAAsB;AAAA,QACzD,WAAW,KAAK;AAAA,MAAA,CAChB;AAED,UAAI,CAAC,SAAS;AACb,cAAM,IAAI,MAAM,mBAAmB,KAAK,0BAA0B;AAAA,UACjE;AAAA,QAAA,CACA;AAAA,MACF;AAEO,aAAA;AAAA,IAAA;AAGR,mDAA0B,YAEtB;AACH,YAAM,EAAE,IAAQ,IAAA,MAAM,KAAK,sBAAqB;AAEhD,aAAO,MAAM,QAAQ,IACpB,IAAI,IAAI,OAAO,OAAM;AACpB,eAAO,KAAK,oBAAoB,EAAE,GAAI,CAAA;AAAA,MACtC,CAAA,CAAC;AAAA,IAAA;AAIJ,+CAAsB,OACrB,SAC0C;AAC1C,YAAM,EACL,MAAM,CAAC,KAAK,GACZ,QAAQ,CAAC,KAAK,EAAA,IACX,MAAM,KAAK,YAAY,SAAS,oBAAoB;AAAA,QACvD,IAAI,KAAK;AAAA,MAAA,CACT;AAED,UAAI,CAAC,OAAO;AACX,cAAM,IAAI,MAAM,iBAAiB,KAAK,mBAAmB,EAAE,OAAO;AAAA,MACnE;AAEO,aAAA;AAAA,IAAA;AAGR,iDACC,YAAyD;AACxD,YAAM,EACL,MAAM,CAAC,OAAO,GACd,QAAQ,CAAC,KAAK,MACX,MAAM,KAAK,YAAY,SAC1B,4BACA,MAAS;AAGV,UAAI,CAAC,SAAS;AACP,cAAA,IAAI,MAAM,sCAAsC;AAAA,UACrD;AAAA,QAAA,CACA;AAAA,MACF;AAEO,aAAA;AAAA,IAAA;AAhIR,SAAK,WAAW;AAChB,SAAK,cAAc;AAAA,EACpB;AAgIA;;;"}
1
+ {"version":3,"file":"createSliceMachineActions.cjs","sources":["../../src/createSliceMachineActions.ts"],"sourcesContent":["import { HookSystem } from \"./lib/HookSystem\";\nimport { SliceMachineHooks, SliceMachineProject } from \"./types\";\n\nimport { CustomTypeLibraryReadHookReturnType } from \"./hooks/customTypeLibrary-read\";\nimport {\n\tCustomTypeReadHookData,\n\tCustomTypeReadHookReturnType,\n} from \"./hooks/customType-read\";\nimport {\n\tSliceLibraryReadHookData,\n\tSliceLibraryReadHookReturnType,\n} from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookData, SliceReadHookReturnType } from \"./hooks/slice-read\";\n\nexport type ReadAllSliceModelsActionArgs<\n\tTWithMetadata extends boolean = false,\n> = {\n\twithMetadata?: TWithMetadata;\n};\n\nexport type ReadAllSliceModelsActionReturnType = (SliceReadHookReturnType & {\n\tlibraryID: string;\n})[];\n\nexport type ReadAllSliceModelsForLibraryActionArgs = {\n\tlibraryID: string;\n};\n\n/**\n * Creates Slice Machine actions.\n *\n * @internal\n */\nexport const createSliceMachineActions = (\n\tproject: SliceMachineProject,\n\thookSystem: HookSystem<SliceMachineHooks>,\n): SliceMachineActions => {\n\treturn new SliceMachineActions(project, hookSystem);\n};\n\n/**\n * Slice Machine actions shared to plugins and hooks.\n */\nexport class SliceMachineActions {\n\t/**\n\t * The Slice Machine project's metadata.\n\t *\n\t * @internal\n\t */\n\tprivate _project: SliceMachineProject;\n\t/**\n\t * The actions' hook system used to internally trigger hook calls.\n\t *\n\t * @internal\n\t */\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\n\tconstructor(\n\t\tproject: SliceMachineProject,\n\t\thookSystem: HookSystem<SliceMachineHooks>,\n\t) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t}\n\n\treadAllSliceModels =\n\t\tasync (): Promise<ReadAllSliceModelsActionReturnType> => {\n\t\t\tconst libraryIDs = this._project.config.libraries || [];\n\n\t\t\treturn (\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tlibraryIDs.map(async (libraryID) => {\n\t\t\t\t\t\tconst models = await this.readAllSliceModelsForLibrary({\n\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn models.map((model) => {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t...model,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t).flat();\n\t\t};\n\n\treadAllSliceModelsForLibrary = async (\n\t\targs: ReadAllSliceModelsForLibraryActionArgs,\n\t): Promise<SliceReadHookReturnType[]> => {\n\t\tconst { sliceIDs } = await this.readSliceLibrary({\n\t\t\tlibraryID: args.libraryID,\n\t\t});\n\n\t\treturn await Promise.all(\n\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\treturn await this.readSliceModel({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID,\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t};\n\n\treadSliceModel = async (\n\t\targs: SliceReadHookData,\n\t): Promise<SliceReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [model],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"slice:read\", {\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (!model) {\n\t\t\tthrow new Error(\n\t\t\t\t`Slice \\`${args.sliceID}\\` not found in the \\`${args.libraryID}\\` library.`,\n\t\t\t\t{ cause },\n\t\t\t);\n\t\t}\n\n\t\treturn model;\n\t};\n\n\treadSliceLibrary = async (\n\t\targs: SliceLibraryReadHookData,\n\t): Promise<SliceLibraryReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [library],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"slice-library:read\", {\n\t\t\tlibraryID: args.libraryID,\n\t\t});\n\n\t\tif (!library) {\n\t\t\tthrow new Error(`Slice library \\`${args.libraryID}\\` not found.`, {\n\t\t\t\tcause,\n\t\t\t});\n\t\t}\n\n\t\treturn library;\n\t};\n\n\treadAllCustomTypeModels = async (): Promise<\n\t\tCustomTypeReadHookReturnType[]\n\t> => {\n\t\tconst { ids } = await this.readCustomTypeLibrary();\n\n\t\treturn await Promise.all(\n\t\t\tids.map(async (id) => {\n\t\t\t\treturn this.readCustomTypeModel({ id });\n\t\t\t}),\n\t\t);\n\t};\n\n\treadCustomTypeModel = async (\n\t\targs: CustomTypeReadHookData,\n\t): Promise<CustomTypeReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [model],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"custom-type:read\", {\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (!model) {\n\t\t\tthrow new Error(`Custom type \\`${args.id}\\` not found.`, { cause });\n\t\t}\n\n\t\treturn model;\n\t};\n\n\treadCustomTypeLibrary =\n\t\tasync (): Promise<CustomTypeLibraryReadHookReturnType> => {\n\t\t\tconst {\n\t\t\t\tdata: [library],\n\t\t\t\terrors: [cause],\n\t\t\t} = await this._hookSystem.callHook(\n\t\t\t\t\"custom-type-library:read\",\n\t\t\t\tundefined,\n\t\t\t);\n\n\t\t\tif (!library) {\n\t\t\t\tthrow new Error(`Couldn't read custom type library.`, {\n\t\t\t\t\tcause,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn library;\n\t\t};\n}\n"],"names":[],"mappings":";;;;;;;;AAiCa,MAAA,4BAA4B,CACxC,SACA,eACwB;AACjB,SAAA,IAAI,oBAAoB,SAAS,UAAU;AACnD;MAKa,oBAAmB;AAAA,EAc/B,YACC,SACA,YAAyC;AAVlC;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUR,8CACC,YAAwD;AACvD,YAAM,aAAa,KAAK,SAAS,OAAO,aAAa,CAAA;AAErD,cACC,MAAM,QAAQ,IACb,WAAW,IAAI,OAAO,cAAa;AAC5B,cAAA,SAAS,MAAM,KAAK,6BAA6B;AAAA,UACtD;AAAA,QAAA,CACA;AAEM,eAAA,OAAO,IAAI,CAAC,UAAS;AACpB,iBAAA;AAAA,YACN;AA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AAsB,OACrB,SAC0C;AAC1C,YAAM,EACL,MAAM,CAAC,KAAK,GACZ,QAAQ,CAAC,KAAK,EAAA,IACX,MAAM,KAAK,YAAY,SAAS,oBAAoB;AAAA,QACvD,IAAI,KAAK;AAAA,MAAA,CACT;AAED,UAAI,CAAC,OAAO;AACL,cAAA,IAAI,MAAM,iBAAiB,KAAK,EAAE,iBAAiB,EAAE,OAAO;AAAA,MACnE;AAEO,aAAA;AAAA,IAAA;AAGR,iDACC,YAAyD;AACxD,YAAM,EACL,MAAM,CAAC,OAAO,GACd,QAAQ,CAAC,KAAK,MACX,MAAM,KAAK,YAAY,SAC1B,4BACA,MAAS;AAGV,UAAI,CAAC,SAAS;AACP,cAAA,IAAI,MAAM,sCAAsC;AAAA,UACrD;AAAA,QAAA,CACA;AAAA,MACF;AAEO,aAAA;AAAA,IAAA;AAhIR,SAAK,WAAW;AAChB,SAAK,cAAc;AAAA,EACpB;AAgIA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createSliceMachineActions.js","sources":["../../src/createSliceMachineActions.ts"],"sourcesContent":["import { HookSystem } from \"./lib/HookSystem\";\nimport { SliceMachineHooks, SliceMachineProject } from \"./types\";\n\nimport { CustomTypeLibraryReadHookReturnType } from \"./hooks/customTypeLibrary-read\";\nimport {\n\tCustomTypeReadHookData,\n\tCustomTypeReadHookReturnType,\n} from \"./hooks/customType-read\";\nimport {\n\tSliceLibraryReadHookData,\n\tSliceLibraryReadHookReturnType,\n} from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookData, SliceReadHookReturnType } from \"./hooks/slice-read\";\n\nexport type ReadAllSliceModelsActionArgs<\n\tTWithMetadata extends boolean = false,\n> = {\n\twithMetadata?: TWithMetadata;\n};\n\nexport type ReadAllSliceModelsActionReturnType = (SliceReadHookReturnType & {\n\tlibraryID: string;\n})[];\n\nexport type ReadAllSliceModelsForLibraryActionArgs = {\n\tlibraryID: string;\n};\n\n/**\n * Creates Slice Machine actions.\n *\n * @internal\n */\nexport const createSliceMachineActions = (\n\tproject: SliceMachineProject,\n\thookSystem: HookSystem<SliceMachineHooks>,\n): SliceMachineActions => {\n\treturn new SliceMachineActions(project, hookSystem);\n};\n\n/**\n * Slice Machine actions shared to plugins and hooks.\n */\nexport class SliceMachineActions {\n\t/**\n\t * The Slice Machine project's metadata.\n\t *\n\t * @internal\n\t */\n\tprivate _project: SliceMachineProject;\n\t/**\n\t * The actions' hook system used to internally trigger hook calls.\n\t *\n\t * @internal\n\t */\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\n\tconstructor(\n\t\tproject: SliceMachineProject,\n\t\thookSystem: HookSystem<SliceMachineHooks>,\n\t) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t}\n\n\treadAllSliceModels =\n\t\tasync (): Promise<ReadAllSliceModelsActionReturnType> => {\n\t\t\tconst libraryIDs = this._project.config.libraries || [];\n\n\t\t\treturn (\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tlibraryIDs.map(async (libraryID) => {\n\t\t\t\t\t\tconst models = await this.readAllSliceModelsForLibrary({\n\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn models.map((model) => {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t...model,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t).flat();\n\t\t};\n\n\treadAllSliceModelsForLibrary = async (\n\t\targs: ReadAllSliceModelsForLibraryActionArgs,\n\t): Promise<SliceReadHookReturnType[]> => {\n\t\tconst { sliceIDs } = await this.readSliceLibrary({\n\t\t\tlibraryID: args.libraryID,\n\t\t});\n\n\t\treturn await Promise.all(\n\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\treturn await this.readSliceModel({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID,\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t};\n\n\treadSliceModel = async (\n\t\targs: SliceReadHookData,\n\t): Promise<SliceReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [model],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"slice:read\", {\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (!model) {\n\t\t\tthrow new Error(\n\t\t\t\t`Slice \\`${args.sliceID}\\` not found in the \\`${args.libraryID}\\` library.`,\n\t\t\t\t{ cause },\n\t\t\t);\n\t\t}\n\n\t\treturn model;\n\t};\n\n\treadSliceLibrary = async (\n\t\targs: SliceLibraryReadHookData,\n\t): Promise<SliceLibraryReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [library],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"slice-library:read\", {\n\t\t\tlibraryID: args.libraryID,\n\t\t});\n\n\t\tif (!library) {\n\t\t\tthrow new Error(`Slice library \\`${args.libraryID}\\` not found.`, {\n\t\t\t\tcause,\n\t\t\t});\n\t\t}\n\n\t\treturn library;\n\t};\n\n\treadAllCustomTypeModels = async (): Promise<\n\t\tCustomTypeReadHookReturnType[]\n\t> => {\n\t\tconst { ids } = await this.readCustomTypeLibrary();\n\n\t\treturn await Promise.all(\n\t\t\tids.map(async (id) => {\n\t\t\t\treturn this.readCustomTypeModel({ id });\n\t\t\t}),\n\t\t);\n\t};\n\n\treadCustomTypeModel = async (\n\t\targs: CustomTypeReadHookData,\n\t): Promise<CustomTypeReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [model],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"custom-type:read\", {\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (!model) {\n\t\t\tthrow new Error(`Custom type \\`${args.id}\\` not found.`, { cause });\n\t\t}\n\n\t\treturn model;\n\t};\n\n\treadCustomTypeLibrary =\n\t\tasync (): Promise<CustomTypeLibraryReadHookReturnType> => {\n\t\t\tconst {\n\t\t\t\tdata: [library],\n\t\t\t\terrors: [cause],\n\t\t\t} = await this._hookSystem.callHook(\n\t\t\t\t\"custom-type-library:read\",\n\t\t\t\tundefined,\n\t\t\t);\n\n\t\t\tif (!library) {\n\t\t\t\tthrow new Error(`Couldn't read custom type library.`, {\n\t\t\t\t\tcause,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn library;\n\t\t};\n}\n"],"names":[],"mappings":";;;;;;AAiCa,MAAA,4BAA4B,CACxC,SACA,eACwB;AACjB,SAAA,IAAI,oBAAoB,SAAS,UAAU;AACnD;MAKa,oBAAmB;AAAA,EAc/B,YACC,SACA,YAAyC;AAVlC;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUR,8CACC,YAAwD;AACvD,YAAM,aAAa,KAAK,SAAS,OAAO,aAAa,CAAA;AAErD,cACC,MAAM,QAAQ,IACb,WAAW,IAAI,OAAO,cAAa;AAC5B,cAAA,SAAS,MAAM,KAAK,6BAA6B;AAAA,UACtD;AAAA,QAAA,CACA;AAEM,eAAA,OAAO,IAAI,CAAC,UAAS;AACpB,iBAAA;AAAA,YACN;AAAA,YACA,GAAG;AAAA,UAAA;AAAA,SAEJ;AAAA,MAAA,CACD,CAAC,GAEF;;AAGJ,wDAA+B,OAC9B,SACuC;AACvC,YAAM,EAAE,SAAA,IAAa,MAAM,KAAK,iBAAiB;AAAA,QAChD,WAAW,KAAK;AAAA,MAAA,CAChB;AAED,aAAO,MAAM,QAAQ,IACpB,SAAS,IAAI,OAAO,YAAW;AACvB,eAAA,MAAM,KAAK,eAAe;AAAA,UAChC,WAAW,KAAK;AAAA,UAChB;AAAA,QAAA,CACA;AAAA,MACD,CAAA,CAAC;AAAA,IAAA;AAIJ,0CAAiB,OAChB,SACqC;AACrC,YAAM,EACL,MAAM,CAAC,KAAK,GACZ,QAAQ,CAAC,KAAK,EAAA,IACX,MAAM,KAAK,YAAY,SAAS,cAA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;AAAA,IAAA;AAhIR,SAAK,WAAW;AAChB,SAAK,cAAc;AAAA,EACpB;AAgIA;"}
1
+ {"version":3,"file":"createSliceMachineActions.js","sources":["../../src/createSliceMachineActions.ts"],"sourcesContent":["import { HookSystem } from \"./lib/HookSystem\";\nimport { SliceMachineHooks, SliceMachineProject } from \"./types\";\n\nimport { CustomTypeLibraryReadHookReturnType } from \"./hooks/customTypeLibrary-read\";\nimport {\n\tCustomTypeReadHookData,\n\tCustomTypeReadHookReturnType,\n} from \"./hooks/customType-read\";\nimport {\n\tSliceLibraryReadHookData,\n\tSliceLibraryReadHookReturnType,\n} from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookData, SliceReadHookReturnType } from \"./hooks/slice-read\";\n\nexport type ReadAllSliceModelsActionArgs<\n\tTWithMetadata extends boolean = false,\n> = {\n\twithMetadata?: TWithMetadata;\n};\n\nexport type ReadAllSliceModelsActionReturnType = (SliceReadHookReturnType & {\n\tlibraryID: string;\n})[];\n\nexport type ReadAllSliceModelsForLibraryActionArgs = {\n\tlibraryID: string;\n};\n\n/**\n * Creates Slice Machine actions.\n *\n * @internal\n */\nexport const createSliceMachineActions = (\n\tproject: SliceMachineProject,\n\thookSystem: HookSystem<SliceMachineHooks>,\n): SliceMachineActions => {\n\treturn new SliceMachineActions(project, hookSystem);\n};\n\n/**\n * Slice Machine actions shared to plugins and hooks.\n */\nexport class SliceMachineActions {\n\t/**\n\t * The Slice Machine project's metadata.\n\t *\n\t * @internal\n\t */\n\tprivate _project: SliceMachineProject;\n\t/**\n\t * The actions' hook system used to internally trigger hook calls.\n\t *\n\t * @internal\n\t */\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\n\tconstructor(\n\t\tproject: SliceMachineProject,\n\t\thookSystem: HookSystem<SliceMachineHooks>,\n\t) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t}\n\n\treadAllSliceModels =\n\t\tasync (): Promise<ReadAllSliceModelsActionReturnType> => {\n\t\t\tconst libraryIDs = this._project.config.libraries || [];\n\n\t\t\treturn (\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tlibraryIDs.map(async (libraryID) => {\n\t\t\t\t\t\tconst models = await this.readAllSliceModelsForLibrary({\n\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn models.map((model) => {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t...model,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t).flat();\n\t\t};\n\n\treadAllSliceModelsForLibrary = async (\n\t\targs: ReadAllSliceModelsForLibraryActionArgs,\n\t): Promise<SliceReadHookReturnType[]> => {\n\t\tconst { sliceIDs } = await this.readSliceLibrary({\n\t\t\tlibraryID: args.libraryID,\n\t\t});\n\n\t\treturn await Promise.all(\n\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\treturn await this.readSliceModel({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID,\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t};\n\n\treadSliceModel = async (\n\t\targs: SliceReadHookData,\n\t): Promise<SliceReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [model],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"slice:read\", {\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (!model) {\n\t\t\tthrow new Error(\n\t\t\t\t`Slice \\`${args.sliceID}\\` not found in the \\`${args.libraryID}\\` library.`,\n\t\t\t\t{ cause },\n\t\t\t);\n\t\t}\n\n\t\treturn model;\n\t};\n\n\treadSliceLibrary = async (\n\t\targs: SliceLibraryReadHookData,\n\t): Promise<SliceLibraryReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [library],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"slice-library:read\", {\n\t\t\tlibraryID: args.libraryID,\n\t\t});\n\n\t\tif (!library) {\n\t\t\tthrow new Error(`Slice library \\`${args.libraryID}\\` not found.`, {\n\t\t\t\tcause,\n\t\t\t});\n\t\t}\n\n\t\treturn library;\n\t};\n\n\treadAllCustomTypeModels = async (): Promise<\n\t\tCustomTypeReadHookReturnType[]\n\t> => {\n\t\tconst { ids } = await this.readCustomTypeLibrary();\n\n\t\treturn await Promise.all(\n\t\t\tids.map(async (id) => {\n\t\t\t\treturn this.readCustomTypeModel({ id });\n\t\t\t}),\n\t\t);\n\t};\n\n\treadCustomTypeModel = async (\n\t\targs: CustomTypeReadHookData,\n\t): Promise<CustomTypeReadHookReturnType> => {\n\t\tconst {\n\t\t\tdata: [model],\n\t\t\terrors: [cause],\n\t\t} = await this._hookSystem.callHook(\"custom-type:read\", {\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (!model) {\n\t\t\tthrow new Error(`Custom type \\`${args.id}\\` not found.`, { cause });\n\t\t}\n\n\t\treturn model;\n\t};\n\n\treadCustomTypeLibrary =\n\t\tasync (): Promise<CustomTypeLibraryReadHookReturnType> => {\n\t\t\tconst {\n\t\t\t\tdata: [library],\n\t\t\t\terrors: [cause],\n\t\t\t} = await this._hookSystem.callHook(\n\t\t\t\t\"custom-type-library:read\",\n\t\t\t\tundefined,\n\t\t\t);\n\n\t\t\tif (!library) {\n\t\t\t\tthrow new Error(`Couldn't read custom type library.`, {\n\t\t\t\t\tcause,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn library;\n\t\t};\n}\n"],"names":[],"mappings":";;;;;;AAiCa,MAAA,4BAA4B,CACxC,SACA,eACwB;AACjB,SAAA,IAAI,oBAAoB,SAAS,UAAU;AACnD;MAKa,oBAAmB;AAAA,EAc/B,YACC,SACA,YAAyC;AAVlC;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUR,8CACC,YAAwD;AACvD,YAAM,aAAa,K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mDAA0B,YAEtB;AACH,YAAM,EAAE,IAAQ,IAAA,MAAM,KAAK,sBAAqB;AAEhD,aAAO,MAAM,QAAQ,IACpB,IAAI,IAAI,OAAO,OAAM;AACpB,eAAO,KAAK,oBAAoB,EAAE,GAAI,CAAA;AAAA,MACtC,CAAA,CAAC;AAAA,IAAA;AAIJ,+CAAsB,OACrB,SAC0C;AAC1C,YAAM,EACL,MAAM,CAAC,KAAK,GACZ,QAAQ,CAAC,KAAK,EAAA,IACX,MAAM,KAAK,YAAY,SAAS,oBAAoB;AAAA,QACvD,IAAI,KAAK;AAAA,MAAA,CACT;AAED,UAAI,CAAC,OAAO;AACL,cAAA,IAAI,MAAM,iBAAiB,KAAK,EAAE,iBAAiB,EAAE,OAAO;AAAA,MACnE;AAEO,aAAA;AAAA,IAAA;AAGR,iDACC,YAAyD;AACxD,YAAM,EACL,MAAM,CAAC,OAAO,GACd,QAAQ,CAAC,KAAK,MACX,MAAM,KAAK,YAAY,SAC1B,4BACA,MAAS;AAGV,UAAI,CAAC,SAAS;AACP,cAAA,IAAI,MAAM,sCAAsC;AAAA,UACrD;AAAA,QAAA,CACA;AAAA,MACF;AAEO,aAAA;AAAA,IAAA;AAhIR,SAAK,WAAW;AAChB,SAAK,cAAc;AAAA,EACpB;AAgIA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createSliceMachineHelpers.cjs","sources":["../../src/createSliceMachineHelpers.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport * as prettier from \"prettier\";\nimport { stripIndent } from \"common-tags\";\n\nimport { decodeSliceMachineConfig } from \"./lib/decodeSliceMachineConfig\";\n\nimport { SliceMachineConfig, SliceMachineProject } from \"./types\";\n\ntype UpdateSliceMachineConfigOptions = {\n\tformat?: boolean;\n};\n\ntype FormatOptions = {\n\tprettier?: prettier.Options;\n\t/**\n\t * Determines if a newline is included at the end of the formatted result.\n\t *\n\t * @defaultValue `true`\n\t */\n\tincludeNewlineAtEnd?: boolean;\n};\n\n/**\n * Creates Slice Machine helpers.\n *\n * @internal\n */\nexport const createSliceMachineHelpers = (\n\tproject: SliceMachineProject,\n): SliceMachineHelpers => {\n\treturn new SliceMachineHelpers(project);\n};\n\n/**\n * Slice Machine helpers shared to plugins and hooks.\n */\nexport class SliceMachineHelpers {\n\t/**\n\t * The Slice Machine project's metadata.\n\t *\n\t * @internal\n\t */\n\tprivate _project: SliceMachineProject;\n\n\tconstructor(project: SliceMachineProject) {\n\t\tthis._project = project;\n\t}\n\n\tgetProject = async (): Promise<SliceMachineProject> => {\n\t\tconst configFilePath = this.joinPathFromRoot(\"slicemachine.config.json\");\n\n\t\tlet rawConfig: unknown | undefined;\n\t\ttry {\n\t\t\tconst contents = await fs.readFile(configFilePath, \"utf8\");\n\t\t\trawConfig = JSON.parse(contents);\n\t\t} catch {\n\t\t\t// noop\n\t\t}\n\n\t\tif (!rawConfig) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(\"No config found.\");\n\t\t}\n\n\t\tconst { value: sliceMachineConfig, error } =\n\t\t\tdecodeSliceMachineConfig(rawConfig);\n\n\t\tif (error) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(`Invalid config. ${error.errors.join(\", \")}`);\n\t\t}\n\n\t\treturn {\n\t\t\t...this._project,\n\t\t\tconfig: sliceMachineConfig,\n\t\t};\n\t};\n\n\tupdateSliceMachineConfig = async (\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t\toptions?: UpdateSliceMachineConfigOptions,\n\t): Promise<void> => {\n\t\tconst { value: decodedSliceMachineConfig, error } =\n\t\t\tdecodeSliceMachineConfig(sliceMachineConfig);\n\n\t\tif (error) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(`Invalid config provided. ${error.errors.join(\", \")}`);\n\t\t}\n\n\t\tconst configFilePath = this.joinPathFromRoot(\"slicemachine.config.json\");\n\t\tlet content = JSON.stringify(decodedSliceMachineConfig, null, 2);\n\n\t\tif (options?.format) {\n\t\t\tcontent = await this.format(content, configFilePath);\n\t\t}\n\n\t\tawait fs.writeFile(configFilePath, content);\n\t};\n\n\tformat = async (\n\t\tsource: string,\n\t\tfilePath?: string,\n\t\toptions?: FormatOptions,\n\t): Promise<string> => {\n\t\tlet formatted = stripIndent(source);\n\n\t\tconst prettierOptions = await prettier.resolveConfig(\n\t\t\tfilePath || this._project.root,\n\t\t);\n\n\t\tformatted = await prettier.format(formatted, {\n\t\t\t...prettierOptions,\n\t\t\tfilepath: filePath,\n\t\t\t...(options?.prettier ?? {}),\n\t\t});\n\n\t\tif (options?.includeNewlineAtEnd === false) {\n\t\t\tformatted = formatted.replace(/[\\r\\n]+$/, \"\");\n\t\t}\n\n\t\treturn formatted;\n\t};\n\n\tjoinPathFromRoot = (...paths: string[]): string => {\n\t\treturn path.join(this._project.root, ...paths);\n\t};\n}\n"],"names":["fs","decodeSliceMachineConfig","stripIndent","prettier","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6Ba,MAAA,4BAA4B,CACxC,YACwB;AACjB,SAAA,IAAI,oBAAoB,OAAO;AACvC;MAKa,oBAAmB;AAAA,EAQ/B,YAAY,SAA4B;AAFhC;AAAA;AAAA;AAAA;AAAA;AAAA;AAMR,sCAAa,YAAyC;AAC/C,YAAA,iBAAiB,KAAK,iBAAiB,0BAA0B;AAEnE,UAAA;AACA,UAAA;AACH,cAAM,WAAW,MAAMA,cAAG,SAAS,gBAAgB,MAAM;AAC7C,oBAAA,KAAK,MAAM,QAAQ;AAAA,MAAA,QAC9B;AAAA,MAEF;AAEA,UAAI,CAAC,WAAW;AAET,cAAA,IAAI,MAAM,kBAAkB;AAAA,MACnC;AAEA,YAAM,EAAE,OAAO,oBAAoB,MAAO,IACzCC,yBAAAA,yBAAyB,SAAS;AAEnC,UAAI,OAAO;AAEV,cAAM,IAAI,MAAM,mBAAmB,MAAM,OAAO,KAAK,IAAI,GAAG;AAAA,MAC7D;AAEO,aAAA;AAAA,QACN,GAAG,KAAK;AAAA,QACR,QAAQ;AAAA,MAAA;AAAA;AAIV,oDAA2B,OAC1B,oBACA,YACkB;AAClB,YAAM,EAAE,OAAO,2BAA2B,MAAO,IAChDA,yBAAAA,yBAAyB,kBAAkB;AAE5C,UAAI,OAAO;AAEV,cAAM,IAAI,MAAM,4BAA4B,MAAM,OAAO,KAAK,IAAI,GAAG;AAAA,MACtE;AAEM,YAAA,iBAAiB,KAAK,iBAAiB,0BAA0B;AACvE,UAAI,UAAU,KAAK,UAAU,2BAA2B,MAAM,CAAC;AAE/D,UAAI,mCAAS,QAAQ;AACpB,kBAAU,MAAM,KAAK,OAAO,SAAS,cAAc;AAAA,MACpD;AAEM,YAAAD,cAAG,UAAU,gBAAgB,OAAO;AAAA,IAAA;AAG3C,kCAAS,OACR,QACA,UACA,YACoB;AAChB,UAAA,YAAYE,uBAAY,MAAM;AAElC,YAAM,kBAAkB,MAAMC,oBAAS,cACtC,YAAY,KAAK,SAAS,IAAI;AAGnB,kBAAA,MAAMA,oBAAS,OAAO,WAAW;AAAA,QAC5C,GAAG;AAAA,QACH,UAAU;AAAA,QACV,IAAI,mCAAS,aAAY;OACzB;AAEG,WAAA,mCAAS,yBAAwB,OAAO;AAC/B,oBAAA,UAAU,QAAQ,YAAY,EAAE;AAAA,MAC7C;AAEO,aAAA;AAAA,IAAA;AAGR,4CAAmB,IAAI,UAA2B;AACjD,aAAOC,gBAAK,KAAK,KAAK,SAAS,MAAM,GAAG,KAAK;AAAA,IAAA;AAhF7C,SAAK,WAAW;AAAA,EACjB;AAiFA;;;"}
1
+ {"version":3,"file":"createSliceMachineHelpers.cjs","sources":["../../src/createSliceMachineHelpers.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport * as prettier from \"prettier\";\nimport { stripIndent } from \"common-tags\";\n\nimport { decodeSliceMachineConfig } from \"./lib/decodeSliceMachineConfig\";\n\nimport { SliceMachineConfig, SliceMachineProject } from \"./types\";\n\ntype UpdateSliceMachineConfigOptions = {\n\tformat?: boolean;\n};\n\ntype FormatOptions = {\n\tprettier?: prettier.Options;\n\t/**\n\t * Determines if a newline is included at the end of the formatted result.\n\t *\n\t * @defaultValue `true`\n\t */\n\tincludeNewlineAtEnd?: boolean;\n};\n\n/**\n * Creates Slice Machine helpers.\n *\n * @internal\n */\nexport const createSliceMachineHelpers = (\n\tproject: SliceMachineProject,\n): SliceMachineHelpers => {\n\treturn new SliceMachineHelpers(project);\n};\n\n/**\n * Slice Machine helpers shared to plugins and hooks.\n */\nexport class SliceMachineHelpers {\n\t/**\n\t * The Slice Machine project's metadata.\n\t *\n\t * @internal\n\t */\n\tprivate _project: SliceMachineProject;\n\n\tconstructor(project: SliceMachineProject) {\n\t\tthis._project = project;\n\t}\n\n\tgetProject = async (): Promise<SliceMachineProject> => {\n\t\tconst configFilePath = this.joinPathFromRoot(\"slicemachine.config.json\");\n\n\t\tlet rawConfig: unknown | undefined;\n\t\ttry {\n\t\t\tconst contents = await fs.readFile(configFilePath, \"utf8\");\n\t\t\trawConfig = JSON.parse(contents);\n\t\t} catch {\n\t\t\t// noop\n\t\t}\n\n\t\tif (!rawConfig) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(\"No config found.\");\n\t\t}\n\n\t\tconst { value: sliceMachineConfig, error } =\n\t\t\tdecodeSliceMachineConfig(rawConfig);\n\n\t\tif (error) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(`Invalid config. ${error.errors.join(\", \")}`);\n\t\t}\n\n\t\treturn {\n\t\t\t...this._project,\n\t\t\tconfig: sliceMachineConfig,\n\t\t};\n\t};\n\n\tupdateSliceMachineConfig = async (\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t\toptions?: UpdateSliceMachineConfigOptions,\n\t): Promise<void> => {\n\t\tconst { value: decodedSliceMachineConfig, error } =\n\t\t\tdecodeSliceMachineConfig(sliceMachineConfig);\n\n\t\tif (error) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(`Invalid config provided. ${error.errors.join(\", \")}`);\n\t\t}\n\n\t\tconst configFilePath = this.joinPathFromRoot(\"slicemachine.config.json\");\n\t\tlet content = JSON.stringify(decodedSliceMachineConfig, null, 2);\n\n\t\tif (options?.format) {\n\t\t\tcontent = await this.format(content, configFilePath);\n\t\t}\n\n\t\tawait fs.writeFile(configFilePath, content);\n\t};\n\n\tformat = async (\n\t\tsource: string,\n\t\tfilePath?: string,\n\t\toptions?: FormatOptions,\n\t): Promise<string> => {\n\t\tlet formatted = stripIndent(source);\n\n\t\tconst prettierOptions = await prettier.resolveConfig(\n\t\t\tfilePath || this._project.root,\n\t\t);\n\n\t\tformatted = await prettier.format(formatted, {\n\t\t\t...prettierOptions,\n\t\t\tfilepath: filePath,\n\t\t\t...(options?.prettier ?? {}),\n\t\t});\n\n\t\tif (options?.includeNewlineAtEnd === false) {\n\t\t\tformatted = formatted.replace(/[\\r\\n]+$/, \"\");\n\t\t}\n\n\t\treturn formatted;\n\t};\n\n\tjoinPathFromRoot = (...paths: string[]): string => {\n\t\treturn path.join(this._project.root, ...paths);\n\t};\n}\n"],"names":["fs","decodeSliceMachineConfig","stripIndent","prettier","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6Ba,MAAA,4BAA4B,CACxC,YACwB;AACjB,SAAA,IAAI,oBAAoB,OAAO;AACvC;MAKa,oBAAmB;AAAA,EAQ/B,YAAY,SAA4B;AAFhC;AAAA;AAAA;AAAA;AAAA;AAAA;AAMR,sCAAa,YAAyC;AAC/C,YAAA,iBAAiB,KAAK,iBAAiB,0BAA0B;AAEnE,UAAA;AACA,UAAA;AACH,cAAM,WAAW,MAAMA,cAAG,SAAS,gBAAgB,MAAM;AAC7C,oBAAA,KAAK,MAAM,QAAQ;AAAA,MAAA,QACxB;AAAA,MAER;AAEA,UAAI,CAAC,WAAW;AAET,cAAA,IAAI,MAAM,kBAAkB;AA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ources":["../../src/createSliceMachineHelpers.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport * as prettier from \"prettier\";\nimport { stripIndent } from \"common-tags\";\n\nimport { decodeSliceMachineConfig } from \"./lib/decodeSliceMachineConfig\";\n\nimport { SliceMachineConfig, SliceMachineProject } from \"./types\";\n\ntype UpdateSliceMachineConfigOptions = {\n\tformat?: boolean;\n};\n\ntype FormatOptions = {\n\tprettier?: prettier.Options;\n\t/**\n\t * Determines if a newline is included at the end of the formatted result.\n\t *\n\t * @defaultValue `true`\n\t */\n\tincludeNewlineAtEnd?: boolean;\n};\n\n/**\n * Creates Slice Machine helpers.\n *\n * @internal\n */\nexport const createSliceMachineHelpers = (\n\tproject: SliceMachineProject,\n): SliceMachineHelpers => {\n\treturn new SliceMachineHelpers(project);\n};\n\n/**\n * Slice Machine helpers shared to plugins and hooks.\n */\nexport class SliceMachineHelpers {\n\t/**\n\t * The Slice Machine project's metadata.\n\t *\n\t * @internal\n\t */\n\tprivate _project: SliceMachineProject;\n\n\tconstructor(project: SliceMachineProject) {\n\t\tthis._project = project;\n\t}\n\n\tgetProject = async (): Promise<SliceMachineProject> => {\n\t\tconst configFilePath = this.joinPathFromRoot(\"slicemachine.config.json\");\n\n\t\tlet rawConfig: unknown | undefined;\n\t\ttry {\n\t\t\tconst contents = await fs.readFile(configFilePath, \"utf8\");\n\t\t\trawConfig = JSON.parse(contents);\n\t\t} catch {\n\t\t\t// noop\n\t\t}\n\n\t\tif (!rawConfig) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(\"No config found.\");\n\t\t}\n\n\t\tconst { value: sliceMachineConfig, error } =\n\t\t\tdecodeSliceMachineConfig(rawConfig);\n\n\t\tif (error) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(`Invalid config. ${error.errors.join(\", \")}`);\n\t\t}\n\n\t\treturn {\n\t\t\t...this._project,\n\t\t\tconfig: sliceMachineConfig,\n\t\t};\n\t};\n\n\tupdateSliceMachineConfig = async (\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t\toptions?: UpdateSliceMachineConfigOptions,\n\t): Promise<void> => {\n\t\tconst { value: decodedSliceMachineConfig, error } =\n\t\t\tdecodeSliceMachineConfig(sliceMachineConfig);\n\n\t\tif (error) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(`Invalid config provided. ${error.errors.join(\", \")}`);\n\t\t}\n\n\t\tconst configFilePath = this.joinPathFromRoot(\"slicemachine.config.json\");\n\t\tlet content = JSON.stringify(decodedSliceMachineConfig, null, 2);\n\n\t\tif (options?.format) {\n\t\t\tcontent = await this.format(content, configFilePath);\n\t\t}\n\n\t\tawait fs.writeFile(configFilePath, content);\n\t};\n\n\tformat = async (\n\t\tsource: string,\n\t\tfilePath?: string,\n\t\toptions?: FormatOptions,\n\t): Promise<string> => {\n\t\tlet formatted = stripIndent(source);\n\n\t\tconst prettierOptions = await prettier.resolveConfig(\n\t\t\tfilePath || this._project.root,\n\t\t);\n\n\t\tformatted = await prettier.format(formatted, {\n\t\t\t...prettierOptions,\n\t\t\tfilepath: filePath,\n\t\t\t...(options?.prettier ?? {}),\n\t\t});\n\n\t\tif (options?.includeNewlineAtEnd === false) {\n\t\t\tformatted = formatted.replace(/[\\r\\n]+$/, \"\");\n\t\t}\n\n\t\treturn formatted;\n\t};\n\n\tjoinPathFromRoot = (...paths: string[]): string => {\n\t\treturn path.join(this._project.root, ...paths);\n\t};\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA6Ba,MAAA,4BAA4B,CACxC,YACwB;AACjB,SAAA,IAAI,oBAAoB,OAAO;AACvC;MAKa,oBAAmB;AAAA,EAQ/B,YAAY,SAA4B;AAFhC;AAAA;AAAA;AAAA;AAAA;AAAA;AAMR,sCAAa,YAAyC;AAC/C,YAAA,iBAAiB,KAAK,iBAAiB,0BAA0B;AAEnE,UAAA;AACA,UAAA;AACH,cAAM,WAAW,MAAM,GAAG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IAAA;AAhF7C,SAAK,WAAW;AAAA,EACjB;AAiFA;"}
1
+ {"version":3,"file":"createSliceMachineHelpers.js","sources":["../../src/createSliceMachineHelpers.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport * as prettier from \"prettier\";\nimport { stripIndent } from \"common-tags\";\n\nimport { decodeSliceMachineConfig } from \"./lib/decodeSliceMachineConfig\";\n\nimport { SliceMachineConfig, SliceMachineProject } from \"./types\";\n\ntype UpdateSliceMachineConfigOptions = {\n\tformat?: boolean;\n};\n\ntype FormatOptions = {\n\tprettier?: prettier.Options;\n\t/**\n\t * Determines if a newline is included at the end of the formatted result.\n\t *\n\t * @defaultValue `true`\n\t */\n\tincludeNewlineAtEnd?: boolean;\n};\n\n/**\n * Creates Slice Machine helpers.\n *\n * @internal\n */\nexport const createSliceMachineHelpers = (\n\tproject: SliceMachineProject,\n): SliceMachineHelpers => {\n\treturn new SliceMachineHelpers(project);\n};\n\n/**\n * Slice Machine helpers shared to plugins and hooks.\n */\nexport class SliceMachineHelpers {\n\t/**\n\t * The Slice Machine project's metadata.\n\t *\n\t * @internal\n\t */\n\tprivate _project: SliceMachineProject;\n\n\tconstructor(project: SliceMachineProject) {\n\t\tthis._project = project;\n\t}\n\n\tgetProject = async (): Promise<SliceMachineProject> => {\n\t\tconst configFilePath = this.joinPathFromRoot(\"slicemachine.config.json\");\n\n\t\tlet rawConfig: unknown | undefined;\n\t\ttry {\n\t\t\tconst contents = await fs.readFile(configFilePath, \"utf8\");\n\t\t\trawConfig = JSON.parse(contents);\n\t\t} catch {\n\t\t\t// noop\n\t\t}\n\n\t\tif (!rawConfig) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(\"No config found.\");\n\t\t}\n\n\t\tconst { value: sliceMachineConfig, error } =\n\t\t\tdecodeSliceMachineConfig(rawConfig);\n\n\t\tif (error) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(`Invalid config. ${error.errors.join(\", \")}`);\n\t\t}\n\n\t\treturn {\n\t\t\t...this._project,\n\t\t\tconfig: sliceMachineConfig,\n\t\t};\n\t};\n\n\tupdateSliceMachineConfig = async (\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t\toptions?: UpdateSliceMachineConfigOptions,\n\t): Promise<void> => {\n\t\tconst { value: decodedSliceMachineConfig, error } =\n\t\t\tdecodeSliceMachineConfig(sliceMachineConfig);\n\n\t\tif (error) {\n\t\t\t// TODO: Write a more friendly and useful message.\n\t\t\tthrow new Error(`Invalid config provided. ${error.errors.join(\", \")}`);\n\t\t}\n\n\t\tconst configFilePath = this.joinPathFromRoot(\"slicemachine.config.json\");\n\t\tlet content = JSON.stringify(decodedSliceMachineConfig, null, 2);\n\n\t\tif (options?.format) {\n\t\t\tcontent = await this.format(content, configFilePath);\n\t\t}\n\n\t\tawait fs.writeFile(configFilePath, content);\n\t};\n\n\tformat = async (\n\t\tsource: string,\n\t\tfilePath?: string,\n\t\toptions?: FormatOptions,\n\t): Promise<string> => {\n\t\tlet formatted = stripIndent(source);\n\n\t\tconst prettierOptions = await prettier.resolveConfig(\n\t\t\tfilePath || this._project.root,\n\t\t);\n\n\t\tformatted = await prettier.format(formatted, {\n\t\t\t...prettierOptions,\n\t\t\tfilepath: filePath,\n\t\t\t...(options?.prettier ?? {}),\n\t\t});\n\n\t\tif (options?.includeNewlineAtEnd === false) {\n\t\t\tformatted = formatted.replace(/[\\r\\n]+$/, \"\");\n\t\t}\n\n\t\treturn formatted;\n\t};\n\n\tjoinPathFromRoot = (...paths: string[]): string => {\n\t\treturn path.join(this._project.root, ...paths);\n\t};\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA6Ba,MAAA,4BAA4B,CACxC,YACwB;AACjB,SAAA,IAAI,oBAAoB,OAAO;AACvC;MAKa,oBAAmB;AAAA,EAQ/B,YAAY,SAA4B;AAFhC;AAAA;AAAA;AAAA;AAAA;AAAA;AAMR,sCAAa,YAAyC;AAC/C,YAAA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A,IAAA;AAGR,4CAAmB,IAAI,UAA2B;AACjD,aAAO,KAAK,KAAK,KAAK,SAAS,MAAM,GAAG,KAAK;AAAA,IAAA;AAhF7C,SAAK,WAAW;AAAA,EACjB;AAiFA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createSliceMachinePluginRunner.cjs","sources":["../../src/createSliceMachinePluginRunner.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport _module, { createRequire } from \"node:module\";\n\nimport { defu } from \"defu\";\n\nimport { HookSystem } from \"./lib/HookSystem\";\nimport { createSliceMachineContext } from \"./createSliceMachineContext\";\nimport {\n\tLoadedSliceMachinePlugin,\n\tSliceMachinePlugin,\n} from \"./defineSliceMachinePlugin\";\nimport {\n\tSliceMachineConfigPluginRegistration,\n\tSliceMachineHookExtraArgs,\n\tSliceMachineHookTypes,\n\tSliceMachineHooks,\n\tSliceMachineProject,\n} from \"./types\";\nimport { createSliceMachineHookSystem } from \"./createSliceMachineHookSystem\";\nimport {\n\tcreateSliceMachineActions,\n\tSliceMachineActions,\n} from \"./createSliceMachineActions\";\nimport {\n\tcreateSliceMachineHelpers,\n\tSliceMachineHelpers,\n} from \"./createSliceMachineHelpers\";\n\n/**\n * @internal\n */\nexport const REQUIRED_ADAPTER_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:create\",\n\t\"slice:read\",\n\t\"slice:rename\",\n\t\"slice:delete\",\n\t\"slice:update\",\n\t\"slice:asset:update\",\n\t\"slice:asset:read\",\n\t\"slice:asset:delete\",\n\t\"slice-library:read\",\n\t\"custom-type:create\",\n\t\"custom-type:read\",\n\t\"custom-type:rename\",\n\t\"custom-type:delete\",\n\t\"custom-type:update\",\n\t\"custom-type:asset:update\",\n\t\"custom-type:asset:read\",\n\t\"custom-type:asset:delete\",\n\t\"custom-type-library:read\",\n];\n/**\n * @internal\n */\nexport const ADAPTER_ONLY_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:read\",\n\t\"slice:asset:read\",\n\t\"slice-library:read\",\n\t\"custom-type:read\",\n\t\"custom-type:asset:read\",\n\t\"custom-type-library:read\",\n\t\"project:environment:read\",\n];\n\ntype SliceMachinePluginRunnerConstructorArgs = {\n\tproject: SliceMachineProject;\n\thookSystem: HookSystem<SliceMachineHooks>;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport class SliceMachinePluginRunner {\n\tprivate _project: SliceMachineProject;\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\tprivate _nativePlugins: Record<string, SliceMachinePlugin>;\n\n\t/**\n\t * Slice Machine actions provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawActions`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawActions: SliceMachineActions;\n\n\t/**\n\t * Slice Machine helpers provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawHelpers: SliceMachineHelpers;\n\n\t// Methods forwarded to the plugin runner's hook system.\n\tcallHook: HookSystem<SliceMachineHooks>[\"callHook\"];\n\thooksForOwner: HookSystem<SliceMachineHooks>[\"hooksForOwner\"];\n\thooksForType: HookSystem<SliceMachineHooks>[\"hooksForType\"];\n\tcreateScope: HookSystem<SliceMachineHooks>[\"createScope\"];\n\n\tconstructor({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins = {},\n\t}: SliceMachinePluginRunnerConstructorArgs) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t\tthis._nativePlugins = nativePlugins;\n\n\t\tthis.rawActions = createSliceMachineActions(\n\t\t\tthis._project,\n\t\t\tthis._hookSystem,\n\t\t);\n\t\tthis.rawHelpers = createSliceMachineHelpers(this._project);\n\n\t\tthis.callHook = this._hookSystem.callHook.bind(this._hookSystem);\n\t\tthis.hooksForOwner = this._hookSystem.hooksForOwner.bind(this._hookSystem);\n\t\tthis.hooksForType = this._hookSystem.hooksForType.bind(this._hookSystem);\n\t\tthis.createScope = this._hookSystem.createScope.bind(this._hookSystem);\n\t}\n\n\tprivate async _loadPlugin(\n\t\tpluginRegistration: SliceMachineConfigPluginRegistration,\n\t): Promise<LoadedSliceMachinePlugin> {\n\t\t// Sanitize registration\n\t\tconst { resolve, options = {} } =\n\t\t\ttypeof pluginRegistration === \"object\" && \"resolve\" in pluginRegistration\n\t\t\t\t? pluginRegistration\n\t\t\t\t: { resolve: pluginRegistration };\n\n\t\tlet plugin: SliceMachinePlugin | undefined = undefined;\n\n\t\tif (typeof resolve === \"string\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\ttry {\n\t\t\t\tconst noop = path.resolve(this._project.root, \"noop.js\");\n\n\t\t\t\tlet resolvedID = resolve;\n\n\t\t\t\t// Support Yarn PnP\n\t\t\t\tif (\n\t\t\t\t\tprocess.versions.pnp &&\n\t\t\t\t\t\"findPnpApi\" in _module &&\n\t\t\t\t\ttypeof _module.findPnpApi === \"function\"\n\t\t\t\t) {\n\t\t\t\t\tconst pnpApi = _module.findPnpApi(noop);\n\t\t\t\t\tif (pnpApi) {\n\t\t\t\t\t\tresolvedID = pnpApi.resolveRequest(resolve, noop);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst raw = await createRequire(noop)(resolvedID);\n\t\t\t\tplugin = raw.default || raw;\n\t\t\t} catch (error) {\n\t\t\t\t// Only log in development, but not during tests when a native plugin matches.\n\t\t\t\tif (\n\t\t\t\t\timport.meta.env.DEV &&\n\t\t\t\t\t!(import.meta.env.TEST && resolve in this._nativePlugins)\n\t\t\t\t) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\t// If an installed plugin cannot be resolved, try loading a native plugin.\n\t\t\t\tplugin = this._nativePlugins[resolve];\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not resolve plugin \\`${resolve}\\`. Check that it has been installed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin = resolve;\n\t\t}\n\n\t\tif (!plugin) {\n\t\t\tthrow new Error(`Could not load plugin: \\`${resolve}\\``);\n\t\t}\n\n\t\tconst mergedOptions = defu(options, plugin.defaultOptions || {});\n\n\t\treturn {\n\t\t\t...plugin,\n\t\t\tresolve,\n\t\t\toptions: mergedOptions,\n\t\t};\n\t}\n\n\tprivate async _setupPlugin(\n\t\tplugin: LoadedSliceMachinePlugin,\n\t\tas: \"adapter\" | \"plugin\",\n\t): Promise<void> {\n\t\tconst context = createSliceMachineContext({\n\t\t\tactions: this.rawActions,\n\t\t\thelpers: this.rawHelpers,\n\t\t\tproject: this._project,\n\t\t\tplugin,\n\t\t});\n\t\tconst hookSystemScope =\n\t\t\tthis._hookSystem.createScope<SliceMachineHookExtraArgs>(\n\t\t\t\tplugin.meta.name,\n\t\t\t\t[context],\n\t\t\t);\n\n\t\t// Prevent plugins from hooking to adapter only hooks\n\t\tconst hook: typeof hookSystemScope.hook =\n\t\t\tas === \"adapter\"\n\t\t\t\t? hookSystemScope.hook\n\t\t\t\t: (type, hook, ...args) => {\n\t\t\t\t\t\tif (ADAPTER_ONLY_HOOKS.includes(type)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn hookSystemScope.hook(type, hook, ...args);\n\t\t\t\t };\n\n\t\t// Run plugin setup with actions and context\n\t\ttry {\n\t\t\tawait plugin.setup({\n\t\t\t\t...context,\n\t\t\t\thook,\n\t\t\t\tunhook: hookSystemScope.unhook,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error.message}`,\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _validateAdapter(adapter: LoadedSliceMachinePlugin): void {\n\t\tconst hooks = this._hookSystem.hooksForOwner(adapter.meta.name);\n\t\tconst hookTypes = hooks.map((hook) => hook.meta.type);\n\n\t\tconst missingHooks = REQUIRED_ADAPTER_HOOKS.filter(\n\t\t\t(requiredHookType) => !hookTypes.includes(requiredHookType),\n\t\t);\n\n\t\tif (missingHooks.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Adapter \\`${\n\t\t\t\t\tadapter.meta.name\n\t\t\t\t}\\` is missing hooks: \\`${missingHooks.join(\"`, `\")}\\``,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync init(): Promise<void> {\n\t\tconst [adapter, ...plugins] = await Promise.all(\n\t\t\t[\n\t\t\t\tthis._project.config.adapter,\n\t\t\t\t...(this._project.config.plugins ?? []),\n\t\t\t].map((pluginRegistration) => this._loadPlugin(pluginRegistration)),\n\t\t);\n\n\t\tawait Promise.all([\n\t\t\tthis._setupPlugin(adapter, \"adapter\"),\n\t\t\t...plugins.map((plugin) => this._setupPlugin(plugin, \"plugin\")),\n\t\t]);\n\n\t\tthis._validateAdapter(adapter);\n\t}\n}\n\ntype CreateSliceMachinePluginRunnerArgs = {\n\tproject: SliceMachineProject;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport const createSliceMachinePluginRunner = ({\n\tproject,\n\tnativePlugins,\n}: CreateSliceMachinePluginRunnerArgs): SliceMachinePluginRunner => {\n\tconst hookSystem = createSliceMachineHookSystem();\n\n\treturn new SliceMachinePluginRunner({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins,\n\t});\n};\n"],"names":["createSliceMachineActions","createSliceMachineHelpers","path","createRequire","defu","createSliceMachineContext","hook","createSliceMachineHookSystem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,cAAA,IAAI,MACT,YAAY,OAAO,KAAK,gCAAgC,MAAM,WAC9D,EAAE,OAAO,MAAO,CAAA;AAAA,MAAA,OAEX;AACN,cAAM,IAAI,MACT,YAAY,OAAO,KAAK,gCAAgC,OAAO;AAAA,MAEjE;AAAA,IACD;AAAA,EACD;AAAA,EAEQ,iBAAiB,SAAiC;AACzD,UAAM,QAAQ,KAAK,YAAY,cAAc,QAAQ,KAAK,IAAI;AAC9D,UAAM,YAAY,MAAM,IAAI,CAAC,SAAS,KAAK,KAAK,IAAI;AAE9C,UAAA,eAAe,uBAAuB,OAC3C,CAAC,qBAAqB,CAAC,UAAU,SAAS,gBAAgB,CAAC;AAG5D,QAAI,aAAa,QAAQ;AAClB,YAAA,IAAI,MACT,aACC,QAAQ,KAAK,8BACY,aAAa,KAAK,MAAM,KAAK;AAAA,IAEzD;AAAA,EACD;AAAA,EAEA,MAAM,OAAI;AACT,UAAM,CAAC,SAAS,GAAG,OAAO,IAAI,MAAM,QAAQ,IAC3C;AAAA,MACC,KAAK,SAAS,OAAO;AAAA,MACrB,GAAI,KAAK,SAAS,OAAO,WAAW,CAAA;AAAA,IAAA,EACnC,IAAI,CAAC,uBAAuB,KAAK,YAAY,kBAAkB,CAAC,CAAC;AAGpE,UAAM,QAAQ,IAAI;AAAA,MACjB,KAAK,aAAa,SAAS,SAAS;AAAA,MACpC,GAAG,QAAQ,IAAI,CAAC,WAAW,KAAK,aAAa,QAAQ,QAAQ,CAAC;AAAA,IAAA,CAC9D;AAED,SAAK,iBAAiB,OAAO;AAAA,EAC9B;AACA;AAUM,MAAM,iCAAiC,CAAC,EAC9C,SACA,oBACkE;AAClE,QAAM,aAAaC,6BAAAA;AAEnB,SAAO,IAAI,yBAAyB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;;;;;"}
1
+ {"version":3,"file":"createSliceMachinePluginRunner.cjs","sources":["../../src/createSliceMachinePluginRunner.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport _module, { createRequire } from \"node:module\";\n\nimport { defu } from \"defu\";\n\nimport { HookSystem } from \"./lib/HookSystem\";\nimport { createSliceMachineContext } from \"./createSliceMachineContext\";\nimport {\n\tLoadedSliceMachinePlugin,\n\tSliceMachinePlugin,\n} from \"./defineSliceMachinePlugin\";\nimport {\n\tSliceMachineConfigPluginRegistration,\n\tSliceMachineHookExtraArgs,\n\tSliceMachineHookTypes,\n\tSliceMachineHooks,\n\tSliceMachineProject,\n} from \"./types\";\nimport { createSliceMachineHookSystem } from \"./createSliceMachineHookSystem\";\nimport {\n\tcreateSliceMachineActions,\n\tSliceMachineActions,\n} from \"./createSliceMachineActions\";\nimport {\n\tcreateSliceMachineHelpers,\n\tSliceMachineHelpers,\n} from \"./createSliceMachineHelpers\";\n\n/**\n * @internal\n */\nexport const REQUIRED_ADAPTER_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:create\",\n\t\"slice:read\",\n\t\"slice:rename\",\n\t\"slice:delete\",\n\t\"slice:update\",\n\t\"slice:asset:update\",\n\t\"slice:asset:read\",\n\t\"slice:asset:delete\",\n\t\"slice-library:read\",\n\t\"custom-type:create\",\n\t\"custom-type:read\",\n\t\"custom-type:rename\",\n\t\"custom-type:delete\",\n\t\"custom-type:update\",\n\t\"custom-type:asset:update\",\n\t\"custom-type:asset:read\",\n\t\"custom-type:asset:delete\",\n\t\"custom-type-library:read\",\n];\n/**\n * @internal\n */\nexport const ADAPTER_ONLY_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:read\",\n\t\"slice:asset:read\",\n\t\"slice-library:read\",\n\t\"custom-type:read\",\n\t\"custom-type:asset:read\",\n\t\"custom-type-library:read\",\n\t\"project:environment:read\",\n];\n\ntype SliceMachinePluginRunnerConstructorArgs = {\n\tproject: SliceMachineProject;\n\thookSystem: HookSystem<SliceMachineHooks>;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport class SliceMachinePluginRunner {\n\tprivate _project: SliceMachineProject;\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\tprivate _nativePlugins: Record<string, SliceMachinePlugin>;\n\n\t/**\n\t * Slice Machine actions provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawActions`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawActions: SliceMachineActions;\n\n\t/**\n\t * Slice Machine helpers provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawHelpers: SliceMachineHelpers;\n\n\t// Methods forwarded to the plugin runner's hook system.\n\tcallHook: HookSystem<SliceMachineHooks>[\"callHook\"];\n\thooksForOwner: HookSystem<SliceMachineHooks>[\"hooksForOwner\"];\n\thooksForType: HookSystem<SliceMachineHooks>[\"hooksForType\"];\n\tcreateScope: HookSystem<SliceMachineHooks>[\"createScope\"];\n\n\tconstructor({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins = {},\n\t}: SliceMachinePluginRunnerConstructorArgs) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t\tthis._nativePlugins = nativePlugins;\n\n\t\tthis.rawActions = createSliceMachineActions(\n\t\t\tthis._project,\n\t\t\tthis._hookSystem,\n\t\t);\n\t\tthis.rawHelpers = createSliceMachineHelpers(this._project);\n\n\t\tthis.callHook = this._hookSystem.callHook.bind(this._hookSystem);\n\t\tthis.hooksForOwner = this._hookSystem.hooksForOwner.bind(this._hookSystem);\n\t\tthis.hooksForType = this._hookSystem.hooksForType.bind(this._hookSystem);\n\t\tthis.createScope = this._hookSystem.createScope.bind(this._hookSystem);\n\t}\n\n\tprivate async _loadPlugin(\n\t\tpluginRegistration: SliceMachineConfigPluginRegistration,\n\t): Promise<LoadedSliceMachinePlugin> {\n\t\t// Sanitize registration\n\t\tconst { resolve, options = {} } =\n\t\t\ttypeof pluginRegistration === \"object\" && \"resolve\" in pluginRegistration\n\t\t\t\t? pluginRegistration\n\t\t\t\t: { resolve: pluginRegistration };\n\n\t\tlet plugin: SliceMachinePlugin | undefined = undefined;\n\n\t\tif (typeof resolve === \"string\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\ttry {\n\t\t\t\tconst noop = path.resolve(this._project.root, \"noop.js\");\n\n\t\t\t\tlet resolvedID = resolve;\n\n\t\t\t\t// Support Yarn PnP\n\t\t\t\tif (\n\t\t\t\t\tprocess.versions.pnp &&\n\t\t\t\t\t\"findPnpApi\" in _module &&\n\t\t\t\t\ttypeof _module.findPnpApi === \"function\"\n\t\t\t\t) {\n\t\t\t\t\tconst pnpApi = _module.findPnpApi(noop);\n\t\t\t\t\tif (pnpApi) {\n\t\t\t\t\t\tresolvedID = pnpApi.resolveRequest(resolve, noop);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst raw = await createRequire(noop)(resolvedID);\n\t\t\t\tplugin = raw.default || raw;\n\t\t\t} catch (error) {\n\t\t\t\t// Only log in development, but not during tests when a native plugin matches.\n\t\t\t\tif (\n\t\t\t\t\timport.meta.env.DEV &&\n\t\t\t\t\t!(import.meta.env.TEST && resolve in this._nativePlugins)\n\t\t\t\t) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\t// If an installed plugin cannot be resolved, try loading a native plugin.\n\t\t\t\tplugin = this._nativePlugins[resolve];\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not resolve plugin \\`${resolve}\\`. Check that it has been installed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin = resolve;\n\t\t}\n\n\t\tif (!plugin) {\n\t\t\tthrow new Error(`Could not load plugin: \\`${resolve}\\``);\n\t\t}\n\n\t\tconst mergedOptions = defu(options, plugin.defaultOptions || {});\n\n\t\treturn {\n\t\t\t...plugin,\n\t\t\tresolve,\n\t\t\toptions: mergedOptions,\n\t\t};\n\t}\n\n\tprivate async _setupPlugin(\n\t\tplugin: LoadedSliceMachinePlugin,\n\t\tas: \"adapter\" | \"plugin\",\n\t): Promise<void> {\n\t\tconst context = createSliceMachineContext({\n\t\t\tactions: this.rawActions,\n\t\t\thelpers: this.rawHelpers,\n\t\t\tproject: this._project,\n\t\t\tplugin,\n\t\t});\n\t\tconst hookSystemScope =\n\t\t\tthis._hookSystem.createScope<SliceMachineHookExtraArgs>(\n\t\t\t\tplugin.meta.name,\n\t\t\t\t[context],\n\t\t\t);\n\n\t\t// Prevent plugins from hooking to adapter only hooks\n\t\tconst hook: typeof hookSystemScope.hook =\n\t\t\tas === \"adapter\"\n\t\t\t\t? hookSystemScope.hook\n\t\t\t\t: (type, hook, ...args) => {\n\t\t\t\t\t\tif (ADAPTER_ONLY_HOOKS.includes(type)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn hookSystemScope.hook(type, hook, ...args);\n\t\t\t\t };\n\n\t\t// Run plugin setup with actions and context\n\t\ttry {\n\t\t\tawait plugin.setup({\n\t\t\t\t...context,\n\t\t\t\thook,\n\t\t\t\tunhook: hookSystemScope.unhook,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error.message}`,\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _validateAdapter(adapter: LoadedSliceMachinePlugin): void {\n\t\tconst hooks = this._hookSystem.hooksForOwner(adapter.meta.name);\n\t\tconst hookTypes = hooks.map((hook) => hook.meta.type);\n\n\t\tconst missingHooks = REQUIRED_ADAPTER_HOOKS.filter(\n\t\t\t(requiredHookType) => !hookTypes.includes(requiredHookType),\n\t\t);\n\n\t\tif (missingHooks.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Adapter \\`${\n\t\t\t\t\tadapter.meta.name\n\t\t\t\t}\\` is missing hooks: \\`${missingHooks.join(\"`, `\")}\\``,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync init(): Promise<void> {\n\t\tconst [adapter, ...plugins] = await Promise.all(\n\t\t\t[\n\t\t\t\tthis._project.config.adapter,\n\t\t\t\t...(this._project.config.plugins ?? []),\n\t\t\t].map((pluginRegistration) => this._loadPlugin(pluginRegistration)),\n\t\t);\n\n\t\tawait Promise.all([\n\t\t\tthis._setupPlugin(adapter, \"adapter\"),\n\t\t\t...plugins.map((plugin) => this._setupPlugin(plugin, \"plugin\")),\n\t\t]);\n\n\t\tthis._validateAdapter(adapter);\n\t}\n}\n\ntype CreateSliceMachinePluginRunnerArgs = {\n\tproject: SliceMachineProject;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport const createSliceMachinePluginRunner = ({\n\tproject,\n\tnativePlugins,\n}: CreateSliceMachinePluginRunnerArgs): SliceMachinePluginRunner => {\n\tconst hookSystem = createSliceMachineHookSystem();\n\n\treturn new SliceMachinePluginRunner({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins,\n\t});\n};\n"],"names":["createSliceMachineActions","createSliceMachineHelpers","path","createRequire","defu","createSliceMachineContext","hook","createSliceMachineHookSystem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,MAAM,yBAAkD;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;AAKM,MAAM,qBAA8C;AAAA,EAC1D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EAEQ,iBAAiB,SAAiC;AACzD,UAAM,QAAQ,KAAK,YAAY,cAAc,QAAQ,KAAK,IAAI;AAC9D,UAAM,YAAY,MAAM,IAAI,CAAC,SAAS,KAAK,KAAK,IAAI;AAE9C,UAAA,eAAe,uBAAuB,OAC3C,CAAC,qBAAqB,CAAC,UAAU,SAAS,gBAAgB,CAAC;AAG5D,QAAI,aAAa,QAAQ;AAClB,YAAA,IAAI,MACT,aACC,QAAQ,KAAK,IACd,0BAA0B,aAAa,KAAK,MAAM,CAAC,IAAI;AAAA,IAEzD;AAAA,EACD;AAAA,EAEA,MAAM,OAAI;AACT,UAAM,CAAC,SAAS,GAAG,OAAO,IAAI,MAAM,QAAQ,IAC3C;AAAA,MACC,KAAK,SAAS,OAAO;AAAA,MACrB,GAAI,KAAK,SAAS,OAAO,WAAW,CAAA;AAAA,IAAA,EACnC,IAAI,CAAC,uBAAuB,KAAK,YAAY,kBAAkB,CAAC,CAAC;AAGpE,UAAM,QAAQ,IAAI;AAAA,MACjB,KAAK,aAAa,SAAS,SAAS;AAAA,MACpC,GAAG,QAAQ,IAAI,CAAC,WAAW,KAAK,aAAa,QAAQ,QAAQ,CAAC;AAAA,IAAA,CAC9D;AAED,SAAK,iBAAiB,OAAO;AAAA,EAC9B;AACA;AAUM,MAAM,iCAAiC,CAAC,EAC9C,SACA,oBACkE;AAClE,QAAM,aAAaC,6BAAAA;AAEnB,SAAO,IAAI,yBAAyB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createSliceMachinePluginRunner.js","sources":["../../src/createSliceMachinePluginRunner.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport _module, { createRequire } from \"node:module\";\n\nimport { defu } from \"defu\";\n\nimport { HookSystem } from \"./lib/HookSystem\";\nimport { createSliceMachineContext } from \"./createSliceMachineContext\";\nimport {\n\tLoadedSliceMachinePlugin,\n\tSliceMachinePlugin,\n} from \"./defineSliceMachinePlugin\";\nimport {\n\tSliceMachineConfigPluginRegistration,\n\tSliceMachineHookExtraArgs,\n\tSliceMachineHookTypes,\n\tSliceMachineHooks,\n\tSliceMachineProject,\n} from \"./types\";\nimport { createSliceMachineHookSystem } from \"./createSliceMachineHookSystem\";\nimport {\n\tcreateSliceMachineActions,\n\tSliceMachineActions,\n} from \"./createSliceMachineActions\";\nimport {\n\tcreateSliceMachineHelpers,\n\tSliceMachineHelpers,\n} from \"./createSliceMachineHelpers\";\n\n/**\n * @internal\n */\nexport const REQUIRED_ADAPTER_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:create\",\n\t\"slice:read\",\n\t\"slice:rename\",\n\t\"slice:delete\",\n\t\"slice:update\",\n\t\"slice:asset:update\",\n\t\"slice:asset:read\",\n\t\"slice:asset:delete\",\n\t\"slice-library:read\",\n\t\"custom-type:create\",\n\t\"custom-type:read\",\n\t\"custom-type:rename\",\n\t\"custom-type:delete\",\n\t\"custom-type:update\",\n\t\"custom-type:asset:update\",\n\t\"custom-type:asset:read\",\n\t\"custom-type:asset:delete\",\n\t\"custom-type-library:read\",\n];\n/**\n * @internal\n */\nexport const ADAPTER_ONLY_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:read\",\n\t\"slice:asset:read\",\n\t\"slice-library:read\",\n\t\"custom-type:read\",\n\t\"custom-type:asset:read\",\n\t\"custom-type-library:read\",\n\t\"project:environment:read\",\n];\n\ntype SliceMachinePluginRunnerConstructorArgs = {\n\tproject: SliceMachineProject;\n\thookSystem: HookSystem<SliceMachineHooks>;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport class SliceMachinePluginRunner {\n\tprivate _project: SliceMachineProject;\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\tprivate _nativePlugins: Record<string, SliceMachinePlugin>;\n\n\t/**\n\t * Slice Machine actions provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawActions`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawActions: SliceMachineActions;\n\n\t/**\n\t * Slice Machine helpers provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawHelpers: SliceMachineHelpers;\n\n\t// Methods forwarded to the plugin runner's hook system.\n\tcallHook: HookSystem<SliceMachineHooks>[\"callHook\"];\n\thooksForOwner: HookSystem<SliceMachineHooks>[\"hooksForOwner\"];\n\thooksForType: HookSystem<SliceMachineHooks>[\"hooksForType\"];\n\tcreateScope: HookSystem<SliceMachineHooks>[\"createScope\"];\n\n\tconstructor({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins = {},\n\t}: SliceMachinePluginRunnerConstructorArgs) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t\tthis._nativePlugins = nativePlugins;\n\n\t\tthis.rawActions = createSliceMachineActions(\n\t\t\tthis._project,\n\t\t\tthis._hookSystem,\n\t\t);\n\t\tthis.rawHelpers = createSliceMachineHelpers(this._project);\n\n\t\tthis.callHook = this._hookSystem.callHook.bind(this._hookSystem);\n\t\tthis.hooksForOwner = this._hookSystem.hooksForOwner.bind(this._hookSystem);\n\t\tthis.hooksForType = this._hookSystem.hooksForType.bind(this._hookSystem);\n\t\tthis.createScope = this._hookSystem.createScope.bind(this._hookSystem);\n\t}\n\n\tprivate async _loadPlugin(\n\t\tpluginRegistration: SliceMachineConfigPluginRegistration,\n\t): Promise<LoadedSliceMachinePlugin> {\n\t\t// Sanitize registration\n\t\tconst { resolve, options = {} } =\n\t\t\ttypeof pluginRegistration === \"object\" && \"resolve\" in pluginRegistration\n\t\t\t\t? pluginRegistration\n\t\t\t\t: { resolve: pluginRegistration };\n\n\t\tlet plugin: SliceMachinePlugin | undefined = undefined;\n\n\t\tif (typeof resolve === \"string\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\ttry {\n\t\t\t\tconst noop = path.resolve(this._project.root, \"noop.js\");\n\n\t\t\t\tlet resolvedID = resolve;\n\n\t\t\t\t// Support Yarn PnP\n\t\t\t\tif (\n\t\t\t\t\tprocess.versions.pnp &&\n\t\t\t\t\t\"findPnpApi\" in _module &&\n\t\t\t\t\ttypeof _module.findPnpApi === \"function\"\n\t\t\t\t) {\n\t\t\t\t\tconst pnpApi = _module.findPnpApi(noop);\n\t\t\t\t\tif (pnpApi) {\n\t\t\t\t\t\tresolvedID = pnpApi.resolveRequest(resolve, noop);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst raw = await createRequire(noop)(resolvedID);\n\t\t\t\tplugin = raw.default || raw;\n\t\t\t} catch (error) {\n\t\t\t\t// Only log in development, but not during tests when a native plugin matches.\n\t\t\t\tif (\n\t\t\t\t\timport.meta.env.DEV &&\n\t\t\t\t\t!(import.meta.env.TEST && resolve in this._nativePlugins)\n\t\t\t\t) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\t// If an installed plugin cannot be resolved, try loading a native plugin.\n\t\t\t\tplugin = this._nativePlugins[resolve];\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not resolve plugin \\`${resolve}\\`. Check that it has been installed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin = resolve;\n\t\t}\n\n\t\tif (!plugin) {\n\t\t\tthrow new Error(`Could not load plugin: \\`${resolve}\\``);\n\t\t}\n\n\t\tconst mergedOptions = defu(options, plugin.defaultOptions || {});\n\n\t\treturn {\n\t\t\t...plugin,\n\t\t\tresolve,\n\t\t\toptions: mergedOptions,\n\t\t};\n\t}\n\n\tprivate async _setupPlugin(\n\t\tplugin: LoadedSliceMachinePlugin,\n\t\tas: \"adapter\" | \"plugin\",\n\t): Promise<void> {\n\t\tconst context = createSliceMachineContext({\n\t\t\tactions: this.rawActions,\n\t\t\thelpers: this.rawHelpers,\n\t\t\tproject: this._project,\n\t\t\tplugin,\n\t\t});\n\t\tconst hookSystemScope =\n\t\t\tthis._hookSystem.createScope<SliceMachineHookExtraArgs>(\n\t\t\t\tplugin.meta.name,\n\t\t\t\t[context],\n\t\t\t);\n\n\t\t// Prevent plugins from hooking to adapter only hooks\n\t\tconst hook: typeof hookSystemScope.hook =\n\t\t\tas === \"adapter\"\n\t\t\t\t? hookSystemScope.hook\n\t\t\t\t: (type, hook, ...args) => {\n\t\t\t\t\t\tif (ADAPTER_ONLY_HOOKS.includes(type)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn hookSystemScope.hook(type, hook, ...args);\n\t\t\t\t };\n\n\t\t// Run plugin setup with actions and context\n\t\ttry {\n\t\t\tawait plugin.setup({\n\t\t\t\t...context,\n\t\t\t\thook,\n\t\t\t\tunhook: hookSystemScope.unhook,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error.message}`,\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _validateAdapter(adapter: LoadedSliceMachinePlugin): void {\n\t\tconst hooks = this._hookSystem.hooksForOwner(adapter.meta.name);\n\t\tconst hookTypes = hooks.map((hook) => hook.meta.type);\n\n\t\tconst missingHooks = REQUIRED_ADAPTER_HOOKS.filter(\n\t\t\t(requiredHookType) => !hookTypes.includes(requiredHookType),\n\t\t);\n\n\t\tif (missingHooks.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Adapter \\`${\n\t\t\t\t\tadapter.meta.name\n\t\t\t\t}\\` is missing hooks: \\`${missingHooks.join(\"`, `\")}\\``,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync init(): Promise<void> {\n\t\tconst [adapter, ...plugins] = await Promise.all(\n\t\t\t[\n\t\t\t\tthis._project.config.adapter,\n\t\t\t\t...(this._project.config.plugins ?? []),\n\t\t\t].map((pluginRegistration) => this._loadPlugin(pluginRegistration)),\n\t\t);\n\n\t\tawait Promise.all([\n\t\t\tthis._setupPlugin(adapter, \"adapter\"),\n\t\t\t...plugins.map((plugin) => this._setupPlugin(plugin, \"plugin\")),\n\t\t]);\n\n\t\tthis._validateAdapter(adapter);\n\t}\n}\n\ntype CreateSliceMachinePluginRunnerArgs = {\n\tproject: SliceMachineProject;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport const createSliceMachinePluginRunner = ({\n\tproject,\n\tnativePlugins,\n}: CreateSliceMachinePluginRunnerArgs): SliceMachinePluginRunner => {\n\tconst hookSystem = createSliceMachineHookSystem();\n\n\treturn new SliceMachinePluginRunner({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins,\n\t});\n};\n"],"names":["hook"],"mappings":";;;;;;;;;;;;;AA+BO,MAAM,yBAAkD;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;AAKM,MAAM,qBAA8C;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;MAYY,yBAAwB;AAAA,EA+BpC,YAAY,EACX,SACA,YACA,gBAAgB,MACyB;AAlClC;AACA;AACA;AAUR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAG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AAM,OAAI;AACT,UAAM,CAAC,SAAS,GAAG,OAAO,IAAI,MAAM,QAAQ,IAC3C;AAAA,MACC,KAAK,SAAS,OAAO;AAAA,MACrB,GAAI,KAAK,SAAS,OAAO,WAAW,CAAA;AAAA,IAAA,EACnC,IAAI,CAAC,uBAAuB,KAAK,YAAY,kBAAkB,CAAC,CAAC;AAGpE,UAAM,QAAQ,IAAI;AAAA,MACjB,KAAK,aAAa,SAAS,SAAS;AAAA,MACpC,GAAG,QAAQ,IAAI,CAAC,WAAW,KAAK,aAAa,QAAQ,QAAQ,CAAC;AAAA,IAAA,CAC9D;AAED,SAAK,iBAAiB,OAAO;AAAA,EAC9B;AACA;AAUM,MAAM,iCAAiC,CAAC,EAC9C,SACA,oBACkE;AAClE,QAAM,aAAa;AAEnB,SAAO,IAAI,yBAAyB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;"}
1
+ {"version":3,"file":"createSliceMachinePluginRunner.js","sources":["../../src/createSliceMachinePluginRunner.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport _module, { createRequire } from \"node:module\";\n\nimport { defu } from \"defu\";\n\nimport { HookSystem } from \"./lib/HookSystem\";\nimport { createSliceMachineContext } from \"./createSliceMachineContext\";\nimport {\n\tLoadedSliceMachinePlugin,\n\tSliceMachinePlugin,\n} from \"./defineSliceMachinePlugin\";\nimport {\n\tSliceMachineConfigPluginRegistration,\n\tSliceMachineHookExtraArgs,\n\tSliceMachineHookTypes,\n\tSliceMachineHooks,\n\tSliceMachineProject,\n} from \"./types\";\nimport { createSliceMachineHookSystem } from \"./createSliceMachineHookSystem\";\nimport {\n\tcreateSliceMachineActions,\n\tSliceMachineActions,\n} from \"./createSliceMachineActions\";\nimport {\n\tcreateSliceMachineHelpers,\n\tSliceMachineHelpers,\n} from \"./createSliceMachineHelpers\";\n\n/**\n * @internal\n */\nexport const REQUIRED_ADAPTER_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:create\",\n\t\"slice:read\",\n\t\"slice:rename\",\n\t\"slice:delete\",\n\t\"slice:update\",\n\t\"slice:asset:update\",\n\t\"slice:asset:read\",\n\t\"slice:asset:delete\",\n\t\"slice-library:read\",\n\t\"custom-type:create\",\n\t\"custom-type:read\",\n\t\"custom-type:rename\",\n\t\"custom-type:delete\",\n\t\"custom-type:update\",\n\t\"custom-type:asset:update\",\n\t\"custom-type:asset:read\",\n\t\"custom-type:asset:delete\",\n\t\"custom-type-library:read\",\n];\n/**\n * @internal\n */\nexport const ADAPTER_ONLY_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:read\",\n\t\"slice:asset:read\",\n\t\"slice-library:read\",\n\t\"custom-type:read\",\n\t\"custom-type:asset:read\",\n\t\"custom-type-library:read\",\n\t\"project:environment:read\",\n];\n\ntype SliceMachinePluginRunnerConstructorArgs = {\n\tproject: SliceMachineProject;\n\thookSystem: HookSystem<SliceMachineHooks>;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport class SliceMachinePluginRunner {\n\tprivate _project: SliceMachineProject;\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\tprivate _nativePlugins: Record<string, SliceMachinePlugin>;\n\n\t/**\n\t * Slice Machine actions provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawActions`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawActions: SliceMachineActions;\n\n\t/**\n\t * Slice Machine helpers provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawHelpers: SliceMachineHelpers;\n\n\t// Methods forwarded to the plugin runner's hook system.\n\tcallHook: HookSystem<SliceMachineHooks>[\"callHook\"];\n\thooksForOwner: HookSystem<SliceMachineHooks>[\"hooksForOwner\"];\n\thooksForType: HookSystem<SliceMachineHooks>[\"hooksForType\"];\n\tcreateScope: HookSystem<SliceMachineHooks>[\"createScope\"];\n\n\tconstructor({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins = {},\n\t}: SliceMachinePluginRunnerConstructorArgs) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t\tthis._nativePlugins = nativePlugins;\n\n\t\tthis.rawActions = createSliceMachineActions(\n\t\t\tthis._project,\n\t\t\tthis._hookSystem,\n\t\t);\n\t\tthis.rawHelpers = createSliceMachineHelpers(this._project);\n\n\t\tthis.callHook = this._hookSystem.callHook.bind(this._hookSystem);\n\t\tthis.hooksForOwner = this._hookSystem.hooksForOwner.bind(this._hookSystem);\n\t\tthis.hooksForType = this._hookSystem.hooksForType.bind(this._hookSystem);\n\t\tthis.createScope = this._hookSystem.createScope.bind(this._hookSystem);\n\t}\n\n\tprivate async _loadPlugin(\n\t\tpluginRegistration: SliceMachineConfigPluginRegistration,\n\t): Promise<LoadedSliceMachinePlugin> {\n\t\t// Sanitize registration\n\t\tconst { resolve, options = {} } =\n\t\t\ttypeof pluginRegistration === \"object\" && \"resolve\" in pluginRegistration\n\t\t\t\t? pluginRegistration\n\t\t\t\t: { resolve: pluginRegistration };\n\n\t\tlet plugin: SliceMachinePlugin | undefined = undefined;\n\n\t\tif (typeof resolve === \"string\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\ttry {\n\t\t\t\tconst noop = path.resolve(this._project.root, \"noop.js\");\n\n\t\t\t\tlet resolvedID = resolve;\n\n\t\t\t\t// Support Yarn PnP\n\t\t\t\tif (\n\t\t\t\t\tprocess.versions.pnp &&\n\t\t\t\t\t\"findPnpApi\" in _module &&\n\t\t\t\t\ttypeof _module.findPnpApi === \"function\"\n\t\t\t\t) {\n\t\t\t\t\tconst pnpApi = _module.findPnpApi(noop);\n\t\t\t\t\tif (pnpApi) {\n\t\t\t\t\t\tresolvedID = pnpApi.resolveRequest(resolve, noop);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst raw = await createRequire(noop)(resolvedID);\n\t\t\t\tplugin = raw.default || raw;\n\t\t\t} catch (error) {\n\t\t\t\t// Only log in development, but not during tests when a native plugin matches.\n\t\t\t\tif (\n\t\t\t\t\timport.meta.env.DEV &&\n\t\t\t\t\t!(import.meta.env.TEST && resolve in this._nativePlugins)\n\t\t\t\t) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\t// If an installed plugin cannot be resolved, try loading a native plugin.\n\t\t\t\tplugin = this._nativePlugins[resolve];\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not resolve plugin \\`${resolve}\\`. Check that it has been installed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin = resolve;\n\t\t}\n\n\t\tif (!plugin) {\n\t\t\tthrow new Error(`Could not load plugin: \\`${resolve}\\``);\n\t\t}\n\n\t\tconst mergedOptions = defu(options, plugin.defaultOptions || {});\n\n\t\treturn {\n\t\t\t...plugin,\n\t\t\tresolve,\n\t\t\toptions: mergedOptions,\n\t\t};\n\t}\n\n\tprivate async _setupPlugin(\n\t\tplugin: LoadedSliceMachinePlugin,\n\t\tas: \"adapter\" | \"plugin\",\n\t): Promise<void> {\n\t\tconst context = createSliceMachineContext({\n\t\t\tactions: this.rawActions,\n\t\t\thelpers: this.rawHelpers,\n\t\t\tproject: this._project,\n\t\t\tplugin,\n\t\t});\n\t\tconst hookSystemScope =\n\t\t\tthis._hookSystem.createScope<SliceMachineHookExtraArgs>(\n\t\t\t\tplugin.meta.name,\n\t\t\t\t[context],\n\t\t\t);\n\n\t\t// Prevent plugins from hooking to adapter only hooks\n\t\tconst hook: typeof hookSystemScope.hook =\n\t\t\tas === \"adapter\"\n\t\t\t\t? hookSystemScope.hook\n\t\t\t\t: (type, hook, ...args) => {\n\t\t\t\t\t\tif (ADAPTER_ONLY_HOOKS.includes(type)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn hookSystemScope.hook(type, hook, ...args);\n\t\t\t\t };\n\n\t\t// Run plugin setup with actions and context\n\t\ttry {\n\t\t\tawait plugin.setup({\n\t\t\t\t...context,\n\t\t\t\thook,\n\t\t\t\tunhook: hookSystemScope.unhook,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error.message}`,\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _validateAdapter(adapter: LoadedSliceMachinePlugin): void {\n\t\tconst hooks = this._hookSystem.hooksForOwner(adapter.meta.name);\n\t\tconst hookTypes = hooks.map((hook) => hook.meta.type);\n\n\t\tconst missingHooks = REQUIRED_ADAPTER_HOOKS.filter(\n\t\t\t(requiredHookType) => !hookTypes.includes(requiredHookType),\n\t\t);\n\n\t\tif (missingHooks.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Adapter \\`${\n\t\t\t\t\tadapter.meta.name\n\t\t\t\t}\\` is missing hooks: \\`${missingHooks.join(\"`, `\")}\\``,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync init(): Promise<void> {\n\t\tconst [adapter, ...plugins] = await Promise.all(\n\t\t\t[\n\t\t\t\tthis._project.config.adapter,\n\t\t\t\t...(this._project.config.plugins ?? []),\n\t\t\t].map((pluginRegistration) => this._loadPlugin(pluginRegistration)),\n\t\t);\n\n\t\tawait Promise.all([\n\t\t\tthis._setupPlugin(adapter, \"adapter\"),\n\t\t\t...plugins.map((plugin) => this._setupPlugin(plugin, \"plugin\")),\n\t\t]);\n\n\t\tthis._validateAdapter(adapter);\n\t}\n}\n\ntype CreateSliceMachinePluginRunnerArgs = {\n\tproject: SliceMachineProject;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport const createSliceMachinePluginRunner = ({\n\tproject,\n\tnativePlugins,\n}: CreateSliceMachinePluginRunnerArgs): SliceMachinePluginRunner => {\n\tconst hookSystem = createSliceMachineHookSystem();\n\n\treturn new SliceMachinePluginRunner({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins,\n\t});\n};\n"],"names":["hook"],"mappings":";;;;;;;;;;;;;AA+BO,MAAM,yBAAkD;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;AAKM,MAAM,qBAA8C;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;MAYY,yBAAwB;AAAA,EA+BpC,YAAY,EACX,SACA,YACA,gBAAgB,MACyB;AAlClC;AACA;AACA;AAUR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA;AAAA;AACA;AACA;AACA;AAOC,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,iBAAiB;AAEtB,SAAK,aAAa,0BACjB,KAAK,UACL,KAAK,WAAW;AAEZ,SAAA,aAAa,0BAA0B,KAAK,QAAQ;AAEzD,SAAK,WAAW,KAAK,YAAY,SAAS,KAAK,KAAK,WAAW;AAC/D,SAAK,gBAAgB,KAAK,YAAY,cAAc,KAAK,KAAK,WAAW;AACzE,SAAK,eAAe,KAAK,YAAY,aAAa,KAAK,KAAK,WAAW;AACvE,SAAK,cAAc,KAAK,YAAY,YAAY,KAAK,KAAK,WAAW;AAAA,E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AAK,aAAa,QAAQ,QAAQ,CAAC;AAAA,IAAA,CAC9D;AAED,SAAK,iBAAiB,OAAO;AAAA,EAC9B;AACA;AAUM,MAAM,iCAAiC,CAAC,EAC9C,SACA,oBACkE;AAClE,QAAM,aAAa;AAEnB,SAAO,IAAI,yBAAyB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"checkPathExists.cjs","sources":["../../../../src/fs/lib/checkPathExists.ts"],"sourcesContent":["import { PathLike } from \"node:fs\";\n\nimport * as fs from \"./fsLimit\";\n\nexport async function checkPathExists(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.access"],"mappings":";;;AAIA,eAAsB,gBAAgB,MAAc;AAC/C,MAAA;AACG,UAAAA,QAAAA,OAAU,IAAI;AAEb,WAAA;AAAA,EAAA,QACN;AACM,WAAA;AAAA,EACR;AACD;;"}
1
+ {"version":3,"file":"checkPathExists.cjs","sources":["../../../../src/fs/lib/checkPathExists.ts"],"sourcesContent":["import { PathLike } from \"node:fs\";\n\nimport * as fs from \"./fsLimit\";\n\nexport async function checkPathExists(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.access"],"mappings":";;;AAIA,eAAsB,gBAAgB,MAAc;AAC/C,MAAA;AACG,UAAAA,QAAAA,OAAU,IAAI;AAEb,WAAA;AAAA,EAAA,QACA;AACA,WAAA;AAAA,EACR;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"checkPathExists.js","sources":["../../../../src/fs/lib/checkPathExists.ts"],"sourcesContent":["import { PathLike } from \"node:fs\";\n\nimport * as fs from \"./fsLimit\";\n\nexport async function checkPathExists(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.access"],"mappings":";AAIA,eAAsB,gBAAgB,MAAc;AAC/C,MAAA;AACG,UAAAA,OAAU,IAAI;AAEb,WAAA;AAAA,EAAA,QACN;AACM,WAAA;AAAA,EACR;AACD;"}
1
+ {"version":3,"file":"checkPathExists.js","sources":["../../../../src/fs/lib/checkPathExists.ts"],"sourcesContent":["import { PathLike } from \"node:fs\";\n\nimport * as fs from \"./fsLimit\";\n\nexport async function checkPathExists(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.access"],"mappings":";AAIA,eAAsB,gBAAgB,MAAc;AAC/C,MAAA;AACG,UAAAA,OAAU,IAAI;AAEb,WAAA;AAAA,EAAA,QACA;AACA,WAAA;AAAA,EACR;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"readCustomTypeLibrary.cjs","sources":["../../../src/fs/readCustomTypeLibrary.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isCustomTypeModel } from \"./lib/isCustomTypeModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { CUSTOM_TYPE_MODEL_FILENAME } from \"./constants\";\nimport {\n\tbuildCustomTypeLibraryDirectoryPath,\n\tBuildCustomTypeLibraryDirectoryPathArgs,\n} from \"./buildCustomTypeLibraryDirectoryPath\";\n\nexport type ReadCustomTypeLibraryArgs = BuildCustomTypeLibraryDirectoryPathArgs;\n\nexport type ReadCustomTypeLibraryReturnType = {\n\tids: string[];\n};\n\nexport const readCustomTypeLibrary = async (\n\targs: ReadCustomTypeLibraryArgs,\n): Promise<ReadCustomTypeLibraryReturnType> => {\n\tconst libraryDir = buildCustomTypeLibraryDirectoryPath({\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!(await checkPathExists(libraryDir))) {\n\t\treturn {\n\t\t\tids: [],\n\t\t};\n\t}\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t/**\n\t * Paths to models that could not be read due to invalid JSON.\n\t */\n\tconst unreadableModelPaths: string[] = [];\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(libraryDir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isCustomTypeDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === CUSTOM_TYPE_MODEL_FILENAME;\n\t\t\t\t});\n\n\t\t\t\tif (isCustomTypeDir) {\n\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\tCUSTOM_TYPE_MODEL_FILENAME,\n\t\t\t\t\t);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\t\t\t\tids.push(modelContents.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\tif (unreadableModelPaths.length > 0) {\n\t\tconst formattedPaths = unreadableModelPaths.join(\", \");\n\n\t\tthrow new Error(\n\t\t\t`The following custom type models could not be read: [${formattedPaths}]`,\n\t\t);\n\t}\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n"],"names":["buildCustomTypeLibraryDirectoryPath","checkPathExists","fs.readdir","path","CUSTOM_TYPE_MODEL_FILENAME","readJSONFile","isCustomTypeModel"],"mappings":";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ources":["../../../src/fs/readCustomTypeLibrary.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isCustomTypeModel } from \"./lib/isCustomTypeModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { CUSTOM_TYPE_MODEL_FILENAME } from \"./constants\";\nimport {\n\tbuildCustomTypeLibraryDirectoryPath,\n\tBuildCustomTypeLibraryDirectoryPathArgs,\n} from \"./buildCustomTypeLibraryDirectoryPath\";\n\nexport type ReadCustomTypeLibraryArgs = BuildCustomTypeLibraryDirectoryPathArgs;\n\nexport type ReadCustomTypeLibraryReturnType = {\n\tids: string[];\n};\n\nexport const readCustomTypeLibrary = async (\n\targs: ReadCustomTypeLibraryArgs,\n): Promise<ReadCustomTypeLibraryReturnType> => {\n\tconst libraryDir = buildCustomTypeLibraryDirectoryPath({\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!(await checkPathExists(libraryDir))) {\n\t\treturn {\n\t\t\tids: [],\n\t\t};\n\t}\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t/**\n\t * Paths to models that could not be read due to invalid JSON.\n\t */\n\tconst unreadableModelPaths: string[] = [];\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(libraryDir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isCustomTypeDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === CUSTOM_TYPE_MODEL_FILENAME;\n\t\t\t\t});\n\n\t\t\t\tif (isCustomTypeDir) {\n\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\tCUSTOM_TYPE_MODEL_FILENAME,\n\t\t\t\t\t);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\t\t\t\tids.push(modelContents.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\tif (unreadableModelPaths.length > 0) {\n\t\tconst formattedPaths = unreadableModelPaths.join(\", \");\n\n\t\tthrow new Error(\n\t\t\t`The following custom type models could not be read: [${formattedPaths}]`,\n\t\t);\n\t}\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n"],"names":["buildCustomTypeLibraryDirectoryPath","checkPathExists","fs.readdir","path","CUSTOM_TYPE_MODEL_FILENAME","readJSONFile","isCustomTypeModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmBa,MAAA,wBAAwB,OACpC,SAC6C;AAC7C,QAAM,aAAaA,oCAAAA,oCAAoC;AAAA,IACtD,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,CAAE,MAAMC,gCAAgB,UAAU,GAAI;AAClC,WAAA;AAAA,MACN,KAAK,CAAE;AAAA,IAAA;AAAA,EAET;AAEM,QAAA,YAAY,MAAMC,gBAAW,YAAY,EAAE,eAAe,MAAM;AAKtE,QAAM,uBAAiC,CAAA;AAEvC,QAAM,MAAgB,CAAA;AACtB,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AACrB,YAAA,mBAAmB,MAAMA,QAAAA,QAC9BC,gBAAK,KAAK,YAAY,SAAS,IAAI,GACnC;AAAA,QACC,eAAe;AAAA,MAAA,CACf;AAEF,YAAM,kBAAkB,iBAAiB,KAAK,CAAC,UAAS;AACvD,eAAO,MAAM,OAAA,KAAY,MAAM,SAASC,UAAAA;AAAAA,MAAA,CACxC;AAED,UAAI,iBAAiB;AACpB,cAAM,YAAYD,gBAAK,KACtB,YACA,SAAS,MACTC,UAAAA,0BAA0B;AAGvB,YAAA;AACG,gBAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAE9C,cAAAC,kBAAAA,kBAAkB,aAAa,GAAG;AACjC,gBAAA,KAAK,cAAc,EAAE;AAAA,UAC1B;AAAA,QAAA,QACO;AACP,+BAAqB,KAAK,SAAS;AAAA,QACpC;AAAA,MACD;AAAA,IACD;AAAA,EACA,CAAA,CAAC;AAGC,MAAA,qBAAqB,SAAS,GAAG;AAC9B,UAAA,iBAAiB,qBAAqB,KAAK,IAAI;AAErD,UAAM,IAAI,MACT,wDAAwD,cAAc,GAAG;AAAA,EAE3E;AAEO,SAAA;AAAA,IACN,KAAK,IAAI,KAAM;AAAA,EAAA;AAEjB;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"readCustomTypeLibrary.js","sources":["../../../src/fs/readCustomTypeLibrary.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isCustomTypeModel } from \"./lib/isCustomTypeModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { CUSTOM_TYPE_MODEL_FILENAME } from \"./constants\";\nimport {\n\tbuildCustomTypeLibraryDirectoryPath,\n\tBuildCustomTypeLibraryDirectoryPathArgs,\n} from \"./buildCustomTypeLibraryDirectoryPath\";\n\nexport type ReadCustomTypeLibraryArgs = BuildCustomTypeLibraryDirectoryPathArgs;\n\nexport type ReadCustomTypeLibraryReturnType = {\n\tids: string[];\n};\n\nexport const readCustomTypeLibrary = async (\n\targs: ReadCustomTypeLibraryArgs,\n): Promise<ReadCustomTypeLibraryReturnType> => {\n\tconst libraryDir = buildCustomTypeLibraryDirectoryPath({\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!(await checkPathExists(libraryDir))) {\n\t\treturn {\n\t\t\tids: [],\n\t\t};\n\t}\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t/**\n\t * Paths to models that could not be read due to invalid JSON.\n\t */\n\tconst unreadableModelPaths: string[] = [];\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(libraryDir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isCustomTypeDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === CUSTOM_TYPE_MODEL_FILENAME;\n\t\t\t\t});\n\n\t\t\t\tif (isCustomTypeDir) {\n\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\tCUSTOM_TYPE_MODEL_FILENAME,\n\t\t\t\t\t);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\t\t\t\tids.push(modelContents.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\tif (unreadableModelPaths.length > 0) {\n\t\tconst formattedPaths = unreadableModelPaths.join(\", \");\n\n\t\tthrow new Error(\n\t\t\t`The following custom type models could not be read: [${formattedPaths}]`,\n\t\t);\n\t}\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n"],"names":["fs.readdir"],"mappings":";;;;;;;AAmBa,MAAA,wBAAwB,OACpC,SAC6C;AAC7C,QAAM,aAAa,oCAAoC;AAAA,IACtD,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,CAAE,MAAM,gBAAgB,UAAU,GAAI;AAClC,WAAA;AAAA,MACN,KAAK,CAAE;AAAA,IAAA;AAAA,EAET;AAEM,QAAA,YAAY,MAAMA,QAAW,YAAY,EAAE,eAAe,MAAM;AAKtE,QAAM,uBAAiC,CAAA;AAEvC,QAAM,MAAgB,CAAA;AACtB,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AACrB,YAAA,mBAAmB,MAAMA,QAC9B,KAAK,KAAK,YAAY,SAAS,IAAI,GACnC;AAAA,QACC,eAAe;AAAA,MAAA,CACf;AAEF,YAAM,kBAAkB,iBAAiB,KAAK,CAAC,UAAS;AACvD,eAAO,MAAM,OAAA,KAAY,MAAM,SAAS;AAAA,MAAA,CACxC;AAED,UAAI,iBAAiB;AACpB,cAAM,YAAY,KAAK,KACtB,YACA,SAAS,MACT,0BAA0B;AAGvB,YAAA;AACG,gBAAA,gBAAgB,MAAM,aAAa,SAAS;AAE9C,cAAA,kBAAkB,aAAa,GAAG;AACjC,gBAAA,KAAK,cAAc,EAAE;AAAA,UAC1B;AAAA,QAAA,QACC;AACD,+BAAqB,KAAK,SAAS;AAAA,QACpC;AAAA,MACD;AAAA,IACD;AAAA,EACA,CAAA,CAAC;AAGC,MAAA,qBAAqB,SAAS,GAAG;AAC9B,UAAA,iBAAiB,qBAAqB,KAAK,IAAI;AAE/C,UAAA,IAAI,MACT,wDAAwD,iBAAiB;AAAA,EAE3E;AAEO,SAAA;AAAA,IACN,KAAK,IAAI,KAAM;AAAA,EAAA;AAEjB;"}
1
+ {"version":3,"file":"readCustomTypeLibrary.js","sources":["../../../src/fs/readCustomTypeLibrary.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isCustomTypeModel } from \"./lib/isCustomTypeModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { CUSTOM_TYPE_MODEL_FILENAME } from \"./constants\";\nimport {\n\tbuildCustomTypeLibraryDirectoryPath,\n\tBuildCustomTypeLibraryDirectoryPathArgs,\n} from \"./buildCustomTypeLibraryDirectoryPath\";\n\nexport type ReadCustomTypeLibraryArgs = BuildCustomTypeLibraryDirectoryPathArgs;\n\nexport type ReadCustomTypeLibraryReturnType = {\n\tids: string[];\n};\n\nexport const readCustomTypeLibrary = async (\n\targs: ReadCustomTypeLibraryArgs,\n): Promise<ReadCustomTypeLibraryReturnType> => {\n\tconst libraryDir = buildCustomTypeLibraryDirectoryPath({\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!(await checkPathExists(libraryDir))) {\n\t\treturn {\n\t\t\tids: [],\n\t\t};\n\t}\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t/**\n\t * Paths to models that could not be read due to invalid JSON.\n\t */\n\tconst unreadableModelPaths: string[] = [];\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(libraryDir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isCustomTypeDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === CUSTOM_TYPE_MODEL_FILENAME;\n\t\t\t\t});\n\n\t\t\t\tif (isCustomTypeDir) {\n\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\tCUSTOM_TYPE_MODEL_FILENAME,\n\t\t\t\t\t);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\t\t\t\tids.push(modelContents.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\tif (unreadableModelPaths.length > 0) {\n\t\tconst formattedPaths = unreadableModelPaths.join(\", \");\n\n\t\tthrow new Error(\n\t\t\t`The following custom type models could not be read: [${formattedPaths}]`,\n\t\t);\n\t}\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n"],"names":["fs.readdir"],"mappings":";;;;;;;AAmBa,MAAA,wBAAwB,OACpC,SAC6C;AAC7C,QAAM,aAAa,oCAAoC;AAAA,IACtD,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,CAAE,MAAM,gBAAgB,UAAU,GAAI;AAClC,WAAA;AAAA,MACN,KAAK,CAAE;AAAA,IAAA;AAAA,EAET;AAEM,QAAA,YAAY,MAAMA,QAAW,YAAY,EAAE,eAAe,MAAM;AAKtE,QAAM,uBAAiC,CAAA;AAEvC,QAAM,MAAgB,CAAA;AACtB,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AACrB,YAAA,mBAAmB,MAAMA,QAC9B,KAAK,KAAK,YAAY,SAAS,IAAI,GACnC;AAAA,QACC,eAAe;AAAA,MAAA,CACf;AAEF,YAAM,kBAAkB,iBAAiB,KAAK,CAAC,UAAS;AACvD,eAAO,MAAM,OAAA,KAAY,MAAM,SAAS;AAAA,MAAA,CACxC;AAED,UAAI,iBAAiB;AACpB,cAAM,YAAY,KAAK,KACtB,YACA,SAAS,MACT,0BAA0B;AAGvB,YAAA;AACG,gBAAA,gBAAgB,MAAM,aAAa,SAAS;AAE9C,cAAA,kBAAkB,aAAa,GAAG;AACjC,gBAAA,KAAK,cAAc,EAAE;AAAA,UAC1B;AAAA,QAAA,QACO;AACP,+BAAqB,KAAK,SAAS;AAAA,QACpC;AAAA,MACD;AAAA,IACD;AAAA,EACA,CAAA,CAAC;AAGC,MAAA,qBAAqB,SAAS,GAAG;AAC9B,UAAA,iBAAiB,qBAAqB,KAAK,IAAI;AAErD,UAAM,IAAI,MACT,wDAAwD,cAAc,GAAG;AAAA,EAE3E;AAEO,SAAA;AAAA,IACN,KAAK,IAAI,KAAM;AAAA,EAAA;AAEjB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"readSliceLibrary.cjs","sources":["../../../src/fs/readSliceLibrary.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isSharedSliceModel } from \"./lib/isSharedSliceModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { SHARED_SLICE_MODEL_FILENAME } from \"./constants\";\nimport {\n\tbuildSliceLibraryDirectoryPath,\n\tBuildSliceLibraryDirectoryPathArgs,\n} from \"./buildSliceLibraryDirectoryPath\";\n\nexport type ReadSliceLibraryArgs = BuildSliceLibraryDirectoryPathArgs;\n\nexport type ReadSliceLibraryReturnType = {\n\tid: string;\n\tsliceIDs: string[];\n};\n\nexport const readSliceLibrary = async (\n\targs: ReadSliceLibraryArgs,\n): Promise<ReadSliceLibraryReturnType> => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: args.libraryID,\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!(await checkPathExists(libraryDir))) {\n\t\treturn {\n\t\t\tid: args.libraryID,\n\t\t\tsliceIDs: [],\n\t\t};\n\t}\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t/**\n\t * Paths to models that could not be read due to invalid JSON.\n\t */\n\tconst unreadableModelPaths: string[] = [];\n\n\tconst sliceIDs: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(libraryDir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isSliceDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === SHARED_SLICE_MODEL_FILENAME;\n\t\t\t\t});\n\n\t\t\t\tif (isSliceDir) {\n\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\tSHARED_SLICE_MODEL_FILENAME,\n\t\t\t\t\t);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (isSharedSliceModel(modelContents)) {\n\t\t\t\t\t\t\tsliceIDs.push(modelContents.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// JSON could not be read or parsed\n\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\tif (unreadableModelPaths.length > 0) {\n\t\tconst formattedPaths = unreadableModelPaths.join(\", \");\n\n\t\tthrow new Error(\n\t\t\t`The following Slice models could not be read: [${formattedPaths}]`,\n\t\t);\n\t}\n\n\treturn {\n\t\tid: args.libraryID,\n\t\tsliceIDs: sliceIDs.sort(),\n\t};\n};\n"],"names":["buildSliceLibraryDirectoryPath","checkPathExists","fs.readdir","path","SHARED_SLICE_MODEL_FILENAME","readJSONFile","isSharedSliceModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoBa,MAAA,mBAAmB,OAC/B,SACwC;AACxC,QAAM,aAAaA,+BAAAA,+BAA+B;AAAA,IACjD,WAAW,KAAK;AAAA,IAChB,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,CAAE,MAAMC,gCAAgB,UAAU,GAAI;AAClC,WAAA;AAAA,MACN,IAAI,KAAK;AAAA,MACT,UAAU,CAAE;AAAA,IAAA;AAAA,EAEd;AAEM,QAAA,YAAY,MAAMC,gBAAW,YAAY,EAAE,eAAe,MAAM;AAKtE,QAAM,uBAAiC,CAAA;AAEvC,QAAM,WAAqB,CAAA;AAC3B,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AACrB,YAAA,mBAAmB,MAAMA,QAAAA,QAC9BC,gBAAK,KAAK,YAAY,SAAS,IAAI,GACnC;AAAA,QACC,eAAe;AAAA,MAAA,CACf;AAEF,YAAM,aAAa,iBAAiB,KAAK,CAAC,UAAS;AAClD,eAAO,MAAM,OAAA,KAAY,MAAM,SAASC,UAAAA;AAAAA,MAAA,CACxC;AAED,UAAI,YAAY;AACf,cAAM,YAAYD,gBAAK,KACtB,YACA,SAAS,MACTC,UAAAA,2BAA2B;AAGxB,YAAA;AACG,gBAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAE9C,cAAAC,mBAAAA,mBAAmB,aAAa,GAAG;AAC7B,qBAAA,KAAK,cAAc,EAAE;AAAA,UAC/B;AAAA,QAAA,QACC;AAED,+BAAqB,KAAK,SAAS;AAAA,QACpC;AAAA,MACD;AAAA,IACD;AAAA,EACA,CAAA,CAAC;AAGC,MAAA,qBAAqB,SAAS,GAAG;AAC9B,UAAA,iBAAiB,qBAAqB,KAAK,IAAI;AAE/C,UAAA,IAAI,MACT,kDAAkD,iBAAiB;AAAA,EAErE;AAEO,SAAA;AAAA,IACN,IAAI,KAAK;AAAA,IACT,UAAU,SAAS,KAAM;AAAA,EAAA;AAE3B;;"}
1
+ {"version":3,"file":"readSliceLibrary.cjs","sources":["../../../src/fs/readSliceLibrary.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isSharedSliceModel } from \"./lib/isSharedSliceModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { SHARED_SLICE_MODEL_FILENAME } from \"./constants\";\nimport {\n\tbuildSliceLibraryDirectoryPath,\n\tBuildSliceLibraryDirectoryPathArgs,\n} from \"./buildSliceLibraryDirectoryPath\";\n\nexport type ReadSliceLibraryArgs = BuildSliceLibraryDirectoryPathArgs;\n\nexport type ReadSliceLibraryReturnType = {\n\tid: string;\n\tsliceIDs: string[];\n};\n\nexport const readSliceLibrary = async (\n\targs: ReadSliceLibraryArgs,\n): Promise<ReadSliceLibraryReturnType> => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: args.libraryID,\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!(await checkPathExists(libraryDir))) {\n\t\treturn {\n\t\t\tid: args.libraryID,\n\t\t\tsliceIDs: [],\n\t\t};\n\t}\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t/**\n\t * Paths to models that could not be read due to invalid JSON.\n\t */\n\tconst unreadableModelPaths: string[] = [];\n\n\tconst sliceIDs: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(libraryDir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isSliceDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === SHARED_SLICE_MODEL_FILENAME;\n\t\t\t\t});\n\n\t\t\t\tif (isSliceDir) {\n\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\tSHARED_SLICE_MODEL_FILENAME,\n\t\t\t\t\t);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (isSharedSliceModel(modelContents)) {\n\t\t\t\t\t\t\tsliceIDs.push(modelContents.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// JSON could not be read or parsed\n\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\tif (unreadableModelPaths.length > 0) {\n\t\tconst formattedPaths = unreadableModelPaths.join(\", \");\n\n\t\tthrow new Error(\n\t\t\t`The following Slice models could not be read: [${formattedPaths}]`,\n\t\t);\n\t}\n\n\treturn {\n\t\tid: args.libraryID,\n\t\tsliceIDs: sliceIDs.sort(),\n\t};\n};\n"],"names":["buildSliceLibraryDirectoryPath","checkPathExists","fs.readdir","path","SHARED_SLICE_MODEL_FILENAME","readJSONFile","isSharedSliceModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoBa,MAAA,mBAAmB,OAC/B,SACwC;AACxC,QAAM,aAAaA,+BAAAA,+BAA+B;AAAA,IACjD,WAAW,KAAK;AAAA,IAChB,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,CAAE,MAAMC,gCAAgB,UAAU,GAAI;AAClC,WAAA;AAAA,MACN,IAAI,KAAK;AAAA,MACT,UAAU,CAAE;AAAA,IAAA;AAAA,EAEd;AAEM,QAAA,YAAY,MAAMC,gBAAW,YAAY,EAAE,eAAe,MAAM;AAKtE,QAAM,uBAAiC,CAAA;AAEvC,QAAM,WAAqB,CAAA;AAC3B,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AACrB,YAAA,mBAAmB,MAAMA,QAAAA,QAC9BC,gBAAK,KAAK,YAAY,SAAS,IAAI,GACnC;AAAA,QACC,eAAe;AAAA,MAAA,CACf;AAEF,YAAM,aAAa,iBAAiB,KAAK,CAAC,UAAS;AAClD,eAAO,MAAM,OAAA,KAAY,MAAM,SAASC,UAAAA;AAAAA,MAAA,CACxC;AAED,UAAI,YAAY;AACf,cAAM,YAAYD,gBAAK,KACtB,YACA,SAAS,MACTC,UAAAA,2BAA2B;AAGxB,YAAA;AACG,gBAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAE9C,cAAAC,mBAAAA,mBAAmB,aAAa,GAAG;AAC7B,qBAAA,KAAK,cAAc,EAAE;AAAA,UAC/B;AAAA,QAAA,QACO;AAEP,+BAAqB,KAAK,SAAS;AAAA,QACpC;AAAA,MACD;AAAA,IACD;AAAA,EACA,CAAA,CAAC;AAGC,MAAA,qBAAqB,SAAS,GAAG;AAC9B,UAAA,iBAAiB,qBAAqB,KAAK,IAAI;AAErD,UAAM,IAAI,MACT,kDAAkD,cAAc,GAAG;AAAA,EAErE;AAEO,SAAA;AAAA,IACN,IAAI,KAAK;AAAA,IACT,UAAU,SAAS,KAAM;AAAA,EAAA;AAE3B;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"readSliceLibrary.js","sources":["../../../src/fs/readSliceLibrary.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isSharedSliceModel } from \"./lib/isSharedSliceModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { SHARED_SLICE_MODEL_FILENAME } from \"./constants\";\nimport {\n\tbuildSliceLibraryDirectoryPath,\n\tBuildSliceLibraryDirectoryPathArgs,\n} from \"./buildSliceLibraryDirectoryPath\";\n\nexport type ReadSliceLibraryArgs = BuildSliceLibraryDirectoryPathArgs;\n\nexport type ReadSliceLibraryReturnType = {\n\tid: string;\n\tsliceIDs: string[];\n};\n\nexport const readSliceLibrary = async (\n\targs: ReadSliceLibraryArgs,\n): Promise<ReadSliceLibraryReturnType> => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: args.libraryID,\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!(await checkPathExists(libraryDir))) {\n\t\treturn {\n\t\t\tid: args.libraryID,\n\t\t\tsliceIDs: [],\n\t\t};\n\t}\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t/**\n\t * Paths to models that could not be read due to invalid JSON.\n\t */\n\tconst unreadableModelPaths: string[] = [];\n\n\tconst sliceIDs: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(libraryDir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isSliceDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === SHARED_SLICE_MODEL_FILENAME;\n\t\t\t\t});\n\n\t\t\t\tif (isSliceDir) {\n\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\tSHARED_SLICE_MODEL_FILENAME,\n\t\t\t\t\t);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (isSharedSliceModel(modelContents)) {\n\t\t\t\t\t\t\tsliceIDs.push(modelContents.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// JSON could not be read or parsed\n\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\tif (unreadableModelPaths.length > 0) {\n\t\tconst formattedPaths = unreadableModelPaths.join(\", \");\n\n\t\tthrow new Error(\n\t\t\t`The following Slice models could not be read: [${formattedPaths}]`,\n\t\t);\n\t}\n\n\treturn {\n\t\tid: args.libraryID,\n\t\tsliceIDs: sliceIDs.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":3,"file":"readSliceLibrary.js","sources":["../../../src/fs/readSliceLibrary.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isSharedSliceModel } from \"./lib/isSharedSliceModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { SHARED_SLICE_MODEL_FILENAME } from \"./constants\";\nimport {\n\tbuildSliceLibraryDirectoryPath,\n\tBuildSliceLibraryDirectoryPathArgs,\n} from \"./buildSliceLibraryDirectoryPath\";\n\nexport type ReadSliceLibraryArgs = BuildSliceLibraryDirectoryPathArgs;\n\nexport type ReadSliceLibraryReturnType = {\n\tid: string;\n\tsliceIDs: string[];\n};\n\nexport const readSliceLibrary = async (\n\targs: ReadSliceLibraryArgs,\n): Promise<ReadSliceLibraryReturnType> => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: args.libraryID,\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!(await checkPathExists(libraryDir))) {\n\t\treturn {\n\t\t\tid: args.libraryID,\n\t\t\tsliceIDs: [],\n\t\t};\n\t}\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t/**\n\t * Paths to models that could not be read due to invalid JSON.\n\t */\n\tconst unreadableModelPaths: string[] = [];\n\n\tconst sliceIDs: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(libraryDir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isSliceDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === SHARED_SLICE_MODEL_FILENAME;\n\t\t\t\t});\n\n\t\t\t\tif (isSliceDir) {\n\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\tSHARED_SLICE_MODEL_FILENAME,\n\t\t\t\t\t);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (isSharedSliceModel(modelContents)) {\n\t\t\t\t\t\t\tsliceIDs.push(modelContents.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// JSON could not be read or parsed\n\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\tif (unreadableModelPaths.length > 0) {\n\t\tconst formattedPaths = unreadableModelPaths.join(\", \");\n\n\t\tthrow new Error(\n\t\t\t`The following Slice models could not be read: [${formattedPaths}]`,\n\t\t);\n\t}\n\n\treturn {\n\t\tid: args.libraryID,\n\t\tsliceIDs: sliceIDs.sort(),\n\t};\n};\n"],"names":["fs.readdir"],"mappings":";;;;;;;AAoBa,MAAA,mBAAmB,OAC/B,SACwC;AACxC,QAAM,aAAa,+BAA+B;AAAA,IACjD,WAAW,KAAK;AAAA,IAChB,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,CAAE,MAAM,gBAAgB,UAAU,GAAI;AAClC,WAAA;AAAA,MACN,IAAI,KAAK;AAAA,MACT,UAAU,CAAE;AAAA,IAAA;AAAA,EAEd;AAEM,QAAA,YAAY,MAAMA,QAAW,YAAY,EAAE,eAAe,MAAM;AAKtE,QAAM,uBAAiC,CAAA;AAEvC,QAAM,WAAqB,CAAA;AAC3B,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AACrB,YAAA,mBAAmB,MAAMA,QAC9B,KAAK,KAAK,YAAY,SAAS,IAAI,GACnC;AAAA,QACC,eAAe;AAAA,MAAA,CACf;AAEF,YAAM,aAAa,iBAAiB,KAAK,CAAC,UAAS;AAClD,eAAO,MAAM,OAAA,KAAY,MAAM,SAAS;AAAA,MAAA,CACxC;AAED,UAAI,YAAY;AACf,cAAM,YAAY,KAAK,KACtB,YACA,SAAS,MACT,2BAA2B;AAGxB,YAAA;AACG,gBAAA,gBAAgB,MAAM,aAAa,SAAS;AAE9C,cAAA,mBAAmB,aAAa,GAAG;AAC7B,qBAAA,KAAK,cAAc,EAAE;AAAA,UAC/B;AAAA,QAAA,QACO;AAEP,+BAAqB,KAAK,SAAS;AAAA,QACpC;AAAA,MACD;AAAA,IACD;AAAA,EACA,CAAA,CAAC;AAGC,MAAA,qBAAqB,SAAS,GAAG;AAC9B,UAAA,iBAAiB,qBAAqB,KAAK,IAAI;AAErD,UAAM,IAAI,MACT,kDAAkD,cAAc,GAAG;AAAA,EAErE;AAEO,SAAA;AAAA,IACN,IAAI,KAAK;AAAA,IACT,UAAU,SAAS,KAAM;AAAA,EAAA;AAE3B;"}
@@ -1 +1 @@
1
- {"version":3,"file":"readSliceModel.cjs","sources":["../../../src/fs/readSliceModel.ts"],"sourcesContent":["import { SharedSlice } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as path from \"node:path\";\n\nimport { SliceMachineHelpers } from \"../createSliceMachineHelpers\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isSharedSliceModel } from \"./lib/isSharedSliceModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { buildSliceLibraryDirectoryPath } from \"./buildSliceLibraryDirectoryPath\";\nimport { SHARED_SLICE_MODEL_FILENAME } from \"./constants\";\n\nexport type ReadSliceModelArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\thelpers: SliceMachineHelpers;\n};\n\nexport type ReadSliceModelReturnType = {\n\tmodel: SharedSlice;\n};\n\nexport const readSliceModel = async (\n\targs: ReadSliceModelArgs,\n): Promise<ReadSliceModelReturnType> => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: args.libraryID,\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (await checkPathExists(libraryDir)) {\n\t\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t\t/**\n\t\t * Paths to models that could not be read due to invalid JSON.\n\t\t */\n\t\tconst unreadableModelPaths: string[] = [];\n\n\t\t// Find the first matching model.\n\t\tconst [model] = (\n\t\t\tawait Promise.all(\n\t\t\t\tchildDirs.map(async (childDir) => {\n\t\t\t\t\tif (childDir.isDirectory()) {\n\t\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\t\tSHARED_SLICE_MODEL_FILENAME,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tisSharedSliceModel(modelContents) &&\n\t\t\t\t\t\t\t\tmodelContents.id === args.sliceID\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn modelContents;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\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).filter((model): model is NonNullable<typeof model> => Boolean(model));\n\n\t\tif (model) {\n\t\t\treturn {\n\t\t\t\tmodel,\n\t\t\t};\n\t\t} else {\n\t\t\tif (unreadableModelPaths.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Did not find a Slice model with ID \"${args.sliceID}\" in the \"${\n\t\t\t\t\t\targs.libraryID\n\t\t\t\t\t}\" Slice Library. The following Slice models could not be read: [${unreadableModelPaths.join(\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}\n\t}\n\n\tthrow new Error(\n\t\t`Did not find a Slice model with ID \"${args.sliceID}\" in the \"${args.libraryID}\" Slice Library.`,\n\t);\n};\n"],"names":["buildSliceLibraryDirectoryPath","checkPathExists","fs.readdir","path","SHARED_SLICE_MODEL_FILENAME","readJSONFile","isSharedSliceModel","model"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBa,MAAA,iBAAiB,OAC7B,SACsC;AACtC,QAAM,aAAaA,+BAAAA,+BAA+B;AAAA,IACjD,WAAW,KAAK;AAAA,IAChB,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAEG,MAAA,MAAMC,gBAAAA,gBAAgB,UAAU,GAAG;AAChC,UAAA,YAAY,MAAMC,gBAAW,YAAY,EAAE,eAAe,MAAM;AAKtE,UAAM,uBAAiC,CAAA;AAGjC,UAAA,CAAC,KAAK,KACX,MAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,UAAA,SAAS,eAAe;AAC3B,cAAM,YAAYC,gBAAK,KACtB,YACA,SAAS,MACTC,UAAAA,2BAA2B;AAGxB,YAAA;AACG,gBAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAElD,cACCC,mBAAAA,mBAAmB,aAAa,KAChC,cAAc,OAAO,KAAK,SACzB;AACM,mBAAA;AAAA,UACR;AAAA,iBACQ;AACR,+BAAqB,KAAK,SAAS;AAAA,QACpC;AAAA,MACD;AAAA,IAAA,CACA,CAAC,GAEF,OAAO,CAACC,WAA8C,QAAQA,MAAK,CAAC;AAEtE,QAAI,OAAO;AACH,aAAA;AAAA,QACN;AAAA,MAAA;AAAA,WAEK;AACF,UAAA,qBAAqB,SAAS,GAAG;AAC9B,cAAA,IAAI,MACT,uCAAuC,KAAK,oBAC3C,KAAK,4EAC6D,qBAAqB,KACvF,IAAI,IACD;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AAEA,QAAM,IAAI,MACT,uCAAuC,KAAK,oBAAoB,KAAK,2BAA2B;AAElG;;"}
1
+ {"version":3,"file":"readSliceModel.cjs","sources":["../../../src/fs/readSliceModel.ts"],"sourcesContent":["import { SharedSlice } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as path from \"node:path\";\n\nimport { SliceMachineHelpers } from \"../createSliceMachineHelpers\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isSharedSliceModel } from \"./lib/isSharedSliceModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { buildSliceLibraryDirectoryPath } from \"./buildSliceLibraryDirectoryPath\";\nimport { SHARED_SLICE_MODEL_FILENAME } from \"./constants\";\n\nexport type ReadSliceModelArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\thelpers: SliceMachineHelpers;\n};\n\nexport type ReadSliceModelReturnType = {\n\tmodel: SharedSlice;\n};\n\nexport const readSliceModel = async (\n\targs: ReadSliceModelArgs,\n): Promise<ReadSliceModelReturnType> => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: args.libraryID,\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (await checkPathExists(libraryDir)) {\n\t\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t\t/**\n\t\t * Paths to models that could not be read due to invalid JSON.\n\t\t */\n\t\tconst unreadableModelPaths: string[] = [];\n\n\t\t// Find the first matching model.\n\t\tconst [model] = (\n\t\t\tawait Promise.all(\n\t\t\t\tchildDirs.map(async (childDir) => {\n\t\t\t\t\tif (childDir.isDirectory()) {\n\t\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\t\tSHARED_SLICE_MODEL_FILENAME,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tisSharedSliceModel(modelContents) &&\n\t\t\t\t\t\t\t\tmodelContents.id === args.sliceID\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn modelContents;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\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).filter((model): model is NonNullable<typeof model> => Boolean(model));\n\n\t\tif (model) {\n\t\t\treturn {\n\t\t\t\tmodel,\n\t\t\t};\n\t\t} else {\n\t\t\tif (unreadableModelPaths.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Did not find a Slice model with ID \"${args.sliceID}\" in the \"${\n\t\t\t\t\t\targs.libraryID\n\t\t\t\t\t}\" Slice Library. The following Slice models could not be read: [${unreadableModelPaths.join(\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}\n\t}\n\n\tthrow new Error(\n\t\t`Did not find a Slice model with ID \"${args.sliceID}\" in the \"${args.libraryID}\" Slice Library.`,\n\t);\n};\n"],"names":["buildSliceLibraryDirectoryPath","checkPathExists","fs.readdir","path","SHARED_SLICE_MODEL_FILENAME","readJSONFile","isSharedSliceModel","model"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBa,MAAA,iBAAiB,OAC7B,SACsC;AACtC,QAAM,aAAaA,+BAAAA,+BAA+B;AAAA,IACjD,WAAW,KAAK;AAAA,IAChB,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAEG,MAAA,MAAMC,gBAAAA,gBAAgB,UAAU,GAAG;AAChC,UAAA,YAAY,MAAMC,gBAAW,YAAY,EAAE,eAAe,MAAM;AAKtE,UAAM,uBAAiC,CAAA;AAGjC,UAAA,CAAC,KAAK,KACX,MAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,UAAA,SAAS,eAAe;AAC3B,cAAM,YAAYC,gBAAK,KACtB,YACA,SAAS,MACTC,UAAAA,2BAA2B;AAGxB,YAAA;AACG,gBAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAElD,cACCC,mBAAAA,mBAAmB,aAAa,KAChC,cAAc,OAAO,KAAK,SACzB;AACM,mBAAA;AAAA,UACR;AAAA,iBACQ,OAAO;AACf,+BAAqB,KAAK,SAAS;AAAA,QACpC;AAAA,MACD;AAAA,IAAA,CACA,CAAC,GAEF,OAAO,CAACC,WAA8C,QAAQA,MAAK,CAAC;AAEtE,QAAI,OAAO;AACH,aAAA;AAAA,QACN;AAAA,MAAA;AAAA,WAEK;AACF,UAAA,qBAAqB,SAAS,GAAG;AACpC,cAAM,IAAI,MACT,uCAAuC,KAAK,OAAO,aAClD,KAAK,SACN,mEAAmE,qBAAqB,KACvF,IAAI,CACJ,GAAG;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AAEM,QAAA,IAAI,MACT,uCAAuC,KAAK,OAAO,aAAa,KAAK,SAAS,kBAAkB;AAElG;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"readSliceModel.js","sources":["../../../src/fs/readSliceModel.ts"],"sourcesContent":["import { SharedSlice } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as path from \"node:path\";\n\nimport { SliceMachineHelpers } from \"../createSliceMachineHelpers\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isSharedSliceModel } from \"./lib/isSharedSliceModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { buildSliceLibraryDirectoryPath } from \"./buildSliceLibraryDirectoryPath\";\nimport { SHARED_SLICE_MODEL_FILENAME } from \"./constants\";\n\nexport type ReadSliceModelArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\thelpers: SliceMachineHelpers;\n};\n\nexport type ReadSliceModelReturnType = {\n\tmodel: SharedSlice;\n};\n\nexport const readSliceModel = async (\n\targs: ReadSliceModelArgs,\n): Promise<ReadSliceModelReturnType> => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: args.libraryID,\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (await checkPathExists(libraryDir)) {\n\t\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t\t/**\n\t\t * Paths to models that could not be read due to invalid JSON.\n\t\t */\n\t\tconst unreadableModelPaths: string[] = [];\n\n\t\t// Find the first matching model.\n\t\tconst [model] = (\n\t\t\tawait Promise.all(\n\t\t\t\tchildDirs.map(async (childDir) => {\n\t\t\t\t\tif (childDir.isDirectory()) {\n\t\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\t\tSHARED_SLICE_MODEL_FILENAME,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tisSharedSliceModel(modelContents) &&\n\t\t\t\t\t\t\t\tmodelContents.id === args.sliceID\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn modelContents;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\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).filter((model): model is NonNullable<typeof model> => Boolean(model));\n\n\t\tif (model) {\n\t\t\treturn {\n\t\t\t\tmodel,\n\t\t\t};\n\t\t} else {\n\t\t\tif (unreadableModelPaths.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Did not find a Slice model with ID \"${args.sliceID}\" in the \"${\n\t\t\t\t\t\targs.libraryID\n\t\t\t\t\t}\" Slice Library. The following Slice models could not be read: [${unreadableModelPaths.join(\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}\n\t}\n\n\tthrow new Error(\n\t\t`Did not find a Slice model with ID \"${args.sliceID}\" in the \"${args.libraryID}\" Slice Library.`,\n\t);\n};\n"],"names":["fs.readdir","model"],"mappings":";;;;;;;AAuBa,MAAA,iBAAiB,OAC7B,SACsC;AACtC,QAAM,aAAa,+BAA+B;AAAA,IACjD,WAAW,KAAK;AAAA,IAChB,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAEG,MAAA,MAAM,gBAAgB,UAAU,GAAG;AAChC,UAAA,YAAY,MAAMA,QAAW,YAAY,EAAE,eAAe,MAAM;AAKtE,UAAM,uBAAiC,CAAA;AAGjC,UAAA,CAAC,KAAK,KACX,MAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,UAAA,SAAS,eAAe;AAC3B,cAAM,YAAY,KAAK,KACtB,YACA,SAAS,MACT,2BAA2B;AAGxB,YAAA;AACG,gBAAA,gBAAgB,MAAM,aAAa,SAAS;AAElD,cACC,mBAAmB,aAAa,KAChC,cAAc,OAAO,KAAK,SACzB;AACM,mBAAA;AAAA,UACR;AAAA,iBACQ;AACR,+BAAqB,KAAK,SAAS;AAAA,QACpC;AAAA,MACD;AAAA,IAAA,CACA,CAAC,GAEF,OAAO,CAACC,WAA8C,QAAQA,MAAK,CAAC;AAEtE,QAAI,OAAO;AACH,aAAA;AAAA,QACN;AAAA,MAAA;AAAA,WAEK;AACF,UAAA,qBAAqB,SAAS,GAAG;AAC9B,cAAA,IAAI,MACT,uCAAuC,KAAK,oBAC3C,KAAK,4EAC6D,qBAAqB,KACvF,IAAI,IACD;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AAEA,QAAM,IAAI,MACT,uCAAuC,KAAK,oBAAoB,KAAK,2BAA2B;AAElG;"}
1
+ {"version":3,"file":"readSliceModel.js","sources":["../../../src/fs/readSliceModel.ts"],"sourcesContent":["import { SharedSlice } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as path from \"node:path\";\n\nimport { SliceMachineHelpers } from \"../createSliceMachineHelpers\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\nimport { isSharedSliceModel } from \"./lib/isSharedSliceModel\";\nimport { readJSONFile } from \"./lib/readJSONFile\";\nimport * as fs from \"./lib/fsLimit\";\n\nimport { buildSliceLibraryDirectoryPath } from \"./buildSliceLibraryDirectoryPath\";\nimport { SHARED_SLICE_MODEL_FILENAME } from \"./constants\";\n\nexport type ReadSliceModelArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\thelpers: SliceMachineHelpers;\n};\n\nexport type ReadSliceModelReturnType = {\n\tmodel: SharedSlice;\n};\n\nexport const readSliceModel = async (\n\targs: ReadSliceModelArgs,\n): Promise<ReadSliceModelReturnType> => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: args.libraryID,\n\t\tabsolute: true,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (await checkPathExists(libraryDir)) {\n\t\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t\t/**\n\t\t * Paths to models that could not be read due to invalid JSON.\n\t\t */\n\t\tconst unreadableModelPaths: string[] = [];\n\n\t\t// Find the first matching model.\n\t\tconst [model] = (\n\t\t\tawait Promise.all(\n\t\t\t\tchildDirs.map(async (childDir) => {\n\t\t\t\t\tif (childDir.isDirectory()) {\n\t\t\t\t\t\tconst modelPath = path.join(\n\t\t\t\t\t\t\tlibraryDir,\n\t\t\t\t\t\t\tchildDir.name,\n\t\t\t\t\t\t\tSHARED_SLICE_MODEL_FILENAME,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tisSharedSliceModel(modelContents) &&\n\t\t\t\t\t\t\t\tmodelContents.id === args.sliceID\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn modelContents;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tunreadableModelPaths.push(modelPath);\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).filter((model): model is NonNullable<typeof model> => Boolean(model));\n\n\t\tif (model) {\n\t\t\treturn {\n\t\t\t\tmodel,\n\t\t\t};\n\t\t} else {\n\t\t\tif (unreadableModelPaths.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Did not find a Slice model with ID \"${args.sliceID}\" in the \"${\n\t\t\t\t\t\targs.libraryID\n\t\t\t\t\t}\" Slice Library. The following Slice models could not be read: [${unreadableModelPaths.join(\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}\n\t}\n\n\tthrow new Error(\n\t\t`Did not find a Slice model with ID \"${args.sliceID}\" in the \"${args.libraryID}\" Slice Library.`,\n\t);\n};\n"],"names":["fs.readdir","model"],"mappings":";;;;;;;AAuBa,MAAA,iBAAiB,OAC7B,SACsC;AACtC,QAAM,aAAa,+BAA+B;AAAA,IACjD,WAAW,KAAK;AAAA,IAChB,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAEG,MAAA,MAAM,gBAAgB,UAAU,GAAG;AAChC,UAAA,YAAY,MAAMA,QAAW,YAAY,EAAE,eAAe,MAAM;AAKtE,UAAM,uBAAiC,CAAA;AAGjC,UAAA,CAAC,KAAK,KACX,MAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,UAAA,SAAS,eAAe;AAC3B,cAAM,YAAY,KAAK,KACtB,YACA,SAAS,MACT,2BAA2B;AAGxB,YAAA;AACG,gBAAA,gBAAgB,MAAM,aAAa,SAAS;AAElD,cACC,mBAAmB,aAAa,KAChC,cAAc,OAAO,KAAK,SACzB;AACM,mBAAA;AAAA,UACR;AAAA,iBACQ,OAAO;AACf,+BAAqB,KAAK,SAAS;AAAA,QACpC;AAAA,MACD;AAAA,IAAA,CACA,CAAC,GAEF,OAAO,CAACC,WAA8C,QAAQA,MAAK,CAAC;AAEtE,QAAI,OAAO;AACH,aAAA;AAAA,QACN;AAAA,MAAA;AAAA,WAEK;AACF,UAAA,qBAAqB,SAAS,GAAG;AACpC,cAAM,IAAI,MACT,uCAAuC,KAAK,OAAO,aAClD,KAAK,SACN,mEAAmE,qBAAqB,KACvF,IAAI,CACJ,GAAG;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AAEM,QAAA,IAAI,MACT,uCAAuC,KAAK,OAAO,aAAa,KAAK,SAAS,kBAAkB;AAElG;"}
@@ -1 +1 @@
1
- {"version":3,"file":"upsertGlobalTypeScriptTypes.cjs","sources":["../../../src/fs/upsertGlobalTypeScriptTypes.ts"],"sourcesContent":["import { detectTypesProvider, generateTypes } from \"prismic-ts-codegen\";\n\nimport { SliceMachineActions } from \"../createSliceMachineActions\";\n\nimport { writeProjectFile, WriteProjectFileArgs } from \"./writeProjectFile\";\nimport {\n\tGLOBAL_TYPESCRIPT_TYPES_FILENAME,\n\tNON_EDITABLE_FILE_BANNER,\n} from \"./constants\";\n\n/**\n * Arguments for `upsertGlobalContentTypes()`.\n */\nexport type UpsertGlobalTypeScriptTypesArgs = {\n\tfilename?: string;\n\tactions: SliceMachineActions;\n} & Omit<WriteProjectFileArgs, \"filename\" | \"contents\">;\n\n/**\n * Creates a globally accessible TypeScript file containing types representing\n * the Prismic repository's content.\n *\n * @returns The file path to the written file.\n */\nexport const upsertGlobalTypeScriptTypes = async (\n\targs: UpsertGlobalTypeScriptTypesArgs,\n): Promise<string> => {\n\tconst project = await args.helpers.getProject();\n\n\tconst [customTypeModelDescriptors, sharedSliceModelDescriptors] =\n\t\tawait Promise.all([\n\t\t\targs.actions.readAllCustomTypeModels(),\n\t\t\targs.actions.readAllSliceModels(),\n\t\t]);\n\n\tconst customTypeModels = customTypeModelDescriptors.map(\n\t\t(customTypeModelDescriptors) => {\n\t\t\treturn customTypeModelDescriptors.model;\n\t\t},\n\t);\n\tconst sharedSliceModels = sharedSliceModelDescriptors.map(\n\t\t(sharedSliceModelDescriptors) => {\n\t\t\treturn sharedSliceModelDescriptors.model;\n\t\t},\n\t);\n\n\tlet contents = generateTypes({\n\t\tcustomTypeModels,\n\t\tsharedSliceModels,\n\t\tclientIntegration: {\n\t\t\tincludeCreateClientInterface: true,\n\t\t\tincludeContentNamespace: true,\n\t\t},\n\t\ttypesProvider: await detectTypesProvider({ cwd: project.root }),\n\t});\n\n\tcontents = `${NON_EDITABLE_FILE_BANNER}\\n\\n${contents}`;\n\n\treturn await writeProjectFile({\n\t\t...args,\n\t\tfilename: args.filename || GLOBAL_TYPESCRIPT_TYPES_FILENAME,\n\t\tcontents,\n\t});\n};\n"],"names":["customTypeModelDescriptors","sharedSliceModelDescriptors","generateTypes","detectTypesProvider","NON_EDITABLE_FILE_BANNER","writeProjectFile","GLOBAL_TYPESCRIPT_TYPES_FILENAME"],"mappings":";;;;;AAwBa,MAAA,8BAA8B,OAC1C,SACoB;AACpB,QAAM,UAAU,MAAM,KAAK,QAAQ,WAAU;AAE7C,QAAM,CAAC,4BAA4B,2BAA2B,IAC7D,MAAM,QAAQ,IAAI;AAAA,IACjB,KAAK,QAAQ,wBAAyB;AAAA,IACtC,KAAK,QAAQ,mBAAoB;AAAA,EAAA,CACjC;AAEF,QAAM,mBAAmB,2BAA2B,IACnD,CAACA,gCAA8B;AAC9B,WAAOA,4BAA2B;AAAA,EAAA,CAClC;AAEF,QAAM,oBAAoB,4BAA4B,IACrD,CAACC,iCAA+B;AAC/B,WAAOA,6BAA4B;AAAA,EAAA,CACnC;AAGF,MAAI,WAAWC,iBAAAA,cAAc;AAAA,IAC5B;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,MAClB,8BAA8B;AAAA,MAC9B,yBAAyB;AAAA,IACzB;AAAA,IACD,eAAe,MAAMC,iBAAAA,oBAAoB,EAAE,KAAK,QAAQ,MAAM;AAAA,EAAA,CAC9D;AAED,aAAW,GAAGC;;EAA+B;AAE7C,SAAO,MAAMC,iBAAAA,iBAAiB;AAAA,IAC7B,GAAG;AAAA,IACH,UAAU,KAAK,YAAYC,UAAA;AAAA,IAC3B;AAAA,EAAA,CACA;AACF;;"}
1
+ {"version":3,"file":"upsertGlobalTypeScriptTypes.cjs","sources":["../../../src/fs/upsertGlobalTypeScriptTypes.ts"],"sourcesContent":["import { detectTypesProvider, generateTypes } from \"prismic-ts-codegen\";\n\nimport { SliceMachineActions } from \"../createSliceMachineActions\";\n\nimport { writeProjectFile, WriteProjectFileArgs } from \"./writeProjectFile\";\nimport {\n\tGLOBAL_TYPESCRIPT_TYPES_FILENAME,\n\tNON_EDITABLE_FILE_BANNER,\n} from \"./constants\";\n\n/**\n * Arguments for `upsertGlobalContentTypes()`.\n */\nexport type UpsertGlobalTypeScriptTypesArgs = {\n\tfilename?: string;\n\tactions: SliceMachineActions;\n} & Omit<WriteProjectFileArgs, \"filename\" | \"contents\">;\n\n/**\n * Creates a globally accessible TypeScript file containing types representing\n * the Prismic repository's content.\n *\n * @returns The file path to the written file.\n */\nexport const upsertGlobalTypeScriptTypes = async (\n\targs: UpsertGlobalTypeScriptTypesArgs,\n): Promise<string> => {\n\tconst project = await args.helpers.getProject();\n\n\tconst [customTypeModelDescriptors, sharedSliceModelDescriptors] =\n\t\tawait Promise.all([\n\t\t\targs.actions.readAllCustomTypeModels(),\n\t\t\targs.actions.readAllSliceModels(),\n\t\t]);\n\n\tconst customTypeModels = customTypeModelDescriptors.map(\n\t\t(customTypeModelDescriptors) => {\n\t\t\treturn customTypeModelDescriptors.model;\n\t\t},\n\t);\n\tconst sharedSliceModels = sharedSliceModelDescriptors.map(\n\t\t(sharedSliceModelDescriptors) => {\n\t\t\treturn sharedSliceModelDescriptors.model;\n\t\t},\n\t);\n\n\tlet contents = generateTypes({\n\t\tcustomTypeModels,\n\t\tsharedSliceModels,\n\t\tclientIntegration: {\n\t\t\tincludeCreateClientInterface: true,\n\t\t\tincludeContentNamespace: true,\n\t\t},\n\t\ttypesProvider: await detectTypesProvider({ cwd: project.root }),\n\t});\n\n\tcontents = `${NON_EDITABLE_FILE_BANNER}\\n\\n${contents}`;\n\n\treturn await writeProjectFile({\n\t\t...args,\n\t\tfilename: args.filename || GLOBAL_TYPESCRIPT_TYPES_FILENAME,\n\t\tcontents,\n\t});\n};\n"],"names":["customTypeModelDescriptors","sharedSliceModelDescriptors","generateTypes","detectTypesProvider","NON_EDITABLE_FILE_BANNER","writeProjectFile","GLOBAL_TYPESCRIPT_TYPES_FILENAME"],"mappings":";;;;;AAwBa,MAAA,8BAA8B,OAC1C,SACoB;AACpB,QAAM,UAAU,MAAM,KAAK,QAAQ,WAAU;AAE7C,QAAM,CAAC,4BAA4B,2BAA2B,IAC7D,MAAM,QAAQ,IAAI;AAAA,IACjB,KAAK,QAAQ,wBAAyB;AAAA,IACtC,KAAK,QAAQ,mBAAoB;AAAA,EAAA,CACjC;AAEF,QAAM,mBAAmB,2BAA2B,IACnD,CAACA,gCAA8B;AAC9B,WAAOA,4BAA2B;AAAA,EAAA,CAClC;AAEF,QAAM,oBAAoB,4BAA4B,IACrD,CAACC,iCAA+B;AAC/B,WAAOA,6BAA4B;AAAA,EAAA,CACnC;AAGF,MAAI,WAAWC,iBAAAA,cAAc;AAAA,IAC5B;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,MAClB,8BAA8B;AAAA,MAC9B,yBAAyB;AAAA,IACzB;AAAA,IACD,eAAe,MAAMC,iBAAAA,oBAAoB,EAAE,KAAK,QAAQ,MAAM;AAAA,EAAA,CAC9D;AAED,aAAW,GAAGC,kCAAwB;AAAA;AAAA,EAAO,QAAQ;AAErD,SAAO,MAAMC,iBAAAA,iBAAiB;AAAA,IAC7B,GAAG;AAAA,IACH,UAAU,KAAK,YAAYC,UAAA;AAAA,IAC3B;AAAA,EAAA,CACA;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"upsertGlobalTypeScriptTypes.js","sources":["../../../src/fs/upsertGlobalTypeScriptTypes.ts"],"sourcesContent":["import { detectTypesProvider, generateTypes } from \"prismic-ts-codegen\";\n\nimport { SliceMachineActions } from \"../createSliceMachineActions\";\n\nimport { writeProjectFile, WriteProjectFileArgs } from \"./writeProjectFile\";\nimport {\n\tGLOBAL_TYPESCRIPT_TYPES_FILENAME,\n\tNON_EDITABLE_FILE_BANNER,\n} from \"./constants\";\n\n/**\n * Arguments for `upsertGlobalContentTypes()`.\n */\nexport type UpsertGlobalTypeScriptTypesArgs = {\n\tfilename?: string;\n\tactions: SliceMachineActions;\n} & Omit<WriteProjectFileArgs, \"filename\" | \"contents\">;\n\n/**\n * Creates a globally accessible TypeScript file containing types representing\n * the Prismic repository's content.\n *\n * @returns The file path to the written file.\n */\nexport const upsertGlobalTypeScriptTypes = async (\n\targs: UpsertGlobalTypeScriptTypesArgs,\n): Promise<string> => {\n\tconst project = await args.helpers.getProject();\n\n\tconst [customTypeModelDescriptors, sharedSliceModelDescriptors] =\n\t\tawait Promise.all([\n\t\t\targs.actions.readAllCustomTypeModels(),\n\t\t\targs.actions.readAllSliceModels(),\n\t\t]);\n\n\tconst customTypeModels = customTypeModelDescriptors.map(\n\t\t(customTypeModelDescriptors) => {\n\t\t\treturn customTypeModelDescriptors.model;\n\t\t},\n\t);\n\tconst sharedSliceModels = sharedSliceModelDescriptors.map(\n\t\t(sharedSliceModelDescriptors) => {\n\t\t\treturn sharedSliceModelDescriptors.model;\n\t\t},\n\t);\n\n\tlet contents = generateTypes({\n\t\tcustomTypeModels,\n\t\tsharedSliceModels,\n\t\tclientIntegration: {\n\t\t\tincludeCreateClientInterface: true,\n\t\t\tincludeContentNamespace: true,\n\t\t},\n\t\ttypesProvider: await detectTypesProvider({ cwd: project.root }),\n\t});\n\n\tcontents = `${NON_EDITABLE_FILE_BANNER}\\n\\n${contents}`;\n\n\treturn await writeProjectFile({\n\t\t...args,\n\t\tfilename: args.filename || GLOBAL_TYPESCRIPT_TYPES_FILENAME,\n\t\tcontents,\n\t});\n};\n"],"names":["customTypeModelDescriptors","sharedSliceModelDescriptors"],"mappings":";;;AAwBa,MAAA,8BAA8B,OAC1C,SACoB;AACpB,QAAM,UAAU,MAAM,KAAK,QAAQ,WAAU;AAE7C,QAAM,CAAC,4BAA4B,2BAA2B,IAC7D,MAAM,QAAQ,IAAI;AAAA,IACjB,KAAK,QAAQ,wBAAyB;AAAA,IACtC,KAAK,QAAQ,mBAAoB;AAAA,EAAA,CACjC;AAEF,QAAM,mBAAmB,2BAA2B,IACnD,CAACA,gCAA8B;AAC9B,WAAOA,4BAA2B;AAAA,EAAA,CAClC;AAEF,QAAM,oBAAoB,4BAA4B,IACrD,CAACC,iCAA+B;AAC/B,WAAOA,6BAA4B;AAAA,EAAA,CACnC;AAGF,MAAI,WAAW,cAAc;AAAA,IAC5B;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,MAClB,8BAA8B;AAAA,MAC9B,yBAAyB;AAAA,IACzB;AAAA,IACD,eAAe,MAAM,oBAAoB,EAAE,KAAK,QAAQ,MAAM;AAAA,EAAA,CAC9D;AAED,aAAW,GAAG;AAAA;AAAA,EAA+B;AAE7C,SAAO,MAAM,iBAAiB;AAAA,IAC7B,GAAG;AAAA,IACH,UAAU,KAAK,YAAY;AAAA,IAC3B;AAAA,EAAA,CACA;AACF;"}
1
+ {"version":3,"file":"upsertGlobalTypeScriptTypes.js","sources":["../../../src/fs/upsertGlobalTypeScriptTypes.ts"],"sourcesContent":["import { detectTypesProvider, generateTypes } from \"prismic-ts-codegen\";\n\nimport { SliceMachineActions } from \"../createSliceMachineActions\";\n\nimport { writeProjectFile, WriteProjectFileArgs } from \"./writeProjectFile\";\nimport {\n\tGLOBAL_TYPESCRIPT_TYPES_FILENAME,\n\tNON_EDITABLE_FILE_BANNER,\n} from \"./constants\";\n\n/**\n * Arguments for `upsertGlobalContentTypes()`.\n */\nexport type UpsertGlobalTypeScriptTypesArgs = {\n\tfilename?: string;\n\tactions: SliceMachineActions;\n} & Omit<WriteProjectFileArgs, \"filename\" | \"contents\">;\n\n/**\n * Creates a globally accessible TypeScript file containing types representing\n * the Prismic repository's content.\n *\n * @returns The file path to the written file.\n */\nexport const upsertGlobalTypeScriptTypes = async (\n\targs: UpsertGlobalTypeScriptTypesArgs,\n): Promise<string> => {\n\tconst project = await args.helpers.getProject();\n\n\tconst [customTypeModelDescriptors, sharedSliceModelDescriptors] =\n\t\tawait Promise.all([\n\t\t\targs.actions.readAllCustomTypeModels(),\n\t\t\targs.actions.readAllSliceModels(),\n\t\t]);\n\n\tconst customTypeModels = customTypeModelDescriptors.map(\n\t\t(customTypeModelDescriptors) => {\n\t\t\treturn customTypeModelDescriptors.model;\n\t\t},\n\t);\n\tconst sharedSliceModels = sharedSliceModelDescriptors.map(\n\t\t(sharedSliceModelDescriptors) => {\n\t\t\treturn sharedSliceModelDescriptors.model;\n\t\t},\n\t);\n\n\tlet contents = generateTypes({\n\t\tcustomTypeModels,\n\t\tsharedSliceModels,\n\t\tclientIntegration: {\n\t\t\tincludeCreateClientInterface: true,\n\t\t\tincludeContentNamespace: true,\n\t\t},\n\t\ttypesProvider: await detectTypesProvider({ cwd: project.root }),\n\t});\n\n\tcontents = `${NON_EDITABLE_FILE_BANNER}\\n\\n${contents}`;\n\n\treturn await writeProjectFile({\n\t\t...args,\n\t\tfilename: args.filename || GLOBAL_TYPESCRIPT_TYPES_FILENAME,\n\t\tcontents,\n\t});\n};\n"],"names":["customTypeModelDescriptors","sharedSliceModelDescriptors"],"mappings":";;;AAwBa,MAAA,8BAA8B,OAC1C,SACoB;AACpB,QAAM,UAAU,MAAM,KAAK,QAAQ,WAAU;AAE7C,QAAM,CAAC,4BAA4B,2BAA2B,IAC7D,MAAM,QAAQ,IAAI;AAAA,IACjB,KAAK,QAAQ,wBAAyB;AAAA,IACtC,KAAK,QAAQ,mBAAoB;AAAA,EAAA,CACjC;AAEF,QAAM,mBAAmB,2BAA2B,IACnD,CAACA,gCAA8B;AAC9B,WAAOA,4BAA2B;AAAA,EAAA,CAClC;AAEF,QAAM,oBAAoB,4BAA4B,IACrD,CAACC,iCAA+B;AAC/B,WAAOA,6BAA4B;AAAA,EAAA,CACnC;AAGF,MAAI,WAAW,cAAc;AAAA,IAC5B;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,MAClB,8BAA8B;AAAA,MAC9B,yBAAyB;AAAA,IACzB;AAAA,IACD,eAAe,MAAM,oBAAoB,EAAE,KAAK,QAAQ,MAAM;AAAA,EAAA,CAC9D;AAED,aAAW,GAAG,wBAAwB;AAAA;AAAA,EAAO,QAAQ;AAErD,SAAO,MAAM,iBAAiB;AAAA,IAC7B,GAAG;AAAA,IACH,UAAU,KAAK,YAAY;AAAA,IAC3B;AAAA,EAAA,CACA;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeProjectEnvironment.cjs","sources":["../../../src/fs/writeProjectEnvironment.ts"],"sourcesContent":["import * as dotenv from \"dotenv\";\n\nimport {\n\tcheckHasProjectFile,\n\tCheckHasProjectFileArgs,\n} from \"./checkHasProjectFile\";\nimport { readProjectFile, ReadProjectFileArgs } from \"./readProjectFile\";\nimport { writeProjectFile, WriteProjectFileArgs } from \"./writeProjectFile\";\n\nexport type WriteProjectEnvironmentArgs = {\n\tvariableName: string;\n\tenvironment: string | undefined;\n} & Omit<CheckHasProjectFileArgs, \"filename\"> &\n\tOmit<ReadProjectFileArgs, \"filename\"> &\n\tOmit<WriteProjectFileArgs, \"contents\" | \"format\" | \"formatOptions\">;\n\nexport const writeProjectEnvironment = async (\n\targs: WriteProjectEnvironmentArgs,\n): Promise<string | undefined> => {\n\tconst hasEnvironmentVariableFile = await checkHasProjectFile({\n\t\tfilename: args.filename,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!hasEnvironmentVariableFile && args.environment === undefined) {\n\t\treturn;\n\t}\n\n\tlet contents = hasEnvironmentVariableFile\n\t\t? await readProjectFile({\n\t\t\t\tfilename: args.filename,\n\t\t\t\thelpers: args.helpers,\n\t\t\t\tencoding: \"utf8\",\n\t\t })\n\t\t: \"\";\n\n\tconst variableLine = `${args.variableName}=${args.environment}\\n`;\n\n\tconst hasExistingVariable = args.variableName in dotenv.parse(contents);\n\n\tif (hasExistingVariable) {\n\t\t// TODO: This regexp/replace is not working.\n\t\tcontents = contents.replace(\n\t\t\tnew RegExp(`^${args.variableName}=.*\\n?$`, \"m\"),\n\t\t\targs.environment === undefined ? \"\" : variableLine,\n\t\t);\n\t} else {\n\t\tif (!contents.endsWith(\"\\n\")) {\n\t\t\tcontents += \"\\n\";\n\t\t}\n\n\t\tcontents += variableLine;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename: args.filename,\n\t\tcontents,\n\t\tformat: false,\n\t\thelpers: args.helpers,\n\t});\n\n\treturn args.filename;\n};\n"],"names":["checkHasProjectFile","readProjectFile","dotenv","writeProjectFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgBa,MAAA,0BAA0B,OACtC,SACgC;AAC1B,QAAA,6BAA6B,MAAMA,wCAAoB;AAAA,IAC5D,UAAU,KAAK;AAAA,IACf,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,CAAC,8BAA8B,KAAK,gBAAgB,QAAW;AAClE;AAAA,EACD;AAEI,MAAA,WAAW,6BACZ,MAAMC,gCAAgB;AAAA,IACtB,UAAU,KAAK;AAAA,IACf,SAAS,KAAK;AAAA,IACd,UAAU;AAAA,EACT,CAAA,IACD;AAEH,QAAM,eAAe,GAAG,KAAK,gBAAgB,KAAK;AAAA;AAElD,QAAM,sBAAsB,KAAK,gBAAgBC,kBAAO,MAAM,QAAQ;AAEtE,MAAI,qBAAqB;AAExB,eAAW,SAAS,QACnB,IAAI,OAAO,IAAI,KAAK;AAAA,KAAuB,GAAG,GAC9C,KAAK,gBAAgB,SAAY,KAAK,YAAY;AAAA,EAAA,OAE7C;AACN,QAAI,CAAC,SAAS,SAAS,IAAI,GAAG;AACjB,kBAAA;AAAA,IACb;AAEY,gBAAA;AAAA,EACb;AAEA,QAAMC,kCAAiB;AAAA,IACtB,UAAU,KAAK;AAAA,IACf;AAAA,IACA,QAAQ;AAAA,IACR,SAAS,KAAK;AAAA,EAAA,CACd;AAED,SAAO,KAAK;AACb;;"}
1
+ {"version":3,"file":"writeProjectEnvironment.cjs","sources":["../../../src/fs/writeProjectEnvironment.ts"],"sourcesContent":["import * as dotenv from \"dotenv\";\n\nimport {\n\tcheckHasProjectFile,\n\tCheckHasProjectFileArgs,\n} from \"./checkHasProjectFile\";\nimport { readProjectFile, ReadProjectFileArgs } from \"./readProjectFile\";\nimport { writeProjectFile, WriteProjectFileArgs } from \"./writeProjectFile\";\n\nexport type WriteProjectEnvironmentArgs = {\n\tvariableName: string;\n\tenvironment: string | undefined;\n} & Omit<CheckHasProjectFileArgs, \"filename\"> &\n\tOmit<ReadProjectFileArgs, \"filename\"> &\n\tOmit<WriteProjectFileArgs, \"contents\" | \"format\" | \"formatOptions\">;\n\nexport const writeProjectEnvironment = async (\n\targs: WriteProjectEnvironmentArgs,\n): Promise<string | undefined> => {\n\tconst hasEnvironmentVariableFile = await checkHasProjectFile({\n\t\tfilename: args.filename,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!hasEnvironmentVariableFile && args.environment === undefined) {\n\t\treturn;\n\t}\n\n\tlet contents = hasEnvironmentVariableFile\n\t\t? await readProjectFile({\n\t\t\t\tfilename: args.filename,\n\t\t\t\thelpers: args.helpers,\n\t\t\t\tencoding: \"utf8\",\n\t\t })\n\t\t: \"\";\n\n\tconst variableLine = `${args.variableName}=${args.environment}\\n`;\n\n\tconst hasExistingVariable = args.variableName in dotenv.parse(contents);\n\n\tif (hasExistingVariable) {\n\t\t// TODO: This regexp/replace is not working.\n\t\tcontents = contents.replace(\n\t\t\tnew RegExp(`^${args.variableName}=.*\\n?$`, \"m\"),\n\t\t\targs.environment === undefined ? \"\" : variableLine,\n\t\t);\n\t} else {\n\t\tif (!contents.endsWith(\"\\n\")) {\n\t\t\tcontents += \"\\n\";\n\t\t}\n\n\t\tcontents += variableLine;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename: args.filename,\n\t\tcontents,\n\t\tformat: false,\n\t\thelpers: args.helpers,\n\t});\n\n\treturn args.filename;\n};\n"],"names":["checkHasProjectFile","readProjectFile","dotenv","writeProjectFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgBa,MAAA,0BAA0B,OACtC,SACgC;AAC1B,QAAA,6BAA6B,MAAMA,wCAAoB;AAAA,IAC5D,UAAU,KAAK;AAAA,IACf,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,CAAC,8BAA8B,KAAK,gBAAgB,QAAW;AAClE;AAAA,EACD;AAEI,MAAA,WAAW,6BACZ,MAAMC,gCAAgB;AAAA,IACtB,UAAU,KAAK;AAAA,IACf,SAAS,KAAK;AAAA,IACd,UAAU;AAAA,EACT,CAAA,IACD;AAEH,QAAM,eAAe,GAAG,KAAK,YAAY,IAAI,KAAK,WAAW;AAAA;AAE7D,QAAM,sBAAsB,KAAK,gBAAgBC,kBAAO,MAAM,QAAQ;AAEtE,MAAI,qBAAqB;AAExB,eAAW,SAAS,QACnB,IAAI,OAAO,IAAI,KAAK,YAAY;AAAA,KAAW,GAAG,GAC9C,KAAK,gBAAgB,SAAY,KAAK,YAAY;AAAA,EAAA,OAE7C;AACN,QAAI,CAAC,SAAS,SAAS,IAAI,GAAG;AACjB,kBAAA;AAAA,IACb;AAEY,gBAAA;AAAA,EACb;AAEA,QAAMC,kCAAiB;AAAA,IACtB,UAAU,KAAK;AAAA,IACf;AAAA,IACA,QAAQ;AAAA,IACR,SAAS,KAAK;AAAA,EAAA,CACd;AAED,SAAO,KAAK;AACb;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeProjectEnvironment.js","sources":["../../../src/fs/writeProjectEnvironment.ts"],"sourcesContent":["import * as dotenv from \"dotenv\";\n\nimport {\n\tcheckHasProjectFile,\n\tCheckHasProjectFileArgs,\n} from \"./checkHasProjectFile\";\nimport { readProjectFile, ReadProjectFileArgs } from \"./readProjectFile\";\nimport { writeProjectFile, WriteProjectFileArgs } from \"./writeProjectFile\";\n\nexport type WriteProjectEnvironmentArgs = {\n\tvariableName: string;\n\tenvironment: string | undefined;\n} & Omit<CheckHasProjectFileArgs, \"filename\"> &\n\tOmit<ReadProjectFileArgs, \"filename\"> &\n\tOmit<WriteProjectFileArgs, \"contents\" | \"format\" | \"formatOptions\">;\n\nexport const writeProjectEnvironment = async (\n\targs: WriteProjectEnvironmentArgs,\n): Promise<string | undefined> => {\n\tconst hasEnvironmentVariableFile = await checkHasProjectFile({\n\t\tfilename: args.filename,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!hasEnvironmentVariableFile && args.environment === undefined) {\n\t\treturn;\n\t}\n\n\tlet contents = hasEnvironmentVariableFile\n\t\t? await readProjectFile({\n\t\t\t\tfilename: args.filename,\n\t\t\t\thelpers: args.helpers,\n\t\t\t\tencoding: \"utf8\",\n\t\t })\n\t\t: \"\";\n\n\tconst variableLine = `${args.variableName}=${args.environment}\\n`;\n\n\tconst hasExistingVariable = args.variableName in dotenv.parse(contents);\n\n\tif (hasExistingVariable) {\n\t\t// TODO: This regexp/replace is not working.\n\t\tcontents = contents.replace(\n\t\t\tnew RegExp(`^${args.variableName}=.*\\n?$`, \"m\"),\n\t\t\targs.environment === undefined ? \"\" : variableLine,\n\t\t);\n\t} else {\n\t\tif (!contents.endsWith(\"\\n\")) {\n\t\t\tcontents += \"\\n\";\n\t\t}\n\n\t\tcontents += variableLine;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename: args.filename,\n\t\tcontents,\n\t\tformat: false,\n\t\thelpers: args.helpers,\n\t});\n\n\treturn args.filename;\n};\n"],"names":[],"mappings":";;;;AAgBa,MAAA,0BAA0B,OACtC,SACgC;AAC1B,QAAA,6BAA6B,MAAM,oBAAoB;AAAA,IAC5D,UAAU,KAAK;AAAA,IACf,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,CAAC,8BAA8B,KAAK,gBAAgB,QAAW;AAClE;AAAA,EACD;AAEI,MAAA,WAAW,6BACZ,MAAM,gBAAgB;AAAA,IACtB,UAAU,KAAK;AAAA,IACf,SAAS,KAAK;AAAA,IACd,UAAU;AAAA,EACT,CAAA,IACD;AAEH,QAAM,eAAe,GAAG,KAAK,gBAAgB,KAAK;AAAA;AAElD,QAAM,sBAAsB,KAAK,gBAAgB,OAAO,MAAM,QAAQ;AAEtE,MAAI,qBAAqB;AAExB,eAAW,SAAS,QACnB,IAAI,OAAO,IAAI,KAAK;AAAA,KAAuB,GAAG,GAC9C,KAAK,gBAAgB,SAAY,KAAK,YAAY;AAAA,EAAA,OAE7C;AACN,QAAI,CAAC,SAAS,SAAS,IAAI,GAAG;AACjB,kBAAA;AAAA,IACb;AAEY,gBAAA;AAAA,EACb;AAEA,QAAM,iBAAiB;AAAA,IACtB,UAAU,KAAK;AAAA,IACf;AAAA,IACA,QAAQ;AAAA,IACR,SAAS,KAAK;AAAA,EAAA,CACd;AAED,SAAO,KAAK;AACb;"}
1
+ {"version":3,"file":"writeProjectEnvironment.js","sources":["../../../src/fs/writeProjectEnvironment.ts"],"sourcesContent":["import * as dotenv from \"dotenv\";\n\nimport {\n\tcheckHasProjectFile,\n\tCheckHasProjectFileArgs,\n} from \"./checkHasProjectFile\";\nimport { readProjectFile, ReadProjectFileArgs } from \"./readProjectFile\";\nimport { writeProjectFile, WriteProjectFileArgs } from \"./writeProjectFile\";\n\nexport type WriteProjectEnvironmentArgs = {\n\tvariableName: string;\n\tenvironment: string | undefined;\n} & Omit<CheckHasProjectFileArgs, \"filename\"> &\n\tOmit<ReadProjectFileArgs, \"filename\"> &\n\tOmit<WriteProjectFileArgs, \"contents\" | \"format\" | \"formatOptions\">;\n\nexport const writeProjectEnvironment = async (\n\targs: WriteProjectEnvironmentArgs,\n): Promise<string | undefined> => {\n\tconst hasEnvironmentVariableFile = await checkHasProjectFile({\n\t\tfilename: args.filename,\n\t\thelpers: args.helpers,\n\t});\n\n\tif (!hasEnvironmentVariableFile && args.environment === undefined) {\n\t\treturn;\n\t}\n\n\tlet contents = hasEnvironmentVariableFile\n\t\t? await readProjectFile({\n\t\t\t\tfilename: args.filename,\n\t\t\t\thelpers: args.helpers,\n\t\t\t\tencoding: \"utf8\",\n\t\t })\n\t\t: \"\";\n\n\tconst variableLine = `${args.variableName}=${args.environment}\\n`;\n\n\tconst hasExistingVariable = args.variableName in dotenv.parse(contents);\n\n\tif (hasExistingVariable) {\n\t\t// TODO: This regexp/replace is not working.\n\t\tcontents = contents.replace(\n\t\t\tnew RegExp(`^${args.variableName}=.*\\n?$`, \"m\"),\n\t\t\targs.environment === undefined ? \"\" : variableLine,\n\t\t);\n\t} else {\n\t\tif (!contents.endsWith(\"\\n\")) {\n\t\t\tcontents += \"\\n\";\n\t\t}\n\n\t\tcontents += variableLine;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename: args.filename,\n\t\tcontents,\n\t\tformat: false,\n\t\thelpers: args.helpers,\n\t});\n\n\treturn args.filename;\n};\n"],"names":[],"mappings":";;;;AAgBa,MAAA,0BAA0B,OACtC,SACgC;AAC1B,QAAA,6BAA6B,MAAM,oBAAoB;AAAA,IAC5D,UAAU,KAAK;AAAA,IACf,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,CAAC,8BAA8B,KAAK,gBAAgB,QAAW;AAClE;AAAA,EACD;AAEI,MAAA,WAAW,6BACZ,MAAM,gBAAgB;AAAA,IACtB,UAAU,KAAK;AAAA,IACf,SAAS,KAAK;AAAA,IACd,UAAU;AAAA,EACT,CAAA,IACD;AAEH,QAAM,eAAe,GAAG,KAAK,YAAY,IAAI,KAAK,WAAW;AAAA;AAE7D,QAAM,sBAAsB,KAAK,gBAAgB,OAAO,MAAM,QAAQ;AAEtE,MAAI,qBAAqB;AAExB,eAAW,SAAS,QACnB,IAAI,OAAO,IAAI,KAAK,YAAY;AAAA,KAAW,GAAG,GAC9C,KAAK,gBAAgB,SAAY,KAAK,YAAY;AAAA,EAAA,OAE7C;AACN,QAAI,CAAC,SAAS,SAAS,IAAI,GAAG;AACjB,kBAAA;AAAA,IACb;AAEY,gBAAA;AAAA,EACb;AAEA,QAAM,iBAAiB;AAAA,IACtB,UAAU,KAAK;AAAA,IACf;AAAA,IACA,QAAQ;AAAA,IACR,SAAS,KAAK;AAAA,EAAA,CACd;AAED,SAAO,KAAK;AACb;"}
@@ -1 +1 @@
1
- {"version":3,"file":"HookSystem.cjs","sources":["../../../src/lib/HookSystem.ts"],"sourcesContent":["/**\n * Extends a function arguments with extra ones.\n */\ntype FnWithExtraArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tF extends (...args: any[]) => any,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTExtraArgs extends any[] = any[],\n> = (\n\t...args: [...args: Parameters<F>, ...extraArgs: TExtraArgs]\n) => ReturnType<F>;\n\n/**\n * Defines a hook handler.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type HookFn<TArgs extends any[] = any[], TReturn = any> = (\n\t...args: TArgs\n) => Promise<TReturn> | TReturn;\n\n/**\n * Generic hook metadata.\n */\ntype HookMeta = Record<string, unknown>;\n\n/**\n * Defines a hook, including its function handler and optional metadata.\n */\nexport type Hook<\n\tTHookFn extends HookFn = HookFn,\n\tTHookMeta extends HookMeta = HookMeta,\n> = {\n\tfn: THookFn;\n\tmeta?: THookMeta;\n};\n\n/**\n * Represents a map of hook types to hook functions and metas.\n */\ntype Hooks = Record<string, Hook>;\n\n/**\n * Builds hook meta arguments after hook meta requirements.\n */\ntype HookMetaArg<THookMeta extends Record<string, unknown> | undefined> =\n\tTHookMeta extends Record<string, unknown>\n\t\t? [meta: THookMeta]\n\t\t: [meta?: never];\n\n/**\n * Defines the return type of the {@link HookSystem.callHook} functions.\n *\n * @internal\n */\nexport type CallHookReturnType<THookFn extends HookFn = HookFn> = Promise<{\n\tdata: Awaited<ReturnType<THookFn>>[];\n\terrors: HookError[];\n}>;\n\n/**\n * Defines the return type of the {@link HookSystem.createScope} functions.\n *\n * @internal\n */\nexport type CreateScopeReturnType<\n\tTHooks extends Hooks = Record<string, { fn: HookFn }>,\n\tTExtraArgs extends unknown[] = never[],\n> = {\n\thook: <TType extends keyof THooks>(\n\t\ttype: TType,\n\t\thookFn: FnWithExtraArgs<THooks[TType][\"fn\"], TExtraArgs>,\n\t\t...[meta]: HookMetaArg<THooks[TType][\"meta\"]>\n\t) => void;\n\tunhook: HookSystem<{\n\t\t[P in keyof THooks]: Omit<THooks[P], \"fn\"> & {\n\t\t\tfn: FnWithExtraArgs<THooks[P][\"fn\"], TExtraArgs>;\n\t\t};\n\t}>[\"unhook\"];\n};\n\ntype RegisteredHookMeta = {\n\tid: string;\n\ttype: string;\n\towner: string;\n\texternal?: HookFn;\n};\n\n/**\n * Represents a registered hook.\n */\ntype RegisteredHook<THook extends Hook = Hook> = {\n\tfn: THook[\"fn\"];\n\tmeta: THook[\"meta\"] extends Record<string, unknown>\n\t\t? RegisteredHookMeta & THook[\"meta\"]\n\t\t: RegisteredHookMeta;\n};\n\nexport class HookError<TError = Error | unknown> extends Error {\n\ttype: string;\n\towner: string;\n\trawMeta: RegisteredHookMeta;\n\trawCause: TError;\n\n\tconstructor(meta: RegisteredHookMeta, cause: TError) {\n\t\tsuper(\n\t\t\t`Error in \\`${meta.owner}\\` during \\`${meta.type}\\` hook: ${\n\t\t\t\tcause instanceof Error ? cause.message : String(cause)\n\t\t\t}`,\n\t\t);\n\n\t\tthis.type = meta.type;\n\t\tthis.owner = meta.owner;\n\t\tthis.rawMeta = meta;\n\t\tthis.rawCause = cause;\n\t\tthis.cause = cause instanceof Error ? cause : undefined;\n\t}\n}\n\nconst uuid = (): string => {\n\treturn (++uuid.i).toString();\n};\nuuid.i = 0;\n\n/**\n * @internal\n */\nexport class HookSystem<THooks extends Hooks = Hooks> {\n\tprivate _registeredHooks: {\n\t\t[K in keyof THooks]?: RegisteredHook<THooks[K]>[];\n\t} = {};\n\n\thook<TType extends keyof THooks>(\n\t\towner: string,\n\t\ttype: TType,\n\t\thookFn: THooks[TType][\"fn\"],\n\t\t...[meta]: HookMetaArg<THooks[TType][\"meta\"]>\n\t): void {\n\t\tconst registeredHook = {\n\t\t\tfn: hookFn,\n\t\t\tmeta: {\n\t\t\t\t...meta,\n\t\t\t\towner,\n\t\t\t\ttype,\n\t\t\t\tid: uuid(),\n\t\t\t},\n\t\t} as RegisteredHook<THooks[TType]>;\n\n\t\tconst registeredHooksForType = this._registeredHooks[type];\n\n\t\tif (registeredHooksForType) {\n\t\t\tregisteredHooksForType.push(registeredHook);\n\t\t} else {\n\t\t\tthis._registeredHooks[type] = [registeredHook];\n\t\t}\n\t}\n\n\tunhook<TType extends keyof THooks>(\n\t\ttype: TType,\n\t\thookFn: THooks[TType][\"fn\"],\n\t): void {\n\t\tthis._registeredHooks[type] = this._registeredHooks[type]?.filter(\n\t\t\t(registeredHook) => registeredHook.fn !== hookFn,\n\t\t);\n\t}\n\n\tasync callHook<TType extends Extract<keyof THooks, string>>(\n\t\ttypeOrTypeAndHookID: TType | { type: TType; hookID: string },\n\t\t...args: Parameters<THooks[TType][\"fn\"]>\n\t): CallHookReturnType<THooks[TType][\"fn\"]> {\n\t\tlet hooks: RegisteredHook<THooks[TType]>[];\n\n\t\tif (typeof typeOrTypeAndHookID === \"string\") {\n\t\t\thooks = this._registeredHooks[typeOrTypeAndHookID] ?? [];\n\t\t} else {\n\t\t\tconst hookForID = this._registeredHooks[typeOrTypeAndHookID.type]?.find(\n\t\t\t\t(hook) => hook.meta.id === typeOrTypeAndHookID.hookID,\n\t\t\t);\n\n\t\t\tif (hookForID) {\n\t\t\t\thooks = [hookForID];\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hook of type \\`${typeOrTypeAndHookID.type}\\` with ID \\`${typeOrTypeAndHookID.hookID}\\` not found.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst promises = hooks.map(async (hook) => {\n\t\t\ttry {\n\t\t\t\treturn await hook.fn(...args);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new HookError(hook.meta, error);\n\t\t\t}\n\t\t});\n\n\t\tconst settledPromises = await Promise.allSettled(promises);\n\n\t\treturn settledPromises.reduce<{\n\t\t\tdata: Awaited<ReturnType<THooks[TType][\"fn\"]>>[];\n\t\t\terrors: HookError[];\n\t\t}>(\n\t\t\t(acc, settledPromise) => {\n\t\t\t\tif (settledPromise.status === \"fulfilled\") {\n\t\t\t\t\tacc.data.push(settledPromise.value);\n\t\t\t\t} else {\n\t\t\t\t\tacc.errors.push(settledPromise.reason);\n\t\t\t\t}\n\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{ data: [], errors: [] },\n\t\t);\n\t}\n\n\t/**\n\t * Returns list of hooks for a given owner\n\t */\n\thooksForOwner(owner: string): RegisteredHook<THooks[string]>[] {\n\t\tconst hooks: RegisteredHook<THooks[string]>[] = [];\n\n\t\tfor (const hookType in this._registeredHooks) {\n\t\t\tconst registeredHooks = this._registeredHooks[hookType];\n\n\t\t\tif (Array.isArray(registeredHooks)) {\n\t\t\t\tfor (const registeredHook of registeredHooks) {\n\t\t\t\t\tif (registeredHook.meta.owner === owner) {\n\t\t\t\t\t\thooks.push(registeredHook);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn hooks;\n\t}\n\n\t/**\n\t * Returns list of hooks for a given type\n\t */\n\thooksForType<TType extends keyof THooks>(\n\t\ttype: TType,\n\t): RegisteredHook<THooks[TType]>[] {\n\t\treturn this._registeredHooks[type] ?? [];\n\t}\n\n\tcreateScope<TExtraArgs extends unknown[] = never[]>(\n\t\towner: string,\n\t\textraArgs: [...TExtraArgs],\n\t): CreateScopeReturnType<THooks, TExtraArgs> {\n\t\treturn {\n\t\t\thook: (type, hookFn, ...[meta]) => {\n\t\t\t\tconst internalHook = ((\n\t\t\t\t\t...args: Parameters<THooks[typeof type][\"fn\"]>\n\t\t\t\t) => {\n\t\t\t\t\treturn hookFn(...args, ...extraArgs);\n\t\t\t\t}) as THooks[typeof type][\"fn\"];\n\n\t\t\t\tconst resolvedMeta = {\n\t\t\t\t\t...meta,\n\t\t\t\t\texternal: hookFn,\n\t\t\t\t} as HookMetaArg<THooks[typeof type][\"meta\"]>[0];\n\n\t\t\t\treturn this.hook(\n\t\t\t\t\towner,\n\t\t\t\t\ttype,\n\t\t\t\t\tinternalHook,\n\t\t\t\t\t// @ts-expect-error - TypeScript fails to assert rest argument.\n\t\t\t\t\tresolvedMeta,\n\t\t\t\t);\n\t\t\t},\n\t\t\tunhook: (type, hookFn) => {\n\t\t\t\tthis._registeredHooks[type] = this._registeredHooks[type]?.filter(\n\t\t\t\t\t(registeredHook) => registeredHook.meta.external !== hookFn,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;AAiGM,MAAO,kBAA4C,MAAK;AAAA,EAM7D,YAAY,MAA0B,OAAa;AAEjD,UAAA,cAAc,KAAK,oBAAoB,KAAK,gBAC3C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACpD;AATJ;AACA;AACA;AACA;AASC,SAAK,OAAO,KAAK;AACjB,SAAK,QAAQ,KAAK;AAClB,SAAK,UAAU;AACf,SAAK,WAAW;AACX,SAAA,QAAQ,iBAAiB,QAAQ,QAAQ;AAAA,EAC/C;AACA;AAED,MAAM,OAAO,MAAa;AACjB,UAAA,EAAE,KAAK,GAAG,SAAQ;AAC3B;AACA,KAAK,IAAI;MAKI,WAAU;AAAA;AACd,4CAEJ,CAAA;AAAA;AAAA,EAEJ,KACC,OACA,MACA,WACG,CAAC,IAAI,GAAqC;AAE7C,UAAM,iBAAiB;AAAA,MACtB,IAAI;AAAA,MACJ,MAAM;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,IAAI,KAAM;AAAA,MACV;AAAA,IAAA;AAGI,UAAA,yBAAyB,KAAK,iBAAiB,IAAI;AAEzD,QAAI,wBAAwB;AAC3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AA,YAAY,KAAK,kBAAkB;AACvC,YAAA,kBAAkB,KAAK,iBAAiB,QAAQ;AAElD,UAAA,MAAM,QAAQ,eAAe,GAAG;AACnC,mBAAW,kBAAkB,iBAAiB;AACzC,cAAA,eAAe,KAAK,UAAU,OAAO;AACxC,kBAAM,KAAK,cAAc;AAAA,UAC1B;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEO,WAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,aACC,MAAW;AAEX,WAAO,KAAK,iBAAiB,IAAI,KAAK,CAAA;AAAA,EACvC;AAAA,EAEA,YACC,OACA,WAA0B;AAEnB,WAAA;AAAA,MACN,MAAM,CAAC,MAAM,WAAW,CAAC,IAAI,MAAK;AAC3B,cAAA,eAAgB,IAClB,SACA;AACH,iBAAO,OAAO,GAAG,MAAM,GAAG,SAAS;AAAA,QAAA;AAGpC,cAAM,eAAe;AAAA,UACpB,GAAG;AAAA,UACH,UAAU;AAAA,QAAA;AAGX,eAAO,KAAK;AAAA,UACX;AAAA,UACA;AAAA,UACA;AAAA;AAAA,UAEA;AAAA,QAAA;AAAA,MAEF;AAAA,MACA,QAAQ,CAAC,MAAM,WAAU;;AACxB,aAAK,iBAAiB,IAAI,KAAI,UAAK,iBAAiB,IAAI,MAA1B,mBAA6B,OAC1D,CAAC,mBAAmB,eAAe,KAAK,aAAa;AAAA,MAEvD;AAAA,IAAA;AAAA,EAEF;AACA;;;"}
1
+ {"version":3,"file":"HookSystem.cjs","sources":["../../../src/lib/HookSystem.ts"],"sourcesContent":["/**\n * Extends a function arguments with extra ones.\n */\ntype FnWithExtraArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tF extends (...args: any[]) => any,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTExtraArgs extends any[] = any[],\n> = (\n\t...args: [...args: Parameters<F>, ...extraArgs: TExtraArgs]\n) => ReturnType<F>;\n\n/**\n * Defines a hook handler.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type HookFn<TArgs extends any[] = any[], TReturn = any> = (\n\t...args: TArgs\n) => Promise<TReturn> | TReturn;\n\n/**\n * Generic hook metadata.\n */\ntype HookMeta = Record<string, unknown>;\n\n/**\n * Defines a hook, including its function handler and optional metadata.\n */\nexport type Hook<\n\tTHookFn extends HookFn = HookFn,\n\tTHookMeta extends HookMeta = HookMeta,\n> = {\n\tfn: THookFn;\n\tmeta?: THookMeta;\n};\n\n/**\n * Represents a map of hook types to hook functions and metas.\n */\ntype Hooks = Record<string, Hook>;\n\n/**\n * Builds hook meta arguments after hook meta requirements.\n */\ntype HookMetaArg<THookMeta extends Record<string, unknown> | undefined> =\n\tTHookMeta extends Record<string, unknown>\n\t\t? [meta: THookMeta]\n\t\t: [meta?: never];\n\n/**\n * Defines the return type of the {@link HookSystem.callHook} functions.\n *\n * @internal\n */\nexport type CallHookReturnType<THookFn extends HookFn = HookFn> = Promise<{\n\tdata: Awaited<ReturnType<THookFn>>[];\n\terrors: HookError[];\n}>;\n\n/**\n * Defines the return type of the {@link HookSystem.createScope} functions.\n *\n * @internal\n */\nexport type CreateScopeReturnType<\n\tTHooks extends Hooks = Record<string, { fn: HookFn }>,\n\tTExtraArgs extends unknown[] = never[],\n> = {\n\thook: <TType extends keyof THooks>(\n\t\ttype: TType,\n\t\thookFn: FnWithExtraArgs<THooks[TType][\"fn\"], TExtraArgs>,\n\t\t...[meta]: HookMetaArg<THooks[TType][\"meta\"]>\n\t) => void;\n\tunhook: HookSystem<{\n\t\t[P in keyof THooks]: Omit<THooks[P], \"fn\"> & {\n\t\t\tfn: FnWithExtraArgs<THooks[P][\"fn\"], TExtraArgs>;\n\t\t};\n\t}>[\"unhook\"];\n};\n\ntype RegisteredHookMeta = {\n\tid: string;\n\ttype: string;\n\towner: string;\n\texternal?: HookFn;\n};\n\n/**\n * Represents a registered hook.\n */\ntype RegisteredHook<THook extends Hook = Hook> = {\n\tfn: THook[\"fn\"];\n\tmeta: THook[\"meta\"] extends Record<string, unknown>\n\t\t? RegisteredHookMeta & THook[\"meta\"]\n\t\t: RegisteredHookMeta;\n};\n\nexport class HookError<TError = Error | unknown> extends Error {\n\ttype: string;\n\towner: string;\n\trawMeta: RegisteredHookMeta;\n\trawCause: TError;\n\n\tconstructor(meta: RegisteredHookMeta, cause: TError) {\n\t\tsuper(\n\t\t\t`Error in \\`${meta.owner}\\` during \\`${meta.type}\\` hook: ${\n\t\t\t\tcause instanceof Error ? cause.message : String(cause)\n\t\t\t}`,\n\t\t);\n\n\t\tthis.type = meta.type;\n\t\tthis.owner = meta.owner;\n\t\tthis.rawMeta = meta;\n\t\tthis.rawCause = cause;\n\t\tthis.cause = cause instanceof Error ? cause : undefined;\n\t}\n}\n\nconst uuid = (): string => {\n\treturn (++uuid.i).toString();\n};\nuuid.i = 0;\n\n/**\n * @internal\n */\nexport class HookSystem<THooks extends Hooks = Hooks> {\n\tprivate _registeredHooks: {\n\t\t[K in keyof THooks]?: RegisteredHook<THooks[K]>[];\n\t} = {};\n\n\thook<TType extends keyof THooks>(\n\t\towner: string,\n\t\ttype: TType,\n\t\thookFn: THooks[TType][\"fn\"],\n\t\t...[meta]: HookMetaArg<THooks[TType][\"meta\"]>\n\t): void {\n\t\tconst registeredHook = {\n\t\t\tfn: hookFn,\n\t\t\tmeta: {\n\t\t\t\t...meta,\n\t\t\t\towner,\n\t\t\t\ttype,\n\t\t\t\tid: uuid(),\n\t\t\t},\n\t\t} as RegisteredHook<THooks[TType]>;\n\n\t\tconst registeredHooksForType = this._registeredHooks[type];\n\n\t\tif (registeredHooksForType) {\n\t\t\tregisteredHooksForType.push(registeredHook);\n\t\t} else {\n\t\t\tthis._registeredHooks[type] = [registeredHook];\n\t\t}\n\t}\n\n\tunhook<TType extends keyof THooks>(\n\t\ttype: TType,\n\t\thookFn: THooks[TType][\"fn\"],\n\t): void {\n\t\tthis._registeredHooks[type] = this._registeredHooks[type]?.filter(\n\t\t\t(registeredHook) => registeredHook.fn !== hookFn,\n\t\t);\n\t}\n\n\tasync callHook<TType extends Extract<keyof THooks, string>>(\n\t\ttypeOrTypeAndHookID: TType | { type: TType; hookID: string },\n\t\t...args: Parameters<THooks[TType][\"fn\"]>\n\t): CallHookReturnType<THooks[TType][\"fn\"]> {\n\t\tlet hooks: RegisteredHook<THooks[TType]>[];\n\n\t\tif (typeof typeOrTypeAndHookID === \"string\") {\n\t\t\thooks = this._registeredHooks[typeOrTypeAndHookID] ?? [];\n\t\t} else {\n\t\t\tconst hookForID = this._registeredHooks[typeOrTypeAndHookID.type]?.find(\n\t\t\t\t(hook) => hook.meta.id === typeOrTypeAndHookID.hookID,\n\t\t\t);\n\n\t\t\tif (hookForID) {\n\t\t\t\thooks = [hookForID];\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hook of type \\`${typeOrTypeAndHookID.type}\\` with ID \\`${typeOrTypeAndHookID.hookID}\\` not found.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst promises = hooks.map(async (hook) => {\n\t\t\ttry {\n\t\t\t\treturn await hook.fn(...args);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new HookError(hook.meta, error);\n\t\t\t}\n\t\t});\n\n\t\tconst settledPromises = await Promise.allSettled(promises);\n\n\t\treturn settledPromises.reduce<{\n\t\t\tdata: Awaited<ReturnType<THooks[TType][\"fn\"]>>[];\n\t\t\terrors: HookError[];\n\t\t}>(\n\t\t\t(acc, settledPromise) => {\n\t\t\t\tif (settledPromise.status === \"fulfilled\") {\n\t\t\t\t\tacc.data.push(settledPromise.value);\n\t\t\t\t} else {\n\t\t\t\t\tacc.errors.push(settledPromise.reason);\n\t\t\t\t}\n\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{ data: [], errors: [] },\n\t\t);\n\t}\n\n\t/**\n\t * Returns list of hooks for a given owner\n\t */\n\thooksForOwner(owner: string): RegisteredHook<THooks[string]>[] {\n\t\tconst hooks: RegisteredHook<THooks[string]>[] = [];\n\n\t\tfor (const hookType in this._registeredHooks) {\n\t\t\tconst registeredHooks = this._registeredHooks[hookType];\n\n\t\t\tif (Array.isArray(registeredHooks)) {\n\t\t\t\tfor (const registeredHook of registeredHooks) {\n\t\t\t\t\tif (registeredHook.meta.owner === owner) {\n\t\t\t\t\t\thooks.push(registeredHook);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn hooks;\n\t}\n\n\t/**\n\t * Returns list of hooks for a given type\n\t */\n\thooksForType<TType extends keyof THooks>(\n\t\ttype: TType,\n\t): RegisteredHook<THooks[TType]>[] {\n\t\treturn this._registeredHooks[type] ?? [];\n\t}\n\n\tcreateScope<TExtraArgs extends unknown[] = never[]>(\n\t\towner: string,\n\t\textraArgs: [...TExtraArgs],\n\t): CreateScopeReturnType<THooks, TExtraArgs> {\n\t\treturn {\n\t\t\thook: (type, hookFn, ...[meta]) => {\n\t\t\t\tconst internalHook = ((\n\t\t\t\t\t...args: Parameters<THooks[typeof type][\"fn\"]>\n\t\t\t\t) => {\n\t\t\t\t\treturn hookFn(...args, ...extraArgs);\n\t\t\t\t}) as THooks[typeof type][\"fn\"];\n\n\t\t\t\tconst resolvedMeta = {\n\t\t\t\t\t...meta,\n\t\t\t\t\texternal: hookFn,\n\t\t\t\t} as HookMetaArg<THooks[typeof type][\"meta\"]>[0];\n\n\t\t\t\treturn this.hook(\n\t\t\t\t\towner,\n\t\t\t\t\ttype,\n\t\t\t\t\tinternalHook,\n\t\t\t\t\t// @ts-expect-error - TypeScript fails to assert rest argument.\n\t\t\t\t\tresolvedMeta,\n\t\t\t\t);\n\t\t\t},\n\t\t\tunhook: (type, hookFn) => {\n\t\t\t\tthis._registeredHooks[type] = this._registeredHooks[type]?.filter(\n\t\t\t\t\t(registeredHook) => registeredHook.meta.external !== hookFn,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;AAiGM,MAAO,kBAA4C,MAAK;AAAA,EAM7D,YAAY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pC,cAAM,eAAe;AAAA,UACpB,GAAG;AAAA,UACH,UAAU;AAAA,QAAA;AAGX,eAAO,KAAK;AAAA,UACX;AAAA,UACA;AAAA,UACA;AAAA;AAAA,UAEA;AAAA,QAAA;AAAA,MAEF;AAAA,MACA,QAAQ,CAAC,MAAM,WAAU;;AACxB,aAAK,iBAAiB,IAAI,KAAI,UAAK,iBAAiB,IAAI,MAA1B,mBAA6B,OAC1D,CAAC,mBAAmB,eAAe,KAAK,aAAa;AAAA,MAEvD;AAAA,IAAA;AAAA,EAEF;AACA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"HookSystem.js","sources":["../../../src/lib/HookSystem.ts"],"sourcesContent":["/**\n * Extends a function arguments with extra ones.\n */\ntype FnWithExtraArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tF extends (...args: any[]) => any,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTExtraArgs extends any[] = any[],\n> = (\n\t...args: [...args: Parameters<F>, ...extraArgs: TExtraArgs]\n) => ReturnType<F>;\n\n/**\n * Defines a hook handler.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type HookFn<TArgs extends any[] = any[], TReturn = any> = (\n\t...args: TArgs\n) => Promise<TReturn> | TReturn;\n\n/**\n * Generic hook metadata.\n */\ntype HookMeta = Record<string, unknown>;\n\n/**\n * Defines a hook, including its function handler and optional metadata.\n */\nexport type Hook<\n\tTHookFn extends HookFn = HookFn,\n\tTHookMeta extends HookMeta = HookMeta,\n> = {\n\tfn: THookFn;\n\tmeta?: THookMeta;\n};\n\n/**\n * Represents a map of hook types to hook functions and metas.\n */\ntype Hooks = Record<string, Hook>;\n\n/**\n * Builds hook meta arguments after hook meta requirements.\n */\ntype HookMetaArg<THookMeta extends Record<string, unknown> | undefined> =\n\tTHookMeta extends Record<string, unknown>\n\t\t? [meta: THookMeta]\n\t\t: [meta?: never];\n\n/**\n * Defines the return type of the {@link HookSystem.callHook} functions.\n *\n * @internal\n */\nexport type CallHookReturnType<THookFn extends HookFn = HookFn> = Promise<{\n\tdata: Awaited<ReturnType<THookFn>>[];\n\terrors: HookError[];\n}>;\n\n/**\n * Defines the return type of the {@link HookSystem.createScope} functions.\n *\n * @internal\n */\nexport type CreateScopeReturnType<\n\tTHooks extends Hooks = Record<string, { fn: HookFn }>,\n\tTExtraArgs extends unknown[] = never[],\n> = {\n\thook: <TType extends keyof THooks>(\n\t\ttype: TType,\n\t\thookFn: FnWithExtraArgs<THooks[TType][\"fn\"], TExtraArgs>,\n\t\t...[meta]: HookMetaArg<THooks[TType][\"meta\"]>\n\t) => void;\n\tunhook: HookSystem<{\n\t\t[P in keyof THooks]: Omit<THooks[P], \"fn\"> & {\n\t\t\tfn: FnWithExtraArgs<THooks[P][\"fn\"], TExtraArgs>;\n\t\t};\n\t}>[\"unhook\"];\n};\n\ntype RegisteredHookMeta = {\n\tid: string;\n\ttype: string;\n\towner: string;\n\texternal?: HookFn;\n};\n\n/**\n * Represents a registered hook.\n */\ntype RegisteredHook<THook extends Hook = Hook> = {\n\tfn: THook[\"fn\"];\n\tmeta: THook[\"meta\"] extends Record<string, unknown>\n\t\t? RegisteredHookMeta & THook[\"meta\"]\n\t\t: RegisteredHookMeta;\n};\n\nexport class HookError<TError = Error | unknown> extends Error {\n\ttype: string;\n\towner: string;\n\trawMeta: RegisteredHookMeta;\n\trawCause: TError;\n\n\tconstructor(meta: RegisteredHookMeta, cause: TError) {\n\t\tsuper(\n\t\t\t`Error in \\`${meta.owner}\\` during \\`${meta.type}\\` hook: ${\n\t\t\t\tcause instanceof Error ? cause.message : String(cause)\n\t\t\t}`,\n\t\t);\n\n\t\tthis.type = meta.type;\n\t\tthis.owner = meta.owner;\n\t\tthis.rawMeta = meta;\n\t\tthis.rawCause = cause;\n\t\tthis.cause = cause instanceof Error ? cause : undefined;\n\t}\n}\n\nconst uuid = (): string => {\n\treturn (++uuid.i).toString();\n};\nuuid.i = 0;\n\n/**\n * @internal\n */\nexport class HookSystem<THooks extends Hooks = Hooks> {\n\tprivate _registeredHooks: {\n\t\t[K in keyof THooks]?: RegisteredHook<THooks[K]>[];\n\t} = {};\n\n\thook<TType extends keyof THooks>(\n\t\towner: string,\n\t\ttype: TType,\n\t\thookFn: THooks[TType][\"fn\"],\n\t\t...[meta]: HookMetaArg<THooks[TType][\"meta\"]>\n\t): void {\n\t\tconst registeredHook = {\n\t\t\tfn: hookFn,\n\t\t\tmeta: {\n\t\t\t\t...meta,\n\t\t\t\towner,\n\t\t\t\ttype,\n\t\t\t\tid: uuid(),\n\t\t\t},\n\t\t} as RegisteredHook<THooks[TType]>;\n\n\t\tconst registeredHooksForType = this._registeredHooks[type];\n\n\t\tif (registeredHooksForType) {\n\t\t\tregisteredHooksForType.push(registeredHook);\n\t\t} else {\n\t\t\tthis._registeredHooks[type] = [registeredHook];\n\t\t}\n\t}\n\n\tunhook<TType extends keyof THooks>(\n\t\ttype: TType,\n\t\thookFn: THooks[TType][\"fn\"],\n\t): void {\n\t\tthis._registeredHooks[type] = this._registeredHooks[type]?.filter(\n\t\t\t(registeredHook) => registeredHook.fn !== hookFn,\n\t\t);\n\t}\n\n\tasync callHook<TType extends Extract<keyof THooks, string>>(\n\t\ttypeOrTypeAndHookID: TType | { type: TType; hookID: string },\n\t\t...args: Parameters<THooks[TType][\"fn\"]>\n\t): CallHookReturnType<THooks[TType][\"fn\"]> {\n\t\tlet hooks: RegisteredHook<THooks[TType]>[];\n\n\t\tif (typeof typeOrTypeAndHookID === \"string\") {\n\t\t\thooks = this._registeredHooks[typeOrTypeAndHookID] ?? [];\n\t\t} else {\n\t\t\tconst hookForID = this._registeredHooks[typeOrTypeAndHookID.type]?.find(\n\t\t\t\t(hook) => hook.meta.id === typeOrTypeAndHookID.hookID,\n\t\t\t);\n\n\t\t\tif (hookForID) {\n\t\t\t\thooks = [hookForID];\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hook of type \\`${typeOrTypeAndHookID.type}\\` with ID \\`${typeOrTypeAndHookID.hookID}\\` not found.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst promises = hooks.map(async (hook) => {\n\t\t\ttry {\n\t\t\t\treturn await hook.fn(...args);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new HookError(hook.meta, error);\n\t\t\t}\n\t\t});\n\n\t\tconst settledPromises = await Promise.allSettled(promises);\n\n\t\treturn settledPromises.reduce<{\n\t\t\tdata: Awaited<ReturnType<THooks[TType][\"fn\"]>>[];\n\t\t\terrors: HookError[];\n\t\t}>(\n\t\t\t(acc, settledPromise) => {\n\t\t\t\tif (settledPromise.status === \"fulfilled\") {\n\t\t\t\t\tacc.data.push(settledPromise.value);\n\t\t\t\t} else {\n\t\t\t\t\tacc.errors.push(settledPromise.reason);\n\t\t\t\t}\n\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{ data: [], errors: [] },\n\t\t);\n\t}\n\n\t/**\n\t * Returns list of hooks for a given owner\n\t */\n\thooksForOwner(owner: string): RegisteredHook<THooks[string]>[] {\n\t\tconst hooks: RegisteredHook<THooks[string]>[] = [];\n\n\t\tfor (const hookType in this._registeredHooks) {\n\t\t\tconst registeredHooks = this._registeredHooks[hookType];\n\n\t\t\tif (Array.isArray(registeredHooks)) {\n\t\t\t\tfor (const registeredHook of registeredHooks) {\n\t\t\t\t\tif (registeredHook.meta.owner === owner) {\n\t\t\t\t\t\thooks.push(registeredHook);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn hooks;\n\t}\n\n\t/**\n\t * Returns list of hooks for a given type\n\t */\n\thooksForType<TType extends keyof THooks>(\n\t\ttype: TType,\n\t): RegisteredHook<THooks[TType]>[] {\n\t\treturn this._registeredHooks[type] ?? [];\n\t}\n\n\tcreateScope<TExtraArgs extends unknown[] = never[]>(\n\t\towner: string,\n\t\textraArgs: [...TExtraArgs],\n\t): CreateScopeReturnType<THooks, TExtraArgs> {\n\t\treturn {\n\t\t\thook: (type, hookFn, ...[meta]) => {\n\t\t\t\tconst internalHook = ((\n\t\t\t\t\t...args: Parameters<THooks[typeof type][\"fn\"]>\n\t\t\t\t) => {\n\t\t\t\t\treturn hookFn(...args, ...extraArgs);\n\t\t\t\t}) as THooks[typeof type][\"fn\"];\n\n\t\t\t\tconst resolvedMeta = {\n\t\t\t\t\t...meta,\n\t\t\t\t\texternal: hookFn,\n\t\t\t\t} as HookMetaArg<THooks[typeof type][\"meta\"]>[0];\n\n\t\t\t\treturn this.hook(\n\t\t\t\t\towner,\n\t\t\t\t\ttype,\n\t\t\t\t\tinternalHook,\n\t\t\t\t\t// @ts-expect-error - TypeScript fails to assert rest argument.\n\t\t\t\t\tresolvedMeta,\n\t\t\t\t);\n\t\t\t},\n\t\t\tunhook: (type, hookFn) => {\n\t\t\t\tthis._registeredHooks[type] = this._registeredHooks[type]?.filter(\n\t\t\t\t\t(registeredHook) => registeredHook.meta.external !== hookFn,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAiGM,MAAO,kBAA4C,MAAK;AAAA,EAM7D,YAAY,MAA0B,OAAa;AAEjD,UAAA,cAAc,KAAK,oBAAoB,KAAK,gBAC3C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACpD;AATJ;AACA;AACA;AACA;AASC,SAAK,OAAO,KAAK;AACjB,SAAK,QAAQ,KAAK;AAClB,SAAK,UAAU;AACf,SAAK,WAAW;AACX,SAAA,QAAQ,iBAAiB,QAAQ,QAAQ;AAAA,EAC/C;AACA;AAED,MAAM,OAAO,MAAa;AACjB,UAAA,EAAE,KAAK,GAAG,SAAQ;AAC3B;AACA,KAAK,IAAI;MAKI,WAAU;AAAA;AACd,4CAEJ,CAAA;AAAA;AAAA,EAEJ,KACC,OACA,MACA,WACG,CAAC,IAAI,GAAqC;AAE7C,UAAM,iBAAiB;AAAA,MACtB,IAAI;AAAA,MACJ,MAAM;AAAA,QACL,GAAG;AAAA,QACH;A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AAE,MAAM,CAAA,GAAI,QAAQ,CAAA,EAAI,CAAA;AAAA,EAE1B;AAAA;AAAA;AAAA;AAAA,EAKA,cAAc,OAAa;AAC1B,UAAM,QAA0C,CAAA;AAErC,eAAA,YAAY,KAAK,kBAAkB;AACvC,YAAA,kBAAkB,KAAK,iBAAiB,QAAQ;AAElD,UAAA,MAAM,QAAQ,eAAe,GAAG;AACnC,mBAAW,kBAAkB,iBAAiB;AACzC,cAAA,eAAe,KAAK,UAAU,OAAO;AACxC,kBAAM,KAAK,cAAc;AAAA,UAC1B;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEO,WAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,aACC,MAAW;AAEX,WAAO,KAAK,iBAAiB,IAAI,KAAK,CAAA;AAAA,EACvC;AAAA,EAEA,YACC,OACA,WAA0B;AAEnB,WAAA;AAAA,MACN,MAAM,CAAC,MAAM,WAAW,CAAC,IAAI,MAAK;AAC3B,cAAA,eAAgB,IAClB,SACA;AACH,iBAAO,OAAO,GAAG,MAAM,GAAG,SAAS;AAAA,QAAA;AAGpC,cAAM,eAAe;AAAA,UACpB,GAAG;AAAA,UACH,UAAU;AAAA,QAAA;AAGX,eAAO,KAAK;AAAA,UACX;AAAA,UACA;AAAA,UACA;AAAA;AAAA,UAEA;AAAA,QAAA;AAAA,MAEF;AAAA,MACA,QAAQ,CAAC,MAAM,WAAU;AA5KtB;AA6KF,aAAK,iBAAiB,IAAI,KAAI,UAAK,iBAAiB,IAAI,MAA1B,mBAA6B,OAC1D,CAAC,mBAAmB,eAAe,KAAK,aAAa;AAAA,MAEvD;AAAA,IAAA;AAAA,EAEF;AACA;"}
1
+ {"version":3,"file":"HookSystem.js","sources":["../../../src/lib/HookSystem.ts"],"sourcesContent":["/**\n * Extends a function arguments with extra ones.\n */\ntype FnWithExtraArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tF extends (...args: any[]) => any,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTExtraArgs extends any[] = any[],\n> = (\n\t...args: [...args: Parameters<F>, ...extraArgs: TExtraArgs]\n) => ReturnType<F>;\n\n/**\n * Defines a hook handler.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type HookFn<TArgs extends any[] = any[], TReturn = any> = (\n\t...args: TArgs\n) => Promise<TReturn> | TReturn;\n\n/**\n * Generic hook metadata.\n */\ntype HookMeta = Record<string, unknown>;\n\n/**\n * Defines a hook, including its function handler and optional metadata.\n */\nexport type Hook<\n\tTHookFn extends HookFn = HookFn,\n\tTHookMeta extends HookMeta = HookMeta,\n> = {\n\tfn: THookFn;\n\tmeta?: THookMeta;\n};\n\n/**\n * Represents a map of hook types to hook functions and metas.\n */\ntype Hooks = Record<string, Hook>;\n\n/**\n * Builds hook meta arguments after hook meta requirements.\n */\ntype HookMetaArg<THookMeta extends Record<string, unknown> | undefined> =\n\tTHookMeta extends Record<string, unknown>\n\t\t? [meta: THookMeta]\n\t\t: [meta?: never];\n\n/**\n * Defines the return type of the {@link HookSystem.callHook} functions.\n *\n * @internal\n */\nexport type CallHookReturnType<THookFn extends HookFn = HookFn> = Promise<{\n\tdata: Awaited<ReturnType<THookFn>>[];\n\terrors: HookError[];\n}>;\n\n/**\n * Defines the return type of the {@link HookSystem.createScope} functions.\n *\n * @internal\n */\nexport type CreateScopeReturnType<\n\tTHooks extends Hooks = Record<string, { fn: HookFn }>,\n\tTExtraArgs extends unknown[] = never[],\n> = {\n\thook: <TType extends keyof THooks>(\n\t\ttype: TType,\n\t\thookFn: FnWithExtraArgs<THooks[TType][\"fn\"], TExtraArgs>,\n\t\t...[meta]: HookMetaArg<THooks[TType][\"meta\"]>\n\t) => void;\n\tunhook: HookSystem<{\n\t\t[P in keyof THooks]: Omit<THooks[P], \"fn\"> & {\n\t\t\tfn: FnWithExtraArgs<THooks[P][\"fn\"], TExtraArgs>;\n\t\t};\n\t}>[\"unhook\"];\n};\n\ntype RegisteredHookMeta = {\n\tid: string;\n\ttype: string;\n\towner: string;\n\texternal?: HookFn;\n};\n\n/**\n * Represents a registered hook.\n */\ntype RegisteredHook<THook extends Hook = Hook> = {\n\tfn: THook[\"fn\"];\n\tmeta: THook[\"meta\"] extends Record<string, unknown>\n\t\t? RegisteredHookMeta & THook[\"meta\"]\n\t\t: RegisteredHookMeta;\n};\n\nexport class HookError<TError = Error | unknown> extends Error {\n\ttype: string;\n\towner: string;\n\trawMeta: RegisteredHookMeta;\n\trawCause: TError;\n\n\tconstructor(meta: RegisteredHookMeta, cause: TError) {\n\t\tsuper(\n\t\t\t`Error in \\`${meta.owner}\\` during \\`${meta.type}\\` hook: ${\n\t\t\t\tcause instanceof Error ? cause.message : String(cause)\n\t\t\t}`,\n\t\t);\n\n\t\tthis.type = meta.type;\n\t\tthis.owner = meta.owner;\n\t\tthis.rawMeta = meta;\n\t\tthis.rawCause = cause;\n\t\tthis.cause = cause instanceof Error ? cause : undefined;\n\t}\n}\n\nconst uuid = (): string => {\n\treturn (++uuid.i).toString();\n};\nuuid.i = 0;\n\n/**\n * @internal\n */\nexport class HookSystem<THooks extends Hooks = Hooks> {\n\tprivate _registeredHooks: {\n\t\t[K in keyof THooks]?: RegisteredHook<THooks[K]>[];\n\t} = {};\n\n\thook<TType extends keyof THooks>(\n\t\towner: string,\n\t\ttype: TType,\n\t\thookFn: THooks[TType][\"fn\"],\n\t\t...[meta]: HookMetaArg<THooks[TType][\"meta\"]>\n\t): void {\n\t\tconst registeredHook = {\n\t\t\tfn: hookFn,\n\t\t\tmeta: {\n\t\t\t\t...meta,\n\t\t\t\towner,\n\t\t\t\ttype,\n\t\t\t\tid: uuid(),\n\t\t\t},\n\t\t} as RegisteredHook<THooks[TType]>;\n\n\t\tconst registeredHooksForType = this._registeredHooks[type];\n\n\t\tif (registeredHooksForType) {\n\t\t\tregisteredHooksForType.push(registeredHook);\n\t\t} else {\n\t\t\tthis._registeredHooks[type] = [registeredHook];\n\t\t}\n\t}\n\n\tunhook<TType extends keyof THooks>(\n\t\ttype: TType,\n\t\thookFn: THooks[TType][\"fn\"],\n\t): void {\n\t\tthis._registeredHooks[type] = this._registeredHooks[type]?.filter(\n\t\t\t(registeredHook) => registeredHook.fn !== hookFn,\n\t\t);\n\t}\n\n\tasync callHook<TType extends Extract<keyof THooks, string>>(\n\t\ttypeOrTypeAndHookID: TType | { type: TType; hookID: string },\n\t\t...args: Parameters<THooks[TType][\"fn\"]>\n\t): CallHookReturnType<THooks[TType][\"fn\"]> {\n\t\tlet hooks: RegisteredHook<THooks[TType]>[];\n\n\t\tif (typeof typeOrTypeAndHookID === \"string\") {\n\t\t\thooks = this._registeredHooks[typeOrTypeAndHookID] ?? [];\n\t\t} else {\n\t\t\tconst hookForID = this._registeredHooks[typeOrTypeAndHookID.type]?.find(\n\t\t\t\t(hook) => hook.meta.id === typeOrTypeAndHookID.hookID,\n\t\t\t);\n\n\t\t\tif (hookForID) {\n\t\t\t\thooks = [hookForID];\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hook of type \\`${typeOrTypeAndHookID.type}\\` with ID \\`${typeOrTypeAndHookID.hookID}\\` not found.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst promises = hooks.map(async (hook) => {\n\t\t\ttry {\n\t\t\t\treturn await hook.fn(...args);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new HookError(hook.meta, error);\n\t\t\t}\n\t\t});\n\n\t\tconst settledPromises = await Promise.allSettled(promises);\n\n\t\treturn settledPromises.reduce<{\n\t\t\tdata: Awaited<ReturnType<THooks[TType][\"fn\"]>>[];\n\t\t\terrors: HookError[];\n\t\t}>(\n\t\t\t(acc, settledPromise) => {\n\t\t\t\tif (settledPromise.status === \"fulfilled\") {\n\t\t\t\t\tacc.data.push(settledPromise.value);\n\t\t\t\t} else {\n\t\t\t\t\tacc.errors.push(settledPromise.reason);\n\t\t\t\t}\n\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{ data: [], errors: [] },\n\t\t);\n\t}\n\n\t/**\n\t * Returns list of hooks for a given owner\n\t */\n\thooksForOwner(owner: string): RegisteredHook<THooks[string]>[] {\n\t\tconst hooks: RegisteredHook<THooks[string]>[] = [];\n\n\t\tfor (const hookType in this._registeredHooks) {\n\t\t\tconst registeredHooks = this._registeredHooks[hookType];\n\n\t\t\tif (Array.isArray(registeredHooks)) {\n\t\t\t\tfor (const registeredHook of registeredHooks) {\n\t\t\t\t\tif (registeredHook.meta.owner === owner) {\n\t\t\t\t\t\thooks.push(registeredHook);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn hooks;\n\t}\n\n\t/**\n\t * Returns list of hooks for a given type\n\t */\n\thooksForType<TType extends keyof THooks>(\n\t\ttype: TType,\n\t): RegisteredHook<THooks[TType]>[] {\n\t\treturn this._registeredHooks[type] ?? [];\n\t}\n\n\tcreateScope<TExtraArgs extends unknown[] = never[]>(\n\t\towner: string,\n\t\textraArgs: [...TExtraArgs],\n\t): CreateScopeReturnType<THooks, TExtraArgs> {\n\t\treturn {\n\t\t\thook: (type, hookFn, ...[meta]) => {\n\t\t\t\tconst internalHook = ((\n\t\t\t\t\t...args: Parameters<THooks[typeof type][\"fn\"]>\n\t\t\t\t) => {\n\t\t\t\t\treturn hookFn(...args, ...extraArgs);\n\t\t\t\t}) as THooks[typeof type][\"fn\"];\n\n\t\t\t\tconst resolvedMeta = {\n\t\t\t\t\t...meta,\n\t\t\t\t\texternal: hookFn,\n\t\t\t\t} as HookMetaArg<THooks[typeof type][\"meta\"]>[0];\n\n\t\t\t\treturn this.hook(\n\t\t\t\t\towner,\n\t\t\t\t\ttype,\n\t\t\t\t\tinternalHook,\n\t\t\t\t\t// @ts-expect-error - TypeScript fails to assert rest argument.\n\t\t\t\t\tresolvedMeta,\n\t\t\t\t);\n\t\t\t},\n\t\t\tunhook: (type, hookFn) => {\n\t\t\t\tthis._registeredHooks[type] = this._registeredHooks[type]?.filter(\n\t\t\t\t\t(regist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AAEnB,WAAA;AAAA,MACN,MAAM,CAAC,MAAM,WAAW,CAAC,IAAI,MAAK;AAC3B,cAAA,eAAgB,IAClB,SACA;AACH,iBAAO,OAAO,GAAG,MAAM,GAAG,SAAS;AAAA,QAAA;AAGpC,cAAM,eAAe;AAAA,UACpB,GAAG;AAAA,UACH,UAAU;AAAA,QAAA;AAGX,eAAO,KAAK;AAAA,UACX;AAAA,UACA;AAAA,UACA;AAAA;AAAA,UAEA;AAAA,QAAA;AAAA,MAEF;AAAA,MACA,QAAQ,CAAC,MAAM,WAAU;AA5KtB;AA6KF,aAAK,iBAAiB,IAAI,KAAI,UAAK,iBAAiB,IAAI,MAA1B,mBAA6B,OAC1D,CAAC,mBAAmB,eAAe,KAAK,aAAa;AAAA,MAEvD;AAAA,IAAA;AAAA,EAEF;AACA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/plugin-kit",
3
- "version": "0.4.77-beta.9",
3
+ "version": "0.4.78-alpha.jp-fix-cr-modal-rules-of-hooks.1",
4
4
  "description": "A set of helpers to develop and run Slice Machine plugins",
5
5
  "keywords": [
6
6
  "typescript",
@@ -94,7 +94,7 @@
94
94
  "prettier-plugin-jsdoc": "1.1.1",
95
95
  "size-limit": "8.2.4",
96
96
  "typescript": "4.9.5",
97
- "vite": "4.3.9",
97
+ "vite": "4.5.14",
98
98
  "vite-plugin-sdk": "0.1.1",
99
99
  "vitest": "0.32.0"
100
100
  },
@@ -104,5 +104,5 @@
104
104
  "publishConfig": {
105
105
  "access": "public"
106
106
  },
107
- "stableVersion": "0.4.76"
107
+ "stableVersion": "0.4.77"
108
108
  }