@forge/bundler 6.0.0-next.8 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,115 @@
1
1
  # @forge/bundler
2
2
 
3
+ ## 6.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 8f2a3c9: Update the package to build on Node 20
8
+
9
+ ### Minor Changes
10
+
11
+ - ba634d9: Remove further sandbox runtime related components
12
+
13
+ ### Patch Changes
14
+
15
+ - 75b7732: Remove feature flag for single wrapper packaging
16
+ - 64befbb: Refactor runtime version manifest check into a linter
17
+ - Updated dependencies [a7bd152]
18
+ - Updated dependencies [67bff6d]
19
+ - Updated dependencies [73a88f6]
20
+ - Updated dependencies [33c5750]
21
+ - Updated dependencies [dd7cad7]
22
+ - Updated dependencies [e4ab25f]
23
+ - Updated dependencies [0c92352]
24
+ - Updated dependencies [8f2a3c9]
25
+ - Updated dependencies [1992aaf]
26
+ - Updated dependencies [75b7732]
27
+ - Updated dependencies [b44a5b3]
28
+ - Updated dependencies [c3df542]
29
+ - Updated dependencies [9f050ff]
30
+ - Updated dependencies [e6cd96a]
31
+ - Updated dependencies [97255de]
32
+ - Updated dependencies [3d96d1c]
33
+ - Updated dependencies [18eab48]
34
+ - Updated dependencies [be59801]
35
+ - Updated dependencies [8a548ce]
36
+ - Updated dependencies [37eba69]
37
+ - Updated dependencies [c2e09b9]
38
+ - Updated dependencies [ba634d9]
39
+ - Updated dependencies [64befbb]
40
+ - Updated dependencies [d33186c]
41
+ - @forge/manifest@10.0.0
42
+ - @forge/lint@5.9.0
43
+ - @forge/cli-shared@8.0.0
44
+
45
+ ## 6.0.0-next.15
46
+
47
+ ### Patch Changes
48
+
49
+ - Updated dependencies [67bff6d]
50
+ - Updated dependencies [3d96d1c]
51
+ - @forge/lint@5.9.0-next.15
52
+ - @forge/manifest@10.0.0-next.13
53
+ - @forge/cli-shared@8.0.0-next.15
54
+
55
+ ## 6.0.0-next.14
56
+
57
+ ### Minor Changes
58
+
59
+ - ba634d9: Remove further sandbox runtime related components
60
+
61
+ ### Patch Changes
62
+
63
+ - Updated dependencies [ba634d9]
64
+ - @forge/cli-shared@8.0.0-next.14
65
+ - @forge/manifest@10.0.0-next.12
66
+ - @forge/lint@5.9.0-next.14
67
+
68
+ ## 6.0.0-next.13
69
+
70
+ ### Patch Changes
71
+
72
+ - Updated dependencies [1992aaf]
73
+ - Updated dependencies [c2e09b9]
74
+ - @forge/manifest@10.0.0-next.11
75
+ - @forge/cli-shared@8.0.0-next.13
76
+ - @forge/lint@5.9.0-next.13
77
+
78
+ ## 6.0.0-next.12
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [d33186c]
83
+ - @forge/cli-shared@8.0.0-next.12
84
+ - @forge/lint@5.9.0-next.12
85
+
86
+ ## 6.0.0-next.11
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies [e6cd96a]
91
+ - @forge/manifest@10.0.0-next.10
92
+ - @forge/cli-shared@8.0.0-next.11
93
+ - @forge/lint@5.9.0-next.11
94
+
95
+ ## 6.0.0-next.10
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies [33c5750]
100
+ - @forge/manifest@10.0.0-next.9
101
+ - @forge/cli-shared@8.0.0-next.10
102
+ - @forge/lint@5.9.0-next.10
103
+
104
+ ## 6.0.0-next.9
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies [37eba69]
109
+ - @forge/manifest@10.0.0-next.8
110
+ - @forge/cli-shared@8.0.0-next.9
111
+ - @forge/lint@5.9.0-next.9
112
+
3
113
  ## 6.0.0-next.8
4
114
 
5
115
  ### Major Changes
package/out/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { getOutputDir, getEntryPoints } from './common';
2
2
  export { runLinter } from './lint';
3
3
  export { NativeUIBundler, NativeUIBundleResult } from './nativeui';
