@arcgis/coding-components 5.1.0-next.88 → 5.1.0-next.89

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 (91) hide show
  1. package/dist/cdn/3VRELPEF.js +2 -0
  2. package/dist/cdn/4B64NBIM.js +2 -0
  3. package/dist/cdn/5DAIGIIS.js +2 -0
  4. package/dist/cdn/6EKA3H3N.js +2 -0
  5. package/dist/cdn/6G5URSC7.js +2 -0
  6. package/dist/cdn/{BVNLUX5A.js → 6HL5GBWZ.js} +1 -1
  7. package/dist/cdn/7B33SKQD.js +2 -0
  8. package/dist/cdn/{GJMI6M3I.js → BA546EMZ.js} +1 -1
  9. package/dist/cdn/{2PRSVBDA.js → BKBBI4SA.js} +1 -1
  10. package/dist/cdn/BQISDYES.js +2 -0
  11. package/dist/cdn/E3TJIEWT.js +2 -0
  12. package/dist/cdn/FEYQMPLI.js +2 -0
  13. package/dist/cdn/GLJQQLP2.js +2 -0
  14. package/dist/cdn/{4I7VT4LW.js → I22MLDO4.js} +1 -1
  15. package/dist/cdn/ID3QICBM.js +4 -0
  16. package/dist/cdn/IIER7Z56.js +2 -0
  17. package/dist/cdn/{LWXQURWG.js → ILQJDTTW.js} +1 -1
  18. package/dist/cdn/JIBWBXDI.js +3 -0
  19. package/dist/cdn/{KEROXLGY.js → JT3FBAVQ.js} +1 -1
  20. package/dist/cdn/KA5TX72B.js +64 -0
  21. package/dist/cdn/MC6EICRD.js +2 -0
  22. package/dist/cdn/MJ7MJPGA.js +2 -0
  23. package/dist/cdn/MTIHPCIF.js +2 -0
  24. package/dist/cdn/N75AXIUZ.js +2 -0
  25. package/dist/cdn/NEIT2PGG.js +2 -0
  26. package/dist/cdn/{N7KYUPBV.js → NK5J27LM.js} +1 -1
  27. package/dist/cdn/NKJUJKFG.js +2 -0
  28. package/dist/cdn/NZDJGAT2.js +2 -0
  29. package/dist/cdn/{JHVMGSI2.js → OI3DH7N2.js} +1 -1
  30. package/dist/cdn/QMNQFBIA.js +4 -0
  31. package/dist/cdn/{INPMAY4D.js → SM3MA3KP.js} +1 -1
  32. package/dist/cdn/SMAQD57G.js +2 -0
  33. package/dist/cdn/{6XDEGPYR.js → UOQZCTHQ.js} +1 -1
  34. package/dist/cdn/{QOX2FNYP.js → VA6SZILK.js} +1 -1
  35. package/dist/cdn/VKNLGQFU.js +2 -0
  36. package/dist/cdn/{YLJUOSJJ.js → XBM4ZDJT.js} +1 -1
  37. package/dist/cdn/YVF4PPDB.js +2 -0
  38. package/dist/cdn/assets/arcade-debugger-console/t9n/messages.en.json +1 -0
  39. package/dist/cdn/assets/arcade-debugger-output/t9n/messages.en.json +1 -0
  40. package/dist/cdn/assets/arcade-editor/t9n/messages.en.json +1 -1
  41. package/dist/cdn/index.js +1 -1
  42. package/dist/chunks/ArcadeDebuggerPreviewTabsState.js +178 -0
  43. package/dist/chunks/arcade-executor.js +76 -67
  44. package/dist/chunks/arcade-service-accessors.js +2 -2
  45. package/dist/chunks/colorize.js +9 -9
  46. package/dist/chunks/debugger-value-components.js +275 -0
  47. package/dist/chunks/debugger-value-styles.js +171 -0
  48. package/dist/chunks/functional.js +83 -0
  49. package/dist/chunks/setup-monaco-theme.js +1 -1
  50. package/dist/chunks/utilities.js +44 -34
  51. package/dist/components/arcgis-arcade-debugger-console/customElement.js +201 -0
  52. package/dist/components/arcgis-arcade-debugger-console/index.js +11 -0
  53. package/dist/components/arcgis-arcade-debugger-output/customElement.js +42 -0
  54. package/dist/components/arcgis-arcade-debugger-output/index.js +5 -0
  55. package/dist/components/arcgis-arcade-editor/customElement.d.ts +34 -1
  56. package/dist/components/arcgis-arcade-editor/customElement.js +639 -111
  57. package/dist/components/arcgis-arcade-editor/index.js +2 -0
  58. package/dist/components/arcgis-arcade-results/customElement.js +52 -155
  59. package/dist/components/arcgis-code-editor/customElement.js +1 -1
  60. package/dist/components/arcgis-code-editor-shell/customElement.d.ts +2 -1
  61. package/dist/components/arcgis-code-editor-shell/customElement.js +17 -8
  62. package/dist/components/arcgis-code-viewer/customElement.d.ts +28 -1
  63. package/dist/components/arcgis-code-viewer/customElement.js +65 -52
  64. package/dist/docs/api.json +1 -1
  65. package/dist/docs/docs.json +1 -1
  66. package/dist/docs/vscode.html-custom-data.json +1 -1
  67. package/dist/docs/web-types.json +1 -1
  68. package/dist/loader.js +5 -3
  69. package/dist/types/lumina.d.ts +2 -2
  70. package/dist/types/preact.d.ts +2 -2
  71. package/dist/types/react.d.ts +2 -2
  72. package/dist/types/stencil.d.ts +2 -2
  73. package/dist/utils/arcade-executor.d.ts +2 -1
  74. package/package.json +5 -5
  75. package/dist/cdn/3GNGWLOI.js +0 -2
  76. package/dist/cdn/3UZ3JCYW.js +0 -4
  77. package/dist/cdn/43A7UCSS.js +0 -2
  78. package/dist/cdn/4Y64BGY2.js +0 -2
  79. package/dist/cdn/BGQRJR32.js +0 -2
  80. package/dist/cdn/CPJ4MNMY.js +0 -2
  81. package/dist/cdn/G2Z2DNVW.js +0 -2
  82. package/dist/cdn/ISAWP6I3.js +0 -2
  83. package/dist/cdn/IVNVT7UT.js +0 -2
  84. package/dist/cdn/KD7MZWFX.js +0 -2
  85. package/dist/cdn/MSV4QVR2.js +0 -2
  86. package/dist/cdn/PX32GRG7.js +0 -2
  87. package/dist/cdn/QRXX4WHP.js +0 -3
  88. package/dist/cdn/T4G2IY4F.js +0 -2
  89. package/dist/cdn/TTOHS2DV.js +0 -11
  90. package/dist/cdn/VUYXKN7I.js +0 -2
  91. package/dist/cdn/YMEY2NOQ.js +0 -4
