@c15t/dev-tools 2.0.0-rc.6 → 2.0.0-rc.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/react.cjs CHANGED
@@ -1969,6 +1969,7 @@ var __webpack_exports__ = {};
1969
1969
  DevTools: ()=>C15TDevTools
1970
1970
  });
1971
1971
  const external_react_namespaceObject = require("react");
1972
+ const external_c15t_namespaceObject = require("c15t");
1972
1973
  const DEVTOOLS_STORAGE_KEY = 'c15t-devtools-position';
1973
1974
  const DRAG_THRESHOLD = 30;
1974
1975
  const VELOCITY_THRESHOLD = 0.15;
@@ -2346,7 +2347,7 @@ var __webpack_exports__ = {};
2346
2347
  }
2347
2348
  return null;
2348
2349
  }
2349
- const version = '2.0.0-rc.6';
2350
+ const version = '2.0.0-rc.8';
2350
2351
  const DEVTOOLS_ICON = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 446 445" aria-label="c15t">
2351
2352
  <path fill="currentColor" d="M223.178.313c39.064 0 70.732 31.668 70.732 70.732-.001 39.064-31.668 70.731-70.732 70.731-12.181 0-23.642-3.079-33.649-8.502l-55.689 55.689a70.267 70.267 0 0 1 5.574 13.441h167.531c8.695-29.217 35.762-50.523 67.804-50.523 39.064 0 70.731 31.668 70.731 70.732s-31.668 70.732-70.731 70.732c-32.042 0-59.108-21.306-67.803-50.523H139.413a70.417 70.417 0 0 1-7.888 17.396l54.046 54.046c10.893-6.851 23.786-10.815 37.605-10.815 39.064 0 70.732 31.669 70.732 70.733 0 39.064-31.668 70.731-70.732 70.731s-70.732-31.667-70.732-70.731c0-10.518 2.296-20.499 6.414-29.471l-57.78-57.78c-8.972 4.117-18.952 6.414-29.47 6.414-39.063 0-70.731-31.668-70.732-70.732 0-39.064 31.669-70.732 70.733-70.732 12.18 0 23.642 3.079 33.649 8.502l55.688-55.688c-5.423-10.007-8.502-21.469-8.502-33.65 0-39.064 31.668-70.733 70.732-70.733Zm0 343.555c-16.742 0-30.314 13.572-30.314 30.314 0 16.741 13.572 30.313 30.314 30.313s30.314-13.572 30.314-30.313c0-16.742-13.572-30.314-30.314-30.314ZM71.611 192.299c-16.742 0-30.315 13.572-30.315 30.314s13.573 30.314 30.315 30.314c16.741 0 30.313-13.572 30.313-30.314 0-16.741-13.572-30.314-30.313-30.314Zm303.138 0c-16.729 0-30.294 13.551-30.315 30.275l.001.039-.001.038c.021 16.725 13.586 30.276 30.315 30.276 16.741 0 30.313-13.572 30.313-30.314 0-16.741-13.572-30.314-30.313-30.314ZM223.178 40.73c-16.742 0-30.314 13.573-30.314 30.315s13.573 30.313 30.314 30.313c16.742 0 30.313-13.572 30.314-30.313 0-16.742-13.572-30.314-30.314-30.315Z"/>
2352
2353
  </svg>`;
@@ -4068,7 +4069,8 @@ var __webpack_exports__ = {};
4068
4069
  'error',
4069
4070
  'consent',
4070
4071
  'network',
4071
- 'iab'
4072
+ 'iab',
4073
+ "script"
4072
4074
  ];
4073
4075
  function createFilterButton(filter, active, onClick) {
4074
4076
  return createButton({
@@ -4083,6 +4085,7 @@ var __webpack_exports__ = {};
4083
4085
  if ('error' === filter) return 'error' === event.type;
4084
4086
  if ('consent' === filter) return 'consent_set' === event.type || 'consent_save' === event.type || 'consent_reset' === event.type;
4085
4087
  if ('network' === filter) return 'network' === event.type;
4088
+ if ("script" === filter) return "script" === event.type;
4086
4089
  return 'iab' === event.type;
4087
4090
  }
4088
4091
  function matchesSearch(event, query) {
@@ -4206,6 +4209,8 @@ var __webpack_exports__ = {};
4206
4209
  return '◉';
4207
4210
  case 'iab':
4208
4211
  return '◆';
4212
+ case "script":
4213
+ return '⌘';
4209
4214
  default:
4210
4215
  return '○';
4211
4216
  }
@@ -4223,6 +4228,8 @@ var __webpack_exports__ = {};
4223
4228
  return 'var(--c15t-devtools-badge-warning, #f59e0b)';
4224
4229
  case 'iab':
4225
4230
  return 'var(--c15t-devtools-badge-info, #3b82f6)';
4231
+ case "script":
4232
+ return 'var(--c15t-devtools-badge-info, #14b8a6)';
4226
4233
  default:
4227
4234
  return 'var(--c15t-text-muted)';
4228
4235
  }
@@ -5523,6 +5530,20 @@ var __webpack_exports__ = {};
5523
5530
  <polyline points="8 6 2 12 8 18"></polyline>
5524
5531
  </svg>`;
