@roots/bud-compiler 5.0.0-next.12 → 5.0.0-next.16
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/README.md +10 -13
- package/lib/cjs/Compiler/index.js +34 -16
- package/lib/cjs/Compiler/index.js.map +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/esm/Compiler/index.js +34 -16
- package/lib/esm/Compiler/index.js.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/tsconfig-esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -6
- package/types/Compiler/index.d.ts +2 -2
- package/types/Compiler/index.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
package/README.md
CHANGED
@@ -7,14 +7,17 @@
|
|
7
7
|
alt="MIT License"
|
8
8
|
src="https://img.shields.io/github/license/roots/bud?color=%23525ddc&style=flat-square"
|
9
9
|
/>
|
10
|
-
<a
|
11
|
-
|
10
|
+
<a
|
11
|
+
href="https://app.fossa.com/projects/git%2Bgithub.com%2Froots%2Fbud?ref=badge_small"
|
12
|
+
alt="FOSSA Status"
|
13
|
+
>
|
14
|
+
<img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Froots%2Fbud.svg?type=small" />
|
12
15
|
</a>
|
13
16
|
<a href="https://www.npmjs.com/package/@roots/bud">
|
14
17
|
<img src="https://img.shields.io/npm/v/@roots/bud.svg?color=%23525ddc&style=flat-square" />
|
15
18
|
</a>
|
16
19
|
<a href="https://codecov.io/gh/roots/bud">
|
17
|
-
<img src="https://codecov.io/gh/roots/bud/branch/next/graph/badge.svg?token=DRJ28OD8XD"/>
|
20
|
+
<img src="https://codecov.io/gh/roots/bud/branch/next/graph/badge.svg?token=DRJ28OD8XD" />
|
18
21
|
</a>
|
19
22
|
<a href="https://twitter.com/rootswp">
|
20
23
|
<img
|
@@ -24,18 +27,18 @@
|
|
24
27
|
</a>
|
25
28
|
</p>
|
26
29
|
|
27
|
-
|
28
30
|
<h1 align="center">
|
29
31
|
<strong>@roots/bud-compiler</strong>
|
30
32
|
</h1>
|
31
33
|
|
32
|
-
|
34
|
+
Compilation handler
|
35
|
+
|
33
36
|
## Installation
|
34
37
|
|
35
38
|
Install **@roots/bud-compiler** to your project.
|
36
39
|
|
37
40
|
```shell
|
38
|
-
yarn add @roots/bud-compiler
|
41
|
+
yarn add @roots/bud-compiler --dev
|
39
42
|
```
|
40
43
|
|
41
44
|
## Documentation
|
@@ -55,20 +58,14 @@ Keep track of development and community news.
|
|
55
58
|
## Contributing
|
56
59
|
|
57
60
|
Contributions are welcome from everyone.
|
58
|
-
|
59
61
|
We have [contribution guidelines](https://github.com/roots/guidelines/blob/master/CONTRIBUTING.md) to help you get started.
|
60
62
|
|
61
63
|
## Sponsors
|
62
64
|
|
63
65
|
Help support our open-source development efforts by [becoming a patron](https://www.patreon.com/rootsdev).
|
64
|
-
|
65
66
|
<a href="https://kinsta.com/?kaid=OFDHAJIXUDIV"><img src="https://cdn.roots.io/app/uploads/kinsta.svg" alt="Kinsta" width="200" height="150"/></a>
|
66
67
|
<a href="https://k-m.com/"><img src="https://cdn.roots.io/app/uploads/km-digital.svg" alt="KM Digital" width="200" height="150"/></a>
|
67
68
|
<a href="https://carrot.com/"><img src="https://cdn.roots.io/app/uploads/carrot.svg" alt="Carrot" width="200" height="150"/></a>
|
68
69
|
<a href="https://www.c21redwood.com/"><img src="https://cdn.roots.io/app/uploads/c21redwood.svg" alt="C21 Redwood Realty" width="200" height="150"/></a>
|
69
70
|
<a href="https://wordpress.com/"><img src="https://cdn.roots.io/app/uploads/wordpress.svg" alt="WordPress.com" width="200" height="150"/></a>
|
70
|
-
<a href="https://
|
71
|
-
<a href="https://www.harnessup.com/"><img src="https://cdn.roots.io/app/uploads/harness-software.svg" alt="Harness Software" width="200" height="150"/></a>
|
72
|
-
<a href="https://www.codersclan.com/"><img src="https://cdn.roots.io/app/uploads/coders-clan.svg" alt="Coders Clan" width="200" height="150"/></a>
|
73
|
-
<a href="https://generodigital.com/"><img src="https://cdn.roots.io/app/uploads/genero.svg" alt="Genero" width="200" height="150"/></a>
|
74
|
-
<a href="https://motto.ca/roots"><img src="https://cdn.roots.io/app/uploads/motto.svg" alt="Motto" width="200" height="150"/></a>
|
71
|
+
<a href="https://pantheon.io/"><img src="https://cdn.roots.io/app/uploads/pantheon.svg" alt="Pantheon" width="200" height="150"/></a>
|
@@ -6,7 +6,6 @@ const bud_framework_1 = require("@roots/bud-framework");
|
|
6
6
|
const bud_support_1 = require("@roots/bud-support");
|
7
7
|
const webpack_1 = require("webpack");
|
8
8
|
const { isFunction } = bud_support_1.lodash;
|
9
|
-
const helpful_decorators_1 = require("helpful-decorators");
|
10
9
|
/**
|
11
10
|
* Initial state
|
12
11
|
*
|
@@ -43,13 +42,16 @@ class Compiler extends bud_framework_1.Service {
|
|
43
42
|
this.config = [];
|
44
43
|
}
|
45
44
|
/**
|
46
|
-
*
|
45
|
+
* Service register event
|
47
46
|
*
|
48
47
|
* @public
|
49
48
|
* @decorator `@bind`
|
50
49
|
*/
|
51
50
|
register() {
|
52
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
51
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
52
|
+
this.app.hooks.filter('event.compiler.register.before', this.app);
|
53
|
+
this.app.hooks.filter('event.compiler.register.after', this.app);
|
54
|
+
});
|
53
55
|
}
|
54
56
|
/**
|
55
57
|
* Initiates compilation
|
@@ -62,7 +64,7 @@ class Compiler extends bud_framework_1.Service {
|
|
62
64
|
compile() {
|
63
65
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
64
66
|
const config = yield this.before();
|
65
|
-
const compiler = yield this.
|
67
|
+
const compiler = yield this.invoke(config);
|
66
68
|
this.app.timeEnd('bud');
|
67
69
|
return compiler;
|
68
70
|
});
|
@@ -71,26 +73,40 @@ class Compiler extends bud_framework_1.Service {
|
|
71
73
|
* @public
|
72
74
|
* @decorator `@bind`
|
73
75
|
*/
|
74
|
-
|
76
|
+
invoke(config) {
|
75
77
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
76
|
-
this.app.hooks.
|
78
|
+
config = yield this.app.hooks.promised('event.compiler.before', config);
|
79
|
+
config = this.app.hooks.filter('config.override', config);
|
77
80
|
this.instance = (0, webpack_1.webpack)(config);
|
78
81
|
this.instance.hooks.done.tap(config[0].name, (stats) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
82
|
+
yield this.app.hooks.filter('event.compiler.done', stats);
|
79
83
|
stats && Object.assign(this.stats, stats.toJson());
|
84
|
+
if (this.app.store.is('features.dashboard', false)) {
|
85
|
+
this.log('log', stats.toString({
|
86
|
+
colors: true,
|
87
|
+
modules: false,
|
88
|
+
children: false,
|
89
|
+
chunks: false,
|
90
|
+
chunkModules: false,
|
91
|
+
entrypoints: false,
|
92
|
+
performance: false,
|
93
|
+
}));
|
94
|
+
}
|
80
95
|
if (this.app.isProduction) {
|
81
96
|
this.instance.close(err => {
|
82
97
|
if (err) {
|
98
|
+
err = this.app.hooks.filter('compiler.error', err);
|
83
99
|
this.stats.errors.push(err);
|
84
100
|
this.log('error', err);
|
85
101
|
}
|
86
|
-
this.app.close(
|
102
|
+
!this.app.dashboard.instance && this.app.close();
|
87
103
|
});
|
88
104
|
}
|
89
105
|
}));
|
90
106
|
new webpack_1.ProgressPlugin((...args) => {
|
91
107
|
this.progress = args;
|
92
108
|
}).apply(this.instance);
|
93
|
-
this.app.hooks.filter('
|
109
|
+
this.app.hooks.filter('event.compiler.after');
|
94
110
|
return this.instance;
|
95
111
|
});
|
96
112
|
}
|
@@ -101,6 +117,7 @@ class Compiler extends bud_framework_1.Service {
|
|
101
117
|
* @decorator `@bind`
|
102
118
|
*/
|
103
119
|
before() {
|
120
|
+
var _a;
|
104
121
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
105
122
|
const config = [];
|
106
123
|
this.stats = INITIAL_STATS;
|
@@ -112,7 +129,7 @@ class Compiler extends bud_framework_1.Service {
|
|
112
129
|
* Attempt to use the parent instance in the compilation if there are entries
|
113
130
|
* registered to it or if it has no child instances registered.
|
114
131
|
*/
|
115
|
-
if (this.app.
|
132
|
+
if (!this.app.hasChildren) {
|
116
133
|
this.app.info(`using config from parent compiler`);
|
117
134
|
config.push(this.app.build.config);
|
118
135
|
return config;
|
@@ -124,7 +141,7 @@ class Compiler extends bud_framework_1.Service {
|
|
124
141
|
* If there are {@link Framework.children} instances, iterate through
|
125
142
|
* them and add to `config`
|
126
143
|
*/
|
127
|
-
yield Promise.all(this.app.children.getValues().map((instance) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
144
|
+
yield Promise.all((_a = this.app.children) === null || _a === void 0 ? void 0 : _a.getValues().map((instance) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
128
145
|
if (!instance.name)
|
129
146
|
return;
|
130
147
|
this.log('success', `\`${instance.name}\` compiler will be tapped`);
|
@@ -149,13 +166,13 @@ class Compiler extends bud_framework_1.Service {
|
|
149
166
|
* here we parse the callback args so that we dont have to
|
150
167
|
* duplicate the callback.
|
151
168
|
*/
|
152
|
-
|
169
|
+
let [err, stats] = args.length > 1 ? args : [null, args.pop()];
|
153
170
|
if ((stats === null || stats === void 0 ? void 0 : stats.toJson) && isFunction(stats.toJson)) {
|
154
171
|
this.stats = stats.toJson((_a = this.app.build.config.stats) !== null && _a !== void 0 ? _a : { preset: 'normal' });
|
155
|
-
this.app.
|
156
|
-
this.app.log(stats.toString());
|
172
|
+
this.stats = this.app.hooks.filter('compiler.stats', this.stats);
|
157
173
|
}
|
158
174
|
if (err) {
|
175
|
+
err = this.app.hooks.filter('compiler.error', err);
|
159
176
|
this.stats.errors.push(err);
|
160
177
|
this.app.store.is('features.dashboard', false) &&
|
161
178
|
this.log('error', err);
|
@@ -166,14 +183,15 @@ class Compiler extends bud_framework_1.Service {
|
|
166
183
|
bud_support_1.bind
|
167
184
|
], Compiler.prototype, "register", null);
|
168
185
|
(0, tslib_1.__decorate)([
|
169
|
-
bud_support_1.bind
|
186
|
+
bud_support_1.bind,
|
187
|
+
bud_support_1.once
|
170
188
|
], Compiler.prototype, "compile", null);
|
171
189
|
(0, tslib_1.__decorate)([
|
172
190
|
bud_support_1.bind
|
173
|
-
], Compiler.prototype, "
|
191
|
+
], Compiler.prototype, "invoke", null);
|
174
192
|
(0, tslib_1.__decorate)([
|
175
193
|
bud_support_1.bind,
|
176
|
-
|
194
|
+
bud_support_1.once
|
177
195
|
], Compiler.prototype, "before", null);
|
178
196
|
(0, tslib_1.__decorate)([
|
179
197
|
bud_support_1.bind
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"],"names":[],"mappings":";;;;AAAA,wDAG6B;AAC7B,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"],"names":[],"mappings":";;;;AAAA,wDAG6B;AAC7B,oDAAqD;AACrD,qCAAiE;AACjE,MAAM,EAAC,UAAU,EAAC,GAAG,oBAAM,CAAA;AAE3B;;;;GAIG;AACH,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,EAAE;CACb,CAAA;AAED;;;;GAIG;AACH,MAAa,QAAS,SAAQ,uBAAO;IAArC;;QAQE;;;;WAIG;QACI,UAAK,GAAqB,aAAa,CAAA;QAS9C;;;;WAIG;QACI,eAAU,GAAY,KAAK,CAAA;QAElC;;WAEG;QACI,WAAM,GAAQ,EAAE,CAAA;IA+LzB,CAAC;IA7LC;;;;;OAKG;IAEU,QAAQ;;YACnB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CACnB,gCAAgC,EAChC,IAAI,CAAC,GAAG,CACT,CAAA;YAED,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CACnB,+BAA+B,EAC/B,IAAI,CAAC,GAAG,CACT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AAC,KAAK,CAAC,MAAM,CAAC,KAAK,mCAAI,EAAC,MAAM,EAAE,QAAQ,EAAC,CAClD,CAAA;YAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAChC,gBAAgB,EAChB,IAAI,CAAC,KAAK,CACX,CAAA;SACF;QAED,IAAI,GAAG,EAAE;YACP,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;YAElD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAC3B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,CAAC;gBAC5C,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;SACzB;IACH,CAAC;CACF;AAtLC;IADC,kBAAI;wCAWJ;AAYD;IAFC,kBAAI;IACJ,kBAAI;uCAOJ;AAOD;IADC,kBAAI;sCAmDJ;AAUD;IAFC,kBAAI;IACJ,kBAAI;sCAiDJ;AASD;IADC,kBAAI;wCA8BJ;AA9NH,4BA+NC"}
|
package/lib/cjs/index.js
CHANGED
@@ -10,7 +10,7 @@ exports.Compiler = void 0;
|
|
10
10
|
* @see https://roots.io/bud
|
11
11
|
* @see https://github.com/roots/bud
|
12
12
|
*
|
13
|
-
* @core @packageDocumentation
|
13
|
+
* @core @packageDocumentation
|
14
14
|
*/
|
15
15
|
var Compiler_1 = require("./Compiler");
|
16
16
|
Object.defineProperty(exports, "Compiler", { enumerable: true, get: function () { return Compiler_1.Compiler; } });
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import { __awaiter, __decorate } from "tslib";
|
2
2
|
import { Service, } from '@roots/bud-framework';
|
3
|
-
import { bind, lodash } from '@roots/bud-support';
|
3
|
+
import { bind, lodash, once } from '@roots/bud-support';
|
4
4
|
import { ProgressPlugin, webpack } from 'webpack';
|
5
5
|
const { isFunction } = lodash;
|
6
|
-
import { once } from 'helpful-decorators';
|
7
6
|
/**
|
8
7
|
* Initial state
|
9
8
|
*
|
@@ -40,13 +39,16 @@ export class Compiler extends Service {
|
|
40
39
|
this.config = [];
|
41
40
|
}
|
42
41
|
/**
|
43
|
-
*
|
42
|
+
* Service register event
|
44
43
|
*
|
45
44
|
* @public
|
46
45
|
* @decorator `@bind`
|
47
46
|
*/
|
48
47
|
register() {
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
49
|
+
this.app.hooks.filter('event.compiler.register.before', this.app);
|
50
|
+
this.app.hooks.filter('event.compiler.register.after', this.app);
|
51
|
+
});
|
50
52
|
}
|
51
53
|
/**
|
52
54
|
* Initiates compilation
|
@@ -59,7 +61,7 @@ export class Compiler extends Service {
|
|
59
61
|
compile() {
|
60
62
|
return __awaiter(this, void 0, void 0, function* () {
|
61
63
|
const config = yield this.before();
|
62
|
-
const compiler = yield this.
|
64
|
+
const compiler = yield this.invoke(config);
|
63
65
|
this.app.timeEnd('bud');
|
64
66
|
return compiler;
|
65
67
|
});
|
@@ -68,26 +70,40 @@ export class Compiler extends Service {
|
|
68
70
|
* @public
|
69
71
|
* @decorator `@bind`
|
70
72
|
*/
|
71
|
-
|
73
|
+
invoke(config) {
|
72
74
|
return __awaiter(this, void 0, void 0, function* () {
|
73
|
-
this.app.hooks.
|
75
|
+
config = yield this.app.hooks.promised('event.compiler.before', config);
|
76
|
+
config = this.app.hooks.filter('config.override', config);
|
74
77
|
this.instance = webpack(config);
|
75
78
|
this.instance.hooks.done.tap(config[0].name, (stats) => __awaiter(this, void 0, void 0, function* () {
|
79
|
+
yield this.app.hooks.filter('event.compiler.done', stats);
|
76
80
|
stats && Object.assign(this.stats, stats.toJson());
|
81
|
+
if (this.app.store.is('features.dashboard', false)) {
|
82
|
+
this.log('log', stats.toString({
|
83
|
+
colors: true,
|
84
|
+
modules: false,
|
85
|
+
children: false,
|
86
|
+
chunks: false,
|
87
|
+
chunkModules: false,
|
88
|
+
entrypoints: false,
|
89
|
+
performance: false,
|
90
|
+
}));
|
91
|
+
}
|
77
92
|
if (this.app.isProduction) {
|
78
93
|
this.instance.close(err => {
|
79
94
|
if (err) {
|
95
|
+
err = this.app.hooks.filter('compiler.error', err);
|
80
96
|
this.stats.errors.push(err);
|
81
97
|
this.log('error', err);
|
82
98
|
}
|
83
|
-
this.app.close(
|
99
|
+
!this.app.dashboard.instance && this.app.close();
|
84
100
|
});
|
85
101
|
}
|
86
102
|
}));
|
87
103
|
new ProgressPlugin((...args) => {
|
88
104
|
this.progress = args;
|
89
105
|
}).apply(this.instance);
|
90
|
-
this.app.hooks.filter('
|
106
|
+
this.app.hooks.filter('event.compiler.after');
|
91
107
|
return this.instance;
|
92
108
|
});
|
93
109
|
}
|
@@ -98,6 +114,7 @@ export class Compiler extends Service {
|
|
98
114
|
* @decorator `@bind`
|
99
115
|
*/
|
100
116
|
before() {
|
117
|
+
var _a;
|
101
118
|
return __awaiter(this, void 0, void 0, function* () {
|
102
119
|
const config = [];
|
103
120
|
this.stats = INITIAL_STATS;
|
@@ -109,7 +126,7 @@ export class Compiler extends Service {
|
|
109
126
|
* Attempt to use the parent instance in the compilation if there are entries
|
110
127
|
* registered to it or if it has no child instances registered.
|
111
128
|
*/
|
112
|
-
if (this.app.
|
129
|
+
if (!this.app.hasChildren) {
|
113
130
|
this.app.info(`using config from parent compiler`);
|
114
131
|
config.push(this.app.build.config);
|
115
132
|
return config;
|
@@ -121,7 +138,7 @@ export class Compiler extends Service {
|
|
121
138
|
* If there are {@link Framework.children} instances, iterate through
|
122
139
|
* them and add to `config`
|
123
140
|
*/
|
124
|
-
yield Promise.all(this.app.children.getValues().map((instance) => __awaiter(this, void 0, void 0, function* () {
|
141
|
+
yield Promise.all((_a = this.app.children) === null || _a === void 0 ? void 0 : _a.getValues().map((instance) => __awaiter(this, void 0, void 0, function* () {
|
125
142
|
if (!instance.name)
|
126
143
|
return;
|
127
144
|
this.log('success', `\`${instance.name}\` compiler will be tapped`);
|
@@ -146,13 +163,13 @@ export class Compiler extends Service {
|
|
146
163
|
* here we parse the callback args so that we dont have to
|
147
164
|
* duplicate the callback.
|
148
165
|
*/
|
149
|
-
|
166
|
+
let [err, stats] = args.length > 1 ? args : [null, args.pop()];
|
150
167
|
if ((stats === null || stats === void 0 ? void 0 : stats.toJson) && isFunction(stats.toJson)) {
|
151
168
|
this.stats = stats.toJson((_a = this.app.build.config.stats) !== null && _a !== void 0 ? _a : { preset: 'normal' });
|
152
|
-
this.app.
|
153
|
-
this.app.log(stats.toString());
|
169
|
+
this.stats = this.app.hooks.filter('compiler.stats', this.stats);
|
154
170
|
}
|
155
171
|
if (err) {
|
172
|
+
err = this.app.hooks.filter('compiler.error', err);
|
156
173
|
this.stats.errors.push(err);
|
157
174
|
this.app.store.is('features.dashboard', false) &&
|
158
175
|
this.log('error', err);
|
@@ -163,11 +180,12 @@ __decorate([
|
|
163
180
|
bind
|
164
181
|
], Compiler.prototype, "register", null);
|
165
182
|
__decorate([
|
166
|
-
bind
|
183
|
+
bind,
|
184
|
+
once
|
167
185
|
], Compiler.prototype, "compile", null);
|
168
186
|
__decorate([
|
169
187
|
bind
|
170
|
-
], Compiler.prototype, "
|
188
|
+
], Compiler.prototype, "invoke", null);
|
171
189
|
__decorate([
|
172
190
|
bind,
|
173
191
|
once
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,OAAO,GACR,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,oBAAoB,CAAA;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,OAAO,GACR,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAC,IAAI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