@metamask/snaps-cli 0.38.1-flask.1 → 1.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 +377 -19
- package/README.md +67 -542
- package/dist/builders.d.ts +27 -0
- package/dist/{esm/builders.js → builders.js} +51 -48
- package/dist/builders.js.map +1 -0
- package/dist/{types/cli.d.ts → cli.d.ts} +1 -1
- package/dist/cli.js +51 -0
- package/dist/cli.js.map +1 -0
- package/dist/cmds/build/buildHandler.d.ts +13 -0
- package/dist/cmds/build/buildHandler.js +37 -0
- package/dist/cmds/build/buildHandler.js.map +1 -0
- package/dist/cmds/build/bundle.d.ts +15 -0
- package/dist/cmds/build/bundle.js +80 -0
- package/dist/cmds/build/bundle.js.map +1 -0
- package/dist/{types/commands/serve → cmds/build}/index.d.ts +4 -4
- package/dist/cmds/build/index.js +29 -0
- package/dist/cmds/build/index.js.map +1 -0
- package/dist/cmds/build/utils.d.ts +56 -0
- package/dist/cmds/build/utils.js +100 -0
- package/dist/cmds/build/utils.js.map +1 -0
- package/dist/cmds/eval/evalHandler.d.ts +9 -0
- package/dist/cmds/eval/evalHandler.js +25 -0
- package/dist/cmds/eval/evalHandler.js.map +1 -0
- package/dist/cmds/eval/index.d.ts +9 -0
- package/dist/cmds/eval/index.js +15 -0
- package/dist/cmds/eval/index.js.map +1 -0
- package/dist/cmds/index.js +14 -0
- package/dist/cmds/index.js.map +1 -0
- package/dist/cmds/init/index.d.ts +9 -0
- package/dist/cmds/init/index.js +34 -0
- package/dist/cmds/init/index.js.map +1 -0
- package/dist/cmds/init/initHandler.d.ts +26 -0
- package/dist/cmds/init/initHandler.js +69 -0
- package/dist/cmds/init/initHandler.js.map +1 -0
- package/dist/cmds/init/initUtils.d.ts +39 -0
- package/dist/cmds/init/initUtils.js +122 -0
- package/dist/cmds/init/initUtils.js.map +1 -0
- package/dist/cmds/manifest/index.d.ts +9 -0
- package/dist/cmds/manifest/index.js +24 -0
- package/dist/cmds/manifest/index.js.map +1 -0
- package/dist/cmds/manifest/manifestHandler.d.ts +10 -0
- package/dist/cmds/manifest/manifestHandler.js +50 -0
- package/dist/cmds/manifest/manifestHandler.js.map +1 -0
- package/dist/cmds/serve/index.d.ts +9 -0
- package/dist/cmds/serve/index.js +15 -0
- package/dist/cmds/serve/index.js.map +1 -0
- package/dist/cmds/serve/serveHandler.d.ts +10 -0
- package/dist/cmds/serve/serveHandler.js +59 -0
- package/dist/cmds/serve/serveHandler.js.map +1 -0
- package/dist/cmds/serve/serveUtils.d.ts +22 -0
- package/dist/cmds/serve/serveUtils.js +39 -0
- package/dist/cmds/serve/serveUtils.js.map +1 -0
- package/dist/cmds/watch/index.d.ts +9 -0
- package/dist/cmds/watch/index.js +32 -0
- package/dist/cmds/watch/index.js.map +1 -0
- package/dist/cmds/watch/watchHandler.d.ts +14 -0
- package/dist/cmds/watch/watchHandler.js +100 -0
- package/dist/cmds/watch/watchHandler.js.map +1 -0
- package/dist/main.js +15 -0
- package/dist/main.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/misc.d.ts +53 -0
- package/dist/utils/misc.js +156 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/snap-config.d.ts +48 -0
- package/dist/utils/snap-config.js +117 -0
- package/dist/utils/snap-config.js.map +1 -0
- package/package.json +35 -54
- 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 -35
- 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 -290
- 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 -96
- package/dist/cjs/webpack/compiler.js.map +0 -1
- package/dist/cjs/webpack/config.js +0 -234
- package/dist/cjs/webpack/config.js.map +0 -1
- package/dist/cjs/webpack/index.js +0 -22
- 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 -36
- package/dist/cjs/webpack/loaders/wasm.js.map +0 -1
- package/dist/cjs/webpack/plugins.js +0 -340
- package/dist/cjs/webpack/plugins.js.map +0 -1
- package/dist/cjs/webpack/utils.js +0 -133
- package/dist/cjs/webpack/utils.js.map +0 -1
- package/dist/esm/builders.js.map +0 -1
- package/dist/esm/cli.js +0 -26
- 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 -294
- 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 -89
- package/dist/esm/webpack/compiler.js.map +0 -1
- package/dist/esm/webpack/config.js +0 -236
- package/dist/esm/webpack/config.js.map +0 -1
- package/dist/esm/webpack/index.js +0 -5
- 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 -26
- package/dist/esm/webpack/loaders/wasm.js.map +0 -1
- package/dist/esm/webpack/plugins.js +0 -343
- package/dist/esm/webpack/plugins.js.map +0 -1
- package/dist/esm/webpack/utils.js +0 -160
- package/dist/esm/webpack/utils.js.map +0 -1
- package/dist/types/__fixtures__/configs/cjs.d.ts +0 -1
- package/dist/types/__fixtures__/configs/esm.d.ts +0 -3
- package/dist/types/__fixtures__/configs/invalid.d.ts +0 -3
- package/dist/types/__fixtures__/configs/javascript/snap.config.d.ts +0 -0
- package/dist/types/__fixtures__/configs/typescript/snap.config.d.ts +0 -3
- package/dist/types/builders.d.ts +0 -8
- package/dist/types/commands/build/build.d.ts +0 -10
- package/dist/types/commands/build/implementation.d.ts +0 -10
- package/dist/types/commands/build/index.d.ts +0 -10
- package/dist/types/commands/eval/__test__/browserify/bad/snap.config.d.ts +0 -3
- package/dist/types/commands/eval/__test__/browserify/good/snap.config.d.ts +0 -3
- package/dist/types/commands/eval/__test__/webpack/bad/snap.config.d.ts +0 -3
- package/dist/types/commands/eval/__test__/webpack/good/snap.config.d.ts +0 -3
- package/dist/types/commands/eval/__test__/webpack/snap.config.d.ts +0 -3
- package/dist/types/commands/eval/eval.d.ts +0 -14
- package/dist/types/commands/eval/implementation.d.ts +0 -9
- package/dist/types/commands/eval/index.d.ts +0 -10
- package/dist/types/commands/manifest/implementation.d.ts +0 -12
- package/dist/types/commands/manifest/index.d.ts +0 -10
- package/dist/types/commands/manifest/manifest.d.ts +0 -14
- package/dist/types/commands/serve/serve.d.ts +0 -16
- package/dist/types/commands/watch/implementation.d.ts +0 -14
- package/dist/types/commands/watch/index.d.ts +0 -10
- package/dist/types/commands/watch/watch.d.ts +0 -19
- package/dist/types/config.d.ts +0 -626
- package/dist/types/errors.d.ts +0 -25
- package/dist/types/index.d.ts +0 -5
- package/dist/types/utils/cli.d.ts +0 -17
- package/dist/types/utils/errors.d.ts +0 -23
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/legacy.d.ts +0 -27
- package/dist/types/utils/logging.d.ts +0 -22
- package/dist/types/utils/path.d.ts +0 -9
- package/dist/types/utils/steps.d.ts +0 -17
- package/dist/types/webpack/compiler.d.ts +0 -29
- package/dist/types/webpack/config.d.ts +0 -37
- package/dist/types/webpack/index.d.ts +0 -3
- package/dist/types/webpack/loaders/browserify.d.ts +0 -16
- package/dist/types/webpack/loaders/wasm.d.ts +0 -20
- package/dist/types/webpack/plugins.d.ts +0 -147
- package/dist/types/webpack/utils.d.ts +0 -156
- /package/dist/{types/commands → cmds}/index.d.ts +0 -0
- /package/dist/{types/main.d.ts → main.d.ts} +0 -0
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _default;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _browserify = /*#__PURE__*/ _interop_require_default(require("browserify"));
|
|
12
|
-
const _stream = require("stream");
|
|
13
|
-
const _builders = require("../../builders");
|
|
14
|
-
const _utils = require("../../utils");
|
|
15
|
-
const _utils1 = require("../utils");
|
|
16
|
-
function _interop_require_default(obj) {
|
|
17
|
-
return obj && obj.__esModule ? obj : {
|
|
18
|
-
default: obj
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* A Browserify loader for Webpack. This exists for backwards compatibility with
|
|
23
|
-
* the legacy configuration format, in order to support the `bundlerCustomizer`
|
|
24
|
-
* function.
|
|
25
|
-
*
|
|
26
|
-
* When this loader is used, the input file will be processed by Browserify, and
|
|
27
|
-
* written to disk by Webpack. Most processing will be handled by Browserify, so
|
|
28
|
-
* there are no benefits like tree-shaking.
|
|
29
|
-
*
|
|
30
|
-
* @param content - The input file contents as a string.
|
|
31
|
-
* @param sourceMap - The source map of the input file.
|
|
32
|
-
*/ const loader = async function(content, sourceMap) {
|
|
33
|
-
const config = this.getOptions();
|
|
34
|
-
const { transpilationMode } = config;
|
|
35
|
-
const bundler = (0, _browserify.default)({
|
|
36
|
-
extensions: [
|
|
37
|
-
'.js',
|
|
38
|
-
'.ts'
|
|
39
|
-
],
|
|
40
|
-
debug: Boolean(sourceMap),
|
|
41
|
-
standalone: '<snap>'
|
|
42
|
-
});
|
|
43
|
-
if (transpilationMode !== _builders.TranspilationModes.None) {
|
|
44
|
-
const babelifyOptions = (0, _utils.processDependencies)(config);
|
|
45
|
-
// We need to statically import all Browserify transforms, and all Babel
|
|
46
|
-
// presets and plugins, and calling `require` is the sanest way to do that.
|
|
47
|
-
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */ bundler.transform(require('babelify'), {
|
|
48
|
-
global: transpilationMode === _builders.TranspilationModes.LocalAndDeps,
|
|
49
|
-
extensions: [
|
|
50
|
-
'.js',
|
|
51
|
-
'.ts'
|
|
52
|
-
],
|
|
53
|
-
presets: [
|
|
54
|
-
require('@babel/preset-typescript'),
|
|
55
|
-
[
|
|
56
|
-
require('@babel/preset-env'),
|
|
57
|
-
{
|
|
58
|
-
targets: {
|
|
59
|
-
browsers: await (0, _utils1.getBrowserslistTargets)()
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
],
|
|
64
|
-
plugins: [
|
|
65
|
-
require('@babel/plugin-transform-runtime'),
|
|
66
|
-
require('@babel/plugin-proposal-class-properties'),
|
|
67
|
-
require('@babel/plugin-proposal-private-methods'),
|
|
68
|
-
require('@babel/plugin-proposal-class-static-block'),
|
|
69
|
-
require('@babel/plugin-proposal-private-property-in-object')
|
|
70
|
-
],
|
|
71
|
-
...babelifyOptions
|
|
72
|
-
});
|
|
73
|
-
/* eslint-enable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */ }
|
|
74
|
-
config.bundlerCustomizer?.(bundler);
|
|
75
|
-
// Browserify doesn't accept a string as an entry point, so we need to convert
|
|
76
|
-
// it to a stream.
|
|
77
|
-
const stream = new _stream.Readable();
|
|
78
|
-
stream.push(content);
|
|
79
|
-
stream.push(null);
|
|
80
|
-
bundler.add(stream, {
|
|
81
|
-
file: this.resourcePath
|
|
82
|
-
});
|
|
83
|
-
return new Promise((resolve, reject)=>{
|
|
84
|
-
bundler.bundle((bundleError, buffer)=>{
|
|
85
|
-
if (bundleError) {
|
|
86
|
-
reject(bundleError);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
// Browserify inlines the source map, so we just pass the output buffer back
|
|
90
|
-
// to Webpack.
|
|
91
|
-
resolve(buffer);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
const _default = loader;
|
|
96
|
-
|
|
97
|
-
//# sourceMappingURL=browserify.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/webpack/loaders/browserify.ts"],"sourcesContent":["import browserify from 'browserify';\nimport { Readable } from 'stream';\nimport type { LoaderDefinitionFunction } from 'webpack';\n\nimport { TranspilationModes } from '../../builders';\nimport type { LegacyOptions } from '../../config';\nimport { processDependencies } from '../../utils';\nimport { getBrowserslistTargets } from '../utils';\n\n/**\n * A Browserify loader for Webpack. This exists for backwards compatibility with\n * the legacy configuration format, in order to support the `bundlerCustomizer`\n * function.\n *\n * When this loader is used, the input file will be processed by Browserify, and\n * written to disk by Webpack. Most processing will be handled by Browserify, so\n * there are no benefits like tree-shaking.\n *\n * @param content - The input file contents as a string.\n * @param sourceMap - The source map of the input file.\n */\nconst loader: LoaderDefinitionFunction<LegacyOptions> = async function (\n content,\n sourceMap,\n) {\n const config = this.getOptions();\n\n const { transpilationMode } = config;\n\n const bundler = browserify({\n extensions: ['.js', '.ts'],\n debug: Boolean(sourceMap),\n standalone: '<snap>',\n });\n\n if (transpilationMode !== TranspilationModes.None) {\n const babelifyOptions = processDependencies(config);\n\n // We need to statically import all Browserify transforms, and all Babel\n // presets and plugins, and calling `require` is the sanest way to do that.\n /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */\n bundler.transform(require('babelify'), {\n global: transpilationMode === TranspilationModes.LocalAndDeps,\n extensions: ['.js', '.ts'],\n presets: [\n require('@babel/preset-typescript'),\n [\n require('@babel/preset-env'),\n {\n targets: {\n browsers: await getBrowserslistTargets(),\n },\n },\n ],\n ],\n plugins: [\n require('@babel/plugin-transform-runtime'),\n require('@babel/plugin-proposal-class-properties'),\n require('@babel/plugin-proposal-private-methods'),\n require('@babel/plugin-proposal-class-static-block'),\n require('@babel/plugin-proposal-private-property-in-object'),\n ],\n ...(babelifyOptions as any),\n });\n /* eslint-enable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */\n }\n\n config.bundlerCustomizer?.(bundler);\n\n // Browserify doesn't accept a string as an entry point, so we need to convert\n // it to a stream.\n const stream = new Readable();\n stream.push(content);\n stream.push(null);\n\n bundler.add(stream, {\n file: this.resourcePath,\n });\n\n return new Promise<Buffer>((resolve, reject) => {\n bundler.bundle((bundleError, buffer: Buffer) => {\n if (bundleError) {\n reject(bundleError);\n return;\n }\n\n // Browserify inlines the source map, so we just pass the output buffer back\n // to Webpack.\n resolve(buffer);\n });\n });\n};\n\nexport default loader;\n"],"names":["loader","content","sourceMap","config","getOptions","transpilationMode","bundler","browserify","extensions","debug","Boolean","standalone","TranspilationModes","None","babelifyOptions","processDependencies","transform","require","global","LocalAndDeps","presets","targets","browsers","getBrowserslistTargets","plugins","bundlerCustomizer","stream","Readable","push","add","file","resourcePath","Promise","resolve","reject","bundle","bundleError","buffer"],"mappings":";;;;+BA6FA;;;eAAA;;;mEA7FuB;wBACE;0BAGU;uBAEC;wBACG;;;;;;AAEvC;;;;;;;;;;;CAWC,GACD,MAAMA,SAAkD,eACtDC,OAAO,EACPC,SAAS;IAET,MAAMC,SAAS,IAAI,CAACC,UAAU;IAE9B,MAAM,EAAEC,iBAAiB,EAAE,GAAGF;IAE9B,MAAMG,UAAUC,IAAAA,mBAAU,EAAC;QACzBC,YAAY;YAAC;YAAO;SAAM;QAC1BC,OAAOC,QAAQR;QACfS,YAAY;IACd;IAEA,IAAIN,sBAAsBO,4BAAkB,CAACC,IAAI,EAAE;QACjD,MAAMC,kBAAkBC,IAAAA,0BAAmB,EAACZ;QAE5C,wEAAwE;QACxE,2EAA2E;QAC3E,8GAA8G,GAC9GG,QAAQU,SAAS,CAACC,QAAQ,aAAa;YACrCC,QAAQb,sBAAsBO,4BAAkB,CAACO,YAAY;YAC7DX,YAAY;gBAAC;gBAAO;aAAM;YAC1BY,SAAS;gBACPH,QAAQ;gBACR;oBACEA,QAAQ;oBACR;wBACEI,SAAS;4BACPC,UAAU,MAAMC,IAAAA,8BAAsB;wBACxC;oBACF;iBACD;aACF;YACDC,SAAS;gBACPP,QAAQ;gBACRA,QAAQ;gBACRA,QAAQ;gBACRA,QAAQ;gBACRA,QAAQ;aACT;YACD,GAAIH,eAAe;QACrB;IACA,6GAA6G,GAC/G;IAEAX,OAAOsB,iBAAiB,GAAGnB;IAE3B,8EAA8E;IAC9E,kBAAkB;IAClB,MAAMoB,SAAS,IAAIC,gBAAQ;IAC3BD,OAAOE,IAAI,CAAC3B;IACZyB,OAAOE,IAAI,CAAC;IAEZtB,QAAQuB,GAAG,CAACH,QAAQ;QAClBI,MAAM,IAAI,CAACC,YAAY;IACzB;IAEA,OAAO,IAAIC,QAAgB,CAACC,SAASC;QACnC5B,QAAQ6B,MAAM,CAAC,CAACC,aAAaC;YAC3B,IAAID,aAAa;gBACfF,OAAOE;gBACP;YACF;YAEA,4EAA4E;YAC5E,cAAc;YACdH,QAAQI;QACV;IACF;AACF;MAEA,WAAerC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, /**
|
|
6
|
-
* A Webpack loader that inlines the WASM module as a `Uint8Array`. This makes
|
|
7
|
-
* it possible to import the WASM module directly, and use it with the
|
|
8
|
-
* `WebAssembly.instantiate` function.
|
|
9
|
-
*
|
|
10
|
-
* This is useful, because snaps are not allowed to import assets from outside
|
|
11
|
-
* of their package. This loader allows you to inline the WASM module as a
|
|
12
|
-
* `Uint8Array`, which can then be passed to `WebAssembly.instantiate`.
|
|
13
|
-
*
|
|
14
|
-
* @param source - The WASM module as a string.
|
|
15
|
-
* @returns A string that exports the WASM module as a `Uint8Array`.
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* import wasm from './program.wasm';
|
|
19
|
-
*
|
|
20
|
-
* const { instance } = await WebAssembly.instantiate(wasm, {});
|
|
21
|
-
* // Do something with the WASM module...
|
|
22
|
-
* ```
|
|
23
|
-
*/ "default", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function() {
|
|
26
|
-
return loader;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
const _utils = require("@metamask/utils");
|
|
30
|
-
function loader(source) {
|
|
31
|
-
(0, _utils.assert)(typeof source === 'string', 'Expected source to be a string.');
|
|
32
|
-
const bytes = (0, _utils.stringToBytes)(source);
|
|
33
|
-
return `export default new Uint8Array(${JSON.stringify(Array.from(bytes))});`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=wasm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/webpack/loaders/wasm.ts"],"sourcesContent":["import { assert, stringToBytes } from '@metamask/utils';\n\n/**\n * A Webpack loader that inlines the WASM module as a `Uint8Array`. This makes\n * it possible to import the WASM module directly, and use it with the\n * `WebAssembly.instantiate` function.\n *\n * This is useful, because snaps are not allowed to import assets from outside\n * of their package. This loader allows you to inline the WASM module as a\n * `Uint8Array`, which can then be passed to `WebAssembly.instantiate`.\n *\n * @param source - The WASM module as a string.\n * @returns A string that exports the WASM module as a `Uint8Array`.\n * @example\n * ```ts\n * import wasm from './program.wasm';\n *\n * const { instance } = await WebAssembly.instantiate(wasm, {});\n * // Do something with the WASM module...\n * ```\n */\nexport default function loader(source: unknown) {\n assert(typeof source === 'string', 'Expected source to be a string.');\n\n const bytes = stringToBytes(source);\n return `export default new Uint8Array(${JSON.stringify(Array.from(bytes))});`;\n}\n"],"names":["loader","source","assert","bytes","stringToBytes","JSON","stringify","Array","from"],"mappings":";;;;+BAEA;;;;;;;;;;;;;;;;;;CAkBC,GACD;;;eAAwBA;;;uBArBc;AAqBvB,SAASA,OAAOC,MAAe;IAC5CC,IAAAA,aAAM,EAAC,OAAOD,WAAW,UAAU;IAEnC,MAAME,QAAQC,IAAAA,oBAAa,EAACH;IAC5B,OAAO,CAAC,8BAA8B,EAAEI,KAAKC,SAAS,CAACC,MAAMC,IAAI,CAACL,QAAQ,EAAE,CAAC;AAC/E"}
|
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
SnapsStatsPlugin: function() {
|
|
13
|
-
return SnapsStatsPlugin;
|
|
14
|
-
},
|
|
15
|
-
SnapsWatchPlugin: function() {
|
|
16
|
-
return SnapsWatchPlugin;
|
|
17
|
-
},
|
|
18
|
-
SnapsBuiltInResolver: function() {
|
|
19
|
-
return SnapsBuiltInResolver;
|
|
20
|
-
},
|
|
21
|
-
SnapsBundleWarningsPlugin: function() {
|
|
22
|
-
return SnapsBundleWarningsPlugin;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
26
|
-
const _utils = require("@metamask/utils");
|
|
27
|
-
const _chalk = require("chalk");
|
|
28
|
-
const _module = require("module");
|
|
29
|
-
const _eval = require("../commands/eval");
|
|
30
|
-
const _utils1 = require("../utils");
|
|
31
|
-
const _utils2 = require("./utils");
|
|
32
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
33
|
-
if (privateCollection.has(obj)) {
|
|
34
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
38
|
-
if (descriptor.get) {
|
|
39
|
-
return descriptor.get.call(receiver);
|
|
40
|
-
}
|
|
41
|
-
return descriptor.value;
|
|
42
|
-
}
|
|
43
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
44
|
-
if (descriptor.set) {
|
|
45
|
-
descriptor.set.call(receiver, value);
|
|
46
|
-
} else {
|
|
47
|
-
if (!descriptor.writable) {
|
|
48
|
-
throw new TypeError("attempted to set read only private field");
|
|
49
|
-
}
|
|
50
|
-
descriptor.value = value;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
54
|
-
if (!privateMap.has(receiver)) {
|
|
55
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
56
|
-
}
|
|
57
|
-
return privateMap.get(receiver);
|
|
58
|
-
}
|
|
59
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
60
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
61
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
62
|
-
}
|
|
63
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
64
|
-
_check_private_redeclaration(obj, privateMap);
|
|
65
|
-
privateMap.set(obj, value);
|
|
66
|
-
}
|
|
67
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
68
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
69
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
70
|
-
return value;
|
|
71
|
-
}
|
|
72
|
-
function _class_private_method_get(receiver, privateSet, fn) {
|
|
73
|
-
if (!privateSet.has(receiver)) {
|
|
74
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
75
|
-
}
|
|
76
|
-
return fn;
|
|
77
|
-
}
|
|
78
|
-
function _class_private_method_init(obj, privateSet) {
|
|
79
|
-
_check_private_redeclaration(obj, privateSet);
|
|
80
|
-
privateSet.add(obj);
|
|
81
|
-
}
|
|
82
|
-
function _define_property(obj, key, value) {
|
|
83
|
-
if (key in obj) {
|
|
84
|
-
Object.defineProperty(obj, key, {
|
|
85
|
-
value: value,
|
|
86
|
-
enumerable: true,
|
|
87
|
-
configurable: true,
|
|
88
|
-
writable: true
|
|
89
|
-
});
|
|
90
|
-
} else {
|
|
91
|
-
obj[key] = value;
|
|
92
|
-
}
|
|
93
|
-
return obj;
|
|
94
|
-
}
|
|
95
|
-
var _spinner = /*#__PURE__*/ new WeakMap(), /**
|
|
96
|
-
* Get the error message for the given stats error.
|
|
97
|
-
*
|
|
98
|
-
* @param statsError - The stats error.
|
|
99
|
-
* @returns The error message.
|
|
100
|
-
*/ _getStatsErrorMessage = /*#__PURE__*/ new WeakSet();
|
|
101
|
-
class SnapsStatsPlugin {
|
|
102
|
-
/**
|
|
103
|
-
* Apply the plugin to the Webpack compiler.
|
|
104
|
-
*
|
|
105
|
-
* @param compiler - The Webpack compiler.
|
|
106
|
-
*/ apply(compiler) {
|
|
107
|
-
compiler.hooks.afterDone.tap(this.constructor.name, (stats)=>{
|
|
108
|
-
if (!stats) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const { modules, time, errors } = stats.toJson();
|
|
112
|
-
(0, _utils.assert)(modules, 'Modules must be defined in stats.');
|
|
113
|
-
(0, _utils.assert)(time, 'Time must be defined in stats.');
|
|
114
|
-
if (errors?.length) {
|
|
115
|
-
const formattedErrors = errors.map(_class_private_method_get(this, _getStatsErrorMessage, getStatsErrorMessage).bind(this)).join('\n\n');
|
|
116
|
-
(0, _utils1.error)(`Compiled ${modules.length} ${(0, _utils2.pluralize)(modules.length, 'file')} in ${time}ms with ${errors.length} ${(0, _utils2.pluralize)(errors.length, 'error')}.\n\n${formattedErrors}\n`, _class_private_field_get(this, _spinner));
|
|
117
|
-
_class_private_field_get(this, _spinner)?.stop();
|
|
118
|
-
process.exitCode = 1;
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
(0, _utils1.info)(`Compiled ${modules.length} ${(0, _utils2.pluralize)(modules.length, 'file')} in ${time}ms.`, _class_private_field_get(this, _spinner));
|
|
122
|
-
if (compiler.watchMode) {
|
|
123
|
-
// The spinner may be restarted by the watch plugin, outside of the
|
|
124
|
-
// `executeSteps` flow, so we stop it here just in case.
|
|
125
|
-
_class_private_field_get(this, _spinner)?.succeed('Done!');
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
constructor(options = {
|
|
130
|
-
verbose: false
|
|
131
|
-
}, spinner){
|
|
132
|
-
_class_private_method_init(this, _getStatsErrorMessage);
|
|
133
|
-
/**
|
|
134
|
-
* The options for the plugin.
|
|
135
|
-
*/ _define_property(this, "options", void 0);
|
|
136
|
-
/**
|
|
137
|
-
* The spinner to use for logging.
|
|
138
|
-
*/ _class_private_field_init(this, _spinner, {
|
|
139
|
-
writable: true,
|
|
140
|
-
value: void 0
|
|
141
|
-
});
|
|
142
|
-
this.options = options;
|
|
143
|
-
_class_private_field_set(this, _spinner, spinner);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function getStatsErrorMessage(statsError) {
|
|
147
|
-
const baseMessage = this.options.verbose ? (0, _utils1.getErrorMessage)(statsError) : statsError.message;
|
|
148
|
-
const [first, ...rest] = baseMessage.split('\n');
|
|
149
|
-
return [
|
|
150
|
-
(0, _snapsutils.indent)((0, _chalk.red)(`• ${first}`), 2),
|
|
151
|
-
...rest.map((message)=>(0, _snapsutils.indent)((0, _chalk.red)(message), 4)),
|
|
152
|
-
statsError.details && (0, _snapsutils.indent)((0, _chalk.dim)(statsError.details), 4)
|
|
153
|
-
].filter(Boolean).join('\n');
|
|
154
|
-
}
|
|
155
|
-
var _spinner1 = /*#__PURE__*/ new WeakMap(), _safeEvaluate = /*#__PURE__*/ new WeakSet();
|
|
156
|
-
class SnapsWatchPlugin {
|
|
157
|
-
/**
|
|
158
|
-
* Apply the plugin to the Webpack compiler.
|
|
159
|
-
*
|
|
160
|
-
* @param compiler - The Webpack compiler.
|
|
161
|
-
*/ apply(compiler) {
|
|
162
|
-
compiler.hooks.invalid.tap(this.constructor.name, (file)=>{
|
|
163
|
-
_class_private_field_get(this, _spinner1)?.start();
|
|
164
|
-
(0, _utils1.info)(`Changes detected in ${(0, _chalk.yellow)(file)}, recompiling.`, _class_private_field_get(this, _spinner1));
|
|
165
|
-
});
|
|
166
|
-
compiler.hooks.afterEmit.tapPromise(this.constructor.name, async ({ fileDependencies })=>{
|
|
167
|
-
this.options.files?.forEach(fileDependencies.add.bind(fileDependencies));
|
|
168
|
-
if (this.options.bundle && this.options.evaluate) {
|
|
169
|
-
await _class_private_method_get(this, _safeEvaluate, safeEvaluate).call(this, this.options.bundle);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
constructor(options, spinner){
|
|
174
|
-
/**
|
|
175
|
-
* Safely evaluate the bundle at the given path. If an error occurs, it will
|
|
176
|
-
* be logged to the console, rather than throwing an error.
|
|
177
|
-
*
|
|
178
|
-
* This function should never throw an error.
|
|
179
|
-
*
|
|
180
|
-
* @param bundlePath - The path to the bundle.
|
|
181
|
-
*/ _class_private_method_init(this, _safeEvaluate);
|
|
182
|
-
/**
|
|
183
|
-
* The options for the plugin.
|
|
184
|
-
*/ _define_property(this, "options", void 0);
|
|
185
|
-
/**
|
|
186
|
-
* The spinner to use for logging.
|
|
187
|
-
*/ _class_private_field_init(this, _spinner1, {
|
|
188
|
-
writable: true,
|
|
189
|
-
value: void 0
|
|
190
|
-
});
|
|
191
|
-
this.options = options;
|
|
192
|
-
_class_private_field_set(this, _spinner1, spinner);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
async function safeEvaluate(bundlePath) {
|
|
196
|
-
try {
|
|
197
|
-
await (0, _eval.evaluate)(bundlePath);
|
|
198
|
-
(0, _utils1.info)(`Snap bundle evaluated successfully.`, _class_private_field_get(this, _spinner1));
|
|
199
|
-
} catch (evaluateError) {
|
|
200
|
-
(0, _utils1.error)(evaluateError.message, _class_private_field_get(this, _spinner1));
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
var _source = /*#__PURE__*/ new WeakMap(), _spinner2 = /*#__PURE__*/ new WeakMap();
|
|
204
|
-
class SnapsBuiltInResolver {
|
|
205
|
-
/**
|
|
206
|
-
* Apply the plugin to the Webpack resolver.
|
|
207
|
-
*
|
|
208
|
-
* @param resolver - The Webpack resolver.
|
|
209
|
-
*/ apply(resolver) {
|
|
210
|
-
resolver.getHook(_class_private_field_get(this, _source)).tapAsync(this.constructor.name, ({ module: isModule, request }, _, callback)=>{
|
|
211
|
-
if (!isModule || !request) {
|
|
212
|
-
return callback();
|
|
213
|
-
}
|
|
214
|
-
const baseRequest = request.split('/')[0];
|
|
215
|
-
if ((0, _module.isBuiltin)(baseRequest) && !this.options.ignore?.includes(baseRequest)) {
|
|
216
|
-
const fallback = resolver.options.fallback.find(({ name })=>name === baseRequest);
|
|
217
|
-
if (fallback && !fallback.alias) {
|
|
218
|
-
this.unresolvedModules.add(baseRequest);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return callback();
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
constructor(options = {
|
|
225
|
-
ignore: []
|
|
226
|
-
}, spinner){
|
|
227
|
-
/**
|
|
228
|
-
* The built-in modules that have been imported, but not resolved.
|
|
229
|
-
*/ _define_property(this, "unresolvedModules", new Set());
|
|
230
|
-
/**
|
|
231
|
-
* The name of the resolver hook to tap into.
|
|
232
|
-
*/ _class_private_field_init(this, _source, {
|
|
233
|
-
writable: true,
|
|
234
|
-
value: 'described-resolve'
|
|
235
|
-
});
|
|
236
|
-
/**
|
|
237
|
-
* The options for the plugin.
|
|
238
|
-
*/ _define_property(this, "options", void 0);
|
|
239
|
-
/**
|
|
240
|
-
* The spinner to use for logging.
|
|
241
|
-
*/ _class_private_field_init(this, _spinner2, {
|
|
242
|
-
writable: true,
|
|
243
|
-
value: void 0
|
|
244
|
-
});
|
|
245
|
-
this.options = options;
|
|
246
|
-
_class_private_field_set(this, _spinner2, spinner);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
var _spinner3 = /*#__PURE__*/ new WeakMap(), /**
|
|
250
|
-
* Check if a built-in module is used, but not provided by Webpack's
|
|
251
|
-
* `fallback` configuration.
|
|
252
|
-
*
|
|
253
|
-
* @param compiler - The Webpack compiler.
|
|
254
|
-
*/ _checkBuiltIns = /*#__PURE__*/ new WeakSet(), /**
|
|
255
|
-
* Check if the given instance is a `ProvidePlugin`. This is not guaranteed to
|
|
256
|
-
* be accurate, but it's good enough for our purposes. If we were to use
|
|
257
|
-
* `instanceof` instead, it might not work if multiple versions of Webpack are
|
|
258
|
-
* installed.
|
|
259
|
-
*
|
|
260
|
-
* @param instance - The instance to check.
|
|
261
|
-
* @returns Whether the instance is a `ProvidePlugin`, i.e., whether it's an
|
|
262
|
-
* object with the name `ProvidePlugin` and a `definitions` property.
|
|
263
|
-
*/ _isProvidePlugin = /*#__PURE__*/ new WeakSet(), /**
|
|
264
|
-
* Check if the `Buffer` global is used, but not provided by Webpack's
|
|
265
|
-
* `DefinePlugin`.
|
|
266
|
-
*
|
|
267
|
-
* @param compiler - The Webpack compiler.
|
|
268
|
-
*/ _checkBuffer = /*#__PURE__*/ new WeakSet();
|
|
269
|
-
class SnapsBundleWarningsPlugin {
|
|
270
|
-
/**
|
|
271
|
-
* Apply the plugin to the Webpack compiler.
|
|
272
|
-
*
|
|
273
|
-
* @param compiler - The Webpack compiler.
|
|
274
|
-
*/ apply(compiler) {
|
|
275
|
-
if (this.options.builtIns) {
|
|
276
|
-
_class_private_method_get(this, _checkBuiltIns, checkBuiltIns).call(this, compiler);
|
|
277
|
-
}
|
|
278
|
-
if (this.options.buffer) {
|
|
279
|
-
_class_private_method_get(this, _checkBuffer, checkBuffer).call(this, compiler);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
constructor(options = {
|
|
283
|
-
buffer: true,
|
|
284
|
-
builtIns: true
|
|
285
|
-
}, spinner){
|
|
286
|
-
_class_private_method_init(this, _checkBuiltIns);
|
|
287
|
-
_class_private_method_init(this, _isProvidePlugin);
|
|
288
|
-
_class_private_method_init(this, _checkBuffer);
|
|
289
|
-
/**
|
|
290
|
-
* The spinner to use for logging.
|
|
291
|
-
*/ _class_private_field_init(this, _spinner3, {
|
|
292
|
-
writable: true,
|
|
293
|
-
value: void 0
|
|
294
|
-
});
|
|
295
|
-
/**
|
|
296
|
-
* The options for the plugin.
|
|
297
|
-
*/ _define_property(this, "options", void 0);
|
|
298
|
-
this.options = options;
|
|
299
|
-
_class_private_field_set(this, _spinner3, spinner);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
function checkBuiltIns(compiler) {
|
|
303
|
-
compiler.hooks.afterCompile.tap(this.constructor.name, ()=>{
|
|
304
|
-
if (!this.options.builtInResolver) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
const { unresolvedModules } = this.options.builtInResolver;
|
|
308
|
-
if (unresolvedModules.size === 0) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
const formattedModules = new Array(...unresolvedModules).map((name)=>(0, _snapsutils.indent)(`• ${name}`, 2)).join('\n');
|
|
312
|
-
(0, _utils1.warn)(`The snap attempted to use one or more Node.js builtins, but no browser fallback has been provided.\n` + `The MetaMask Snaps CLI does not support Node.js builtins by default. If you want to use this module, you must provide a fallback: https://webpack.js.org/configuration/resolve/#resolvefallback.\n` + `To disable this warning, set ${(0, _chalk.yellow)('`stats.builtIns`')} to ${(0, _chalk.yellow)('`false`')} in your snap config file, or add the module to the ${(0, _chalk.yellow)('`stats.builtIns.ignore`')} array.\n\n${formattedModules}\n`, _class_private_field_get(this, _spinner3));
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
function isProvidePlugin(instance) {
|
|
316
|
-
return (0, _utils.isObject)(instance) && instance.constructor.name === 'ProvidePlugin' && (0, _utils.hasProperty)(instance, 'definitions');
|
|
317
|
-
}
|
|
318
|
-
function checkBuffer(compiler) {
|
|
319
|
-
const plugin = compiler.options.plugins?.find((instance)=>_class_private_method_get(this, _isProvidePlugin, isProvidePlugin).call(this, instance));
|
|
320
|
-
// If the `ProvidePlugin` is configured to provide `Buffer`, then we don't
|
|
321
|
-
// need to warn the user.
|
|
322
|
-
if (plugin) {
|
|
323
|
-
const { definitions } = plugin;
|
|
324
|
-
if (definitions.Buffer) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
compiler.hooks.compilation.tap(this.constructor.name, (compilation)=>{
|
|
329
|
-
compilation.hooks.afterProcessAssets.tap(this.constructor.name, (assets)=>{
|
|
330
|
-
// Check if assets use `Buffer`.
|
|
331
|
-
const bufferAssets = Object.entries(assets).filter(([name])=>name.endsWith('.js')).filter(([, asset])=>asset.source().includes('Buffer'));
|
|
332
|
-
if (bufferAssets.length === 0) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
(0, _utils1.warn)(`The snap attempted to use the Node.js Buffer global, which is not supported by the MetaMask Snaps CLI.\n` + `To use the Buffer global, you must use the ${(0, _chalk.yellow)('`ProvidePlugin`')} to inject it: https://webpack.js.org/plugins/provide-plugin/.\n` + `To disable this warning, set ${(0, _chalk.yellow)('`stats.buffer`')} to ${(0, _chalk.yellow)('`false`')} in your snap config file.`, _class_private_field_get(this, _spinner3));
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
//# sourceMappingURL=plugins.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/webpack/plugins.ts"],"sourcesContent":["import { indent } from '@metamask/snaps-utils';\nimport { assert, hasProperty, isObject } from '@metamask/utils';\nimport { 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';\n\nimport { evaluate } from '../commands/eval';\nimport { error, getErrorMessage, info, warn } from '../utils';\nimport { 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 } = 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(this.#getStatsErrorMessage.bind(this))\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 info(\n `Compiled ${modules.length} ${pluralize(\n modules.length,\n 'file',\n )} in ${time}ms.`,\n this.#spinner,\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 * @returns The error message.\n */\n #getStatsErrorMessage(statsError: StatsError) {\n const baseMessage = this.options.verbose\n ? getErrorMessage(statsError)\n : statsError.message;\n\n const [first, ...rest] = baseMessage.split('\\n');\n\n return [\n indent(red(`• ${first}`), 2),\n ...rest.map((message) => indent(red(message), 4)),\n statsError.details && indent(dim(statsError.details), 4),\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 spinner to use for logging.\n */\n readonly #spinner?: Ora;\n\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 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 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, () => {\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) => indent(`• ${name}`, 2))\n .join('\\n');\n\n warn(\n `The snap attempted to use one or more Node.js builtins, but no browser fallback has been provided.\\n` +\n `The MetaMask Snaps CLI does not support Node.js builtins by default. If you want to use this module, you must provide a fallback: https://webpack.js.org/configuration/resolve/#resolvefallback.\\n` +\n `To disable this warning, set ${yellow(\n '`stats.builtIns`',\n )} to ${yellow(\n '`false`',\n )} in your snap config file, or add the module to the ${yellow(\n '`stats.builtIns.ignore`',\n )} array.\\n\\n${formattedModules}\\n`,\n this.#spinner,\n );\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 warn(\n `The snap attempted to use the Node.js Buffer global, which is not supported by the MetaMask Snaps CLI.\\n` +\n `To use the Buffer global, you must use the ${yellow(\n '`ProvidePlugin`',\n )} to inject it: https://webpack.js.org/plugins/provide-plugin/.\\n` +\n `To disable this warning, set ${yellow(\n '`stats.buffer`',\n )} to ${yellow('`false`')} in your snap config file.`,\n this.#spinner,\n );\n },\n );\n });\n }\n}\n"],"names":["SnapsStatsPlugin","SnapsWatchPlugin","SnapsBuiltInResolver","SnapsBundleWarningsPlugin","apply","compiler","hooks","afterDone","tap","constructor","name","stats","modules","time","errors","toJson","assert","length","formattedErrors","map","getStatsErrorMessage","bind","join","error","pluralize","spinner","stop","process","exitCode","info","watchMode","succeed","options","verbose","statsError","baseMessage","getErrorMessage","message","first","rest","split","indent","red","details","dim","filter","Boolean","invalid","file","start","yellow","afterEmit","tapPromise","fileDependencies","files","forEach","add","bundle","evaluate","safeEvaluate","bundlePath","evaluateError","resolver","getHook","source","tapAsync","module","isModule","request","_","callback","baseRequest","isBuiltin","ignore","includes","fallback","find","alias","unresolvedModules","Set","builtIns","checkBuiltIns","buffer","checkBuffer","afterCompile","builtInResolver","size","formattedModules","Array","warn","instance","isObject","hasProperty","plugin","plugins","isProvidePlugin","definitions","Buffer","compilation","afterProcessAssets","assets","bufferAssets","Object","entries","endsWith","asset"],"mappings":";;;;;;;;;;;IA6BaA,gBAAgB;eAAhBA;;IA6HAC,gBAAgB;eAAhBA;;IA2EAC,oBAAoB;eAApBA;;IA0GAC,yBAAyB;eAAzBA;;;4BA/UU;uBACuB;uBACb;wBACP;sBAWD;wBAC0B;wBACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsBf,wCAkET;;;;;GAKC,GACD;AAjFK,MAAMH;IAqBX;;;;GAIC,GACDI,MAAMC,QAAkB,EAAE;QACxBA,SAASC,KAAK,CAACC,SAAS,CAACC,GAAG,CAAC,IAAI,CAACC,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