@@ -11,8 +11,8 @@ import { CSS, attribute, html, query } from "../../base/web-components";
1111import { KCUIElement , KCUIIconElement } from "../../kc-ui" ;
1212import { sprites_url } from "../icons/sprites" ;
1313import { Project } from "../project" ;
14- import { GitHub } from "../services/github" ;
1514import { GitHubFileSystem } from "../services/github-vfs" ;
15+ import { CodebergFileSystem } from "../services/codeberg-vfs" ;
1616import { FetchFileSystem , type VirtualFileSystem } from "../services/vfs" ;
1717import { KCBoardAppElement } from "./kc-board/app" ;
1818import { KCSchematicAppElement } from "./kc-schematic/app" ;
@@ -82,7 +82,11 @@ class KiCanvasShellElement extends KCUIElement {
8282
8383 override initialContentCallback ( ) {
8484 const url_params = new URLSearchParams ( document . location . search ) ;
85- const github_paths = url_params . getAll ( "github" ) ;
85+
86+ const urls = [
87+ ...url_params . getAll ( "github" ) ,
88+ ...url_params . getAll ( "repo" ) ,
89+ ] ;
8690
8791 later ( async ( ) => {
8892 if ( this . src ) {
@@ -91,8 +95,12 @@ class KiCanvasShellElement extends KCUIElement {
9195 return ;
9296 }
9397
94- if ( github_paths . length ) {
95- const vfs = await GitHubFileSystem . fromURLs ( ...github_paths ) ;
98+ if ( urls . length ) {
99+ const vfs = await this . load_repo ( ...urls ) ;
100+ if ( ! vfs ) {
101+ return ;
102+ }
103+
96104 await this . setup_project ( vfs ) ;
97105 return ;
98106 }
@@ -104,15 +112,18 @@ class KiCanvasShellElement extends KCUIElement {
104112
105113 this . link_input . addEventListener ( "input" , async ( e ) => {
106114 const link = this . link_input . value ;
107- if ( ! GitHub . parse_url ( link ) ) {
115+ const vfs = await this . load_repo ( link ) ;
116+
117+ if ( ! vfs ) {
118+ // TODO: show error message: invaild URL
119+ console . error ( `Invalid URL: ${ link } ` ) ;
108120 return ;
109121 }
110122
111- const vfs = await GitHubFileSystem . fromURLs ( link ) ;
112123 await this . setup_project ( vfs ) ;
113124
114125 const location = new URL ( window . location . href ) ;
115- location . searchParams . set ( "github " , link ) ;
126+ location . searchParams . set ( "repo " , link ) ;
116127 window . history . pushState ( null , "" , location ) ;
117128 } ) ;
118129
@@ -123,6 +134,15 @@ class KiCanvasShellElement extends KCUIElement {
123134 } ) ;
124135 }
125136
137+ private async load_repo (
138+ ...url : string [ ]
139+ ) : Promise < VirtualFileSystem | null > {
140+ return (
141+ ( await GitHubFileSystem . fromURLs ( ...url ) ) ??
142+ ( await CodebergFileSystem . fromURLs ( ...url ) )
143+ ) ;
144+ }
145+
126146 private async setup_project ( vfs : VirtualFileSystem ) {
127147 this . loaded = false ;
128148 this . loading = true ;
@@ -174,7 +194,7 @@ class KiCanvasShellElement extends KCUIElement {
174194 < input
175195 name ="link "
176196 type ="text "
177- placeholder ="Paste a GitHub link... "
197+ placeholder ="Paste a GitHub/Codeberg link... "
178198 autofocus />
179199 < p >
180200 or drag & drop your KiCad files, or< button
0 commit comments