@mastra/core 0.5.0-alpha.9 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.cjs +3 -2140
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/{base-CMEKtEnE.d.cts → base-CIPKleAU.d.cts} +97 -60
- package/dist/{base-B78F6w8S.d.ts → base-C_Oq53qk.d.ts} +97 -60
- package/dist/base.cjs +5 -140
- package/dist/bundler/index.cjs +5 -160
- package/dist/chunk-2W2GYEYQ.cjs +25 -0
- package/dist/chunk-3ASEZT7U.cjs +1586 -0
- package/dist/chunk-43Y7WG5W.cjs +335 -0
- package/dist/{chunk-IM7CM3DU.js → chunk-4Y74D74B.js} +1 -1
- package/dist/chunk-ENT7U27Y.cjs +37 -0
- package/dist/chunk-F5UYWPV4.cjs +14 -0
- package/dist/chunk-FL3GQXQ2.cjs +218 -0
- package/dist/chunk-FRQFWZDN.cjs +2 -0
- package/dist/chunk-GXQRMKSN.cjs +367 -0
- package/dist/chunk-HJPMYDWO.cjs +37 -0
- package/dist/chunk-IIWRJFLQ.cjs +51 -0
- package/dist/chunk-KFQ7Z3PO.cjs +347 -0
- package/dist/{chunk-TWAIC2XA.js → chunk-KP5UAFLN.js} +1 -1
- package/dist/chunk-KPKFLQFR.cjs +12 -0
- package/dist/{chunk-NR5T72G7.js → chunk-MLFXOST6.js} +1 -1
- package/dist/{chunk-6V737PR2.js → chunk-OD7ZMKHY.js} +166 -58
- package/dist/chunk-OTFLHXHZ.cjs +65 -0
- package/dist/chunk-RWTSGWWL.cjs +81 -0
- package/dist/chunk-ST5RMVLG.cjs +87 -0
- package/dist/chunk-SYQ7NK2E.cjs +24 -0
- package/dist/chunk-UZNQG7QO.cjs +1868 -0
- package/dist/chunk-V5ORZPFW.cjs +38 -0
- package/dist/chunk-VA4P7QJT.cjs +443 -0
- package/dist/chunk-WB2HREXE.cjs +166 -0
- package/dist/chunk-WOMOGDGR.cjs +691 -0
- package/dist/chunk-XB2TJ7LX.cjs +408 -0
- package/dist/{chunk-4AQBRUR2.js → chunk-XF2FMJYK.js} +1 -1
- package/dist/chunk-XLSROQ26.cjs +91 -0
- package/dist/chunk-YK3XJ52U.cjs +192 -0
- package/dist/{chunk-EWB556GS.js → chunk-YPD6BQIM.js} +29 -1
- package/dist/deployer/index.cjs +5 -167
- package/dist/eval/index.cjs +9 -105
- package/dist/eval/index.d.cts +1 -1
- package/dist/eval/index.d.ts +1 -1
- package/dist/hooks/index.cjs +14 -83
- package/dist/index.cjs +253 -7516
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -7
- package/dist/integration/index.cjs +9 -108
- package/dist/integration/index.d.cts +1 -1
- package/dist/integration/index.d.ts +1 -1
- package/dist/llm/index.d.cts +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/logger/index.cjs +33 -161
- package/dist/mastra/index.cjs +3 -1755
- package/dist/mastra/index.d.cts +1 -1
- package/dist/mastra/index.d.ts +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -2050
- package/dist/memory/index.d.cts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/relevance/index.cjs +10 -2201
- package/dist/relevance/index.d.cts +19 -2
- package/dist/relevance/index.d.ts +19 -2
- package/dist/relevance/index.js +1 -1
- package/dist/storage/index.cjs +29 -367
- package/dist/storage/index.d.cts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/libsql/index.cjs +9 -798
- package/dist/storage/libsql/index.d.cts +1 -1
- package/dist/storage/libsql/index.d.ts +1 -1
- package/dist/telemetry/index.cjs +21 -408
- package/dist/telemetry/index.d.cts +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/index.cjs +11 -22
- package/dist/tools/index.d.cts +3 -3
- package/dist/tools/index.d.ts +3 -3
- package/dist/tts/index.cjs +3 -328
- package/dist/utils.cjs +41 -350
- package/dist/utils.d.cts +3 -3
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +1 -1
- package/dist/vector/filter/index.cjs +7 -189
- package/dist/vector/index.cjs +5 -172
- package/dist/vector/libsql/index.cjs +9 -1047
- package/dist/voice/index.cjs +8 -306
- package/dist/workflows/index.cjs +65 -1936
- package/dist/workflows/index.d.cts +4 -3
- package/dist/workflows/index.d.ts +4 -3
- package/dist/workflows/index.js +1 -1
- package/package.json +27 -27
|
@@ -14,12 +14,31 @@ var Mastra = class {
|
|
|
14
14
|
#agents;
|
|
15
15
|
#logger;
|
|
16
16
|
#workflows;
|
|
17
|
-
#telemetry;
|
|
18
17
|
#tts;
|
|
19
18
|
#deployer;
|
|
19
|
+
#serverMiddleware = [];
|
|
20
|
+
#telemetry;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated use getStorage() instead
|
|
23
|
+
*/
|
|
20
24
|
storage;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated use getMemory() instead
|
|
27
|
+
*/
|
|
21
28
|
memory;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated use getTelemetry() instead
|
|
31
|
+
*/
|
|
32
|
+
get telemetry() {
|
|
33
|
+
return this.#telemetry;
|
|
34
|
+
}
|
|
22
35
|
constructor(config) {
|
|
36
|
+
if (config?.serverMiddleware) {
|
|
37
|
+
this.#serverMiddleware = config.serverMiddleware.map(m => ({
|
|
38
|
+
handler: m.handler,
|
|
39
|
+
path: m.path || "/api/*"
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
23
42
|
let logger;
|
|
24
43
|
if (config?.logger === false) {
|
|
25
44
|
logger = noopLogger;
|
|
@@ -310,6 +329,15 @@ This is a warning for now, but will throw an error in the future
|
|
|
310
329
|
getTelemetry() {
|
|
311
330
|
return this.#telemetry;
|
|
312
331
|
}
|
|
332
|
+
getMemory() {
|
|
333
|
+
return this.memory;
|
|
334
|
+
}
|
|
335
|
+
getStorage() {
|
|
336
|
+
return this.storage;
|
|
337
|
+
}
|
|
338
|
+
getServerMiddleware() {
|
|
339
|
+
return this.#serverMiddleware;
|
|
340
|
+
}
|
|
313
341
|
async getLogsByRunId({
|
|
314
342
|
runId,
|
|
315
343
|
transportId
|
package/dist/deployer/index.cjs
CHANGED
|
@@ -1,172 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var dotenv = require('dotenv');
|
|
5
|
-
var stream = require('stream');
|
|
6
|
-
var pino = require('pino');
|
|
7
|
-
var pretty = require('pino-pretty');
|
|
3
|
+
var chunkKPKFLQFR_cjs = require('../chunk-KPKFLQFR.cjs');
|
|
8
4
|
|
|
9
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
5
|
|
|
11
|
-
var pino__default = /*#__PURE__*/_interopDefault(pino);
|
|
12
|
-
var pretty__default = /*#__PURE__*/_interopDefault(pretty);
|
|
13
6
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
INFO: "info"};
|
|
19
|
-
var Logger = class {
|
|
20
|
-
logger;
|
|
21
|
-
transports;
|
|
22
|
-
constructor(options = {}) {
|
|
23
|
-
this.transports = options.transports || {};
|
|
24
|
-
const transportsAry = Object.entries(this.transports);
|
|
25
|
-
this.logger = pino__default.default(
|
|
26
|
-
{
|
|
27
|
-
name: options.name || "app",
|
|
28
|
-
level: options.level || LogLevel.INFO,
|
|
29
|
-
formatters: {
|
|
30
|
-
level: (label) => {
|
|
31
|
-
return {
|
|
32
|
-
level: label
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
options.overrideDefaultTransports ? options?.transports?.default : transportsAry.length === 0 ? pretty__default.default({
|
|
38
|
-
colorize: true,
|
|
39
|
-
levelFirst: true,
|
|
40
|
-
ignore: "pid,hostname",
|
|
41
|
-
colorizeObjects: true,
|
|
42
|
-
translateTime: "SYS:standard",
|
|
43
|
-
singleLine: false
|
|
44
|
-
}) : pino__default.default.multistream([
|
|
45
|
-
...transportsAry.map(([_, transport]) => ({
|
|
46
|
-
stream: transport,
|
|
47
|
-
level: options.level || LogLevel.INFO
|
|
48
|
-
})),
|
|
49
|
-
{
|
|
50
|
-
stream: pretty__default.default({
|
|
51
|
-
colorize: true,
|
|
52
|
-
levelFirst: true,
|
|
53
|
-
ignore: "pid,hostname",
|
|
54
|
-
colorizeObjects: true,
|
|
55
|
-
translateTime: "SYS:standard",
|
|
56
|
-
singleLine: false
|
|
57
|
-
}),
|
|
58
|
-
level: options.level || LogLevel.INFO
|
|
59
|
-
}
|
|
60
|
-
])
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
debug(message, args = {}) {
|
|
64
|
-
this.logger.debug(args, message);
|
|
65
|
-
}
|
|
66
|
-
info(message, args = {}) {
|
|
67
|
-
this.logger.info(args, message);
|
|
68
|
-
}
|
|
69
|
-
warn(message, args = {}) {
|
|
70
|
-
this.logger.warn(args, message);
|
|
71
|
-
}
|
|
72
|
-
error(message, args = {}) {
|
|
73
|
-
this.logger.error(args, message);
|
|
74
|
-
}
|
|
75
|
-
// Stream creation for process output handling
|
|
76
|
-
createStream() {
|
|
77
|
-
return new stream.Transform({
|
|
78
|
-
transform: (chunk, _encoding, callback) => {
|
|
79
|
-
const line = chunk.toString().trim();
|
|
80
|
-
if (line) {
|
|
81
|
-
this.info(line);
|
|
82
|
-
}
|
|
83
|
-
callback(null, chunk);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
async getLogs(transportId) {
|
|
88
|
-
if (!transportId || !this.transports[transportId]) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
return this.transports[transportId].getLogs();
|
|
92
|
-
}
|
|
93
|
-
async getLogsByRunId({ runId, transportId }) {
|
|
94
|
-
return this.transports[transportId]?.getLogsByRunId({ runId });
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
function createLogger(options) {
|
|
98
|
-
return new Logger(options);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// src/base.ts
|
|
102
|
-
var MastraBase = class {
|
|
103
|
-
component = RegisteredLogger.LLM;
|
|
104
|
-
logger;
|
|
105
|
-
name;
|
|
106
|
-
telemetry;
|
|
107
|
-
constructor({ component, name }) {
|
|
108
|
-
this.component = component || RegisteredLogger.LLM;
|
|
109
|
-
this.name = name;
|
|
110
|
-
this.logger = createLogger({ name: `${this.component} - ${this.name}` });
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Set the logger for the agent
|
|
114
|
-
* @param logger
|
|
115
|
-
*/
|
|
116
|
-
__setLogger(logger) {
|
|
117
|
-
this.logger = logger;
|
|
118
|
-
this.logger.debug(`Logger updated [component=${this.component}] [name=${this.name}]`);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Set the telemetry for the
|
|
122
|
-
* @param telemetry
|
|
123
|
-
*/
|
|
124
|
-
__setTelemetry(telemetry) {
|
|
125
|
-
this.telemetry = telemetry;
|
|
126
|
-
this.logger.debug(`Telemetry updated [component=${this.component}] [tracer=${this.telemetry.tracer}]`);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Get the telemetry on the vector
|
|
130
|
-
* @returns telemetry
|
|
131
|
-
*/
|
|
132
|
-
__getTelemetry() {
|
|
133
|
-
return this.telemetry;
|
|
134
|
-
}
|
|
135
|
-
/*
|
|
136
|
-
get experimental_telemetry config
|
|
137
|
-
*/
|
|
138
|
-
get experimental_telemetry() {
|
|
139
|
-
return this.telemetry ? {
|
|
140
|
-
// tracer: this.telemetry.tracer,
|
|
141
|
-
tracer: this.telemetry.getBaggageTracer(),
|
|
142
|
-
isEnabled: !!this.telemetry.tracer
|
|
143
|
-
} : void 0;
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// src/bundler/index.ts
|
|
148
|
-
var MastraBundler = class extends MastraBase {
|
|
149
|
-
constructor({ name, component = "BUNDLER" }) {
|
|
150
|
-
super({ component, name });
|
|
151
|
-
}
|
|
152
|
-
async loadEnvVars() {
|
|
153
|
-
const envVars = /* @__PURE__ */ new Map();
|
|
154
|
-
for (const file of await this.getEnvFiles()) {
|
|
155
|
-
const content = await promises.readFile(file, "utf-8");
|
|
156
|
-
const config = dotenv.parse(content);
|
|
157
|
-
Object.entries(config).forEach(([key, value]) => {
|
|
158
|
-
envVars.set(key, value);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
return envVars;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// src/deployer/index.ts
|
|
166
|
-
var MastraDeployer = class extends MastraBundler {
|
|
167
|
-
constructor({ name }) {
|
|
168
|
-
super({ component: "DEPLOYER", name });
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
exports.MastraDeployer = MastraDeployer;
|
|
7
|
+
Object.defineProperty(exports, "MastraDeployer", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkKPKFLQFR_cjs.MastraDeployer; }
|
|
10
|
+
});
|
package/dist/eval/index.cjs
CHANGED
|
@@ -1,110 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var Metric = class {
|
|
5
|
-
};
|
|
3
|
+
var chunkV5ORZPFW_cjs = require('../chunk-V5ORZPFW.cjs');
|
|
6
4
|
|
|
7
|
-
// src/hooks/mitt.ts
|
|
8
|
-
function mitt(all) {
|
|
9
|
-
all = all || /* @__PURE__ */ new Map();
|
|
10
|
-
return {
|
|
11
|
-
/**
|
|
12
|
-
* A Map of event names to registered handler functions.
|
|
13
|
-
*/
|
|
14
|
-
all,
|
|
15
|
-
/**
|
|
16
|
-
* Register an event handler for the given type.
|
|
17
|
-
* @param {string|symbol} type Type of event to listen for, or `'*'` for all events
|
|
18
|
-
* @param {Function} handler Function to call in response to given event
|
|
19
|
-
* @memberOf mitt
|
|
20
|
-
*/
|
|
21
|
-
on(type, handler) {
|
|
22
|
-
const handlers = all.get(type);
|
|
23
|
-
if (handlers) {
|
|
24
|
-
handlers.push(handler);
|
|
25
|
-
} else {
|
|
26
|
-
all.set(type, [handler]);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
/**
|
|
30
|
-
* Remove an event handler for the given type.
|
|
31
|
-
* If `handler` is omitted, all handlers of the given type are removed.
|
|
32
|
-
* @param {string|symbol} type Type of event to unregister `handler` from (`'*'` to remove a wildcard handler)
|
|
33
|
-
* @param {Function} [handler] Handler function to remove
|
|
34
|
-
* @memberOf mitt
|
|
35
|
-
*/
|
|
36
|
-
off(type, handler) {
|
|
37
|
-
const handlers = all.get(type);
|
|
38
|
-
if (handlers) {
|
|
39
|
-
if (handler) {
|
|
40
|
-
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
|
|
41
|
-
} else {
|
|
42
|
-
all.set(type, []);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* Invoke all handlers for the given type.
|
|
48
|
-
* If present, `'*'` handlers are invoked after type-matched handlers.
|
|
49
|
-
*
|
|
50
|
-
* Note: Manually firing '*' handlers is not supported.
|
|
51
|
-
*
|
|
52
|
-
* @param {string|symbol} type The event type to invoke
|
|
53
|
-
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
|
|
54
|
-
* @memberOf mitt
|
|
55
|
-
*/
|
|
56
|
-
emit(type, evt) {
|
|
57
|
-
let handlers = all.get(type);
|
|
58
|
-
if (handlers) {
|
|
59
|
-
handlers.slice().map((handler) => {
|
|
60
|
-
handler(evt);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
handlers = all.get("*");
|
|
64
|
-
if (handlers) {
|
|
65
|
-
handlers.slice().map((handler) => {
|
|
66
|
-
handler(type, evt);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
5
|
|
|
73
|
-
// src/hooks/index.ts
|
|
74
|
-
var hooks = mitt();
|
|
75
|
-
function executeHook(hook, data) {
|
|
76
|
-
setImmediate(() => {
|
|
77
|
-
hooks.emit(hook, data);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
6
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
testInfo,
|
|
90
|
-
instructions
|
|
91
|
-
}) {
|
|
92
|
-
const runIdToUse = runId || crypto.randomUUID();
|
|
93
|
-
const metricResult = await metric.measure(input.toString(), output);
|
|
94
|
-
const traceObject = {
|
|
95
|
-
input: input.toString(),
|
|
96
|
-
output,
|
|
97
|
-
result: metricResult,
|
|
98
|
-
agentName,
|
|
99
|
-
metricName: metric.constructor.name,
|
|
100
|
-
instructions,
|
|
101
|
-
globalRunId,
|
|
102
|
-
runId: runIdToUse,
|
|
103
|
-
testInfo
|
|
104
|
-
};
|
|
105
|
-
executeHook("onEvaluation" /* ON_EVALUATION */, traceObject);
|
|
106
|
-
return metricResult;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
exports.Metric = Metric;
|
|
110
|
-
exports.evaluate = evaluate;
|
|
7
|
+
Object.defineProperty(exports, "Metric", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkV5ORZPFW_cjs.Metric; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "evaluate", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkV5ORZPFW_cjs.evaluate; }
|
|
14
|
+
});
|
package/dist/eval/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { M as Metric, T as TestInfo, a as MetricResult } from '../types-CwTG2XyQ.cjs';
|
|
2
|
-
import { A as Agent } from '../base-
|
|
2
|
+
import { A as Agent } from '../base-CIPKleAU.cjs';
|
|
3
3
|
import 'ai';
|
|
4
4
|
import '../base-DboIg_Cd.cjs';
|
|
5
5
|
import '@opentelemetry/api';
|
package/dist/eval/index.d.ts
CHANGED
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,87 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
function mitt(all) {
|
|
5
|
-
all = all || /* @__PURE__ */ new Map();
|
|
6
|
-
return {
|
|
7
|
-
/**
|
|
8
|
-
* A Map of event names to registered handler functions.
|
|
9
|
-
*/
|
|
10
|
-
all,
|
|
11
|
-
/**
|
|
12
|
-
* Register an event handler for the given type.
|
|
13
|
-
* @param {string|symbol} type Type of event to listen for, or `'*'` for all events
|
|
14
|
-
* @param {Function} handler Function to call in response to given event
|
|
15
|
-
* @memberOf mitt
|
|
16
|
-
*/
|
|
17
|
-
on(type, handler) {
|
|
18
|
-
const handlers = all.get(type);
|
|
19
|
-
if (handlers) {
|
|
20
|
-
handlers.push(handler);
|
|
21
|
-
} else {
|
|
22
|
-
all.set(type, [handler]);
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
/**
|
|
26
|
-
* Remove an event handler for the given type.
|
|
27
|
-
* If `handler` is omitted, all handlers of the given type are removed.
|
|
28
|
-
* @param {string|symbol} type Type of event to unregister `handler` from (`'*'` to remove a wildcard handler)
|
|
29
|
-
* @param {Function} [handler] Handler function to remove
|
|
30
|
-
* @memberOf mitt
|
|
31
|
-
*/
|
|
32
|
-
off(type, handler) {
|
|
33
|
-
const handlers = all.get(type);
|
|
34
|
-
if (handlers) {
|
|
35
|
-
if (handler) {
|
|
36
|
-
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
|
|
37
|
-
} else {
|
|
38
|
-
all.set(type, []);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* Invoke all handlers for the given type.
|
|
44
|
-
* If present, `'*'` handlers are invoked after type-matched handlers.
|
|
45
|
-
*
|
|
46
|
-
* Note: Manually firing '*' handlers is not supported.
|
|
47
|
-
*
|
|
48
|
-
* @param {string|symbol} type The event type to invoke
|
|
49
|
-
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
|
|
50
|
-
* @memberOf mitt
|
|
51
|
-
*/
|
|
52
|
-
emit(type, evt) {
|
|
53
|
-
let handlers = all.get(type);
|
|
54
|
-
if (handlers) {
|
|
55
|
-
handlers.slice().map((handler) => {
|
|
56
|
-
handler(evt);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
handlers = all.get("*");
|
|
60
|
-
if (handlers) {
|
|
61
|
-
handlers.slice().map((handler) => {
|
|
62
|
-
handler(type, evt);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
3
|
+
var chunkST5RMVLG_cjs = require('../chunk-ST5RMVLG.cjs');
|
|
68
4
|
|
|
69
|
-
// src/hooks/index.ts
|
|
70
|
-
var AvailableHooks = /* @__PURE__ */ ((AvailableHooks2) => {
|
|
71
|
-
AvailableHooks2["ON_EVALUATION"] = "onEvaluation";
|
|
72
|
-
AvailableHooks2["ON_GENERATION"] = "onGeneration";
|
|
73
|
-
return AvailableHooks2;
|
|
74
|
-
})(AvailableHooks || {});
|
|
75
|
-
var hooks = mitt();
|
|
76
|
-
function registerHook(hook, action) {
|
|
77
|
-
hooks.on(hook, action);
|
|
78
|
-
}
|
|
79
|
-
function executeHook(hook, data) {
|
|
80
|
-
setImmediate(() => {
|
|
81
|
-
hooks.emit(hook, data);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
5
|
|
|
85
|
-
|
|
86
|
-
exports
|
|
87
|
-
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "AvailableHooks", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkST5RMVLG_cjs.AvailableHooks; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "executeHook", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkST5RMVLG_cjs.executeHook; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "registerHook", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkST5RMVLG_cjs.registerHook; }
|
|
18
|
+
});
|