4
- export { SandboxBundler, getNodeBundler, NODE_RUNTIME_CODE_FILE } from './runtime';
4
+ export { getNodeBundler, NODE_RUNTIME_CODE_FILE } from './runtime';
5
5
  export { Bundler, BundlerError, BundlerOutput, BundlerWatch, EntryPoint, WatcherMonitor } from './types';
6
6
  export { getCompiler, handleWebpackCompilationResult } from './webpack';
7
7
  export { getNativeUiBuildConfig } from './config/nativeui';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
package/out/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalWrapperProvider = exports.getWrapperProvider = exports.getNativeUiBuildConfig = exports.handleWebpackCompilationResult = exports.getCompiler = exports.BundlerError = exports.NODE_RUNTIME_CODE_FILE = exports.getNodeBundler = exports.SandboxBundler = exports.NativeUIBundler = exports.runLinter = exports.getEntryPoints = exports.getOutputDir = void 0;
3
+ exports.LocalWrapperProvider = exports.getWrapperProvider = exports.getNativeUiBuildConfig = exports.handleWebpackCompilationResult = exports.getCompiler = exports.BundlerError = exports.NODE_RUNTIME_CODE_FILE = exports.getNodeBundler = exports.NativeUIBundler = exports.runLinter = exports.getEntryPoints = exports.getOutputDir = void 0;
4
4
  var common_1 = require("./common");
5
5
  Object.defineProperty(exports, "getOutputDir", { enumerable: true, get: function () { return common_1.getOutputDir; } });
6
6
  Object.defineProperty(exports, "getEntryPoints", { enumerable: true, get: function () { return common_1.getEntryPoints; } });
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "runLinter", { enumerable: true, get: function ()
9
9
  var nativeui_1 = require("./nativeui");
10
10
  Object.defineProperty(exports, "NativeUIBundler", { enumerable: true, get: function () { return nativeui_1.NativeUIBundler; } });
11
11
  var runtime_1 = require("./runtime");
12
- Object.defineProperty(exports, "SandboxBundler", { enumerable: true, get: function () { return runtime_1.SandboxBundler; } });
13
12
  Object.defineProperty(exports, "getNodeBundler", { enumerable: true, get: function () { return runtime_1.getNodeBundler; } });
14
13
  Object.defineProperty(exports, "NODE_RUNTIME_CODE_FILE", { enumerable: true, get: function () { return runtime_1.NODE_RUNTIME_CODE_FILE; } });
15
14
  var types_1 = require("./types");
package/out/runtime.d.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  import { ConfigReader } from '@forge/cli-shared';
2
- import { BundleLogger, Bundler, BundlerArgs } from './types';
3
- import { ConfigWithOutput, WebpackBundler } from './webpack';
2
+ import { BundleLogger, Bundler } from './types';
4
3
  import { WrapperProvider } from './wrapper-provider';
5
- export declare class SandboxBundler extends WebpackBundler {
6
- constructor(logger: BundleLogger);
7
- getConfig(args: BundlerArgs): Promise<ConfigWithOutput>;
8
- }
9
4
  export declare const NODE_RUNTIME_CODE_FILE = "__forge__.cjs";
10
5
  export declare function userCodePath(entryKey: string): string;
11
6
  export declare function getNodeBundler(logger: BundleLogger, wrapperProvider: WrapperProvider, configReader: ConfigReader): Bundler;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAqD,MAAM,mBAAmB,CAAC;AAIpG,OAAO,EACL,YAAY,EACZ,OAAO,EACP,WAAW,EAKZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAiB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGpE,qBAAa,cAAe,SAAQ,cAAc;gBACpC,MAAM,EAAE,YAAY;IAI1B,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAG9D;AAKD,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAoBtD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAsJD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GACzB,OAAO,CAET"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAqD,MAAM,mBAAmB,CAAC;AAGpG,OAAO,EACL,YAAY,EACZ,OAAO,EAMR,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAiB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAMpE,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAoBtD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAsJD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GACzB,OAAO,CAET"}
package/out/runtime.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNodeBundler = exports.userCodePath = exports.NODE_RUNTIME_CODE_FILE = exports.SandboxBundler = void 0;
3
+ exports.getNodeBundler = exports.userCodePath = exports.NODE_RUNTIME_CODE_FILE = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const path_1 = tslib_1.__importDefault(require("path"));
6
6
  const promises_1 = tslib_1.__importDefault(require("fs/promises"));
