forgepress 0.0.1 → 0.0.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.
Files changed (56) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md +28 -83
  2. package/dist/_chunks/client.d.mts +1 -1
  3. package/dist/_chunks/config.mjs +61 -19
  4. package/dist/_chunks/{validate.mjs → content.mjs} +350 -217
  5. package/dist/_chunks/fetch.mjs +2 -2
  6. package/dist/_chunks/files.mjs +32 -0
  7. package/dist/_chunks/libs/diff.mjs +485 -0
  8. package/dist/_chunks/media.mjs +282 -0
  9. package/dist/_chunks/once.mjs +16 -0
  10. package/dist/_chunks/output.mjs +98 -252
  11. package/dist/_chunks/plugin.mjs +87 -0
  12. package/dist/_chunks/preview.mjs +248 -0
  13. package/dist/_chunks/project.d.mts +7 -0
  14. package/dist/_chunks/reader.mjs +5 -9
  15. package/dist/_chunks/reader2.mjs +150 -202
  16. package/dist/_chunks/references.mjs +8 -5
  17. package/dist/_chunks/resolve.d.mts +2 -0
  18. package/dist/_chunks/response.mjs +5 -0
  19. package/dist/_chunks/routes.mjs +9 -0
  20. package/dist/_chunks/serialize.mjs +82 -0
  21. package/dist/_chunks/settings.mjs +328 -0
  22. package/dist/_chunks/settings2.mjs +2 -0
  23. package/dist/_chunks/types.d.mts +229 -24
  24. package/dist/_chunks/types2.d.mts +25 -0
  25. package/dist/_chunks/value.mjs +123 -1
  26. package/dist/cli/bin.mjs +50 -37
  27. package/dist/editor/index.mjs +9961 -8653
  28. package/dist/index.d.mts +2 -3
  29. package/dist/index.mjs +14 -24
  30. package/dist/next/preview.d.mts +1 -0
  31. package/dist/next/preview.mjs +3 -0
  32. package/dist/next/reload.d.mts +1 -0
  33. package/dist/next/reload.mjs +20 -0
  34. package/dist/next/settings.d.mts +12 -0
  35. package/dist/next/settings.mjs +2 -0
  36. package/dist/plugin/next.d.mts +11 -0
  37. package/dist/plugin/next.mjs +213 -0
  38. package/dist/plugin/nuxt.d.mts +7 -0
  39. package/dist/plugin/nuxt.mjs +52 -0
  40. package/dist/plugin/watcher.d.mts +1 -0
  41. package/dist/plugin/watcher.mjs +23 -0
  42. package/dist/preview/index.d.mts +1 -2
  43. package/dist/preview/index.mjs +1 -243
  44. package/dist/preview/react.d.mts +1 -0
  45. package/dist/preview/react.mjs +34 -0
  46. package/dist/unplugin.d.mts +12 -17
  47. package/dist/unplugin.mjs +1 -500
  48. package/package.json +72 -8
  49. package/dist/_chunks/config.d.mts +0 -35
  50. package/dist/_chunks/entry.d.mts +0 -194
  51. package/dist/_chunks/libs/@oxc-project/types.d.mts +0 -1297
  52. package/dist/_chunks/libs/@rolldown/pluginutils.d.mts +0 -62
  53. package/dist/_chunks/libs/rolldown.d.mts +0 -4711
  54. package/dist/_chunks/output2.mjs +0 -333
  55. package/dist/_chunks/parse.mjs +0 -22
  56. package/dist/_chunks/types.mjs +0 -2
@@ -1,97 +1,42 @@
1
1
  # Licenses of Bundled Dependencies
2
2
 
3
3
  The published artifact additionally contains code with the following licenses:
4
- MIT
4
+ BSD-3-Clause
5
5
 
6
6
  # Bundled Dependencies
7
7
 
8
- ## @oxc-project/types
8
+ ## diff
9
9
 