@@ -11,8 +11,9 @@ import type { PublicLitElement as LitElement } from "@arcgis/lumina";
11
11
  * @cssproperty [--arcgis-coding-components-code-editor-side-panel-max-w] - The max width for the code editor side panel *
12
12
  * @cssproperty [--arcgis-coding-components-code-editor-results-panel-max-h] - The max height for the code editor results panel *
13
13
  * @cssproperty [--arcgis-coding-components-code-editor-results-panel-h] - The default height for the code editor results panel (preferred over min-h). *
14
- * @slot [top-action-bar] - A slot for placing a top action bar above the editor area.
14
+ * @slot [top-action-bar] - A slot for placing a top action bar above the editor area. This slot is deprecated in favor of bottom action bar, removal planned for 6.0
15
15
  * @slot [editor] - A slot for placing the main code editor component.
16
+ * @slot [bottom-action-bar] - A slot for placing a bottom action bar between the editor and results panel.
16
17
  * @slot [results-panel] - A slot for placing a results panel below the code editor.
17
18
  * @slot [side-panel] - A slot for placing a side panel next to the code editor area.
18
19
  * @slot [side-action-bar] - A slot for placing a side action bar next to the side panel.
@@ -1,17 +1,26 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import { c as o } from "../../chunks/runtime.js";
3
- import { css as e, html as n } from "lit";
4
- import { LitElement as r } from "@arcgis/lumina";
5
- const i = e`:host{--arcgis-coding-components-internal-border: var( --arcgis-coding-components-border, 1px solid var(--calcite-color-border-3) );--arcgis-coding-components-internal-background-color: var( --arcgis-coding-components-background-color, var(--calcite-color-foreground-1) );--arcgis-coding-components-internal-side-action-bar-max-w: var(--arcgis-coding-components-side-action-bar-max-w, 25%);--arcgis-coding-components-internal-code-editor-side-panel-w: var( --arcgis-coding-components-code-editor-side-panel-w, 600px );--arcgis-coding-components-internal-code-editor-side-panel-max-w: var( --arcgis-coding-components-code-editor-side-panel-max-w, 45% );--arcgis-coding-components-internal-code-editor-results-panel-max-h: var( --arcgis-coding-components-code-editor-results-panel-max-h, 50% );--arcgis-coding-components-internal-code-editor-results-panel-h: var( --arcgis-coding-components-code-editor-results-panel-h, 50% );display:flex;flex-direction:column;position:relative;overflow:hidden;border:var(--arcgis-coding-components-internal-border);box-sizing:border-box;background-color:var(--arcgis-coding-components-internal-background-color);height:100%;.flex-adjustable{flex:1 1 auto;overflow:hidden}.flex-row{display:flex;flex-direction:row;overflow:hidden}.flex-column{display:flex;flex-direction:column;overflow:hidden}}slot[name=top-action-bar]::slotted(*){border-bottom:var(--arcgis-coding-components-internal-border);flex:0 0 auto}slot[name=side-panel]::slotted(*){max-width:var(--arcgis-coding-components-internal-code-editor-side-panel-max-w);width:var(--arcgis-coding-components-internal-code-editor-side-panel-w);border-inline-start:var(--arcgis-coding-components-internal-border);box-sizing:border-box;flex:1 0 auto}slot[name=side-panel]::slotted(.hidden){display:none}slot[name=editor]::slotted(*){flex:1 1 auto;overflow:hidden}slot[name=results-panel]::slotted(*){flex:0 0 var(--arcgis-coding-components-internal-code-editor-results-panel-h);overflow:hidden;border-top:var(--arcgis-coding-components-internal-border);box-sizing:border-box;max-height:var(--arcgis-coding-components-internal-code-editor-results-panel-max-h);margin-bottom:-1px}slot[name=side-action-bar]::slotted(*){max-width:var(--arcgis-coding-components-internal-side-action-bar-max-w);border-inline-start:var(--arcgis-coding-components-internal-border)}`;
6
- class t extends r {
2
+ import { c as n } from "../../chunks/runtime.js";
3
+ import { css as t, html as r } from "lit";
4
+ import { LitElement as a } from "@arcgis/lumina";
5
+ import { slotChangeHasContent as s } from "@arcgis/toolkit/dom";
6
+ const i = t`:host{--arcgis-coding-components-internal-border: var( --arcgis-coding-components-border, 1px solid var(--calcite-color-border-3) );--arcgis-coding-components-internal-background-color: var( --arcgis-coding-components-background-color, var(--calcite-color-foreground-1) );--arcgis-coding-components-internal-side-action-bar-max-w: var(--arcgis-coding-components-side-action-bar-max-w, 25%);--arcgis-coding-components-internal-code-editor-side-panel-w: var( --arcgis-coding-components-code-editor-side-panel-w, 600px );--arcgis-coding-components-internal-code-editor-side-panel-max-w: var( --arcgis-coding-components-code-editor-side-panel-max-w, 45% );--arcgis-coding-components-internal-code-editor-results-panel-max-h: var( --arcgis-coding-components-code-editor-results-panel-max-h, 50% );--arcgis-coding-components-internal-code-editor-results-panel-h: var( --arcgis-coding-components-code-editor-results-panel-h, 50% );display:flex;flex-direction:column;position:relative;overflow:hidden;border:var(--arcgis-coding-components-internal-border);box-sizing:border-box;background-color:var(--arcgis-coding-components-internal-background-color);height:100%;.flex-adjustable{flex:1 1 auto;overflow:hidden}.flex-row{display:flex;flex-direction:row;overflow:hidden}.flex-column{display:flex;flex-direction:column;overflow:hidden}}slot[name=top-action-bar]{flex:0 0 auto}slot[name=top-action-bar]::slotted(*){border-bottom:var(--arcgis-coding-components-internal-border)}slot[name=bottom-action-bar]{flex:0 0 auto}slot[name=bottom-action-bar]::slotted(*){border-top:var(--arcgis-coding-components-internal-border)}slot[name=side-panel]::slotted(*){max-width:var(--arcgis-coding-components-internal-code-editor-side-panel-max-w);width:var(--arcgis-coding-components-internal-code-editor-side-panel-w);border-inline-start:var(--arcgis-coding-components-internal-border);box-sizing:border-box;flex:1 0 auto}slot[name=side-panel]::slotted(.hidden){display:none}slot[name=editor]::slotted(*){flex:auto;min-height:0}slot[name=results-panel]{display:flex;flex:0 0 auto;overflow:hidden}:host(.results-has-content) slot[name=results-panel]{height:var(--arcgis-coding-components-internal-code-editor-results-panel-h);max-height:var(--arcgis-coding-components-internal-code-editor-results-panel-max-h)}slot[name=results-panel]::slotted(*){border-top:var(--arcgis-coding-components-internal-border);box-sizing:border-box;flex:auto}slot[name=side-action-bar]::slotted(*){max-width:var(--arcgis-coding-components-internal-side-action-bar-max-w);border-inline-start:var(--arcgis-coding-components-internal-border)}`;
7
+ class l extends a {
8
+ constructor() {
9
+ super(...arguments), this._onResultsPanelSlotChange = (o) => {
10
+ if (!o.target)
11
+ return;
12
+ const e = s(o);
13
+ this.el.classList.toggle("results-has-content", e);
14
+ };
15
+ }
7
16
  static {
8
17
  this.styles = [i];
9
18
  }
10
19
  render() {
11
- return n`<slot name=top-action-bar></slot><div class="flex-row flex-adjustable"><div class="flex-column flex-adjustable"><slot name=editor></slot><slot name=results-panel></slot></div><slot name=side-panel></slot><slot name=side-action-bar></slot></div>`;
20
+ return r`<slot name=top-action-bar></slot><div class="flex-row flex-adjustable"><div class="flex-column flex-adjustable"><slot name=editor></slot><slot name=bottom-action-bar></slot><slot name=results-panel @slotchange=${this._onResultsPanelSlotChange}></slot></div><slot name=side-panel></slot><slot name=side-action-bar></slot></div>`;
12
21
  }
13
22
  }
14
- o("arcgis-code-editor-shell", t);
23
+ n("arcgis-code-editor-shell", l);
15
24
  export {
16
- t as CodeEditorShell
25
+ l as CodeEditorShell
17
26
  };
@@ -26,6 +26,20 @@ import type { PublicLitElement as LitElement } from "@arcgis/lumina";
26
26
  * to plain text. For safety and to prevent the markup from rendering in-page, wrap the snippet in a `<template>`.
27
27
  * If no `<template>` is provided, the component falls back to concatenating the `outerHTML` of element nodes and the
28
28
  * raw text of text nodes. Script contents are treated as inert string data; they are never executed.
29
+ * @example
30
+ * Monaco-style line numbers
31
+ * ```tsx
32
+ * <arcgis-code-viewer language="typescript" lineNumbers="on">
33
+ * const answer = 42;
34
+ * console.log(answer);
35
+ * </arcgis-code-viewer>
36
+ * ```
37
+ * @example
38
+ * Custom line numbers using Monaco's formatter pattern
39
+ * ```ts
40
+ * const viewer = document.querySelector("arcgis-code-viewer");
41
+ * viewer.lineNumbers = (lineNumber) => String(lineNumber + 40);
42
+ * ```
29
43
  * @internal
30
44
  */
31
45
  export abstract class ArcgisCodeViewer extends LitElement {
@@ -40,10 +54,23 @@ export abstract class ArcgisCodeViewer extends LitElement {
40
54
  * @default "arcade"
41
55
  */
42
56
  accessor language: string;
57
+ /**
58
+ * Controls line number rendering using Monaco's `lineNumbers` paradigm.
59
+ *
60
+ * - `"off"`: hide the gutter
61
+ * - `"on"`: render 1-based line numbers
62
+ * - `(lineNumber) => string`: render custom labels, such as offset line numbers
63
+ *
64
+ * @default "off"
65
+ */
66
+ accessor lineNumbers: ArcgisCodeViewerLineNumbers;
43
67
  /**
44
68
  * When `true`, adds a round style to the component.
45
69
  *
46
70
  * @default false
47
71
  */
48
72
  accessor round: boolean;
49
- }
73
+ }
74
+
75
+ /** @internal */
76
+ export type ArcgisCodeViewerLineNumbers = "off" | "on" | ((lineNumber: number) => string);
@@ -1,46 +1,46 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
2
  import { g as m, c as u } from "../../chunks/runtime.js";
3
- import { LitElement as p } from "@arcgis/lumina";
4
- import { slotChangeHasContent as g, observeAncestorsMutation as f, unsafeGetCalciteModeName as _ } from "@arcgis/toolkit/dom";
5
- import { load as S } from "@arcgis/lumina/controllers";
6
- import { i as v } from "../../chunks/monaco-importer.js";
7
- import { css as E, html as a } from "lit";
8
- import { w as l, s as h } from "../../chunks/setup-monaco-theme.js";
9
- import { c as T, g as c, o as b } from "../../chunks/colorize.js";
10
- import { s as C } from "../../chunks/arcade-service-accessors.js";
11
- import { debounce as y } from "@arcgis/toolkit/function";
12
- import { Task as N } from "@lit/task";
13
- import { rethrowError as O, log as w } from "@arcgis/toolkit/log";
14
- const z = E`pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-color-foreground-2);padding:var(--calcite-spacing-sm);white-space:pre-line;code{font-size:var(--calcite-font-size--2);font-family:var(--calcite-font-family-code)}}:host([round]){pre{border-radius:var(--calcite-corner-radius-round)}}`;
15
- class L extends p {
3
+ import { LitElement as g } from "@arcgis/lumina";
4
+ import { slotChangeHasContent as p, observeAncestorsMutation as f, unsafeGetCalciteModeName as _ } from "@arcgis/toolkit/dom";
5
+ import { load as v } from "@arcgis/lumina/controllers";
6
+ import { i as b } from "../../chunks/monaco-importer.js";
7
+ import { css as y, html as a } from "lit";
8
+ import { w as l, s as c } from "../../chunks/setup-monaco-theme.js";
9
+ import { c as S, g as d, o as N } from "../../chunks/colorize.js";
10
+ import { s as E } from "../../chunks/arcade-service-accessors.js";
11
+ import { debounce as T } from "@arcgis/toolkit/function";
12
+ import { Task as w } from "@lit/task";
13
+ import { rethrowError as C, log as L } from "@arcgis/toolkit/log";
14
+ const O = y`:host{display:block}.arcgis-code-viewer-container{display:flex;align-items:stretch;background-color:var(--calcite-color-foreground-2)}.arcgis-code-viewer__gutter{display:flex;min-width:var(--calcite-spacing-md);padding:0 var(--calcite-spacing-xs) 0 var(--calcite-spacing-sm);border-inline-end:1px solid var(--calcite-color-border-3);color:var(--calcite-color-text-3);font-size:var(--calcite-font-size--2);font-family:var(--calcite-font-family-code);user-select:none;justify-items:center;font-variant-numeric:tabular-nums}.arcgis-code-viewer__line-number{display:flex;align-items:center}pre.arcgis-code-viewer{display:flex;direction:ltr;overflow-x:auto;margin:0;padding:var(--calcite-spacing-sm);white-space:pre-line;code{font-size:var(--calcite-font-size--2);font-family:var(--calcite-font-family-code)}}:host([round]){.arcgis-code-viewer-container{border-radius:var(--calcite-corner-radius-round)}}`;
15
+ class z extends g {
16
16
  constructor() {
17
- super(...arguments), this._monacoEditor = S(v), this.#t = Promise.withResolvers(), this.#e = "", this._slotContentObservers = [], this._onDefaultSlotChange = async (e) => {
18
- g(e) || (this._codeFromSlot = "");
19
- const t = e.target instanceof HTMLSlotElement ? e.target : null, o = t ? this._computeSlotText(t) : "";
20
- t && this._observeAssignedSlotNodes(t), o !== this._codeFromSlot && (this._codeFromSlot = o), this.#t.resolve();
21
- }, this._colorizeTask = new N(this, {
22
- task: async ([e, t], { signal: o }) => {
23
- if (await this.#t.promise, o.aborted)
17
+ super(...arguments), this._monacoEditor = v(b), this.#t = Promise.withResolvers(), this.#e = "", this._slotContentObservers = [], this._onDefaultSlotChange = async (e) => {
18
+ p(e) || (this._codeFromSlot = "");
19
+ const t = e.target instanceof HTMLSlotElement ? e.target : null, s = t ? this._computeSlotText(t) : "";
20
+ t && this._observeAssignedSlotNodes(t), s !== this._codeFromSlot && (this._codeFromSlot = s), this.#t.resolve();
21
+ }, this._colorizeTask = new w(this, {
22
+ task: async ([e, t], { signal: s }) => {
23
+ if (await this.#t.promise, s.aborted)
24
24
  return this.#e;
25
- if (await l(t), o.aborted)
25
+ if (await l(t), s.aborted)
26
26
  return this.#e;
27
- const i = await T(e, t);
28
- return o.aborted ? this.#e : (this.#e = i, i);
27
+ const r = await S(e, t);
28
+ return s.aborted ? this.#e : (this.#e = r, r);
29
29
  },
30
30
  args: () => [this._codeFromSlot, this.language]
31
- }), this._codeFromSlot = "", this.language = "arcade", this.round = !1;
31
+ }), this._codeFromSlot = "", this.language = "arcade", this.round = !1, this.lineNumbers = "off";
32
32
  }
33
33
  static {
34
- this.properties = { _codeFromSlot: 16, language: 1, round: 7 };
34
+ this.properties = { _codeFromSlot: 16, language: 1, round: 7, lineNumbers: 1 };
35
35
  }
36
36
  static {
37
- this.styles = z;
37
+ this.styles = O;
38
38
  }
39
39
  #t;
40
40
  #e;
41
41
  async load() {
42
- C(m("./assets")), await h(this.language), await l(this.language), this._applyColorizeStyles(c()), this.manager.onLifecycle(() => (this._themeObserver = f(this.el, ["class"], () => this.updateTheme()), this._themeChangedListener = b(() => {
43
- this._applyColorizeStyles(c());
42
+ E(m("./assets")), await c(this.language), await l(this.language), this._applyColorizeStyles(d()), this.manager.onLifecycle(() => (this._themeObserver = f(this.el, ["class"], () => this.updateTheme()), this._themeChangedListener = N(() => {
43
+ this._applyColorizeStyles(d());
44
44
  }), this.updateTheme(), () => {
45
45
  this._themeObserver?.(), this._themeObserver = void 0, this._themeChangedListener?.dispose(), this._themeChangedListener = void 0;
46
46
  }));
@@ -49,7 +49,7 @@ class L extends p {
49
49
  this.el.hasChildNodes() || this.#t.resolve();
50
50
  }
51
51
  willUpdate(e) {
52
- e.has("language") && h(this.language).then(() => l(this.language)).catch(O(this));
52
+ e.has("language") && c(this.language).then(() => l(this.language)).catch(C(this));
53
53
  }
54
54
  disconnectedCallback() {
55
55
  super.disconnectedCallback(), this._disposeSlotObservers();
@@ -62,35 +62,35 @@ class L extends p {
62
62
  const t = e.assignedNodes({ flatten: !0 });
63
63
  if (!t.length)
64
64
  return;
65
- const o = /* @__PURE__ */ new Set();
66
- for (const s of t)
67
- s.nodeType === Node.ELEMENT_NODE ? o.add(s) : s.nodeType === Node.TEXT_NODE && s.parentElement && o.add(s.parentElement);
68
- const i = { characterData: !0, childList: !0, subtree: !0 }, r = y(() => {
69
- const s = this._computeSlotText(e);
70
- s !== this._codeFromSlot && (this._codeFromSlot = s);
71
- }, 100), d = (s) => {
72
- if (s.some((n) => n.type === "childList")) {
65
+ const s = /* @__PURE__ */ new Set();
66
+ for (const o of t)
67
+ o.nodeType === Node.ELEMENT_NODE ? s.add(o) : o.nodeType === Node.TEXT_NODE && o.parentElement && s.add(o.parentElement);
68
+ const r = { characterData: !0, childList: !0, subtree: !0 }, i = T(() => {
69
+ const o = this._computeSlotText(e);
70
+ o !== this._codeFromSlot && (this._codeFromSlot = o);
71
+ }, 100), h = (o) => {
72
+ if (o.some((n) => n.type === "childList")) {
73
73
  const n = this._computeSlotText(e);
74
74
  n !== this._codeFromSlot && (this._codeFromSlot = n);
75
75
  return;
76
76
  }
77
- r();
77
+ i();
78
78
  };
79
- o.forEach((s) => {
80
- const n = new MutationObserver(d);
81
- n.observe(s, i), this._slotContentObservers.push(n);
79
+ s.forEach((o) => {
80
+ const n = new MutationObserver(h);
81
+ n.observe(o, r), this._slotContentObservers.push(n);
82
82
  });
83
83
  }
84
84
  _computeSlotText(e) {
85
- const t = e.assignedNodes({ flatten: !0 }).filter((o) => o.nodeType !== Node.COMMENT_NODE);
85
+ const t = e.assignedNodes({ flatten: !0 }).filter((s) => s.nodeType !== Node.COMMENT_NODE);
86
86
  if (this.language === "html" && t.length) {
87
- const o = t.find((r) => r.nodeType === Node.ELEMENT_NODE && r.tagName === "TEMPLATE");
88
- if (o)
89
- return (o.innerHTML ?? "").trim();
90
- const i = t.map((r) => r.nodeType === Node.ELEMENT_NODE ? r.outerHTML : r.nodeType === Node.TEXT_NODE ? r.textContent ?? "" : "").join("").trim();
91
- return i && process.env.NODE_ENV !== "production" && w("warn", this, "Consider wrapping your snippet in a <template> for fully inert, intention-revealing markup."), i;
87
+ const s = t.find((i) => i.nodeType === Node.ELEMENT_NODE && i.tagName === "TEMPLATE");
88
+ if (s)
89
+ return (s.innerHTML ?? "").trim();
90
+ const r = t.map((i) => i.nodeType === Node.ELEMENT_NODE ? i.outerHTML : i.nodeType === Node.TEXT_NODE ? i.textContent ?? "" : "").join("").trim();
91
+ return r && process.env.NODE_ENV !== "production" && L("warn", this, "Consider wrapping your snippet in a <template> for fully inert, intention-revealing markup."), r;
92
92
  }
93
- return t.map((o) => o.textContent ?? "").join("").trim();
93
+ return t.map((s) => s.textContent ?? "").join("").trim();
94
94
  }
95
95
  updateTheme() {
96
96
  const e = _(this.el) === "light" ? "vs" : "vs-dark";
@@ -104,15 +104,28 @@ class L extends p {
104
104
  }
105
105
  this._colorizeSheet.replaceSync(e);
106
106
  }
107
+ _showLineNumbers() {
108
+ return typeof this.lineNumbers == "function" || this.lineNumbers === "on";
109
+ }
110
+ _getLineNumberLabel(e) {
111
+ return typeof this.lineNumbers == "function" ? this.lineNumbers(e) : `${e}`;
112
+ }
113
+ _getRenderedLineNumbers() {
114
+ if (!this._showLineNumbers())
115
+ return [];
116
+ const e = Math.max(this._codeFromSlot.split(/\r\n|\r|\n/u).length, 1);
117
+ return Array.from({ length: e }, (t, s) => this._getLineNumberLabel(s + 1));
118
+ }
107
119
  render() {
108
- return a`<div><slot @slotchange=${this._onDefaultSlotChange} style="display:none" aria-hidden=true></slot><pre class="arcgis-code-viewer" aria-label=${`${this.language} code snippet`}>${this._colorizeTask.render({
120
+ const e = this._getRenderedLineNumbers();
121
+ return a`<div class=${`arcgis-code-viewer-container${e.length ? " arcgis-code-viewer-container--with-line-numbers" : ""}`}><slot @slotchange=${this._onDefaultSlotChange} style="display:none" aria-hidden=true></slot>${e.length ? a`<div class="arcgis-code-viewer__gutter" aria-hidden=true>${e.map((t) => a`<span class="arcgis-code-viewer__line-number">${t}</span>`)}</div>` : null}<pre class="arcgis-code-viewer" aria-label=${`${this.language} code snippet`}>${this._colorizeTask.render({
109
122
  error: () => null,
110
123
  pending: () => a`<code class=${`language-${this.language}`}></code>`,
111
- complete: (e) => a`<code class=${`language-${this.language}`} .innerHTML=${e ?? ""}></code>`
124
+ complete: (t) => a`<code class=${`language-${this.language}`} .innerHTML=${t ?? ""}></code>`
112
125
  })}</pre></div>`;
113
126
  }
114
127
  }
115
- u("arcgis-code-viewer", L);
128
+ u("arcgis-code-viewer", z);
116
129
  export {
117
- L as ArcgisCodeViewer
130
+ z as ArcgisCodeViewer
118
131
  };