create-caspian-app 0.2.0-beta.51 → 0.2.0-beta.53

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/dist/main.py CHANGED
@@ -248,6 +248,7 @@ class RPCMiddleware:
248
248
  # Route Registration
249
249
  # ====
250
250
 
251
+
251
252
  _route_module_cache = {}
252
253
  _route_signature_cache = {}
253
254
 
@@ -1 +1,13 @@
1
- import"/js/pp-reactive-v2.js";
1
+ import "/js/pp-reactive-v2.js";
2
+
3
+ const pp = (globalThis).pp;
4
+
5
+ if (document.readyState !== "loading") {
6
+ pp?.mount?.();
7
+ } else {
8
+ document.addEventListener(
9
+ "DOMContentLoaded",
10
+ () => pp?.mount?.(),
11
+ { once: true },
12
+ );
13
+ }
@@ -1,8 +1,7 @@
1
1
  import { fileURLToPath } from "url";
2
- import { dirname } from "path";
2
+ import { dirname, extname, relative } from "path";
3
3
  import chokidar, { FSWatcher } from "chokidar";
4
4
  import { spawn, ChildProcess, execFile } from "child_process";
5
- import { relative } from "path";
6
5
 
7
6
  export const PUBLIC_DIR = "public";
8
7
  export const SRC_DIR = "src";
@@ -30,6 +29,24 @@ export const DEFAULT_IGNORES: (string | RegExp)[] = [
30
29
 
31
30
  export const DEFAULT_AWF = { stabilityThreshold: 300, pollInterval: 100 };
32
31
 
32
+ function hasGlobPattern(value: string): boolean {
33
+ return /[*{[]/.test(value);
34
+ }
35
+
36
+ function getWatchBase(root: string): string {
37
+ if (hasGlobPattern(root)) {
38
+ const globIndex = root.search(/[*{[]/);
39
+ const prefix = root.slice(0, globIndex).replace(/[\\/]+$/, "");
40
+ return prefix || ".";
41
+ }
42
+
43
+ return extname(root) ? dirname(root) : root;
44
+ }
45
+
46
+ function formatWatchTarget(root: string): string {
47
+ return root.replace(/\\/g, "/");
48
+ }
49
+
33
50
  export function createSrcWatcher(
34
51
  root: string,
35
52
  opts: {
@@ -50,6 +67,7 @@ export function createSrcWatcher(
50
67
  logPrefix = "watch",
51
68
  usePolling = true,
52
69
  } = opts;
70
+ const watchBase = getWatchBase(root);
53
71
 
54
72
  const watcher = chokidar.watch(root, {
55
73
  ignoreInitial: true,
@@ -62,14 +80,14 @@ export function createSrcWatcher(
62
80
 
63
81
  watcher
64
82
  .on("ready", () => {
65
- console.log(`[${logPrefix}] Watching ${root.replace(/\\/g, "/")}/**/*`);
83
+ console.log(`[${logPrefix}] Watching ${formatWatchTarget(root)}`);
66
84
  })
67
85
  .on("all", (event: WatchEvent, filePath: string) => {
68
86
  if (exts && exts.length > 0) {
69
87
  const ok = exts.some((ext) => filePath.endsWith(ext));
70
88
  if (!ok) return;
71
89
  }
72
- const rel = relative(root, filePath).replace(/\\/g, "/");
90
+ const rel = relative(watchBase, filePath).replace(/\\/g, "/");
73
91
  if (event === "add" || event === "change" || event === "unlink") {
74
92
  onEvent(event, filePath, rel);
75
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-caspian-app",
3
- "version": "0.2.0-beta.51",
3
+ "version": "0.2.0-beta.53",
4
4
  "description": "Scaffold a new Caspian project (FastAPI-powered reactive Python framework).",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",