juxscript 1.1.47 → 1.1.48
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeparser.d.ts","sourceRoot":"","sources":["codeparser.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqClD,CAAC;AAEF,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,UAAU;IACnB,OAAO,CAAC,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"codeparser.d.ts","sourceRoot":"","sources":["codeparser.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqClD,CAAC;AAEF,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,UAAU;IACnB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAwC;IAE7D;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAqB,GAAG,UAAU,EAAE;IAiBzE,OAAO,CAAC,MAAM,CAAC,UAAU;IA6FzB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAcpC;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,IAAI;CAK5B;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAUhD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAS/C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAiCnE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAmB9C;AAID;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;CAQtB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/lib/utils/codeparser.js
CHANGED
|
@@ -41,6 +41,10 @@ export class CodeParser {
|
|
|
41
41
|
* Parse code with caching
|
|
42
42
|
*/
|
|
43
43
|
static parse(code, language = 'javascript') {
|
|
44
|
+
// ✅ Guard against undefined cache
|
|
45
|
+
if (!this._cache) {
|
|
46
|
+
this._cache = new Map();
|
|
47
|
+
}
|
|
44
48
|
const cacheKey = `${language}:${code}`;
|
|
45
49
|
if (this._cache.has(cacheKey)) {
|
|
46
50
|
return this._cache.get(cacheKey);
|
|
@@ -151,10 +155,12 @@ export class CodeParser {
|
|
|
151
155
|
* Clear cache (useful for development)
|
|
152
156
|
*/
|
|
153
157
|
static clearCache() {
|
|
154
|
-
this._cache
|
|
158
|
+
if (this._cache) {
|
|
159
|
+
this._cache.clear();
|
|
160
|
+
}
|
|
155
161
|
}
|
|
156
162
|
}
|
|
157
|
-
CodeParser._cache = new Map();
|
|
163
|
+
CodeParser._cache = new Map(); // ✅ Initialize inline
|
|
158
164
|
/**
|
|
159
165
|
* Get CSS class for a token
|
|
160
166
|
*/
|
package/lib/utils/codeparser.ts
CHANGED
|
@@ -59,12 +59,17 @@ export interface ParsedLine {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export class CodeParser {
|
|
62
|
-
private static _cache
|
|
62
|
+
private static _cache: Map<string, ParsedLine[]> = new Map(); // ✅ Initialize inline
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Parse code with caching
|
|
66
66
|
*/
|
|
67
67
|
static parse(code: string, language: string = 'javascript'): ParsedLine[] {
|
|
68
|
+
// ✅ Guard against undefined cache
|
|
69
|
+
if (!this._cache) {
|
|
70
|
+
this._cache = new Map();
|
|
71
|
+
}
|
|
72
|
+
|
|
68
73
|
const cacheKey = `${language}:${code}`;
|
|
69
74
|
|
|
70
75
|
if (this._cache.has(cacheKey)) {
|
|
@@ -191,7 +196,9 @@ export class CodeParser {
|
|
|
191
196
|
* Clear cache (useful for development)
|
|
192
197
|
*/
|
|
193
198
|
static clearCache(): void {
|
|
194
|
-
this._cache
|
|
199
|
+
if (this._cache) {
|
|
200
|
+
this._cache.clear();
|
|
201
|
+
}
|
|
195
202
|
}
|
|
196
203
|
}
|
|
197
204
|
|