@spirobel/mininext 0.2.9 → 0.2.11

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
@@ -1,15 +1,11 @@
1
1
  # mininext
2
2
 
3
- To install dependencies:
3
+ To install
4
4
 
5
5
  ```bash
6
- bun install
6
+ bun add @spirobel/mininext
7
7
  ```
8
8
 
9
- To run:
9
+ syntax highlighting:
10
10
 
11
- ```bash
12
- bun run index.ts
13
- ```
14
-
15
- This project was created using `bun init` in bun v1.1.7. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
11
+ [mininext vs code extension](https://marketplace.visualstudio.com/items?itemName=spirobel.mini-next-vs-code)
package/dist/html.js CHANGED
@@ -169,10 +169,12 @@ export async function htmlResponder(mini, maybeUnresolved, head = default_head,
169
169
  </div>`;
170
170
  }
171
171
  if (!(maybeUnresolved instanceof JsonString)) {
172
+ const reloader = new HtmlString();
173
+ reloader.push(global.Reloader || "");
172
174
  maybeUnresolved = html `<!DOCTYPE html>
173
175
  <html>
174
176
  <head>
175
- ${global.Reloader || ""} ${head}
177
+ ${reloader} ${head}
176
178
  </head>
177
179
  <body>
178
180
  ${maybeUnresolved}
@@ -1,5 +1,8 @@
1
1
  import { url, Mini, type HtmlHandler } from "./url";
2
2
  import { html, isError, HtmlString, head, commonHead, cssReset } from "./html";
3
+ declare global {
4
+ var PROJECT_ROOT: string | undefined;
5
+ }
3
6
  declare function build(backendPath?: string): Promise<void>;
4
7
  declare const standardDevReloader: HtmlString;
5
8
  export { url, html, head, build, isError, HtmlString, type HtmlHandler, Mini, standardDevReloader, commonHead, cssReset, };
package/dist/mininext.js CHANGED
@@ -2,7 +2,9 @@ import { url, Mini } from "./url";
2
2
  import { html, isError, HtmlString, head, commonHead, cssReset } from "./html";
3
3
  import { watch } from "fs/promises";
4
4
  import * as path from "path";
5
- const PROJECT_ROOT = import.meta.dir + "/../../../../";
5
+ function projectRoot() {
6
+ return global.PROJECT_ROOT || import.meta.dir + "/../../../../";
7
+ }
6
8
  async function build(backendPath = "backend/backend.ts") {
7
9
  await buildBackend(backendPath);
8
10
  if (Bun.argv[2] === "dev") {
@@ -13,7 +15,7 @@ const myPlugin = {
13
15
  name: "node buffer in the frontend",
14
16
  setup(build) {
15
17
  build.onResolve({ filter: /^buffer$/ }, (args) => {
16
- const path_to_buffer_lib = path.resolve(PROJECT_ROOT, "node_modules/buffer/index.js");
18
+ const path_to_buffer_lib = path.resolve(projectRoot(), "node_modules/buffer/index.js");
17
19
  if (path_to_buffer_lib)
18
20
  return {
19
21
  path: path_to_buffer_lib,
@@ -25,7 +27,7 @@ async function buildBackend(backendPath = "backend/backend.ts") {
25
27
  global.FrontendScriptUrls = [];
26
28
  global.FrontendScripts = [];
27
29
  global.bundledSVGs = {};
28
- const i = await import(path.resolve(PROJECT_ROOT, backendPath));
30
+ const i = await import(path.resolve(projectRoot(), backendPath));
29
31
  for (const frontend of url.getFrontends()) {
30
32
  const f = await buildFrontend(frontend);
31
33
  FrontendScriptUrls.push("/" + f.url);
@@ -33,7 +35,7 @@ async function buildBackend(backendPath = "backend/backend.ts") {
33
35
  }
34
36
  for (const svgPath of url.getSvgPaths()) {
35
37
  const parsedSvgPath = path.parse(svgPath);
36
- const svgContent = Bun.file(path.join(PROJECT_ROOT + "/backend/", svgPath));
38
+ const svgContent = Bun.file(path.join(projectRoot() + "/backend/", svgPath));
37
39
  const svgHash = Bun.hash(await svgContent.arrayBuffer());
38
40
  const svgUrl = `/${parsedSvgPath.name}-${svgHash}.svg`;
39
41
  bundledSVGs[svgUrl] = {
@@ -42,8 +44,8 @@ async function buildBackend(backendPath = "backend/backend.ts") {
42
44
  };
43
45
  }
44
46
  const res = await Bun.build({
45
- entrypoints: [path.resolve(PROJECT_ROOT, backendPath)],
46
- outdir: path.resolve(PROJECT_ROOT, "dist"),
47
+ entrypoints: [path.resolve(projectRoot(), backendPath)],
48
+ outdir: path.resolve(projectRoot(), "dist"),
47
49
  naming: "backend.js",
48
50
  minify: Bun.argv[2] === "dev" ? false : true, //production
49
51
  target: "node",
@@ -56,8 +58,8 @@ async function buildBackend(backendPath = "backend/backend.ts") {
56
58
  }
57
59
  async function buildFrontend(file) {
58
60
  const result = await Bun.build({
59
- entrypoints: [path.resolve(PROJECT_ROOT, `frontend/${file}`)],
60
- outdir: path.resolve(PROJECT_ROOT, "dist"),
61
+ entrypoints: [path.resolve(projectRoot(), `frontend/${file}`)],
62
+ outdir: path.resolve(projectRoot(), "dist"),
61
63
  naming: "[name]-[hash].[ext]",
62
64
  minify: Bun.argv[2] === "dev" ? false : true, //production
63
65
  target: "browser",
@@ -95,7 +97,7 @@ async function devServer() {
95
97
  async function watchAndBuild(dir) {
96
98
  try {
97
99
  //start the file watcher that will rebuild frontend on save
98
- const watcher = watch(path.resolve(PROJECT_ROOT, dir), {
100
+ const watcher = watch(path.resolve(projectRoot(), dir), {
99
101
  recursive: true,
100
102
  });
101
103
  for await (const event of watcher) {
package/mininext/html.ts CHANGED
@@ -217,10 +217,12 @@ export async function htmlResponder(
217
217
  </div>`;
218
218
  }
219
219
  if (!(maybeUnresolved instanceof JsonString)) {
220
+ const reloader = new HtmlString();
221
+ reloader.push(global.Reloader || "");
220
222
  maybeUnresolved = html`<!DOCTYPE html>
221
223
  <html>
222
224
  <head>
223
- ${global.Reloader || ""} ${head}
225
+ ${reloader} ${head}
224
226
  </head>
225
227
  <body>
226
228
  ${maybeUnresolved}
@@ -2,8 +2,12 @@ import { url, Mini, type HtmlHandler } from "./url";
2
2
  import { html, isError, HtmlString, head, commonHead, cssReset } from "./html";
3
3
  import { watch } from "fs/promises";
4
4
  import * as path from "path";
5
- const PROJECT_ROOT = import.meta.dir + "/../../../../";
6
-
5
+ function projectRoot() {
6
+ return global.PROJECT_ROOT || import.meta.dir + "/../../../../";
7
+ }
8
+ declare global {
9
+ var PROJECT_ROOT: string | undefined;
10
+ }
7
11
  async function build(backendPath: string = "backend/backend.ts") {
8
12
  await buildBackend(backendPath);
9
13
  if (Bun.argv[2] === "dev") {
@@ -17,7 +21,7 @@ const myPlugin: BunPlugin = {
17
21
  setup(build) {
18
22
  build.onResolve({ filter: /^buffer$/ }, (args) => {
19
23
  const path_to_buffer_lib = path.resolve(
20
- PROJECT_ROOT,
24
+ projectRoot(),
21
25
  "node_modules/buffer/index.js"
22
26
  );
23
27
  if (path_to_buffer_lib)
@@ -31,7 +35,7 @@ async function buildBackend(backendPath: string = "backend/backend.ts") {
31
35
  global.FrontendScriptUrls = [];
32
36
  global.FrontendScripts = [];
33
37
  global.bundledSVGs = {};
34
- const i = await import(path.resolve(PROJECT_ROOT, backendPath));
38
+ const i = await import(path.resolve(projectRoot(), backendPath));
35
39
 
36
40
  for (const frontend of url.getFrontends()) {
37
41
  const f = await buildFrontend(frontend);
@@ -40,7 +44,9 @@ async function buildBackend(backendPath: string = "backend/backend.ts") {
40
44
  }
41
45
  for (const svgPath of url.getSvgPaths()) {
42
46
  const parsedSvgPath = path.parse(svgPath);
43
- const svgContent = Bun.file(path.join(PROJECT_ROOT + "/backend/", svgPath));
47
+ const svgContent = Bun.file(
48
+ path.join(projectRoot() + "/backend/", svgPath)
49
+ );
44
50
  const svgHash = Bun.hash(await svgContent.arrayBuffer());
45
51
  const svgUrl = `/${parsedSvgPath.name}-${svgHash}.svg`;
46
52
  bundledSVGs[svgUrl] = {
@@ -49,8 +55,8 @@ async function buildBackend(backendPath: string = "backend/backend.ts") {
49
55
  };
50
56
  }
51
57
  const res = await Bun.build({
52
- entrypoints: [path.resolve(PROJECT_ROOT, backendPath)],
53
- outdir: path.resolve(PROJECT_ROOT, "dist"),
58
+ entrypoints: [path.resolve(projectRoot(), backendPath)],
59
+ outdir: path.resolve(projectRoot(), "dist"),
54
60
  naming: "backend.js",
55
61
  minify: Bun.argv[2] === "dev" ? false : true, //production
56
62
  target: "node",
@@ -64,8 +70,8 @@ async function buildBackend(backendPath: string = "backend/backend.ts") {
64
70
 
65
71
  async function buildFrontend(file: string) {
66
72
  const result = await Bun.build({
67
- entrypoints: [path.resolve(PROJECT_ROOT, `frontend/${file}`)],
68
- outdir: path.resolve(PROJECT_ROOT, "dist"),
73
+ entrypoints: [path.resolve(projectRoot(), `frontend/${file}`)],
74
+ outdir: path.resolve(projectRoot(), "dist"),
69
75
  naming: "[name]-[hash].[ext]",
70
76
  minify: Bun.argv[2] === "dev" ? false : true, //production
71
77
  target: "browser",
@@ -103,7 +109,7 @@ async function devServer() {
103
109
  async function watchAndBuild(dir: string) {
104
110
  try {
105
111
  //start the file watcher that will rebuild frontend on save
106
- const watcher = watch(path.resolve(PROJECT_ROOT, dir), {
112
+ const watcher = watch(path.resolve(projectRoot(), dir), {
107
113
  recursive: true,
108
114
  });
109
115
  for await (const event of watcher) {
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  },
14
14
  "files": ["dist", "mininext"],
15
- "version": "0.2.9",
15
+ "version": "0.2.11",
16
16
  "devDependencies": {
17
17
  "@types/bun": "latest"
18
18
  },