minista 2.7.5 → 2.8.2

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/README.md CHANGED
@@ -80,6 +80,10 @@ import { defineConfig } from "minista"
80
80
 
81
81
  export default defineConfig({
82
82
  base: "/", // string
83
+ // Absolute URL pathname, e.g. "/foo/"
84
+ // Full URL, e.g. "https://foo.com/"
85
+ // Empty string or "./" (for embedded deployment)
86
+ // https://ja.vitejs.dev/config/shared-options.html#base
83
87
  public: "public", // string
84
88
  out: "dist", // string
85
89
  root: {
@@ -92,12 +96,22 @@ export default defineConfig({
92
96
  srcExt: ["tsx", "jsx", "md", "mdx"], // string[]
93
97
  },
94
98
  assets: {
95
- entry: "", // string | string[] | { [key: string]: string }
99
+ entry: "",
100
+ // | string
101
+ // | string[]
102
+ // | { [key: string]: string }
103
+ // | {
104
+ // name?: string
105
+ // input: string
106
+ // insertPages: string | string[] | { include: string[]; exclude?: string[] }
107
+ // }[]
96
108
  outDir: "assets", // string
109
+ outName: "[name]", // string
97
110
  bundle: {
98
111
  outName: "bundle", // string
99
112
  },
100
113
  partial: {
114
+ useSplitPerPage: false, // boolean
101
115
  usePreact: false, // boolean
102
116
  useIntersectionObserver: true, // boolean
103
117
  outName: "partial", // string
package/dist/app.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  import React from "react";
2
3
  import ReactDOM from "react-dom";
3
4
  import { Pages } from "./pages.js";
package/dist/beautify.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  import React from "react";
2
3
  import fs from "fs-extra";
3
4
  import pc from "picocolors";
package/dist/build.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Options as MdxOptions } from "@mdx-js/esbuild";
2
2
  import type { Config as SvgrOptions } from "@svgr/core";
3
3
  import type { InlineConfig } from "vite";
4
- import type { MinistaResolveConfig, RootStaticContent, RootJsxContent, GlobalStaticData, GetGlobalStaticData, PageJsxContent, StaticData, StaticDataItem, GetStaticData, AliasArray, PartialModules, CssOptions } from "./types.js";
4
+ import type { MinistaResolveConfig, RootStaticContent, RootJsxContent, GlobalStaticData, GetGlobalStaticData, PageJsxContent, StaticData, StaticDataItem, GetStaticData, AliasArray, PartialModules, CssOptions, EntryObject, AssetsTagObject } from "./types.js";
5
5
  export declare function buildTempPages(entryPoints: string[], buildOptions: {
6
6
  outBase: string;
7
7
  outDir: string;
@@ -10,12 +10,12 @@ export declare function buildTempPages(entryPoints: string[], buildOptions: {
10
10
  svgrOptions: SvgrOptions;
11
11
  cssOptions: CssOptions;
12
12
  }): Promise<void>;
13
- export declare function buildStaticPages({ entryPoints, tempRootFilePath, outBase, outDir, assetsTagStr, showLog, }: {
13
+ export declare function buildStaticPages({ entryPoints, tempRootFilePath, outBase, outDir, assetsTagArray, showLog, }: {
14
14
  entryPoints: string[];
15
15
  tempRootFilePath: string;
16
16
  outBase: string;
17
17
  outDir: string;
18
- assetsTagStr: string;
18
+ assetsTagArray: AssetsTagObject[];
19
19
  showLog: boolean;
20
20
  }): Promise<void>;
21
21
  export declare function buildRootEsmContent(tempRootFilePath: string): Promise<{
@@ -23,21 +23,21 @@ export declare function buildRootEsmContent(tempRootFilePath: string): Promise<{
23
23
  staticData: GlobalStaticData;
24
24
  }>;
25
25
  export declare function buildGlobalStaticData(getGlobalStaticData: GetGlobalStaticData): Promise<GlobalStaticData>;
26
- export declare function buildStaticPage({ entryPoint, outFile, rootStaticContent, assetsTagStr, outDir, showLog, }: {
26
+ export declare function buildStaticPage({ entryPoint, outFile, rootStaticContent, assetsTagArray, outDir, showLog, }: {
27
27
  entryPoint: string;
28
28
  outFile: string;
29
29
  rootStaticContent: RootStaticContent;
30
- assetsTagStr: string;
30
+ assetsTagArray: AssetsTagObject[];
31
31
  outDir: string;
32
32
  showLog: boolean;
33
33
  }): Promise<void>;
34
34
  export declare function buildStaticData(getStaticData: GetStaticData): Promise<StaticData>;
35
- export declare function buildHtmlPage({ pageJsxContent, staticDataItem, routePath, rootStaticContent, assetsTagStr, frontmatter, outDir, showLog, }: {
35
+ export declare function buildHtmlPage({ pageJsxContent, staticDataItem, routePath, rootStaticContent, assetsTagArray, frontmatter, outDir, showLog, }: {
36
36
  pageJsxContent: PageJsxContent;
37
37
  staticDataItem: StaticDataItem;
38
38
  routePath: string;
39
39
  rootStaticContent: RootStaticContent;
40
- assetsTagStr: string;
40
+ assetsTagArray: AssetsTagObject[];
41
41
  frontmatter: any;
42
42
  outDir: string;
43
43
  showLog: boolean;
@@ -48,15 +48,22 @@ export declare function buildTempAssets(viteConfig: InlineConfig, buildOptions:
48
48
  outDir: string;
49
49
  assetDir: string;
50
50
  }): Promise<void>;
51
- export declare function buildAssetsTagStr(entryPoints: string[], buildOptions: {
51
+ export declare function buildAssetsTagArray({ entryPoints, // (*.css|*.js)
52
+ outBase, hrefBase, entryPattern, bundlePattern, partialPattern, }: {
53
+ entryPoints: string[];
52
54
  outBase: string;
53
- outDir: string;
54
- }): Promise<string>;
55
+ hrefBase: string;
56
+ entryPattern?: EntryObject[];
57
+ bundlePattern?: EntryObject[];
58
+ partialPattern?: EntryObject[];
59
+ }): AssetsTagObject[];
60
+ export declare function buildAssetsTagStr({ pathname, assetsTagArray, }: {
61
+ pathname: string;
62
+ assetsTagArray: AssetsTagObject[];
63
+ }): string;
55
64
  export declare function buildViteImporterRoots(config: MinistaResolveConfig): Promise<void>;
56
65
  export declare function buildViteImporterRoutes(config: MinistaResolveConfig): Promise<void>;
57
- export declare function buildViteImporterAssets(entry: {
58
- [key: string]: string;
59
- }): Promise<void>;
66
+ export declare function buildViteImporterAssets(entry: EntryObject[]): Promise<void>;
60
67
  export declare function buildViteImporterBlankAssets(): Promise<void>;
61
68
  export declare function buildPartialModules(moduleFilePaths: string[], config: MinistaResolveConfig): Promise<PartialModules>;
62
69
  export declare function buildPartialStringIndex(partialModules: PartialModules, buildOptions: {
@@ -72,10 +79,30 @@ export declare function buildPartialStringBundle(entryPoint: string, buildOption
72
79
  export declare function buildPartialStringInitial(entryPoint: string, partialModules: PartialModules, buildOptions: {
73
80
  outFile: string;
74
81
  }): Promise<void>;
82
+ export declare function buildPartialHydratePages(partialModules: PartialModules, config: MinistaResolveConfig, buildOptions: {
83
+ roots: string[];
84
+ pages: string[];
85
+ outBase: string;
86
+ outFile: string;
87
+ }): Promise<{
88
+ name: string;
89
+ insertPages: string[];
90
+ hasPartialModules: {
91
+ id: string;
92
+ phId: string;
93
+ phDomId: string;
94
+ htmlId: string;
95
+ targetsId: string;
96
+ importer: string;
97
+ rootAttr: string;
98
+ rootDOMElement: string;
99
+ rootStyleStr: string;
100
+ }[];
101
+ }[]>;
75
102
  export declare function buildPartialHydrateIndex(partialModules: PartialModules, config: MinistaResolveConfig, buildOptions: {
76
103
  outFile: string;
77
104
  }): Promise<void>;
78
- export declare function buildPartialHydrateAssets(viteConfig: InlineConfig, config: MinistaResolveConfig, buildOptions: {
105
+ export declare function buildPartialHydrateAsset(viteConfig: InlineConfig, config: MinistaResolveConfig, buildOptions: {
79
106
  input: string;
80
107
  bundleOutName: string;
81
108
  outDir: string;
package/dist/build.js CHANGED
@@ -1,22 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1
+ "use strict";
20
2
  import React from "react";
21
3
  import fs from "fs-extra";
22
4
  import path from "path";
@@ -32,6 +14,7 @@ import {
32
14
  } from "vite";
33
15
  import { parse } from "node-html-parser";
34
16
  import mojigiri from "mojigiri";
17
+ import picomatch from "picomatch";
35
18
  import { systemConfig } from "./system.js";
36
19
  import { getFilePath } from "./path.js";
37
20
  import {
@@ -42,7 +25,7 @@ import {
42
25
  } from "./esbuild.js";
43
26
  import { resolveaAssetFileName } from "./vite.js";
44
27
  import { renderHtml } from "./render.js";
45
- import { slashEnd, reactStylesToString } from "./utils.js";
28
+ import { slashEnd, reactStylesToString, getFilename } from "./utils.js";
46
29
  import { cssModulePlugin } from "./css.js";
47
30
  const __filename = url.fileURLToPath(import.meta.url);
48
31
  const __dirname = path.dirname(__filename);
@@ -108,7 +91,7 @@ async function buildStaticPages({
108
91
  tempRootFilePath,
109
92
  outBase,
110
93
  outDir,
111
- assetsTagStr,
94
+ assetsTagArray,
112
95
  showLog
113
96
  }) {
114
97
  const rootStaticContent = await buildRootEsmContent(tempRootFilePath);
@@ -122,7 +105,7 @@ async function buildStaticPages({
122
105
  entryPoint,
123
106
  outFile: filename,
124
107
  rootStaticContent,
125
- assetsTagStr,
108
+ assetsTagArray,
126
109
  outDir,
127
110
  showLog
128
111
  });
@@ -151,7 +134,7 @@ async function buildStaticPage({
151
134
  entryPoint,
152
135
  outFile,
153
136
  rootStaticContent,
154
- assetsTagStr,
137
+ assetsTagArray,
155
138
  outDir,
156
139
  showLog
157
140
  }) {
@@ -168,27 +151,27 @@ async function buildStaticPage({
168
151
  staticDataItem,
169
152
  routePath: outFile,
170
153
  rootStaticContent,
171
- assetsTagStr,
154
+ assetsTagArray,
172
155
  frontmatter,
173
156
  outDir,
174
157
  showLog
175
158
  });
176
159
  }
177
160
  if ("props" in staticData && "paths" in staticData === false) {
178
- const staticDataItem = __spreadValues(__spreadValues({}, defaultStaticDataItem), staticData);
161
+ const staticDataItem = { ...defaultStaticDataItem, ...staticData };
179
162
  return await buildHtmlPage({
180
163
  pageJsxContent,
181
164
  staticDataItem,
182
165
  routePath: outFile,
183
166
  rootStaticContent,
184
- assetsTagStr,
167
+ assetsTagArray,
185
168
  frontmatter,
186
169
  outDir,
187
170
  showLog
188
171
  });
189
172
  }
190
173
  if ("paths" in staticData) {
191
- const staticDataItem = __spreadValues(__spreadValues({}, defaultStaticDataItem), staticData);
174
+ const staticDataItem = { ...defaultStaticDataItem, ...staticData };
192
175
  let fixedOutfile = outFile;
193
176
  for await (const [key, value] of Object.entries(staticDataItem.paths)) {
194
177
  const reg = new RegExp("\\[" + key + "\\]", "g");
@@ -199,7 +182,7 @@ async function buildStaticPage({
199
182
  staticDataItem,
200
183
  routePath: fixedOutfile,
201
184
  rootStaticContent,
202
- assetsTagStr,
185
+ assetsTagArray,
203
186
  frontmatter,
204
187
  outDir,
205
188
  showLog
@@ -208,7 +191,7 @@ async function buildStaticPage({
208
191
  if (Array.isArray(staticData) && staticData.length > 0) {
209
192
  const entryPoints = staticData;
210
193
  await Promise.all(entryPoints.map(async (entryPoint2) => {
211
- const staticDataItem = __spreadValues(__spreadValues({}, defaultStaticDataItem), entryPoint2);
194
+ const staticDataItem = { ...defaultStaticDataItem, ...entryPoint2 };
212
195
  let fixedOutfile = outFile;
213
196
  for await (const [key, value] of Object.entries(staticDataItem.paths)) {
214
197
  const reg = new RegExp("\\[" + key + "\\]", "g");
@@ -219,7 +202,7 @@ async function buildStaticPage({
219
202
  staticDataItem,
220
203
  routePath: fixedOutfile,
221
204
  rootStaticContent,
222
- assetsTagStr,
205
+ assetsTagArray,
223
206
  frontmatter,
224
207
  outDir,
225
208
  showLog
@@ -236,7 +219,7 @@ async function buildHtmlPage({
236
219
  staticDataItem,
237
220
  routePath,
238
221
  rootStaticContent,
239
- assetsTagStr,
222
+ assetsTagArray,
240
223
  frontmatter,
241
224
  outDir,
242
225
  showLog
@@ -258,28 +241,38 @@ async function buildHtmlPage({
258
241
  if (PageComponent === Fragment) {
259
242
  return /* @__PURE__ */ React.createElement(Fragment, null);
260
243
  } else {
261
- return /* @__PURE__ */ React.createElement(PageComponent, __spreadProps(__spreadValues(__spreadValues({}, globalStaticData == null ? void 0 : globalStaticData.props), staticProps), {
244
+ return /* @__PURE__ */ React.createElement(PageComponent, {
245
+ ...globalStaticData == null ? void 0 : globalStaticData.props,
246
+ ...staticProps,
262
247
  frontmatter,
263
248
  location
264
- }));
249
+ });
265
250
  }
266
251
  })());
267
252
  } else {
268
- return /* @__PURE__ */ React.createElement(RootComponent, __spreadProps(__spreadValues(__spreadValues({}, globalStaticData == null ? void 0 : globalStaticData.props), staticProps), {
253
+ return /* @__PURE__ */ React.createElement(RootComponent, {
254
+ ...globalStaticData == null ? void 0 : globalStaticData.props,
255
+ ...staticProps,
269
256
  frontmatter,
270
257
  location
271
- }), (() => {
258
+ }, (() => {
272
259
  if (PageComponent === Fragment) {
273
260
  return /* @__PURE__ */ React.createElement(Fragment, null);
274
261
  } else {
275
- return /* @__PURE__ */ React.createElement(PageComponent, __spreadProps(__spreadValues(__spreadValues({}, globalStaticData == null ? void 0 : globalStaticData.props), staticProps), {
262
+ return /* @__PURE__ */ React.createElement(PageComponent, {
263
+ ...globalStaticData == null ? void 0 : globalStaticData.props,
264
+ ...staticProps,
276
265
  frontmatter,
277
266
  location
278
- }));
267
+ });
279
268
  }
280
269
  })());
281
270
  }
282
271
  };
272
+ const assetsTagStr = buildAssetsTagStr({
273
+ pathname: location.pathname,
274
+ assetsTagArray
275
+ });
283
276
  const renderdHtml = await renderHtml(/* @__PURE__ */ React.createElement(RenderComponent, null), assetsTagStr);
284
277
  const html = [renderdHtml];
285
278
  const stringInitial = getFilePath(systemConfig.temp.partialHydration.outDir, "string-initial", "json");
@@ -330,18 +323,78 @@ async function buildTempAssets(viteConfig, buildOptions) {
330
323
  });
331
324
  }
332
325
  }
333
- async function buildAssetsTagStr(entryPoints, buildOptions) {
334
- const winOutBase = buildOptions.outBase.replaceAll("/", "\\");
335
- const assetsTags = entryPoints.map((entryPoint) => {
336
- const assetPath = entryPoint.replace(buildOptions.outBase, buildOptions.outDir).replace(winOutBase, buildOptions.outDir).replaceAll("\\", "/");
326
+ function buildAssetsTagArray({
327
+ entryPoints,
328
+ outBase,
329
+ hrefBase,
330
+ entryPattern = [],
331
+ bundlePattern = [],
332
+ partialPattern = []
333
+ }) {
334
+ const winOutBase = outBase.replaceAll("/", "\\");
335
+ const assets = entryPoints.map((entryPoint) => {
336
+ const assetPath = entryPoint.replace(outBase, hrefBase).replace(winOutBase, hrefBase).replaceAll("\\", "/");
337
+ const name = getFilename(assetPath);
337
338
  if (assetPath.endsWith(".css")) {
338
- return `<link rel="stylesheet" href="${assetPath}">`;
339
- } else if (assetPath.endsWith(".js")) {
340
- return `<script defer src="${assetPath}"><\/script>`;
339
+ return {
340
+ name,
341
+ assetTag: `<link rel="stylesheet" href="${assetPath}">`,
342
+ assetPath
343
+ };
344
+ } else {
345
+ return {
346
+ name,
347
+ assetTag: `<script defer src="${assetPath}"><\/script>`,
348
+ assetPath
349
+ };
341
350
  }
342
351
  });
343
- const assetsTagStr = assetsTags.join("");
344
- return assetsTagStr;
352
+ const patterns = [...entryPattern, ...bundlePattern, ...partialPattern];
353
+ const result = assets.map((asset) => {
354
+ const targetPattern = patterns.find((pattern) => pattern.name === asset.name);
355
+ if (targetPattern) {
356
+ return {
357
+ pattern: targetPattern.insertPages,
358
+ assetTag: asset.assetTag,
359
+ assetPath: asset.assetPath
360
+ };
361
+ } else {
362
+ return {
363
+ pattern: ["**/*"],
364
+ assetTag: asset.assetTag,
365
+ assetPath: asset.assetPath
366
+ };
367
+ }
368
+ });
369
+ return result;
370
+ }
371
+ function buildAssetsTagStr({
372
+ pathname,
373
+ assetsTagArray
374
+ }) {
375
+ if (!assetsTagArray.length) {
376
+ return "";
377
+ }
378
+ const result = assetsTagArray.map((item) => {
379
+ const check = picomatch.isMatch(pathname, item.pattern);
380
+ if (!check) {
381
+ return "";
382
+ }
383
+ if (!item.assetPath.startsWith("./")) {
384
+ return item.assetTag;
385
+ }
386
+ const slashArray = pathname.match(/\//g);
387
+ const slashCount = slashArray ? slashArray.length : 1;
388
+ if (slashCount >= 2) {
389
+ const upStr = [...Array(slashCount - 1)].map(() => "../").join("");
390
+ const relativePath = item.assetPath.replace(/^\.\//, upStr);
391
+ const relativeAssetTag = item.assetTag.replace(new RegExp(item.assetPath), relativePath);
392
+ return relativeAssetTag;
393
+ } else {
394
+ return item.assetTag;
395
+ }
396
+ }).join("");
397
+ return result;
345
398
  }
346
399
  async function buildViteImporterRoots(config) {
347
400
  const outFile = systemConfig.temp.viteImporter.outDir + "/roots.js";
@@ -386,6 +439,7 @@ async function buildViteImporterRoutes(config) {
386
439
  ${replaceFileNameArrayStr}
387
440
  .replace(/\\[\\.{3}.+\\]/, "*")
388
441
  .replace(/\\[(.+)\\]/, ":$1")
442
+ .replace(/^.\\//, "/")
389
443
  return {
390
444
  routePath: routePath,
391
445
  PageComponent: ROUTES[route].default,
@@ -405,14 +459,24 @@ async function buildViteImporterRoutes(config) {
405
459
  }
406
460
  async function buildViteImporterAssets(entry) {
407
461
  const outFile = systemConfig.temp.viteImporter.outDir + "/assets.js";
408
- const assetsPathArray = Object.values(entry);
409
- const filteredAssetsPathArray = assetsPathArray.filter((path2) => path2.match(/\.(js|cjs|mjs|jsx|ts|tsx)$/));
410
- const importArray = filteredAssetsPathArray.map((path2) => {
411
- return `import("/${path2}")`;
462
+ const globalEntry = entry.filter((item) => item.insertPages.length === 1 && item.insertPages[0] === "**/*");
463
+ const globalJsEntry = globalEntry.filter((item) => item.input.match(/\.(js|cjs|mjs|jsx|ts|tsx)$/));
464
+ const globalJsImportArray = globalJsEntry.map((item) => {
465
+ return `import("/${item.input}")`;
412
466
  });
413
- const importArrayStr = importArray.join("\n ");
414
- const template = `export const getAssets = () => {
415
- ${importArrayStr}
467
+ const globalJsImportStr = globalJsImportArray.join("\n ");
468
+ const otherEntry = entry.filter((item) => !(item.insertPages.length === 1 && item.insertPages[0] === "**/*"));
469
+ const otherImportArray = otherEntry.map((item) => {
470
+ const insertPagesStr = item.insertPages.map((pattern) => `"${pattern}"`).join();
471
+ return ` if (picomatch.isMatch(pathname, [${insertPagesStr}])) {
472
+ import("/${item.input}")
473
+ }`;
474
+ });
475
+ const otherImportStr = otherImportArray.join("\n ");
476
+ const template = `import picomatch from "picomatch-browser"
477
+ export const getAssets = (pathname) => {
478
+ ${globalJsImportStr}
479
+ ${otherImportStr}
416
480
  }`;
417
481
  await fs.outputFile(outFile, template).catch((err) => {
418
482
  console.error(err);
@@ -522,10 +586,61 @@ async function buildPartialStringInitial(entryPoint, partialModules, buildOption
522
586
  html: replacedHtml
523
587
  };
524
588
  });
525
- const template = JSON.stringify({ items });
526
- await fs.outputFile(outFile, template).catch((err) => {
589
+ const template = { items };
590
+ await fs.outputJson(outFile, template, { spaces: 2 }).catch((err) => {
591
+ console.error(err);
592
+ });
593
+ }
594
+ async function buildPartialHydratePages(partialModules, config, buildOptions) {
595
+ async function searchHasPhIds(targetPath, phIds2) {
596
+ const targetPathRelative = path.relative(".", targetPath);
597
+ const code = await fs.readFile(targetPathRelative, "utf8");
598
+ const codeWithPhIds = phIds2.filter((phId) => code.includes(phId));
599
+ return { path: targetPath, hasPhIds: codeWithPhIds };
600
+ }
601
+ const phIds = partialModules.map((item) => item.id);
602
+ const roots = [];
603
+ const pages = [];
604
+ await Promise.all(buildOptions.roots.map(async (item) => {
605
+ const root = await searchHasPhIds(item, phIds);
606
+ return roots.push(root);
607
+ }));
608
+ await Promise.all(buildOptions.pages.map(async (item) => {
609
+ const page = await searchHasPhIds(item, phIds);
610
+ return pages.push(page);
611
+ }));
612
+ const rootHasPhIds = roots.length > 0 ? roots[0].hasPhIds : "";
613
+ const pagesWithRoot = pages.map((item) => ({
614
+ path: item.path,
615
+ hasPhIds: [.../* @__PURE__ */ new Set([...item.hasPhIds, ...rootHasPhIds])].sort(),
616
+ groupId: [.../* @__PURE__ */ new Set([...item.hasPhIds, ...rootHasPhIds])].sort().join("-")
617
+ }));
618
+ const groupIds = [
619
+ ...new Set(pagesWithRoot.map((item) => item.groupId).filter((item) => item))
620
+ ].sort();
621
+ const groups = groupIds.map((item) => ({
622
+ groupId: item,
623
+ pages: pagesWithRoot.filter((childItem) => childItem.groupId === item)
624
+ }));
625
+ const hydratePages = groups.map((item, index) => {
626
+ const name = `${config.assets.partial.outName}-${index + 1}`;
627
+ const winOutBase = buildOptions.outBase.replaceAll("/", "\\");
628
+ const reg1 = new RegExp(`^${buildOptions.outBase}|index.mjs`, "g");
629
+ const reg2 = new RegExp(`.mjs`, "g");
630
+ const insertPages = item.pages.map((childItem) => childItem.path.replace(reg1, "").replace(reg2, "").replace(winOutBase, "").replaceAll("\\", "/"));
631
+ const reg = new RegExp(`(${item.pages[0].hasPhIds.join("|")})`, "g");
632
+ const hasPartialModules = partialModules.filter((item2) => item2.id.match(reg));
633
+ return {
634
+ name,
635
+ insertPages,
636
+ hasPartialModules
637
+ };
638
+ });
639
+ const template = hydratePages;
640
+ await fs.outputJson(buildOptions.outFile, template, { spaces: 2 }).catch((err) => {
527
641
  console.error(err);
528
642
  });
643
+ return hydratePages;
529
644
  }
530
645
  async function buildPartialHydrateIndex(partialModules, config, buildOptions) {
531
646
  const tmpImporters = partialModules.map((module) => {
@@ -567,7 +682,7 @@ ${tmpRendersStr}`;
567
682
  console.error(err);
568
683
  });
569
684
  }
570
- async function buildPartialHydrateAssets(viteConfig, config, buildOptions) {
685
+ async function buildPartialHydrateAsset(viteConfig, config, buildOptions) {
571
686
  var _a;
572
687
  const activePreact = buildOptions.usePreact && userPkgHasPreact;
573
688
  const resolveAliasPreact = [
@@ -773,12 +888,14 @@ async function buildCopyDir(targetDir, outDir, log) {
773
888
  }
774
889
  }
775
890
  export {
891
+ buildAssetsTagArray,
776
892
  buildAssetsTagStr,
777
893
  buildCopyDir,
778
894
  buildGlobalStaticData,
779
895
  buildHtmlPage,
780
- buildPartialHydrateAssets,
896
+ buildPartialHydrateAsset,
781
897
  buildPartialHydrateIndex,
898
+ buildPartialHydratePages,
782
899
  buildPartialModules,
783
900
  buildPartialStringBundle,
784
901
  buildPartialStringIndex,
package/dist/bundle.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  import React from "react";
2
3
  import "/@minista-temp/vite-importer/roots.js";
3
4
  import "/@minista-temp/vite-importer/routes.js";
package/dist/cli.js CHANGED
@@ -1,19 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
1
+ "use strict";
17
2
  import React from "react";
18
3
  import fs from "fs-extra";
19
4
  import { cac } from "cac";
@@ -41,7 +26,7 @@ import {
41
26
  } from "./generate.js";
42
27
  const cli = cac("minista");
43
28
  function cleanOptions(options) {
44
- const ret = __spreadValues({}, options);
29
+ const ret = { ...options };
45
30
  delete ret["--"];
46
31
  return ret;
47
32
  }
@@ -66,7 +51,7 @@ cli.command("[root]", "start dev server").alias("dev").option("--host [host]", `
66
51
  emptyResolveDir(systemConfig.temp.icons.outDir),
67
52
  emptyResolveDir(systemConfig.temp.partialHydration.outDir)
68
53
  ]);
69
- await generateViteImporters(config, viteConfig);
54
+ await generateViteImporters(config);
70
55
  await Promise.all([
71
56
  createDevServer(viteConfig),
72
57
  createDevServerAssets(config, mdxConfig)
@@ -90,7 +75,7 @@ cli.command("build [root]", "build for production").action(async () => {
90
75
  emptyResolveDir(systemConfig.temp.partialHydration.outDir),
91
76
  emptyResolveDir(config.out)
92
77
  ]);
93
- await Promise.all([generateViteImporters(config, viteConfig)]);
78
+ await Promise.all([generateViteImporters(config)]);
94
79
  await Promise.all([
95
80
  generateTempRoot(config, mdxConfig),
96
81
  generateTempPages(config, mdxConfig),
package/dist/comment.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  import React from "react";
2
3
  const Comment = ({ text }) => {
3
4
  return /* @__PURE__ */ React.createElement("div", {
package/dist/config.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { AliasOptions as ViteAliasOptions } from "vite";
2
- import type { MinistaConfig, MinistaUserConfig, MinistaResolveConfig, MinistaResolveAliasInput, AliasArray } from "./types.js";
2
+ import type { MinistaConfig, MinistaUserConfig, MinistaResolveConfig, MinistaEntry, EntryObject, MinistaResolveAliasInput, AliasArray } from "./types.js";
3
3
  export declare const defaultConfig: MinistaConfig;
4
4
  export declare function mergeConfig(userConfig: MinistaUserConfig): Promise<MinistaConfig>;
5
+ export declare function resolveEntry(entry: MinistaEntry): Promise<EntryObject[]>;
5
6
  export declare function mergeAlias(configAlias: MinistaResolveAliasInput, viteConfigAlias: ViteAliasOptions): Promise<AliasArray>;
6
7
  export declare function resolveConfig(config: MinistaConfig): Promise<MinistaResolveConfig>;
7
8
  export declare function getConfig(userConfig: MinistaUserConfig): Promise<MinistaResolveConfig>;