@modern-js/app-tools 2.63.0 → 2.63.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 (61) hide show
  1. package/dist/cjs/commands/dev.js +1 -1
  2. package/dist/cjs/commands/serve.js +1 -1
  3. package/dist/cjs/new/compat/hooks.js +11 -4
  4. package/dist/cjs/new/compat/utils.js +10 -1
  5. package/dist/cjs/new/context.js +0 -1
  6. package/dist/cjs/plugins/analyze/getBundleEntry.js +2 -2
  7. package/dist/cjs/plugins/analyze/getFileSystemEntry.js +9 -9
  8. package/dist/cjs/plugins/analyze/getHtmlTemplate.js +51 -25
  9. package/dist/cjs/plugins/analyze/index.js +128 -130
  10. package/dist/cjs/plugins/deploy/index.js +12 -14
  11. package/dist/cjs/plugins/initialize/index.js +1 -1
  12. package/dist/cjs/utils/printInstructions.js +12 -3
  13. package/dist/cjs/utils/restart.js +2 -1
  14. package/dist/esm/commands/dev.js +2 -2
  15. package/dist/esm/commands/serve.js +2 -2
  16. package/dist/esm/new/compat/hooks.js +27 -17
  17. package/dist/esm/new/compat/utils.js +10 -1
  18. package/dist/esm/new/context.js +0 -1
  19. package/dist/esm/plugins/analyze/getBundleEntry.js +3 -3
  20. package/dist/esm/plugins/analyze/getFileSystemEntry.js +12 -12
  21. package/dist/esm/plugins/analyze/getHtmlTemplate.js +101 -28
  22. package/dist/esm/plugins/analyze/index.js +328 -331
  23. package/dist/esm/plugins/deploy/index.js +84 -88
  24. package/dist/esm/plugins/initialize/index.js +1 -1
  25. package/dist/esm/utils/printInstructions.js +29 -2
  26. package/dist/esm/utils/restart.js +2 -1
  27. package/dist/esm-node/commands/dev.js +2 -2
  28. package/dist/esm-node/commands/serve.js +2 -2
  29. package/dist/esm-node/new/compat/hooks.js +11 -4
  30. package/dist/esm-node/new/compat/utils.js +10 -1
  31. package/dist/esm-node/new/context.js +0 -1
  32. package/dist/esm-node/plugins/analyze/getBundleEntry.js +2 -2
  33. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +9 -9
  34. package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +49 -24
  35. package/dist/esm-node/plugins/analyze/index.js +128 -130
  36. package/dist/esm-node/plugins/deploy/index.js +12 -14
  37. package/dist/esm-node/plugins/initialize/index.js +1 -1
  38. package/dist/esm-node/utils/printInstructions.js +10 -2
  39. package/dist/esm-node/utils/restart.js +2 -1
  40. package/dist/types/builder/generator/adapterCopy.d.ts +2 -1
  41. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +3 -2
  42. package/dist/types/builder/generator/createCopyPattern.d.ts +4 -3
  43. package/dist/types/builder/generator/getBuilderEnvironments.d.ts +2 -2
  44. package/dist/types/builder/index.d.ts +1 -1
  45. package/dist/types/builder/shared/createCopyInfo.d.ts +3 -2
  46. package/dist/types/builder/shared/types.d.ts +3 -2
  47. package/dist/types/config/initialize/index.d.ts +3 -2
  48. package/dist/types/config/initialize/inits.d.ts +4 -3
  49. package/dist/types/new/context.d.ts +0 -1
  50. package/dist/types/plugins/analyze/getBundleEntry.d.ts +3 -3
  51. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +3 -3
  52. package/dist/types/plugins/analyze/getHtmlTemplate.d.ts +26 -5
  53. package/dist/types/plugins/analyze/getServerRoutes.d.ts +2 -2
  54. package/dist/types/plugins/analyze/index.d.ts +2 -3
  55. package/dist/types/plugins/deploy/index.d.ts +2 -3
  56. package/dist/types/plugins/deploy/platforms/platform.d.ts +3 -3
  57. package/dist/types/plugins/deploy/utils.d.ts +2 -2
  58. package/dist/types/types/new.d.ts +38 -21
  59. package/dist/types/utils/printInstructions.d.ts +3 -1
  60. package/dist/types/utils/routes.d.ts +2 -1
  61. package/package.json +20 -20
