juxscript 1.1.317 → 1.1.319

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":"tag.d.ts","sourceRoot":"","sources":["../../../lib/components/tag.ts"],"names":[],"mappings":"AAIA,UAAU,UAAU;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,cAAM,GAAG;IACL,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe;IAOjE,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAC5B,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAC1B,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAG1B,QAAQ,IAAI,MAAM;IAClB,UAAU,IAAI,MAAM;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC3B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC3B,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAE/B,UAAU,IAAI,WAAW,GAAG,IAAI;IAEhC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW;CAuBvC;AAED,wBAAgB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAA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AAE,UAAe,OAAqC;AAC7F,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,OAAoC;AAC3F,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,OAAoC;AAC3F,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,OAAoC;AAC3F,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,OAAoC;AAC3F,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,OAAoC;AAC3F,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,OAAoC;AAE3F,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC;AAC3B,eAAe,GAAG,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import generateId from '../utils/idgen.js';
2
2
  import { pageState } from '../state/pageState.js';
3
- import highlightCode from '../utils/codeHighlight.js';
3
+ import codeparser from '../utils/codeparser.js';
4
4
  class Tag {
5
5
  constructor(id, tagName, options = {}) {
6
6
  this._element = null;
@@ -66,35 +66,16 @@ export function code(id, options = {}) {
66
66
  if (!document.getElementById('__jux-hl-styles')) {
67
67
  const style = document.createElement('style');
68
68
  style.id = '__jux-hl-styles';
69
- style.textContent = `
70
- .jux-code {
71
- display: block;
72
- background: hsl(var(--muted, 0 0% 96%));
73
- border: 1px solid hsl(var(--border, 0 0% 89.8%));
74
- border-radius: var(--radius, 6px);
75
- padding: 12px 16px;
76
- font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
77
- font-size: 13px;
78
- line-height: 1.5;
79
- overflow-x: auto;
80
- white-space: pre;
81
- tab-size: 2;
82
- }
83
- .jux-hl-keyword { color: hsl(var(--primary, 262 83% 58%)); font-weight: 600; }
84
- .jux-hl-string { color: hsl(142 71% 45%); }
85
- .jux-hl-number { color: hsl(25 95% 53%); }
86
- .jux-hl-comment { color: hsl(var(--muted-foreground, 0 0% 45%)); font-style: italic; }
87
- .jux-hl-fn { color: hsl(221 83% 53%); }
88
- .jux-hl-punct { color: hsl(var(--muted-foreground, 0 0% 45%)); }
89
- .jux-hl-ident { color: hsl(var(--foreground, 0 0% 9%)); }
90
- `;
69
+ style.textContent = codeparser.getCSS();
91
70
  document.head.appendChild(style);
92
71
  }
93
- // Highlight content and render as innerHTML
72
+ // Parse and highlight content
94
73
  const raw = options.content || '';
95
74
  const trimmed = raw.replace(/^\n+/, '').replace(/\n+$/, '');
96
- const highlighted = highlightCode(trimmed);
97
- // Create as <pre><code> for proper formatting
75
+ const parsed = codeparser.parse(trimmed);
76
+ // Build line-by-line HTML
77
+ const linesHtml = parsed.map(line => `<div class="jux-code-line"><span class="jux-code-line-number">${line.lineNumber}</span><span class="jux-code-line-content">${line.html}</span></div>`).join('');
78
+ // Create as <pre> with inner code structure
98
79
  const t = new Tag(id, 'pre', {
99
80
  ...options,
100
81
  content: undefined,
@@ -104,7 +85,8 @@ export function code(id, options = {}) {
104
85
  const el = t.getElement();
105
86
  if (el) {
106
87
  const codeEl = document.createElement('code');
107
- codeEl.innerHTML = highlighted;
88
+ codeEl.className = 'jux-code-lines';
89
+ codeEl.innerHTML = linesHtml;
108
90
  el.appendChild(codeEl);
109
91
  }
110
92
  pageState.__register(t);
@@ -1 +1 @@
1
- {"version":3,"file":"codeparser.d.ts","sourceRoot":"","sources":["../../../lib/utils/codeparser.ts"],"names":[],"mappings":"AA2DA,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;AAwOD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAEnE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAkG9C;;;;;;;AAED,wBAKE"}
1
+ {"version":3,"file":"codeparser.d.ts","sourceRoot":"","sources":["../../../lib/utils/codeparser.ts"],"names":[],"mappings":"AA2DA,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;AAuPD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAEnE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAwD9C;;;;;;;AAED,wBAKE"}
@@ -225,7 +225,16 @@ function tokenizeLine(line) {
225
225
  result += `<span class="${tokenClass}">${escaped}</span>`;
226
226
  }
227
227
  else {
228
- result += escaped;
228
+ // Check if it's a function call
229
+ let k = i + word.length;
230
+ while (k < len && line[k] === ' ')
231
+ k++;
232
+ if (line[k] === '(') {
233
+ result += `<span class="token-function">${escaped}</span>`;
234
+ }
235
+ else {
236
+ result += `<span class="token-identifier">${escaped}</span>`;
237
+ }
229
238
  }
230
239
  i += word.length;
231
240
  continue;
@@ -237,6 +246,13 @@ function tokenizeLine(line) {
237
246
  i += num.length;
238
247
  continue;
239
248
  }
249
+ // Dot/spread
250
+ if (char === '.') {
251
+ const op = consumeOperator(line, i);
252
+ result += `<span class="token-operator">${escapeHtml(op)}</span>`;
253
+ i += op.length;
254
+ continue;
255
+ }
240
256
  // Operators (multi-char)
241
257
  if (isOperator(char)) {
242
258
  const op = consumeOperator(line, i);
@@ -306,100 +322,58 @@ export function getSyntaxHighlightCSS() {
306
322
  return `
307
323
  /* Semantic Code Highlighting */
308
324
  .jux-code {
309
- font-family: 'Consolas', 'Monaco', monospace;
310
- font-size: 14px;
325
+ font-family: 'Consolas', 'Monaco', 'SF Mono', 'Fira Code', monospace;
326
+ font-size: 13px;
311
327
  line-height: 1.6;
312
328
  background: #1e1e1e;
329
+ color: #d4d4d4;
313
330
  border-radius: 8px;
314
331
  overflow: hidden;
315
- margin: 1rem 0;
332
+ margin: 0.5rem 0;
316
333
  padding: 1rem;
317
334
  overflow-x: auto;
318
335
  }
319
-
320
336
  .jux-code-lines {
321
337
  display: block;
322
338
  }
323
-
324
339
  .jux-code-line {
325
340
  display: flex;
326
341
  align-items: flex-start;
327
342
  min-height: 1.6em;
328
343
  }
329
-
330
344
  .jux-code-line:hover {
331
345
  background-color: rgba(255, 255, 255, 0.03);
332
346
  }
333
-
334
- .jux-code-line-highlight {
335
- background-color: rgba(255, 215, 0, 0.1);
336
- border-left: 3px solid #ffd700;
337
- padding-left: 0.5rem;
338
- }
339
-
340
347
  .jux-code-line-number {
341
348
  display: inline-block;
342
- min-width: 3rem;
349
+ min-width: 2.5rem;
343
350
  text-align: right;
344
351
  padding-right: 1rem;
345
- color: #858585;
352
+ color: #555;
346
353
  user-select: none;
347
354
  flex-shrink: 0;
348
355
  }
349
-
350
356
  .jux-code-line-content {
351
357
  flex: 1;
352
358
  color: #d4d4d4;
353
359
  white-space: pre;
354
- overflow-x: auto;
355
- }
356
-
357
- .jux-code-no-numbers .jux-code-line-number {
358
- display: none;
359
360
  }
360
361
 
361
- /* Token colors - Semantic categories */
362
- .token-control {
363
- color: #c678dd; /* Purple - control flow (if, for, return) */
364
- font-weight: 600;
365
- }
366
- .token-declaration {
367
- color: #61afef; /* Blue - declarations (const, let, function) */
368
- font-weight: 600;
369
- }
370
- .token-operator-keyword {
371
- color: #e06c75; /* Red - operator keywords (typeof, instanceof) */
372
- font-weight: 600;
373
- }
374
- .token-special {
375
- color: #e5c07b; /* Yellow - special keywords (this, super, async) */
376
- font-weight: 600;
377
- }
378
- .token-jux {
379
- color: #56b6c2; /* Cyan - JUX-specific (jux, state, render) */
380
- font-weight: 700;
381
- }
382
- .token-number {
383
- color: #d19a66; /* Orange - numbers */
384
- }
385
- .token-string {
386
- color: #98c379; /* Green - strings */
387
- }
388
- .token-comment {
389
- color: #5c6370; /* Gray - comments */
390
- font-style: italic;
391
- }
392
- .token-structural {
393
- color: #abb2bf; /* Light gray - braces, brackets, parens */
394
- font-weight: 600;
395
- }
396
- .token-delimiter {
397
- color: #777; /* Dark gray - semicolons, commas, colons */
398
- }
399
- .token-operator {
400
- color: #56b6c2; /* Cyan - operators (+, -, *, etc.) */
401
- }
402
- `;
362
+ /* Semantic token colors One Dark inspired */
363
+ .token-control { color: #c678dd; font-weight: 600; }
364
+ .token-declaration { color: #61afef; font-weight: 600; }
365
+ .token-operator-keyword { color: #e06c75; font-weight: 600; }
366
+ .token-special { color: #e5c07b; font-weight: 600; }
367
+ .token-jux { color: #56b6c2; font-weight: 700; }
368
+ .token-number { color: #d19a66; }
369
+ .token-string { color: #98c379; }
370
+ .token-comment { color: #5c6370; font-style: italic; }
371
+ .token-function { color: #61afef; }
372
+ .token-identifier { color: #e06c75; }
373
+ .token-structural { color: #abb2bf; font-weight: 600; }
374
+ .token-delimiter { color: #777; }
375
+ .token-operator { color: #56b6c2; }
376
+ `;
403
377
  }
404
378
  export default {
405
379
  parse: parseCode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.1.317",
3
+ "version": "1.1.319",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "./dist/lib/index.js",