mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Factored out codemirror as chunked lazy based import (#2252)
* Factored out codemirror as chunked lazy based import
This commit is contained in:
committed by
GitHub
parent
796373cfa6
commit
7e65836423
@@ -34,6 +34,9 @@ import {
|
||||
inputFailure,
|
||||
} from "./hooks.js";
|
||||
|
||||
import codemirror from "./plugins/codemirror.js";
|
||||
export { codemirror };
|
||||
|
||||
import { stdlib, optional } from "./stdlib.js";
|
||||
export { stdlib, optional, inputFailure };
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// ⚠️ This file is an artifact: DO NOT MODIFY
|
||||
export default {
|
||||
codemirror: () =>
|
||||
import(
|
||||
/* webpackIgnore: true */
|
||||
"./plugins/codemirror.js"
|
||||
),
|
||||
["deprecations-manager"]: () =>
|
||||
import(
|
||||
/* webpackIgnore: true */
|
||||
|
||||
31
core/src/plugins/codemirror.js
Normal file
31
core/src/plugins/codemirror.js
Normal file
@@ -0,0 +1,31 @@
|
||||
// lazy loaded on-demand codemirror related files
|
||||
export default {
|
||||
get core() {
|
||||
return import(/* webpackIgnore: true */ "../3rd-party/codemirror.js");
|
||||
},
|
||||
get state() {
|
||||
return import(
|
||||
/* webpackIgnore: true */ "../3rd-party/codemirror_state.js"
|
||||
);
|
||||
},
|
||||
get python() {
|
||||
return import(
|
||||
/* webpackIgnore: true */ "../3rd-party/codemirror_lang-python.js"
|
||||
);
|
||||
},
|
||||
get language() {
|
||||
return import(
|
||||
/* webpackIgnore: true */ "../3rd-party/codemirror_language.js"
|
||||
);
|
||||
},
|
||||
get view() {
|
||||
return import(
|
||||
/* webpackIgnore: true */ "../3rd-party/codemirror_view.js"
|
||||
);
|
||||
},
|
||||
get commands() {
|
||||
return import(
|
||||
/* webpackIgnore: true */ "../3rd-party/codemirror_commands.js"
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
import { Hook, XWorker, dedent, defineProperties } from "polyscript/exports";
|
||||
import { TYPES, offline_interpreter, relative_url, stdlib } from "../core.js";
|
||||
import { notify } from "./error.js";
|
||||
import codemirror from "./codemirror.js";
|
||||
|
||||
const RUN_BUTTON = `<svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg>`;
|
||||
|
||||
@@ -194,14 +195,12 @@ const init = async (script, type, interpreter) => {
|
||||
{ keymap },
|
||||
{ defaultKeymap, indentWithTab },
|
||||
] = await Promise.all([
|
||||
import(/* webpackIgnore: true */ "../3rd-party/codemirror.js"),
|
||||
import(/* webpackIgnore: true */ "../3rd-party/codemirror_state.js"),
|
||||
import(
|
||||
/* webpackIgnore: true */ "../3rd-party/codemirror_lang-python.js"
|
||||
),
|
||||
import(/* webpackIgnore: true */ "../3rd-party/codemirror_language.js"),
|
||||
import(/* webpackIgnore: true */ "../3rd-party/codemirror_view.js"),
|
||||
import(/* webpackIgnore: true */ "../3rd-party/codemirror_commands.js"),
|
||||
codemirror.core,
|
||||
codemirror.state,
|
||||
codemirror.python,
|
||||
codemirror.language,
|
||||
codemirror.view,
|
||||
codemirror.commands,
|
||||
]);
|
||||
|
||||
let isSetup = script.hasAttribute("setup");
|
||||
|
||||
3
core/types/core.d.ts
vendored
3
core/types/core.d.ts
vendored
@@ -7,6 +7,7 @@ export function donkey(options: any): Promise<{
|
||||
kill: () => void;
|
||||
}>;
|
||||
export function offline_interpreter(config: any): string;
|
||||
import codemirror from './plugins/codemirror.js';
|
||||
import { stdlib } from "./stdlib.js";
|
||||
import { optional } from "./stdlib.js";
|
||||
import { inputFailure } from "./hooks.js";
|
||||
@@ -63,4 +64,4 @@ declare const exportedHooks: {
|
||||
};
|
||||
declare const exportedConfig: {};
|
||||
declare const exportedWhenDefined: any;
|
||||
export { stdlib, optional, inputFailure, TYPES, relative_url, exportedPyWorker as PyWorker, exportedMPWorker as MPWorker, exportedHooks as hooks, exportedConfig as config, exportedWhenDefined as whenDefined };
|
||||
export { codemirror, stdlib, optional, inputFailure, TYPES, relative_url, exportedPyWorker as PyWorker, exportedMPWorker as MPWorker, exportedHooks as hooks, exportedConfig as config, exportedWhenDefined as whenDefined };
|
||||
|
||||
1
core/types/plugins.d.ts
vendored
1
core/types/plugins.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
declare const _default: {
|
||||
codemirror: () => Promise<typeof import("./plugins/codemirror.js")>;
|
||||
"deprecations-manager": () => Promise<typeof import("./plugins/deprecations-manager.js")>;
|
||||
donkey: () => Promise<typeof import("./plugins/donkey.js")>;
|
||||
error: () => Promise<typeof import("./plugins/error.js")>;
|
||||
|
||||
9
core/types/plugins/codemirror.d.ts
vendored
Normal file
9
core/types/plugins/codemirror.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
declare namespace _default {
|
||||
const core: Promise<typeof import("../3rd-party/codemirror.js")>;
|
||||
const state: Promise<typeof import("../3rd-party/codemirror_state.js")>;
|
||||
const python: Promise<typeof import("../3rd-party/codemirror_lang-python.js")>;
|
||||
const language: Promise<typeof import("../3rd-party/codemirror_language.js")>;
|
||||
const view: Promise<typeof import("../3rd-party/codemirror_view.js")>;
|
||||
const commands: Promise<typeof import("../3rd-party/codemirror_commands.js")>;
|
||||
}
|
||||
export default _default;
|
||||
Reference in New Issue
Block a user