@envelop/core 4.0.3 → 5.0.0-alpha-20231006093815-abe48e7c

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.
@@ -34,16 +34,19 @@ function createEnvelopOrchestrator({ plugins, }) {
34
34
  };
35
35
  const contextErrorHandlers = [];
36
36
  // Iterate all plugins and trigger onPluginInit
37
- for (const [i, plugin] of plugins.entries()) {
37
+ for (let i = 0; i < plugins.length; i++) {
38
+ const plugin = plugins[i];
39
+ const pluginsToAdd = [];
38
40
  plugin.onPluginInit &&
39
41
  plugin.onPluginInit({
40
42
  plugins,
41
43
  addPlugin: newPlugin => {
42
- plugins.push(newPlugin);
44
+ pluginsToAdd.push(newPlugin);
43
45
  },
44
46
  setSchema: modifiedSchema => replaceSchema(modifiedSchema, i),
45
47
  registerContextErrorHandler: handler => contextErrorHandlers.push(handler),
46
48
  });
49
+ pluginsToAdd.length && plugins.splice(i + 1, 0, ...pluginsToAdd);
47
50
  }
48
51
  // A set of before callbacks defined here in order to allow it to be used later
49
52
  const beforeCallbacks = {
@@ -31,16 +31,19 @@ export function createEnvelopOrchestrator({ plugins, }) {
31
31
  };
32
32
  const contextErrorHandlers = [];
33
33
  // Iterate all plugins and trigger onPluginInit
34
- for (const [i, plugin] of plugins.entries()) {
34
+ for (let i = 0; i < plugins.length; i++) {
35
+ const plugin = plugins[i];
36
+ const pluginsToAdd = [];
35
37
  plugin.onPluginInit &&
36
38
  plugin.onPluginInit({
37
39
  plugins,
38
40
  addPlugin: newPlugin => {
39
- plugins.push(newPlugin);
41
+ pluginsToAdd.push(newPlugin);
40
42
  },
41
43
  setSchema: modifiedSchema => replaceSchema(modifiedSchema, i),
42
44
  registerContextErrorHandler: handler => contextErrorHandlers.push(handler),
43
45
  });
46
+ pluginsToAdd.length && plugins.splice(i + 1, 0, ...pluginsToAdd);
44
47
  }
45
48
  // A set of before callbacks defined here in order to allow it to be used later
46
49
  const beforeCallbacks = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envelop/core",
3
- "version": "4.0.3",
3
+ "version": "5.0.0-alpha-20231006093815-abe48e7c",
4
4
  "sideEffects": false,
5
5
  "dependencies": {
6
6
  "@envelop/types": "4.0.1",