@youtyan/code-viewer 0.8.8 → 0.8.9

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/README.md CHANGED
@@ -152,7 +152,9 @@ A file detail page lays out up to four tabs — **Preview**, **Code**,
152
152
  preview. Media files (images, video, audio, PDF) show a **Preview** tab only
153
153
  — there is no Code tab for binary media. `Blame` and `History` each have
154
154
  their own canonical URL (`view=blame`, `view=history`), so deep links and
155
- the browser back/forward stay in sync. The Blame tab reuses the source
155
+ the browser back/forward stay in sync. Opening another file from the
156
+ repository tree keeps the active tab (a file that cannot be previewed falls
157
+ back to Code). The Blame tab reuses the source
156
158
  view's row component, so line numbers, drag-selection of `line=` ranges,
157
159
  syntax highlighting and the Viewer Settings code font size all match the
158
160
  Code tab.
@@ -12956,7 +12956,8 @@ var init_source_meta = __esm(() => {
12956
12956
  cts: "typescript",
12957
12957
  kts: "kotlin",
12958
12958
  cxx: "cpp",
12959
- hxx: "cpp"
12959
+ hxx: "cpp",
12960
+ gd: "gdscript"
12960
12961
  };
12961
12962
  TEXT_SOURCE_EXTENSIONS = new Set([
12962
12963
  ...Object.keys(EXT_TO_LANG),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youtyan/code-viewer",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "description": "Local browser-based code and git diff viewer",
5
5
  "type": "module",
6
6
  "bin": {
package/web/app.js CHANGED
@@ -445,15 +445,47 @@ ${lines.join(`
445
445
  ]
446
446
  };
447
447
  }
448
- function ensureTerraformHighlightLanguage(hljsRef) {
448
+ function gdscriptLanguageDefinition(hljs) {
449
+ const api = hljs;
450
+ return {
451
+ name: "GDScript",
452
+ aliases: ["gd"],
453
+ keywords: {
454
+ keyword: "and as assert await break breakpoint class class_name const continue elif else enum extends for func if in is match not or pass return self signal static super var void when while yield",
455
+ literal: "true false null PI TAU INF NAN",
456
+ built_in: "print printerr printraw print_rich print_debug push_error push_warning preload load range len abs absf absi sign floor ceil round clamp clampf clampi lerp lerpf min max pow sqrt randf randi randf_range randi_range randomize str int float bool typeof type_exists is_instance_valid Vector2 Vector2i Vector3 Vector3i Vector4 Vector4i Rect2 Rect2i Transform2D Transform3D Basis Quaternion Plane AABB Color NodePath StringName Callable Signal Array Dictionary PackedByteArray PackedInt32Array PackedInt64Array PackedFloat32Array PackedFloat64Array PackedStringArray PackedVector2Array PackedVector3Array PackedColorArray"
457
+ },
458
+ contains: [
459
+ lineComment(api, "#"),
460
+ {
461
+ scope: "string",
462
+ begin: '"""',
463
+ end: '"""'
464
+ },
465
+ api.QUOTE_STRING_MODE || { scope: "string", begin: '"', end: '"' },
466
+ { scope: "string", begin: "'", end: "'" },
467
+ { scope: "meta", begin: "@[A-Za-z_]\\w*" },
468
+ { scope: "symbol", begin: "[$%][A-Za-z_/][\\w/]*" },
469
+ api.NUMBER_MODE || { scope: "number", begin: "\\b\\d+(\\.\\d+)?\\b" },
470
+ { scope: "function", begin: "\\b[A-Za-z_]\\w*(?=\\()" }
471
+ ]
472
+ };
473
+ }
474
+ function ensureHighlightLanguage(hljsRef, name, definition) {
449
475
  if (!hljsRef?.registerLanguage)
450
476
  return;
451
- if (hljsRef.getLanguage?.("terraform"))
477
+ if (hljsRef.getLanguage?.(name))
452
478
  return;
453
479
  try {
454
- hljsRef.registerLanguage("terraform", terraformLanguageDefinition);
480
+ hljsRef.registerLanguage(name, definition);
455
481
  } catch {}
456
482
  }
483
+ function ensureTerraformHighlightLanguage(hljsRef) {
484
+ ensureHighlightLanguage(hljsRef, "terraform", terraformLanguageDefinition);
485
+ }
486
+ function ensureGdscriptHighlightLanguage(hljsRef) {
487
+ ensureHighlightLanguage(hljsRef, "gdscript", gdscriptLanguageDefinition);
488
+ }
457
489
 
458
490
  // web-src/core/icons.ts
459
491
  var FOLDER_ICON_PATHS = {
@@ -1314,7 +1346,8 @@ ${lines.join(`
1314
1346
  cts: "typescript",
1315
1347
  kts: "kotlin",
1316
1348
  cxx: "cpp",
1317
- hxx: "cpp"
1349
+ hxx: "cpp",
1350
+ gd: "gdscript"
1318
1351
  };
1319
1352
  var TEXT_SOURCE_EXTENSIONS = new Set([
1320
1353
  ...Object.keys(EXT_TO_LANG),
@@ -7585,6 +7618,8 @@ ${lines.join(`
7585
7618
  tf: "terraform",
7586
7619
  tfvars: "terraform",
7587
7620
  hcl: "terraform",
7621
+ gd: "gdscript",
7622
+ godot: "gdscript",
7588
7623
  yml: "yaml",
7589
7624
  ts: "typescript",
7590
7625
  tsx: "typescript",
@@ -7601,6 +7636,7 @@ ${lines.join(`
7601
7636
  "csharp",
7602
7637
  "css",
7603
7638
  "dockerfile",
7639
+ "gdscript",
7604
7640
  "go",
7605
7641
  "graphql",
7606
7642
  "html",
@@ -9799,6 +9835,24 @@ ${frontmatter.yaml}
9799
9835
  function isBlobOrBlameFileRoute(route) {
9800
9836
  return route.screen === "file" && (route.view === "blob" || route.view === "blame");
9801
9837
  }
9838
+ function fileRouteKeepingActiveView(currentRoute, target, range) {
9839
+ const base2 = {
9840
+ screen: "file",
9841
+ path: target.path,
9842
+ ref: target.ref,
9843
+ range
9844
+ };
9845
+ if (currentRoute.screen !== "file")
9846
+ return { ...base2, view: "blob" };
9847
+ if (currentRoute.view === "blame" || currentRoute.view === "history")
9848
+ return { ...base2, view: currentRoute.view };
9849
+ const keepPreview = currentRoute.view === "blob" && !!currentRoute.preview && (isPreviewableSource(target.path) || isMediaPreviewOnlySource(target.path));
9850
+ return {
9851
+ ...base2,
9852
+ view: "blob",
9853
+ ...keepPreview ? { preview: true } : {}
9854
+ };
9855
+ }
9802
9856
  function createFileViewTabButton(deps, target, view, label, active) {
9803
9857
  const btn = document.createElement("button");
9804
9858
  btn.type = "button";
@@ -26248,7 +26302,7 @@ ${entry.message}` : entry.detail ?? entry.message ?? "";
26248
26302
  },
26249
26303
  {
26250
26304
  kind: "paragraph",
26251
- text: "A file detail page exposes up to four tabs — Preview, Code, Blame, History. For text files Code is the default and ?preview=1 opts in to the Markdown / HTML preview; media files (images, video, audio, PDF) show a Preview tab only, with no Code tab. Blame and History have their own canonical URLs (view=blame, view=history) so deep links and the browser back/forward stay in sync, and they keep the Repository sidebar visible."
26305
+ text: "A file detail page exposes up to four tabs — Preview, Code, Blame, History. For text files Code is the default and ?preview=1 opts in to the Markdown / HTML preview; media files (images, video, audio, PDF) show a Preview tab only, with no Code tab. Blame and History have their own canonical URLs (view=blame, view=history) so deep links and the browser back/forward stay in sync, and they keep the Repository sidebar visible. Opening another file from the repository tree keeps the active tab (a file that cannot be previewed falls back to Code)."
26252
26306
  },
26253
26307
  {
26254
26308
  kind: "paragraph",
@@ -26931,7 +26985,7 @@ code-viewer query agent-help`
26931
26985
  },
26932
26986
  {
26933
26987
  kind: "paragraph",
26934
- text: "ファイル詳細ページには最大 4 つのタブ (Preview / Code / Blame / History) があります。テキストファイルは Code がデフォルトで、?preview=1 を付けると Markdown / HTML プレビューに切り替わります。画像・動画・音声・PDF などのメディアファイルは Preview タブのみ表示され、Code タブは表示されません。Blame と History はそれぞれ専用 URL (view=blame, view=history) を持つため、ディープリンクとブラウザの戻る / 進むが同期し、いずれも Repository サイドバーは表示されたままです。"
26988
+ text: "ファイル詳細ページには最大 4 つのタブ (Preview / Code / Blame / History) があります。テキストファイルは Code がデフォルトで、?preview=1 を付けると Markdown / HTML プレビューに切り替わります。画像・動画・音声・PDF などのメディアファイルは Preview タブのみ表示され、Code タブは表示されません。Blame と History はそれぞれ専用 URL (view=blame, view=history) を持つため、ディープリンクとブラウザの戻る / 進むが同期し、いずれも Repository サイドバーは表示されたままです。ツリーから別のファイルを開いても選択中のタブは維持されます (プレビューできないファイルでは Code に戻ります)。"
26935
26989
  },
26936
26990
  {
26937
26991
  kind: "paragraph",
@@ -33118,14 +33172,10 @@ code-viewer query agent-help`
33118
33172
  loadRepo();
33119
33173
  return;
33120
33174
  }
33121
- setRoute({
33122
- screen: "file",
33123
- path: file.path,
33124
- ref: normalizedRef,
33125
- view: "blob",
33126
- range: currentRange()
33127
- });
33128
- renderStandaloneSource({ path: file.path, ref: normalizedRef });
33175
+ const fileRoute = fileRouteKeepingActiveView(STATE.route, { path: file.path, ref: normalizedRef }, currentRange());
33176
+ setRoute(fileRoute);
33177
+ if (fileRoute.view === "blob")
33178
+ renderStandaloneSource({ path: file.path, ref: normalizedRef });
33129
33179
  });
33130
33180
  await activateRepoSidebarPath(currentPath);
33131
33181
  }).catch(() => {
@@ -37644,6 +37694,7 @@ code-viewer query agent-help`
37644
37694
  if (!hljsRef)
37645
37695
  return null;
37646
37696
  ensureTerraformHighlightLanguage(hljsRef);
37697
+ ensureGdscriptHighlightLanguage(hljsRef);
37647
37698
  if (!highlightConfigured && typeof hljsRef.configure === "function") {
37648
37699
  hljsRef.configure({ ignoreUnescapedHTML: true });
37649
37700
  highlightConfigured = true;