@embroider/compat 3.6.0 → 3.6.2-unstable.a691d39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/audit/babel-visitor.js +7 -1
- package/src/audit/babel-visitor.js.map +1 -1
- package/src/audit/build.js.map +1 -1
- package/src/audit.d.ts +6 -53
- package/src/audit.js +92 -276
- package/src/audit.js.map +1 -1
- package/src/babel-plugin-adjust-imports.js +2 -2
- package/src/babel-plugin-adjust-imports.js.map +1 -1
- package/src/compat-adapters/@ember-data/store.d.ts +1 -5
- package/src/compat-adapters/@ember-data/store.js +3 -15
- package/src/compat-adapters/@ember-data/store.js.map +1 -1
- package/src/compat-adapters/ember-fetch.d.ts +5 -0
- package/src/compat-adapters/ember-fetch.js +19 -0
- package/src/compat-adapters/ember-fetch.js.map +1 -0
- package/src/compat-adapters/ember-resolver.d.ts +4 -0
- package/src/compat-adapters/ember-resolver.js +21 -0
- package/src/compat-adapters/ember-resolver.js.map +1 -0
- package/src/compat-addons.js +1 -1
- package/src/compat-addons.js.map +1 -1
- package/src/compat-app-builder.d.ts +8 -50
- package/src/compat-app-builder.js +113 -1007
- package/src/compat-app-builder.js.map +1 -1
- package/src/compat-app.d.ts +2 -20
- package/src/compat-app.js +51 -170
- package/src/compat-app.js.map +1 -1
- package/src/content-for-config.d.ts +11 -0
- package/src/content-for-config.js +66 -0
- package/src/content-for-config.js.map +1 -0
- package/src/default-pipeline.d.ts +2 -2
- package/src/default-pipeline.js +21 -0
- package/src/default-pipeline.js.map +1 -1
- package/src/dependency-rules.js +17 -10
- package/src/dependency-rules.js.map +1 -1
- package/src/http-audit.d.ts +13 -0
- package/src/http-audit.js +60 -0
- package/src/http-audit.js.map +1 -0
- package/src/index.d.ts +1 -2
- package/src/index.js +2 -3
- package/src/index.js.map +1 -1
- package/src/module-visitor.d.ts +52 -0
- package/src/module-visitor.js +285 -0
- package/src/module-visitor.js.map +1 -0
- package/src/options.d.ts +3 -2
- package/src/options.js +3 -0
- package/src/options.js.map +1 -1
- package/src/resolver-transform.js +7 -4
- package/src/resolver-transform.js.map +1 -1
- package/src/standalone-addon-build.js +6 -15
- package/src/standalone-addon-build.js.map +1 -1
- package/src/v1-config.d.ts +0 -8
- package/src/v1-config.js +1 -51
- package/src/v1-config.js.map +1 -1
- package/src/compat-adapters/@ember-data/debug.d.ts +0 -6
- package/src/compat-adapters/@ember-data/debug.js +0 -22
- package/src/compat-adapters/@ember-data/debug.js.map +0 -1
- package/src/sync-dir.d.ts +0 -8
- package/src/sync-dir.js +0 -68
- package/src/sync-dir.js.map +0 -1
- package/src/template-tag-codemod.d.ts +0 -10
- package/src/template-tag-codemod.js +0 -258
- package/src/template-tag-codemod.js.map +0 -1
- package/src/v1-appboot.d.ts +0 -14
- package/src/v1-appboot.js +0 -47
- package/src/v1-appboot.js.map +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const broccoli_plugin_1 = __importDefault(require("broccoli-plugin"));
|
|
7
|
+
const fs_extra_1 = require("fs-extra");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
class ContentForConfig extends broccoli_plugin_1.default {
|
|
10
|
+
constructor(configTree, options) {
|
|
11
|
+
super([configTree], {
|
|
12
|
+
annotation: 'embroider:content-for-config',
|
|
13
|
+
persistentOutput: true,
|
|
14
|
+
needsCache: false,
|
|
15
|
+
});
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.defaultContentForTypes = [
|
|
18
|
+
'head',
|
|
19
|
+
'test-head',
|
|
20
|
+
'head-footer',
|
|
21
|
+
'test-head-footer',
|
|
22
|
+
'body',
|
|
23
|
+
'test-body',
|
|
24
|
+
'body-footer',
|
|
25
|
+
'test-body-footer',
|
|
26
|
+
'config-module',
|
|
27
|
+
'app-boot',
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
readContents() {
|
|
31
|
+
if (!this.contentFor) {
|
|
32
|
+
throw new Error(`ContentForConfig not available until after the build`);
|
|
33
|
+
}
|
|
34
|
+
return this.contentFor;
|
|
35
|
+
}
|
|
36
|
+
build() {
|
|
37
|
+
var _a;
|
|
38
|
+
if (!this.contentFor)
|
|
39
|
+
this.contentFor = {};
|
|
40
|
+
const availableContentForTypes = (_a = this.options.availableContentForTypes) !== null && _a !== void 0 ? _a : [];
|
|
41
|
+
const extendedContentTypes = new Set([...this.defaultContentForTypes, ...availableContentForTypes]);
|
|
42
|
+
let appConfig = this.getAppConfig();
|
|
43
|
+
appConfig.forEach((configPath) => {
|
|
44
|
+
extendedContentTypes.forEach(contentType => {
|
|
45
|
+
const matchExp = this.options.pattern.match;
|
|
46
|
+
if (!this.contentFor[configPath.file])
|
|
47
|
+
this.contentFor[configPath.file] = {};
|
|
48
|
+
if (!this.contentFor[configPath.file][contentType]) {
|
|
49
|
+
let contents = this.options.pattern.replacement.call(null, configPath.json, matchExp, contentType);
|
|
50
|
+
this.contentFor[configPath.file][contentType] = contents;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
getAppConfig() {
|
|
56
|
+
return this.options.configPaths.map((configPath) => {
|
|
57
|
+
let config = (0, fs_extra_1.readFileSync)((0, path_1.join)(this.inputPaths[0], configPath.path), { encoding: 'utf8' });
|
|
58
|
+
return {
|
|
59
|
+
file: configPath.file,
|
|
60
|
+
json: JSON.parse(config),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = ContentForConfig;
|
|
66
|
+
//# sourceMappingURL=content-for-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-for-config.js","sourceRoot":"","sources":["content-for-config.ts"],"names":[],"m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,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;gBAC7E,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;oBACnD,IAAI,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;oBACnG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC;gBAC3D,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAA0C,EAAE,EAAE;YACjF,IAAI,MAAM,GAAG,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3F,OAAO;gBACL,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;aACzB,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7DD,mCA6DC","sourcesContent":["import Plugin from 'broccoli-plugin';\nimport type { Node } from 'broccoli-node-api';\nimport { readFileSync } from 'fs-extra';\nimport { join } from 'path';\n\nexport default class ContentForConfig extends Plugin {\n // The object keys are the content types and each value is the HTML\n // code that should replace the corresponding {{content-for}}\n // Example: { body: '<p>This snippet replaces content-for \\\"body\\\" in the app index.html</p>' }\n private contentFor: any;\n\n private defaultContentForTypes = [\n 'head',\n 'test-head',\n 'head-footer',\n 'test-head-footer',\n 'body',\n 'test-body',\n 'body-footer',\n 'test-body-footer',\n 'config-module',\n 'app-boot',\n ];\n\n constructor(configTree: Node, private options: any) {\n super([configTree], {\n annotation: 'embroider:content-for-config',\n persistentOutput: true,\n needsCache: false,\n });\n }\n\n readContents() {\n if (!this.contentFor) {\n throw new Error(`ContentForConfig not available until after the build`);\n }\n return this.contentFor;\n }\n\n build() {\n if (!this.contentFor) this.contentFor = {};\n const availableContentForTypes = this.options.availableContentForTypes ?? [];\n const extendedContentTypes = new Set([...this.defaultContentForTypes, ...availableContentForTypes]);\n\n let appConfig = this.getAppConfig();\n appConfig.forEach((configPath: { file: string; json: any }) => {\n extendedContentTypes.forEach(contentType => {\n const matchExp = this.options.pattern.match;\n if (!this.contentFor[configPath.file]) this.contentFor[configPath.file] = {};\n if (!this.contentFor[configPath.file][contentType]) {\n let contents = this.options.pattern.replacement.call(null, configPath.json, matchExp, contentType);\n this.contentFor[configPath.file][contentType] = contents;\n }\n });\n });\n }\n\n getAppConfig() {\n return this.options.configPaths.map((configPath: { file: string; path: string }) => {\n let config = readFileSync(join(this.inputPaths[0], configPath.path), { encoding: 'utf8' });\n return {\n file: configPath.file,\n json: JSON.parse(config),\n };\n });\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type Options from './options';
|
|
2
2
|
import type { PackagerConstructor, Variant, EmberAppInstance } from '@embroider/core';
|
|
3
3
|
import type { Node } from 'broccoli-node-api';
|
|
4
4
|
export interface PipelineOptions<PackagerOptions> extends Options {
|
|
5
5
|
packagerOptions?: PackagerOptions;
|
|
6
|
-
onOutputPath?: (outputPath: string) => void;
|
|
7
6
|
variants?: Variant[];
|
|
8
7
|
}
|
|
9
8
|
export declare function stableWorkspaceDir(appRoot: string, environment: string): string;
|
|
10
9
|
export default function defaultPipeline<PackagerOptions>(emberApp: EmberAppInstance, packager?: PackagerConstructor<PackagerOptions>, options?: PipelineOptions<PackagerOptions>): Node;
|
|
10
|
+
export declare function prebuild(emberApp: EmberAppInstance, options?: Options): Node;
|
package/src/default-pipeline.js
CHANGED
|
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.stableWorkspaceDir = stableWorkspaceDir;
|
|
7
7
|
exports.default = defaultPipeline;
|
|
8
|
+
exports.prebuild = prebuild;
|
|
9
|
+
const options_1 = require("./options");
|
|
8
10
|
const _1 = require(".");
|
|
9
11
|
const core_1 = require("@embroider/core");
|
|
10
12
|
const core_2 = require("@embroider/core");
|
|
@@ -37,6 +39,25 @@ function defaultPipeline(emberApp, packager, options = {}) {
|
|
|
37
39
|
let variants = (options && options.variants) || defaultVariants(emberApp);
|
|
38
40
|
return new BroccoliPackager(embroiderApp.asStage(addons), variants, options && options.packagerOptions);
|
|
39
41
|
}
|
|
42
|
+
const defaultPrebuildOptions = {
|
|
43
|
+
...options_1.recommendedOptions.optimized,
|
|
44
|
+
amdCompatibility: {
|
|
45
|
+
es: [],
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
function prebuild(emberApp, options) {
|
|
49
|
+
let outputPath;
|
|
50
|
+
let addons;
|
|
51
|
+
let embroiderApp = new _1.App(emberApp, { ...defaultPrebuildOptions, ...options });
|
|
52
|
+
addons = new _1.Addons(embroiderApp);
|
|
53
|
+
addons.ready().then(result => {
|
|
54
|
+
outputPath = result.outputPath;
|
|
55
|
+
});
|
|
56
|
+
if (process.env.STAGE1_ONLY) {
|
|
57
|
+
return (0, broccoli_merge_trees_1.default)([addons.tree, (0, broccoli_file_creator_1.default)('.stage1-output', () => outputPath)]);
|
|
58
|
+
}
|
|
59
|
+
return (0, broccoli_merge_trees_1.default)([embroiderApp.asStage(addons).tree, (0, broccoli_file_creator_1.default)('.stage2-output', () => outputPath)]);
|
|
60
|
+
}
|
|
40
61
|
function hasFastboot(emberApp) {
|
|
41
62
|
return emberApp.project.addons.find(a => a.name === 'ember-cli-fastboot');
|
|
42
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-pipeline.js","sourceRoot":"","sources":["default-pipeline.ts"],"names":[],"mappings":";;;;;AAkBA,gDAKC;AAED,kCA0BC;
|
|
1
|
+
{"version":3,"file":"default-pipeline.js","sourceRoot":"","sources":["default-pipeline.ts"],"names":[],"mappings":";;;;;AAkBA,gDAKC;AAED,kCA0BC;AASD,4BAgBC;AA3ED,uCAA+C;AAC/C,wBAAgD;AAEhD,0CAAmD;AACnD,0CAAyC;AAEzC,kFAA8C;AAC9C,gFAA8C;AAC9C,mCAAoC;AACpC,+BAAqC;AACrC,mCAA2C;AAO3C,SAAgB,kBAAkB,CAAC,OAAe,EAAE,WAAmB;IACrE,IAAI,IAAI,GAAG,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,IAAA,cAAO,EAAC,IAAA,aAAS,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAE,CAAC,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACzB,OAAO,IAAA,WAAI,EAAC,aAAM,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,SAAwB,eAAe,CACrC,QAA0B,EAC1B,QAA+C,EAC/C,UAA4C,EAAE;IAE9C,IAAI,UAAkB,CAAC;IACvB,IAAI,MAAM,CAAC;IAEX,IAAI,YAAY,GAAG,IAAI,MAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE9C,MAAM,GAAG,IAAI,SAAY,CAAC,YAAY,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QAC3B,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,IAAI,OAAO,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AqB,EAAE,KAAK;SAC7B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type Options from './options';\nimport { recommendedOptions } from './options';\nimport { App, Addons as CompatAddons } from '.';\nimport type { PackagerConstructor, Variant, EmberAppInstance } from '@embroider/core';\nimport { toBroccoliPlugin } from '@embroider/core';\nimport { tmpdir } from '@embroider/core';\nimport type { Node } from 'broccoli-node-api';\nimport writeFile from 'broccoli-file-creator';\nimport mergeTrees from 'broccoli-merge-trees';\nimport { createHash } from 'crypto';\nimport { join, dirname } from 'path';\nimport { sync as pkgUpSync } from 'pkg-up';\n\nexport interface PipelineOptions<PackagerOptions> extends Options {\n packagerOptions?: PackagerOptions;\n variants?: Variant[];\n}\n\nexport function stableWorkspaceDir(appRoot: string, environment: string) {\n let hash = createHash('md5');\n hash.update(dirname(pkgUpSync({ cwd: appRoot })!));\n hash.update(environment);\n return join(tmpdir, 'embroider', hash.digest('hex').slice(0, 6));\n}\n\nexport default function defaultPipeline<PackagerOptions>(\n emberApp: EmberAppInstance,\n packager?: PackagerConstructor<PackagerOptions>,\n options: PipelineOptions<PackagerOptions> = {}\n): Node {\n let outputPath: string;\n let addons;\n\n let embroiderApp = new App(emberApp, options);\n\n addons = new CompatAddons(embroiderApp);\n addons.ready().then(result => {\n outputPath = result.outputPath;\n });\n\n if (process.env.STAGE1_ONLY) {\n return mergeTrees([addons.tree, writeFile('.stage1-output', () => outputPath)]);\n }\n\n if (process.env.STAGE2_ONLY || !packager) {\n return mergeTrees([embroiderApp.asStage(addons).tree, writeFile('.stage2-output', () => outputPath)]);\n }\n\n let BroccoliPackager = toBroccoliPlugin(packager);\n let variants = (options && options.variants) || defaultVariants(emberApp);\n return new BroccoliPackager(embroiderApp.asStage(addons), variants, options && options.packagerOptions);\n}\n\nconst defaultPrebuildOptions = {\n ...recommendedOptions.optimized,\n amdCompatibility: {\n es: [],\n },\n};\n\nexport function prebuild(emberApp: EmberAppInstance, options?: Options): Node {\n let outputPath: string;\n let addons;\n\n let embroiderApp = new App(emberApp, { ...defaultPrebuildOptions, ...options });\n\n addons = new CompatAddons(embroiderApp);\n addons.ready().then(result => {\n outputPath = result.outputPath;\n });\n\n if (process.env.STAGE1_ONLY) {\n return mergeTrees([addons.tree, writeFile('.stage1-output', () => outputPath)]);\n }\n\n return mergeTrees([embroiderApp.asStage(addons).tree, writeFile('.stage2-output', () => outputPath)]);\n}\n\nfunction hasFastboot(emberApp: EmberAppInstance | EmberAppInstance) {\n return emberApp.project.addons.find(a => a.name === 'ember-cli-fastboot');\n}\n\nfunction defaultVariants(emberApp: EmberAppInstance): Variant[] {\n let variants: Variant[] = [];\n if (emberApp.env === 'production') {\n variants.push({\n name: 'browser',\n runtime: 'browser',\n optimizeForProduction: true,\n });\n if (hasFastboot(emberApp)) {\n variants.push({\n name: 'fastboot',\n runtime: 'fastboot',\n optimizeForProduction: true,\n });\n }\n } else {\n variants.push({\n name: 'dev',\n runtime: hasFastboot(emberApp) ? 'all' : 'browser',\n optimizeForProduction: false,\n });\n }\n return variants;\n}\n"]}
|
package/src/dependency-rules.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.appTreeRulesDir = appTreeRulesDir;
|
|
|
6
6
|
const core_1 = require("@embroider/core");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const semver_1 = require("semver");
|
|
9
|
+
const resolve_exports_1 = require("resolve.exports");
|
|
9
10
|
// take a component rule from the authoring format to a format more optimized
|
|
10
11
|
// for consumption in the resolver
|
|
11
12
|
function preprocessComponentRule(componentRules) {
|
|
@@ -66,16 +67,22 @@ function activePackageRules(packageRules, activePackages) {
|
|
|
66
67
|
}
|
|
67
68
|
function appTreeRulesDir(root, resolver) {
|
|
68
69
|
let pkg = resolver.packageCache.ownerOfFile(root);
|
|
69
|
-
if (pkg
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
if (pkg) {
|
|
71
|
+
if (pkg.isV2Addon()) {
|
|
72
|
+
// in general v2 addons can keep their app tree stuff in other places than
|
|
73
|
+
// "_app_" and we would need to check their package.json to see. But this code
|
|
74
|
+
// is only for applying packageRules to auto-upgraded v1 addons and apps, and
|
|
75
|
+
// those we always organize predictably.
|
|
76
|
+
return (0, path_1.resolve)(root, '_app_');
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// this is an app
|
|
80
|
+
let matched = (0, resolve_exports_1.resolve)(pkg.packageJSON, './index.js');
|
|
81
|
+
if (matched) {
|
|
82
|
+
return (0, path_1.dirname)((0, path_1.resolve)(root, matched[0]));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
79
85
|
}
|
|
86
|
+
return root;
|
|
80
87
|
}
|
|
81
88
|
//# sourceMappingURL=dependency-rules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;AA6KA,0DAkCC;AAED,gDAqBC;AAED,0CAYC;AAnPD,0CAA8C;AAC9C,+BAA+B;AAC/B,mCAAmC;AAwKnC,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uBAAuB,CAAC,cAA8B;;IACpE,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC;QAC7C,KAAK,IAAI,KAAK,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC;YAC3D,IAAI,IAAI,EAAE,QAAQ,CAAC;YACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;YAC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AAI,IAAA,kBAAS,EAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;gBACjG,IAAI,KAAK,GAAG,IAAA,kBAAW,EAAC,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;gBACtD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACrB,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,eAAe,CAAC,IAAY,EAAE,QAAkB;IAC9D,IAAI,GAAG,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,SAAS,EAAE,EAAE,CAAC;QACrB,0EAA0E;QAC1E,8EAA8E;QAC9E,6EAA6E;QAC7E,wCAAwC;QACxC,OAAO,IAAA,cAAO,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,mDAAmD;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { Resolver } from '@embroider/core';\nimport { getOrCreate } from '@embroider/core';\nimport { resolve } from 'path';\nimport { satisfies } from 'semver';\n\nexport interface PackageRules {\n // This whole set of rules will only apply when the given addon package\n // matching the given semver range is present and active.\n package: string;\n semverRange?: string;\n\n components?: {\n // I would prefer to write the key type here as `ComponentSnippet` to aid\n // documentation, but Typescript won't allow it. See ComponentSnippet below.\n [key: string]: ComponentRules;\n };\n\n addonModules?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n appModules?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n addonTemplates?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n\n appTemplates?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n}\n\nexport interface ActivePackageRules extends PackageRules {\n // the location(s) of active packages that match this rule.\n roots: string[];\n}\n\nexport interface TemplateRules {\n // Tells embroider which list of components may be needed for a given path.\n // For example, if your template says `{{component this.panel}}` and you know\n // that `this.panel` can be either \"light-panel\" or \"dark-panel\", you would\n // say: `invokes: { \"this.panel\": [\"<LightPanel/>\", \"<DarkPanel/>\"] }`\n invokes?: {\n [path: string]: ComponentSnippet[];\n };\n\n // Embroider will complain if you try to use staticHelper and/or\n // staticComponents and you have ambiguous forms that might be a component or\n // a helper or just some data that is being rendered. For example, if a\n // template says `{{something}}`, we can't tell if that is `<Something />` or\n // `{{ (something) }}` or `{{this.something}}`.\n disambiguate?: {\n [dasherizedName: string]: 'component' | 'helper' | 'data';\n };\n}\n\nexport interface ComponentRules extends TemplateRules {\n // This declares that our component yields other components that are safe to\n // invoke with the {{component}} helper.\n //\n // The array corresponds to your yielded positional arguments. Any value that\n // is true is considered a safe component. Any value can be a hash in which\n // individual keys that are true are considered safe components.\n //\n // Examples:\n //\n // If you do: {{yield (component \"x\") }}\n // Then say: yieldsSafeComponents: [true]\n //\n // If you do: {{yield (hash x=(component \"x\") y=(component \"y\")) }}\n // Then say: yieldsSafeComponents: [{x: true, y: true}]\n //\n yieldsSafeComponents?: (boolean | { [name: string]: boolean })[];\n\n // This declares that our component yields some of its arguments unchanged.\n //\n // The array corresponds to your yielded positional arguments. Each value can\n // be:\n // false, meaning this yielded value is not one of our arguments\n // a string, meaning this yielded value is our argument with that name\n // or a POJO, whose individual properties are string naming which arguments\n // from whence they came.\n //\n // Examples:\n //\n // If you do: {{yield @foo}}\n // Then say: yieldsArguments: ['foo']\n //\n // If you do: {{yield (hash x=@foo) }}\n // Then say: yieldsArguments: [{ x: 'foo' }]\n yieldsArguments?: (string | { [name: string]: string })[];\n\n // This declares that our component accepts arguments that will be invoked\n // with the {{component}} helper. This silences warnings in the places where\n // we consume them, while introducing warnings in the places where people are\n // passing them to us (if they are doing so in a way that is too dynamic to\n // analyze).\n //\n // If you use this, you may also need to set `layout`, see below.\n acceptsComponentArguments?: ArgumentMapping[];\n\n // If you want to use `acceptsComponentArguments` on a component that\n // customies its own `layout` (which is most addon-provided components), you\n // need to tell us here how to find its template by setting either `addonPath`\n // or `appPath`.\n layout?: {\n // This is a path relative to the addon root, assuming V2 format.\n addonPath?: string;\n // This is the path relative to the app root, assuming V2 format.\n appPath?: string;\n };\n\n // An unresolvable component is usually a build error (when your app has the\n // staticComponent Option enabled). But you can tell Embroider to ignore it by\n // setting this.\n safeToIgnore?: boolean;\n}\n\nexport interface ModuleRules {\n // We will resolve these components into the corresponding JS and HBS files\n // and generate imports such that this module depends on them.\n dependsOnComponents?: ComponentSnippet[];\n\n // This adds new imports to our module, as if they were really there. Helpful\n // for working around addons that depend on things but don't say so.\n dependsOnModules?: string[];\n}\n\n// The bare \"string\" short form implies that `becomes` is the same as `name`.\nexport type ArgumentMapping =\n | string\n | {\n // the name of the argument you accept\n name: string;\n // the name its consumed as in your template\n becomes: string;\n };\n\n// A component snippet is a string containing valid HBS that is a single\n// component invocation. We use it to refer to components in a way that doesn't\n// require any new syntax or rules, and that's necessarily supported by whatever\n// build-time template resolver is in use.\n//\n// Examples of valid ComponentSnippets:\n//\n// \"{{my-component}}\"\n// \"{{my-component/foo}}\"\n// \"<MyComponent />\"\n// \"{{component 'my-component'}}\"\n//\ntype ComponentSnippet = string;\n\nexport interface PreprocessedComponentRule {\n yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n safeToIgnore: boolean;\n safeInteriorPaths: string[];\n disambiguate: Record<string, 'component' | 'helper' | 'data'>;\n}\n\n// take a component rule from the authoring format to a format more optimized\n// for consumption in the resolver\nexport function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule {\n let argumentsAreComponents = [];\n let safeInteriorPaths = [];\n if (componentRules.acceptsComponentArguments) {\n for (let entry of componentRules.acceptsComponentArguments) {\n let name, interior;\n if (typeof entry === 'string') {\n name = interior = entry;\n } else {\n name = entry.name;\n interior = entry.becomes;\n }\n if (name.startsWith('@')) {\n name = name.slice(1);\n }\n argumentsAreComponents.push(name);\n safeInteriorPaths.push(interior);\n safeInteriorPaths.push('this.' + interior);\n safeInteriorPaths.push('@' + name);\n }\n }\n if (componentRules.invokes) {\n for (let [path] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n }\n }\n return {\n safeInteriorPaths,\n safeToIgnore: Boolean(componentRules.safeToIgnore),\n argumentsAreComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\n disambiguate: componentRules?.disambiguate ?? {},\n };\n}\n\nexport function activePackageRules(\n packageRules: PackageRules[],\n activePackages: { name: string; root: string; version: string }[]\n): ActivePackageRules[] {\n // rule order implies precedence. The first rule that matches a given package\n // applies to that package, and no other rule does.\n let rootsPerRule = new Map();\n for (let pkg of activePackages) {\n for (let rule of packageRules) {\n if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {\n let roots = getOrCreate(rootsPerRule, rule, () => []);\n roots.push(pkg.root);\n break;\n }\n }\n }\n let output = [];\n for (let [rule, roots] of rootsPerRule) {\n output.push(Object.assign({ roots }, rule));\n }\n return output;\n}\n\nexport function appTreeRulesDir(root: string, resolver: Resolver) {\n let pkg = resolver.packageCache.ownerOfFile(root);\n if (pkg?.isV2Addon()) {\n // in general v2 addons can keep their app tree stuff in other places than\n // \"_app_\" and we would need to check their package.json to see. But this code\n // is only for applying packageRules to auto-upgraded v1 addons and apps, and\n // those we always organize predictably.\n return resolve(root, '_app_');\n } else {\n // auto-upgraded apps don't get an exist _app_ dir.\n return root;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;AA8KA,0DAkCC;AAED,gDAqBC;AAED,0CAkBC;AA1PD,0CAA8C;AAC9C,+BAAuD;AACvD,mCAAmC;AACnC,qDAA4D;AAwK5D,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uBAAuB,CAAC,cAA8B;;IACpE,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC;QAC7C,KAAK,IAAI,KAAK,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC;YAC3D,IAAI,IAAI,EAAE,QAAQ,CAAC;YACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;YAC3B,CAAC;YACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACvB,CAAC;YACD,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC,iBAAiB,CAAC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;YAC3C,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AAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,eAAe,CAAC,IAAY,EAAE,QAAkB;IAC9D,IAAI,GAAG,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC;YACpB,0EAA0E;YAC1E,8EAA8E;YAC9E,6EAA6E;YAC7E,wCAAwC;YACxC,OAAO,IAAA,cAAW,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,iBAAiB;YACjB,IAAI,OAAO,GAAG,IAAA,yBAAc,EAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YAC5D,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,IAAA,cAAO,EAAC,IAAA,cAAW,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { Resolver } from '@embroider/core';\nimport { getOrCreate } from '@embroider/core';\nimport { resolve as pathResolve, dirname } from 'path';\nimport { satisfies } from 'semver';\nimport { resolve as resolveExports } from 'resolve.exports';\n\nexport interface PackageRules {\n // This whole set of rules will only apply when the given addon package\n // matching the given semver range is present and active.\n package: string;\n semverRange?: string;\n\n components?: {\n // I would prefer to write the key type here as `ComponentSnippet` to aid\n // documentation, but Typescript won't allow it. See ComponentSnippet below.\n [key: string]: ComponentRules;\n };\n\n addonModules?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n appModules?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n addonTemplates?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n\n appTemplates?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n}\n\nexport interface ActivePackageRules extends PackageRules {\n // the location(s) of active packages that match this rule.\n roots: string[];\n}\n\nexport interface TemplateRules {\n // Tells embroider which list of components may be needed for a given path.\n // For example, if your template says `{{component this.panel}}` and you know\n // that `this.panel` can be either \"light-panel\" or \"dark-panel\", you would\n // say: `invokes: { \"this.panel\": [\"<LightPanel/>\", \"<DarkPanel/>\"] }`\n invokes?: {\n [path: string]: ComponentSnippet[];\n };\n\n // Embroider will complain if you try to use staticHelper and/or\n // staticComponents and you have ambiguous forms that might be a component or\n // a helper or just some data that is being rendered. For example, if a\n // template says `{{something}}`, we can't tell if that is `<Something />` or\n // `{{ (something) }}` or `{{this.something}}`.\n disambiguate?: {\n [dasherizedName: string]: 'component' | 'helper' | 'data';\n };\n}\n\nexport interface ComponentRules extends TemplateRules {\n // This declares that our component yields other components that are safe to\n // invoke with the {{component}} helper.\n //\n // The array corresponds to your yielded positional arguments. Any value that\n // is true is considered a safe component. Any value can be a hash in which\n // individual keys that are true are considered safe components.\n //\n // Examples:\n //\n // If you do: {{yield (component \"x\") }}\n // Then say: yieldsSafeComponents: [true]\n //\n // If you do: {{yield (hash x=(component \"x\") y=(component \"y\")) }}\n // Then say: yieldsSafeComponents: [{x: true, y: true}]\n //\n yieldsSafeComponents?: (boolean | { [name: string]: boolean })[];\n\n // This declares that our component yields some of its arguments unchanged.\n //\n // The array corresponds to your yielded positional arguments. Each value can\n // be:\n // false, meaning this yielded value is not one of our arguments\n // a string, meaning this yielded value is our argument with that name\n // or a POJO, whose individual properties are string naming which arguments\n // from whence they came.\n //\n // Examples:\n //\n // If you do: {{yield @foo}}\n // Then say: yieldsArguments: ['foo']\n //\n // If you do: {{yield (hash x=@foo) }}\n // Then say: yieldsArguments: [{ x: 'foo' }]\n yieldsArguments?: (string | { [name: string]: string })[];\n\n // This declares that our component accepts arguments that will be invoked\n // with the {{component}} helper. This silences warnings in the places where\n // we consume them, while introducing warnings in the places where people are\n // passing them to us (if they are doing so in a way that is too dynamic to\n // analyze).\n //\n // If you use this, you may also need to set `layout`, see below.\n acceptsComponentArguments?: ArgumentMapping[];\n\n // If you want to use `acceptsComponentArguments` on a component that\n // customies its own `layout` (which is most addon-provided components), you\n // need to tell us here how to find its template by setting either `addonPath`\n // or `appPath`.\n layout?: {\n // This is a path relative to the addon root, assuming V2 format.\n addonPath?: string;\n // This is the path relative to the app root, assuming V2 format.\n appPath?: string;\n };\n\n // An unresolvable component is usually a build error (when your app has the\n // staticComponent Option enabled). But you can tell Embroider to ignore it by\n // setting this.\n safeToIgnore?: boolean;\n}\n\nexport interface ModuleRules {\n // We will resolve these components into the corresponding JS and HBS files\n // and generate imports such that this module depends on them.\n dependsOnComponents?: ComponentSnippet[];\n\n // This adds new imports to our module, as if they were really there. Helpful\n // for working around addons that depend on things but don't say so.\n dependsOnModules?: string[];\n}\n\n// The bare \"string\" short form implies that `becomes` is the same as `name`.\nexport type ArgumentMapping =\n | string\n | {\n // the name of the argument you accept\n name: string;\n // the name its consumed as in your template\n becomes: string;\n };\n\n// A component snippet is a string containing valid HBS that is a single\n// component invocation. We use it to refer to components in a way that doesn't\n// require any new syntax or rules, and that's necessarily supported by whatever\n// build-time template resolver is in use.\n//\n// Examples of valid ComponentSnippets:\n//\n// \"{{my-component}}\"\n// \"{{my-component/foo}}\"\n// \"<MyComponent />\"\n// \"{{component 'my-component'}}\"\n//\ntype ComponentSnippet = string;\n\nexport interface PreprocessedComponentRule {\n yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n safeToIgnore: boolean;\n safeInteriorPaths: string[];\n disambiguate: Record<string, 'component' | 'helper' | 'data'>;\n}\n\n// take a component rule from the authoring format to a format more optimized\n// for consumption in the resolver\nexport function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule {\n let argumentsAreComponents = [];\n let safeInteriorPaths = [];\n if (componentRules.acceptsComponentArguments) {\n for (let entry of componentRules.acceptsComponentArguments) {\n let name, interior;\n if (typeof entry === 'string') {\n name = interior = entry;\n } else {\n name = entry.name;\n interior = entry.becomes;\n }\n if (name.startsWith('@')) {\n name = name.slice(1);\n }\n argumentsAreComponents.push(name);\n safeInteriorPaths.push(interior);\n safeInteriorPaths.push('this.' + interior);\n safeInteriorPaths.push('@' + name);\n }\n }\n if (componentRules.invokes) {\n for (let [path] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n }\n }\n return {\n safeInteriorPaths,\n safeToIgnore: Boolean(componentRules.safeToIgnore),\n argumentsAreComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\n disambiguate: componentRules?.disambiguate ?? {},\n };\n}\n\nexport function activePackageRules(\n packageRules: PackageRules[],\n activePackages: { name: string; root: string; version: string }[]\n): ActivePackageRules[] {\n // rule order implies precedence. The first rule that matches a given package\n // applies to that package, and no other rule does.\n let rootsPerRule = new Map();\n for (let pkg of activePackages) {\n for (let rule of packageRules) {\n if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {\n let roots = getOrCreate(rootsPerRule, rule, () => []);\n roots.push(pkg.root);\n break;\n }\n }\n }\n let output = [];\n for (let [rule, roots] of rootsPerRule) {\n output.push(Object.assign({ roots }, rule));\n }\n return output;\n}\n\nexport function appTreeRulesDir(root: string, resolver: Resolver) {\n let pkg = resolver.packageCache.ownerOfFile(root);\n if (pkg) {\n if (pkg.isV2Addon()) {\n // in general v2 addons can keep their app tree stuff in other places than\n // \"_app_\" and we would need to check their package.json to see. But this code\n // is only for applying packageRules to auto-upgraded v1 addons and apps, and\n // those we always organize predictably.\n return pathResolve(root, '_app_');\n } else {\n // this is an app\n let matched = resolveExports(pkg.packageJSON, './index.js');\n if (matched) {\n return dirname(pathResolve(root, matched[0]));\n }\n }\n }\n return root;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Finding } from './audit';
|
|
2
|
+
import { type Module } from './module-visitor';
|
|
3
|
+
export interface HTTPAuditOptions {
|
|
4
|
+
appURL: string;
|
|
5
|
+
startingFrom: string[];
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
export declare function httpAudit(options: HTTPAuditOptions): Promise<{
|
|
9
|
+
modules: {
|
|
10
|
+
[file: string]: Module;
|
|
11
|
+
};
|
|
12
|
+
findings: Finding[];
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.httpAudit = httpAudit;
|
|
4
|
+
const babel_visitor_1 = require("./audit/babel-visitor");
|
|
5
|
+
const module_visitor_1 = require("./module-visitor");
|
|
6
|
+
async function httpAudit(options) {
|
|
7
|
+
let findings = [];
|
|
8
|
+
async function resolveId(specifier, fromFile) {
|
|
9
|
+
return new URL(specifier, fromFile).href;
|
|
10
|
+
}
|
|
11
|
+
async function fetchWithRetry(id, options) {
|
|
12
|
+
var _a;
|
|
13
|
+
let remainingTries = 5;
|
|
14
|
+
let backoffMS = 666;
|
|
15
|
+
for (;;) {
|
|
16
|
+
try {
|
|
17
|
+
return await ((_a = options.fetch) !== null && _a !== void 0 ? _a : globalThis.fetch)(id);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
if (remainingTries-- > 0) {
|
|
21
|
+
backoffMS *= 1.5;
|
|
22
|
+
await new Promise(r => setTimeout(r, backoffMS));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function load(id) {
|
|
28
|
+
let response = await fetchWithRetry(id, options);
|
|
29
|
+
let content = await response.text();
|
|
30
|
+
let type;
|
|
31
|
+
if (response.status !== 200) {
|
|
32
|
+
throw new Error(`oops status code ${response.status} - ${response.statusText} for ${id}: ${content}`);
|
|
33
|
+
}
|
|
34
|
+
switch (response.headers.get('content-type')) {
|
|
35
|
+
case 'text/javascript':
|
|
36
|
+
type = 'javascript';
|
|
37
|
+
break;
|
|
38
|
+
case 'text/html':
|
|
39
|
+
type = 'html';
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
throw new Error(`oops content type ${response.headers.get('content-type')} for ${id}`);
|
|
43
|
+
}
|
|
44
|
+
return { content, type };
|
|
45
|
+
}
|
|
46
|
+
let modules = await (0, module_visitor_1.visitModules)({
|
|
47
|
+
base: options.appURL,
|
|
48
|
+
entrypoints: options.startingFrom.map(s => new URL(s, options.appURL).href),
|
|
49
|
+
babelConfig: { ast: true },
|
|
50
|
+
frames: new babel_visitor_1.CodeFrameStorage(),
|
|
51
|
+
findings,
|
|
52
|
+
resolveId,
|
|
53
|
+
load,
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
modules,
|
|
57
|
+
findings,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=http-audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-audit.js","sourceRoot":"","sources":["http-audit.ts"],"names":[],"mappings":";;AAUA,8BA2DC;AApED,yDAAyD;AACzD,qDAA+E;AAQxE,KAAK,UAAU,SAAS,CAC7B,OAAyB;IAEzB,IAAI,QAAQ,GAAc,EAAE,CAAC;IAE7B,KAAK,UAAU,SAAS,CAAC,SAAiB,EAAE,QAAgB;QAC1D,OAAO,IAAI,GAAG,CAAC,SAAS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AO,CAAC,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC3F,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO,GAAG,MAAM,IAAA,6BAAY,EAAC;QAC/B,IAAI,EAAE,OAAO,CAAC,MAAM;QACpB,WAAW,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;QAC3E,WAAW,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;QAC1B,MAAM,EAAE,IAAI,gCAAgB,EAAE;QAC9B,QAAQ;QACR,SAAS;QACT,IAAI;KACL,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC","sourcesContent":["import type { Finding } from './audit';\nimport { CodeFrameStorage } from './audit/babel-visitor';\nimport { type Module, visitModules, type ContentType } from './module-visitor';\n\nexport interface HTTPAuditOptions {\n appURL: string;\n startingFrom: string[];\n fetch?: typeof fetch;\n}\n\nexport async function httpAudit(\n options: HTTPAuditOptions\n): Promise<{ modules: { [file: string]: Module }; findings: Finding[] }> {\n let findings: Finding[] = [];\n\n async function resolveId(specifier: string, fromFile: string): Promise<string | undefined> {\n return new URL(specifier, fromFile).href;\n }\n\n async function fetchWithRetry(id: string, options: HTTPAuditOptions) {\n let remainingTries = 5;\n let backoffMS = 666;\n\n for (;;) {\n try {\n return await (options.fetch ?? globalThis.fetch)(id);\n } catch (err) {\n if (remainingTries-- > 0) {\n backoffMS *= 1.5;\n await new Promise(r => setTimeout(r, backoffMS));\n }\n }\n }\n }\n\n async function load(id: string): Promise<{ content: string | Buffer; type: ContentType }> {\n let response = await fetchWithRetry(id, options);\n let content = await response.text();\n let type: ContentType;\n if (response.status !== 200) {\n throw new Error(`oops status code ${response.status} - ${response.statusText} for ${id}: ${content}`);\n }\n switch (response.headers.get('content-type')) {\n case 'text/javascript':\n type = 'javascript';\n break;\n case 'text/html':\n type = 'html';\n break;\n default:\n throw new Error(`oops content type ${response.headers.get('content-type')} for ${id}`);\n }\n return { content, type };\n }\n\n let modules = await visitModules({\n base: options.appURL,\n entrypoints: options.startingFrom.map(s => new URL(s, options.appURL).href),\n babelConfig: { ast: true },\n frames: new CodeFrameStorage(),\n findings,\n resolveId,\n load,\n });\n\n return {\n modules,\n findings,\n };\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -2,6 +2,5 @@ export { default as App } from './compat-app';
|
|
|
2
2
|
export { default as Addons } from './compat-addons';
|
|
3
3
|
export { default as Options, recommendedOptions } from './options';
|
|
4
4
|
export { default as V1Addon } from './v1-addon';
|
|
5
|
-
export { default as compatBuild, PipelineOptions } from './default-pipeline';
|
|
6
|
-
export { default as templateTagCodemod } from './template-tag-codemod';
|
|
5
|
+
export { default as compatBuild, prebuild, PipelineOptions } from './default-pipeline';
|
|
7
6
|
export { PackageRules, ModuleRules } from './dependency-rules';
|
package/src/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.prebuild = exports.compatBuild = exports.V1Addon = exports.recommendedOptions = exports.Addons = exports.App = void 0;
|
|
7
7
|
var compat_app_1 = require("./compat-app");
|
|
8
8
|
Object.defineProperty(exports, "App", { enumerable: true, get: function () { return __importDefault(compat_app_1).default; } });
|
|
9
9
|
var compat_addons_1 = require("./compat-addons");
|
|
@@ -14,6 +14,5 @@ var v1_addon_1 = require("./v1-addon");
|
|
|
14
14
|
Object.defineProperty(exports, "V1Addon", { enumerable: true, get: function () { return __importDefault(v1_addon_1).default; } });
|
|
15
15
|
var default_pipeline_1 = require("./default-pipeline");
|
|
16
16
|
Object.defineProperty(exports, "compatBuild", { enumerable: true, get: function () { return __importDefault(default_pipeline_1).default; } });
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(exports, "templateTagCodemod", { enumerable: true, get: function () { return __importDefault(template_tag_codemod_1).default; } });
|
|
17
|
+
Object.defineProperty(exports, "prebuild", { enumerable: true, get: function () { return default_pipeline_1.prebuild; } });
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAA8C;AAArC,kHAAA,OAAO,OAAO;AACvB,iDAAoD;AAA3C,wHAAA,OAAO,OAAU;AAC1B,qCAAmE;AAAtC,6GAAA,kBAAkB,OAAA;AAC/C,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAA8C;AAArC,kHAAA,OAAO,OAAO;AACvB,iDAAoD;AAA3C,wHAAA,OAAO,OAAU;AAC1B,qCAAmE;AAAtC,6GAAA,kBAAkB,OAAA;AAC/C,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,uDAAuF;AAA9E,gIAAA,OAAO,OAAe;AAAE,4GAAA,QAAQ,OAAA","sourcesContent":["export { default as App } from './compat-app';\nexport { default as Addons } from './compat-addons';\nexport { default as Options, recommendedOptions } from './options';\nexport { default as V1Addon } from './v1-addon';\nexport { default as compatBuild, prebuild, PipelineOptions } from './default-pipeline';\nexport { PackageRules, ModuleRules } from './dependency-rules';\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type CodeFrameStorage, type NamespaceMarker } from './audit/babel-visitor';
|
|
2
|
+
import type { Finding } from './audit';
|
|
3
|
+
import type { TransformOptions } from '@babel/core';
|
|
4
|
+
export type Module = CompleteModule | ParsedModule | UnparseableModule;
|
|
5
|
+
export interface UnparseableModule {
|
|
6
|
+
type: 'unparseable';
|
|
7
|
+
appRelativePath: string;
|
|
8
|
+
consumedFrom: (string | RootMarker)[];
|
|
9
|
+
}
|
|
10
|
+
export interface ParsedModule extends Omit<UnparseableModule, 'type'> {
|
|
11
|
+
type: 'parsed';
|
|
12
|
+
imports: Import[];
|
|
13
|
+
resolutions: {
|
|
14
|
+
[source: string]: string | null;
|
|
15
|
+
};
|
|
16
|
+
content: string;
|
|
17
|
+
isCJS: boolean;
|
|
18
|
+
isAMD: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface CompleteModule extends Omit<ParsedModule, 'type'> {
|
|
21
|
+
type: 'complete';
|
|
22
|
+
exports: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface Import {
|
|
25
|
+
source: string;
|
|
26
|
+
specifiers: {
|
|
27
|
+
name: string | NamespaceMarker;
|
|
28
|
+
local: string | null;
|
|
29
|
+
codeFrameIndex: number | undefined;
|
|
30
|
+
}[];
|
|
31
|
+
codeFrameIndex: number | undefined;
|
|
32
|
+
}
|
|
33
|
+
interface VisitorParams {
|
|
34
|
+
base: string;
|
|
35
|
+
resolveId: (specifier: string, fromFile: string) => Promise<string | undefined>;
|
|
36
|
+
load: (id: string) => Promise<{
|
|
37
|
+
content: string | Buffer;
|
|
38
|
+
type: ContentType;
|
|
39
|
+
} | undefined>;
|
|
40
|
+
entrypoints: string[];
|
|
41
|
+
debug?: boolean;
|
|
42
|
+
findings: Finding[];
|
|
43
|
+
frames: CodeFrameStorage;
|
|
44
|
+
babelConfig: TransformOptions;
|
|
45
|
+
}
|
|
46
|
+
export declare function visitModules(params: VisitorParams): Promise<Record<string, Module>>;
|
|
47
|
+
export type ContentType = 'javascript' | 'html';
|
|
48
|
+
export interface RootMarker {
|
|
49
|
+
isRoot: true;
|
|
50
|
+
}
|
|
51
|
+
export declare function isRootMarker(value: string | RootMarker | undefined): value is RootMarker;
|
|
52
|
+
export {};
|