@halo-dev/shiki-code-element 1.3.1 → 1.3.2
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.js +47 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//#region ../node_modules/.pnpm/@unocss+reset@66.6.2/node_modules/@unocss/reset/tailwind.css?inline
|
|
2
|
+
var e = "*,:before,:after{box-sizing:border-box;border-style:solid;border-width:0;border-color:var(--un-default-border-color,#e5e7eb)}:before,:after{--un-content:\"\"}html,:host{-webkit-text-size-adjust:100%;tab-size:4;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5}body{line-height:inherit;margin:0}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-feature-settings:normal;font-variation-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-feature-settings:inherit;font-variation-settings:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:#0000;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{margin:0;padding:0;list-style:none}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}", t = globalThis, n = t.ShadowRoot && (t.ShadyCSS === void 0 || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, r = Symbol(), i = /* @__PURE__ */ new WeakMap(), a = class {
|
|
2
3
|
constructor(e, t, n) {
|
|
3
4
|
if (this._$cssResult$ = !0, n !== r) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
4
5
|
this.cssText = e, this.t = t;
|
|
@@ -65,7 +66,7 @@ var e = "*,:before,:after{box-sizing:border-box;border-style:solid;border-width:
|
|
|
65
66
|
useDefault: !1,
|
|
66
67
|
hasChanged: g
|
|
67
68
|
};
|
|
68
|
-
Symbol.metadata ??= Symbol("metadata"), f.litPropertyMetadata ??= new WeakMap();
|
|
69
|
+
Symbol.metadata ??= Symbol("metadata"), f.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
|
|
69
70
|
var v = class extends HTMLElement {
|
|
70
71
|
static addInitializer(e) {
|
|
71
72
|
this._$Ei(), (this.l ??= []).push(e);
|
|
@@ -117,7 +118,7 @@ var v = class extends HTMLElement {
|
|
|
117
118
|
let t = litPropertyMetadata.get(e);
|
|
118
119
|
if (t !== void 0) for (let [e, n] of t) this.elementProperties.set(e, n);
|
|
119
120
|
}
|
|
120
|
-
this._$Eh = new Map();
|
|
121
|
+
this._$Eh = /* @__PURE__ */ new Map();
|
|
121
122
|
for (let [e, t] of this.elementProperties) {
|
|
122
123
|
let n = this._$Eu(e, t);
|
|
123
124
|
n !== void 0 && this._$Eh.set(n, e);
|
|
@@ -140,16 +141,16 @@ var v = class extends HTMLElement {
|
|
|
140
141
|
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
|
|
141
142
|
}
|
|
142
143
|
_$Ev() {
|
|
143
|
-
this._$ES = new Promise(((e) => this.enableUpdating = e)), this._$AL = new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((e) => e(this)));
|
|
144
|
+
this._$ES = new Promise(((e) => this.enableUpdating = e)), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((e) => e(this)));
|
|
144
145
|
}
|
|
145
146
|
addController(e) {
|
|
146
|
-
(this._$EO ??= new Set()).add(e), this.renderRoot !== void 0 && this.isConnected && e.hostConnected?.();
|
|
147
|
+
(this._$EO ??= /* @__PURE__ */ new Set()).add(e), this.renderRoot !== void 0 && this.isConnected && e.hostConnected?.();
|
|
147
148
|
}
|
|
148
149
|
removeController(e) {
|
|
149
150
|
this._$EO?.delete(e);
|
|
150
151
|
}
|
|
151
152
|
_$E_() {
|
|
152
|
-
let e = new Map(), t = this.constructor.elementProperties;
|
|
153
|
+
let e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties;
|
|
153
154
|
for (let n of t.keys()) this.hasOwnProperty(n) && (e.set(n, this[n]), delete this[n]);
|
|
154
155
|
e.size > 0 && (this._$Ep = e);
|
|
155
156
|
}
|
|
@@ -192,7 +193,7 @@ var v = class extends HTMLElement {
|
|
|
192
193
|
!1 === this.isUpdatePending && (this._$ES = this._$EP());
|
|
193
194
|
}
|
|
194
195
|
C(e, t, { useDefault: n, reflect: r, wrapped: i }, a) {
|
|
195
|
-
n && !(this._$Ej ??= new Map()).has(e) && (this._$Ej.set(e, a ?? t ?? this[e]), !0 !== i || a !== void 0) || (this._$AL.has(e) || (this.hasUpdated || n || (t = void 0), this._$AL.set(e, t)), !0 === r && this._$Em !== e && (this._$Eq ??= new Set()).add(e));
|
|
196
|
+
n && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(e) && (this._$Ej.set(e, a ?? t ?? this[e]), !0 !== i || a !== void 0) || (this._$AL.has(e) || (this.hasUpdated || n || (t = void 0), this._$AL.set(e, t)), !0 === r && this._$Em !== e && (this._$Eq ??= /* @__PURE__ */ new Set()).add(e));
|
|
196
197
|
}
|
|
197
198
|
async _$EP() {
|
|
198
199
|
this.isUpdatePending = !0;
|
|
@@ -233,7 +234,7 @@ var v = class extends HTMLElement {
|
|
|
233
234
|
this._$EO?.forEach(((e) => e.hostUpdated?.())), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e);
|
|
234
235
|
}
|
|
235
236
|
_$EM() {
|
|
236
|
-
this._$AL = new Map(), this.isUpdatePending = !1;
|
|
237
|
+
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
|
|
237
238
|
}
|
|
238
239
|
get updateComplete() {
|
|
239
240
|
return this.getUpdateComplete();
|
|
@@ -250,12 +251,14 @@ var v = class extends HTMLElement {
|
|
|
250
251
|
updated(e) {}
|
|
251
252
|
firstUpdated(e) {}
|
|
252
253
|
};
|
|
253
|
-
v.elementStyles = [], v.shadowRootOptions = { mode: "open" }, v[m("elementProperties")] = new Map(), v[m("finalized")] = new Map(), ae?.({ ReactiveElement: v }), (f.reactiveElementVersions ??= []).push("2.1.1");
|
|
254
|
+
v.elementStyles = [], v.shadowRootOptions = { mode: "open" }, v[m("elementProperties")] = /* @__PURE__ */ new Map(), v[m("finalized")] = /* @__PURE__ */ new Map(), ae?.({ ReactiveElement: v }), (f.reactiveElementVersions ??= []).push("2.1.1");
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region ../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js
|
|
254
257
|
var y = globalThis, b = y.trustedTypes, x = b ? b.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, oe = "$lit$", S = `lit$${Math.random().toFixed(9).slice(2)}$`, C = "?" + S, se = `<${C}>`, w = document, T = () => w.createComment(""), E = (e) => e === null || typeof e != "object" && typeof e != "function", D = Array.isArray, ce = (e) => D(e) || typeof e?.[Symbol.iterator] == "function", O = "[ \n\f\r]", k = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, A = /-->/g, j = />/g, M = RegExp(`>|${O}(?:([^\\s"'>=/]+)(${O}*=${O}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`, "g"), le = /'/g, ue = /"/g, N = /^(?:script|style|textarea|title)$/i, P = ((e) => (t, ...n) => ({
|
|
255
258
|
_$litType$: e,
|
|
256
259
|
strings: t,
|
|
257
260
|
values: n
|
|
258
|
-
}))(1), F = Symbol.for("lit-noChange"), I = Symbol.for("lit-nothing"), L = new WeakMap(), R = w.createTreeWalker(w, 129);
|
|
261
|
+
}))(1), F = Symbol.for("lit-noChange"), I = Symbol.for("lit-nothing"), L = /* @__PURE__ */ new WeakMap(), R = w.createTreeWalker(w, 129);
|
|
259
262
|
function z(e, t) {
|
|
260
263
|
if (!D(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
261
264
|
return x === void 0 ? t : x.createHTML(t);
|
|
@@ -419,7 +422,7 @@ var fe = class {
|
|
|
419
422
|
return this._$AM._$AU;
|
|
420
423
|
}
|
|
421
424
|
constructor(e, t, n, r, i) {
|
|
422
|
-
this.type = 1, this._$AH = I, this._$AN = void 0, this.element = e, this.name = t, this._$AM = r, this.options = i, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$AH = Array(n.length - 1).fill(new String()), this.strings = n) : this._$AH = I;
|
|
425
|
+
this.type = 1, this._$AH = I, this._$AN = void 0, this.element = e, this.name = t, this._$AM = r, this.options = i, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$AH = Array(n.length - 1).fill(/* @__PURE__ */ new String()), this.strings = n) : this._$AH = I;
|
|
423
426
|
}
|
|
424
427
|
_$AI(e, t = this, n, r) {
|
|
425
428
|
let i = this.strings, a = !1;
|
|
@@ -503,6 +506,8 @@ var ve = (e, t, n) => {
|
|
|
503
506
|
G._$litElement$ = !0, G.finalized = !0, W.litElementHydrateSupport?.({ LitElement: G });
|
|
504
507
|
var ye = W.litElementPolyfillSupport;
|
|
505
508
|
ye?.({ LitElement: G }), (W.litElementVersions ??= []).push("4.2.1");
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region ../node_modules/.pnpm/@lit+reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js
|
|
506
511
|
var be = {
|
|
507
512
|
attribute: !0,
|
|
508
513
|
type: String,
|
|
@@ -511,7 +516,7 @@ var be = {
|
|
|
511
516
|
hasChanged: g
|
|
512
517
|
}, xe = (e = be, t, n) => {
|
|
513
518
|
let { kind: r, metadata: i } = n, a = globalThis.litPropertyMetadata.get(i);
|
|
514
|
-
if (a === void 0 && globalThis.litPropertyMetadata.set(i, a = new Map()), r === "setter" && ((e = Object.create(e)).wrapped = !0), a.set(n.name, e), r === "accessor") {
|
|
519
|
+
if (a === void 0 && globalThis.litPropertyMetadata.set(i, a = /* @__PURE__ */ new Map()), r === "setter" && ((e = Object.create(e)).wrapped = !0), a.set(n.name, e), r === "accessor") {
|
|
515
520
|
let { name: r } = n;
|
|
516
521
|
return {
|
|
517
522
|
set(n) {
|
|
@@ -538,6 +543,8 @@ function K(e) {
|
|
|
538
543
|
return t.constructor.createProperty(n, e), r ? Object.getOwnPropertyDescriptor(t, n) : void 0;
|
|
539
544
|
})(e, t, n);
|
|
540
545
|
}
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region ../node_modules/.pnpm/@lit+reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js
|
|
541
548
|
function q(e) {
|
|
542
549
|
return K({
|
|
543
550
|
...e,
|
|
@@ -545,6 +552,8 @@ function q(e) {
|
|
|
545
552
|
attribute: !1
|
|
546
553
|
});
|
|
547
554
|
}
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region ../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directive.js
|
|
548
557
|
var Se = {
|
|
549
558
|
ATTRIBUTE: 1,
|
|
550
559
|
CHILD: 2,
|
|
@@ -589,10 +598,16 @@ var Se = {
|
|
|
589
598
|
};
|
|
590
599
|
J.directiveName = "unsafeHTML", J.resultType = 1;
|
|
591
600
|
var Y = Ce(J);
|
|
601
|
+
//#endregion
|
|
602
|
+
//#region ../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/when.js
|
|
592
603
|
function X(e, t, n) {
|
|
593
604
|
return e ? t(e) : n?.(e);
|
|
594
605
|
}
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/styles/shiki.css?inline
|
|
595
608
|
var Te = ".shiki{color-scheme:var(--shiki-theme-type,light);padding:.875em;overflow-x:auto}code{z-index:0;width:max-content;min-width:100%;font-size:var(--font-size,.875em);counter-reset:step;counter-increment:step 0;display:block;position:relative}code .line:before{content:counter(step);counter-increment:step;text-align:right;color:#738a9480;width:1rem;margin-right:1.5rem;display:inline-block}code .line:last-child:empty{display:none}code .line:last-child:has(>span:empty:only-child){display:none}.has-diff .diff,.has-highlighted .highlighted{width:100%;display:inline-block;position:relative}.has-diff .diff.remove:before{content:\"-\"}.has-diff .diff.add:before{content:\"+\"}.has-diff .diff.remove:after{content:\"\";z-index:-1;background:#ef444426;border-left:1px solid #ef4444cc;position:absolute;inset:0 -.875em}.has-diff .diff.add:after{content:\"\";z-index:-1;background:#22c55e26;border-left:1px solid #22c55ecc;position:absolute;inset:0 -.875em}.has-focused .line:not(.focused){opacity:.7;filter:blur(.095rem);transition:filter .35s,opacity .35s}.has-focused:hover .line:not(.focused){opacity:1;filter:blur()}.has-highlighted .highlighted:after{content:\"\";z-index:-1;background:#65758529;border-left:1px solid #22c55ecc;position:absolute;inset:0 -.875em}.has-highlighted .highlighted.error:after{background:#f43f5e29!important;border-left:1px solid #f43f5ecc!important}.has-highlighted .highlighted.warning:after{background:#eab30829!important;border-left:1px solid #eab308cc!important}.has-highlighted .highlighted.info:after{background:#65758529!important;border-left:1px solid #657585cc!important}:host([color-scheme=dark]) .shiki,:host([color-scheme=dark]) .shiki span{color:var(--shiki-dark)!important}:host([color-scheme=dark]) .shiki{background-color:var(--shiki-dark-bg)!important}";
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/utils/copy-to-clipboard.ts
|
|
596
611
|
function Ee(e, t) {
|
|
597
612
|
if (navigator.clipboard) navigator.clipboard.writeText(e).then(() => {
|
|
598
613
|
t();
|
|
@@ -608,12 +623,16 @@ function Ee(e, t) {
|
|
|
608
623
|
document.body.removeChild(n);
|
|
609
624
|
}
|
|
610
625
|
}
|
|
626
|
+
//#endregion
|
|
627
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
611
628
|
function Z(e, t, n, r) {
|
|
612
629
|
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
613
630
|
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
614
631
|
else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
|
|
615
632
|
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
616
633
|
}
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region src/variants/base.ts
|
|
617
636
|
var Q = class extends G {
|
|
618
637
|
constructor(...e) {
|
|
619
638
|
super(...e), this.options = {
|
|
@@ -637,6 +656,8 @@ var Q = class extends G {
|
|
|
637
656
|
}
|
|
638
657
|
};
|
|
639
658
|
Z([K({ type: Object })], Q.prototype, "options", void 0), Z([q()], Q.prototype, "copied", void 0);
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/variants/simple.ts
|
|
640
661
|
var De = class extends Q {
|
|
641
662
|
render() {
|
|
642
663
|
return P`
|
|
@@ -699,6 +720,8 @@ var De = class extends Q {
|
|
|
699
720
|
}
|
|
700
721
|
};
|
|
701
722
|
customElements.get("shiki-code-simple-variant") || customElements.define("shiki-code-simple-variant", De);
|
|
723
|
+
//#endregion
|
|
724
|
+
//#region src/variants/mac.ts
|
|
702
725
|
var Oe = class extends Q {
|
|
703
726
|
constructor(...e) {
|
|
704
727
|
super(...e), this.fold = !1;
|
|
@@ -782,6 +805,8 @@ var Oe = class extends Q {
|
|
|
782
805
|
}
|
|
783
806
|
};
|
|
784
807
|
Z([q()], Oe.prototype, "fold", void 0), customElements.get("shiki-code-mac-variant") || customElements.define("shiki-code-mac-variant", Oe);
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/shiki-code.ts
|
|
785
810
|
var $ = class extends G {
|
|
786
811
|
constructor(...e) {
|
|
787
812
|
super(...e), this.lightTheme = "github-light", this.darkTheme = "github-dark", this.variant = "simple", this.fontSize = "0.875em", this.loading = !0, this.html = "", this.languageCode = "", this.languageName = "", this.lightThemeRegistration = null, this.darkThemeRegistration = null, this.code = "", this.copied = !1, this.error = "", this._observer = null, this._media = null, this._colorScheme = "light";
|
|
@@ -835,9 +860,15 @@ var $ = class extends G {
|
|
|
835
860
|
}
|
|
836
861
|
async process(e) {
|
|
837
862
|
try {
|
|
838
|
-
this.languageCode = this.extractLanguageCode(e.classList) || "plaintext", this.languageCode === "auto" && (this.languageCode = "plaintext"), this.languageCode === "text" && (this.languageCode = "plaintext"), this.code = e.textContent || ""
|
|
839
|
-
let
|
|
840
|
-
this.
|
|
863
|
+
this.languageCode = this.extractLanguageCode(e.classList) || "plaintext", this.languageCode === "auto" && (this.languageCode = "plaintext"), this.languageCode === "text" && (this.languageCode = "plaintext"), this.code = e.textContent || "";
|
|
864
|
+
let t = await this.renderCodeAsHtml(this.code || "", this.languageCode);
|
|
865
|
+
this.html = t;
|
|
866
|
+
let { getSingletonHighlighter: n } = await import("shiki"), r = await n();
|
|
867
|
+
if (this.languageCode !== "plaintext") {
|
|
868
|
+
let e = r.getLanguage(this.languageCode);
|
|
869
|
+
this.languageName = e.name;
|
|
870
|
+
} else this.languageName = "plaintext";
|
|
871
|
+
this.lightThemeRegistration = r.getTheme(this.lightTheme), this.darkThemeRegistration = r.getTheme(this.darkTheme || this.lightTheme);
|
|
841
872
|
} catch (e) {
|
|
842
873
|
e instanceof Error && (this.error = e.message);
|
|
843
874
|
} finally {
|
|
@@ -902,4 +933,5 @@ Z([K({
|
|
|
902
933
|
type: String,
|
|
903
934
|
attribute: "font-size"
|
|
904
935
|
})], $.prototype, "fontSize", void 0), Z([q()], $.prototype, "loading", void 0), Z([q()], $.prototype, "html", void 0), Z([q()], $.prototype, "languageCode", void 0), Z([q()], $.prototype, "languageName", void 0), Z([q()], $.prototype, "lightThemeRegistration", void 0), Z([q()], $.prototype, "darkThemeRegistration", void 0), Z([q()], $.prototype, "code", void 0), Z([q()], $.prototype, "copied", void 0), Z([q()], $.prototype, "error", void 0), Z([q()], $.prototype, "_colorScheme", void 0), customElements.get("shiki-code") || customElements.define("shiki-code", $);
|
|
936
|
+
//#endregion
|
|
905
937
|
export { $ as ShikiCode };
|