@seip/bluebird-js 0.1.7 → 0.2.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.
Files changed (151) hide show
  1. package/AGENTS.md +727 -620
  2. package/README.md +670 -607
  3. package/app/models/user.js +19 -0
  4. package/app/resources/html/home.html +137 -0
  5. package/app/resources/html/layouts/main.html +55 -0
  6. package/app/resources/html/notFound.html +14 -0
  7. package/app/resources/html/table.html +15 -0
  8. package/app/resources/html/terms.html +46 -0
  9. package/app/resources/index.html +27 -0
  10. package/app/resources/layouts/AppLayout.jsx +92 -0
  11. package/app/resources/main.jsx +18 -0
  12. package/app/resources/pages/Dashboard.jsx +93 -0
  13. package/app/resources/pages/Home.jsx +140 -0
  14. package/app/resources/pages/Login.jsx +35 -0
  15. package/app/resources/pages/NotFound.jsx +16 -0
  16. package/app/resources/pages/Register.jsx +55 -0
  17. package/app/resources/pages/TableDemo.jsx +85 -0
  18. package/app/resources/routes.jsx +59 -0
  19. package/app/resources/spa.js +73 -0
  20. package/app/resources/styles.css +9 -0
  21. package/app/routes/api.js +129 -50
  22. package/app/routes/auth.js +209 -0
  23. package/app/routes/web.js +89 -47
  24. package/core/ai.js +30 -10
  25. package/core/app.d.ts +2 -18
  26. package/core/app.js +987 -801
  27. package/core/auth.d.ts +2 -13
  28. package/core/auth.js +444 -326
  29. package/core/cli/build.js +37 -0
  30. package/core/cli/dev.js +155 -0
  31. package/core/cli/doctor.js +37 -2
  32. package/core/cli/export.js +191 -0
  33. package/core/cli/init.js +91 -322
  34. package/core/cli/nginx.js +1 -1
  35. package/core/cli/templates.js +139 -0
  36. package/core/cli/view.js +98 -161
  37. package/core/config.js +44 -2
  38. package/core/csrf.js +156 -24
  39. package/core/database.js +1184 -1131
  40. package/core/debug.js +1 -1
  41. package/core/html.js +8 -1
  42. package/core/index.d.ts +126 -310
  43. package/core/paths.js +55 -0
  44. package/core/ratelimit.js +10 -1
  45. package/core/react/client/api.js +239 -0
  46. package/core/react/client/auth.js +236 -0
  47. package/core/react/client/components.js +1321 -0
  48. package/core/react/client/datatable.js +595 -0
  49. package/core/react/client/i18n.js +440 -0
  50. package/core/react/client/index.d.ts +314 -0
  51. package/core/react/client/index.js +50 -0
  52. package/core/react/client/router.js +26 -0
  53. package/core/react/client/theme.css +512 -0
  54. package/core/render-cache.js +250 -212
  55. package/core/render.d.ts +25 -21
  56. package/core/render.js +738 -736
  57. package/core/router.d.ts +2 -3
  58. package/core/router.js +171 -171
  59. package/core/seo.js +10 -0
  60. package/core/spa.js +599 -0
  61. package/core/view-loader.js +155 -613
  62. package/core/vite-plugin.d.ts +18 -0
  63. package/core/vite-plugin.js +162 -0
  64. package/core/vite.js +250 -145
  65. package/index.js +22 -18
  66. package/jsconfig.json +5 -3
  67. package/package.json +114 -92
  68. package/production.md +8 -3
  69. package/public/js/bluebird.js +1886 -0
  70. package/templates/_auth/app/database.js +19 -0
  71. package/templates/_auth/app/models/user.js +22 -0
  72. package/templates/_auth/app/routes/auth-router.js +304 -0
  73. package/templates/_base/app/resources/html/layouts/main.html +55 -0
  74. package/templates/_base/app/resources/html/notFound.html +14 -0
  75. package/templates/_base/app/resources/index.html +27 -0
  76. package/templates/_base/app/resources/styles.css +9 -0
  77. package/templates/api/app/models/note.js +18 -0
  78. package/templates/api/app/routes/api.js +82 -0
  79. package/templates/api/app/routes/auth.js +11 -0
  80. package/templates/api/index.js +19 -0
  81. package/templates/api/template.json +13 -0
  82. package/templates/auth/app/mail.js +11 -0
  83. package/templates/auth/app/models/password_reset.js +18 -0
  84. package/templates/auth/app/resources/html/home.html +21 -0
  85. package/templates/auth/app/resources/html/partials/nav.html +2 -0
  86. package/templates/auth/app/resources/layouts/AppLayout.jsx +60 -0
  87. package/templates/auth/app/resources/main.jsx +18 -0
  88. package/templates/auth/app/resources/pages/Dashboard.jsx +51 -0
  89. package/templates/auth/app/resources/pages/ForgotPassword.jsx +34 -0
  90. package/templates/auth/app/resources/pages/Login.jsx +36 -0
  91. package/templates/auth/app/resources/pages/NotFound.jsx +16 -0
  92. package/templates/auth/app/resources/pages/Profile.jsx +99 -0
  93. package/templates/auth/app/resources/pages/Register.jsx +50 -0
  94. package/templates/auth/app/resources/pages/ResetPassword.jsx +50 -0
  95. package/templates/auth/app/resources/routes.jsx +54 -0
  96. package/templates/auth/app/resources/spa.js +29 -0
  97. package/templates/auth/app/routes/api.js +17 -0
  98. package/templates/auth/app/routes/auth.js +13 -0
  99. package/templates/auth/app/routes/web.js +21 -0
  100. package/templates/auth/index.js +19 -0
  101. package/templates/auth/template.json +15 -0
  102. package/templates/blank/app/models/.gitkeep +0 -0
  103. package/templates/blank/app/resources/html/home.html +27 -0
  104. package/templates/blank/app/resources/html/partials/nav.html +1 -0
  105. package/templates/blank/app/resources/main.jsx +16 -0
  106. package/templates/blank/app/resources/pages/Home.jsx +42 -0
  107. package/templates/blank/app/resources/pages/NotFound.jsx +27 -0
  108. package/templates/blank/app/resources/routes.jsx +15 -0
  109. package/templates/blank/app/resources/spa.js +24 -0
  110. package/templates/blank/app/routes/api.js +11 -0
  111. package/templates/blank/app/routes/web.js +21 -0
  112. package/templates/blank/index.js +13 -0
  113. package/templates/blank/template.json +12 -0
  114. package/templates/blog/app/lib/blog.js +149 -0
  115. package/templates/blog/app/models/post.js +22 -0
  116. package/templates/blog/app/resources/html/home.html +28 -0
  117. package/templates/blog/app/resources/html/not-found.html +5 -0
  118. package/templates/blog/app/resources/html/partials/nav.html +2 -0
  119. package/templates/blog/app/resources/html/partials/post-card.html +9 -0
  120. package/templates/blog/app/resources/html/post.html +8 -0
  121. package/templates/blog/app/resources/layouts/AdminLayout.jsx +54 -0
  122. package/templates/blog/app/resources/main.jsx +18 -0
  123. package/templates/blog/app/resources/pages/Login.jsx +31 -0
  124. package/templates/blog/app/resources/pages/NotFound.jsx +16 -0
  125. package/templates/blog/app/resources/pages/PostEditor.jsx +51 -0
  126. package/templates/blog/app/resources/pages/Posts.jsx +83 -0
  127. package/templates/blog/app/resources/pages/Register.jsx +43 -0
  128. package/templates/blog/app/resources/routes.jsx +51 -0
  129. package/templates/blog/app/resources/spa.js +25 -0
  130. package/templates/blog/app/resources/styles.css +40 -0
  131. package/templates/blog/app/routes/api.js +77 -0
  132. package/templates/blog/app/routes/auth.js +10 -0
  133. package/templates/blog/app/routes/web.js +114 -0
  134. package/templates/blog/index.js +21 -0
  135. package/templates/blog/template.json +14 -0
  136. package/vite.config.js +11 -0
  137. package/app/views/components/Header.jsx +0 -42
  138. package/app/views/components/LiveCounter.jsx +0 -67
  139. package/app/views/layouts/main/view.jsx +0 -201
  140. package/app/views/legal/terms.html +0 -29
  141. package/app/views/pages/about.jsx +0 -98
  142. package/app/views/pages/dashboard.jsx +0 -278
  143. package/app/views/pages/index.jsx +0 -123
  144. package/app/views/pages/login.jsx +0 -141
  145. package/core/actions.d.ts +0 -4
  146. package/core/actions.js +0 -355
  147. package/core/jsx.d.ts +0 -38
  148. package/core/jsx.js +0 -1597
  149. package/core/vite.d.ts +0 -3
  150. package/public/js/bluebird-client.js +0 -3265
  151. package/public/js/tailwind.js +0 -8
