@fontoxml/fontoxml-development-tools 3.8.1 → 3.9.0-beta.1

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.
Files changed (117) hide show
  1. package/bitbucket-pipelines.yml +7 -0
  2. package/npm-shrinkwrap.json +14989 -23378
  3. package/package.json +13 -15
  4. package/src/modules/editor/src/commands/command.run.controller.js +12 -7
  5. package/src/modules/editor/src/getWebpackConfig.js +33 -178
  6. package/src/modules/editor/src/getWebpackDevMiddlewareConfig.js +9 -16
  7. package/src/modules/editor/src/templates/app-entry.ts +66 -0
  8. package/src/modules/editor/src/webpackLoaders/generatedLoader.cjs +79 -61
  9. package/src/modules/editor/src/webpackLoaders/platformSourceMapLoader.cjs +4 -7
  10. package/src/modules/editor/src/webpackLoaders/symbolLoader.cjs +7 -7
  11. package/src/modules/editor/src/webpackLoaders/vendorsSourceMapLoader.cjs +3 -5
  12. package/src/modules/editor/src/webpackPlugins/CopyPlugin.js +224 -172
  13. package/src/modules/editor/src/webpackPlugins/DependenciesInLoadOrderPlugin.js +11 -2
  14. package/src/modules/editor/src/webpackPlugins/FdtOutputPlugin.js +95 -102
  15. package/src/modules/editor/src/webpackPlugins/RemoveExplicitExtensionResolvePlugin.js +18 -19
  16. package/src/modules/editor/src/webpackPlugins/ResolveImportAliasPlugin.js +18 -10
  17. package/src/modules/editor/src/webpackPlugins/UnitTestPlugin.js +23 -13
  18. package/src/modules/editor/test/fixtures.test.js +0 -3
  19. package/src/modules/editor-pre-7-7-0/test/api/schema/zipSchemaSource.test.js +20 -1
  20. package/src/modules/editor/src/templates/app-entry.cjs +0 -69
  21. package/src/modules/editor/test/apps/minimal/config/configuration.js +0 -5
  22. package/src/modules/editor/test/apps/minimal/config/fonto-manifest.json +0 -6
  23. package/src/modules/editor/test/apps/minimal/config/schemaExperienceResolver.js +0 -15
  24. package/src/modules/editor/test/apps/minimal/packages/app-test/src/SCHEMA_LOCATIONS.js +0 -1
  25. package/src/modules/editor/test/apps/minimal/packages/app-test/src/install.js +0 -3
  26. package/src/modules/editor/test/apps/minimal/platform/fontoxml-configuration/fonto-manifest.json +0 -4
  27. package/src/modules/editor/test/apps/minimal/platform/fontoxml-configuration/src/configurationManager.js +0 -11
  28. package/src/modules/editor/test/apps/minimal/platform/fontoxml-editor/fonto-manifest.json +0 -4
  29. package/src/modules/editor/test/apps/minimal/platform/fontoxml-editor/src/editor/Router.jsx +0 -1
  30. package/src/modules/editor/test/apps/minimal/platform/fontoxml-editor/src/renderApp.js +0 -5
  31. package/src/modules/editor/test/apps/minimal/platform/fontoxml-localization/fonto-manifest.json +0 -4
  32. package/src/modules/editor/test/apps/minimal/platform/fontoxml-localization/src/localizationManager.js +0 -3
  33. package/src/modules/editor/test/apps/minimal/platform/fontoxml-modular-schema-experience/fonto-manifest.json +0 -4
  34. package/src/modules/editor/test/apps/minimal/platform/fontoxml-modular-schema-experience/src/sxManager.js +0 -13
  35. package/src/modules/editor/test/apps/minimal/platform/fontoxml-operations/fonto-manifest.json +0 -4
  36. package/src/modules/editor/test/apps/minimal/platform/fontoxml-operations/src/operationsManager.js +0 -3
  37. package/src/modules/editor/test/apps/minimal/platform/fontoxml-platform-base/fonto-manifest.json +0 -7
  38. package/src/modules/editor/test/apps/minimal/platform/fontoxml-platform-base/src/configureSxModule.js +0 -3
  39. package/src/modules/editor/test/apps/minimal/platform/fontoxml-platform-package/fonto-manifest.json +0 -4
  40. package/src/modules/editor/test/apps/minimal/platform/fontoxml-platform-package/src/install.js +0 -3
  41. package/src/modules/editor/test/apps/minimal/platform/fontoxml-selectors/fonto-manifest.json +0 -4
  42. package/src/modules/editor/test/apps/minimal/platform/fontoxml-selectors/src/registerXQueryModule.js +0 -1
  43. package/src/modules/editor/test/apps/minimal/platform/fontoxml-shims/fonto-manifest.json +0 -4
  44. package/src/modules/editor/test/apps/minimal/platform/fontoxml-shims/src/main.js +0 -1
  45. package/src/modules/editor/test/apps/minimal/platform/fontoxml-utils/fonto-manifest.json +0 -4
  46. package/src/modules/editor/test/apps/minimal/platform/fontoxml-utils/src/getQueryParameterByName.js +0 -1
  47. package/src/modules/editor/test/apps/minimal/platform/fontoxml-vendors/fonto-manifest.json +0 -4
  48. package/src/modules/editor/test/apps/minimal/platform/fontoxml-vendors/src/glamor.js +0 -12
  49. package/src/modules/editor/test/apps/minimal/platform/fontoxml-vendors/src/react-dom.js +0 -6
  50. package/src/modules/editor/test/apps/minimal/platform/fontoxml-vendors/src/react-dom.min.js +0 -6
  51. package/src/modules/editor/test/apps/minimal/platform/fontoxml-vendors/src/react.js +0 -1
  52. package/src/modules/editor/test/apps/minimal/platform/fontoxml-vendors/src/react.min.js +0 -1
  53. package/src/modules/editor/test/dependecyWatching.test.js +0 -741
  54. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddAllSpecialFilesToPackage/generatedConfigureSxModule.out.js +0 -26
  55. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddAllSpecialFilesToPackage/generatedInstall.out.js +0 -13
  56. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddAllSpecialFilesToPackage/generatedMessages.out.js +0 -7
  57. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddAllSpecialFilesToPackage/generatedSetDefaultConfiguration.out.js +0 -3
  58. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddAllSpecialFilesToPackage/generatedStyles.out.js +0 -1
  59. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddConfiguresxmoduleToPackage/generatedConfigureSxModule.out.js +0 -26
  60. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddInstallToPackage/generatedInstall.out.js +0 -9
  61. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddMessagesEoToPackage/generatedMessages.out.js +0 -5
  62. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddMessagesToPackage/generatedMessages.out.js +0 -5
  63. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddOperationsToPackage/generatedInstall.out.js +0 -9
  64. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddOperationsWildcardToPackage/generatedInstall.out.js +0 -9
  65. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddSetdefaultconfigurationToPackage/generatedSetDefaultConfiguration.out.js +0 -3
  66. package/src/modules/editor/test/fixtures/dependencyWatching/addSpecialFileToExistingPackage/canAddStylesToPackage/generatedStyles.out.js +0 -1
  67. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewEmptyAppPackage/generatedConfigureSxModule.out.js +0 -20
  68. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewEmptyAppPackage/generatedInstall.out.js +0 -7
  69. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewEmptyAppPackage/generatedMessages.out.js +0 -1
  70. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewEmptyAppPackage/generatedSetdefaultconfiguration.out.js +0 -0
  71. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewEmptyAppPackage/generatedStyles.out.js +0 -0
  72. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewPackageAsConfigDependency/generatedInstall.out.js +0 -9
  73. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewPackageAsConfigDependency/generatedInstallBefore.out.js +0 -7
  74. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewPackageAsOtherPackageDependency/generatedInstall.out.js +0 -9
  75. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewPackageAsOtherPackageDependency/generatedInstallBefore.out.js +0 -7
  76. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewPackageWithSpecialFiles/generatedConfigureSxModule.out.js +0 -26
  77. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewPackageWithSpecialFiles/generatedInstall.out.js +0 -13
  78. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewPackageWithSpecialFiles/generatedMessages.out.js +0 -7
  79. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewPackageWithSpecialFiles/generatedSetDefaultConfiguration.out.js +0 -3
  80. package/src/modules/editor/test/fixtures/dependencyWatching/newPackage/canAddANewPackageWithSpecialFiles/generatedStyles.out.js +0 -1
  81. package/src/modules/editor/test/fixtures/dependencyWatching/overridePackage/canAddANewOverridePackage/overrideRenderApp.out.js +0 -3
  82. package/src/modules/editor/test/fixtures/dependencyWatching/overridePackage/canRemoveAnOverridePackage/overrideRenderApp.out.js +0 -3
  83. package/src/modules/editor/test/fixtures/dependencyWatching/overridePackage/canRemoveAnOverridePackage/renderApp.out.js +0 -3
  84. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/beforeEachHook/generatedConfigureSxModule.out.js +0 -26
  85. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/beforeEachHook/generatedInstall.out.js +0 -13
  86. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/beforeEachHook/generatedMessages.out.js +0 -7
  87. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/beforeEachHook/generatedSetDefaultConfiguration.out.js +0 -3
  88. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/beforeEachHook/generatedStyles.out.js +0 -1
  89. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveAllSpecialFilesFromPackage/generatedConfigureSxModule.out.js +0 -23
  90. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveAllSpecialFilesFromPackage/generatedInstall.out.js +0 -7
  91. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveAllSpecialFilesFromPackage/generatedMessages.out.js +0 -1
  92. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveAllSpecialFilesFromPackage/generatedSetDefaultConfiguration.out.js +0 -0
  93. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveAllSpecialFilesFromPackage/generatedStyles.out.js +0 -0
  94. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveConfiguresxmoduleFromPackage/generatedConfigureSxModule.out.js +0 -23
  95. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveInstallFromPackage/generatedInstall.out.js +0 -11
  96. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveMessagesEoFromPackage/generatedMessages.out.js +0 -5
  97. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveMessagesFromPackage/generatedMessages.out.js +0 -5
  98. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveOperationsFromPackage/generatedInstall.out.js +0 -11
  99. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveOperationsWildcardFromPackage/generatedInstall.out.js +0 -11
  100. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveSetDefaultConfigurationFromPackage/generatedSetDefaultConfiguration.out.js +0 -0
  101. package/src/modules/editor/test/fixtures/dependencyWatching/removeSpecialFileFromExistingPackage/canRemoveStylesFromPackage/generatedStyles.out.js +0 -0
  102. package/src/modules/editor/test/fixtures/dependencyWatching/removedPackage/beforeEachHook/generatedInstall.out.js +0 -9
  103. package/src/modules/editor/test/fixtures/dependencyWatching/removedPackage/canRemoveAPackage/generatedInstall.out.js +0 -7
  104. package/src/modules/editor/test/fixtures/dependencyWatching/removedPackage/canRemovePackageFromConfigManifest/generatedInstall.out.js +0 -7
  105. package/src/modules/editor/test/fixtures/dependencyWatching/removedPackage/canRemovePackageFromOtherPackageManifest/generatedInstall.out.js +0 -9
  106. package/src/modules/editor/test/fixtures/dependencyWatching/removedPackage/canRemovePackageFromOtherPackageManifest/generatedInstallBefore.out.js +0 -11
  107. package/src/modules/editor/test/helpers/appMutations/addFilesToPackage.js +0 -105
  108. package/src/modules/editor/test/helpers/appMutations/addFontoManifestToPackage.js +0 -46
  109. package/src/modules/editor/test/helpers/appMutations/addPackage.js +0 -53
  110. package/src/modules/editor/test/helpers/appMutations/generateSpecialFiles.js +0 -59
  111. package/src/modules/editor/test/helpers/appMutations/mutateConfigFontoManifest.js +0 -49
  112. package/src/modules/editor/test/helpers/appMutations/mutatePackageFontoManifest.js +0 -67
  113. package/src/modules/editor/test/helpers/appMutations/removeFilesFromPackage.js +0 -33
  114. package/src/modules/editor/test/helpers/appMutations/removePackage.js +0 -33
  115. package/src/modules/editor/test/helpers/createAppStructure.js +0 -17
  116. package/src/modules/editor/test/helpers/createTempDirectory.js +0 -20
  117. package/src/modules/editor/test/helpers/createWebpackWatch.js +0 -444
