repl-sdk 1.0.1 → 1.0.2
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/package.json +4 -12
- package/dist/apl-fqmucPXA.js +0 -141
- package/dist/apl-fqmucPXA.js.map +0 -1
- package/dist/asciiarmor-DucZyvP0.js +0 -57
- package/dist/asciiarmor-DucZyvP0.js.map +0 -1
- package/dist/asn1-BnOEsgAm.js +0 -145
- package/dist/asn1-BnOEsgAm.js.map +0 -1
- package/dist/assets/tar-worker-CxTcoQcr.js +0 -593
- package/dist/assets/tar-worker-CxTcoQcr.js.map +0 -1
- package/dist/asterisk-QAlztEwS.js +0 -346
- package/dist/asterisk-QAlztEwS.js.map +0 -1
- package/dist/brainfuck-DZVCuF_t.js +0 -54
- package/dist/brainfuck-DZVCuF_t.js.map +0 -1
- package/dist/clike-CTYGlS6x.js +0 -800
- package/dist/clike-CTYGlS6x.js.map +0 -1
- package/dist/clojure-BhXMqnxz.js +0 -850
- package/dist/clojure-BhXMqnxz.js.map +0 -1
- package/dist/cmake-BGaNd9E7.js +0 -72
- package/dist/cmake-BGaNd9E7.js.map +0 -1
- package/dist/cobol-4yqQntpt.js +0 -121
- package/dist/cobol-4yqQntpt.js.map +0 -1
- package/dist/codemirror-De3S70Np.js +0 -2912
- package/dist/codemirror-De3S70Np.js.map +0 -1
- package/dist/coffeescript-D2dXvhEc.js +0 -309
- package/dist/coffeescript-D2dXvhEc.js.map +0 -1
- package/dist/commonlisp-CF_VNHQR.js +0 -131
- package/dist/commonlisp-CF_VNHQR.js.map +0 -1
- package/dist/crystal-DyuLTqLs.js +0 -399
- package/dist/crystal-DyuLTqLs.js.map +0 -1
- package/dist/css-DkSyTW67.js +0 -1773
- package/dist/css-DkSyTW67.js.map +0 -1
- package/dist/cypher-Dlu_3r4V.js +0 -122
- package/dist/cypher-Dlu_3r4V.js.map +0 -1
- package/dist/d-UURgV0Ux.js +0 -180
- package/dist/d-UURgV0Ux.js.map +0 -1
- package/dist/diff-B_Bi2Crb.js +0 -26
- package/dist/diff-B_Bi2Crb.js.map +0 -1
- package/dist/dockerfile-Bvk733Ga.js +0 -202
- package/dist/dockerfile-Bvk733Ga.js.map +0 -1
- package/dist/dtd-Dy74G54E.js +0 -115
- package/dist/dtd-Dy74G54E.js.map +0 -1
- package/dist/dylan-TSb-Nfix.js +0 -315
- package/dist/dylan-TSb-Nfix.js.map +0 -1
- package/dist/ebnf-4fKAGW3a.js +0 -141
- package/dist/ebnf-4fKAGW3a.js.map +0 -1
- package/dist/ecl-B59qGGVg.js +0 -179
- package/dist/ecl-B59qGGVg.js.map +0 -1
- package/dist/eiffel-Dze7nlu3.js +0 -135
- package/dist/eiffel-Dze7nlu3.js.map +0 -1
- package/dist/elm-DG7jkhNZ.js +0 -177
- package/dist/elm-DG7jkhNZ.js.map +0 -1
- package/dist/erlang-BO6gOnGA.js +0 -675
- package/dist/erlang-BO6gOnGA.js.map +0 -1
- package/dist/factor-CMxFHDqz.js +0 -66
- package/dist/factor-CMxFHDqz.js.map +0 -1
- package/dist/fcl-CDDUNjTj.js +0 -142
- package/dist/fcl-CDDUNjTj.js.map +0 -1
- package/dist/forth-B9D2JCeE.js +0 -117
- package/dist/forth-B9D2JCeE.js.map +0 -1
- package/dist/fortran-CAG2BFbe.js +0 -468
- package/dist/fortran-CAG2BFbe.js.map +0 -1
- package/dist/gas-0Aw8zDr5.js +0 -294
- package/dist/gas-0Aw8zDr5.js.map +0 -1
- package/dist/gherkin-DhZlEZiy.js +0 -116
- package/dist/gherkin-DhZlEZiy.js.map +0 -1
- package/dist/gjs-DfguZDLq.js +0 -173
- package/dist/gjs-DfguZDLq.js.map +0 -1
- package/dist/gmd-Yas-Oo8k.js +0 -163
- package/dist/gmd-Yas-Oo8k.js.map +0 -1
- package/dist/groovy-CpwJiBl7.js +0 -224
- package/dist/groovy-CpwJiBl7.js.map +0 -1
- package/dist/haskell-ySd-OUo8.js +0 -460
- package/dist/haskell-ySd-OUo8.js.map +0 -1
- package/dist/haxe-7MlzfeYV.js +0 -515
- package/dist/haxe-7MlzfeYV.js.map +0 -1
- package/dist/hbs-CxcmWxSJ.js +0 -62
- package/dist/hbs-CxcmWxSJ.js.map +0 -1
- package/dist/http-BqypyemW.js +0 -80
- package/dist/http-BqypyemW.js.map +0 -1
- package/dist/idl-4HIGJlDI.js +0 -986
- package/dist/idl-4HIGJlDI.js.map +0 -1
- package/dist/index-B3Meoznj.js +0 -118
- package/dist/index-B3Meoznj.js.map +0 -1
- package/dist/index-BQyfDUUx.js +0 -692
- package/dist/index-BQyfDUUx.js.map +0 -1
- package/dist/index-BRDroAD8.js +0 -305
- package/dist/index-BRDroAD8.js.map +0 -1
- package/dist/index-BRMAzRyM.js +0 -179
- package/dist/index-BRMAzRyM.js.map +0 -1
- package/dist/index-Bb8uYQgv.js +0 -927
- package/dist/index-Bb8uYQgv.js.map +0 -1
- package/dist/index-BlOjO66K.js +0 -17618
- package/dist/index-BlOjO66K.js.map +0 -1
- package/dist/index-BoGWnSNL.js +0 -706
- package/dist/index-BoGWnSNL.js.map +0 -1
- package/dist/index-BsRrEiOu.js +0 -98
- package/dist/index-BsRrEiOu.js.map +0 -1
- package/dist/index-C2sFZMth.js +0 -391
- package/dist/index-C2sFZMth.js.map +0 -1
- package/dist/index-C7xwOjmS.js +0 -291
- package/dist/index-C7xwOjmS.js.map +0 -1
- package/dist/index-CA3lFUx6.js +0 -315
- package/dist/index-CA3lFUx6.js.map +0 -1
- package/dist/index-CB-pPTIf.js +0 -98
- package/dist/index-CB-pPTIf.js.map +0 -1
- package/dist/index-CCa6x1FE.js +0 -386
- package/dist/index-CCa6x1FE.js.map +0 -1
- package/dist/index-CD4DINI1.js +0 -158
- package/dist/index-CD4DINI1.js.map +0 -1
- package/dist/index-CE0B_fcG.js +0 -328
- package/dist/index-CE0B_fcG.js.map +0 -1
- package/dist/index-CVGAEPMV.js +0 -2139
- package/dist/index-CVGAEPMV.js.map +0 -1
- package/dist/index-CmaT2afn.js +0 -332
- package/dist/index-CmaT2afn.js.map +0 -1
- package/dist/index-D8sUxXp5.js +0 -83
- package/dist/index-D8sUxXp5.js.map +0 -1
- package/dist/index-DIz8Vpn-.js +0 -737
- package/dist/index-DIz8Vpn-.js.map +0 -1
- package/dist/index-DNP1xT-S.js +0 -408
- package/dist/index-DNP1xT-S.js.map +0 -1
- package/dist/index-DOAqdvnQ.js +0 -862
- package/dist/index-DOAqdvnQ.js.map +0 -1
- package/dist/index-DVUMFbgi.js +0 -152
- package/dist/index-DVUMFbgi.js.map +0 -1
- package/dist/index-VeTBKRVd.js +0 -83
- package/dist/index-VeTBKRVd.js.map +0 -1
- package/dist/index-dXZeR7Bx.js +0 -1767
- package/dist/index-dXZeR7Bx.js.map +0 -1
- package/dist/index-gtqbIb6T.js +0 -62
- package/dist/index-gtqbIb6T.js.map +0 -1
- package/dist/index-pN_pUAQ7.js +0 -2426
- package/dist/index-pN_pUAQ7.js.map +0 -1
- package/dist/index-wasu5VX0.js +0 -1150
- package/dist/index-wasu5VX0.js.map +0 -1
- package/dist/javascript-Bt8B7yTi.js +0 -993
- package/dist/javascript-Bt8B7yTi.js.map +0 -1
- package/dist/julia-Bs6JJhYG.js +0 -408
- package/dist/julia-Bs6JJhYG.js.map +0 -1
- package/dist/livescript-DmzgM3Yt.js +0 -297
- package/dist/livescript-DmzgM3Yt.js.map +0 -1
- package/dist/lua-8cJgIlqe.js +0 -257
- package/dist/lua-8cJgIlqe.js.map +0 -1
- package/dist/mathematica-DNLOL9PQ.js +0 -111
- package/dist/mathematica-DNLOL9PQ.js.map +0 -1
- package/dist/mbox-Ga7d4MMN.js +0 -118
- package/dist/mbox-Ga7d4MMN.js.map +0 -1
- package/dist/mirc-Dma3B8rS.js +0 -108
- package/dist/mirc-Dma3B8rS.js.map +0 -1
- package/dist/mllike-DHn7xckP.js +0 -335
- package/dist/mllike-DHn7xckP.js.map +0 -1
- package/dist/modelica-0d55jYY0.js +0 -148
- package/dist/modelica-0d55jYY0.js.map +0 -1
- package/dist/mscgen-DdqZYINH.js +0 -136
- package/dist/mscgen-DdqZYINH.js.map +0 -1
- package/dist/mumps-Btr8VblO.js +0 -94
- package/dist/mumps-Btr8VblO.js.map +0 -1
- package/dist/nginx-DTDtBDVN.js +0 -142
- package/dist/nginx-DTDtBDVN.js.map +0 -1
- package/dist/nsis-3zG7tgur.js +0 -63
- package/dist/nsis-3zG7tgur.js.map +0 -1
- package/dist/ntriples-CvgOYMpL.js +0 -154
- package/dist/ntriples-CvgOYMpL.js.map +0 -1
- package/dist/octave-DYBj3-tl.js +0 -201
- package/dist/octave-DYBj3-tl.js.map +0 -1
- package/dist/oz-R_e8WMIi.js +0 -232
- package/dist/oz-R_e8WMIi.js.map +0 -1
- package/dist/parse-CAqQaKsh.js +0 -21685
- package/dist/parse-CAqQaKsh.js.map +0 -1
- package/dist/pascal-GD8iposT.js +0 -106
- package/dist/pascal-GD8iposT.js.map +0 -1
- package/dist/perl-DL9mHpoi.js +0 -1106
- package/dist/perl-DL9mHpoi.js.map +0 -1
- package/dist/pig-C_4T4YIV.js +0 -102
- package/dist/pig-C_4T4YIV.js.map +0 -1
- package/dist/powershell-B0suO7Vd.js +0 -329
- package/dist/powershell-B0suO7Vd.js.map +0 -1
- package/dist/properties-BR-vP1aU.js +0 -59
- package/dist/properties-BR-vP1aU.js.map +0 -1
- package/dist/protobuf-BxgpyhoW.js +0 -78
- package/dist/protobuf-BxgpyhoW.js.map +0 -1
- package/dist/pug-vHnWR0UE.js +0 -406
- package/dist/pug-vHnWR0UE.js.map +0 -1
- package/dist/puppet-Bdao66PW.js +0 -138
- package/dist/puppet-Bdao66PW.js.map +0 -1
- package/dist/python-BFGRmuZ9.js +0 -427
- package/dist/python-BFGRmuZ9.js.map +0 -1
- package/dist/q-CrbCVq4a.js +0 -132
- package/dist/q-CrbCVq4a.js.map +0 -1
- package/dist/r-V7nswm59.js +0 -171
- package/dist/r-V7nswm59.js.map +0 -1
- package/dist/render-app-island-B-i8rvGi.js +0 -61
- package/dist/render-app-island-B-i8rvGi.js.map +0 -1
- package/dist/repl-sdk.js +0 -7
- package/dist/repl-sdk.js.map +0 -1
- package/dist/rpm-C-DLY-If.js +0 -110
- package/dist/rpm-C-DLY-If.js.map +0 -1
- package/dist/ruby-JDKLJNK0.js +0 -331
- package/dist/ruby-JDKLJNK0.js.map +0 -1
- package/dist/sas-D2UG-yhZ.js +0 -208
- package/dist/sas-D2UG-yhZ.js.map +0 -1
- package/dist/scheme-BKzrkGJD.js +0 -223
- package/dist/scheme-BKzrkGJD.js.map +0 -1
- package/dist/shell-BlsXDxCn.js +0 -223
- package/dist/shell-BlsXDxCn.js.map +0 -1
- package/dist/sieve-CjwBwOY5.js +0 -136
- package/dist/sieve-CjwBwOY5.js.map +0 -1
- package/dist/simple-mode-DMneyfDu.js +0 -131
- package/dist/simple-mode-DMneyfDu.js.map +0 -1
- package/dist/smalltalk-BOIGQuhN.js +0 -122
- package/dist/smalltalk-BOIGQuhN.js.map +0 -1
- package/dist/solr-CwD7U71z.js +0 -70
- package/dist/solr-CwD7U71z.js.map +0 -1
- package/dist/sparql-DYskk2vE.js +0 -250
- package/dist/sparql-DYskk2vE.js.map +0 -1
- package/dist/spreadsheet-Bgtt3oLP.js +0 -88
- package/dist/spreadsheet-Bgtt3oLP.js.map +0 -1
- package/dist/sql-Cei9CMfk.js +0 -343
- package/dist/sql-Cei9CMfk.js.map +0 -1
- package/dist/stex-C1nZSzAw.js +0 -231
- package/dist/stex-C1nZSzAw.js.map +0 -1
- package/dist/stylus-BkS-boTH.js +0 -566
- package/dist/stylus-BkS-boTH.js.map +0 -1
- package/dist/swift-FRZi1uvB.js +0 -292
- package/dist/swift-FRZi1uvB.js.map +0 -1
- package/dist/tcl-CUcaCdmq.js +0 -115
- package/dist/tcl-CUcaCdmq.js.map +0 -1
- package/dist/textile-BnFpjsrl.js +0 -415
- package/dist/textile-BnFpjsrl.js.map +0 -1
- package/dist/tiddlywiki-CjprD-Qp.js +0 -219
- package/dist/tiddlywiki-CjprD-Qp.js.map +0 -1
- package/dist/tiki-DK9DOeWn.js +0 -269
- package/dist/tiki-DK9DOeWn.js.map +0 -1
- package/dist/toml-BOuWGMcf.js +0 -77
- package/dist/toml-BOuWGMcf.js.map +0 -1
- package/dist/troff-E1bJ0PPL.js +0 -62
- package/dist/troff-E1bJ0PPL.js.map +0 -1
- package/dist/ttcn-cfg-Dc39-fIP.js +0 -134
- package/dist/ttcn-cfg-Dc39-fIP.js.map +0 -1
- package/dist/ttcn-tKd4HLu4.js +0 -193
- package/dist/ttcn-tKd4HLu4.js.map +0 -1
- package/dist/turtle-Dq7-1WAf.js +0 -125
- package/dist/turtle-Dq7-1WAf.js.map +0 -1
- package/dist/vb-Dp90gtsv.js +0 -197
- package/dist/vb-Dp90gtsv.js.map +0 -1
- package/dist/vbscript-Bfn8O8I7.js +0 -479
- package/dist/vbscript-Bfn8O8I7.js.map +0 -1
- package/dist/velocity-BwIZK1TH.js +0 -150
- package/dist/velocity-BwIZK1TH.js.map +0 -1
- package/dist/verilog-CnT9bMk0.js +0 -430
- package/dist/verilog-CnT9bMk0.js.map +0 -1
- package/dist/vhdl-DCkMIyT9.js +0 -159
- package/dist/vhdl-DCkMIyT9.js.map +0 -1
- package/dist/webidl-BTLTThCm.js +0 -205
- package/dist/webidl-BTLTThCm.js.map +0 -1
- package/dist/xquery-BrBUuxMR.js +0 -526
- package/dist/xquery-BrBUuxMR.js.map +0 -1
- package/dist/yacas-b5lAVEIl.js +0 -131
- package/dist/yacas-b5lAVEIl.js.map +0 -1
- package/dist/z80-ClgwfNdB.js +0 -93
- package/dist/z80-ClgwfNdB.js.map +0 -1
package/dist/index-CVGAEPMV.js
DELETED
|
@@ -1,2139 +0,0 @@
|
|
|
1
|
-
import { wrap } from "comlink";
|
|
2
|
-
import { exports as _exports } from "resolve.exports";
|
|
3
|
-
import { resolve as resolve$2 } from "resolve.imports";
|
|
4
|
-
const types = {
|
|
5
|
-
"application/andrew-inset": ["ez"],
|
|
6
|
-
"application/appinstaller": ["appinstaller"],
|
|
7
|
-
"application/applixware": ["aw"],
|
|
8
|
-
"application/appx": ["appx"],
|
|
9
|
-
"application/appxbundle": ["appxbundle"],
|
|
10
|
-
"application/atom+xml": ["atom"],
|
|
11
|
-
"application/atomcat+xml": ["atomcat"],
|
|
12
|
-
"application/atomdeleted+xml": ["atomdeleted"],
|
|
13
|
-
"application/atomsvc+xml": ["atomsvc"],
|
|
14
|
-
"application/atsc-dwd+xml": ["dwd"],
|
|
15
|
-
"application/atsc-held+xml": ["held"],
|
|
16
|
-
"application/atsc-rsat+xml": ["rsat"],
|
|
17
|
-
"application/automationml-aml+xml": ["aml"],
|
|
18
|
-
"application/automationml-amlx+zip": ["amlx"],
|
|
19
|
-
"application/bdoc": ["bdoc"],
|
|
20
|
-
"application/calendar+xml": ["xcs"],
|
|
21
|
-
"application/ccxml+xml": ["ccxml"],
|
|
22
|
-
"application/cdfx+xml": ["cdfx"],
|
|
23
|
-
"application/cdmi-capability": ["cdmia"],
|
|
24
|
-
"application/cdmi-container": ["cdmic"],
|
|
25
|
-
"application/cdmi-domain": ["cdmid"],
|
|
26
|
-
"application/cdmi-object": ["cdmio"],
|
|
27
|
-
"application/cdmi-queue": ["cdmiq"],
|
|
28
|
-
"application/cpl+xml": ["cpl"],
|
|
29
|
-
"application/cu-seeme": ["cu"],
|
|
30
|
-
"application/cwl": ["cwl"],
|
|
31
|
-
"application/dash+xml": ["mpd"],
|
|
32
|
-
"application/dash-patch+xml": ["mpp"],
|
|
33
|
-
"application/davmount+xml": ["davmount"],
|
|
34
|
-
"application/dicom": ["dcm"],
|
|
35
|
-
"application/docbook+xml": ["dbk"],
|
|
36
|
-
"application/dssc+der": ["dssc"],
|
|
37
|
-
"application/dssc+xml": ["xdssc"],
|
|
38
|
-
"application/ecmascript": ["ecma"],
|
|
39
|
-
"application/emma+xml": ["emma"],
|
|
40
|
-
"application/emotionml+xml": ["emotionml"],
|
|
41
|
-
"application/epub+zip": ["epub"],
|
|
42
|
-
"application/exi": ["exi"],
|
|
43
|
-
"application/express": ["exp"],
|
|
44
|
-
"application/fdf": ["fdf"],
|
|
45
|
-
"application/fdt+xml": ["fdt"],
|
|
46
|
-
"application/font-tdpfr": ["pfr"],
|
|
47
|
-
"application/geo+json": ["geojson"],
|
|
48
|
-
"application/gml+xml": ["gml"],
|
|
49
|
-
"application/gpx+xml": ["gpx"],
|
|
50
|
-
"application/gxf": ["gxf"],
|
|
51
|
-
"application/gzip": ["gz"],
|
|
52
|
-
"application/hjson": ["hjson"],
|
|
53
|
-
"application/hyperstudio": ["stk"],
|
|
54
|
-
"application/inkml+xml": ["ink", "inkml"],
|
|
55
|
-
"application/ipfix": ["ipfix"],
|
|
56
|
-
"application/its+xml": ["its"],
|
|
57
|
-
"application/java-archive": ["jar", "war", "ear"],
|
|
58
|
-
"application/java-serialized-object": ["ser"],
|
|
59
|
-
"application/java-vm": ["class"],
|
|
60
|
-
"application/javascript": ["*js"],
|
|
61
|
-
"application/json": ["json", "map"],
|
|
62
|
-
"application/json5": ["json5"],
|
|
63
|
-
"application/jsonml+json": ["jsonml"],
|
|
64
|
-
"application/ld+json": ["jsonld"],
|
|
65
|
-
"application/lgr+xml": ["lgr"],
|
|
66
|
-
"application/lost+xml": ["lostxml"],
|
|
67
|
-
"application/mac-binhex40": ["hqx"],
|
|
68
|
-
"application/mac-compactpro": ["cpt"],
|
|
69
|
-
"application/mads+xml": ["mads"],
|
|
70
|
-
"application/manifest+json": ["webmanifest"],
|
|
71
|
-
"application/marc": ["mrc"],
|
|
72
|
-
"application/marcxml+xml": ["mrcx"],
|
|
73
|
-
"application/mathematica": ["ma", "nb", "mb"],
|
|
74
|
-
"application/mathml+xml": ["mathml"],
|
|
75
|
-
"application/mbox": ["mbox"],
|
|
76
|
-
"application/media-policy-dataset+xml": ["mpf"],
|
|
77
|
-
"application/mediaservercontrol+xml": ["mscml"],
|
|
78
|
-
"application/metalink+xml": ["metalink"],
|
|
79
|
-
"application/metalink4+xml": ["meta4"],
|
|
80
|
-
"application/mets+xml": ["mets"],
|
|
81
|
-
"application/mmt-aei+xml": ["maei"],
|
|
82
|
-
"application/mmt-usd+xml": ["musd"],
|
|
83
|
-
"application/mods+xml": ["mods"],
|
|
84
|
-
"application/mp21": ["m21", "mp21"],
|
|
85
|
-
"application/mp4": ["*mp4", "*mpg4", "mp4s", "m4p"],
|
|
86
|
-
"application/msix": ["msix"],
|
|
87
|
-
"application/msixbundle": ["msixbundle"],
|
|
88
|
-
"application/msword": ["doc", "dot"],
|
|
89
|
-
"application/mxf": ["mxf"],
|
|
90
|
-
"application/n-quads": ["nq"],
|
|
91
|
-
"application/n-triples": ["nt"],
|
|
92
|
-
"application/node": ["cjs"],
|
|
93
|
-
"application/octet-stream": [
|
|
94
|
-
"bin",
|
|
95
|
-
"dms",
|
|
96
|
-
"lrf",
|
|
97
|
-
"mar",
|
|
98
|
-
"so",
|
|
99
|
-
"dist",
|
|
100
|
-
"distz",
|
|
101
|
-
"pkg",
|
|
102
|
-
"bpk",
|
|
103
|
-
"dump",
|
|
104
|
-
"elc",
|
|
105
|
-
"deploy",
|
|
106
|
-
"exe",
|
|
107
|
-
"dll",
|
|
108
|
-
"deb",
|
|
109
|
-
"dmg",
|
|
110
|
-
"iso",
|
|
111
|
-
"img",
|
|
112
|
-
"msi",
|
|
113
|
-
"msp",
|
|
114
|
-
"msm",
|
|
115
|
-
"buffer"
|
|
116
|
-
],
|
|
117
|
-
"application/oda": ["oda"],
|
|
118
|
-
"application/oebps-package+xml": ["opf"],
|
|
119
|
-
"application/ogg": ["ogx"],
|
|
120
|
-
"application/omdoc+xml": ["omdoc"],
|
|
121
|
-
"application/onenote": [
|
|
122
|
-
"onetoc",
|
|
123
|
-
"onetoc2",
|
|
124
|
-
"onetmp",
|
|
125
|
-
"onepkg",
|
|
126
|
-
"one",
|
|
127
|
-
"onea"
|
|
128
|
-
],
|
|
129
|
-
"application/oxps": ["oxps"],
|
|
130
|
-
"application/p2p-overlay+xml": ["relo"],
|
|
131
|
-
"application/patch-ops-error+xml": ["xer"],
|
|
132
|
-
"application/pdf": ["pdf"],
|
|
133
|
-
"application/pgp-encrypted": ["pgp"],
|
|
134
|
-
"application/pgp-keys": ["asc"],
|
|
135
|
-
"application/pgp-signature": ["sig", "*asc"],
|
|
136
|
-
"application/pics-rules": ["prf"],
|
|
137
|
-
"application/pkcs10": ["p10"],
|
|
138
|
-
"application/pkcs7-mime": ["p7m", "p7c"],
|
|
139
|
-
"application/pkcs7-signature": ["p7s"],
|
|
140
|
-
"application/pkcs8": ["p8"],
|
|
141
|
-
"application/pkix-attr-cert": ["ac"],
|
|
142
|
-
"application/pkix-cert": ["cer"],
|
|
143
|
-
"application/pkix-crl": ["crl"],
|
|
144
|
-
"application/pkix-pkipath": ["pkipath"],
|
|
145
|
-
"application/pkixcmp": ["pki"],
|
|
146
|
-
"application/pls+xml": ["pls"],
|
|
147
|
-
"application/postscript": ["ai", "eps", "ps"],
|
|
148
|
-
"application/provenance+xml": ["provx"],
|
|
149
|
-
"application/pskc+xml": ["pskcxml"],
|
|
150
|
-
"application/raml+yaml": ["raml"],
|
|
151
|
-
"application/rdf+xml": ["rdf", "owl"],
|
|
152
|
-
"application/reginfo+xml": ["rif"],
|
|
153
|
-
"application/relax-ng-compact-syntax": ["rnc"],
|
|
154
|
-
"application/resource-lists+xml": ["rl"],
|
|
155
|
-
"application/resource-lists-diff+xml": ["rld"],
|
|
156
|
-
"application/rls-services+xml": ["rs"],
|
|
157
|
-
"application/route-apd+xml": ["rapd"],
|
|
158
|
-
"application/route-s-tsid+xml": ["sls"],
|
|
159
|
-
"application/route-usd+xml": ["rusd"],
|
|
160
|
-
"application/rpki-ghostbusters": ["gbr"],
|
|
161
|
-
"application/rpki-manifest": ["mft"],
|
|
162
|
-
"application/rpki-roa": ["roa"],
|
|
163
|
-
"application/rsd+xml": ["rsd"],
|
|
164
|
-
"application/rss+xml": ["rss"],
|
|
165
|
-
"application/rtf": ["rtf"],
|
|
166
|
-
"application/sbml+xml": ["sbml"],
|
|
167
|
-
"application/scvp-cv-request": ["scq"],
|
|
168
|
-
"application/scvp-cv-response": ["scs"],
|
|
169
|
-
"application/scvp-vp-request": ["spq"],
|
|
170
|
-
"application/scvp-vp-response": ["spp"],
|
|
171
|
-
"application/sdp": ["sdp"],
|
|
172
|
-
"application/senml+xml": ["senmlx"],
|
|
173
|
-
"application/sensml+xml": ["sensmlx"],
|
|
174
|
-
"application/set-payment-initiation": ["setpay"],
|
|
175
|
-
"application/set-registration-initiation": ["setreg"],
|
|
176
|
-
"application/shf+xml": ["shf"],
|
|
177
|
-
"application/sieve": ["siv", "sieve"],
|
|
178
|
-
"application/smil+xml": ["smi", "smil"],
|
|
179
|
-
"application/sparql-query": ["rq"],
|
|
180
|
-
"application/sparql-results+xml": ["srx"],
|
|
181
|
-
"application/sql": ["sql"],
|
|
182
|
-
"application/srgs": ["gram"],
|
|
183
|
-
"application/srgs+xml": ["grxml"],
|
|
184
|
-
"application/sru+xml": ["sru"],
|
|
185
|
-
"application/ssdl+xml": ["ssdl"],
|
|
186
|
-
"application/ssml+xml": ["ssml"],
|
|
187
|
-
"application/swid+xml": ["swidtag"],
|
|
188
|
-
"application/tei+xml": ["tei", "teicorpus"],
|
|
189
|
-
"application/thraud+xml": ["tfi"],
|
|
190
|
-
"application/timestamped-data": ["tsd"],
|
|
191
|
-
"application/toml": ["toml"],
|
|
192
|
-
"application/trig": ["trig"],
|
|
193
|
-
"application/ttml+xml": ["ttml"],
|
|
194
|
-
"application/ubjson": ["ubj"],
|
|
195
|
-
"application/urc-ressheet+xml": ["rsheet"],
|
|
196
|
-
"application/urc-targetdesc+xml": ["td"],
|
|
197
|
-
"application/voicexml+xml": ["vxml"],
|
|
198
|
-
"application/wasm": ["wasm"],
|
|
199
|
-
"application/watcherinfo+xml": ["wif"],
|
|
200
|
-
"application/widget": ["wgt"],
|
|
201
|
-
"application/winhlp": ["hlp"],
|
|
202
|
-
"application/wsdl+xml": ["wsdl"],
|
|
203
|
-
"application/wspolicy+xml": ["wspolicy"],
|
|
204
|
-
"application/xaml+xml": ["xaml"],
|
|
205
|
-
"application/xcap-att+xml": ["xav"],
|
|
206
|
-
"application/xcap-caps+xml": ["xca"],
|
|
207
|
-
"application/xcap-diff+xml": ["xdf"],
|
|
208
|
-
"application/xcap-el+xml": ["xel"],
|
|
209
|
-
"application/xcap-ns+xml": ["xns"],
|
|
210
|
-
"application/xenc+xml": ["xenc"],
|
|
211
|
-
"application/xfdf": ["xfdf"],
|
|
212
|
-
"application/xhtml+xml": ["xhtml", "xht"],
|
|
213
|
-
"application/xliff+xml": ["xlf"],
|
|
214
|
-
"application/xml": ["xml", "xsl", "xsd", "rng"],
|
|
215
|
-
"application/xml-dtd": ["dtd"],
|
|
216
|
-
"application/xop+xml": ["xop"],
|
|
217
|
-
"application/xproc+xml": ["xpl"],
|
|
218
|
-
"application/xslt+xml": ["*xsl", "xslt"],
|
|
219
|
-
"application/xspf+xml": ["xspf"],
|
|
220
|
-
"application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"],
|
|
221
|
-
"application/yang": ["yang"],
|
|
222
|
-
"application/yin+xml": ["yin"],
|
|
223
|
-
"application/zip": ["zip"],
|
|
224
|
-
"application/zip+dotlottie": ["lottie"],
|
|
225
|
-
"audio/3gpp": ["*3gpp"],
|
|
226
|
-
"audio/aac": ["adts", "aac"],
|
|
227
|
-
"audio/adpcm": ["adp"],
|
|
228
|
-
"audio/amr": ["amr"],
|
|
229
|
-
"audio/basic": ["au", "snd"],
|
|
230
|
-
"audio/midi": ["mid", "midi", "kar", "rmi"],
|
|
231
|
-
"audio/mobile-xmf": ["mxmf"],
|
|
232
|
-
"audio/mp3": ["*mp3"],
|
|
233
|
-
"audio/mp4": ["m4a", "mp4a", "m4b"],
|
|
234
|
-
"audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"],
|
|
235
|
-
"audio/ogg": ["oga", "ogg", "spx", "opus"],
|
|
236
|
-
"audio/s3m": ["s3m"],
|
|
237
|
-
"audio/silk": ["sil"],
|
|
238
|
-
"audio/wav": ["wav"],
|
|
239
|
-
"audio/wave": ["*wav"],
|
|
240
|
-
"audio/webm": ["weba"],
|
|
241
|
-
"audio/xm": ["xm"],
|
|
242
|
-
"font/collection": ["ttc"],
|
|
243
|
-
"font/otf": ["otf"],
|
|
244
|
-
"font/ttf": ["ttf"],
|
|
245
|
-
"font/woff": ["woff"],
|
|
246
|
-
"font/woff2": ["woff2"],
|
|
247
|
-
"image/aces": ["exr"],
|
|
248
|
-
"image/apng": ["apng"],
|
|
249
|
-
"image/avci": ["avci"],
|
|
250
|
-
"image/avcs": ["avcs"],
|
|
251
|
-
"image/avif": ["avif"],
|
|
252
|
-
"image/bmp": ["bmp", "dib"],
|
|
253
|
-
"image/cgm": ["cgm"],
|
|
254
|
-
"image/dicom-rle": ["drle"],
|
|
255
|
-
"image/dpx": ["dpx"],
|
|
256
|
-
"image/emf": ["emf"],
|
|
257
|
-
"image/fits": ["fits"],
|
|
258
|
-
"image/g3fax": ["g3"],
|
|
259
|
-
"image/gif": ["gif"],
|
|
260
|
-
"image/heic": ["heic"],
|
|
261
|
-
"image/heic-sequence": ["heics"],
|
|
262
|
-
"image/heif": ["heif"],
|
|
263
|
-
"image/heif-sequence": ["heifs"],
|
|
264
|
-
"image/hej2k": ["hej2"],
|
|
265
|
-
"image/ief": ["ief"],
|
|
266
|
-
"image/jaii": ["jaii"],
|
|
267
|
-
"image/jais": ["jais"],
|
|
268
|
-
"image/jls": ["jls"],
|
|
269
|
-
"image/jp2": ["jp2", "jpg2"],
|
|
270
|
-
"image/jpeg": ["jpg", "jpeg", "jpe"],
|
|
271
|
-
"image/jph": ["jph"],
|
|
272
|
-
"image/jphc": ["jhc"],
|
|
273
|
-
"image/jpm": ["jpm", "jpgm"],
|
|
274
|
-
"image/jpx": ["jpx", "jpf"],
|
|
275
|
-
"image/jxl": ["jxl"],
|
|
276
|
-
"image/jxr": ["jxr"],
|
|
277
|
-
"image/jxra": ["jxra"],
|
|
278
|
-
"image/jxrs": ["jxrs"],
|
|
279
|
-
"image/jxs": ["jxs"],
|
|
280
|
-
"image/jxsc": ["jxsc"],
|
|
281
|
-
"image/jxsi": ["jxsi"],
|
|
282
|
-
"image/jxss": ["jxss"],
|
|
283
|
-
"image/ktx": ["ktx"],
|
|
284
|
-
"image/ktx2": ["ktx2"],
|
|
285
|
-
"image/pjpeg": ["jfif"],
|
|
286
|
-
"image/png": ["png"],
|
|
287
|
-
"image/sgi": ["sgi"],
|
|
288
|
-
"image/svg+xml": ["svg", "svgz"],
|
|
289
|
-
"image/t38": ["t38"],
|
|
290
|
-
"image/tiff": ["tif", "tiff"],
|
|
291
|
-
"image/tiff-fx": ["tfx"],
|
|
292
|
-
"image/webp": ["webp"],
|
|
293
|
-
"image/wmf": ["wmf"],
|
|
294
|
-
"message/disposition-notification": ["disposition-notification"],
|
|
295
|
-
"message/global": ["u8msg"],
|
|
296
|
-
"message/global-delivery-status": ["u8dsn"],
|
|
297
|
-
"message/global-disposition-notification": ["u8mdn"],
|
|
298
|
-
"message/global-headers": ["u8hdr"],
|
|
299
|
-
"message/rfc822": ["eml", "mime", "mht", "mhtml"],
|
|
300
|
-
"model/3mf": ["3mf"],
|
|
301
|
-
"model/gltf+json": ["gltf"],
|
|
302
|
-
"model/gltf-binary": ["glb"],
|
|
303
|
-
"model/iges": ["igs", "iges"],
|
|
304
|
-
"model/jt": ["jt"],
|
|
305
|
-
"model/mesh": ["msh", "mesh", "silo"],
|
|
306
|
-
"model/mtl": ["mtl"],
|
|
307
|
-
"model/obj": ["obj"],
|
|
308
|
-
"model/prc": ["prc"],
|
|
309
|
-
"model/step": ["step", "stp", "stpnc", "p21", "210"],
|
|
310
|
-
"model/step+xml": ["stpx"],
|
|
311
|
-
"model/step+zip": ["stpz"],
|
|
312
|
-
"model/step-xml+zip": ["stpxz"],
|
|
313
|
-
"model/stl": ["stl"],
|
|
314
|
-
"model/u3d": ["u3d"],
|
|
315
|
-
"model/vrml": ["wrl", "vrml"],
|
|
316
|
-
"model/x3d+binary": ["*x3db", "x3dbz"],
|
|
317
|
-
"model/x3d+fastinfoset": ["x3db"],
|
|
318
|
-
"model/x3d+vrml": ["*x3dv", "x3dvz"],
|
|
319
|
-
"model/x3d+xml": ["x3d", "x3dz"],
|
|
320
|
-
"model/x3d-vrml": ["x3dv"],
|
|
321
|
-
"text/cache-manifest": ["appcache", "manifest"],
|
|
322
|
-
"text/calendar": ["ics", "ifb"],
|
|
323
|
-
"text/coffeescript": ["coffee", "litcoffee"],
|
|
324
|
-
"text/css": ["css"],
|
|
325
|
-
"text/csv": ["csv"],
|
|
326
|
-
"text/html": ["html", "htm", "shtml"],
|
|
327
|
-
"text/jade": ["jade"],
|
|
328
|
-
"text/javascript": ["js", "mjs"],
|
|
329
|
-
"text/jsx": ["jsx"],
|
|
330
|
-
"text/less": ["less"],
|
|
331
|
-
"text/markdown": ["md", "markdown"],
|
|
332
|
-
"text/mathml": ["mml"],
|
|
333
|
-
"text/mdx": ["mdx"],
|
|
334
|
-
"text/n3": ["n3"],
|
|
335
|
-
"text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"],
|
|
336
|
-
"text/richtext": ["rtx"],
|
|
337
|
-
"text/rtf": ["*rtf"],
|
|
338
|
-
"text/sgml": ["sgml", "sgm"],
|
|
339
|
-
"text/shex": ["shex"],
|
|
340
|
-
"text/slim": ["slim", "slm"],
|
|
341
|
-
"text/spdx": ["spdx"],
|
|
342
|
-
"text/stylus": ["stylus", "styl"],
|
|
343
|
-
"text/tab-separated-values": ["tsv"],
|
|
344
|
-
"text/troff": ["t", "tr", "roff", "man", "me", "ms"],
|
|
345
|
-
"text/turtle": ["ttl"],
|
|
346
|
-
"text/uri-list": ["uri", "uris", "urls"],
|
|
347
|
-
"text/vcard": ["vcard"],
|
|
348
|
-
"text/vtt": ["vtt"],
|
|
349
|
-
"text/wgsl": ["wgsl"],
|
|
350
|
-
"text/xml": ["*xml"],
|
|
351
|
-
"text/yaml": ["yaml", "yml"],
|
|
352
|
-
"video/3gpp": ["3gp", "3gpp"],
|
|
353
|
-
"video/3gpp2": ["3g2"],
|
|
354
|
-
"video/h261": ["h261"],
|
|
355
|
-
"video/h263": ["h263"],
|
|
356
|
-
"video/h264": ["h264"],
|
|
357
|
-
"video/iso.segment": ["m4s"],
|
|
358
|
-
"video/jpeg": ["jpgv"],
|
|
359
|
-
"video/jpm": ["*jpm", "*jpgm"],
|
|
360
|
-
"video/mj2": ["mj2", "mjp2"],
|
|
361
|
-
"video/mp2t": ["ts", "m2t", "m2ts", "mts"],
|
|
362
|
-
"video/mp4": ["mp4", "mp4v", "mpg4"],
|
|
363
|
-
"video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"],
|
|
364
|
-
"video/ogg": ["ogv"],
|
|
365
|
-
"video/quicktime": ["qt", "mov"],
|
|
366
|
-
"video/webm": ["webm"]
|
|
367
|
-
};
|
|
368
|
-
Object.freeze(types);
|
|
369
|
-
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
370
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
371
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
372
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
373
|
-
};
|
|
374
|
-
var _Mime_extensionToType, _Mime_typeToExtension, _Mime_typeToExtensions;
|
|
375
|
-
class Mime {
|
|
376
|
-
constructor(...args) {
|
|
377
|
-
_Mime_extensionToType.set(this, /* @__PURE__ */ new Map());
|
|
378
|
-
_Mime_typeToExtension.set(this, /* @__PURE__ */ new Map());
|
|
379
|
-
_Mime_typeToExtensions.set(this, /* @__PURE__ */ new Map());
|
|
380
|
-
for (const arg of args) {
|
|
381
|
-
this.define(arg);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
define(typeMap, force = false) {
|
|
385
|
-
for (let [type, extensions] of Object.entries(typeMap)) {
|
|
386
|
-
type = type.toLowerCase();
|
|
387
|
-
extensions = extensions.map((ext) => ext.toLowerCase());
|
|
388
|
-
if (!__classPrivateFieldGet(this, _Mime_typeToExtensions, "f").has(type)) {
|
|
389
|
-
__classPrivateFieldGet(this, _Mime_typeToExtensions, "f").set(type, /* @__PURE__ */ new Set());
|
|
390
|
-
}
|
|
391
|
-
const allExtensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type);
|
|
392
|
-
let first = true;
|
|
393
|
-
for (let extension of extensions) {
|
|
394
|
-
const starred = extension.startsWith("*");
|
|
395
|
-
extension = starred ? extension.slice(1) : extension;
|
|
396
|
-
allExtensions?.add(extension);
|
|
397
|
-
if (first) {
|
|
398
|
-
__classPrivateFieldGet(this, _Mime_typeToExtension, "f").set(type, extension);
|
|
399
|
-
}
|
|
400
|
-
first = false;
|
|
401
|
-
if (starred)
|
|
402
|
-
continue;
|
|
403
|
-
const currentType = __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(extension);
|
|
404
|
-
if (currentType && currentType != type && !force) {
|
|
405
|
-
throw new Error(`"${type} -> ${extension}" conflicts with "${currentType} -> ${extension}". Pass \`force=true\` to override this definition.`);
|
|
406
|
-
}
|
|
407
|
-
__classPrivateFieldGet(this, _Mime_extensionToType, "f").set(extension, type);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return this;
|
|
411
|
-
}
|
|
412
|
-
getType(path) {
|
|
413
|
-
if (typeof path !== "string")
|
|
414
|
-
return null;
|
|
415
|
-
const last = path.replace(/^.*[/\\]/s, "").toLowerCase();
|
|
416
|
-
const ext = last.replace(/^.*\./s, "").toLowerCase();
|
|
417
|
-
const hasPath = last.length < path.length;
|
|
418
|
-
const hasDot = ext.length < last.length - 1;
|
|
419
|
-
if (!hasDot && hasPath)
|
|
420
|
-
return null;
|
|
421
|
-
return __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(ext) ?? null;
|
|
422
|
-
}
|
|
423
|
-
getExtension(type) {
|
|
424
|
-
if (typeof type !== "string")
|
|
425
|
-
return null;
|
|
426
|
-
type = type?.split?.(";")[0];
|
|
427
|
-
return (type && __classPrivateFieldGet(this, _Mime_typeToExtension, "f").get(type.trim().toLowerCase())) ?? null;
|
|
428
|
-
}
|
|
429
|
-
getAllExtensions(type) {
|
|
430
|
-
if (typeof type !== "string")
|
|
431
|
-
return null;
|
|
432
|
-
return __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type.toLowerCase()) ?? null;
|
|
433
|
-
}
|
|
434
|
-
_freeze() {
|
|
435
|
-
this.define = () => {
|
|
436
|
-
throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
|
|
437
|
-
};
|
|
438
|
-
Object.freeze(this);
|
|
439
|
-
for (const extensions of __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").values()) {
|
|
440
|
-
Object.freeze(extensions);
|
|
441
|
-
}
|
|
442
|
-
return this;
|
|
443
|
-
}
|
|
444
|
-
_getTestState() {
|
|
445
|
-
return {
|
|
446
|
-
types: __classPrivateFieldGet(this, _Mime_extensionToType, "f"),
|
|
447
|
-
extensions: __classPrivateFieldGet(this, _Mime_typeToExtension, "f")
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
_Mime_extensionToType = /* @__PURE__ */ new WeakMap(), _Mime_typeToExtension = /* @__PURE__ */ new WeakMap(), _Mime_typeToExtensions = /* @__PURE__ */ new WeakMap();
|
|
452
|
-
const mime = new Mime(types)._freeze();
|
|
453
|
-
function assert(message, test) {
|
|
454
|
-
if (!test) {
|
|
455
|
-
throw new Error(message);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
let i = 0;
|
|
459
|
-
function nextId() {
|
|
460
|
-
i += 1;
|
|
461
|
-
return `repl_${i}`;
|
|
462
|
-
}
|
|
463
|
-
const fakeDomain = "repl.sdk";
|
|
464
|
-
const tgzPrefix = "file:///tgz.repl.sdk/";
|
|
465
|
-
const unzippedPrefix = "file:///tgz.repl.sdk/unzipped";
|
|
466
|
-
function prefix_tgz(url) {
|
|
467
|
-
return `${tgzPrefix}${url}`;
|
|
468
|
-
}
|
|
469
|
-
function isRecord(x) {
|
|
470
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
471
|
-
}
|
|
472
|
-
const secretKey = "__repl-sdk__compiler__";
|
|
473
|
-
const secret = Symbol.for(secretKey);
|
|
474
|
-
function getGlobal() {
|
|
475
|
-
const global = (
|
|
476
|
-
/** @type {ExtendedWindow} */
|
|
477
|
-
globalThis
|
|
478
|
-
);
|
|
479
|
-
return global;
|
|
480
|
-
}
|
|
481
|
-
assert(
|
|
482
|
-
`There is already an instance of repl-sdk, and there can only be one. Make sure that your dependency graph is correct.`,
|
|
483
|
-
!getGlobal()[secret]
|
|
484
|
-
);
|
|
485
|
-
class Caches {
|
|
486
|
-
clear() {
|
|
487
|
-
delete getGlobal()[secret];
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Cache of resolved modulePaths to their module "value"
|
|
491
|
-
*
|
|
492
|
-
* @type {{ [modulePath: string]: unknown }}
|
|
493
|
-
*/
|
|
494
|
-
get resolves() {
|
|
495
|
-
this.#root.resolves ||= {};
|
|
496
|
-
return this.#root.resolves;
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Cache of untarred tarballs
|
|
500
|
-
*
|
|
501
|
-
* @type {Map<string, import('./types.ts').UntarredPackage>}
|
|
502
|
-
*/
|
|
503
|
-
get tarballs() {
|
|
504
|
-
this.#root.tarballs ||= /* @__PURE__ */ new Map();
|
|
505
|
-
return this.#root.tarballs;
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Cache of request resolutions
|
|
509
|
-
*
|
|
510
|
-
* @type {Map<string, ResolveIdValue>}
|
|
511
|
-
*/
|
|
512
|
-
get resolveId() {
|
|
513
|
-
this.#root.resolveId ||= /* @__PURE__ */ new Map();
|
|
514
|
-
return this.#root.resolveId;
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Cache of request Key to file content string
|
|
518
|
-
*
|
|
519
|
-
* @type {Map<string, { code: string, ext: string }>}
|
|
520
|
-
*/
|
|
521
|
-
get fileCache() {
|
|
522
|
-
this.#root.fileCache ||= /* @__PURE__ */ new Map();
|
|
523
|
-
return this.#root.fileCache;
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* For any key, store a promise for resolving later
|
|
527
|
-
*
|
|
528
|
-
* @type {Map<string, Promise<unknown>>}
|
|
529
|
-
*/
|
|
530
|
-
get promiseCache() {
|
|
531
|
-
this.#root.promiseCache ||= /* @__PURE__ */ new Map();
|
|
532
|
-
return this.#root.promiseCache;
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* @template Return
|
|
536
|
-
* @type {(key: string, callback: () => Promise<any>) => Promise<any>}
|
|
537
|
-
*/
|
|
538
|
-
cachedPromise(key, callback) {
|
|
539
|
-
const existing = this.promiseCache.get(key);
|
|
540
|
-
if (existing) {
|
|
541
|
-
return (
|
|
542
|
-
/** @type {Promise<Return>} */
|
|
543
|
-
existing
|
|
544
|
-
);
|
|
545
|
-
}
|
|
546
|
-
const promise = callback();
|
|
547
|
-
this.promiseCache.set(key, promise);
|
|
548
|
-
return promise;
|
|
549
|
-
}
|
|
550
|
-
get requestCache() {
|
|
551
|
-
this.#root.requestCache ||= /* @__PURE__ */ new Map();
|
|
552
|
-
return this.#root.requestCache;
|
|
553
|
-
}
|
|
554
|
-
get #root() {
|
|
555
|
-
const global = getGlobal();
|
|
556
|
-
global[secret] ||= {};
|
|
557
|
-
global[secret].caches ||= this;
|
|
558
|
-
return global[secret];
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
const cache = new Caches();
|
|
562
|
-
const externalPackages = [
|
|
563
|
-
"@ember/test-helpers",
|
|
564
|
-
"@ember/string",
|
|
565
|
-
"@ember/test-waiters",
|
|
566
|
-
"@ember/render-modifiers",
|
|
567
|
-
"@glimmer/component"
|
|
568
|
-
];
|
|
569
|
-
function resolve$1(id) {
|
|
570
|
-
if (id === "@ember/template-compiler/runtime") {
|
|
571
|
-
return `https://esm.sh/*ember-source/dist/packages/@ember/template-compiler/runtime.js`;
|
|
572
|
-
}
|
|
573
|
-
const isExternalEmber = externalPackages.some((name) => id.startsWith(name));
|
|
574
|
-
if (isExternalEmber) {
|
|
575
|
-
return `https://esm.sh/*${id}`;
|
|
576
|
-
}
|
|
577
|
-
if (id.startsWith("@ember")) {
|
|
578
|
-
return `https://esm.sh/*ember-source/dist/packages/${id}`;
|
|
579
|
-
}
|
|
580
|
-
if (id.startsWith("@glimmer")) {
|
|
581
|
-
return `https://esm.sh/*ember-source/dist/dependencies/${id}.js`;
|
|
582
|
-
}
|
|
583
|
-
if (id.startsWith("@embroider/macros")) {
|
|
584
|
-
return () => ({
|
|
585
|
-
// passthrough, we are not doing dead-code-elimination
|
|
586
|
-
/**
|
|
587
|
-
* @param {unknown} x
|
|
588
|
-
*/
|
|
589
|
-
macroCondition: (x) => Boolean(x),
|
|
590
|
-
// I *could* actually implement this
|
|
591
|
-
dependencySatisfies: () => true,
|
|
592
|
-
isDevelopingApp: () => true,
|
|
593
|
-
getGlobalConfig: () => ({
|
|
594
|
-
WarpDrive: {
|
|
595
|
-
debug: false,
|
|
596
|
-
env: {
|
|
597
|
-
DEBUG: false,
|
|
598
|
-
TESTING: false,
|
|
599
|
-
PRODUCTION: true
|
|
600
|
-
},
|
|
601
|
-
activeLogging: false,
|
|
602
|
-
compatWith: "99.0",
|
|
603
|
-
features: {},
|
|
604
|
-
deprecations: {},
|
|
605
|
-
polyfillUUID: false,
|
|
606
|
-
includeDataAdapter: false
|
|
607
|
-
}
|
|
608
|
-
})
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
function onUnhandled(e, handle) {
|
|
613
|
-
if (!e.reason?.message) return;
|
|
614
|
-
let reason = e.reason.message;
|
|
615
|
-
if (reason.includes("Stack trace for the update:")) {
|
|
616
|
-
reason += " (see console)";
|
|
617
|
-
}
|
|
618
|
-
handle(reason);
|
|
619
|
-
}
|
|
620
|
-
const gjs = {
|
|
621
|
-
resolve: resolve$1,
|
|
622
|
-
onUnhandled,
|
|
623
|
-
codemirror: {
|
|
624
|
-
lang: async () => {
|
|
625
|
-
const { gjs: gjs2 } = await import("./index-CB-pPTIf.js");
|
|
626
|
-
return gjs2();
|
|
627
|
-
}
|
|
628
|
-
},
|
|
629
|
-
compiler: async (...args) => {
|
|
630
|
-
const gjs2 = await import("./gjs-DfguZDLq.js");
|
|
631
|
-
return gjs2.compiler(...args);
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
const hbs = {
|
|
635
|
-
resolve: resolve$1,
|
|
636
|
-
onUnhandled,
|
|
637
|
-
codemirror: {
|
|
638
|
-
lang: async () => {
|
|
639
|
-
const { glimmer } = await import("./index-Bb8uYQgv.js");
|
|
640
|
-
return glimmer();
|
|
641
|
-
}
|
|
642
|
-
},
|
|
643
|
-
compiler: async (...args) => {
|
|
644
|
-
const hbs2 = await import("./hbs-CxcmWxSJ.js");
|
|
645
|
-
return hbs2.compiler(...args);
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
const gmd = {
|
|
649
|
-
resolve: resolve$1,
|
|
650
|
-
onUnhandled,
|
|
651
|
-
codemirror: {
|
|
652
|
-
lang: async () => {
|
|
653
|
-
const { glimdown } = await import("./index-wasu5VX0.js");
|
|
654
|
-
return glimdown();
|
|
655
|
-
},
|
|
656
|
-
support: async () => {
|
|
657
|
-
const { gjs: gjs2 } = await import("./index-CB-pPTIf.js");
|
|
658
|
-
return [gjs2().support];
|
|
659
|
-
}
|
|
660
|
-
},
|
|
661
|
-
compiler: async (...args) => {
|
|
662
|
-
const hbs2 = await import("./gmd-Yas-Oo8k.js");
|
|
663
|
-
return hbs2.compiler(...args);
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
const js = {
|
|
667
|
-
codemirror: {
|
|
668
|
-
lang: async () => {
|
|
669
|
-
const { javascript } = await import("./index-pN_pUAQ7.js").then((n) => n.k);
|
|
670
|
-
return javascript();
|
|
671
|
-
}
|
|
672
|
-
},
|
|
673
|
-
compiler: async (config, api) => {
|
|
674
|
-
return {
|
|
675
|
-
compile: async (text, options) => {
|
|
676
|
-
return text;
|
|
677
|
-
},
|
|
678
|
-
render: async (element, fun, extra, compiler) => {
|
|
679
|
-
assert(
|
|
680
|
-
`js document must have a function for a default export. Instead received: ${typeof fun}`,
|
|
681
|
-
typeof fun === "function"
|
|
682
|
-
);
|
|
683
|
-
await fun(element);
|
|
684
|
-
compiler.announce("info", "Done");
|
|
685
|
-
}
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
function isNotMarkdownLike(lang) {
|
|
690
|
-
return lang !== "md" && lang !== "gmd" && lang !== "mdx";
|
|
691
|
-
}
|
|
692
|
-
function isPreview(meta) {
|
|
693
|
-
if (!meta) return false;
|
|
694
|
-
return meta.includes("preview");
|
|
695
|
-
}
|
|
696
|
-
function isBelow(meta) {
|
|
697
|
-
if (!meta) return false;
|
|
698
|
-
return meta.includes("below");
|
|
699
|
-
}
|
|
700
|
-
function buildCodeFenceMetaUtils(api) {
|
|
701
|
-
const allowedFormats = api.getAllowedFormats().filter(isNotMarkdownLike);
|
|
702
|
-
function needsLive(lang, flavor) {
|
|
703
|
-
if (!allowedFormats.includes(lang)) return false;
|
|
704
|
-
return api.optionsFor(lang, flavor).needsLiveMeta ?? true;
|
|
705
|
-
}
|
|
706
|
-
function getFlavorFromMeta(meta, lang) {
|
|
707
|
-
const flavors = api.getFlavorsFor(lang);
|
|
708
|
-
const flavor = meta?.trim().split(" ").find((metum) => flavors.includes(metum));
|
|
709
|
-
return flavor;
|
|
710
|
-
}
|
|
711
|
-
function isLive(meta, lang) {
|
|
712
|
-
const flavor = getFlavorFromMeta(meta, lang);
|
|
713
|
-
if (!needsLive(lang, flavor)) return true;
|
|
714
|
-
if (!meta) return false;
|
|
715
|
-
return meta.includes("live");
|
|
716
|
-
}
|
|
717
|
-
return {
|
|
718
|
-
isPreview,
|
|
719
|
-
isBelow,
|
|
720
|
-
isLive,
|
|
721
|
-
needsLive,
|
|
722
|
-
allowedFormats,
|
|
723
|
-
getFlavorFromMeta
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
function filterOptions(options) {
|
|
727
|
-
if (!isRecord(options)) {
|
|
728
|
-
return { remarkPlugins: [], rehypePlugins: [] };
|
|
729
|
-
}
|
|
730
|
-
return {
|
|
731
|
-
remarkPlugins: (
|
|
732
|
-
/** @type {Plugin[]}*/
|
|
733
|
-
options?.remarkPlugins || []
|
|
734
|
-
),
|
|
735
|
-
rehypePlugins: (
|
|
736
|
-
/** @type {Plugin[]}*/
|
|
737
|
-
options?.rehypePlugins || []
|
|
738
|
-
)
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
const md = {
|
|
742
|
-
codemirror: {
|
|
743
|
-
lang: async () => {
|
|
744
|
-
const { glimdown } = await import("./index-wasu5VX0.js");
|
|
745
|
-
return glimdown();
|
|
746
|
-
}
|
|
747
|
-
},
|
|
748
|
-
compiler: async (config, api) => {
|
|
749
|
-
const { isLive, isPreview: isPreview2, needsLive, allowedFormats, isBelow: isBelow2, getFlavorFromMeta } = buildCodeFenceMetaUtils(api);
|
|
750
|
-
const userOptions = filterOptions(
|
|
751
|
-
/** @type {Record<string, unknown>} */
|
|
752
|
-
config.userOptions?.md || config
|
|
753
|
-
);
|
|
754
|
-
const { parseMarkdown } = await import("./parse-CAqQaKsh.js");
|
|
755
|
-
return {
|
|
756
|
-
compile: async (text, options) => {
|
|
757
|
-
const compileOptions = filterOptions(options);
|
|
758
|
-
const result = await parseMarkdown(text, {
|
|
759
|
-
remarkPlugins: [...userOptions.remarkPlugins, ...compileOptions.remarkPlugins],
|
|
760
|
-
rehypePlugins: [...userOptions.rehypePlugins, ...compileOptions.rehypePlugins],
|
|
761
|
-
isLive,
|
|
762
|
-
isPreview: isPreview2,
|
|
763
|
-
isBelow: isBelow2,
|
|
764
|
-
needsLive,
|
|
765
|
-
ALLOWED_FORMATS: allowedFormats,
|
|
766
|
-
getFlavorFromMeta
|
|
767
|
-
});
|
|
768
|
-
const escaped = result.text.replace(/`/g, "\\`");
|
|
769
|
-
return { compiled: `export default \`${escaped}\``, ...result };
|
|
770
|
-
},
|
|
771
|
-
render: async (element, compiled, extra, compiler) => {
|
|
772
|
-
element.innerHTML = /** @type {string} */
|
|
773
|
-
compiled;
|
|
774
|
-
const destroyables = [];
|
|
775
|
-
await Promise.all(
|
|
776
|
-
/** @type {unknown[]} */
|
|
777
|
-
extra.codeBlocks.map(async (info) => {
|
|
778
|
-
const infoObj = (
|
|
779
|
-
/** @type {Record<string, unknown>} */
|
|
780
|
-
info
|
|
781
|
-
);
|
|
782
|
-
if (!api.canCompile(
|
|
783
|
-
/** @type {string} */
|
|
784
|
-
infoObj.format,
|
|
785
|
-
/** @type {string} */
|
|
786
|
-
infoObj.flavor
|
|
787
|
-
)) {
|
|
788
|
-
return;
|
|
789
|
-
}
|
|
790
|
-
const flavor = (
|
|
791
|
-
/** @type {string} */
|
|
792
|
-
infoObj.flavor
|
|
793
|
-
);
|
|
794
|
-
const subRender = await compiler.compile(
|
|
795
|
-
/** @type {string} */
|
|
796
|
-
infoObj.format,
|
|
797
|
-
/** @type {string} */
|
|
798
|
-
infoObj.code,
|
|
799
|
-
{
|
|
800
|
-
...compiler.optionsFor(
|
|
801
|
-
/** @type {string} */
|
|
802
|
-
infoObj.format,
|
|
803
|
-
flavor
|
|
804
|
-
),
|
|
805
|
-
flavor
|
|
806
|
-
}
|
|
807
|
-
);
|
|
808
|
-
const selector = `#${/** @type {string} */
|
|
809
|
-
infoObj.placeholderId}`;
|
|
810
|
-
const target = element.querySelector(selector);
|
|
811
|
-
assert(
|
|
812
|
-
`Could not find placeholder / target element (using selector: \`${selector}\`). Could not render ${/** @type {string} */
|
|
813
|
-
infoObj.format} block.`,
|
|
814
|
-
target
|
|
815
|
-
);
|
|
816
|
-
destroyables.push(subRender.destroy);
|
|
817
|
-
target.appendChild(subRender.element);
|
|
818
|
-
})
|
|
819
|
-
);
|
|
820
|
-
compiler.announce("info", "Done");
|
|
821
|
-
return () => {
|
|
822
|
-
for (const subDestroy of destroyables) {
|
|
823
|
-
subDestroy();
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
};
|
|
830
|
-
function parseSpecifier(specifier) {
|
|
831
|
-
let name = "";
|
|
832
|
-
let version = "";
|
|
833
|
-
let path = ".";
|
|
834
|
-
const chars = specifier.split("");
|
|
835
|
-
const hasScope = chars[0] === "@";
|
|
836
|
-
let isVersion = false;
|
|
837
|
-
let isPath = false;
|
|
838
|
-
let finishedName = false;
|
|
839
|
-
let slashCount = 0;
|
|
840
|
-
for (let i2 = 0; i2 < chars.length; i2++) {
|
|
841
|
-
const char = chars[i2];
|
|
842
|
-
if (char === "@" && i2 > 0) {
|
|
843
|
-
finishedName = true;
|
|
844
|
-
isVersion = true;
|
|
845
|
-
continue;
|
|
846
|
-
} else if (char === "/") {
|
|
847
|
-
slashCount++;
|
|
848
|
-
if (hasScope) {
|
|
849
|
-
if (slashCount > 1) {
|
|
850
|
-
finishedName = true;
|
|
851
|
-
}
|
|
852
|
-
} else {
|
|
853
|
-
finishedName = true;
|
|
854
|
-
}
|
|
855
|
-
if (finishedName) {
|
|
856
|
-
isPath = true;
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
if (isVersion && char === "/") {
|
|
860
|
-
isVersion = false;
|
|
861
|
-
isPath = true;
|
|
862
|
-
}
|
|
863
|
-
if (isVersion) {
|
|
864
|
-
version += char;
|
|
865
|
-
} else if (isPath) {
|
|
866
|
-
path += char;
|
|
867
|
-
} else {
|
|
868
|
-
name += char;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
return {
|
|
872
|
-
name,
|
|
873
|
-
version: version || void 0,
|
|
874
|
-
path
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
function splitSubPath(importPath) {
|
|
878
|
-
const parsed = parseSpecifier(importPath);
|
|
879
|
-
return [parsed.name, parsed.path === "." ? "" : parsed.path];
|
|
880
|
-
}
|
|
881
|
-
function esmSh(versions, importPath, allExternal = false) {
|
|
882
|
-
const [name, subPath] = splitSubPath(importPath);
|
|
883
|
-
const version = versions[name];
|
|
884
|
-
const subPathExport = subPath.length === 0 || subPath.startsWith("/") ? subPath : `/${subPath}`;
|
|
885
|
-
const externals = allExternal ? "*" : "";
|
|
886
|
-
return version ? `https://esm.sh/${externals}${name}@${version}${subPathExport}` : `https://esm.sh/${externals}${name}${subPathExport}`;
|
|
887
|
-
}
|
|
888
|
-
const esmsh = {
|
|
889
|
-
/**
|
|
890
|
-
* @param {Record<string, string>} versions
|
|
891
|
-
* @param {string} importPath
|
|
892
|
-
*/
|
|
893
|
-
async import(versions, importPath) {
|
|
894
|
-
const url = esmSh(versions, importPath);
|
|
895
|
-
return await import(
|
|
896
|
-
/* @vite-ignore */
|
|
897
|
-
url
|
|
898
|
-
);
|
|
899
|
-
},
|
|
900
|
-
/**
|
|
901
|
-
* @param {Record<string, string>} versions
|
|
902
|
-
* @param {string[]} deps the names of deps to pull from esm.sh
|
|
903
|
-
*/
|
|
904
|
-
async importAll(versions, deps = []) {
|
|
905
|
-
return await Promise.all(
|
|
906
|
-
deps.map((dep) => {
|
|
907
|
-
return esmsh.import(versions, dep);
|
|
908
|
-
})
|
|
909
|
-
);
|
|
910
|
-
}
|
|
911
|
-
};
|
|
912
|
-
const mermaid = {
|
|
913
|
-
needsLiveMeta: false,
|
|
914
|
-
codemirror: {
|
|
915
|
-
lang: async () => {
|
|
916
|
-
const { mermaid: mermaid2 } = await import("./index-DOAqdvnQ.js");
|
|
917
|
-
return mermaid2();
|
|
918
|
-
}
|
|
919
|
-
},
|
|
920
|
-
compiler: async (config, api) => {
|
|
921
|
-
const versions = config.versions;
|
|
922
|
-
const { default: mermaid2 } = await api.tryResolve("mermaid", () => {
|
|
923
|
-
return esmsh.import(versions, "mermaid");
|
|
924
|
-
});
|
|
925
|
-
let id = 0;
|
|
926
|
-
return {
|
|
927
|
-
compile: async (text) => {
|
|
928
|
-
return `export default \`${text}\`;`;
|
|
929
|
-
},
|
|
930
|
-
render: async (element, text, _, compiler) => {
|
|
931
|
-
const { svg } = await mermaid2.render("graphDiv" + id++, text);
|
|
932
|
-
element.innerHTML = svg;
|
|
933
|
-
compiler.announce("info", "Done");
|
|
934
|
-
}
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
};
|
|
938
|
-
const jsx = {
|
|
939
|
-
codemirror: {
|
|
940
|
-
lang: async () => {
|
|
941
|
-
const { javascript } = await import("./index-pN_pUAQ7.js").then((n) => n.k);
|
|
942
|
-
return javascript({ jsx: true });
|
|
943
|
-
}
|
|
944
|
-
},
|
|
945
|
-
resolve: (id) => {
|
|
946
|
-
switch (id) {
|
|
947
|
-
case "react":
|
|
948
|
-
return `https://esm.sh/react@19.2.3/es2022/react.development.mjs`;
|
|
949
|
-
case "react/jsx-dev-runtime":
|
|
950
|
-
return `https://esm.sh/react@19.2.3/es2022/jsx-dev-runtime.development.mjs`;
|
|
951
|
-
case "react-dom/client":
|
|
952
|
-
return `https://esm.sh/react-dom@19.2.3/es2022/client.development.mjs`;
|
|
953
|
-
case "@babel/standalone":
|
|
954
|
-
return `https://esm.sh/@babel/standalone`;
|
|
955
|
-
}
|
|
956
|
-
},
|
|
957
|
-
compiler: async (config, api) => {
|
|
958
|
-
const [reactDom, babel] = await api.tryResolveAll(["react-dom/client", "@babel/standalone"]);
|
|
959
|
-
const { createRoot } = reactDom;
|
|
960
|
-
return {
|
|
961
|
-
async compile(text) {
|
|
962
|
-
const result = babel.transform(text, {
|
|
963
|
-
filename: `repl.js`,
|
|
964
|
-
presets: [
|
|
965
|
-
[
|
|
966
|
-
babel.availablePresets.react,
|
|
967
|
-
{
|
|
968
|
-
// useBuiltIns: true,
|
|
969
|
-
}
|
|
970
|
-
]
|
|
971
|
-
]
|
|
972
|
-
});
|
|
973
|
-
return result.code;
|
|
974
|
-
},
|
|
975
|
-
async render(element, component) {
|
|
976
|
-
const root = createRoot(element);
|
|
977
|
-
await new Promise((resolve2) => requestAnimationFrame(resolve2));
|
|
978
|
-
root.render(component);
|
|
979
|
-
await new Promise((resolve2) => requestAnimationFrame(resolve2));
|
|
980
|
-
}
|
|
981
|
-
};
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
const svelte = {
|
|
985
|
-
codemirror: {
|
|
986
|
-
lang: async () => {
|
|
987
|
-
const { svelte: svelte2 } = await import("./index-DIz8Vpn-.js");
|
|
988
|
-
return svelte2();
|
|
989
|
-
}
|
|
990
|
-
},
|
|
991
|
-
/**
|
|
992
|
-
* Default config, known to work with how the compiler and render functions are configured.
|
|
993
|
-
*/
|
|
994
|
-
resolve: (id) => {
|
|
995
|
-
if (["svelte"].some((x) => id.startsWith(x))) {
|
|
996
|
-
return esmSh(
|
|
997
|
-
{
|
|
998
|
-
svelte: "5.35.7"
|
|
999
|
-
},
|
|
1000
|
-
id,
|
|
1001
|
-
false
|
|
1002
|
-
) + // + '?target=esnext';
|
|
1003
|
-
"?dev&target=esnext&keep-names";
|
|
1004
|
-
}
|
|
1005
|
-
if ([
|
|
1006
|
-
"zimmerframe",
|
|
1007
|
-
"locate-character",
|
|
1008
|
-
"acorn",
|
|
1009
|
-
"clsx",
|
|
1010
|
-
"magic-string",
|
|
1011
|
-
"@ampproject/remapping",
|
|
1012
|
-
"@jridgewell/sourcemap-codec",
|
|
1013
|
-
"axobject-query",
|
|
1014
|
-
"esrap",
|
|
1015
|
-
"is-reference",
|
|
1016
|
-
"aria-query",
|
|
1017
|
-
"@sveltejs/acorn-typescript"
|
|
1018
|
-
].some((x) => id.startsWith(x))) {
|
|
1019
|
-
return esmSh({}, id, false);
|
|
1020
|
-
}
|
|
1021
|
-
},
|
|
1022
|
-
compiler: async (config, api) => {
|
|
1023
|
-
const [svelte2, compiler] = await api.tryResolveAll(["svelte", "svelte/compiler"]);
|
|
1024
|
-
return {
|
|
1025
|
-
compile: async (text, options) => {
|
|
1026
|
-
const output = await compiler.compile(text, {
|
|
1027
|
-
/* this errors if unexpected options are passed */
|
|
1028
|
-
generate: "client",
|
|
1029
|
-
fragments: "html",
|
|
1030
|
-
// Placeholder for now until multiple files are supported
|
|
1031
|
-
filename: "repl-sdk.svelte",
|
|
1032
|
-
dev: true,
|
|
1033
|
-
runes: true
|
|
1034
|
-
// experimental: {
|
|
1035
|
-
// async: true,
|
|
1036
|
-
// },
|
|
1037
|
-
});
|
|
1038
|
-
return { compiled: output.js.code, css: output.css?.code };
|
|
1039
|
-
},
|
|
1040
|
-
render: async (element, component, { css }) => {
|
|
1041
|
-
const div = document.createElement("div");
|
|
1042
|
-
if (css) {
|
|
1043
|
-
const style = document.createElement("style");
|
|
1044
|
-
style.innerHTML = /** @type {string} */
|
|
1045
|
-
css;
|
|
1046
|
-
element.appendChild(style);
|
|
1047
|
-
}
|
|
1048
|
-
element.appendChild(div);
|
|
1049
|
-
requestAnimationFrame(() => {
|
|
1050
|
-
svelte2.mount(component, {
|
|
1051
|
-
target: element,
|
|
1052
|
-
props: {
|
|
1053
|
-
/* no props */
|
|
1054
|
-
}
|
|
1055
|
-
});
|
|
1056
|
-
api.announce("info", "Done");
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
};
|
|
1060
|
-
}
|
|
1061
|
-
};
|
|
1062
|
-
const vue = {
|
|
1063
|
-
codemirror: {
|
|
1064
|
-
lang: async () => {
|
|
1065
|
-
const { vue: vue2 } = await import("./index-VeTBKRVd.js");
|
|
1066
|
-
return vue2();
|
|
1067
|
-
}
|
|
1068
|
-
},
|
|
1069
|
-
/**
|
|
1070
|
-
* Default config, known to work with how the compiler and render functions are configured.
|
|
1071
|
-
*/
|
|
1072
|
-
resolve: (id) => {
|
|
1073
|
-
switch (id) {
|
|
1074
|
-
case "vue":
|
|
1075
|
-
return `https://cdn.jsdelivr.net/npm/vue@3.5.16/+esm`;
|
|
1076
|
-
case "@vue/repl":
|
|
1077
|
-
return `https://cdn.jsdelivr.net/npm/@vue/repl@4.5.1/+esm`;
|
|
1078
|
-
}
|
|
1079
|
-
},
|
|
1080
|
-
compiler: async (config, api) => {
|
|
1081
|
-
const [{ createApp }, { compileFile, useStore }] = await api.tryResolveAll([
|
|
1082
|
-
"vue",
|
|
1083
|
-
"@vue/repl"
|
|
1084
|
-
]);
|
|
1085
|
-
const store = useStore();
|
|
1086
|
-
return {
|
|
1087
|
-
compile: async (text, options) => {
|
|
1088
|
-
const output = { js: "", css: "", ssr: "" };
|
|
1089
|
-
await compileFile(store, {
|
|
1090
|
-
code: text,
|
|
1091
|
-
filename: options.fileName,
|
|
1092
|
-
language: "vue",
|
|
1093
|
-
compiled: output
|
|
1094
|
-
});
|
|
1095
|
-
return { compiled: output.js, css: output.css };
|
|
1096
|
-
},
|
|
1097
|
-
render: async (element, component, { css }, compiler) => {
|
|
1098
|
-
const div = document.createElement("div");
|
|
1099
|
-
const style = document.createElement("style");
|
|
1100
|
-
style.innerHTML = /** @type {string} */
|
|
1101
|
-
css;
|
|
1102
|
-
element.appendChild(div);
|
|
1103
|
-
element.appendChild(style);
|
|
1104
|
-
createApp(component).mount(div);
|
|
1105
|
-
compiler.announce("info", "Done");
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
};
|
|
1110
|
-
const compilers = {
|
|
1111
|
-
hbs: {
|
|
1112
|
-
/**
|
|
1113
|
-
* ember has historically used a subset of HBS, and then built its own features on top of.
|
|
1114
|
-
*
|
|
1115
|
-
* It is not "handlebars", but does share a lot of similarities.
|
|
1116
|
-
* (and these continue in ember's new gjs and gts formats)
|
|
1117
|
-
*
|
|
1118
|
-
*/
|
|
1119
|
-
ember: hbs
|
|
1120
|
-
},
|
|
1121
|
-
/**
|
|
1122
|
-
* Markdown, but every code fense can be a live "Island"
|
|
1123
|
-
* if `live` is in the codefence's meta tag and the compiler
|
|
1124
|
-
* is registered here, or by the user of repl-sdk.
|
|
1125
|
-
*/
|
|
1126
|
-
md,
|
|
1127
|
-
/**
|
|
1128
|
-
* Glimmer-flavored Markdown.
|
|
1129
|
-
*
|
|
1130
|
-
* Like the markdow renderer, but the resulting HTML
|
|
1131
|
-
* is a Glimmer Component, rather than just plain HTML.
|
|
1132
|
-
*
|
|
1133
|
-
* https://emberjs.com
|
|
1134
|
-
* https://repl.nullvoxpopuli.com
|
|
1135
|
-
* https://kolay.nullvoxpopuli.com
|
|
1136
|
-
* https://tutorial.glimdown.com
|
|
1137
|
-
* https://limber.glimdown.com
|
|
1138
|
-
*/
|
|
1139
|
-
gmd,
|
|
1140
|
-
/**
|
|
1141
|
-
* Glimmer-Flavored JavaScript
|
|
1142
|
-
*
|
|
1143
|
-
* https://emberjs.com
|
|
1144
|
-
*/
|
|
1145
|
-
gjs,
|
|
1146
|
-
/**
|
|
1147
|
-
* TODO:
|
|
1148
|
-
* Glimmer-flavored TypeScript
|
|
1149
|
-
*
|
|
1150
|
-
* https://emberjs.com
|
|
1151
|
-
*/
|
|
1152
|
-
// gts: ember.gts,
|
|
1153
|
-
/**
|
|
1154
|
-
* Just vanilla JS.
|
|
1155
|
-
*/
|
|
1156
|
-
js,
|
|
1157
|
-
/**
|
|
1158
|
-
* JSX is too overloaded to treat one way.
|
|
1159
|
-
* We need to split this, and then make folks choose which one to use
|
|
1160
|
-
* - jsx-react
|
|
1161
|
-
* - jsx-vue
|
|
1162
|
-
* - jsx-solid
|
|
1163
|
-
* - (etc)
|
|
1164
|
-
*
|
|
1165
|
-
* This means that as a generic compiler, we can't just have jsx support.
|
|
1166
|
-
* And in markdown, we'll need to support choosing which flavor of jsx
|
|
1167
|
-
* via meta tags on the codefences.
|
|
1168
|
-
*
|
|
1169
|
-
* For example:
|
|
1170
|
-
* ```jsx solid
|
|
1171
|
-
* export default <></>;
|
|
1172
|
-
* ```
|
|
1173
|
-
*
|
|
1174
|
-
* or
|
|
1175
|
-
* ```jsx react
|
|
1176
|
-
* export default <></>;
|
|
1177
|
-
* ```
|
|
1178
|
-
*/
|
|
1179
|
-
jsx: {
|
|
1180
|
-
/**
|
|
1181
|
-
* https://react.dev/
|
|
1182
|
-
*/
|
|
1183
|
-
react: jsx
|
|
1184
|
-
/**
|
|
1185
|
-
* TODO:
|
|
1186
|
-
* https://www.solidjs.com/
|
|
1187
|
-
*/
|
|
1188
|
-
// solid: solid.jsx,
|
|
1189
|
-
},
|
|
1190
|
-
/**
|
|
1191
|
-
* https://mermaid.js.org/
|
|
1192
|
-
*/
|
|
1193
|
-
mermaid,
|
|
1194
|
-
/**
|
|
1195
|
-
* https://svelte.dev/
|
|
1196
|
-
*/
|
|
1197
|
-
svelte,
|
|
1198
|
-
/**
|
|
1199
|
-
* https://vuejs.org/
|
|
1200
|
-
*/
|
|
1201
|
-
vue
|
|
1202
|
-
};
|
|
1203
|
-
const STABLE_REFERENCE = {
|
|
1204
|
-
resolve: () => {
|
|
1205
|
-
throw new Error(
|
|
1206
|
-
`'resolve' not implemented in STABLE_REFERENCE. Has the Compiler been set up correctly?`
|
|
1207
|
-
);
|
|
1208
|
-
},
|
|
1209
|
-
fetch: async () => {
|
|
1210
|
-
throw new Error(
|
|
1211
|
-
`'fetch' not implemented in STABLE_REFERENCE. Has the Compiler been set up correctly?`
|
|
1212
|
-
);
|
|
1213
|
-
}
|
|
1214
|
-
};
|
|
1215
|
-
globalThis.esmsInitOptions = {
|
|
1216
|
-
shimMode: true,
|
|
1217
|
-
// skip: [`https://esm.sh`, 'https://jspm.dev/', 'https://cdn.jsdelivr.net/'],
|
|
1218
|
-
revokeBlobURLs: true,
|
|
1219
|
-
// default false
|
|
1220
|
-
mapOverrides: true,
|
|
1221
|
-
// default false
|
|
1222
|
-
/**
|
|
1223
|
-
* @param {string} id
|
|
1224
|
-
* @param {string} parentUrl
|
|
1225
|
-
* @param {(id: string, parentUrl: string) => string} resolve
|
|
1226
|
-
* @returns {string}
|
|
1227
|
-
*/
|
|
1228
|
-
resolve: (id, parentUrl, resolve2) => STABLE_REFERENCE.resolve(id, parentUrl, resolve2),
|
|
1229
|
-
// NOTE: may need source hook
|
|
1230
|
-
// https://github.com/guybedford/es-module-shims?tab=readme-ov-file#source-hook
|
|
1231
|
-
//
|
|
1232
|
-
/**
|
|
1233
|
-
* @param {string} url
|
|
1234
|
-
* @param {RequestInit} options
|
|
1235
|
-
* @returns {Promise<Response>}
|
|
1236
|
-
*/
|
|
1237
|
-
fetch: (url, options) => STABLE_REFERENCE.fetch(url, options)
|
|
1238
|
-
};
|
|
1239
|
-
let requestId = 1;
|
|
1240
|
-
function requestKey() {
|
|
1241
|
-
return `repl-request-${requestId++}`;
|
|
1242
|
-
}
|
|
1243
|
-
function getTarRequestId({ to, from }) {
|
|
1244
|
-
const request = Request.of({ to, from });
|
|
1245
|
-
const key = requestKey();
|
|
1246
|
-
cache.requestCache.set(key, request);
|
|
1247
|
-
return `${unzippedPrefix}/${key}`;
|
|
1248
|
-
}
|
|
1249
|
-
class Request {
|
|
1250
|
-
static get #idCache() {
|
|
1251
|
-
return cache.requestCache;
|
|
1252
|
-
}
|
|
1253
|
-
/**
|
|
1254
|
-
* @param {{ to: string, from?: string }} toFrom
|
|
1255
|
-
*/
|
|
1256
|
-
static of({ to, from }) {
|
|
1257
|
-
const isRoot = to.match(/^[A-Za-z@]/);
|
|
1258
|
-
const fromId = from?.replace(unzippedPrefix + "/", "");
|
|
1259
|
-
const request = Request.fromSpecifier(isRoot ? to : `${to}?from=${fromId}`);
|
|
1260
|
-
return request;
|
|
1261
|
-
}
|
|
1262
|
-
/**
|
|
1263
|
-
* @param {string} id
|
|
1264
|
-
*/
|
|
1265
|
-
static fromRequestId(id) {
|
|
1266
|
-
const request = Request.#idCache.get(id);
|
|
1267
|
-
assert(`Could not find request from id:${id}`, request);
|
|
1268
|
-
return request;
|
|
1269
|
-
}
|
|
1270
|
-
/**
|
|
1271
|
-
* @param {string} specifier
|
|
1272
|
-
*/
|
|
1273
|
-
static fromSpecifier(specifier) {
|
|
1274
|
-
return new Request(specifier);
|
|
1275
|
-
}
|
|
1276
|
-
/** @type {string} */
|
|
1277
|
-
#to;
|
|
1278
|
-
/** @type {Request | undefined} */
|
|
1279
|
-
#from;
|
|
1280
|
-
/**
|
|
1281
|
-
* @private
|
|
1282
|
-
* @param {string} specifier
|
|
1283
|
-
*/
|
|
1284
|
-
constructor(specifier) {
|
|
1285
|
-
const removedPrefix = specifier.replace(unzippedPrefix, "");
|
|
1286
|
-
const [full, query] = removedPrefix.split("?");
|
|
1287
|
-
this.original = specifier;
|
|
1288
|
-
assert(`Invalid specifier: ${specifier}`, full);
|
|
1289
|
-
if (full.startsWith(".") || full.startsWith("#")) {
|
|
1290
|
-
if (!query) {
|
|
1291
|
-
throw new Error(
|
|
1292
|
-
`Missing query, ?from for specifier: ${specifier}. From is required for relative and subpath-imports.`
|
|
1293
|
-
);
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
this.#to = full;
|
|
1297
|
-
if (query) {
|
|
1298
|
-
const search = new URLSearchParams(query);
|
|
1299
|
-
const fromQp = search.get("from");
|
|
1300
|
-
assert(`Missing query, ?from for specifier: ${specifier}`, fromQp);
|
|
1301
|
-
const from = Request.fromRequestId(fromQp);
|
|
1302
|
-
this.#from = from;
|
|
1303
|
-
this.name = from.name;
|
|
1304
|
-
this.version = from.version;
|
|
1305
|
-
} else {
|
|
1306
|
-
const parsed = parseSpecifier(full);
|
|
1307
|
-
const { name, version = "latest", path } = parsed;
|
|
1308
|
-
this.name = name;
|
|
1309
|
-
this.version = version.replace(/\.+$/, "");
|
|
1310
|
-
this.#to = path;
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
get to() {
|
|
1314
|
-
return this.#to;
|
|
1315
|
-
}
|
|
1316
|
-
get from() {
|
|
1317
|
-
return this.#from;
|
|
1318
|
-
}
|
|
1319
|
-
get key() {
|
|
1320
|
-
return `__name__/${this.name}[AT:V]${this.version}/__to__/${this.to}`;
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
const CONDITIONS = ["repl", "module", "browser", "import", "default", "development"];
|
|
1324
|
-
const resolveCache = /* @__PURE__ */ new Map();
|
|
1325
|
-
const AT = "___AT___";
|
|
1326
|
-
const fakeProtocol = "repl://";
|
|
1327
|
-
function resolvePath(start, target) {
|
|
1328
|
-
const base = start.replace(/^@([^/]+)\/([^/]+)/, `${AT}$1___$2`);
|
|
1329
|
-
const url = new URL(target, fakeProtocol + fakeDomain + base);
|
|
1330
|
-
return url.href.replace(fakeProtocol + fakeDomain, "").replace(AT, "@").replace("___", "/").replace(/^\//, "./");
|
|
1331
|
-
}
|
|
1332
|
-
function resolve(untarred, request) {
|
|
1333
|
-
let answer = void 0;
|
|
1334
|
-
const key = request.key;
|
|
1335
|
-
if (resolveCache.has(key)) {
|
|
1336
|
-
return resolveCache.get(key);
|
|
1337
|
-
}
|
|
1338
|
-
answer ||= fromImports(untarred, request, answer);
|
|
1339
|
-
answer ||= fromInternalImport(untarred, request, answer);
|
|
1340
|
-
answer ||= fromExportsString(untarred, request, answer);
|
|
1341
|
-
answer ||= fromExports(untarred, request, answer);
|
|
1342
|
-
answer ||= fromModule(untarred, request, answer);
|
|
1343
|
-
answer ||= fromBrowser(untarred, request, answer);
|
|
1344
|
-
answer ||= fromMain(untarred, request, answer);
|
|
1345
|
-
answer ||= fromIndex(untarred, request, answer);
|
|
1346
|
-
answer ||= fromFallback(untarred, request, answer);
|
|
1347
|
-
if (answer) {
|
|
1348
|
-
resolveCache.set(key, answer);
|
|
1349
|
-
}
|
|
1350
|
-
return answer;
|
|
1351
|
-
}
|
|
1352
|
-
function fromInternalImport(untarred, request, answer) {
|
|
1353
|
-
if (answer) return answer;
|
|
1354
|
-
if (!request.from) return answer;
|
|
1355
|
-
const fromSpecifier = request.from;
|
|
1356
|
-
const answerFrom = resolve(untarred, fromSpecifier);
|
|
1357
|
-
if (!answerFrom) {
|
|
1358
|
-
printError(untarred, fromSpecifier, answer);
|
|
1359
|
-
return;
|
|
1360
|
-
}
|
|
1361
|
-
const inTarFile = resolvePath(
|
|
1362
|
-
fromSpecifier.name + "/" + answerFrom.inTarFile,
|
|
1363
|
-
request.to
|
|
1364
|
-
).replace(new RegExp(`^${fromSpecifier.name}/`), "");
|
|
1365
|
-
const result = checkFile(untarred, inTarFile);
|
|
1366
|
-
if (result) {
|
|
1367
|
-
return createAnswer(result, request, "internalImport");
|
|
1368
|
-
}
|
|
1369
|
-
printError(untarred, request, answer);
|
|
1370
|
-
}
|
|
1371
|
-
function fromExports(untarred, request, answer) {
|
|
1372
|
-
if (answer) return answer;
|
|
1373
|
-
const exports$1 = untarred.manifest.exports;
|
|
1374
|
-
if (!(typeof exports$1 === "object")) return answer;
|
|
1375
|
-
const foundArray = _exports(untarred.manifest, request.to, {
|
|
1376
|
-
conditions: CONDITIONS
|
|
1377
|
-
});
|
|
1378
|
-
const found = foundArray?.map((f) => checkFile(untarred, f)).find(Boolean);
|
|
1379
|
-
if (found) {
|
|
1380
|
-
return createAnswer(found, request, "exports");
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
function fromImports(untarred, request, answer) {
|
|
1384
|
-
if (answer) return answer;
|
|
1385
|
-
if (!request.to.startsWith("#")) return answer;
|
|
1386
|
-
const imports = untarred.manifest.imports;
|
|
1387
|
-
if (!(typeof imports === "object")) return answer;
|
|
1388
|
-
const found = resolve$2({ content: untarred.manifest }, request.to, {
|
|
1389
|
-
conditions: CONDITIONS
|
|
1390
|
-
});
|
|
1391
|
-
if (found) {
|
|
1392
|
-
return createAnswer(found.replace(/^\.\//, ""), request, "imports");
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
function fromExportsString(untarred, request, answer) {
|
|
1396
|
-
if (answer) return answer;
|
|
1397
|
-
if (!hasExports(untarred)) return answer;
|
|
1398
|
-
return checkLegacyEntry(untarred, request, "exports");
|
|
1399
|
-
}
|
|
1400
|
-
function fromModule(untarred, request, answer) {
|
|
1401
|
-
if (answer) return answer;
|
|
1402
|
-
if (hasExports(untarred)) return answer;
|
|
1403
|
-
return checkLegacyEntry(untarred, request, "module");
|
|
1404
|
-
}
|
|
1405
|
-
function fromBrowser(untarred, request, answer) {
|
|
1406
|
-
if (answer) return answer;
|
|
1407
|
-
if (hasExports(untarred)) return answer;
|
|
1408
|
-
return checkLegacyEntry(untarred, request, "browser");
|
|
1409
|
-
}
|
|
1410
|
-
function fromMain(untarred, request, answer) {
|
|
1411
|
-
if (answer) return answer;
|
|
1412
|
-
if (hasExports(untarred)) return answer;
|
|
1413
|
-
return checkLegacyEntry(untarred, request, "main");
|
|
1414
|
-
}
|
|
1415
|
-
function checkLegacyEntry(untarred, request, entryName) {
|
|
1416
|
-
if (request.to !== ".") return;
|
|
1417
|
-
const filePath = untarred.manifest[
|
|
1418
|
-
/** @type {keyof typeof untarred.manifest} */
|
|
1419
|
-
entryName
|
|
1420
|
-
];
|
|
1421
|
-
if (!filePath || typeof filePath !== "string") return;
|
|
1422
|
-
const result = checkFile(untarred, filePath);
|
|
1423
|
-
if (result) {
|
|
1424
|
-
return createAnswer(result, request, entryName);
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
function fromIndex(untarred, request, answer) {
|
|
1428
|
-
if (answer) return answer;
|
|
1429
|
-
if (hasExports(untarred)) return answer;
|
|
1430
|
-
if (request.to === ".") {
|
|
1431
|
-
if (untarred.contents["index.js"]) {
|
|
1432
|
-
return {
|
|
1433
|
-
inTarFile: "index.js",
|
|
1434
|
-
ext: "js",
|
|
1435
|
-
from: "index"
|
|
1436
|
-
};
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
function fromFallback(untarred, request, answer) {
|
|
1441
|
-
if (answer) return answer;
|
|
1442
|
-
const result = checkFile(untarred, request.to);
|
|
1443
|
-
if (result) {
|
|
1444
|
-
return createAnswer(result, request, "fallback");
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
function checkFile(untarred, filePath) {
|
|
1448
|
-
if (!filePath) return;
|
|
1449
|
-
for (const prefix of ["", "pkg/"]) {
|
|
1450
|
-
const path = prefix + filePath;
|
|
1451
|
-
const dotless = prefix + filePath.replace(/^\.\//, "");
|
|
1452
|
-
if (untarred.contents[path]) {
|
|
1453
|
-
return path;
|
|
1454
|
-
}
|
|
1455
|
-
if (untarred.contents[dotless]) {
|
|
1456
|
-
return dotless;
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
function extName(filePath) {
|
|
1461
|
-
return filePath.split(".").pop();
|
|
1462
|
-
}
|
|
1463
|
-
function hasExports(untarred) {
|
|
1464
|
-
return Boolean(untarred.manifest.exports);
|
|
1465
|
-
}
|
|
1466
|
-
function createAnswer(forFile, request, fromMethod) {
|
|
1467
|
-
const ext = extName(forFile);
|
|
1468
|
-
assert(
|
|
1469
|
-
`All files must have an extension. This file (in ${request.name}) did not have an extension: ${forFile}`,
|
|
1470
|
-
ext
|
|
1471
|
-
);
|
|
1472
|
-
return {
|
|
1473
|
-
inTarFile: forFile,
|
|
1474
|
-
ext,
|
|
1475
|
-
from: fromMethod
|
|
1476
|
-
};
|
|
1477
|
-
}
|
|
1478
|
-
function printError(untarred, request, answer) {
|
|
1479
|
-
const { name, exports: exports$1, main, module, browser } = untarred.manifest;
|
|
1480
|
-
console.group(`${name} file info`);
|
|
1481
|
-
console.info(`${name} has these files: `, Object.keys(untarred.contents));
|
|
1482
|
-
console.info(`We searched for '${request.original}'`);
|
|
1483
|
-
console.info(`from: `, { exports: exports$1, main, module, browser });
|
|
1484
|
-
console.info(`And found: `, answer);
|
|
1485
|
-
console.info(`The request was: `, request);
|
|
1486
|
-
console.groupEnd();
|
|
1487
|
-
debugger;
|
|
1488
|
-
throw new Error(`Could not find file for ${request.original}`);
|
|
1489
|
-
}
|
|
1490
|
-
const worker = new Worker(new URL(
|
|
1491
|
-
/* @vite-ignore */
|
|
1492
|
-
"/assets/tar-worker-CxTcoQcr.js",
|
|
1493
|
-
import.meta.url
|
|
1494
|
-
), {
|
|
1495
|
-
name: "Tar & NPM Downloader Worker",
|
|
1496
|
-
type: "module"
|
|
1497
|
-
});
|
|
1498
|
-
const com = wrap(worker);
|
|
1499
|
-
async function getFromTarball(url) {
|
|
1500
|
-
const key = url.replace(unzippedPrefix + "/", "");
|
|
1501
|
-
const request = cache.requestCache.get(key);
|
|
1502
|
-
assert(`Missing request for ${url}`, request);
|
|
1503
|
-
if (cache.fileCache.has(key)) {
|
|
1504
|
-
return cache.fileCache.get(key);
|
|
1505
|
-
}
|
|
1506
|
-
const data = await cache.cachedPromise(key, async () => {
|
|
1507
|
-
const untarred2 = await com.getTar(request.name, request.version);
|
|
1508
|
-
const answer = resolve(untarred2, request);
|
|
1509
|
-
if (!answer) {
|
|
1510
|
-
throw new Error(`Could not find file for ${request.original}`);
|
|
1511
|
-
}
|
|
1512
|
-
return { answer, name: request.name, version: request.version };
|
|
1513
|
-
});
|
|
1514
|
-
const untarred = await com.getTar(request.name, request.version);
|
|
1515
|
-
const result = getFile(untarred, key, data.answer);
|
|
1516
|
-
assert(`Missing file for ${url}`, result);
|
|
1517
|
-
cache.fileCache.set(key, result);
|
|
1518
|
-
return result;
|
|
1519
|
-
}
|
|
1520
|
-
function getFile(untarred, key, answer) {
|
|
1521
|
-
const request = Request.fromRequestId(key);
|
|
1522
|
-
if (!answer) {
|
|
1523
|
-
printError(untarred, request, answer);
|
|
1524
|
-
return;
|
|
1525
|
-
}
|
|
1526
|
-
const { inTarFile, ext } = answer;
|
|
1527
|
-
const code = untarred.contents[inTarFile]?.text;
|
|
1528
|
-
if (!code) {
|
|
1529
|
-
printError(untarred, request, answer);
|
|
1530
|
-
return;
|
|
1531
|
-
}
|
|
1532
|
-
return { code, ext };
|
|
1533
|
-
}
|
|
1534
|
-
assert(`There is no document. repl-sdk is meant to be ran in a browser`, globalThis.document);
|
|
1535
|
-
const defaultFormats = Object.keys(compilers);
|
|
1536
|
-
const defaults = {
|
|
1537
|
-
formats: compilers
|
|
1538
|
-
};
|
|
1539
|
-
class Compiler {
|
|
1540
|
-
/** @type {Options} */
|
|
1541
|
-
#options;
|
|
1542
|
-
/**
|
|
1543
|
-
* Options may be passed to the compiler to add to its behavior.
|
|
1544
|
-
* @param {Partial<Options>} options
|
|
1545
|
-
*/
|
|
1546
|
-
constructor(options = defaults) {
|
|
1547
|
-
this.#options = Object.assign({}, defaults, options);
|
|
1548
|
-
STABLE_REFERENCE.resolve = this.#resolve;
|
|
1549
|
-
STABLE_REFERENCE.fetch = this.#fetch;
|
|
1550
|
-
window.addEventListener("unhandledrejection", this.#handleUnhandledRejection);
|
|
1551
|
-
}
|
|
1552
|
-
/**
|
|
1553
|
-
*
|
|
1554
|
-
* @param {HTMLElement} element
|
|
1555
|
-
* @param {any} options
|
|
1556
|
-
*/
|
|
1557
|
-
async createEditor(element, { text, format, handleUpdate, extensions }) {
|
|
1558
|
-
return cache.cachedPromise("codemirror", async () => {
|
|
1559
|
-
const { buildCodemirror } = await import("./codemirror-De3S70Np.js");
|
|
1560
|
-
return buildCodemirror({
|
|
1561
|
-
element,
|
|
1562
|
-
text,
|
|
1563
|
-
format,
|
|
1564
|
-
extensions,
|
|
1565
|
-
handleUpdate,
|
|
1566
|
-
getLang: async (format2) => {
|
|
1567
|
-
const [lang, flavor] = format2.split("|");
|
|
1568
|
-
assert(`Could not determine 'lang' from format: ${format2}`, lang);
|
|
1569
|
-
const compiler = this.#resolveFormat(lang, flavor);
|
|
1570
|
-
const loadLang = compiler.codemirror?.lang;
|
|
1571
|
-
assert(
|
|
1572
|
-
`The compiler for '${format2}' is missing its configuration for 'codemirror.lang'`,
|
|
1573
|
-
loadLang
|
|
1574
|
-
);
|
|
1575
|
-
return await loadLang();
|
|
1576
|
-
},
|
|
1577
|
-
getSupport: async (format2) => {
|
|
1578
|
-
const [lang, flavor] = format2.split("|");
|
|
1579
|
-
assert(`Could not determine 'lang' from format: ${format2}`, lang);
|
|
1580
|
-
const compiler = this.#resolveFormat(lang, flavor);
|
|
1581
|
-
const loadSupport = compiler.codemirror.support;
|
|
1582
|
-
return await loadSupport?.();
|
|
1583
|
-
}
|
|
1584
|
-
});
|
|
1585
|
-
});
|
|
1586
|
-
}
|
|
1587
|
-
/**
|
|
1588
|
-
* @param {PromiseRejectionEvent} e
|
|
1589
|
-
*/
|
|
1590
|
-
#handleUnhandledRejection = (e) => {
|
|
1591
|
-
let handled = false;
|
|
1592
|
-
for (const onUnhandled2 of this.#compilerOnUnhandled) {
|
|
1593
|
-
onUnhandled2(e, (message) => {
|
|
1594
|
-
this.#announce("error", message);
|
|
1595
|
-
handled = true;
|
|
1596
|
-
});
|
|
1597
|
-
if (handled) break;
|
|
1598
|
-
}
|
|
1599
|
-
if (handled) return;
|
|
1600
|
-
this.#announce("error", e.reason);
|
|
1601
|
-
};
|
|
1602
|
-
/**
|
|
1603
|
-
* Order of preference
|
|
1604
|
-
* 1. manually resolved (from the caller)
|
|
1605
|
-
* 2. specified in the compiler config (to use CDN)
|
|
1606
|
-
* 3. download tarball from npm
|
|
1607
|
-
* or resolve from already downloaded tarball
|
|
1608
|
-
*
|
|
1609
|
-
* NOTE: when we return a new URL, we want to collapse the parentURI
|
|
1610
|
-
* so that we don't get compound query params in nested requests.
|
|
1611
|
-
*
|
|
1612
|
-
* @param {string} id
|
|
1613
|
-
* @param {string} parentUrl
|
|
1614
|
-
* @param {(id: string, parentUrl: string) => string} resolve
|
|
1615
|
-
* @returns {string}
|
|
1616
|
-
*/
|
|
1617
|
-
#resolve = (id, parentUrl, resolve2) => {
|
|
1618
|
-
const vanilla = deCDN(id);
|
|
1619
|
-
this.#announce("info", `Loading ${vanilla}`);
|
|
1620
|
-
this.#log("[resolve]", id, "from", parentUrl);
|
|
1621
|
-
if (this.#options.resolve?.[vanilla]) {
|
|
1622
|
-
this.#log(`[resolve] ${vanilla} found in manually specified resolver`);
|
|
1623
|
-
return `manual:${vanilla}`;
|
|
1624
|
-
}
|
|
1625
|
-
for (const compilerResolve of this.#compilerResolvers) {
|
|
1626
|
-
const result = compilerResolve(vanilla);
|
|
1627
|
-
if (result) {
|
|
1628
|
-
this.#log(`[resolve] ${vanilla} found in compiler config at ${result}.`);
|
|
1629
|
-
if (typeof result === "function") {
|
|
1630
|
-
return `configured:${vanilla}`;
|
|
1631
|
-
}
|
|
1632
|
-
return result;
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
if (parentUrl.startsWith(tgzPrefix) && (id.startsWith(".") || id.startsWith("#"))) {
|
|
1636
|
-
const answer = getTarRequestId({ to: id, from: parentUrl });
|
|
1637
|
-
return answer;
|
|
1638
|
-
}
|
|
1639
|
-
if (id.startsWith("https://")) return resolve2(id, parentUrl);
|
|
1640
|
-
if (id.startsWith("blob:")) return resolve2(id, parentUrl);
|
|
1641
|
-
if (id.startsWith(".")) return resolve2(id, parentUrl);
|
|
1642
|
-
if (parentUrl.startsWith("https://") && parentUrl !== location.href)
|
|
1643
|
-
return resolve2(id, parentUrl);
|
|
1644
|
-
if (parentUrl.startsWith("https://") && parentUrl.startsWith("/"))
|
|
1645
|
-
return resolve2(id, parentUrl);
|
|
1646
|
-
if (id.startsWith("node:")) {
|
|
1647
|
-
this.#log(`Is known node module: ${id}. Grabbing polyfill`);
|
|
1648
|
-
if (id === "node:process") return prefix_tgz(`process`);
|
|
1649
|
-
if (id === "node:buffer") return prefix_tgz(`buffer`);
|
|
1650
|
-
if (id === "node:events") return prefix_tgz(`events`);
|
|
1651
|
-
if (id === "node:path") return prefix_tgz(`path-browser`);
|
|
1652
|
-
if (id === "node:util") return prefix_tgz(`util-browser`);
|
|
1653
|
-
if (id === "node:crypto") return prefix_tgz(`crypto-browserify`);
|
|
1654
|
-
if (id === "node:stream") return prefix_tgz(`stream-browserify`);
|
|
1655
|
-
if (id === "node:fs") return prefix_tgz(`browserify-fs`);
|
|
1656
|
-
}
|
|
1657
|
-
this.#log(`[resolve] ${id} not found, deferring to npmjs.com's provided tarball`);
|
|
1658
|
-
return getTarRequestId({ to: id, from: parentUrl });
|
|
1659
|
-
};
|
|
1660
|
-
/**
|
|
1661
|
-
* @param {string} url
|
|
1662
|
-
* @param {RequestInit} options
|
|
1663
|
-
* @returns {Promise<Response>}
|
|
1664
|
-
*/
|
|
1665
|
-
#fetch = async (url, options) => {
|
|
1666
|
-
const mimeType = mime.getType(url) ?? "application/javascript";
|
|
1667
|
-
this.#log(`[fetch] attempting to fetch: ${url}. Assuming ${mimeType}`);
|
|
1668
|
-
if (url.startsWith("manual:")) {
|
|
1669
|
-
const name = url.replace(/^manual:/, "");
|
|
1670
|
-
this.#log("[fetch] resolved url in manually specified resolver", url);
|
|
1671
|
-
const result = await this.#resolveManually(name);
|
|
1672
|
-
assert(`Failed to resolve ${name}`, result);
|
|
1673
|
-
const blobContent = `const mod = window[Symbol.for('${secretKey}')].resolves?.['${name}'];
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
if (!mod) { throw new Error('Could not resolve \`${name}\`. Does the module exist? ( checked ${url} )') }
|
|
1677
|
-
|
|
1678
|
-
${Object.keys(result).map((exportName) => {
|
|
1679
|
-
if (exportName === "default") {
|
|
1680
|
-
return `export default mod.default ?? mod;`;
|
|
1681
|
-
}
|
|
1682
|
-
return `export const ${exportName} = mod.${exportName};`;
|
|
1683
|
-
}).join("\n")}
|
|
1684
|
-
`;
|
|
1685
|
-
const blob = new Blob(Array.from(blobContent), { type: mimeType });
|
|
1686
|
-
this.#log(
|
|
1687
|
-
`[fetch] returning blob mapping to manually resolved import for ${name}`
|
|
1688
|
-
// blobContent
|
|
1689
|
-
);
|
|
1690
|
-
this.#announce("info", `Loaded ${name}`);
|
|
1691
|
-
return new Response(blob);
|
|
1692
|
-
}
|
|
1693
|
-
if (url.startsWith("configured:")) {
|
|
1694
|
-
const name = url.replace(/^configured:/, "");
|
|
1695
|
-
this.#log(
|
|
1696
|
-
"[fetch] resolved url in a preconfigured (in the compiler config) specified resolver",
|
|
1697
|
-
url
|
|
1698
|
-
);
|
|
1699
|
-
let result;
|
|
1700
|
-
for (const compilerResolve of this.#compilerResolvers) {
|
|
1701
|
-
const fn = compilerResolve(name);
|
|
1702
|
-
if (fn) {
|
|
1703
|
-
this.#log(`[fetch] ${name} found in compiler config at ${result}.`);
|
|
1704
|
-
result = await fn();
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
assert(`Failed to resolve ${name}`, result);
|
|
1708
|
-
cache.resolves[name] = result;
|
|
1709
|
-
const blobContent = `const mod = window[Symbol.for('${secretKey}')].resolves?.['${name}'];
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
if (!mod) { throw new Error('Could not resolve \`${name}\`. Does the module exist? ( checked ${url} )') }
|
|
1713
|
-
|
|
1714
|
-
${Object.keys(result).map((exportName) => {
|
|
1715
|
-
if (exportName === "default") {
|
|
1716
|
-
return `export default mod.default ?? mod;`;
|
|
1717
|
-
}
|
|
1718
|
-
return `export const ${exportName} = mod.${exportName};`;
|
|
1719
|
-
}).join("\n")}
|
|
1720
|
-
`;
|
|
1721
|
-
const blob = new Blob(Array.from(blobContent), { type: mimeType });
|
|
1722
|
-
this.#log(
|
|
1723
|
-
`[fetch] returning blob mapping to configured resolved import for ${name}`
|
|
1724
|
-
// blobContent
|
|
1725
|
-
);
|
|
1726
|
-
this.#announce("info", `Loaded ${name}`);
|
|
1727
|
-
return new Response(blob);
|
|
1728
|
-
}
|
|
1729
|
-
if (url.startsWith(unzippedPrefix)) {
|
|
1730
|
-
this.#log("[fetch] resolved url via tgz resolver", url, options);
|
|
1731
|
-
const tarInfo = await getFromTarball(url);
|
|
1732
|
-
assert(`Could not find file for ${url}`, tarInfo);
|
|
1733
|
-
const { code, ext } = tarInfo;
|
|
1734
|
-
const file = await this.#postProcess(code, ext);
|
|
1735
|
-
const type = mime.getType(ext);
|
|
1736
|
-
return new Response(new Blob([file], { type: type ?? "application/javascript" }));
|
|
1737
|
-
}
|
|
1738
|
-
if (url.startsWith("https://")) {
|
|
1739
|
-
return fetch(url, options);
|
|
1740
|
-
}
|
|
1741
|
-
this.#log("[fetch] fetching url", url, options);
|
|
1742
|
-
const response = await fetch(url, options);
|
|
1743
|
-
if (!response.ok) return response;
|
|
1744
|
-
const source = await response.text();
|
|
1745
|
-
this.#announce("info", `Loaded ${url}`);
|
|
1746
|
-
return new Response(new Blob([source], { type: "application/javascript" }));
|
|
1747
|
-
};
|
|
1748
|
-
/**
|
|
1749
|
-
* NOTE: this does not resolve compilers that are not loaded yet.
|
|
1750
|
-
* So there would be a bit of a race condition here if different compilers
|
|
1751
|
-
* were to have incompatible post-processing handlers.
|
|
1752
|
-
*
|
|
1753
|
-
* @param {string} text
|
|
1754
|
-
* @param {string} ext
|
|
1755
|
-
*/
|
|
1756
|
-
async #postProcess(text, ext) {
|
|
1757
|
-
let code = text;
|
|
1758
|
-
for (const compiler of this.#compilers) {
|
|
1759
|
-
if (compiler.handlers?.[ext]) {
|
|
1760
|
-
code = await compiler.handlers[ext](code);
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
return code;
|
|
1764
|
-
}
|
|
1765
|
-
/**
|
|
1766
|
-
* @param {string} format
|
|
1767
|
-
* @param {string} text
|
|
1768
|
-
* @param {{ fileName?: string, flavor?: string, [key: string]: unknown }} [ options ]
|
|
1769
|
-
* @returns {Promise<{ element: HTMLElement, destroy: () => void }>}
|
|
1770
|
-
*/
|
|
1771
|
-
async compile(format, text, options = {}) {
|
|
1772
|
-
this.#announce("info", `Compiling ${format}`);
|
|
1773
|
-
try {
|
|
1774
|
-
return await this.#compile(format, text, options);
|
|
1775
|
-
} catch (e) {
|
|
1776
|
-
const message = e instanceof Error ? e.message : e;
|
|
1777
|
-
this.#announce("error", String(message));
|
|
1778
|
-
this.#error(e);
|
|
1779
|
-
throw e;
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
/**
|
|
1783
|
-
* @param {string} format
|
|
1784
|
-
* @param {string} text
|
|
1785
|
-
* @param {{ fileName?: string, flavor?: string, [key: string]: unknown }} [ options ]
|
|
1786
|
-
* @returns {Promise<{ element: HTMLElement, destroy: () => void }>}
|
|
1787
|
-
*/
|
|
1788
|
-
async #compile(format, text, options) {
|
|
1789
|
-
this.#log("[compile] idempotently installing es-module-shim");
|
|
1790
|
-
await import("es-module-shims");
|
|
1791
|
-
const opts = { ...options };
|
|
1792
|
-
opts.fileName ||= `dynamic.${format}`;
|
|
1793
|
-
this.#log("[compile] compiling");
|
|
1794
|
-
const compiler = await this.#getCompiler(format, opts.flavor);
|
|
1795
|
-
const compiled = await compiler.compile(text, opts);
|
|
1796
|
-
let compiledText = 'export default "failed to compile"';
|
|
1797
|
-
let extras = { compiled: "" };
|
|
1798
|
-
if (typeof compiled === "string") {
|
|
1799
|
-
compiledText = compiled;
|
|
1800
|
-
extras = { compiled: compiledText };
|
|
1801
|
-
} else if (typeof compiled.compiled === "string") {
|
|
1802
|
-
const { compiled: text2 } = compiled;
|
|
1803
|
-
compiledText = text2;
|
|
1804
|
-
extras = compiled;
|
|
1805
|
-
} else {
|
|
1806
|
-
let value = compiled;
|
|
1807
|
-
if ("compiled" in compiled) {
|
|
1808
|
-
value = compiled.compiled;
|
|
1809
|
-
extras = compiled;
|
|
1810
|
-
}
|
|
1811
|
-
return this.#render(compiler, value, {
|
|
1812
|
-
...extras,
|
|
1813
|
-
compiled: value
|
|
1814
|
-
});
|
|
1815
|
-
}
|
|
1816
|
-
const asBlobUrl = textToBlobUrl(compiledText);
|
|
1817
|
-
const { default: defaultExport } = await shimmedImport(
|
|
1818
|
-
/* @vite-ignore */
|
|
1819
|
-
asBlobUrl
|
|
1820
|
-
);
|
|
1821
|
-
this.#log("[compile] preparing to render", defaultExport, extras);
|
|
1822
|
-
return this.#render(compiler, defaultExport, extras);
|
|
1823
|
-
}
|
|
1824
|
-
#compilerCache = /* @__PURE__ */ new WeakMap();
|
|
1825
|
-
#compilers = /* @__PURE__ */ new Set();
|
|
1826
|
-
#compilerResolvers = /* @__PURE__ */ new Set();
|
|
1827
|
-
/**
|
|
1828
|
-
* @type {Set<(e: PromiseRejectionEvent, handle: (message: string) => void) => void>}
|
|
1829
|
-
*/
|
|
1830
|
-
#compilerOnUnhandled = /* @__PURE__ */ new Set();
|
|
1831
|
-
/**
|
|
1832
|
-
* @param {string} format
|
|
1833
|
-
* @param {string | undefined} flavor
|
|
1834
|
-
*/
|
|
1835
|
-
async #getCompiler(format, flavor) {
|
|
1836
|
-
const config = this.#resolveFormat(format, flavor);
|
|
1837
|
-
if (this.#compilerCache.has(config)) {
|
|
1838
|
-
return this.#compilerCache.get(config);
|
|
1839
|
-
}
|
|
1840
|
-
if (config.resolve) {
|
|
1841
|
-
this.#compilerResolvers.add(config.resolve);
|
|
1842
|
-
}
|
|
1843
|
-
if (config.onUnhandled) {
|
|
1844
|
-
this.#compilerOnUnhandled.add(config.onUnhandled);
|
|
1845
|
-
}
|
|
1846
|
-
const options = this.optionsFor(format, flavor);
|
|
1847
|
-
const compiler = await config.compiler(options, this.#nestedPublicAPI);
|
|
1848
|
-
this.#compilerCache.set(config, compiler);
|
|
1849
|
-
this.#compilers.add(compiler);
|
|
1850
|
-
return compiler;
|
|
1851
|
-
}
|
|
1852
|
-
/**
|
|
1853
|
-
* @param {string} format
|
|
1854
|
-
* @param {string | undefined} flavor
|
|
1855
|
-
* @returns {import('./types').CompilerConfig}
|
|
1856
|
-
*/
|
|
1857
|
-
#resolveFormat(format, flavor) {
|
|
1858
|
-
let config = this.#options.formats[format];
|
|
1859
|
-
assert(
|
|
1860
|
-
`${format} is not a configured format / extension. The currently configured formats are ${Object.keys(this.#options.formats).join(", ")}`,
|
|
1861
|
-
config
|
|
1862
|
-
);
|
|
1863
|
-
if (flavor && flavor in config) {
|
|
1864
|
-
config = /** @type {{ [flavor: string]: CompilerConfig}} */
|
|
1865
|
-
config[flavor];
|
|
1866
|
-
}
|
|
1867
|
-
assert(
|
|
1868
|
-
`The config for ${format}${flavor ? ` (using flavor ${flavor})` : ""} is missing the 'compiler' function. It had keys: ${Object.keys(
|
|
1869
|
-
/** @type {any} */
|
|
1870
|
-
config
|
|
1871
|
-
)}. If this is a language with multiple flavors, make sure you specify the flavor.`,
|
|
1872
|
-
"compiler" in /** @type {any} */
|
|
1873
|
-
config
|
|
1874
|
-
);
|
|
1875
|
-
return (
|
|
1876
|
-
/** @type {import('./types').CompilerConfig} */
|
|
1877
|
-
config
|
|
1878
|
-
);
|
|
1879
|
-
}
|
|
1880
|
-
/**
|
|
1881
|
-
* @param {string} format
|
|
1882
|
-
* @param {string | undefined} flavor
|
|
1883
|
-
* @returns {{ [key: string]: unknown }}
|
|
1884
|
-
*/
|
|
1885
|
-
#resolveUserOptions(format, flavor) {
|
|
1886
|
-
let config = (
|
|
1887
|
-
/** @type {{ [key: string]: unknown }} */
|
|
1888
|
-
this.#options.options?.[format]
|
|
1889
|
-
);
|
|
1890
|
-
if (!config) return {};
|
|
1891
|
-
if (flavor && flavor in config) {
|
|
1892
|
-
config = /** @type {{ [key: string]: unknown }} */
|
|
1893
|
-
config[flavor];
|
|
1894
|
-
}
|
|
1895
|
-
return config ?? {};
|
|
1896
|
-
}
|
|
1897
|
-
/**
|
|
1898
|
-
* @param {import('./types.ts').Compiler} compiler
|
|
1899
|
-
* @param {string} whatToRender
|
|
1900
|
-
* @param {{ compiled: string } & Record<string, unknown>} extras
|
|
1901
|
-
* @returns {Promise<{ element: HTMLElement, destroy: () => void }>}
|
|
1902
|
-
*/
|
|
1903
|
-
async #render(compiler, whatToRender, extras) {
|
|
1904
|
-
this.#announce("info", "Rendering");
|
|
1905
|
-
const div = this.#createDiv();
|
|
1906
|
-
assert(`Cannot render falsey values. Did compilation succeed?`, whatToRender);
|
|
1907
|
-
const destroy = await compiler.render(div, whatToRender, extras, this.#nestedPublicAPI);
|
|
1908
|
-
await new Promise((resolve2) => requestAnimationFrame(resolve2));
|
|
1909
|
-
return {
|
|
1910
|
-
element: div,
|
|
1911
|
-
destroy: () => {
|
|
1912
|
-
if (destroy) {
|
|
1913
|
-
return destroy();
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
};
|
|
1917
|
-
}
|
|
1918
|
-
/**
|
|
1919
|
-
* @param {string} format
|
|
1920
|
-
* @param {string | undefined} flavor
|
|
1921
|
-
*/
|
|
1922
|
-
optionsFor = (format, flavor) => {
|
|
1923
|
-
const { needsLiveMeta } = this.#resolveFormat(format, flavor);
|
|
1924
|
-
return {
|
|
1925
|
-
needsLiveMeta: (
|
|
1926
|
-
/* @type {boolean | undefined} */
|
|
1927
|
-
needsLiveMeta ?? true
|
|
1928
|
-
),
|
|
1929
|
-
versions: this.#options.versions ?? {},
|
|
1930
|
-
...this.#resolveUserOptions(format, flavor) ?? {}
|
|
1931
|
-
};
|
|
1932
|
-
};
|
|
1933
|
-
static clearCache() {
|
|
1934
|
-
cache.clear();
|
|
1935
|
-
}
|
|
1936
|
-
/**
|
|
1937
|
-
* @param {string} name
|
|
1938
|
-
* @param {(name?: string) => Promise<undefined | object>} [fallback]
|
|
1939
|
-
* @returns {Promise<undefined | object>}
|
|
1940
|
-
*/
|
|
1941
|
-
#resolveManually = async (name, fallback) => {
|
|
1942
|
-
const existing = cache.resolves[name];
|
|
1943
|
-
if (existing) {
|
|
1944
|
-
this.#log("[#resolveManually]", name, "already resolved");
|
|
1945
|
-
return existing;
|
|
1946
|
-
}
|
|
1947
|
-
let result = (
|
|
1948
|
-
/** @type {object | undefined} */
|
|
1949
|
-
await this.#options.resolve?.[name]
|
|
1950
|
-
);
|
|
1951
|
-
if (!result) {
|
|
1952
|
-
this.#log(`[#resolveManually] Could not resolve ${name}`);
|
|
1953
|
-
}
|
|
1954
|
-
if (typeof result === "function") {
|
|
1955
|
-
if (!result) {
|
|
1956
|
-
this.#log(`[#resolveManually] Value for ${name} is a function. Invoking.`);
|
|
1957
|
-
}
|
|
1958
|
-
result = await result();
|
|
1959
|
-
}
|
|
1960
|
-
if (fallback) {
|
|
1961
|
-
result = await fallback(name);
|
|
1962
|
-
}
|
|
1963
|
-
cache.resolves[name] ||= await result;
|
|
1964
|
-
return result;
|
|
1965
|
-
};
|
|
1966
|
-
/**
|
|
1967
|
-
* @type {import('./types.ts').PublicMethods}
|
|
1968
|
-
*/
|
|
1969
|
-
#nestedPublicAPI = {
|
|
1970
|
-
/**
|
|
1971
|
-
* @param {'error' | 'info'} type
|
|
1972
|
-
* @param {string} message
|
|
1973
|
-
* @returns {void}
|
|
1974
|
-
*/
|
|
1975
|
-
announce: (type, message) => this.#announce(type, message),
|
|
1976
|
-
/**
|
|
1977
|
-
* @param {string} name
|
|
1978
|
-
* @param {(name?: string) => Promise<object | undefined>} [fallback]
|
|
1979
|
-
* @returns {Promise<object | undefined>}
|
|
1980
|
-
*/
|
|
1981
|
-
tryResolve: async (name, fallback) => {
|
|
1982
|
-
const existing = await this.#resolveManually(name, fallback);
|
|
1983
|
-
if (existing) {
|
|
1984
|
-
this.#log(name, "already resolved");
|
|
1985
|
-
return existing;
|
|
1986
|
-
}
|
|
1987
|
-
const shimmed = await shimmedImport(
|
|
1988
|
-
/* vite-ignore */
|
|
1989
|
-
name
|
|
1990
|
-
);
|
|
1991
|
-
return shimmed;
|
|
1992
|
-
},
|
|
1993
|
-
/**
|
|
1994
|
-
* @param {string[]} names
|
|
1995
|
-
* @param {(name?: string) => Promise<unknown>} [fallback]
|
|
1996
|
-
* @returns {Promise<unknown[]>}
|
|
1997
|
-
*/
|
|
1998
|
-
tryResolveAll: async (names, fallback) => {
|
|
1999
|
-
const results = await Promise.all(
|
|
2000
|
-
names.map((name) => {
|
|
2001
|
-
return this.#nestedPublicAPI.tryResolve(name);
|
|
2002
|
-
})
|
|
2003
|
-
);
|
|
2004
|
-
if (fallback) {
|
|
2005
|
-
const morePromises = {};
|
|
2006
|
-
for (let i2 = 0; i2 < results.length; i2++) {
|
|
2007
|
-
const result = results[i2];
|
|
2008
|
-
const name = names[i2];
|
|
2009
|
-
if (!result) {
|
|
2010
|
-
this.#warn(`Could not load ${name}. Trying fallback.`);
|
|
2011
|
-
morePromises[i2] = fallback(name);
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
await Promise.all(Object.values(morePromises));
|
|
2015
|
-
for (let i2 = 0; i2 < results.length; i2++) {
|
|
2016
|
-
results[i2];
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
return results;
|
|
2020
|
-
},
|
|
2021
|
-
/**
|
|
2022
|
-
* @param {Parameters<Compiler['compile']>} args
|
|
2023
|
-
*/
|
|
2024
|
-
compile: (...args) => this.compile(...args),
|
|
2025
|
-
/**
|
|
2026
|
-
* @param {Parameters<Compiler['optionsFor']>} args
|
|
2027
|
-
*/
|
|
2028
|
-
optionsFor: (...args) => this.optionsFor(...args),
|
|
2029
|
-
canCompile: (format, flavor) => {
|
|
2030
|
-
let config = this.#options.formats[format];
|
|
2031
|
-
if (!config) {
|
|
2032
|
-
return {
|
|
2033
|
-
result: false,
|
|
2034
|
-
reason: `${format} is not a configured format / extension. The currently configured formats are ${Object.keys(this.#options.formats).join(", ")}`
|
|
2035
|
-
};
|
|
2036
|
-
}
|
|
2037
|
-
if (flavor && flavor in config) {
|
|
2038
|
-
config = /** @type {{ [flavor: string]: CompilerConfig}} */
|
|
2039
|
-
config[flavor];
|
|
2040
|
-
}
|
|
2041
|
-
if (!config) {
|
|
2042
|
-
return {
|
|
2043
|
-
result: false,
|
|
2044
|
-
reason: `${format} for ${flavor} is not a configured format / extension. The currently configured formats are ${Object.keys(this.#options.formats).join(", ")}`
|
|
2045
|
-
};
|
|
2046
|
-
}
|
|
2047
|
-
if ("compiler" in config) {
|
|
2048
|
-
return { result: true };
|
|
2049
|
-
}
|
|
2050
|
-
return {
|
|
2051
|
-
result: false,
|
|
2052
|
-
reason: `The config for ${format}${flavor ? ` (using flavor ${flavor})` : ""} is missing the 'compiler' function. It had keys: ${Object.keys(config)}. If this is a language with multiple flavors, make sure you specify the flavor.`
|
|
2053
|
-
};
|
|
2054
|
-
},
|
|
2055
|
-
getCompiler: (format, flavor) => this.#getCompiler(format, flavor),
|
|
2056
|
-
getAllowedFormats: () => Object.keys(this.#options.formats),
|
|
2057
|
-
getFlavorsFor: (format) => {
|
|
2058
|
-
const config = this.#options.formats[format];
|
|
2059
|
-
if (!config) return [];
|
|
2060
|
-
if (typeof config === "function") return [];
|
|
2061
|
-
if (typeof config === "object") {
|
|
2062
|
-
return Object.keys(config);
|
|
2063
|
-
}
|
|
2064
|
-
return [];
|
|
2065
|
-
}
|
|
2066
|
-
};
|
|
2067
|
-
#createDiv() {
|
|
2068
|
-
const div = document.createElement("div");
|
|
2069
|
-
div.setAttribute("data-repl-output", "");
|
|
2070
|
-
div.id = nextId();
|
|
2071
|
-
return div;
|
|
2072
|
-
}
|
|
2073
|
-
/**
|
|
2074
|
-
* @param {'error' | 'info'} type
|
|
2075
|
-
* @param {string} message
|
|
2076
|
-
*/
|
|
2077
|
-
#announce(type, message) {
|
|
2078
|
-
if (!this.#options?.on?.log) return;
|
|
2079
|
-
this.#options.on.log(type, message);
|
|
2080
|
-
}
|
|
2081
|
-
/**
|
|
2082
|
-
* @param {Parameters<typeof console.debug>} args
|
|
2083
|
-
*/
|
|
2084
|
-
#log(...args) {
|
|
2085
|
-
if (this.#options.logging) {
|
|
2086
|
-
console.debug(...args);
|
|
2087
|
-
}
|
|
2088
|
-
}
|
|
2089
|
-
/**
|
|
2090
|
-
* @param {Parameters<typeof console.warn>} args
|
|
2091
|
-
*/
|
|
2092
|
-
#warn(...args) {
|
|
2093
|
-
if (this.#options.logging) {
|
|
2094
|
-
console.warn(...args);
|
|
2095
|
-
}
|
|
2096
|
-
}
|
|
2097
|
-
/**
|
|
2098
|
-
* @param {Parameters<typeof console.error>} args
|
|
2099
|
-
*/
|
|
2100
|
-
#error(...args) {
|
|
2101
|
-
if (this.#options.logging) {
|
|
2102
|
-
console.error(...args);
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
/**
|
|
2106
|
-
* @param {string} message
|
|
2107
|
-
*/
|
|
2108
|
-
announceError(message) {
|
|
2109
|
-
this.#announce("error", message);
|
|
2110
|
-
}
|
|
2111
|
-
}
|
|
2112
|
-
function textToBlobUrl(text) {
|
|
2113
|
-
const blob = new Blob([text], { type: "text/javascript" });
|
|
2114
|
-
const blobUrl = URL.createObjectURL(blob);
|
|
2115
|
-
return blobUrl;
|
|
2116
|
-
}
|
|
2117
|
-
function shimmedImport(...args) {
|
|
2118
|
-
if (!globalThis.importShim) {
|
|
2119
|
-
throw new Error(`Could not find importShim. Has the REPL been set up correctly?`);
|
|
2120
|
-
}
|
|
2121
|
-
return globalThis.importShim(...args);
|
|
2122
|
-
}
|
|
2123
|
-
function deCDN(id) {
|
|
2124
|
-
const noQPs = id.split("?")[0];
|
|
2125
|
-
return (
|
|
2126
|
-
/** @type {string} */
|
|
2127
|
-
noQPs
|
|
2128
|
-
);
|
|
2129
|
-
}
|
|
2130
|
-
export {
|
|
2131
|
-
Compiler as C,
|
|
2132
|
-
assert as a,
|
|
2133
|
-
buildCodeFenceMetaUtils as b,
|
|
2134
|
-
defaults as c,
|
|
2135
|
-
defaultFormats as d,
|
|
2136
|
-
isRecord as i,
|
|
2137
|
-
nextId as n
|
|
2138
|
-
};
|
|
2139
|
-
//# sourceMappingURL=index-CVGAEPMV.js.map
|