@smthrs/plugin 0.0.0-stage → 1.0.0-rc.4
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/CHANGELOG.md +79 -0
- package/LICENSE +21 -0
- package/README.md +86 -2
- package/dist/cjs/Config.d.ts +129 -0
- package/dist/cjs/Config.d.ts.map +1 -0
- package/dist/cjs/Config.js +115 -0
- package/dist/cjs/Config.js.map +7 -0
- package/dist/cjs/Hooks.d.ts +176 -0
- package/dist/cjs/Hooks.d.ts.map +1 -0
- package/dist/cjs/Hooks.js +34 -0
- package/dist/cjs/Hooks.js.map +7 -0
- package/dist/cjs/Kernel.d.ts +81 -0
- package/dist/cjs/Kernel.d.ts.map +1 -0
- package/dist/cjs/Kernel.js +57 -0
- package/dist/cjs/Kernel.js.map +7 -0
- package/dist/cjs/Plugin.d.ts +71 -0
- package/dist/cjs/Plugin.d.ts.map +1 -0
- package/dist/cjs/Plugin.js +25 -0
- package/dist/cjs/Plugin.js.map +7 -0
- package/dist/cjs/PluginError.d.ts +50 -0
- package/dist/cjs/PluginError.d.ts.map +1 -0
- package/dist/cjs/PluginError.js +58 -0
- package/dist/cjs/PluginError.js.map +7 -0
- package/dist/cjs/Plugins.d.ts +97 -0
- package/dist/cjs/Plugins.d.ts.map +1 -0
- package/dist/cjs/Plugins.js +160 -0
- package/dist/cjs/Plugins.js.map +7 -0
- package/dist/cjs/Resolve.d.ts +128 -0
- package/dist/cjs/Resolve.d.ts.map +1 -0
- package/dist/cjs/Resolve.js +343 -0
- package/dist/cjs/Resolve.js.map +7 -0
- package/dist/cjs/index.d.ts +83 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +45 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/Boundary.d.ts +96 -0
- package/dist/cjs/internal/Boundary.d.ts.map +1 -0
- package/dist/cjs/internal/Boundary.js +129 -0
- package/dist/cjs/internal/Boundary.js.map +7 -0
- package/dist/cjs/internal/mergePluginLayers.d.ts +21 -0
- package/dist/cjs/internal/mergePluginLayers.d.ts.map +1 -0
- package/dist/cjs/internal/mergePluginLayers.js +57 -0
- package/dist/cjs/internal/mergePluginLayers.js.map +7 -0
- package/dist/cjs/internal/snapshotCacheEnvironment.d.ts +19 -0
- package/dist/cjs/internal/snapshotCacheEnvironment.d.ts.map +1 -0
- package/dist/cjs/internal/snapshotCacheEnvironment.js +92 -0
- package/dist/cjs/internal/snapshotCacheEnvironment.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/Config.d.ts +129 -0
- package/dist/esm/Config.d.ts.map +1 -0
- package/dist/esm/Config.js +160 -0
- package/dist/esm/Config.js.map +1 -0
- package/dist/esm/Hooks.d.ts +176 -0
- package/dist/esm/Hooks.d.ts.map +1 -0
- package/dist/esm/Hooks.js +56 -0
- package/dist/esm/Hooks.js.map +1 -0
- package/dist/esm/Kernel.d.ts +81 -0
- package/dist/esm/Kernel.d.ts.map +1 -0
- package/dist/esm/Kernel.js +58 -0
- package/dist/esm/Kernel.js.map +1 -0
- package/dist/esm/Plugin.d.ts +71 -0
- package/dist/esm/Plugin.d.ts.map +1 -0
- package/dist/esm/Plugin.js +20 -0
- package/dist/esm/Plugin.js.map +1 -0
- package/dist/esm/PluginError.d.ts +50 -0
- package/dist/esm/PluginError.d.ts.map +1 -0
- package/dist/esm/PluginError.js +53 -0
- package/dist/esm/PluginError.js.map +1 -0
- package/dist/esm/Plugins.d.ts +97 -0
- package/dist/esm/Plugins.d.ts.map +1 -0
- package/dist/esm/Plugins.js +178 -0
- package/dist/esm/Plugins.js.map +1 -0
- package/dist/esm/Resolve.d.ts +128 -0
- package/dist/esm/Resolve.d.ts.map +1 -0
- package/dist/esm/Resolve.js +367 -0
- package/dist/esm/Resolve.js.map +1 -0
- package/dist/esm/index.d.ts +83 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +48 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/Boundary.d.ts +96 -0
- package/dist/esm/internal/Boundary.d.ts.map +1 -0
- package/dist/esm/internal/Boundary.js +162 -0
- package/dist/esm/internal/Boundary.js.map +1 -0
- package/dist/esm/internal/mergePluginLayers.d.ts +21 -0
- package/dist/esm/internal/mergePluginLayers.d.ts.map +1 -0
- package/dist/esm/internal/mergePluginLayers.js +41 -0
- package/dist/esm/internal/mergePluginLayers.js.map +1 -0
- package/dist/esm/internal/snapshotCacheEnvironment.d.ts +19 -0
- package/dist/esm/internal/snapshotCacheEnvironment.d.ts.map +1 -0
- package/dist/esm/internal/snapshotCacheEnvironment.js +63 -0
- package/dist/esm/internal/snapshotCacheEnvironment.js.map +1 -0
- package/docs/README.md +131 -0
- package/docs/api.md +522 -0
- package/docs/concepts/configuration.md +111 -0
- package/docs/concepts/hook-kinds.md +107 -0
- package/docs/concepts/resolution.md +132 -0
- package/docs/guides/cache-identity.md +106 -0
- package/docs/guides/contribute-services.md +84 -0
- package/docs/guides/host-your-own-hooks.md +129 -0
- package/docs/guides/order-handlers.md +76 -0
- package/docs/guides/select-plugins.md +72 -0
- package/docs/guides/testing.md +149 -0
- package/docs/installation.md +71 -0
- package/docs/quickstart.md +151 -0
- package/docs/troubleshooting.md +179 -0
- package/package.json +179 -3
- package/src/Config.ts +207 -0
- package/src/Hooks.ts +212 -0
- package/src/Kernel.ts +119 -0
- package/src/Plugin.ts +80 -0
- package/src/PluginError.ts +62 -0
- package/src/Plugins.ts +254 -0
- package/src/Resolve.ts +535 -0
- package/src/index.ts +91 -0
- package/src/internal/Boundary.ts +252 -0
- package/src/internal/mergePluginLayers.ts +57 -0
- package/src/internal/snapshotCacheEnvironment.ts +77 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Resolve.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Bounded plugin resolution: admit, filter, validate, order, and snapshot.\n *\n * The resulting catalog owns every record it exposes. Dispatch never reads a\n * caller-owned map, plugin record, hook object, config value, or cache identity.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as ImmutableMap from \"@smthrs/canonical/ReadonlyMap\"\nimport type { Action } from \"@smthrs/flow\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport type { FlowsConfig } from \"./Config.ts\"\nimport * as Config from \"./Config.ts\"\nimport type { HookCatalog, HookKind, HookObject } from \"./Hooks.ts\"\nimport { engineHooks, handlerOf, orderOf } from \"./Hooks.ts\"\nimport type { FlowsHooks } from \"./index.ts\"\nimport * as Boundary from \"./internal/Boundary.ts\"\nimport { mergePluginLayers } from \"./internal/mergePluginLayers.ts\"\nimport { snapshotCacheEnvironment } from \"./internal/snapshotCacheEnvironment.ts\"\nimport type { Apply, FlowsPlugin, PluginInput } from \"./Plugin.ts\"\nimport { PluginError, type PluginErrorCode } from \"./PluginError.ts\"\n\n/**\n * Maximum nested preset-array depth accepted at startup.\n *\n * @category limits\n * @since 1.0.0-rc.0\n */\nexport const maximumPluginDepth = 64\n\n/**\n * Maximum plugins accepted by one kernel.\n *\n * @category limits\n * @since 1.0.0-rc.0\n */\nexport const maximumPlugins = 256\n\n/**\n * Maximum aggregate hook handlers accepted by one kernel.\n *\n * @category limits\n * @since 1.0.0-rc.0\n */\nexport const maximumHandlers = 1_024\n\n/**\n * Maximum input nodes, including arrays and omitted entries.\n *\n * @category limits\n * @since 1.0.0-rc.0\n */\nexport const maximumPluginInputNodes = 4_096\n\n/**\n * Maximum UTF-16 length of one plugin or hook name.\n *\n * @category limits\n * @since 1.0.0-rc.0\n */\nexport const maximumPluginNameLength = 256\n\n/**\n * Default fiber bound for parallel observers.\n *\n * @category limits\n * @since 1.0.0-rc.0\n */\nexport const defaultParallelConcurrency = 16\n\n/**\n * Maximum configurable parallel-observer bound.\n *\n * @category limits\n * @since 1.0.0-rc.0\n */\nexport const maximumParallelConcurrency = 256\n\n/**\n * One resolved handler with immutable attribution.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface HandlerRecord {\n readonly plugin: string\n readonly hook: string\n readonly handler: (...args: Array<any>) => unknown\n}\n\n/**\n * The immutable output of plugin resolution.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Resolved<H = FlowsHooks> {\n readonly plugins: ReadonlyArray<FlowsPlugin<H>>\n readonly handlers: ReadonlyMap<string, ReadonlyArray<HandlerRecord>>\n /** The frozen runtime catalog this resolution admitted. Dispatch refuses a method whose kind differs from it. */\n readonly kinds: Readonly<Record<string, HookKind>>\n readonly parallelConcurrency: number\n readonly cacheEnvironment?: Action.CacheEnvironment | undefined\n}\n\n/**\n * Options for {@link resolve}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Options<H = FlowsHooks> {\n /** Pre-resolution config tested by `apply` predicates. */\n readonly config?: FlowsConfig | undefined\n /** Host whose literal `apply` selectors are active. Defaults to `\"engine\"`. */\n readonly target?: \"engine\" | \"harness\" | undefined\n /**\n * Hook names recognized by this host, each with the kind `H` declares for\n * it. The shared `config` and `configResolved` hooks are fixed to\n * `waterfall` and `parallel`; another kind fails with `hook_kind_mismatch`.\n */\n readonly hooks?: HookCatalog<H> | undefined\n /** Complete composition identity for sealed activity keys. Requires every selected plugin to have a version. */\n readonly cacheEnvironment?: Action.CacheEnvironment | undefined\n /** Maximum observers run at once. Defaults to 16 and cannot exceed 256. */\n readonly parallelConcurrency?: number | undefined\n}\n\ninterface RawOptions {\n readonly config: unknown\n readonly target: unknown\n readonly hooks: unknown\n readonly cacheEnvironment: unknown\n readonly parallelConcurrency: unknown\n}\n\nconst failure = (\n code: PluginErrorCode,\n message: string,\n path: string,\n fields: { readonly plugin?: string; readonly hook?: string } = {}\n): PluginError => new PluginError({ code, message, path, ...fields })\n\nconst invalidPlugin = (\n path: string,\n complaint: string,\n fields: { readonly plugin?: string; readonly hook?: string } = {}\n): PluginError => failure(\"invalid_plugin\", `plugin input ${complaint}`, path, fields)\n\n// Bound before quoting or scanning caller-controlled keys. Keep Boundary's\n// identifier/dot and JSON-quoted/bracket path convention.\nconst diagnosticKey = (key: string): string => key.length > 64 ? `${key.slice(0, 64)}...` : key\n\nconst childPath = (path: string, key: string): string => {\n const bounded = diagnosticKey(key)\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(bounded) ? `${path}.${bounded}` : `${path}[${JSON.stringify(bounded)}]`\n}\n\nconst ownData = (\n input: unknown,\n path: string,\n allowed?: ReadonlySet<string>\n): Readonly<Record<string, unknown>> => {\n if (typeof input !== \"object\" || input === null || Array.isArray(input)) {\n throw invalidPlugin(path, \"must be an ordinary record\")\n }\n const prototype = Object.getPrototypeOf(input)\n if (prototype !== Object.prototype && prototype !== null) throw invalidPlugin(path, \"must be an ordinary record\")\n const output: Record<string, unknown> = {}\n for (const key of Reflect.ownKeys(input)) {\n if (typeof key !== \"string\") throw invalidPlugin(path, \"must not contain symbol keys\")\n if (allowed !== undefined && !allowed.has(key)) {\n throw invalidPlugin(childPath(path, key), \"contains an unknown property\")\n }\n const descriptor = Object.getOwnPropertyDescriptor(input, key)\n if (descriptor === undefined || !(\"value\" in descriptor) || !descriptor.enumerable) {\n throw invalidPlugin(childPath(path, key), \"must be an enumerable data property\")\n }\n Object.defineProperty(output, key, { value: descriptor.value, enumerable: true })\n }\n return output\n}\n\nconst snapshotOptions = (input: unknown): RawOptions => {\n const values = ownData(\n input,\n \"$options\",\n new Set([\"config\", \"target\", \"hooks\", \"cacheEnvironment\", \"parallelConcurrency\"])\n )\n return {\n config: values.config,\n target: values.target,\n hooks: values.hooks,\n cacheEnvironment: values.cacheEnvironment,\n parallelConcurrency: values.parallelConcurrency\n }\n}\n\nconst validName = (value: unknown): value is string =>\n typeof value === \"string\" && value.length > 0 && value.length <= maximumPluginNameLength &&\n Boundary.isWellFormedText(value) && !/^\\s*$/u.test(value) && !/\\p{Cc}/u.test(value)\n\nconst snapshotCatalog = (input: unknown): Readonly<Record<string, HookKind>> => {\n if (typeof input !== \"object\" || input === null || Array.isArray(input)) {\n throw invalidPlugin(\"$options.hooks\", \"must be an ordinary hook catalog\")\n }\n const prototype = Object.getPrototypeOf(input)\n if (prototype !== Object.prototype && prototype !== null) {\n throw invalidPlugin(\"$options.hooks\", \"must be an ordinary hook catalog\")\n }\n const output: Record<string, HookKind> = {}\n for (const key of Reflect.ownKeys(input)) {\n if (typeof key !== \"string\" || !validName(key)) {\n throw invalidPlugin(\"$options.hooks\", \"contains an invalid hook name\")\n }\n const descriptor = Object.getOwnPropertyDescriptor(input, key)\n if (descriptor === undefined || !(\"value\" in descriptor) || !descriptor.enumerable) {\n throw invalidPlugin(childPath(\"$options.hooks\", key), \"must be an enumerable data property\")\n }\n if (!([\"sequential\", \"parallel\", \"first\", \"waterfall\"] as ReadonlyArray<unknown>).includes(descriptor.value)) {\n throw invalidPlugin(childPath(\"$options.hooks\", key), \"contains an invalid hook kind\")\n }\n Object.defineProperty(output, key, { value: descriptor.value, enumerable: true })\n }\n for (const hook of Object.keys(engineHooks) as ReadonlyArray<keyof typeof engineHooks>) {\n if (Object.hasOwn(output, hook) && output[hook] !== engineHooks[hook]) {\n throw failure(\n \"hook_kind_mismatch\",\n `hook catalog declares shared hook ${JSON.stringify(hook)} as ${\n JSON.stringify(output[hook])\n }, the kernel dispatches it as ${JSON.stringify(engineHooks[hook])}`,\n childPath(\"$options.hooks\", hook),\n { hook }\n )\n }\n }\n return Object.freeze(output)\n}\n\nconst snapshotHook = (\n entry: unknown,\n path: string,\n plugin: string,\n hook: string\n): ((...args: Array<any>) => unknown) | HookObject<(...args: Array<any>) => unknown> => {\n if (typeof entry === \"function\") return entry as (...args: Array<any>) => unknown\n if (entry === undefined) {\n throw invalidPlugin(path, \"must be a function or a hook object\", { plugin, hook })\n }\n const values = ownData(entry, path, new Set([\"order\", \"handler\"]))\n if (typeof values.handler !== \"function\") {\n throw invalidPlugin(`${path}.handler`, \"must be a function\", { plugin, hook })\n }\n if (values.order !== undefined && values.order !== \"pre\" && values.order !== \"post\") {\n throw invalidPlugin(`${path}.order`, \"must be pre or post\", { plugin, hook })\n }\n return Object.freeze({\n ...(values.order === undefined ? {} : { order: values.order }),\n handler: values.handler\n }) as HookObject<(...args: Array<any>) => unknown>\n}\n\nconst snapshotPlugin = <H>(\n input: unknown,\n path: string\n): FlowsPlugin<H> => {\n const values = ownData(input, path, new Set([\"name\", \"version\", \"enforce\", \"apply\", \"layer\", \"hooks\"]))\n if (!validName(values.name)) throw invalidPlugin(`${path}.name`, \"requires a bounded non-empty name\")\n const name = values.name\n if (values.version !== undefined && !validName(values.version)) {\n throw invalidPlugin(`${path}.version`, \"requires a bounded non-empty version\", { plugin: name })\n }\n if (values.enforce !== undefined && values.enforce !== \"pre\" && values.enforce !== \"post\") {\n throw invalidPlugin(`${path}.enforce`, \"must be pre or post\", { plugin: name })\n }\n if (\n values.apply !== undefined && values.apply !== \"engine\" && values.apply !== \"harness\" &&\n typeof values.apply !== \"function\"\n ) throw invalidPlugin(`${path}.apply`, \"must be engine, harness, or a predicate\", { plugin: name })\n if (values.layer !== undefined && !Layer.isLayer(values.layer)) {\n throw invalidPlugin(`${path}.layer`, \"must be an Effect Layer\", { plugin: name })\n }\n\n let hooks: Readonly<Record<string, unknown>> | undefined\n if (values.hooks !== undefined) {\n const rawHooks = ownData(values.hooks, `${path}.hooks`)\n const snapshot: Record<string, unknown> = Object.create(null)\n for (const [index, hook] of Object.keys(rawHooks).entries()) {\n if (!validName(hook)) {\n throw invalidPlugin(`${path}.hooks[${index}]`, \"contains an invalid hook name\")\n }\n const entry = rawHooks[hook]\n Object.defineProperty(snapshot, hook, {\n value: snapshotHook(entry, childPath(`${path}.hooks`, hook), name, hook),\n enumerable: true\n })\n }\n hooks = Object.freeze(snapshot)\n }\n\n return Object.freeze({\n name,\n ...(values.version === undefined ? {} : { version: values.version }),\n ...(values.enforce === undefined ? {} : { enforce: values.enforce }),\n ...(values.apply === undefined ? {} : { apply: values.apply as Apply }),\n ...(values.layer === undefined ? {} : { layer: values.layer as Layer.Layer<never, any, any> }),\n ...(hooks === undefined ? {} : { hooks: hooks as Partial<H> })\n })\n}\n\ninterface AdmittedPlugin<H> {\n readonly plugin: FlowsPlugin<H>\n readonly path: string\n}\n\nconst flatten = <H>(input: unknown): ReadonlyArray<AdmittedPlugin<H>> => {\n const output: Array<AdmittedPlugin<H>> = []\n const arrays = new WeakSet<object>()\n const stack: Array<{ readonly value: unknown; readonly path: string; readonly depth: number }> = [\n { value: input, path: \"$\", depth: 0 }\n ]\n let nodes = 0\n while (stack.length > 0) {\n const current = stack.pop()!\n nodes += 1\n if (current.value === false || current.value === null || current.value === undefined) continue\n if (Array.isArray(current.value)) {\n if (current.depth >= maximumPluginDepth) {\n throw failure(\"resource_limit\", `plugin input exceeds the depth limit of ${maximumPluginDepth}`, current.path)\n }\n if (arrays.has(current.value)) throw invalidPlugin(current.path, \"contains a cycle or repeated preset array\")\n arrays.add(current.value)\n const length = current.value.length\n // Every queued frame and array element costs a node, including omitted\n // entries. Refuse before enumerating keys, descriptors, or child frames.\n if (length > maximumPluginInputNodes - nodes - stack.length) {\n throw failure(\"resource_limit\", `plugin input exceeds the ${maximumPluginInputNodes}-node limit`, current.path)\n }\n const keys = Reflect.ownKeys(current.value)\n if (keys.length !== length + 1 || !keys.includes(\"length\")) {\n throw invalidPlugin(current.path, \"must be a dense preset array with no extra properties\")\n }\n for (let index = length - 1; index >= 0; index--) {\n const descriptor = Object.getOwnPropertyDescriptor(current.value, String(index))\n if (descriptor === undefined || !(\"value\" in descriptor) || !descriptor.enumerable) {\n throw invalidPlugin(`${current.path}[${index}]`, \"must be an enumerable data property\")\n }\n stack.push({ value: descriptor.value, path: `${current.path}[${index}]`, depth: current.depth + 1 })\n }\n continue\n }\n output.push(Object.freeze({ plugin: snapshotPlugin<H>(current.value, current.path), path: current.path }))\n if (output.length > maximumPlugins) {\n throw failure(\"resource_limit\", `plugin input exceeds the ${maximumPlugins}-plugin limit`, current.path)\n }\n }\n return output\n}\n\nconst included = <H>(\n plugin: FlowsPlugin<H>,\n config: FlowsConfig,\n target: \"engine\" | \"harness\"\n): Effect.Effect<boolean, PluginError> => {\n const apply = plugin.apply\n if (apply === undefined) return Effect.succeed(true)\n if (typeof apply !== \"function\") return Effect.succeed(apply === target)\n return Effect.try({\n try: () => apply(config),\n catch: () =>\n failure(\"apply_failed\", `plugin \"${plugin.name}\" apply predicate failed`, \"$.apply\", {\n plugin: plugin.name\n })\n }).pipe(\n Effect.flatMap((result) =>\n typeof result === \"boolean\"\n ? Effect.succeed(result)\n : Effect.fail(invalidPlugin(\"$.apply\", \"predicate must return a boolean\", { plugin: plugin.name }))\n )\n )\n}\n\nconst rank = (enforce: \"pre\" | \"post\" | undefined): number => (enforce === \"pre\" ? 0 : enforce === \"post\" ? 2 : 1)\n\n/**\n * Resolves a plugin preset into an immutable, resource-bounded catalog.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const resolve = <H = FlowsHooks>(\n input: PluginInput<NoInfer<H>>,\n options: Options<NoInfer<H>> = {},\n configOverride?: FlowsConfig\n): Effect.Effect<Resolved<H>, PluginError> =>\n Effect.gen(function*() {\n const raw = yield* Effect.try({\n try: () => snapshotOptions(options),\n catch: (cause) =>\n cause instanceof PluginError\n ? cause\n : invalidPlugin(\"$options\", \"could not be inspected without executing user code\")\n })\n if (configOverride !== undefined && raw.config !== undefined) {\n return yield* Effect.fail(invalidPlugin(\n \"$options.config\",\n \"cannot declare config in options alongside the positional override\"\n ))\n }\n if (raw.target !== undefined && raw.target !== \"engine\" && raw.target !== \"harness\") {\n return yield* Effect.fail(invalidPlugin(\"$options.target\", \"must be engine or harness\"))\n }\n if (\n raw.parallelConcurrency !== undefined &&\n (typeof raw.parallelConcurrency !== \"number\" || !Number.isSafeInteger(raw.parallelConcurrency) ||\n raw.parallelConcurrency <= 0 ||\n raw.parallelConcurrency > maximumParallelConcurrency)\n ) {\n return yield* Effect.fail(failure(\n \"resource_limit\",\n `parallel concurrency must be between 1 and ${maximumParallelConcurrency}`,\n \"$options.parallelConcurrency\"\n ))\n }\n const parallelConcurrency = raw.parallelConcurrency === undefined\n ? defaultParallelConcurrency\n : raw.parallelConcurrency\n const config = yield* Config.snapshot(configOverride ?? raw.config ?? {})\n const known = yield* Effect.try({\n try: () => snapshotCatalog(raw.hooks ?? engineHooks),\n catch: (cause) =>\n cause instanceof PluginError\n ? cause\n : invalidPlugin(\"$options.hooks\", \"could not be inspected without executing user code\")\n })\n const admitted = yield* Effect.try({\n try: () => flatten<H>(input),\n catch: (cause) =>\n cause instanceof PluginError\n ? cause\n : invalidPlugin(\"$\", \"could not be inspected without executing user code\")\n })\n const target = raw.target ?? \"engine\"\n const selected = yield* Effect.filter(admitted, ({ plugin }) => included(plugin, config, target))\n\n let handlerCount = 0\n for (const { path, plugin } of selected) {\n const pluginHooks = plugin.hooks as Readonly<Record<string, unknown>> | undefined\n if (pluginHooks === undefined) continue\n for (const hook of Object.keys(pluginHooks)) {\n if (!Object.hasOwn(known, hook)) {\n return yield* Effect.fail(failure(\n \"unknown_hook\",\n `plugin ${JSON.stringify(plugin.name)} declares unknown hook ${JSON.stringify(diagnosticKey(hook))}`,\n childPath(`${path}.hooks`, hook),\n { plugin: plugin.name, hook }\n ))\n }\n handlerCount += 1\n if (handlerCount > maximumHandlers) {\n return yield* Effect.fail(failure(\n \"resource_limit\",\n `plugin handlers exceed the limit of ${maximumHandlers}`,\n childPath(`${path}.hooks`, hook)\n ))\n }\n }\n }\n\n const seen = new Set<string>()\n for (const { plugin } of selected) {\n if (seen.has(plugin.name)) {\n return yield* Effect.fail(failure(\n \"duplicate_name\",\n `duplicate plugin name \"${plugin.name}\"`,\n \"$.name\",\n { plugin: plugin.name }\n ))\n }\n seen.add(plugin.name)\n }\n\n const plugins = Object.freeze(\n selected\n .map(({ plugin }, index) => ({ plugin, index }))\n .sort((left, right) => rank(left.plugin.enforce) - rank(right.plugin.enforce) || left.index - right.index)\n .map(({ plugin }) => plugin)\n )\n const entries: Array<readonly [string, ReadonlyArray<HandlerRecord>]> = []\n for (const hook of Object.keys(known)) {\n const records: Array<{\n readonly record: HandlerRecord\n readonly enforceRank: number\n readonly orderRank: number\n readonly index: number\n }> = []\n for (const [index, plugin] of plugins.entries()) {\n const pluginHooks = plugin.hooks as Readonly<Record<string, unknown>> | undefined\n if (pluginHooks === undefined || !Object.hasOwn(pluginHooks, hook)) continue\n const entry = pluginHooks[hook]\n const record = Object.freeze({ plugin: plugin.name, hook, handler: handlerOf(entry) })\n records.push({ record, enforceRank: rank(plugin.enforce), orderRank: rank(orderOf(entry)), index })\n }\n // Vite's rule, verbatim: the per-hook `order` is the outer partition and\n // the enforce-sorted plugin list supplies the stable order inside it, so a\n // hook marked `order: \"pre\"` runs ahead of every normal-order handler even\n // when its plugin is `enforce: \"post\"`.\n const ordered = records\n .sort((left, right) =>\n left.orderRank - right.orderRank || left.enforceRank - right.enforceRank || left.index - right.index\n )\n .map(({ record }) => record)\n if (ordered.length > 0) entries.push([hook, Object.freeze(ordered)])\n }\n const cacheEnvironment = yield* snapshotCacheEnvironment(raw.cacheEnvironment, plugins)\n return Object.freeze({\n plugins,\n handlers: ImmutableMap.make(entries),\n kinds: known,\n parallelConcurrency,\n ...(cacheEnvironment === undefined ? {} : { cacheEnvironment })\n })\n })\n\n/**\n * Merges every resolved plugin layer left-to-right and supplies the detached\n * cache environment captured during resolution.\n *\n * @category combinators\n * @since 1.0.0-rc.0\n */\nexport const layer = <H>(resolved: Resolved<H>): Layer.Layer<any, PluginError, any> =>\n mergePluginLayers(resolved.plugins, resolved.cacheEnvironment)\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mBAA8B;AAE9B,aAAwB;AACxB,YAAuB;AAEvB,aAAwB;AAExB,mBAAgD;AAEhD,eAA0B;AAC1B,+BAAkC;AAClC,sCAAyC;AAEzC,yBAAkD;AAQ3C,MAAM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AO,OAAO,OAAO,CAAC,CAAC;AAAA,EACrE;AACA,QAAM,mBAAmB,WAAO,0DAAyB,IAAI,kBAAkB,OAAO;AACtF,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,UAAU,aAAa,KAAK,OAAO;AAAA,IACnC,OAAO;AAAA,IACP;AAAA,IACA,GAAI,qBAAqB,SAAY,CAAC,IAAI,EAAE,iBAAiB;AAAA,EAC/D,CAAC;AACH,CAAC;AASI,MAAM,QAAQ,CAAI,iBACvB,4CAAkB,SAAS,SAAS,SAAS,gBAAgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bounded cell-host plugin kernel: typed hooks, resolution and ordering,
|
|
3
|
+
* and the config pipeline.
|
|
4
|
+
*
|
|
5
|
+
* The public package contract is documented at
|
|
6
|
+
* {@link https://smithers.sh/docs/reference/api/plugin}, with the shipped host catalog in
|
|
7
|
+
* `packages/smithers/agent/src/CellPlugin.ts`. Durable
|
|
8
|
+
* engine extension remains dependency injection; this package does not expose
|
|
9
|
+
* an engine-wide lifecycle registry.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.0.0-rc.0
|
|
12
|
+
*/
|
|
13
|
+
import type * as Effect from "effect/Effect";
|
|
14
|
+
import type { FlowsConfig, ResolvedConfig } from "./Config.ts";
|
|
15
|
+
import type { ParallelHook, WaterfallHook } from "./Hooks.ts";
|
|
16
|
+
/**
|
|
17
|
+
* The shared kernel's base hook catalog.
|
|
18
|
+
*
|
|
19
|
+
* Declared here, in the package entry point, so that the documented
|
|
20
|
+
* augmentation specifier works: an interface can only be augmented in the
|
|
21
|
+
* module that declares it:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* declare module "@smthrs/plugin" {
|
|
25
|
+
* interface FlowsHooks {
|
|
26
|
+
* toolCall: SequentialHook<(ctx: ToolCallContext) => Effect.Effect<Option.Option<ToolOverride>>>
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Closed for dispatch, open for augmentation: the kernel dispatches only the
|
|
32
|
+
* config lifecycle below; a host supplies and dispatches its own catalog over
|
|
33
|
+
* the same augmented interface.
|
|
34
|
+
*
|
|
35
|
+
* Both startup hooks are context-free: `Kernel.make` runs them before any
|
|
36
|
+
* plugin layer exists and supplies no services of its own, so a handler that
|
|
37
|
+
* needs a service provides it inside the hook. A host whose startup hooks do
|
|
38
|
+
* require services declares a separate hook interface, and `Kernel.make` then
|
|
39
|
+
* surfaces those requirements as `Kernel.StartupContext<H>`.
|
|
40
|
+
*
|
|
41
|
+
* @category models
|
|
42
|
+
* @since 1.0.0-rc.0
|
|
43
|
+
*/
|
|
44
|
+
export interface FlowsHooks {
|
|
45
|
+
readonly config: WaterfallHook<(config: FlowsConfig) => Effect.Effect<Partial<FlowsConfig> | void, any, never>>;
|
|
46
|
+
readonly configResolved: ParallelHook<(config: ResolvedConfig) => Effect.Effect<void, any, never>>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @since 1.0.0-rc.0
|
|
50
|
+
* @category config
|
|
51
|
+
*/
|
|
52
|
+
export * as Config from "./Config.ts";
|
|
53
|
+
/**
|
|
54
|
+
* @since 1.0.0-rc.0
|
|
55
|
+
* @category hooks
|
|
56
|
+
*/
|
|
57
|
+
export * from "./Hooks.ts";
|
|
58
|
+
/**
|
|
59
|
+
* @since 1.0.0-rc.0
|
|
60
|
+
* @category startup
|
|
61
|
+
*/
|
|
62
|
+
export * as Kernel from "./Kernel.ts";
|
|
63
|
+
/**
|
|
64
|
+
* @since 1.0.0-rc.0
|
|
65
|
+
* @category models
|
|
66
|
+
*/
|
|
67
|
+
export * from "./Plugin.ts";
|
|
68
|
+
/**
|
|
69
|
+
* @since 1.0.0-rc.0
|
|
70
|
+
* @category errors
|
|
71
|
+
*/
|
|
72
|
+
export * from "./PluginError.ts";
|
|
73
|
+
/**
|
|
74
|
+
* @since 1.0.0-rc.0
|
|
75
|
+
* @category dispatch
|
|
76
|
+
*/
|
|
77
|
+
export * as Plugins from "./Plugins.ts";
|
|
78
|
+
/**
|
|
79
|
+
* @since 1.0.0-rc.0
|
|
80
|
+
* @category resolution
|
|
81
|
+
*/
|
|
82
|
+
export * as Resolve from "./Resolve.ts";
|
|
83
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,MAAM,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;IAC/G,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,MAAM,EAAE,cAAc,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;CACnG;AAED;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;GAGG;AACH,cAAc,YAAY,CAAA;AAE1B;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;GAGG;AACH,cAAc,aAAa,CAAA;AAE3B;;;GAGG;AACH,cAAc,kBAAkB,CAAA;AAEhC;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
Config: () => Config,
|
|
33
|
+
Kernel: () => Kernel,
|
|
34
|
+
Plugins: () => Plugins,
|
|
35
|
+
Resolve: () => Resolve
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
var Config = __toESM(require("./Config.js"), 1);
|
|
39
|
+
__reExport(index_exports, require("./Hooks.js"), module.exports);
|
|
40
|
+
var Kernel = __toESM(require("./Kernel.js"), 1);
|
|
41
|
+
__reExport(index_exports, require("./Plugin.js"), module.exports);
|
|
42
|
+
__reExport(index_exports, require("./PluginError.js"), module.exports);
|
|
43
|
+
var Plugins = __toESM(require("./Plugins.js"), 1);
|
|
44
|
+
var Resolve = __toESM(require("./Resolve.js"), 1);
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The bounded cell-host plugin kernel: typed hooks, resolution and ordering,\n * and the config pipeline.\n *\n * The public package contract is documented at\n * {@link https://smithers.sh/docs/reference/api/plugin}, with the shipped host catalog in\n * `packages/smithers/agent/src/CellPlugin.ts`. Durable\n * engine extension remains dependency injection; this package does not expose\n * an engine-wide lifecycle registry.\n *\n * @since 1.0.0-rc.0\n */\n\nimport type * as Effect from \"effect/Effect\"\nimport type { FlowsConfig, ResolvedConfig } from \"./Config.ts\"\nimport type { ParallelHook, WaterfallHook } from \"./Hooks.ts\"\n\n/**\n * The shared kernel's base hook catalog.\n *\n * Declared here, in the package entry point, so that the documented\n * augmentation specifier works: an interface can only be augmented in the\n * module that declares it:\n *\n * ```ts\n * declare module \"@smthrs/plugin\" {\n * interface FlowsHooks {\n * toolCall: SequentialHook<(ctx: ToolCallContext) => Effect.Effect<Option.Option<ToolOverride>>>\n * }\n * }\n * ```\n *\n * Closed for dispatch, open for augmentation: the kernel dispatches only the\n * config lifecycle below; a host supplies and dispatches its own catalog over\n * the same augmented interface.\n *\n * Both startup hooks are context-free: `Kernel.make` runs them before any\n * plugin layer exists and supplies no services of its own, so a handler that\n * needs a service provides it inside the hook. A host whose startup hooks do\n * require services declares a separate hook interface, and `Kernel.make` then\n * surfaces those requirements as `Kernel.StartupContext<H>`.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface FlowsHooks {\n readonly config: WaterfallHook<(config: FlowsConfig) => Effect.Effect<Partial<FlowsConfig> | void, any, never>>\n readonly configResolved: ParallelHook<(config: ResolvedConfig) => Effect.Effect<void, any, never>>\n}\n\n/**\n * @since 1.0.0-rc.0\n * @category config\n */\nexport * as Config from \"./Config.ts\"\n\n/**\n * @since 1.0.0-rc.0\n * @category hooks\n */\nexport * from \"./Hooks.ts\"\n\n/**\n * @since 1.0.0-rc.0\n * @category startup\n */\nexport * as Kernel from \"./Kernel.ts\"\n\n/**\n * @since 1.0.0-rc.0\n * @category models\n */\nexport * from \"./Plugin.ts\"\n\n/**\n * @since 1.0.0-rc.0\n * @category errors\n */\nexport * from \"./PluginError.ts\"\n\n/**\n * @since 1.0.0-rc.0\n * @category dispatch\n */\nexport * as Plugins from \"./Plugins.ts\"\n\n/**\n * @since 1.0.0-rc.0\n * @category resolution\n */\nexport * as Resolve from \"./Resolve.ts\"\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsDA,aAAwB;AAMxB,0BAAc,uBA5Dd;AAkEA,aAAwB;AAMxB,0BAAc,wBAxEd;AA8EA,0BAAc,6BA9Ed;AAoFA,cAAyB;AAMzB,cAAyB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inert JSON admission for plugin configuration and cache identity.
|
|
3
|
+
*
|
|
4
|
+
* Reflection is descriptor-only: accessors never execute, hostile proxies are
|
|
5
|
+
* refused, and accepted values are detached before they are frozen.
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
* @since 1.0.0-rc.0
|
|
9
|
+
*/
|
|
10
|
+
import * as BoundedJson from "@smthrs/canonical/BoundedJson";
|
|
11
|
+
/**
|
|
12
|
+
* Strict JSON value accepted by the boundary.
|
|
13
|
+
*
|
|
14
|
+
* @private
|
|
15
|
+
* @since 1.0.0-rc.0
|
|
16
|
+
*/
|
|
17
|
+
export type Json = BoundedJson.Json;
|
|
18
|
+
/**
|
|
19
|
+
* Resource bounds for one admitted tree.
|
|
20
|
+
*
|
|
21
|
+
* @private
|
|
22
|
+
* @since 1.0.0-rc.0
|
|
23
|
+
*/
|
|
24
|
+
export type Limits = BoundedJson.StrictLimits;
|
|
25
|
+
/**
|
|
26
|
+
* Successful admission.
|
|
27
|
+
*
|
|
28
|
+
* @private
|
|
29
|
+
* @since 1.0.0-rc.0
|
|
30
|
+
*/
|
|
31
|
+
export interface AdmissionSuccess {
|
|
32
|
+
readonly ok: true;
|
|
33
|
+
readonly value: Json;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Refusal with a stable value path.
|
|
37
|
+
*
|
|
38
|
+
* @private
|
|
39
|
+
* @since 1.0.0-rc.0
|
|
40
|
+
*/
|
|
41
|
+
export interface AdmissionFailure {
|
|
42
|
+
readonly ok: false;
|
|
43
|
+
readonly path: string;
|
|
44
|
+
readonly complaint: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Result of inert JSON admission.
|
|
48
|
+
*
|
|
49
|
+
* @private
|
|
50
|
+
* @since 1.0.0-rc.0
|
|
51
|
+
*/
|
|
52
|
+
export type Admission = AdmissionSuccess | AdmissionFailure;
|
|
53
|
+
/**
|
|
54
|
+
* Default configuration bounds.
|
|
55
|
+
*
|
|
56
|
+
* @private
|
|
57
|
+
* @since 1.0.0-rc.0
|
|
58
|
+
*/
|
|
59
|
+
export declare const defaultLimits: Limits;
|
|
60
|
+
/**
|
|
61
|
+
* Tests whether a string contains paired UTF-16 surrogate units.
|
|
62
|
+
*
|
|
63
|
+
* @private
|
|
64
|
+
* @since 1.0.0-rc.0
|
|
65
|
+
*/
|
|
66
|
+
export declare const isWellFormedText: (value: string) => boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Copies one strict JSON tree under explicit resource bounds.
|
|
69
|
+
*
|
|
70
|
+
* @private
|
|
71
|
+
* @since 1.0.0-rc.0
|
|
72
|
+
*/
|
|
73
|
+
export declare const admit: (input: unknown, limits?: Limits) => Admission;
|
|
74
|
+
/**
|
|
75
|
+
* Admits only a JSON record at the root.
|
|
76
|
+
*
|
|
77
|
+
* @private
|
|
78
|
+
* @since 1.0.0-rc.0
|
|
79
|
+
*/
|
|
80
|
+
export declare const record: (input: unknown, limits?: Limits) => AdmissionSuccess | AdmissionFailure;
|
|
81
|
+
/**
|
|
82
|
+
* Merges two independently admitted records, retaining unchanged subtrees.
|
|
83
|
+
* Both operands must come from successful admission, and the patch must be a
|
|
84
|
+
* fresh copy: their trees must be disjoint. Each output branch then comes from
|
|
85
|
+
* at most one location in either tree, preserving the no-repeated-reference
|
|
86
|
+
* invariant without walking retained subtrees. Limits apply to the result.
|
|
87
|
+
*
|
|
88
|
+
* @private
|
|
89
|
+
* @since 1.0.0-rc.0
|
|
90
|
+
*/
|
|
91
|
+
export declare const mergeRecords: (base: {
|
|
92
|
+
readonly [key: string]: Json;
|
|
93
|
+
}, patch: {
|
|
94
|
+
readonly [key: string]: Json;
|
|
95
|
+
}, limits?: Limits) => Admission;
|
|
96
|
+
//# sourceMappingURL=Boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Boundary.d.ts","sourceRoot":"","sources":["../../../src/internal/Boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,MAAM,IAAI,GAAG,WAAW,C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ames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Boundary_exports = {};
|
|
30
|
+
__export(Boundary_exports, {
|
|
31
|
+
admit: () => admit,
|
|
32
|
+
defaultLimits: () => defaultLimits,
|
|
33
|
+
isWellFormedText: () => isWellFormedText,
|
|
34
|
+
mergeRecords: () => mergeRecords,
|
|
35
|
+
record: () => record
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(Boundary_exports);
|
|
38
|
+
var BoundedJson = __toESM(require("@smthrs/canonical/BoundedJson"), 1);
|
|
39
|
+
const defaultLimits = Object.freeze({
|
|
40
|
+
maxBytes: 1024 * 1024,
|
|
41
|
+
maxDepth: 64,
|
|
42
|
+
maxMembers: 4096,
|
|
43
|
+
maxNodes: 8192,
|
|
44
|
+
maxStringBytes: 64 * 1024,
|
|
45
|
+
maxKeyBytes: 1024
|
|
46
|
+
});
|
|
47
|
+
const isWellFormedText = (value) => value.isWellFormed();
|
|
48
|
+
const childPath = (path, key) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? `${path}.${key}` : `${path}[${JSON.stringify(key)}]`;
|
|
49
|
+
const encodedStringBytes = (value) => BoundedJson.encodedStringBytes(value);
|
|
50
|
+
const boundedPath = (path) => {
|
|
51
|
+
let bytes = 2 + 3;
|
|
52
|
+
let prefix = "";
|
|
53
|
+
for (const character of path) {
|
|
54
|
+
const point = character.codePointAt(0);
|
|
55
|
+
bytes += character === '"' || character === "\\" ? 2 : point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
|
|
56
|
+
if (bytes > 192) return `${prefix}...`;
|
|
57
|
+
prefix += character;
|
|
58
|
+
}
|
|
59
|
+
return path;
|
|
60
|
+
};
|
|
61
|
+
const snapshots = /* @__PURE__ */ new WeakMap();
|
|
62
|
+
const scalarTotals = (bytes) => ({ bytes, members: 0, nodes: 1, depth: 0 });
|
|
63
|
+
const total = (entries) => {
|
|
64
|
+
const totals = { bytes: 2 + Math.max(0, entries.size - 1), members: entries.size, nodes: 1, depth: 1 };
|
|
65
|
+
for (const entry of entries.values()) {
|
|
66
|
+
totals.bytes += entry.keyBytes + entry.totals.bytes;
|
|
67
|
+
totals.members += entry.totals.members;
|
|
68
|
+
totals.nodes += entry.totals.nodes;
|
|
69
|
+
totals.depth = Math.max(totals.depth, 1 + entry.totals.depth);
|
|
70
|
+
}
|
|
71
|
+
return totals;
|
|
72
|
+
};
|
|
73
|
+
const remember = (value) => {
|
|
74
|
+
const entries = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const [key, child] of Object.entries(value)) {
|
|
76
|
+
entries.set(key, {
|
|
77
|
+
keyBytes: Array.isArray(value) ? 0 : encodedStringBytes(key) + 1,
|
|
78
|
+
totals: typeof child === "object" && child !== null ? snapshots.get(child).totals : scalarTotals(typeof child === "string" ? encodedStringBytes(child) : String(child).length)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
snapshots.set(value, { totals: total(entries), entries });
|
|
82
|
+
};
|
|
83
|
+
const admit = (input, limits = defaultLimits) => {
|
|
84
|
+
const result = BoundedJson.admitStrict(input, limits, {
|
|
85
|
+
ordinaryRecords: true,
|
|
86
|
+
boundedText: true,
|
|
87
|
+
onContainer: remember
|
|
88
|
+
});
|
|
89
|
+
return result.ok ? result : {
|
|
90
|
+
...result,
|
|
91
|
+
path: boundedPath(result.path),
|
|
92
|
+
complaint: result.complaint === "must be dense and have no extra properties" ? "must be a dense array with no extra properties" : result.complaint
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
const record = (input, limits = defaultLimits) => {
|
|
96
|
+
const admitted = admit(input, limits);
|
|
97
|
+
return admitted.ok && (admitted.value === null || Array.isArray(admitted.value) || typeof admitted.value !== "object") ? { ok: false, path: "$", complaint: "must be a JSON record" } : admitted;
|
|
98
|
+
};
|
|
99
|
+
const mergeRecords = (base, patch, limits = defaultLimits) => {
|
|
100
|
+
const merge = (left, right, path) => {
|
|
101
|
+
const entries = new Map(snapshots.get(left).entries);
|
|
102
|
+
const result = { ...left };
|
|
103
|
+
for (const [key, entry] of snapshots.get(right).entries) {
|
|
104
|
+
const previous = left[key];
|
|
105
|
+
const next = right[key];
|
|
106
|
+
if (typeof previous === "object" && previous !== null && !Array.isArray(previous) && typeof next === "object" && next !== null && !Array.isArray(next)) {
|
|
107
|
+
const merged = merge(
|
|
108
|
+
previous,
|
|
109
|
+
next,
|
|
110
|
+
childPath(path, key)
|
|
111
|
+
);
|
|
112
|
+
if (!merged.ok) return merged;
|
|
113
|
+
result[key] = merged.value;
|
|
114
|
+
entries.set(key, { keyBytes: entry.keyBytes, totals: snapshots.get(merged.value).totals });
|
|
115
|
+
} else {
|
|
116
|
+
result[key] = next;
|
|
117
|
+
entries.set(key, entry);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const totals = total(entries);
|
|
121
|
+
const complaint = totals.members > limits.maxMembers ? `exceeds the ${limits.maxMembers}-member limit` : totals.nodes > limits.maxNodes ? `exceeds the ${limits.maxNodes}-node limit` : totals.bytes > limits.maxBytes ? `exceeds the ${limits.maxBytes}-byte limit` : totals.depth > limits.maxDepth ? `exceeds the depth limit of ${limits.maxDepth}` : void 0;
|
|
122
|
+
if (complaint !== void 0) return { ok: false, path: boundedPath(path), complaint };
|
|
123
|
+
Object.freeze(result);
|
|
124
|
+
snapshots.set(result, { totals, entries });
|
|
125
|
+
return { ok: true, value: result };
|
|
126
|
+
};
|
|
127
|
+
return merge(base, patch, "$");
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=Boundary.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/internal/Boundary.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Inert JSON admission for plugin configuration and cache identity.\n *\n * Reflection is descriptor-only: accessors never execute, hostile proxies are\n * refused, and accepted values are detached before they are frozen.\n *\n * @private\n * @since 1.0.0-rc.0\n */\n\nimport * as BoundedJson from \"@smthrs/canonical/BoundedJson\"\n\n/**\n * Strict JSON value accepted by the boundary.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport type Json = BoundedJson.Json\n\n/**\n * Resource bounds for one admitted tree.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport type Limits = BoundedJson.StrictLimits\n\n/**\n * Successful admission.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport interface AdmissionSuccess {\n readonly ok: true\n readonly value: Json\n}\n\n/**\n * Refusal with a stable value path.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport interface AdmissionFailure {\n readonly ok: false\n readonly path: string\n readonly complaint: string\n}\n\n/**\n * Result of inert JSON admission.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport type Admission = AdmissionSuccess | AdmissionFailure\n\n/**\n * Default configuration bounds.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const defaultLimits: Limits = Object.freeze({\n maxBytes: 1024 * 1024,\n maxDepth: 64,\n maxMembers: 4_096,\n maxNodes: 8_192,\n maxStringBytes: 64 * 1024,\n maxKeyBytes: 1_024\n})\n\n/**\n * Tests whether a string contains paired UTF-16 surrogate units.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const isWellFormedText = (value: string): boolean => value.isWellFormed()\n\nconst childPath = (path: string, key: string): string =>\n /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? `${path}.${key}` : `${path}[${JSON.stringify(key)}]`\n\nconst encodedStringBytes = (value: string): number => BoundedJson.encodedStringBytes(value)!\n\n// Paths contain only well-formed text and JSON-escaped keys. Count their JSON\n// bytes without encoding the whole path, reserving quotes and a truncation marker.\nconst boundedPath = (path: string): string => {\n let bytes = 2 + 3\n let prefix = \"\"\n for (const character of path) {\n const point = character.codePointAt(0)!\n bytes += character === \"\\\"\" || character === \"\\\\\"\n ? 2\n : point <= 0x7f\n ? 1\n : point <= 0x7ff\n ? 2\n : point <= 0xffff\n ? 3\n : 4\n if (bytes > 192) return `${prefix}...`\n prefix += character\n }\n return path\n}\n\ninterface Totals {\n bytes: number\n members: number\n nodes: number\n depth: number\n}\n\ninterface Entry {\n readonly keyBytes: number\n readonly totals: Totals\n}\n\ninterface Snapshot {\n readonly totals: Totals\n readonly entries: Map<string, Entry>\n}\n\n// Only detached containers constructed here enter this map. Mutable caller\n// objects and Object.freeze alone never establish admission.\nconst snapshots = new WeakMap<object, Snapshot>()\n\nconst scalarTotals = (bytes: number): Totals => ({ bytes, members: 0, nodes: 1, depth: 0 })\n\nconst total = (entries: ReadonlyMap<string, Entry>): Totals => {\n const totals: Totals = { bytes: 2 + Math.max(0, entries.size - 1), members: entries.size, nodes: 1, depth: 1 }\n for (const entry of entries.values()) {\n totals.bytes += entry.keyBytes + entry.totals.bytes\n totals.members += entry.totals.members\n totals.nodes += entry.totals.nodes\n totals.depth = Math.max(totals.depth, 1 + entry.totals.depth)\n }\n return totals\n}\n\nconst remember = (value: ReadonlyArray<Json> | { readonly [key: string]: Json }): void => {\n const entries = new Map<string, Entry>()\n for (const [key, child] of Object.entries(value)) {\n entries.set(key, {\n keyBytes: Array.isArray(value) ? 0 : encodedStringBytes(key) + 1,\n totals: typeof child === \"object\" && child !== null ?\n snapshots.get(child)!.totals\n : scalarTotals(typeof child === \"string\" ? encodedStringBytes(child) : String(child).length)\n })\n }\n snapshots.set(value, { totals: total(entries), entries })\n}\n\n/**\n * Copies one strict JSON tree under explicit resource bounds.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const admit = (input: unknown, limits: Limits = defaultLimits): Admission => {\n const result = BoundedJson.admitStrict(input, limits, {\n ordinaryRecords: true,\n boundedText: true,\n onContainer: remember\n })\n return result.ok ? result : {\n ...result,\n path: boundedPath(result.path),\n complaint: result.complaint === \"must be dense and have no extra properties\"\n ? \"must be a dense array with no extra properties\" :\n result.complaint\n }\n}\n\n/**\n * Admits only a JSON record at the root.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const record = (\n input: unknown,\n limits: Limits = defaultLimits\n): AdmissionSuccess | AdmissionFailure => {\n const admitted = admit(input, limits)\n return admitted.ok && (admitted.value === null || Array.isArray(admitted.value) || typeof admitted.value !== \"object\")\n ? { ok: false, path: \"$\", complaint: \"must be a JSON record\" }\n : admitted\n}\n\n/**\n * Merges two independently admitted records, retaining unchanged subtrees.\n * Both operands must come from successful admission, and the patch must be a\n * fresh copy: their trees must be disjoint. Each output branch then comes from\n * at most one location in either tree, preserving the no-repeated-reference\n * invariant without walking retained subtrees. Limits apply to the result.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const mergeRecords = (\n base: { readonly [key: string]: Json },\n patch: { readonly [key: string]: Json },\n limits: Limits = defaultLimits\n): Admission => {\n const merge = (\n left: { readonly [key: string]: Json },\n right: { readonly [key: string]: Json },\n path: string\n ): Admission => {\n const entries = new Map(snapshots.get(left)!.entries)\n const result = { ...left }\n for (const [key, entry] of snapshots.get(right)!.entries) {\n const previous = left[key]\n const next = right[key]!\n if (\n typeof previous === \"object\" && previous !== null && !Array.isArray(previous) &&\n typeof next === \"object\" && next !== null && !Array.isArray(next)\n ) {\n const merged = merge(\n previous as { readonly [key: string]: Json },\n next as { readonly [key: string]: Json },\n childPath(path, key)\n )\n if (!merged.ok) return merged\n result[key] = merged.value\n entries.set(key, { keyBytes: entry.keyBytes, totals: snapshots.get(merged.value as object)!.totals })\n } else {\n result[key] = next\n entries.set(key, entry)\n }\n }\n const totals = total(entries)\n const complaint = totals.members > limits.maxMembers ?\n `exceeds the ${limits.maxMembers}-member limit`\n : totals.nodes > limits.maxNodes ?\n `exceeds the ${limits.maxNodes}-node limit`\n : totals.bytes > limits.maxBytes ?\n `exceeds the ${limits.maxBytes}-byte limit`\n : totals.depth > limits.maxDepth ?\n `exceeds the depth limit of ${limits.maxDepth}`\n : undefined\n if (complaint !== undefined) return { ok: false, path: boundedPath(path), complaint }\n Object.freeze(result)\n snapshots.set(result, { totals, entries })\n return { ok: true, value: result }\n }\n return merge(base, patch, \"$\")\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,kBAA6B;AAuDtB,MAAM,gBAAwB,OAAO,OAAO;AAAA,EACjD,UAAU,OAAO;AAAA,EACjB,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,gBAAgB,KAAK;AAAA,EACrB,aAAa;AACf,CAAC;AAQM,MAAM,mBAAmB,CAAC,UAA2B,MAAM,aAAa;AAE/E,MAAM,YAAY,CAAC,MAAc,QAC/B,6BAA6B,KAAK,G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,UACA;AAAA,UACA,UAAU,MAAM,GAAG;AAAA,QACrB;AACA,YAAI,CAAC,OAAO,GAAI,QAAO;AACvB,eAAO,GAAG,IAAI,OAAO;AACrB,gBAAQ,IAAI,KAAK,EAAE,UAAU,MAAM,UAAU,QAAQ,UAAU,IAAI,OAAO,KAAe,EAAG,OAAO,CAAC;AAAA,MACtG,OAAO;AACL,eAAO,GAAG,IAAI;AACd,gBAAQ,IAAI,KAAK,KAAK;AAAA,MACxB;AAAA,IACF;AACA,UAAM,SAAS,MAAM,OAAO;AAC5B,UAAM,YAAY,OAAO,UAAU,OAAO,aACxC,eAAe,OAAO,UAAU,kBAC9B,OAAO,QAAQ,OAAO,WACxB,eAAe,OAAO,QAAQ,gBAC5B,OAAO,QAAQ,OAAO,WACxB,eAAe,OAAO,QAAQ,gBAC5B,OAAO,QAAQ,OAAO,WACxB,8BAA8B,OAAO,QAAQ,KAC3C;AACJ,QAAI,cAAc,OAAW,QAAO,EAAE,IAAI,OAAO,MAAM,YAAY,IAAI,GAAG,UAAU;AACpF,WAAO,OAAO,MAAM;AACpB,cAAU,IAAI,QAAQ,EAAE,QAAQ,QAAQ,CAAC;AACzC,WAAO,EAAE,IAAI,MAAM,OAAO,OAAO;AAAA,EACnC;AACA,SAAO,MAAM,MAAM,OAAO,GAAG;AAC/B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect layer composition for a resolved plugin list.
|
|
3
|
+
*
|
|
4
|
+
* @private
|
|
5
|
+
* @since 1.0.0-rc.0
|
|
6
|
+
*/
|
|
7
|
+
import { Action } from "@smthrs/flow";
|
|
8
|
+
import * as Layer from "effect/Layer";
|
|
9
|
+
import type { FlowsPlugin } from "../Plugin.ts";
|
|
10
|
+
import { PluginError } from "../PluginError.ts";
|
|
11
|
+
/**
|
|
12
|
+
* Merges plugin layers left-to-right, wrapping each build failure as
|
|
13
|
+
* `layer_failed`, then seals the cache environment: it is supplied beneath
|
|
14
|
+
* the plugin layers and overrides anything they output, and an absent
|
|
15
|
+
* declaration stays absent.
|
|
16
|
+
*
|
|
17
|
+
* @private
|
|
18
|
+
* @since 1.0.0-rc.0
|
|
19
|
+
*/
|
|
20
|
+
export declare const mergePluginLayers: <H>(plugins: ReadonlyArray<FlowsPlugin<H>>, cacheEnvironment: Action.CacheEnvironment | undefined) => Layer.Layer<any, PluginError, any>;
|
|
21
|
+
//# sourceMappingURL=mergePluginLayers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergePluginLayers.d.ts","sourceRoot":"","sources":["../../../src/internal/mergePluginLayers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EACjC,SAAS,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EACtC,kBAAkB,MAAM,CAAC,gBAAgB,GAAG,SAAS,KACpD,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,CA+BnC,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var mergePluginLayers_exports = {};
|
|
30
|
+
__export(mergePluginLayers_exports, {
|
|
31
|
+
mergePluginLayers: () => mergePluginLayers
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(mergePluginLayers_exports);
|
|
34
|
+
var import_flow = require("@smthrs/flow");
|
|
35
|
+
var Effect = __toESM(require("effect/Effect"), 1);
|
|
36
|
+
var Layer = __toESM(require("effect/Layer"), 1);
|
|
37
|
+
var import_PluginError = require("../PluginError.js");
|
|
38
|
+
const mergePluginLayers = (plugins, cacheEnvironment) => {
|
|
39
|
+
const layers = plugins.flatMap(
|
|
40
|
+
(plugin) => plugin.layer ? [
|
|
41
|
+
Layer.catchCause(plugin.layer, (cause) => Layer.effectDiscard(
|
|
42
|
+
Effect.fail(
|
|
43
|
+
new import_PluginError.PluginError({
|
|
44
|
+
code: "layer_failed",
|
|
45
|
+
message: `plugin "${plugin.name}" failed to build its layer`,
|
|
46
|
+
plugin: plugin.name,
|
|
47
|
+
cause
|
|
48
|
+
})
|
|
49
|
+
)
|
|
50
|
+
))
|
|
51
|
+
] : []
|
|
52
|
+
);
|
|
53
|
+
const merged = layers.length === 0 ? Layer.empty : layers.reduce((accumulated, next) => Layer.provideMerge(next, accumulated));
|
|
54
|
+
const environment = Layer.succeed(import_flow.Action.CurrentCacheEnvironment)(cacheEnvironment);
|
|
55
|
+
return Layer.merge(Layer.provideMerge(merged, environment), environment);
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=mergePluginLayers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/internal/mergePluginLayers.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Effect layer composition for a resolved plugin list.\n *\n * @private\n * @since 1.0.0-rc.0\n */\n\nimport { Action } from \"@smthrs/flow\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport type { FlowsPlugin } from \"../Plugin.ts\"\nimport { PluginError } from \"../PluginError.ts\"\n\n/**\n * Merges plugin layers left-to-right, wrapping each build failure as\n * `layer_failed`, then seals the cache environment: it is supplied beneath\n * the plugin layers and overrides anything they output, and an absent\n * declaration stays absent.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const mergePluginLayers = <H>(\n plugins: ReadonlyArray<FlowsPlugin<H>>,\n cacheEnvironment: Action.CacheEnvironment | undefined\n): Layer.Layer<any, PluginError, any> => {\n const layers = plugins.flatMap((plugin) =>\n plugin.layer\n ? [\n Layer.catchCause(plugin.layer, (cause) =>\n Layer.effectDiscard(\n Effect.fail(\n new PluginError({\n code: \"layer_failed\",\n message: `plugin \"${plugin.name}\" failed to build its layer`,\n plugin: plugin.name,\n cause\n })\n )\n )) as Layer.Layer<any, PluginError, any>\n ]\n : []\n )\n const merged = (layers.length === 0\n ? Layer.empty\n : layers.reduce((accumulated, next) => Layer.provideMerge(next, accumulated))) as Layer.Layer<any, PluginError, any>\n // The sealed environment is provided beneath the plugin layers so they can\n // read it, then merged last so it overrides any plugin output. An absent\n // declaration is sealed as `undefined`, so no plugin layer can declare or\n // replace the composition's cache identity.\n const environment = Layer.succeed(Action.CurrentCacheEnvironment)(cacheEnvironment) as unknown as Layer.Layer<\n any,\n PluginError,\n any\n >\n return Layer.merge(Layer.provideMerge(merged, environment), environment)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,kBAAuB;AACvB,aAAwB;AACxB,YAAuB;AAEvB,yBAA4B;AAWrB,MAAM,oBAAoB,CAC/B,SACA,qBACuC;AACvC,QAAM,SAAS,QAAQ;AAAA,IAAQ,CAAC,WAC9B,OAAO,QACH;AAAA,MACA,MAAM,WAAW,OAAO,OAAO,CAAC,UAC9B,MAAM;AAAA,QACJ,OAAO;AAAA,UACL,IAAI,+BAAY;AAAA,YACd,MAAM;AAAA,YACN,SAAS,WAAW,OAAO,IAAI;AAAA,YAC/B,QAAQ,OAAO;AAAA,YACf;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACL,IACE,CAAC;AAAA,EACP;AACA,QAAM,SAAU,OAAO,WAAW,IAC9B,MAAM,QACN,OAAO,OAAO,CAAC,aAAa,SAAS,MAAM,aAAa,MAAM,WAAW,CAAC;AAK9E,QAAM,cAAc,MAAM,QAAQ,mBAAO,uBAAuB,EAAE,gBAAgB;AAKlF,SAAO,MAAM,MAAM,MAAM,aAAa,QAAQ,WAAW,GAAG,WAAW;AACzE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache identity admission for a resolved plugin list.
|
|
3
|
+
*
|
|
4
|
+
* @private
|
|
5
|
+
* @since 1.0.0-rc.0
|
|
6
|
+
*/
|
|
7
|
+
import { Action } from "@smthrs/flow";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import type { FlowsPlugin } from "../Plugin.ts";
|
|
10
|
+
import { PluginError } from "../PluginError.ts";
|
|
11
|
+
/**
|
|
12
|
+
* Admits a caller cache environment and prepends one escaped `name@version`
|
|
13
|
+
* identity per plugin, in resolved order. An absent input stays absent.
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
* @since 1.0.0-rc.0
|
|
17
|
+
*/
|
|
18
|
+
export declare const snapshotCacheEnvironment: <H>(input: unknown, plugins: ReadonlyArray<FlowsPlugin<H>>) => Effect.Effect<Action.CacheEnvironment | undefined, PluginError>;
|
|
19
|
+
//# sourceMappingURL=snapshotCacheEnvironment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotCacheEnvironment.d.ts","sourceRoot":"","sources":["../../../src/internal/snapshotCacheEnvironment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAO/C;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,EACxC,OAAO,OAAO,EACd,SAAS,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KACrC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,GAAG,SAAS,EAAE,WAAW,CAgDhE,CAAA"}
|