5525
5532
  const scriptsSearchByContainer = new WeakMap();
5533
+ const expandedScriptsByContainer = new WeakMap();
5534
+ const CHEVRON_DOWN_ICON = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
5535
+ <polyline points="6 9 12 15 18 9"></polyline>
5536
+ </svg>`;
5537
+ const CHEVRON_RIGHT_ICON = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
5538
+ <polyline points="9 18 15 12 9 6"></polyline>
5539
+ </svg>`;
5540
+ function getExpandedScripts(container) {
5541
+ const existing = expandedScriptsByContainer.get(container);
5542
+ if (existing) return existing;
5543
+ const expanded = new Set();
5544
+ expandedScriptsByContainer.set(container, expanded);
5545
+ return expanded;
5546
+ }
5526
5547
  function renderScriptsPanel(container, options) {
5527
5548
  const { getState, getEvents } = options;
5528
5549
  clearElement(container);
@@ -5584,6 +5605,10 @@ var __webpack_exports__ = {};
5584
5605
  for (const script of filteredScripts){
5585
5606
  const scriptId = script.id;
5586
5607
  const isLoaded = true === loadedScripts[scriptId];
5608
+ const scriptEvents = getScriptActivityEvents(events, scriptId);
5609
+ const latestActivity = scriptEvents[scriptEvents.length - 1];
5610
+ const expandedScripts = getExpandedScripts(container);
5611
+ const isExpanded = expandedScripts.has(scriptId);
5587
5612
  const category = script.category;
5588
5613
  const categoryDisplay = 'string' == typeof category ? category : JSON.stringify(category);
5589
5614
  let status = 'pending';
@@ -5605,7 +5630,7 @@ var __webpack_exports__ = {};
5605
5630
  text: status.charAt(0).toUpperCase() + status.slice(1),
5606
5631
  variant: statusVariant
5607
5632
  });
5608
- const row = renderer_div({
5633
+ const header = renderer_div({
5609
5634
  style: {
5610
5635
  display: 'flex',
5611
5636
  alignItems: 'center',
@@ -5644,19 +5669,57 @@ var __webpack_exports__ = {};
5644
5669
  whiteSpace: 'nowrap'
5645
5670
  },
5646
5671
  text: `Category: ${categoryDisplay}`
5647
- })
5672
+ }),
5673
+ ...latestActivity && scriptEvents.length > 0 ? [
5674
+ renderer_div({
5675
+ style: {
5676
+ fontSize: 'var(--c15t-devtools-font-size-xs)',
5677
+ color: 'var(--c15t-text-muted)',
5678
+ overflow: 'hidden',
5679
+ textOverflow: 'ellipsis',
5680
+ whiteSpace: 'nowrap'
5681
+ },
5682
+ text: `Activity: ${latestActivity.message} (${scriptEvents.length} event${1 === scriptEvents.length ? '' : 's'})`
5683
+ })
5684
+ ] : []
5648
5685
  ]
5649
5686
  }),
5650
5687
  renderer_div({
5651
5688
  style: {
5652
- flexShrink: '0'
5689
+ flexShrink: '0',
5690
+ display: 'flex',
5691
+ alignItems: 'center',
5692
+ gap: '8px'
5653
5693
  },
5654
5694
  children: [
5655
- badge
5695
+ badge,
5696
+ ...scriptEvents.length > 0 ? [
5697
+ createAccordionToggle({
5698
+ scriptId,
5699
+ isExpanded,
5700
+ onToggle: ()=>{
5701
+ if (isExpanded) expandedScripts.delete(scriptId);
5702
+ else expandedScripts.add(scriptId);
5703
+ renderScriptsPanel(container, options);
5704
+ }
5705
+ })
5706
+ ] : []
5656
5707
  ]
5657
5708
  })
