Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
'Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq'
)
;
}
console
.
warn
(
(
as
)
.
)
;
}
const
enum
{
,
,
,
,
}
class
RequestMessage
{
public
readonly
=
.
;
constructor
(
public
readonly
:
number
,
public
readonly
:
string
,
public
readonly
:
string
,
public
readonly
:
string
,
public
readonly
:
unknown
[
]
)
{
}
}
class
ReplyMessage
{
public
readonly
=
.
;
constructor
(
public
readonly
:
number
,
public
readonly
:
string
,
public
readonly
:
unknown
,
public
readonly
:
unknown
|
)
{
}
}
class
SubscribeEventMessage
{
public
readonly
=
.
;
constructor
(
public
readonly
:
number
,
public
readonly
:
string
,
public
readonly
:
string
,
public
readonly
:
string
,
public
readonly
:
unknown
)
{
}
}
class
EventMessage
{
public
readonly
=
.
;
constructor
(
public
readonly
:
number
,
public
readonly
:
string
,
public
readonly
:
unknown
)
{
}
}
class
UnsubscribeEventMessage
{
public
readonly
=
.
;
constructor
(
public
readonly
:
number
,
public
readonly
:
string
)
{
}
}
export
type
Message
=
|
|
|
|
;
interface
IMessageReply
{
resolve
:
(
?
:
unknown
)
=>
void
;
reject
:
(
?
:
unknown
)
=>
void
;
}
interface
IMessageHandler
{
sendMessage
(
:
unknown
,
?
:
[
]
)
:
void
;
handleMessage
(
:
string
,
:
string
,
:
unknown
[
]
)
:
Promise
<
unknown
>
;
handleEvent
(
:
string
,
:
string
,
:
unknown
)
:
<
unknown
>
;
}
class
WebWorkerProtocol
{
private
:
number
;
private
:
number
;
private
:
{
[
:
string
]
:
}
;
private
:
<
string
,
<
unknown
>>
;
private
:
<
string
,
>
;
private
:
;
constructor
(
:
)
{
this
.
=
-
1
;
this
.
=
;
this
.
=
0
;
this
.
=
.
create
(
null
)
;
this
.
=
new
Map<string, Emitter<unknown>>
(
)
;
this
.
=
new
Map<string, IDisposable>
(
)
;
}
public
setWorkerId
(
:
number
)
:
void
{
this
.
=
;
}
public
async
sendMessage
(
:
string
,
:
string
,
:
unknown
[
]
)
:
Promise
<
unknown
>
{
const
=
String
(
++
this
.
)
;
return
new
Promise<unknown>
(
(
,
)
=>
{
this
.
[
]
=
{
:
,
:
}
;
this
.
_send
(
new
RequestMessage
(
this
.
,
,
,
,
)
)
;
}
)
;
}
public
listen
(
:
string
,
:
string
,
:
unknown
)
:
<
unknown
>
{
let
:
string
|
null
=
null
;
const
=
new
Emitter<unknown>
(
{
onWillAddFirstListener
:
(
)
=>
{
=
String
(
++
this
.
)
;
this
.
.
set
(
,
)
;
this
.
_send
(
new
SubscribeEventMessage
(
this
.
,
,
,
,
)
)
;
}
,
onDidRemoveLastListener
:
(
)
=>
{
this
.
.
delete
(
!
)
;
this
.
_send
(
new
UnsubscribeEventMessage
(
this
.
,
!
)
)
;
=
null
;
}
}
)
;
return
.
;
}
public
handleMessage
(
:
unknown
)
:
void
{
if
(
!
||
!
(
as
)
.
)
{
return
;
}
if
(
this
.
!==
-
1
&&
(
as
)
.
!==
this
.
)
{
return
;
}
this
.
_handleMessage
(
as
)
;
}
public
createProxyToRemoteChannel<Textends object>
(
:
string
,
?
:
(
)
=>
Promise
<
void
>
)
:
T
{
const
=
{
get
:
(
:
<
,
unknown
>
,
:
)
=>
{
if
(
typeof
===
'string'
&&
!
[
]
)
{
if
(
propertyIsDynamicEvent
(
)
)
{
// onDynamic...
[
]
=
(
:
unknown
)
:
<
unknown
>
=>
{
return
this
.
listen
(
,
,
)
;
}
;
}
else
if
(
propertyIsEvent
(
)
)
{
// on...
[
]
=
this
.
listen
(
,
,
undefined
)
;
}
else
if
(
.
charCodeAt
(
0
)
===
.
)
{
// $...
[
]
=
async
(
...
:
unknown
[
]
)
=>
{
await
?.
(
)
;
return
this
.
sendMessage
(
,
,
)
;
}
;
}
}
return
[
]
;
}
}
;
return
new
Proxy
(
.
create
(
null
)
,
)
;
}
private
_handleMessage
(
:
)
:
void
{
switch
(
.
)
{
case
.
:
return
this
.
_handleReplyMessage
(
)
;
case
.
:
return
this
.
_handleRequestMessage
(
)
;
case
.
:
return
this
.
_handleSubscribeEventMessage
(
)
;
case
.
:
return
this
.
_handleEventMessage
(
)
;
case
.
:
return
this
.
_handleUnsubscribeEventMessage
(
)
;
}
}
private
_handleReplyMessage
(
:
)
:
void
{
if
(
!
this
.
[
.
]
)
{
console
.
warn
(
'Got reply to unknown seq'
)
;
return
;
}
const
=
this
.
[
.
]
;
delete
this
.
[
.
]
;
if
(
.
)
{
let
=
.
;
if
(
(
.
as
)
.
)
{
const
=
new
Error
(
)
;
.
=
(
.
as
)
.
;
.
=
(
.
as
)
.
;
.
=
(
.
as
)
.
;
=
;
}
.
reject
(
)
;
return
;
}
.
resolve
(
.
)
;
}
private
_handleRequestMessage
(
:
)
:
void
{
const
=
.
;
const
=
this
.
.
handleMessage
(
.
,
.
,
.
)
;
.
then
(
(
)
=>
{
this
.
_send
(
new
ReplyMessage
(
this
.
,
,
,
undefined
)
)
;
}
,
(
)
=>
{
if
(
.
instanceof
Error
)
{
// Loading errors have a detail property that points to the actual error
.
=
transformErrorForSerialization
(
.
)
;
}
this
.
_send
(
new
ReplyMessage
(
this
.
,
,
undefined
,
transformErrorForSerialization
(
)
)
)
;
}
)
;
}
private
_handleSubscribeEventMessage
(
:
)
:
void
{
const
=
.
;
const
=
this
.
.
handleEvent
(
.
,
.
,
.
)
(
(
)
=>
{
this
.
_send
(
new
EventMessage
(
this
.
,
,
)
)
;
}
)
;
this
.
.
set
(
,
)
;
}
private
_handleEventMessage
(
:
)
:
void
{
const
=
this
.
.
get
(
.
)
;
if
(
===
undefined
)
{
console
.
warn
(
'Got event for unknown req'
)
;
return
;
}
.
fire
(
.
)
;
}
private
_handleUnsubscribeEventMessage
(
:
)
:
void
{
const
=
this
.
.
get
(
.
)
;
if
(
===
undefined
)
{
console
.
warn
(
'Got unsubscribe for unknown req'
)
;
return
;
}
.
dispose
(
)
;
this
.
.
delete
(
.
)
;
}
private
_send
(
:
)
:
void
{
const
:
[
]
=
[
]
;
if
(
.
===
.
)
{
for
(
let
=
0
;
<
.
.
;
++
)
{
const
=
.
[
]
;
if
(
instanceof
ArrayBuffer
)
{
.
push
(
)
;
}
}
}
else
if
(
.
===
.
)
{
if
(
.
instanceof
ArrayBuffer
)
{
.
push
(
.
)
;
}
}
this
.
.
sendMessage
(
,
)
;
}
}
type
ProxiedMethodName
=
(
`$${string}`
|
`on${string}`
)
;
export
type
Proxied<T>
=
{
[
K
in
keyof
T
]
:
T
[
K
]
extends
(
...
:
infer
A
)
=>
infer
R
?
(
K
extends
ProxiedMethodName
?
(
...
:
A
)
=>
Promise
<
<
R
>>
:
never
)
:
never
}
;
export
interface
IWebWorkerClient<TProxy>
{
:
<
>
;
dispose
(
)
:
void
;
setChannel<Textends object>
(
:
string
,
:
T
)
:
void
;
getChannel<Textends object>
(
:
string
)
:
<
T
>
;
}
export
interface
IWebWorkerServer
{
setChannel<Textends object>
(
:
string
,
:
T
)
:
void
;
getChannel<Textends object>
(
:
string
)
:
<
T
>
;
}
/**
* Main thread side
*/
export
class
WebWorkerClient<Wextends object>
extends
Disposable
implements
IWebWorkerClient<W>
{
private
readonly
:
;
private
readonly
:
Promise
<
void
>
;
private
readonly
:
;
public
readonly
:
<
W
>
;
private
readonly
:
<
string
,
>
=
new
Map
(
)
;
private
readonly
:
<
string
,
>
=
new
Map
(
)
;
constructor
(
:
)
{
super
(
)
;
this
.
=
this
.
_register
(
)
;
this
.
_register
(
this
.
.
onMessage
(
(
)
=>
{
this
.
.
handleMessage
(
)
;
}
)
)
;
this
.
_register
(
this
.
.
onError
(
(
)
=>
{
logOnceWebWorkerWarning
(
)
;
onUnexpectedError
(
)
;
}
)
)
;
this
.
=
new
WebWorkerProtocol
(
{
:
(
:
,
:
[
]
)
:
void
=>
{
this
.
.
postMessage
(
,
)
;
}
,
:
(
:
string
,
:
string
,
:
unknown
[
]
)
:
Promise
<
unknown
>
=>
{
return
this
.
_handleMessage
(
,
,
)
;
}
,
:
(
:
string
,
:
string
,
:
unknown
)
:
<
unknown
>
=>
{
return
this
.
_handleEvent
(
,
,
)
;
}
}
)
;
this
.
.
setWorkerId
(
this
.
.
getId
(
)
)
;
// Send initialize message
this
.
=
this
.
.
sendMessage
(
DEFAULT_CHANNEL
,
INITIALIZE
,
[
this
.
.
getId
(
)
,
]
)
.
then
(
(
)
=>
{
}
)
;
this
.
=
this
.
.
createProxyToRemoteChannel
(
DEFAULT_CHANNEL
,
async
(
)
=>
{
await
this
.
;
}
)
;
this
.
.
catch
(
(
)
=>
{
this
.
_onError
(
'Worker failed to load '
,
)
;
}
)
;
}
private
_handleMessage
(
:
string
,
:
string
,
:
unknown
[
]
)
:
Promise
<
unknown
>
{
const
:
|
undefined
=
this
.
.
get
(
)
;
if
(
!
)
{
return
Promise
.
reject
(
new
Error
(
`Missing channel ${channelName} on main thread`
)
)
;
}
const
=
(
as
<
string
,
unknown
>
)
[
]
;
if
(
typeof
!==
'function'
)
{
return
Promise
.
reject
(
new
Error
(
`Missing method ${method} on main thread channel ${channelName}`
)
)
;
}
try
{
return
Promise
.
resolve
(
fn
.
apply
(
,
)
)
;
}
catch
(
)
{
return
Promise
.
reject
(
)
;
}
}
private
_handleEvent
(
:
string
,
:
string
,
:
unknown
)
:
<
unknown
>
{
const
:
|
undefined
=
this
.
.
get
(
)
;
if
(
!
)
{
throw
new
Error
(
`Missing channel ${channelName} on main thread`
)
;
}
if
(
propertyIsDynamicEvent
(
)
)
{
const
=
(
as
<
string
,
unknown
>
)
[
]
;
if
(
typeof
!==
'function'
)
{
throw
new
Error
(
`Missing dynamic event ${eventName} on main thread channel ${channelName}.`
)
;
}
const
=
fn
.
call
(
,
)
;
if
(
typeof
!==
'function'
)
{
throw
new
Error
(
`Missing dynamic event ${eventName} on main thread channel ${channelName}.`
)
;
}
return
;
}
if
(
propertyIsEvent
(
)
)
{
const
=
(
as
<
string
,
unknown
>
)
[
]
;
if
(
typeof
!==
'function'
)
{
throw
new
Error
(
`Missing event ${eventName} on main thread channel ${channelName}.`
)
;
}
return
as
<
unknown
>
;
}
throw
new
Error
(
`Malformed event name ${eventName}`
)
;
}
public
setChannel<Textends object>
(
:
string
,
:
T
)
:
void
{
this
.
.
set
(
,
)
;
}
public
getChannel<Textends object>
(
:
string
)
:
<
T
>
{
let
=
this
.
.
get
(
)
;
if
(
===
undefined
)
{
=
this
.
.
createProxyToRemoteChannel
(
,
async
(
)
=>
{
await
this
.
;
}
)
;
this
.
.
set
(
,
)
;
}
return
as
<
T
>
;
}
private
_onError
(
:
string
,
?
:
unknown
)
:
void
{
console
.
error
(
)
;
console
.
info
(
)
;
}
}
function
propertyIsEvent
(
:
string
)
:
boolean
{
// Assume a property is an event if it has a form of "onSomething"
return
[
0
]
===
'o'
&&
[
1
]
===
'n'
&&
.
isUpperAsciiLetter
(
.
charCodeAt
(
2
)
)
;
}
function
propertyIsDynamicEvent
(
:
string
)
:
boolean
{
// Assume a property is a dynamic event (a method that returns an event) if it has a form of "onDynamicSomething"