@smthrs/plugin 1.0.0-rc.6 → 1.0.0-rc.8
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/README.md +3 -1
- package/dist/cjs/Resolve.d.ts.map +1 -1
- package/dist/cjs/Resolve.js +11 -10
- package/dist/cjs/Resolve.js.map +2 -2
- package/dist/cjs/internal/snapshotCacheEnvironment.d.ts +6 -2
- package/dist/cjs/internal/snapshotCacheEnvironment.d.ts.map +1 -1
- package/dist/cjs/internal/snapshotCacheEnvironment.js +2 -2
- package/dist/cjs/internal/snapshotCacheEnvironment.js.map +2 -2
- package/dist/esm/Resolve.d.ts.map +1 -1
- package/dist/esm/Resolve.js +12 -11
- package/dist/esm/Resolve.js.map +1 -1
- package/dist/esm/internal/snapshotCacheEnvironment.d.ts +6 -2
- package/dist/esm/internal/snapshotCacheEnvironment.d.ts.map +1 -1
- package/dist/esm/internal/snapshotCacheEnvironment.js +4 -3
- package/dist/esm/internal/snapshotCacheEnvironment.js.map +1 -1
- package/docs/README.md +3 -1
- package/docs/guides/cache-identity.md +1 -1
- package/docs/installation.md +5 -1
- package/docs/quickstart.md +2 -1
- package/package.json +3 -3
- package/src/Resolve.ts +14 -13
- package/src/internal/snapshotCacheEnvironment.ts +5 -4
package/README.md
CHANGED
|
@@ -12,7 +12,9 @@ A typed, bounded plugin kernel for Effect programs: Vite's plugin model, with
|
|
|
12
12
|
hooks that are ordinary Effects, ordering that follows Vite's rules exactly, and
|
|
13
13
|
a resolution boundary that copies every value a caller hands it.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
```bash
|
|
16
|
+
npm install @smthrs/plugin@next effect
|
|
17
|
+
```
|
|
16
18
|
|
|
17
19
|
```ts
|
|
18
20
|
import { type FlowsPlugin, Kernel } from "@smthrs/plugin"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resolve.d.ts","sourceRoot":"","sources":["../../src/Resolve.ts"],"names":[],"mappings":"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 -228,18 +228,18 @@ const flatten = (input) => {
|
|
|
228
228
|
}
|
|
229
229
|
return output;
|
|
230
230
|
};
|
|
231
|
-
const included = (plugin, config, target) => {
|
|
231
|
+
const included = ({ path, plugin }, config, target) => {
|
|
232
232
|
const apply = plugin.apply;
|
|
233
233
|
if (apply === void 0) return Effect.succeed(true);
|
|
234
234
|
if (typeof apply !== "function") return Effect.succeed(apply === target);
|
|
235
235
|
return Effect.try({
|
|
236
236
|
try: () => apply(config),
|
|
237
|
-
catch: () => failure("apply_failed", `plugin "${plugin.name}" apply predicate failed`,
|
|
237
|
+
catch: () => failure("apply_failed", `plugin "${plugin.name}" apply predicate failed`, `${path}.apply`, {
|
|
238
238
|
plugin: plugin.name
|
|
239
239
|
})
|
|
240
240
|
}).pipe(
|
|
241
241
|
Effect.flatMap(
|
|
242
|
-
(result) => typeof result === "boolean" ? Effect.succeed(result) : Effect.fail(invalidPlugin(
|
|
242
|
+
(result) => typeof result === "boolean" ? Effect.succeed(result) : Effect.fail(invalidPlugin(`${path}.apply`, "predicate must return a boolean", { plugin: plugin.name }))
|
|
243
243
|
)
|
|
244
244
|
);
|
|
245
245
|
};
|
|
@@ -276,7 +276,7 @@ const resolve = (input, options = {}, configOverride) => Effect.gen(function* ()
|
|
|
276
276
|
catch: (cause) => cause instanceof import_PluginError.PluginError ? cause : invalidPlugin("$", "could not be inspected without executing user code")
|
|
277
277
|
});
|
|
278
278
|
const target = raw.target ?? "engine";
|
|
279
|
-
const selected = yield* Effect.filter(admitted, (
|
|
279
|
+
const selected = yield* Effect.filter(admitted, (entry) => included(entry, config, target));
|
|
280
280
|
let handlerCount = 0;
|
|
281
281
|
for (const { path, plugin } of selected) {
|
|
282
282
|
const pluginHooks = plugin.hooks;
|
|
@@ -301,20 +301,21 @@ const resolve = (input, options = {}, configOverride) => Effect.gen(function* ()
|
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
const seen = /* @__PURE__ */ new Set();
|
|
304
|
-
for (const { plugin } of selected) {
|
|
304
|
+
for (const { path, plugin } of selected) {
|
|
305
305
|
if (seen.has(plugin.name)) {
|
|
306
306
|
return yield* Effect.fail(failure(
|
|
307
307
|
"duplicate_name",
|
|
308
308
|
`duplicate plugin name "${plugin.name}"`,
|
|
309
|
-
|
|
309
|
+
`${path}.name`,
|
|
310
310
|
{ plugin: plugin.name }
|
|
311
311
|
));
|
|
312
312
|
}
|
|
313
313
|
seen.add(plugin.name);
|
|
314
314
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
);
|
|
315
|
+
const orderedEntries = selected.map((entry, index) => ({ entry, index })).sort(
|
|
316
|
+
(left, right) => rank(left.entry.plugin.enforce) - rank(right.entry.plugin.enforce) || left.index - right.index
|
|
317
|
+
).map(({ entry }) => entry);
|
|
318
|
+
const plugins = Object.freeze(orderedEntries.map(({ plugin }) => plugin));
|
|
318
319
|
const entries = [];
|
|
319
320
|
for (const hook of Object.keys(known)) {
|
|
320
321
|
const records = [];
|
|
@@ -330,7 +331,7 @@ const resolve = (input, options = {}, configOverride) => Effect.gen(function* ()
|
|
|
330
331
|
).map(({ record }) => record);
|
|
331
332
|
if (ordered.length > 0) entries.push([hook, Object.freeze(ordered)]);
|
|
332
333
|
}
|
|
333
|
-
const cacheEnvironment = yield* (0, import_snapshotCacheEnvironment.snapshotCacheEnvironment)(raw.cacheEnvironment,
|
|
334
|
+
const cacheEnvironment = yield* (0, import_snapshotCacheEnvironment.snapshotCacheEnvironment)(raw.cacheEnvironment, orderedEntries);
|
|
334
335
|
return Object.freeze({
|
|
335
336
|
plugins,
|
|
336
337
|
handlers: ImmutableMap.make(entries),
|
package/dist/cjs/Resolve.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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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Q,MAAM,2CAA2C;AAC5G,aAAO,IAAI,QAAQ,KAAK;AACxB,YAAM,SAAS,QAAQ,MAAM;AAG7B,UAAI,SAAS,0BAA0B,QAAQ,MAAM,QAAQ;AAC3D,cAAM,QAAQ,kBAAkB,4BAA4B,uBAAuB,eAAe,QAAQ,IAAI;AAAA,MAChH;AACA,YAAM,OAAO,QAAQ,QAAQ,QAAQ,KAAK;AAC1C,UAAI,KAAK,WAAW,SAAS,KAAK,CAAC,KAAK,SAAS,QAAQ,GAAG;AAC1D,cAAM,cAAc,QAAQ,MAAM,uDAAuD;AAAA,MAC3F;AACA,eAAS,QAAQ,SAAS,GAAG,SAAS,GAAG,SAAS;AAChD,cAAM,aAAa,OAAO,yBAAyB,QAAQ,OAAO,OAAO,KAAK,CAAC;AAC/E,YAAI,eAAe,UAAa,EAAE,WAAW,eAAe,CAAC,WAAW,YAAY;AAClF,gBAAM,cAAc,GAAG,QAAQ,IAAI,IAAI,KAAK,KAAK,qCAAqC;AAAA,QACxF;AACA,cAAM,KAAK,EAAE,OAAO,WAAW,OAAO,MAAM,GAAG,QAAQ,IAAI,IAAI,KAAK,KAAK,OAAO,QAAQ,QAAQ,EAAE,CAAC;AAAA,MACrG;AACA;AAAA,IACF;AACA,WAAO,KAAK,OAAO,OAAO,EAAE,QAAQ,eAAkB,QAAQ,OAAO,QAAQ,IAAI,GAAG,MAAM,QAAQ,KAAK,CAAC,CAAC;AACzG,QAAI,OAAO,SAAS,gBAAgB;AAClC,YAAM,QAAQ,kBAAkB,4BAA4B,cAAc,iBAAiB,QAAQ,IAAI;AAAA,IACzG;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,WAAW,CACf,
|
|
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 { path, plugin }: AdmittedPlugin<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`, `${path}.apply`, {\n plugin: plugin.name\n })\n }).pipe(\n Effect.flatMap((result) =>\n typeof result === \"boolean\"\n ? Effect.succeed(result)\n : Effect.fail(invalidPlugin(`${path}.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, (entry) => included(entry, 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 { path, 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 `${path}.name`,\n { plugin: plugin.name }\n ))\n }\n seen.add(plugin.name)\n }\n\n const orderedEntries = selected\n .map((entry, index) => ({ entry, index }))\n .sort((left, right) =>\n rank(left.entry.plugin.enforce) - rank(right.entry.plugin.enforce) || left.index - right.index\n )\n .map(({ entry }) => entry)\n const plugins = Object.freeze(orderedEntries.map(({ plugin }) => plugin))\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, orderedEntries)\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,qBAAqB;AAQ3B,MAAM,iBAAiB;AAQvB,MAAM,kB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;AAC7B,QAAI,QAAQ,SAAS,EAAG,SAAQ,KAAK,CAAC,MAAM,OAAO,OAAO,OAAO,CAAC,CAAC;AAAA,EACrE;AACA,QAAM,mBAAmB,WAAO,0DAAyB,IAAI,kBAAkB,cAAc;AAC7F,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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,10 +10,14 @@ import type { FlowsPlugin } from "../Plugin.ts";
|
|
|
10
10
|
import { PluginError } from "../PluginError.ts";
|
|
11
11
|
/**
|
|
12
12
|
* Admits a caller cache environment and prepends one escaped `name@version`
|
|
13
|
-
* identity per plugin, in resolved order. An absent input stays absent.
|
|
13
|
+
* identity per plugin, in resolved order. An absent input stays absent. A
|
|
14
|
+
* versionless plugin is refused at the dollar-path it was admitted from.
|
|
14
15
|
*
|
|
15
16
|
* @private
|
|
16
17
|
* @since 1.0.0-rc.0
|
|
17
18
|
*/
|
|
18
|
-
export declare const snapshotCacheEnvironment: <H>(input: unknown, plugins: ReadonlyArray<
|
|
19
|
+
export declare const snapshotCacheEnvironment: <H>(input: unknown, plugins: ReadonlyArray<{
|
|
20
|
+
readonly plugin: FlowsPlugin<H>;
|
|
21
|
+
readonly path: string;
|
|
22
|
+
}>) => Effect.Effect<Action.CacheEnvironment | undefined, PluginError>;
|
|
19
23
|
//# sourceMappingURL=snapshotCacheEnvironment.d.ts.map
|
|
@@ -1 +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
|
|
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;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,EACxC,OAAO,OAAO,EACd,SAAS,aAAa,CAAC;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,KACjF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,GAAG,SAAS,EAAE,WAAW,CAgDhE,CAAA"}
|
|
@@ -43,13 +43,13 @@ const escapePluginIdentityPart = (value) => (
|
|
|
43
43
|
const snapshotCacheEnvironment = (input, plugins) => {
|
|
44
44
|
if (input === void 0) return Effect.succeed(void 0);
|
|
45
45
|
const pluginIdentities = [];
|
|
46
|
-
for (const plugin of plugins) {
|
|
46
|
+
for (const { path, plugin } of plugins) {
|
|
47
47
|
if (plugin.version === void 0) {
|
|
48
48
|
return Effect.fail(
|
|
49
49
|
new import_PluginError.PluginError({
|
|
50
50
|
code: "cache_environment_invalid",
|
|
51
51
|
message: `cache environment requires a version for plugin "${plugin.name}"`,
|
|
52
|
-
path:
|
|
52
|
+
path: `${path}.version`,
|
|
53
53
|
plugin: plugin.name
|
|
54
54
|
})
|
|
55
55
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/internal/snapshotCacheEnvironment.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Cache identity admission 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 Schema from \"effect/Schema\"\nimport type { FlowsPlugin } from \"../Plugin.ts\"\nimport { PluginError } from \"../PluginError.ts\"\nimport * as Boundary from \"./Boundary.ts\"\n\nconst escapePluginIdentityPart = (value: string): string =>\n // Percent must be escaped first so literal escape-looking text remains distinct from the `@` escape added next.\n value.replaceAll(\"%\", \"%25\").replaceAll(\"@\", \"%40\")\n\n/**\n * Admits a caller cache environment and prepends one escaped `name@version`\n * identity per plugin, in resolved order. An absent input stays absent.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const snapshotCacheEnvironment = <H>(\n input: unknown,\n plugins: ReadonlyArray<FlowsPlugin<H
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,kBAAuB;AACvB,aAAwB;AACxB,aAAwB;AAExB,yBAA4B;AAC5B,eAA0B;AAE1B,MAAM,2BAA2B,CAAC;AAAA;AAAA,EAEhC,MAAM,WAAW,KAAK,KAAK,EAAE,WAAW,KAAK,KAAK;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * Cache identity admission 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 Schema from \"effect/Schema\"\nimport type { FlowsPlugin } from \"../Plugin.ts\"\nimport { PluginError } from \"../PluginError.ts\"\nimport * as Boundary from \"./Boundary.ts\"\n\nconst escapePluginIdentityPart = (value: string): string =>\n // Percent must be escaped first so literal escape-looking text remains distinct from the `@` escape added next.\n value.replaceAll(\"%\", \"%25\").replaceAll(\"@\", \"%40\")\n\n/**\n * Admits a caller cache environment and prepends one escaped `name@version`\n * identity per plugin, in resolved order. An absent input stays absent. A\n * versionless plugin is refused at the dollar-path it was admitted from.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const snapshotCacheEnvironment = <H>(\n input: unknown,\n plugins: ReadonlyArray<{ readonly plugin: FlowsPlugin<H>; readonly path: string }>\n): Effect.Effect<Action.CacheEnvironment | undefined, PluginError> => {\n if (input === undefined) return Effect.succeed(undefined)\n const pluginIdentities: Array<string> = []\n for (const { path, plugin } of plugins) {\n if (plugin.version === undefined) {\n return Effect.fail(\n new PluginError({\n code: \"cache_environment_invalid\",\n message: `cache environment requires a version for plugin \"${plugin.name}\"`,\n path: `${path}.version`,\n plugin: plugin.name\n })\n )\n }\n pluginIdentities.push(`${escapePluginIdentityPart(plugin.name)}@${escapePluginIdentityPart(plugin.version)}`)\n }\n const admitted = Boundary.record(input)\n if (!admitted.ok) {\n return Effect.fail(\n new PluginError({\n code: \"cache_environment_invalid\",\n message: `cache environment ${admitted.complaint}`,\n path: `$options.cacheEnvironment${admitted.path.slice(1)}`\n })\n )\n }\n return Schema.decodeUnknownEffect(Action.CacheEnvironment)(admitted.value).pipe(\n Effect.mapError(() =>\n new PluginError({\n code: \"cache_environment_invalid\",\n message: \"cache environment does not match the complete cache identity schema\",\n path: \"$options.cacheEnvironment\"\n })\n ),\n Effect.map((environment) => {\n const capabilities: Record<string, ReadonlyArray<string>> = {}\n for (const name of Object.keys(environment.capabilities)) {\n Object.defineProperty(capabilities, name, {\n value: Object.freeze([...environment.capabilities[name]!]),\n enumerable: true\n })\n }\n return Object.freeze({\n layers: Object.freeze([...pluginIdentities, ...environment.layers]),\n capabilities: Object.freeze(capabilities)\n })\n })\n )\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA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;CAClD;AAkQD;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,GAAG,UAAU,EACpC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAC9B,UAAS,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAM,EACjC,iBAAiB,WAAW,KAC3B,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,CAiIrC,CAAA;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,UAAU,QAAQ,CAAC,CAAC,CAAC,KAAG,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,CAClB,CAAA"}
|
package/dist/esm/Resolve.js
CHANGED
|
@@ -241,7 +241,7 @@ const flatten = (input) => {
|
|
|
241
241
|
}
|
|
242
242
|
return output;
|
|
243
243
|
};
|
|
244
|
-
const included = (plugin, config, target) => {
|
|
244
|
+
const included = ({ path, plugin }, config, target) => {
|
|
245
245
|
const apply = plugin.apply;
|
|
246
246
|
if (apply === undefined)
|
|
247
247
|
return Effect.succeed(true);
|
|
@@ -249,12 +249,12 @@ const included = (plugin, config, target) => {
|
|
|
249
249
|
return Effect.succeed(apply === target);
|
|
250
250
|
return Effect.try({
|
|
251
251
|
try: () => apply(config),
|
|
252
|
-
catch: () => failure("apply_failed", `plugin "${plugin.name}" apply predicate failed`,
|
|
252
|
+
catch: () => failure("apply_failed", `plugin "${plugin.name}" apply predicate failed`, `${path}.apply`, {
|
|
253
253
|
plugin: plugin.name
|
|
254
254
|
})
|
|
255
255
|
}).pipe(Effect.flatMap((result) => typeof result === "boolean"
|
|
256
256
|
? Effect.succeed(result)
|
|
257
|
-
: Effect.fail(invalidPlugin(
|
|
257
|
+
: Effect.fail(invalidPlugin(`${path}.apply`, "predicate must return a boolean", { plugin: plugin.name }))));
|
|
258
258
|
};
|
|
259
259
|
const rank = (enforce) => (enforce === "pre" ? 0 : enforce === "post" ? 2 : 1);
|
|
260
260
|
/**
|
|
@@ -299,7 +299,7 @@ export const resolve = (input, options = {}, configOverride) => Effect.gen(funct
|
|
|
299
299
|
: invalidPlugin("$", "could not be inspected without executing user code")
|
|
300
300
|
});
|
|
301
301
|
const target = raw.target ?? "engine";
|
|
302
|
-
const selected = yield* Effect.filter(admitted, (
|
|
302
|
+
const selected = yield* Effect.filter(admitted, (entry) => included(entry, config, target));
|
|
303
303
|
let handlerCount = 0;
|
|
304
304
|
for (const { path, plugin } of selected) {
|
|
305
305
|
const pluginHooks = plugin.hooks;
|
|
@@ -316,16 +316,17 @@ export const resolve = (input, options = {}, configOverride) => Effect.gen(funct
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
const seen = new Set();
|
|
319
|
-
for (const { plugin } of selected) {
|
|
319
|
+
for (const { path, plugin } of selected) {
|
|
320
320
|
if (seen.has(plugin.name)) {
|
|
321
|
-
return yield* Effect.fail(failure("duplicate_name", `duplicate plugin name "${plugin.name}"`,
|
|
321
|
+
return yield* Effect.fail(failure("duplicate_name", `duplicate plugin name "${plugin.name}"`, `${path}.name`, { plugin: plugin.name }));
|
|
322
322
|
}
|
|
323
323
|
seen.add(plugin.name);
|
|
324
324
|
}
|
|
325
|
-
const
|
|
326
|
-
.map((
|
|
327
|
-
.sort((left, right) => rank(left.plugin.enforce) - rank(right.plugin.enforce) || left.index - right.index)
|
|
328
|
-
.map(({
|
|
325
|
+
const orderedEntries = selected
|
|
326
|
+
.map((entry, index) => ({ entry, index }))
|
|
327
|
+
.sort((left, right) => rank(left.entry.plugin.enforce) - rank(right.entry.plugin.enforce) || left.index - right.index)
|
|
328
|
+
.map(({ entry }) => entry);
|
|
329
|
+
const plugins = Object.freeze(orderedEntries.map(({ plugin }) => plugin));
|
|
329
330
|
const entries = [];
|
|
330
331
|
for (const hook of Object.keys(known)) {
|
|
331
332
|
const records = [];
|
|
@@ -347,7 +348,7 @@ export const resolve = (input, options = {}, configOverride) => Effect.gen(funct
|
|
|
347
348
|
if (ordered.length > 0)
|
|
348
349
|
entries.push([hook, Object.freeze(ordered)]);
|
|
349
350
|
}
|
|
350
|
-
const cacheEnvironment = yield* snapshotCacheEnvironment(raw.cacheEnvironment,
|
|
351
|
+
const cacheEnvironment = yield* snapshotCacheEnvironment(raw.cacheEnvironment, orderedEntries);
|
|
351
352
|
return Object.freeze({
|
|
352
353
|
plugins,
|
|
353
354
|
handlers: ImmutableMap.make(entries),
|
package/dist/esm/Resolve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resolve.js","sourceRoot":"","sources":["../../src/Resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAA;AAE7D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE5D,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AAEjF,OAAO,EAAE,WAAW,EAAwB,MAAM,kBAAkB,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAA;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAE1C;;;;;GAKG;AACH,M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CAAC,CAAC,CAAC,CAAA;IACtE,CAAC;IACD,MAAM,gBAAgB,GAAG,KAAK,CAAC,CAAC,wBAAwB,CAAC,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IACvF,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO;QACP,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;QACpC,KAAK,EAAE,KAAK;QACZ,mBAAmB;QACnB,GAAG,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC;KAChE,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEJ;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAI,QAAqB,EAAsC,EAAE,CACpF,iBAAiB,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAA","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"]}
|
|
1
|
+
{"version":3,"file":"Resolve.js","sourceRoot":"","sources":["../../src/Resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAA;AAE7D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE5D,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AAEjF,OAAO,EAAE,WAAW,EAAwB,MAAM,kBAAkB,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAA;AAE5C;;;;;GAKG;AACH,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IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CACrG;aACA,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAA;QAC9B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACtE,CAAC;IACD,MAAM,gBAAgB,GAAG,KAAK,CAAC,CAAC,wBAAwB,CAAC,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAA;IAC9F,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO;QACP,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;QACpC,KAAK,EAAE,KAAK;QACZ,mBAAmB;QACnB,GAAG,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC;KAChE,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEJ;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAI,QAAqB,EAAsC,EAAE,CACpF,iBAAiB,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAA","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 { path, plugin }: AdmittedPlugin<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`, `${path}.apply`, {\n plugin: plugin.name\n })\n }).pipe(\n Effect.flatMap((result) =>\n typeof result === \"boolean\"\n ? Effect.succeed(result)\n : Effect.fail(invalidPlugin(`${path}.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, (entry) => included(entry, 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 { path, 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 `${path}.name`,\n { plugin: plugin.name }\n ))\n }\n seen.add(plugin.name)\n }\n\n const orderedEntries = selected\n .map((entry, index) => ({ entry, index }))\n .sort((left, right) =>\n rank(left.entry.plugin.enforce) - rank(right.entry.plugin.enforce) || left.index - right.index\n )\n .map(({ entry }) => entry)\n const plugins = Object.freeze(orderedEntries.map(({ plugin }) => plugin))\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, orderedEntries)\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"]}
|
|
@@ -10,10 +10,14 @@ import type { FlowsPlugin } from "../Plugin.ts";
|
|
|
10
10
|
import { PluginError } from "../PluginError.ts";
|
|
11
11
|
/**
|
|
12
12
|
* Admits a caller cache environment and prepends one escaped `name@version`
|
|
13
|
-
* identity per plugin, in resolved order. An absent input stays absent.
|
|
13
|
+
* identity per plugin, in resolved order. An absent input stays absent. A
|
|
14
|
+
* versionless plugin is refused at the dollar-path it was admitted from.
|
|
14
15
|
*
|
|
15
16
|
* @private
|
|
16
17
|
* @since 1.0.0-rc.0
|
|
17
18
|
*/
|
|
18
|
-
export declare const snapshotCacheEnvironment: <H>(input: unknown, plugins: ReadonlyArray<
|
|
19
|
+
export declare const snapshotCacheEnvironment: <H>(input: unknown, plugins: ReadonlyArray<{
|
|
20
|
+
readonly plugin: FlowsPlugin<H>;
|
|
21
|
+
readonly path: string;
|
|
22
|
+
}>) => Effect.Effect<Action.CacheEnvironment | undefined, PluginError>;
|
|
19
23
|
//# sourceMappingURL=snapshotCacheEnvironment.d.ts.map
|
|
@@ -1 +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
|
|
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;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,EACxC,OAAO,OAAO,EACd,SAAS,aAAa,CAAC;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,KACjF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,GAAG,SAAS,EAAE,WAAW,CAgDhE,CAAA"}
|
|
@@ -14,7 +14,8 @@ const escapePluginIdentityPart = (value) =>
|
|
|
14
14
|
value.replaceAll("%", "%25").replaceAll("@", "%40");
|
|
15
15
|
/**
|
|
16
16
|
* Admits a caller cache environment and prepends one escaped `name@version`
|
|
17
|
-
* identity per plugin, in resolved order. An absent input stays absent.
|
|
17
|
+
* identity per plugin, in resolved order. An absent input stays absent. A
|
|
18
|
+
* versionless plugin is refused at the dollar-path it was admitted from.
|
|
18
19
|
*
|
|
19
20
|
* @private
|
|
20
21
|
* @since 1.0.0-rc.0
|
|
@@ -23,12 +24,12 @@ export const snapshotCacheEnvironment = (input, plugins) => {
|
|
|
23
24
|
if (input === undefined)
|
|
24
25
|
return Effect.succeed(undefined);
|
|
25
26
|
const pluginIdentities = [];
|
|
26
|
-
for (const plugin of plugins) {
|
|
27
|
+
for (const { path, plugin } of plugins) {
|
|
27
28
|
if (plugin.version === undefined) {
|
|
28
29
|
return Effect.fail(new PluginError({
|
|
29
30
|
code: "cache_environment_invalid",
|
|
30
31
|
message: `cache environment requires a version for plugin "${plugin.name}"`,
|
|
31
|
-
path:
|
|
32
|
+
path: `${path}.version`,
|
|
32
33
|
plugin: plugin.name
|
|
33
34
|
}));
|
|
34
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotCacheEnvironment.js","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;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC,MAAM,wBAAwB,GAAG,CAAC,KAAa,EAAU,EAAE;AACzD,gHAAgH;AAChH,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AAErD
|
|
1
|
+
{"version":3,"file":"snapshotCacheEnvironment.js","sourceRoot":"","sources":["../../../src/internal/snapshotCacheEnvironment.ts"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":["/**\n * Cache identity admission 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 Schema from \"effect/Schema\"\nimport type { FlowsPlugin } from \"../Plugin.ts\"\nimport { PluginError } from \"../PluginError.ts\"\nimport * as Boundary from \"./Boundary.ts\"\n\nconst escapePluginIdentityPart = (value: string): string =>\n // Percent must be escaped first so literal escape-looking text remains distinct from the `@` escape added next.\n value.replaceAll(\"%\", \"%25\").replaceAll(\"@\", \"%40\")\n\n/**\n * Admits a caller cache environment and prepends one escaped `name@version`\n * identity per plugin, in resolved order. An absent input stays absent. A\n * versionless plugin is refused at the dollar-path it was admitted from.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const snapshotCacheEnvironment = <H>(\n input: unknown,\n plugins: ReadonlyArray<{ readonly plugin: FlowsPlugin<H>; readonly path: string }>\n): Effect.Effect<Action.CacheEnvironment | undefined, PluginError> => {\n if (input === undefined) return Effect.succeed(undefined)\n const pluginIdentities: Array<string> = []\n for (const { path, plugin } of plugins) {\n if (plugin.version === undefined) {\n return Effect.fail(\n new PluginError({\n code: \"cache_environment_invalid\",\n message: `cache environment requires a version for plugin \"${plugin.name}\"`,\n path: `${path}.version`,\n plugin: plugin.name\n })\n )\n }\n pluginIdentities.push(`${escapePluginIdentityPart(plugin.name)}@${escapePluginIdentityPart(plugin.version)}`)\n }\n const admitted = Boundary.record(input)\n if (!admitted.ok) {\n return Effect.fail(\n new PluginError({\n code: \"cache_environment_invalid\",\n message: `cache environment ${admitted.complaint}`,\n path: `$options.cacheEnvironment${admitted.path.slice(1)}`\n })\n )\n }\n return Schema.decodeUnknownEffect(Action.CacheEnvironment)(admitted.value).pipe(\n Effect.mapError(() =>\n new PluginError({\n code: \"cache_environment_invalid\",\n message: \"cache environment does not match the complete cache identity schema\",\n path: \"$options.cacheEnvironment\"\n })\n ),\n Effect.map((environment) => {\n const capabilities: Record<string, ReadonlyArray<string>> = {}\n for (const name of Object.keys(environment.capabilities)) {\n Object.defineProperty(capabilities, name, {\n value: Object.freeze([...environment.capabilities[name]!]),\n enumerable: true\n })\n }\n return Object.freeze({\n layers: Object.freeze([...pluginIdentities, ...environment.layers]),\n capabilities: Object.freeze(capabilities)\n })\n })\n )\n}\n"]}
|
package/docs/README.md
CHANGED
|
@@ -51,7 +51,9 @@ class, no registration call, and no inheritance.
|
|
|
51
51
|
|
|
52
52
|
## Install
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
```bash
|
|
55
|
+
npm install @smthrs/plugin@next effect
|
|
56
|
+
```
|
|
55
57
|
|
|
56
58
|
Node.js 26.4.0 or later is required. For the runtime requirements, the import
|
|
57
59
|
forms, and the subpaths the export map blocks, see
|
|
@@ -67,7 +67,7 @@ const refused = Kernel.make(
|
|
|
67
67
|
{},
|
|
68
68
|
{ cacheEnvironment: { layers: [], capabilities: {} } }
|
|
69
69
|
)
|
|
70
|
-
// Fails with PluginError { code: "cache_environment_invalid", plugin: "flows-plugin-model-sonnet", path: "
|
|
70
|
+
// Fails with PluginError { code: "cache_environment_invalid", plugin: "flows-plugin-model-sonnet", path: "$[0].version" }
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
A versionless plugin is refused rather than folded in as a bare name, because a
|
package/docs/installation.md
CHANGED
|
@@ -7,7 +7,11 @@ sidebar:
|
|
|
7
7
|
|
|
8
8
|
## Install the package
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
```bash
|
|
11
|
+
npm install @smthrs/plugin@next effect
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The `next` tag carries the 1.0 release candidates.
|
|
11
15
|
|
|
12
16
|
Install `effect` explicitly, in the range `^4.0.4`. The kernel depends on it, but your
|
|
13
17
|
plugins import `Effect`, `Layer`, and `Option` directly, so `effect` belongs in
|
package/docs/quickstart.md
CHANGED
|
@@ -16,7 +16,8 @@ defines the plugins and runs the host. There are no services to provide.
|
|
|
16
16
|
## Prerequisites
|
|
17
17
|
|
|
18
18
|
- Node.js 26.4.0 or later.
|
|
19
|
-
- A TypeScript project with the package installed
|
|
19
|
+
- A TypeScript project with the package installed:
|
|
20
|
+
`npm install @smthrs/plugin@next effect`.
|
|
20
21
|
|
|
21
22
|
## Declare the host's hook catalog
|
|
22
23
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smthrs/plugin",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"smthrs": {
|
|
7
7
|
"group": "agent"
|
|
@@ -145,8 +145,8 @@
|
|
|
145
145
|
"tag": "next"
|
|
146
146
|
},
|
|
147
147
|
"dependencies": {
|
|
148
|
-
"@smthrs/canonical": "1.0.0-rc.
|
|
149
|
-
"@smthrs/flow": "1.0.0-rc.
|
|
148
|
+
"@smthrs/canonical": "1.0.0-rc.8",
|
|
149
|
+
"@smthrs/flow": "1.0.0-rc.8"
|
|
150
150
|
},
|
|
151
151
|
"devDependencies": {
|
|
152
152
|
"@effect/language-service": "0.87.2",
|
package/src/Resolve.ts
CHANGED
|
@@ -360,7 +360,7 @@ const flatten = <H>(input: unknown): ReadonlyArray<AdmittedPlugin<H>> => {
|
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
const included = <H>(
|
|
363
|
-
plugin:
|
|
363
|
+
{ path, plugin }: AdmittedPlugin<H>,
|
|
364
364
|
config: FlowsConfig,
|
|
365
365
|
target: "engine" | "harness"
|
|
366
366
|
): Effect.Effect<boolean, PluginError> => {
|
|
@@ -370,14 +370,14 @@ const included = <H>(
|
|
|
370
370
|
return Effect.try({
|
|
371
371
|
try: () => apply(config),
|
|
372
372
|
catch: () =>
|
|
373
|
-
failure("apply_failed", `plugin "${plugin.name}" apply predicate failed`,
|
|
373
|
+
failure("apply_failed", `plugin "${plugin.name}" apply predicate failed`, `${path}.apply`, {
|
|
374
374
|
plugin: plugin.name
|
|
375
375
|
})
|
|
376
376
|
}).pipe(
|
|
377
377
|
Effect.flatMap((result) =>
|
|
378
378
|
typeof result === "boolean"
|
|
379
379
|
? Effect.succeed(result)
|
|
380
|
-
: Effect.fail(invalidPlugin(
|
|
380
|
+
: Effect.fail(invalidPlugin(`${path}.apply`, "predicate must return a boolean", { plugin: plugin.name }))
|
|
381
381
|
)
|
|
382
382
|
)
|
|
383
383
|
}
|
|
@@ -443,7 +443,7 @@ export const resolve = <H = FlowsHooks>(
|
|
|
443
443
|
: invalidPlugin("$", "could not be inspected without executing user code")
|
|
444
444
|
})
|
|
445
445
|
const target = raw.target ?? "engine"
|
|
446
|
-
const selected = yield* Effect.filter(admitted, (
|
|
446
|
+
const selected = yield* Effect.filter(admitted, (entry) => included(entry, config, target))
|
|
447
447
|
|
|
448
448
|
let handlerCount = 0
|
|
449
449
|
for (const { path, plugin } of selected) {
|
|
@@ -470,24 +470,25 @@ export const resolve = <H = FlowsHooks>(
|
|
|
470
470
|
}
|
|
471
471
|
|
|
472
472
|
const seen = new Set<string>()
|
|
473
|
-
for (const { plugin } of selected) {
|
|
473
|
+
for (const { path, plugin } of selected) {
|
|
474
474
|
if (seen.has(plugin.name)) {
|
|
475
475
|
return yield* Effect.fail(failure(
|
|
476
476
|
"duplicate_name",
|
|
477
477
|
`duplicate plugin name "${plugin.name}"`,
|
|
478
|
-
|
|
478
|
+
`${path}.name`,
|
|
479
479
|
{ plugin: plugin.name }
|
|
480
480
|
))
|
|
481
481
|
}
|
|
482
482
|
seen.add(plugin.name)
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
485
|
+
const orderedEntries = selected
|
|
486
|
+
.map((entry, index) => ({ entry, index }))
|
|
487
|
+
.sort((left, right) =>
|
|
488
|
+
rank(left.entry.plugin.enforce) - rank(right.entry.plugin.enforce) || left.index - right.index
|
|
489
|
+
)
|
|
490
|
+
.map(({ entry }) => entry)
|
|
491
|
+
const plugins = Object.freeze(orderedEntries.map(({ plugin }) => plugin))
|
|
491
492
|
const entries: Array<readonly [string, ReadonlyArray<HandlerRecord>]> = []
|
|
492
493
|
for (const hook of Object.keys(known)) {
|
|
493
494
|
const records: Array<{
|
|
@@ -514,7 +515,7 @@ export const resolve = <H = FlowsHooks>(
|
|
|
514
515
|
.map(({ record }) => record)
|
|
515
516
|
if (ordered.length > 0) entries.push([hook, Object.freeze(ordered)])
|
|
516
517
|
}
|
|
517
|
-
const cacheEnvironment = yield* snapshotCacheEnvironment(raw.cacheEnvironment,
|
|
518
|
+
const cacheEnvironment = yield* snapshotCacheEnvironment(raw.cacheEnvironment, orderedEntries)
|
|
518
519
|
return Object.freeze({
|
|
519
520
|
plugins,
|
|
520
521
|
handlers: ImmutableMap.make(entries),
|
|
@@ -18,24 +18,25 @@ const escapePluginIdentityPart = (value: string): string =>
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Admits a caller cache environment and prepends one escaped `name@version`
|
|
21
|
-
* identity per plugin, in resolved order. An absent input stays absent.
|
|
21
|
+
* identity per plugin, in resolved order. An absent input stays absent. A
|
|
22
|
+
* versionless plugin is refused at the dollar-path it was admitted from.
|
|
22
23
|
*
|
|
23
24
|
* @private
|
|
24
25
|
* @since 1.0.0-rc.0
|
|
25
26
|
*/
|
|
26
27
|
export const snapshotCacheEnvironment = <H>(
|
|
27
28
|
input: unknown,
|
|
28
|
-
plugins: ReadonlyArray<FlowsPlugin<H
|
|
29
|
+
plugins: ReadonlyArray<{ readonly plugin: FlowsPlugin<H>; readonly path: string }>
|
|
29
30
|
): Effect.Effect<Action.CacheEnvironment | undefined, PluginError> => {
|
|
30
31
|
if (input === undefined) return Effect.succeed(undefined)
|
|
31
32
|
const pluginIdentities: Array<string> = []
|
|
32
|
-
for (const plugin of plugins) {
|
|
33
|
+
for (const { path, plugin } of plugins) {
|
|
33
34
|
if (plugin.version === undefined) {
|
|
34
35
|
return Effect.fail(
|
|
35
36
|
new PluginError({
|
|
36
37
|
code: "cache_environment_invalid",
|
|
37
38
|
message: `cache environment requires a version for plugin "${plugin.name}"`,
|
|
38
|
-
path:
|
|
39
|
+
path: `${path}.version`,
|
|
39
40
|
plugin: plugin.name
|
|
40
41
|
})
|
|
41
42
|
)
|