@@ -8,19 +8,9 @@ const webpack_1 = tslib_1.__importDefault(require("webpack"));
8
8
  var RawSource = webpack_1.default.sources.RawSource;
9
9
  const cli_shared_1 = require("@forge/cli-shared");
10
10
  const common_1 = require("./config/common");
11
- const sandbox_1 = require("./config/sandbox");
12
11
  const typescript_1 = require("./typescript");
13
12
  const webpack_2 = require("./webpack");
14
13
  const i18n_1 = require("@forge/i18n");
15
- class SandboxBundler extends webpack_2.WebpackBundler {
16
- constructor(logger) {
17
- super(logger);
18
- }
19
- async getConfig(args) {
20
- return (0, sandbox_1.getSandboxedRuntimeBuildConfig)(args);
21
- }
22
- }
23
- exports.SandboxBundler = SandboxBundler;
24
14
  exports.NODE_RUNTIME_CODE_FILE = '__forge__.cjs';
25
15
  const NODE_RUNTIME_BACKUP_WRAPPER_FILE = '__forge_wrapper__.cjs';
26
16
  const NODE_RUNTIME_USE_LOCAL_WRAPPER_FILE = '__forge_use_local_wrapper.txt';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/bundler",
3
- "version": "6.0.0-next.8",
3
+ "version": "6.0.0",
4
4
  "description": "Default bundler for Forge apps",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Atlassian",
@@ -18,56 +18,32 @@
18
18
  "@babel/plugin-transform-numeric-separator": "^7.23.4",
19
19
  "@babel/plugin-transform-optional-chaining": "^7.23.4",
20
20
  "@babel/plugin-transform-react-jsx": "^7.23.4",
21
- "@forge/api": "6.0.0-next.0",
22
- "@forge/cli-shared": "8.0.0-next.8",
21
+ "@forge/cli-shared": "8.0.0",
23
22
  "@forge/i18n": "0.0.6",
24
- "@forge/lint": "5.9.0-next.8",
25
- "@forge/manifest": "10.0.0-next.7",
23
+ "@forge/lint": "5.9.0",
24
+ "@forge/manifest": "10.0.0",
26
25
  "@forge/util": "1.4.9",
27
- "assert": "^2.1.0",
28
26
  "babel-loader": "^8.3.0",
29
- "browserify-zlib": "^0.2.0",
30
- "buffer": "^6.0.3",
31
- "chalk": "^4.1.2",
32
27
  "cheerio": "^0.22.0",
33
- "console-browserify": "^1.2.0",
34
28
  "cross-spawn": "^7.0.5",
35
- "crypto-browserify": "^3.12.0",
36
- "events": "^3.3.0",
37
29
  "fs-extra": "^11.2.0",
38
- "headers-utils": "^3.0.2",
39
30
  "html-webpack-plugin": "^5.6.0",
40
- "inherits": "^2.0.4",
41
- "memfs": "^4.6.0",
42
31
  "nock": "13.5.4",
43
32
  "node-fetch": "2.7.0",
44
- "os-browserify": "^0.3.0",
45
- "path-browserify": "^1.0.1",
46
- "process": "^0.11.10",
47
- "punycode": "^2.3.1",
48
- "querystring-browser": "^1.0.4",
49
- "readable-stream": "^4.5.2",
50
- "string_decoder": "^1.3.0",
51
- "text-encoder-lite": "^2.0.0",
52
- "timers-browserify": "^2.0.12",
53
33
  "tmp": "^0.2.3",
54
34
  "ts-loader": "^9.5.1",
55
35
  "typescript": "4.8.4",
56
- "url": "^0.11.3",
57
- "util": "^0.12.5",
58
36
  "webpack": "5.94.0",
59
- "webpack-bundle-analyzer": "^4.10.1",
60
- "whatwg-url": "^12.0.1"
37
+ "webpack-bundle-analyzer": "^4.10.1"
61
38
  },
