@metamask/snaps-cli 5.1.1 → 6.0.0
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/CHANGELOG.md +8 -1
- package/dist/builders.js +10 -0
- package/dist/builders.js.map +1 -0
- package/dist/builders.mjs +10 -0
- package/dist/builders.mjs.map +1 -0
- package/dist/chunk-25SLEORF.mjs +28 -0
- package/dist/chunk-25SLEORF.mjs.map +1 -0
- package/dist/chunk-2QVYYMUD.js +365 -0
- package/dist/chunk-2QVYYMUD.js.map +1 -0
- package/dist/{esm/webpack/config.js → chunk-3LNPS7AX.js} +182 -156
- package/dist/chunk-3LNPS7AX.js.map +1 -0
- package/dist/chunk-46JUPGRY.js +22 -0
- package/dist/chunk-46JUPGRY.js.map +1 -0
- package/dist/chunk-4NHBPMKT.js +54 -0
- package/dist/chunk-4NHBPMKT.js.map +1 -0
- package/dist/chunk-4OKAI7AP.js +52 -0
- package/dist/chunk-4OKAI7AP.js.map +1 -0
- package/dist/chunk-5DDAAM2X.js +41 -0
- package/dist/chunk-5DDAAM2X.js.map +1 -0
- package/dist/chunk-5DSV76XV.mjs +10 -0
- package/dist/chunk-5DSV76XV.mjs.map +1 -0
- package/dist/chunk-5JPLNWCO.js +24 -0
- package/dist/chunk-5JPLNWCO.js.map +1 -0
- package/dist/chunk-5VAZH7L7.js +64 -0
- package/dist/chunk-5VAZH7L7.js.map +1 -0
- package/dist/chunk-5YUHRLH6.js +22 -0
- package/dist/chunk-5YUHRLH6.js.map +1 -0
- package/dist/chunk-6IF2UBYA.mjs +13 -0
- package/dist/chunk-6IF2UBYA.mjs.map +1 -0
- package/dist/chunk-6NJAXMSB.js +135 -0
- package/dist/chunk-6NJAXMSB.js.map +1 -0
- package/dist/chunk-6VFUO2H5.mjs +124 -0
- package/dist/chunk-6VFUO2H5.mjs.map +1 -0
- package/dist/chunk-7SN4Y44H.js +287 -0
- package/dist/chunk-7SN4Y44H.js.map +1 -0
- package/dist/chunk-ASOCIPDR.js +10 -0
- package/dist/chunk-ASOCIPDR.js.map +1 -0
- package/dist/chunk-B455GFXP.mjs +54 -0
- package/dist/chunk-B455GFXP.mjs.map +1 -0
- package/dist/chunk-DWS4BJTE.mjs +64 -0
- package/dist/chunk-DWS4BJTE.mjs.map +1 -0
- package/dist/chunk-EQRMXKXY.js +346 -0
- package/dist/chunk-EQRMXKXY.js.map +1 -0
- package/dist/chunk-EXGQAOQS.js +64 -0
- package/dist/chunk-EXGQAOQS.js.map +1 -0
- package/dist/chunk-EXJCMAUI.mjs +23 -0
- package/dist/chunk-EXJCMAUI.mjs.map +1 -0
- package/dist/chunk-FPG4GBXZ.js +30 -0
- package/dist/chunk-FPG4GBXZ.js.map +1 -0
- package/dist/chunk-FYTQTDZU.mjs +52 -0
- package/dist/chunk-FYTQTDZU.mjs.map +1 -0
- package/dist/chunk-G3IYVYVR.js +31 -0
- package/dist/chunk-G3IYVYVR.js.map +1 -0
- package/dist/chunk-GC7BNDLY.js +23 -0
- package/dist/chunk-GC7BNDLY.js.map +1 -0
- package/dist/chunk-GKG7TO7T.js +28 -0
- package/dist/chunk-GKG7TO7T.js.map +1 -0
- package/dist/chunk-GU2KH52B.mjs +53 -0
- package/dist/chunk-GU2KH52B.mjs.map +1 -0
- package/dist/chunk-GUXDSKV4.mjs +51 -0
- package/dist/chunk-GUXDSKV4.mjs.map +1 -0
- package/dist/chunk-HGYXRW5B.js +50 -0
- package/dist/chunk-HGYXRW5B.js.map +1 -0
- package/dist/chunk-HJ4276TR.mjs +41 -0
- package/dist/chunk-HJ4276TR.mjs.map +1 -0
- package/dist/chunk-HNLMKJBX.js +30 -0
- package/dist/chunk-HNLMKJBX.js.map +1 -0
- package/dist/chunk-IJYBCHVM.js +32 -0
- package/dist/chunk-IJYBCHVM.js.map +1 -0
- package/dist/chunk-IQTGFRWK.js +18 -0
- package/dist/chunk-IQTGFRWK.js.map +1 -0
- package/dist/chunk-IYAFFTJU.js +23 -0
- package/dist/chunk-IYAFFTJU.js.map +1 -0
- package/dist/chunk-JMISQ4HT.mjs +31 -0
- package/dist/chunk-JMISQ4HT.mjs.map +1 -0
- package/dist/chunk-K3TSXPME.js +16 -0
- package/dist/chunk-K3TSXPME.js.map +1 -0
- package/dist/{cjs/webpack/config.js → chunk-KKTPKAZN.mjs} +181 -153
- package/dist/chunk-KKTPKAZN.mjs.map +1 -0
- package/dist/chunk-KZFWI73A.js +28 -0
- package/dist/chunk-KZFWI73A.js.map +1 -0
- package/dist/chunk-L5TMG6BQ.js +37 -0
- package/dist/chunk-L5TMG6BQ.js.map +1 -0
- package/dist/chunk-MCN7UXG3.mjs +287 -0
- package/dist/chunk-MCN7UXG3.mjs.map +1 -0
- package/dist/chunk-MIV2UFTA.js +13 -0
- package/dist/chunk-MIV2UFTA.js.map +1 -0
- package/dist/chunk-MMBQXT2G.mjs +30 -0
- package/dist/chunk-MMBQXT2G.mjs.map +1 -0
- package/dist/chunk-NO53G7NT.js +61 -0
- package/dist/chunk-NO53G7NT.js.map +1 -0
- package/dist/chunk-O2QUFUOY.js +53 -0
- package/dist/chunk-O2QUFUOY.js.map +1 -0
- package/dist/chunk-OF4BF57X.mjs +22 -0
- package/dist/chunk-OF4BF57X.mjs.map +1 -0
- package/dist/chunk-OVCYXVWI.mjs +1 -0
- package/dist/chunk-OVCYXVWI.mjs.map +1 -0
- package/dist/chunk-PDNDGMB2.mjs +365 -0
- package/dist/chunk-PDNDGMB2.mjs.map +1 -0
- package/dist/chunk-QCP4QKMQ.mjs +24 -0
- package/dist/chunk-QCP4QKMQ.mjs.map +1 -0
- package/dist/chunk-QH4AQR33.mjs +61 -0
- package/dist/chunk-QH4AQR33.mjs.map +1 -0
- package/dist/chunk-S5ERYB6I.mjs +64 -0
- package/dist/chunk-S5ERYB6I.mjs.map +1 -0
- package/dist/chunk-SAEZHRJJ.mjs +23 -0
- package/dist/chunk-SAEZHRJJ.mjs.map +1 -0
- package/dist/chunk-T3KPXUAU.js +24 -0
- package/dist/chunk-T3KPXUAU.js.map +1 -0
- package/dist/chunk-T74IXMA3.mjs +50 -0
- package/dist/chunk-T74IXMA3.mjs.map +1 -0
- package/dist/chunk-TLTTWAEI.mjs +37 -0
- package/dist/chunk-TLTTWAEI.mjs.map +1 -0
- package/dist/chunk-TX4BG5GS.mjs +50 -0
- package/dist/chunk-TX4BG5GS.mjs.map +1 -0
- package/dist/chunk-UA5FEKKH.mjs +30 -0
- package/dist/chunk-UA5FEKKH.mjs.map +1 -0
- package/dist/chunk-UBWM7UOC.mjs +32 -0
- package/dist/chunk-UBWM7UOC.mjs.map +1 -0
- package/dist/chunk-USFFVX52.mjs +35 -0
- package/dist/chunk-USFFVX52.mjs.map +1 -0
- package/dist/chunk-V5Q5HRXB.mjs +30 -0
- package/dist/chunk-V5Q5HRXB.mjs.map +1 -0
- package/dist/chunk-VI3ZJJYO.mjs +346 -0
- package/dist/chunk-VI3ZJJYO.mjs.map +1 -0
- package/dist/chunk-VTJFPUIA.mjs +22 -0
- package/dist/chunk-VTJFPUIA.mjs.map +1 -0
- package/dist/chunk-WH7GOZP7.js +51 -0
- package/dist/chunk-WH7GOZP7.js.map +1 -0
- package/dist/chunk-WJNHZ4YF.js +35 -0
- package/dist/chunk-WJNHZ4YF.js.map +1 -0
- package/dist/chunk-WKL7DYYW.mjs +16 -0
- package/dist/chunk-WKL7DYYW.mjs.map +1 -0
- package/dist/chunk-X2RPNWBJ.mjs +24 -0
- package/dist/chunk-X2RPNWBJ.mjs.map +1 -0
- package/dist/chunk-X3D3MHWF.js +44 -0
- package/dist/chunk-X3D3MHWF.js.map +1 -0
- package/dist/chunk-X4FWMO4H.mjs +18 -0
- package/dist/chunk-X4FWMO4H.mjs.map +1 -0
- package/dist/chunk-Y5PQG4KA.js +1 -0
- package/dist/chunk-Y5PQG4KA.js.map +1 -0
- package/dist/chunk-YDLKS46R.js +30 -0
- package/dist/chunk-YDLKS46R.js.map +1 -0
- package/dist/chunk-YURDB35F.js +124 -0
- package/dist/chunk-YURDB35F.js.map +1 -0
- package/dist/chunk-YYYOE2GO.mjs +32 -0
- package/dist/chunk-YYYOE2GO.mjs.map +1 -0
- package/dist/chunk-ZOQ32RQI.mjs +135 -0
- package/dist/chunk-ZOQ32RQI.mjs.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +21 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/commands/build/build.js +29 -0
- package/dist/commands/build/build.js.map +1 -0
- package/dist/commands/build/build.mjs +29 -0
- package/dist/commands/build/build.mjs.map +1 -0
- package/dist/commands/build/implementation.js +28 -0
- package/dist/commands/build/implementation.js.map +1 -0
- package/dist/commands/build/implementation.mjs +28 -0
- package/dist/commands/build/implementation.mjs.map +1 -0
- package/dist/commands/build/index.js +33 -0
- package/dist/commands/build/index.js.map +1 -0
- package/dist/commands/build/index.mjs +33 -0
- package/dist/commands/build/index.mjs.map +1 -0
- package/dist/commands/eval/eval.js +18 -0
- package/dist/commands/eval/eval.js.map +1 -0
- package/dist/commands/eval/eval.mjs +18 -0
- package/dist/commands/eval/eval.mjs.map +1 -0
- package/dist/commands/eval/implementation.js +9 -0
- package/dist/commands/eval/implementation.js.map +1 -0
- package/dist/commands/eval/implementation.mjs +9 -0
- package/dist/commands/eval/implementation.mjs.map +1 -0
- package/dist/commands/eval/index.js +22 -0
- package/dist/commands/eval/index.js.map +1 -0
- package/dist/commands/eval/index.mjs +22 -0
- package/dist/commands/eval/index.mjs.map +1 -0
- package/dist/commands/index.js +39 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/index.mjs +39 -0
- package/dist/commands/index.mjs.map +1 -0
- package/dist/commands/manifest/implementation.js +17 -0
- package/dist/commands/manifest/implementation.js.map +1 -0
- package/dist/commands/manifest/implementation.mjs +17 -0
- package/dist/commands/manifest/implementation.mjs.map +1 -0
- package/dist/commands/manifest/index.js +22 -0
- package/dist/commands/manifest/index.js.map +1 -0
- package/dist/commands/manifest/index.mjs +22 -0
- package/dist/commands/manifest/index.mjs.map +1 -0
- package/dist/commands/manifest/manifest.js +18 -0
- package/dist/commands/manifest/manifest.js.map +1 -0
- package/dist/commands/manifest/manifest.mjs +18 -0
- package/dist/commands/manifest/manifest.mjs.map +1 -0
- package/dist/commands/serve/index.js +29 -0
- package/dist/commands/serve/index.js.map +1 -0
- package/dist/commands/serve/index.mjs +29 -0
- package/dist/commands/serve/index.mjs.map +1 -0
- package/dist/commands/serve/serve.js +28 -0
- package/dist/commands/serve/serve.js.map +1 -0
- package/dist/commands/serve/serve.mjs +28 -0
- package/dist/commands/serve/serve.mjs.map +1 -0
- package/dist/commands/watch/implementation.js +28 -0
- package/dist/commands/watch/implementation.js.map +1 -0
- package/dist/commands/watch/implementation.mjs +28 -0
- package/dist/commands/watch/implementation.mjs.map +1 -0
- package/dist/commands/watch/index.js +33 -0
- package/dist/commands/watch/index.js.map +1 -0
- package/dist/commands/watch/index.mjs +33 -0
- package/dist/commands/watch/index.mjs.map +1 -0
- package/dist/commands/watch/watch.js +29 -0
- package/dist/commands/watch/watch.js.map +1 -0
- package/dist/commands/watch/watch.mjs +29 -0
- package/dist/commands/watch/watch.mjs.map +1 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mjs +36 -0
- package/dist/config.mjs.map +1 -0
- package/dist/errors.js +12 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +12 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +43 -0
- package/dist/index.mjs.map +1 -0
- package/dist/main.js +49 -0
- package/dist/main.js.map +1 -0
- package/dist/main.mjs +49 -0
- package/dist/main.mjs.map +1 -0
- package/dist/structs.js +8 -0
- package/dist/structs.js.map +1 -0
- package/dist/structs.mjs +8 -0
- package/dist/structs.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/commands/eval/implementation.d.ts +1 -1
- package/dist/types/config.d.ts +2 -2
- package/dist/types/structs.d.ts +20 -0
- package/dist/types/webpack/loaders/function.d.ts +34 -0
- package/dist/types/webpack/loaders/index.d.ts +3 -0
- package/dist/types/webpack/utils.d.ts +13 -11
- package/dist/types/yargs.d.js +1 -0
- package/dist/types/yargs.d.js.map +1 -0
- package/dist/types/yargs.d.mjs +2 -0
- package/dist/types/yargs.d.mjs.map +1 -0
- package/dist/utils/cli.js +14 -0
- package/dist/utils/cli.js.map +1 -0
- package/dist/utils/cli.mjs +14 -0
- package/dist/utils/cli.mjs.map +1 -0
- package/dist/utils/errors.js +11 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/errors.mjs +11 -0
- package/dist/utils/errors.mjs.map +1 -0
- package/dist/utils/index.js +47 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +47 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/legacy.js +13 -0
- package/dist/utils/legacy.js.map +1 -0
- package/dist/utils/legacy.mjs +13 -0
- package/dist/utils/legacy.mjs.map +1 -0
- package/dist/utils/logging.js +12 -0
- package/dist/utils/logging.js.map +1 -0
- package/dist/utils/logging.mjs +12 -0
- package/dist/utils/logging.mjs.map +1 -0
- package/dist/utils/path.js +8 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/path.mjs +8 -0
- package/dist/utils/path.mjs.map +1 -0
- package/dist/utils/steps.js +11 -0
- package/dist/utils/steps.js.map +1 -0
- package/dist/utils/steps.mjs +11 -0
- package/dist/utils/steps.mjs.map +1 -0
- package/dist/webpack/compiler.js +25 -0
- package/dist/webpack/compiler.js.map +1 -0
- package/dist/webpack/compiler.mjs +25 -0
- package/dist/webpack/compiler.mjs.map +1 -0
- package/dist/webpack/config.js +24 -0
- package/dist/webpack/config.js.map +1 -0
- package/dist/webpack/config.mjs +24 -0
- package/dist/webpack/config.mjs.map +1 -0
- package/dist/webpack/index.js +44 -0
- package/dist/webpack/index.js.map +1 -0
- package/dist/webpack/index.mjs +44 -0
- package/dist/webpack/index.mjs.map +1 -0
- package/dist/webpack/loaders/browserify.js +19 -0
- package/dist/webpack/loaders/browserify.js.map +1 -0
- package/dist/webpack/loaders/browserify.mjs +19 -0
- package/dist/webpack/loaders/browserify.mjs.map +1 -0
- package/dist/webpack/loaders/function.js +10 -0
- package/dist/webpack/loaders/function.js.map +1 -0
- package/dist/webpack/loaders/function.mjs +10 -0
- package/dist/webpack/loaders/function.mjs.map +1 -0
- package/dist/webpack/loaders/index.js +25 -0
- package/dist/webpack/loaders/index.js.map +1 -0
- package/dist/webpack/loaders/index.mjs +25 -0
- package/dist/webpack/loaders/index.mjs.map +1 -0
- package/dist/webpack/loaders/wasm.js +16 -0
- package/dist/webpack/loaders/wasm.js.map +1 -0
- package/dist/webpack/loaders/wasm.mjs +16 -0
- package/dist/webpack/loaders/wasm.mjs.map +1 -0
- package/dist/webpack/plugins.js +29 -0
- package/dist/webpack/plugins.js.map +1 -0
- package/dist/webpack/plugins.mjs +29 -0
- package/dist/webpack/plugins.mjs.map +1 -0
- package/dist/webpack/server.js +10 -0
- package/dist/webpack/server.js.map +1 -0
- package/dist/webpack/server.mjs +10 -0
- package/dist/webpack/server.mjs.map +1 -0
- package/dist/webpack/utils.js +37 -0
- package/dist/webpack/utils.js.map +1 -0
- package/dist/webpack/utils.mjs +37 -0
- package/dist/webpack/utils.mjs.map +1 -0
- package/package.json +21 -21
- package/.browserslistrc +0 -3
- package/dist/cjs/builders.js +0 -148
- package/dist/cjs/builders.js.map +0 -1
- package/dist/cjs/cli.js +0 -68
- package/dist/cjs/cli.js.map +0 -1
- package/dist/cjs/commands/build/build.js +0 -54
- package/dist/cjs/commands/build/build.js.map +0 -1
- package/dist/cjs/commands/build/implementation.js +0 -31
- package/dist/cjs/commands/build/implementation.js.map +0 -1
- package/dist/cjs/commands/build/index.js +0 -45
- package/dist/cjs/commands/build/index.js.map +0 -1
- package/dist/cjs/commands/eval/eval.js +0 -57
- package/dist/cjs/commands/eval/eval.js.map +0 -1
- package/dist/cjs/commands/eval/implementation.js +0 -27
- package/dist/cjs/commands/eval/implementation.js.map +0 -1
- package/dist/cjs/commands/eval/index.js +0 -50
- package/dist/cjs/commands/eval/index.js.map +0 -1
- package/dist/cjs/commands/index.js +0 -30
- package/dist/cjs/commands/index.js.map +0 -1
- package/dist/cjs/commands/manifest/implementation.js +0 -34
- package/dist/cjs/commands/manifest/implementation.js.map +0 -1
- package/dist/cjs/commands/manifest/index.js +0 -50
- package/dist/cjs/commands/manifest/index.js.map +0 -1
- package/dist/cjs/commands/manifest/manifest.js +0 -55
- package/dist/cjs/commands/manifest/manifest.js.map +0 -1
- package/dist/cjs/commands/serve/index.js +0 -33
- package/dist/cjs/commands/serve/index.js.map +0 -1
- package/dist/cjs/commands/serve/serve.js +0 -21
- package/dist/cjs/commands/serve/serve.js.map +0 -1
- package/dist/cjs/commands/watch/implementation.js +0 -35
- package/dist/cjs/commands/watch/implementation.js.map +0 -1
- package/dist/cjs/commands/watch/index.js +0 -47
- package/dist/cjs/commands/watch/index.js.map +0 -1
- package/dist/cjs/commands/watch/watch.js +0 -51
- package/dist/cjs/commands/watch/watch.js.map +0 -1
- package/dist/cjs/config.js +0 -320
- package/dist/cjs/config.js.map +0 -1
- package/dist/cjs/errors.js +0 -37
- package/dist/cjs/errors.js.map +0 -1
- package/dist/cjs/index.js +0 -77
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/main.js +0 -19
- package/dist/cjs/main.js.map +0 -1
- package/dist/cjs/utils/cli.js +0 -61
- package/dist/cjs/utils/cli.js.map +0 -1
- package/dist/cjs/utils/errors.js +0 -42
- package/dist/cjs/utils/errors.js.map +0 -1
- package/dist/cjs/utils/index.js +0 -25
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/legacy.js +0 -48
- package/dist/cjs/utils/legacy.js.map +0 -1
- package/dist/cjs/utils/logging.js +0 -46
- package/dist/cjs/utils/logging.js.map +0 -1
- package/dist/cjs/utils/path.js +0 -16
- package/dist/cjs/utils/path.js.map +0 -1
- package/dist/cjs/utils/steps.js +0 -52
- package/dist/cjs/utils/steps.js.map +0 -1
- package/dist/cjs/webpack/compiler.js +0 -19
- package/dist/cjs/webpack/compiler.js.map +0 -1
- package/dist/cjs/webpack/config.js.map +0 -1
- package/dist/cjs/webpack/index.js +0 -23
- package/dist/cjs/webpack/index.js.map +0 -1
- package/dist/cjs/webpack/loaders/browserify.js +0 -97
- package/dist/cjs/webpack/loaders/browserify.js.map +0 -1
- package/dist/cjs/webpack/loaders/wasm.js +0 -92
- package/dist/cjs/webpack/loaders/wasm.js.map +0 -1
- package/dist/cjs/webpack/plugins.js +0 -341
- package/dist/cjs/webpack/plugins.js.map +0 -1
- package/dist/cjs/webpack/server.js +0 -139
- package/dist/cjs/webpack/server.js.map +0 -1
- package/dist/cjs/webpack/utils.js +0 -254
- package/dist/cjs/webpack/utils.js.map +0 -1
- package/dist/esm/builders.js +0 -130
- package/dist/esm/builders.js.map +0 -1
- package/dist/esm/cli.js +0 -56
- package/dist/esm/cli.js.map +0 -1
- package/dist/esm/commands/build/build.js +0 -51
- package/dist/esm/commands/build/build.js.map +0 -1
- package/dist/esm/commands/build/implementation.js +0 -27
- package/dist/esm/commands/build/implementation.js.map +0 -1
- package/dist/esm/commands/build/index.js +0 -17
- package/dist/esm/commands/build/index.js.map +0 -1
- package/dist/esm/commands/eval/eval.js +0 -54
- package/dist/esm/commands/eval/eval.js.map +0 -1
- package/dist/esm/commands/eval/implementation.js +0 -24
- package/dist/esm/commands/eval/implementation.js.map +0 -1
- package/dist/esm/commands/eval/index.js +0 -22
- package/dist/esm/commands/eval/index.js.map +0 -1
- package/dist/esm/commands/index.js +0 -15
- package/dist/esm/commands/index.js.map +0 -1
- package/dist/esm/commands/manifest/implementation.js +0 -33
- package/dist/esm/commands/manifest/implementation.js.map +0 -1
- package/dist/esm/commands/manifest/index.js +0 -22
- package/dist/esm/commands/manifest/index.js.map +0 -1
- package/dist/esm/commands/manifest/manifest.js +0 -52
- package/dist/esm/commands/manifest/manifest.js.map +0 -1
- package/dist/esm/commands/serve/index.js +0 -18
- package/dist/esm/commands/serve/index.js.map +0 -1
- package/dist/esm/commands/serve/serve.js +0 -17
- package/dist/esm/commands/serve/serve.js.map +0 -1
- package/dist/esm/commands/watch/implementation.js +0 -34
- package/dist/esm/commands/watch/implementation.js.map +0 -1
- package/dist/esm/commands/watch/index.js +0 -19
- package/dist/esm/commands/watch/index.js.map +0 -1
- package/dist/esm/commands/watch/watch.js +0 -50
- package/dist/esm/commands/watch/watch.js.map +0 -1
- package/dist/esm/config.js +0 -324
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/errors.js +0 -30
- package/dist/esm/errors.js.map +0 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/main.js +0 -10
- package/dist/esm/main.js.map +0 -1
- package/dist/esm/utils/cli.js +0 -43
- package/dist/esm/utils/cli.js.map +0 -1
- package/dist/esm/utils/errors.js +0 -43
- package/dist/esm/utils/errors.js.map +0 -1
- package/dist/esm/utils/index.js +0 -8
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/legacy.js +0 -47
- package/dist/esm/utils/legacy.js.map +0 -1
- package/dist/esm/utils/logging.js +0 -40
- package/dist/esm/utils/logging.js.map +0 -1
- package/dist/esm/utils/path.js +0 -13
- package/dist/esm/utils/path.js.map +0 -1
- package/dist/esm/utils/steps.js +0 -43
- package/dist/esm/utils/steps.js.map +0 -1
- package/dist/esm/webpack/compiler.js +0 -15
- package/dist/esm/webpack/compiler.js.map +0 -1
- package/dist/esm/webpack/config.js.map +0 -1
- package/dist/esm/webpack/index.js +0 -6
- package/dist/esm/webpack/index.js.map +0 -1
- package/dist/esm/webpack/loaders/browserify.js +0 -82
- package/dist/esm/webpack/loaders/browserify.js.map +0 -1
- package/dist/esm/webpack/loaders/wasm.js +0 -87
- package/dist/esm/webpack/loaders/wasm.js.map +0 -1
- package/dist/esm/webpack/plugins.js +0 -344
- package/dist/esm/webpack/plugins.js.map +0 -1
- package/dist/esm/webpack/server.js +0 -133
- package/dist/esm/webpack/server.js.map +0 -1
- package/dist/esm/webpack/utils.js +0 -285
- package/dist/esm/webpack/utils.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkIJYBCHVMjs = require('./chunk-IJYBCHVM.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkG3IYVYVRjs = require('./chunk-G3IYVYVR.js');
|
|
7
|
+
|
|
8
|
+
// src/utils/steps.ts
|
|
9
|
+
var _chalk = require('chalk');
|
|
10
|
+
var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
|
|
11
|
+
async function executeSteps(steps, context) {
|
|
12
|
+
const spinner = _ora2.default.call(void 0, {
|
|
13
|
+
// Ora writes to `process.stderr` by default.
|
|
14
|
+
stream: process.stdout
|
|
15
|
+
});
|
|
16
|
+
spinner.start();
|
|
17
|
+
try {
|
|
18
|
+
for (const step of steps) {
|
|
19
|
+
if (step.condition && !step.condition(context)) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
spinner.start(_chalk.dim.call(void 0, step.name));
|
|
23
|
+
await step.task({
|
|
24
|
+
...context,
|
|
25
|
+
spinner
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (spinner.isSpinning) {
|
|
29
|
+
spinner.succeed("Done!");
|
|
30
|
+
}
|
|
31
|
+
} catch (_error) {
|
|
32
|
+
_chunkG3IYVYVRjs.error.call(void 0, _chunkIJYBCHVMjs.getErrorMessage.call(void 0, _error), spinner);
|
|
33
|
+
spinner.stop();
|
|
34
|
+
process.exitCode = 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
exports.executeSteps = executeSteps;
|
|
41
|
+
//# sourceMappingURL=chunk-5DDAAM2X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/steps.ts"],"names":[],"mappings":";;;;;;;;AAAA,SAAS,WAAW;AAEpB,OAAO,mBAAmB;AAsB1B,eAAsB,aACpB,OACA,SACA;AACA,QAAM,UAAU,cAAc;AAAA;AAAA,IAE5B,QAAQ,QAAQ;AAAA,EAClB,CAAC;AAED,UAAQ,MAAM;AAEd,MAAI;AACF,eAAW,QAAQ,OAAO;AAExB,UAAI,KAAK,aAAa,CAAC,KAAK,UAAU,OAAO,GAAG;AAC9C;AAAA,MACF;AAIA,cAAQ,MAAM,IAAI,KAAK,IAAI,CAAC;AAE5B,YAAM,KAAK,KAAK;AAAA,QACd,GAAG;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AAIA,QAAI,QAAQ,YAAY;AACtB,cAAQ,QAAQ,OAAO;AAAA,IACzB;AAAA,EACF,SAAS,QAAQ;AACf,UAAM,gBAAgB,MAAM,GAAG,OAAO;AACtC,YAAQ,KAAK;AACb,YAAQ,WAAW;AAAA,EACrB;AACF","sourcesContent":["import { dim } from 'chalk';\nimport type { Ora } from 'ora';\nimport createSpinner from 'ora';\n\nimport { getErrorMessage } from './errors';\nimport { error } from './logging';\n\nexport type Step<Context extends Record<string, unknown>> = {\n name: string;\n condition?: (context: Context) => boolean;\n task: (context: Context & { spinner: Ora }) => Promise<void>;\n};\n\nexport type Steps<Context extends Record<string, unknown>> = Readonly<\n Step<Context>[]\n>;\n\n/**\n * Execute a list of steps in series. Each step receives the context object and\n * a spinner instance.\n *\n * @param steps - The steps to execute.\n * @param context - The context object that will be passed to each step.\n */\nexport async function executeSteps<Context extends Record<string, unknown>>(\n steps: Steps<Context>,\n context: Context,\n) {\n const spinner = createSpinner({\n // Ora writes to `process.stderr` by default.\n stream: process.stdout,\n });\n\n spinner.start();\n\n try {\n for (const step of steps) {\n // If the step has a condition, and it returns false, we skip the step.\n if (step.condition && !step.condition(context)) {\n continue;\n }\n\n // Calling `start` here instead of setting `spinner.text` seems to work\n // better when the process doesn't have a TTY.\n spinner.start(dim(step.name));\n\n await step.task({\n ...context,\n spinner,\n });\n }\n\n // The spinner may have been stopped by a step, so we only succeed if it's\n // still spinning.\n if (spinner.isSpinning) {\n spinner.succeed('Done!');\n }\n } catch (_error) {\n error(getErrorMessage(_error), spinner);\n spinner.stop();\n process.exitCode = 1;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/path.ts"],"sourcesContent":["import { relative } from 'path';\n\n/**\n * Get the relative path from the current working directory to the given\n * absolute path.\n *\n * @param absolutePath - The absolute path.\n * @param cwd - The current working directory. Defaults to `process.cwd()`.\n * @returns The relative path.\n */\nexport function getRelativePath(absolutePath: string, cwd = process.cwd()) {\n return relative(cwd, absolutePath);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAUlB,SAAS,gBAAgB,cAAsB,MAAM,QAAQ,IAAI,GAAG;AACzE,SAAO,SAAS,KAAK,YAAY;AACnC;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk4NHBPMKTjs = require('./chunk-4NHBPMKT.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk6NJAXMSBjs = require('./chunk-6NJAXMSB.js');
|
|
7
|
+
|
|
8
|
+
// src/commands/watch/index.ts
|
|
9
|
+
var command = {
|
|
10
|
+
command: ["watch", "w"],
|
|
11
|
+
desc: "Build Snap on change",
|
|
12
|
+
builder: (yarg) => {
|
|
13
|
+
yarg.option("src", _chunk6NJAXMSBjs.builders_default.src).option("eval", _chunk6NJAXMSBjs.builders_default.eval).option("dist", _chunk6NJAXMSBjs.builders_default.dist).option("outfileName", _chunk6NJAXMSBjs.builders_default.outfileName).option("sourceMaps", _chunk6NJAXMSBjs.builders_default.sourceMaps).option("stripComments", _chunk6NJAXMSBjs.builders_default.stripComments).option("transpilationMode", _chunk6NJAXMSBjs.builders_default.transpilationMode).option("depsToTranspile", _chunk6NJAXMSBjs.builders_default.depsToTranspile).option("manifest", _chunk6NJAXMSBjs.builders_default.manifest).option("writeManifest", _chunk6NJAXMSBjs.builders_default.writeManifest).option("serve", _chunk6NJAXMSBjs.builders_default.serve).option("root", _chunk6NJAXMSBjs.builders_default.root).option("port", _chunk6NJAXMSBjs.builders_default.port).implies("writeManifest", "manifest").implies("depsToTranspile", "transpilationMode");
|
|
14
|
+
},
|
|
15
|
+
handler: async (argv) => _chunk4NHBPMKTjs.watchHandler.call(void 0, argv.context.config, {
|
|
16
|
+
port: argv.port
|
|
17
|
+
})
|
|
18
|
+
};
|
|
19
|
+
var watch_default = command;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
exports.watch_default = watch_default;
|
|
24
|
+
//# sourceMappingURL=chunk-5JPLNWCO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/watch/index.ts"],"names":[],"mappings":";;;;;;;;AAMA,IAAM,UAAU;AAAA,EACd,SAAS,CAAC,SAAS,GAAG;AAAA,EACtB,MAAM;AAAA,EACN,SAAS,CAAC,SAAqB;AAC7B,SACG,OAAO,OAAO,iBAAS,GAAG,EAC1B,OAAO,QAAQ,iBAAS,IAAI,EAC5B,OAAO,QAAQ,iBAAS,IAAI,EAC5B,OAAO,eAAe,iBAAS,WAAW,EAC1C,OAAO,cAAc,iBAAS,UAAU,EACxC,OAAO,iBAAiB,iBAAS,aAAa,EAC9C,OAAO,qBAAqB,iBAAS,iBAAiB,EACtD,OAAO,mBAAmB,iBAAS,eAAe,EAClD,OAAO,YAAY,iBAAS,QAAQ,EACpC,OAAO,iBAAiB,iBAAS,aAAa,EAC9C,OAAO,SAAS,iBAAS,KAAK,EAC9B,OAAO,QAAQ,iBAAS,IAAI,EAC5B,OAAO,QAAQ,iBAAS,IAAI,EAC5B,QAAQ,iBAAiB,UAAU,EACnC,QAAQ,mBAAmB,mBAAmB;AAAA,EACnD;AAAA,EACA,SAAS,OAAO,SACd,aAAa,KAAK,QAAQ,QAAQ;AAAA,IAChC,MAAM,KAAK;AAAA,EACb,CAAC;AACL;AAGA,IAAO,gBAAQ","sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { watchHandler } from './watch';\n\nconst command = {\n command: ['watch', 'w'],\n desc: 'Build Snap on change',\n builder: (yarg: yargs.Argv) => {\n yarg\n .option('src', builders.src)\n .option('eval', builders.eval)\n .option('dist', builders.dist)\n .option('outfileName', builders.outfileName)\n .option('sourceMaps', builders.sourceMaps)\n .option('stripComments', builders.stripComments)\n .option('transpilationMode', builders.transpilationMode)\n .option('depsToTranspile', builders.depsToTranspile)\n .option('manifest', builders.manifest)\n .option('writeManifest', builders.writeManifest)\n .option('serve', builders.serve)\n .option('root', builders.root)\n .option('port', builders.port)\n .implies('writeManifest', 'manifest')\n .implies('depsToTranspile', 'transpilationMode');\n },\n handler: async (argv: YargsArgs) =>\n watchHandler(argv.context.config, {\n port: argv.port,\n }),\n};\n\nexport * from './implementation';\nexport default command;\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/webpack/loaders/wasm.ts
|
|
2
|
+
var _utils = require('@metamask/utils');
|
|
3
|
+
var _path = require('path');
|
|
4
|
+
function getImports(importMap) {
|
|
5
|
+
return Object.entries(importMap).map(
|
|
6
|
+
([moduleName, exportNames]) => `import { ${exportNames.join(", ")} } from ${JSON.stringify(
|
|
7
|
+
moduleName
|
|
8
|
+
)};`
|
|
9
|
+
).join("\n");
|
|
10
|
+
}
|
|
11
|
+
function getModuleImports(importMap) {
|
|
12
|
+
return Object.entries(importMap).map(
|
|
13
|
+
([moduleName, exportNames]) => `${JSON.stringify(moduleName)}: { ${exportNames.join(", ")} },`
|
|
14
|
+
).join("\n");
|
|
15
|
+
}
|
|
16
|
+
function getExports(descriptors) {
|
|
17
|
+
return descriptors.map((descriptor) => {
|
|
18
|
+
if (descriptor.name === "default") {
|
|
19
|
+
return `export default exports[${JSON.stringify(descriptor.name)}];`;
|
|
20
|
+
}
|
|
21
|
+
return `export const ${descriptor.name} = exports[${JSON.stringify(
|
|
22
|
+
descriptor.name
|
|
23
|
+
)}];`;
|
|
24
|
+
}).join("\n");
|
|
25
|
+
}
|
|
26
|
+
var loader = async function loader2(source) {
|
|
27
|
+
_utils.assert.call(void 0, source instanceof Uint8Array, "Expected source to be a Uint8Array.");
|
|
28
|
+
const bytes = new Uint8Array(source);
|
|
29
|
+
const wasmModule = await WebAssembly.compile(bytes);
|
|
30
|
+
const exports = WebAssembly.Module.exports(wasmModule);
|
|
31
|
+
const imports = WebAssembly.Module.imports(wasmModule).reduce((target, descriptor) => {
|
|
32
|
+
var _a;
|
|
33
|
+
_nullishCoalesce(target[_a = descriptor.module], () => ( (target[_a] = [])));
|
|
34
|
+
target[descriptor.module].push(descriptor.name);
|
|
35
|
+
return target;
|
|
36
|
+
}, {});
|
|
37
|
+
const path = _path.dirname.call(void 0, this.resourcePath);
|
|
38
|
+
for (const name of Object.keys(imports)) {
|
|
39
|
+
this.addDependency(_path.resolve.call(void 0, path, name));
|
|
40
|
+
}
|
|
41
|
+
return `
|
|
42
|
+
${getImports(imports)}
|
|
43
|
+
|
|
44
|
+
const bytes = new Uint8Array(${JSON.stringify(Array.from(source))});
|
|
45
|
+
const module = new WebAssembly.Module(bytes);
|
|
46
|
+
const instance = new WebAssembly.Instance(module, {
|
|
47
|
+
${getModuleImports(imports)}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const exports = instance.exports;
|
|
51
|
+
${getExports(exports)}
|
|
52
|
+
`;
|
|
53
|
+
};
|
|
54
|
+
var wasm_default = loader;
|
|
55
|
+
var raw = true;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
exports.getImports = getImports; exports.getModuleImports = getModuleImports; exports.getExports = getExports; exports.wasm_default = wasm_default; exports.raw = raw;
|
|
64
|
+
//# sourceMappingURL=chunk-5VAZH7L7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webpack/loaders/wasm.ts"],"names":["loader"],"mappings":";AAEA,SAAS,cAAc;AACvB,SAAS,SAAS,eAAe;AAU1B,SAAS,WAAW,WAAqC;AAC9D,SAAO,OAAO,QAAQ,SAAS,EAC5B;AAAA,IACC,CAAC,CAAC,YAAY,WAAW,MACvB,YAAY,YAAY,KAAK,IAAI,CAAC,WAAW,KAAK;AAAA,MAChD;AAAA,IACF,CAAC;AAAA,EACL,EACC,KAAK,IAAI;AACd;AASO,SAAS,iBAAiB,WAAqC;AACpE,SAAO,OAAO,QAAQ,SAAS,EAC5B;AAAA,IACC,CAAC,CAAC,YAAY,WAAW,MACvB,GAAG,KAAK,UAAU,UAAU,CAAC,OAAO,YAAY,KAAK,IAAI,CAAC;AAAA,EAC9D,EACC,KAAK,IAAI;AACd;AAUO,SAAS,WAAW,aAAmD;AAC5E,SAAO,YACJ,IAAI,CAAC,eAAe;AACnB,QAAI,WAAW,SAAS,WAAW;AACjC,aAAO,0BAA0B,KAAK,UAAU,WAAW,IAAI,CAAC;AAAA,IAClE;AAEA,WAAO,gBAAgB,WAAW,IAAI,cAAc,KAAK;AAAA,MACvD,WAAW;AAAA,IACb,CAAC;AAAA,EACH,CAAC,EACA,KAAK,IAAI;AACd;AAiBA,IAAM,SAAmC,eAAeA,QACtD,QACA;AACA,SAAO,kBAAkB,YAAY,qCAAqC;AAE1E,QAAM,QAAQ,IAAI,WAAW,MAAM;AACnC,QAAM,aAAa,MAAM,YAAY,QAAQ,KAAK;AAGlD,QAAM,UAAU,YAAY,OAAO,QAAQ,UAAU;AACrD,QAAM,UAAU,YAAY,OAAO,QAAQ,UAAU,EAAE,OAErD,CAAC,QAAQ,eAAe;AAzF5B;AA0FI,gBAAO,WAAW,YAAlB,aAA8B,CAAC;AAC/B,WAAO,WAAW,MAAM,EAAE,KAAK,WAAW,IAAI;AAE9C,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AAIL,QAAM,OAAO,QAAQ,KAAK,YAAY;AACtC,aAAW,QAAQ,OAAO,KAAK,OAAO,GAAG;AACvC,SAAK,cAAc,QAAQ,MAAM,IAAI,CAAC;AAAA,EACxC;AAEA,SAAO;AAAA,MACH,WAAW,OAAO,CAAC;AAAA;AAAA,mCAEU,KAAK,UAAU,MAAM,KAAK,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA,QAG7D,iBAAiB,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA,MAI3B,WAAW,OAAO,CAAC;AAAA;AAEzB;AAEA,IAAO,eAAQ;AAKR,IAAM,MAAM","sourcesContent":["/* eslint-disable no-restricted-globals */\n\nimport { assert } from '@metamask/utils';\nimport { dirname, resolve } from 'path';\nimport type { LoaderDefinitionFunction } from 'webpack';\n\n/**\n * Get the imports code for the WASM module. This code imports each of the\n * imports from the WASM module.\n *\n * @param importMap - The import map for the WASM module.\n * @returns The imports code for the WASM module.\n */\nexport function getImports(importMap: Record<string, string[]>) {\n return Object.entries(importMap)\n .map(\n ([moduleName, exportNames]) =>\n `import { ${exportNames.join(', ')} } from ${JSON.stringify(\n moduleName,\n )};`,\n )\n .join('\\n');\n}\n\n/**\n * Get the imports code to use in `WebAssembly.Instance`. This code adds each of\n * the imports to the `imports` object.\n *\n * @param importMap - The import map for the WASM module.\n * @returns The imports code for the WASM module.\n */\nexport function getModuleImports(importMap: Record<string, string[]>) {\n return Object.entries(importMap)\n .map(\n ([moduleName, exportNames]) =>\n `${JSON.stringify(moduleName)}: { ${exportNames.join(', ')} },`,\n )\n .join('\\n');\n}\n\n/**\n * Get the exports code for the WASM module. This code exports each of the\n * exports from the WASM module as a variable. This function assumes that the\n * exports are available in a variable named `exports`.\n *\n * @param descriptors - The export descriptors from the WASM module.\n * @returns The exports code for the WASM module.\n */\nexport function getExports(descriptors: WebAssembly.ModuleExportDescriptor[]) {\n return descriptors\n .map((descriptor) => {\n if (descriptor.name === 'default') {\n return `export default exports[${JSON.stringify(descriptor.name)}];`;\n }\n\n return `export const ${descriptor.name} = exports[${JSON.stringify(\n descriptor.name,\n )}];`;\n })\n .join('\\n');\n}\n\n/**\n * A Webpack loader that synchronously loads the WASM module. This makes it\n * possible to import the WASM module directly.\n *\n * @param source - The WASM module as `Uint8Array`.\n * @returns The WASM module as a JavaScript string.\n * @example\n * ```ts\n * import * as wasm from './program.wasm';\n *\n * // Do something with the WASM module...\n * ```\n */\n// Note: This function needs to be defined like this, so that Webpack can bind\n// `this` to the loader context, and TypeScript can infer the type of `this`.\nconst loader: LoaderDefinitionFunction = async function loader(\n source: unknown,\n) {\n assert(source instanceof Uint8Array, 'Expected source to be a Uint8Array.');\n\n const bytes = new Uint8Array(source);\n const wasmModule = await WebAssembly.compile(bytes);\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const exports = WebAssembly.Module.exports(wasmModule);\n const imports = WebAssembly.Module.imports(wasmModule).reduce<\n Record<string, string[]>\n >((target, descriptor) => {\n target[descriptor.module] ??= [];\n target[descriptor.module].push(descriptor.name);\n\n return target;\n }, {});\n\n // Add the WASM import as a dependency so that Webpack will watch it for\n // changes.\n const path = dirname(this.resourcePath);\n for (const name of Object.keys(imports)) {\n this.addDependency(resolve(path, name));\n }\n\n return `\n ${getImports(imports)}\n\n const bytes = new Uint8Array(${JSON.stringify(Array.from(source))});\n const module = new WebAssembly.Module(bytes);\n const instance = new WebAssembly.Instance(module, {\n ${getModuleImports(imports)}\n });\n\n const exports = instance.exports;\n ${getExports(exports)}\n `;\n};\n\nexport default loader;\n\n// By setting `raw` to `true`, we are telling Webpack to provide the source as a\n// `Uint8Array` instead of converting it to a string. This allows us to avoid\n// having to convert the source back to a `Uint8Array` in the loader.\nexport const raw = true;\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkNO53G7NTjs = require('./chunk-NO53G7NT.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk6NJAXMSBjs = require('./chunk-6NJAXMSB.js');
|
|
7
|
+
|
|
8
|
+
// src/commands/build/index.ts
|
|
9
|
+
var command = {
|
|
10
|
+
command: ["build", "b"],
|
|
11
|
+
desc: "Build snap from source",
|
|
12
|
+
builder: (yarg) => {
|
|
13
|
+
yarg.option("dist", _chunk6NJAXMSBjs.builders_default.dist).option("eval", _chunk6NJAXMSBjs.builders_default.eval).option("manifest", _chunk6NJAXMSBjs.builders_default.manifest).option("outfileName", _chunk6NJAXMSBjs.builders_default.outfileName).option("sourceMaps", _chunk6NJAXMSBjs.builders_default.sourceMaps).option("src", _chunk6NJAXMSBjs.builders_default.src).option("stripComments", _chunk6NJAXMSBjs.builders_default.stripComments).option("transpilationMode", _chunk6NJAXMSBjs.builders_default.transpilationMode).option("depsToTranspile", _chunk6NJAXMSBjs.builders_default.depsToTranspile).option("writeManifest", _chunk6NJAXMSBjs.builders_default.writeManifest).implies("writeManifest", "manifest").implies("depsToTranspile", "transpilationMode");
|
|
14
|
+
},
|
|
15
|
+
handler: async (argv) => _chunkNO53G7NTjs.buildHandler.call(void 0, argv.context.config)
|
|
16
|
+
};
|
|
17
|
+
var build_default = command;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.build_default = build_default;
|
|
22
|
+
//# sourceMappingURL=chunk-5YUHRLH6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/build/index.ts"],"names":[],"mappings":";;;;;;;;AAMA,IAAM,UAAU;AAAA,EACd,SAAS,CAAC,SAAS,GAAG;AAAA,EACtB,MAAM;AAAA,EACN,SAAS,CAAC,SAAqB;AAC7B,SACG,OAAO,QAAQ,iBAAS,IAAI,EAC5B,OAAO,QAAQ,iBAAS,IAAI,EAC5B,OAAO,YAAY,iBAAS,QAAQ,EACpC,OAAO,eAAe,iBAAS,WAAW,EAC1C,OAAO,cAAc,iBAAS,UAAU,EACxC,OAAO,OAAO,iBAAS,GAAG,EAC1B,OAAO,iBAAiB,iBAAS,aAAa,EAC9C,OAAO,qBAAqB,iBAAS,iBAAiB,EACtD,OAAO,mBAAmB,iBAAS,eAAe,EAClD,OAAO,iBAAiB,iBAAS,aAAa,EAC9C,QAAQ,iBAAiB,UAAU,EACnC,QAAQ,mBAAmB,mBAAmB;AAAA,EACnD;AAAA,EACA,SAAS,OAAO,SAAoB,aAAa,KAAK,QAAQ,MAAM;AACtE;AAGA,IAAO,gBAAQ","sourcesContent":["import type yargs from 'yargs';\n\nimport builders from '../../builders';\nimport type { YargsArgs } from '../../types/yargs';\nimport { buildHandler } from './build';\n\nconst command = {\n command: ['build', 'b'],\n desc: 'Build snap from source',\n builder: (yarg: yargs.Argv) => {\n yarg\n .option('dist', builders.dist)\n .option('eval', builders.eval)\n .option('manifest', builders.manifest)\n .option('outfileName', builders.outfileName)\n .option('sourceMaps', builders.sourceMaps)\n .option('src', builders.src)\n .option('stripComments', builders.stripComments)\n .option('transpilationMode', builders.transpilationMode)\n .option('depsToTranspile', builders.depsToTranspile)\n .option('writeManifest', builders.writeManifest)\n .implies('writeManifest', 'manifest')\n .implies('depsToTranspile', 'transpilationMode');\n },\n handler: async (argv: YargsArgs) => buildHandler(argv.context.config),\n};\n\nexport * from './implementation';\nexport default command;\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/structs.ts
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
import { coerce, string } from "superstruct";
|
|
4
|
+
function file() {
|
|
5
|
+
return coerce(string(), string(), (value) => {
|
|
6
|
+
return resolve(process.cwd(), value);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
file
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-6IF2UBYA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/structs.ts"],"sourcesContent":["import { resolve } from 'path';\nimport { coerce, string } from 'superstruct';\n\n/**\n * A wrapper of `superstruct`'s `string` struct that coerces a value to a string\n * and resolves it relative to the current working directory. This is useful\n * for specifying file paths in a configuration file, as it allows the user to\n * use both relative and absolute paths.\n *\n * @returns The `superstruct` struct, which validates that the value is a\n * string, and resolves it relative to the current working directory.\n * @example\n * ```ts\n * const config = struct({\n * file: file(),\n * // ...\n * });\n *\n * const value = create({ file: 'path/to/file' }, config);\n * console.log(value.file); // /process/cwd/path/to/file\n * ```\n */\nexport function file() {\n return coerce(string(), string(), (value) => {\n return resolve(process.cwd(), value);\n });\n}\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,QAAQ,cAAc;AAqBxB,SAAS,OAAO;AACrB,SAAO,OAAO,OAAO,GAAG,OAAO,GAAG,CAAC,UAAU;AAC3C,WAAO,QAAQ,QAAQ,IAAI,GAAG,KAAK;AAAA,EACrC,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/builders.ts
|
|
2
|
+
var TranspilationModes = /* @__PURE__ */ ((TranspilationModes2) => {
|
|
3
|
+
TranspilationModes2["LocalAndDeps"] = "localAndDeps";
|
|
4
|
+
TranspilationModes2["LocalOnly"] = "localOnly";
|
|
5
|
+
TranspilationModes2["None"] = "none";
|
|
6
|
+
return TranspilationModes2;
|
|
7
|
+
})(TranspilationModes || {});
|
|
8
|
+
var builders = {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10
|
+
config: {
|
|
11
|
+
alias: "c",
|
|
12
|
+
describe: "Path to config file",
|
|
13
|
+
type: "string",
|
|
14
|
+
normalize: true
|
|
15
|
+
},
|
|
16
|
+
fix: {
|
|
17
|
+
describe: "Attempt to fix snap.manifest.json",
|
|
18
|
+
type: "boolean"
|
|
19
|
+
},
|
|
20
|
+
input: {
|
|
21
|
+
alias: "i",
|
|
22
|
+
describe: "Snap bundle file to evaluate",
|
|
23
|
+
type: "string",
|
|
24
|
+
normalize: true
|
|
25
|
+
},
|
|
26
|
+
// Deprecated Browserify options.
|
|
27
|
+
bundle: {
|
|
28
|
+
alias: "b",
|
|
29
|
+
describe: "Snap bundle file",
|
|
30
|
+
type: "string",
|
|
31
|
+
normalize: true,
|
|
32
|
+
deprecated: "Use --input instead."
|
|
33
|
+
},
|
|
34
|
+
dist: {
|
|
35
|
+
alias: "d",
|
|
36
|
+
describe: "Output directory",
|
|
37
|
+
type: "string",
|
|
38
|
+
normalize: true,
|
|
39
|
+
deprecated: true
|
|
40
|
+
},
|
|
41
|
+
eval: {
|
|
42
|
+
alias: "e",
|
|
43
|
+
describe: "Attempt to evaluate Snap bundle in SES",
|
|
44
|
+
type: "boolean",
|
|
45
|
+
deprecated: true
|
|
46
|
+
},
|
|
47
|
+
manifest: {
|
|
48
|
+
alias: "m",
|
|
49
|
+
describe: "Validate snap.manifest.json",
|
|
50
|
+
type: "boolean",
|
|
51
|
+
deprecated: true
|
|
52
|
+
},
|
|
53
|
+
port: {
|
|
54
|
+
alias: "p",
|
|
55
|
+
describe: "Local server port for testing",
|
|
56
|
+
type: "number",
|
|
57
|
+
coerce: (arg) => {
|
|
58
|
+
const port = Number.parseInt(String(arg), 10);
|
|
59
|
+
if (Number.isNaN(port)) {
|
|
60
|
+
throw new Error(`Invalid port: "${String(arg)}".`);
|
|
61
|
+
}
|
|
62
|
+
return port;
|
|
63
|
+
},
|
|
64
|
+
deprecated: true
|
|
65
|
+
},
|
|
66
|
+
outfileName: {
|
|
67
|
+
alias: "n",
|
|
68
|
+
describe: "Output file name",
|
|
69
|
+
type: "string",
|
|
70
|
+
deprecated: true
|
|
71
|
+
},
|
|
72
|
+
root: {
|
|
73
|
+
alias: "r",
|
|
74
|
+
describe: "Server root directory",
|
|
75
|
+
type: "string",
|
|
76
|
+
normalize: true,
|
|
77
|
+
deprecated: true
|
|
78
|
+
},
|
|
79
|
+
sourceMaps: {
|
|
80
|
+
describe: "Whether builds include sourcemaps",
|
|
81
|
+
type: "boolean",
|
|
82
|
+
deprecated: true
|
|
83
|
+
},
|
|
84
|
+
src: {
|
|
85
|
+
alias: "s",
|
|
86
|
+
describe: "Source file",
|
|
87
|
+
type: "string",
|
|
88
|
+
normalize: true,
|
|
89
|
+
deprecated: true
|
|
90
|
+
},
|
|
91
|
+
stripComments: {
|
|
92
|
+
alias: "strip",
|
|
93
|
+
describe: "Whether to remove code comments from the build output",
|
|
94
|
+
type: "boolean",
|
|
95
|
+
deprecated: true
|
|
96
|
+
},
|
|
97
|
+
suppressWarnings: {
|
|
98
|
+
type: "boolean",
|
|
99
|
+
describe: "Whether to suppress warnings",
|
|
100
|
+
deprecated: true
|
|
101
|
+
},
|
|
102
|
+
transpilationMode: {
|
|
103
|
+
type: "string",
|
|
104
|
+
describe: "Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing",
|
|
105
|
+
choices: Object.values(TranspilationModes),
|
|
106
|
+
deprecated: true
|
|
107
|
+
},
|
|
108
|
+
depsToTranspile: {
|
|
109
|
+
type: "array",
|
|
110
|
+
describe: "Transpile only the listed dependencies.",
|
|
111
|
+
deprecated: true
|
|
112
|
+
},
|
|
113
|
+
verboseErrors: {
|
|
114
|
+
type: "boolean",
|
|
115
|
+
describe: "Display original errors",
|
|
116
|
+
deprecated: true
|
|
117
|
+
},
|
|
118
|
+
writeManifest: {
|
|
119
|
+
describe: "Make necessary changes to the snap manifest file",
|
|
120
|
+
type: "boolean",
|
|
121
|
+
deprecated: true
|
|
122
|
+
},
|
|
123
|
+
serve: {
|
|
124
|
+
describe: "Serve snap file(s) locally for testing",
|
|
125
|
+
type: "boolean",
|
|
126
|
+
deprecated: true
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var builders_default = builders;
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
exports.TranspilationModes = TranspilationModes; exports.builders_default = builders_default;
|
|
135
|
+
//# sourceMappingURL=chunk-6NJAXMSB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/builders.ts"],"names":["TranspilationModes"],"mappings":";AAEO,IAAK,qBAAL,kBAAKA,wBAAL;AACL,EAAAA,oBAAA,kBAAe;AACf,EAAAA,oBAAA,eAAY;AACZ,EAAAA,oBAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AAMZ,IAAM,WAA8C;AAAA;AAAA,EAElD,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA,EAEA,KAAK;AAAA,IACH,UAAU;AAAA,IACV,MAAM;AAAA,EACR;AAAA,EAEA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA;AAAA,EAGA,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EAEA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EAEA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,EACd;AAAA,EAEA,UAAU;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,EACd;AAAA,EAEA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ,CAAC,QAAiB;AACxB,YAAM,OAAO,OAAO,SAAS,OAAO,GAAG,GAAG,EAAE;AAC5C,UAAI,OAAO,MAAM,IAAI,GAAG;AACtB,cAAM,IAAI,MAAM,kBAAkB,OAAO,GAAG,CAAC,IAAI;AAAA,MACnD;AAEA,aAAO;AAAA,IACT;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EAEA,aAAa;AAAA,IACX,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,EACd;AAAA,EAEA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EAEA,YAAY;AAAA,IACV,UAAU;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,EACd;AAAA,EAEA,KAAK;AAAA,IACH,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EAEA,eAAe;AAAA,IACb,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,EACd;AAAA,EAEA,kBAAkB;AAAA,IAChB,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AAAA,EAEA,mBAAmB;AAAA,IACjB,MAAM;AAAA,IACN,UACE;AAAA,IACF,SAAS,OAAO,OAAO,kBAAkB;AAAA,IACzC,YAAY;AAAA,EACd;AAAA,EAEA,iBAAiB;AAAA,IACf,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AAAA,EAEA,eAAe;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AAAA,EAEA,eAAe;AAAA,IACb,UAAU;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,EACd;AAAA,EAEA,OAAO;AAAA,IACL,UAAU;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,EACd;AACF;AAEA,IAAO,mBAAQ","sourcesContent":["import type { Options } from 'yargs';\n\nexport enum TranspilationModes {\n LocalAndDeps = 'localAndDeps',\n LocalOnly = 'localOnly',\n None = 'none',\n}\n\nconst builders: Record<string, Readonly<Options>> = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n config: {\n alias: 'c',\n describe: 'Path to config file',\n type: 'string',\n normalize: true,\n },\n\n fix: {\n describe: 'Attempt to fix snap.manifest.json',\n type: 'boolean',\n },\n\n input: {\n alias: 'i',\n describe: 'Snap bundle file to evaluate',\n type: 'string',\n normalize: true,\n },\n\n // Deprecated Browserify options.\n bundle: {\n alias: 'b',\n describe: 'Snap bundle file',\n type: 'string',\n normalize: true,\n deprecated: 'Use --input instead.',\n },\n\n dist: {\n alias: 'd',\n describe: 'Output directory',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n eval: {\n alias: 'e',\n describe: 'Attempt to evaluate Snap bundle in SES',\n type: 'boolean',\n deprecated: true,\n },\n\n manifest: {\n alias: 'm',\n describe: 'Validate snap.manifest.json',\n type: 'boolean',\n deprecated: true,\n },\n\n port: {\n alias: 'p',\n describe: 'Local server port for testing',\n type: 'number',\n coerce: (arg: unknown) => {\n const port = Number.parseInt(String(arg), 10);\n if (Number.isNaN(port)) {\n throw new Error(`Invalid port: \"${String(arg)}\".`);\n }\n\n return port;\n },\n deprecated: true,\n },\n\n outfileName: {\n alias: 'n',\n describe: 'Output file name',\n type: 'string',\n deprecated: true,\n },\n\n root: {\n alias: 'r',\n describe: 'Server root directory',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n sourceMaps: {\n describe: 'Whether builds include sourcemaps',\n type: 'boolean',\n deprecated: true,\n },\n\n src: {\n alias: 's',\n describe: 'Source file',\n type: 'string',\n normalize: true,\n deprecated: true,\n },\n\n stripComments: {\n alias: 'strip',\n describe: 'Whether to remove code comments from the build output',\n type: 'boolean',\n deprecated: true,\n },\n\n suppressWarnings: {\n type: 'boolean',\n describe: 'Whether to suppress warnings',\n deprecated: true,\n },\n\n transpilationMode: {\n type: 'string',\n describe:\n 'Whether to use Babel to transpile all source code (including dependencies), local source code only, or nothing',\n choices: Object.values(TranspilationModes),\n deprecated: true,\n },\n\n depsToTranspile: {\n type: 'array',\n describe: 'Transpile only the listed dependencies.',\n deprecated: true,\n },\n\n verboseErrors: {\n type: 'boolean',\n describe: 'Display original errors',\n deprecated: true,\n },\n\n writeManifest: {\n describe: 'Make necessary changes to the snap manifest file',\n type: 'boolean',\n deprecated: true,\n },\n\n serve: {\n describe: 'Serve snap file(s) locally for testing',\n type: 'boolean',\n deprecated: true,\n },\n};\n\nexport default builders;\n"]}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// src/webpack/server.ts
|
|
2
|
+
import {
|
|
3
|
+
logError,
|
|
4
|
+
NpmSnapFileNames,
|
|
5
|
+
readJsonFile
|
|
6
|
+
} from "@metamask/snaps-utils/node";
|
|
7
|
+
import { createServer } from "http";
|
|
8
|
+
import { join, relative, resolve as resolvePath, sep, posix } from "path";
|
|
9
|
+
import serveMiddleware from "serve-handler";
|
|
10
|
+
function getRelativePath(from, to) {
|
|
11
|
+
return relative(from, to).split(sep).join(posix.sep);
|
|
12
|
+
}
|
|
13
|
+
function getAllowedPaths(config, manifest) {
|
|
14
|
+
const auxiliaryFiles = manifest.source.files?.map(
|
|
15
|
+
(file) => getRelativePath(
|
|
16
|
+
config.server.root,
|
|
17
|
+
resolvePath(config.server.root, file)
|
|
18
|
+
)
|
|
19
|
+
) ?? [];
|
|
20
|
+
const localizationFiles = manifest.source.locales?.map(
|
|
21
|
+
(localization) => getRelativePath(
|
|
22
|
+
config.server.root,
|
|
23
|
+
resolvePath(config.server.root, localization)
|
|
24
|
+
)
|
|
25
|
+
) ?? [];
|
|
26
|
+
const otherFiles = manifest.source.location.npm.iconPath ? [
|
|
27
|
+
getRelativePath(
|
|
28
|
+
config.server.root,
|
|
29
|
+
resolvePath(
|
|
30
|
+
config.server.root,
|
|
31
|
+
manifest.source.location.npm.iconPath
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
] : [];
|
|
35
|
+
return [
|
|
36
|
+
getRelativePath(
|
|
37
|
+
config.server.root,
|
|
38
|
+
resolvePath(
|
|
39
|
+
config.server.root,
|
|
40
|
+
config.output.path,
|
|
41
|
+
config.output.filename
|
|
42
|
+
)
|
|
43
|
+
),
|
|
44
|
+
getRelativePath(
|
|
45
|
+
config.server.root,
|
|
46
|
+
resolvePath(config.server.root, NpmSnapFileNames.Manifest)
|
|
47
|
+
),
|
|
48
|
+
...auxiliaryFiles,
|
|
49
|
+
...localizationFiles,
|
|
50
|
+
...otherFiles
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
function getServer(config) {
|
|
54
|
+
async function getResponse(request, response) {
|
|
55
|
+
const manifestPath = join(config.server.root, NpmSnapFileNames.Manifest);
|
|
56
|
+
const { result } = await readJsonFile(manifestPath);
|
|
57
|
+
const allowedPaths = getAllowedPaths(config, result);
|
|
58
|
+
const path = request.url?.slice(1);
|
|
59
|
+
const allowed = allowedPaths.some((allowedPath) => path === allowedPath);
|
|
60
|
+
if (!allowed) {
|
|
61
|
+
response.statusCode = 404;
|
|
62
|
+
response.end();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
await serveMiddleware(request, response, {
|
|
66
|
+
public: config.server.root,
|
|
67
|
+
directoryListing: false,
|
|
68
|
+
headers: [
|
|
69
|
+
{
|
|
70
|
+
source: "**/*",
|
|
71
|
+
headers: [
|
|
72
|
+
{
|
|
73
|
+
key: "Cache-Control",
|
|
74
|
+
value: "no-cache"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
key: "Access-Control-Allow-Origin",
|
|
78
|
+
value: "*"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const server = createServer((request, response) => {
|
|
86
|
+
getResponse(request, response).catch(
|
|
87
|
+
/* istanbul ignore next */
|
|
88
|
+
(error) => {
|
|
89
|
+
logError(error);
|
|
90
|
+
response.statusCode = 500;
|
|
91
|
+
response.end();
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
const listen = async (port = config.server.port) => {
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
try {
|
|
98
|
+
server.listen(port, () => {
|
|
99
|
+
const close = async () => {
|
|
100
|
+
await new Promise((resolveClose, rejectClose) => {
|
|
101
|
+
server.close((closeError) => {
|
|
102
|
+
if (closeError) {
|
|
103
|
+
return rejectClose(closeError);
|
|
104
|
+
}
|
|
105
|
+
return resolveClose();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
const address = server.address();
|
|
110
|
+
resolve({ port: address.port, server, close });
|
|
111
|
+
});
|
|
112
|
+
} catch (listenError) {
|
|
113
|
+
reject(listenError);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
return { listen };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
getAllowedPaths,
|
|
122
|
+
getServer
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=chunk-6VFUO2H5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webpack/server.ts"],"sourcesContent":["import type { SnapManifest } from '@metamask/snaps-utils';\nimport {\n logError,\n NpmSnapFileNames,\n readJsonFile,\n} from '@metamask/snaps-utils/node';\nimport type { IncomingMessage, Server, ServerResponse } from 'http';\nimport { createServer } from 'http';\nimport type { AddressInfo } from 'net';\nimport { join, relative, resolve as resolvePath, sep, posix } from 'path';\nimport serveMiddleware from 'serve-handler';\n\nimport type { ProcessedConfig } from '../config';\n\n/**\n * Get the relative path from one path to another.\n *\n * Note: This is a modified version of `path.relative` that uses Posix\n * separators for URL-compatibility.\n *\n * @param from - The path to start from.\n * @param to - The path to end at.\n * @returns The relative path.\n */\nfunction getRelativePath(from: string, to: string) {\n return relative(from, to).split(sep).join(posix.sep);\n}\n\n/**\n * Get the allowed paths for the static server. This includes the output file,\n * the manifest file, and any auxiliary/localization files.\n *\n * @param config - The config object.\n * @param manifest - The Snap manifest object.\n * @returns An array of allowed paths.\n */\nexport function getAllowedPaths(\n config: ProcessedConfig,\n manifest: SnapManifest,\n) {\n const auxiliaryFiles =\n manifest.source.files?.map((file) =>\n getRelativePath(\n config.server.root,\n resolvePath(config.server.root, file),\n ),\n ) ?? [];\n\n const localizationFiles =\n manifest.source.locales?.map((localization) =>\n getRelativePath(\n config.server.root,\n resolvePath(config.server.root, localization),\n ),\n ) ?? [];\n\n const otherFiles = manifest.source.location.npm.iconPath\n ? [\n getRelativePath(\n config.server.root,\n resolvePath(\n config.server.root,\n manifest.source.location.npm.iconPath,\n ),\n ),\n ]\n : [];\n\n return [\n getRelativePath(\n config.server.root,\n resolvePath(\n config.server.root,\n config.output.path,\n config.output.filename,\n ),\n ),\n getRelativePath(\n config.server.root,\n resolvePath(config.server.root, NpmSnapFileNames.Manifest),\n ),\n ...auxiliaryFiles,\n ...localizationFiles,\n ...otherFiles,\n ];\n}\n\n/**\n * Get a static server for development purposes.\n *\n * Note: We're intentionally not using `webpack-dev-server` here because it\n * adds a lot of extra stuff to the output that we don't need, and it's\n * difficult to customize.\n *\n * @param config - The config object.\n * @returns An object with a `listen` method that returns a promise that\n * resolves when the server is listening.\n */\nexport function getServer(config: ProcessedConfig) {\n /**\n * Get the response for a request. This is extracted into a function so that\n * we can easily catch errors and send a 500 response.\n *\n * @param request - The request.\n * @param response - The response.\n * @returns A promise that resolves when the response is sent.\n */\n async function getResponse(\n request: IncomingMessage,\n response: ServerResponse,\n ) {\n const manifestPath = join(config.server.root, NpmSnapFileNames.Manifest);\n const { result } = await readJsonFile<SnapManifest>(manifestPath);\n const allowedPaths = getAllowedPaths(config, result);\n\n const path = request.url?.slice(1);\n const allowed = allowedPaths.some((allowedPath) => path === allowedPath);\n\n if (!allowed) {\n response.statusCode = 404;\n response.end();\n return;\n }\n\n await serveMiddleware(request, response, {\n public: config.server.root,\n directoryListing: false,\n headers: [\n {\n source: '**/*',\n headers: [\n {\n key: 'Cache-Control',\n value: 'no-cache',\n },\n {\n key: 'Access-Control-Allow-Origin',\n value: '*',\n },\n ],\n },\n ],\n });\n }\n\n const server = createServer((request, response) => {\n getResponse(request, response).catch(\n /* istanbul ignore next */\n (error) => {\n logError(error);\n response.statusCode = 500;\n response.end();\n },\n );\n });\n\n /**\n * Start the server on the port specified in the config.\n *\n * @param port - The port to listen on.\n * @returns A promise that resolves when the server is listening. The promise\n * resolves to an object with the port and the server instance. Note that if\n * the `config.server.port` is `0`, the OS will choose a random port for us,\n * so we need to get the port from the server after it starts.\n */\n const listen = async (port = config.server.port) => {\n return new Promise<{\n port: number;\n server: Server;\n close: () => Promise<void>;\n }>((resolve, reject) => {\n try {\n server.listen(port, () => {\n const close = async () => {\n await new Promise<void>((resolveClose, rejectClose) => {\n server.close((closeError) => {\n if (closeError) {\n return rejectClose(closeError);\n }\n\n return resolveClose();\n });\n });\n };\n\n const address = server.address() as AddressInfo;\n resolve({ port: address.port, server, close });\n });\n } catch (listenError) {\n reject(listenError);\n }\n });\n };\n\n return { listen };\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,oBAAoB;AAE7B,SAAS,MAAM,UAAU,WAAW,aAAa,KAAK,aAAa;AACnE,OAAO,qBAAqB;AAc5B,SAAS,gBAAgB,MAAc,IAAY;AACjD,SAAO,SAAS,MAAM,EAAE,EAAE,MAAM,GAAG,EAAE,KAAK,MAAM,GAAG;AACrD;AAUO,SAAS,gBACd,QACA,UACA;AACA,QAAM,iBACJ,SAAS,OAAO,OAAO;AAAA,IAAI,CAAC,SAC1B;AAAA,MACE,OAAO,OAAO;AAAA,MACd,YAAY,OAAO,OAAO,MAAM,IAAI;AAAA,IACtC;AAAA,EACF,KAAK,CAAC;AAER,QAAM,oBACJ,SAAS,OAAO,SAAS;AAAA,IAAI,CAAC,iBAC5B;AAAA,MACE,OAAO,OAAO;AAAA,MACd,YAAY,OAAO,OAAO,MAAM,YAAY;AAAA,IAC9C;AAAA,EACF,KAAK,CAAC;AAER,QAAM,aAAa,SAAS,OAAO,SAAS,IAAI,WAC5C;AAAA,IACE;AAAA,MACE,OAAO,OAAO;AAAA,MACd;AAAA,QACE,OAAO,OAAO;AAAA,QACd,SAAS,OAAO,SAAS,IAAI;AAAA,MAC/B;AAAA,IACF;AAAA,EACF,IACA,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,MACE,OAAO,OAAO;AAAA,MACd;AAAA,QACE,OAAO,OAAO;AAAA,QACd,OAAO,OAAO;AAAA,QACd,OAAO,OAAO;AAAA,MAChB;AAAA,IACF;AAAA,IACA;AAAA,MACE,OAAO,OAAO;AAAA,MACd,YAAY,OAAO,OAAO,MAAM,iBAAiB,QAAQ;AAAA,IAC3D;AAAA,IACA,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AACF;AAaO,SAAS,UAAU,QAAyB;AASjD,iBAAe,YACb,SACA,UACA;AACA,UAAM,eAAe,KAAK,OAAO,OAAO,MAAM,iBAAiB,QAAQ;AACvE,UAAM,EAAE,OAAO,IAAI,MAAM,aAA2B,YAAY;AAChE,UAAM,eAAe,gBAAgB,QAAQ,MAAM;AAEnD,UAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,UAAM,UAAU,aAAa,KAAK,CAAC,gBAAgB,SAAS,WAAW;AAEvE,QAAI,CAAC,SAAS;AACZ,eAAS,aAAa;AACtB,eAAS,IAAI;AACb;AAAA,IACF;AAEA,UAAM,gBAAgB,SAAS,UAAU;AAAA,MACvC,QAAQ,OAAO,OAAO;AAAA,MACtB,kBAAkB;AAAA,MAClB,SAAS;AAAA,QACP;AAAA,UACE,QAAQ;AAAA,UACR,SAAS;AAAA,YACP;AAAA,cACE,KAAK;AAAA,cACL,OAAO;AAAA,YACT;AAAA,YACA;AAAA,cACE,KAAK;AAAA,cACL,OAAO;AAAA,YACT;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,SAAS,aAAa,CAAC,SAAS,aAAa;AACjD,gBAAY,SAAS,QAAQ,EAAE;AAAA;AAAA,MAE7B,CAAC,UAAU;AACT,iBAAS,KAAK;AACd,iBAAS,aAAa;AACtB,iBAAS,IAAI;AAAA,MACf;AAAA,IACF;AAAA,EACF,CAAC;AAWD,QAAM,SAAS,OAAO,OAAO,OAAO,OAAO,SAAS;AAClD,WAAO,IAAI,QAIR,CAAC,SAAS,WAAW;AACtB,UAAI;AACF,eAAO,OAAO,MAAM,MAAM;AACxB,gBAAM,QAAQ,YAAY;AACxB,kBAAM,IAAI,QAAc,CAAC,cAAc,gBAAgB;AACrD,qBAAO,MAAM,CAAC,eAAe;AAC3B,oBAAI,YAAY;AACd,yBAAO,YAAY,UAAU;AAAA,gBAC/B;AAEA,uBAAO,aAAa;AAAA,cACtB,CAAC;AAAA,YACH,CAAC;AAAA,UACH;AAEA,gBAAM,UAAU,OAAO,QAAQ;AAC/B,kBAAQ,EAAE,MAAM,QAAQ,MAAM,QAAQ,MAAM,CAAC;AAAA,QAC/C,CAAC;AAAA,MACH,SAAS,aAAa;AACpB,eAAO,WAAW;AAAA,MACpB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,OAAO;AAClB;","names":[]}
|