5658
5709
  ]
5659
5710
  });
5711
+ const details = isExpanded && scriptEvents.length > 0 ? createScriptActivityDetails(scriptEvents) : null;
5712
+ const row = renderer_div({
5713
+ style: {
5714
+ display: 'flex',
5715
+ flexDirection: 'column',
5716
+ borderBottom: '1px solid var(--c15t-border)'
5717
+ },
5718
+ children: [
5719
+ header,
5720
+ details
5721
+ ]
5722
+ });
5660
5723
  scriptsList.appendChild(row);
5661
5724
  }
5662
5725
  const lastRow = scriptsList.lastElementChild;
@@ -5793,13 +5856,172 @@ var __webpack_exports__ = {};
5793
5856
  return 'string' == typeof url ? url : event.message;
5794
5857
  }
5795
5858
  function formatEventTime(timestamp) {
5796
- return new Date(timestamp).toLocaleTimeString('en-US', {
5797
- hour12: false,
5798
- hour: '2-digit',
5799
- minute: '2-digit',
5800
- second: '2-digit'
5859
+ const date = new Date(timestamp);
5860
+ const hours = String(date.getHours()).padStart(2, '0');
5861
+ const minutes = String(date.getMinutes()).padStart(2, '0');
5862
+ const seconds = String(date.getSeconds()).padStart(2, '0');
5863
+ const milliseconds = String(date.getMilliseconds()).padStart(3, '0');
5864
+ return `${hours}:${minutes}:${seconds}.${milliseconds}`;
5865
+ }
5866
+ function getScriptActivityEvents(events, scriptId) {
5867
+ return events.filter((event)=>{
5868
+ if ("script" !== event.type) return false;
5869
+ const data = event.data;
5870
+ if (data?.scriptId !== scriptId) return false;
5871
+ return data?.scope === 'lifecycle' || data?.scope === 'phase';
5872
+ }).sort((left, right)=>left.timestamp - right.timestamp);
5873
+ }
5874
+ function createAccordionToggle(options) {
5875
+ const { scriptId, isExpanded, onToggle } = options;
5876
+ const toggle = renderer_button({
5877
+ ariaLabel: `${isExpanded ? 'Collapse' : 'Expand'} ${scriptId} activity`,
5878
+ ariaExpanded: isExpanded ? 'true' : 'false',
5879
+ style: {
5880
+ display: 'inline-flex',
5881
+ alignItems: 'center',
5882
+ justifyContent: 'center',
5883
+ width: '24px',
5884
+ height: '24px',
5885
+ padding: '0',
5886
+ border: '1px solid var(--c15t-border)',
5887
+ borderRadius: '6px',
5888
+ background: 'transparent',
5889
+ color: 'var(--c15t-text-muted)',
5890
+ cursor: 'pointer',
5891
+ flexShrink: '0'
5892
+ },
5893
+ onClick: onToggle
5894
+ });
5895
+ toggle.innerHTML = isExpanded ? CHEVRON_DOWN_ICON : CHEVRON_RIGHT_ICON;
5896
+ return toggle;
5897
+ }
5898
+ function createScriptActivityDetails(events) {
5899
+ const groupedEvents = groupScriptActivityEvents(events.slice(-8));
5900
+ return renderer_div({
5901
+ style: {
5902
+ display: 'flex',
5903
+ flexDirection: 'column',
5904
+ gap: '6px',
5905
+ padding: '0 0 10px 0',
5906
+ marginLeft: '0'
5907
+ },
5908
+ children: groupedEvents.map(([groupName, groupEvents])=>createScriptActivityGroup(groupName, groupEvents))
5909
+ });
5910
+ }
5911
+ function createScriptActivityGroup(groupName, events) {
5912
+ return renderer_div({
5913
+ style: {
5914
+ display: 'flex',
5915
+ flexDirection: 'column',
5916
+ gap: '4px'
5917
+ },
5918
+ children: [
5919
+ renderer_span({
5920
+ style: {
5921
+ fontSize: 'var(--c15t-devtools-font-size-xs)',
5922
+ fontWeight: '600',
5923
+ color: 'var(--c15t-text)',
5924
+ textTransform: 'none'
5925
+ },
5926
+ text: groupName
5927
+ }),
5928
+ ...events.map((event)=>createScriptActivityRow(event))
5929
+ ]
5801
5930
  });
5802
5931
  }
5932
+ function createScriptActivityRow(event) {
5933
+ const data = event.data ?? {};
5934
+ const scope = 'string' == typeof data.scope ? data.scope : void 0;
5935
+ const phase = 'string' == typeof data.phase ? data.phase : void 0;
5936
+ const stepType = 'string' == typeof data.stepType ? data.stepType : void 0;
5937
+ const metadata = [
5938
+ scope,
5939
+ phase,
5940
+ stepType
5941
+ ].filter(Boolean).join(' / ');
5942
+ return renderer_div({
5943
+ style: {
5944
+ display: 'flex',
5945
+ flexDirection: 'column',
5946
+ gap: '2px',
5947
+ padding: '6px 10px',
5948
+ marginLeft: '0',
5949
+ borderLeft: '2px solid var(--c15t-border)',
5950
+ backgroundColor: 'var(--c15t-devtools-surface-secondary, rgba(127,127,127,0.06))',
5951
+ borderRadius: '0 8px 8px 0'
5952
+ },
5953
+ children: [
5954
+ renderer_div({
5955
+ style: {
5956
+ display: 'flex',
5957
+ alignItems: 'center',
5958
+ justifyContent: 'space-between',
5959
+ gap: '8px'
5960
+ },
5961
+ children: [
5962
+ renderer_span({
5963
+ style: {
5964
+ fontSize: 'var(--c15t-devtools-font-size-xs)',
5965
+ fontWeight: '600',
5966
+ color: 'var(--c15t-text)'
5967
+ },
5968
+ text: event.message
5969
+ }),
5970
+ renderer_span({
5971
+ style: {
5972
+ fontSize: 'var(--c15t-devtools-font-size-xs)',
5973
+ color: 'var(--c15t-text-muted)',
5974
+ flexShrink: '0'
5975
+ },
5976
+ text: formatEventTime(event.timestamp)
5977
+ })
5978
+ ]
5979
+ }),
5980
+ ...metadata ? [
5981
+ renderer_span({
5982
+ style: {
5983
+ fontSize: 'var(--c15t-devtools-font-size-xs)',
5984
+ color: 'var(--c15t-text-muted)'
5985
+ },
5986
+ text: metadata
5987
+ })
5988
+ ] : []
5989
+ ]
5990
+ });
5991
+ }
5992
+ function groupScriptActivityEvents(events) {
5993
+ const groups = new Map();
5994
+ for (const event of events){
5995
+ const groupName = getScriptActivityGroupName(event);
5996
+ const existing = groups.get(groupName);
5997
+ if (existing) existing.push(event);
5998
+ else groups.set(groupName, [
5999
+ event
6000
+ ]);
6001
+ }
6002
+ const orderedGroupNames = [
6003
+ 'onBeforeLoad',
6004
+ 'onLoad',
6005
+ 'onConsentChange',
6006
+ 'other'
6007
+ ];
6008
+ return orderedGroupNames.map((groupName)=>{
6009
+ const groupEvents = groups.get(groupName);
6010
+ return groupEvents ? [
6011
+ groupName,
6012
+ groupEvents
6013
+ ] : null;
6014
+ }).filter((group)=>null !== group);
6015
+ }
6016
+ function getScriptActivityGroupName(event) {
6017
+ const data = event.data ?? {};
6018
+ if ('string' == typeof data.callback) return data.callback;
6019
+ const phase = 'string' == typeof data.phase ? data.phase : '';
6020
+ if ('bootstrap' === phase || 'consent-default' === phase || 'setup' === phase || 'onBeforeLoadGranted' === phase || 'onBeforeLoadDenied' === phase) return 'onBeforeLoad';
6021
+ if ('afterLoad' === phase || 'onLoadGranted' === phase || 'onLoadDenied' === phase) return 'onLoad';
6022
+ if ('consent-update' === phase || 'onConsentChange' === phase || 'onConsentGranted' === phase || 'onConsentDenied' === phase) return 'onConsentChange';
6023
+ return 'other';
6024
+ }
5803
6025
  function scripts_truncateText(text, maxLength) {
5804
6026
  if (text.length <= maxLength) return text;
5805
6027
  return `${text.slice(0, maxLength - 3)}...`;
@@ -6368,6 +6590,7 @@ var __webpack_exports__ = {};
6368
6590
  const state = entry.store.getState();
6369
6591
  state.setCallback('onBannerFetched', entry.originalCallbacks.onBannerFetched);
6370
6592
  state.setCallback('onConsentSet', entry.originalCallbacks.onConsentSet);
6593
+ state.setCallback('onConsentChanged', entry.originalCallbacks.onConsentChanged);
6371
6594
  state.setCallback('onError', entry.originalCallbacks.onError);
6372
6595
  state.setCallback('onBeforeConsentRevocationReload', entry.originalCallbacks.onBeforeConsentRevocationReload);
6373
6596
  const blocker = state.networkBlocker;
@@ -6405,6 +6628,14 @@ var __webpack_exports__ = {};
6405
6628
  });
6406
6629
  if ('function' == typeof entry.originalCallbacks.onConsentSet) entry.originalCallbacks.onConsentSet(payload);
6407
6630
  });
