@bitcobblers/wod-wiki-ui 0.56.2208 → 0.57.2213

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.
@@ -311,7 +311,7 @@ var lineIdsExtension = ViewPlugin.fromClass(
311
311
  if (!label) label = timestamp;
312
312
  }
313
313
  id = label.toLowerCase().replace(/[^\w]+/g, "-");
314
- } else if (/^```(time|log)/.test(trimmed)) {
314
+ } else if (/^```(time|wod|whiteboard|log)/i.test(trimmed)) {
315
315
  id = `workout-line-${i}`;
316
316
  }
317
317
  if (id && line.from >= view.viewport.from && line.to <= view.viewport.to) {
@@ -331,6 +331,33 @@ var lineIdsExtension = ViewPlugin.fromClass(
331
331
  decorations: (v) => v.decorations
332
332
  }
333
333
  );
334
+ var affiliateTagFacet = Facet.define({
335
+ combine(values2) {
336
+ for (let i = values2.length - 1; i >= 0; i--) {
337
+ const trimmed = values2[i]?.trim();
338
+ if (trimmed) return trimmed;
339
+ }
340
+ return null;
341
+ }
342
+ });
343
+ var AMAZON_RETAIL_HOST_RE = /^(?:www\.|smile\.|m\.)?amazon\.[a-z]{2,3}(?:\.[a-z]{2})?$/i;
344
+ function isAmazonRetailHost(hostname) {
345
+ return AMAZON_RETAIL_HOST_RE.test(hostname);
346
+ }
347
+ function applyAmazonAffiliateTag(url, associateTag) {
348
+ const tag = associateTag?.trim();
349
+ if (!tag || !/^https?:\/\//i.test(url)) return url;
350
+ try {
351
+ const parsed = new URL(url);
352
+ if (!isAmazonRetailHost(parsed.hostname)) return url;
353
+ parsed.searchParams.set("tag", tag);
354
+ return parsed.toString();
355
+ } catch {
356
+ return url;
357
+ }
358
+ }
359
+
360
+ // src/extensions/link-open.ts
334
361
  var navigationFacet = Facet.define({
335
362
  combine(values2) {
336
363
  return values2.length > 0 ? values2[values2.length - 1] : null;
@@ -421,12 +448,13 @@ var ctrlClickPlugin = ViewPlugin.fromClass(
421
448
  if (!url) return;
422
449
  e.preventDefault();
423
450
  e.stopPropagation();
451
+ const resolvedUrl = applyAmazonAffiliateTag(url, view.state.facet(affiliateTagFacet));
424
452
  const navHook = view.state.facet(navigationFacet);
425
453
  if (navHook) {
426
- navHook(url, view);
454
+ navHook(resolvedUrl, view);
427
455
  } else if (typeof window !== "undefined") {
428
- const isInternal = url.startsWith("/") || url.startsWith("#");
429
- window.open(url, isInternal ? "_self" : "_blank", isInternal ? void 0 : "noopener,noreferrer");
456
+ const isInternal = resolvedUrl.startsWith("/") || resolvedUrl.startsWith("#");
457
+ window.open(resolvedUrl, isInternal ? "_self" : "_blank", isInternal ? void 0 : "noopener,noreferrer");
430
458
  }
431
459
  };
432
460
  view.dom.addEventListener("mousedown", this.handler, true);
@@ -4046,11 +4074,12 @@ function appendFormattedCellContent(container, rawText, view) {
4046
4074
  } else if (match[2] !== void 0 && match[3] !== void 0) {
4047
4075
  const label = match[2];
4048
4076
  const url = match[3];
4077
+ const isExternal = /^https?:\/\//i.test(url);
4078
+ const resolvedUrl = isExternal ? applyAmazonAffiliateTag(url, view.state.facet(affiliateTagFacet)) : url;
4049
4079
  const a = document.createElement("a");
4050
- a.href = url;
4080
+ a.href = resolvedUrl;
4051
4081
  a.textContent = label;
4052
4082
  a.className = "cm-table-cell-link underline underline-offset-2";
4053
- const isExternal = /^https?:\/\//i.test(url);
4054
4083
  if (isExternal) {
4055
4084
  a.target = "_blank";
4056
4085
  a.rel = "noopener noreferrer";
@@ -4508,7 +4537,8 @@ function openLinkEditPopover(anchorEl, view, match) {
4508
4537
  openBtn.addEventListener("click", (e) => {
4509
4538
  e.preventDefault();
4510
4539
  e.stopPropagation();
4511
- const targetUrl = urlInput.value.trim() || match.url;
4540
+ const rawUrl = urlInput.value.trim() || match.url;
4541
+ const targetUrl = applyAmazonAffiliateTag(rawUrl, view.state.facet(affiliateTagFacet));
4512
4542
  closeActiveLinkPopover();
4513
4543
  const navHook = view.state.facet(navigationFacet);
4514
4544
  if (!isExternalHttpUrl(targetUrl) && navHook) {
@@ -4595,21 +4625,23 @@ function openLinkEditPopover(anchorEl, view, match) {
4595
4625
  labelInput.select();
4596
4626
  }
4597
4627
  var LinkPillWidget = class extends WidgetType {
4598
- constructor(label, url, from, to, readOnly) {
4628
+ constructor(label, url, from, to, readOnly, affiliateTag) {
4599
4629
  super();
4600
4630
  this.label = label;
4601
4631
  this.url = url;
4602
4632
  this.from = from;
4603
4633
  this.to = to;
4604
4634
  this.readOnly = readOnly;
4635
+ this.affiliateTag = affiliateTag;
4605
4636
  }
4606
4637
  label;
4607
4638
  url;
4608
4639
  from;
4609
4640
  to;
4610
4641
  readOnly;
4642
+ affiliateTag;
4611
4643
  eq(other) {
4612
- return this.label === other.label && this.url === other.url && this.from === other.from && this.to === other.to && this.readOnly === other.readOnly;
4644
+ return this.label === other.label && this.url === other.url && this.from === other.from && this.to === other.to && this.readOnly === other.readOnly && this.affiliateTag === other.affiliateTag;
4613
4645
  }
4614
4646
  toDOM(view) {
4615
4647
  const isExternal = isExternalHttpUrl(this.url);
@@ -4636,9 +4668,10 @@ var LinkPillWidget = class extends WidgetType {
4636
4668
  });
4637
4669
  }
4638
4670
  pill.appendChild(label);
4671
+ const resolvedUrl = isExternal ? applyAmazonAffiliateTag(this.url, this.affiliateTag) : this.url;
4639
4672
  const open = document.createElement("a");
4640
4673
  open.className = "cm-link-pill-open";
4641
- open.href = this.url;
4674
+ open.href = resolvedUrl;
4642
4675
  if (isExternal) {
4643
4676
  open.target = "_blank";
4644
4677
  open.rel = "noopener noreferrer";
@@ -4650,11 +4683,11 @@ var LinkPillWidget = class extends WidgetType {
4650
4683
  if (navHook) {
4651
4684
  e.preventDefault();
4652
4685
  e.stopPropagation();
4653
- navHook(this.url, view);
4686
+ navHook(resolvedUrl, view);
4654
4687
  }
4655
4688
  });
4656
4689
  }
4657
- open.title = this.url;
4690
+ open.title = resolvedUrl;
4658
4691
  open.appendChild(createLinkArrowIcon(isExternal));
4659
4692
  pill.appendChild(open);
4660
4693
  return pill;
@@ -4788,7 +4821,8 @@ function buildLinkDecos(state) {
4788
4821
  link.url,
4789
4822
  link.from,
4790
4823
  link.to,
4791
- state.readOnly
4824
+ state.readOnly,
4825
+ state.facet(affiliateTagFacet)
4792
4826
  )
4793
4827
  })
4794
4828
  );
@@ -6833,9 +6867,6 @@ function WqlBars({ result, unit: unitProp }) {
6833
6867
  ] }) });
6834
6868
  }
6835
6869
  var MAX_ROWS = 12;
6836
- function formatValue(v, unit) {
6837
- return `${v.toLocaleString()}${unit ? ` ${unit}` : ""}`;
6838
- }
6839
6870
  function WqlTable({ result, unit: unitProp }) {
6840
6871
  const shape = useChartShape(result);
6841
6872
  const unit = result.series[0]?.unit ?? unitProp ?? "";
@@ -6843,14 +6874,14 @@ function WqlTable({ result, unit: unitProp }) {
6843
6874
  if (shape.kind === "scalar") {
6844
6875
  return {
6845
6876
  head: ["Metric", "Value"],
6846
- body: [[result.series[0]?.label ?? "scalar", formatValue(shape.value, unit)]],
6877
+ body: [[result.series[0]?.label ?? "scalar", formatTimeseriesTooltipValue(shape.value, unit)]],
6847
6878
  more: 0
6848
6879
  };
6849
6880
  }
6850
6881
  if (shape.kind === "bars") {
6851
6882
  const all = result.series.map((s) => [
6852
6883
  s.label,
6853
- formatValue(s.points[0]?.value ?? 0, unit)
6884
+ formatTimeseriesTooltipValue(s.points[0]?.value ?? 0, unit)
6854
6885
  ]);
6855
6886
  return {
6856
6887
  head: ["Series", "Value"],
@@ -6871,7 +6902,7 @@ function WqlTable({ result, unit: unitProp }) {
6871
6902
  formatTimestamp(ts),
6872
6903
  ...result.series.map((s) => {
6873
6904
  const v = seriesMap.get(s.label)?.get(ts);
6874
- return v !== void 0 ? formatValue(v, unit) : "\u2014";
6905
+ return v !== void 0 ? formatTimeseriesTooltipValue(v, unit) : "\u2014";
6875
6906
  })
6876
6907
  ]);
6877
6908
  return { head, body, more: Math.max(0, timestamps.length - MAX_ROWS) };
@@ -17627,6 +17658,6 @@ function editorPreset(optionsOrDialect = "markdown") {
17627
17658
  return extensions;
17628
17659
  }
17629
17660
 
17630
- export { AGG_OPTIONS, CANONICAL_BLOCK_TYPES, CLAUSE_META, ComposerRegistry, DEFAULT_DIAGNOSTICS_DEBOUNCE_MS, DEFAULT_OUTPUT_FILTERS, DEFAULT_PRIMARY_FILTER, DefaultFrontmatterWidget, EditorDialog, GROUPBY_OPTIONS, GoalRings, INTERNAL_FRONTMATTER_KEYS, KIND_OPTIONS, METRIC_OPTIONS, MULTI_VALUE_TYPES, MetricBadge, OUTPUT_TYPE_CLASS, OUTPUT_TYPE_DOT, OutputFilterPills, OutputStatementsTable, PLANE_OPTIONS, PRBadge, ProposedMetricBadge, QueryBlockView, QueryObjectBuilder, QueryValue, ROLLUP_OPTIONS, RowsResultsChrome, RowsTable, SERIES_COLORS, SOURCE_OPTIONS, SUGGESTION_BINDINGS, StackedBar, TARGET_OPTIONS, TIME_OPTIONS, TONE_CLASS, TokenSlotPill, TopList, UNIT_OPTIONS, WHERE_AGGREGATORS, WHERE_METRICS, WidgetChart, WidgetProblemBadge, WqlBars, WqlComposer, WqlDiagnosticsStrip, WqlEmptyState, WqlQueryInspectorModal, WqlTable, WqlTimeseries, ZoneDistribution, activeCursorSection, addRuntimePanel, attachmentUrlFacet, autocompleteTooltipTheme, bindTokenParamIntoWql, bindTokenToQueryObject, blockTypesFromBlocks, canonicalSuggestionItems, cn, compactNumber, composerRegistry, computeSessionPrHighlights, configureOverlayActions, createExecutorDocumentHost, cursorFocusExtension, customCompletionSources, cycleBaselineLayer, dateRangeSlot, dispatchAddRuntimePanel, dispatchExpandRuntimePanel, dispatchGutterHighlights, dispatchRemoveRuntimePanel, editQueryClause, editingQuerySectionsField, editingWidgetsField, editorFocusField, editorFocusTracker, editorPreset, editorTheme, embedPreviewDecorations, expandRuntimePanel, extractBlockQueries, extractMetricsByCategory, fenceCompletion, findQueryBlockSection, findWorkoutErrors, forceSectionParse, formatClockTime, formatMMSS, formatTimeseriesTick, formatTimeseriesTooltipValue, formatTimestamp, frontmatterDebugMode, frontmatterDetailed, frontmatterKeymap, frontmatterPreview, frontmatterPreviewField, frontmatterReferenceIndex, frontmatterSource, frontmatterSuggestions, frontmatterVisibility, getClauseMeta, getCursorFocusState, getOverlayActions, getSuggestionBinding, gutterHighlightsField, gutterUnified, handleFenceAutoWrap, handleSmartUrlPaste, hashCode, inlineButtonDecoration, insertMarkdownLinkCommand, invalidateSuggestions, isEditorFocused, isInternalFrontmatterKey, isNavigableUrl, lineIdsExtension, linkOpen, linkPreview, loadSuggestions, markdownSyntaxHiding, markdownTablePreview, matchFilterTypeahead, mergeSeries, mergeSuggestionItems, mergeTagSuggestions, navigationFacet, nestedCompletion, nestedCompletionOptions, normalizeOutputFilter, normalizeSimplePipelineToAggregate, notebookSlugsFromBlocks, outputToRunResult, outputsToRunResult, patchBlockQuery, presentBadges, previewDecorations, primaryQueryOf, promoteFindToChartObject, queryBlockPreview, readSessionRpe, referenceIndexReload, registeredSectionWidgets, removeRuntimePanel, removeSeriesLayer, resolveCodeLanguage, resolveQueryDraft, runtimePanelField, saveBlockQuerySource, sectionAtPos, sectionField, sectionGeometry, sectionIdentity, sectionIdentityHistory, sectionMove, sectionRestore, sectionSaved, sessionQueryFence, sessionQueryInsert, sessionQueryWql, setEditorFocused, setFrontmatterDetailed, setFrontmatterSource, setGutterHighlights, setPrimaryQueryOnObject, setQuerySourceEditing, setSuggestionBinding, slashBlockCompletion, smartIncrement, summarizeAggregate, summarizeFind, summarizePipeline, tagsFromStaticBlocks, toChartResult, toggleCompareLayer, toggleGoalLayer, toggleInlineMarkdown, toggleWidgetEdit, tooltipTimestamp, urlAtPos, useChartShape, useComposerSlots, useSuggestions, useVisualViewportRect, useWqlStageCounts, widgetBlockPreview, wodAutoWrap, wodAutocompletion, wodCompletionSource, wodEditorKeymap, wodLinter, wodOverlayPanel, workoutLintSource, wqlToPills, wrapInTimeFence };
17631
- //# sourceMappingURL=chunk-3NJIIKMT.mjs.map
17632
- //# sourceMappingURL=chunk-3NJIIKMT.mjs.map
17661
+ export { AGG_OPTIONS, CANONICAL_BLOCK_TYPES, CLAUSE_META, ComposerRegistry, DEFAULT_DIAGNOSTICS_DEBOUNCE_MS, DEFAULT_OUTPUT_FILTERS, DEFAULT_PRIMARY_FILTER, DefaultFrontmatterWidget, EditorDialog, GROUPBY_OPTIONS, GoalRings, INTERNAL_FRONTMATTER_KEYS, KIND_OPTIONS, METRIC_OPTIONS, MULTI_VALUE_TYPES, MetricBadge, OUTPUT_TYPE_CLASS, OUTPUT_TYPE_DOT, OutputFilterPills, OutputStatementsTable, PLANE_OPTIONS, PRBadge, ProposedMetricBadge, QueryBlockView, QueryObjectBuilder, QueryValue, ROLLUP_OPTIONS, RowsResultsChrome, RowsTable, SERIES_COLORS, SOURCE_OPTIONS, SUGGESTION_BINDINGS, StackedBar, TARGET_OPTIONS, TIME_OPTIONS, TONE_CLASS, TokenSlotPill, TopList, UNIT_OPTIONS, WHERE_AGGREGATORS, WHERE_METRICS, WidgetChart, WidgetProblemBadge, WqlBars, WqlComposer, WqlDiagnosticsStrip, WqlEmptyState, WqlQueryInspectorModal, WqlTable, WqlTimeseries, ZoneDistribution, activeCursorSection, addRuntimePanel, affiliateTagFacet, applyAmazonAffiliateTag, attachmentUrlFacet, autocompleteTooltipTheme, bindTokenParamIntoWql, bindTokenToQueryObject, blockTypesFromBlocks, canonicalSuggestionItems, cn, compactNumber, composerRegistry, computeSessionPrHighlights, configureOverlayActions, createExecutorDocumentHost, cursorFocusExtension, customCompletionSources, cycleBaselineLayer, dateRangeSlot, dispatchAddRuntimePanel, dispatchExpandRuntimePanel, dispatchGutterHighlights, dispatchRemoveRuntimePanel, editQueryClause, editingQuerySectionsField, editingWidgetsField, editorFocusField, editorFocusTracker, editorPreset, editorTheme, embedPreviewDecorations, expandRuntimePanel, extractBlockQueries, extractMetricsByCategory, fenceCompletion, findQueryBlockSection, findWorkoutErrors, forceSectionParse, formatClockTime, formatMMSS, formatTimeseriesTick, formatTimeseriesTooltipValue, formatTimestamp, frontmatterDebugMode, frontmatterDetailed, frontmatterKeymap, frontmatterPreview, frontmatterPreviewField, frontmatterReferenceIndex, frontmatterSource, frontmatterSuggestions, frontmatterVisibility, getClauseMeta, getCursorFocusState, getOverlayActions, getSuggestionBinding, gutterHighlightsField, gutterUnified, handleFenceAutoWrap, handleSmartUrlPaste, hashCode, inlineButtonDecoration, insertMarkdownLinkCommand, invalidateSuggestions, isAmazonRetailHost, isEditorFocused, isInternalFrontmatterKey, isNavigableUrl, lineIdsExtension, linkOpen, linkPreview, loadSuggestions, markdownSyntaxHiding, markdownTablePreview, matchFilterTypeahead, mergeSeries, mergeSuggestionItems, mergeTagSuggestions, navigationFacet, nestedCompletion, nestedCompletionOptions, normalizeOutputFilter, normalizeSimplePipelineToAggregate, notebookSlugsFromBlocks, outputToRunResult, outputsToRunResult, patchBlockQuery, presentBadges, previewDecorations, primaryQueryOf, promoteFindToChartObject, queryBlockPreview, readSessionRpe, referenceIndexReload, registeredSectionWidgets, removeRuntimePanel, removeSeriesLayer, resolveCodeLanguage, resolveQueryDraft, runtimePanelField, saveBlockQuerySource, sectionAtPos, sectionField, sectionGeometry, sectionIdentity, sectionIdentityHistory, sectionMove, sectionRestore, sectionSaved, sessionQueryFence, sessionQueryInsert, sessionQueryWql, setEditorFocused, setFrontmatterDetailed, setFrontmatterSource, setGutterHighlights, setPrimaryQueryOnObject, setQuerySourceEditing, setSuggestionBinding, slashBlockCompletion, smartIncrement, summarizeAggregate, summarizeFind, summarizePipeline, tagsFromStaticBlocks, toChartResult, toggleCompareLayer, toggleGoalLayer, toggleInlineMarkdown, toggleWidgetEdit, tooltipTimestamp, urlAtPos, useChartShape, useComposerSlots, useSuggestions, useVisualViewportRect, useWqlStageCounts, widgetBlockPreview, wodAutoWrap, wodAutocompletion, wodCompletionSource, wodEditorKeymap, wodLinter, wodOverlayPanel, workoutLintSource, wqlToPills, wrapInTimeFence };
17662
+ //# sourceMappingURL=chunk-W23ZR6NQ.mjs.map
17663
+ //# sourceMappingURL=chunk-W23ZR6NQ.mjs.map