10
- License: MIT
11
- By: Boshen and oxc contributors
12
- Repository: https://github.com/oxc-project/oxc
10
+ License: BSD-3-Clause
11
+ By: Kevin Decker <kpdecker@gmail.com> (http://incaseofstairs.com), Mark Amery <markrobertamery+jsdiff@gmail.com>
12
+ Repository: https://github.com/kpdecker/jsdiff
13
13
 
14
- > MIT License
14
+ > BSD 3-Clause License
15
15
  >
16
- > Copyright (c) 2024-present VoidZero Inc. & Contributors
17
- > Copyright (c) 2023 Boshen
16
+ > Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
17
+ > All rights reserved.
18
18
  >
19
- > Permission is hereby granted, free of charge, to any person obtaining a copy
20
- > of this software and associated documentation files (the "Software"), to deal
21
- > in the Software without restriction, including without limitation the rights
22
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
- > copies of the Software, and to permit persons to whom the Software is
24
- > furnished to do so, subject to the following conditions:
19
+ > Redistribution and use in source and binary forms, with or without
20
+ > modification, are permitted provided that the following conditions are met:
25
21
  >
26
- > The above copyright notice and this permission notice shall be included in all
27
- > copies or substantial portions of the Software.
22
+ > 1. Redistributions of source code must retain the above copyright notice, this
23
+ > list of conditions and the following disclaimer.
28
24
  >
29
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
- > SOFTWARE.
36
-
37
- ---------------------------------------
38
-
39
- ## @rolldown/pluginutils
40
-
41
- License: MIT
42
- Repository: https://github.com/rolldown/plugins
43
-
44
- > MIT License
45
- >
46
- > Copyright (c) 2026-present, rolldown/plugins repository contributors
47
- >
48
- > Permission is hereby granted, free of charge, to any person obtaining a copy
49
- > of this software and associated documentation files (the "Software"), to deal
50
- > in the Software without restriction, including without limitation the rights
51
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
52
- > copies of the Software, and to permit persons to whom the Software is
53
- > furnished to do so, subject to the following conditions:
54
- >
55
- > The above copyright notice and this permission notice shall be included in all
56
- > copies or substantial portions of the Software.
57
- >
58
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
63
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
64
- > SOFTWARE.
65
-
66
- ---------------------------------------
67
-
68
- ## rolldown
69
-
70
- License: MIT
71
- Repository: https://github.com/rolldown/rolldown
72
-
73
- > MIT License
74
- >
75
- > Copyright (c) 2024-present VoidZero Inc. & Contributors
76
- >
77
- > Permission is hereby granted, free of charge, to any person obtaining a copy
78
- > of this software and associated documentation files (the "Software"), to deal
79
- > in the Software without restriction, including without limitation the rights
80
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
81
- > copies of the Software, and to permit persons to whom the Software is
82
- > furnished to do so, subject to the following conditions:
83
- >
84
- > The above copyright notice and this permission notice shall be included in all
85
- > copies or substantial portions of the Software.
86
- >
87
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
90
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
92
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
93
- > SOFTWARE.
25
+ > 2. Redistributions in binary form must reproduce the above copyright notice,
26
+ > this list of conditions and the following disclaimer in the documentation
27
+ > and/or other materials provided with the distribution.
94
28
  >
95
- > end of terms and conditions
29
+ > 3. Neither the name of the copyright holder nor the names of its
30
+ > contributors may be used to endorse or promote products derived from
31
+ > this software without specific prior written permission.
96
32
  >
97
- > The licenses of externally maintained libraries from which parts of the Software is derived are listed [here](https://github.com/rolldown/rolldown/blob/main/THIRD-PARTY-LICENSE).
33
+ > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
34
+ > AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35
+ > IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36
+ > DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
37
+ > FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38
+ > DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
39
+ > SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
40
+ > CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41
+ > OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
42
+ > OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,2 +1,2 @@
1
- import "./types.mjs";
1
+ import "./types2.mjs";
2
2
  export type ContentReader = (path: string) => Promise<unknown>;
@@ -1,37 +1,79 @@
1
1
  import { errorMessage } from "./error.mjs";
2
- import { DEFAULT_CONTENT_PATH, createPaths, resolveMedia, resolveOutput } from "./output.mjs";
3
- import { existsSync } from "node:fs";
2
+ import { DEFAULT_CONTENT_PATH, createPaths, prefixer, resolveMedia, resolveOutput } from "./media.mjs";
4
3
  import { dirname, join } from "node:path";
5
4
  import process from "node:process";
5
+ import { existsSync } from "node:fs";
6
6
  import { pathToFileURL } from "node:url";
7
+ function checkRepositoryPath(label, path, provider) {
8
+ try {
9
+ prefixer(provider.base)(path);
10
+ } catch {
11
+ const project = provider.base ? `provider.base ${JSON.stringify(provider.base)}` : "the root of the repository";
12
+ throw new Error(`[forgepress] the ${label} ${JSON.stringify(path)} is outside the repository when the project is at ${project}. Set provider.base to the folder of this project in the repository`);
13
+ }
14
+ }
7
15
  function resolveConfig(config) {
16
+ const paths = createPaths(config?.path);
17
+ const media = resolveMedia(config?.media);
18
+ if (config?.provider) {
19
+ checkRepositoryPath("content folder", paths.dir, config.provider);
20
+ checkRepositoryPath("media folder", media.dir, config.provider);
21
+ }
8
22
  return {
9
- paths: createPaths(config?.path),
10
- media: resolveMedia(config?.media),
23
+ paths,
24
+ media,
11
25
  output: resolveOutput(config?.output),
12
26
  content: config?.content,
13
27
  provider: config?.provider
14
28
  };
15
29
  }
16
- const CONFIG_FILES = ["forgepress.config.mjs", "forgepress.config.js"];
17
- function marks(dir, contentPath) {
18
- return CONFIG_FILES.some((file) => existsSync(join(dir, file))) || existsSync(join(dir, contentPath));
30
+ const CONFIG_FILES = [
31
+ "forgepress.config.ts",
32
+ "forgepress.config.mts",
33
+ "forgepress.config.mjs",
34
+ "forgepress.config.js"
35
+ ];
36
+ function ancestor(start, found) {
37
+ for (let dir = start;; dir = dirname(dir)) {
38
+ if (found(dir)) return dir;
39
+ if (dir === dirname(dir)) return void 0;
40
+ }
19
41
  }
20
42
  function findRoot(start = process.cwd(), contentPath = DEFAULT_CONTENT_PATH) {
21
- for (let dir = start;; dir = dirname(dir)) {
22
- if (marks(dir, contentPath)) return dir;
23
- if (dir === dirname(dir)) return start;
43
+ const marks = [
44
+ ...CONFIG_FILES,
45
+ createPaths(contentPath).schema,
46
+ "package.json"
47
+ ];
48
+ return ancestor(start, (dir) => marks.some((file) => existsSync(join(dir, file)))) ?? start;
49
+ }
50
+ const TYPESCRIPT = /\.m?ts$/;
51
+ let imports = 0;
52
+ async function importConfig(path) {
53
+ const url = pathToFileURL(path);
54
+ imports += 1;
55
+ url.search = String(imports);
56
+ try {
57
+ return await import(url.href);
58
+ } catch (error) {
59
+ if (error.code !== "MODULE_NOT_FOUND") throw error;
60
+ return await import(path);
24
61
  }
25
62
  }
63
+ function reason(file, cause) {
64
+ if (TYPESCRIPT.test(file) && !process.features.typescript) return `Node.js ${process.versions.node} can't run TypeScript. Use Node.js 22.18 or newer, or write the config as forgepress.config.mjs`;
65
+ return errorMessage(cause);
66
+ }
67
+ function configFile(root) {
68
+ return CONFIG_FILES.find((file) => existsSync(join(root, file)));
69
+ }
26
70
  async function loadConfig(root) {
27
- for (const file of CONFIG_FILES) {
28
- const path = join(root, file);
29
- if (!existsSync(path)) continue;
30
- try {
31
- return (await import(pathToFileURL(path).href)).default;
32
- } catch (cause) {
33
- throw new Error(`[forgepress] could not load ${file}: ${errorMessage(cause)}`, { cause });
34
- }
71
+ const file = configFile(root);
72
+ if (!file) return void 0;
73
+ try {
74
+ return (await importConfig(join(root, file))).default;
75
+ } catch (cause) {
76
+ throw new Error(`[forgepress] could not load ${file}: ${reason(file, cause)}`, { cause });
35
77
  }
36
78
  }
37
- export { findRoot, loadConfig, resolveConfig };
79
+ export { configFile, findRoot, loadConfig, resolveConfig };