juxscript 1.1.49 → 1.1.51

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":"code.d.ts","sourceRoot":"","sources":["code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAOxD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,SAAS,GAAG;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,IAAK,SAAQ,aAAa,CAAC,SAAS,CAAC;IAChD,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAS;gBAE9B,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IAYjD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAIhD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAsBtC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IA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AA4B;IAClD,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAS;gBAE9B,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IAYjD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAIhD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAsBtC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAKrC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK9B,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IASrC;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,aAAa;IAoBrB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA0B1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAezB,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;CA4EnE;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAEhE"}
@@ -149,9 +149,8 @@ export class Code extends BaseComponent {
149
149
  wrapper.className += ` ${className}`;
150
150
  if (style)
151
151
  wrapper.setAttribute('style', style);
152
- const pre = document.createElement('pre');
153
- pre.className = `language-${language}`;
154
- const codeEl = document.createElement('code');
152
+ // ✅ Remove <pre>, just use a div with code styling
153
+ const codeEl = document.createElement('div');
155
154
  codeEl.className = 'jux-code-lines';
156
155
  // Build initial lines with parsed tokens
157
156
  const parsedLines = this._parseLines();
@@ -162,8 +161,7 @@ export class Code extends BaseComponent {
162
161
  const lineEl = this._createLineElement(parsedLine, lineNumber, isHighlighted);
163
162
  codeEl.appendChild(lineEl);
164
163
  });
165
- pre.appendChild(codeEl);
166
- wrapper.appendChild(pre);
164
+ wrapper.appendChild(codeEl);
167
165
  this._wireStandardEvents(wrapper);
168
166
  // Wire sync bindings
169
167
  this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
@@ -180,7 +178,6 @@ export class Code extends BaseComponent {
180
178
  stateObj.subscribe((val) => {
181
179
  const transformed = transform(val);
182
180
  this.state.language = transformed;
183
- pre.className = `language-${transformed}`;
184
181
  this._rebuildLines();
185
182
  });
186
183
  }
@@ -198,10 +198,8 @@ export class Code extends BaseComponent<CodeState> {
198
198
  if (className) wrapper.className += ` ${className}`;
199
199
  if (style) wrapper.setAttribute('style', style);
200
200
 
201
- const pre = document.createElement('pre');
202
- pre.className = `language-${language}`;
203
-
204
- const codeEl = document.createElement('code');
201
+ // ✅ Remove <pre>, just use a div with code styling
202
+ const codeEl = document.createElement('div');
205
203
  codeEl.className = 'jux-code-lines';
206
204
 
207
205
  // Build initial lines with parsed tokens
@@ -215,8 +213,7 @@ export class Code extends BaseComponent<CodeState> {
215
213
  codeEl.appendChild(lineEl);
216
214
  });
217
215
 
218
- pre.appendChild(codeEl);
219
- wrapper.appendChild(pre);
216
+ wrapper.appendChild(codeEl);
220
217
 
221
218
  this._wireStandardEvents(wrapper);
222
219
 
@@ -237,7 +234,6 @@ export class Code extends BaseComponent<CodeState> {
237
234
  stateObj.subscribe((val: any) => {
238
235
  const transformed = transform(val);
239
236
  this.state.language = transformed;
240
- pre.className = `language-${transformed}`;
241
237
  this._rebuildLines();
242
238
  });
243
239
  }
@@ -3,6 +3,10 @@ export interface ParsedLine {
3
3
  html: string;
4
4
  raw: string;
5
5
  }
6
+ /**
7
+ * Escape HTML entities
8
+ */
9
+ declare function escapeHtml(text: string): string;
6
10
  /**
7
11
  * Parse code into lines with simple syntax highlighting
8
12
  */
@@ -11,10 +15,6 @@ export declare function parseCode(code: string, language?: string): ParsedLine[]
11
15
  * Render a parsed line (just returns the pre-generated HTML)
12
16
  */
13
17
  export declare function renderLineWithTokens(parsedLine: ParsedLine): string;
