@antglobal/copilot-cards-web 0.0.20260915071159-dev.5 → 0.0.20260915071159-dev.9

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.
Files changed (2) hide show
  1. package/dist/index.js +50 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2905,6 +2905,34 @@ BaseElement.UNITLESS_PROPS = new Set([
2905
2905
  'widows',
2906
2906
  ]);
2907
2907
 
2908
+ /** Marked 18 uses Array.at internally; install it only on runtimes without it. */
2909
+ function ensureArrayAt() {
2910
+ if (typeof Array.prototype.at === 'function')
2911
+ return;
2912
+ // Marked calls this built-in directly; keep the fallback non-enumerable and preserve native implementations.
2913
+ // eslint-disable-next-line no-extend-native
2914
+ Object.defineProperty(Array.prototype, 'at', {
2915
+ configurable: true,
2916
+ writable: true,
2917
+ enumerable: false,
2918
+ // Class methods stay strict in non-module bundles and, like native at, are not constructors.
2919
+ value: class {
2920
+ static at(index) {
2921
+ if (this == null)
2922
+ throw new TypeError('Array.at called on null or undefined');
2923
+ const object = Object(this);
2924
+ const length = Math.min(Math.max(Math.trunc(+object.length) || 0, 0), Number.MAX_SAFE_INTEGER);
2925
+ const relativeIndex = Math.trunc(+index) || 0;
2926
+ const offset = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;
2927
+ return offset < 0 || offset >= length ? undefined : object[offset];
2928
+ }
2929
+ }.at,
2930
+ });
2931
+ const unscopables = Array.prototype[Symbol.unscopables];
2932
+ if (unscopables)
2933
+ unscopables.at = true;
2934
+ }
2935
+
2908
2936
  /**
2909
2937
  * CardText — Custom Element for rendering text content in a card.
2910
2938
  *
@@ -3279,6 +3307,7 @@ class CardText extends BaseElement {
3279
3307
  * Parse markdown to HTML using marked.
3280
3308
  */
3281
3309
  _parseMarkdown(text) {
3310
+ ensureArrayAt();
3282
3311
  const result = marked.parse(text);
3283
3312
  // marked.parse can return string or Promise; we use sync mode
3284
3313
  return typeof result === 'string' ? result : '';
@@ -6522,6 +6551,20 @@ if (typeof customElements !== 'undefined' && !customElements.get(CardLoading.is)
6522
6551
  customElements.define(CardLoading.is, CardLoading);
6523
6552
  }
6524
6553
 
6554
+ /** Replace SDK-owned DOM children on WebViews predating ParentNode.replaceChildren. */
6555
+ function replaceChildren(container, ...children) {
6556
+ if (typeof container.replaceChildren === 'function') {
6557
+ container.replaceChildren(...children);
6558
+ return;
6559
+ }
6560
+ const fragment = container.ownerDocument.createDocumentFragment();
6561
+ for (const child of children)
6562
+ fragment.appendChild(child);
6563
+ while (container.firstChild)
6564
+ container.removeChild(container.firstChild);
6565
+ container.appendChild(fragment);
6566
+ }
6567
+
6525
6568
  const DEFAULT_COLOR = '#1677ff';
6526
6569
  function nonNegative(value) {
6527
6570
  const number = Number(value);
@@ -6702,7 +6745,7 @@ class CardProgress extends BaseElement {
6702
6745
  if (valueText)
6703
6746
  track.setAttribute('aria-valuetext', valueText);
6704
6747
  }
6705
- this.shadowRoot.replaceChildren(styleElement, wrapper);
6748
+ replaceChildren(this.shadowRoot, styleElement, wrapper);
6706
6749
  applyResponsiveStyles(this.shadowRoot, this._responsive);
6707
6750
  }
6708
6751
  buildLegend(segments, position, style, isExpressionResultStyle) {
@@ -10424,7 +10467,7 @@ function renderBoundCard(container, schema, options) {
10424
10467
  for (const suffix of candidate.suffix) {
10425
10468
  disposeBoundSubtreeWithoutThrow(suffix);
10426
10469
  }
10427
- candidate.fragment.replaceChildren();
10470
+ replaceChildren(candidate.fragment);
10428
10471
  candidate.state = 'disposed';
10429
10472
  }
10430
10473
  function prepareRepeatAppendCandidates(preparedRoot, appendPlans, draft) {
@@ -10798,7 +10841,7 @@ function renderBoundCard(container, schema, options) {
10798
10841
  let adoptionThrew = false;
10799
10842
  let adoptionError;
10800
10843
  try {
10801
- container.replaceChildren(element);
10844
+ replaceChildren(container, element);
10802
10845
  }
10803
10846
  catch (error) {
10804
10847
  adoptionThrew = true;
@@ -11317,7 +11360,7 @@ function renderBoundCard(container, schema, options) {
11317
11360
  else {
11318
11361
  disposeChartsIn(container);
11319
11362
  }
11320
- container.replaceChildren();
11363
+ replaceChildren(container);
11321
11364
  const lifecycleNodes = [...activeLifecycleNodes.entries()];
11322
11365
  activeLifecycleNodes.clear();
11323
11366
  lifecycleQueue = lifecycleQueue
@@ -12086,7 +12129,7 @@ function renderStaticCard(container, schema, options) {
12086
12129
  return;
12087
12130
  }
12088
12131
  disposeChartsIn(container);
12089
- container.replaceChildren(initialTree.element);
12132
+ replaceChildren(container, initialTree.element);
12090
12133
  mountedTree = initialTree;
12091
12134
  }
12092
12135
  else {
@@ -12190,7 +12233,7 @@ function renderStaticCard(container, schema, options) {
12190
12233
  else {
12191
12234
  disposeChartsIn(container);
12192
12235
  }
12193
- container.replaceChildren();
12236
+ replaceChildren(container);
12194
12237
  for (const record of lifecycleRecords.values())
12195
12238
  destroyLifecycle(record);
12196
12239
  }
@@ -13292,7 +13335,7 @@ function renderStreamingCard(container, options = {}) {
13292
13335
  const scrollPositions = captureBoundScrollPositions(container);
13293
13336
  const mediaStates = captureBoundMediaStates(container);
13294
13337
  disposeChartsIn(container);
13295
- container.replaceChildren(prepared.dom);
13338
+ replaceChildren(container, prepared.dom);
13296
13339
  replaceProductionIndexes(prepared.indexes);
13297
13340
  currentSchema = schema;
13298
13341
  currentMaterialized = stableMaterialized;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antglobal/copilot-cards-web",
3
- "version": "0.0.20260915071159-dev.5",
3
+ "version": "0.0.20260915071159-dev.9",
4
4
  "description": "Web Component renderer for copilot bot card SDK — PC + Mobile + WebView unified rendering via Custom Elements",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@antglobal/copilot-cards-core": "0.0.20260915071159-dev.5",
31
+ "@antglobal/copilot-cards-core": "0.0.20260915071159-dev.9",
32
32
  "echarts": "^5.6.0",
33
33
  "marked": "^18.0.5",
34
34
  "tslib": "^2.8.1",