@smthrs/plugin 1.0.0-rc.7 → 1.0.0-rc.9
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/Plugins.d.ts.map +1 -1
- package/dist/cjs/Plugins.js +17 -8
- package/dist/cjs/Plugins.js.map +2 -2
- package/dist/cjs/Resolve.d.ts.map +1 -1
- package/dist/cjs/Resolve.js +22 -19
- 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/Plugins.d.ts.map +1 -1
- package/dist/esm/Plugins.js +21 -9
- package/dist/esm/Plugins.js.map +1 -1
- package/dist/esm/Resolve.d.ts.map +1 -1
- package/dist/esm/Resolve.js +23 -21
- 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/api.md +6 -4
- package/docs/guides/cache-identity.md +1 -1
- package/docs/installation.md +5 -1
- package/docs/quickstart.md +2 -1
- package/docs/troubleshooting.md +2 -1
- package/package.json +4 -4
- package/src/Plugins.ts +25 -8
- package/src/Resolve.ts +26 -22
- 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":"Plugins.d.ts","sourceRoot":"","sources":["../../src/Plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAY,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAA8B,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Plugins.d.ts","sourceRoot":"","sources":["../../src/Plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAY,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAA8B,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAmE5F;;;;;GAKG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC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
var import_Resolve = require("./Resolve.js");
|
|
46
46
|
const empty = Object.freeze([]);
|
|
47
|
-
const kindMismatch = (resolved, hook, kind) => {
|
|
48
|
-
if (!Object.hasOwn(resolved.kinds, hook))
|
|
47
|
+
const kindMismatch = (resolved, hook, kind, handlers) => {
|
|
48
|
+
if (!Object.hasOwn(resolved.kinds, hook)) {
|
|
49
|
+
if (handlers.length === 0) return void 0;
|
|
50
|
+
return new import_PluginError.PluginError({
|
|
51
|
+
code: "hook_kind_mismatch",
|
|
52
|
+
message: `hook "${hook}" has handlers but is not declared in the runtime catalog`,
|
|
53
|
+
hook
|
|
54
|
+
});
|
|
55
|
+
}
|
|
49
56
|
const declared = resolved.kinds[hook];
|
|
50
57
|
if (declared === kind) return void 0;
|
|
51
58
|
return new import_PluginError.PluginError({
|
|
@@ -81,7 +88,7 @@ const runHandler = (record, args) => {
|
|
|
81
88
|
const make = (resolved) => {
|
|
82
89
|
const handlers = (hook) => resolved.handlers.get(hook) ?? empty;
|
|
83
90
|
const sequential = ((hook, ...args) => Effect.gen(function* () {
|
|
84
|
-
const mismatch = kindMismatch(resolved, hook, "sequential");
|
|
91
|
+
const mismatch = kindMismatch(resolved, hook, "sequential", handlers(hook));
|
|
85
92
|
if (mismatch !== void 0) return yield* Effect.fail(mismatch);
|
|
86
93
|
const results = [];
|
|
87
94
|
for (const record of handlers(hook)) {
|
|
@@ -90,7 +97,7 @@ const make = (resolved) => {
|
|
|
90
97
|
return results;
|
|
91
98
|
}));
|
|
92
99
|
const parallel = ((hook, ...args) => {
|
|
93
|
-
const mismatch = kindMismatch(resolved, hook, "parallel");
|
|
100
|
+
const mismatch = kindMismatch(resolved, hook, "parallel", handlers(hook));
|
|
94
101
|
if (mismatch !== void 0) return Effect.succeed([mismatch]);
|
|
95
102
|
return Effect.forEach(
|
|
96
103
|
handlers(hook),
|
|
@@ -101,7 +108,7 @@ const make = (resolved) => {
|
|
|
101
108
|
).pipe(Effect.map((chunks) => chunks.flat()));
|
|
102
109
|
});
|
|
103
110
|
const first = ((hook, ...args) => Effect.gen(function* () {
|
|
104
|
-
const mismatch = kindMismatch(resolved, hook, "first");
|
|
111
|
+
const mismatch = kindMismatch(resolved, hook, "first", handlers(hook));
|
|
105
112
|
if (mismatch !== void 0) return yield* Effect.fail(mismatch);
|
|
106
113
|
for (const record of handlers(hook)) {
|
|
107
114
|
const result = yield* runHandler(record, args);
|
|
@@ -120,7 +127,7 @@ const make = (resolved) => {
|
|
|
120
127
|
return Option.none();
|
|
121
128
|
}));
|
|
122
129
|
const waterfall = ((hook, initial, merge) => Effect.gen(function* () {
|
|
123
|
-
const mismatch = kindMismatch(resolved, hook, "waterfall");
|
|
130
|
+
const mismatch = kindMismatch(resolved, hook, "waterfall", handlers(hook));
|
|
124
131
|
if (mismatch !== void 0) return yield* Effect.fail(mismatch);
|
|
125
132
|
let value = initial;
|
|
126
133
|
for (const record of handlers(hook)) {
|
|
@@ -133,12 +140,14 @@ const make = (resolved) => {
|
|
|
133
140
|
message: cause.message,
|
|
134
141
|
plugin: record.plugin,
|
|
135
142
|
hook: record.hook,
|
|
136
|
-
path: cause.path
|
|
143
|
+
path: cause.path,
|
|
144
|
+
cause
|
|
137
145
|
}) : new import_PluginError.PluginError({
|
|
138
146
|
code: "config_invalid",
|
|
139
147
|
message: `waterfall hook "${record.hook}" in plugin "${record.plugin}" returned an invalid patch`,
|
|
140
148
|
plugin: record.plugin,
|
|
141
|
-
hook: record.hook
|
|
149
|
+
hook: record.hook,
|
|
150
|
+
cause
|
|
142
151
|
})
|
|
143
152
|
});
|
|
144
153
|
}
|
package/dist/cjs/Plugins.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Plugins.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The dispatcher: a plain service over a resolved plugin list, generic over the\n * hook interface.\n *\n * The public package contract is documented at\n * {@link https://smithers.sh/docs/reference/api/plugin}. Each host holds an instance over its\n * augmented `FlowsHooks` and may dispatch only the runtime catalog it supplied.\n * The shipped cell host owns the three\n * waterfalls declared in `packages/smithers/agent/src/CellPlugin.ts`; there is\n * no engine-wide lifecycle dispatcher.\n *\n * Cancellation is fiber interruption via scope closure; nothing here threads an\n * `AbortSignal`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as ImmutableMap from \"@smthrs/canonical/ReadonlyMap\"\nimport type * as Cause from \"effect/Cause\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport * as Option from \"effect/Option\"\nimport type { ArgsOf, ContextOf, HookKind, KeysOfKind, SuccessOf } from \"./Hooks.ts\"\nimport { engineHooks } from \"./Hooks.ts\"\nimport type { FlowsHooks } from \"./index.ts\"\nimport { PluginError } from \"./PluginError.ts\"\nimport { defaultParallelConcurrency, type HandlerRecord, type Resolved } from \"./Resolve.ts\"\n\nconst empty: ReadonlyArray<HandlerRecord> = Object.freeze([])\n\n// The typed catalog and the runtime catalog can only drift when a host casts\n// around `KeysOfKind`; refuse before any handler runs rather than execute a\n// hook under semantics its declaration never promised.\nconst kindMismatch = (resolved: Resolved<unknown>, hook: string, kind: HookKind): PluginError | undefined => {\n if (!Object.hasOwn(resolved.kinds, hook)) return undefined\n const declared = resolved.kinds[hook]\n if (declared === kind) return undefined\n return new PluginError({\n code: \"hook_kind_mismatch\",\n message: `hook \"${hook}\" is declared ${JSON.stringify(declared)} in the runtime catalog but was dispatched as ${\n JSON.stringify(kind)\n }`,\n hook\n })\n}\n\nconst runHandler = (\n record: HandlerRecord,\n args: ReadonlyArray<unknown>\n): Effect.Effect<unknown, PluginError, any> => {\n const onCause = (cause: Cause.Cause<unknown>) =>\n Effect.fail(\n new PluginError({\n code: \"hook_failed\",\n message: `hook \"${record.hook}\" failed in plugin \"${record.plugin}\"`,\n plugin: record.plugin,\n hook: record.hook,\n cause\n })\n )\n\n return Effect.sync(() => record.handler(...args)).pipe(\n Effect.catchCause(onCause),\n Effect.flatMap((result) =>\n Effect.isEffect(result)\n ? result.pipe(Effect.catchCause(onCause))\n : Effect.fail(\n new PluginError({\n code: \"hook_failed\",\n message: `hook \"${record.hook}\" in plugin \"${record.plugin}\" returned a non-Effect (${typeof result})`,\n plugin: record.plugin,\n hook: record.hook\n })\n )\n )\n )\n}\n\n/**\n * The dispatch surface.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Service<H = FlowsHooks> {\n /** The resolved list this dispatcher walks. */\n readonly resolved: Resolved<H>\n /** Frozen, ordered handler records for a hook. */\n readonly handlers: (hook: string) => ReadonlyArray<HandlerRecord>\n /** Runs every handler in resolved order, one at a time. */\n readonly sequential: <K extends KeysOfKind<H, \"sequential\">>(\n hook: K,\n ...args: ArgsOf<H[K]>\n ) => Effect.Effect<ReadonlyArray<SuccessOf<H[K]>>, PluginError, ContextOf<H[K]>>\n /**\n * Runs every handler concurrently, ignoring results. Never fails: handler\n * failures are returned so the caller can report them at its own boundary.\n */\n readonly parallel: <K extends KeysOfKind<H, \"parallel\">>(\n hook: K,\n ...args: ArgsOf<H[K]>\n ) => Effect.Effect<ReadonlyArray<PluginError>, never, ContextOf<H[K]>>\n /** Runs handlers in order until one returns `Option.some`. */\n readonly first: <K extends KeysOfKind<H, \"first\">>(\n hook: K,\n ...args: ArgsOf<H[K]>\n ) => Effect.Effect<SuccessOf<H[K]>, PluginError, ContextOf<H[K]>>\n /** Threads a value through every handler, merging each returned patch. */\n readonly waterfall: <K extends KeysOfKind<H, \"waterfall\">>(\n hook: K,\n initial: ArgsOf<H[K]>[0],\n merge: (previous: ArgsOf<H[K]>[0], patch: Exclude<SuccessOf<H[K]>, void>) => ArgsOf<H[K]>[0]\n ) => Effect.Effect<ArgsOf<H[K]>[0], PluginError, ContextOf<H[K]>>\n}\n\n/**\n * Builds a dispatcher over an already resolved plugin list.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const make = <H = FlowsHooks>(resolved: Resolved<H>): Service<H> => {\n const handlers = (hook: string): ReadonlyArray<HandlerRecord> => resolved.handlers.get(hook) ?? empty\n\n const sequential = ((hook: string, ...args: Array<unknown>) =>\n Effect.gen(function*() {\n const mismatch = kindMismatch(resolved, hook, \"sequential\")\n if (mismatch !== undefined) return yield* Effect.fail(mismatch)\n const results: Array<unknown> = []\n for (const record of handlers(hook)) {\n results.push(yield* runHandler(record, args))\n }\n return results\n })) as Service<H>[\"sequential\"]\n\n const parallel = ((hook: string, ...args: Array<unknown>) => {\n const mismatch = kindMismatch(resolved, hook, \"parallel\")\n if (mismatch !== undefined) return Effect.succeed([mismatch])\n return Effect.forEach(\n handlers(hook),\n (record) =>\n runHandler(record, args).pipe(\n Effect.match({ onFailure: (error) => [error], onSuccess: () => [] as Array<PluginError> })\n ),\n { concurrency: resolved.parallelConcurrency }\n ).pipe(Effect.map((chunks) => chunks.flat()))\n }) as Service<H>[\"parallel\"]\n\n const first = ((hook: string, ...args: Array<unknown>) =>\n Effect.gen(function*() {\n const mismatch = kindMismatch(resolved, hook, \"first\")\n if (mismatch !== undefined) return yield* Effect.fail(mismatch)\n for (const record of handlers(hook)) {\n const result = yield* runHandler(record, args)\n if (!Option.isOption(result)) {\n return yield* Effect.fail(\n new PluginError({\n code: \"invalid_hook_result\",\n message: `first hook \"${record.hook}\" in plugin \"${record.plugin}\" did not return an Option`,\n plugin: record.plugin,\n hook: record.hook\n })\n )\n }\n if (Option.isSome(result)) return result\n }\n return Option.none()\n })) as unknown as Service<H>[\"first\"]\n\n const waterfall =\n ((hook: string, initial: unknown, merge: (previous: unknown, patch: unknown) => unknown) =>\n Effect.gen(function*() {\n const mismatch = kindMismatch(resolved, hook, \"waterfall\")\n if (mismatch !== undefined) return yield* Effect.fail(mismatch)\n let value = initial\n for (const record of handlers(hook)) {\n const patch = yield* runHandler(record, [value])\n if (patch !== undefined) {\n value = yield* Effect.try({\n try: () => merge(value, patch),\n catch: (cause) =>\n cause instanceof PluginError\n ? new PluginError({\n code: cause.code,\n message: cause.message,\n plugin: record.plugin,\n hook: record.hook,\n path: cause.path\n })\n : new PluginError({\n code: \"config_invalid\",\n message: `waterfall hook \"${record.hook}\" in plugin \"${record.plugin}\" returned an invalid patch`,\n plugin: record.plugin,\n hook: record.hook\n })\n })\n }\n }\n return value\n })) as Service<H>[\"waterfall\"]\n\n return Object.freeze({ resolved, handlers, sequential, parallel, first, waterfall })\n}\n\n/**\n * A dispatcher with no plugins at all.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const makeNoop = <H = FlowsHooks>(): Service<H> =>\n make<H>(Object.freeze({\n plugins: Object.freeze([]),\n handlers: ImmutableMap.make<string, ReadonlyArray<HandlerRecord>>(),\n kinds: engineHooks,\n parallelConcurrency: defaultParallelConcurrency\n }))\n\n/**\n * The shared dispatcher, as a service tag.\n *\n * This tag holds one dispatcher over the process-wide augmented `FlowsHooks`.\n * `declare module \"@smthrs/plugin\"` augmentation is the supported extension\n * mechanism for values placed in the tag. A host typed against a separate hook\n * interface holds its `Service<H>` directly, as `@smthrs/agent` does, and does\n * not use this tag or its layers.\n *\n * @category context\n * @since 1.0.0-rc.0\n */\nexport class Plugins extends Context.Service<Plugins, Service>()(\"flows/plugin/Plugins\") {}\n\n/**\n * Layer providing a dispatcher over an already resolved plugin list.\n *\n * This layer targets the shared augmented `FlowsHooks` catalog only. A host\n * with a separate hook interface holds its `Service<H>` directly.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = (resolved: Resolved): Layer.Layer<Plugins> => Layer.succeed(Plugins)(make(resolved))\n\n/**\n * Layer providing a dispatcher with no plugins.\n *\n * This layer targets the shared augmented `FlowsHooks` catalog only. A host\n * with a separate hook interface holds its `Service<H>` directly.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layerNoop: Layer.Layer<Plugins> = Layer.succeed(Plugins)(makeNoop())\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,mBAA8B;AAE9B,cAAyB;AACzB,aAAwB;AACxB,YAAuB;AACvB,aAAwB;AAExB,mBAA4B;AAE5B,yBAA4B;AAC5B,qBAA8E;AAE9E,MAAM,QAAsC,OAAO,OAAO,CAAC,CAAC;
|
|
4
|
+
"sourcesContent": ["/**\n * The dispatcher: a plain service over a resolved plugin list, generic over the\n * hook interface.\n *\n * The public package contract is documented at\n * {@link https://smithers.sh/docs/reference/api/plugin}. Each host holds an instance over its\n * augmented `FlowsHooks` and may dispatch only the runtime catalog it supplied.\n * The shipped cell host owns the three\n * waterfalls declared in `packages/smithers/agent/src/CellPlugin.ts`; there is\n * no engine-wide lifecycle dispatcher.\n *\n * Cancellation is fiber interruption via scope closure; nothing here threads an\n * `AbortSignal`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as ImmutableMap from \"@smthrs/canonical/ReadonlyMap\"\nimport type * as Cause from \"effect/Cause\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport * as Option from \"effect/Option\"\nimport type { ArgsOf, ContextOf, HookKind, KeysOfKind, SuccessOf } from \"./Hooks.ts\"\nimport { engineHooks } from \"./Hooks.ts\"\nimport type { FlowsHooks } from \"./index.ts\"\nimport { PluginError } from \"./PluginError.ts\"\nimport { defaultParallelConcurrency, type HandlerRecord, type Resolved } from \"./Resolve.ts\"\n\nconst empty: ReadonlyArray<HandlerRecord> = Object.freeze([])\n\n// The typed catalog and the runtime catalog can only drift when a host casts\n// around `KeysOfKind`; refuse before any handler runs rather than execute a\n// hook under semantics its declaration never promised.\n// A hook the catalog does not declare dispatches as empty, unless a\n// hand-built resolution registered handlers for it: those have no declared\n// kind to honor, so they are refused too.\nconst kindMismatch = (\n resolved: Resolved<unknown>,\n hook: string,\n kind: HookKind,\n handlers: ReadonlyArray<HandlerRecord>\n): PluginError | undefined => {\n if (!Object.hasOwn(resolved.kinds, hook)) {\n if (handlers.length === 0) return undefined\n return new PluginError({\n code: \"hook_kind_mismatch\",\n message: `hook \"${hook}\" has handlers but is not declared in the runtime catalog`,\n hook\n })\n }\n const declared = resolved.kinds[hook]\n if (declared === kind) return undefined\n return new PluginError({\n code: \"hook_kind_mismatch\",\n message: `hook \"${hook}\" is declared ${JSON.stringify(declared)} in the runtime catalog but was dispatched as ${\n JSON.stringify(kind)\n }`,\n hook\n })\n}\n\nconst runHandler = (\n record: HandlerRecord,\n args: ReadonlyArray<unknown>\n): Effect.Effect<unknown, PluginError, any> => {\n const onCause = (cause: Cause.Cause<unknown>) =>\n Effect.fail(\n new PluginError({\n code: \"hook_failed\",\n message: `hook \"${record.hook}\" failed in plugin \"${record.plugin}\"`,\n plugin: record.plugin,\n hook: record.hook,\n cause\n })\n )\n\n return Effect.sync(() => record.handler(...args)).pipe(\n Effect.catchCause(onCause),\n Effect.flatMap((result) =>\n Effect.isEffect(result)\n ? result.pipe(Effect.catchCause(onCause))\n : Effect.fail(\n new PluginError({\n code: \"hook_failed\",\n message: `hook \"${record.hook}\" in plugin \"${record.plugin}\" returned a non-Effect (${typeof result})`,\n plugin: record.plugin,\n hook: record.hook\n })\n )\n )\n )\n}\n\n/**\n * The dispatch surface.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Service<H = FlowsHooks> {\n /** The resolved list this dispatcher walks. */\n readonly resolved: Resolved<H>\n /** Frozen, ordered handler records for a hook. */\n readonly handlers: (hook: string) => ReadonlyArray<HandlerRecord>\n /** Runs every handler in resolved order, one at a time. */\n readonly sequential: <K extends KeysOfKind<H, \"sequential\">>(\n hook: K,\n ...args: ArgsOf<H[K]>\n ) => Effect.Effect<ReadonlyArray<SuccessOf<H[K]>>, PluginError, ContextOf<H[K]>>\n /**\n * Runs every handler concurrently, ignoring results. Never fails: handler\n * failures are returned so the caller can report them at its own boundary.\n */\n readonly parallel: <K extends KeysOfKind<H, \"parallel\">>(\n hook: K,\n ...args: ArgsOf<H[K]>\n ) => Effect.Effect<ReadonlyArray<PluginError>, never, ContextOf<H[K]>>\n /** Runs handlers in order until one returns `Option.some`. */\n readonly first: <K extends KeysOfKind<H, \"first\">>(\n hook: K,\n ...args: ArgsOf<H[K]>\n ) => Effect.Effect<SuccessOf<H[K]>, PluginError, ContextOf<H[K]>>\n /** Threads a value through every handler, merging each returned patch. */\n readonly waterfall: <K extends KeysOfKind<H, \"waterfall\">>(\n hook: K,\n initial: ArgsOf<H[K]>[0],\n merge: (previous: ArgsOf<H[K]>[0], patch: Exclude<SuccessOf<H[K]>, void>) => ArgsOf<H[K]>[0]\n ) => Effect.Effect<ArgsOf<H[K]>[0], PluginError, ContextOf<H[K]>>\n}\n\n/**\n * Builds a dispatcher over an already resolved plugin list.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const make = <H = FlowsHooks>(resolved: Resolved<H>): Service<H> => {\n const handlers = (hook: string): ReadonlyArray<HandlerRecord> => resolved.handlers.get(hook) ?? empty\n\n const sequential = ((hook: string, ...args: Array<unknown>) =>\n Effect.gen(function*() {\n const mismatch = kindMismatch(resolved, hook, \"sequential\", handlers(hook))\n if (mismatch !== undefined) return yield* Effect.fail(mismatch)\n const results: Array<unknown> = []\n for (const record of handlers(hook)) {\n results.push(yield* runHandler(record, args))\n }\n return results\n })) as Service<H>[\"sequential\"]\n\n const parallel = ((hook: string, ...args: Array<unknown>) => {\n const mismatch = kindMismatch(resolved, hook, \"parallel\", handlers(hook))\n if (mismatch !== undefined) return Effect.succeed([mismatch])\n return Effect.forEach(\n handlers(hook),\n (record) =>\n runHandler(record, args).pipe(\n Effect.match({ onFailure: (error) => [error], onSuccess: () => [] as Array<PluginError> })\n ),\n { concurrency: resolved.parallelConcurrency }\n ).pipe(Effect.map((chunks) => chunks.flat()))\n }) as Service<H>[\"parallel\"]\n\n const first = ((hook: string, ...args: Array<unknown>) =>\n Effect.gen(function*() {\n const mismatch = kindMismatch(resolved, hook, \"first\", handlers(hook))\n if (mismatch !== undefined) return yield* Effect.fail(mismatch)\n for (const record of handlers(hook)) {\n const result = yield* runHandler(record, args)\n if (!Option.isOption(result)) {\n return yield* Effect.fail(\n new PluginError({\n code: \"invalid_hook_result\",\n message: `first hook \"${record.hook}\" in plugin \"${record.plugin}\" did not return an Option`,\n plugin: record.plugin,\n hook: record.hook\n })\n )\n }\n if (Option.isSome(result)) return result\n }\n return Option.none()\n })) as unknown as Service<H>[\"first\"]\n\n const waterfall =\n ((hook: string, initial: unknown, merge: (previous: unknown, patch: unknown) => unknown) =>\n Effect.gen(function*() {\n const mismatch = kindMismatch(resolved, hook, \"waterfall\", handlers(hook))\n if (mismatch !== undefined) return yield* Effect.fail(mismatch)\n let value = initial\n for (const record of handlers(hook)) {\n const patch = yield* runHandler(record, [value])\n if (patch !== undefined) {\n value = yield* Effect.try({\n try: () => merge(value, patch),\n catch: (cause) =>\n cause instanceof PluginError\n ? new PluginError({\n code: cause.code,\n message: cause.message,\n plugin: record.plugin,\n hook: record.hook,\n path: cause.path,\n cause\n })\n : new PluginError({\n code: \"config_invalid\",\n message: `waterfall hook \"${record.hook}\" in plugin \"${record.plugin}\" returned an invalid patch`,\n plugin: record.plugin,\n hook: record.hook,\n cause\n })\n })\n }\n }\n return value\n })) as Service<H>[\"waterfall\"]\n\n return Object.freeze({ resolved, handlers, sequential, parallel, first, waterfall })\n}\n\n/**\n * A dispatcher with no plugins at all.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const makeNoop = <H = FlowsHooks>(): Service<H> =>\n make<H>(Object.freeze({\n plugins: Object.freeze([]),\n handlers: ImmutableMap.make<string, ReadonlyArray<HandlerRecord>>(),\n kinds: engineHooks,\n parallelConcurrency: defaultParallelConcurrency\n }))\n\n/**\n * The shared dispatcher, as a service tag.\n *\n * This tag holds one dispatcher over the process-wide augmented `FlowsHooks`.\n * `declare module \"@smthrs/plugin\"` augmentation is the supported extension\n * mechanism for values placed in the tag. A host typed against a separate hook\n * interface holds its `Service<H>` directly, as `@smthrs/agent` does, and does\n * not use this tag or its layers.\n *\n * @category context\n * @since 1.0.0-rc.0\n */\nexport class Plugins extends Context.Service<Plugins, Service>()(\"flows/plugin/Plugins\") {}\n\n/**\n * Layer providing a dispatcher over an already resolved plugin list.\n *\n * This layer targets the shared augmented `FlowsHooks` catalog only. A host\n * with a separate hook interface holds its `Service<H>` directly.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = (resolved: Resolved): Layer.Layer<Plugins> => Layer.succeed(Plugins)(make(resolved))\n\n/**\n * Layer providing a dispatcher with no plugins.\n *\n * This layer targets the shared augmented `FlowsHooks` catalog only. A host\n * with a separate hook interface holds its `Service<H>` directly.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layerNoop: Layer.Layer<Plugins> = Layer.succeed(Plugins)(makeNoop())\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,mBAA8B;AAE9B,cAAyB;AACzB,aAAwB;AACxB,YAAuB;AACvB,aAAwB;AAExB,mBAA4B;AAE5B,yBAA4B;AAC5B,qBAA8E;AAE9E,MAAM,QAAsC,OAAO,OAAO,CAAC,CAAC;AAQ5D,MAAM,eAAe,CACnB,UACA,MACA,MACA,aAC4B;AAC5B,MAAI,CAAC,OAAO,OAAO,SAAS,OAAO,IAAI,GAAG;AACxC,QAAI,SAAS,WAAW,EAAG,QAAO;AAClC,WAAO,IAAI,+BAAY;AAAA,MACrB,MAAM;AAAA,MACN,SAAS,SAAS,IAAI;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AACA,QAAM,WAAW,SAAS,MAAM,IAAI;AACpC,MAAI,aAAa,KAAM,QAAO;AAC9B,SAAO,IAAI,+BAAY;AAAA,IACrB,MAAM;AAAA,IACN,SAAS,SAAS,IAAI,iBAAiB,KAAK,UAAU,QAAQ,CAAC,iDAC7D,KAAK,UAAU,IAAI,CACrB;AAAA,I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D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;IACzC,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;IAClD;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;IAC3C,gHAAgH;IAChH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,gBAAgB,GAAG,SAAS,CAAA;IAC/D,2EAA2E;IAC3E,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAClD;AAqQD;;;;;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/cjs/Resolve.js
CHANGED
|
@@ -62,21 +62,23 @@ const childPath = (path, key) => {
|
|
|
62
62
|
const bounded = diagnosticKey(key);
|
|
63
63
|
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(bounded) ? `${path}.${bounded}` : `${path}[${JSON.stringify(bounded)}]`;
|
|
64
64
|
};
|
|
65
|
-
const ownData = (input, path, allowed) => {
|
|
65
|
+
const ownData = (input, path, allowed, fields = {}) => {
|
|
66
66
|
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
67
|
-
throw invalidPlugin(path, "must be an ordinary record");
|
|
67
|
+
throw invalidPlugin(path, "must be an ordinary record", fields);
|
|
68
68
|
}
|
|
69
69
|
const prototype = Object.getPrototypeOf(input);
|
|
70
|
-
if (prototype !== Object.prototype && prototype !== null)
|
|
70
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
71
|
+
throw invalidPlugin(path, "must be an ordinary record", fields);
|
|
72
|
+
}
|
|
71
73
|
const output = {};
|
|
72
74
|
for (const key of Reflect.ownKeys(input)) {
|
|
73
|
-
if (typeof key !== "string") throw invalidPlugin(path, "must not contain symbol keys");
|
|
75
|
+
if (typeof key !== "string") throw invalidPlugin(path, "must not contain symbol keys", fields);
|
|
74
76
|
if (allowed !== void 0 && !allowed.has(key)) {
|
|
75
|
-
throw invalidPlugin(childPath(path, key), "contains an unknown property");
|
|
77
|
+
throw invalidPlugin(childPath(path, key), "contains an unknown property", fields);
|
|
76
78
|
}
|
|
77
79
|
const descriptor = Object.getOwnPropertyDescriptor(input, key);
|
|
78
80
|
if (descriptor === void 0 || !("value" in descriptor) || !descriptor.enumerable) {
|
|
79
|
-
throw invalidPlugin(childPath(path, key), "must be an enumerable data property");
|
|
81
|
+
throw invalidPlugin(childPath(path, key), "must be an enumerable data property", fields);
|
|
80
82
|
}
|
|
81
83
|
Object.defineProperty(output, key, { value: descriptor.value, enumerable: true });
|
|
82
84
|
}
|
|
@@ -136,7 +138,7 @@ const snapshotHook = (entry, path, plugin, hook) => {
|
|
|
136
138
|
if (entry === void 0) {
|
|
137
139
|
throw invalidPlugin(path, "must be a function or a hook object", { plugin, hook });
|
|
138
140
|
}
|
|
139
|
-
const values = ownData(entry, path, /* @__PURE__ */ new Set(["order", "handler"]));
|
|
141
|
+
const values = ownData(entry, path, /* @__PURE__ */ new Set(["order", "handler"]), { plugin, hook });
|
|
140
142
|
if (typeof values.handler !== "function") {
|
|
141
143
|
throw invalidPlugin(`${path}.handler`, "must be a function", { plugin, hook });
|
|
142
144
|
}
|
|
@@ -164,11 +166,11 @@ const snapshotPlugin = (input, path) => {
|
|
|
164
166
|
}
|
|
165
167
|
let hooks;
|
|
166
168
|
if (values.hooks !== void 0) {
|
|
167
|
-
const rawHooks = ownData(values.hooks, `${path}.hooks
|
|
169
|
+
const rawHooks = ownData(values.hooks, `${path}.hooks`, void 0, { plugin: name });
|
|
168
170
|
const snapshot = /* @__PURE__ */ Object.create(null);
|
|
169
171
|
for (const [index, hook] of Object.keys(rawHooks).entries()) {
|
|
170
172
|
if (!validName(hook)) {
|
|
171
|
-
throw invalidPlugin(`${path}.hooks[${index}]`, "contains an invalid hook name");
|
|
173
|
+
throw invalidPlugin(`${path}.hooks[${index}]`, "contains an invalid hook name", { plugin: name });
|
|
172
174
|
}
|
|
173
175
|
const entry = rawHooks[hook];
|
|
174
176
|
Object.defineProperty(snapshot, hook, {
|
|
@@ -228,18 +230,18 @@ const flatten = (input) => {
|
|
|
228
230
|
}
|
|
229
231
|
return output;
|
|
230
232
|
};
|
|
231
|
-
const included = (plugin, config, target) => {
|
|
233
|
+
const included = ({ path, plugin }, config, target) => {
|
|
232
234
|
const apply = plugin.apply;
|
|
233
235
|
if (apply === void 0) return Effect.succeed(true);
|
|
234
236
|
if (typeof apply !== "function") return Effect.succeed(apply === target);
|
|
235
237
|
return Effect.try({
|
|
236
238
|
try: () => apply(config),
|
|
237
|
-
catch: () => failure("apply_failed", `plugin "${plugin.name}" apply predicate failed`,
|
|
239
|
+
catch: () => failure("apply_failed", `plugin "${plugin.name}" apply predicate failed`, `${path}.apply`, {
|
|
238
240
|
plugin: plugin.name
|
|
239
241
|
})
|
|
240
242
|
}).pipe(
|
|
241
243
|
Effect.flatMap(
|
|
242
|
-
(result) => typeof result === "boolean" ? Effect.succeed(result) : Effect.fail(invalidPlugin(
|
|
244
|
+
(result) => typeof result === "boolean" ? Effect.succeed(result) : Effect.fail(invalidPlugin(`${path}.apply`, "predicate must return a boolean", { plugin: plugin.name }))
|
|
243
245
|
)
|
|
244
246
|
);
|
|
245
247
|
};
|
|
@@ -276,7 +278,7 @@ const resolve = (input, options = {}, configOverride) => Effect.gen(function* ()
|
|
|
276
278
|
catch: (cause) => cause instanceof import_PluginError.PluginError ? cause : invalidPlugin("$", "could not be inspected without executing user code")
|
|
277
279
|
});
|
|
278
280
|
const target = raw.target ?? "engine";
|
|
279
|
-
const selected = yield* Effect.filter(admitted, (
|
|
281
|
+
const selected = yield* Effect.filter(admitted, (entry) => included(entry, config, target));
|
|
280
282
|
let handlerCount = 0;
|
|
281
283
|
for (const { path, plugin } of selected) {
|
|
282
284
|
const pluginHooks = plugin.hooks;
|
|
@@ -301,20 +303,21 @@ const resolve = (input, options = {}, configOverride) => Effect.gen(function* ()
|
|
|
301
303
|
}
|
|
302
304
|
}
|
|
303
305
|
const seen = /* @__PURE__ */ new Set();
|
|
304
|
-
for (const { plugin } of selected) {
|
|
306
|
+
for (const { path, plugin } of selected) {
|
|
305
307
|
if (seen.has(plugin.name)) {
|
|
306
308
|
return yield* Effect.fail(failure(
|
|
307
309
|
"duplicate_name",
|
|
308
310
|
`duplicate plugin name "${plugin.name}"`,
|
|
309
|
-
|
|
311
|
+
`${path}.name`,
|
|
310
312
|
{ plugin: plugin.name }
|
|
311
313
|
));
|
|
312
314
|
}
|
|
313
315
|
seen.add(plugin.name);
|
|
314
316
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
);
|
|
317
|
+
const orderedEntries = selected.map((entry, index) => ({ entry, index })).sort(
|
|
318
|
+
(left, right) => rank(left.entry.plugin.enforce) - rank(right.entry.plugin.enforce) || left.index - right.index
|
|
319
|
+
).map(({ entry }) => entry);
|
|
320
|
+
const plugins = Object.freeze(orderedEntries.map(({ plugin }) => plugin));
|
|
318
321
|
const entries = [];
|
|
319
322
|
for (const hook of Object.keys(known)) {
|
|
320
323
|
const records = [];
|
|
@@ -330,7 +333,7 @@ const resolve = (input, options = {}, configOverride) => Effect.gen(function* ()
|
|
|
330
333
|
).map(({ record }) => record);
|
|
331
334
|
if (ordered.length > 0) entries.push([hook, Object.freeze(ordered)]);
|
|
332
335
|
}
|
|
333
|
-
const cacheEnvironment = yield* (0, import_snapshotCacheEnvironment.snapshotCacheEnvironment)(raw.cacheEnvironment,
|
|
336
|
+
const cacheEnvironment = yield* (0, import_snapshotCacheEnvironment.snapshotCacheEnvironment)(raw.cacheEnvironment, orderedEntries);
|
|
334
337
|
return Object.freeze({
|
|
335
338
|
plugins,
|
|
336
339
|
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,qBAAqB;AAQ3B,MAAM,iBAAiB;AAQvB,MAAM,kBAAkB;AAQxB,MAAM,0BAA0B;AAQhC,MAAM,0BAA0B;AAQhC,MAAM,6BAA6B;AAQnC,MAAM,6BAA6B;AA4D1C,MAAM,UAAU,CACd,MACA,SACA,MACA,SAA+D,CAAC,MAChD,IAAI,+BAAY,EAAE,MAAM,SAAS,MAAM,GAAG,OAAO,CAAC;AAEpE,MAAM,gBAAgB,CACpB,MACA,WACA,SAA+D,CAAC,MAChD,QAAQ,kBAAkB,gBAAgB,SAAS,IAAI,MAAM,MAAM;AAIrF,MAAM,gBAAgB,CAAC,QAAwB,IAAI,SAAS,KAAK,GAAG,IAAI,MAAM,GAAG,EAAE,CAAC,QAAQ;AAE5F,MAAM,YAAY,CAAC,MAAc,QAAwB;AACvD,QAAM,UAAU,cAAc,GAAG;AACjC,SAAO,6BAA6B,KAAK,OAAO,IAAI,GAAG,IAAI,IAAI,OAAO,KAAK,GAAG,IAAI,IAAI,KAAK,UAAU,OAAO,CAAC;AAC/G;AAEA,MAAM,UAAU,CACd,OACA,MACA,YACsC;AACtC,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ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O,OAAO,aAAa,IAAI,EAAG;AACpE,YAAM,QAAQ,YAAY,IAAI;AAC9B,YAAM,SAAS,OAAO,OAAO,EAAE,QAAQ,OAAO,MAAM,MAAM,aAAS,wBAAU,KAAK,EAAE,CAAC;AACrF,cAAQ,KAAK,EAAE,QAAQ,aAAa,KAAK,OAAO,OAAO,GAAG,WAAW,SAAK,sBAAQ,KAAK,CAAC,GAAG,MAAM,CAAC;AAAA,IACpG;AAKA,UAAM,UAAU,QACb;AAAA,MAAK,CAAC,MAAM,UACX,KAAK,YAAY,MAAM,aAAa,KAAK,cAAc,MAAM,eAAe,KAAK,QAAQ,MAAM;AAAA,IACjG,EACC,IAAI,CAAC,EAAE,OAAO,MAAM,MAAM;AAC7B,QAAI,QAAQ,SAAS,EAAG,SAAQ,KAAK,CAAC,MAAM,OAAO,OAAO,OAAO,CAAC,CAAC;AAAA,EACrE;AACA,QAAM,mBAAmB,WAAO,0DAAyB,IAAI,kBAAkB,OAAO;AACtF,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,UAAU,aAAa,KAAK,OAAO;AAAA,IACnC,OAAO;AAAA,IACP;AAAA,IACA,GAAI,qBAAqB,SAAY,CAAC,IAAI,EAAE,iBAAiB;AAAA,EAC/D,CAAC;AACH,CAAC;AASI,MAAM,QAAQ,CAAI,iBACvB,4CAAkB,SAAS,SAAS,SAAS,gBAAgB;",
|
|
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 fields: { readonly plugin?: string; readonly hook?: 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\", fields)\n }\n const prototype = Object.getPrototypeOf(input)\n if (prototype !== Object.prototype && prototype !== null) {\n throw invalidPlugin(path, \"must be an ordinary record\", fields)\n }\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\", fields)\n if (allowed !== undefined && !allowed.has(key)) {\n throw invalidPlugin(childPath(path, key), \"contains an unknown property\", fields)\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\", fields)\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\"]), { plugin, hook })\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`, undefined, { plugin: name })\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\", { plugin: 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,kBAAkB;AAQxB,MAAM,0BAA0B;AAQhC,MAAM,0BAA0B;AAQhC,MAAM,6BAA6B;AAQnC,MAAM,6BAA6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AAM;AAAA,IACjG,EACC,IAAI,CAAC,EAAE,OAAO,MAAM,MAAM;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"],
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AAM,eAAsD,CAAC;AAC7D,iBAAW,QAAQ,OAAO,KAAK,YAAY,YAAY,GAAG;AACxD,eAAO,eAAe,cAAc,MAAM;AAAA,UACxC,OAAO,OAAO,OAAO,CAAC,GAAG,YAAY,aAAa,IAAI,CAAE,CAAC;AAAA,UACzD,YAAY;AAAA,QACd,CAAC;AAAA,MACH;AACA,aAAO,OAAO,OAAO;AAAA,QACnB,QAAQ,OAAO,OAAO,CAAC,GAAG,kBAAkB,GAAG,YAAY,MAAM,CAAC;AAAA,QAClE,cAAc,OAAO,OAAO,YAAY;AAAA,MAC1C,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugins.d.ts","sourceRoot":"","sources":["../../src/Plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAY,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAA8B,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Plugins.d.ts","sourceRoot":"","sources":["../../src/Plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,EA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