62
39
  "devDependencies": {
63
40
  "@atlassian/xen-test-util": "^4.2.0",
64
- "@forge/runtime": "6.0.0-next.0",
41
+ "@forge/runtime": "6.0.0",
65
42
  "@types/cross-spawn": "^6.0.6",
66
43
  "@types/fs-extra": "^11.0.4",
67
44
  "@types/jest": "^29.5.12",
68
45
  "@types/node": "20.19.0",
69
46
  "@types/react": "^18.2.64",
70
- "@types/readable-stream": "^4.0.10",
71
47
  "@types/webpack-bundle-analyzer": "^4.7.0",
72
48
  "@typescript-eslint/eslint-plugin": "^5.62.0",
73
49
  "@typescript-eslint/parser": "^5.62.0",
@@ -1,5 +0,0 @@
1
- import { CommonWebpackConfig } from './common';
2
- import { BundlerArgs } from '../types';
3
- export declare const SANDBOXED_WEBPACK_CONFIG_NAME = "sandboxed-runtime";
4
- export declare const getSandboxedRuntimeBuildConfig: (args: BundlerArgs) => CommonWebpackConfig;
5
- //# sourceMappingURL=sandbox.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/config/sandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAA8D,MAAM,UAAU,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,6BAA6B,sBAAsB,CAAC;AA0DjE,eAAO,MAAM,8BAA8B,SAAU,WAAW,KAAG,mBAwElE,CAAC"}
@@ -1,112 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSandboxedRuntimeBuildConfig = exports.SANDBOXED_WEBPACK_CONFIG_NAME = void 0;
4
- const tslib_1 = require("tslib");
5
- const webpack_1 = tslib_1.__importDefault(require("webpack"));
6
- const stub_plugin_1 = require("../stub-plugin");
7
- const common_1 = require("./common");
8
- exports.SANDBOXED_WEBPACK_CONFIG_NAME = 'sandboxed-runtime';
9
- const getCustomModulesAliases = () => {
10
- return {
11
- 'browserify-cipher': (0, common_1.resolveModulePath)('browserify-cipher/browser.js'),
12
- 'browserify-sign/algos': (0, common_1.resolveModulePath)('browserify-sign/algos.js'),
13
- 'browserify-sign': (0, common_1.resolveModulePath)('browserify-sign/browser/index.js'),
14
- 'create-ecdh': (0, common_1.resolveModulePath)('create-ecdh/browser.js'),
15
- 'create-hash/md5': (0, common_1.resolveModulePath)('create-hash/md5.js'),
16
- 'create-hash': (0, common_1.resolveModulePath)('create-hash/browser.js'),
17
- 'create-hmac': (0, common_1.resolveModulePath)('create-hmac/browser.js'),
18
- 'diffie-hellman': (0, common_1.resolveModulePath)('diffie-hellman/browser.js'),
19
- pbkdf2: (0, common_1.resolveModulePath)('pbkdf2/browser.js'),
20
- 'public-encrypt': (0, common_1.resolveModulePath)('public-encrypt/browser.js'),
21
- randombytes: (0, common_1.resolveModulePath)('randombytes/browser.js'),
22
- randomfill: (0, common_1.resolveModulePath)('randomfill/browser.js'),
23
- assert: (0, common_1.resolveModulePath)('assert/'),
24
- buffer: (0, common_1.resolveModulePath)('buffer/'),
25
- console: (0, common_1.resolveModulePath)('console-browserify'),
26
- crypto: (0, common_1.resolveModulePath)('crypto-browserify'),
27
- events: (0, common_1.resolveModulePath)('events/'),
28
- inherits: (0, common_1.resolveModulePath)('inherits/inherits_browser.js'),
29
- os: (0, common_1.resolveModulePath)('os-browserify/browser'),
30
- punycode: (0, common_1.resolveModulePath)('punycode/'),
31
- process: (0, common_1.resolveModulePath)('process/browser.js'),
32
- string_decoder: (0, common_1.resolveModulePath)('string_decoder/'),
33
- timers: (0, common_1.resolveModulePath)('timers-browserify'),
34
- url: (0, common_1.resolveModulePath)('url/'),
35
- util: (0, common_1.resolveModulePath)('util/'),
36
- zlib: (0, common_1.resolveModulePath)('browserify-zlib'),
37
- fs: (0, common_1.resolveModulePath)('memfs'),
38
- http: (0, common_1.resolveStubPath)('http-sandbox'),
39
- https: (0, common_1.resolveStubPath)('http-sandbox'),
40
- path: (0, common_1.resolveModulePath)('path-browserify'),
41
- querystring: (0, common_1.resolveModulePath)('querystring-browser'),
42
- stream: (0, common_1.resolveModulePath)('readable-stream'),
43
- 'supports-color': (0, common_1.resolveModulePath)('supports-color/index.js')
44
- };
45
- };
46
- const getSandboxedRuntimeBuildConfig = (args) => {
47
- const webpackConfig = (0, common_1.getCommonWebpackConfig)(args);
48
- const sandboxedConfigPlugins = [
49
- new webpack_1.default.ProvidePlugin({
50
- Buffer: [(0, common_1.resolveModulePath)('buffer/'), 'Buffer'],
51
- path: (0, common_1.resolveModulePath)('path-browserify'),
52
- querystring: (0, common_1.resolveModulePath)('querystring-browser'),
53
- stream: (0, common_1.resolveModulePath)('readable-stream'),
54
- TextDecoder: [(0, common_1.resolveModulePath)('text-encoder-lite'), 'TextDecoderLite'],
55
- TextEncoder: [(0, common_1.resolveModulePath)('text-encoder-lite'), 'TextEncoderLite'],
56
- URL: [(0, common_1.resolveModulePath)('whatwg-url'), 'URL'],
57
- URLSearchParams: [(0, common_1.resolveModulePath)('whatwg-url'), 'URLSearchParams']
58
- }),
59
- new stub_plugin_1.StubPlugin({
60
- modules: [
61
- 'async_hooks',
62
- 'child_process',
63
- 'cluster',
64
- 'constants',
65
- 'dgram',
66
- 'dns',
67
- 'domain',
68
- 'http2',
69
- 'module',
70
- 'net',
71
- 'perf_hooks',
72
- 'readline',
73
- 'repl',
74
- 'sys',
75
- 'tls',
76
- 'trace_events',
77
- 'tty',
78
- 'v8',
79
- 'vm',
80
- 'worker_threads'
81
- ],
82
- placeholder: 'requestedModule',
83
- stub: (0, common_1.resolveStubPath)('unsupported')
84
- })
85
- ];
86
- sandboxedConfigPlugins.forEach((plugin) => webpackConfig.plugins.push(plugin));
87
- const moduleRuls = [
88
- {
89
- test: /(readable-stream|pbkdf2|util)\//,
90
- resolve: {
91
- aliasFields: ['browser']
92
- }
93
- },
94
- {
95
- test: /axios\//,
96
- resolve: {
97
- aliasFields: []
98
- }
99
- }
100
- ];
101
- moduleRuls.forEach((rule) => webpackConfig.module.rules.push(rule));
102
- webpackConfig.target = 'webworker';
103
- webpackConfig.resolve = {
104
- ...webpackConfig.resolve,
105
- mainFields: ['main', 'module'],
106
- exportsFields: [],
107
- alias: getCustomModulesAliases()
108
- };
109
- webpackConfig.name = exports.SANDBOXED_WEBPACK_CONFIG_NAME;
110
- return webpackConfig;
111
- };
112
- exports.getSandboxedRuntimeBuildConfig = getSandboxedRuntimeBuildConfig;
@@ -1,16 +0,0 @@
1
- import webpack, { Compiler } from 'webpack';
2
- interface StubPluginOptions {
3
- modules: string[];
4
- placeholder?: string;
5
- stub: string;
6
- }
7
- export declare class StubPlugin implements webpack.WebpackPluginInstance {
8
- private modules;
9
- private placeholder;
10
- private stub;
11
- constructor({ modules, placeholder, stub }: StubPluginOptions);
12
- apply(compiler: Compiler): void;
13
- private getDeclaration;
14
- }
15
- export {};
16
- //# sourceMappingURL=stub-plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stub-plugin.d.ts","sourceRoot":"","sources":["../src/stub-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI5C,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,UAAW,YAAW,OAAO,CAAC,qBAAqB;IAC9D,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,IAAI,CAA4B;gBAE5B,EAAE,OAAY,EAAE,WAAW,EAAE,IAAS,EAAE,EAAE,iBAAiB;IAMhE,KAAK,CAAC,QAAQ,EAAE,QAAQ;IA2C/B,OAAO,CAAC,cAAc;CAWvB"}
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StubPlugin = void 0;
4
- const ConstDependency = require('webpack/lib/dependencies/ConstDependency');
5
- class StubPlugin {
6
- modules;
7
- placeholder;
8
- stub;
9
- constructor({ modules = [], placeholder, stub = '' }) {
10
- this.modules = modules;
11
- this.placeholder = placeholder;
12
- this.stub = stub;
13
- }
14
- apply(compiler) {
15
- compiler.resolverFactory.hooks.resolver.for('normal').tap(StubPlugin.name, (resolver) => {
16
- resolver.hooks.resolve.tapAsync(StubPlugin.name, (request, resolveContext, callback) => {
17
- const requestedModule = request.request;
18
- if (!this.modules.includes(requestedModule)) {
19
- return callback();
20
- }
21
- const stubRequest = `${this.stub}?${requestedModule}`;
22
- resolver.doResolve(resolver.hooks.resolve, {
23
- ...request,
24
- request: stubRequest
25
- }, `Stub for ${requestedModule}`, resolveContext, callback);
26
- });
27
- });
28
- if (this.placeholder) {
29
- compiler.hooks.normalModuleFactory.tap(StubPlugin.name, (normalModuleFactory) => {
30
- normalModuleFactory.hooks.parser.for('javascript/auto').tap(StubPlugin.name, (parser) => {
31
- parser.hooks.program.tap(StubPlugin.name, (ast) => {
32
- if (parser.state.current.request && parser.state.current.request.includes(this.stub)) {
33
- const requestedModule = parser.state.module.rawRequest;
34
- const declaration = this.getDeclaration(ast, this.placeholder);
35
- if (declaration) {
36
- const replacement = new ConstDependency(`const ${this.placeholder} = '${requestedModule}';`, declaration.range);
37
- replacement.loc = declaration.loc;
38
- parser.state.current.addDependency(replacement);
39
- }
40
- }
41
- });
42
- });
43
- });
44
- }
45
- }
46
- getDeclaration(ast, name) {
47
- return ast.body.find((node) => {
48
- if (node.type === 'VariableDeclaration') {
49
- return node.declarations.find((declaration) => {
50
- if (declaration.id.name === name) {
51
- return declaration;
52
- }
53
- });
54
- }
55
- });
56
- }
57
- }
58
- exports.StubPlugin = StubPlugin;
@@ -1,34 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { IncomingMessage } from 'http';
5
- import { RequestOptions } from 'https';
6
- import { Writable } from 'readable-stream';
7
- import { URL } from 'url';
8
- import { FetchOptions } from '@forge/api';
9
- declare type HttpCallback = (res: IncomingMessage) => void;
10
- declare type HttpArg = RequestOptions | string | URL | HttpCallback;
11
- export declare const isHttpRequestOptions: (options: HttpArg) => options is RequestOptions;
12
- interface ChainableOptions {
13
- timeout?: number;
14
- headers: {
15
- [key: string]: string;
16
- };
17
- }
18
- export declare class Request extends Writable {
19
- private reqBody;
20
- private chainableOptions;
21
- constructor(options: RequestOptions | string | URL, callback?: HttpCallback);
22
- setHeader(name: string, value: string): Request;
23
- setTimeout(value: number, callback?: () => void): Request;
24
- private fetch;
25
- _write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
26
- static urlFromFetchArgs(options: RequestOptions | string | URL): string;
27
- static convertToForgeFetchArgs(options: RequestOptions | string | URL, chainableOptions: ChainableOptions): {
28
- url: string;
29
- init: FetchOptions;
30
- };
31
- abort(): void;
32
- }
33
- export {};
34
- //# sourceMappingURL=http-sandbox-impl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-sandbox-impl.d.ts","sourceRoot":"","sources":["../../src/stubs/http-sandbox-impl.ts"],"names":[],"mappings":";;;AAGA,OAAO,EAAuB,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAY,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1B,OAAO,EAAe,YAAY,EAAS,MAAM,YAAY,CAAC;AAE9D,aAAK,YAAY,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;AAEnD,aAAK,OAAO,GAAG,cAAc,GAAG,MAAM,GAAG,GAAG,GAAG,YAAY,CAAC;AAQ5D,eAAO,MAAM,oBAAoB,YAAa,OAAO,8BACJ,CAAC;AAYlD,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAED,qBAAa,OAAQ,SAAQ,QAAQ;IACnC,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,YAAY;IAapE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAM/C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO;YAQlD,KAAK;IAqBZ,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI;IAe3F,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM;IAiBvE,MAAM,CAAC,uBAAuB,CAC5B,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EACtC,gBAAgB,EAAE,gBAAgB,GACjC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE;IAyBtC,KAAK;CAGN"}
@@ -1,185 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Request = exports.isHttpRequestOptions = void 0;
4
- const readable_stream_1 = require("readable-stream");
5
- const api_1 = require("@forge/api");
6
- const isCallback = (options) => typeof options === 'function';
7
- const isString = (options) => typeof options === 'string';
8
- const isURL = (options) => typeof options === 'object' && options.constructor.name === 'URL';
9
- const isStringOrURL = (options) => isString(options) || isURL(options);
10
- const isHttpRequestOptions = (options) => !isStringOrURL(options) && !isCallback(options);
11
- exports.isHttpRequestOptions = isHttpRequestOptions;
12
- function formatHttpRequestArgsToUrl(options) {
13
- const protocol = 'https:';
14
- const auth = options.auth ? `${options.auth}@` : '';
15
- const host = options.hostname ?? options.host;
16
- const port = options.port ? `:${options.port}` : '';
17
- const path = options.path ?? '/';
18
- return `${protocol}//${auth}${host}${port}${path}`;
19
- }
20
- class Request extends readable_stream_1.Writable {
21
- reqBody;
22
- chainableOptions;
23
- constructor(options, callback) {
24
- super();
25
- this.reqBody = [];
26
- this.chainableOptions = {
27
- headers: {}
28
- };
29
- if (callback) {
30
- this.on('response', callback);
31
- }
32
- this.on('finish', this.fetch.bind(this, options));
33
- }
34
- setHeader(name, value) {
35
- this.chainableOptions.headers[name] = value;
36
- return this;
37
- }
38
- setTimeout(value, callback) {
39
- this.chainableOptions.timeout = value;
40
- if (callback) {
41
- this.on('timeout', callback);
42
- }
43
- return this;
44
- }
45
- async fetch(options) {
46
- const { url, init } = Request.convertToForgeFetchArgs(options, this.chainableOptions);
47
- if (init.method && init.method !== 'HEAD' && init.method !== 'GET') {
48
- init.body = Buffer.concat(this.reqBody);
49
- }
50
- try {
51
- const response = await (0, api_1.fetch)(url, init);
52
- const content = await response.arrayBuffer();
53
- const transformedAPIResponse = new Response(content, response);
54
- this.emit('response', transformedAPIResponse);
55
- }
56
- catch (err) {
57
- if (err.message.startsWith('network timeout')) {
58
- this.emit('timeout');
59
- }
60
- else {
61
- this.emit('error', err);
62
- }
63
- }
64
- }
65
- _write(chunk, encoding, callback) {
66
- try {
67
- if (Buffer.isEncoding(encoding)) {
68
- this.reqBody.push(Buffer.from(chunk, encoding));
69
- }
70
- else if (Buffer.isBuffer(chunk)) {
71
- this.reqBody.push(chunk);
72
- }
73
- else {
74
- this.reqBody.push(Buffer.from(chunk));
75
- }
76
- callback();
77
- }
78
- catch (err) {
79
- callback(err);
80
- }
81
- }
82
- static urlFromFetchArgs(options) {
83
- if (isString(options)) {
84
- return options;
85
- }
86
- else if (isURL(options)) {
87
- return options.toString();
88
- }
89
- else {
90
- try {
91
- return formatHttpRequestArgsToUrl(options);
92
- }
93
- catch (err) {
94
- console.error('Unable to make request with unrecognised URL options:', options);
95
- throw err;
96
- }
97
- }
98
- }
99
- static convertToForgeFetchArgs(options, chainableOptions) {
100
- const url = Request.urlFromFetchArgs(options);
101
- if (isStringOrURL(options)) {
102
- return { url, init: chainableOptions };
103
- }
104
- else {
105
- const reqOpts = {};
106
- if (options.headers) {
107
- reqOpts.headers = {};
108
- for (const header in options.headers) {
109
- const headerValue = options.headers[header];
110
- if (headerValue) {
111
- reqOpts.headers[header] = headerValue.toString();
112
- }
113
- }
114
- }
115
- if (options.timeout) {
116
- reqOpts.timeout = options.timeout;
117
- }
118
- reqOpts.method = options.method || 'GET';
119
- return { url, init: { ...chainableOptions, ...reqOpts } };
120
- }
121
- }
122
- abort() {
123
- }
124
- }
125
- exports.Request = Request;
126
- const HEADERS_DISCARD_DUPLICATES = new Set([
127
- 'age',
128
- 'authorization',
129
- 'content-length',
130
- 'content-type',
131
- 'etag',
132
- 'expires',
133
- 'from',
134
- 'host',
135
- 'if-modified-since',
136
- 'if-unmodified-since',
137
- 'last-modified',
138
- 'location',
139
- 'max-forwards',
140
- 'proxy-authorization',
141
- 'referer',
142
- 'retry-after',
143
- 'server',
144
- 'user-agent'
145
- ]);
146
- class Response extends readable_stream_1.Readable {
147
- statusCode;
148
- statusMessage;
149
- headers;
150
- headersDistinct;
151
- constructor(content, response) {
152
- super();
153
- this.statusCode = response.status;
154
- this.statusMessage = response.statusText;
155
- this.headers = {};
156
- this.headersDistinct = {};
157
- const rawHeaders = response.headers.raw();
158
- for (const [name, value] of Object.entries(rawHeaders)) {
159
- if (name === 'content-encoding') {
160
- continue;
161
- }
162
- let distinctValues;
163
- let overrideHeaderValue;
164
- if (HEADERS_DISCARD_DUPLICATES.has(name)) {
165
- const allHeaderValues = value.split(', ');
166
- overrideHeaderValue = allHeaderValues[0];
167
- distinctValues = allHeaderValues;
168
- }
169
- else if (name === 'set-cookie') {
170
- distinctValues = [value];
171
- }
172
- else if (name === 'cookie') {
173
- distinctValues = value.split('; ');
174
- }
175
- else {
176
- distinctValues = value.split(', ');
177
- }
178
- this.headers[name] = overrideHeaderValue ?? value;
179
- this.headersDistinct[name] = distinctValues;
180
- }
181
- this._read = () => { };
182
- this.push(Buffer.from(content));
183
- this.push(null);
184
- }
185
- }
@@ -1,13 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { AgentOptions, IncomingMessage } from 'http';
5
- import { RequestOptions } from 'https';
6
- import { URL } from 'url';
7
- import { Request } from './http-sandbox-impl';
8
- export declare function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): Request;
9
- export declare function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): Request;
10
- export declare class Agent {
11
- constructor(options: AgentOptions);
12
- }
13
- //# sourceMappingURL=http-sandbox.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-sandbox.d.ts","sourceRoot":"","sources":["../../src/stubs/http-sandbox.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAwB,MAAM,qBAAqB,CAAC;AAEpE,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAElH;AAED,wBAAgB,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAO9G;AAID,qBAAa,KAAK;gBACJ,OAAO,EAAE,YAAY;CAOlC"}
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Agent = exports.get = exports.request = void 0;
4
- const http_sandbox_impl_1 = require("./http-sandbox-impl");
5
- function request(options, callback) {
6
- return new http_sandbox_impl_1.Request(options, callback);
7
- }
8
- exports.request = request;
9
- function get(options, callback) {
10
- if ((0, http_sandbox_impl_1.isHttpRequestOptions)(options)) {
11
- options = { ...options, method: 'GET' };
12
- }
13
- const result = new http_sandbox_impl_1.Request(options, callback);
14
- result.end();
15
- return result;
16
- }
17
- exports.get = get;
18
- const NUM_SUPPORTED_AGENT_OPTIONS = 1;
19
- class Agent {
20
- constructor(options) {
21
- if (Object.keys(options).length > NUM_SUPPORTED_AGENT_OPTIONS) {
22
- console.warn("Forge only supports 'keepAlive' as an option to http.Agent");
23
- }
24
- return { keepAlive: options.keepAlive };
25
- }
26
- }
27
- exports.Agent = Agent;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=unsupported.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unsupported.d.ts","sourceRoot":"","sources":["../../src/stubs/unsupported.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const text_1 = require("../text");
4
- const requestedModule = '';
5
- const once = (fn) => (...args) => {
6
- if (fn) {
7
- fn(...args);
8
- }
9
- fn = null;
10
- };
11
- const warnOnce = once((message) => console.warn(message));
12
- const stub = (path) => new Proxy(() => {
13
- const prop = `${path}()`;
14
- console.log(`${prop} called`);
15
- return stub(`${prop}`);
16
- }, {
17
- get: (_, prop) => {
18
- warnOnce(text_1.Text.unsupported(requestedModule));
19
- return prop === Symbol.toPrimitive ? () => 'unsupported' : stub(`${path}.${prop.toString()}`);
20
- }
21
- });
22
- module.exports = stub(requestedModule);