@bitcobblers/wod-wiki-lang 0.46.2168 → 0.47.2170

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.mjs CHANGED
@@ -376,12 +376,20 @@ function tagMarkerSlugs(metrics) {
376
376
  }
377
377
  return slugs;
378
378
  }
379
+ function isEquationMetricValue(value) {
380
+ if (typeof value !== "string") return false;
381
+ const trimmed = value.trim();
382
+ if (!trimmed) return false;
383
+ if (/^[+-]?\d+(?:\.\d+)?(?:\s*[A-Za-z%/][\w%/.-]*)?$/.test(trimmed)) return false;
384
+ if (/^[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*$/.test(trimmed)) return false;
385
+ return /[*/+()]|\s-\s|->|\b(?:convert|sum|avg|min|max|count|last|round|floor|ceil|abs|clamp|lookup|when|and|or)\b/.test(trimmed);
386
+ }
379
387
  function tagContributionMetrics(contributions, origin = "parser") {
380
- return contributions.map((contribution) => ({
388
+ return contributions.filter((c) => !c.type.trim().startsWith("summaries.") && !isEquationMetricValue(c.value)).map((contribution) => ({
381
389
  type: contribution.type,
382
390
  value: contribution.value,
383
391
  origin,
384
- image: String(contribution.value),
392
+ image: contribution.unit ? `${String(contribution.value)} ${contribution.unit}` : String(contribution.value),
385
393
  ...contribution.unit ? { unit: contribution.unit } : {}
386
394
  }));
387
395
  }
@@ -9590,6 +9598,37 @@ function isSupportedMetricValue(val) {
9590
9598
  function isPlainObject(val) {
9591
9599
  return Boolean(val) && typeof val === "object" && !Array.isArray(val);
9592
9600
  }
9601
+ function extractTagPropertyRules(tags2, slugs) {
9602
+ if (!tags2 || slugs.length === 0) return [];
9603
+ const rules = [];
9604
+ for (const slug of slugs) {
9605
+ const resolved = resolveTagContributions(tags2, slug);
9606
+ if (resolved.metrics.length === 0) continue;
9607
+ const metrics = {};
9608
+ const summaries = {};
9609
+ for (const m of resolved.metrics) {
9610
+ const key = m.type.trim();
9611
+ if (!key) continue;
9612
+ if (key.startsWith("summaries.")) {
9613
+ const subKey = key.slice("summaries.".length).trim();
9614
+ if (subKey && !(subKey in summaries)) {
9615
+ summaries[subKey] = String(m.value);
9616
+ }
9617
+ } else if (!(key in metrics)) {
9618
+ metrics[key] = m.unit ? `${String(m.value)} ${m.unit}` : m.value === null || typeof m.value === "boolean" ? String(m.value) : m.value;
9619
+ }
9620
+ }
9621
+ if (Object.keys(metrics).length > 0 || Object.keys(summaries).length > 0) {
9622
+ rules.push({
9623
+ layer: "tag",
9624
+ sourceSlug: slug,
9625
+ metrics,
9626
+ summaries
9627
+ });
9628
+ }
9629
+ }
9630
+ return rules;
9631
+ }
9593
9632
  function compilePropertySummaryCalcs(sources) {
9594
9633
  const ordered = [...sources].sort(
9595
9634
  (a, b) => LAYER_PRECEDENCE[b.layer] - LAYER_PRECEDENCE[a.layer]
@@ -12280,9 +12319,24 @@ var CalcEngine = class {
12280
12319
  const fenced = (d) => !d.fences || d.fences.includes(deps.dialect);
12281
12320
  this.segmentCalcs = registry.byScope("segment").filter(fenced);
12282
12321
  this.workoutCalcs = registry.byScope("workout").filter(fenced);
12322
+ const noteDefinedSummaries = /* @__PURE__ */ new Set();
12323
+ for (const src of deps.propertySources ?? []) {
12324
+ for (const k of Object.keys(src.summaries ?? {})) {
12325
+ noteDefinedSummaries.add(k.trim());
12326
+ }
12327
+ }
12283
12328
  for (const tag of deps.tags?.list() ?? []) {
12284
12329
  const resolved = resolveTagContributions(deps.tags, tag.slug);
12285
- for (const name2 of resolved.functions) {
12330
+ const carriedNames = [...resolved.functions];
12331
+ for (const m of resolved.metrics) {
12332
+ if (m.type.trim().startsWith("summaries.")) {
12333
+ const summaryId = m.type.trim().slice("summaries.".length).trim();
12334
+ if (summaryId && !noteDefinedSummaries.has(summaryId)) {
12335
+ carriedNames.push(summaryId);
12336
+ }
12337
+ }
12338
+ }
12339
+ for (const name2 of carriedNames) {
12286
12340
  const carriers = this.tagCarriedFunctions.get(name2);
12287
12341
  if (carriers) carriers.add(tag.slug);
12288
12342
  else this.tagCarriedFunctions.set(name2, /* @__PURE__ */ new Set([tag.slug]));
@@ -12345,10 +12399,13 @@ var CalcEngine = class {
12345
12399
  if (output.outputType !== "segment" || !output.isLeaf) return output;
12346
12400
  const effortData = extractEffortData(output.metrics.rawMetrics);
12347
12401
  if (effortData) this.lastSegmentEffort = effortData.resolved.slug;
12348
- if (this.deps.propertySources && this.deps.propertySources.length > 0) {
12402
+ const appliedTags = this.appliedTags(output);
12403
+ const tagSources = extractTagPropertyRules(this.deps.tags, appliedTags);
12404
+ const allSources = [...tagSources, ...this.deps.propertySources ?? []];
12405
+ if (allSources.length > 0) {
12349
12406
  runMetricShakeOutQueue(output.metrics, {
12350
12407
  stage: "log",
12351
- sources: this.deps.propertySources,
12408
+ sources: allSources,
12352
12409
  lookups: this.deps.lookups,
12353
12410
  lastEffortSlug: this.lastSegmentEffort
12354
12411
  });
@@ -12367,7 +12424,6 @@ var CalcEngine = class {
12367
12424
  if (climbGrade && typeof climbGrade === "object" && "raw" in climbGrade) {
12368
12425
  effortTags.grade = String(climbGrade.raw);
12369
12426
  }
12370
- const appliedTags = this.appliedTags(output);
12371
12427
  for (const def of this.segmentCalcs) {
12372
12428
  if (!this.isActive(def, appliedTags)) continue;
12373
12429
  const ctx = this.makeContext(atoms);
@@ -13587,8 +13643,11 @@ function createCalcStack(options) {
13587
13643
  const registry = new CalculationRegistry(lookups);
13588
13644
  for (const def of BUILTIN_CALCS) registry.register(def);
13589
13645
  for (const def of options.calcs ?? []) registry.register(def);
13590
- if (options.propertySources && options.propertySources.length > 0) {
13591
- for (const def of compilePropertySummaryCalcs(options.propertySources)) {
13646
+ const allTagSlugs = (options.tags?.list() ?? []).map((t2) => t2.slug);
13647
+ const tagRules = extractTagPropertyRules(options.tags, allTagSlugs);
13648
+ const combinedSources = [...options.propertySources ?? [], ...tagRules];
13649
+ if (combinedSources.length > 0) {
13650
+ for (const def of compilePropertySummaryCalcs(combinedSources)) {
13592
13651
  registry.register(def);
13593
13652
  }
13594
13653
  }
@@ -15700,6 +15759,6 @@ function compareStatement(expectations, actual, mode) {
15700
15759
  return diffs;
15701
15760
  }
15702
15761
 
15703
- export { ABSENT, AGGREGATE_BUILTINS, AUTHORITATIVE_CASTS, AbortSessionAction, AmrapLogicStrategy, AnalyticsEngine, AnalyticsTransformer, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockBuilder, BlockContext, ButtonBehavior, COMPLETION_PROPERTY_KEYS, CONSUMED_HINTS, CONSUMED_HINT_KEYS, CONTEXT_ATOMS, CalcEngine, CalcEvalError, CalcParseError, CalcRegistrationError, CalcUnitError, CalculationRegistry, CardioDialect, ChildSelectionBehavior, ChildrenStrategy, ChoiceGroupMetric, ClearChildrenAction, ClimbDialect, ClimbMetricType, CompileAndPushBlockAction, CompletionTimestampBehavior, CompositeEffortRegistry, CompositeEquipmentRegistry, CompositePropertyRegistry, CountdownTimerBehavior, CountupTimerBehavior, CrossFitDialect, DAY, DEFAULT_RESOLVER_OPTIONS, DEFAULT_RUNTIME_OPTIONS, DEFAULT_SOUND_PROFILE, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_COUNT, DIM_ENERGY, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, DISCIPLINE_FACTORS, DialectStack, EFFORT_DATA_METRIC_TYPE, EFFORT_DISCIPLINES, EFFORT_REGISTRY_ORIGINS, EffortBlock, EffortFallbackStrategy, EffortResolver, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, ExecutionContext, ExitBehavior, FixtureSyntaxError, GenericGroupStrategy, GenericLoopStrategy, GenericTimerStrategy, HabitsDialect, INTENSITY_TIERS, InMemoryEffortRegistry, IntervalLogicStrategy, JitCompiler, LabelingBehavior, LocalEventProvider, LocalRuntimeSubscription, LookupRegistry, MAX_TAG_CONTRIBUTION_DEPTH, MdTimerRuntime, MemoryLocation, MemoryTypeEnum, MetricPromotionBehavior, NAMED_COMPOUNDS, NextAction, NextEvent, NextEventHandler, OutputEmitter, PRODUCTION_STRATEGIES, PROPERTY_KEY_TO_METRIC_TYPE, PopBlockAction, PushBlockAction, PushRestBlockAction, REFERENCE_PAIR_KEYS, REST_EXCLUSION, RPE_LABELS, RUNTIME_LOG_SUBJECT_WIDTH, RegisterEventHandlerAction, Registry, ReportOutputBehavior, ReportOutputStrategy, RestBlock, RoundsMetric, RuntimeAdapter, RuntimeBlock, RuntimeBuilder, RuntimeClock, RuntimeFactory, RuntimeLogger, RuntimeMemory, RuntimeObservers, RuntimeStack, SEED_PRECEDENCE_RANK, SOUND_PLAY_EVENT, SOUND_PROFILE_METRIC, STANDARD_UNITS, STORE_CALCS, STREAM_ATOMS, STRUCTURAL_EFFORT_WORDS, ScriptRuntime, SessionRootBlock, SessionRootStrategy, SnapshotClock, SoundProfileBehavior, SoundStrategy, SpanTrackingBehavior, StandardAnalyticsProfile, StartSessionAction, StartWorkoutAction, SubscriptionManager, TAG_MARKER_PREFIX, ThrowError, ThrowErrorAction, TimeSpan, TwoPassEffortResolutionProcess, TypedMemoryReference, UNITS, UnitRegistry, UnitSet, UnitsDialect, UnregisterEventHandlerAction, UpdateNextPreviewAction, VISIBILITY_ICONS, VISIBILITY_LABELS, WaitingToStartBlock, WaitingToStartInjectorBehavior, WhiteboardScript, WodDialect, YogaDialect, addAliasToEffort, addDim, applyTemplateDefaults, buildStaticLookups, buildTooltip, bundledEfforts, calculateElapsed, canonicalizeType, checkCalcLine, classifyStatements, closeCurrentSpan, collapseUnresolvedChoices, commonFixtureSet, compareStatement, compileLineForm, compilePropertySummaryCalcs, composeDivUnit, composeMulUnit, compoundName, computeColumnLabel, computeLabel, computeWorkloadRollups, convertScalar, createAnalyticsEngineForBlock, createCalcEngine, createCalcStack, createCompiler, createDialectStack, createDisciplinesTable, createEffortTable, createLineLocator, createPolicy as createMetricPresentationPolicy, createMockClock, createParser, createProfileTable, createReferenceIndex, createRpeLabelsTable, dailySessionLoads, dayBucket, dedupeEntitiesByPrecedence, dialectRegistry, dialectStack, diffStatement, dimEquals, disciplineFactorFor, documentToEffort, documentToEquipment, documentToTag, effortToDocument, equipmentToDocument, evaluate, extractEffortData, extractMetrics, extractPropertyRulesFromMeta, extractStatementRefs, extractStatements, extractStatementsRaw, extractSyntaxFacts, filterTagsByVisibility, findBestFuzzyMatch, findTagContributionCycles, findUnresolvedChoices, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDim, formatDuration, formatRuntimeLogLine, formatRuntimeLogRule, formatRuntimeTimestamp, formatSoundTrigger, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getHints, getMetricVisibility, getUnit, hasHint, hintMetric, hintsToContainer, inferDim, isCastSubscription, isChoiceResolved, isDimensionless, isEffortDiscipline, isFragmentTag, isTimeLikeMetric, isWithinThreshold, levenshteinDistance, metricPresentation, mutateTimerSpans, normalizeForFuzzy, num, openSpan, outputNodeId, outputNodeIds, padRuntimeLogEvent, padRuntimeLogSubject, parseCalcLine, parseEffortFile, parseEquipmentFile, parseExpression, parseMetricLine, parseScript, parseSoundTrigger, printCalculation, readNestedSection, readTimer, realtimeProcessorRegistry, renderMetric, resolveDominantOrigin, resolveEntityRank, resolveEntityTier, resolveProfileRules, resolveSoundProfile, resolveSourceRank, resolveSourceTier, resolveTagContributions, runMetricShakeOutQueue, slugifyRefLabel, snippetCompletions, startSpan, str, strategyRegistry, subDim, summaryProcessorRegistry, tagCategoryToDocument, tagContributionMetrics, tagMarkerSlug, tagMarkerSlugs, tagMarkerType, tagToDocument, toStoredOutputStatement, truthy, validateOutputUnit, parser as whiteboardParser, whiteboardScript, whiteboardScriptCompletion, whiteboardScriptCompletionSource, whiteboardScriptLanguage, whiteboardScriptSnippets, writeChoiceSelection };
15762
+ export { ABSENT, AGGREGATE_BUILTINS, AUTHORITATIVE_CASTS, AbortSessionAction, AmrapLogicStrategy, AnalyticsEngine, AnalyticsTransformer, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockBuilder, BlockContext, ButtonBehavior, COMPLETION_PROPERTY_KEYS, CONSUMED_HINTS, CONSUMED_HINT_KEYS, CONTEXT_ATOMS, CalcEngine, CalcEvalError, CalcParseError, CalcRegistrationError, CalcUnitError, CalculationRegistry, CardioDialect, ChildSelectionBehavior, ChildrenStrategy, ChoiceGroupMetric, ClearChildrenAction, ClimbDialect, ClimbMetricType, CompileAndPushBlockAction, CompletionTimestampBehavior, CompositeEffortRegistry, CompositeEquipmentRegistry, CompositePropertyRegistry, CountdownTimerBehavior, CountupTimerBehavior, CrossFitDialect, DAY, DEFAULT_RESOLVER_OPTIONS, DEFAULT_RUNTIME_OPTIONS, DEFAULT_SOUND_PROFILE, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_COUNT, DIM_ENERGY, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, DISCIPLINE_FACTORS, DialectStack, EFFORT_DATA_METRIC_TYPE, EFFORT_DISCIPLINES, EFFORT_REGISTRY_ORIGINS, EffortBlock, EffortFallbackStrategy, EffortResolver, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, ExecutionContext, ExitBehavior, FixtureSyntaxError, GenericGroupStrategy, GenericLoopStrategy, GenericTimerStrategy, HabitsDialect, INTENSITY_TIERS, InMemoryEffortRegistry, IntervalLogicStrategy, JitCompiler, LabelingBehavior, LocalEventProvider, LocalRuntimeSubscription, LookupRegistry, MAX_TAG_CONTRIBUTION_DEPTH, MdTimerRuntime, MemoryLocation, MemoryTypeEnum, MetricPromotionBehavior, NAMED_COMPOUNDS, NextAction, NextEvent, NextEventHandler, OutputEmitter, PRODUCTION_STRATEGIES, PROPERTY_KEY_TO_METRIC_TYPE, PopBlockAction, PushBlockAction, PushRestBlockAction, REFERENCE_PAIR_KEYS, REST_EXCLUSION, RPE_LABELS, RUNTIME_LOG_SUBJECT_WIDTH, RegisterEventHandlerAction, Registry, ReportOutputBehavior, ReportOutputStrategy, RestBlock, RoundsMetric, RuntimeAdapter, RuntimeBlock, RuntimeBuilder, RuntimeClock, RuntimeFactory, RuntimeLogger, RuntimeMemory, RuntimeObservers, RuntimeStack, SEED_PRECEDENCE_RANK, SOUND_PLAY_EVENT, SOUND_PROFILE_METRIC, STANDARD_UNITS, STORE_CALCS, STREAM_ATOMS, STRUCTURAL_EFFORT_WORDS, ScriptRuntime, SessionRootBlock, SessionRootStrategy, SnapshotClock, SoundProfileBehavior, SoundStrategy, SpanTrackingBehavior, StandardAnalyticsProfile, StartSessionAction, StartWorkoutAction, SubscriptionManager, TAG_MARKER_PREFIX, ThrowError, ThrowErrorAction, TimeSpan, TwoPassEffortResolutionProcess, TypedMemoryReference, UNITS, UnitRegistry, UnitSet, UnitsDialect, UnregisterEventHandlerAction, UpdateNextPreviewAction, VISIBILITY_ICONS, VISIBILITY_LABELS, WaitingToStartBlock, WaitingToStartInjectorBehavior, WhiteboardScript, WodDialect, YogaDialect, addAliasToEffort, addDim, applyTemplateDefaults, buildStaticLookups, buildTooltip, bundledEfforts, calculateElapsed, canonicalizeType, checkCalcLine, classifyStatements, closeCurrentSpan, collapseUnresolvedChoices, commonFixtureSet, compareStatement, compileLineForm, compilePropertySummaryCalcs, composeDivUnit, composeMulUnit, compoundName, computeColumnLabel, computeLabel, computeWorkloadRollups, convertScalar, createAnalyticsEngineForBlock, createCalcEngine, createCalcStack, createCompiler, createDialectStack, createDisciplinesTable, createEffortTable, createLineLocator, createPolicy as createMetricPresentationPolicy, createMockClock, createParser, createProfileTable, createReferenceIndex, createRpeLabelsTable, dailySessionLoads, dayBucket, dedupeEntitiesByPrecedence, dialectRegistry, dialectStack, diffStatement, dimEquals, disciplineFactorFor, documentToEffort, documentToEquipment, documentToTag, effortToDocument, equipmentToDocument, evaluate, extractEffortData, extractMetrics, extractPropertyRulesFromMeta, extractStatementRefs, extractStatements, extractStatementsRaw, extractSyntaxFacts, extractTagPropertyRules, filterTagsByVisibility, findBestFuzzyMatch, findTagContributionCycles, findUnresolvedChoices, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDim, formatDuration, formatRuntimeLogLine, formatRuntimeLogRule, formatRuntimeTimestamp, formatSoundTrigger, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getHints, getMetricVisibility, getUnit, hasHint, hintMetric, hintsToContainer, inferDim, isCastSubscription, isChoiceResolved, isDimensionless, isEffortDiscipline, isFragmentTag, isTimeLikeMetric, isWithinThreshold, levenshteinDistance, metricPresentation, mutateTimerSpans, normalizeForFuzzy, num, openSpan, outputNodeId, outputNodeIds, padRuntimeLogEvent, padRuntimeLogSubject, parseCalcLine, parseEffortFile, parseEquipmentFile, parseExpression, parseMetricLine, parseScript, parseSoundTrigger, printCalculation, readNestedSection, readTimer, realtimeProcessorRegistry, renderMetric, resolveDominantOrigin, resolveEntityRank, resolveEntityTier, resolveProfileRules, resolveSoundProfile, resolveSourceRank, resolveSourceTier, resolveTagContributions, runMetricShakeOutQueue, slugifyRefLabel, snippetCompletions, startSpan, str, strategyRegistry, subDim, summaryProcessorRegistry, tagCategoryToDocument, tagContributionMetrics, tagMarkerSlug, tagMarkerSlugs, tagMarkerType, tagToDocument, toStoredOutputStatement, truthy, validateOutputUnit, parser as whiteboardParser, whiteboardScript, whiteboardScriptCompletion, whiteboardScriptCompletionSource, whiteboardScriptLanguage, whiteboardScriptSnippets, writeChoiceSelection };
15704
15763
  //# sourceMappingURL=index.mjs.map
15705
15764
  //# sourceMappingURL=index.mjs.map