@bitcobblers/wod-wiki-lang 0.1.6 → 0.1.8

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/index.cjs CHANGED
@@ -5620,6 +5620,11 @@ function createBrowserRuntimeNow() {
5620
5620
  nowMs: () => getRuntimeNowMs()
5621
5621
  };
5622
5622
  }
5623
+
5624
+ // src/runtime/contracts/ICastSubscription.ts
5625
+ function isCastSubscription(s) {
5626
+ return "sendAnalyticsSummary" in s && typeof s.sendAnalyticsSummary === "function";
5627
+ }
5623
5628
  var CompletionTimestampBehavior = class {
5624
5629
  completionTime;
5625
5630
  wasComplete = false;
@@ -11942,6 +11947,170 @@ var RuntimeAdapter = class {
11942
11947
  return icons[memoryType];
11943
11948
  }
11944
11949
  };
11950
+
11951
+ // src/runtime/subscriptions/LocalRuntimeSubscription.ts
11952
+ var LocalRuntimeSubscription = class {
11953
+ id;
11954
+ onStackSnapshotCallback;
11955
+ onOutputCallback;
11956
+ constructor(options) {
11957
+ this.id = options?.id ?? "local";
11958
+ this.onStackSnapshotCallback = options?.onStackSnapshot;
11959
+ this.onOutputCallback = options?.onOutput;
11960
+ }
11961
+ onStackSnapshot(snapshot) {
11962
+ this.onStackSnapshotCallback?.(snapshot);
11963
+ }
11964
+ onOutput(output) {
11965
+ this.onOutputCallback?.(output);
11966
+ }
11967
+ dispose() {
11968
+ this.onStackSnapshotCallback = void 0;
11969
+ this.onOutputCallback = void 0;
11970
+ }
11971
+ };
11972
+
11973
+ // src/runtime/subscriptions/LocalEventProvider.ts
11974
+ var LocalEventProvider = class _LocalEventProvider {
11975
+ constructor(runtime) {
11976
+ this.runtime = runtime;
11977
+ }
11978
+ runtime;
11979
+ static subscriptionCounter = 0;
11980
+ unsubscribes = [];
11981
+ disposed = false;
11982
+ dispatch(event) {
11983
+ if (this.disposed) return;
11984
+ this.runtime.handle(event);
11985
+ }
11986
+ onEvent(handler) {
11987
+ if (this.disposed) return () => {
11988
+ };
11989
+ const ownerId = `local-event-provider-${_LocalEventProvider.subscriptionCounter++}`;
11990
+ const unsubscribeFromBus = this.runtime.eventBus.on("*", (event) => {
11991
+ handler(event);
11992
+ }, ownerId);
11993
+ const unsubscribe = () => {
11994
+ unsubscribeFromBus();
11995
+ this.unsubscribes = this.unsubscribes.filter((candidate) => candidate !== unsubscribe);
11996
+ };
11997
+ this.unsubscribes.push(unsubscribe);
11998
+ return unsubscribe;
11999
+ }
12000
+ dispose() {
12001
+ if (this.disposed) return;
12002
+ this.disposed = true;
12003
+ const unsubscribes = [...this.unsubscribes];
12004
+ this.unsubscribes = [];
12005
+ for (const unsubscribe of unsubscribes) {
12006
+ unsubscribe();
12007
+ }
12008
+ }
12009
+ };
12010
+
12011
+ // src/runtime/subscriptions/SubscriptionManager.ts
12012
+ var SubscriptionManager = class {
12013
+ constructor(runtime) {
12014
+ this.runtime = runtime;
12015
+ this.stackUnsub = this.runtime.subscribeToStack((snapshot) => {
12016
+ for (const sub of this.subscriptions.values()) {
12017
+ try {
12018
+ sub.onStackSnapshot(snapshot);
12019
+ } catch (err) {
12020
+ console.error(`[SubscriptionManager] Error in subscription '${sub.id}' onStackSnapshot:`, err);
12021
+ }
12022
+ }
12023
+ });
12024
+ this.outputUnsub = this.runtime.subscribeToOutput((output) => {
12025
+ for (const sub of this.subscriptions.values()) {
12026
+ try {
12027
+ sub.onOutput(output);
12028
+ } catch (err) {
12029
+ console.error(`[SubscriptionManager] Error in subscription '${sub.id}' onOutput:`, err);
12030
+ }
12031
+ }
12032
+ });
12033
+ }
12034
+ runtime;
12035
+ subscriptions = /* @__PURE__ */ new Map();
12036
+ stackUnsub = null;
12037
+ outputUnsub = null;
12038
+ disposed = false;
12039
+ /**
12040
+ * Register a subscription. If a subscription with the same ID already exists,
12041
+ * the old one is disposed and replaced.
12042
+ *
12043
+ * New subscriptions immediately receive the current stack state and any
12044
+ * existing output statements to catch them up.
12045
+ */
12046
+ add(subscription) {
12047
+ if (this.disposed) {
12048
+ console.warn("[SubscriptionManager] Cannot add subscription after dispose");
12049
+ return;
12050
+ }
12051
+ const existing = this.subscriptions.get(subscription.id);
12052
+ if (existing) {
12053
+ existing.dispose();
12054
+ }
12055
+ this.subscriptions.set(subscription.id, subscription);
12056
+ try {
12057
+ subscription.onStackSnapshot({
12058
+ type: "initial",
12059
+ blocks: [...this.runtime.stack.blocks],
12060
+ depth: this.runtime.stack.count,
12061
+ clockTime: this.runtime.clock.currentDate
12062
+ });
12063
+ const currentOutputs = this.runtime.getOutputStatements();
12064
+ for (const output of currentOutputs) {
12065
+ subscription.onOutput(output);
12066
+ }
12067
+ } catch (err) {
12068
+ console.error(`[SubscriptionManager] Error catching up subscription '${subscription.id}':`, err);
12069
+ }
12070
+ }
12071
+ /**
12072
+ * Remove and dispose a subscription by ID.
12073
+ * Returns true if the subscription was found and removed.
12074
+ */
12075
+ remove(id) {
12076
+ const sub = this.subscriptions.get(id);
12077
+ if (!sub) return false;
12078
+ sub.dispose();
12079
+ this.subscriptions.delete(id);
12080
+ return true;
12081
+ }
12082
+ /**
12083
+ * Check if a subscription with the given ID is registered.
12084
+ */
12085
+ has(id) {
12086
+ return this.subscriptions.has(id);
12087
+ }
12088
+ /**
12089
+ * Get the number of active subscriptions.
12090
+ */
12091
+ get count() {
12092
+ return this.subscriptions.size;
12093
+ }
12094
+ /**
12095
+ * Dispose all subscriptions and unsubscribe from the runtime.
12096
+ */
12097
+ dispose() {
12098
+ if (this.disposed) return;
12099
+ this.disposed = true;
12100
+ this.stackUnsub?.();
12101
+ this.stackUnsub = null;
12102
+ this.outputUnsub?.();
12103
+ this.outputUnsub = null;
12104
+ for (const sub of this.subscriptions.values()) {
12105
+ try {
12106
+ sub.dispose();
12107
+ } catch (err) {
12108
+ console.error(`[SubscriptionManager] Error disposing subscription '${sub.id}':`, err);
12109
+ }
12110
+ }
12111
+ this.subscriptions.clear();
12112
+ }
12113
+ };
11945
12114
  function formatMetricLabel(key) {
11946
12115
  return key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, " ");
