@bluelibs/runner 4.6.0-alpha.1 → 4.6.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/README.md CHANGED
@@ -9,20 +9,21 @@ _Or: How I Learned to Stop Worrying and Love Dependency Injection_
9
9
  <a href="https://github.com/bluelibs/runner" target="_blank"><img src="https://img.shields.io/badge/github-blue" alt="GitHub" /></a>
10
10
  </p>
11
11
 
12
- | Resource | Type | Notes |
13
- | ------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------- |
14
- | [Presentation Website](https://runner.bluelibs.com/) | Website | Overview, features, and highlights |
15
- | [BlueLibs Runner GitHub](https://github.com/bluelibs/runner) | GitHub | Source code, issues, and releases |
16
- | [BlueLibs Runner Dev](https://github.com/bluelibs/runner-dev) | GitHub | Development tools and CLI for BlueLibs Runner |
17
- | [UX Friendly Docs](https://bluelibs.github.io/runner/) | Docs | Clean, navigable documentation |
18
- | [AI Friendly Docs (<5000 tokens)](https://github.com/bluelibs/runner/blob/main/AI.md) | Docs | Short, token-friendly summary (<5000 tokens) |
19
- | [Migrate from 3.x.x to 4.x.x](https://github.com/bluelibs/runner/blob/main/readmes/MIGRATION.md) | Guide | Step-by-step upgrade from v3 to v4 |
20
- | [Runner Lore](https://github.com/bluelibs/runner/blob/main/readmes) | Docs | Design notes, deep dives, and context |
21
- | [Example: Express + OpenAPI + SQLite](https://github.com/bluelibs/runner/tree/main/examples/express-openapi-sqlite) | Example | Full Express + OpenAPI + SQLite demo |
22
- || [Example: Fastify + MikroORM + PostgreSQL](https://github.com/bluelibs/runner/tree/main/examples/fastify-mikroorm) | Example | Full Fastify + MikroORM + PostgreSQL demo |
23
- || [OpenAI Runner Chatbot](https://chatgpt.com/g/g-68b756abec648191aa43eaa1ea7a7945-runner?model=gpt-5-thinking) | Chatbot | Ask questions interactively, or feed README.md to your own AI |
12
+ | Resource | Type | Notes |
13
+ | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------- |
14
+ | [Presentation Website](https://runner.bluelibs.com/) | Website | Overview, features, and highlights |
15
+ | [BlueLibs Runner GitHub](https://github.com/bluelibs/runner) | GitHub | Source code, issues, and releases |
16
+ | [BlueLibs Runner Dev](https://github.com/bluelibs/runner-dev) | GitHub | Development tools and CLI for BlueLibs Runner |
17
+ | [UX Friendly Docs](https://bluelibs.github.io/runner/) | Docs | Clean, navigable documentation |
18
+ | [AI Friendly Docs (<5000 tokens)](https://github.com/bluelibs/runner/blob/main/AI.md) | Docs | Short, token-friendly summary (<5000 tokens) |
19
+ | [Migrate from 3.x.x to 4.x.x](https://github.com/bluelibs/runner/blob/main/readmes/MIGRATION.md) | Guide | Step-by-step upgrade from v3 to v4 |
20
+ | [Runner Lore](https://github.com/bluelibs/runner/blob/main/readmes) | Docs | Design notes, deep dives, and context |
21
+ | [Example: Express + OpenAPI + SQLite](https://github.com/bluelibs/runner/tree/main/examples/express-openapi-sqlite) | Example | Full Express + OpenAPI + SQLite demo |
22
+ | [Example: Fastify + MikroORM + PostgreSQL](https://github.com/bluelibs/runner/tree/main/examples/fastify-mikroorm) | Example | Full Fastify + MikroORM + PostgreSQL demo |
23
+ | [OpenAI Runner Chatbot](https://chatgpt.com/g/g-68b756abec648191aa43eaa1ea7a7945-runner?model=gpt-5-thinking) | Chatbot | Ask questions interactively, or feed README.md to your own AI |
24
24
 
25
25
  ### Community & Policies
26
+
26
27
  - Code of Conduct: see [CODE_OF_CONDUCT](./CODE_OF_CONDUCT.md)
27
28
  - Contributing: see [CONTRIBUTING](./CONTRIBUTING.md)
28
29
  - Security: see [SECURITY](./SECURITY.md)
@@ -996,7 +997,9 @@ type ConfigInput = ExtractResourceConfig<typeof config>; // { baseUrl: string }
996
997
  type ConfigValue = ExtractResourceValue<typeof config>; // { baseUrl: string }
997
998
 
998
999
  // Event example
999
- const userRegistered = event<{ userId: string; email: string }>({ id: "app.events.userRegistered" });
1000
+ const userRegistered = event<{ userId: string; email: string }>({
1001
+ id: "app.events.userRegistered",
1002
+ });
1000
1003
  type UserRegisteredPayload = ExtractEventPayload<typeof userRegistered>; // { userId: string; email: string }
1001
1004
  ```
1002
1005
 
@@ -227,6 +227,7 @@ __name(loadAsyncLocalStorageClass, "loadAsyncLocalStorageClass");
227
227
  // src/platform/adapters/node.ts
228
228
  var NodePlatformAdapter = class {
229
229
  constructor() {
230
+ this.id = "node";
230
231
  this.setTimeout = globalThis.setTimeout;
231
232
  this.clearTimeout = globalThis.clearTimeout;
232
233
  }
@@ -282,6 +283,7 @@ var NodePlatformAdapter = class {
282
283
  // src/platform/adapters/browser.ts
283
284
  var BrowserPlatformAdapter = class {
284
285
  constructor() {
286
+ this.id = "browser";
285
287
  this.setTimeout = globalThis.setTimeout;
286
288
  this.clearTimeout = globalThis.clearTimeout;
287
289
  }
@@ -347,6 +349,10 @@ var BrowserPlatformAdapter = class {
347
349
 
348
350
  // src/platform/adapters/edge.ts
349
351
  var EdgePlatformAdapter = class extends BrowserPlatformAdapter {
352
+ constructor() {
353
+ super(...arguments);
354
+ this.id = "edge";
355
+ }
350
356
  static {
351
357
  __name(this, "EdgePlatformAdapter");
352
358
  }
@@ -359,6 +365,7 @@ var EdgePlatformAdapter = class extends BrowserPlatformAdapter {
359
365
  // src/platform/adapters/universal-generic.ts
360
366
  var GenericUniversalPlatformAdapter = class {
361
367
  constructor() {
368
+ this.id = "universal";
362
369
  this.setTimeout = globalThis.setTimeout;
363
370
  this.clearTimeout = globalThis.clearTimeout;
364
371
  }
@@ -402,7 +409,8 @@ var GenericUniversalPlatformAdapter = class {
402
409
  }
403
410
  return () => {
404
411
  tgt.removeEventListener?.("beforeunload", handlers.before);
405
- if (handlers.visibility) tgt.removeEventListener?.("visibilitychange", handlers.visibility);
412
+ if (handlers.visibility)
413
+ tgt.removeEventListener?.("visibilitychange", handlers.visibility);
406
414
  };
407
415
  }
408
416
  return () => {
@@ -456,6 +464,7 @@ function detectEnvironment() {
456
464
  __name(detectEnvironment, "detectEnvironment");
457
465
  var UniversalPlatformAdapter = class {
458
466
  constructor() {
467
+ this.id = "universal";
459
468
  this.inner = null;
460
469
  this.setTimeout = globalThis.setTimeout;
461
470
  this.clearTimeout = globalThis.clearTimeout;
@@ -557,7 +566,7 @@ var platformInstance = null;
557
566
  function getPlatform() {
558
567
  if (!platformInstance) {
559
568
  platformInstance = createPlatformAdapter();
560
- detectEnvironment();
569
+ platformInstance.id;
561
570
  }
562
571
  return platformInstance;
563
572
  }
@@ -2612,18 +2621,7 @@ var EventManager = class {
2612
2621
  }
2613
2622
  const frame = { id: eventDefinition.id, source };
2614
2623
  const processEmission = /* @__PURE__ */ __name(async () => {
2615
- const pseudoForExclude = {
2616
- id: eventDefinition.id,
2617
- data,
2618
- timestamp: /* @__PURE__ */ new Date(),
2619
- source,
2620
- meta: eventDefinition.meta || {},
2621
- stopPropagation: /* @__PURE__ */ __name(() => {
2622
- }, "stopPropagation"),
2623
- isPropagationStopped: /* @__PURE__ */ __name(() => false, "isPropagationStopped"),
2624
- tags: eventDefinition.tags
2625
- };
2626
- const excludeFromGlobal = this.isExcludedFromGlobal(pseudoForExclude);
2624
+ const excludeFromGlobal = globalTags.excludeFromGlobalHooks.exists(eventDefinition);
2627
2625
  const allListeners = excludeFromGlobal ? this.listeners.get(eventDefinition.id) || [] : this.getCachedMergedListeners(eventDefinition.id);
2628
2626
  let propagationStopped = false;
2629
2627
  const event = {
@@ -2750,21 +2748,8 @@ var EventManager = class {
2750
2748
  if (this.globalListeners.length === 0) {
2751
2749
  return false;
2752
2750
  }
2753
- const pseudoEmission = {
2754
- id: eventDefinition.id,
2755
- data: void 0,
2756
- timestamp: /* @__PURE__ */ new Date(),
2757
- source: "",
2758
- meta: eventDefinition.meta || {},
2759
- stopPropagation: /* @__PURE__ */ __name(() => {
2760
- }, "stopPropagation"),
2761
- isPropagationStopped: /* @__PURE__ */ __name(() => false, "isPropagationStopped"),
2762
- tags: eventDefinition.tags
2763
- };
2764
- if (this.isExcludedFromGlobal(pseudoEmission)) {
2765
- return false;
2766
- }
2767
- return true;
2751
+ const isExcludedFromGlobal = globalTags.excludeFromGlobalHooks.exists(eventDefinition);
2752
+ return !isExcludedFromGlobal;
2768
2753
  }
2769
2754
  /**
2770
2755
  * Adds an interceptor for all event emissions
@@ -4165,9 +4150,8 @@ var RunResult = class {
4165
4150
  };
4166
4151
 
4167
4152
  // src/run.ts
4168
- var platform3 = getPlatform();
4169
4153
  async function run(resourceOrResourceWithConfig, options) {
4170
- await platform3.init();
4154
+ await getPlatform().init();
4171
4155
  const {
4172
4156
  debug = void 0,
4173
4157
  logs = {},
@@ -4178,7 +4162,7 @@ async function run(resourceOrResourceWithConfig, options) {
4178
4162
  runtimeCycleDetection = true
4179
4163
  } = options || {};
4180
4164
  const {
4181
- printThreshold = platform3.getEnv("NODE_ENV") === "test" ? null : "info",
4165
+ printThreshold = getPlatform().getEnv("NODE_ENV") === "test" ? null : "info",
4182
4166
  printStrategy = "pretty",
4183
4167
  bufferLogs = false
4184
4168
  } = logs;