6631
+ store.getState().setCallback('onConsentChanged', (payload)=>{
6632
+ emitEvent(entry, {
6633
+ type: 'consent_save',
6634
+ message: 'Consent preferences changed',
6635
+ data: payload
6636
+ });
6637
+ if ('function' == typeof entry.originalCallbacks.onConsentChanged) entry.originalCallbacks.onConsentChanged(payload);
6638
+ });
6408
6639
  store.getState().setCallback('onError', (payload)=>{
6409
6640
  const errorMessage = payload.error;
6410
6641
  emitEvent(entry, {
@@ -6545,6 +6776,25 @@ var __webpack_exports__ = {};
6545
6776
  loadedScripts: state.loadedScripts
6546
6777
  };
6547
6778
  }
6779
+ function scriptDebugEventToLogEntry(event) {
6780
+ return {
6781
+ type: "script",
6782
+ message: event.message,
6783
+ data: {
6784
+ ...event.data ?? {},
6785
+ source: event.source,
6786
+ scope: event.scope,
6787
+ action: event.action,
6788
+ scriptId: event.scriptId,
6789
+ elementId: event.elementId,
6790
+ hasConsent: event.hasConsent,
6791
+ callback: event.callback,
6792
+ phase: event.phase,
6793
+ stepType: event.stepType,
6794
+ stepIndex: event.stepIndex
6795
+ }
6796
+ };
6797
+ }
6548
6798
  function createDevTools(options = {}) {
6549
6799
  const { namespace = 'c15tStore', position = 'bottom-right', defaultOpen = false } = options;
6550
6800
  const stateManager = state_manager_createStateManager({
@@ -6552,6 +6802,7 @@ var __webpack_exports__ = {};
6552
6802
  isOpen: defaultOpen
6553
6803
  });
6554
6804
  let detachInstrumentation = null;
6805
+ let detachScriptDebug = null;
6555
6806
  const storeConnector = store_connector_createStoreConnector({
6556
6807
  namespace,
6557
6808
  onConnect: (_state, store)=>{
@@ -6563,6 +6814,10 @@ var __webpack_exports__ = {};
6563
6814
  stateManager.addEvent(event);
6564
6815
  }
6565
6816
  });
6817
+ detachScriptDebug?.();
6818
+ detachScriptDebug = (0, external_c15t_namespaceObject.subscribeToScriptDebugEvents)((event)=>{
6819
+ stateManager.addEvent(scriptDebugEventToLogEntry(event));
6820
+ });
6566
6821
  stateManager.setConnected(true);
6567
6822
  stateManager.addEvent({
6568
6823
  type: 'info',
@@ -6599,6 +6854,8 @@ var __webpack_exports__ = {};
6599
6854
  stateManager.setConnected(false);
6600
6855
  detachInstrumentation?.();
6601
6856
  detachInstrumentation = null;
6857
+ detachScriptDebug?.();
6858
+ detachScriptDebug = null;
6602
6859
  stateManager.addEvent({
6603
6860
  type: 'error',
6604
6861
  message: 'Disconnected from c15tStore'
@@ -6688,6 +6945,8 @@ var __webpack_exports__ = {};
6688
6945
  destroy: ()=>{
6689
6946
  detachInstrumentation?.();
6690
6947
  detachInstrumentation = null;
6948
+ detachScriptDebug?.();
6949
+ detachScriptDebug = null;
6691
6950
  panelHeightAnimator.destroy();
6692
6951
  tabsInstance?.destroy();
6693
6952
  panelInstance.destroy();