@rws-framework/client 2.13.2 → 2.13.4
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/.bin/add-v.sh +9 -9
- package/.bin/emerge.sh +15 -15
- package/.emerge-fast.yaml +46 -46
- package/.emerge-typescript-template.yaml +23 -23
- package/.emerge-vis-output/fast-element/emerge-file_result_dependency_graph.graphml +693 -693
- package/.emerge-vis-output/fast-element/emerge-filesystem_graph.graphml +705 -705
- package/.emerge-vis-output/fast-element/emerge-statistics-metrics.txt +440 -440
- package/.emerge-vis-output/fast-element/html/emerge.html +500 -500
- package/.emerge-vis-output/fast-element/html/jsconfig.json +8 -8
- package/.emerge-vis-output/fast-element/html/resources/css/custom.css +211 -211
- package/.emerge-vis-output/fast-element/html/resources/js/emerge_common.js +44 -44
- package/.emerge-vis-output/fast-element/html/resources/js/emerge_data.js +13 -13
- package/.emerge-vis-output/fast-element/html/resources/js/emerge_git.js +1413 -1413
- package/.emerge-vis-output/fast-element/html/resources/js/emerge_graph.js +539 -539
- package/.emerge-vis-output/fast-element/html/resources/js/emerge_heatmap.js +219 -219
- package/.emerge-vis-output/fast-element/html/resources/js/emerge_hull.js +179 -179
- package/.emerge-vis-output/fast-element/html/resources/js/emerge_main.js +1002 -1002
- package/.emerge-vis-output/fast-element/html/resources/js/emerge_search.js +71 -71
- package/.emerge-vis-output/fast-element/html/resources/js/emerge_ui.js +199 -199
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-grid.css +4123 -4123
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-grid.min.css +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-grid.rtl.css +4122 -4122
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-grid.rtl.min.css +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-reboot.css +487 -487
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-reboot.min.css +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-reboot.rtl.css +484 -484
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-reboot.rtl.min.css +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-utilities.css +4265 -4265
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-utilities.min.css +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-utilities.rtl.css +4256 -4256
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap-utilities.rtl.min.css +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap.css +10877 -10877
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap.min.css +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap.rtl.css +10841 -10841
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/css/bootstrap.rtl.min.css +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/js/bootstrap.bundle.js +7075 -7075
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/js/bootstrap.bundle.min.js +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/js/bootstrap.esm.js +5202 -5202
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/js/bootstrap.esm.min.js +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/js/bootstrap.js +5249 -5249
- package/.emerge-vis-output/fast-element/html/vendors/bootstrap/js/bootstrap.min.js +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/d3/d3.v7.8.4.min.js +2 -2
- package/.emerge-vis-output/fast-element/html/vendors/d3/d3.v7.min.js +2 -2
- package/.emerge-vis-output/fast-element/html/vendors/dark-mode-switch/css/dark-mode.css +148 -148
- package/.emerge-vis-output/fast-element/html/vendors/daterangepicker/daterangepicker.min.js +7 -7
- package/.emerge-vis-output/fast-element/html/vendors/daterangepicker/moment.min.js +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/hull/hull.js +373 -373
- package/.emerge-vis-output/fast-element/html/vendors/jquery/jquery-3.6.0.min.js +2 -2
- package/.emerge-vis-output/fast-element/html/vendors/popper/popper.min.js +6 -6
- package/.emerge-vis-output/fast-element/html/vendors/simpleheat/simpleheat.js +141 -141
- package/.emerge-vis-output/fast-foundation/emerge-file_result_dependency_graph.graphml +4043 -4043
- package/.emerge-vis-output/fast-foundation/emerge-filesystem_graph.graphml +4538 -4538
- package/.emerge-vis-output/fast-foundation/emerge-statistics-metrics.txt +2510 -2510
- package/.emerge-vis-output/fast-foundation/html/emerge.html +500 -500
- package/.emerge-vis-output/fast-foundation/html/jsconfig.json +8 -8
- package/.emerge-vis-output/fast-foundation/html/resources/css/custom.css +211 -211
- package/.emerge-vis-output/fast-foundation/html/resources/js/emerge_common.js +44 -44
- package/.emerge-vis-output/fast-foundation/html/resources/js/emerge_data.js +13 -13
- package/.emerge-vis-output/fast-foundation/html/resources/js/emerge_git.js +1413 -1413
- package/.emerge-vis-output/fast-foundation/html/resources/js/emerge_graph.js +539 -539
- package/.emerge-vis-output/fast-foundation/html/resources/js/emerge_heatmap.js +219 -219
- package/.emerge-vis-output/fast-foundation/html/resources/js/emerge_hull.js +179 -179
- package/.emerge-vis-output/fast-foundation/html/resources/js/emerge_main.js +1002 -1002
- package/.emerge-vis-output/fast-foundation/html/resources/js/emerge_search.js +71 -71
- package/.emerge-vis-output/fast-foundation/html/resources/js/emerge_ui.js +199 -199
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-grid.css +4123 -4123
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-grid.min.css +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-grid.rtl.css +4122 -4122
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-grid.rtl.min.css +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-reboot.css +487 -487
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-reboot.min.css +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-reboot.rtl.css +484 -484
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-reboot.rtl.min.css +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-utilities.css +4265 -4265
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-utilities.min.css +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-utilities.rtl.css +4256 -4256
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap-utilities.rtl.min.css +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap.css +10877 -10877
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap.min.css +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap.rtl.css +10841 -10841
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/css/bootstrap.rtl.min.css +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/js/bootstrap.bundle.js +7075 -7075
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/js/bootstrap.bundle.min.js +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/js/bootstrap.esm.js +5202 -5202
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/js/bootstrap.esm.min.js +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/js/bootstrap.js +5249 -5249
- package/.emerge-vis-output/fast-foundation/html/vendors/bootstrap/js/bootstrap.min.js +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/d3/d3.v7.8.4.min.js +2 -2
- package/.emerge-vis-output/fast-foundation/html/vendors/d3/d3.v7.min.js +2 -2
- package/.emerge-vis-output/fast-foundation/html/vendors/dark-mode-switch/css/dark-mode.css +148 -148
- package/.emerge-vis-output/fast-foundation/html/vendors/daterangepicker/daterangepicker.min.js +7 -7
- package/.emerge-vis-output/fast-foundation/html/vendors/daterangepicker/moment.min.js +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/hull/hull.js +373 -373
- package/.emerge-vis-output/fast-foundation/html/vendors/jquery/jquery-3.6.0.min.js +2 -2
- package/.emerge-vis-output/fast-foundation/html/vendors/popper/popper.min.js +6 -6
- package/.emerge-vis-output/fast-foundation/html/vendors/simpleheat/simpleheat.js +141 -141
- package/.emerge-vis-output/rws-client/emerge-file_result_dependency_graph.graphml +1143 -1143
- package/.emerge-vis-output/rws-client/emerge-filesystem_graph.graphml +1003 -1003
- package/.emerge-vis-output/rws-client/emerge-statistics-metrics.txt +655 -655
- package/.emerge-vis-output/rws-client/html/emerge.html +500 -500
- package/.emerge-vis-output/rws-client/html/jsconfig.json +8 -8
- package/.emerge-vis-output/rws-client/html/resources/css/custom.css +211 -211
- package/.emerge-vis-output/rws-client/html/resources/js/emerge_common.js +44 -44
- package/.emerge-vis-output/rws-client/html/resources/js/emerge_data.js +13 -13
- package/.emerge-vis-output/rws-client/html/resources/js/emerge_git.js +1413 -1413
- package/.emerge-vis-output/rws-client/html/resources/js/emerge_graph.js +539 -539
- package/.emerge-vis-output/rws-client/html/resources/js/emerge_heatmap.js +219 -219
- package/.emerge-vis-output/rws-client/html/resources/js/emerge_hull.js +179 -179
- package/.emerge-vis-output/rws-client/html/resources/js/emerge_main.js +1002 -1002
- package/.emerge-vis-output/rws-client/html/resources/js/emerge_search.js +71 -71
- package/.emerge-vis-output/rws-client/html/resources/js/emerge_ui.js +199 -199
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-grid.css +4123 -4123
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-grid.min.css +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-grid.rtl.css +4122 -4122
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-grid.rtl.min.css +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-reboot.css +487 -487
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-reboot.min.css +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-reboot.rtl.css +484 -484
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-reboot.rtl.min.css +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-utilities.css +4265 -4265
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-utilities.min.css +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-utilities.rtl.css +4256 -4256
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap-utilities.rtl.min.css +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap.css +10877 -10877
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap.min.css +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap.rtl.css +10841 -10841
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/css/bootstrap.rtl.min.css +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/js/bootstrap.bundle.js +7075 -7075
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/js/bootstrap.bundle.min.js +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/js/bootstrap.esm.js +5202 -5202
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/js/bootstrap.esm.min.js +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/js/bootstrap.js +5249 -5249
- package/.emerge-vis-output/rws-client/html/vendors/bootstrap/js/bootstrap.min.js +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/d3/d3.v7.8.4.min.js +2 -2
- package/.emerge-vis-output/rws-client/html/vendors/d3/d3.v7.min.js +2 -2
- package/.emerge-vis-output/rws-client/html/vendors/dark-mode-switch/css/dark-mode.css +148 -148
- package/.emerge-vis-output/rws-client/html/vendors/daterangepicker/daterangepicker.min.js +7 -7
- package/.emerge-vis-output/rws-client/html/vendors/daterangepicker/moment.min.js +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/hull/hull.js +373 -373
- package/.emerge-vis-output/rws-client/html/vendors/jquery/jquery-3.6.0.min.js +2 -2
- package/.emerge-vis-output/rws-client/html/vendors/popper/popper.min.js +6 -6
- package/.emerge-vis-output/rws-client/html/vendors/simpleheat/simpleheat.js +141 -141
- package/.eslintrc.json +51 -51
- package/.gitmodules +2 -2
- package/.setup/.eslintrc.json +11 -11
- package/.setup/_base.eslintrc.json +48 -48
- package/.setup/tsconfig.json +28 -28
- package/PLUGINS.MD +188 -188
- package/README.md +1023 -1023
- package/_tools.js +396 -396
- package/builder/vite/index.ts +4 -4
- package/{cfg/build_steps → builder}/vite/loaders/html.ts +11 -11
- package/{cfg/build_steps → builder}/vite/loaders/index.ts +8 -8
- package/{cfg/build_steps → builder}/vite/loaders/loader.type.ts +27 -27
- package/{cfg/build_steps → builder}/vite/loaders/scss.ts +32 -32
- package/{cfg/build_steps → builder}/vite/loaders/ts.ts +309 -309
- package/builder/vite/rws.vite.config.ts +56 -49
- package/{cfg/build_steps → builder}/vite/rws_scss_plugin.ts +61 -60
- package/{cfg/build_steps → builder}/vite/scss/_compiler.ts +95 -94
- package/{cfg/build_steps → builder}/vite/scss/_fonts.ts +80 -80
- package/{cfg/build_steps → builder}/vite/scss/_fs.ts +83 -81
- package/{cfg/build_steps → builder}/vite/scss/_import.ts +191 -184
- package/builder/webpack/after/copy.js +78 -78
- package/builder/webpack/after/sw.js +13 -13
- package/builder/webpack/index.js +10 -10
- package/builder/webpack/loaders/rws_fast_html_loader.js +17 -17
- package/builder/webpack/loaders/rws_fast_scss_loader.js +43 -43
- package/builder/webpack/loaders/rws_fast_ts_loader.js +96 -96
- package/builder/webpack/loaders/ts/html_error.js +19 -19
- package/builder/webpack/rws.webpack.config.js +169 -169
- package/builder/webpack/rws_scss_plugin.js +62 -62
- package/builder/webpack/rws_webpack_plugin.js +137 -137
- package/builder/webpack/scss/_compiler.js +97 -97
- package/builder/webpack/scss/_fonts.js +80 -80
- package/builder/webpack/scss/_fs.js +84 -84
- package/builder/webpack/scss/_import.js +186 -186
- package/cfg/_default.cfg.js +26 -26
- package/cfg/_storage.d.ts +22 -22
- package/cfg/_storage.js +42 -42
- package/cfg/build_steps/vite/_build_config.ts +105 -105
- package/cfg/build_steps/vite/_env_defines.ts +17 -17
- package/cfg/build_steps/vite/_loaders.ts +187 -186
- package/cfg/build_steps/vite/index.ts +2 -2
- package/cfg/build_steps/vite/types.ts +7 -7
- package/cfg/build_steps/webpack/_actions.js +85 -85
- package/cfg/build_steps/webpack/_aliases.js +9 -9
- package/cfg/build_steps/webpack/_build_config.js +76 -76
- package/cfg/build_steps/webpack/_cache.js +98 -98
- package/cfg/build_steps/webpack/_component_handling.js +60 -60
- package/cfg/build_steps/webpack/_dev_servers.js +14 -14
- package/cfg/build_steps/webpack/_env_defines.js +18 -18
- package/cfg/build_steps/webpack/_info.js +18 -18
- package/cfg/build_steps/webpack/_loaders.js +223 -223
- package/cfg/build_steps/webpack/_plugins.js +102 -102
- package/cfg/build_steps/webpack/_production.js +37 -37
- package/cfg/build_steps/webpack/_rws_externals.js +68 -68
- package/cfg/build_steps/webpack/_timing.js +52 -52
- package/cfg/build_steps/webpack/_webpack_config.js +58 -58
- package/cfg/tsconfigSetup.js +150 -150
- package/console.js +86 -86
- package/docs/assets/26e93147f10415a0ed4a.svg +6 -6
- package/docs/assets/75c9471662e97ee24f29.svg +7 -7
- package/docs/assets/db90e4df2373980c497d.svg +9 -9
- package/docs/assets/highlight.css +127 -127
- package/docs/assets/main.js +59 -59
- package/docs/assets/style.css +1414 -1414
- package/docs/classes/ApiServiceInstance.html +25 -25
- package/docs/classes/ConfigServiceInstance.html +21 -21
- package/docs/classes/DOMServiceInstance.html +17 -17
- package/docs/classes/NotifyServiceInstance.html +15 -15
- package/docs/classes/RWSClientInstance.html +45 -45
- package/docs/classes/RWSPlugin.html +13 -13
- package/docs/classes/RWSService.html +10 -10
- package/docs/classes/RWSViewComponent.html +1022 -1022
- package/docs/classes/ServiceWorkerServiceInstance.html +13 -13
- package/docs/classes/UtilsServiceInstance.html +13 -13
- package/docs/functions/attr.html +5 -5
- package/docs/functions/observable.html +3 -3
- package/docs/index.html +179 -179
- package/docs/interfaces/HTMLTag.html +3 -3
- package/docs/interfaces/IRWSConfig.html +20 -20
- package/docs/interfaces/IRWSDecoratorOptions.html +5 -5
- package/docs/interfaces/IRWSHttpRoute.html +2 -2
- package/docs/interfaces/IRWSPrefixedHTTProutes.html +2 -2
- package/docs/interfaces/IRWSUser.html +5 -5
- package/docs/modules.html +45 -45
- package/foundation/index.js +1 -1
- package/foundation/rws-foundation.d.ts +7 -7
- package/foundation/rws-foundation.js +7 -7
- package/package.json +108 -108
- package/service_worker/src/_service_worker.ts +83 -83
- package/service_worker/tsconfig.json +20 -20
- package/service_worker/webpack.config.js +66 -66
- package/src/client/components.ts +67 -67
- package/src/client/config.ts +165 -165
- package/src/client/services.ts +27 -27
- package/src/client.ts +212 -212
- package/src/components/_attrs/_default_observable_accessor.ts +8 -8
- package/src/components/_attrs/_extended_accessor.ts +40 -40
- package/src/components/_attrs/_external_handler.ts +7 -7
- package/src/components/_attrs/_external_observable_accessor.ts +8 -8
- package/src/components/_attrs/angular-attr.ts +34 -34
- package/src/components/_attrs/external-attr.ts +59 -59
- package/src/components/_attrs/external-observable.ts +52 -52
- package/src/components/_attrs/sanitize-html.ts +80 -80
- package/src/components/_component.ts +245 -245
- package/src/components/_container.ts +15 -15
- package/src/components/_decorator.ts +122 -122
- package/src/components/_decorators/RWSFillBuild.ts +54 -54
- package/src/components/_decorators/RWSInject.ts +49 -49
- package/src/components/_decorators/RWSService.ts +11 -11
- package/src/components/_decorators/_di.ts +15 -15
- package/src/components/_definitions.ts +64 -64
- package/src/components/_event_handling.ts +40 -40
- package/src/components/index.ts +14 -14
- package/src/components/loader/component.ts +12 -12
- package/src/components/loader/styles/layout.scss +13 -13
- package/src/components/progress/component.ts +54 -54
- package/src/components/progress/styles/layout.scss +90 -90
- package/src/components/progress/template.html +24 -24
- package/src/components/uploader/component.ts +83 -83
- package/src/components/uploader/styles/layout.scss +130 -130
- package/src/components/uploader/template.html +16 -16
- package/src/index.ts +93 -93
- package/src/plugins/_builder.js +31 -31
- package/src/plugins/_plugin.ts +63 -63
- package/src/services/ApiService.ts +242 -242
- package/src/services/ConfigService.ts +134 -134
- package/src/services/DOMService.ts +100 -100
- package/src/services/NotifyService.ts +47 -47
- package/src/services/ServiceWorkerService.ts +60 -60
- package/src/services/UtilsService.ts +60 -60
- package/src/services/_service.ts +64 -64
- package/src/styles/_darkreader.scss +30 -30
- package/src/styles/_grid.scss +75 -75
- package/src/styles/_misc.scss +8 -8
- package/src/styles/_scrollbars.scss +40 -40
- package/src/styles/includes.scss +4 -4
- package/src/types/IRWSConfig.ts +30 -30
- package/src/types/IRWSPlugin.ts +18 -18
- package/src/types/IRWSUser.ts +6 -6
- package/src/types/IRWSViewComponent.ts +36 -36
- package/src/types/RWSNotify.ts +6 -6
- package/src/types/RWSWindow.ts +41 -41
- package/tsconfig.json +30 -30
- package/typedoc.json +13 -13
- package/types/declarations.d.ts +8 -8
- package/types/docs-typings.d.ts +15 -15
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
const rwsAfterCopy = require('./after/copy');
|
|
2
|
-
const rwsAfterSW = require('./after/sw');
|
|
3
|
-
const deepmerge = require('deepmerge');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const _DEFAULT_CONFIG = { actions: [], executionDir: process.cwd(), packageDir: process.cwd(), dev: false, devDebug: null }
|
|
7
|
-
|
|
8
|
-
const _DEFAULT_ACTION = {
|
|
9
|
-
type: 'copy',
|
|
10
|
-
actionHandler: {
|
|
11
|
-
'targetDir': [
|
|
12
|
-
'filePath0',
|
|
13
|
-
'filePath1'
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
event: 'done'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
class RWSWebpackPlugin {
|
|
20
|
-
config = _DEFAULT_CONFIG;
|
|
21
|
-
_allowedActionTypes = ['copy', 'custom', 'service_worker'];
|
|
22
|
-
|
|
23
|
-
constructor(config = {}) {
|
|
24
|
-
this.config = deepmerge(this.config, config);
|
|
25
|
-
this.customOptions = {
|
|
26
|
-
devDebug: this.config.devDebug
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
apply(compiler) {
|
|
31
|
-
const actionsEvents = this.config.actions.map(item => item.event ? item.event : 'done');
|
|
32
|
-
const errorActionsEvents = this.config.error_actions.map(item => item.event ? item.event : null).filter(item => !!item);
|
|
33
|
-
|
|
34
|
-
compiler.hooks.compilation.tap('RWSWebpackPlugin', (compilation) => {
|
|
35
|
-
compilation['customOptions'] = this.customOptions;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
Array.from(new Set(actionsEvents)).forEach((eventName) => {
|
|
39
|
-
compiler.hooks[eventName].tapPromise('RWSWebpackPlugin', async (buildInfo) => {
|
|
40
|
-
const proms = this.config.actions.filter(item => item.event === _DEFAULT_ACTION.event || !item.event).map(async (rwsAfterAction) => {
|
|
41
|
-
return await this._runActionType(rwsAfterAction.type, rwsAfterAction.actionHandler);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return await Promise.all(proms);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
if (!this.config.dev) {
|
|
49
|
-
compiler.hooks.emit.tapAsync('RWSWebpackPlugin', (compilation, callback) => {
|
|
50
|
-
Object.keys(compilation.assets).forEach((filename) => {
|
|
51
|
-
|
|
52
|
-
if (filename.endsWith('.js')) {
|
|
53
|
-
const asset = compilation.assets[filename];
|
|
54
|
-
let source = asset.source();
|
|
55
|
-
|
|
56
|
-
if ((source.indexOf('css`') > -1 || source.indexOf('html`') > -1)) {
|
|
57
|
-
const updatedSource = source.replace(/\n/g, '');
|
|
58
|
-
|
|
59
|
-
// Update the asset with the new content
|
|
60
|
-
compilation.assets[filename] = {
|
|
61
|
-
source: () => updatedSource,
|
|
62
|
-
size: () => updatedSource.length
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
callback();
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// compiler.hooks.done.tap('RWSWebpackPlugin', (stats) => {
|
|
73
|
-
// // Check if there were any errors
|
|
74
|
-
// if (stats.hasErrors()) {
|
|
75
|
-
// console.error('Build failed with errors:');
|
|
76
|
-
|
|
77
|
-
// // Log the errors
|
|
78
|
-
// const info = stats.toJson();
|
|
79
|
-
// console.error(info.errors);
|
|
80
|
-
|
|
81
|
-
// Array.from(new Set(actionsEvents)).forEach((eventName) => {
|
|
82
|
-
// compiler.hooks[eventName].tapPromise('RWSWebpackPlugin', async (buildInfo) => {
|
|
83
|
-
// const proms = this.config.actions.filter(item => item.event === _DEFAULT_ACTION.event || !item.event).map(async (rwsAfterAction) => {
|
|
84
|
-
// return await this._runActionType(rwsAfterAction.type, rwsAfterAction.actionHandler);
|
|
85
|
-
// });
|
|
86
|
-
|
|
87
|
-
// return await Promise.all(proms);
|
|
88
|
-
// });
|
|
89
|
-
// });
|
|
90
|
-
|
|
91
|
-
// // Optionally exit the process with a non-zero status
|
|
92
|
-
// process.exit(1);
|
|
93
|
-
// } else {
|
|
94
|
-
// console.log('Build completed successfully.');
|
|
95
|
-
// }
|
|
96
|
-
// });
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async _runActionType(actionType, action) {
|
|
100
|
-
if (!this._allowedActionTypes.includes(actionType)) {
|
|
101
|
-
throw new Error(`[RWSAfter webpack plugin] Action type ${actionType} is not allowed`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
switch (actionType) {
|
|
105
|
-
case 'copy': {
|
|
106
|
-
const copyFiles = typeof action === 'function' ? await action() : action;
|
|
107
|
-
|
|
108
|
-
await rwsAfterCopy(copyFiles, this.config);
|
|
109
|
-
return;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
//@TODO
|
|
113
|
-
case 'service_worker': {
|
|
114
|
-
|
|
115
|
-
const serviceWorkerPath = typeof action === 'function' ? await action() : action;
|
|
116
|
-
await rwsAfterSW(serviceWorkerPath);
|
|
117
|
-
return;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
case 'custom': {
|
|
121
|
-
|
|
122
|
-
if (typeof action !== 'function') {
|
|
123
|
-
console.error('Custom RWS action must be a function.')
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
await action();
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
default:
|
|
132
|
-
console.warn('RWSWebpackPlugin::_runActionType could not act upon input. Please resolve.');
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
1
|
+
const rwsAfterCopy = require('./after/copy');
|
|
2
|
+
const rwsAfterSW = require('./after/sw');
|
|
3
|
+
const deepmerge = require('deepmerge');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const _DEFAULT_CONFIG = { actions: [], executionDir: process.cwd(), packageDir: process.cwd(), dev: false, devDebug: null }
|
|
7
|
+
|
|
8
|
+
const _DEFAULT_ACTION = {
|
|
9
|
+
type: 'copy',
|
|
10
|
+
actionHandler: {
|
|
11
|
+
'targetDir': [
|
|
12
|
+
'filePath0',
|
|
13
|
+
'filePath1'
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
event: 'done'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class RWSWebpackPlugin {
|
|
20
|
+
config = _DEFAULT_CONFIG;
|
|
21
|
+
_allowedActionTypes = ['copy', 'custom', 'service_worker'];
|
|
22
|
+
|
|
23
|
+
constructor(config = {}) {
|
|
24
|
+
this.config = deepmerge(this.config, config);
|
|
25
|
+
this.customOptions = {
|
|
26
|
+
devDebug: this.config.devDebug
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
apply(compiler) {
|
|
31
|
+
const actionsEvents = this.config.actions.map(item => item.event ? item.event : 'done');
|
|
32
|
+
const errorActionsEvents = this.config.error_actions.map(item => item.event ? item.event : null).filter(item => !!item);
|
|
33
|
+
|
|
34
|
+
compiler.hooks.compilation.tap('RWSWebpackPlugin', (compilation) => {
|
|
35
|
+
compilation['customOptions'] = this.customOptions;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
Array.from(new Set(actionsEvents)).forEach((eventName) => {
|
|
39
|
+
compiler.hooks[eventName].tapPromise('RWSWebpackPlugin', async (buildInfo) => {
|
|
40
|
+
const proms = this.config.actions.filter(item => item.event === _DEFAULT_ACTION.event || !item.event).map(async (rwsAfterAction) => {
|
|
41
|
+
return await this._runActionType(rwsAfterAction.type, rwsAfterAction.actionHandler);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return await Promise.all(proms);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (!this.config.dev) {
|
|
49
|
+
compiler.hooks.emit.tapAsync('RWSWebpackPlugin', (compilation, callback) => {
|
|
50
|
+
Object.keys(compilation.assets).forEach((filename) => {
|
|
51
|
+
|
|
52
|
+
if (filename.endsWith('.js')) {
|
|
53
|
+
const asset = compilation.assets[filename];
|
|
54
|
+
let source = asset.source();
|
|
55
|
+
|
|
56
|
+
if ((source.indexOf('css`') > -1 || source.indexOf('html`') > -1)) {
|
|
57
|
+
const updatedSource = source.replace(/\n/g, '');
|
|
58
|
+
|
|
59
|
+
// Update the asset with the new content
|
|
60
|
+
compilation.assets[filename] = {
|
|
61
|
+
source: () => updatedSource,
|
|
62
|
+
size: () => updatedSource.length
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
callback();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// compiler.hooks.done.tap('RWSWebpackPlugin', (stats) => {
|
|
73
|
+
// // Check if there were any errors
|
|
74
|
+
// if (stats.hasErrors()) {
|
|
75
|
+
// console.error('Build failed with errors:');
|
|
76
|
+
|
|
77
|
+
// // Log the errors
|
|
78
|
+
// const info = stats.toJson();
|
|
79
|
+
// console.error(info.errors);
|
|
80
|
+
|
|
81
|
+
// Array.from(new Set(actionsEvents)).forEach((eventName) => {
|
|
82
|
+
// compiler.hooks[eventName].tapPromise('RWSWebpackPlugin', async (buildInfo) => {
|
|
83
|
+
// const proms = this.config.actions.filter(item => item.event === _DEFAULT_ACTION.event || !item.event).map(async (rwsAfterAction) => {
|
|
84
|
+
// return await this._runActionType(rwsAfterAction.type, rwsAfterAction.actionHandler);
|
|
85
|
+
// });
|
|
86
|
+
|
|
87
|
+
// return await Promise.all(proms);
|
|
88
|
+
// });
|
|
89
|
+
// });
|
|
90
|
+
|
|
91
|
+
// // Optionally exit the process with a non-zero status
|
|
92
|
+
// process.exit(1);
|
|
93
|
+
// } else {
|
|
94
|
+
// console.log('Build completed successfully.');
|
|
95
|
+
// }
|
|
96
|
+
// });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async _runActionType(actionType, action) {
|
|
100
|
+
if (!this._allowedActionTypes.includes(actionType)) {
|
|
101
|
+
throw new Error(`[RWSAfter webpack plugin] Action type ${actionType} is not allowed`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
switch (actionType) {
|
|
105
|
+
case 'copy': {
|
|
106
|
+
const copyFiles = typeof action === 'function' ? await action() : action;
|
|
107
|
+
|
|
108
|
+
await rwsAfterCopy(copyFiles, this.config);
|
|
109
|
+
return;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
//@TODO
|
|
113
|
+
case 'service_worker': {
|
|
114
|
+
|
|
115
|
+
const serviceWorkerPath = typeof action === 'function' ? await action() : action;
|
|
116
|
+
await rwsAfterSW(serviceWorkerPath);
|
|
117
|
+
return;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
case 'custom': {
|
|
121
|
+
|
|
122
|
+
if (typeof action !== 'function') {
|
|
123
|
+
console.error('Custom RWS action must be a function.')
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
await action();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
default:
|
|
132
|
+
console.warn('RWSWebpackPlugin::_runActionType could not act upon input. Please resolve.');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
138
|
module.exports = RWSWebpackPlugin;
|
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
const sass = require('sass');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const emojiRegex = require('emoji-regex');
|
|
5
|
-
|
|
6
|
-
const _scss_fonts_builder = require('./_fonts');
|
|
7
|
-
let _scss_fonts = null;
|
|
8
|
-
|
|
9
|
-
const _scss_import_builder = require('./_import');
|
|
10
|
-
let _scss_import = null;
|
|
11
|
-
|
|
12
|
-
function compileScssCode(scssCode, fileRootDir, createFile = false, filePath = null, minify = false) {
|
|
13
|
-
_scss_fonts = _scss_fonts_builder(this);
|
|
14
|
-
_scss_import = _scss_import_builder(this);
|
|
15
|
-
|
|
16
|
-
const [scssImports] = _scss_import.extractScssImports(scssCode, fileRootDir);
|
|
17
|
-
|
|
18
|
-
const dependencies = scssImports.map((item) => item[2]);
|
|
19
|
-
|
|
20
|
-
if (scssImports && scssImports.length) {
|
|
21
|
-
scssCode = _scss_import.replaceImports(_scss_import.processImports(scssImports, fileRootDir), scssCode);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const uses = _scss_import.extractScssUses(scssCode)[0];
|
|
25
|
-
let scssUses = '';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
uses.forEach(scssUse => {
|
|
29
|
-
const useLine = scssUse[1];
|
|
30
|
-
if(scssCode.indexOf(useLine) === -1){
|
|
31
|
-
scssUses += useLine + '\n';
|
|
32
|
-
scssCode = scssCode.replace(useLine + '\n', '');
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
scssCode = removeComments(scssUses + scssCode);
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
const result = sass.compileString(scssCode, { loadPaths: [fileRootDir]});
|
|
40
|
-
|
|
41
|
-
let compiledCode = result.css.toString();
|
|
42
|
-
compiledCode = _scss_fonts.replaceFontUrlWithBase64(compiledCode);
|
|
43
|
-
compiledCode = replaceEmojisWithQuestionMark(compiledCode, fileRootDir);
|
|
44
|
-
return { code: compiledCode, dependencies};
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.error('SASS Error in', fileRootDir);
|
|
47
|
-
|
|
48
|
-
console.error(err);
|
|
49
|
-
throw err;
|
|
50
|
-
return '';
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function checkForImporterType(_module, checkTypeExt) {
|
|
55
|
-
let importingFileExtension = '';
|
|
56
|
-
|
|
57
|
-
if (_module && _module.issuer && _module.issuer.resource) {
|
|
58
|
-
importingFileExtension = path.extname(_module.issuer.resource);
|
|
59
|
-
if (importingFileExtension === ('.' + checkTypeExt)) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return false
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function replaceEmojisWithQuestionMark(code, componentDir) {
|
|
70
|
-
const regex = emojiRegex();
|
|
71
|
-
let hasEmoji = false;
|
|
72
|
-
|
|
73
|
-
const result = code.replace(regex, (match) => {
|
|
74
|
-
hasEmoji = true;
|
|
75
|
-
return '?';
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
if (hasEmoji) {
|
|
79
|
-
console.log(chalk.yellow(`Emojis in css detected and replaced with "?" in "${path.dirname(componentDir)}" component`));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function removeComments(code) {
|
|
86
|
-
code = code.replace(/\/\/.*$/gm, '');
|
|
87
|
-
code = code.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
88
|
-
code = code.replace(/^\s*$(?:\r\n?|\n)/gm, '');
|
|
89
|
-
|
|
90
|
-
return code;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
module.exports = function(element) {
|
|
94
|
-
return {
|
|
95
|
-
checkForImporterType: checkForImporterType.bind(element),
|
|
96
|
-
compileScssCode: compileScssCode.bind(element)
|
|
97
|
-
};
|
|
1
|
+
const sass = require('sass');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const emojiRegex = require('emoji-regex');
|
|
5
|
+
|
|
6
|
+
const _scss_fonts_builder = require('./_fonts');
|
|
7
|
+
let _scss_fonts = null;
|
|
8
|
+
|
|
9
|
+
const _scss_import_builder = require('./_import');
|
|
10
|
+
let _scss_import = null;
|
|
11
|
+
|
|
12
|
+
function compileScssCode(scssCode, fileRootDir, createFile = false, filePath = null, minify = false) {
|
|
13
|
+
_scss_fonts = _scss_fonts_builder(this);
|
|
14
|
+
_scss_import = _scss_import_builder(this);
|
|
15
|
+
|
|
16
|
+
const [scssImports] = _scss_import.extractScssImports(scssCode, fileRootDir);
|
|
17
|
+
|
|
18
|
+
const dependencies = scssImports.map((item) => item[2]);
|
|
19
|
+
|
|
20
|
+
if (scssImports && scssImports.length) {
|
|
21
|
+
scssCode = _scss_import.replaceImports(_scss_import.processImports(scssImports, fileRootDir), scssCode);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const uses = _scss_import.extractScssUses(scssCode)[0];
|
|
25
|
+
let scssUses = '';
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
uses.forEach(scssUse => {
|
|
29
|
+
const useLine = scssUse[1];
|
|
30
|
+
if(scssCode.indexOf(useLine) === -1){
|
|
31
|
+
scssUses += useLine + '\n';
|
|
32
|
+
scssCode = scssCode.replace(useLine + '\n', '');
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
scssCode = removeComments(scssUses + scssCode);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const result = sass.compileString(scssCode, { loadPaths: [fileRootDir]});
|
|
40
|
+
|
|
41
|
+
let compiledCode = result.css.toString();
|
|
42
|
+
compiledCode = _scss_fonts.replaceFontUrlWithBase64(compiledCode);
|
|
43
|
+
compiledCode = replaceEmojisWithQuestionMark(compiledCode, fileRootDir);
|
|
44
|
+
return { code: compiledCode, dependencies};
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.error('SASS Error in', fileRootDir);
|
|
47
|
+
|
|
48
|
+
console.error(err);
|
|
49
|
+
throw err;
|
|
50
|
+
return '';
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function checkForImporterType(_module, checkTypeExt) {
|
|
55
|
+
let importingFileExtension = '';
|
|
56
|
+
|
|
57
|
+
if (_module && _module.issuer && _module.issuer.resource) {
|
|
58
|
+
importingFileExtension = path.extname(_module.issuer.resource);
|
|
59
|
+
if (importingFileExtension === ('.' + checkTypeExt)) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function replaceEmojisWithQuestionMark(code, componentDir) {
|
|
70
|
+
const regex = emojiRegex();
|
|
71
|
+
let hasEmoji = false;
|
|
72
|
+
|
|
73
|
+
const result = code.replace(regex, (match) => {
|
|
74
|
+
hasEmoji = true;
|
|
75
|
+
return '?';
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (hasEmoji) {
|
|
79
|
+
console.log(chalk.yellow(`Emojis in css detected and replaced with "?" in "${path.dirname(componentDir)}" component`));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function removeComments(code) {
|
|
86
|
+
code = code.replace(/\/\/.*$/gm, '');
|
|
87
|
+
code = code.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
88
|
+
code = code.replace(/^\s*$(?:\r\n?|\n)/gm, '');
|
|
89
|
+
|
|
90
|
+
return code;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = function(element) {
|
|
94
|
+
return {
|
|
95
|
+
checkForImporterType: checkForImporterType.bind(element),
|
|
96
|
+
compileScssCode: compileScssCode.bind(element)
|
|
97
|
+
};
|
|
98
98
|
};
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const FONT_REGEX = /url\(['"]?(.+?\.(woff|woff2|eot|ttf|otf))['"]?\)/gm;
|
|
4
|
-
|
|
5
|
-
const _scss_import_builder = require('./_import');
|
|
6
|
-
let _scss_import = null;
|
|
7
|
-
|
|
8
|
-
function hasFontEmbeds(css) {
|
|
9
|
-
return FONT_REGEX.test(css);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function embedFontsInCss(css, cssFilePath) {
|
|
13
|
-
let match;
|
|
14
|
-
|
|
15
|
-
while ((match = FONT_REGEX.exec(css)) !== null) {
|
|
16
|
-
const fontPath = match[1];
|
|
17
|
-
const absoluteFontPath = path.resolve(path.dirname(cssFilePath), fontPath);
|
|
18
|
-
|
|
19
|
-
if (fs.existsSync(absoluteFontPath)) {
|
|
20
|
-
const fontData = fs.readFileSync(absoluteFontPath);
|
|
21
|
-
const base64Font = fontData.toString('base64');
|
|
22
|
-
const fontMimeType = getFontMimeType(path.extname(absoluteFontPath));
|
|
23
|
-
const fontDataURL = `data:${fontMimeType};base64,${base64Font}`;
|
|
24
|
-
|
|
25
|
-
css = css.replace(new RegExp(match[0], 'g'), `url(${fontDataURL})`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return css;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getFontMimeType(extension) {
|
|
33
|
-
switch (extension) {
|
|
34
|
-
case '.woff': return 'font/woff';
|
|
35
|
-
case '.woff2': return 'font/woff2';
|
|
36
|
-
case '.eot': return 'application/vnd.ms-fontobject';
|
|
37
|
-
case '.ttf': return 'font/ttf';
|
|
38
|
-
case '.otf': return 'font/otf';
|
|
39
|
-
default: return 'application/octet-stream';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function convertFontToBase64(fontPath) {
|
|
44
|
-
return fs.readFileSync(fontPath, { encoding: 'base64' });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function replaceFontUrlWithBase64(cssContent) {
|
|
48
|
-
const fontFaceRegex = /@font-face\s*\{[^}]*\}/g;
|
|
49
|
-
let fontFaces = [...cssContent.matchAll(fontFaceRegex)];
|
|
50
|
-
_scss_import = _scss_import_builder(this);
|
|
51
|
-
|
|
52
|
-
for (const fontFace of fontFaces) {
|
|
53
|
-
const fontFaceContent = fontFace[0];
|
|
54
|
-
const urlRegex = /url\((['"]?)([^)'"]+)(\1)\)/g;
|
|
55
|
-
let match;
|
|
56
|
-
|
|
57
|
-
let modifiedFontFaceContent = fontFaceContent;
|
|
58
|
-
|
|
59
|
-
while ((match = urlRegex.exec(fontFaceContent)) !== null) {
|
|
60
|
-
// Create a promise to convert each font to Base64 and replace in CSS
|
|
61
|
-
const base64 = convertFontToBase64(_scss_import.processImportPath(match[2], null, true));
|
|
62
|
-
const base64Font = `data:font/woff2;base64,${base64}`;
|
|
63
|
-
|
|
64
|
-
modifiedFontFaceContent = modifiedFontFaceContent.replace(match[2], base64Font);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
cssContent = cssContent.replace(fontFaceContent, modifiedFontFaceContent)
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
return cssContent;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
module.exports = function(element) {
|
|
74
|
-
return {
|
|
75
|
-
hasFontEmbeds: hasFontEmbeds.bind(element),
|
|
76
|
-
embedFontsInCss: embedFontsInCss.bind(element),
|
|
77
|
-
getFontMimeType: getFontMimeType.bind(element),
|
|
78
|
-
convertFontToBase64: convertFontToBase64.bind(element),
|
|
79
|
-
replaceFontUrlWithBase64: replaceFontUrlWithBase64.bind(element)
|
|
80
|
-
};
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const FONT_REGEX = /url\(['"]?(.+?\.(woff|woff2|eot|ttf|otf))['"]?\)/gm;
|
|
4
|
+
|
|
5
|
+
const _scss_import_builder = require('./_import');
|
|
6
|
+
let _scss_import = null;
|
|
7
|
+
|
|
8
|
+
function hasFontEmbeds(css) {
|
|
9
|
+
return FONT_REGEX.test(css);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function embedFontsInCss(css, cssFilePath) {
|
|
13
|
+
let match;
|
|
14
|
+
|
|
15
|
+
while ((match = FONT_REGEX.exec(css)) !== null) {
|
|
16
|
+
const fontPath = match[1];
|
|
17
|
+
const absoluteFontPath = path.resolve(path.dirname(cssFilePath), fontPath);
|
|
18
|
+
|
|
19
|
+
if (fs.existsSync(absoluteFontPath)) {
|
|
20
|
+
const fontData = fs.readFileSync(absoluteFontPath);
|
|
21
|
+
const base64Font = fontData.toString('base64');
|
|
22
|
+
const fontMimeType = getFontMimeType(path.extname(absoluteFontPath));
|
|
23
|
+
const fontDataURL = `data:${fontMimeType};base64,${base64Font}`;
|
|
24
|
+
|
|
25
|
+
css = css.replace(new RegExp(match[0], 'g'), `url(${fontDataURL})`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return css;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getFontMimeType(extension) {
|
|
33
|
+
switch (extension) {
|
|
34
|
+
case '.woff': return 'font/woff';
|
|
35
|
+
case '.woff2': return 'font/woff2';
|
|
36
|
+
case '.eot': return 'application/vnd.ms-fontobject';
|
|
37
|
+
case '.ttf': return 'font/ttf';
|
|
38
|
+
case '.otf': return 'font/otf';
|
|
39
|
+
default: return 'application/octet-stream';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function convertFontToBase64(fontPath) {
|
|
44
|
+
return fs.readFileSync(fontPath, { encoding: 'base64' });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function replaceFontUrlWithBase64(cssContent) {
|
|
48
|
+
const fontFaceRegex = /@font-face\s*\{[^}]*\}/g;
|
|
49
|
+
let fontFaces = [...cssContent.matchAll(fontFaceRegex)];
|
|
50
|
+
_scss_import = _scss_import_builder(this);
|
|
51
|
+
|
|
52
|
+
for (const fontFace of fontFaces) {
|
|
53
|
+
const fontFaceContent = fontFace[0];
|
|
54
|
+
const urlRegex = /url\((['"]?)([^)'"]+)(\1)\)/g;
|
|
55
|
+
let match;
|
|
56
|
+
|
|
57
|
+
let modifiedFontFaceContent = fontFaceContent;
|
|
58
|
+
|
|
59
|
+
while ((match = urlRegex.exec(fontFaceContent)) !== null) {
|
|
60
|
+
// Create a promise to convert each font to Base64 and replace in CSS
|
|
61
|
+
const base64 = convertFontToBase64(_scss_import.processImportPath(match[2], null, true));
|
|
62
|
+
const base64Font = `data:font/woff2;base64,${base64}`;
|
|
63
|
+
|
|
64
|
+
modifiedFontFaceContent = modifiedFontFaceContent.replace(match[2], base64Font);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
cssContent = cssContent.replace(fontFaceContent, modifiedFontFaceContent)
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return cssContent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = function(element) {
|
|
74
|
+
return {
|
|
75
|
+
hasFontEmbeds: hasFontEmbeds.bind(element),
|
|
76
|
+
embedFontsInCss: embedFontsInCss.bind(element),
|
|
77
|
+
getFontMimeType: getFontMimeType.bind(element),
|
|
78
|
+
convertFontToBase64: convertFontToBase64.bind(element),
|
|
79
|
+
replaceFontUrlWithBase64: replaceFontUrlWithBase64.bind(element)
|
|
80
|
+
};
|
|
81
81
|
};
|