@pyscript/core 0.5.7 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{codemirror-jVwF0Nvq.js → codemirror-DgYE9rP-.js} +2 -2
- package/dist/{codemirror-jVwF0Nvq.js.map → codemirror-DgYE9rP-.js.map} +1 -1
- package/dist/codemirror_commands-DzVQ2VDo.js +2 -0
- package/dist/codemirror_commands-DzVQ2VDo.js.map +1 -0
- package/dist/core-ChsB5XKV.js +2 -0
- package/dist/core-ChsB5XKV.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/{deprecations-manager-DSTPOQe0.js → deprecations-manager-BIGbxm9d.js} +2 -2
- package/dist/{deprecations-manager-DSTPOQe0.js.map → deprecations-manager-BIGbxm9d.js.map} +1 -1
- package/dist/{error-D2xNLHJ6.js → error-CZ_xZceV.js} +2 -2
- package/dist/{error-D2xNLHJ6.js.map → error-CZ_xZceV.js.map} +1 -1
- package/dist/{mpy-BR_l4RTo.js → mpy-sbGK0OC8.js} +2 -2
- package/dist/{mpy-BR_l4RTo.js.map → mpy-sbGK0OC8.js.map} +1 -1
- package/dist/{py-C4pTyP7z.js → py-DaDp5KT2.js} +2 -2
- package/dist/{py-C4pTyP7z.js.map → py-DaDp5KT2.js.map} +1 -1
- package/dist/py-editor-QaFsPbeG.js +2 -0
- package/dist/py-editor-QaFsPbeG.js.map +1 -0
- package/dist/{py-terminal-D1VMb_71.js → py-terminal-DkjvNCaY.js} +2 -2
- package/dist/{py-terminal-D1VMb_71.js.map → py-terminal-DkjvNCaY.js.map} +1 -1
- package/dist/{zip-BIfA-Q-T.js → zip-DrwYHuF9.js} +2 -2
- package/dist/zip-DrwYHuF9.js.map +1 -0
- package/package.json +9 -9
- package/src/plugins/py-editor.js +58 -23
- package/src/stdlib/pyscript/event_handling.py +10 -2
- package/src/stdlib/pyscript/web.py +1 -1
- package/src/stdlib/pyscript.js +2 -2
- package/dist/codemirror_commands-DbitAX-b.js +0 -2
- package/dist/codemirror_commands-DbitAX-b.js.map +0 -1
- package/dist/core-CHD-6qHy.js +0 -2
- package/dist/core-CHD-6qHy.js.map +0 -1
- package/dist/py-editor-DN6Ir37A.js +0 -2
- package/dist/py-editor-DN6Ir37A.js.map +0 -1
- package/dist/zip-BIfA-Q-T.js.map +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pyscript/core",
|
3
|
-
"version": "0.5.
|
3
|
+
"version": "0.5.8",
|
4
4
|
"type": "module",
|
5
5
|
"description": "PyScript",
|
6
6
|
"module": "./index.js",
|
@@ -19,7 +19,7 @@
|
|
19
19
|
"./package.json": "./package.json"
|
20
20
|
},
|
21
21
|
"scripts": {
|
22
|
-
"server": "npx static-handler --coi .",
|
22
|
+
"server": "echo \"➡️ TESTS @ $(tput bold)http://localhost:8080/tests/$(tput sgr0)\"; npx static-handler --coi .",
|
23
23
|
"build": "export ESLINT_USE_FLAT_CONFIG=true;npm run build:3rd-party && npm run build:stdlib && npm run build:plugins && npm run build:core && npm run build:tests-index && if [ -z \"$NO_MIN\" ]; then eslint src/ && npm run ts && npm run test:integration; fi",
|
24
24
|
"build:core": "rm -rf dist && rollup --config rollup/core.config.js && cp src/3rd-party/*.css dist/",
|
25
25
|
"build:flatted": "node rollup/flatted.cjs",
|
@@ -45,13 +45,13 @@
|
|
45
45
|
"dependencies": {
|
46
46
|
"@ungap/with-resolvers": "^0.1.0",
|
47
47
|
"basic-devtools": "^0.1.6",
|
48
|
-
"polyscript": "^0.15.
|
48
|
+
"polyscript": "^0.15.3",
|
49
49
|
"sticky-module": "^0.1.1",
|
50
50
|
"to-json-callback": "^0.1.1",
|
51
51
|
"type-checked-collections": "^0.1.7"
|
52
52
|
},
|
53
53
|
"devDependencies": {
|
54
|
-
"@codemirror/commands": "^6.6.
|
54
|
+
"@codemirror/commands": "^6.6.1",
|
55
55
|
"@codemirror/lang-python": "^6.1.6",
|
56
56
|
"@codemirror/language": "^6.10.2",
|
57
57
|
"@codemirror/state": "^6.4.1",
|
@@ -63,16 +63,16 @@
|
|
63
63
|
"@webreflection/toml-j0.4": "^1.1.3",
|
64
64
|
"@xterm/addon-fit": "^0.10.0",
|
65
65
|
"@xterm/addon-web-links": "^0.11.0",
|
66
|
-
"bun": "^1.1.
|
66
|
+
"bun": "^1.1.27",
|
67
67
|
"chokidar": "^3.6.0",
|
68
68
|
"codemirror": "^6.0.1",
|
69
|
-
"eslint": "^9.
|
69
|
+
"eslint": "^9.10.0",
|
70
70
|
"flatted": "^3.3.1",
|
71
|
-
"rollup": "^4.21.
|
71
|
+
"rollup": "^4.21.3",
|
72
72
|
"rollup-plugin-postcss": "^4.0.2",
|
73
73
|
"rollup-plugin-string": "^3.0.0",
|
74
|
-
"static-handler": "^0.
|
75
|
-
"typescript": "^5.
|
74
|
+
"static-handler": "^0.5.3",
|
75
|
+
"typescript": "^5.6.2",
|
76
76
|
"xterm": "^5.3.0",
|
77
77
|
"xterm-readline": "^1.1.1"
|
78
78
|
},
|
package/src/plugins/py-editor.js
CHANGED
@@ -24,6 +24,11 @@ const hooks = {
|
|
24
24
|
},
|
25
25
|
};
|
26
26
|
|
27
|
+
const validate = (config, result) => {
|
28
|
+
if (typeof result === "boolean") throw `Invalid source: ${config}`;
|
29
|
+
return result;
|
30
|
+
};
|
31
|
+
|
27
32
|
async function execute({ currentTarget }) {
|
28
33
|
const { env, pySrc, outDiv } = this;
|
29
34
|
const hasRunButton = !!currentTarget;
|
@@ -41,20 +46,31 @@ async function execute({ currentTarget }) {
|
|
41
46
|
};
|
42
47
|
const { config } = this;
|
43
48
|
if (config) {
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
// verify that config can be parsed and used
|
50
|
+
try {
|
51
|
+
details.configURL = relative_url(config);
|
52
|
+
if (config.endsWith(".toml")) {
|
53
|
+
const [{ parse }, toml] = await Promise.all([
|
54
|
+
import(
|
55
|
+
/* webpackIgnore: true */ "../3rd-party/toml.js"
|
56
|
+
),
|
57
|
+
fetch(config).then((r) => r.ok && r.text()),
|
58
|
+
]);
|
59
|
+
details.config = parse(validate(config, toml));
|
60
|
+
} else if (config.endsWith(".json")) {
|
61
|
+
const json = await fetch(config).then(
|
62
|
+
(r) => r.ok && r.json(),
|
63
|
+
);
|
64
|
+
details.config = validate(config, json);
|
65
|
+
} else {
|
66
|
+
details.configURL = relative_url("./config.txt");
|
67
|
+
details.config = JSON.parse(config);
|
68
|
+
}
|
69
|
+
details.version = offline_interpreter(details.config);
|
70
|
+
} catch (error) {
|
71
|
+
notify(error);
|
72
|
+
return;
|
56
73
|
}
|
57
|
-
details.version = offline_interpreter(details.config);
|
58
74
|
} else {
|
59
75
|
details.config = {};
|
60
76
|
}
|
@@ -75,9 +91,12 @@ async function execute({ currentTarget }) {
|
|
75
91
|
return envs.get(env).then((xworker) => {
|
76
92
|
xworker.onerror = ({ error }) => {
|
77
93
|
if (hasRunButton) {
|
78
|
-
outDiv.
|
79
|
-
|
80
|
-
|
94
|
+
outDiv.insertAdjacentHTML(
|
95
|
+
"beforeend",
|
96
|
+
`<span style='color:red'>${
|
97
|
+
error.message || error
|
98
|
+
}</span>\n`,
|
99
|
+
);
|
81
100
|
}
|
82
101
|
console.error(error);
|
83
102
|
};
|
@@ -92,7 +111,10 @@ async function execute({ currentTarget }) {
|
|
92
111
|
};
|
93
112
|
sync.writeErr = (str) => {
|
94
113
|
if (hasRunButton) {
|
95
|
-
outDiv.
|
114
|
+
outDiv.insertAdjacentHTML(
|
115
|
+
"beforeend",
|
116
|
+
`<span style='color:red'>${str}</span>\n`,
|
117
|
+
);
|
96
118
|
} else {
|
97
119
|
notify(str);
|
98
120
|
console.error(str);
|
@@ -192,9 +214,22 @@ const init = async (script, type, interpreter) => {
|
|
192
214
|
|
193
215
|
configs.set(env, hasConfig);
|
194
216
|
|
195
|
-
let source = script.
|
196
|
-
|
197
|
-
|
217
|
+
let source = script.textContent;
|
218
|
+
|
219
|
+
// verify the src points to a valid file that can be parsed
|
220
|
+
const { src } = script;
|
221
|
+
if (src) {
|
222
|
+
try {
|
223
|
+
source = validate(
|
224
|
+
src,
|
225
|
+
await fetch(src).then((b) => b.ok && b.text()),
|
226
|
+
);
|
227
|
+
} catch (error) {
|
228
|
+
notify(error);
|
229
|
+
return;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
198
233
|
const context = {
|
199
234
|
// allow the listener to be overridden at distance
|
200
235
|
handleEvent: execute,
|
@@ -273,14 +308,14 @@ const init = async (script, type, interpreter) => {
|
|
273
308
|
},
|
274
309
|
});
|
275
310
|
|
276
|
-
const
|
311
|
+
const notifyEditor = () => {
|
277
312
|
const event = new Event(`${type}-editor`, { bubbles: true });
|
278
313
|
script.dispatchEvent(event);
|
279
314
|
};
|
280
315
|
|
281
316
|
if (isSetup) {
|
282
317
|
await context.handleEvent({ currentTarget: null });
|
283
|
-
|
318
|
+
notifyEditor();
|
284
319
|
return;
|
285
320
|
}
|
286
321
|
|
@@ -339,7 +374,7 @@ const init = async (script, type, interpreter) => {
|
|
339
374
|
});
|
340
375
|
|
341
376
|
editor.focus();
|
342
|
-
|
377
|
+
notifyEditor();
|
343
378
|
};
|
344
379
|
|
345
380
|
// avoid too greedy MutationObserver operations at distance
|
@@ -41,8 +41,16 @@ def when(event_type=None, selector=None):
|
|
41
41
|
# Function doesn't receive events
|
42
42
|
if not sig.parameters:
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
# Function is async: must be awaited
|
45
|
+
if inspect.iscoroutinefunction(func):
|
46
|
+
|
47
|
+
async def wrapper(*args, **kwargs):
|
48
|
+
await func()
|
49
|
+
|
50
|
+
else:
|
51
|
+
|
52
|
+
def wrapper(*args, **kwargs):
|
53
|
+
func()
|
46
54
|
|
47
55
|
else:
|
48
56
|
wrapper = func
|
package/src/stdlib/pyscript.js
CHANGED
@@ -3,14 +3,14 @@ export default {
|
|
3
3
|
"pyscript": {
|
4
4
|
"__init__.py": "from polyscript import lazy_py_modules as py_import\nfrom pyscript.display import HTML,display\nfrom pyscript.fetch import fetch\nfrom pyscript.magic_js import RUNNING_IN_WORKER,PyWorker,config,current_target,document,js_import,js_modules,sync,window\nfrom pyscript.storage import Storage,storage\nfrom pyscript.websocket import WebSocket\nif not RUNNING_IN_WORKER:from pyscript.workers import create_named_worker,workers\ntry:from pyscript.event_handling import when\nexcept:from pyscript.util import NotSupported;when=NotSupported('pyscript.when','pyscript.when currently not available with this interpreter')",
|
5
5
|
"display.py": "_L='_repr_mimebundle_'\n_K='image/svg+xml'\n_J='application/json'\n_I='__repr__'\n_H='savefig'\n_G='text/html'\n_F='image/jpeg'\n_E='application/javascript'\n_D='utf-8'\n_C='text/plain'\n_B='image/png'\n_A=None\nimport base64,html,io,re\nfrom pyscript.magic_js import current_target,document,window\n_MIME_METHODS={_H:_B,'_repr_javascript_':_E,'_repr_json_':_J,'_repr_latex':'text/latex','_repr_png_':_B,'_repr_jpeg_':_F,'_repr_pdf_':'application/pdf','_repr_svg_':_K,'_repr_markdown_':'text/markdown','_repr_html_':_G,_I:_C}\ndef _render_image(mime,value,meta):\n\tA=value\n\tif isinstance(A,bytes):A=base64.b64encode(A).decode(_D)\n\tB=re.compile('^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$')\n\tif len(A)>0 and not B.match(A):A=base64.b64encode(A.encode(_D)).decode(_D)\n\tC=f\"data:{mime};charset=utf-8;base64,{A}\";D=' '.join(['{k}=\"{v}\"'for(A,B)in meta.items()]);return f'<img src=\"{C}\" {D}></img>'\ndef _identity(value,meta):return value\n_MIME_RENDERERS={_C:html.escape,_G:_identity,_B:lambda value,meta:_render_image(_B,value,meta),_F:lambda value,meta:_render_image(_F,value,meta),_K:_identity,_J:_identity,_E:lambda value,meta:f\"<script>{value}<\\\\/script>\"}\nclass HTML:\n\tdef __init__(A,html):A._html=html\n\tdef _repr_html_(A):return A._html\ndef _eval_formatter(obj,print_method):\n\tB=obj;A=print_method\n\tif A==_I:return repr(B)\n\telif hasattr(B,A):\n\t\tif A==_H:C=io.BytesIO();B.savefig(C,format='png');C.seek(0);return base64.b64encode(C.read()).decode(_D)\n\t\treturn getattr(B,A)()\n\telif A==_L:return{},{}\ndef _format_mime(obj):\n\tC=obj\n\tif isinstance(C,str):return html.escape(C),_C\n\tD=_eval_formatter(C,_L)\n\tif isinstance(D,tuple):E,I=D\n\telse:E=D\n\tA,F=_A,[]\n\tfor(H,B)in _MIME_METHODS.items():\n\t\tif B in E:A=E[B]\n\t\telse:A=_eval_formatter(C,H)\n\t\tif A is _A:continue\n\t\telif B not in _MIME_RENDERERS:F.append(B);continue\n\t\tbreak\n\tif A is _A:\n\t\tif F:window.console.warn(f\"Rendered object requested unavailable MIME renderers: {F}\")\n\t\tA=repr(A);B=_C\n\telif isinstance(A,tuple):A,G=A\n\telse:G={}\n\treturn _MIME_RENDERERS[B](A,G),B\ndef _write(element,value,append=False):\n\tB=element;C,D=_format_mime(value)\n\tif C=='\\\\n':return\n\tif append:A=document.createElement('div');B.append(A)\n\telse:\n\t\tA=B.lastElementChild\n\t\tif A is _A:A=B\n\tif D in(_E,_G):E=document.createRange().createContextualFragment(C);A.append(E)\n\telse:A.innerHTML=C\ndef display(*D,target=_A,append=True):\n\tC=append;A=target\n\tif A is _A:A=current_target()\n\telif not isinstance(A,str):raise TypeError(f\"target must be str or None, not {A.__class__.__name__}\")\n\telif A=='':raise ValueError('Cannot have an empty target')\n\telif A.startswith('#'):A=A[1:]\n\tB=document.getElementById(A)\n\tif B is _A:raise ValueError(f\"Invalid selector with id={A}. Cannot be found in the page.\")\n\tif B.tagName=='SCRIPT'and hasattr(B,'target'):B=B.target\n\tfor E in D:\n\t\tif not C:B.replaceChildren()\n\t\t_write(B,E,append=C)",
|
6
|
-
"event_handling.py": "import inspect\ntry:from pyodide.ffi.wrappers import add_event_listener\nexcept ImportError:\n\tdef add_event_listener(el,event_type,func):el.addEventListener(event_type,func)\nfrom pyscript.magic_js import document\ndef when(event_type=None,selector=None):\n\tA=selector\n\tdef B(func):\n\t\tB=func;from pyscript.web import Element as E,ElementCollection as F\n\t\tif isinstance(A,str):C=document.querySelectorAll(A)\n\t\telif isinstance(A,E):C=[A._dom_element]\n\t\telif isinstance(A,F):C=[A._dom_element for A in A]\n\t\telif isinstance(A,list):C=A\n\t\telse:C=[A]\n\t\ttry:\n\t\t\tG=inspect.signature(B)\n\t\t\tif not G.parameters:\n\t\t\t\tdef D(*A,**C):B()\n\t\t\telse:D=B\n\t\texcept AttributeError:\n\t\t\tdef D(*C,**D):\n\t\t\t\ttry:return B(*C,**D)\n\t\t\t\texcept TypeError as A:\n\t\t\t\t\tif'takes'in str(A)and'positional arguments'in str(A):return B()\n\t\t\t\t\traise\n\t\tfor H in C:add_event_listener(H,event_type,D)\n\t\treturn B\n\treturn B",
|
6
|
+
"event_handling.py": "import inspect\ntry:from pyodide.ffi.wrappers import add_event_listener\nexcept ImportError:\n\tdef add_event_listener(el,event_type,func):el.addEventListener(event_type,func)\nfrom pyscript.magic_js import document\ndef when(event_type=None,selector=None):\n\tA=selector\n\tdef B(func):\n\t\tB=func;from pyscript.web import Element as E,ElementCollection as F\n\t\tif isinstance(A,str):C=document.querySelectorAll(A)\n\t\telif isinstance(A,E):C=[A._dom_element]\n\t\telif isinstance(A,F):C=[A._dom_element for A in A]\n\t\telif isinstance(A,list):C=A\n\t\telse:C=[A]\n\t\ttry:\n\t\t\tG=inspect.signature(B)\n\t\t\tif not G.parameters:\n\t\t\t\tif inspect.iscoroutinefunction(B):\n\t\t\t\t\tasync def D(*A,**C):await B()\n\t\t\t\telse:\n\t\t\t\t\tdef D(*A,**C):B()\n\t\t\telse:D=B\n\t\texcept AttributeError:\n\t\t\tdef D(*C,**D):\n\t\t\t\ttry:return B(*C,**D)\n\t\t\t\texcept TypeError as A:\n\t\t\t\t\tif'takes'in str(A)and'positional arguments'in str(A):return B()\n\t\t\t\t\traise\n\t\tfor H in C:add_event_listener(H,event_type,D)\n\t\treturn B\n\treturn B",
|
7
7
|
"fetch.py": "import json,js\nfrom pyscript.util import as_bytearray\nclass _Response:\n\tdef __init__(A,response):A._response=response\n\tdef __getattr__(A,attr):return getattr(A._response,attr)\n\tasync def arrayBuffer(B):\n\t\tA=await B._response.arrayBuffer()\n\t\tif hasattr(A,'to_py'):return A.to_py()\n\t\treturn memoryview(as_bytearray(A))\n\tasync def blob(A):return await A._response.blob()\n\tasync def bytearray(A):B=await A._response.arrayBuffer();return as_bytearray(B)\n\tasync def json(A):return json.loads(await A.text())\n\tasync def text(A):return await A._response.text()\nclass _DirectResponse:\n\t@staticmethod\n\tdef setup(promise,response):A=promise;A._response=_Response(response);return A._response\n\tdef __init__(B,promise):A=promise;B._promise=A;A._response=None;A.arrayBuffer=B.arrayBuffer;A.blob=B.blob;A.bytearray=B.bytearray;A.json=B.json;A.text=B.text\n\tasync def _response(A):\n\t\tif not A._promise._response:await A._promise\n\t\treturn A._promise._response\n\tasync def arrayBuffer(A):B=await A._response();return await B.arrayBuffer()\n\tasync def blob(A):B=await A._response();return await B.blob()\n\tasync def bytearray(A):B=await A._response();return await B.bytearray()\n\tasync def json(A):B=await A._response();return await B.json()\n\tasync def text(A):B=await A._response();return await B.text()\ndef fetch(url,**B):C=js.JSON.parse(json.dumps(B));D=lambda response,*B:_DirectResponse.setup(A,response);A=js.fetch(url,C).then(D);_DirectResponse(A);return A",
|
8
8
|
"ffi.py": "try:\n\timport js;from pyodide.ffi import create_proxy as _cp,to_js as _py_tjs;from_entries=js.Object.fromEntries\n\tdef _tjs(value,**A):\n\t\tB='dict_converter'\n\t\tif not hasattr(A,B):A[B]=from_entries\n\t\treturn _py_tjs(value,**A)\nexcept:from jsffi import create_proxy as _cp;from jsffi import to_js as _tjs\ncreate_proxy=_cp\nto_js=_tjs",
|
9
9
|
"flatted.py": "import json as _json\nclass _Known:\n\tdef __init__(A):A.key=[];A.value=[]\nclass _String:\n\tdef __init__(A,value):A.value=value\ndef _array_keys(value):\n\tA=[];B=0\n\tfor C in value:A.append(B);B+=1\n\treturn A\ndef _object_keys(value):\n\tA=[]\n\tfor B in value:A.append(B)\n\treturn A\ndef _is_array(value):A=value;return isinstance(A,list)or isinstance(A,tuple)\ndef _is_object(value):return isinstance(value,dict)\ndef _is_string(value):return isinstance(value,str)\ndef _index(known,input,value):B=value;A=known;input.append(B);C=str(len(input)-1);A.key.append(B);A.value.append(C);return C\ndef _loop(keys,input,known,output):\n\tA=output\n\tfor B in keys:\n\t\tC=A[B]\n\t\tif isinstance(C,_String):_ref(B,input[int(C.value)],input,known,A)\n\treturn A\ndef _ref(key,value,input,known,output):\n\tB=known;A=value\n\tif _is_array(A)and not A in B:B.append(A);A=_loop(_array_keys(A),input,B,A)\n\telif _is_object(A)and not A in B:B.append(A);A=_loop(_object_keys(A),input,B,A)\n\toutput[key]=A\ndef _relate(known,input,value):\n\tB=known;A=value\n\tif _is_string(A)or _is_array(A)or _is_object(A):\n\t\ttry:return B.value[B.key.index(A)]\n\t\texcept:return _index(B,input,A)\n\treturn A\ndef _transform(known,input,value):\n\tB=known;A=value\n\tif _is_array(A):\n\t\tC=[]\n\t\tfor F in A:C.append(_relate(B,input,F))\n\t\treturn C\n\tif _is_object(A):\n\t\tD={}\n\t\tfor E in A:D[E]=_relate(B,input,A[E])\n\t\treturn D\n\treturn A\ndef _wrap(value):\n\tA=value\n\tif _is_string(A):return _String(A)\n\tif _is_array(A):\n\t\tB=0\n\t\tfor D in A:A[B]=_wrap(D);B+=1\n\telif _is_object(A):\n\t\tfor C in A:A[C]=_wrap(A[C])\n\treturn A\ndef parse(value,*C,**D):\n\tA=value;E=_json.loads(A,*C,**D);B=[]\n\tfor A in E:B.append(_wrap(A))\n\tinput=[]\n\tfor A in B:\n\t\tif isinstance(A,_String):input.append(A.value)\n\t\telse:input.append(A)\n\tA=input[0]\n\tif _is_array(A):return _loop(_array_keys(A),input,[A],A)\n\tif _is_object(A):return _loop(_object_keys(A),input,[A],A)\n\treturn A\ndef stringify(value,*D,**E):\n\tB=_Known();input=[];C=[];A=int(_index(B,input,value))\n\twhile A<len(input):C.append(_transform(B,input,input[A]));A+=1\n\treturn _json.dumps(C,*D,**E)",
|
10
10
|
"magic_js.py": "import json,sys,js as globalThis\nfrom polyscript import config as _config,js_modules\nfrom pyscript.util import NotSupported\nRUNNING_IN_WORKER=not hasattr(globalThis,'document')\nconfig=json.loads(globalThis.JSON.stringify(_config))\nclass JSModule:\n\tdef __init__(A,name):A.name=name\n\tdef __getattr__(B,field):\n\t\tA=field\n\t\tif not A.startswith('_'):return getattr(getattr(js_modules,B.name),A)\nfor name in globalThis.Reflect.ownKeys(js_modules):sys.modules[f\"pyscript.js_modules.{name}\"]=JSModule(name)\nsys.modules['pyscript.js_modules']=js_modules\nif RUNNING_IN_WORKER:\n\timport polyscript;PyWorker=NotSupported('pyscript.PyWorker','pyscript.PyWorker works only when running in the main thread')\n\ttry:import js;window=polyscript.xworker.window;document=window.document;js.document=document;js_import=window.Function('return (...urls) => Promise.all(urls.map((url) => import(url)))')()\n\texcept:message='Unable to use `window` or `document` -> https://docs.pyscript.net/latest/faq/#sharedarraybuffer';globalThis.console.warn(message);window=NotSupported('pyscript.window',message);document=NotSupported('pyscript.document',message);js_import=None\n\tsync=polyscript.xworker.sync\n\tdef current_target():return polyscript.target\nelse:\n\timport _pyscript;from _pyscript import PyWorker,js_import;window=globalThis;document=globalThis.document;sync=NotSupported('pyscript.sync','pyscript.sync works only when running in a worker')\n\tdef current_target():return _pyscript.target",
|
11
11
|
"storage.py": "_C='memoryview'\n_B='bytearray'\n_A='generic'\nfrom polyscript import storage as _storage\nfrom pyscript.flatted import parse as _parse\nfrom pyscript.flatted import stringify as _stringify\ndef _to_idb(value):\n\tA=value\n\tif A is None:return _stringify(['null',0])\n\tif isinstance(A,(bool,float,int,str,list,dict,tuple)):return _stringify([_A,A])\n\tif isinstance(A,bytearray):return _stringify([_B,[A for A in A]])\n\tif isinstance(A,memoryview):return _stringify([_C,[A for A in A]])\n\traise TypeError(f\"Unexpected value: {A}\")\ndef _from_idb(value):\n\tC=value;A,B=_parse(C)\n\tif A=='null':return\n\tif A==_A:return B\n\tif A==_B:return bytearray(B)\n\tif A==_C:return memoryview(bytearray(B))\n\treturn C\nclass Storage(dict):\n\tdef __init__(B,store):A=store;super().__init__({A:_from_idb(B)for(A,B)in A.entries()});B.__store__=A\n\tdef __delitem__(A,attr):A.__store__.delete(attr);super().__delitem__(attr)\n\tdef __setitem__(B,attr,value):A=value;B.__store__.set(attr,_to_idb(A));super().__setitem__(attr,A)\n\tdef clear(A):A.__store__.clear();super().clear()\n\tasync def sync(A):await A.__store__.sync()\nasync def storage(name='',storage_class=Storage):\n\tif not name:raise ValueError('The storage name must be defined')\n\treturn storage_class(await _storage(f\"@pyscript/{name}\"))",
|
12
12
|
"util.py": "import js\ndef as_bytearray(buffer):\n\tA=js.Uint8Array.new(buffer);B=A.length;C=bytearray(B)\n\tfor D in range(0,B):C[D]=A[D]\n\treturn C\nclass NotSupported:\n\tdef __init__(A,name,error):object.__setattr__(A,'name',name);object.__setattr__(A,'error',error)\n\tdef __repr__(A):return f\"<NotSupported {A.name} [{A.error}]>\"\n\tdef __getattr__(A,attr):raise AttributeError(A.error)\n\tdef __setattr__(A,attr,value):raise AttributeError(A.error)\n\tdef __call__(A,*B):raise TypeError(A.error)",
|
13
|
-
"web.py": "_A=None\nfrom pyscript import document,when\ndef wrap_dom_element(dom_element):return Element.wrap_dom_element(dom_element)\nclass Element:\n\telement_classes_by_tag_name={}\n\t@classmethod\n\tdef get_tag_name(A):return A.__name__.replace('_','')\n\t@classmethod\n\tdef register_element_classes(B,element_classes):\n\t\tfor A in element_classes:C=A.get_tag_name();B.element_classes_by_tag_name[C]=A\n\t@classmethod\n\tdef unregister_element_classes(A,element_classes):\n\t\tfor B in element_classes:C=B.get_tag_name();A.element_classes_by_tag_name.pop(C,_A)\n\t@classmethod\n\tdef wrap_dom_element(A,dom_element):B=dom_element;C=A.element_classes_by_tag_name.get(B.tagName.lower(),A);return C(dom_element=B)\n\tdef __init__(A,dom_element=_A,classes=_A,style=_A,**B):A._dom_element=dom_element or document.createElement(type(A).get_tag_name());A._classes=Classes(A);A._style=Style(A);A.update(classes=classes,style=style,**B)\n\tdef __eq__(A,obj):return isinstance(obj,Element)and obj._dom_element==A._dom_element\n\tdef __getitem__(B,key):\n\t\tA=key\n\t\tif isinstance(A,int)or isinstance(A,slice):return B.children[A]\n\t\treturn B.find(A)\n\tdef __getattr__(B,name):\n\t\tA=name\n\t\tif A.endswith('_'):A=A[:-1]\n\t\treturn getattr(B._dom_element,A)\n\tdef __setattr__(C,name,value):\n\t\tB=value;A=name\n\t\tif A.startswith('_'):super().__setattr__(A,B)\n\t\telse:\n\t\t\tif A.endswith('_'):A=A[:-1]\n\t\t\tsetattr(C._dom_element,A,B)\n\t@property\n\tdef children(self):return ElementCollection.wrap_dom_elements(self._dom_element.children)\n\t@property\n\tdef classes(self):return self._classes\n\t@property\n\tdef parent(self):\n\t\tif self._dom_element.parentElement is _A:return\n\t\treturn Element.wrap_dom_element(self._dom_element.parentElement)\n\t@property\n\tdef style(self):return self._style\n\tdef append(B,*C):\n\t\tfor A in C:\n\t\t\tif isinstance(A,Element):B._dom_element.appendChild(A._dom_element)\n\t\t\telif isinstance(A,ElementCollection):\n\t\t\t\tfor D in A:B._dom_element.appendChild(D._dom_element)\n\t\t\telif isinstance(A,list)or isinstance(A,tuple):\n\t\t\t\tfor E in A:B.append(E)\n\t\t\telse:\n\t\t\t\ttry:A.tagName;B._dom_element.appendChild(A)\n\t\t\t\texcept AttributeError:\n\t\t\t\t\ttry:\n\t\t\t\t\t\tA.length\n\t\t\t\t\t\tfor F in A:B._dom_element.appendChild(F)\n\t\t\t\t\texcept AttributeError:raise TypeError(f'Element \"{A}\" is a proxy object, \"but not a valid element or a NodeList.')\n\tdef clone(B,clone_id=_A):A=Element.wrap_dom_element(B._dom_element.cloneNode(True));A.id=clone_id;return A\n\tdef find(A,selector):return ElementCollection.wrap_dom_elements(A._dom_element.querySelectorAll(selector))\n\tdef show_me(A):A._dom_element.scrollIntoView()\n\tdef update(A,classes=_A,style=_A,**D):\n\t\tC=style;B=classes\n\t\tif B:A.classes.add(B)\n\t\tif C:A.style.set(**C)\n\t\tfor(E,F)in D.items():setattr(A,E,F)\nclass Classes:\n\tdef __init__(A,element):A._element=element;A._class_list=A._element._dom_element.classList\n\tdef __contains__(A,item):return item in A._class_list\n\tdef __eq__(C,other):\n\t\tA=other\n\t\tif isinstance(A,Classes):B=list(A._class_list)\n\t\telse:\n\t\t\ttry:B=iter(A)\n\t\t\texcept TypeError:return False\n\t\treturn set(C._class_list)==set(B)\n\tdef __iter__(A):return iter(A._class_list)\n\tdef __len__(A):return A._class_list.length\n\tdef __repr__(A):return f\"Classes({', '.join(A._class_list)})\"\n\tdef __str__(A):return' '.join(A._class_list)\n\tdef add(B,*C):\n\t\tfor A in C:\n\t\t\tif isinstance(A,list):\n\t\t\t\tfor D in A:B.add(D)\n\t\t\telse:B._class_list.add(A)\n\tdef contains(A,class_name):return class_name in A\n\tdef remove(B,*C):\n\t\tfor A in C:\n\t\t\tif isinstance(A,list):\n\t\t\t\tfor D in A:B.remove(D)\n\t\t\telse:B._class_list.remove(A)\n\tdef replace(A,old_class,new_class):A.remove(old_class);A.add(new_class)\n\tdef toggle(A,*C):\n\t\tfor B in C:\n\t\t\tif B in A:A.remove(B)\n\t\t\telse:A.add(B)\nclass HasOptions:\n\t@property\n\tdef options(self):\n\t\tA=self\n\t\tif not hasattr(A,'_options'):A._options=Options(A)\n\t\treturn A._options\nclass Options:\n\tdef __init__(A,element):A._element=element\n\tdef __getitem__(A,key):return A.options[key]\n\tdef __iter__(A):yield from A.options\n\tdef __len__(A):return len(A.options)\n\tdef __repr__(A):return f\"{A.__class__.__name__} (length: {len(A)}) {A.options}\"\n\t@property\n\tdef options(self):return[Element.wrap_dom_element(A)for A in self._element._dom_element.options]\n\t@property\n\tdef selected(self):return self.options[self._element._dom_element.selectedIndex]\n\tdef add(D,value=_A,html=_A,text=_A,before=_A,**B):\n\t\tC=value;A=before\n\t\tif C is not _A:B['value']=C\n\t\tif html is not _A:B['innerHTML']=html\n\t\tif text is not _A:B['text']=text\n\t\tE=option(**B)\n\t\tif A:\n\t\t\tif isinstance(A,Element):A=A._dom_element\n\t\tD._element._dom_element.add(E._dom_element,A)\n\tdef clear(A):\n\t\twhile len(A)>0:A.remove(0)\n\tdef remove(A,index):A._element._dom_element.remove(index)\nclass Style:\n\tdef __init__(A,element):A._element=element;A._style=A._element._dom_element.style\n\tdef __getitem__(A,key):return A._style.getPropertyValue(key)\n\tdef __setitem__(A,key,value):A._style.setProperty(key,value)\n\tdef remove(A,key):A._style.removeProperty(key)\n\tdef set(A,**B):\n\t\tfor(C,D)in B.items():A._element._dom_element.style.setProperty(C,D)\n\t@property\n\tdef visible(self):return self._element._dom_element.style.visibility\n\t@visible.setter\n\tdef visible(self,value):self._element._dom_element.style.visibility=value\nclass ContainerElement(Element):\n\tdef __init__(B,*C,children=_A,dom_element=_A,style=_A,classes=_A,**D):\n\t\tsuper().__init__(dom_element=dom_element,style=style,classes=classes,**D)\n\t\tfor A in list(C)+(children or[]):\n\t\t\tif isinstance(A,Element)or isinstance(A,ElementCollection):B.append(A)\n\t\t\telse:B.innerHTML+=A\n\tdef __iter__(A):yield from A.children\nclass ClassesCollection:\n\tdef __init__(A,collection):A._collection=collection\n\tdef __contains__(A,class_name):\n\t\tfor B in A._collection:\n\t\t\tif class_name in B.classes:return True\n\t\treturn False\n\tdef __eq__(B,other):A=other;return isinstance(A,ClassesCollection)and B._collection==A._collection\n\tdef __iter__(A):\n\t\tfor B in A._all_class_names():yield B\n\tdef __len__(A):return len(A._all_class_names())\n\tdef __repr__(A):return f\"ClassesCollection({repr(A._collection)})\"\n\tdef __str__(A):return' '.join(A._all_class_names())\n\tdef add(A,*B):\n\t\tfor C in A._collection:C.classes.add(*B)\n\tdef contains(A,class_name):return class_name in A\n\tdef remove(A,*B):\n\t\tfor C in A._collection:C.classes.remove(*B)\n\tdef replace(A,old_class,new_class):\n\t\tfor B in A._collection:B.classes.replace(old_class,new_class)\n\tdef toggle(A,*B):\n\t\tfor C in A._collection:C.classes.toggle(*B)\n\tdef _all_class_names(B):\n\t\tA=set()\n\t\tfor C in B._collection:\n\t\t\tfor D in C.classes:A.add(D)\n\t\treturn A\nclass StyleCollection:\n\tdef __init__(A,collection):A._collection=collection\n\tdef __getitem__(A,key):return[A.style[key]for A in A._collection._elements]\n\tdef __setitem__(A,key,value):\n\t\tfor B in A._collection._elements:B.style[key]=value\n\tdef __repr__(A):return f\"StyleCollection({repr(A._collection)})\"\n\tdef remove(A,key):\n\t\tfor B in A._collection._elements:B.style.remove(key)\nclass ElementCollection:\n\t@classmethod\n\tdef wrap_dom_elements(A,dom_elements):return A([Element.wrap_dom_element(A)for A in dom_elements])\n\tdef __init__(A,elements):A._elements=elements;A._classes=ClassesCollection(A);A._style=StyleCollection(A)\n\tdef __eq__(A,obj):return isinstance(obj,ElementCollection)and obj._elements==A._elements\n\tdef __getitem__(B,key):\n\t\tA=key\n\t\tif isinstance(A,int):return B._elements[A]\n\t\telif isinstance(A,slice):return ElementCollection(B._elements[A])\n\t\treturn B.find(A)\n\tdef __iter__(A):yield from A._elements\n\tdef __len__(A):return len(A._elements)\n\tdef __repr__(A):return f\"{A.__class__.__name__} (length: {len(A._elements)}) {A._elements}\"\n\tdef __getattr__(A,name):return[getattr(A,name)for A in A._elements]\n\tdef __setattr__(C,name,value):\n\t\tB=value;A=name\n\t\tif A.startswith('_'):super().__setattr__(A,B)\n\t\telse:\n\t\t\tfor D in C._elements:setattr(D,A,B)\n\t@property\n\tdef classes(self):return self._classes\n\t@property\n\tdef elements(self):return self._elements\n\t@property\n\tdef style(self):return self._style\n\tdef find(B,selector):\n\t\tA=[]\n\t\tfor C in B._elements:A.extend(C.find(selector))\n\t\treturn ElementCollection(A)\nclass a(ContainerElement):0\nclass abbr(ContainerElement):0\nclass address(ContainerElement):0\nclass area(Element):0\nclass article(ContainerElement):0\nclass aside(ContainerElement):0\nclass audio(ContainerElement):0\nclass b(ContainerElement):0\nclass base(Element):0\nclass blockquote(ContainerElement):0\nclass body(ContainerElement):0\nclass br(Element):0\nclass button(ContainerElement):0\nclass canvas(ContainerElement):\n\tdef download(A,filename='snapped.png'):B=a(download=filename,href=A._dom_element.toDataURL());A.append(B);B._dom_element.click()\n\tdef draw(E,what,width=_A,height=_A):\n\t\tC=height;B=width;A=what\n\t\tif isinstance(A,Element):A=A._dom_element\n\t\tD=E._dom_element.getContext('2d')\n\t\tif B or C:D.drawImage(A,0,0,B,C)\n\t\telse:D.drawImage(A,0,0)\nclass caption(ContainerElement):0\nclass cite(ContainerElement):0\nclass code(ContainerElement):0\nclass col(Element):0\nclass colgroup(ContainerElement):0\nclass data(ContainerElement):0\nclass datalist(ContainerElement,HasOptions):0\nclass dd(ContainerElement):0\nclass del_(ContainerElement):0\nclass details(ContainerElement):0\nclass dialog(ContainerElement):0\nclass div(ContainerElement):0\nclass dl(ContainerElement):0\nclass dt(ContainerElement):0\nclass em(ContainerElement):0\nclass embed(Element):0\nclass fieldset(ContainerElement):0\nclass figcaption(ContainerElement):0\nclass figure(ContainerElement):0\nclass footer(ContainerElement):0\nclass form(ContainerElement):0\nclass h1(ContainerElement):0\nclass h2(ContainerElement):0\nclass h3(ContainerElement):0\nclass h4(ContainerElement):0\nclass h5(ContainerElement):0\nclass h6(ContainerElement):0\nclass head(ContainerElement):0\nclass header(ContainerElement):0\nclass hgroup(ContainerElement):0\nclass hr(Element):0\nclass html(ContainerElement):0\nclass i(ContainerElement):0\nclass iframe(ContainerElement):0\nclass img(Element):0\nclass input_(Element):0\nclass ins(ContainerElement):0\nclass kbd(ContainerElement):0\nclass label(ContainerElement):0\nclass legend(ContainerElement):0\nclass li(ContainerElement):0\nclass link(Element):0\nclass main(ContainerElement):0\nclass map_(ContainerElement):0\nclass mark(ContainerElement):0\nclass menu(ContainerElement):0\nclass meta(ContainerElement):0\nclass meter(ContainerElement):0\nclass nav(ContainerElement):0\nclass object_(ContainerElement):0\nclass ol(ContainerElement):0\nclass optgroup(ContainerElement,HasOptions):0\nclass option(ContainerElement):0\nclass output(ContainerElement):0\nclass p(ContainerElement):0\nclass param(ContainerElement):0\nclass picture(ContainerElement):0\nclass pre(ContainerElement):0\nclass progress(ContainerElement):0\nclass q(ContainerElement):0\nclass s(ContainerElement):0\nclass script(ContainerElement):0\nclass section(ContainerElement):0\nclass select(ContainerElement,HasOptions):0\nclass small(ContainerElement):0\nclass source(Element):0\nclass span(ContainerElement):0\nclass strong(ContainerElement):0\nclass style(ContainerElement):0\nclass sub(ContainerElement):0\nclass summary(ContainerElement):0\nclass sup(ContainerElement):0\nclass table(ContainerElement):0\nclass tbody(ContainerElement):0\nclass td(ContainerElement):0\nclass template(ContainerElement):0\nclass textarea(ContainerElement):0\nclass tfoot(ContainerElement):0\nclass th(ContainerElement):0\nclass thead(ContainerElement):0\nclass time(ContainerElement):0\nclass title(ContainerElement):0\nclass tr(ContainerElement):0\nclass track(Element):0\nclass u(ContainerElement):0\nclass ul(ContainerElement):0\nclass var(ContainerElement):0\nclass video(ContainerElement):\n\tdef snap(D,to=_A,width=_A,height=_A):\n\t\tG='CANVAS';F='Element to snap to must be a canvas.';C=height;B=width;A=to;B=B if B is not _A else D.videoWidth;C=C if C is not _A else D.videoHeight\n\t\tif A is _A:A=canvas(width=B,height=C)\n\t\telif isinstance(A,Element):\n\t\t\tif A.tag!='canvas':raise TypeError(F)\n\t\telif getattr(A,'tagName','')==G:A=canvas(dom_element=A)\n\t\telif isinstance(A,str):\n\t\t\tE=document.querySelectorAll(A)\n\t\t\tif E.length==0:raise TypeError('No element with selector {to} to snap to.')\n\t\t\tif E[0].tagName!=G:raise TypeError(F)\n\t\t\tA=canvas(dom_element=E[0])\n\t\tA.draw(D,B,C);return A\nclass wbr(Element):0\nELEMENT_CLASSES=[a,abbr,address,area,article,aside,audio,b,base,blockquote,body,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,dd,del_,details,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,img,input_,ins,kbd,label,legend,li,link,main,map_,mark,menu,meta,meter,nav,object_,ol,optgroup,option,output,p,param,picture,pre,progress,q,s,script,section,select,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,u,ul,var,video,wbr]\nElement.register_element_classes(ELEMENT_CLASSES)\nclass Page:\n\tdef __init__(A):A.html=Element.wrap_dom_element(document.documentElement);A.body=Element.wrap_dom_element(document.body);A.head=Element.wrap_dom_element(document.head)\n\tdef __getitem__(A,selector):return A.find(selector)\n\t@property\n\tdef title(self):return document.title\n\t@title.setter\n\tdef title(self,value):document.title=value\n\tdef append(A,*B):A.body.append(*B)\n\tdef find(A,selector):return ElementCollection.wrap_dom_elements(document.querySelectorAll(selector))\npage=Page()",
|
13
|
+
"web.py": "_A=None\nfrom pyscript import document,when\ndef wrap_dom_element(dom_element):return Element.wrap_dom_element(dom_element)\nclass Element:\n\telement_classes_by_tag_name={}\n\t@classmethod\n\tdef get_tag_name(A):return A.__name__.replace('_','')\n\t@classmethod\n\tdef register_element_classes(B,element_classes):\n\t\tfor A in element_classes:C=A.get_tag_name();B.element_classes_by_tag_name[C]=A\n\t@classmethod\n\tdef unregister_element_classes(A,element_classes):\n\t\tfor B in element_classes:C=B.get_tag_name();A.element_classes_by_tag_name.pop(C,_A)\n\t@classmethod\n\tdef wrap_dom_element(A,dom_element):B=dom_element;C=A.element_classes_by_tag_name.get(B.tagName.lower(),A);return C(dom_element=B)\n\tdef __init__(A,dom_element=_A,classes=_A,style=_A,**B):A._dom_element=dom_element or document.createElement(type(A).get_tag_name());A._classes=Classes(A);A._style=Style(A);A.update(classes=classes,style=style,**B)\n\tdef __eq__(A,obj):return isinstance(obj,Element)and obj._dom_element==A._dom_element\n\tdef __getitem__(B,key):\n\t\tA=key\n\t\tif isinstance(A,int)or isinstance(A,slice):return B.children[A]\n\t\treturn B.find(A)\n\tdef __getattr__(B,name):\n\t\tA=name\n\t\tif A.endswith('_'):A=A[:-1]\n\t\treturn getattr(B._dom_element,A)\n\tdef __setattr__(C,name,value):\n\t\tB=value;A=name\n\t\tif A.startswith('_'):super().__setattr__(A,B)\n\t\telse:\n\t\t\tif A.endswith('_'):A=A[:-1]\n\t\t\tsetattr(C._dom_element,A,B)\n\t@property\n\tdef children(self):return ElementCollection.wrap_dom_elements(self._dom_element.children)\n\t@property\n\tdef classes(self):return self._classes\n\t@property\n\tdef parent(self):\n\t\tif self._dom_element.parentElement is _A:return\n\t\treturn Element.wrap_dom_element(self._dom_element.parentElement)\n\t@property\n\tdef style(self):return self._style\n\tdef append(B,*C):\n\t\tfor A in C:\n\t\t\tif isinstance(A,Element):B._dom_element.appendChild(A._dom_element)\n\t\t\telif isinstance(A,ElementCollection):\n\t\t\t\tfor D in A:B._dom_element.appendChild(D._dom_element)\n\t\t\telif isinstance(A,list)or isinstance(A,tuple):\n\t\t\t\tfor E in A:B.append(E)\n\t\t\telse:\n\t\t\t\ttry:A.tagName;B._dom_element.appendChild(A)\n\t\t\t\texcept AttributeError:\n\t\t\t\t\ttry:\n\t\t\t\t\t\tA.length\n\t\t\t\t\t\tfor F in A:B._dom_element.appendChild(F)\n\t\t\t\t\texcept AttributeError:raise TypeError(f'Element \"{A}\" is a proxy object, \"but not a valid element or a NodeList.')\n\tdef clone(B,clone_id=_A):A=Element.wrap_dom_element(B._dom_element.cloneNode(True));A.id=clone_id;return A\n\tdef find(A,selector):return ElementCollection.wrap_dom_elements(A._dom_element.querySelectorAll(selector))\n\tdef show_me(A):A._dom_element.scrollIntoView()\n\tdef update(A,classes=_A,style=_A,**D):\n\t\tC=style;B=classes\n\t\tif B:A.classes.add(B)\n\t\tif C:A.style.set(**C)\n\t\tfor(E,F)in D.items():setattr(A,E,F)\nclass Classes:\n\tdef __init__(A,element):A._element=element;A._class_list=A._element._dom_element.classList\n\tdef __contains__(A,item):return item in A._class_list\n\tdef __eq__(C,other):\n\t\tA=other\n\t\tif isinstance(A,Classes):B=list(A._class_list)\n\t\telse:\n\t\t\ttry:B=iter(A)\n\t\t\texcept TypeError:return False\n\t\treturn set(C._class_list)==set(B)\n\tdef __iter__(A):return iter(A._class_list)\n\tdef __len__(A):return A._class_list.length\n\tdef __repr__(A):return f\"Classes({', '.join(A._class_list)})\"\n\tdef __str__(A):return' '.join(A._class_list)\n\tdef add(B,*C):\n\t\tfor A in C:\n\t\t\tif isinstance(A,list):\n\t\t\t\tfor D in A:B.add(D)\n\t\t\telse:B._class_list.add(A)\n\tdef contains(A,class_name):return class_name in A\n\tdef remove(B,*C):\n\t\tfor A in C:\n\t\t\tif isinstance(A,list):\n\t\t\t\tfor D in A:B.remove(D)\n\t\t\telse:B._class_list.remove(A)\n\tdef replace(A,old_class,new_class):A.remove(old_class);A.add(new_class)\n\tdef toggle(A,*C):\n\t\tfor B in C:\n\t\t\tif B in A:A.remove(B)\n\t\t\telse:A.add(B)\nclass HasOptions:\n\t@property\n\tdef options(self):\n\t\tA=self\n\t\tif not hasattr(A,'_options'):A._options=Options(A)\n\t\treturn A._options\nclass Options:\n\tdef __init__(A,element):A._element=element\n\tdef __getitem__(A,key):return A.options[key]\n\tdef __iter__(A):yield from A.options\n\tdef __len__(A):return len(A.options)\n\tdef __repr__(A):return f\"{A.__class__.__name__} (length: {len(A)}) {A.options}\"\n\t@property\n\tdef options(self):return[Element.wrap_dom_element(A)for A in self._element._dom_element.options]\n\t@property\n\tdef selected(self):return self.options[self._element._dom_element.selectedIndex]\n\tdef add(D,value=_A,html=_A,text=_A,before=_A,**B):\n\t\tC=value;A=before\n\t\tif C is not _A:B['value']=C\n\t\tif html is not _A:B['innerHTML']=html\n\t\tif text is not _A:B['text']=text\n\t\tE=option(**B)\n\t\tif A:\n\t\t\tif isinstance(A,Element):A=A._dom_element\n\t\tD._element._dom_element.add(E._dom_element,A)\n\tdef clear(A):\n\t\twhile len(A)>0:A.remove(0)\n\tdef remove(A,index):A._element._dom_element.remove(index)\nclass Style:\n\tdef __init__(A,element):A._element=element;A._style=A._element._dom_element.style\n\tdef __getitem__(A,key):return A._style.getPropertyValue(key)\n\tdef __setitem__(A,key,value):A._style.setProperty(key,value)\n\tdef remove(A,key):A._style.removeProperty(key)\n\tdef set(A,**B):\n\t\tfor(C,D)in B.items():A._element._dom_element.style.setProperty(C,D)\n\t@property\n\tdef visible(self):return self._element._dom_element.style.visibility\n\t@visible.setter\n\tdef visible(self,value):self._element._dom_element.style.visibility=value\nclass ContainerElement(Element):\n\tdef __init__(B,*C,children=_A,dom_element=_A,style=_A,classes=_A,**D):\n\t\tsuper().__init__(dom_element=dom_element,style=style,classes=classes,**D)\n\t\tfor A in list(C)+(children or[]):\n\t\t\tif isinstance(A,Element)or isinstance(A,ElementCollection):B.append(A)\n\t\t\telse:B._dom_element.insertAdjacentHTML('beforeend',A)\n\tdef __iter__(A):yield from A.children\nclass ClassesCollection:\n\tdef __init__(A,collection):A._collection=collection\n\tdef __contains__(A,class_name):\n\t\tfor B in A._collection:\n\t\t\tif class_name in B.classes:return True\n\t\treturn False\n\tdef __eq__(B,other):A=other;return isinstance(A,ClassesCollection)and B._collection==A._collection\n\tdef __iter__(A):\n\t\tfor B in A._all_class_names():yield B\n\tdef __len__(A):return len(A._all_class_names())\n\tdef __repr__(A):return f\"ClassesCollection({repr(A._collection)})\"\n\tdef __str__(A):return' '.join(A._all_class_names())\n\tdef add(A,*B):\n\t\tfor C in A._collection:C.classes.add(*B)\n\tdef contains(A,class_name):return class_name in A\n\tdef remove(A,*B):\n\t\tfor C in A._collection:C.classes.remove(*B)\n\tdef replace(A,old_class,new_class):\n\t\tfor B in A._collection:B.classes.replace(old_class,new_class)\n\tdef toggle(A,*B):\n\t\tfor C in A._collection:C.classes.toggle(*B)\n\tdef _all_class_names(B):\n\t\tA=set()\n\t\tfor C in B._collection:\n\t\t\tfor D in C.classes:A.add(D)\n\t\treturn A\nclass StyleCollection:\n\tdef __init__(A,collection):A._collection=collection\n\tdef __getitem__(A,key):return[A.style[key]for A in A._collection._elements]\n\tdef __setitem__(A,key,value):\n\t\tfor B in A._collection._elements:B.style[key]=value\n\tdef __repr__(A):return f\"StyleCollection({repr(A._collection)})\"\n\tdef remove(A,key):\n\t\tfor B in A._collection._elements:B.style.remove(key)\nclass ElementCollection:\n\t@classmethod\n\tdef wrap_dom_elements(A,dom_elements):return A([Element.wrap_dom_element(A)for A in dom_elements])\n\tdef __init__(A,elements):A._elements=elements;A._classes=ClassesCollection(A);A._style=StyleCollection(A)\n\tdef __eq__(A,obj):return isinstance(obj,ElementCollection)and obj._elements==A._elements\n\tdef __getitem__(B,key):\n\t\tA=key\n\t\tif isinstance(A,int):return B._elements[A]\n\t\telif isinstance(A,slice):return ElementCollection(B._elements[A])\n\t\treturn B.find(A)\n\tdef __iter__(A):yield from A._elements\n\tdef __len__(A):return len(A._elements)\n\tdef __repr__(A):return f\"{A.__class__.__name__} (length: {len(A._elements)}) {A._elements}\"\n\tdef __getattr__(A,name):return[getattr(A,name)for A in A._elements]\n\tdef __setattr__(C,name,value):\n\t\tB=value;A=name\n\t\tif A.startswith('_'):super().__setattr__(A,B)\n\t\telse:\n\t\t\tfor D in C._elements:setattr(D,A,B)\n\t@property\n\tdef classes(self):return self._classes\n\t@property\n\tdef elements(self):return self._elements\n\t@property\n\tdef style(self):return self._style\n\tdef find(B,selector):\n\t\tA=[]\n\t\tfor C in B._elements:A.extend(C.find(selector))\n\t\treturn ElementCollection(A)\nclass a(ContainerElement):0\nclass abbr(ContainerElement):0\nclass address(ContainerElement):0\nclass area(Element):0\nclass article(ContainerElement):0\nclass aside(ContainerElement):0\nclass audio(ContainerElement):0\nclass b(ContainerElement):0\nclass base(Element):0\nclass blockquote(ContainerElement):0\nclass body(ContainerElement):0\nclass br(Element):0\nclass button(ContainerElement):0\nclass canvas(ContainerElement):\n\tdef download(A,filename='snapped.png'):B=a(download=filename,href=A._dom_element.toDataURL());A.append(B);B._dom_element.click()\n\tdef draw(E,what,width=_A,height=_A):\n\t\tC=height;B=width;A=what\n\t\tif isinstance(A,Element):A=A._dom_element\n\t\tD=E._dom_element.getContext('2d')\n\t\tif B or C:D.drawImage(A,0,0,B,C)\n\t\telse:D.drawImage(A,0,0)\nclass caption(ContainerElement):0\nclass cite(ContainerElement):0\nclass code(ContainerElement):0\nclass col(Element):0\nclass colgroup(ContainerElement):0\nclass data(ContainerElement):0\nclass datalist(ContainerElement,HasOptions):0\nclass dd(ContainerElement):0\nclass del_(ContainerElement):0\nclass details(ContainerElement):0\nclass dialog(ContainerElement):0\nclass div(ContainerElement):0\nclass dl(ContainerElement):0\nclass dt(ContainerElement):0\nclass em(ContainerElement):0\nclass embed(Element):0\nclass fieldset(ContainerElement):0\nclass figcaption(ContainerElement):0\nclass figure(ContainerElement):0\nclass footer(ContainerElement):0\nclass form(ContainerElement):0\nclass h1(ContainerElement):0\nclass h2(ContainerElement):0\nclass h3(ContainerElement):0\nclass h4(ContainerElement):0\nclass h5(ContainerElement):0\nclass h6(ContainerElement):0\nclass head(ContainerElement):0\nclass header(ContainerElement):0\nclass hgroup(ContainerElement):0\nclass hr(Element):0\nclass html(ContainerElement):0\nclass i(ContainerElement):0\nclass iframe(ContainerElement):0\nclass img(Element):0\nclass input_(Element):0\nclass ins(ContainerElement):0\nclass kbd(ContainerElement):0\nclass label(ContainerElement):0\nclass legend(ContainerElement):0\nclass li(ContainerElement):0\nclass link(Element):0\nclass main(ContainerElement):0\nclass map_(ContainerElement):0\nclass mark(ContainerElement):0\nclass menu(ContainerElement):0\nclass meta(ContainerElement):0\nclass meter(ContainerElement):0\nclass nav(ContainerElement):0\nclass object_(ContainerElement):0\nclass ol(ContainerElement):0\nclass optgroup(ContainerElement,HasOptions):0\nclass option(ContainerElement):0\nclass output(ContainerElement):0\nclass p(ContainerElement):0\nclass param(ContainerElement):0\nclass picture(ContainerElement):0\nclass pre(ContainerElement):0\nclass progress(ContainerElement):0\nclass q(ContainerElement):0\nclass s(ContainerElement):0\nclass script(ContainerElement):0\nclass section(ContainerElement):0\nclass select(ContainerElement,HasOptions):0\nclass small(ContainerElement):0\nclass source(Element):0\nclass span(ContainerElement):0\nclass strong(ContainerElement):0\nclass style(ContainerElement):0\nclass sub(ContainerElement):0\nclass summary(ContainerElement):0\nclass sup(ContainerElement):0\nclass table(ContainerElement):0\nclass tbody(ContainerElement):0\nclass td(ContainerElement):0\nclass template(ContainerElement):0\nclass textarea(ContainerElement):0\nclass tfoot(ContainerElement):0\nclass th(ContainerElement):0\nclass thead(ContainerElement):0\nclass time(ContainerElement):0\nclass title(ContainerElement):0\nclass tr(ContainerElement):0\nclass track(Element):0\nclass u(ContainerElement):0\nclass ul(ContainerElement):0\nclass var(ContainerElement):0\nclass video(ContainerElement):\n\tdef snap(D,to=_A,width=_A,height=_A):\n\t\tG='CANVAS';F='Element to snap to must be a canvas.';C=height;B=width;A=to;B=B if B is not _A else D.videoWidth;C=C if C is not _A else D.videoHeight\n\t\tif A is _A:A=canvas(width=B,height=C)\n\t\telif isinstance(A,Element):\n\t\t\tif A.tag!='canvas':raise TypeError(F)\n\t\telif getattr(A,'tagName','')==G:A=canvas(dom_element=A)\n\t\telif isinstance(A,str):\n\t\t\tE=document.querySelectorAll(A)\n\t\t\tif E.length==0:raise TypeError('No element with selector {to} to snap to.')\n\t\t\tif E[0].tagName!=G:raise TypeError(F)\n\t\t\tA=canvas(dom_element=E[0])\n\t\tA.draw(D,B,C);return A\nclass wbr(Element):0\nELEMENT_CLASSES=[a,abbr,address,area,article,aside,audio,b,base,blockquote,body,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,dd,del_,details,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,img,input_,ins,kbd,label,legend,li,link,main,map_,mark,menu,meta,meter,nav,object_,ol,optgroup,option,output,p,param,picture,pre,progress,q,s,script,section,select,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,u,ul,var,video,wbr]\nElement.register_element_classes(ELEMENT_CLASSES)\nclass Page:\n\tdef __init__(A):A.html=Element.wrap_dom_element(document.documentElement);A.body=Element.wrap_dom_element(document.body);A.head=Element.wrap_dom_element(document.head)\n\tdef __getitem__(A,selector):return A.find(selector)\n\t@property\n\tdef title(self):return document.title\n\t@title.setter\n\tdef title(self,value):document.title=value\n\tdef append(A,*B):A.body.append(*B)\n\tdef find(A,selector):return ElementCollection.wrap_dom_elements(document.querySelectorAll(selector))\npage=Page()",
|
14
14
|
"websocket.py": "_A='onmessage'\nimport js\nfrom pyscript.ffi import create_proxy\nfrom pyscript.util import as_bytearray\ncode='code'\nprotocols='protocols'\nreason='reason'\nclass EventMessage:\n\tdef __init__(A,event):A._event=event\n\tdef __getattr__(B,attr):\n\t\tA=getattr(B._event,attr)\n\t\tif attr=='data'and not isinstance(A,str):\n\t\t\tif hasattr(A,'to_py'):return A.to_py()\n\t\t\treturn memoryview(as_bytearray(A))\n\t\treturn A\nclass WebSocket:\n\tCONNECTING=0;OPEN=1;CLOSING=2;CLOSED=3\n\tdef __init__(E,**A):\n\t\tD=A['url']\n\t\tif protocols in A:B=js.WebSocket.new(D,A[protocols])\n\t\telse:B=js.WebSocket.new(D)\n\t\tobject.__setattr__(E,'_ws',B)\n\t\tfor C in['onclose','onerror',_A,'onopen']:\n\t\t\tif C in A:setattr(B,C,create_proxy(A[C]))\n\tdef __getattr__(A,attr):return getattr(A._ws,attr)\n\tdef __setattr__(B,attr,value):\n\t\tC=value;A=attr\n\t\tif A==_A:B._ws[A]=lambda e:C(EventMessage(e))\n\t\telse:B._ws[A]=C\n\tdef close(B,**A):\n\t\tif code in A and reason in A:B._ws.close(A[code],A[reason])\n\t\telif code in A:B._ws.close(A[code])\n\t\telse:B._ws.close()\n\tdef send(B,data):\n\t\tA=data\n\t\tif isinstance(A,str):B._ws.send(A)\n\t\telse:\n\t\t\tC=js.Uint8Array.new(len(A))\n\t\t\tfor(D,E)in enumerate(A):C[D]=E\n\t\t\tB._ws.send(C)",
|
15
15
|
"workers.py": "import js as _js\nfrom polyscript import workers as _workers\n_get=_js.Reflect.get\ndef _set(script,name,value=''):script.setAttribute(name,value)\nclass _ReadOnlyProxy:\n\tdef __getitem__(A,name):return _get(_workers,name)\n\tdef __getattr__(A,name):return _get(_workers,name)\nworkers=_ReadOnlyProxy()\nasync def create_named_worker(src='',name='',config=None,type='py'):\n\tC=name;B=config;from json import dumps\n\tif not src:raise ValueError('Named workers require src')\n\tif not C:raise ValueError('Named workers require a name')\n\tA=_js.document.createElement('script');A.type=type;A.src=src;_set(A,'worker');_set(A,'name',C)\n\tif B:_set(A,'config',isinstance(B,str)and B or dumps(B))\n\t_js.document.body.append(A);return await workers[C]"
|
16
16
|
}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import{Annotation as e,Facet as t,EditorSelection as n,Text as r,findClusterBreak as o,countColumn as l,combineConfig as s,StateField as i,Transaction as a,ChangeSet as c,ChangeDesc as f,StateEffect as u,CharCategory as h}from"./codemirror_state-D1qTXrff.js";import{E as m,D as d}from"./codemirror_view-Dlz0Kbbt.js";import{q as p,r as g,u as y,v,s as A,w as k,b as w,i as D}from"./codemirror_language-DADyF0Bo.js";const S=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=I(e.state,n.from);return r.line?M(e):!!r.block&&T(e)};function x(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let o=e(t,n);return!!o&&(r(n.update(o)),!0)}}const M=x(L,0),B=x(L,1),C=x(L,2),E=x(R,0),O=x(R,1),b=x(R,2),T=x(((e,t)=>R(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),o=n.to<=r.to?r:e.doc.lineAt(n.to),l=t.length-1;l>=0&&t[l].to>r.from?t[l].to=o.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return t}(t))),0);function I(e,t){let n=e.languageDataAt("commentTokens",t);return n.length?n[0]:{}}const V=50;function R(e,t,n=t.selection.ranges){let r=n.map((e=>I(t,e.from).block));if(!r.every((e=>e)))return null;let o=n.map(((e,n)=>function(e,{open:t,close:n},r,o){let l,s,i=e.sliceDoc(r-V,r),a=e.sliceDoc(o,o+V),c=/\s*$/.exec(i)[0].length,f=/^\s*/.exec(a)[0].length,u=i.length-c;if(i.slice(u-t.length,u)==t&&a.slice(f,f+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:o+f,margin:f&&1}};o-r<=2*V?l=s=e.sliceDoc(r,o):(l=e.sliceDoc(r,r+V),s=e.sliceDoc(o-V,o));let h=/^\s*/.exec(l)[0].length,m=/\s*$/.exec(s)[0].length,d=s.length-m-n.length;return l.slice(h,h+t.length)==t&&s.slice(d,d+n.length)==n?{open:{pos:r+h+t.length,margin:/\s/.test(l.charAt(h+t.length))?1:0},close:{pos:o-m-n.length,margin:/\s/.test(s.charAt(d-1))?1:0}}:null}(t,r[n],e.from,e.to)));if(2!=e&&!o.every((e=>e)))return{changes:t.changes(n.map(((e,t)=>o[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}])))};if(1!=e&&o.some((e=>e))){let e=[];for(let t,n=0;n<o.length;n++)if(t=o[n]){let o=r[n],{open:l,close:s}=t;e.push({from:l.pos-o.open.length,to:l.pos+l.margin},{from:s.pos-s.margin,to:s.pos+o.close.length})}return{changes:e}}return null}function L(e,t,n=t.selection.ranges){let r=[],o=-1;for(let{from:e,to:l}of n){let n=r.length,s=1e9,i=I(t,e).line;if(i){for(let n=e;n<=l;){let a=t.doc.lineAt(n);if(a.from>o&&(e==l||l>a.from)){o=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,n=a.text.slice(e,e+i.length)==i?e:-1;e<a.text.length&&e<s&&(s=e),r.push({line:a,comment:n,token:i,indent:e,empty:t,single:!1})}n=a.to+1}if(s<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=s);r.length==n+1&&(r[n].single=!0)}}if(2!=e&&r.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:n,indent:o,empty:l,single:s}of r)!s&&l||e.push({from:t.from+o,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:n,token:o}of r)if(n>=0){let r=t.from+n,l=r+o.length;" "==t.text[l-t.from]&&l++,e.push({from:r,to:l})}return{changes:e}}return null}const J=e.define(),N=e.define(),H=t.define(),U=t.define({combine:e=>s(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),z=i.define({create:()=>ie.empty,update(e,t){let n=t.state.facet(U),r=t.annotation(J);if(r){let o=X.fromTransaction(t,r.selection),l=r.side,s=0==l?e.undone:e.done;return s=o?Y(s,s.length,n.minDepth,o):ne(s,t.startState.selection),new ie(0==l?r.rest:s,0==l?s:r.rest)}let o=t.annotation(N);if("full"!=o&&"before"!=o||(e=e.isolate()),!1===t.annotation(a.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let l=X.fromTransaction(t),s=t.annotation(a.time),i=t.annotation(a.userEvent);return l?e=e.addChanges(l,s,i,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,i,n.newGroupDelay)),"full"!=o&&"after"!=o||(e=e.isolate()),e},toJSON:e=>({done:e.done.map((e=>e.toJSON())),undone:e.undone.map((e=>e.toJSON()))}),fromJSON:e=>new ie(e.done.map(X.fromJSON),e.undone.map(X.fromJSON))});function j(e={}){return[z,U.of(e),m.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?W:"historyRedo"==e.inputType?q:null;return!!n&&(e.preventDefault(),n(t))}})]}const G=z;function P(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let o=n.field(z,!1);if(!o)return!1;let l=o.pop(e,n,t);return!!l&&(r(l),!0)}}const W=P(0,!1),q=P(1,!1),$=P(0,!0),_=P(1,!0);function F(e){return function(t){let n=t.field(z,!1);if(!n)return 0;let r=0==e?n.done:n.undone;return r.length-(r.length&&!r[0].changes?1:0)}}const K=F(0),Q=F(1);class X{constructor(e,t,n,r,o){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=o}setSelAfter(e){return new X(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((e=>e.toJSON()))}}static fromJSON(e){return new X(e.changes&&c.fromJSON(e.changes),[],e.mapped&&f.fromJSON(e.mapped),e.startSelection&&n.fromJSON(e.startSelection),e.selectionsAfter.map(n.fromJSON))}static fromTransaction(e,t){let n=ee;for(let t of e.startState.facet(H)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new X(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,ee)}static selection(e){return new X(void 0,ee,void 0,void 0,e)}}function Y(e,t,n,r){let o=t+1>n+20?t-n-1:0,l=e.slice(o,t);return l.push(r),l}function Z(e,t){return e.length?t.length?e.concat(t):e:t}const ee=[],te=200;function ne(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-te));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Y(e,e.length-1,1e9,n.setSelAfter(r)))}return[X.selection([t])]}function re(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function oe(e,t){if(!e.length)return e;let n=e.length,r=ee;for(;n;){let o=le(e[n-1],t,r);if(o.changes&&!o.changes.empty||o.effects.length){let t=e.slice(0,n);return t[n-1]=o,t}t=o.mapped,n--,r=o.selectionsAfter}return r.length?[X.selection(r)]:ee}function le(e,t,n){let r=Z(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):ee,n);if(!e.changes)return X.selection(r);let o=e.changes.map(t),l=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(l):l;return new X(o,u.mapEffects(e.effects,t),s,e.startSelection.map(l),r)}const se=/^(input\.type|delete)($|\.)/;class ie{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new ie(this.done,this.undone):this}addChanges(e,t,n,r,o){let l=this.done,s=l[l.length-1];return l=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||se.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(o,function(e,t){let n=[],r=!1;return e.iterChangedRanges(((e,t)=>n.push(e,t))),t.iterChangedRanges(((e,t,o,l)=>{for(let e=0;e<n.length;){let t=n[e++],s=n[e++];l>=t&&o<=s&&(r=!0)}})),r}(s.changes,e.changes))||"input.type.compose"==n)?Y(l,l.length-1,r.minDepth,new X(e.changes.compose(s.changes),Z(e.effects,s.effects),s.mapped,s.startSelection,ee)):Y(l,l.length,r.minDepth,e),new ie(l,ee,t,n)}addSelection(e,t,n,r){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:ee;return o.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(l=o[o.length-1],s=e,l.ranges.length==s.ranges.length&&0===l.ranges.filter(((e,t)=>e.empty!=s.ranges[t].empty)).length)?this:new ie(ne(this.done,e),this.undone,t,n);var l,s}addMapping(e){return new ie(oe(this.done,e),oe(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let o=r[r.length-1],l=o.selectionsAfter[0]||t.selection;if(n&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:J.of({side:e,rest:re(r),selection:l}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let n=1==r.length?ee:r.slice(0,r.length-1);return o.mapped&&(n=oe(n,o.mapped)),t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:J.of({side:e,rest:n,selection:l}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}ie.empty=new ie(ee,ee);const ae=[{key:"Mod-z",run:W,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:q,preventDefault:!0},{linux:"Ctrl-Shift-z",run:q,preventDefault:!0},{key:"Mod-u",run:$,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:_,preventDefault:!0}];function ce(e,t){return n.create(e.ranges.map(t),e.mainIndex)}function fe(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function ue({state:e,dispatch:t},n){let r=ce(e.selection,n);return!r.eq(e.selection,!0)&&(t(fe(e,r)),!0)}function he(e,t){return n.cursor(t?e.to:e.from)}function me(e,t){return ue(e,(n=>n.empty?e.moveByChar(n,t):he(n,t)))}function de(e){return e.textDirectionAt(e.state.selection.main.head)==d.LTR}const pe=e=>me(e,!de(e)),ge=e=>me(e,de(e)),ye=e=>me(e,!0),ve=e=>me(e,!1);function Ae(e,t){return ue(e,(n=>n.empty?e.moveByGroup(n,t):he(n,t)))}const ke=e=>Ae(e,!de(e)),we=e=>Ae(e,de(e)),De=e=>Ae(e,!0),Se=e=>Ae(e,!1),xe="undefined"!=typeof Intl&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Me(e,t,r){let o=e.state.charCategorizer(t.from),l=h.Space,s=t.from,i=0,a=!1,c=!1,f=!1,u=t=>{if(a)return!1;s+=r?t.length:-t.length;let n,u=o(t);if(u==h.Word&&t.charCodeAt(0)<128&&/[\W_]/.test(t)&&(u=-1),l==h.Space&&(l=u),l!=u)return!1;if(l==h.Word)if(t.toLowerCase()==t){if(!r&&c)return!1;f=!0}else if(f){if(r)return!1;a=!0}else{if(c&&r&&o(n=e.state.sliceDoc(s,s+1))==h.Word&&n.toLowerCase()==n)return!1;c=!0}return i++,!0},m=e.moveByChar(t,r,(e=>(u(e),u)));if(xe&&l==h.Word&&m.from==t.from+i*(r?1:-1)){let o=Math.min(t.head,m.head),l=Math.max(t.head,m.head),s=e.state.sliceDoc(o,l);if(s.length>1&&/[\u4E00-\uffff]/.test(s)){let e=Array.from(xe.segment(s));if(e.length>1)return r?n.cursor(t.head+e[1].index,-1):n.cursor(m.head+e[e.length-1].index,1)}}return m}function Be(e,t){return ue(e,(n=>n.empty?Me(e,n,t):he(n,t)))}const Ce=e=>Be(e,!0),Ee=e=>Be(e,!1);function Oe(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function be(e,t,r){let o,l,s=A(e).resolveInner(t.head),i=r?w.closedBy:w.openedBy;for(let n=t.head;;){let t=r?s.childAfter(n):s.childBefore(n);if(!t)break;Oe(e,t,i)?s=t:n=r?t.to:t.from}return l=s.type.prop(i)&&(o=r?v(e,s.from,1):v(e,s.to,-1))&&o.matched?r?o.end.to:o.end.from:r?s.to:s.from,n.cursor(l,r?-1:1)}const Te=e=>ue(e,(t=>be(e.state,t,!de(e)))),Ie=e=>ue(e,(t=>be(e.state,t,de(e))));function Ve(e,t){return ue(e,(n=>{if(!n.empty)return he(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)}))}const Re=e=>Ve(e,!1),Le=e=>Ve(e,!0);function Je(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,o=0;if(n){for(let t of e.state.facet(m.scrollMargins)){let n=t(e);(null==n?void 0:n.top)&&(r=Math.max(null==n?void 0:n.top,r)),(null==n?void 0:n.bottom)&&(o=Math.max(null==n?void 0:n.bottom,o))}t=e.scrollDOM.clientHeight-r-o}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:o,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function Ne(e,t){let n,r=Je(e),{state:o}=e,l=ce(o.selection,(n=>n.empty?e.moveVertically(n,t,r.height):he(n,t)));if(l.eq(o.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(o.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),i=s.top+r.marginTop,a=s.bottom-r.marginBottom;t&&t.top>i&&t.bottom<a&&(n=m.scrollIntoView(l.main.head,{y:"start",yMargin:t.top-i}))}return e.dispatch(fe(o,l),{effects:n}),!0}const He=e=>Ne(e,!1),Ue=e=>Ne(e,!0);function ze(e,t,r){let o=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,r);if(l.head==t.head&&l.head!=(r?o.to:o.from)&&(l=e.moveToLineBoundary(t,r,!1)),!r&&l.head==o.from&&o.length){let r=/^\s*/.exec(e.state.sliceDoc(o.from,Math.min(o.from+100,o.to)))[0].length;r&&t.head!=o.from+r&&(l=n.cursor(o.from+r))}return l}const je=e=>ue(e,(t=>ze(e,t,!0))),Ge=e=>ue(e,(t=>ze(e,t,!1))),Pe=e=>ue(e,(t=>ze(e,t,!de(e)))),We=e=>ue(e,(t=>ze(e,t,de(e)))),qe=e=>ue(e,(t=>n.cursor(e.lineBlockAt(t.head).from,1))),$e=e=>ue(e,(t=>n.cursor(e.lineBlockAt(t.head).to,-1)));function _e(e,t,r){let o=!1,l=ce(e.selection,(t=>{let l=v(e,t.head,-1)||v(e,t.head,1)||t.head>0&&v(e,t.head-1,1)||t.head<e.doc.length&&v(e,t.head+1,-1);if(!l||!l.end)return t;o=!0;let s=l.start.from==t.head?l.end.to:l.end.from;return r?n.range(t.anchor,s):n.cursor(s)}));return!!o&&(t(fe(e,l)),!0)}const Fe=({state:e,dispatch:t})=>_e(e,t,!1),Ke=({state:e,dispatch:t})=>_e(e,t,!0);function Qe(e,t){let r=ce(e.state.selection,(e=>{let r=t(e);return n.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)}));return!r.eq(e.state.selection)&&(e.dispatch(fe(e.state,r)),!0)}function Xe(e,t){return Qe(e,(n=>e.moveByChar(n,t)))}const Ye=e=>Xe(e,!de(e)),Ze=e=>Xe(e,de(e)),et=e=>Xe(e,!0),tt=e=>Xe(e,!1);function nt(e,t){return Qe(e,(n=>e.moveByGroup(n,t)))}const rt=e=>nt(e,!de(e)),ot=e=>nt(e,de(e)),lt=e=>nt(e,!0),st=e=>nt(e,!1);function it(e,t){return Qe(e,(n=>Me(e,n,t)))}const at=e=>it(e,!0),ct=e=>it(e,!1),ft=e=>Qe(e,(t=>be(e.state,t,!de(e)))),ut=e=>Qe(e,(t=>be(e.state,t,de(e))));function ht(e,t){return Qe(e,(n=>e.moveVertically(n,t)))}const mt=e=>ht(e,!1),dt=e=>ht(e,!0);function pt(e,t){return Qe(e,(n=>e.moveVertically(n,t,Je(e).height)))}const gt=e=>pt(e,!1),yt=e=>pt(e,!0),vt=e=>Qe(e,(t=>ze(e,t,!0))),At=e=>Qe(e,(t=>ze(e,t,!1))),kt=e=>Qe(e,(t=>ze(e,t,!de(e)))),wt=e=>Qe(e,(t=>ze(e,t,de(e)))),Dt=e=>Qe(e,(t=>n.cursor(e.lineBlockAt(t.head).from))),St=e=>Qe(e,(t=>n.cursor(e.lineBlockAt(t.head).to))),xt=({state:e,dispatch:t})=>(t(fe(e,{anchor:0})),!0),Mt=({state:e,dispatch:t})=>(t(fe(e,{anchor:e.doc.length})),!0),Bt=({state:e,dispatch:t})=>(t(fe(e,{anchor:e.selection.main.anchor,head:0})),!0),Ct=({state:e,dispatch:t})=>(t(fe(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Et=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Ot=({state:e,dispatch:t})=>{let r=Ft(e).map((({from:t,to:r})=>n.range(t,Math.min(r+1,e.doc.length))));return t(e.update({selection:n.create(r),userEvent:"select"})),!0},bt=({state:e,dispatch:t})=>{let r=ce(e.selection,(t=>{var r;for(let o=A(e).resolveStack(t.from,1);o;o=o.next){let{node:e}=o;if((e.from<t.from&&e.to>=t.to||e.to>t.to&&e.from<=t.from)&&(null===(r=e.parent)||void 0===r?void 0:r.parent))return n.range(e.to,e.from)}return t}));return t(fe(e,r)),!0},Tt=({state:e,dispatch:t})=>{let r=e.selection,o=null;return r.ranges.length>1?o=n.create([r.main]):r.main.empty||(o=n.create([n.cursor(r.main.head)])),!!o&&(t(fe(e,o)),!0)};function It(e,t){if(e.state.readOnly)return!1;let r="delete.selection",{state:o}=e,l=o.changeByRange((o=>{let{from:l,to:s}=o;if(l==s){let n=t(o);n<l?(r="delete.backward",n=Vt(e,n,!1)):n>l&&(r="delete.forward",n=Vt(e,n,!0)),l=Math.min(l,n),s=Math.max(s,n)}else l=Vt(e,l,!1),s=Vt(e,s,!0);return l==s?{range:o}:{changes:{from:l,to:s},range:n.cursor(l,l<o.head?-1:1)}}));return!l.changes.empty&&(e.dispatch(o.update(l,{scrollIntoView:!0,userEvent:r,effects:"delete.selection"==r?m.announce.of(o.phrase("Selection deleted")):void 0})),!0)}function Vt(e,t,n){if(e instanceof m)for(let r of e.state.facet(m.atomicRanges).map((t=>t(e))))r.between(t,t,((e,r)=>{e<t&&r>t&&(t=n?r:e)}));return t}const Rt=(e,t,n)=>It(e,(r=>{let s,i,a=r.from,{state:c}=e,f=c.doc.lineAt(a);if(n&&!t&&a>f.from&&a<f.from+200&&!/[^ \t]/.test(s=f.text.slice(0,a-f.from))){if("\t"==s[s.length-1])return a-1;let e=l(s,c.tabSize)%k(c)||k(c);for(let t=0;t<e&&" "==s[s.length-1-t];t++)a--;i=a}else i=o(f.text,a-f.from,t,t)+f.from,i==a&&f.number!=(t?c.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(f.text.slice(i-f.from,a-f.from))&&(i=o(f.text,i-f.from,!1,!1)+f.from);return i})),Lt=e=>Rt(e,!1,!0),Jt=e=>Rt(e,!1,!1),Nt=e=>Rt(e,!0,!1),Ht=(e,t)=>It(e,(n=>{let r=n.head,{state:l}=e,s=l.doc.lineAt(r),i=l.charCategorizer(r);for(let e=null;;){if(r==(t?s.to:s.from)){r==n.head&&s.number!=(t?l.doc.lines:1)&&(r+=t?1:-1);break}let a=o(s.text,r-s.from,t)+s.from,c=s.text.slice(Math.min(r,a)-s.from,Math.max(r,a)-s.from),f=i(c);if(null!=e&&f!=e)break;" "==c&&r==n.head||(e=f),r=a}return r})),Ut=e=>Ht(e,!1),zt=e=>Ht(e,!0),jt=e=>It(e,(t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})),Gt=e=>It(e,(t=>{let n=e.lineBlockAt(t.head).from;return t.head>n?n:Math.max(0,t.head-1)})),Pt=e=>It(e,(t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)})),Wt=e=>It(e,(t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})),qt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=[];for(let t=0,r="",o=e.doc.iter();;){if(o.next(),o.lineBreak||o.done){let e=r.search(/\s+$/);if(e>-1&&n.push({from:t-(r.length-e),to:t}),o.done)break;r=""}else r=o.value;t+=o.value.length}return!!n.length&&(t(e.update({changes:n,userEvent:"delete"})),!0)},$t=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let o=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:r.of(["",""])},range:n.cursor(e.from)})));return t(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0},_t=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange((t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let r=t.from,l=e.doc.lineAt(r),s=r==l.from?r-1:o(l.text,r-l.from,!1)+l.from,i=r==l.to?r+1:o(l.text,r-l.from,!0)+l.from;return{changes:{from:s,to:i,insert:e.doc.slice(r,i).append(e.doc.slice(s,r))},range:n.cursor(i)}}));return!r.changes.empty&&(t(e.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ft(e){let t=[],n=-1;for(let r of e.selection.ranges){let o=e.doc.lineAt(r.from),l=e.doc.lineAt(r.to);if(r.empty||r.to!=l.from||(l=e.doc.lineAt(r.to-1)),n>=o.number){let e=t[t.length-1];e.to=l.to,e.ranges.push(r)}else t.push({from:o.from,to:l.to,ranges:[r]});n=l.number+1}return t}function Kt(e,t,r){if(e.readOnly)return!1;let o=[],l=[];for(let t of Ft(e)){if(r?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(r?t.to+1:t.from-1),i=s.length+1;if(r){o.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak});for(let r of t.ranges)l.push(n.range(Math.min(e.doc.length,r.anchor+i),Math.min(e.doc.length,r.head+i)))}else{o.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text});for(let e of t.ranges)l.push(n.range(e.anchor-i,e.head-i))}}return!!o.length&&(t(e.update({changes:o,scrollIntoView:!0,selection:n.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0)}const Qt=({state:e,dispatch:t})=>Kt(e,t,!1),Xt=({state:e,dispatch:t})=>Kt(e,t,!0);function Yt(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Ft(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});return t(e.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Zt=({state:e,dispatch:t})=>Yt(e,t,!1),en=({state:e,dispatch:t})=>Yt(e,t,!0),tn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Ft(t).map((({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n})))),r=ce(t.selection,(t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),o=e.coordsAtPos(t.head,t.assoc||1);o&&(n=r.bottom+e.documentTop-o.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)})).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0},nn=({state:e,dispatch:t})=>(t(e.update(e.replaceSelection(e.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),rn=({state:e,dispatch:t})=>(t(e.update(e.changeByRange((t=>{let r=/^\s*/.exec(e.doc.lineAt(t.from).text)[0];return{changes:{from:t.from,to:t.to,insert:e.lineBreak+r},range:n.cursor(t.from+r.length+1)}})),{scrollIntoView:!0,userEvent:"input"})),!0);const on=sn(!1),ln=sn(!0);function sn(e){return({state:t,dispatch:o})=>{if(t.readOnly)return!1;let s=t.changeByRange((o=>{let{from:s,to:i}=o,a=t.doc.lineAt(s),c=!e&&s==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,r=A(e).resolveInner(t),o=r.childBefore(t),l=r.childAfter(t);return o&&l&&o.to<=t&&l.from>=t&&(n=o.type.prop(w.closedBy))&&n.indexOf(l.name)>-1&&e.doc.lineAt(o.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(o.to,l.from))?{from:o.to,to:l.from}:null}(t,s);e&&(s=i=(i<=a.to?a:t.doc.lineAt(i)).to);let f=new p(t,{simulateBreak:s,simulateDoubleBreak:!!c}),u=g(f,s);for(null==u&&(u=l(/^\s*/.exec(t.doc.lineAt(s).text)[0],t.tabSize));i<a.to&&/\s/.test(a.text[i-a.from]);)i++;c?({from:s,to:i}=c):s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let h=["",y(t,u)];return c&&h.push(y(t,f.lineIndent(a.from,-1))),{changes:{from:s,to:i,insert:r.of(h)},range:n.cursor(s+1+h[1].length)}}));return o(t.update(s,{scrollIntoView:!0,userEvent:"input"})),!0}}function an(e,t){let r=-1;return e.changeByRange((o=>{let l=[];for(let n=o.from;n<=o.to;){let s=e.doc.lineAt(n);s.number>r&&(o.empty||o.to>s.from)&&(t(s,l,o),r=s.number),n=s.to+1}let s=e.changes(l);return{changes:l,range:n.range(s.mapPos(o.anchor,1),s.mapPos(o.head,1))}}))}const cn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new p(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),o=an(e,((t,o,l)=>{let s=g(r,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let i=/^\s*/.exec(t.text)[0],a=y(e,s);(i!=a||l.from<t.from+i.length)&&(n[t.from]=s,o.push({from:t.from,to:t.from+i.length,insert:a}))}));return o.changes.empty||t(e.update(o,{userEvent:"indent"})),!0},fn=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(an(e,((t,n)=>{n.push({from:t.from,insert:e.facet(D)})})),{userEvent:"input.indent"})),!0),un=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(an(e,((t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let o=l(r,e.tabSize),s=0,i=y(e,Math.max(0,o-k(e)));for(;s<r.length&&s<i.length&&r.charCodeAt(s)==i.charCodeAt(s);)s++;n.push({from:t.from+s,to:t.from+r.length,insert:i.slice(s)})})),{userEvent:"delete.dedent"})),!0),hn=e=>(e.setTabFocusMode(),!0),mn=e=>(e.setTabFocusMode(2e3),!0),dn=({state:e,dispatch:t})=>e.selection.ranges.some((e=>!e.empty))?fn({state:e,dispatch:t}):(t(e.update(e.replaceSelection("\t"),{scrollIntoView:!0,userEvent:"input"})),!0),pn=[{key:"Ctrl-b",run:pe,shift:Ye,preventDefault:!0},{key:"Ctrl-f",run:ge,shift:Ze},{key:"Ctrl-p",run:Re,shift:mt},{key:"Ctrl-n",run:Le,shift:dt},{key:"Ctrl-a",run:qe,shift:Dt},{key:"Ctrl-e",run:$e,shift:St},{key:"Ctrl-d",run:Nt},{key:"Ctrl-h",run:Lt},{key:"Ctrl-k",run:jt},{key:"Ctrl-Alt-h",run:Ut},{key:"Ctrl-o",run:$t},{key:"Ctrl-t",run:_t},{key:"Ctrl-v",run:Ue}],gn=[{key:"ArrowLeft",run:pe,shift:Ye,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ke,shift:rt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Pe,shift:kt,preventDefault:!0},{key:"ArrowRight",run:ge,shift:Ze,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:we,shift:ot,preventDefault:!0},{mac:"Cmd-ArrowRight",run:We,shift:wt,preventDefault:!0},{key:"ArrowUp",run:Re,shift:mt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:xt,shift:Bt},{mac:"Ctrl-ArrowUp",run:He,shift:gt},{key:"ArrowDown",run:Le,shift:dt,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Mt,shift:Ct},{mac:"Ctrl-ArrowDown",run:Ue,shift:yt},{key:"PageUp",run:He,shift:gt},{key:"PageDown",run:Ue,shift:yt},{key:"Home",run:Ge,shift:At,preventDefault:!0},{key:"Mod-Home",run:xt,shift:Bt},{key:"End",run:je,shift:vt,preventDefault:!0},{key:"Mod-End",run:Mt,shift:Ct},{key:"Enter",run:on},{key:"Mod-a",run:Et},{key:"Backspace",run:Lt,shift:Lt},{key:"Delete",run:Nt},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ut},{key:"Mod-Delete",mac:"Alt-Delete",run:zt},{mac:"Mod-Backspace",run:Pt},{mac:"Mod-Delete",run:Wt}].concat(pn.map((e=>({mac:e.key,run:e.run,shift:e.shift})))),yn=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Te,shift:ft},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Ie,shift:ut},{key:"Alt-ArrowUp",run:Qt},{key:"Shift-Alt-ArrowUp",run:Zt},{key:"Alt-ArrowDown",run:Xt},{key:"Shift-Alt-ArrowDown",run:en},{key:"Escape",run:Tt},{key:"Mod-Enter",run:ln},{key:"Alt-l",mac:"Ctrl-l",run:Ot},{key:"Mod-i",run:bt,preventDefault:!0},{key:"Mod-[",run:un},{key:"Mod-]",run:fn},{key:"Mod-Alt-\\",run:cn},{key:"Shift-Mod-k",run:tn},{key:"Shift-Mod-\\",run:Fe},{key:"Mod-/",run:S},{key:"Alt-A",run:E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:hn}].concat(gn),vn={key:"Tab",run:fn,shift:un};export{O as blockComment,b as blockUncomment,en as copyLineDown,Zt as copyLineUp,ve as cursorCharBackward,ye as cursorCharForward,pe as cursorCharLeft,ge as cursorCharRight,Mt as cursorDocEnd,xt as cursorDocStart,Se as cursorGroupBackward,De as cursorGroupForward,ke as cursorGroupLeft,we as cursorGroupRight,Ge as cursorLineBoundaryBackward,je as cursorLineBoundaryForward,Pe as cursorLineBoundaryLeft,We as cursorLineBoundaryRight,Le as cursorLineDown,$e as cursorLineEnd,qe as cursorLineStart,Re as cursorLineUp,Fe as cursorMatchingBracket,Ue as cursorPageDown,He as cursorPageUp,Ee as cursorSubwordBackward,Ce as cursorSubwordForward,Te as cursorSyntaxLeft,Ie as cursorSyntaxRight,yn as defaultKeymap,Lt as deleteCharBackward,Jt as deleteCharBackwardStrict,Nt as deleteCharForward,Ut as deleteGroupBackward,zt as deleteGroupForward,tn as deleteLine,Pt as deleteLineBoundaryBackward,Wt as deleteLineBoundaryForward,jt as deleteToLineEnd,Gt as deleteToLineStart,qt as deleteTrailingWhitespace,pn as emacsStyleKeymap,j as history,G as historyField,ae as historyKeymap,un as indentLess,fn as indentMore,cn as indentSelection,vn as indentWithTab,ln as insertBlankLine,nn as insertNewline,on as insertNewlineAndIndent,rn as insertNewlineKeepIndent,dn as insertTab,H as invertedEffects,N as isolateHistory,B as lineComment,C as lineUncomment,Xt as moveLineDown,Qt as moveLineUp,q as redo,Q as redoDepth,_ as redoSelection,Et as selectAll,tt as selectCharBackward,et as selectCharForward,Ye as selectCharLeft,Ze as selectCharRight,Ct as selectDocEnd,Bt as selectDocStart,st as selectGroupBackward,lt as selectGroupForward,rt as selectGroupLeft,ot as selectGroupRight,Ot as selectLine,At as selectLineBoundaryBackward,vt as selectLineBoundaryForward,kt as selectLineBoundaryLeft,wt as selectLineBoundaryRight,dt as selectLineDown,St as selectLineEnd,Dt as selectLineStart,mt as selectLineUp,Ke as selectMatchingBracket,yt as selectPageDown,gt as selectPageUp,bt as selectParentSyntax,ct as selectSubwordBackward,at as selectSubwordForward,ft as selectSyntaxLeft,ut as selectSyntaxRight,Tt as simplifySelection,$t as splitLine,gn as standardKeymap,mn as temporarilySetTabFocusMode,E as toggleBlockComment,T as toggleBlockCommentByLine,S as toggleComment,M as toggleLineComment,hn as toggleTabFocusMode,_t as transposeChars,W as undo,K as undoDepth,$ as undoSelection};
|
2
|
-
//# sourceMappingURL=codemirror_commands-DbitAX-b.js.map
|