@clayroach/effect-unplugin 4.0.0-effect4-transformer.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts ADDED
@@ -0,0 +1,162 @@
1
+ /**
2
+ * @since 0.0.1
3
+ */
4
+
5
+ /**
6
+ * Filter pattern for file matching.
7
+ *
8
+ * @since 0.0.1
9
+ * @category models
10
+ */
11
+ export type FilterPattern = string | RegExp | ReadonlyArray<string | RegExp>
12
+
13
+ /**
14
+ * Effect combinators that can be auto-instrumented with spans.
15
+ *
16
+ * @since 0.0.1
17
+ * @category models
18
+ */
19
+ export type InstrumentableEffect =
20
+ | "gen"
21
+ | "fork"
22
+ | "forkDaemon"
23
+ | "forkScoped"
24
+ | "all"
25
+ | "forEach"
26
+ | "filter"
27
+ | "reduce"
28
+ | "iterate"
29
+ | "loop"
30
+
31
+ /**
32
+ * Span name format options.
33
+ *
34
+ * @since 0.0.1
35
+ * @category models
36
+ */
37
+ export type SpanNameFormat = "function" | "location" | "full"
38
+
39
+ /**
40
+ * File/function filtering for a specific combinator.
41
+ *
42
+ * @since 0.0.1
43
+ * @category models
44
+ */
45
+ export interface CombinatorFilter {
46
+ /**
47
+ * File glob patterns to include (single or array)
48
+ */
49
+ readonly files?: string | ReadonlyArray<string> | undefined
50
+ /**
51
+ * File glob patterns to exclude (single or array)
52
+ */
53
+ readonly excludeFiles?: string | ReadonlyArray<string> | undefined
54
+ /**
55
+ * Function name regex patterns to include (single or array)
56
+ */
57
+ readonly functions?: string | ReadonlyArray<string> | undefined
58
+ /**
59
+ * Function name regex patterns to exclude (single or array)
60
+ */
61
+ readonly excludeFunctions?: string | ReadonlyArray<string> | undefined
62
+ }
63
+
64
+ /**
65
+ * Depth-based instrumentation strategy.
66
+ *
67
+ * @since 0.0.1
68
+ * @category models
69
+ */
70
+ export interface DepthInstrumentationStrategy {
71
+ readonly type: "depth"
72
+ /**
73
+ * Global max nesting depth for all combinators (default: Infinity)
74
+ * 0 = top-level only, 1 = one level deep, etc.
75
+ */
76
+ readonly maxDepth?: number | undefined
77
+ /**
78
+ * Per-combinator depth limits (overrides maxDepth)
79
+ */
80
+ readonly perCombinator?: Partial<Record<InstrumentableEffect, number>> | undefined
81
+ }
82
+
83
+ /**
84
+ * Override-based instrumentation strategy with file/function filtering.
85
+ *
86
+ * @since 0.0.1
87
+ * @category models
88
+ */
89
+ export interface OverrideInstrumentationStrategy {
90
+ readonly type: "overrides"
91
+ /**
92
+ * Per-combinator filter rules
93
+ */
94
+ readonly rules: Partial<Record<InstrumentableEffect, CombinatorFilter>>
95
+ }
96
+
97
+ /**
98
+ * Options for auto-instrumentation with withSpan.
99
+ *
100
+ * @since 0.0.1
101
+ * @category models
102
+ */
103
+ export interface SpanInstrumentationOptions {
104
+ /**
105
+ * Enable auto-instrumentation with withSpan.
106
+ * @default false
107
+ */
108
+ readonly enabled?: boolean | undefined
109
+ /**
110
+ * Effect combinators to instrument. Defaults to all supported combinators.
111
+ */
112
+ readonly include?: ReadonlyArray<InstrumentableEffect> | undefined
113
+ /**
114
+ * Effect combinators to exclude from instrumentation.
115
+ */
116
+ readonly exclude?: ReadonlyArray<InstrumentableEffect> | undefined
117
+ /**
118
+ * Span name format.
119
+ * - "function": `effect.gen (fetchUser)` - combinator + function name (DEFAULT)
120
+ * - "location": `effect.gen (index.ts:23)` - combinator + file:line
121
+ * - "full": `effect.gen (fetchUser @ index.ts:23)` - all info
122
+ * @default "function"
123
+ */
124
+ readonly nameFormat?: SpanNameFormat | undefined
125
+ /**
126
+ * Instrumentation strategy for fine-grained control.
127
+ * - depth: Limit by nesting depth
128
+ * - overrides: File/function filtering per combinator
129
+ */
130
+ readonly strategy?: DepthInstrumentationStrategy | OverrideInstrumentationStrategy | undefined
131
+ }
132
+
133
+ /**
134
+ * Options for the source trace transformer plugin.
135
+ *
136
+ * @since 0.0.1
137
+ * @category models
138
+ */
139
+ export interface SourceTraceOptions {
140
+ /**
141
+ * Files to include in transformation. Defaults to TypeScript/JavaScript files.
142
+ */
143
+ readonly include?: FilterPattern | undefined
144
+ /**
145
+ * Files to exclude from transformation. Defaults to node_modules.
146
+ */
147
+ readonly exclude?: FilterPattern | undefined
148
+ /**
149
+ * Extract function name from yield* expression for the stack frame.
150
+ * @default true
151
+ */
152
+ readonly extractFunctionName?: boolean | undefined
153
+ /**
154
+ * Enable yield* source tracing with CurrentStackFrame.
155
+ * @default true
156
+ */
157
+ readonly sourceTrace?: boolean | undefined
158
+ /**
159
+ * Auto-instrumentation options for wrapping Effect combinators with withSpan.
160
+ */
161
+ readonly spans?: SpanInstrumentationOptions | undefined
162
+ }
package/src/vite.ts ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Vite plugin for Effect source location tracing.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * // vite.config.ts
7
+ * import { defineConfig } from "vite"
8
+ * import effectSourceTrace from "@effect/unplugin/vite"
9
+ *
10
+ * export default defineConfig({
11
+ * plugins: [effectSourceTrace()]
12
+ * })
13
+ * ```
14
+ *
15
+ * @since 0.0.1
16
+ */
17
+ import unplugin from "./index.ts"
18
+
19
+ export default unplugin.vite
package/src/webpack.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Webpack plugin for Effect source location tracing.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * // webpack.config.js
7
+ * import effectSourceTrace from "@effect/unplugin/webpack"
8
+ *
9
+ * export default {
10
+ * plugins: [effectSourceTrace()]
11
+ * }
12
+ * ```
13
+ *
14
+ * @since 0.0.1
15
+ */
16
+ import unplugin from "./index.ts"
17
+
18
+ export default unplugin.webpack