@slicemachine/plugin-kit 0.4.38-alpha.aa-dt-1875.2 → 0.4.38-alpha.feat-responsive-menu.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.
- package/dist/createSliceMachinePluginRunner.cjs +1 -0
- package/dist/createSliceMachinePluginRunner.cjs.map +1 -1
- package/dist/createSliceMachinePluginRunner.js +1 -0
- package/dist/createSliceMachinePluginRunner.js.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.d.ts +43 -0
- package/dist/index.d.ts +1 -0
- package/dist/types.cjs +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/createSliceMachinePluginRunner.ts +1 -0
- package/src/hooks/sliceSimulator-setup-read.ts +63 -0
- package/src/index.ts +9 -0
- package/src/types.ts +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSliceMachinePluginRunner.cjs","sources":["../../src/createSliceMachinePluginRunner.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { 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 raw = await createRequire(\n\t\t\t\t\tpath.resolve(this._project.root, \"noop.js\"),\n\t\t\t\t)(resolve);\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","createRequire","path","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;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,aAAaA,oDACjB,KAAK,UACL,KAAK,WAAW;AAEZ,SAAA,aAAaC,0BAAAA,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,EACtE;AAAA,EAEQ,MAAM,YACb,oBAAwD;AAGxD,UAAM,EAAE,SAAS,UAAU,OAC1B,OAAO,uBAAuB,YAAY,aAAa,qBACpD,qBACA,EAAE,SAAS;AAEf,QAAI,SAAyC;AAEzC,QAAA,OAAO,YAAY,UAAU;AAE5B,UAAA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ACT,YAAY,OAAO,KAAK,gCAAgC,OAAO;AAAA,MAEhE;AAAA,IACD;AAAA,EACF;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,IAExD;AAAA,EACF;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 { 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\"slice-simulator:setup: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 raw = await createRequire(\n\t\t\t\t\tpath.resolve(this._project.root, \"noop.js\"),\n\t\t\t\t)(resolve);\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","createRequire","path","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;AAAA,EACA;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,aAAaA,oDACjB,KAAK,UACL,KAAK,WAAW;AAEZ,SAAA,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,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 { 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 raw = await createRequire(\n\t\t\t\t\tpath.resolve(this._project.root, \"noop.js\"),\n\t\t\t\t)(resolve);\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,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AC,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 { 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\"slice-simulator:setup: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 raw = await createRequire(\n\t\t\t\t\tpath.resolve(this._project.root, \"noop.js\"),\n\t\t\t\t)(resolve);\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":";;;;;;;;;;;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Q,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,IAExD;AAAA,EACF;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,aAAa;AAEnB,SAAO,IAAI,yBAAyB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ExtendSliceMachineHook, SliceMachinePluginOptions, Promisable, SliceMachineHook } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* An object representing validation for a Slice Simulator set up step.
|
|
4
|
+
*/
|
|
5
|
+
export type SliceSimulatorSetupStepValidationMessage = {
|
|
6
|
+
title: string;
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* An object representing a step to set up Slice Simulator.
|
|
11
|
+
*/
|
|
12
|
+
export type SliceSimulatorSetupStep = {
|
|
13
|
+
title: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
body: string;
|
|
16
|
+
validate?: () => Promisable<SliceSimulatorSetupStepValidationMessage | SliceSimulatorSetupStepValidationMessage[] | void>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Data provided to `slice-simulator:setup:read` hook handlers.
|
|
20
|
+
*/
|
|
21
|
+
export type SliceSimulatorSetupReadHookData = undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Return value for `slice-simulator:setup:read` hook handlers.
|
|
24
|
+
*/
|
|
25
|
+
export type SliceSimulatorSetupReadHookReturnType = SliceSimulatorSetupStep[];
|
|
26
|
+
/**
|
|
27
|
+
* Base version of a `slice-simulator:setup:read` hook handler without plugin
|
|
28
|
+
* runner context.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export type SliceSimulatorSetupReadHookBase = SliceMachineHook<undefined, SliceSimulatorSetupReadHookReturnType>;
|
|
33
|
+
/**
|
|
34
|
+
* Handler for the `slice-simulator:setup:read` hook. The hook is called when a
|
|
35
|
+
* Slice Simulator set up steps are needed.
|
|
36
|
+
*
|
|
37
|
+
* This hook is **required** to be implemented by adapters.
|
|
38
|
+
*
|
|
39
|
+
* This hook will only be called in adapters.
|
|
40
|
+
*
|
|
41
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
42
|
+
*/
|
|
43
|
+
export type SliceSimulatorSetupReadHook<TPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions> = ExtendSliceMachineHook<SliceSimulatorSetupReadHookBase, TPluginOptions>;
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export type { CustomTypeDeleteHook, CustomTypeDeleteHookData, CustomTypeDeleteHo
|
|
|
26
26
|
export type { CustomTypeReadHook, CustomTypeReadHookData, CustomTypeReadHookReturnType, } from "./hooks/customType-read";
|
|
27
27
|
export type { CustomTypeLibraryReadHook, CustomTypeLibraryReadHookData, CustomTypeLibraryReadHookReturnType, } from "./hooks/customTypeLibrary-read";
|
|
28
28
|
export type { SnippetReadHook, SnippetReadHookData, SnippetReadHookReturnType, Snippet, } from "./hooks/snippet-read";
|
|
29
|
+
export type { SliceSimulatorSetupReadHook, SliceSimulatorSetupReadHookData, SliceSimulatorSetupReadHookReturnType, SliceSimulatorSetupStep, SliceSimulatorSetupStepValidationMessage, } from "./hooks/sliceSimulator-setup-read";
|
|
29
30
|
export type { ProjectEnvironmentReadHook, ProjectEnvironmentReadHookData, ProjectEnvironmentReadHookReturnType, } from "./hooks/project-environment-read";
|
|
30
31
|
export type { ProjectEnvironmentUpdateHook, ProjectEnvironmentUpdateHookData, ProjectEnvironmentUpdateHookReturnType, } from "./hooks/project-environment-update";
|
|
31
32
|
export type { ProjectInitHook, ProjectInitHookData, ProjectInitHookReturnType, } from "./hooks/project-init";
|
package/dist/types.cjs
CHANGED
|
@@ -22,6 +22,7 @@ const SliceMachineHookType = {
|
|
|
22
22
|
documentation_read: "documentation:read",
|
|
23
23
|
sliceTemplateLibrary_read: "slice-template-library:read",
|
|
24
24
|
snippet_read: "snippet:read",
|
|
25
|
+
sliceSimulator_setup_read: "slice-simulator:setup:read",
|
|
25
26
|
project_init: "project:init",
|
|
26
27
|
project_environment_read: "project:environment:read",
|
|
27
28
|
project_environment_update: "project:environment:update",
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sources":["../../src/types.ts"],"sourcesContent":["import { SliceMachineContext } from \"./createSliceMachineContext\";\nimport { SliceMachinePlugin } from \"./defineSliceMachinePlugin\";\nimport { Hook } from \"./lib/HookSystem\";\n\nimport { ProjectInitHookBase } from \"./hooks/project-init\";\nimport { CustomTypeAssetDeleteHookBase } from \"./hooks/customType-asset-delete\";\nimport { CustomTypeAssetReadHookBase } from \"./hooks/customType-asset-read\";\nimport { CustomTypeAssetUpdateHookBase } from \"./hooks/customType-asset-update\";\nimport { CustomTypeCreateHookBase } from \"./hooks/customType-create\";\nimport { CustomTypeDeleteHookBase } from \"./hooks/customType-delete\";\nimport { CustomTypeLibraryReadHookBase } from \"./hooks/customTypeLibrary-read\";\nimport { CustomTypeReadHookBase } from \"./hooks/customType-read\";\nimport { CustomTypeRenameHookBase } from \"./hooks/customType-rename\";\nimport { CustomTypeUpdateHookBase } from \"./hooks/customType-update\";\nimport { DebugHookBase } from \"./hooks/debug\";\nimport { SliceAssetDeleteHookBase } from \"./hooks/slice-asset-delete\";\nimport { SliceAssetReadHookBase } from \"./hooks/slice-asset-read\";\nimport { SliceAssetUpdateHookBase } from \"./hooks/slice-asset-update\";\nimport { SliceCreateHookBase } from \"./hooks/slice-create\";\nimport { SliceDeleteHookBase } from \"./hooks/slice-delete\";\nimport { SliceLibraryReadHookBase } from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookBase } from \"./hooks/slice-read\";\nimport { SliceRenameHookBase } from \"./hooks/slice-rename\";\nimport { SliceUpdateHookBase } from \"./hooks/slice-update\";\nimport { SnippetReadHookBase } from \"./hooks/snippet-read\";\nimport { DocumentationReadHookBase } from \"./hooks/documentation-read\";\n\nimport { SliceTemplateLibraryReadHookBase } from \"./hooks/sliceTemplateLibrary-read\";\nimport { ProjectEnvironmentReadHookBase } from \"./hooks/project-environment-read\";\nimport { ProjectEnvironmentUpdateHookBase } from \"./hooks/project-environment-update\";\n\n/**\n * A value optionally wrapped in a `PromiseLike`.\n *\n * @typeParam T - The value that can optionally be wrapped.\n */\nexport type Promisable<T> = T | PromiseLike<T>;\n\n/**\n * A generic type for a user-provided plugin options. Prefer using a\n * plugin-specific type over this type.\n */\nexport type SliceMachinePluginOptions = Record<string, unknown>;\n\n/**\n * A string, object, or instance representing a registered plugin.\n *\n * @typeParam TPluginOptions - User-provided options for the plugin.\n */\nexport type SliceMachineConfigPluginRegistration<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> =\n\t| string\n\t| SliceMachinePlugin\n\t| {\n\t\t\tresolve: string | SliceMachinePlugin;\n\t\t\toptions?: TPluginOptions;\n\t };\n\n/**\n * Slice Machine configuration from `slicemachine.config.js`.\n */\nexport type SliceMachineConfig = {\n\t// TODO: Can we make `apiEndpoint` optional?\n\tapiEndpoint?: string;\n\t// NOTE: This is a new property.\n\trepositoryName: string;\n\tlocalSliceSimulatorURL?: string;\n\tlibraries?: string[];\n\tadapter: SliceMachineConfigPluginRegistration;\n\tplugins?: SliceMachineConfigPluginRegistration[];\n\tlabs?: { legacySliceUpgrader?: boolean };\n};\n\n/**\n * Slice Machine project metadata.\n */\nexport type SliceMachineProject = {\n\t/**\n\t * An absolute path to project root.\n\t */\n\troot: string;\n\t/**\n\t * Slice Machine `slicemachine.config.json` content, validated.\n\t */\n\tconfig: SliceMachineConfig;\n};\n\n/**\n * A Slice Library's metadata.\n */\nexport type SliceLibrary = {\n\tid: string;\n};\n\n// ============================================================================\n//\n// # HOOK TYPES\n//\n// ============================================================================\n\n/**\n * A hook handler.\n */\nexport type SliceMachineHook<TData, TReturn> = (\n\tdata: TData,\n) => Promisable<TReturn>;\n\n/**\n * Extra arguments provided to hooks when called.\n *\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type SliceMachineHookExtraArgs<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = [context: SliceMachineContext<TPluginOptions>];\n\n/**\n * Utility type to extend a hook handler's type with Slice Machine-specific\n * extra arguments.\n *\n * @typeParam THook - Hook handler to extend.\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type ExtendSliceMachineHook<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTHook extends SliceMachineHook<any, any>,\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = (\n\t...args: [\n\t\t...args: Parameters<THook>,\n\t\t...extraArgs: SliceMachineHookExtraArgs<TPluginOptions>,\n\t]\n) => ReturnType<THook>;\n\n/**\n * Hook types.\n */\nexport const SliceMachineHookType = {\n\tslice_create: \"slice:create\",\n\tslice_update: \"slice:update\",\n\tslice_rename: \"slice:rename\",\n\tslice_delete: \"slice:delete\",\n\tslice_read: \"slice:read\",\n\tslice_asset_update: \"slice:asset:update\",\n\tslice_asset_delete: \"slice:asset:delete\",\n\tslice_asset_read: \"slice:asset:read\",\n\tsliceLibrary_read: \"slice-library:read\",\n\n\tcustomType_create: \"custom-type:create\",\n\tcustomType_update: \"custom-type:update\",\n\tcustomType_rename: \"custom-type:rename\",\n\tcustomType_delete: \"custom-type:delete\",\n\tcustomType_read: \"custom-type:read\",\n\tcustomType_asset_update: \"custom-type:asset:update\",\n\tcustomType_asset_delete: \"custom-type:asset:delete\",\n\tcustomType_asset_read: \"custom-type:asset:read\",\n\tcustomTypeLibrary_read: \"custom-type-library:read\",\n\tdocumentation_read: \"documentation:read\",\n\tsliceTemplateLibrary_read: \"slice-template-library:read\",\n\n\tsnippet_read: \"snippet:read\",\n\n\tproject_init: \"project:init\",\n\tproject_environment_read: \"project:environment:read\",\n\tproject_environment_update: \"project:environment:update\",\n\n\tdebug: \"debug\",\n} as const;\n\n/**\n * Hook types.\n */\nexport type SliceMachineHookTypes =\n\t(typeof SliceMachineHookType)[keyof typeof SliceMachineHookType];\n\n/**\n * Slice Machine-specific hook handlers.\n */\nexport type SliceMachineHooks = {\n\t// Slices\n\t[SliceMachineHookType.slice_create]: Hook<SliceCreateHookBase>;\n\t[SliceMachineHookType.slice_update]: Hook<SliceUpdateHookBase>;\n\t[SliceMachineHookType.slice_rename]: Hook<SliceRenameHookBase>;\n\t[SliceMachineHookType.slice_delete]: Hook<SliceDeleteHookBase>;\n\t[SliceMachineHookType.slice_read]: Hook<SliceReadHookBase>;\n\t[SliceMachineHookType.slice_asset_update]: Hook<SliceAssetUpdateHookBase>;\n\t[SliceMachineHookType.slice_asset_delete]: Hook<SliceAssetDeleteHookBase>;\n\t[SliceMachineHookType.slice_asset_read]: Hook<SliceAssetReadHookBase>;\n\n\t// Slice Libraries\n\t[SliceMachineHookType.sliceLibrary_read]: Hook<SliceLibraryReadHookBase>;\n\n\t// Custom Types\n\t[SliceMachineHookType.customType_create]: Hook<CustomTypeCreateHookBase>;\n\t[SliceMachineHookType.customType_update]: Hook<CustomTypeUpdateHookBase>;\n\t[SliceMachineHookType.customType_rename]: Hook<CustomTypeRenameHookBase>;\n\t[SliceMachineHookType.customType_delete]: Hook<CustomTypeDeleteHookBase>;\n\t[SliceMachineHookType.customType_read]: Hook<CustomTypeReadHookBase>;\n\t[SliceMachineHookType.customType_asset_update]: Hook<CustomTypeAssetUpdateHookBase>;\n\t[SliceMachineHookType.customType_asset_delete]: Hook<CustomTypeAssetDeleteHookBase>;\n\t[SliceMachineHookType.customType_asset_read]: Hook<CustomTypeAssetReadHookBase>;\n\n\t// Custom Type Libraries\n\t[SliceMachineHookType.customTypeLibrary_read]: Hook<CustomTypeLibraryReadHookBase>;\n\n\t// Snippets\n\t[SliceMachineHookType.snippet_read]: Hook<SnippetReadHookBase>;\n\n\t// Documentation\n\t[SliceMachineHookType.documentation_read]: Hook<DocumentationReadHookBase>;\n\n\t// Project\n\t[SliceMachineHookType.project_init]: Hook<ProjectInitHookBase>;\n\t[SliceMachineHookType.project_environment_read]: Hook<ProjectEnvironmentReadHookBase>;\n\t[SliceMachineHookType.project_environment_update]: Hook<ProjectEnvironmentUpdateHookBase>;\n\n\t// Debug\n\t[SliceMachineHookType.debug]: Hook<DebugHookBase>;\n\n\t// Slice templates\n\t[SliceMachineHookType.sliceTemplateLibrary_read]: Hook<SliceTemplateLibraryReadHookBase>;\n};\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"types.cjs","sources":["../../src/types.ts"],"sourcesContent":["import { SliceMachineContext } from \"./createSliceMachineContext\";\nimport { SliceMachinePlugin } from \"./defineSliceMachinePlugin\";\nimport { Hook } from \"./lib/HookSystem\";\n\nimport { ProjectInitHookBase } from \"./hooks/project-init\";\nimport { CustomTypeAssetDeleteHookBase } from \"./hooks/customType-asset-delete\";\nimport { CustomTypeAssetReadHookBase } from \"./hooks/customType-asset-read\";\nimport { CustomTypeAssetUpdateHookBase } from \"./hooks/customType-asset-update\";\nimport { CustomTypeCreateHookBase } from \"./hooks/customType-create\";\nimport { CustomTypeDeleteHookBase } from \"./hooks/customType-delete\";\nimport { CustomTypeLibraryReadHookBase } from \"./hooks/customTypeLibrary-read\";\nimport { CustomTypeReadHookBase } from \"./hooks/customType-read\";\nimport { CustomTypeRenameHookBase } from \"./hooks/customType-rename\";\nimport { CustomTypeUpdateHookBase } from \"./hooks/customType-update\";\nimport { DebugHookBase } from \"./hooks/debug\";\nimport { SliceAssetDeleteHookBase } from \"./hooks/slice-asset-delete\";\nimport { SliceAssetReadHookBase } from \"./hooks/slice-asset-read\";\nimport { SliceAssetUpdateHookBase } from \"./hooks/slice-asset-update\";\nimport { SliceCreateHookBase } from \"./hooks/slice-create\";\nimport { SliceDeleteHookBase } from \"./hooks/slice-delete\";\nimport { SliceLibraryReadHookBase } from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookBase } from \"./hooks/slice-read\";\nimport { SliceRenameHookBase } from \"./hooks/slice-rename\";\nimport { SliceSimulatorSetupReadHookBase } from \"./hooks/sliceSimulator-setup-read\";\nimport { SliceUpdateHookBase } from \"./hooks/slice-update\";\nimport { SnippetReadHookBase } from \"./hooks/snippet-read\";\nimport { DocumentationReadHookBase } from \"./hooks/documentation-read\";\n\nimport { SliceTemplateLibraryReadHookBase } from \"./hooks/sliceTemplateLibrary-read\";\nimport { ProjectEnvironmentReadHookBase } from \"./hooks/project-environment-read\";\nimport { ProjectEnvironmentUpdateHookBase } from \"./hooks/project-environment-update\";\n\n/**\n * A value optionally wrapped in a `PromiseLike`.\n *\n * @typeParam T - The value that can optionally be wrapped.\n */\nexport type Promisable<T> = T | PromiseLike<T>;\n\n/**\n * A generic type for a user-provided plugin options. Prefer using a\n * plugin-specific type over this type.\n */\nexport type SliceMachinePluginOptions = Record<string, unknown>;\n\n/**\n * A string, object, or instance representing a registered plugin.\n *\n * @typeParam TPluginOptions - User-provided options for the plugin.\n */\nexport type SliceMachineConfigPluginRegistration<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> =\n\t| string\n\t| SliceMachinePlugin\n\t| {\n\t\t\tresolve: string | SliceMachinePlugin;\n\t\t\toptions?: TPluginOptions;\n\t };\n\n/**\n * Slice Machine configuration from `slicemachine.config.js`.\n */\nexport type SliceMachineConfig = {\n\t// TODO: Can we make `apiEndpoint` optional?\n\tapiEndpoint?: string;\n\t// NOTE: This is a new property.\n\trepositoryName: string;\n\tlocalSliceSimulatorURL?: string;\n\tlibraries?: string[];\n\tadapter: SliceMachineConfigPluginRegistration;\n\tplugins?: SliceMachineConfigPluginRegistration[];\n\tlabs?: { legacySliceUpgrader?: boolean };\n};\n\n/**\n * Slice Machine project metadata.\n */\nexport type SliceMachineProject = {\n\t/**\n\t * An absolute path to project root.\n\t */\n\troot: string;\n\t/**\n\t * Slice Machine `slicemachine.config.json` content, validated.\n\t */\n\tconfig: SliceMachineConfig;\n};\n\n/**\n * A Slice Library's metadata.\n */\nexport type SliceLibrary = {\n\tid: string;\n};\n\n// ============================================================================\n//\n// # HOOK TYPES\n//\n// ============================================================================\n\n/**\n * A hook handler.\n */\nexport type SliceMachineHook<TData, TReturn> = (\n\tdata: TData,\n) => Promisable<TReturn>;\n\n/**\n * Extra arguments provided to hooks when called.\n *\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type SliceMachineHookExtraArgs<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = [context: SliceMachineContext<TPluginOptions>];\n\n/**\n * Utility type to extend a hook handler's type with Slice Machine-specific\n * extra arguments.\n *\n * @typeParam THook - Hook handler to extend.\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type ExtendSliceMachineHook<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTHook extends SliceMachineHook<any, any>,\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = (\n\t...args: [\n\t\t...args: Parameters<THook>,\n\t\t...extraArgs: SliceMachineHookExtraArgs<TPluginOptions>,\n\t]\n) => ReturnType<THook>;\n\n/**\n * Hook types.\n */\nexport const SliceMachineHookType = {\n\tslice_create: \"slice:create\",\n\tslice_update: \"slice:update\",\n\tslice_rename: \"slice:rename\",\n\tslice_delete: \"slice:delete\",\n\tslice_read: \"slice:read\",\n\tslice_asset_update: \"slice:asset:update\",\n\tslice_asset_delete: \"slice:asset:delete\",\n\tslice_asset_read: \"slice:asset:read\",\n\tsliceLibrary_read: \"slice-library:read\",\n\n\tcustomType_create: \"custom-type:create\",\n\tcustomType_update: \"custom-type:update\",\n\tcustomType_rename: \"custom-type:rename\",\n\tcustomType_delete: \"custom-type:delete\",\n\tcustomType_read: \"custom-type:read\",\n\tcustomType_asset_update: \"custom-type:asset:update\",\n\tcustomType_asset_delete: \"custom-type:asset:delete\",\n\tcustomType_asset_read: \"custom-type:asset:read\",\n\tcustomTypeLibrary_read: \"custom-type-library:read\",\n\tdocumentation_read: \"documentation:read\",\n\tsliceTemplateLibrary_read: \"slice-template-library:read\",\n\n\tsnippet_read: \"snippet:read\",\n\n\tsliceSimulator_setup_read: \"slice-simulator:setup:read\",\n\n\tproject_init: \"project:init\",\n\tproject_environment_read: \"project:environment:read\",\n\tproject_environment_update: \"project:environment:update\",\n\n\tdebug: \"debug\",\n} as const;\n\n/**\n * Hook types.\n */\nexport type SliceMachineHookTypes =\n\t(typeof SliceMachineHookType)[keyof typeof SliceMachineHookType];\n\n/**\n * Slice Machine-specific hook handlers.\n */\nexport type SliceMachineHooks = {\n\t// Slices\n\t[SliceMachineHookType.slice_create]: Hook<SliceCreateHookBase>;\n\t[SliceMachineHookType.slice_update]: Hook<SliceUpdateHookBase>;\n\t[SliceMachineHookType.slice_rename]: Hook<SliceRenameHookBase>;\n\t[SliceMachineHookType.slice_delete]: Hook<SliceDeleteHookBase>;\n\t[SliceMachineHookType.slice_read]: Hook<SliceReadHookBase>;\n\t[SliceMachineHookType.slice_asset_update]: Hook<SliceAssetUpdateHookBase>;\n\t[SliceMachineHookType.slice_asset_delete]: Hook<SliceAssetDeleteHookBase>;\n\t[SliceMachineHookType.slice_asset_read]: Hook<SliceAssetReadHookBase>;\n\n\t// Slice Libraries\n\t[SliceMachineHookType.sliceLibrary_read]: Hook<SliceLibraryReadHookBase>;\n\n\t// Custom Types\n\t[SliceMachineHookType.customType_create]: Hook<CustomTypeCreateHookBase>;\n\t[SliceMachineHookType.customType_update]: Hook<CustomTypeUpdateHookBase>;\n\t[SliceMachineHookType.customType_rename]: Hook<CustomTypeRenameHookBase>;\n\t[SliceMachineHookType.customType_delete]: Hook<CustomTypeDeleteHookBase>;\n\t[SliceMachineHookType.customType_read]: Hook<CustomTypeReadHookBase>;\n\t[SliceMachineHookType.customType_asset_update]: Hook<CustomTypeAssetUpdateHookBase>;\n\t[SliceMachineHookType.customType_asset_delete]: Hook<CustomTypeAssetDeleteHookBase>;\n\t[SliceMachineHookType.customType_asset_read]: Hook<CustomTypeAssetReadHookBase>;\n\n\t// Custom Type Libraries\n\t[SliceMachineHookType.customTypeLibrary_read]: Hook<CustomTypeLibraryReadHookBase>;\n\n\t// Snippets\n\t[SliceMachineHookType.snippet_read]: Hook<SnippetReadHookBase>;\n\n\t// Documentation\n\t[SliceMachineHookType.documentation_read]: Hook<DocumentationReadHookBase>;\n\n\t// Slice Simulator\n\t[SliceMachineHookType.sliceSimulator_setup_read]: Hook<SliceSimulatorSetupReadHookBase>;\n\n\t// Project\n\t[SliceMachineHookType.project_init]: Hook<ProjectInitHookBase>;\n\t[SliceMachineHookType.project_environment_read]: Hook<ProjectEnvironmentReadHookBase>;\n\t[SliceMachineHookType.project_environment_update]: Hook<ProjectEnvironmentUpdateHookBase>;\n\n\t// Debug\n\t[SliceMachineHookType.debug]: Hook<DebugHookBase>;\n\n\t// Slice templates\n\t[SliceMachineHookType.sliceTemplateLibrary_read]: Hook<SliceTemplateLibraryReadHookBase>;\n};\n"],"names":[],"mappings":";;AA2IO,MAAM,uBAAuB;AAAA,EACnC,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EAEnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAE3B,cAAc;AAAA,EAEd,2BAA2B;AAAA,EAE3B,cAAc;AAAA,EACd,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAE5B,OAAO;;;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { SliceDeleteHookBase } from "./hooks/slice-delete";
|
|
|
20
20
|
import { SliceLibraryReadHookBase } from "./hooks/sliceLibrary-read";
|
|
21
21
|
import { SliceReadHookBase } from "./hooks/slice-read";
|
|
22
22
|
import { SliceRenameHookBase } from "./hooks/slice-rename";
|
|
23
|
+
import { SliceSimulatorSetupReadHookBase } from "./hooks/sliceSimulator-setup-read";
|
|
23
24
|
import { SliceUpdateHookBase } from "./hooks/slice-update";
|
|
24
25
|
import { SnippetReadHookBase } from "./hooks/snippet-read";
|
|
25
26
|
import { DocumentationReadHookBase } from "./hooks/documentation-read";
|
|
@@ -125,6 +126,7 @@ export declare const SliceMachineHookType: {
|
|
|
125
126
|
readonly documentation_read: "documentation:read";
|
|
126
127
|
readonly sliceTemplateLibrary_read: "slice-template-library:read";
|
|
127
128
|
readonly snippet_read: "snippet:read";
|
|
129
|
+
readonly sliceSimulator_setup_read: "slice-simulator:setup:read";
|
|
128
130
|
readonly project_init: "project:init";
|
|
129
131
|
readonly project_environment_read: "project:environment:read";
|
|
130
132
|
readonly project_environment_update: "project:environment:update";
|
|
@@ -158,6 +160,7 @@ export type SliceMachineHooks = {
|
|
|
158
160
|
[SliceMachineHookType.customTypeLibrary_read]: Hook<CustomTypeLibraryReadHookBase>;
|
|
159
161
|
[SliceMachineHookType.snippet_read]: Hook<SnippetReadHookBase>;
|
|
160
162
|
[SliceMachineHookType.documentation_read]: Hook<DocumentationReadHookBase>;
|
|
163
|
+
[SliceMachineHookType.sliceSimulator_setup_read]: Hook<SliceSimulatorSetupReadHookBase>;
|
|
161
164
|
[SliceMachineHookType.project_init]: Hook<ProjectInitHookBase>;
|
|
162
165
|
[SliceMachineHookType.project_environment_read]: Hook<ProjectEnvironmentReadHookBase>;
|
|
163
166
|
[SliceMachineHookType.project_environment_update]: Hook<ProjectEnvironmentUpdateHookBase>;
|
package/dist/types.js
CHANGED
|
@@ -20,6 +20,7 @@ const SliceMachineHookType = {
|
|
|
20
20
|
documentation_read: "documentation:read",
|
|
21
21
|
sliceTemplateLibrary_read: "slice-template-library:read",
|
|
22
22
|
snippet_read: "snippet:read",
|
|
23
|
+
sliceSimulator_setup_read: "slice-simulator:setup:read",
|
|
23
24
|
project_init: "project:init",
|
|
24
25
|
project_environment_read: "project:environment:read",
|
|
25
26
|
project_environment_update: "project:environment:update",
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["import { SliceMachineContext } from \"./createSliceMachineContext\";\nimport { SliceMachinePlugin } from \"./defineSliceMachinePlugin\";\nimport { Hook } from \"./lib/HookSystem\";\n\nimport { ProjectInitHookBase } from \"./hooks/project-init\";\nimport { CustomTypeAssetDeleteHookBase } from \"./hooks/customType-asset-delete\";\nimport { CustomTypeAssetReadHookBase } from \"./hooks/customType-asset-read\";\nimport { CustomTypeAssetUpdateHookBase } from \"./hooks/customType-asset-update\";\nimport { CustomTypeCreateHookBase } from \"./hooks/customType-create\";\nimport { CustomTypeDeleteHookBase } from \"./hooks/customType-delete\";\nimport { CustomTypeLibraryReadHookBase } from \"./hooks/customTypeLibrary-read\";\nimport { CustomTypeReadHookBase } from \"./hooks/customType-read\";\nimport { CustomTypeRenameHookBase } from \"./hooks/customType-rename\";\nimport { CustomTypeUpdateHookBase } from \"./hooks/customType-update\";\nimport { DebugHookBase } from \"./hooks/debug\";\nimport { SliceAssetDeleteHookBase } from \"./hooks/slice-asset-delete\";\nimport { SliceAssetReadHookBase } from \"./hooks/slice-asset-read\";\nimport { SliceAssetUpdateHookBase } from \"./hooks/slice-asset-update\";\nimport { SliceCreateHookBase } from \"./hooks/slice-create\";\nimport { SliceDeleteHookBase } from \"./hooks/slice-delete\";\nimport { SliceLibraryReadHookBase } from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookBase } from \"./hooks/slice-read\";\nimport { SliceRenameHookBase } from \"./hooks/slice-rename\";\nimport { SliceUpdateHookBase } from \"./hooks/slice-update\";\nimport { SnippetReadHookBase } from \"./hooks/snippet-read\";\nimport { DocumentationReadHookBase } from \"./hooks/documentation-read\";\n\nimport { SliceTemplateLibraryReadHookBase } from \"./hooks/sliceTemplateLibrary-read\";\nimport { ProjectEnvironmentReadHookBase } from \"./hooks/project-environment-read\";\nimport { ProjectEnvironmentUpdateHookBase } from \"./hooks/project-environment-update\";\n\n/**\n * A value optionally wrapped in a `PromiseLike`.\n *\n * @typeParam T - The value that can optionally be wrapped.\n */\nexport type Promisable<T> = T | PromiseLike<T>;\n\n/**\n * A generic type for a user-provided plugin options. Prefer using a\n * plugin-specific type over this type.\n */\nexport type SliceMachinePluginOptions = Record<string, unknown>;\n\n/**\n * A string, object, or instance representing a registered plugin.\n *\n * @typeParam TPluginOptions - User-provided options for the plugin.\n */\nexport type SliceMachineConfigPluginRegistration<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> =\n\t| string\n\t| SliceMachinePlugin\n\t| {\n\t\t\tresolve: string | SliceMachinePlugin;\n\t\t\toptions?: TPluginOptions;\n\t };\n\n/**\n * Slice Machine configuration from `slicemachine.config.js`.\n */\nexport type SliceMachineConfig = {\n\t// TODO: Can we make `apiEndpoint` optional?\n\tapiEndpoint?: string;\n\t// NOTE: This is a new property.\n\trepositoryName: string;\n\tlocalSliceSimulatorURL?: string;\n\tlibraries?: string[];\n\tadapter: SliceMachineConfigPluginRegistration;\n\tplugins?: SliceMachineConfigPluginRegistration[];\n\tlabs?: { legacySliceUpgrader?: boolean };\n};\n\n/**\n * Slice Machine project metadata.\n */\nexport type SliceMachineProject = {\n\t/**\n\t * An absolute path to project root.\n\t */\n\troot: string;\n\t/**\n\t * Slice Machine `slicemachine.config.json` content, validated.\n\t */\n\tconfig: SliceMachineConfig;\n};\n\n/**\n * A Slice Library's metadata.\n */\nexport type SliceLibrary = {\n\tid: string;\n};\n\n// ============================================================================\n//\n// # HOOK TYPES\n//\n// ============================================================================\n\n/**\n * A hook handler.\n */\nexport type SliceMachineHook<TData, TReturn> = (\n\tdata: TData,\n) => Promisable<TReturn>;\n\n/**\n * Extra arguments provided to hooks when called.\n *\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type SliceMachineHookExtraArgs<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = [context: SliceMachineContext<TPluginOptions>];\n\n/**\n * Utility type to extend a hook handler's type with Slice Machine-specific\n * extra arguments.\n *\n * @typeParam THook - Hook handler to extend.\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type ExtendSliceMachineHook<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTHook extends SliceMachineHook<any, any>,\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = (\n\t...args: [\n\t\t...args: Parameters<THook>,\n\t\t...extraArgs: SliceMachineHookExtraArgs<TPluginOptions>,\n\t]\n) => ReturnType<THook>;\n\n/**\n * Hook types.\n */\nexport const SliceMachineHookType = {\n\tslice_create: \"slice:create\",\n\tslice_update: \"slice:update\",\n\tslice_rename: \"slice:rename\",\n\tslice_delete: \"slice:delete\",\n\tslice_read: \"slice:read\",\n\tslice_asset_update: \"slice:asset:update\",\n\tslice_asset_delete: \"slice:asset:delete\",\n\tslice_asset_read: \"slice:asset:read\",\n\tsliceLibrary_read: \"slice-library:read\",\n\n\tcustomType_create: \"custom-type:create\",\n\tcustomType_update: \"custom-type:update\",\n\tcustomType_rename: \"custom-type:rename\",\n\tcustomType_delete: \"custom-type:delete\",\n\tcustomType_read: \"custom-type:read\",\n\tcustomType_asset_update: \"custom-type:asset:update\",\n\tcustomType_asset_delete: \"custom-type:asset:delete\",\n\tcustomType_asset_read: \"custom-type:asset:read\",\n\tcustomTypeLibrary_read: \"custom-type-library:read\",\n\tdocumentation_read: \"documentation:read\",\n\tsliceTemplateLibrary_read: \"slice-template-library:read\",\n\n\tsnippet_read: \"snippet:read\",\n\n\tproject_init: \"project:init\",\n\tproject_environment_read: \"project:environment:read\",\n\tproject_environment_update: \"project:environment:update\",\n\n\tdebug: \"debug\",\n} as const;\n\n/**\n * Hook types.\n */\nexport type SliceMachineHookTypes =\n\t(typeof SliceMachineHookType)[keyof typeof SliceMachineHookType];\n\n/**\n * Slice Machine-specific hook handlers.\n */\nexport type SliceMachineHooks = {\n\t// Slices\n\t[SliceMachineHookType.slice_create]: Hook<SliceCreateHookBase>;\n\t[SliceMachineHookType.slice_update]: Hook<SliceUpdateHookBase>;\n\t[SliceMachineHookType.slice_rename]: Hook<SliceRenameHookBase>;\n\t[SliceMachineHookType.slice_delete]: Hook<SliceDeleteHookBase>;\n\t[SliceMachineHookType.slice_read]: Hook<SliceReadHookBase>;\n\t[SliceMachineHookType.slice_asset_update]: Hook<SliceAssetUpdateHookBase>;\n\t[SliceMachineHookType.slice_asset_delete]: Hook<SliceAssetDeleteHookBase>;\n\t[SliceMachineHookType.slice_asset_read]: Hook<SliceAssetReadHookBase>;\n\n\t// Slice Libraries\n\t[SliceMachineHookType.sliceLibrary_read]: Hook<SliceLibraryReadHookBase>;\n\n\t// Custom Types\n\t[SliceMachineHookType.customType_create]: Hook<CustomTypeCreateHookBase>;\n\t[SliceMachineHookType.customType_update]: Hook<CustomTypeUpdateHookBase>;\n\t[SliceMachineHookType.customType_rename]: Hook<CustomTypeRenameHookBase>;\n\t[SliceMachineHookType.customType_delete]: Hook<CustomTypeDeleteHookBase>;\n\t[SliceMachineHookType.customType_read]: Hook<CustomTypeReadHookBase>;\n\t[SliceMachineHookType.customType_asset_update]: Hook<CustomTypeAssetUpdateHookBase>;\n\t[SliceMachineHookType.customType_asset_delete]: Hook<CustomTypeAssetDeleteHookBase>;\n\t[SliceMachineHookType.customType_asset_read]: Hook<CustomTypeAssetReadHookBase>;\n\n\t// Custom Type Libraries\n\t[SliceMachineHookType.customTypeLibrary_read]: Hook<CustomTypeLibraryReadHookBase>;\n\n\t// Snippets\n\t[SliceMachineHookType.snippet_read]: Hook<SnippetReadHookBase>;\n\n\t// Documentation\n\t[SliceMachineHookType.documentation_read]: Hook<DocumentationReadHookBase>;\n\n\t// Project\n\t[SliceMachineHookType.project_init]: Hook<ProjectInitHookBase>;\n\t[SliceMachineHookType.project_environment_read]: Hook<ProjectEnvironmentReadHookBase>;\n\t[SliceMachineHookType.project_environment_update]: Hook<ProjectEnvironmentUpdateHookBase>;\n\n\t// Debug\n\t[SliceMachineHookType.debug]: Hook<DebugHookBase>;\n\n\t// Slice templates\n\t[SliceMachineHookType.sliceTemplateLibrary_read]: Hook<SliceTemplateLibraryReadHookBase>;\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["import { SliceMachineContext } from \"./createSliceMachineContext\";\nimport { SliceMachinePlugin } from \"./defineSliceMachinePlugin\";\nimport { Hook } from \"./lib/HookSystem\";\n\nimport { ProjectInitHookBase } from \"./hooks/project-init\";\nimport { CustomTypeAssetDeleteHookBase } from \"./hooks/customType-asset-delete\";\nimport { CustomTypeAssetReadHookBase } from \"./hooks/customType-asset-read\";\nimport { CustomTypeAssetUpdateHookBase } from \"./hooks/customType-asset-update\";\nimport { CustomTypeCreateHookBase } from \"./hooks/customType-create\";\nimport { CustomTypeDeleteHookBase } from \"./hooks/customType-delete\";\nimport { CustomTypeLibraryReadHookBase } from \"./hooks/customTypeLibrary-read\";\nimport { CustomTypeReadHookBase } from \"./hooks/customType-read\";\nimport { CustomTypeRenameHookBase } from \"./hooks/customType-rename\";\nimport { CustomTypeUpdateHookBase } from \"./hooks/customType-update\";\nimport { DebugHookBase } from \"./hooks/debug\";\nimport { SliceAssetDeleteHookBase } from \"./hooks/slice-asset-delete\";\nimport { SliceAssetReadHookBase } from \"./hooks/slice-asset-read\";\nimport { SliceAssetUpdateHookBase } from \"./hooks/slice-asset-update\";\nimport { SliceCreateHookBase } from \"./hooks/slice-create\";\nimport { SliceDeleteHookBase } from \"./hooks/slice-delete\";\nimport { SliceLibraryReadHookBase } from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookBase } from \"./hooks/slice-read\";\nimport { SliceRenameHookBase } from \"./hooks/slice-rename\";\nimport { SliceSimulatorSetupReadHookBase } from \"./hooks/sliceSimulator-setup-read\";\nimport { SliceUpdateHookBase } from \"./hooks/slice-update\";\nimport { SnippetReadHookBase } from \"./hooks/snippet-read\";\nimport { DocumentationReadHookBase } from \"./hooks/documentation-read\";\n\nimport { SliceTemplateLibraryReadHookBase } from \"./hooks/sliceTemplateLibrary-read\";\nimport { ProjectEnvironmentReadHookBase } from \"./hooks/project-environment-read\";\nimport { ProjectEnvironmentUpdateHookBase } from \"./hooks/project-environment-update\";\n\n/**\n * A value optionally wrapped in a `PromiseLike`.\n *\n * @typeParam T - The value that can optionally be wrapped.\n */\nexport type Promisable<T> = T | PromiseLike<T>;\n\n/**\n * A generic type for a user-provided plugin options. Prefer using a\n * plugin-specific type over this type.\n */\nexport type SliceMachinePluginOptions = Record<string, unknown>;\n\n/**\n * A string, object, or instance representing a registered plugin.\n *\n * @typeParam TPluginOptions - User-provided options for the plugin.\n */\nexport type SliceMachineConfigPluginRegistration<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> =\n\t| string\n\t| SliceMachinePlugin\n\t| {\n\t\t\tresolve: string | SliceMachinePlugin;\n\t\t\toptions?: TPluginOptions;\n\t };\n\n/**\n * Slice Machine configuration from `slicemachine.config.js`.\n */\nexport type SliceMachineConfig = {\n\t// TODO: Can we make `apiEndpoint` optional?\n\tapiEndpoint?: string;\n\t// NOTE: This is a new property.\n\trepositoryName: string;\n\tlocalSliceSimulatorURL?: string;\n\tlibraries?: string[];\n\tadapter: SliceMachineConfigPluginRegistration;\n\tplugins?: SliceMachineConfigPluginRegistration[];\n\tlabs?: { legacySliceUpgrader?: boolean };\n};\n\n/**\n * Slice Machine project metadata.\n */\nexport type SliceMachineProject = {\n\t/**\n\t * An absolute path to project root.\n\t */\n\troot: string;\n\t/**\n\t * Slice Machine `slicemachine.config.json` content, validated.\n\t */\n\tconfig: SliceMachineConfig;\n};\n\n/**\n * A Slice Library's metadata.\n */\nexport type SliceLibrary = {\n\tid: string;\n};\n\n// ============================================================================\n//\n// # HOOK TYPES\n//\n// ============================================================================\n\n/**\n * A hook handler.\n */\nexport type SliceMachineHook<TData, TReturn> = (\n\tdata: TData,\n) => Promisable<TReturn>;\n\n/**\n * Extra arguments provided to hooks when called.\n *\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type SliceMachineHookExtraArgs<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = [context: SliceMachineContext<TPluginOptions>];\n\n/**\n * Utility type to extend a hook handler's type with Slice Machine-specific\n * extra arguments.\n *\n * @typeParam THook - Hook handler to extend.\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type ExtendSliceMachineHook<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTHook extends SliceMachineHook<any, any>,\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = (\n\t...args: [\n\t\t...args: Parameters<THook>,\n\t\t...extraArgs: SliceMachineHookExtraArgs<TPluginOptions>,\n\t]\n) => ReturnType<THook>;\n\n/**\n * Hook types.\n */\nexport const SliceMachineHookType = {\n\tslice_create: \"slice:create\",\n\tslice_update: \"slice:update\",\n\tslice_rename: \"slice:rename\",\n\tslice_delete: \"slice:delete\",\n\tslice_read: \"slice:read\",\n\tslice_asset_update: \"slice:asset:update\",\n\tslice_asset_delete: \"slice:asset:delete\",\n\tslice_asset_read: \"slice:asset:read\",\n\tsliceLibrary_read: \"slice-library:read\",\n\n\tcustomType_create: \"custom-type:create\",\n\tcustomType_update: \"custom-type:update\",\n\tcustomType_rename: \"custom-type:rename\",\n\tcustomType_delete: \"custom-type:delete\",\n\tcustomType_read: \"custom-type:read\",\n\tcustomType_asset_update: \"custom-type:asset:update\",\n\tcustomType_asset_delete: \"custom-type:asset:delete\",\n\tcustomType_asset_read: \"custom-type:asset:read\",\n\tcustomTypeLibrary_read: \"custom-type-library:read\",\n\tdocumentation_read: \"documentation:read\",\n\tsliceTemplateLibrary_read: \"slice-template-library:read\",\n\n\tsnippet_read: \"snippet:read\",\n\n\tsliceSimulator_setup_read: \"slice-simulator:setup:read\",\n\n\tproject_init: \"project:init\",\n\tproject_environment_read: \"project:environment:read\",\n\tproject_environment_update: \"project:environment:update\",\n\n\tdebug: \"debug\",\n} as const;\n\n/**\n * Hook types.\n */\nexport type SliceMachineHookTypes =\n\t(typeof SliceMachineHookType)[keyof typeof SliceMachineHookType];\n\n/**\n * Slice Machine-specific hook handlers.\n */\nexport type SliceMachineHooks = {\n\t// Slices\n\t[SliceMachineHookType.slice_create]: Hook<SliceCreateHookBase>;\n\t[SliceMachineHookType.slice_update]: Hook<SliceUpdateHookBase>;\n\t[SliceMachineHookType.slice_rename]: Hook<SliceRenameHookBase>;\n\t[SliceMachineHookType.slice_delete]: Hook<SliceDeleteHookBase>;\n\t[SliceMachineHookType.slice_read]: Hook<SliceReadHookBase>;\n\t[SliceMachineHookType.slice_asset_update]: Hook<SliceAssetUpdateHookBase>;\n\t[SliceMachineHookType.slice_asset_delete]: Hook<SliceAssetDeleteHookBase>;\n\t[SliceMachineHookType.slice_asset_read]: Hook<SliceAssetReadHookBase>;\n\n\t// Slice Libraries\n\t[SliceMachineHookType.sliceLibrary_read]: Hook<SliceLibraryReadHookBase>;\n\n\t// Custom Types\n\t[SliceMachineHookType.customType_create]: Hook<CustomTypeCreateHookBase>;\n\t[SliceMachineHookType.customType_update]: Hook<CustomTypeUpdateHookBase>;\n\t[SliceMachineHookType.customType_rename]: Hook<CustomTypeRenameHookBase>;\n\t[SliceMachineHookType.customType_delete]: Hook<CustomTypeDeleteHookBase>;\n\t[SliceMachineHookType.customType_read]: Hook<CustomTypeReadHookBase>;\n\t[SliceMachineHookType.customType_asset_update]: Hook<CustomTypeAssetUpdateHookBase>;\n\t[SliceMachineHookType.customType_asset_delete]: Hook<CustomTypeAssetDeleteHookBase>;\n\t[SliceMachineHookType.customType_asset_read]: Hook<CustomTypeAssetReadHookBase>;\n\n\t// Custom Type Libraries\n\t[SliceMachineHookType.customTypeLibrary_read]: Hook<CustomTypeLibraryReadHookBase>;\n\n\t// Snippets\n\t[SliceMachineHookType.snippet_read]: Hook<SnippetReadHookBase>;\n\n\t// Documentation\n\t[SliceMachineHookType.documentation_read]: Hook<DocumentationReadHookBase>;\n\n\t// Slice Simulator\n\t[SliceMachineHookType.sliceSimulator_setup_read]: Hook<SliceSimulatorSetupReadHookBase>;\n\n\t// Project\n\t[SliceMachineHookType.project_init]: Hook<ProjectInitHookBase>;\n\t[SliceMachineHookType.project_environment_read]: Hook<ProjectEnvironmentReadHookBase>;\n\t[SliceMachineHookType.project_environment_update]: Hook<ProjectEnvironmentUpdateHookBase>;\n\n\t// Debug\n\t[SliceMachineHookType.debug]: Hook<DebugHookBase>;\n\n\t// Slice templates\n\t[SliceMachineHookType.sliceTemplateLibrary_read]: Hook<SliceTemplateLibraryReadHookBase>;\n};\n"],"names":[],"mappings":"AA2IO,MAAM,uBAAuB;AAAA,EACnC,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EAEnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAE3B,cAAc;AAAA,EAEd,2BAA2B;AAAA,EAE3B,cAAc;AAAA,EACd,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAE5B,OAAO;;"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtendSliceMachineHook,
|
|
3
|
+
SliceMachinePluginOptions,
|
|
4
|
+
Promisable,
|
|
5
|
+
SliceMachineHook,
|
|
6
|
+
} from "../types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An object representing validation for a Slice Simulator set up step.
|
|
10
|
+
*/
|
|
11
|
+
export type SliceSimulatorSetupStepValidationMessage = {
|
|
12
|
+
title: string;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An object representing a step to set up Slice Simulator.
|
|
18
|
+
*/
|
|
19
|
+
export type SliceSimulatorSetupStep = {
|
|
20
|
+
title: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
body: string;
|
|
23
|
+
validate?: () => Promisable<
|
|
24
|
+
| SliceSimulatorSetupStepValidationMessage
|
|
25
|
+
| SliceSimulatorSetupStepValidationMessage[]
|
|
26
|
+
| void
|
|
27
|
+
>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Data provided to `slice-simulator:setup:read` hook handlers.
|
|
32
|
+
*/
|
|
33
|
+
export type SliceSimulatorSetupReadHookData = undefined;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Return value for `slice-simulator:setup:read` hook handlers.
|
|
37
|
+
*/
|
|
38
|
+
export type SliceSimulatorSetupReadHookReturnType = SliceSimulatorSetupStep[];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Base version of a `slice-simulator:setup:read` hook handler without plugin
|
|
42
|
+
* runner context.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export type SliceSimulatorSetupReadHookBase = SliceMachineHook<
|
|
47
|
+
undefined,
|
|
48
|
+
SliceSimulatorSetupReadHookReturnType
|
|
49
|
+
>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Handler for the `slice-simulator:setup:read` hook. The hook is called when a
|
|
53
|
+
* Slice Simulator set up steps are needed.
|
|
54
|
+
*
|
|
55
|
+
* This hook is **required** to be implemented by adapters.
|
|
56
|
+
*
|
|
57
|
+
* This hook will only be called in adapters.
|
|
58
|
+
*
|
|
59
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
60
|
+
*/
|
|
61
|
+
export type SliceSimulatorSetupReadHook<
|
|
62
|
+
TPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,
|
|
63
|
+
> = ExtendSliceMachineHook<SliceSimulatorSetupReadHookBase, TPluginOptions>;
|
package/src/index.ts
CHANGED
|
@@ -169,6 +169,15 @@ export type {
|
|
|
169
169
|
Snippet,
|
|
170
170
|
} from "./hooks/snippet-read";
|
|
171
171
|
|
|
172
|
+
// slice-simulator-setup:read
|
|
173
|
+
export type {
|
|
174
|
+
SliceSimulatorSetupReadHook,
|
|
175
|
+
SliceSimulatorSetupReadHookData,
|
|
176
|
+
SliceSimulatorSetupReadHookReturnType,
|
|
177
|
+
SliceSimulatorSetupStep,
|
|
178
|
+
SliceSimulatorSetupStepValidationMessage,
|
|
179
|
+
} from "./hooks/sliceSimulator-setup-read";
|
|
180
|
+
|
|
172
181
|
// project:environment:read
|
|
173
182
|
export type {
|
|
174
183
|
ProjectEnvironmentReadHook,
|
package/src/types.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { SliceDeleteHookBase } from "./hooks/slice-delete";
|
|
|
21
21
|
import { SliceLibraryReadHookBase } from "./hooks/sliceLibrary-read";
|
|
22
22
|
import { SliceReadHookBase } from "./hooks/slice-read";
|
|
23
23
|
import { SliceRenameHookBase } from "./hooks/slice-rename";
|
|
24
|
+
import { SliceSimulatorSetupReadHookBase } from "./hooks/sliceSimulator-setup-read";
|
|
24
25
|
import { SliceUpdateHookBase } from "./hooks/slice-update";
|
|
25
26
|
import { SnippetReadHookBase } from "./hooks/snippet-read";
|
|
26
27
|
import { DocumentationReadHookBase } from "./hooks/documentation-read";
|
|
@@ -161,6 +162,8 @@ export const SliceMachineHookType = {
|
|
|
161
162
|
|
|
162
163
|
snippet_read: "snippet:read",
|
|
163
164
|
|
|
165
|
+
sliceSimulator_setup_read: "slice-simulator:setup:read",
|
|
166
|
+
|
|
164
167
|
project_init: "project:init",
|
|
165
168
|
project_environment_read: "project:environment:read",
|
|
166
169
|
project_environment_update: "project:environment:update",
|
|
@@ -210,6 +213,9 @@ export type SliceMachineHooks = {
|
|
|
210
213
|
// Documentation
|
|
211
214
|
[SliceMachineHookType.documentation_read]: Hook<DocumentationReadHookBase>;
|
|
212
215
|
|
|
216
|
+
// Slice Simulator
|
|
217
|
+
[SliceMachineHookType.sliceSimulator_setup_read]: Hook<SliceSimulatorSetupReadHookBase>;
|
|
218
|
+
|
|
213
219
|
// Project
|
|
214
220
|
[SliceMachineHookType.project_init]: Hook<ProjectInitHookBase>;
|
|
215
221
|
[SliceMachineHookType.project_environment_read]: Hook<ProjectEnvironmentReadHookBase>;
|