@tradejs/node 1.0.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/pine.js ADDED
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/pine.ts
32
+ var pine_exports = {};
33
+ __export(pine_exports, {
34
+ createLoadPineScript: () => createLoadPineScript,
35
+ loadPineScript: () => loadPineScript,
36
+ runPineScript: () => runPineScript
37
+ });
38
+ module.exports = __toCommonJS(pine_exports);
39
+ var import_node_fs = __toESM(require("fs"));
40
+ var import_node_path = __toESM(require("path"));
41
+ __reExport(pine_exports, require("@tradejs/core/pine"), module.exports);
42
+ var loadPinets = () => {
43
+ const resolvedPath = require.resolve("pinets");
44
+ const cjsPath = resolvedPath.includes("pinets.min.browser") ? resolvedPath.replace(/pinets\.min\.browser(\.es)?\.js$/, "pinets.min.cjs") : resolvedPath;
45
+ return require(cjsPath);
46
+ };
47
+ var loadPineScript = (filePath, fallback = "") => {
48
+ const resolvedPath = String(filePath || "").trim();
49
+ if (!resolvedPath) {
50
+ return fallback;
51
+ }
52
+ try {
53
+ return import_node_fs.default.readFileSync(resolvedPath, "utf8").trim();
54
+ } catch {
55
+ return fallback;
56
+ }
57
+ };
58
+ var createLoadPineScript = (baseDir) => {
59
+ const resolvedBaseDir = import_node_path.default.resolve(baseDir);
60
+ return (fileNameOrPath, fallback = "") => {
61
+ const rawPath = String(fileNameOrPath || "").trim();
62
+ if (!rawPath) {
63
+ return fallback;
64
+ }
65
+ const resolvedPath = import_node_path.default.isAbsolute(rawPath) ? rawPath : import_node_path.default.resolve(resolvedBaseDir, rawPath);
66
+ return loadPineScript(resolvedPath, fallback);
67
+ };
68
+ };
69
+ var MINUTE_MS = 6e4;
70
+ var normalizeTimestampMs = (timestamp) => timestamp < 1e12 ? timestamp * 1e3 : timestamp;
71
+ var resolveCandleDuration = (candles) => {
72
+ if (candles.length < 2) {
73
+ return MINUTE_MS;
74
+ }
75
+ const first = normalizeTimestampMs(candles[0].timestamp);
76
+ const second = normalizeTimestampMs(candles[1].timestamp);
77
+ const duration = Math.max(second - first, MINUTE_MS);
78
+ return Number.isFinite(duration) && duration > 0 ? duration : MINUTE_MS;
79
+ };
80
+ var toPineRuntimeCandles = (candles) => {
81
+ const candleDuration = resolveCandleDuration(candles);
82
+ return candles.map((candle) => {
83
+ const openTime = normalizeTimestampMs(candle.timestamp);
84
+ return {
85
+ open: Number(candle.open),
86
+ high: Number(candle.high),
87
+ low: Number(candle.low),
88
+ close: Number(candle.close),
89
+ volume: Number(candle.volume ?? 0),
90
+ openTime,
91
+ closeTime: openTime + candleDuration
92
+ };
93
+ });
94
+ };
95
+ var runPineScript = async ({
96
+ candles,
97
+ script,
98
+ symbol = "SYMBOL",
99
+ timeframe = "15",
100
+ inputs = {},
101
+ limit
102
+ }) => {
103
+ const { PineTS, Indicator } = loadPinets();
104
+ const trimmedScript = String(script || "").trim();
105
+ if (!trimmedScript) {
106
+ throw new Error("Pine script is empty");
107
+ }
108
+ if (!Array.isArray(candles) || candles.length === 0) {
109
+ throw new Error("No candles provided for Pine script execution");
110
+ }
111
+ const pineCandles = toPineRuntimeCandles(candles);
112
+ const pine = new PineTS(
113
+ pineCandles,
114
+ symbol,
115
+ timeframe,
116
+ Math.max(1, limit ?? pineCandles.length)
117
+ );
118
+ const indicator = new Indicator(trimmedScript, inputs);
119
+ const context = await pine.run(indicator);
120
+ return context;
121
+ };
122
+ // Annotate the CommonJS export names for ESM import in node:
123
+ 0 && (module.exports = {
124
+ createLoadPineScript,
125
+ loadPineScript,
126
+ runPineScript,
127
+ ...require("@tradejs/core/pine")
128
+ });
package/dist/pine.mjs ADDED
@@ -0,0 +1,11 @@
1
+ import {
2
+ createLoadPineScript,
3
+ loadPineScript,
4
+ runPineScript
5
+ } from "./chunk-CVTV6S2V.mjs";
6
+ import "./chunk-6DZX6EAA.mjs";
7
+ export {
8
+ createLoadPineScript,
9
+ loadPineScript,
10
+ runPineScript
11
+ };
@@ -0,0 +1,15 @@
1
+ import { StrategyManifest, StrategyCreator, StrategyRegistryEntry } from '@tradejs/types';
2
+
3
+ declare const ensureStrategyPluginsLoaded: () => Promise<void>;
4
+ declare const ensureIndicatorPluginsLoaded: () => Promise<void>;
5
+ declare const getStrategyCreator: (name: string) => Promise<StrategyCreator | undefined>;
6
+ declare const getAvailableStrategyNames: () => Promise<string[]>;
7
+ declare const getRegisteredStrategies: () => Record<string, StrategyCreator>;
8
+ declare const getRegisteredManifests: () => StrategyManifest[];
9
+ declare const getStrategyManifest: (name?: string) => StrategyManifest | undefined;
10
+ declare const isKnownStrategy: (name: string) => boolean;
11
+ declare const registerStrategyEntries: (entries: readonly StrategyRegistryEntry[]) => void;
12
+ declare const resetStrategyRegistryCache: () => void;
13
+ declare const strategies: Record<string, StrategyCreator>;
14
+
15
+ export { ensureIndicatorPluginsLoaded, ensureStrategyPluginsLoaded, getAvailableStrategyNames, getRegisteredManifests, getRegisteredStrategies, getStrategyCreator, getStrategyManifest, isKnownStrategy, registerStrategyEntries, resetStrategyRegistryCache, strategies };
@@ -0,0 +1,15 @@
1
+ import { StrategyManifest, StrategyCreator, StrategyRegistryEntry } from '@tradejs/types';
2
+
3
+ declare const ensureStrategyPluginsLoaded: () => Promise<void>;
4
+ declare const ensureIndicatorPluginsLoaded: () => Promise<void>;
5
+ declare const getStrategyCreator: (name: string) => Promise<StrategyCreator | undefined>;
6
+ declare const getAvailableStrategyNames: () => Promise<string[]>;
7
+ declare const getRegisteredStrategies: () => Record<string, StrategyCreator>;
8
+ declare const getRegisteredManifests: () => StrategyManifest[];
9
+ declare const getStrategyManifest: (name?: string) => StrategyManifest | undefined;
10
+ declare const isKnownStrategy: (name: string) => boolean;
11
+ declare const registerStrategyEntries: (entries: readonly StrategyRegistryEntry[]) => void;
12
+ declare const resetStrategyRegistryCache: () => void;
13
+ declare const strategies: Record<string, StrategyCreator>;
14
+
15
+ export { ensureIndicatorPluginsLoaded, ensureStrategyPluginsLoaded, getAvailableStrategyNames, getRegisteredManifests, getRegisteredStrategies, getStrategyCreator, getStrategyManifest, isKnownStrategy, registerStrategyEntries, resetStrategyRegistryCache, strategies };
@@ -0,0 +1,439 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/registry.ts
31
+ var registry_exports = {};
32
+ __export(registry_exports, {
33
+ ensureIndicatorPluginsLoaded: () => ensureIndicatorPluginsLoaded,
34
+ ensureStrategyPluginsLoaded: () => ensureStrategyPluginsLoaded,
35
+ getAvailableStrategyNames: () => getAvailableStrategyNames,
36
+ getRegisteredManifests: () => getRegisteredManifests,
37
+ getRegisteredStrategies: () => getRegisteredStrategies,
38
+ getStrategyCreator: () => getStrategyCreator,
39
+ getStrategyManifest: () => getStrategyManifest,
40
+ isKnownStrategy: () => isKnownStrategy,
41
+ registerStrategyEntries: () => registerStrategyEntries,
42
+ resetStrategyRegistryCache: () => resetStrategyRegistryCache,
43
+ strategies: () => strategies
44
+ });
45
+ module.exports = __toCommonJS(registry_exports);
46
+
47
+ // src/strategy/manifests.ts
48
+ var import_indicators = require("@tradejs/core/indicators");
49
+ var import_logger2 = require("@tradejs/infra/logger");
50
+
51
+ // src/tradejsConfig.ts
52
+ var import_fs = __toESM(require("fs"));
53
+ var import_path = __toESM(require("path"));
54
+ var import_module = require("module");
55
+ var import_url = require("url");
56
+ var import_logger = require("@tradejs/infra/logger");
57
+ var CONFIG_FILE_NAMES = [
58
+ "tradejs.config.ts",
59
+ "tradejs.config.mts",
60
+ "tradejs.config.js",
61
+ "tradejs.config.mjs",
62
+ "tradejs.config.cjs"
63
+ ];
64
+ var TS_MODULE_RE = /\.(cts|mts|ts)$/i;
65
+ var cachedByCwd = /* @__PURE__ */ new Map();
66
+ var announcedConfigFile = /* @__PURE__ */ new Set();
67
+ var tsNodeRegistered = false;
68
+ var getTradejsProjectCwd = (cwd) => {
69
+ const explicit = String(cwd ?? "").trim();
70
+ if (explicit) {
71
+ return import_path.default.resolve(explicit);
72
+ }
73
+ const fromEnv = String(process.env.PROJECT_CWD || "").trim();
74
+ if (fromEnv) {
75
+ return import_path.default.resolve(fromEnv);
76
+ }
77
+ return process.cwd();
78
+ };
79
+ var normalizeConfig = (rawConfig) => {
80
+ if (!rawConfig || typeof rawConfig !== "object") {
81
+ return {};
82
+ }
83
+ const config = rawConfig;
84
+ const strategies2 = Array.isArray(config.strategies) ? config.strategies.map((value) => String(value || "").trim()).filter(Boolean) : [];
85
+ const indicators = Array.isArray(config.indicators) ? config.indicators.map((value) => String(value || "").trim()).filter(Boolean) : [];
86
+ const connectors = Array.isArray(config.connectors) ? config.connectors.map((value) => String(value || "").trim()).filter(Boolean) : [];
87
+ return {
88
+ strategies: strategies2,
89
+ indicators,
90
+ connectors
91
+ };
92
+ };
93
+ var getRequireFn = (cwd = getTradejsProjectCwd()) => (0, import_module.createRequire)(import_path.default.join(import_path.default.resolve(cwd), "__tradejs_loader__.js"));
94
+ var ensureTsNodeRegistered = async () => {
95
+ if (tsNodeRegistered) {
96
+ return;
97
+ }
98
+ const tsNodeModule = await import("ts-node");
99
+ const tsNode = tsNodeModule.default ?? tsNodeModule;
100
+ tsNode.register?.({
101
+ transpileOnly: true,
102
+ compilerOptions: {
103
+ module: "commonjs",
104
+ moduleResolution: "node"
105
+ }
106
+ });
107
+ tsNodeRegistered = true;
108
+ };
109
+ var toImportSpecifier = (moduleName) => {
110
+ if (moduleName.startsWith("file://")) {
111
+ return moduleName;
112
+ }
113
+ if (import_path.default.isAbsolute(moduleName)) {
114
+ return (0, import_url.pathToFileURL)(moduleName).href;
115
+ }
116
+ return moduleName;
117
+ };
118
+ var isTsModulePath = (moduleName) => TS_MODULE_RE.test(moduleName.split("?")[0]);
119
+ var isRelativeModulePath = (moduleName) => moduleName.startsWith("./") || moduleName.startsWith("../");
120
+ var isBareModuleSpecifier = (moduleName) => {
121
+ const normalized = String(moduleName ?? "").trim();
122
+ if (!normalized) {
123
+ return false;
124
+ }
125
+ if (normalized.startsWith("file://") || import_path.default.isAbsolute(normalized) || isRelativeModulePath(normalized)) {
126
+ return false;
127
+ }
128
+ return true;
129
+ };
130
+ var importConfigFile = async (configFilePath) => {
131
+ const ext = import_path.default.extname(configFilePath).toLowerCase();
132
+ const configFileUrl = `${toImportSpecifier(configFilePath)}?t=${Date.now()}`;
133
+ if (ext === ".ts" || ext === ".mts") {
134
+ const requireFn = getRequireFn(import_path.default.dirname(configFilePath));
135
+ await ensureTsNodeRegistered();
136
+ return requireFn(configFilePath);
137
+ }
138
+ return import(
139
+ /* webpackIgnore: true */
140
+ configFileUrl
141
+ );
142
+ };
143
+ var importTradejsModule = async (moduleName) => {
144
+ const normalized = String(moduleName ?? "").trim();
145
+ if (!normalized) {
146
+ return {};
147
+ }
148
+ let modulePath = normalized;
149
+ if (normalized.startsWith("file://")) {
150
+ try {
151
+ modulePath = (0, import_url.fileURLToPath)(normalized);
152
+ } catch {
153
+ modulePath = normalized;
154
+ }
155
+ }
156
+ const requireFn = getRequireFn(
157
+ import_path.default.isAbsolute(modulePath) ? import_path.default.dirname(modulePath) : getTradejsProjectCwd()
158
+ );
159
+ if (isTsModulePath(modulePath)) {
160
+ await ensureTsNodeRegistered();
161
+ return requireFn(modulePath);
162
+ }
163
+ if (isBareModuleSpecifier(normalized)) {
164
+ return requireFn(normalized);
165
+ }
166
+ try {
167
+ return await import(
168
+ /* webpackIgnore: true */
169
+ toImportSpecifier(normalized)
170
+ );
171
+ } catch (error) {
172
+ if (isTsModulePath(modulePath)) {
173
+ await ensureTsNodeRegistered();
174
+ return requireFn(modulePath);
175
+ }
176
+ throw error;
177
+ }
178
+ };
179
+ var resolveExportedConfig = (moduleExports) => {
180
+ const candidate = moduleExports && typeof moduleExports === "object" && "default" in moduleExports ? moduleExports.default : moduleExports;
181
+ return normalizeConfig(candidate);
182
+ };
183
+ var findConfigFilePath = (cwd) => {
184
+ let currentDir = import_path.default.resolve(cwd);
185
+ while (true) {
186
+ for (const fileName of CONFIG_FILE_NAMES) {
187
+ const fullPath = import_path.default.join(currentDir, fileName);
188
+ if (import_fs.default.existsSync(fullPath) && import_fs.default.statSync(fullPath).isFile()) {
189
+ return fullPath;
190
+ }
191
+ }
192
+ const parentDir = import_path.default.dirname(currentDir);
193
+ if (parentDir === currentDir) {
194
+ return null;
195
+ }
196
+ currentDir = parentDir;
197
+ }
198
+ };
199
+ var resolvePluginModuleSpecifier = (moduleName, cwd = getTradejsProjectCwd()) => {
200
+ const normalized = String(moduleName ?? "").trim();
201
+ if (!normalized) {
202
+ return "";
203
+ }
204
+ if (normalized.startsWith("file://")) {
205
+ try {
206
+ return (0, import_url.fileURLToPath)(normalized);
207
+ } catch {
208
+ return normalized;
209
+ }
210
+ }
211
+ if (import_path.default.isAbsolute(normalized)) {
212
+ return normalized;
213
+ }
214
+ if (isRelativeModulePath(normalized)) {
215
+ return import_path.default.resolve(cwd, normalized);
216
+ }
217
+ return normalized;
218
+ };
219
+ var loadTradejsConfig = async (cwd = getTradejsProjectCwd()) => {
220
+ const cached = cachedByCwd.get(cwd);
221
+ if (cached) {
222
+ return cached;
223
+ }
224
+ const configFilePath = findConfigFilePath(cwd);
225
+ if (!configFilePath) {
226
+ cachedByCwd.set(cwd, {});
227
+ return {};
228
+ }
229
+ try {
230
+ const moduleExports = await importConfigFile(configFilePath);
231
+ const config = resolveExportedConfig(moduleExports);
232
+ cachedByCwd.set(cwd, config);
233
+ if (!announcedConfigFile.has(configFilePath)) {
234
+ announcedConfigFile.add(configFilePath);
235
+ import_logger.logger.log("info", "Loaded TradeJS config: %s", configFilePath);
236
+ }
237
+ return config;
238
+ } catch (error) {
239
+ import_logger.logger.log(
240
+ "warn",
241
+ "Failed to load TradeJS config from %s: %s",
242
+ configFilePath,
243
+ String(error)
244
+ );
245
+ cachedByCwd.set(cwd, {});
246
+ return {};
247
+ }
248
+ };
249
+
250
+ // src/strategy/manifests.ts
251
+ var strategyCreators = /* @__PURE__ */ new Map();
252
+ var strategyManifestsMap = /* @__PURE__ */ new Map();
253
+ var pluginsLoadPromise = null;
254
+ var toUniqueModules = (modules = []) => [
255
+ ...new Set(modules.map((moduleName) => moduleName.trim()).filter(Boolean))
256
+ ];
257
+ var getConfiguredPluginModuleNames = async () => {
258
+ const config = await loadTradejsConfig();
259
+ return {
260
+ strategyModules: toUniqueModules(config.strategies),
261
+ indicatorModules: toUniqueModules(config.indicators)
262
+ };
263
+ };
264
+ var extractModuleEntries = (moduleExport, key) => {
265
+ if (!moduleExport || typeof moduleExport !== "object") {
266
+ return null;
267
+ }
268
+ const candidate = moduleExport;
269
+ if (Array.isArray(candidate[key])) {
270
+ return candidate[key];
271
+ }
272
+ const defaultExport = candidate.default;
273
+ if (defaultExport && Array.isArray(defaultExport[key])) {
274
+ return defaultExport[key];
275
+ }
276
+ return null;
277
+ };
278
+ var extractStrategyPluginDefinition = (moduleExport) => {
279
+ const strategyEntries = extractModuleEntries(
280
+ moduleExport,
281
+ "strategyEntries"
282
+ );
283
+ return strategyEntries ? { strategyEntries } : null;
284
+ };
285
+ var extractIndicatorPluginDefinition = (moduleExport) => {
286
+ const indicatorEntries = extractModuleEntries(
287
+ moduleExport,
288
+ "indicatorEntries"
289
+ );
290
+ return indicatorEntries ? { indicatorEntries } : null;
291
+ };
292
+ var registerEntries = (entries, source) => {
293
+ for (const entry of entries) {
294
+ const strategyName = entry.manifest?.name;
295
+ if (!strategyName) {
296
+ import_logger2.logger.warn("Skip strategy entry without name from %s", source);
297
+ continue;
298
+ }
299
+ if (strategyCreators.has(strategyName)) {
300
+ import_logger2.logger.warn(
301
+ 'Skip duplicate strategy "%s" from %s: already registered',
302
+ strategyName,
303
+ source
304
+ );
305
+ continue;
306
+ }
307
+ strategyCreators.set(strategyName, entry.creator);
308
+ strategyManifestsMap.set(strategyName, entry.manifest);
309
+ }
310
+ };
311
+ var importStrategyPluginModule = async (moduleName) => {
312
+ if (typeof importTradejsModule === "function") {
313
+ return importTradejsModule(moduleName);
314
+ }
315
+ return import(
316
+ /* webpackIgnore: true */
317
+ moduleName
318
+ );
319
+ };
320
+ var ensureStrategyPluginsLoaded = async () => {
321
+ if (pluginsLoadPromise) {
322
+ return pluginsLoadPromise;
323
+ }
324
+ pluginsLoadPromise = (async () => {
325
+ const { strategyModules, indicatorModules } = await getConfiguredPluginModuleNames();
326
+ const strategySet = new Set(strategyModules);
327
+ const indicatorSet = new Set(indicatorModules);
328
+ const pluginModuleNames = [
329
+ .../* @__PURE__ */ new Set([...strategyModules, ...indicatorModules])
330
+ ];
331
+ if (!pluginModuleNames.length) return;
332
+ for (const moduleName of pluginModuleNames) {
333
+ try {
334
+ const resolvedModuleName = resolvePluginModuleSpecifier(moduleName);
335
+ const moduleExport = await importStrategyPluginModule(resolvedModuleName);
336
+ if (strategySet.has(moduleName)) {
337
+ const pluginDefinition = extractStrategyPluginDefinition(moduleExport);
338
+ if (!pluginDefinition) {
339
+ import_logger2.logger.warn(
340
+ 'Skip strategy plugin "%s": export { strategyEntries } is missing',
341
+ moduleName
342
+ );
343
+ } else {
344
+ registerEntries(pluginDefinition.strategyEntries, moduleName);
345
+ }
346
+ }
347
+ if (indicatorSet.has(moduleName)) {
348
+ const indicatorPluginDefinition = extractIndicatorPluginDefinition(moduleExport);
349
+ if (!indicatorPluginDefinition) {
350
+ import_logger2.logger.warn(
351
+ 'Skip indicator plugin "%s": export { indicatorEntries } is missing',
352
+ moduleName
353
+ );
354
+ } else {
355
+ (0, import_indicators.registerIndicatorEntries)(
356
+ indicatorPluginDefinition.indicatorEntries,
357
+ moduleName
358
+ );
359
+ }
360
+ }
361
+ if (!strategySet.has(moduleName) && !indicatorSet.has(moduleName)) {
362
+ import_logger2.logger.warn(
363
+ 'Skip plugin "%s": no strategy/indicator sections requested in config',
364
+ moduleName
365
+ );
366
+ }
367
+ } catch (error) {
368
+ import_logger2.logger.warn(
369
+ 'Failed to load plugin "%s": %s',
370
+ moduleName,
371
+ String(error)
372
+ );
373
+ }
374
+ }
375
+ })();
376
+ return pluginsLoadPromise;
377
+ };
378
+ var ensureIndicatorPluginsLoaded = ensureStrategyPluginsLoaded;
379
+ var getStrategyCreator = async (name) => {
380
+ await ensureStrategyPluginsLoaded();
381
+ return strategyCreators.get(name);
382
+ };
383
+ var getAvailableStrategyNames = async () => {
384
+ await ensureStrategyPluginsLoaded();
385
+ return [...strategyCreators.keys()].sort((a, b) => a.localeCompare(b));
386
+ };
387
+ var getRegisteredStrategies = () => {
388
+ return Object.fromEntries(strategyCreators.entries());
389
+ };
390
+ var getRegisteredManifests = () => {
391
+ return [...strategyManifestsMap.values()];
392
+ };
393
+ var getStrategyManifest = (name) => {
394
+ return name ? strategyManifestsMap.get(name) : void 0;
395
+ };
396
+ var isKnownStrategy = (name) => {
397
+ return strategyCreators.has(name);
398
+ };
399
+ var registerStrategyEntries = (entries) => {
400
+ registerEntries(entries, "runtime");
401
+ };
402
+ var resetStrategyRegistryCache = () => {
403
+ strategyCreators.clear();
404
+ strategyManifestsMap.clear();
405
+ (0, import_indicators.resetIndicatorRegistryCache)();
406
+ pluginsLoadPromise = null;
407
+ };
408
+ var strategies = new Proxy(
409
+ {},
410
+ {
411
+ get: (_target, property) => {
412
+ if (typeof property !== "string") {
413
+ return void 0;
414
+ }
415
+ return strategyCreators.get(property);
416
+ },
417
+ ownKeys: () => {
418
+ return [...strategyCreators.keys()];
419
+ },
420
+ getOwnPropertyDescriptor: () => ({
421
+ enumerable: true,
422
+ configurable: true
423
+ })
424
+ }
425
+ );
426
+ // Annotate the CommonJS export names for ESM import in node:
427
+ 0 && (module.exports = {
428
+ ensureIndicatorPluginsLoaded,
429
+ ensureStrategyPluginsLoaded,
430
+ getAvailableStrategyNames,
431
+ getRegisteredManifests,
432
+ getRegisteredStrategies,
433
+ getStrategyCreator,
434
+ getStrategyManifest,
435
+ isKnownStrategy,
436
+ registerStrategyEntries,
437
+ resetStrategyRegistryCache,
438
+ strategies
439
+ });
@@ -0,0 +1,29 @@
1
+ import "./chunk-5YNMSWL3.mjs";
2
+ import {
3
+ ensureIndicatorPluginsLoaded,
4
+ ensureStrategyPluginsLoaded,
5
+ getAvailableStrategyNames,
6
+ getRegisteredManifests,
7
+ getRegisteredStrategies,
8
+ getStrategyCreator,
9
+ getStrategyManifest,
10
+ isKnownStrategy,
11
+ registerStrategyEntries,
12
+ resetStrategyRegistryCache,
13
+ strategies
14
+ } from "./chunk-MHCXPD2B.mjs";
15
+ import "./chunk-DE7ADBIR.mjs";
16
+ import "./chunk-6DZX6EAA.mjs";
17
+ export {
18
+ ensureIndicatorPluginsLoaded,
19
+ ensureStrategyPluginsLoaded,
20
+ getAvailableStrategyNames,
21
+ getRegisteredManifests,
22
+ getRegisteredStrategies,
23
+ getStrategyCreator,
24
+ getStrategyManifest,
25
+ isKnownStrategy,
26
+ registerStrategyEntries,
27
+ resetStrategyRegistryCache,
28
+ strategies
29
+ };