mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 03:05:38 -05:00
refactor py-config to use json (#754)
* refactor py-config to use toml * switch from toml to json and add unit tests * fix test for py-config * fix integration test * use flat structure for JSON * allow merging configs * replace arrays instead of concatenating them * remove extra keys from inline config of integration test * simplify array replacement logic * allow config from src to be partial as well * add comments to unit tests * add unit test for setting config from both inline and src * handle parse errors + validate config supplied * separate functions for src and inline * suggested improvements * show error message in red on parser error * fix eslint * use resolveJsonModule as true * use default config defined as a variable without import * remove disable eslint comment * remove import for covfefe.json as well * metadata injection * add support for schema + extra keys * use schema_version
This commit is contained in:
@@ -16,21 +16,37 @@ import { getLogger } from './logger';
|
||||
|
||||
const logger = getLogger('pyscript/runtime');
|
||||
|
||||
export const version = "<<VERSION>>";
|
||||
export type RuntimeInterpreter = PyodideInterface | null;
|
||||
|
||||
export interface AppConfig extends Record<string, any> {
|
||||
name?: string;
|
||||
description?: string;
|
||||
version?: string;
|
||||
schema_version?: number;
|
||||
type?: string;
|
||||
author_name?: string;
|
||||
author_email?: string;
|
||||
license?: string;
|
||||
autoclose_loader?: boolean;
|
||||
runtimes?: Array<RuntimeConfig>;
|
||||
packages?: Array<string>;
|
||||
paths?: Array<string>;
|
||||
plugins?: Array<string>;
|
||||
pyscript?: PyScriptMetadata;
|
||||
}
|
||||
|
||||
export type PyScriptMetadata = {
|
||||
version?: string;
|
||||
time?: string;
|
||||
}
|
||||
|
||||
export type RuntimeConfig = {
|
||||
src: string;
|
||||
src?: string;
|
||||
name?: string;
|
||||
lang?: string;
|
||||
};
|
||||
|
||||
export type AppConfig = {
|
||||
autoclose_loader: boolean;
|
||||
name?: string;
|
||||
version?: string;
|
||||
runtimes?: Array<RuntimeConfig>;
|
||||
};
|
||||
|
||||
let loader: PyLoader | undefined;
|
||||
globalLoader.subscribe(value => {
|
||||
loader = value;
|
||||
@@ -52,7 +68,7 @@ scriptsQueue.subscribe((value: PyScript[]) => {
|
||||
});
|
||||
|
||||
let appConfig_: AppConfig = {
|
||||
autoclose_loader: true,
|
||||
autoclose_loader: true
|
||||
};
|
||||
|
||||
appConfig.subscribe((value: AppConfig) => {
|
||||
|
||||
Reference in New Issue
Block a user