11import { getMeta } from "$lib/meta/meta-storage" ;
22import type { SerialPortLike } from "$lib/serial/device" ;
33import type {
4- CCOSInEvent ,
54 CCOSInitEvent ,
65 CCOSKeyPressEvent ,
76 CCOSKeyReleaseEvent ,
@@ -11,7 +10,7 @@ import { KEYCODE_TO_SCANCODE, SCANCODE_TO_KEYCODE } from "./ccos-interop";
1110
1211const device = "zero_wasm" ;
1312
14- class CCOSKeyboardEvent extends KeyboardEvent {
13+ export class CCOSKeyboardEvent extends KeyboardEvent {
1514 constructor ( ...params : ConstructorParameters < typeof KeyboardEvent > ) {
1615 super ( ...params ) ;
1716 }
@@ -26,7 +25,46 @@ const MASK_GUI = 0b1000_1000;
2625export class CCOS implements SerialPortLike {
2726 private readonly currKeys = new Set < number > ( ) ;
2827
29- private readonly layout = new Map < string , string > ( ) ;
28+ private readonly layout = new Map < string , string > ( [
29+ ...Array . from (
30+ { length : 26 } ,
31+ ( _ , i ) =>
32+ [
33+ JSON . stringify ( [ `Key${ String . fromCharCode ( 65 + i ) } ` , "Shift" ] ) ,
34+ String . fromCharCode ( 65 + i ) ,
35+ ] as const ,
36+ ) ,
37+ ...Array . from (
38+ { length : 10 } ,
39+ ( _ , i ) => [ JSON . stringify ( [ `Key${ i } ` ] ) , i . toString ( ) ] as const ,
40+ ) ,
41+
42+ [ JSON . stringify ( [ "Space" ] ) , " " ] ,
43+ [ JSON . stringify ( [ "Backquote" ] ) , "`" ] ,
44+ [ JSON . stringify ( [ "Minus" ] ) , "-" ] ,
45+ [ JSON . stringify ( [ "Comma" ] ) , "," ] ,
46+ [ JSON . stringify ( [ "Period" ] ) , "." ] ,
47+ [ JSON . stringify ( [ "Semicolon" ] ) , ";" ] ,
48+ [ JSON . stringify ( [ "Equal" ] ) , "=" ] ,
49+
50+ [ JSON . stringify ( [ "Backquote" , "Shift" ] ) , "~" ] ,
51+ [ JSON . stringify ( [ "Minus" , "Shift" ] ) , "_" ] ,
52+ [ JSON . stringify ( [ "Comma" , "Shift" ] ) , "<" ] ,
53+ [ JSON . stringify ( [ "Period" , "Shift" ] ) , ">" ] ,
54+ [ JSON . stringify ( [ "Semicolon" , "Shift" ] ) , ":" ] ,
55+ [ JSON . stringify ( [ "Equal" , "Shift" ] ) , "+" ] ,
56+
57+ [ JSON . stringify ( [ "Digit0" , "Shift" ] ) , ")" ] ,
58+ [ JSON . stringify ( [ "Digit1" , "Shift" ] ) , "!" ] ,
59+ [ JSON . stringify ( [ "Digit2" , "Shift" ] ) , "@" ] ,
60+ [ JSON . stringify ( [ "Digit3" , "Shift" ] ) , "#" ] ,
61+ [ JSON . stringify ( [ "Digit4" , "Shift" ] ) , "$" ] ,
62+ [ JSON . stringify ( [ "Digit5" , "Shift" ] ) , "%" ] ,
63+ [ JSON . stringify ( [ "Digit6" , "Shift" ] ) , "^" ] ,
64+ [ JSON . stringify ( [ "Digit7" , "Shift" ] ) , "&" ] ,
65+ [ JSON . stringify ( [ "Digit8" , "Shift" ] ) , "*" ] ,
66+ [ JSON . stringify ( [ "Digit9" , "Shift" ] ) , "(" ] ,
67+ ] ) ;
3068
3169 private readonly worker = new Worker ( "/ccos-worker.js" , { type : "module" } ) ;
3270
@@ -126,7 +164,6 @@ export class CCOS implements SerialPortLike {
126164 this . controller ?. enqueue ( event . data ) ;
127165 return ;
128166 }
129- console . log ( "CCOS worker message" , event . data ) ;
130167 switch ( event . data . type ) {
131168 case "ready" : {
132169 this . resolveReady ( ) ;
@@ -220,7 +257,7 @@ export class CCOS implements SerialPortLike {
220257}
221258
222259export async function fetchCCOS (
223- version = ".2.2.0-beta.12+266bdda " ,
260+ version = "3.0.0-rc.0 " ,
224261 fetch : typeof window . fetch = window . fetch ,
225262) : Promise < CCOS | undefined > {
226263 const meta = await getMeta ( device , version , fetch ) ;
0 commit comments