11947
12116
  }
@@ -13110,13 +13279,13 @@ function toStoredOutputStatement(output) {
13110
13279
  }
13111
13280
 
13112
13281
  // src/version.ts
13113
- var VERSION = "0.1.6";
13114
- var GIT_SHA = "9c5467d";
13115
- var BUILD_TIME = "2026-08-18T18:12:54.408Z";
13282
+ var VERSION = "0.1.8";
13283
+ var GIT_SHA = "52af1e3";
13284
+ var BUILD_TIME = "2026-08-18T18:19:06.086Z";
13116
13285
  var SEMVER = {
13117
- version: "0.1.6",
13118
- gitSha: "9c5467d",
13119
- buildTime: "2026-08-18T18:12:54.408Z"
13286
+ version: "0.1.8",
13287
+ gitSha: "52af1e3",
13288
+ buildTime: "2026-08-18T18:19:06.086Z"
13120
13289
  };
13121
13290
 
13122
13291
  exports.AbortSessionAction = AbortSessionAction;
@@ -13162,6 +13331,8 @@ exports.HabitsDialect = HabitsDialect;
13162
13331
  exports.INTENSITY_TIERS = INTENSITY_TIERS;
13163
13332
  exports.InMemoryEffortRegistry = InMemoryEffortRegistry;
13164
13333
  exports.JitCompiler = JitCompiler;
13334
+ exports.LocalEventProvider = LocalEventProvider;
13335
+ exports.LocalRuntimeSubscription = LocalRuntimeSubscription;
13165
13336
  exports.LookupRegistry = LookupRegistry;
13166
13337
  exports.MdTimerRuntime = MdTimerRuntime;
13167
13338
  exports.MemoryLocation = MemoryLocation;
@@ -13197,6 +13368,7 @@ exports.SnapshotClock = SnapshotClock;
13197
13368
  exports.StandardAnalyticsProfile = StandardAnalyticsProfile;
13198
13369
  exports.StartSessionAction = StartSessionAction;
13199
13370
  exports.StartWorkoutAction = StartWorkoutAction;
13371
+ exports.SubscriptionManager = SubscriptionManager;
13200
13372
  exports.ThrowError = ThrowError;
13201
13373
  exports.ThrowErrorAction = ThrowErrorAction;
13202
13374
  exports.TimeSpan = TimeSpan;
@@ -13268,6 +13440,7 @@ exports.getRuntimeNowMs = getRuntimeNowMs;
13268
13440
  exports.hasHint = hasHint;
13269
13441
  exports.hintMetric = hintMetric;
13270
13442
  exports.hintsToContainer = hintsToContainer;
13443
+ exports.isCastSubscription = isCastSubscription;
13271
13444
  exports.isEffortDiscipline = isEffortDiscipline;
13272
13445
  exports.isFragmentTag = isFragmentTag;
13273
13446
  exports.isTimeLikeMetric = isTimeLikeMetric;