@@ -1,23 +1,6 @@
1
1
  import os from 'os';
2
- import DirectoryWatcher from 'watchpack/lib/DirectoryWatcher.js';
3
2
  import webpack from 'webpack';
4
3
 
5
- // Monkey patch watchpack to output any chokidar errors.
6
- let response;
7
- let watchErrorDebounceTimeout;
8
-
9
- const originalOnWatcherError = DirectoryWatcher.prototype.onWatcherError;
10
- DirectoryWatcher.prototype.onWatcherError = function (_error) {
11
- clearTimeout(watchErrorDebounceTimeout);
12
- watchErrorDebounceTimeout = setTimeout(() => {
13
- (response || console).error(
14
- '\nSomething went wrong while watching for file changes. Try closing applications, such as other development servers or IDEs, and restarting the development server to resolve this issue.'
15
- );
16
- }, 500);
17
-
18
- return originalOnWatcherError.apply(this, arguments);
19
- };
20
-
21
4
  const BUILD_MESSAGE_DEBOUNCE_IN_MS = 100;
22
5
 
23
6
  function getEndTimestamp(stats) {
@@ -26,146 +9,156 @@ function getEndTimestamp(stats) {
26
9
  ).toLocaleTimeString();
27
10
  }
28
11
 
12
+ /**
13
+ * This plugin wraps webpack's output to ensure only the import stuff gets
14
+ * outputted to the command line.
15
+ */
29
16
  export default class FdtOutputPlugin {
30
17
  constructor(options) {
31
18
  this.res = options.res;
32
- this.inDevelopmentMode = options.inDevelopmentMode;
19
+ this.inDevelopmentMode = !!options.inDevelopmentMode;
33
20
 
34
21
  this.hasClearLine =
35
22
  typeof this.res.config.stdout.clearLine === 'function';
36
23
 
37
24
  this.resetState();
38
-
39
- response = this.res;
40
25
  }
41
26
 
42
27
  resetState() {
43
28
  this.previousBuildMessageTimestamp = 0;
44
- this.previousBuildProgressIsMinify = false;
45
29
  this.previousProgressIsBuild = false;
46
30
  this.previousRoundedPercentage = null;
47
31
  }
48
32
 
49
- handler(percentage, message, ...args) {
50
- if (message === 'doneWithStats') {
51
- this.previousProgressIsBuild = false;
52
- const stats = args[0];
53
- const endTimestamp = getEndTimestamp(stats);
54
- const statusPrefix = stats
55
- ? `Build done at ${endTimestamp} in ${
56
- stats.endTime - stats.startTime
57
- }ms`
58
- : `Build done at ${endTimestamp}`;
59
-
60
- if (stats && (stats.hasErrors() || stats.hasWarnings())) {
61
- this.res.needsClearing = true;
62
- this.res[stats.hasErrors() ? 'error' : 'notice'](
63
- stats.hasErrors() && stats.hasWarnings()
64
- ? `${statusPrefix}, with errors and warnings:`
65
- : stats.hasErrors()
66
- ? `${statusPrefix}, with errors:`
67
- : `${statusPrefix}, with warnings:`,
68
- false
69
- );
33
+ /**
34
+ * @param {number} percentage
35
+ * @param {string} message
36
+ * @param {...string} args
37
+ */
38
+ progressHandler(percentage, _message, ..._args) {
39
+ if (percentage >= 0.99) {
40
+ return;
41
+ }
70
42
 
71
- const errorsAndWarnings = stats.toString({
72
- all: false,
73
- colors: true,
74
- errors: true,
75
- moduleTrace: true,
76
- warnings: true,
77
- });
78
-
79
- this.res.raw(errorsAndWarnings);
80
- this.res.raw(os.EOL + os.EOL);
81
-
82
- this.res.needsClearing = false;
83
- if (this.inDevelopmentMode) {
84
- this.res.log(
85
- 'Waiting for new changes...',
86
- this.hasClearLine
87
- );
88
- }
89
- } else {
90
- this.res.needsClearing = true;
91
- if (this.inDevelopmentMode) {
92
- this.res.success(
93
- `${statusPrefix}, waiting for new changes...`,
94
- this.hasClearLine
95
- );
96
- } else {
97
- this.res.success(
98
- `${statusPrefix}.
99
- `,
100
- false
101
- );
102
- }
103
- }
104
- } else if (message === 'failedWithError') {
105
- this.previousProgressIsBuild = false;
106
- this.res.needsClearing = true;
107
- const error = args[0];
108
- const endTimestamp = getEndTimestamp();
109
- this.res.error(
110
- `Failed at ${endTimestamp} with error: ${
111
- error && error.message ? error.message : error
112
- }`,
113
- this.hasClearLine
114
- );
115
- } else if (this.hasClearLine || !this.previousProgressIsBuild) {
43
+ if (this.hasClearLine || !this.previousProgressIsBuild) {
116
44
  const roundedPercentage = Math.floor(percentage * 100);
117
45
  const buildMessageTimestamp = Date.now();
118
- const buildProgressIsMinify =
119
- message === 'chunk asset optimization';
120
46
 
121
47
  // Relax outputting of progress based on previous state.
122
48
  if (
123
49
  !this.previousProgressIsBuild ||
124
- this.previousBuildProgressIsMinify !== buildProgressIsMinify ||
125
50
  (roundedPercentage > this.previousRoundedPercentage &&
126
51
  buildMessageTimestamp >
127
52
  this.previousBuildMessageTimestamp +
128
53
  BUILD_MESSAGE_DEBOUNCE_IN_MS)
129
54
  ) {
130
55
  this.previousBuildMessageTimestamp = buildMessageTimestamp;
131
- this.previousBuildProgressIsMinify = buildProgressIsMinify;
132
56
  this.previousProgressIsBuild = true;
133
57
  this.previousRoundedPercentage = roundedPercentage;
134
58
 
135
59
  this.res.needsClearing = true;
136
60
 
137
- const statusPrefix = buildProgressIsMinify
138
- ? 'Minifying'
139
- : 'Building';
140
61
  this.res.log(
141
62
  this.hasClearLine
142
- ? `${statusPrefix}... ${roundedPercentage}%`
143
- : `${statusPrefix}...`,
63
+ ? `Building... ${roundedPercentage}%`
64
+ : `Building...`,
144
65
  true
145
66
  );
146
67
  }
147
68
  }
148
69
  }
149
70
 
71
+ /**
72
+ * @param {webpack.Stats} stats
73
+ */
74
+ doneHandler(stats) {
75
+ this.previousProgressIsBuild = false;
76
+ const endTimestamp = getEndTimestamp(stats);
77
+ const statusPrefix = stats
78
+ ? `Build done at ${endTimestamp} in ${
79
+ stats.endTime - stats.startTime
80
+ }ms`
81
+ : `Build done at ${endTimestamp}`;
82
+
83
+ if (stats && (stats.hasErrors() || stats.hasWarnings())) {
84
+ this.res.needsClearing = true;
85
+ this.res.clearIfNeeded();
86
+
87
+ const errorsAndWarnings = stats.toString({
88
+ all: false,
89
+ colors: true,
90
+ errors: true,
91
+ moduleTrace: true,
92
+ warnings: true,
93
+ });
94
+ this.res.raw(errorsAndWarnings);
95
+ this.res.raw(os.EOL + os.EOL);
96
+
97
+ this.res[stats.hasErrors() ? 'error' : 'notice'](
98
+ stats.hasErrors() && stats.hasWarnings()
99
+ ? `${statusPrefix}, with errors and warnings.`
100
+ : stats.hasErrors()
101
+ ? `${statusPrefix}, with errors.`
102
+ : `${statusPrefix}, with warnings.`,
103
+ false
104
+ );
105
+ this.res.break();
106
+
107
+ this.res.needsClearing = false;
108
+ if (this.inDevelopmentMode) {
109
+ this.res.log('Waiting for new changes...', this.hasClearLine);
110
+ }
111
+ } else {
112
+ this.res.needsClearing = true;
113
+ if (this.inDevelopmentMode) {
114
+ this.res.success(
115
+ `${statusPrefix}, waiting for new changes...`,
116
+ this.hasClearLine
117
+ );
118
+ } else {
119
+ this.res.success(
120
+ `${statusPrefix}.
121
+ `,
122
+ false
123
+ );
124
+ }
125
+ }
126
+ }
127
+
128
+ failedHandler(error) {
129
+ this.previousProgressIsBuild = false;
130
+ this.res.needsClearing = true;
131
+ const endTimestamp = getEndTimestamp();
132
+ this.res.error(
133
+ `Failed at ${endTimestamp} with error: ${
134
+ error && error.message ? error.message : error
135
+ }`,
136
+ this.hasClearLine
137
+ );
138
+ }
139
+
140
+ /**
141
+ * @param {webpack.Compiler} compiler
142
+ */
150
143
  apply(compiler) {
151
144
  // Listen to compile hook before the webpack ProgressPlugin, to reset state.
152
- compiler.hooks.compile.tap('FdtOutputPlugin', (_compilationParams) => {
145
+ compiler.hooks.compile.tap(FdtOutputPlugin.name, () => {
153
146
  this.resetState();
154
147
  });
155
148
 
156
149
  // Use ProgressPlugin to handle most hooks.
157
150
  new webpack.ProgressPlugin({
158
- handler: this.handler.bind(this),
151
+ handler: this.progressHandler.bind(this),
159
152
  }).apply(compiler);
160
153
 
161
154
  // Listen to done hook and call handler WITH stats, which ProgressPlugin does not do.
162
- compiler.hooks.done.tap('FdtOutputPlugin', (stats) => {
163
- this.handler(1, 'doneWithStats', stats);
155
+ compiler.hooks.done.tap(FdtOutputPlugin.name, (stats) => {
156
+ this.doneHandler(stats);
164
157
  });
165
158
 
166
159
  // Listen to failed hook and call handler, which ProgressPlugin does not do.
167
- compiler.hooks.failed.tap('FdtOutputPlugin', (error) => {
168
- this.handler(1, 'failedWithError', error);
160
+ compiler.hooks.failed.tap(FdtOutputPlugin.name, (error) => {
161
+ this.failedHandler(error);
169
162
  });
170
163
  }
171
164
  }
@@ -1,35 +1,35 @@
1
+ /** @typedef {import('enhanced-resolve').Resolver} Resolver */
2
+
1
3
  import getPaths from 'enhanced-resolve/lib/getPaths.js';
2
4
  import path from 'path';
3
5
 
4
- /** @typedef {import('enhanced-resolve').Resolver} Resolver */
5
-
6
+ /**
7
+ * This plugin ensures that import paths with an extension are always resolved
8
+ * as if they were extensionless.
9
+ */
6
10
  export default class RemoveExplicitExtensionResolvePlugin {
7
11
  constructor(options = {}) {
8
12
  this.options = options;
9
-
10
- // Performing this plugin as early as possible. An alternative is to do it in the raw-file
11
- // step (which is the same stap as the AppendPlugin runs, used for resolve.extensions).
12
- this.source = 'resolve';
13
- this.target = 'resolve';
14
13
  }
15
14
 
16
15
  /**
17
16
  * @param {Resolver} resolver
18
17
  */
19
18
  apply(resolver) {
20
- const target = resolver.ensureHook(this.target);
19
+ const target = resolver.ensureHook('resolve');
21
20
  resolver
22
- .getHook(this.source)
21
+ .getHook('resolve')
23
22
  .tapAsync(
24
- 'RemoveExplicitExtensionResolvePlugin',
23
+ RemoveExplicitExtensionResolvePlugin.name,
25
24
  (request, resolveContext, callback) => {
26
25
  const basename = getPaths.basename(request.request);
27
26
  if (!basename) {
28
27
  return callback();
29
28
  }
30
29
 
31
- // If there is no extension, or the extension is not in the list of extensions, do
32
- // not try to resolve with different extensions.
30
+ // If there is no extension, or the extension is not in the
31
+ // list of extensions, do not try to resolve with different
32
+ // extensions.
33
33
  const extension = path.extname(basename);
34
34
  const extensions = this.options.extensions || [];
35
35
  if (!extension || !extensions.includes(extension)) {
@@ -43,18 +43,17 @@ export default class RemoveExplicitExtensionResolvePlugin {
43
43
  );
44
44
  const dirPath = path.dirname(request.request);
45
45
  if (!request.request.startsWith(dirPath)) {
46
- throw new Error(
47
- `Failed to remove explicit extension for "${request.request}" to "${fileNameWithoutExtension}".`
46
+ return callback(
47
+ new Error(
48
+ `Failed to remove explicit extension for "${request.request}" to "${fileNameWithoutExtension}".`
49
+ )
48
50
  );
49
51
  }
50
52
  const obj = {
51
53
  ...request,
52
- request: resolver.join(
53
- dirPath,
54
- fileNameWithoutExtension
55
- ),
54
+ request: `${dirPath}/${fileNameWithoutExtension}`,
56
55
  };
57
- resolver.doResolve(
56
+ return resolver.doResolve(
58
57
  target,
59
58
  obj,
60
59
  `removing extension ${extension}`,
@@ -1,28 +1,37 @@
1
+ /** @typedef {import('webpack').Compiler} Compiler */
2
+
1
3
  import { importAliases as legacyImportAliases } from '../config.js';
2
4
 
5
+ /**
6
+ * This plugin resolves special import aliases to their actual location on disk,
7
+ * e.g. 'fds/components' to 'fontoxml-vendors/src/fds/components'.
8
+ */
3
9
  export default class ResolveImportAliasPlugin {
4
- #inDevelopmentMode;
10
+ inDevelopmentMode;
5
11
 
6
12
  constructor(options) {
7
- this.#inDevelopmentMode = options.inDevelopmentMode || false;
13
+ this.inDevelopmentMode = options.inDevelopmentMode || false;
8
14
  }
9
15
 
10
16
  _addImportAlias(importAliases, importAlias) {
11
17
  importAliases.set(
12
18
  importAlias.alias,
13
- (this.#inDevelopmentMode && importAlias.devImport) ||
19
+ (this.inDevelopmentMode && importAlias.devImport) ||
14
20
  importAlias.import
15
21
  );
16
22
  }
17
23
 
24
+ /**
25
+ * @param {Compiler} compiler
26
+ */
18
27
  apply(compiler) {
19
28
  const importAliases = new Map();
20
29
 
21
30
  // On each compilation, gather all import aliases as early as possible
22
31
  // and store them so they can be used in the resolver plugin below.
23
32
  compiler.hooks.thisCompilation.tap(
24
- 'ResolveImportAliasPlugin',
25
- (compilation, _compilationParams) => {
33
+ ResolveImportAliasPlugin.name,
34
+ (compilation) => {
26
35
  // Start with a clean slate for each compilation.
27
36
  importAliases.clear();
28
37
 
@@ -77,13 +86,12 @@ export default class ResolveImportAliasPlugin {
77
86
 
78
87
  compiler.resolverFactory.hooks.resolver
79
88
  .for('normal')
80
- .tap('ResolveImportAliasPlugin', (resolver) => {
89
+ .tap(ResolveImportAliasPlugin.name, (resolver) => {
81
90
  const target = resolver.ensureHook('resolve');
82
-
83
91
  resolver.getHook('resolve').tapAsync(
84
92
  // Loosely based on Webpack's own alias resolve plugin.
85
93
  // See: https://github.com/webpack/enhanced-resolve/blob/main/lib/AliasPlugin.js
86
- 'ResolveImportAliasPlugin',
94
+ ResolveImportAliasPlugin.name,
87
95
  (request, resolveContext, callback) => {
88
96
  const innerRequest = request.request || request.path;
89
97
 
@@ -113,10 +121,10 @@ export default class ResolveImportAliasPlugin {
113
121
 
114
122
  // Don't allow other aliasing or raw request.
115
123
  if (result === undefined) {
116
- return callback(null, null);
124
+ return callback(undefined, null);
117
125
  }
118
126
 
119
- callback(null, result);
127
+ callback(undefined, result);
120
128
  }
121
129
  );
122
130
  }
@@ -1,20 +1,26 @@
1
+ /** @typedef {import('webpack').Compiler} Compiler */
2
+
1
3
  import {
2
4
  addPackageDependencies,
3
5
  getPackageManifest,
4
6
  orderPackages,
5
7
  } from '../getDependenciesInLoadOrder.js';
6
8
 
7
- const plugin = { name: 'UnitTestPlugin' };
8
-
9
+ /**
10
+ * This plugin fakes a proper dependency tree for unit tests.
11
+ */
9
12
  export default class UnitTestPlugin {
10
13
  constructor(options) {
11
14
  this.options = options;
12
15
  }
13
16
 
17
+ /**
18
+ * @param {Compiler} compiler
19
+ */
14
20
  apply(compiler) {
15
21
  compiler.hooks.thisCompilation.tap(
16
- plugin,
17
- (compilation, _compilationParams) => {
22
+ UnitTestPlugin.name,
23
+ (compilation) => {
18
24
  try {
19
25
  const packageRootFolders =
20
26
  this.options.paths.packageRootFolders;
@@ -24,13 +30,14 @@ export default class UnitTestPlugin {
24
30
  if (!compilation.packagesInfoInLoadOrder) {
25
31
  compilation.errors.push(
26
32
  new Error(
27
- `Could not get package load order information. Make sure the package exists, and ${plugin.name} runs after the dependencies in load order plugin.`
33
+ `Could not get package load order information. Make sure the package exists, and ${UnitTestPlugin.name} runs after the dependencies in load order plugin.`
28
34
  )
29
35
  );
30
36
  return;
31
37
  }
32
38
 
33
- // Map packagesInfoInLoadOrder back to packageInfoByPackageName.
39
+ // Map packagesInfoInLoadOrder back to
40
+ // packageInfoByPackageName.
34
41
  const packageInfoByPackageName =
35
42
  compilation.packagesInfoInLoadOrder.reduce(
36
43
  (acc, packageInfo) => {
@@ -40,8 +47,9 @@ export default class UnitTestPlugin {
40
47
  Object.create(null)
41
48
  );
42
49
 
43
- // Add a virtual package for the tests, as devDependencies may be circular if seen as
44
- // dependencies of the package itself.
50
+ // Add a virtual package for the tests, as devDependencies
51
+ // may be circular if seen as dependencies of the package
52
+ // itself.
45
53
  const manifest = getPackageManifest(rootPackagePath);
46
54
  const virtualTestPackageName = `${rootPackageName}-virtual-test-package`;
47
55
  const initialPackageInfo = {
@@ -62,7 +70,8 @@ export default class UnitTestPlugin {
62
70
  packageInfoByPackageName
63
71
  );
64
72
 
65
- // Now topologically sort everything again, and filter out the virtual test package.
73
+ // Now topologically sort everything again, and filter out
74
+ // the virtual test package.
66
75
  compilation.packagesInfoInLoadOrder = orderPackages(
67
76
  packageInfoByPackageName
68
77
  ).filter(
@@ -72,12 +81,13 @@ export default class UnitTestPlugin {
72
81
 
73
82
  compilation.packagesInfoInLoadOrderError = null;
74
83
 
75
- // Set the package to unit test on the compilation for use in the generated loader.
84
+ // Set the package to unit test on the compilation for use
85
+ // in the generated loader.
76
86
  compilation.unitTestPackageInfo =
77
87
  packageInfoByPackageName[rootPackageName];
78
88
  } catch (error) {
79
- // Do not directly push the error to compilation errors, but let consumers
80
- // handle errors themselves.
89
+ // Do not directly push the error to compilation errors, but
90
+ // let consumers handle errors themselves.
81
91
  compilation.packagesInfoInLoadOrder = null;
82
92
  compilation.packagesInfoInLoadOrderError = error;
83
93
  compilation.unitTestPackageInfo = null;
@@ -85,7 +95,7 @@ export default class UnitTestPlugin {
85
95
  }
86
96
  );
87
97
 
88
- compiler.hooks.done.tap(plugin, (stats) => {
98
+ compiler.hooks.done.tap(UnitTestPlugin.name, (stats) => {
89
99
  if (
90
100
  stats.compilation.errors &&
91
101
  stats.compilation.errors.length &&
@@ -32,9 +32,6 @@ function getFixtureOptions(fixture) {
32
32
  }
33
33
 
34
34
  const testFactoryFunctionByName = {
35
- // Fixtures handled by other tests.
36
- dependencyWatching: false,
37
-
38
35
  notFound: (_fixturesPath, fixture, _fixtureOptions) => {
39
36
  return () => {
40
37
  assert.fail(`No testsuite for ${getTestSuiteName(fixture)}.`);
@@ -1,15 +1,34 @@
1
1
  import assert from 'assert';
2
2
  import fs from 'fs-extra';
3
3
  import path from 'path';
4
+ import tmp from 'tmp';
4
5
  import unzipper from 'unzipper';
5
6
  import { fileURLToPath } from 'url';
6
7
 
7
- import createTempDirectory from '../../../../editor/test/helpers/createTempDirectory.js';
8
8
  import schemaZipHelpers from '../../../src/api/schema/zipHelpers.js';
9
9
 
10
10
  const __filename = fileURLToPath(import.meta.url);
11
11
  const __dirname = path.dirname(__filename);
12
12
 
13
+ export default async function createTempDirectory() {
14
+ return new Promise((resolve, reject) => {
15
+ tmp.dir(
16
+ {
17
+ prefix: 'fonto-dev-test-',
18
+ unsafeCleanup: true,
19
+ },
20
+ (error, path, cleanupCallback) => {
21
+ if (error) {
22
+ reject(error);
23
+ return;
24
+ }
25
+
26
+ resolve({ path, cleanupCallback });
27
+ }
28
+ );
29
+ });
30
+ }
31
+
13
32
  describe('api/schema/schemaZipHelpers', () => {
14
33
  describe('zipSchemaSource', () => {
15
34
  const fixturePath = path.join(
@@ -1,69 +0,0 @@
1
- (function appEntry() {
2
- return Promise.resolve()
3
- .then(function () {
4
- window.startFontoBootstrap();
5
-
6
- require('fontoxml-shims/src/main');
7
-
8
- const glamor = require('glamor');
9
- glamor.styleSheet.maxLength = 4;
10
- glamor.plugins.remove(
11
- glamor.plugins.fns.find(function (pluginFn) {
12
- return pluginFn.name === 'prefixes';
13
- })
14
- );
15
-
16
- const getQueryParameterByName =
17
- require('fontoxml-utils/src/getQueryParameterByName').default;
18
- const scope = getQueryParameterByName(
19
- window.location.search,
20
- 'scope'
21
- );
22
- const configurationManager =
23
- require('fontoxml-configuration/src/configurationManager').default;
24
- configurationManager.set('scope', scope ? JSON.parse(scope) : {});
25
- configurationManager.set(
26
- 'version-info',
27
- require('./generated?type=versionInfo').default
28
- );
29
- configurationManager.set(
30
- 'fonto-debug-build',
31
- require('./generated?type=debugBuild').default
32
- );
33
-
34
- require('./generated?type=styles');
35
-
36
- require('./generated?type=setDefaultConfiguration');
37
-
38
- require('config/configuration');
39
-
40
- return configurationManager.applyDefaults();
41
- })
42
- .then(function () {
43
- require('./generated?type=messages');
44
-
45
- require('./generated?type=configureSxModule');
46
-
47
- require('config/schemaExperienceResolver');
48
-
49
- require('./generated?type=install');
50
-
51
- require('react');
52
- const ReactDOM = require('react-dom');
53
- const renderApp = require('fontoxml-editor/src/renderApp').default;
54
-
55
- ReactDOM.render(
56
- renderApp(),
57
- window.document.getElementById('index-app-root')
58
- );
59
-
60
- window.completeFontoBootstrap();
61
- })
62
- .catch(function (error) {
63
- if (window.showFontoError) {
64
- window.showFontoError(error);
65
- } else {
66
- throw error;
67
- }
68
- });
69
- })();
@@ -1,5 +0,0 @@
1
- // import configurationManager from 'fontoxml-configuration/src/configurationManager.js';
2
-
3
- // configurationManager.set('paragraph-node-name-for-pasting', 'paragraph');
4
-
5
- // No configuration.
@@ -1,6 +0,0 @@
1
- {
2
- "dependencies": {
3
- "app-test": "packages/app-test",
4
- "fontoxml-platform-base": "platform/fontoxml-platform-base"
5
- }
6
- }
@@ -1,15 +0,0 @@
1
- // import configurationManager from 'fontoxml-configuration/src/configurationManager.js';
2
- // import sxManager from 'fontoxml-modular-schema-experience/src/sxManager.js';
3
- // import SchemaLocationToSchemaExperienceResolver from 'fontoxml-schema-experience-resolver/src/SchemaLocationToSchemaExperienceResolver.js';
4
- // import TEST_SX_SHELL_LOCATION from 'app-test/src/SCHEMA_LOCATIONS.js';
5
-
6
- // var schemaLocationToSchemaExperienceResolver = new SchemaLocationToSchemaExperienceResolver();
7
- // schemaLocationToSchemaExperienceResolver.register(
8
- // sxManager.defineSchemaExperience('assets/schemas/test-sx-shell.json', [
9
- // 'test-sx-shell'
10
- // ]),
11
- // TEST_SX_SHELL_LOCATION
12
- // );
13
- // configurationManager.set('schema-experience-resolver', schemaLocationToSchemaExperienceResolver);
14
-
15
- // No schema experience resolver.
@@ -1 +0,0 @@
1
- export default ['urn:fontoxml:test'];
@@ -1,3 +0,0 @@
1
- export default function install() {
2
- // Do stuff
3
- }
@@ -1,4 +0,0 @@
1
- {
2
- "dependencies": {},
3
- "role": "internal"
4
- }
@@ -1,11 +0,0 @@
1
- class ConfigurationManager {
2
- set() {
3
- //
4
- }
5
-
6
- applyDefaults() {
7
- //
8
- }
9
- }
10
-
11
- export default new ConfigurationManager();
@@ -1,4 +0,0 @@
1
- {
2
- "dependencies": {},
3
- "role": "internal"
4
- }