@@ -1,212 +1,250 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { getRedisClient } from "./cache.js";
4
- import Config from "./config.js";
5
-
6
- const props = Config.props();
7
- const DEBUG = props.debug;
8
- const PM2_INSTANCES = parseInt(process.env.PM2_INSTANCES || "1", 10);
9
- const RENDER_CACHE_MAX = parseInt(process.env.RENDER_CACHE_MAX || "500", 10);
10
- const RENDER_CACHE_TTL = parseInt(process.env.RENDER_CACHE_TTL || "300", 10);
11
-
12
- const isMultiInstance = PM2_INSTANCES > 1;
13
-
14
- /**
15
- * Resolves the writable render file cache directory.
16
- * @returns {string}
17
- */
18
- function getFileCacheDir() {
19
- return path.join(Config.userDataDir(), "app/cache");
20
- }
21
-
22
- let fileCacheEnabled = false;
23
-
24
- if (!DEBUG) {
25
- try {
26
- const cacheDir = getFileCacheDir();
27
- fs.mkdirSync(cacheDir, { recursive: true });
28
- fs.accessSync(cacheDir, fs.constants.W_OK);
29
- fileCacheEnabled = true;
30
- } catch {
31
- console.warn("[RENDER CACHE] app/cache/ is not writable — file cache disabled.");
32
- }
33
- }
34
-
35
- /**
36
- * In-memory LRU cache map.
37
- * @type {Map<string, {value: string, expiry: number}>}
38
- */
39
- const lru = new Map();
40
-
41
- /**
42
- * Evicts the oldest LRU entry when the cap is exceeded.
43
- */
44
- function evictLru() {
45
- if (lru.size >= RENDER_CACHE_MAX) {
46
- const key = lru.keys().next().value;
47
- if (key !== undefined) lru.delete(key);
48
- }
49
- }
50
-
51
- /**
52
- * Returns a safe filesystem key derived from the cache key string.
53
- * @param {string} key
54
- * @returns {string}
55
- */
56
- function toCacheFileName(key) {
57
- return key.replace(/[^a-z0-9_-]/gi, "_").substring(0, 200) + ".html";
58
- }
59
-
60
- /**
61
- * Reads a cached string from the file cache, respecting TTL.
62
- * @param {string} key
63
- * @returns {string|null}
64
- */
65
- function readFileCache(key) {
66
- if (!fileCacheEnabled) return null;
67
- const file = path.join(getFileCacheDir(), toCacheFileName(key));
68
- try {
69
- const stats = fs.statSync(file);
70
- const age = (Date.now() - stats.mtimeMs) / 1000;
71
- if (age > RENDER_CACHE_TTL) return null;
72
- return fs.readFileSync(file, "utf8");
73
- } catch {
74
- return null;
75
- }
76
- }
77
-
78
- /**
79
- * Writes a string to the file cache.
80
- * @param {string} key
81
- * @param {string} value
82
- */
83
- function writeFileCache(key, value) {
84
- if (!fileCacheEnabled) return;
85
- try {
86
- const file = path.join(getFileCacheDir(), toCacheFileName(key));
87
- fs.writeFileSync(file, value, "utf8");
88
- } catch {}
89
- }
90
-
91
- /**
92
- * Multi-layer rendering cache manager.
93
- * Provides L1 (In-Memory LRU), L2 (Redis), and L3 (File) caching layers.
94
- */
95
- export class RenderCache {
96
- /**
97
- * Looks up a cached HTML string across memory, Redis, and file cache.
98
- * @param {string} key - Cache key.
99
- * @returns {Promise<string|null>}
100
- */
101
- static async lookup(key) {
102
- const entry = lru.get(key);
103
- if (entry && entry.expiry > Date.now()) {
104
- lru.delete(key);
105
- lru.set(key, entry);
106
- return entry.value;
107
- }
108
- if (entry) lru.delete(key);
109
-
110
- if (isMultiInstance) {
111
- const redis = getRedisClient();
112
- if (redis) {
113
- try {
114
- const val = await redis.get(`render:${key}`);
115
- if (val) {
116
- evictLru();
117
- lru.set(key, { value: val, expiry: Date.now() + RENDER_CACHE_TTL * 1000 });
118
- return val;
119
- }
120
- } catch {}
121
- } else {
122
- const fromFile = readFileCache(key);
123
- if (fromFile) {
124
- evictLru();
125
- lru.set(key, { value: fromFile, expiry: Date.now() + RENDER_CACHE_TTL * 1000 });
126
- return fromFile;
127
- }
128
- }
129
- }
130
-
131
- return null;
132
- }
133
-
134
- /**
135
- * Stores a rendered string in all active cache layers.
136
- * @param {string} key - Cache key.
137
- * @param {string} value - HTML string to store.
138
- * @param {number} [ttl=RENDER_CACHE_TTL] - Time to live in seconds.
139
- * @returns {Promise<void>}
140
- */
141
- static async store(key, value, ttl = RENDER_CACHE_TTL) {
142
- evictLru();
143
- lru.set(key, { value, expiry: Date.now() + ttl * 1000 });
144
-
145
- if (isMultiInstance) {
146
- const redis = getRedisClient();
147
- if (redis) {
148
- try {
149
- await redis.set(`render:${key}`, value, { EX: ttl });
150
- return;
151
- } catch {}
152
- }
153
- writeFileCache(key, value);
154
- }
155
- }
156
-
157
- /**
158
- * Clears in-memory LRU cache.
159
- */
160
- static clearMemory() {
161
- lru.clear();
162
- }
163
-
164
- /**
165
- * Invalidates one or more keys across all cache layers.
166
- * @param {string|string[]} [keys]
167
- * @returns {Promise<void>}
168
- */
169
- static async invalidate(keys) {
170
- if (!keys) {
171
- lru.clear();
172
- return;
173
- }
174
-
175
- const list = Array.isArray(keys) ? keys : [keys];
176
- for (const key of list) {
177
- const viewKey = `view:${key}`;
178
- const routeKey = `route:${key}`;
179
- const partialRouteKey = `route:partial:${key}`;
180
- const fragmentKey = `fragment:${key}`;
181
-
182
- lru.delete(key);
183
- lru.delete(viewKey);
184
- lru.delete(routeKey);
185
- lru.delete(partialRouteKey);
186
- lru.delete(fragmentKey);
187
-
188
- const redis = getRedisClient();
189
- if (redis) {
190
- try {
191
- await redis.del(`render:${key}`);
192
- await redis.del(`render:${viewKey}`);
193
- await redis.del(`render:${routeKey}`);
194
- await redis.del(`render:${partialRouteKey}`);
195
- await redis.del(`render:${fragmentKey}`);
196
- } catch {}
197
- }
198
-
199
- if (fileCacheEnabled) {
200
- const cacheDir = getFileCacheDir();
201
- for (const k of [key, viewKey, routeKey, partialRouteKey, fragmentKey]) {
202
- try {
203
- const f = path.join(cacheDir, toCacheFileName(k));
204
- if (fs.existsSync(f)) fs.unlinkSync(f);
205
- } catch {}
206
- }
207
- }
208
- }
209
- }
210
- }
211
-
212
- export default RenderCache;
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { getRedisClient } from "./cache.js";
4
+ import Config from "./config.js";
5
+
6
+ const props = Config.props();
7
+ const DEBUG = props.debug;
8
+ const PM2_INSTANCES = parseInt(process.env.PM2_INSTANCES || "1", 10);
9
+ const RENDER_CACHE_MAX = parseInt(process.env.RENDER_CACHE_MAX || "500", 10);
10
+ const RENDER_CACHE_TTL = parseInt(process.env.RENDER_CACHE_TTL || "300", 10);
11
+
12
+ const isMultiInstance = PM2_INSTANCES > 1;
13
+
14
+ /**
15
+ * Resolves the writable render file cache directory.
16
+ * @returns {string}
17
+ */
18
+ function getFileCacheDir() {
19
+ return path.join(Config.userDataDir(), "app/cache");
20
+ }
21
+
22
+ let fileCacheEnabled = false;
23
+
24
+ if (!DEBUG) {
25
+ try {
26
+ const cacheDir = getFileCacheDir();
27
+ fs.mkdirSync(cacheDir, { recursive: true });
28
+ fs.accessSync(cacheDir, fs.constants.W_OK);
29
+ fileCacheEnabled = true;
30
+ } catch {
31
+ console.warn("[RENDER CACHE] app/cache/ is not writable — file cache disabled.");
32
+ }
33
+ }
34
+
35
+ const lru = new Map();
36
+
37
+ /**
38
+ * Evicts the oldest LRU entry when the cap is exceeded.
39
+ */
40
+ function evictLru() {
41
+ if (lru.size >= RENDER_CACHE_MAX) {
42
+ const key = lru.keys().next().value;
43
+ if (key !== undefined) lru.delete(key);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Returns a safe filesystem key derived from the cache key string.
49
+ * @param {string} key
50
+ * @returns {string}
51
+ */
52
+ function toCacheFileName(key) {
53
+ return key.replace(/[^a-z0-9_-]/gi, "_").substring(0, 200) + ".html";
54
+ }
55
+
56
+ /**
57
+ * Reads a cached string from the file cache, respecting custom or default TTL.
58
+ * @param {string} key
59
+ * @returns {{ value: string, expiry: number } | null}
60
+ */
61
+ function readFileCache(key) {
62
+ if (!fileCacheEnabled) return null;
63
+ const file = path.join(getFileCacheDir(), toCacheFileName(key));
64
+ try {
65
+ const stats = fs.statSync(file);
66
+ const raw = fs.readFileSync(file, "utf8");
67
+ const match = raw.match(/^<!--bb-exp:(\d+)-->\n/);
68
+ if (match) {
69
+ const expiry = parseInt(match[1], 10);
70
+ if (Date.now() > expiry) {
71
+ try {
72
+ fs.unlinkSync(file);
73
+ } catch {}
74
+ return null;
75
+ }
76
+ return { value: raw.slice(match[0].length), expiry };
77
+ }
78
+ const age = (Date.now() - stats.mtimeMs) / 1000;
79
+ if (age > RENDER_CACHE_TTL) return null;
80
+ return { value: raw, expiry: stats.mtimeMs + RENDER_CACHE_TTL * 1000 };
81
+ } catch {
82
+ return null;
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Writes a string to the file cache with embedded expiration metadata.
88
+ * @param {string} key
89
+ * @param {string} value
90
+ * @param {number} [expiry]
91
+ */
92
+ function writeFileCache(key, value, expiry) {
93
+ if (!fileCacheEnabled) return;
94
+ try {
95
+ const file = path.join(getFileCacheDir(), toCacheFileName(key));
96
+ const exp = expiry || Date.now() + RENDER_CACHE_TTL * 1000;
97
+ fs.writeFileSync(file, `<!--bb-exp:${exp}-->\n${value}`, "utf8");
98
+ } catch {}
99
+ }
100
+
101
+ /**
102
+ * Multi-layer rendering cache manager.
103
+ * Provides L1 (In-Memory LRU), L2 (Redis), and L3 (File) caching layers.
104
+ */
105
+ export class RenderCache {
106
+ /**
107
+ * Looks up a cached HTML string across memory, Redis, and file cache.
108
+ * @param {string} key - Cache key.
109
+ * @returns {Promise<string|null>}
110
+ */
111
+ static async lookup(key) {
112
+ const entry = lru.get(key);
113
+ if (entry && entry.expiry > Date.now()) {
114
+ lru.delete(key);
115
+ lru.set(key, entry);
116
+ return entry.value;
117
+ }
118
+ if (entry) lru.delete(key);
119
+
120
+ if (isMultiInstance) {
121
+ const redis = getRedisClient();
122
+ if (redis) {
123
+ try {
124
+ const val = await redis.get(`render:${key}`);
125
+ if (val) {
126
+ evictLru();
127
+ lru.set(key, { value: val, expiry: Date.now() + RENDER_CACHE_TTL * 1000 });
128
+ return val;
129
+ }
130
+ } catch {}
131
+ } else {
132
+ const fromFile = readFileCache(key);
133
+ if (fromFile) {
134
+ evictLru();
135
+ lru.set(key, fromFile);
136
+ return fromFile.value;
137
+ }
138
+ }
139
+ }
140
+
141
+ return null;
142
+ }
143
+
144
+ /**
145
+ * Stores a rendered string in all active cache layers.
146
+ * @param {string} key - Cache key.
147
+ * @param {string} value - HTML string to store.
148
+ * @param {number} [ttl=RENDER_CACHE_TTL] - Time to live in seconds.
149
+ * @returns {Promise<void>}
150
+ */
151
+ static async store(key, value, ttl = RENDER_CACHE_TTL) {
152
+ const expiry = Date.now() + ttl * 1000;
153
+ evictLru();
154
+ lru.set(key, { value, expiry });
155
+
156
+ if (isMultiInstance) {
157
+ const redis = getRedisClient();
158
+ if (redis) {
159
+ try {
160
+ await redis.set(`render:${key}`, value, { EX: ttl });
161
+ return;
162
+ } catch {}
163
+ }
164
+ writeFileCache(key, value, expiry);
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Clears in-memory LRU cache.
170
+ */
171
+ static clearMemory() {
172
+ lru.clear();
173
+ }
174
+
175
+ /**
176
+ * Invalidates one or more keys across all cache layers, including query/URL variants.
177
+ * @param {string|string[]} [keys]
178
+ * @returns {Promise<void>}
179
+ */
180
+ static async invalidate(keys) {
181
+ if (!keys) {
182
+ lru.clear();
183
+ return;
184
+ }
185
+
186
+ const list = Array.isArray(keys) ? keys : [keys];
187
+ const redis = getRedisClient();
188
+ const cacheDir = fileCacheEnabled ? getFileCacheDir() : null;
189
+ let cacheFiles = null;
190
+ if (cacheDir) {
191
+ try {
192
+ cacheFiles = fs.readdirSync(cacheDir);
193
+ } catch {
194
+ cacheFiles = [];
195
+ }
196
+ }
197
+
198
+ for (const key of list) {
199
+ const prefixes = [
200
+ key,
201
+ `view:${key}`,
202
+ `route:${key}`,
203
+ `spa:${key}`,
204
+ `fragment:${key}`,
205
+ ];
206
+ const matches = (existingKey) =>
207
+ prefixes.some(
208
+ (p) =>
209
+ existingKey === p ||
210
+ existingKey.startsWith(`${p}:`) ||
211
+ existingKey.startsWith(`${p}?`) ||
212
+ existingKey.startsWith(`${p}#`)
213
+ );
214
+
215
+ for (const existingKey of Array.from(lru.keys())) {
216
+ if (matches(existingKey)) lru.delete(existingKey);
217
+ }
218
+
219
+ if (redis) {
220
+ try {
221
+ for (const p of prefixes) {
222
+ await redis.del(`render:${p}`);
223
+ if (typeof redis.scanIterator === "function") {
224
+ for (const sep of [":", "?", "#"]) {
225
+ const pattern = `render:${p.replace(/[*?[\]\\]/g, "\\$&")}${sep === "?" ? "\\?" : sep}*`;
226
+ for await (const found of redis.scanIterator({ MATCH: pattern, COUNT: 200 })) {
227
+ const batch = Array.isArray(found) ? found : [found];
228
+ if (batch.length > 0) await redis.del(batch);
229
+ }
230
+ }
231
+ }
232
+ }
233
+ } catch {}
234
+ }
235
+
236
+ if (cacheDir && cacheFiles) {
237
+ const fileStems = prefixes.map((p) => toCacheFileName(p).slice(0, -".html".length));
238
+ for (const file of cacheFiles) {
239
+ const stem = file.slice(0, -".html".length);
240
+ if (!fileStems.some((f) => stem === f || stem.startsWith(`${f}_`))) continue;
241
+ try {
242
+ fs.unlinkSync(path.join(cacheDir, file));
243
+ } catch {}
244
+ }
245
+ }
246
+ }
247
+ }
248
+ }
249
+
250
+ export default RenderCache;
package/core/render.d.ts CHANGED
@@ -1,21 +1,25 @@
1
- import {
2
- Render,
3
- RenderIslandOptions,
4
- RenderHtmlOptions,
5
- IslandComponentProps,
6
- h,
7
- Fragment,
8
- Island,
9
- Client,
10
- } from "./index.js";
11
- export default Render;
12
- export {
13
- Render,
14
- RenderIslandOptions,
15
- RenderHtmlOptions,
16
- IslandComponentProps,
17
- h,
18
- Fragment,
19
- Island,
20
- Client,
21
- };
1
+ import type { NextFunction, Request, RequestHandler, Response } from "express";
2
+
3
+ export interface RenderOptions {
4
+ layout?: string | false;
5
+ cache?: number;
6
+ ttl?: number;
7
+ query?: string[];
8
+ cacheQuery?: string[];
9
+ raw?: boolean;
10
+ }
11
+
12
+ export class Render {
13
+ static renderString(template: string, data?: Record<string, any>, ctx?: Record<string, any>): Promise<string>;
14
+ static component(viewName: string, data?: Record<string, any>, ctx?: Record<string, any>): Promise<string>;
15
+ static html(res: Response, viewName: string, data?: Record<string, any>, options?: number | RenderOptions): Promise<any>;
16
+ static send(res: Response, viewName: string, data?: Record<string, any>, ttlOrOptions?: number | RenderOptions): Promise<any>;
17
+ static partial(res: Response, partialName: string, data?: Record<string, any>): Promise<any>;
18
+ static view(viewName: string, dataOrFn?: Record<string, any> | ((req: Request, res: Response) => any), options?: number | RenderOptions): RequestHandler;
19
+ static cache(seconds?: number, options?: { allowAuthenticated?: boolean; query?: string[] }): (req: Request, res: Response, next: NextFunction) => Promise<any>;
20
+ static redirect(req: Request, res: Response, url: string, status?: number): void;
21
+ static clearTemplateCache(): void;
22
+ static invalidate(keys?: string | string[]): Promise<void>;
23
+ }
24
+
25
+ export default Render;