noofpi 1.0.0 → 1.1.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.
package/bin/noofpi.mjs CHANGED
File without changes
@@ -3,8 +3,8 @@ import {
3
3
  createViteConfig,
4
4
  finishPresetBuild,
5
5
  resolveFonts
6
- } from "./chunk-KAV3UNMO.js";
7
- import "./chunk-WXEYXDO6.js";
6
+ } from "./chunk-M7TMNIVH.js";
7
+ import "./chunk-NX6BO7UB.js";
8
8
  import "./chunk-MTXQR32N.js";
9
9
  import "./chunk-ELXCFUA4.js";
10
10
  import "./chunk-G35DW4NA.js";
@@ -2,7 +2,7 @@ import {
2
2
  toPublicConfig,
3
3
  toServerConfig,
4
4
  variantWidths
5
- } from "./chunk-WXEYXDO6.js";
5
+ } from "./chunk-NX6BO7UB.js";
6
6
  import {
7
7
  SSR_OUTLET
8
8
  } from "./chunk-MTXQR32N.js";
@@ -816,6 +816,7 @@ function noofpiPlugin(options) {
816
816
 
817
817
  // src/vite/config.ts
818
818
  import path12 from "path";
819
+ import { fileURLToPath } from "url";
819
820
  import vue from "@vitejs/plugin-vue";
820
821
  import tailwindcss from "@tailwindcss/vite";
821
822
  import { mergeConfig } from "vite";
@@ -957,9 +958,18 @@ function createViteConfig(root, config, kind, fonts = NO_FONTS) {
957
958
  imagesPlugin(config.images),
958
959
  noofpiPlugin({ root, config, css: resolveCss(root, config, fonts) })
959
960
  ],
960
- resolve: { dedupe: ["vue", "vue-router"] },
961
+ resolve: {
962
+ dedupe: ["vue", "vue-router"],
963
+ // vue-router reports through `nostics`; the stub keeps the console free of its warnings
964
+ alias: {
965
+ nostics: fileURLToPath(
966
+ new URL("./runtime/silent-diagnostics.js", import.meta.url)
967
+ )
968
+ }
969
+ },
961
970
  // noofpi's runtime imports virtual modules, so it must go through vite instead of being externalized
962
- ssr: { noExternal: ["noofpi"] },
971
+ // vue-router too: its `nostics` import has to go through the alias above
972
+ ssr: { noExternal: ["noofpi", "vue-router"] },
963
973
  // Subpaths must be listed too: a prebundled `noofpi/runtime` would be a second copy of the runtime modules
964
974
  // (different injection keys than the ones `createNoofpiApp` provides)
965
975
  optimizeDeps: {
@@ -18,6 +18,9 @@ var BUILD_PRESETS = [
18
18
  "cloudflare-pages",
19
19
  "github-pages"
20
20
  ];
21
+ function isCloudflarePreset(preset) {
22
+ return preset === "cloudflare-worker" || preset === "cloudflare-pages";
23
+ }
21
24
  function assertBuildPreset(value, source) {
22
25
  if (!BUILD_PRESETS.includes(value)) {
23
26
  throw new Error(
@@ -270,6 +273,7 @@ function toServerConfig(config) {
270
273
 
271
274
  export {
272
275
  BUILD_PRESETS,
276
+ isCloudflarePreset,
273
277
  assertBuildPreset,
274
278
  FONT_PROVIDERS,
275
279
  variantWidths,
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  BUILD_PRESETS,
3
3
  assertBuildPreset,
4
4
  resolveConfig
5
- } from "./chunk-WXEYXDO6.js";
5
+ } from "./chunk-NX6BO7UB.js";
6
6
  import "./chunk-ELXCFUA4.js";
7
7
  import "./chunk-FIJJ3EGL.js";
8
8
 
@@ -72,10 +72,10 @@ async function main() {
72
72
  await loadEnvFiles(root, command === "dev" ? "development" : "production");
73
73
  const config = await loadConfig(root);
74
74
  if (command === "dev") {
75
- const { startDev } = await import("./dev-ZJ732ORK.js");
75
+ const { startDev } = await import("./dev-Y5IW7464.js");
76
76
  await startDev(root, config, overrides);
77
77
  } else if (command === "build") {
78
- const { buildApp } = await import("./build-77DKK3YK.js");
78
+ const { buildApp } = await import("./build-GGRF4JTM.js");
79
79
  const preset = option(args, "--preset");
80
80
  await buildApp(
81
81
  root,
@@ -83,7 +83,7 @@ async function main() {
83
83
  preset ? assertBuildPreset(preset, "--preset") : void 0
84
84
  );
85
85
  } else {
86
- const { startProd } = await import("./start-I2LQWV7B.js");
86
+ const { startProd } = await import("./start-IK3X6V3N.js");
87
87
  await startProd(root, config, overrides);
88
88
  }
89
89
  }
@@ -8,8 +8,10 @@ import {
8
8
  htmlTemplate,
9
9
  resolveCss,
10
10
  resolveFonts
11
- } from "./chunk-KAV3UNMO.js";
12
- import "./chunk-WXEYXDO6.js";
11
+ } from "./chunk-M7TMNIVH.js";
12
+ import {
13
+ isCloudflarePreset
14
+ } from "./chunk-NX6BO7UB.js";
13
15
  import {
14
16
  createHandler
15
17
  } from "./chunk-2XCZWFIQ.js";
@@ -27,7 +29,7 @@ import "./chunk-Y3NBZ6DW.js";
27
29
 
28
30
  // src/vite/dev.ts
29
31
  import { createServer as createHttpServer } from "http";
30
- import path from "path";
32
+ import path2 from "path";
31
33
  import { createServer as createViteServer, normalizePath } from "vite";
32
34
 
33
35
  // src/shortcuts.ts
@@ -57,6 +59,30 @@ function bindShortcuts(options) {
57
59
  return true;
58
60
  }
59
61
 
62
+ // src/vite/platform.ts
63
+ import { existsSync } from "fs";
64
+ import { createRequire } from "module";
65
+ import path from "path";
66
+ import { pathToFileURL } from "url";
67
+ var WRANGLER_CONFIGS = ["wrangler.json", "wrangler.jsonc", "wrangler.toml"];
68
+ async function startPlatformProxy(root, config) {
69
+ if (!isCloudflarePreset(config.build.preset)) return void 0;
70
+ let entry;
71
+ try {
72
+ entry = createRequire(path.join(root, "package.json")).resolve("wrangler");
73
+ } catch {
74
+ console.warn(
75
+ "[noofpi] Cloudflare bindings are not available in dev: install wrangler (`wrangler` devDependency)"
76
+ );
77
+ return void 0;
78
+ }
79
+ const { getPlatformProxy } = await import(pathToFileURL(entry).href);
80
+ const configPath = WRANGLER_CONFIGS.map((file) => path.join(root, file)).find(
81
+ existsSync
82
+ );
83
+ return getPlatformProxy({ configPath });
84
+ }
85
+
60
86
  // src/vite/dev.ts
61
87
  async function startDev(root, config, overrides) {
62
88
  const startedAt = performance.now();
@@ -79,11 +105,12 @@ async function startDev(root, config, overrides) {
79
105
  )
80
106
  );
81
107
  const stylesheets = resolveCss(root, config, fonts).map((file) => {
82
- const relative = path.relative(root, file);
83
- const outside = relative.startsWith("..") || path.isAbsolute(relative);
108
+ const relative = path2.relative(root, file);
109
+ const outside = relative.startsWith("..") || path2.isAbsolute(relative);
84
110
  const url = outside ? "/@fs/" + normalizePath(file) : "/" + normalizePath(relative);
85
111
  return url + "?direct";
86
112
  });
113
+ const platform = await startPlatformProxy(root, config);
87
114
  const handler = createHandler({
88
115
  load: () => vite.ssrLoadModule("virtual:noofpi/server"),
89
116
  getTemplate: (url) => vite.transformIndexHtml(url, htmlTemplate(DEV_ENTRY, stylesheets)),
@@ -94,7 +121,7 @@ async function startDev(root, config, overrides) {
94
121
  });
95
122
  httpServer.on("request", (req, res) => {
96
123
  vite.middlewares(req, res, () => {
97
- handler(toWebRequest(req)).then(
124
+ handler(toWebRequest(req), platform?.env).then(
98
125
  (response) => sendWebResponse(res, response),
99
126
  (error) => {
100
127
  console.error(error);
@@ -109,7 +136,7 @@ async function startDev(root, config, overrides) {
109
136
  });
110
137
  for (const url of stylesheets) vite.warmupRequest(url).catch(() => {
111
138
  });
112
- const close = () => vite.close().then(() => {
139
+ const close = () => Promise.all([vite.close(), platform?.dispose()]).then(() => {
113
140
  httpServer.closeAllConnections();
114
141
  httpServer.close();
115
142
  });
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  BUILD_PRESETS,
3
3
  FONT_PROVIDERS,
4
4
  defineNoofpiConfig
5
- } from "./chunk-WXEYXDO6.js";
5
+ } from "./chunk-NX6BO7UB.js";
6
6
  import "./chunk-ELXCFUA4.js";
7
7
  import {
8
8
  FETCH_MODES
@@ -0,0 +1,11 @@
1
+ // src/runtime/silent-diagnostics.ts
2
+ var diagnostic = () => new Error();
3
+ var createConsoleReporter = () => () => {
4
+ };
5
+ var defineDiagnostics = (_options) => new Proxy({}, { get: () => diagnostic });
6
+ var defineProdDiagnostics = defineDiagnostics;
7
+ export {
8
+ createConsoleReporter,
9
+ defineDiagnostics,
10
+ defineProdDiagnostics
11
+ };
@@ -3,8 +3,8 @@ import {
3
3
  } from "./chunk-WX2V6EYH.js";
4
4
  import {
5
5
  OUTPUT_DIR
6
- } from "./chunk-KAV3UNMO.js";
7
- import "./chunk-WXEYXDO6.js";
6
+ } from "./chunk-M7TMNIVH.js";
7
+ import "./chunk-NX6BO7UB.js";
8
8
  import {
9
9
  createHandler
10
10
  } from "./chunk-2XCZWFIQ.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noofpi",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "A minimal Vue + Vite full-stack framework built around doofpi",
5
5
  "license": "MIT",
6
6
  "author": "Lior Cohen",