forgepress 0.0.0 → 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 (57) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md +42 -0
  2. package/dist/_chunks/client.d.mts +2 -0
  3. package/dist/_chunks/config.mjs +79 -0
  4. package/dist/_chunks/content.mjs +733 -0
  5. package/dist/_chunks/error.mjs +4 -0
  6. package/dist/_chunks/fetch.mjs +13 -0
  7. package/dist/_chunks/files.mjs +32 -0
  8. package/dist/_chunks/libs/diff.mjs +485 -0
  9. package/dist/_chunks/locate.mjs +7 -0
  10. package/dist/_chunks/media.mjs +282 -0
  11. package/dist/_chunks/once.mjs +16 -0
  12. package/dist/_chunks/output.mjs +104 -0
  13. package/dist/_chunks/overlay.mjs +8 -0
  14. package/dist/_chunks/plugin.mjs +87 -0
  15. package/dist/_chunks/preview.mjs +248 -0
  16. package/dist/_chunks/project.d.mts +7 -0
  17. package/dist/_chunks/reader.mjs +19 -0
  18. package/dist/_chunks/reader2.mjs +797 -0
  19. package/dist/_chunks/references.mjs +56 -0
  20. package/dist/_chunks/resolve.d.mts +2 -0
  21. package/dist/_chunks/response.mjs +5 -0
  22. package/dist/_chunks/routes.mjs +9 -0
  23. package/dist/_chunks/serialize.mjs +82 -0
  24. package/dist/_chunks/settings.mjs +328 -0
  25. package/dist/_chunks/settings2.mjs +2 -0
  26. package/dist/_chunks/types.d.mts +230 -0
  27. package/dist/_chunks/types2.d.mts +25 -0
  28. package/dist/_chunks/value.mjs +139 -0
  29. package/dist/cli/bin.d.mts +1 -0
  30. package/dist/cli/bin.mjs +61 -0
  31. package/dist/disk/reader.d.mts +4 -0
  32. package/dist/disk/reader.mjs +2 -0
  33. package/dist/editor/index.d.mts +3 -0
  34. package/dist/editor/index.mjs +61951 -0
  35. package/dist/index.d.mts +104 -0
  36. package/dist/index.mjs +237 -0
  37. package/dist/next/preview.d.mts +1 -0
  38. package/dist/next/preview.mjs +3 -0
  39. package/dist/next/reload.d.mts +1 -0
  40. package/dist/next/reload.mjs +20 -0
  41. package/dist/next/settings.d.mts +12 -0
  42. package/dist/next/settings.mjs +2 -0
  43. package/dist/plugin/next.d.mts +11 -0
  44. package/dist/plugin/next.mjs +213 -0
  45. package/dist/plugin/nuxt.d.mts +7 -0
  46. package/dist/plugin/nuxt.mjs +52 -0
  47. package/dist/plugin/watcher.d.mts +1 -0
  48. package/dist/plugin/watcher.mjs +23 -0
  49. package/dist/preview/index.d.mts +4 -0
  50. package/dist/preview/index.mjs +2 -0
  51. package/dist/preview/react.d.mts +1 -0
  52. package/dist/preview/react.mjs +34 -0
  53. package/dist/query/fetch.d.mts +3 -0
  54. package/dist/query/fetch.mjs +2 -0
  55. package/dist/unplugin.d.mts +13 -0
  56. package/dist/unplugin.mjs +2 -0
  57. package/package.json +146 -2
@@ -0,0 +1,42 @@
1
+ # Licenses of Bundled Dependencies
2
+
3
+ The published artifact additionally contains code with the following licenses:
4
+ BSD-3-Clause
5
+
6
+ # Bundled Dependencies
7
+
8
+ ## diff
9
+
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
+
14
+ > BSD 3-Clause License
15
+ >
16
+ > Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
17
+ > All rights reserved.
18
+ >
19
+ > Redistribution and use in source and binary forms, with or without
20
+ > modification, are permitted provided that the following conditions are met:
21
+ >
22
+ > 1. Redistributions of source code must retain the above copyright notice, this
23
+ > list of conditions and the following disclaimer.
24
+ >
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.
28
+ >
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.
32
+ >
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.
@@ -0,0 +1,2 @@
1
+ import "./types2.mjs";
2
+ export type ContentReader = (path: string) => Promise<unknown>;
@@ -0,0 +1,79 @@
1
+ import { errorMessage } from "./error.mjs";
2
+ import { DEFAULT_CONTENT_PATH, createPaths, prefixer, resolveMedia, resolveOutput } from "./media.mjs";
3
+ import { dirname, join } from "node:path";
4
+ import process from "node:process";
5
+ import { existsSync } from "node:fs";
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
+ }
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
+ }
22
+ return {
23
+ paths,
24
+ media,
25
+ output: resolveOutput(config?.output),
26
+ content: config?.content,
27
+ provider: config?.provider
28
+ };
29
+ }
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
+ }
41
+ }
42
+ function findRoot(start = process.cwd(), contentPath = DEFAULT_CONTENT_PATH) {
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);
61
+ }
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
+ }
70
+ async function loadConfig(root) {
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 });
77
+ }
78
+ }
79
+ export { configFile, findRoot, loadConfig, resolveConfig };