14
- /**
15
- * Escape HTML entities
16
- */
17
- declare function escapeHtml(text: string): string;
18
18
  /**
19
19
  * Generate CSS for syntax highlighting
20
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"codeparser.d.ts","sourceRoot":"","sources":["codeparser.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,UAAU;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAqB,GAAG,UAAU,EAAE,CAQrF;AAqCD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAEnE;AAED;;GAEG;AACH,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOxC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAsE9C;AAED;;GAEG;;;;;;;AACH,wBAKE"}
1
+ {"version":3,"file":"codeparser.d.ts","sourceRoot":"","sources":["codeparser.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,UAAU;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOxC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAqB,GAAG,UAAU,EAAE,CAQrF;AAsCD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAEnE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAiE9C;AAED;;GAEG;;;;;;;AACH,wBAKE"}
@@ -9,6 +9,17 @@ const KEYWORDS = new Set([
9
9
  'typeof', 'var', 'void', 'while', 'with', 'yield', 'from', 'of',
10
10
  'static', 'get', 'set', 'as', 'interface', 'type', 'enum', 'namespace'
11
11
  ]);
12
+ /**
13
+ * Escape HTML entities
14
+ */
15
+ function escapeHtml(text) {
16
+ return text
17
+ .replace(/&/g, '&amp;')
18
+ .replace(/</g, '&lt;')
19
+ .replace(/>/g, '&gt;')
20
+ .replace(/"/g, '&quot;')
21
+ .replace(/'/g, '&#39;');
22
+ }
12
23
  /**
13
24
  * Parse code into lines with simple syntax highlighting
14
25
  */
@@ -26,26 +37,26 @@ export function parseCode(code, language = 'javascript') {
26
37
  function highlightLine(line) {
27
38
  if (!line.trim())
28
39
  return ' ';
29
- let result = line;
30
- // 1. Comments (do first to avoid highlighting keywords in comments)
31
- result = result.replace(/(\/\/.*$)/g, '<span class="token-comment">$1</span>');
32
- result = result.replace(/(\/\*[\s\S]*?\*\/)/g, '<span class="token-comment">$1</span>');
33
- // 2. Strings (avoid highlighting keywords in strings)
34
- result = result.replace(/(['"`])(?:(?=(\\?))\2.)*?\1/g, (match) => {
35
- return `<span class="token-string">${escapeHtml(match)}</span>`;
36
- });
40
+ // Escape the raw line first
41
+ let escaped = escapeHtml(line);
42
+ // Now add spans (on already-escaped text)
43
+ // 1. Comments
44
+ escaped = escaped.replace(/(\/\/.*$)/g, '<span class="token-comment">$1</span>');
45
+ escaped = escaped.replace(/(\/\*[\s\S]*?\*\/)/g, '<span class="token-comment">$1</span>');
46
+ // 2. Strings (already escaped, so look for &quot; etc)
47
+ escaped = escaped.replace(/(&quot;[^&]*?&quot;|&#39;[^&]*?&#39;|`[^`]*?`)/g, '<span class="token-string">$1</span>');
37
48
  // 3. Numbers
38
- result = result.replace(/\b(\d+\.?\d*)\b/g, '<span class="token-number">$1</span>');
49
+ escaped = escaped.replace(/\b(\d+\.?\d*)\b/g, '<span class="token-number">$1</span>');
39
50
  // 4. Keywords (only whole words)
40
51
  KEYWORDS.forEach(keyword => {
41
52
  const regex = new RegExp(`\\b(${keyword})\\b`, 'g');
42
- result = result.replace(regex, '<span class="token-keyword">$1</span>');
53
+ escaped = escaped.replace(regex, '<span class="token-keyword">$1</span>');
43
54
  });
44
- // 5. Braces, brackets, parentheses
45
- result = result.replace(/([{}[\]()])/g, '<span class="token-punctuation">$1</span>');
55
+ // 5. Braces, brackets, parentheses (these are plain text, not escaped)
56
+ escaped = escaped.replace(/([{}[\]()])/g, '<span class="token-punctuation">$1</span>');
46
57
  // 6. Operators
47
- result = result.replace(/([+\-*/%=<>!&|^~?:])/g, '<span class="token-operator">$1</span>');
48
- return result || ' ';
58
+ escaped = escaped.replace(/([+\-*/%=&lt;&gt;!&|^~?:])/g, '<span class="token-operator">$1</span>');
59
+ return escaped || ' ';
49
60
  }
50
61
  /**
51
62
  * Render a parsed line (just returns the pre-generated HTML)
@@ -53,17 +64,6 @@ function highlightLine(line) {
53
64
  export function renderLineWithTokens(parsedLine) {
54
65
  return parsedLine.html;
55
66
  }
56
- /**
57
- * Escape HTML entities
58
- */
59
- function escapeHtml(text) {
60
- return text
61
- .replace(/&/g, '&amp;')
62
- .replace(/</g, '&lt;')
63
- .replace(/>/g, '&gt;')
64
- .replace(/"/g, '&quot;')
65
- .replace(/'/g, '&#39;');
66
- }
67
67
  /**
68
68
  * Generate CSS for syntax highlighting
69
69
  */
@@ -78,13 +78,8 @@ export function getSyntaxHighlightCSS() {
78
78
  border-radius: 8px;
79
79
  overflow: hidden;
80
80
  margin: 1rem 0;
81
- }
82
-
83
- .jux-code pre {
84
- margin: 0;
85
81
  padding: 1rem;
86
82
  overflow-x: auto;
87
- background: transparent;
88
83
  }
89
84
 
90
85
  .jux-code-lines {
@@ -16,6 +16,18 @@ export interface ParsedLine {
16
16
  raw: string;
17
17
  }
18
18
 
19
+ /**
20
+ * Escape HTML entities
21
+ */
22
+ function escapeHtml(text: string): string {
23
+ return text
24
+ .replace(/&/g, '&amp;')
25
+ .replace(/</g, '&lt;')
26
+ .replace(/>/g, '&gt;')
27
+ .replace(/"/g, '&quot;')
28
+ .replace(/'/g, '&#39;');
29
+ }
30
+
19
31
  /**
20
32
  * Parse code into lines with simple syntax highlighting
21
33
  */
@@ -35,33 +47,34 @@ export function parseCode(code: string, language: string = 'javascript'): Parsed
35
47
  function highlightLine(line: string): string {
36
48
  if (!line.trim()) return ' ';
37
49
 
38
- let result = line;
50
+ // Escape the raw line first
51
+ let escaped = escapeHtml(line);
39
52
 
40
- // 1. Comments (do first to avoid highlighting keywords in comments)
41
- result = result.replace(/(\/\/.*$)/g, '<span class="token-comment">$1</span>');
42
- result = result.replace(/(\/\*[\s\S]*?\*\/)/g, '<span class="token-comment">$1</span>');
53
+ // Now add spans (on already-escaped text)
43
54
 
44
- // 2. Strings (avoid highlighting keywords in strings)
45
- result = result.replace(/(['"`])(?:(?=(\\?))\2.)*?\1/g, (match) => {
46
- return `<span class="token-string">${escapeHtml(match)}</span>`;
47
- });
55
+ // 1. Comments
56
+ escaped = escaped.replace(/(\/\/.*$)/g, '<span class="token-comment">$1</span>');
57
+ escaped = escaped.replace(/(\/\*[\s\S]*?\*\/)/g, '<span class="token-comment">$1</span>');
58
+
59
+ // 2. Strings (already escaped, so look for &quot; etc)
60
+ escaped = escaped.replace(/(&quot;[^&]*?&quot;|&#39;[^&]*?&#39;|`[^`]*?`)/g, '<span class="token-string">$1</span>');
48
61
 
49
62
  // 3. Numbers
50
- result = result.replace(/\b(\d+\.?\d*)\b/g, '<span class="token-number">$1</span>');
63
+ escaped = escaped.replace(/\b(\d+\.?\d*)\b/g, '<span class="token-number">$1</span>');
51
64
 
52
65
  // 4. Keywords (only whole words)
53
66
  KEYWORDS.forEach(keyword => {
54
67
  const regex = new RegExp(`\\b(${keyword})\\b`, 'g');
55
- result = result.replace(regex, '<span class="token-keyword">$1</span>');
68
+ escaped = escaped.replace(regex, '<span class="token-keyword">$1</span>');
56
69
  });
57
70
 
58
- // 5. Braces, brackets, parentheses
59
- result = result.replace(/([{}[\]()])/g, '<span class="token-punctuation">$1</span>');
71
+ // 5. Braces, brackets, parentheses (these are plain text, not escaped)
72
+ escaped = escaped.replace(/([{}[\]()])/g, '<span class="token-punctuation">$1</span>');
60
73
 
61
74
  // 6. Operators
62
- result = result.replace(/([+\-*/%=<>!&|^~?:])/g, '<span class="token-operator">$1</span>');
75
+ escaped = escaped.replace(/([+\-*/%=&lt;&gt;!&|^~?:])/g, '<span class="token-operator">$1</span>');
63
76
 
64
- return result || ' ';
77
+ return escaped || ' ';
65
78
  }
66
79
 
67
80
  /**
@@ -71,18 +84,6 @@ export function renderLineWithTokens(parsedLine: ParsedLine): string {
71
84
  return parsedLine.html;
72
85
  }
73
86
 
74
- /**
75
- * Escape HTML entities
76
- */
77
- function escapeHtml(text: string): string {
78
- return text
79
- .replace(/&/g, '&amp;')
80
- .replace(/</g, '&lt;')
81
- .replace(/>/g, '&gt;')
82
- .replace(/"/g, '&quot;')
83
- .replace(/'/g, '&#39;');
84
- }
85
-
86
87
  /**
87
88
  * Generate CSS for syntax highlighting
88
89
  */
@@ -97,13 +98,8 @@ export function getSyntaxHighlightCSS(): string {
97
98
  border-radius: 8px;
98
99
  overflow: hidden;
99
100
  margin: 1rem 0;
100
- }
101
-
102
- .jux-code pre {
103
- margin: 0;
104
101
  padding: 1rem;
105
102
  overflow-x: auto;
106
- background: transparent;
107
103
  }
108
104
 
109
105
  .jux-code-lines {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.1.49",
3
+ "version": "1.1.51",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "index.js",