@onepercentio/one-ui 1.2.6 → 1.3.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.
|
@@ -31,7 +31,7 @@ const { findPathDeep } = require("deepdash")(lodash);
|
|
|
31
31
|
|
|
32
32
|
function findAllStaticGeneration() {
|
|
33
33
|
const glob = require("glob");
|
|
34
|
-
const results = glob.sync("**/*.+(static|email).tsx", {
|
|
34
|
+
const results = glob.sync("**/*.+(static|email|document).tsx", {
|
|
35
35
|
cwd: join(resolve("."), "src"),
|
|
36
36
|
absolute: true,
|
|
37
37
|
});
|
|
@@ -41,7 +41,7 @@ function findAllStaticGeneration() {
|
|
|
41
41
|
|
|
42
42
|
function parseResultsrToEntries(results) {
|
|
43
43
|
return results.reduce((entries, filePath) => {
|
|
44
|
-
const [_, fileName] = /[\\/]([^\\/]+).(static|email).tsx/.exec(filePath);
|
|
44
|
+
const [_, fileName] = /[\\/]([^\\/]+).(static|email|document).tsx/.exec(filePath);
|
|
45
45
|
entries[fileName] = filePath;
|
|
46
46
|
return entries;
|
|
47
47
|
}, {});
|
|
@@ -221,7 +221,7 @@ async function createConfig(
|
|
|
221
221
|
});
|
|
222
222
|
|
|
223
223
|
whereToPlaceTheNewLoaderPath.splice(1, 0, {
|
|
224
|
-
test: /\.email\.tsx/,
|
|
224
|
+
test: [/\.email\.tsx/, /\.document\.tsx/],
|
|
225
225
|
use: [
|
|
226
226
|
{
|
|
227
227
|
loader: babelLoader.loader,
|
|
@@ -384,8 +384,15 @@ module.exports = async function initEmailWebpack() {
|
|
|
384
384
|
templatesFilter,
|
|
385
385
|
);
|
|
386
386
|
checkTemplatesCount(config.entry);
|
|
387
|
-
|
|
387
|
+
|
|
388
|
+
/** @type {import("webpack").Configuration} */
|
|
389
|
+
const finalConfig = {...config, bail: true}
|
|
390
|
+
return finalConfig;
|
|
388
391
|
};
|
|
389
392
|
|
|
390
393
|
module.exports.checkTemplatesCount = checkTemplatesCount;
|
|
391
394
|
/** @typedef {{mainHtml: [htmlPath: string, htmlOutputFilename: string][], templatesFilter: (availableTemplates: string[]) => Promise<string[]>}} EmailGeneratorConfig */
|
|
395
|
+
|
|
396
|
+
process.on("uncaughtException", e => {
|
|
397
|
+
console.log("Had error", e)
|
|
398
|
+
})
|
|
@@ -89,11 +89,49 @@ const prepareSizes = (options) => {
|
|
|
89
89
|
}));
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
+
function getIssuer(loaderContext, currentModule) {
|
|
93
|
+
const compilation = loaderContext._compilation;
|
|
94
|
+
|
|
95
|
+
if (
|
|
96
|
+
compilation &&
|
|
97
|
+
compilation.moduleGraph &&
|
|
98
|
+
typeof compilation.moduleGraph.getIssuer === "function"
|
|
99
|
+
) {
|
|
100
|
+
return compilation.moduleGraph.getIssuer(currentModule);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return currentModule && currentModule.issuer;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function shouldExportAsDataUrl(loaderContext) {
|
|
107
|
+
const documentEntryPattern = /\.document\.tsx(?:[?#].*)?$/;
|
|
108
|
+
let currentModule = loaderContext._module;
|
|
109
|
+
const visited = new Set();
|
|
110
|
+
|
|
111
|
+
while (currentModule && !visited.has(currentModule)) {
|
|
112
|
+
visited.add(currentModule);
|
|
113
|
+
|
|
114
|
+
const request =
|
|
115
|
+
currentModule.resource ||
|
|
116
|
+
currentModule.userRequest ||
|
|
117
|
+
currentModule.request ||
|
|
118
|
+
"";
|
|
119
|
+
|
|
120
|
+
if (documentEntryPattern.test(request)) {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
currentModule = getIssuer(loaderContext, currentModule);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
|
|
92
130
|
function _default(content) {
|
|
93
131
|
const options = Object.assign(
|
|
94
132
|
{},
|
|
95
133
|
loaderUtils.getOptions(this),
|
|
96
|
-
loaderUtils.parseQuery(this.resourceQuery || "?")
|
|
134
|
+
loaderUtils.parseQuery(this.resourceQuery || "?"),
|
|
97
135
|
);
|
|
98
136
|
const context = options.context || this.rootContext;
|
|
99
137
|
const callback = this.async();
|
|
@@ -101,7 +139,7 @@ function _default(content) {
|
|
|
101
139
|
options.name = options.name || "[contenthash].png";
|
|
102
140
|
options.name = options.name.replace(
|
|
103
141
|
"[name]",
|
|
104
|
-
_path.default.basename(this.resourcePath).replace(/\..*$/, "")
|
|
142
|
+
_path.default.basename(this.resourcePath).replace(/\..*$/, ""),
|
|
105
143
|
);
|
|
106
144
|
let outputPathBase = loaderUtils.interpolateName(this, options.name, {
|
|
107
145
|
context,
|
|
@@ -113,6 +151,8 @@ function _default(content) {
|
|
|
113
151
|
outputPathBase = _path.default.join(options.outputPath, outputPathBase);
|
|
114
152
|
}
|
|
115
153
|
|
|
154
|
+
const exportAsDataUrl = shouldExportAsDataUrl(this);
|
|
155
|
+
|
|
116
156
|
Promise.all(
|
|
117
157
|
prepareSizes(options).map((size) => {
|
|
118
158
|
return new Promise((resolve, reject) => {
|
|
@@ -121,7 +161,7 @@ function _default(content) {
|
|
|
121
161
|
if (size.width > -1 && size.height > -1) {
|
|
122
162
|
sharpInst = sharpInst.resize(
|
|
123
163
|
size.width * options.resizeFactor,
|
|
124
|
-
size.height * options.resizeFactor
|
|
164
|
+
size.height * options.resizeFactor,
|
|
125
165
|
);
|
|
126
166
|
}
|
|
127
167
|
|
|
@@ -148,20 +188,27 @@ function _default(content) {
|
|
|
148
188
|
return finalSize[match] || finalSize[match] === 0
|
|
149
189
|
? finalSize[match]
|
|
150
190
|
: match;
|
|
151
|
-
}
|
|
191
|
+
},
|
|
152
192
|
);
|
|
153
|
-
|
|
193
|
+
|
|
194
|
+
if (!exportAsDataUrl) {
|
|
195
|
+
this.emitFile(outputPath, data);
|
|
196
|
+
}
|
|
197
|
+
|
|
154
198
|
resolve({
|
|
155
199
|
size: finalSize,
|
|
156
200
|
outputPath,
|
|
201
|
+
data,
|
|
157
202
|
});
|
|
158
203
|
}
|
|
159
204
|
});
|
|
160
205
|
});
|
|
161
|
-
})
|
|
206
|
+
}),
|
|
162
207
|
)
|
|
163
208
|
.then((results) => {
|
|
164
|
-
let output =
|
|
209
|
+
let output = exportAsDataUrl
|
|
210
|
+
? `module.exports = "data:image/png;base64,${results[0].data.toString("base64")}";`
|
|
211
|
+
: `module.exports = __webpack_public_path__ + "${results[0].outputPath}";`;
|
|
165
212
|
callback(null, output);
|
|
166
213
|
})
|
|
167
214
|
.catch((error) => {
|
|
@@ -67,10 +67,8 @@
|
|
|
67
67
|
height: auto;
|
|
68
68
|
padding: 0px !important;
|
|
69
69
|
}
|
|
70
|
-
padding: 16px 32px;
|
|
71
70
|
position: relative;
|
|
72
|
-
width:
|
|
73
|
-
max-width: 640px;
|
|
71
|
+
max-width: 95vw;
|
|
74
72
|
background: $mainBackgroundColor;
|
|
75
73
|
backdrop-filter: var(--adaptive-dialog-backdrop, initial);
|
|
76
74
|
display: flex;
|
|
@@ -67,10 +67,8 @@
|
|
|
67
67
|
height: auto;
|
|
68
68
|
padding: 0px !important;
|
|
69
69
|
}
|
|
70
|
-
padding: 16px 32px;
|
|
71
70
|
position: relative;
|
|
72
|
-
width:
|
|
73
|
-
max-width: 640px;
|
|
71
|
+
max-width: 95vw;
|
|
74
72
|
background: $mainBackgroundColor;
|
|
75
73
|
backdrop-filter: var(--adaptive-dialog-backdrop, initial);
|
|
76
74
|
display: flex;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onepercentio/one-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A set of reusable components created through the development of Onepercent projects",
|
|
5
5
|
"repository": "git@github.com:onepercentio/one-ui.git",
|
|
6
6
|
"author": "Murilo Oliveira de Araujo <murilo.araujo@onepercent.io>",
|