Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Basthon
Basthon Kernel
Commits
2864caa6
Commit
2864caa6
authored
Oct 17, 2022
by
Romain Casati
Browse files
API: allow kernel specific options at build.
parent
b0fdde5c
Changes
9
Hide whitespace changes
Inline
Side-by-side
packages/browser-bundle/src/main.ts
View file @
2864caa6
...
...
@@ -7,10 +7,10 @@ declare global {
}
}
const
loader
=
new
KernelLoader
(
window
.
basthonRoot
??
"
./
"
,
window
.
basthonKernel
??
"
python3
"
);
const
loader
=
new
KernelLoader
(
{
"
rootPath
"
:
window
.
basthonRoot
??
"
./
"
,
"
language
"
:
window
.
basthonKernel
??
"
python3
"
}
);
(
async
()
=>
{
loader
.
showLoader
(
"
Chargement de Basthon...
"
,
true
);
...
...
packages/gui-base/src/main.ts
View file @
2864caa6
...
...
@@ -11,8 +11,7 @@ declare global {
}
export
interface
GUIOptions
{
kernelRootPath
:
string
,
language
:
string
,
kernelOptions
:
any
,
uiName
?:
string
,
noCheckpointsInit
?:
boolean
,
}
...
...
@@ -36,14 +35,14 @@ export class GUIBase {
private
_console_error
:
(
message
:
string
)
=>
void
=
console
.
error
;
public
constructor
(
options
:
GUIOptions
)
{
this
.
_language
=
options
.
language
;
this
.
_loader
=
new
KernelLoader
(
options
.
kernel
RootPath
,
options
.
language
);
this
.
_language
=
options
?.
kernelOptions
?
.
language
;
this
.
_loader
=
new
KernelLoader
(
options
.
kernel
Options
);
// loading Basthon (errors are fatal)
this
.
_loader
.
showLoader
(
"
Chargement de Basthon...
"
,
false
,
false
);
/* per language checkpoints */
if
(
!
options
.
noCheckpointsInit
)
this
.
_checkpoints
=
new
CheckpointsManager
<
string
>
(
`
${
options
.
uiName
}
.
${
option
s
.
language
}
`
,
this
.
_maxCheckpoints
);
`
${
options
.
uiName
}
.
${
thi
s
.
_
language
}
`
,
this
.
_maxCheckpoints
);
/* globale states (not language specific) */
this
.
_stateStorage
=
new
Storage
(
`
${
options
.
uiName
}
.states`
);
}
...
...
packages/kernel-base/src/kernel.ts
View file @
2864caa6
...
...
@@ -33,9 +33,9 @@ export class KernelBase {
private
readonly
_loaded
=
new
PromiseDelegate
<
void
>
();
public
_execution_count
:
number
=
0
;
constructor
(
rootPath
:
string
)
{
constructor
(
options
:
any
)
{
// root path where kernel is installed
this
.
_rootPath
=
rootPath
;
this
.
_rootPath
=
options
.
rootPath
;
}
/**
...
...
packages/kernel-javascript/src/kernel.ts
View file @
2864caa6
...
...
@@ -8,8 +8,8 @@ export class KernelJavaScript extends KernelBase {
window
:
undefined
,
};;
constructor
(
rootPath
:
string
)
{
super
(
rootPath
);
constructor
(
options
:
any
)
{
super
(
options
);
this
.
_execution_count
=
0
;
}
...
...
packages/kernel-loader/src/main.ts
View file @
2864caa6
...
...
@@ -27,9 +27,9 @@ export class KernelLoader {
private
_loaderTextElem
?:
HTMLDivElement
;
private
_loaderTextError
?:
HTMLDivElement
;
constructor
(
rootPath
:
string
,
language
:
string
,
constructor
(
options
:
any
,
loaderId
?:
string
)
{
const
language
:
string
=
options
.
language
;
if
(
loaderId
!=
null
)
this
.
_loaderId
=
loaderId
;
if
(
document
.
readyState
===
'
loading
'
)
{
...
...
@@ -49,25 +49,25 @@ export class KernelLoader {
case
"
python3
"
:
case
"
python3.10
"
:
const
{
KernelPython3
}
=
await
import
(
"
@basthon/kernel-python3
"
);
this
.
_kernel
=
new
KernelPython3
(
rootPath
);
this
.
_kernel
=
new
KernelPython3
(
options
);
break
;
case
"
python3-old
"
:
case
"
python3.8
"
:
const
{
KernelPython3Old
}
=
await
import
(
"
@basthon/kernel-python3-old
"
);
this
.
_kernel
=
new
KernelPython3Old
(
rootPath
);
this
.
_kernel
=
new
KernelPython3Old
(
options
);
break
;
case
"
js
"
:
case
"
javascript
"
:
const
{
KernelJavaScript
}
=
await
import
(
"
@basthon/kernel-javascript
"
);
this
.
_kernel
=
new
KernelJavaScript
(
rootPath
);
this
.
_kernel
=
new
KernelJavaScript
(
options
);
break
;
case
"
sql
"
:
const
{
KernelSQL
}
=
await
import
(
"
@basthon/kernel-sql
"
);
this
.
_kernel
=
new
KernelSQL
(
rootPath
);
this
.
_kernel
=
new
KernelSQL
(
options
);
break
;
case
"
ocaml
"
:
const
{
KernelOCaml
}
=
await
import
(
"
@basthon/kernel-ocaml
"
);
this
.
_kernel
=
new
KernelOCaml
(
rootPath
);
this
.
_kernel
=
new
KernelOCaml
(
options
);
break
;
default
:
window
.
console
.
error
(
`Kernel '
${
language
}
' not supported.`
);
...
...
packages/kernel-ocaml/src/kernel.ts
View file @
2864caa6
...
...
@@ -17,8 +17,8 @@ export class KernelOCaml extends KernelBase {
private
__eval_data__
?:
any
=
{};
private
_initInnerCode
:
string
;
constructor
(
rootPath
:
string
)
{
super
(
rootPath
);
constructor
(
options
:
any
)
{
super
(
options
);
this
.
_initInnerCode
=
`\
open Js_of_ocaml
module Basthon = struct
...
...
packages/kernel-python3-old/src/kernel.ts
View file @
2864caa6
...
...
@@ -21,7 +21,7 @@ export class KernelPython3Old extends KernelBase {
private
__kernel__
:
any
=
null
;
public
pythonVersion
:
string
=
""
;
constructor
(
rootPath
:
string
)
{
super
(
rootPath
);
}
constructor
(
options
:
any
)
{
super
(
options
);
}
/**
* Get the URL of Basthon modules dir.
...
...
packages/kernel-python3/src/kernel.ts
View file @
2864caa6
...
...
@@ -22,7 +22,7 @@ export class KernelPython3 extends KernelBase {
private
__kernel__
:
any
=
null
;
public
pythonVersion
:
string
=
""
;
constructor
(
rootPath
:
string
)
{
super
(
rootPath
);
}
constructor
(
options
:
any
)
{
super
(
options
);
}
/**
* Get the URL of Basthon modules dir.
...
...
packages/kernel-sql/src/kernel.ts
View file @
2864caa6
...
...
@@ -13,8 +13,8 @@ export class KernelSQL extends KernelBase {
private
db
:
any
;
private
_dots
:
{
[
key
:
string
]:
{
[
key
:
string
]:
string
|
(()
=>
unknown
)
}
};
public
constructor
(
rootPath
:
string
)
{
super
(
rootPath
);
public
constructor
(
options
:
any
)
{
super
(
options
);
this
.
_execution_count
=
0
;
// initial db file (used to restart SQLite)
this
.
_dbInit
=
undefined
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment