@metamask/snaps-cli 5.1.1 → 6.0.1
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 +13 -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-26C34AS7.mjs +287 -0
- package/dist/chunk-26C34AS7.mjs.map +1 -0
- package/dist/chunk-2SUDRRT6.mjs +50 -0
- package/dist/chunk-2SUDRRT6.mjs.map +1 -0
- package/dist/chunk-3WWFQLH4.mjs +30 -0
- package/dist/chunk-3WWFQLH4.mjs.map +1 -0
- package/dist/chunk-45LOTCC4.mjs +1 -0
- package/dist/chunk-45LOTCC4.mjs.map +1 -0
- package/dist/chunk-4QUVE3EK.js +53 -0
- package/dist/chunk-4QUVE3EK.js.map +1 -0
- package/dist/chunk-5CLEKHXE.js +54 -0
- package/dist/chunk-5CLEKHXE.js.map +1 -0
- package/dist/chunk-5KQNAW4C.mjs +346 -0
- package/dist/chunk-5KQNAW4C.mjs.map +1 -0
- package/dist/chunk-6EEZHGF5.js +23 -0
- package/dist/chunk-6EEZHGF5.js.map +1 -0
- package/dist/chunk-7NQQGJZJ.mjs +35 -0
- package/dist/chunk-7NQQGJZJ.mjs.map +1 -0
- package/dist/chunk-7RHK2YTB.mjs +32 -0
- package/dist/chunk-7RHK2YTB.mjs.map +1 -0
- package/dist/chunk-AZMQTZXZ.mjs +28 -0
- package/dist/chunk-AZMQTZXZ.mjs.map +1 -0
- package/dist/chunk-B3NNVTA6.js +32 -0
- package/dist/chunk-B3NNVTA6.js.map +1 -0
- package/dist/chunk-BALQOCUO.js +22 -0
- package/dist/chunk-BALQOCUO.js.map +1 -0
- package/dist/chunk-BVPYLBE5.js +365 -0
- package/dist/chunk-BVPYLBE5.js.map +1 -0
- package/dist/chunk-BYNQODL3.mjs +23 -0
- package/dist/chunk-BYNQODL3.mjs.map +1 -0
- package/dist/chunk-C44RRX3H.js +18 -0
- package/dist/chunk-C44RRX3H.js.map +1 -0
- package/dist/chunk-C46KEPAC.js +37 -0
- package/dist/chunk-C46KEPAC.js.map +1 -0
- package/dist/chunk-CGJKCIHP.js +28 -0
- package/dist/chunk-CGJKCIHP.js.map +1 -0
- package/dist/chunk-CIYE263O.js +30 -0
- package/dist/chunk-CIYE263O.js.map +1 -0
- package/dist/chunk-DBLADLQ4.js +10 -0
- package/dist/chunk-DBLADLQ4.js.map +1 -0
- package/dist/chunk-EDEA4QTA.js +35 -0
- package/dist/chunk-EDEA4QTA.js.map +1 -0
- package/dist/chunk-ERSRIVYH.mjs +64 -0
- package/dist/chunk-ERSRIVYH.mjs.map +1 -0
- package/dist/chunk-G3COWLG5.mjs +23 -0
- package/dist/chunk-G3COWLG5.mjs.map +1 -0
- package/dist/chunk-GKRRE4WN.mjs +30 -0
- package/dist/chunk-GKRRE4WN.mjs.map +1 -0
- package/dist/chunk-HQBA5RU6.mjs +54 -0
- package/dist/chunk-HQBA5RU6.mjs.map +1 -0
- package/dist/chunk-HYPSSFE5.mjs +13 -0
- package/dist/chunk-HYPSSFE5.mjs.map +1 -0
- package/dist/chunk-JAHNVVLT.mjs +18 -0
- package/dist/chunk-JAHNVVLT.mjs.map +1 -0
- package/dist/chunk-JCVSYVPD.mjs +24 -0
- package/dist/chunk-JCVSYVPD.mjs.map +1 -0
- package/dist/chunk-JI3B665Z.js +24 -0
- package/dist/chunk-JI3B665Z.js.map +1 -0
- package/dist/chunk-JL3URCHO.mjs +53 -0
- package/dist/chunk-JL3URCHO.mjs.map +1 -0
- package/dist/chunk-K26BOY6Z.mjs +51 -0
- package/dist/chunk-K26BOY6Z.mjs.map +1 -0
- package/dist/chunk-K5QMGTQL.mjs +22 -0
- package/dist/chunk-K5QMGTQL.mjs.map +1 -0
- package/dist/chunk-KLOPX6DO.js +51 -0
- package/dist/chunk-KLOPX6DO.js.map +1 -0
- package/dist/chunk-KUSHMQXD.js +64 -0
- package/dist/chunk-KUSHMQXD.js.map +1 -0
- package/dist/chunk-L72RLBV5.mjs +37 -0
- package/dist/chunk-L72RLBV5.mjs.map +1 -0
- package/dist/chunk-MDHJ5HLM.js +287 -0
- package/dist/chunk-MDHJ5HLM.js.map +1 -0
- package/dist/chunk-MR44GPM3.mjs +135 -0
- package/dist/chunk-MR44GPM3.mjs.map +1 -0
- package/dist/chunk-MUYXNION.js +30 -0
- package/dist/chunk-MUYXNION.js.map +1 -0
- package/dist/chunk-OKDY7C7S.js +346 -0
- package/dist/chunk-OKDY7C7S.js.map +1 -0
- package/dist/chunk-OPE2PGM6.mjs +24 -0
- package/dist/chunk-OPE2PGM6.mjs.map +1 -0
- package/dist/chunk-PDYQXXLP.js +30 -0
- package/dist/chunk-PDYQXXLP.js.map +1 -0
- package/dist/chunk-PFB25A2Q.mjs +52 -0
- package/dist/chunk-PFB25A2Q.mjs.map +1 -0
- package/dist/chunk-QFK7JVP3.js +52 -0
- package/dist/chunk-QFK7JVP3.js.map +1 -0
- package/dist/chunk-QHCKVO3P.js +28 -0
- package/dist/chunk-QHCKVO3P.js.map +1 -0
- package/dist/chunk-QMD3VO6R.mjs +30 -0
- package/dist/chunk-QMD3VO6R.mjs.map +1 -0
- package/dist/chunk-R6NBQKVH.js +16 -0
- package/dist/chunk-R6NBQKVH.js.map +1 -0
- package/dist/chunk-R77RJHC5.mjs +44 -0
- package/dist/chunk-R77RJHC5.mjs.map +1 -0
- package/dist/chunk-S45DIQPN.js +13 -0
- package/dist/chunk-S45DIQPN.js.map +1 -0
- package/dist/chunk-S76EZ6HY.js +23 -0
- package/dist/chunk-S76EZ6HY.js.map +1 -0
- package/dist/chunk-S7UP2YYF.js +135 -0
- package/dist/chunk-S7UP2YYF.js.map +1 -0
- package/dist/chunk-SVYNCWMH.js +61 -0
- package/dist/chunk-SVYNCWMH.js.map +1 -0
- package/dist/chunk-SYRWT2KT.mjs +124 -0
- package/dist/chunk-SYRWT2KT.mjs.map +1 -0
- package/dist/chunk-T7NEPTM5.mjs +61 -0
- package/dist/chunk-T7NEPTM5.mjs.map +1 -0
- package/dist/chunk-TDSL55B3.mjs +10 -0
- package/dist/chunk-TDSL55B3.mjs.map +1 -0
- package/dist/chunk-TJ2F3J6X.js +31 -0
- package/dist/chunk-TJ2F3J6X.js.map +1 -0
- package/dist/chunk-U4VFMIGO.js +24 -0
- package/dist/chunk-U4VFMIGO.js.map +1 -0
- package/dist/chunk-VXOV3ZCB.js +1 -0
- package/dist/chunk-VXOV3ZCB.js.map +1 -0
- package/dist/chunk-WO7DMSQU.mjs +16 -0
- package/dist/chunk-WO7DMSQU.mjs.map +1 -0
- package/dist/chunk-WP2N4NCO.js +50 -0
- package/dist/chunk-WP2N4NCO.js.map +1 -0
- package/dist/chunk-WYDHPUWV.mjs +28 -0
- package/dist/chunk-WYDHPUWV.mjs.map +1 -0
- package/dist/chunk-X3D3MHWF.js +44 -0
- package/dist/chunk-X3D3MHWF.js.map +1 -0
- package/dist/chunk-X7TESUC7.mjs +22 -0
- package/dist/chunk-X7TESUC7.mjs.map +1 -0
- package/dist/chunk-X7VYAL2L.mjs +365 -0
- package/dist/chunk-X7VYAL2L.mjs.map +1 -0
- package/dist/chunk-XGWLFH7Y.js +41 -0
- package/dist/chunk-XGWLFH7Y.js.map +1 -0
- package/dist/{cjs/webpack/config.js → chunk-XUYXKO4F.js} +181 -153
- package/dist/chunk-XUYXKO4F.js.map +1 -0
- package/dist/chunk-XZJLYKES.mjs +64 -0
- package/dist/chunk-XZJLYKES.mjs.map +1 -0
- package/dist/chunk-YCYGKEXF.mjs +41 -0
- package/dist/chunk-YCYGKEXF.mjs.map +1 -0
- package/dist/chunk-YGEAZQSC.js +124 -0
- package/dist/chunk-YGEAZQSC.js.map +1 -0
- package/dist/chunk-YQ2E7NEA.js +64 -0
- package/dist/chunk-YQ2E7NEA.js.map +1 -0
- package/dist/chunk-YQVCFM6L.js +22 -0
- package/dist/chunk-YQVCFM6L.js.map +1 -0
- package/dist/{esm/webpack/config.js → chunk-YWCNJELN.mjs} +182 -156
- package/dist/chunk-YWCNJELN.mjs.map +1 -0
- package/dist/chunk-ZAW4ZWQX.mjs +31 -0
- package/dist/chunk-ZAW4ZWQX.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 +1 -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,346 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkMUYXNIONjs = require('./chunk-MUYXNION.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkMDHJ5HLMjs = require('./chunk-MDHJ5HLM.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkB3NNVTA6js = require('./chunk-B3NNVTA6.js');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunkTJ2F3J6Xjs = require('./chunk-TJ2F3J6X.js');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunkX3D3MHWFjs = require('./chunk-X3D3MHWF.js');
|
|
22
|
+
|
|
23
|
+
// src/webpack/plugins.ts
|
|
24
|
+
var _utils = require('@metamask/utils');
|
|
25
|
+
var _chalk = require('chalk');
|
|
26
|
+
var _module = require('module');
|
|
27
|
+
var _webpack = require('webpack');
|
|
28
|
+
var _spinner, _getStatsErrorMessage, getStatsErrorMessage_fn;
|
|
29
|
+
var SnapsStatsPlugin = class {
|
|
30
|
+
constructor(options = {
|
|
31
|
+
verbose: false
|
|
32
|
+
}, spinner) {
|
|
33
|
+
/**
|
|
34
|
+
* Get the error message for the given stats error.
|
|
35
|
+
*
|
|
36
|
+
* @param statsError - The stats error.
|
|
37
|
+
* @param color - The color to use for the error message.
|
|
38
|
+
* @returns The error message.
|
|
39
|
+
*/
|
|
40
|
+
_chunkX3D3MHWFjs.__privateAdd.call(void 0, this, _getStatsErrorMessage);
|
|
41
|
+
/**
|
|
42
|
+
* The spinner to use for logging.
|
|
43
|
+
*/
|
|
44
|
+
_chunkX3D3MHWFjs.__privateAdd.call(void 0, this, _spinner, void 0);
|
|
45
|
+
this.options = options;
|
|
46
|
+
_chunkX3D3MHWFjs.__privateSet.call(void 0, this, _spinner, spinner);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Apply the plugin to the Webpack compiler.
|
|
50
|
+
*
|
|
51
|
+
* @param compiler - The Webpack compiler.
|
|
52
|
+
*/
|
|
53
|
+
apply(compiler) {
|
|
54
|
+
compiler.hooks.afterDone.tap(this.constructor.name, (stats) => {
|
|
55
|
+
if (!stats) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const { modules, time, errors, warnings } = stats.toJson();
|
|
59
|
+
_utils.assert.call(void 0, modules, "Modules must be defined in stats.");
|
|
60
|
+
_utils.assert.call(void 0, time, "Time must be defined in stats.");
|
|
61
|
+
if (errors?.length) {
|
|
62
|
+
const formattedErrors = errors.map((statsError) => _chunkX3D3MHWFjs.__privateMethod.call(void 0, this, _getStatsErrorMessage, getStatsErrorMessage_fn).call(this, statsError)).join("\n\n");
|
|
63
|
+
_chunkTJ2F3J6Xjs.error.call(void 0,
|
|
64
|
+
`Compiled ${modules.length} ${_chunkMDHJ5HLMjs.pluralize.call(void 0,
|
|
65
|
+
modules.length,
|
|
66
|
+
"file"
|
|
67
|
+
)} in ${time}ms with ${errors.length} ${_chunkMDHJ5HLMjs.pluralize.call(void 0,
|
|
68
|
+
errors.length,
|
|
69
|
+
"error"
|
|
70
|
+
)}.
|
|
71
|
+
|
|
72
|
+
${formattedErrors}
|
|
73
|
+
`,
|
|
74
|
+
_chunkX3D3MHWFjs.__privateGet.call(void 0, this, _spinner)
|
|
75
|
+
);
|
|
76
|
+
_chunkX3D3MHWFjs.__privateGet.call(void 0, this, _spinner)?.stop();
|
|
77
|
+
process.exitCode = 1;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (warnings?.length) {
|
|
81
|
+
const formattedWarnings = warnings.map(
|
|
82
|
+
(statsWarning) => _chunkX3D3MHWFjs.__privateMethod.call(void 0, this, _getStatsErrorMessage, getStatsErrorMessage_fn).call(this, statsWarning, _chalk.yellow)
|
|
83
|
+
).join("\n\n");
|
|
84
|
+
_chunkTJ2F3J6Xjs.warn.call(void 0,
|
|
85
|
+
`Compiled ${modules.length} ${_chunkMDHJ5HLMjs.pluralize.call(void 0,
|
|
86
|
+
modules.length,
|
|
87
|
+
"file"
|
|
88
|
+
)} in ${time}ms with ${warnings.length} ${_chunkMDHJ5HLMjs.pluralize.call(void 0,
|
|
89
|
+
warnings.length,
|
|
90
|
+
"warning"
|
|
91
|
+
)}.
|
|
92
|
+
|
|
93
|
+
${formattedWarnings}
|
|
94
|
+
`,
|
|
95
|
+
_chunkX3D3MHWFjs.__privateGet.call(void 0, this, _spinner)
|
|
96
|
+
);
|
|
97
|
+
} else {
|
|
98
|
+
_chunkTJ2F3J6Xjs.info.call(void 0,
|
|
99
|
+
`Compiled ${modules.length} ${_chunkMDHJ5HLMjs.pluralize.call(void 0,
|
|
100
|
+
modules.length,
|
|
101
|
+
"file"
|
|
102
|
+
)} in ${time}ms.`,
|
|
103
|
+
_chunkX3D3MHWFjs.__privateGet.call(void 0, this, _spinner)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (compiler.watchMode) {
|
|
107
|
+
_chunkX3D3MHWFjs.__privateGet.call(void 0, this, _spinner)?.succeed("Done!");
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
_spinner = new WeakMap();
|
|
113
|
+
_getStatsErrorMessage = new WeakSet();
|
|
114
|
+
getStatsErrorMessage_fn = function(statsError, color = _chalk.red) {
|
|
115
|
+
const baseMessage = this.options.verbose ? _chunkB3NNVTA6js.getErrorMessage.call(void 0, statsError) : statsError.message;
|
|
116
|
+
const [first, ...rest] = baseMessage.split("\n");
|
|
117
|
+
return [
|
|
118
|
+
color(_chunkMDHJ5HLMjs.formatText.call(void 0, `\u2022 ${first}`, 4, 2)),
|
|
119
|
+
...rest.map((message) => _chunkMDHJ5HLMjs.formatText.call(void 0, color(message), 4)),
|
|
120
|
+
statsError.details && `
|
|
121
|
+
${_chunkMDHJ5HLMjs.formatText.call(void 0, _chalk.dim.call(void 0, statsError.details), 6)}`
|
|
122
|
+
].filter(Boolean).join("\n");
|
|
123
|
+
};
|
|
124
|
+
var _spinner2, _safeEvaluate, safeEvaluate_fn;
|
|
125
|
+
var SnapsWatchPlugin = class {
|
|
126
|
+
constructor(options, spinner) {
|
|
127
|
+
/**
|
|
128
|
+
* Safely evaluate the bundle at the given path. If an error occurs, it will
|
|
129
|
+
* be logged to the console, rather than throwing an error.
|
|
130
|
+
*
|
|
131
|
+
* This function should never throw an error.
|
|
132
|
+
*
|
|
133
|
+
* @param bundlePath - The path to the bundle.
|
|
134
|
+
*/
|
|
135
|
+
_chunkX3D3MHWFjs.__privateAdd.call(void 0, this, _safeEvaluate);
|
|
136
|
+
/**
|
|
137
|
+
* The spinner to use for logging.
|
|
138
|
+
*/
|
|
139
|
+
_chunkX3D3MHWFjs.__privateAdd.call(void 0, this, _spinner2, void 0);
|
|
140
|
+
this.options = options;
|
|
141
|
+
_chunkX3D3MHWFjs.__privateSet.call(void 0, this, _spinner2, spinner);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Apply the plugin to the Webpack compiler.
|
|
145
|
+
*
|
|
146
|
+
* @param compiler - The Webpack compiler.
|
|
147
|
+
*/
|
|
148
|
+
apply(compiler) {
|
|
149
|
+
compiler.hooks.invalid.tap(this.constructor.name, (file) => {
|
|
150
|
+
_chunkX3D3MHWFjs.__privateGet.call(void 0, this, _spinner2)?.start();
|
|
151
|
+
_chunkTJ2F3J6Xjs.info.call(void 0, `Changes detected in ${_chalk.yellow.call(void 0, file)}, recompiling.`, _chunkX3D3MHWFjs.__privateGet.call(void 0, this, _spinner2));
|
|
152
|
+
});
|
|
153
|
+
compiler.hooks.afterEmit.tapPromise(
|
|
154
|
+
this.constructor.name,
|
|
155
|
+
async ({ fileDependencies }) => {
|
|
156
|
+
this.options.files?.forEach(
|
|
157
|
+
fileDependencies.add.bind(fileDependencies)
|
|
158
|
+
);
|
|
159
|
+
if (this.options.bundle && this.options.evaluate) {
|
|
160
|
+
await _chunkX3D3MHWFjs.__privateMethod.call(void 0, this, _safeEvaluate, safeEvaluate_fn).call(this, this.options.bundle);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
_spinner2 = new WeakMap();
|
|
167
|
+
_safeEvaluate = new WeakSet();
|
|
168
|
+
safeEvaluate_fn = async function(bundlePath) {
|
|
169
|
+
try {
|
|
170
|
+
await _chunkMUYXNIONjs.evaluate.call(void 0, bundlePath);
|
|
171
|
+
_chunkTJ2F3J6Xjs.info.call(void 0, `Snap bundle evaluated successfully.`, _chunkX3D3MHWFjs.__privateGet.call(void 0, this, _spinner2));
|
|
172
|
+
} catch (evaluateError) {
|
|
173
|
+
_chunkTJ2F3J6Xjs.error.call(void 0, evaluateError.message, _chunkX3D3MHWFjs.__privateGet.call(void 0, this, _spinner2));
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
var _source, _spinner3;
|
|
177
|
+
var SnapsBuiltInResolver = class {
|
|
178
|
+
constructor(options = {
|
|
179
|
+
ignore: []
|
|
180
|
+
}, spinner) {
|
|
181
|
+
/**
|
|
182
|
+
* The built-in modules that have been imported, but not resolved.
|
|
183
|
+
*/
|
|
184
|
+
this.unresolvedModules = /* @__PURE__ */ new Set();
|
|
185
|
+
/**
|
|
186
|
+
* The name of the resolver hook to tap into.
|
|
187
|
+
*/
|
|
188
|
+
_chunkX3D3MHWFjs.__privateAdd.call(void 0, this, _source, "described-resolve");
|
|
189
|
+
/**
|
|
190
|
+
* The spinner to use for logging.
|
|
191
|
+
*/
|
|
192
|
+
_chunkX3D3MHWFjs.__privateAdd.call(void 0, this, _spinner3, void 0);
|
|
193
|
+
this.options = options;
|
|
194
|
+
_chunkX3D3MHWFjs.__privateSet.call(void 0, this, _spinner3, spinner);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Apply the plugin to the Webpack resolver.
|
|
198
|
+
*
|
|
199
|
+
* @param resolver - The Webpack resolver.
|
|
200
|
+
*/
|
|
201
|
+
apply(resolver) {
|
|
202
|
+
resolver.getHook(_chunkX3D3MHWFjs.__privateGet.call(void 0, this, _source)).tapAsync(
|
|
203
|
+
this.constructor.name,
|
|
204
|
+
({ module: isModule, request }, _, callback) => {
|
|
205
|
+
if (!isModule || !request) {
|
|
206
|
+
return callback();
|
|
207
|
+
}
|
|
208
|
+
const baseRequest = request.split("/")[0];
|
|
209
|
+
if (_module.isBuiltin.call(void 0, baseRequest) && !this.options.ignore?.includes(baseRequest)) {
|
|
210
|
+
const fallback = resolver.options.fallback.find(
|
|
211
|
+
({ name }) => name === baseRequest
|
|
212
|
+
);
|
|
213
|
+
if (fallback && !fallback.alias) {
|
|
214
|
+
this.unresolvedModules.add(baseRequest);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return callback();
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
_source = new WeakMap();
|
|
223
|
+
_spinner3 = new WeakMap();
|
|
224
|
+
var _checkBuiltIns, checkBuiltIns_fn, _isProvidePlugin, isProvidePlugin_fn, _checkBuffer, checkBuffer_fn;
|
|
225
|
+
var SnapsBundleWarningsPlugin = class {
|
|
226
|
+
constructor(options = {
|
|
227
|
+
buffer: true,
|
|
228
|
+
builtIns: true
|
|
229
|
+
}) {
|
|
230
|
+
/**
|
|
231
|
+
* Check if a built-in module is used, but not provided by Webpack's
|
|
232
|
+
* `fallback` configuration.
|
|
233
|
+
*
|
|
234
|
+
* @param compiler - The Webpack compiler.
|
|
235
|
+
*/
|
|
236
|
+
_chunkX3D3MHWFjs.__privateAdd.call(void 0, this, _checkBuiltIns);
|
|
237
|
+
/**
|
|
238
|
+
* Check if the given instance is a `ProvidePlugin`. This is not guaranteed to
|
|
239
|
+
* be accurate, but it's good enough for our purposes. If we were to use
|
|
240
|
+
* `instanceof` instead, it might not work if multiple versions of Webpack are
|
|
241
|
+
* installed.
|
|
242
|
+
*
|
|
243
|
+
* @param instance - The instance to check.
|
|
244
|
+
* @returns Whether the instance is a `ProvidePlugin`, i.e., whether it's an
|
|
245
|
+
* object with the name `ProvidePlugin` and a `definitions` property.
|
|
246
|
+
*/
|
|
247
|
+
_chunkX3D3MHWFjs.__privateAdd.call(void 0, this, _isProvidePlugin);
|
|
248
|
+
/**
|
|
249
|
+
* Check if the `Buffer` global is used, but not provided by Webpack's
|
|
250
|
+
* `DefinePlugin`.
|
|
251
|
+
*
|
|
252
|
+
* @param compiler - The Webpack compiler.
|
|
253
|
+
*/
|
|
254
|
+
_chunkX3D3MHWFjs.__privateAdd.call(void 0, this, _checkBuffer);
|
|
255
|
+
this.options = options;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Apply the plugin to the Webpack compiler.
|
|
259
|
+
*
|
|
260
|
+
* @param compiler - The Webpack compiler.
|
|
261
|
+
*/
|
|
262
|
+
apply(compiler) {
|
|
263
|
+
if (this.options.builtIns) {
|
|
264
|
+
_chunkX3D3MHWFjs.__privateMethod.call(void 0, this, _checkBuiltIns, checkBuiltIns_fn).call(this, compiler);
|
|
265
|
+
}
|
|
266
|
+
if (this.options.buffer) {
|
|
267
|
+
_chunkX3D3MHWFjs.__privateMethod.call(void 0, this, _checkBuffer, checkBuffer_fn).call(this, compiler);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
_checkBuiltIns = new WeakSet();
|
|
272
|
+
checkBuiltIns_fn = function(compiler) {
|
|
273
|
+
compiler.hooks.afterCompile.tap(this.constructor.name, (compilation) => {
|
|
274
|
+
if (!this.options.builtInResolver) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const { unresolvedModules } = this.options.builtInResolver;
|
|
278
|
+
if (unresolvedModules.size === 0) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const formattedModules = new Array(...unresolvedModules).map((name) => `\u2022 ${name}`).join("\n");
|
|
282
|
+
const webpackError = new (0, _webpack.WebpackError)(
|
|
283
|
+
`The snap attempted to use one or more Node.js builtins, but no browser fallback has been provided. The MetaMask Snaps CLI does not support Node.js builtins by default. If you want to use this module, you must set ${_chalk.bold.call(void 0,
|
|
284
|
+
"`polyfills`"
|
|
285
|
+
)} to ${_chalk.bold.call(void 0,
|
|
286
|
+
"`true`"
|
|
287
|
+
)} or an object with the builtins to polyfill as the key and ${_chalk.bold.call(void 0,
|
|
288
|
+
"`true`"
|
|
289
|
+
)} as the value. To disable this warning, set ${_chalk.bold.call(void 0,
|
|
290
|
+
"`stats.builtIns`"
|
|
291
|
+
)} to ${_chalk.bold.call(void 0,
|
|
292
|
+
"`false`"
|
|
293
|
+
)} in your snap config file, or add the module to the ${_chalk.bold.call(void 0,
|
|
294
|
+
"`stats.builtIns.ignore`"
|
|
295
|
+
)} array.`
|
|
296
|
+
);
|
|
297
|
+
webpackError.details = formattedModules;
|
|
298
|
+
compilation.warnings.push(webpackError);
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
_isProvidePlugin = new WeakSet();
|
|
302
|
+
isProvidePlugin_fn = function(instance) {
|
|
303
|
+
return _utils.isObject.call(void 0, instance) && instance.constructor.name === "ProvidePlugin" && _utils.hasProperty.call(void 0, instance, "definitions");
|
|
304
|
+
};
|
|
305
|
+
_checkBuffer = new WeakSet();
|
|
306
|
+
checkBuffer_fn = function(compiler) {
|
|
307
|
+
const plugin = compiler.options.plugins?.find(
|
|
308
|
+
(instance) => _chunkX3D3MHWFjs.__privateMethod.call(void 0, this, _isProvidePlugin, isProvidePlugin_fn).call(this, instance)
|
|
309
|
+
);
|
|
310
|
+
if (plugin) {
|
|
311
|
+
const { definitions } = plugin;
|
|
312
|
+
if (definitions.Buffer) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
|
|
317
|
+
compilation.hooks.afterProcessAssets.tap(
|
|
318
|
+
this.constructor.name,
|
|
319
|
+
(assets) => {
|
|
320
|
+
const bufferAssets = Object.entries(assets).filter(([name]) => name.endsWith(".js")).filter(([, asset]) => asset.source().includes("Buffer"));
|
|
321
|
+
if (bufferAssets.length === 0) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
compilation.warnings.push(
|
|
325
|
+
new (0, _webpack.WebpackError)(
|
|
326
|
+
`The snap attempted to use the Node.js Buffer global, which is not supported in the MetaMask Snaps CLI by default. To use the Buffer global, you must polyfill Buffer by setting ${_chalk.bold.call(void 0,
|
|
327
|
+
"`buffer`"
|
|
328
|
+
)} to ${_chalk.bold.call(void 0, "`true`")} in the ${_chalk.bold.call(void 0,
|
|
329
|
+
"`polyfills`"
|
|
330
|
+
)} config object in your snap config. To disable this warning, set ${_chalk.bold.call(void 0,
|
|
331
|
+
"`stats.buffer`"
|
|
332
|
+
)} to ${_chalk.bold.call(void 0, "`false`")} in your snap config file.`
|
|
333
|
+
)
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
exports.SnapsStatsPlugin = SnapsStatsPlugin; exports.SnapsWatchPlugin = SnapsWatchPlugin; exports.SnapsBuiltInResolver = SnapsBuiltInResolver; exports.SnapsBundleWarningsPlugin = SnapsBundleWarningsPlugin;
|
|
346
|
+
//# sourceMappingURL=chunk-OKDY7C7S.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webpack/plugins.ts"],"names":["_spinner"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,QAAQ,aAAa,gBAAgB;AAC9C,SA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AA,IACF;AAAA,EACF,CAAC;AACH","sourcesContent":["import { assert, hasProperty, isObject } from '@metamask/utils';\nimport { bold, dim, red, yellow } from 'chalk';\nimport { isBuiltin } from 'module';\nimport type { Ora } from 'ora';\nimport type {\n Compiler,\n ProvidePlugin,\n ResolvePluginInstance,\n Resolver,\n StatsError,\n WebpackPluginInstance,\n} from 'webpack';\nimport { WebpackError } from 'webpack';\n\nimport { evaluate } from '../commands/eval';\nimport { error, getErrorMessage, info, warn } from '../utils';\nimport { formatText, pluralize } from './utils';\n\nexport type SnapsStatsPluginOptions = {\n /**\n * Whether to log the verbose stats.\n */\n verbose?: boolean;\n};\n\n/**\n * A plugin that logs the stats after compilation. This is useful for logging\n * the number of files compiled, and the time taken to compile them.\n */\nexport class SnapsStatsPlugin implements WebpackPluginInstance {\n /**\n * The options for the plugin.\n */\n readonly options: SnapsStatsPluginOptions;\n\n /**\n * The spinner to use for logging.\n */\n readonly #spinner?: Ora;\n\n constructor(\n options: SnapsStatsPluginOptions = {\n verbose: false,\n },\n spinner?: Ora,\n ) {\n this.options = options;\n this.#spinner = spinner;\n }\n\n /**\n * Apply the plugin to the Webpack compiler.\n *\n * @param compiler - The Webpack compiler.\n */\n apply(compiler: Compiler) {\n compiler.hooks.afterDone.tap(this.constructor.name, (stats) => {\n if (!stats) {\n return;\n }\n\n const { modules, time, errors, warnings } = stats.toJson();\n\n assert(modules, 'Modules must be defined in stats.');\n assert(time, 'Time must be defined in stats.');\n\n if (errors?.length) {\n const formattedErrors = errors\n .map((statsError) => this.#getStatsErrorMessage(statsError))\n .join('\\n\\n');\n\n error(\n `Compiled ${modules.length} ${pluralize(\n modules.length,\n 'file',\n )} in ${time}ms with ${errors.length} ${pluralize(\n errors.length,\n 'error',\n )}.\\n\\n${formattedErrors}\\n`,\n this.#spinner,\n );\n\n this.#spinner?.stop();\n\n process.exitCode = 1;\n return;\n }\n\n if (warnings?.length) {\n const formattedWarnings = warnings\n .map((statsWarning) =>\n this.#getStatsErrorMessage(statsWarning, yellow),\n )\n .join('\\n\\n');\n\n warn(\n `Compiled ${modules.length} ${pluralize(\n modules.length,\n 'file',\n )} in ${time}ms with ${warnings.length} ${pluralize(\n warnings.length,\n 'warning',\n )}.\\n\\n${formattedWarnings}\\n`,\n this.#spinner,\n );\n } else {\n info(\n `Compiled ${modules.length} ${pluralize(\n modules.length,\n 'file',\n )} in ${time}ms.`,\n this.#spinner,\n );\n }\n\n if (compiler.watchMode) {\n // The spinner may be restarted by the watch plugin, outside of the\n // `executeSteps` flow, so we stop it here just in case.\n this.#spinner?.succeed('Done!');\n }\n });\n }\n\n /**\n * Get the error message for the given stats error.\n *\n * @param statsError - The stats error.\n * @param color - The color to use for the error message.\n * @returns The error message.\n */\n #getStatsErrorMessage(statsError: StatsError, color = red) {\n const baseMessage = this.options.verbose\n ? getErrorMessage(statsError)\n : statsError.message;\n\n const [first, ...rest] = baseMessage.split('\\n');\n\n return [\n color(formatText(`• ${first}`, 4, 2)),\n ...rest.map((message) => formatText(color(message), 4)),\n statsError.details && `\\n${formatText(dim(statsError.details), 6)}`,\n ]\n .filter(Boolean)\n .join('\\n');\n }\n}\n\n/**\n * The options for the {@link SnapsWatchPlugin}.\n */\nexport type SnapsWatchPluginOptions = {\n /**\n * The bundle path. This is the file that will be evaluated, if the `evaluate`\n * option is set.\n */\n bundle?: string;\n\n /**\n * Whether to evaluate the bundle. This only applies if the `bundle` option is\n * set.\n */\n evaluate?: boolean;\n\n /**\n * The extra files to watch.\n */\n files?: string[];\n};\n\n/**\n * A plugin that adds extra files to watch. This is useful for watching files\n * that are not imported by the entry point, such as the `snap.manifest.json`\n * file.\n */\nexport class SnapsWatchPlugin implements WebpackPluginInstance {\n /**\n * The options for the plugin.\n */\n readonly options: SnapsWatchPluginOptions;\n\n /**\n * The spinner to use for logging.\n */\n readonly #spinner?: Ora;\n\n constructor(options: SnapsWatchPluginOptions, spinner?: Ora) {\n this.options = options;\n this.#spinner = spinner;\n }\n\n /**\n * Apply the plugin to the Webpack compiler.\n *\n * @param compiler - The Webpack compiler.\n */\n apply(compiler: Compiler) {\n compiler.hooks.invalid.tap(this.constructor.name, (file) => {\n this.#spinner?.start();\n info(`Changes detected in ${yellow(file)}, recompiling.`, this.#spinner);\n });\n\n compiler.hooks.afterEmit.tapPromise(\n this.constructor.name,\n async ({ fileDependencies }) => {\n this.options.files?.forEach(\n fileDependencies.add.bind(fileDependencies),\n );\n\n if (this.options.bundle && this.options.evaluate) {\n await this.#safeEvaluate(this.options.bundle);\n }\n },\n );\n }\n\n /**\n * Safely evaluate the bundle at the given path. If an error occurs, it will\n * be logged to the console, rather than throwing an error.\n *\n * This function should never throw an error.\n *\n * @param bundlePath - The path to the bundle.\n */\n async #safeEvaluate(bundlePath: string) {\n try {\n await evaluate(bundlePath);\n info(`Snap bundle evaluated successfully.`, this.#spinner);\n } catch (evaluateError) {\n error(evaluateError.message, this.#spinner);\n }\n }\n}\n\n/**\n * The options for the {@link SnapsBuiltInResolver}.\n */\nexport type SnapsBuiltInResolverOptions = {\n /**\n * The built-in modules to ignore.\n */\n ignore?: string[];\n};\n\n/**\n * A plugin that logs a message when a built-in module is not resolved. The\n * MetaMask Snaps CLI does not support built-in modules by default, and this\n * plugin is used to warn the user when they try to import a built-in module,\n * when no fallback is configured.\n */\nexport class SnapsBuiltInResolver implements ResolvePluginInstance {\n /**\n * The built-in modules that have been imported, but not resolved.\n */\n readonly unresolvedModules = new Set<string>();\n\n /**\n * The name of the resolver hook to tap into.\n */\n readonly #source = 'described-resolve';\n\n /**\n * The options for the plugin.\n */\n readonly options: SnapsBuiltInResolverOptions;\n\n /**\n * The spinner to use for logging.\n */\n readonly #spinner?: Ora;\n\n constructor(\n options: SnapsBuiltInResolverOptions = {\n ignore: [],\n },\n spinner?: Ora,\n ) {\n this.options = options;\n this.#spinner = spinner;\n }\n\n /**\n * Apply the plugin to the Webpack resolver.\n *\n * @param resolver - The Webpack resolver.\n */\n apply(resolver: Resolver) {\n resolver\n .getHook(this.#source)\n .tapAsync(\n this.constructor.name,\n ({ module: isModule, request }, _, callback) => {\n if (!isModule || !request) {\n return callback();\n }\n\n const baseRequest = request.split('/')[0];\n if (\n isBuiltin(baseRequest) &&\n !this.options.ignore?.includes(baseRequest)\n ) {\n const fallback = resolver.options.fallback.find(\n ({ name }) => name === baseRequest,\n );\n\n if (fallback && !fallback.alias) {\n this.unresolvedModules.add(baseRequest);\n }\n }\n\n return callback();\n },\n );\n }\n}\n\n/**\n * The options for the {@link SnapsBundleWarningsPlugin}.\n */\nexport type SnapsBundleWarningsPluginOptions = {\n /**\n * The {@link SnapsBuiltInResolver} instance to use for detecting built-in\n * modules.\n */\n builtInResolver?: SnapsBuiltInResolver | false;\n\n /**\n * Whether to show warnings if built-in modules are used, but not provided by\n * Webpack's `fallback` configuration.\n */\n builtIns?: boolean;\n\n /**\n * Whether to show warnings if the `Buffer` global is used, but not provided\n * by Webpack's `DefinePlugin`.\n */\n buffer?: boolean;\n};\n\n/**\n * A plugin that logs a message when:\n *\n * - A built-in module is not resolved. The MetaMask Snaps CLI does not support\n * built-in modules by default, and this plugin is used to warn the user when\n * they try to import a built-in module, when no fallback is configured.\n * - A snap uses the `Buffer` global. The MetaMask Snaps CLI does not support\n * the `Buffer` global by default, and this plugin is used to warn the user when\n * they try to use the `Buffer` global.\n *\n * We use both a resolver and a plugin, because the resolver is used to detect\n * when a built-in module is imported, and the plugin is used to log a single\n * message when the compilation is complete. We can't do everything in a single\n * plugin, because the resolver doesn't have access to the compilation, and the\n * plugin doesn't have access to the resolver.\n */\n\nexport class SnapsBundleWarningsPlugin implements WebpackPluginInstance {\n /**\n * The options for the plugin.\n */\n readonly options: SnapsBundleWarningsPluginOptions;\n\n constructor(\n options: SnapsBundleWarningsPluginOptions = {\n buffer: true,\n builtIns: true,\n },\n ) {\n this.options = options;\n }\n\n /**\n * Apply the plugin to the Webpack compiler.\n *\n * @param compiler - The Webpack compiler.\n */\n apply(compiler: Compiler) {\n if (this.options.builtIns) {\n this.#checkBuiltIns(compiler);\n }\n\n if (this.options.buffer) {\n this.#checkBuffer(compiler);\n }\n }\n\n /**\n * Check if a built-in module is used, but not provided by Webpack's\n * `fallback` configuration.\n *\n * @param compiler - The Webpack compiler.\n */\n #checkBuiltIns(compiler: Compiler) {\n compiler.hooks.afterCompile.tap(this.constructor.name, (compilation) => {\n if (!this.options.builtInResolver) {\n return;\n }\n\n const { unresolvedModules } = this.options.builtInResolver;\n if (unresolvedModules.size === 0) {\n return;\n }\n\n const formattedModules = new Array(...unresolvedModules)\n .map((name) => `• ${name}`)\n .join('\\n');\n\n const webpackError = new WebpackError(\n `The snap attempted to use one or more Node.js builtins, but no browser fallback has been provided. The MetaMask Snaps CLI does not support Node.js builtins by default. If you want to use this module, you must set ${bold(\n '`polyfills`',\n )} to ${bold(\n '`true`',\n )} or an object with the builtins to polyfill as the key and ${bold(\n '`true`',\n )} as the value. To disable this warning, set ${bold(\n '`stats.builtIns`',\n )} to ${bold(\n '`false`',\n )} in your snap config file, or add the module to the ${bold(\n '`stats.builtIns.ignore`',\n )} array.`,\n );\n\n webpackError.details = formattedModules;\n compilation.warnings.push(webpackError);\n });\n }\n\n /**\n * Check if the given instance is a `ProvidePlugin`. This is not guaranteed to\n * be accurate, but it's good enough for our purposes. If we were to use\n * `instanceof` instead, it might not work if multiple versions of Webpack are\n * installed.\n *\n * @param instance - The instance to check.\n * @returns Whether the instance is a `ProvidePlugin`, i.e., whether it's an\n * object with the name `ProvidePlugin` and a `definitions` property.\n */\n #isProvidePlugin(instance: unknown): instance is ProvidePlugin {\n return (\n isObject(instance) &&\n instance.constructor.name === 'ProvidePlugin' &&\n hasProperty(instance, 'definitions')\n );\n }\n\n /**\n * Check if the `Buffer` global is used, but not provided by Webpack's\n * `DefinePlugin`.\n *\n * @param compiler - The Webpack compiler.\n */\n #checkBuffer(compiler: Compiler) {\n const plugin = compiler.options.plugins?.find((instance) =>\n this.#isProvidePlugin(instance),\n ) as ProvidePlugin | undefined;\n\n // If the `ProvidePlugin` is configured to provide `Buffer`, then we don't\n // need to warn the user.\n if (plugin) {\n const { definitions } = plugin;\n if (definitions.Buffer) {\n return;\n }\n }\n\n compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {\n compilation.hooks.afterProcessAssets.tap(\n this.constructor.name,\n (assets) => {\n // Check if assets use `Buffer`.\n const bufferAssets = Object.entries(assets)\n .filter(([name]) => name.endsWith('.js'))\n .filter(([, asset]) => asset.source().includes('Buffer'));\n\n if (bufferAssets.length === 0) {\n return;\n }\n\n compilation.warnings.push(\n new WebpackError(\n `The snap attempted to use the Node.js Buffer global, which is not supported in the MetaMask Snaps CLI by default. To use the Buffer global, you must polyfill Buffer by setting ${bold(\n '`buffer`',\n )} to ${bold('`true`')} in the ${bold(\n '`polyfills`',\n )} config object in your snap config. To disable this warning, set ${bold(\n '`stats.buffer`',\n )} to ${bold('`false`')} in your snap config file.`,\n ),\n );\n },\n );\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
watchHandler
|
|
3
|
+
} from "./chunk-HQBA5RU6.mjs";
|
|
4
|
+
import {
|
|
5
|
+
builders_default
|
|
6
|
+
} from "./chunk-MR44GPM3.mjs";
|
|
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", builders_default.src).option("eval", builders_default.eval).option("dist", builders_default.dist).option("outfileName", builders_default.outfileName).option("sourceMaps", builders_default.sourceMaps).option("stripComments", builders_default.stripComments).option("transpilationMode", builders_default.transpilationMode).option("depsToTranspile", builders_default.depsToTranspile).option("manifest", builders_default.manifest).option("writeManifest", builders_default.writeManifest).option("serve", builders_default.serve).option("root", builders_default.root).option("port", builders_default.port).implies("writeManifest", "manifest").implies("depsToTranspile", "transpilationMode");
|
|
14
|
+
},
|
|
15
|
+
handler: async (argv) => watchHandler(argv.context.config, {
|
|
16
|
+
port: argv.port
|
|
17
|
+
})
|
|
18
|
+
};
|
|
19
|
+
var watch_default = command;
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
watch_default
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-OPE2PGM6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/watch/index.ts"],"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"],"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;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/legacy.ts
|
|
2
|
+
function processDependencies(config) {
|
|
3
|
+
const { depsToTranspile, transpilationMode } = config;
|
|
4
|
+
if (transpilationMode === "localAndDeps" /* LocalAndDeps */) {
|
|
5
|
+
const regex = getDependencyRegExp(depsToTranspile);
|
|
6
|
+
if (regex !== null) {
|
|
7
|
+
return [regex];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
function getDependencyRegExp(dependencies) {
|
|
13
|
+
if (!dependencies || dependencies.includes(".") || !dependencies.length) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const paths = sanitizeDependencyPaths(dependencies);
|
|
17
|
+
return RegExp(`/node_modules/(?!${paths.join("|")})`, "u");
|
|
18
|
+
}
|
|
19
|
+
function sanitizeDependencyPaths(dependencies) {
|
|
20
|
+
return dependencies.map((dependency) => {
|
|
21
|
+
return dependency.replace(/^[/\\]+/u, "").replace(/[/\\]+$/u, "");
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.processDependencies = processDependencies; exports.getDependencyRegExp = getDependencyRegExp; exports.sanitizeDependencyPaths = sanitizeDependencyPaths;
|
|
30
|
+
//# sourceMappingURL=chunk-PDYQXXLP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/legacy.ts"],"names":[],"mappings":";AAaO,SAAS,oBAAoB,QAAuB;AACzD,QAAM,EAAE,iBAAiB,kBAAkB,IAAI;AAC/C,MAAI,yDAAuD;AACzD,UAAM,QAAQ,oBAAoB,eAAe;AACjD,QAAI,UAAU,MAAM;AAClB,aAAO,CAAC,KAAK;AAAA,IACf;AAAA,EACF;AAEA,SAAO,CAAC;AACV;AAQO,SAAS,oBAAoB,cAAuC;AACzE,MAAI,CAAC,gBAAgB,aAAa,SAAS,GAAG,KAAK,CAAC,aAAa,QAAQ;AACvE,WAAO;AAAA,EACT;AAEA,QAAM,QAAkB,wBAAwB,YAAY;AAC5D,SAAO,OAAO,oBAAoB,MAAM,KAAK,GAAG,CAAC,KAAK,GAAG;AAC3D;AASO,SAAS,wBAAwB,cAAkC;AACxE,SAAO,aAAa,IAAI,CAAC,eAAe;AACtC,WAAO,WAAW,QAAQ,YAAY,EAAE,EAAE,QAAQ,YAAY,EAAE;AAAA,EAClE,CAAC;AACH","sourcesContent":["import { TranspilationModes } from '../builders';\nimport type { LegacyOptions } from '../config';\n\n/**\n * Get the dependencies to transpile, as well as the regular input file.\n *\n * If `transpilationMode` is not set to `localAndDeps`, this will return an\n * empty array.\n *\n * @param config - The config object.\n * @returns An array with regular expressions of dependencies that should be\n * transpiled.\n */\nexport function processDependencies(config: LegacyOptions) {\n const { depsToTranspile, transpilationMode } = config;\n if (transpilationMode === TranspilationModes.LocalAndDeps) {\n const regex = getDependencyRegExp(depsToTranspile);\n if (regex !== null) {\n return [regex];\n }\n }\n\n return [];\n}\n\n/**\n * Processes a string of space delimited dependencies into one RegExp string.\n *\n * @param dependencies - An array of dependencies to add to the RegExp.\n * @returns A RegExp object.\n */\nexport function getDependencyRegExp(dependencies: string[]): RegExp | null {\n if (!dependencies || dependencies.includes('.') || !dependencies.length) {\n return null;\n }\n\n const paths: string[] = sanitizeDependencyPaths(dependencies);\n return RegExp(`/node_modules/(?!${paths.join('|')})`, 'u');\n}\n\n/**\n * Helper function to remove any leading and trailing slashes from dependency\n * list.\n *\n * @param dependencies - An array of dependencies to sanitize.\n * @returns An array of sanitized paths.\n */\nexport function sanitizeDependencyPaths(dependencies: string[]): string[] {\n return dependencies.map((dependency) => {\n return dependency.replace(/^[/\\\\]+/u, '').replace(/[/\\\\]+$/u, '');\n });\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
manifest
|
|
3
|
+
} from "./chunk-2SUDRRT6.mjs";
|
|
4
|
+
import {
|
|
5
|
+
executeSteps
|
|
6
|
+
} from "./chunk-YCYGKEXF.mjs";
|
|
7
|
+
import {
|
|
8
|
+
CommandError
|
|
9
|
+
} from "./chunk-X7TESUC7.mjs";
|
|
10
|
+
|
|
11
|
+
// src/commands/manifest/manifest.ts
|
|
12
|
+
import { isFile } from "@metamask/snaps-utils/node";
|
|
13
|
+
var steps = [
|
|
14
|
+
{
|
|
15
|
+
name: "Checking the input file.",
|
|
16
|
+
task: async ({ input }) => {
|
|
17
|
+
if (!await isFile(input)) {
|
|
18
|
+
throw new CommandError(
|
|
19
|
+
`Manifest file not found: "${input}". Make sure that the \`snap.manifest.json\` file exists.`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "Validating the snap manifest.",
|
|
26
|
+
task: async ({ input, config, options, spinner }) => {
|
|
27
|
+
const write = getWriteManifest(config, options);
|
|
28
|
+
const valid = await manifest(input, write, spinner);
|
|
29
|
+
if (valid) {
|
|
30
|
+
spinner.succeed("The snap manifest file is valid.");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
function getWriteManifest(config, options) {
|
|
36
|
+
if (typeof options.fix === "boolean") {
|
|
37
|
+
return options.fix;
|
|
38
|
+
}
|
|
39
|
+
return config.legacy?.writeManifest ?? false;
|
|
40
|
+
}
|
|
41
|
+
async function manifestHandler(config, options) {
|
|
42
|
+
await executeSteps(steps, {
|
|
43
|
+
input: config.manifest.path,
|
|
44
|
+
config,
|
|
45
|
+
options
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
manifestHandler
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=chunk-PFB25A2Q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/manifest/manifest.ts"],"sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\n\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps } from '../../utils';\nimport { manifest } from './implementation';\n\ntype ManifestOptions = {\n fix?: boolean;\n};\n\ntype ManifestContext = {\n input: string;\n config: ProcessedConfig;\n options: ManifestOptions;\n};\n\nconst steps: Steps<ManifestContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ input }) => {\n if (!(await isFile(input))) {\n throw new CommandError(\n `Manifest file not found: \"${input}\". Make sure that the \\`snap.manifest.json\\` file exists.`,\n );\n }\n },\n },\n {\n name: 'Validating the snap manifest.',\n task: async ({ input, config, options, spinner }) => {\n const write = getWriteManifest(config, options);\n const valid = await manifest(input, write, spinner);\n\n if (valid) {\n spinner.succeed('The snap manifest file is valid.');\n }\n },\n },\n];\n\n/**\n * Get whether to write the manifest to disk.\n *\n * @param config - The config object.\n * @param options - The options object.\n * @returns Whether to write the manifest to disk.\n */\nfunction getWriteManifest(config: ProcessedConfig, options: ManifestOptions) {\n if (typeof options.fix === 'boolean') {\n return options.fix;\n }\n\n return config.legacy?.writeManifest ?? false;\n}\n\n/**\n * Validates a snap.manifest.json file. Attempts to fix the manifest and write\n * the fixed version to disk if `writeManifest` is true. Throws if validation\n * fails.\n *\n * @param config - The config object.\n * @param options - The options object.\n */\nexport async function manifestHandler(\n config: ProcessedConfig,\n options: ManifestOptions,\n) {\n await executeSteps(steps, {\n input: config.manifest.path,\n config,\n options,\n });\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,cAAc;AAkBvB,IAAM,QAAgC;AAAA,EACpC;AAAA,IACE,MAAM;AAAA,IACN,MAAM,OAAO,EAAE,MAAM,MAAM;AACzB,UAAI,CAAE,MAAM,OAAO,KAAK,GAAI;AAC1B,cAAM,IAAI;AAAA,UACR,6BAA6B,KAAK;AAAA,QACpC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM,OAAO,EAAE,OAAO,QAAQ,SAAS,QAAQ,MAAM;AACnD,YAAM,QAAQ,iBAAiB,QAAQ,OAAO;AAC9C,YAAM,QAAQ,MAAM,SAAS,OAAO,OAAO,OAAO;AAElD,UAAI,OAAO;AACT,gBAAQ,QAAQ,kCAAkC;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AACF;AASA,SAAS,iBAAiB,QAAyB,SAA0B;AAC3E,MAAI,OAAO,QAAQ,QAAQ,WAAW;AACpC,WAAO,QAAQ;AAAA,EACjB;AAEA,SAAO,OAAO,QAAQ,iBAAiB;AACzC;AAUA,eAAsB,gBACpB,QACA,SACA;AACA,QAAM,aAAa,OAAO;AAAA,IACxB,OAAO,OAAO,SAAS;AAAA,IACvB;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkWP2N4NCOjs = require('./chunk-WP2N4NCO.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkXGWLFH7Yjs = require('./chunk-XGWLFH7Y.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkBALQOCUOjs = require('./chunk-BALQOCUO.js');
|
|
10
|
+
|
|
11
|
+
// src/commands/manifest/manifest.ts
|
|
12
|
+
var _node = require('@metamask/snaps-utils/node');
|
|
13
|
+
var steps = [
|
|
14
|
+
{
|
|
15
|
+
name: "Checking the input file.",
|
|
16
|
+
task: async ({ input }) => {
|
|
17
|
+
if (!await _node.isFile.call(void 0, input)) {
|
|
18
|
+
throw new (0, _chunkBALQOCUOjs.CommandError)(
|
|
19
|
+
`Manifest file not found: "${input}". Make sure that the \`snap.manifest.json\` file exists.`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "Validating the snap manifest.",
|
|
26
|
+
task: async ({ input, config, options, spinner }) => {
|
|
27
|
+
const write = getWriteManifest(config, options);
|
|
28
|
+
const valid = await _chunkWP2N4NCOjs.manifest.call(void 0, input, write, spinner);
|
|
29
|
+
if (valid) {
|
|
30
|
+
spinner.succeed("The snap manifest file is valid.");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
function getWriteManifest(config, options) {
|
|
36
|
+
if (typeof options.fix === "boolean") {
|
|
37
|
+
return options.fix;
|
|
38
|
+
}
|
|
39
|
+
return config.legacy?.writeManifest ?? false;
|
|
40
|
+
}
|
|
41
|
+
async function manifestHandler(config, options) {
|
|
42
|
+
await _chunkXGWLFH7Yjs.executeSteps.call(void 0, steps, {
|
|
43
|
+
input: config.manifest.path,
|
|
44
|
+
config,
|
|
45
|
+
options
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
exports.manifestHandler = manifestHandler;
|
|
52
|
+
//# sourceMappingURL=chunk-QFK7JVP3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/manifest/manifest.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,cAAc;AAkBvB,IAAM,QAAgC;AAAA,EACpC;AAAA,IACE,MAAM;AAAA,IACN,MAAM,OAAO,EAAE,MAAM,MAAM;AACzB,UAAI,CAAE,MAAM,OAAO,KAAK,GAAI;AAC1B,cAAM,IAAI;AAAA,UACR,6BAA6B,KAAK;AAAA,QACpC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM,OAAO,EAAE,OAAO,QAAQ,SAAS,QAAQ,MAAM;AACnD,YAAM,QAAQ,iBAAiB,QAAQ,OAAO;AAC9C,YAAM,QAAQ,MAAM,SAAS,OAAO,OAAO,OAAO;AAElD,UAAI,OAAO;AACT,gBAAQ,QAAQ,kCAAkC;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AACF;AASA,SAAS,iBAAiB,QAAyB,SAA0B;AAC3E,MAAI,OAAO,QAAQ,QAAQ,WAAW;AACpC,WAAO,QAAQ;AAAA,EACjB;AAEA,SAAO,OAAO,QAAQ,iBAAiB;AACzC;AAUA,eAAsB,gBACpB,QACA,SACA;AACA,QAAM,aAAa,OAAO;AAAA,IACxB,OAAO,OAAO,SAAS;AAAA,IACvB;AAAA,IACA;AAAA,EACF,CAAC;AACH","sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\n\nimport type { ProcessedConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps } from '../../utils';\nimport { manifest } from './implementation';\n\ntype ManifestOptions = {\n fix?: boolean;\n};\n\ntype ManifestContext = {\n input: string;\n config: ProcessedConfig;\n options: ManifestOptions;\n};\n\nconst steps: Steps<ManifestContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ input }) => {\n if (!(await isFile(input))) {\n throw new CommandError(\n `Manifest file not found: \"${input}\". Make sure that the \\`snap.manifest.json\\` file exists.`,\n );\n }\n },\n },\n {\n name: 'Validating the snap manifest.',\n task: async ({ input, config, options, spinner }) => {\n const write = getWriteManifest(config, options);\n const valid = await manifest(input, write, spinner);\n\n if (valid) {\n spinner.succeed('The snap manifest file is valid.');\n }\n },\n },\n];\n\n/**\n * Get whether to write the manifest to disk.\n *\n * @param config - The config object.\n * @param options - The options object.\n * @returns Whether to write the manifest to disk.\n */\nfunction getWriteManifest(config: ProcessedConfig, options: ManifestOptions) {\n if (typeof options.fix === 'boolean') {\n return options.fix;\n }\n\n return config.legacy?.writeManifest ?? false;\n}\n\n/**\n * Validates a snap.manifest.json file. Attempts to fix the manifest and write\n * the fixed version to disk if `writeManifest` is true. Throws if validation\n * fails.\n *\n * @param config - The config object.\n * @param options - The options object.\n */\nexport async function manifestHandler(\n config: ProcessedConfig,\n options: ManifestOptions,\n) {\n await executeSteps(steps, {\n input: config.manifest.path,\n config,\n options,\n });\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/webpack/loaders/function.ts
|
|
2
|
+
var loader = function(content) {
|
|
3
|
+
const { fn } = this.getOptions();
|
|
4
|
+
return fn.bind(this)(content);
|
|
5
|
+
};
|
|
6
|
+
var function_default = loader;
|
|
7
|
+
function getFunctionLoader(fn, options) {
|
|
8
|
+
return {
|
|
9
|
+
// We use `__filename` as the loader, so Webpack will execute the loader in
|
|
10
|
+
// this file, with the actual function in the options.
|
|
11
|
+
loader: __filename,
|
|
12
|
+
options: {
|
|
13
|
+
fn,
|
|
14
|
+
...options
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (typeof module !== "undefined" && process?.env?.NODE_ENV !== "test") {
|
|
19
|
+
module.exports = loader;
|
|
20
|
+
module.exports.getFunctionLoader = getFunctionLoader;
|
|
21
|
+
module.exports.raw = true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
exports.function_default = function_default; exports.getFunctionLoader = getFunctionLoader;
|
|
28
|
+
//# sourceMappingURL=chunk-QHCKVO3P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webpack/loaders/function.ts"],"names":[],"mappings":";AAoBA,IAAM,SAA0D,SAC9D,SACA;AACA,QAAM,EAAE,GAAG,IAAI,KAAK,WAAW;AAC/B,SAAO,GAAG,KAAK,IAAI,EAAE,OAAO;AAC9B;AAEA,IAAO,mBAAQ;AAUR,SAAS,kBACd,IACA,SACA;AACA,SAAO;AAAA;AAAA;AAAA,IAGL,QAAQ;AAAA,IACR,SAAS;AAAA,MACP;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EACF;AACF;AAMA,IAAI,OAAO,WAAW,eAAe,SAAS,KAAK,aAAa,QAAQ;AACtE,SAAO,UAAU;AACjB,SAAO,QAAQ,oBAAoB;AACnC,SAAO,QAAQ,MAAM;AACvB","sourcesContent":["import type { LoaderDefinitionFunction } from 'webpack';\n\n/**\n * Options for the function loader.\n */\nexport type FunctionLoaderOptions = {\n /**\n * The function to execute. This is bound to the loader context, so it can\n * access the loader options and other properties.\n */\n fn: LoaderDefinitionFunction;\n};\n\n/**\n * A loader that executes a function. See {@link getFunctionLoader} for more\n * information.\n *\n * @param content - The input file contents as a `Uint8Array`.\n * @returns The output of the function.\n */\nconst loader: LoaderDefinitionFunction<FunctionLoaderOptions> = function (\n content,\n) {\n const { fn } = this.getOptions();\n return fn.bind(this)(content);\n};\n\nexport default loader;\n\n/**\n * Get a loader that executes the given function. This is useful for executing\n * loaders without needing to pass a file to Webpack.\n *\n * @param fn - The function to execute.\n * @param options - The options to pass to the loader.\n * @returns The loader definition.\n */\nexport function getFunctionLoader<Options>(\n fn: LoaderDefinitionFunction<Options>,\n options: Options,\n) {\n return {\n // We use `__filename` as the loader, so Webpack will execute the loader in\n // this file, with the actual function in the options.\n loader: __filename,\n options: {\n fn,\n ...options,\n },\n };\n}\n\n// When running as CJS, we need to export the loader as a default export, since\n// `tsup` exports it as `loader_default`.\n// istanbul ignore next 3\n// eslint-disable-next-line n/no-process-env\nif (typeof module !== 'undefined' && process?.env?.NODE_ENV !== 'test') {\n module.exports = loader;\n module.exports.getFunctionLoader = getFunctionLoader;\n module.exports.raw = true;\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/utils/legacy.ts
|
|
2
|
+
function processDependencies(config) {
|
|
3
|
+
const { depsToTranspile, transpilationMode } = config;
|
|
4
|
+
if (transpilationMode === "localAndDeps" /* LocalAndDeps */) {
|
|
5
|
+
const regex = getDependencyRegExp(depsToTranspile);
|
|
6
|
+
if (regex !== null) {
|
|
7
|
+
return [regex];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
function getDependencyRegExp(dependencies) {
|
|
13
|
+
if (!dependencies || dependencies.includes(".") || !dependencies.length) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const paths = sanitizeDependencyPaths(dependencies);
|
|
17
|
+
return RegExp(`/node_modules/(?!${paths.join("|")})`, "u");
|
|
18
|
+
}
|
|
19
|
+
function sanitizeDependencyPaths(dependencies) {
|
|
20
|
+
return dependencies.map((dependency) => {
|
|
21
|
+
return dependency.replace(/^[/\\]+/u, "").replace(/[/\\]+$/u, "");
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
processDependencies,
|
|
27
|
+
getDependencyRegExp,
|
|
28
|
+
sanitizeDependencyPaths
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=chunk-QMD3VO6R.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/legacy.ts"],"sourcesContent":["import { TranspilationModes } from '../builders';\nimport type { LegacyOptions } from '../config';\n\n/**\n * Get the dependencies to transpile, as well as the regular input file.\n *\n * If `transpilationMode` is not set to `localAndDeps`, this will return an\n * empty array.\n *\n * @param config - The config object.\n * @returns An array with regular expressions of dependencies that should be\n * transpiled.\n */\nexport function processDependencies(config: LegacyOptions) {\n const { depsToTranspile, transpilationMode } = config;\n if (transpilationMode === TranspilationModes.LocalAndDeps) {\n const regex = getDependencyRegExp(depsToTranspile);\n if (regex !== null) {\n return [regex];\n }\n }\n\n return [];\n}\n\n/**\n * Processes a string of space delimited dependencies into one RegExp string.\n *\n * @param dependencies - An array of dependencies to add to the RegExp.\n * @returns A RegExp object.\n */\nexport function getDependencyRegExp(dependencies: string[]): RegExp | null {\n if (!dependencies || dependencies.includes('.') || !dependencies.length) {\n return null;\n }\n\n const paths: string[] = sanitizeDependencyPaths(dependencies);\n return RegExp(`/node_modules/(?!${paths.join('|')})`, 'u');\n}\n\n/**\n * Helper function to remove any leading and trailing slashes from dependency\n * list.\n *\n * @param dependencies - An array of dependencies to sanitize.\n * @returns An array of sanitized paths.\n */\nexport function sanitizeDependencyPaths(dependencies: string[]): string[] {\n return dependencies.map((dependency) => {\n return dependency.replace(/^[/\\\\]+/u, '').replace(/[/\\\\]+$/u, '');\n });\n}\n"],"mappings":";AAaO,SAAS,oBAAoB,QAAuB;AACzD,QAAM,EAAE,iBAAiB,kBAAkB,IAAI;AAC/C,MAAI,yDAAuD;AACzD,UAAM,QAAQ,oBAAoB,eAAe;AACjD,QAAI,UAAU,MAAM;AAClB,aAAO,CAAC,KAAK;AAAA,IACf;AAAA,EACF;AAEA,SAAO,CAAC;AACV;AAQO,SAAS,oBAAoB,cAAuC;AACzE,MAAI,CAAC,gBAAgB,aAAa,SAAS,GAAG,KAAK,CAAC,aAAa,QAAQ;AACvE,WAAO;AAAA,EACT;AAEA,QAAM,QAAkB,wBAAwB,YAAY;AAC5D,SAAO,OAAO,oBAAoB,MAAM,KAAK,GAAG,CAAC,KAAK,GAAG;AAC3D;AASO,SAAS,wBAAwB,cAAkC;AACxE,SAAO,aAAa,IAAI,CAAC,eAAe;AACtC,WAAO,WAAW,QAAQ,YAAY,EAAE,EAAE,QAAQ,YAAY,EAAE;AAAA,EAClE,CAAC;AACH;","names":[]}
|