@speedkit/cli 4.29.0 → 4.31.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 +14 -0
- package/README.md +1 -1
- package/dist/services/customer-config/customer-config-service-model.d.ts +6 -0
- package/dist/services/customer-config/customer-config-service-model.js +1 -0
- package/dist/services/customer-config/customer-config-service.d.ts +5 -0
- package/dist/services/customer-config/customer-config-service.js +15 -0
- package/dist/services/deploy/checks/activation/customer-approval-check.d.ts +21 -0
- package/dist/services/deploy/checks/activation/customer-approval-check.js +62 -0
- package/dist/services/deploy/checks/activation/customer-approval-check.spec.js +64 -0
- package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.js +9 -7
- package/dist/services/deploy/checks/pre-deploy/split-change-check.js +7 -6
- package/dist/services/deploy/deploy-service-factory.js +2 -1
- package/dist/services/deploy/handler/install-resource-handler.d.ts +7 -1
- package/dist/services/deploy/handler/install-resource-handler.js +40 -19
- package/dist/services/deploy/handler/testing-installation-links.d.ts +10 -0
- package/dist/services/deploy/handler/testing-installation-links.js +27 -0
- package/dist/services/deploy/handler/testing-installation-links.spec.d.ts +1 -0
- package/dist/services/deploy/handler/testing-installation-links.spec.js +43 -0
- package/dist/services/integration-api/file-list.d.ts +2 -1
- package/dist/services/integration-api/file-list.js +7 -1
- package/dist/services/integration-api/handler/install-resource-handler.js +10 -2
- package/dist/services/integration-api/integration-api-model.d.ts +8 -0
- package/dist/services/integration-api/integration-api-model.js +3 -0
- package/dist/services/integration-api/spec/config-plugin.spec.d.ts +1 -0
- package/dist/services/integration-api/spec/config-plugin.spec.js +188 -0
- package/dist/services/integration-api/spec/speed-kit-config-file.spec.d.ts +1 -0
- package/dist/{helpers/evaluate-speed-kit-config.spec.js → services/integration-api/spec/speed-kit-config-file.spec.js} +43 -12
- package/dist/services/integration-api/spec/speed-kit-config.spec.d.ts +1 -0
- package/dist/services/integration-api/spec/speed-kit-config.spec.js +108 -0
- package/dist/services/integration-api/struct/config-plugin.d.ts +41 -0
- package/dist/services/integration-api/struct/config-plugin.js +241 -0
- package/dist/services/integration-api/struct/customer-config.d.ts +7 -1
- package/dist/services/integration-api/struct/customer-config.js +10 -3
- package/dist/services/integration-api/struct/speed-kit-config-file.d.ts +46 -0
- package/dist/services/integration-api/struct/speed-kit-config-file.js +223 -0
- package/dist/services/integration-api/struct/speed-kit-config.d.ts +84 -0
- package/dist/services/integration-api/struct/speed-kit-config.js +114 -0
- package/dist/services/integration-api/virtual/static-recipe.d.ts +1 -1
- package/dist/services/query-builder/queries/spec/golden-configs.d.ts +2 -0
- package/dist/services/query-builder/queries/spec/golden-configs.js +37 -0
- package/dist/services/query-builder/queries/spec/golden.spec.js +5 -4
- package/dist/services/query-builder/queries/spec/queries.spec.js +2 -1
- package/dist/services/query-builder/queries/spec/reported-bugs.spec.js +2 -1
- package/dist/services/query-builder/query-builder-factory.js +4 -8
- package/dist/services/query-builder/query-builder-service.js +4 -0
- package/dist/services/query-builder/query-builder-service.spec.js +2 -1
- package/dist/services/query-builder/rules/rule-model.d.ts +6 -2
- package/dist/services/query-builder/rules/rule-model.js +0 -2
- package/dist/services/query-builder/rules/rule-parser.d.ts +7 -8
- package/dist/services/query-builder/rules/rule-parser.js +41 -47
- package/dist/services/query-builder/rules/spec/rule-parser.spec.js +30 -32
- package/dist/services/query-builder/rules/spec/rule-reducer.spec.js +2 -1
- package/dist/services/query-builder/rules/spec/rule-relevance.spec.js +7 -3
- package/dist/services/query-builder/rules/spec/rule-to-sql.spec.js +3 -2
- package/dist/services/query-builder/rules/spec/strip-parameters.spec.js +5 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/dist/helpers/evaluate-speed-kit-config.d.ts +0 -11
- package/dist/helpers/evaluate-speed-kit-config.js +0 -150
- /package/dist/{helpers/evaluate-speed-kit-config.spec.d.ts → services/deploy/checks/activation/customer-approval-check.spec.d.ts} +0 -0
- /package/dist/services/{deploy → integration-api}/error/evaluate-sk-config-error.d.ts +0 -0
- /package/dist/services/{deploy → integration-api}/error/evaluate-sk-config-error.js +0 -0
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import * as vm from "node:vm";
|
|
2
2
|
import { expect } from "chai";
|
|
3
3
|
import { describe, it } from "mocha";
|
|
4
|
-
import { parseCondition, parseRuleSets,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
expect(parseRuleSetVersion({ ruleSetConfig: { version: 2 } })).to.equal(2);
|
|
11
|
-
});
|
|
12
|
-
it("should read a version given as a string", () => {
|
|
13
|
-
expect(parseRuleSetVersion({ ruleSetConfig: { version: "2" } })).to.equal(2);
|
|
14
|
-
});
|
|
15
|
-
it("should fall back for an unusable version", () => {
|
|
16
|
-
expect(parseRuleSetVersion({ ruleSetConfig: { version: "x" } })).to.equal(1);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
4
|
+
import { parseCondition, parseRuleSets, parseStripQueryParams, } from "../rule-parser.js";
|
|
5
|
+
import { SpeedKitConfig, } from "../../../integration-api/struct/speed-kit-config.js";
|
|
6
|
+
/** The rule sets of a config, the way the query builder reads one. */
|
|
7
|
+
function ruleSetsOf(config) {
|
|
8
|
+
return parseRuleSets(SpeedKitConfig.createFrom(config));
|
|
9
|
+
}
|
|
19
10
|
describe("parseCondition", () => {
|
|
20
11
|
it("should wrap a single string", () => {
|
|
21
12
|
expect(parseCondition("/shop")).to.deep.equal([
|
|
@@ -51,30 +42,30 @@ describe("parseCondition", () => {
|
|
|
51
42
|
});
|
|
52
43
|
describe("parseRuleSets", () => {
|
|
53
44
|
it("should read every whitelist rule, not just the first", () => {
|
|
54
|
-
const { whitelist } =
|
|
45
|
+
const { whitelist } = ruleSetsOf({
|
|
55
46
|
whitelist: [{ host: ["www.shop.de"] }, { host: ["m.shop.de"] }],
|
|
56
47
|
});
|
|
57
48
|
expect(whitelist).to.have.lengthOf(2);
|
|
58
49
|
expect(whitelist[1].source).to.equal("whitelist[1]");
|
|
59
50
|
});
|
|
60
51
|
it("should keep the conditions of a rule together", () => {
|
|
61
|
-
const { enabledSites } =
|
|
52
|
+
const { enabledSites } = ruleSetsOf({
|
|
62
53
|
enabledSites: [{ host: ["www.shop.de"], pathname: [/^\/p\//i] }],
|
|
63
54
|
});
|
|
64
55
|
expect(enabledSites[0].conditions.map(({ subject }) => subject)).to.deep.eq(["host", "pathname"]);
|
|
65
56
|
});
|
|
66
57
|
it("should normalize the content types", () => {
|
|
67
|
-
const { blacklist } =
|
|
58
|
+
const { blacklist } = ruleSetsOf({
|
|
68
59
|
blacklist: [{ contentType: "Image" }],
|
|
69
60
|
});
|
|
70
61
|
expect(blacklist[0].contentTypes).to.deep.equal(["image"]);
|
|
71
62
|
});
|
|
72
63
|
it("should leave the content types undefined when there are none", () => {
|
|
73
|
-
const { blacklist } =
|
|
64
|
+
const { blacklist } = ruleSetsOf({ blacklist: [{ pathname: "/a" }] });
|
|
74
65
|
expect(blacklist[0].contentTypes).to.equal(undefined);
|
|
75
66
|
});
|
|
76
67
|
it("should record criteria that are not part of the url", () => {
|
|
77
|
-
const { disabledSites } =
|
|
68
|
+
const { disabledSites } = ruleSetsOf({
|
|
78
69
|
disabledSites: [{ cookie: /loggedIn/, mobile: true, pathname: "/a" }],
|
|
79
70
|
});
|
|
80
71
|
expect(disabledSites[0].criteriaOutsideTheUrl).to.deep.equal([
|
|
@@ -83,44 +74,41 @@ describe("parseRuleSets", () => {
|
|
|
83
74
|
]);
|
|
84
75
|
});
|
|
85
76
|
it("should apply the config version to every rule", () => {
|
|
86
|
-
const { enabledSites } =
|
|
77
|
+
const { enabledSites } = ruleSetsOf({
|
|
87
78
|
enabledSites: [{ pathname: "/a" }],
|
|
88
79
|
ruleSetConfig: { version: 2 },
|
|
89
80
|
});
|
|
90
81
|
expect(enabledSites[0].ruleSetVersion).to.equal(2);
|
|
91
82
|
});
|
|
92
83
|
it("should let a rule override the version", () => {
|
|
93
|
-
const { enabledSites } =
|
|
84
|
+
const { enabledSites } = ruleSetsOf({
|
|
94
85
|
enabledSites: [{ pathname: "/a", ruleSetVersion: 1 }],
|
|
95
86
|
ruleSetConfig: { version: 2 },
|
|
96
87
|
});
|
|
97
88
|
expect(enabledSites[0].ruleSetVersion).to.equal(1);
|
|
98
89
|
});
|
|
99
90
|
it("should survive a config without any rule set", () => {
|
|
100
|
-
const parsed =
|
|
91
|
+
const parsed = ruleSetsOf({});
|
|
101
92
|
expect(parsed.whitelist).to.deep.equal([]);
|
|
102
93
|
expect(parsed.enabledSites).to.deep.equal([]);
|
|
103
94
|
expect(parsed.stripQueryParams).to.deep.equal([]);
|
|
104
95
|
});
|
|
105
|
-
it("should ignore a rule set that is not an array", () => {
|
|
106
|
-
expect(parseRuleSets({ blacklist: "everything" }).blacklist).to.deep.equal([]);
|
|
107
|
-
});
|
|
108
96
|
it("should keep a rule without conditions", () => {
|
|
109
|
-
const { whitelist } =
|
|
97
|
+
const { whitelist } = ruleSetsOf({ whitelist: [{}] });
|
|
110
98
|
expect(whitelist).to.have.lengthOf(1);
|
|
111
99
|
expect(whitelist[0].conditions).to.deep.equal([]);
|
|
112
100
|
expect(whitelist[0].matchesNothing).to.equal(true);
|
|
113
101
|
});
|
|
114
102
|
it("should mark a rule with an empty condition as matching nothing", () => {
|
|
115
|
-
const { blacklist } =
|
|
103
|
+
const { blacklist } = ruleSetsOf({ blacklist: [{ host: [] }] });
|
|
116
104
|
expect(blacklist[0].matchesNothing).to.equal(true);
|
|
117
105
|
});
|
|
118
106
|
it("should mark an empty content type as matching nothing", () => {
|
|
119
|
-
const { blacklist } =
|
|
107
|
+
const { blacklist } = ruleSetsOf({ blacklist: [{ contentType: [] }] });
|
|
120
108
|
expect(blacklist[0].matchesNothing).to.equal(true);
|
|
121
109
|
});
|
|
122
110
|
it("should not mark a rule with a usable condition", () => {
|
|
123
|
-
const { blacklist } =
|
|
111
|
+
const { blacklist } = ruleSetsOf({ blacklist: [{ host: ["a.de"] }] });
|
|
124
112
|
expect(blacklist[0].matchesNothing).to.equal(false);
|
|
125
113
|
});
|
|
126
114
|
});
|
|
@@ -132,10 +120,20 @@ describe("parseStripQueryParams", () => {
|
|
|
132
120
|
expect(rules[0].enabledSites).to.equal(undefined);
|
|
133
121
|
});
|
|
134
122
|
it("should read a single parameter", () => {
|
|
135
|
-
expect(parseStripQueryParams("gclid", 2)[0].params).to.deep.equal([
|
|
123
|
+
expect(parseStripQueryParams(["gclid"], 2)[0].params).to.deep.equal([
|
|
136
124
|
{ kind: "string", value: "gclid" },
|
|
137
125
|
]);
|
|
138
126
|
});
|
|
127
|
+
it("should read a bare pattern from another realm", () => {
|
|
128
|
+
// A bare list is told apart from a list of rules by what is in it, and a
|
|
129
|
+
// config's own regular expressions are not `instanceof RegExp` here. Read
|
|
130
|
+
// as a rule, such an entry carries no `params` and is dropped — the whole
|
|
131
|
+
// list with it, so nothing would ever be stripped.
|
|
132
|
+
const foreign = vm.runInNewContext("/^utm[_-]/");
|
|
133
|
+
const rules = parseStripQueryParams(["gclid", foreign], 2);
|
|
134
|
+
expect(rules).to.have.lengthOf(1);
|
|
135
|
+
expect(rules[0].params).to.have.lengthOf(2);
|
|
136
|
+
});
|
|
139
137
|
it("should keep the pages a rule is scoped to", () => {
|
|
140
138
|
const rules = parseStripQueryParams([{ enabledSites: [{ pathname: [/^\/p\//i] }], params: ["size"] }], 2);
|
|
141
139
|
expect(rules[0].enabledSites).to.have.lengthOf(1);
|
|
@@ -145,6 +143,6 @@ describe("parseStripQueryParams", () => {
|
|
|
145
143
|
expect(parseStripQueryParams([{ enabledSites: [] }], 2)).to.deep.equal([]);
|
|
146
144
|
});
|
|
147
145
|
it("should return nothing when the property is missing", () => {
|
|
148
|
-
expect(parseStripQueryParams(
|
|
146
|
+
expect(parseStripQueryParams([], 2)).to.deep.equal([]);
|
|
149
147
|
});
|
|
150
148
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
2
|
import { describe, it } from "mocha";
|
|
3
3
|
import { parseRuleSets } from "../rule-parser.js";
|
|
4
|
+
import { SpeedKitConfig } from "../../../integration-api/struct/speed-kit-config.js";
|
|
4
5
|
import { absorbRules, dropUnreachableRules, findShadowedRules, reductionBudget, } from "../rule-reducer.js";
|
|
5
6
|
function rulesOf(config, version = 2) {
|
|
6
|
-
return parseRuleSets({ ruleSetConfig: { version }, ...config });
|
|
7
|
+
return parseRuleSets(SpeedKitConfig.createFrom({ ruleSetConfig: { version }, ...config }));
|
|
7
8
|
}
|
|
8
9
|
function blacklist(rules, version = 2) {
|
|
9
10
|
return rulesOf({ blacklist: rules }, version).blacklist;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
2
|
import { describe, it } from "mocha";
|
|
3
3
|
import { parseRuleSets } from "../rule-parser.js";
|
|
4
|
+
import { SpeedKitConfig } from "../../../integration-api/struct/speed-kit-config.js";
|
|
4
5
|
import { keepRelevantRules } from "../rule-relevance.js";
|
|
5
6
|
function blacklist(...rules) {
|
|
6
|
-
return parseRuleSets({ blacklist: rules })
|
|
7
|
+
return parseRuleSets(SpeedKitConfig.createFrom({ blacklist: rules }))
|
|
8
|
+
.blacklist;
|
|
7
9
|
}
|
|
8
10
|
function blacklistV2(...rules) {
|
|
9
|
-
return parseRuleSets({
|
|
10
|
-
|
|
11
|
+
return parseRuleSets(SpeedKitConfig.createFrom({
|
|
12
|
+
blacklist: rules,
|
|
13
|
+
ruleSetConfig: { version: 2 },
|
|
14
|
+
})).blacklist;
|
|
11
15
|
}
|
|
12
16
|
describe("keepRelevantRules content types", () => {
|
|
13
17
|
it("should drop a rule that only applies to other content types", () => {
|
|
@@ -2,13 +2,14 @@ import { expect } from "chai";
|
|
|
2
2
|
import { describe, it } from "mocha";
|
|
3
3
|
import { column, formatPredicate, isFalse, isTrue, leaf, } from "../../sql/index.js";
|
|
4
4
|
import { parseRuleSets } from "../rule-parser.js";
|
|
5
|
+
import { SpeedKitConfig } from "../../../integration-api/struct/speed-kit-config.js";
|
|
5
6
|
import { translateRules, urlSubjects } from "../rule-to-sql.js";
|
|
6
7
|
const subjects = urlSubjects(column("url"));
|
|
7
8
|
function enabledSites(rules, version) {
|
|
8
|
-
return parseRuleSets({
|
|
9
|
+
return parseRuleSets(SpeedKitConfig.createFrom({
|
|
9
10
|
enabledSites: rules,
|
|
10
11
|
...(version ? { ruleSetConfig: { version } } : {}),
|
|
11
|
-
}).enabledSites;
|
|
12
|
+
})).enabledSites;
|
|
12
13
|
}
|
|
13
14
|
function sql(rules, version) {
|
|
14
15
|
return formatPredicate(translateRules(enabledSites(rules, version), subjects).predicate);
|
|
@@ -2,12 +2,15 @@ import { expect } from "chai";
|
|
|
2
2
|
import { describe, it } from "mocha";
|
|
3
3
|
import { column, formatPredicate } from "../../sql/index.js";
|
|
4
4
|
import { parseRuleSets } from "../rule-parser.js";
|
|
5
|
+
import { SpeedKitConfig } from "../../../integration-api/struct/speed-kit-config.js";
|
|
5
6
|
import { urlSubjects } from "../rule-to-sql.js";
|
|
6
7
|
import { notStrippedParameter, prepareStripParameters, strippedUrlExpression, } from "../strip-parameters.js";
|
|
7
8
|
const subjects = urlSubjects(column("url"));
|
|
8
9
|
function prepare(stripQueryParams, version = 2) {
|
|
9
|
-
return prepareStripParameters(parseRuleSets({
|
|
10
|
-
|
|
10
|
+
return prepareStripParameters(parseRuleSets(SpeedKitConfig.createFrom({
|
|
11
|
+
ruleSetConfig: { version },
|
|
12
|
+
stripQueryParams,
|
|
13
|
+
})).stripQueryParams, subjects);
|
|
11
14
|
}
|
|
12
15
|
function strippedUrl(stripQueryParams, version = 2) {
|
|
13
16
|
return strippedUrlExpression(prepare(stripQueryParams, version), "url");
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { InstallResourceFile } from "../services/integration-api/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* The `window.speedKit` a config assigned — whatever shape the config wrote,
|
|
4
|
-
* not the seed object the browser mock starts from.
|
|
5
|
-
*/
|
|
6
|
-
export type EvaluatedSpeedKitConfig = Record<string, any>;
|
|
7
|
-
export declare function evaluateLocalSpeedKitConfig(app: string, origin: string, speedKitConfigFile: InstallResourceFile): Promise<EvaluatedSpeedKitConfig>;
|
|
8
|
-
export declare function evaluateLocalAndRemoteSpeedKit(app: string, origin: string, speedKitConfigFile: InstallResourceFile, activeSpeedKitConfig: string): Promise<{
|
|
9
|
-
localSpeedKit: EvaluatedSpeedKitConfig;
|
|
10
|
-
remoteSpeedKit: EvaluatedSpeedKitConfig;
|
|
11
|
-
}>;
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { EvaluateSkConfigError } from "../services/deploy/error/evaluate-sk-config-error.js";
|
|
2
|
-
import * as vm from "node:vm";
|
|
3
|
-
import { BundleServiceFactory } from "../services/bundler/index.js";
|
|
4
|
-
import ApplicationError from "../services/error-handling/error/application-error.js";
|
|
5
|
-
export async function evaluateLocalSpeedKitConfig(app, origin, speedKitConfigFile) {
|
|
6
|
-
const localBrowserContext = buildBrowserMock(origin, app);
|
|
7
|
-
const localFileContent = safeFileContentWrapper(await bundle(speedKitConfigFile.getContent(), app));
|
|
8
|
-
vm.runInNewContext(localFileContent, localBrowserContext, {
|
|
9
|
-
filename: speedKitConfigFile.path,
|
|
10
|
-
displayErrors: false,
|
|
11
|
-
breakOnSigint: true,
|
|
12
|
-
});
|
|
13
|
-
if (localBrowserContext.vmError !== null) {
|
|
14
|
-
throw new EvaluateSkConfigError(`[config_Speedkit.js] ${localBrowserContext.vmError?.message}`);
|
|
15
|
-
}
|
|
16
|
-
return localBrowserContext.window.speedKit;
|
|
17
|
-
}
|
|
18
|
-
export async function evaluateLocalAndRemoteSpeedKit(app, origin, speedKitConfigFile, activeSpeedKitConfig) {
|
|
19
|
-
const localBrowserContext = buildBrowserMock(origin, app);
|
|
20
|
-
const localFileContent = safeFileContentWrapper(await bundle(speedKitConfigFile.getContent(), app));
|
|
21
|
-
vm.runInNewContext(localFileContent, localBrowserContext, {
|
|
22
|
-
filename: speedKitConfigFile.path,
|
|
23
|
-
displayErrors: false,
|
|
24
|
-
breakOnSigint: true,
|
|
25
|
-
});
|
|
26
|
-
const remoteBrowserContext = buildBrowserMock(origin, app);
|
|
27
|
-
const remoteFileContent = safeFileContentWrapper(await bundle(activeSpeedKitConfig, app));
|
|
28
|
-
vm.runInNewContext(remoteFileContent, remoteBrowserContext, {
|
|
29
|
-
displayErrors: false,
|
|
30
|
-
breakOnSigint: true,
|
|
31
|
-
});
|
|
32
|
-
if (localBrowserContext.vmError !== null) {
|
|
33
|
-
throw new EvaluateSkConfigError(`[config_Speedkit.js] ${localBrowserContext.vmError?.message}`);
|
|
34
|
-
}
|
|
35
|
-
if (remoteBrowserContext.vmError !== null) {
|
|
36
|
-
throw new EvaluateSkConfigError(`[remote_config] ${JSON.stringify(remoteBrowserContext.vmError?.message)}`);
|
|
37
|
-
}
|
|
38
|
-
const localSpeedKit = localBrowserContext.window.speedKit;
|
|
39
|
-
const remoteSpeedKit = remoteBrowserContext.window.speedKit;
|
|
40
|
-
return { localSpeedKit, remoteSpeedKit };
|
|
41
|
-
}
|
|
42
|
-
function buildBrowserMock(origin, app) {
|
|
43
|
-
const originUrl = new URL(origin);
|
|
44
|
-
const window = {
|
|
45
|
-
location: originUrl,
|
|
46
|
-
APP: app,
|
|
47
|
-
speedKit: {
|
|
48
|
-
split: undefined,
|
|
49
|
-
splitTestId: undefined,
|
|
50
|
-
detectDevice: () => {
|
|
51
|
-
/* empty */
|
|
52
|
-
},
|
|
53
|
-
customVariation: [],
|
|
54
|
-
},
|
|
55
|
-
SpeedKit: {},
|
|
56
|
-
serviceWorkerUrl: "",
|
|
57
|
-
screen: { width: 0, height: 0 },
|
|
58
|
-
devicePixelRatio: 1,
|
|
59
|
-
setTimeout: () => {
|
|
60
|
-
/* empty */
|
|
61
|
-
},
|
|
62
|
-
clearTimeout: () => {
|
|
63
|
-
/* empty */
|
|
64
|
-
},
|
|
65
|
-
addEventListener: () => {
|
|
66
|
-
/* empty */
|
|
67
|
-
},
|
|
68
|
-
removeEventListener: () => {
|
|
69
|
-
/* empty */
|
|
70
|
-
},
|
|
71
|
-
navigator: {
|
|
72
|
-
userAgent: "",
|
|
73
|
-
connection: {},
|
|
74
|
-
cookieEnabled: false,
|
|
75
|
-
languages: [],
|
|
76
|
-
online: true,
|
|
77
|
-
},
|
|
78
|
-
top: {},
|
|
79
|
-
};
|
|
80
|
-
window.top = window;
|
|
81
|
-
// A config may read the DOM while it builds itself — `precache` is
|
|
82
|
-
// frequently a list of script and link hrefs. There is no document here, so
|
|
83
|
-
// these answer the way the DOM answers for a page without matches: an empty
|
|
84
|
-
// list, not `undefined`, which `Array.from` and `forEach` would choke on.
|
|
85
|
-
const document = {
|
|
86
|
-
cookie: "",
|
|
87
|
-
referrer: "",
|
|
88
|
-
getElementById: () => null,
|
|
89
|
-
querySelector: () => null,
|
|
90
|
-
querySelectorAll: () => [],
|
|
91
|
-
createElement: () => {
|
|
92
|
-
/* empty */
|
|
93
|
-
},
|
|
94
|
-
addEventListener: () => {
|
|
95
|
-
/* empty */
|
|
96
|
-
},
|
|
97
|
-
removeEventListener: () => {
|
|
98
|
-
/* empty */
|
|
99
|
-
},
|
|
100
|
-
head: {},
|
|
101
|
-
body: {},
|
|
102
|
-
};
|
|
103
|
-
document.head = document;
|
|
104
|
-
document.body = document;
|
|
105
|
-
return {
|
|
106
|
-
vmError: null,
|
|
107
|
-
...window,
|
|
108
|
-
window,
|
|
109
|
-
document,
|
|
110
|
-
navigator: { userAgent: "" },
|
|
111
|
-
localStorage: {
|
|
112
|
-
getItem: () => {
|
|
113
|
-
/* empty */
|
|
114
|
-
},
|
|
115
|
-
setItem: () => {
|
|
116
|
-
/* empty */
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
JSON: JSON,
|
|
120
|
-
decodeURIComponent: decodeURIComponent,
|
|
121
|
-
URL: URL,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function safeFileContentWrapper(fileContent) {
|
|
125
|
-
return `
|
|
126
|
-
try{
|
|
127
|
-
${fileContent}
|
|
128
|
-
} catch (error){
|
|
129
|
-
vmError = error
|
|
130
|
-
}
|
|
131
|
-
`;
|
|
132
|
-
}
|
|
133
|
-
async function bundle(content, app) {
|
|
134
|
-
if (!content) {
|
|
135
|
-
throw new ApplicationError("Content is empty");
|
|
136
|
-
}
|
|
137
|
-
const bundler = new BundleServiceFactory("./").buildService();
|
|
138
|
-
return bundler.bundle({
|
|
139
|
-
basePaths: {
|
|
140
|
-
"speed-kit-config": "https://www.baqend.com/speed-kit-config/latest/",
|
|
141
|
-
},
|
|
142
|
-
entryPoints: { "config.js": content },
|
|
143
|
-
logLevel: "error",
|
|
144
|
-
minify: false,
|
|
145
|
-
define: {
|
|
146
|
-
APP: JSON.stringify(app),
|
|
147
|
-
},
|
|
148
|
-
platform: "browser",
|
|
149
|
-
});
|
|
150
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|