@@ -16,147 +16,145 @@ var analyze_default = ({ bundler }) => ({
16
16
  setup: (api) => {
17
17
  let pagesDir = [];
18
18
  let nestedRouteEntries = [];
19
- return {
20
- async prepare() {
21
- var _resolvedConfig_source;
22
- let appContext = api.useAppContext();
23
- const resolvedConfig = api.useResolvedConfigContext();
24
- const hookRunners = api.useHookRunners();
25
- try {
26
- if (checkIsBuildCommands()) {
27
- fs.emptydirSync(appContext.internalDirectory);
28
- }
29
- } catch {
30
- }
31
- const apiOnly = await isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir, appContext.apiDirectory);
32
- await hookRunners.addRuntimeExports();
33
- if (apiOnly) {
34
- const { routes: routes2 } = await hookRunners.modifyServerRoutes({
35
- routes: []
36
- });
37
- debug(`server routes: %o`, routes2);
38
- appContext = {
39
- ...api.useAppContext(),
40
- apiOnly,
41
- serverRoutes: routes2
42
- };
43
- api.setAppContext(appContext);
44
- return;
19
+ api.onPrepare(async () => {
20
+ var _resolvedConfig_source;
21
+ let appContext = api.getAppContext();
22
+ const resolvedConfig = api.getNormalizedConfig();
23
+ const hooks = api.getHooks();
24
+ try {
25
+ if (checkIsBuildCommands()) {
26
+ fs.emptydirSync(appContext.internalDirectory);
45
27
  }
46
- const [{ getBundleEntry }, { getServerRoutes }, { getHtmlTemplate }] = await Promise.all([
47
- import("./getBundleEntry.js"),
48
- import("./getServerRoutes.js"),
49
- import("./getHtmlTemplate.js")
50
- ]);
51
- const { entrypoints } = await hookRunners.modifyEntrypoints({
52
- entrypoints: await getBundleEntry(hookRunners, appContext, resolvedConfig)
28
+ } catch {
29
+ }
30
+ const apiOnly = await isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir, appContext.apiDirectory);
31
+ await hooks.addRuntimeExports.call();
32
+ if (apiOnly) {
33
+ const { routes: routes2 } = await hooks.modifyServerRoutes.call({
34
+ routes: []
53
35
  });
54
- debug(`entrypoints: %o`, entrypoints);
55
- const initialRoutes = getServerRoutes(entrypoints, {
56
- appContext,
57
- config: resolvedConfig
36
+ debug(`server routes: %o`, routes2);
37
+ api.updateAppContext({
38
+ apiOnly,
39
+ serverRoutes: routes2
58
40
  });
59
- const { routes } = await hookRunners.modifyServerRoutes({
60
- routes: initialRoutes
41
+ return;
42
+ }
43
+ const [{ getBundleEntry }, { getServerRoutes }, { getHtmlTemplate }] = await Promise.all([
44
+ import("./getBundleEntry.js"),
45
+ import("./getServerRoutes.js"),
46
+ import("./getHtmlTemplate.js")
47
+ ]);
48
+ const { entrypoints } = await hooks.modifyEntrypoints.call({
49
+ entrypoints: await getBundleEntry(hooks, appContext, resolvedConfig)
50
+ });
51
+ debug(`entrypoints: %o`, entrypoints);
52
+ const initialRoutes = getServerRoutes(entrypoints, {
53
+ appContext,
54
+ config: resolvedConfig
55
+ });
56
+ const { routes } = await hooks.modifyServerRoutes.call({
57
+ routes: initialRoutes
58
+ });
59
+ debug(`server routes: %o`, routes);
60
+ appContext = {
61
+ ...api.getAppContext(),
62
+ entrypoints,
63
+ serverRoutes: routes
64
+ };
65
+ api.updateAppContext(appContext);
66
+ nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
67
+ pagesDir = entrypoints.map((point) => point.entry).filter((entry) => entry && !path.extname(entry)).concat(nestedRouteEntries);
68
+ const { partialsByEntrypoint, htmlTemplates } = await getHtmlTemplate(entrypoints, hooks, {
69
+ appContext,
70
+ config: resolvedConfig
71
+ });
72
+ debug(`html templates: %o`, htmlTemplates);
73
+ api.updateAppContext({
74
+ partialsByEntrypoint
75
+ });
76
+ let checkedEntries = entrypoints.map((point) => point.entryName);
77
+ if (isDevCommand()) {
78
+ const { entry } = minimist(getArgv());
79
+ checkedEntries = await getSelectedEntries(typeof entry === "string" ? entry.split(",") : entry, entrypoints);
80
+ }
81
+ appContext = {
82
+ ...api.getAppContext(),
83
+ entrypoints,
84
+ checkedEntries,
85
+ apiOnly,
86
+ serverRoutes: routes,
87
+ htmlTemplates
88
+ };
89
+ api.updateAppContext(appContext);
90
+ if (checkIsBuildCommands()) {
91
+ await hooks.generateEntryCode.call({
92
+ entrypoints
61
93
  });
62
- debug(`server routes: %o`, routes);
63
- appContext = {
64
- ...api.useAppContext(),
65
- entrypoints,
66
- serverRoutes: routes
67
- };
68
- api.setAppContext(appContext);
69
- nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
70
- pagesDir = entrypoints.map((point) => point.entry).filter((entry) => entry && !path.extname(entry)).concat(nestedRouteEntries);
71
- const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
72
- appContext,
73
- config: resolvedConfig
94
+ const normalizedConfig = api.getNormalizedConfig();
95
+ const createBuilderForModern = await createBuilderGenerator(bundler);
96
+ const builder = await createBuilderForModern({
97
+ normalizedConfig,
98
+ appContext
74
99
  });
75
- debug(`html templates: %o`, htmlTemplates);
76
- let checkedEntries = entrypoints.map((point) => point.entryName);
77
- if (isDevCommand()) {
78
- const { entry } = minimist(getArgv());
79
- checkedEntries = await getSelectedEntries(typeof entry === "string" ? entry.split(",") : entry, entrypoints);
80
- }
81
- appContext = {
82
- ...api.useAppContext(),
83
- entrypoints,
84
- checkedEntries,
85
- apiOnly,
86
- serverRoutes: routes,
87
- htmlTemplates
88
- };
89
- api.setAppContext(appContext);
90
- if (checkIsBuildCommands()) {
91
- await hookRunners.generateEntryCode({
92
- entrypoints
93
- });
94
- const normalizedConfig = api.useResolvedConfigContext();
95
- const createBuilderForModern = await createBuilderGenerator(bundler);
96
- const builder = await createBuilderForModern({
97
- normalizedConfig,
98
- appContext
99
- });
100
- builder.onBeforeBuild(async ({ bundlerConfigs, isFirstCompile }) => {
101
- if (!isFirstCompile) {
102
- return;
103
- }
104
- const hookRunners2 = api.useHookRunners();
105
- await generateRoutes(appContext);
106
- await hookRunners2.beforeBuild({
107
- bundlerConfigs
108
- });
100
+ builder.onBeforeBuild(async ({ bundlerConfigs, isFirstCompile, environments, isWatch }) => {
101
+ if (!isFirstCompile) {
102
+ return;
103
+ }
104
+ await generateRoutes(appContext);
105
+ await hooks.onBeforeBuild.call({
106
+ isFirstCompile,
107
+ isWatch,
108
+ environments,
109
+ bundlerConfigs
109
110
  });
110
- builder.onAfterBuild(async ({ stats }) => {
111
- const hookRunners2 = api.useHookRunners();
112
- await hookRunners2.afterBuild({
113
- stats
114
- });
115
- await emitResolvedConfig(appContext.appDirectory, normalizedConfig);
111
+ });
112
+ builder.onAfterBuild(async ({ stats, environments, isFirstCompile, isWatch }) => {
113
+ await hooks.onAfterBuild.call({
114
+ stats,
115
+ environments,
116
+ isFirstCompile,
117
+ isWatch
116
118
  });
117
- builder.onDevCompileDone(async ({ isFirstCompile }) => {
118
- const hookRunners2 = api.useHookRunners();
119
- hookRunners2.afterDev({
120
- isFirstCompile
121
- });
122
- if (isFirstCompile) {
123
- printInstructions(hookRunners2, appContext, normalizedConfig);
124
- }
119
+ await emitResolvedConfig(appContext.appDirectory, normalizedConfig);
120
+ });
121
+ builder.onDevCompileDone(async ({ isFirstCompile }) => {
122
+ hooks.onAfterDev.call({
123
+ isFirstCompile
125
124
  });
126
- builder.onBeforeCreateCompiler(async ({ bundlerConfigs }) => {
127
- const hookRunners2 = api.useHookRunners();
128
- await hookRunners2.beforeCreateCompiler({
129
- bundlerConfigs
130
- });
125
+ if (isFirstCompile) {
126
+ printInstructions(hooks, appContext, normalizedConfig);
127
+ }
128
+ });
129
+ builder.onBeforeCreateCompiler(async ({ bundlerConfigs, environments }) => {
130
+ await hooks.onBeforeCreateCompiler.call({
131
+ environments,
132
+ bundlerConfigs
131
133
  });
132
- builder.onAfterCreateCompiler(async ({ compiler }) => {
133
- const hookRunners2 = api.useHookRunners();
134
- await hookRunners2.afterCreateCompiler({
135
- compiler
136
- });
134
+ });
135
+ builder.onAfterCreateCompiler(async ({ compiler, environments }) => {
136
+ await hooks.onAfterCreateCompiler.call({
137
+ environments,
138
+ compiler
137
139
  });
138
- builder.addPlugins(resolvedConfig.builderPlugins);
139
- appContext = {
140
- ...api.useAppContext(),
141
- builder
142
- };
143
- api.setAppContext(appContext);
144
- }
145
- },
146
- watchFiles() {
147
- return {
148
- files: pagesDir,
149
- isPrivate: true
150
- };
151
- },
152
- resolvedConfig({ resolved }) {
153
- const appContext = api.useAppContext();
154
- const config = initialNormalizedConfig(resolved, appContext, bundler);
155
- return {
156
- resolved: config
157
- };
140
+ });
141
+ builder.addPlugins(resolvedConfig.builderPlugins);
142
+ api.updateAppContext({
143
+ builder
144
+ });
158
145
  }
159
- };
146
+ });
147
+ api.addWatchFiles(() => {
148
+ return {
149
+ files: pagesDir,
150
+ isPrivate: true
151
+ };
152
+ });
153
+ api.modifyResolvedConfig((resolved) => {
154
+ const appContext = api.getAppContext();
155
+ const config = initialNormalizedConfig(resolved, appContext, bundler);
156
+ return config;
157
+ });
160
158
  }
161
159
  });
162
160
  export {
@@ -22,21 +22,19 @@ var deploy_default = () => ({
22
22
  name: "@modern-js/plugin-deploy",
23
23
  setup: (api) => {
24
24
  const deployTarget = process.env.MODERNJS_DEPLOY || provider || "node";
25
- return {
26
- async deploy() {
27
- const appContext = api.useAppContext();
28
- const { metaName } = appContext;
29
- if (metaName !== "modern-js" && !process.env.MODERNJS_DEPLOY) {
30
- return;
31
- }
32
- const modernConfig = api.useResolvedConfigContext();
33
- const deployPreset = await getDeployPreset(appContext, modernConfig, deployTarget);
34
- (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare());
35
- (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput());
36
- (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry());
37
- (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.end) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.end());
25
+ api.deploy(async () => {
26
+ const appContext = api.getAppContext();
27
+ const { metaName } = appContext;
28
+ if (metaName !== "modern-js" && !process.env.MODERNJS_DEPLOY) {
29
+ return;
38
30
  }
39
- };
31
+ const modernConfig = api.getNormalizedConfig();
32
+ const deployPreset = await getDeployPreset(appContext, modernConfig, deployTarget);
33
+ (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare());
34
+ (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput());
35
+ (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry());
36
+ (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.end) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.end());
37
+ });
40
38
  }
41
39
  });
42
40
  export {
@@ -27,7 +27,7 @@ var initialize_default = ({ bundler }) => ({
27
27
  appContext = {
28
28
  ...appContext,
29
29
  port,
30
- distDirectory: ensureAbsolutePath(appContext.distDirectory, ((_resolved_output_distPath = resolved.output.distPath) === null || _resolved_output_distPath === void 0 ? void 0 : _resolved_output_distPath.root) || "dist")
30
+ distDirectory: ensureAbsolutePath(appContext.appDirectory, ((_resolved_output_distPath = resolved.output.distPath) === null || _resolved_output_distPath === void 0 ? void 0 : _resolved_output_distPath.root) || "dist")
31
31
  };
32
32
  api.updateAppContext(appContext);
33
33
  const normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
@@ -1,5 +1,12 @@
1
1
  import { logger, prettyInstructions } from "@modern-js/utils";
2
- const printInstructions = async (hookRunners, appContext, config) => {
2
+ const printInstructions = async (hooks, appContext, config) => {
3
+ const message = prettyInstructions(appContext, config);
4
+ const { instructions } = await hooks.onBeforePrintInstructions.call({
5
+ instructions: message
6
+ });
7
+ logger.log(instructions);
8
+ };
9
+ const printInstructionsCompat = async (hookRunners, appContext, config) => {
3
10
  const message = prettyInstructions(appContext, config);
4
11
  const { instructions } = await hookRunners.beforePrintInstructions({
5
12
  instructions: message
@@ -7,5 +14,6 @@ const printInstructions = async (hookRunners, appContext, config) => {
7
14
  logger.log(instructions);
8
15
  };
9
16
  export {
10
- printInstructions
17
+ printInstructions,
18
+ printInstructionsCompat
11
19
  };
@@ -1,5 +1,6 @@
1
1
  import { cli } from "@modern-js/plugin-v2/cli";
2
- import { chalk, clearConsole, getFullArgv, logger, program } from "@modern-js/utils";
2
+ import { chalk, clearConsole, getFullArgv, logger } from "@modern-js/utils";
3
+ import { program } from "@modern-js/utils/commander";
3
4
  async function restart(hooksRunner, filename) {
4
5
  clearConsole();
5
6
  logger.info(`Restart because ${chalk.yellow(filename)} is changed...
@@ -1,3 +1,4 @@
1
1
  import type { RsbuildPlugin } from '@modern-js/uni-builder';
2
+ import type { Bundler } from '../../types';
2
3
  import type { BuilderOptions } from '../shared';
3
- export declare const builderPluginAdapterCopy: (options: BuilderOptions<'shared'>) => RsbuildPlugin;
4
+ export declare const builderPluginAdapterCopy: <B extends Bundler>(options: BuilderOptions<B>) => RsbuildPlugin;
@@ -1,2 +1,3 @@
1
- import type { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
2
- export declare function createBuilderProviderConfig<B extends Bundler>(resolveConfig: AppNormalizedConfig<B>, appContext: IAppContext): Omit<AppNormalizedConfig<B>, 'plugins'>;
1
+ import type { AppNormalizedConfig, Bundler } from '../../types';
2
+ import type { AppToolsContext } from '../../types/new';
3
+ export declare function createBuilderProviderConfig<B extends Bundler>(resolveConfig: AppNormalizedConfig<B>, appContext: AppToolsContext<B>): Omit<AppNormalizedConfig<B>, 'plugins'>;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import type { Rspack, RspackChain } from '@rsbuild/core';
3
- import type { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
4
- export declare function createPublicPattern(appContext: IAppContext, config: AppNormalizedConfig, chain: RspackChain): {
3
+ import type { AppNormalizedConfig, Bundler } from '../../types';
4
+ import type { AppToolsContext } from '../../types/new';
5
+ export declare function createPublicPattern<B extends Bundler>(appContext: AppToolsContext<B>, config: AppNormalizedConfig, chain: RspackChain): {
5
6
  info: (file: {
6
7
  sourceFilename: string;
7
8
  }) => {
@@ -13,4 +14,4 @@ export declare function createPublicPattern(appContext: IAppContext, config: App
13
14
  noErrorOnMissing: boolean;
14
15
  transform: (content: Buffer, absoluteFrom: string) => string | Buffer;
15
16
  };
16
- export declare function createUploadPattern<B extends Bundler>(appContext: IAppContext, config: AppNormalizedConfig<B>): Rspack.CopyRspackPluginOptions['patterns']['0'];
17
+ export declare function createUploadPattern<B extends Bundler>(appContext: AppToolsContext<B>, config: AppNormalizedConfig<B>): Rspack.CopyRspackPluginOptions['patterns']['0'];
@@ -1,6 +1,6 @@
1
- import type { IAppContext } from '@modern-js/core';
2
1
  import type { AppNormalizedConfig, Bundler } from '../../types';
3
- export declare function getBuilderEnvironments<B extends Bundler>(normalizedConfig: AppNormalizedConfig<'shared'>, appContext: IAppContext, tempBuilderConfig: Omit<AppNormalizedConfig<B>, 'plugins'>): {
2
+ import type { AppToolsContext } from '../../types/new';
3
+ export declare function getBuilderEnvironments<B extends Bundler>(normalizedConfig: AppNormalizedConfig<B>, appContext: AppToolsContext<B>, tempBuilderConfig: Omit<AppNormalizedConfig<B>, 'plugins'>): {
4
4
  environments: {
5
5
  [name: string]: import("@rsbuild/core").EnvironmentConfig;
6
6
  };
@@ -1 +1 @@
1
- export declare function createBuilderGenerator(bundler: 'webpack' | 'rspack'): Promise<typeof import("./builder-rspack/index.js").createRspackBuilderForModern>;
1
+ export declare function createBuilderGenerator(bundler: 'webpack' | 'rspack'): Promise<typeof import("./builder-rspack/index.js").createRspackBuilderForModern | typeof import("./builder-webpack/index.js").createWebpackBuilderForModern>;
@@ -1,5 +1,6 @@
1
- import type { AppNormalizedConfig, IAppContext } from '../../types';
2
- export declare function createCopyInfo(appContext: IAppContext, config: AppNormalizedConfig<'shared'>): {
1
+ import type { AppNormalizedConfig, Bundler } from '../../types';
2
+ import type { AppToolsContext } from '../../types/new';
3
+ export declare function createCopyInfo<B extends Bundler>(appContext: AppToolsContext<B>, config: AppNormalizedConfig<B>): {
3
4
  configDir: string;
4
5
  uploadDir: string;
5
6
  publicDir: string;
@@ -1,5 +1,6 @@
1
- import type { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
1
+ import type { AppNormalizedConfig, Bundler } from '../../types';
2
+ import type { AppToolsContext } from '../../types/new';
2
3
  export type BuilderOptions<B extends Bundler> = {
3
4
  normalizedConfig: AppNormalizedConfig<B>;
4
- appContext: IAppContext;
5
+ appContext: AppToolsContext<B>;
5
6
  };
@@ -1,2 +1,3 @@
1
- import type { AppNormalizedConfig, IAppContext } from '../../types';
2
- export declare function initialNormalizedConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext, bundler: 'webpack' | 'rspack'): AppNormalizedConfig<'shared'>;
1
+ import type { AppNormalizedConfig } from '../../types';
2
+ import type { AppToolsContext } from '../../types/new';
3
+ export declare function initialNormalizedConfig(config: AppNormalizedConfig<'shared'>, appContext: AppToolsContext<'shared'>, bundler: 'webpack' | 'rspack'): AppNormalizedConfig<'shared'>;
@@ -1,4 +1,5 @@
1
- import type { AppNormalizedConfig, IAppContext } from '../../types';
2
- export declare function initHtmlConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext): AppNormalizedConfig<'shared'>['html'];
3
- export declare function initSourceConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext, bundler: 'webpack' | 'rspack'): void;
1
+ import type { AppNormalizedConfig } from '../../types';
2
+ import type { AppToolsContext } from '../../types/new';
3
+ export declare function initHtmlConfig(config: AppNormalizedConfig<'shared'>, appContext: AppToolsContext<'shared'>): AppNormalizedConfig<'shared'>['html'];
4
+ export declare function initSourceConfig(config: AppNormalizedConfig<'shared'>, appContext: AppToolsContext<'shared'>, bundler: 'webpack' | 'rspack'): void;
4
5
  export declare function createBuilderModuleScope(config: AppNormalizedConfig<'webpack'>): (string | RegExp)[] | undefined;
@@ -20,7 +20,6 @@ export declare const initAppContext: ({ appDirectory, runtimeConfigFile, options
20
20
  apiDirectory: string;
21
21
  lambdaDirectory: string;
22
22
  sharedDirectory: string;
23
- distDirectory: string;
24
23
  serverPlugins: never[];
25
24
  internalDirectory: string;
26
25
  htmlTemplates: {};
@@ -1,4 +1,4 @@
1
- import type { CliHooksRunner } from '@modern-js/core';
2
1
  import type { Entrypoint } from '@modern-js/types';
3
- import type { AppNormalizedConfig, AppTools, IAppContext } from '../../types';
4
- export declare const getBundleEntry: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
2
+ import type { AppNormalizedConfig } from '../../types';
3
+ import type { AppToolsContext, AppToolsHooks } from '../../types/new';
4
+ export declare const getBundleEntry: (hooks: AppToolsHooks<'shared'>, appContext: AppToolsContext<'shared'>, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
@@ -1,5 +1,5 @@
1
- import type { CliHooksRunner } from '@modern-js/core';
2
1
  import type { Entrypoint } from '@modern-js/types';
3
- import type { AppNormalizedConfig, AppTools, IAppContext } from '../../types';
2
+ import type { AppNormalizedConfig } from '../../types';
3
+ import type { AppToolsContext, AppToolsHooks } from '../../types/new';
4
4
  export type { Entrypoint };
5
- export declare const getFileSystemEntry: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
5
+ export declare const getFileSystemEntry: (hooks: AppToolsHooks<'shared'>, appContext: AppToolsContext<'shared'>, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
@@ -1,6 +1,27 @@
1
- import type { Entrypoint, HtmlTemplates } from '@modern-js/types';
2
- import type { AppNormalizedConfig, AppTools, IAppContext, PluginAPI } from '../../types';
3
- export declare const getHtmlTemplate: (entrypoints: Entrypoint[], api: PluginAPI<AppTools<'shared'>>, { appContext, config, }: {
4
- appContext: IAppContext;
1
+ import type { Entrypoint, HtmlPartials, HtmlTemplates } from '@modern-js/types';
2
+ import type { AppNormalizedConfig } from '../../types';
3
+ import type { AppToolsContext, AppToolsHooks } from '../../types/new';
4
+ export declare const getModifyHtmlPartials: (partials: Record<keyof HtmlPartials, string[]>) => {
5
+ top: {
6
+ append: (...script: string[]) => void;
7
+ prepend: (...script: string[]) => void;
8
+ current: string[];
9
+ };
10
+ head: {
11
+ append: (...script: string[]) => void;
12
+ prepend: (...script: string[]) => void;
13
+ current: string[];
14
+ };
15
+ body: {
16
+ append: (...script: string[]) => void;
17
+ prepend: (...script: string[]) => void;
18
+ current: string[];
19
+ };
20
+ };
21
+ export declare const getHtmlTemplate: (entrypoints: Entrypoint[], hooks: AppToolsHooks<'shared'>, { appContext, config, }: {
22
+ appContext: AppToolsContext<'shared'>;
5
23
  config: AppNormalizedConfig<'shared'>;
6
- }) => Promise<HtmlTemplates>;
24
+ }) => Promise<{
25
+ partialsByEntrypoint: Record<string, HtmlPartials>;
26
+ htmlTemplates: HtmlTemplates;
27
+ }>;
@@ -1,7 +1,7 @@
1
- import type { IAppContext } from '@modern-js/core';
2
1
  import type { Entrypoint, ServerRoute } from '@modern-js/types';
3
2
  import type { AppNormalizedConfig } from '../../types';
3
+ import type { AppToolsContext } from '../../types/new';
4
4
  export declare const getServerRoutes: (entrypoints: Entrypoint[], { appContext, config, }: {
5
- appContext: IAppContext;
5
+ appContext: AppToolsContext<'shared'>;
6
6
  config: AppNormalizedConfig<'shared'>;
7
7
  }) => ServerRoute[];
@@ -1,6 +1,5 @@
1
- import type { CliPlugin } from '@modern-js/core';
2
- import type { AppTools } from '../../types';
1
+ import type { AppTools, CliPluginFuture } from '../../types';
3
2
  declare const _default: ({ bundler, }: {
4
3
  bundler: 'webpack' | 'rspack';
5
- }) => CliPlugin<AppTools<'shared'>>;
4
+ }) => CliPluginFuture<AppTools<'shared'>>;
6
5
  export default _default;
@@ -1,4 +1,3 @@
1
- import type { CliPlugin } from '@modern-js/core';
2
- import type { AppTools } from '../../types';
3
- declare const _default: () => CliPlugin<AppTools>;
1
+ import type { AppTools, CliPluginFuture } from '../../types';
2
+ declare const _default: () => CliPluginFuture<AppTools<'shared'>>;
4
3
  export default _default;
@@ -1,6 +1,6 @@
1
- import type { IAppContext, NormalizedConfig } from '@modern-js/core';
2
- import type { AppTools } from '../../../types';
3
- export type CreatePreset = (appContext: IAppContext, config: NormalizedConfig<AppTools>, needModernServer?: boolean) => DeployPreset;
1
+ import type { AppToolsNormalizedConfig } from '../../../types';
2
+ import type { AppToolsContext } from '../../../types/new';
3
+ export type CreatePreset = (appContext: AppToolsContext<'shared'>, config: AppToolsNormalizedConfig, needModernServer?: boolean) => DeployPreset;
4
4
  type DeployPreset = {
5
5
  prepare?: () => Promise<void>;
6
6
  writeOutput?: () => Promise<void>;
@@ -1,11 +1,11 @@
1
- import type { IAppContext } from '@modern-js/core';
1
+ import type { AppToolsContext } from '../../types/new';
2
2
  export type ServerAppContext = {
3
3
  sharedDirectory: string;
4
4
  apiDirectory: string;
5
5
  lambdaDirectory: string;
6
6
  metaName: string;
7
7
  };
8
- export declare const serverAppContenxtTemplate: (appContext: IAppContext) => {
8
+ export declare const serverAppContenxtTemplate: (appContext: AppToolsContext<'shared'>) => {
9
9
  sharedDirectory: string;
10
10
  apiDirectory: string;
11
11
  lambdaDirectory: string;