@teyik0/furin 0.4.0-alpha.2 → 0.5.0-alpha.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.
- package/dist/build/compile-entry.d.ts +2 -1
- package/dist/build/compile-entry.ts +17 -13
- package/dist/build/elysia-aot.d.ts +9 -0
- package/dist/build/entry-template.d.ts +5 -1
- package/dist/build/entry-template.ts +27 -6
- package/dist/build/index.js +969 -528
- package/dist/build/private-server-sourcemaps.d.ts +2 -0
- package/dist/build/server-app-entry.d.ts +12 -0
- package/dist/build/types.d.ts +2 -0
- package/dist/cache.d.ts +1 -0
- package/dist/cache.js +185 -0
- package/dist/cli/index.js +983 -541
- package/dist/client/document.d.ts +2 -0
- package/dist/client/internal/runtime-types.d.ts +8 -1
- package/dist/client/link.js +232 -11
- package/dist/client/sync.d.ts +1 -0
- package/dist/client.js +11 -0
- package/dist/config.d.ts +28 -22
- package/dist/config.js +25 -2
- package/dist/define-route.d.ts +273 -1009
- package/dist/furin.d.ts +20 -5
- package/dist/furin.js +6431 -5457
- package/dist/plugin/routes.d.ts +6 -0
- package/dist/rsc-client.js +9 -1
- package/dist/rsc.js +19 -7
- package/dist/server/assets/production.d.ts +3 -0
- package/dist/server/auto-invalidate/plugin.d.ts +8 -24
- package/dist/server/auto-invalidate/runtime.d.ts +2 -2
- package/dist/server/browser-events/shutdown.d.ts +3 -0
- package/dist/server/cache/invalidation.d.ts +1 -1
- package/dist/server/cache/page-cache-state.d.ts +5 -0
- package/dist/server/cache/page-cache.d.ts +53 -0
- package/dist/server/cache/redis/index.d.ts +41 -0
- package/dist/server/cache/redis/index.js +451 -0
- package/dist/server/cache/redis/scripts.d.ts +6 -0
- package/dist/server/context-logger.d.ts +2 -2
- package/dist/server/dev/plugin.d.ts +1 -0
- package/dist/server/dev/runtime.production.d.ts +1 -0
- package/dist/server/dev-page-plugin.d.ts +7 -0
- package/dist/server/evlog.d.ts +14 -0
- package/dist/server/internal.d.ts +6 -0
- package/dist/server/internal.js +2539 -0
- package/dist/server/production-server.d.ts +13 -0
- package/dist/server/production-server.js +2906 -0
- package/dist/server/render/not-found.d.ts +1 -1
- package/dist/server/render/ssg.d.ts +5 -0
- package/dist/server/render/static-params.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +1 -1
- package/dist/server/router/hmr.d.ts +6 -0
- package/dist/server/router/hmr.production.d.ts +5 -0
- package/dist/server/router/plugin.d.ts +5 -1
- package/dist/server/router/schemas.d.ts +1 -0
- package/dist/server/sync/index.js +798 -117
- package/dist/server/sync/plugin.d.ts +31 -158
- package/dist/server/sync/stream.d.ts +38 -49
- package/dist/shared/elysia-contract.d.ts +8 -14
- package/dist/shared/production-build.d.ts +2 -0
- package/package.json +19 -8
- package/src/adapter/README.md +9 -2
- package/src/adapter/bun.ts +146 -41
- package/src/adapter/package.ts +6 -2
- package/src/adapter/runtime-build.ts +11 -4
- package/src/adapter/static.ts +8 -6
- package/src/adapter/vercel.ts +64 -31
- package/src/build/client.ts +18 -1
- package/src/build/compile-entry.ts +17 -13
- package/src/build/elysia-aot.ts +102 -0
- package/src/build/entry-template.ts +27 -6
- package/src/build/hydrate.ts +5 -1
- package/src/build/index.ts +5 -5
- package/src/build/private-server-sourcemaps.ts +20 -0
- package/src/build/production-instrumentation.ts +2 -2
- package/src/build/server-app-entry.ts +61 -0
- package/src/build/shared.ts +3 -1
- package/src/build/ssg-cache.ts +5 -10
- package/src/build/types.ts +2 -0
- package/src/build/virtual-entry.ts +5 -4
- package/src/cache.ts +12 -0
- package/src/cli/config.ts +3 -3
- package/src/cli/index.ts +6 -2
- package/src/client/document.tsx +19 -0
- package/src/client/internal/runtime-types.ts +10 -1
- package/src/client/sync.ts +1 -0
- package/src/config.ts +33 -4
- package/src/define-route.ts +266 -128
- package/src/furin.ts +168 -154
- package/src/plugin/route-config-autofix.ts +11 -2
- package/src/plugin/routes.ts +85 -29
- package/src/rsc/codec.ts +11 -6
- package/src/rsc/render-error.ts +3 -1
- package/src/server/assets/production.ts +99 -0
- package/src/server/auto-invalidate/plugin.ts +4 -4
- package/src/server/auto-invalidate/runtime.ts +74 -42
- package/src/server/browser-events/plugin.ts +13 -1
- package/src/server/browser-events/shutdown.ts +32 -0
- package/src/server/cache/invalidation.ts +61 -20
- package/src/server/cache/page-cache-state.ts +22 -0
- package/src/server/cache/page-cache.ts +300 -0
- package/src/server/cache/redis/index.ts +367 -0
- package/src/server/cache/redis/scripts.ts +200 -0
- package/src/server/context-logger.ts +5 -5
- package/src/server/dev/plugin.ts +10 -1
- package/src/server/dev/runtime.production.ts +4 -0
- package/src/server/dev-page-plugin.ts +54 -10
- package/src/server/evlog.ts +106 -0
- package/src/server/internal.ts +7 -0
- package/src/server/production-server.ts +135 -0
- package/src/server/render/document.tsx +7 -1
- package/src/server/render/isr.ts +480 -132
- package/src/server/render/loaders.ts +18 -12
- package/src/server/render/not-found.ts +4 -4
- package/src/server/render/ppr-document.ts +2 -2
- package/src/server/render/ppr-route.ts +193 -7
- package/src/server/render/ssg.ts +148 -4
- package/src/server/render/ssr.ts +6 -7
- package/src/server/render/static-params.ts +174 -0
- package/src/server/render/template.ts +5 -1
- package/src/server/router/defined-route.ts +2 -1
- package/src/server/router/discovery.ts +3 -1
- package/src/server/router/hmr.production.ts +11 -0
- package/src/server/router/hmr.ts +85 -76
- package/src/server/router/plugin.ts +118 -50
- package/src/server/router/schema-merge.ts +10 -3
- package/src/server/router/schemas.ts +174 -61
- package/src/server/sync/plugin.ts +14 -10
- package/src/server/sync/response.ts +3 -3
- package/src/server/sync/stream.ts +43 -2
- package/src/shared/elysia-contract.ts +23 -25
- package/src/shared/production-build.ts +20 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/server/cache/redis/scripts.ts
|
|
3
|
+
var ACQUIRE_PAGE_CACHE_LEASE_SCRIPT = `
|
|
4
|
+
local raw = redis.call('GET', KEYS[1])
|
|
5
|
+
local now_parts = redis.call('TIME')
|
|
6
|
+
local now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)
|
|
7
|
+
if raw then
|
|
8
|
+
local active = cjson.decode(raw)
|
|
9
|
+
if active.expiresAt > now then return nil end
|
|
10
|
+
if active.indexMember then redis.call('ZREM', KEYS[4], active.indexMember) end
|
|
11
|
+
for _, key in ipairs(active.tagLeaseKeys or {}) do
|
|
12
|
+
redis.call('ZREM', key, active.indexMember)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
local fence = redis.call('INCR', KEYS[2])
|
|
16
|
+
redis.call('PEXPIRE', KEYS[2], ARGV[4])
|
|
17
|
+
local fields = cjson.decode(ARGV[3])
|
|
18
|
+
local values = {}
|
|
19
|
+
for index, field in ipairs(fields) do
|
|
20
|
+
values[index] = tonumber(redis.call('HGET', KEYS[3], field) or '0')
|
|
21
|
+
end
|
|
22
|
+
redis.call('PEXPIRE', KEYS[3], ARGV[4])
|
|
23
|
+
local tag_lease_keys = {}
|
|
24
|
+
for index = 5, #KEYS do table.insert(tag_lease_keys, KEYS[index]) end
|
|
25
|
+
local lease = {
|
|
26
|
+
tagLeaseKeys = tag_lease_keys,
|
|
27
|
+
expiresAt = now + tonumber(ARGV[2]),
|
|
28
|
+
fence = fence,
|
|
29
|
+
fields = fields,
|
|
30
|
+
id = ARGV[1],
|
|
31
|
+
indexMember = cjson.encode({id = ARGV[1], path = ARGV[5], tags = cjson.decode(ARGV[6])}),
|
|
32
|
+
values = values
|
|
33
|
+
}
|
|
34
|
+
redis.call('SET', KEYS[1], cjson.encode(lease), 'PX', ARGV[2])
|
|
35
|
+
redis.call('ZREMRANGEBYSCORE', KEYS[4], '-inf', now)
|
|
36
|
+
redis.call('ZADD', KEYS[4], lease.expiresAt, lease.indexMember)
|
|
37
|
+
redis.call('PEXPIRE', KEYS[4], ARGV[4])
|
|
38
|
+
for _, key in ipairs(tag_lease_keys) do
|
|
39
|
+
redis.call('ZREMRANGEBYSCORE', key, '-inf', now)
|
|
40
|
+
redis.call('ZADD', key, lease.expiresAt, lease.indexMember)
|
|
41
|
+
redis.call('PEXPIRE', key, ARGV[4])
|
|
42
|
+
end
|
|
43
|
+
return cjson.encode(lease)
|
|
44
|
+
`;
|
|
45
|
+
var COMMIT_PAGE_CACHE_ENTRY_SCRIPT = `
|
|
46
|
+
local raw = redis.call('GET', KEYS[1])
|
|
47
|
+
if not raw then return 'superseded' end
|
|
48
|
+
local lease = cjson.decode(raw)
|
|
49
|
+
local now_parts = redis.call('TIME')
|
|
50
|
+
local now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)
|
|
51
|
+
if lease.id ~= ARGV[1] or lease.fence ~= tonumber(ARGV[2]) or lease.expiresAt <= now then
|
|
52
|
+
return 'superseded'
|
|
53
|
+
end
|
|
54
|
+
for index, field in ipairs(lease.fields) do
|
|
55
|
+
local current = tonumber(redis.call('HGET', KEYS[3], field) or '0')
|
|
56
|
+
if current ~= lease.values[index] then
|
|
57
|
+
redis.call('DEL', KEYS[1])
|
|
58
|
+
if lease.indexMember then redis.call('ZREM', KEYS[5], lease.indexMember) end
|
|
59
|
+
for _, key in ipairs(lease.tagLeaseKeys or {}) do redis.call('ZREM', key, lease.indexMember) end
|
|
60
|
+
return 'superseded'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
local previous_raw = redis.call('GET', KEYS[2])
|
|
64
|
+
if previous_raw then
|
|
65
|
+
local previous = cjson.decode(previous_raw)
|
|
66
|
+
if previous.indexMember then
|
|
67
|
+
redis.call('ZREM', previous.pathsKey, previous.indexMember)
|
|
68
|
+
for _, tag_key in ipairs(previous.tagKeys) do
|
|
69
|
+
redis.call('ZREM', tag_key, previous.indexMember)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
local expires_at = now + tonumber(ARGV[5])
|
|
74
|
+
redis.call('SET', KEYS[2], ARGV[3], 'PX', ARGV[5])
|
|
75
|
+
redis.call('ZREMRANGEBYSCORE', KEYS[4], '-inf', now)
|
|
76
|
+
redis.call('ZADD', KEYS[4], expires_at, ARGV[4])
|
|
77
|
+
redis.call('PEXPIRE', KEYS[4], ARGV[6])
|
|
78
|
+
for index = 6, #KEYS do
|
|
79
|
+
redis.call('ZREMRANGEBYSCORE', KEYS[index], '-inf', now)
|
|
80
|
+
redis.call('ZADD', KEYS[index], expires_at, ARGV[4])
|
|
81
|
+
redis.call('PEXPIRE', KEYS[index], ARGV[6])
|
|
82
|
+
end
|
|
83
|
+
redis.call('PEXPIRE', KEYS[3], ARGV[6])
|
|
84
|
+
redis.call('DEL', KEYS[1])
|
|
85
|
+
if lease.indexMember then redis.call('ZREM', KEYS[5], lease.indexMember) end
|
|
86
|
+
for _, key in ipairs(lease.tagLeaseKeys or {}) do redis.call('ZREM', key, lease.indexMember) end
|
|
87
|
+
return 'stored'
|
|
88
|
+
`;
|
|
89
|
+
var READ_PAGE_CACHE_ENTRY_SCRIPT = `
|
|
90
|
+
local raw = redis.call('GET', KEYS[1])
|
|
91
|
+
if not raw then return nil end
|
|
92
|
+
local value = cjson.decode(raw)
|
|
93
|
+
for index, field in ipairs(value.fields) do
|
|
94
|
+
local current = tonumber(redis.call('HGET', KEYS[2], field) or '0')
|
|
95
|
+
if current ~= value.values[index] then
|
|
96
|
+
redis.call('DEL', KEYS[1])
|
|
97
|
+
if value.indexMember then
|
|
98
|
+
redis.call('ZREM', value.pathsKey, value.indexMember)
|
|
99
|
+
for _, tag_key in ipairs(value.tagKeys) do
|
|
100
|
+
redis.call('ZREM', tag_key, value.indexMember)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
return nil
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
return raw
|
|
107
|
+
`;
|
|
108
|
+
var RELEASE_PAGE_CACHE_LEASE_SCRIPT = `
|
|
109
|
+
local raw = redis.call('GET', KEYS[1])
|
|
110
|
+
if not raw then return 0 end
|
|
111
|
+
local lease = cjson.decode(raw)
|
|
112
|
+
if lease.id == ARGV[1] and lease.fence == tonumber(ARGV[2]) then
|
|
113
|
+
if lease.indexMember then redis.call('ZREM', KEYS[2], lease.indexMember) end
|
|
114
|
+
for _, key in ipairs(lease.tagLeaseKeys or {}) do redis.call('ZREM', key, lease.indexMember) end
|
|
115
|
+
return redis.call('DEL', KEYS[1])
|
|
116
|
+
end
|
|
117
|
+
return 0
|
|
118
|
+
`;
|
|
119
|
+
var INVALIDATE_PAGE_CACHE_PATH_SCRIPT = `
|
|
120
|
+
redis.call('HINCRBY', KEYS[1], ARGV[1], 1)
|
|
121
|
+
redis.call('PEXPIRE', KEYS[1], ARGV[4])
|
|
122
|
+
local now_parts = redis.call('TIME')
|
|
123
|
+
local now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)
|
|
124
|
+
redis.call('ZREMRANGEBYSCORE', KEYS[2], '-inf', now)
|
|
125
|
+
local members = redis.call('ZRANGE', KEYS[2], 0, -1)
|
|
126
|
+
local seen = {}
|
|
127
|
+
local affected = {}
|
|
128
|
+
local function matches_path(path)
|
|
129
|
+
if path == ARGV[2] then return true end
|
|
130
|
+
return ARGV[3] == 'layout' and (ARGV[2] == '/' or string.sub(path, 1, string.len(ARGV[2]) + 1) == ARGV[2] .. '/')
|
|
131
|
+
end
|
|
132
|
+
for _, member in ipairs(members) do
|
|
133
|
+
local index = cjson.decode(member)
|
|
134
|
+
if matches_path(index.path) then
|
|
135
|
+
redis.call('DEL', index.entryKey)
|
|
136
|
+
redis.call('ZREM', index.pathsKey, member)
|
|
137
|
+
for _, tag_key in ipairs(index.tagKeys) do
|
|
138
|
+
redis.call('ZREM', tag_key, member)
|
|
139
|
+
end
|
|
140
|
+
if not seen[index.path] then
|
|
141
|
+
seen[index.path] = true
|
|
142
|
+
table.insert(affected, index.path)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
redis.call('ZREMRANGEBYSCORE', KEYS[3], '-inf', now)
|
|
147
|
+
for _, member in ipairs(redis.call('ZRANGE', KEYS[3], 0, -1)) do
|
|
148
|
+
local lease = cjson.decode(member)
|
|
149
|
+
if matches_path(lease.path) and not seen[lease.path] then
|
|
150
|
+
seen[lease.path] = true
|
|
151
|
+
table.insert(affected, lease.path)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
return affected
|
|
155
|
+
`;
|
|
156
|
+
var INVALIDATE_PAGE_CACHE_TAGS_SCRIPT = `
|
|
157
|
+
local tags = cjson.decode(ARGV[1])
|
|
158
|
+
for _, tag in ipairs(tags) do
|
|
159
|
+
redis.call('HINCRBY', KEYS[1], 'tag:' .. tag, 1)
|
|
160
|
+
end
|
|
161
|
+
redis.call('PEXPIRE', KEYS[1], ARGV[2])
|
|
162
|
+
local now_parts = redis.call('TIME')
|
|
163
|
+
local now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)
|
|
164
|
+
local seen_members = {}
|
|
165
|
+
local seen_paths = {}
|
|
166
|
+
local affected = {}
|
|
167
|
+
for key_index = 4, 3 + #tags do
|
|
168
|
+
redis.call('ZREMRANGEBYSCORE', KEYS[key_index], '-inf', now)
|
|
169
|
+
local members = redis.call('ZRANGE', KEYS[key_index], 0, -1)
|
|
170
|
+
for _, member in ipairs(members) do
|
|
171
|
+
if not seen_members[member] then
|
|
172
|
+
seen_members[member] = true
|
|
173
|
+
local index = cjson.decode(member)
|
|
174
|
+
redis.call('DEL', index.entryKey)
|
|
175
|
+
redis.call('ZREM', index.pathsKey, member)
|
|
176
|
+
for _, tag_key in ipairs(index.tagKeys) do
|
|
177
|
+
redis.call('ZREM', tag_key, member)
|
|
178
|
+
end
|
|
179
|
+
if not seen_paths[index.path] then
|
|
180
|
+
seen_paths[index.path] = true
|
|
181
|
+
table.insert(affected, index.path)
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
for key_index = 4 + #tags, #KEYS do
|
|
187
|
+
redis.call('ZREMRANGEBYSCORE', KEYS[key_index], '-inf', now)
|
|
188
|
+
for _, member in ipairs(redis.call('ZRANGE', KEYS[key_index], 0, -1)) do
|
|
189
|
+
local lease = cjson.decode(member)
|
|
190
|
+
if not seen_paths[lease.path] then
|
|
191
|
+
seen_paths[lease.path] = true
|
|
192
|
+
table.insert(affected, lease.path)
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
return affected
|
|
197
|
+
`;
|
|
198
|
+
|
|
199
|
+
// src/server/cache/redis/index.ts
|
|
200
|
+
var TRAILING_SLASHES = /\/+$/;
|
|
201
|
+
var DEFAULT_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
202
|
+
var METADATA_GRACE_MS = 24 * 60 * 60 * 1000;
|
|
203
|
+
function assertNamespace(namespace) {
|
|
204
|
+
if (namespace.length === 0) {
|
|
205
|
+
throw new Error("[furin-page-cache-redis] namespace must not be empty.");
|
|
206
|
+
}
|
|
207
|
+
if (!namespace.isWellFormed()) {
|
|
208
|
+
throw new Error("[furin-page-cache-redis] namespace must contain valid Unicode.");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function digest(value) {
|
|
212
|
+
return new Bun.CryptoHasher("sha256").update(value).digest("hex");
|
|
213
|
+
}
|
|
214
|
+
function identityDigest(identity) {
|
|
215
|
+
return digest(JSON.stringify([identity.scope, identity.buildId, identity.mode, identity.key]));
|
|
216
|
+
}
|
|
217
|
+
function layoutPaths(path) {
|
|
218
|
+
if (path === "/") {
|
|
219
|
+
return ["/"];
|
|
220
|
+
}
|
|
221
|
+
const paths = ["/"];
|
|
222
|
+
let current = "";
|
|
223
|
+
for (const segment of path.split("/").filter(Boolean)) {
|
|
224
|
+
current += `/${segment}`;
|
|
225
|
+
paths.push(current);
|
|
226
|
+
}
|
|
227
|
+
return paths;
|
|
228
|
+
}
|
|
229
|
+
function normalizeInvalidationPath(path) {
|
|
230
|
+
return path.length > 1 ? path.replace(TRAILING_SLASHES, "") : path;
|
|
231
|
+
}
|
|
232
|
+
function selectorFields(identity) {
|
|
233
|
+
return [
|
|
234
|
+
`page:${identity.path}`,
|
|
235
|
+
...layoutPaths(identity.path).map((path) => `layout:${path}`),
|
|
236
|
+
...identity.tags.map((tag) => `tag:${tag}`)
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
function stringResult(value, operation) {
|
|
240
|
+
if (typeof value !== "string") {
|
|
241
|
+
throw new Error(`[furin-page-cache-redis] Invalid ${operation} response.`);
|
|
242
|
+
}
|
|
243
|
+
return value;
|
|
244
|
+
}
|
|
245
|
+
function stringArrayResult(value, operation) {
|
|
246
|
+
if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) {
|
|
247
|
+
throw new Error(`[furin-page-cache-redis] Invalid ${operation} response.`);
|
|
248
|
+
}
|
|
249
|
+
return value;
|
|
250
|
+
}
|
|
251
|
+
function parseLease(raw) {
|
|
252
|
+
const value = JSON.parse(raw);
|
|
253
|
+
if (typeof value !== "object" || value === null || !("expiresAt" in value) || typeof value.expiresAt !== "number" || !("fence" in value) || typeof value.fence !== "number" || !("fields" in value) || !Array.isArray(value.fields) || value.fields.some((field) => typeof field !== "string") || !("id" in value) || typeof value.id !== "string" || !("values" in value) || !Array.isArray(value.values) || value.values.some((revision) => typeof revision !== "number")) {
|
|
254
|
+
throw new Error("[furin-page-cache-redis] Invalid lease document.");
|
|
255
|
+
}
|
|
256
|
+
return value;
|
|
257
|
+
}
|
|
258
|
+
function parseEntry(raw) {
|
|
259
|
+
const value = JSON.parse(raw);
|
|
260
|
+
if (typeof value !== "object" || value === null || !("entry" in value) || typeof value.entry !== "object" || value.entry === null || !("cachedAt" in value.entry) || typeof value.entry.cachedAt !== "number" || !("payload" in value.entry) || typeof value.entry.payload !== "string" || !("revalidate" in value.entry) || typeof value.entry.revalidate !== "number" && value.entry.revalidate !== null) {
|
|
261
|
+
throw new Error("[furin-page-cache-redis] Invalid cache entry document.");
|
|
262
|
+
}
|
|
263
|
+
return value.entry;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
class RedisPageCache {
|
|
267
|
+
client;
|
|
268
|
+
metadataRetentionMs;
|
|
269
|
+
prefix;
|
|
270
|
+
retentionMs;
|
|
271
|
+
constructor(options) {
|
|
272
|
+
assertNamespace(options.namespace);
|
|
273
|
+
const retentionMs = options.retentionMs ?? DEFAULT_RETENTION_MS;
|
|
274
|
+
if (!Number.isSafeInteger(retentionMs) || retentionMs <= 0 || retentionMs > Number.MAX_SAFE_INTEGER - METADATA_GRACE_MS) {
|
|
275
|
+
throw new Error("[furin-page-cache-redis] retentionMs must be a positive safe integer.");
|
|
276
|
+
}
|
|
277
|
+
this.client = options.client;
|
|
278
|
+
this.prefix = `furin:page:{${encodeURIComponent(options.namespace)}}`;
|
|
279
|
+
this.retentionMs = retentionMs;
|
|
280
|
+
this.metadataRetentionMs = retentionMs + METADATA_GRACE_MS;
|
|
281
|
+
}
|
|
282
|
+
async acquire({
|
|
283
|
+
identity,
|
|
284
|
+
leaseMs
|
|
285
|
+
}) {
|
|
286
|
+
const id = crypto.randomUUID();
|
|
287
|
+
const keys = [
|
|
288
|
+
this.leaseKey(identity),
|
|
289
|
+
this.fenceKey(identity),
|
|
290
|
+
this.versionsKey(identity.scope),
|
|
291
|
+
this.leasesKey(identity.scope),
|
|
292
|
+
...[...new Set(identity.tags)].map((tag) => this.tagLeasesKey(identity.scope, tag))
|
|
293
|
+
];
|
|
294
|
+
const raw = await this.client.send("EVAL", [
|
|
295
|
+
ACQUIRE_PAGE_CACHE_LEASE_SCRIPT,
|
|
296
|
+
String(keys.length),
|
|
297
|
+
...keys,
|
|
298
|
+
id,
|
|
299
|
+
String(leaseMs),
|
|
300
|
+
JSON.stringify(selectorFields(identity)),
|
|
301
|
+
String(this.metadataRetentionMs),
|
|
302
|
+
identity.path,
|
|
303
|
+
JSON.stringify(identity.tags)
|
|
304
|
+
]);
|
|
305
|
+
if (raw === null) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
const lease = parseLease(stringResult(raw, "lease acquisition"));
|
|
309
|
+
return {
|
|
310
|
+
expiresAt: lease.expiresAt,
|
|
311
|
+
fence: lease.fence,
|
|
312
|
+
id: lease.id,
|
|
313
|
+
revision: JSON.stringify(lease.values)
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
async commit({
|
|
317
|
+
entry,
|
|
318
|
+
identity,
|
|
319
|
+
lease
|
|
320
|
+
}) {
|
|
321
|
+
const tagKeys = [...new Set(identity.tags)].map((tag) => this.tagPathsKey(identity.scope, tag));
|
|
322
|
+
const entryKey = this.entryKey(identity);
|
|
323
|
+
const pathsKey = this.pathsKey(identity.scope);
|
|
324
|
+
const indexMember = JSON.stringify({
|
|
325
|
+
entryKey,
|
|
326
|
+
path: identity.path,
|
|
327
|
+
pathsKey,
|
|
328
|
+
tagKeys
|
|
329
|
+
});
|
|
330
|
+
const document = {
|
|
331
|
+
entry,
|
|
332
|
+
fields: selectorFields(identity),
|
|
333
|
+
indexMember,
|
|
334
|
+
pathsKey,
|
|
335
|
+
tagKeys,
|
|
336
|
+
values: JSON.parse(lease.revision)
|
|
337
|
+
};
|
|
338
|
+
const keys = [
|
|
339
|
+
this.leaseKey(identity),
|
|
340
|
+
entryKey,
|
|
341
|
+
this.versionsKey(identity.scope),
|
|
342
|
+
pathsKey,
|
|
343
|
+
this.leasesKey(identity.scope),
|
|
344
|
+
...tagKeys
|
|
345
|
+
];
|
|
346
|
+
const result = await this.client.send("EVAL", [
|
|
347
|
+
COMMIT_PAGE_CACHE_ENTRY_SCRIPT,
|
|
348
|
+
String(keys.length),
|
|
349
|
+
...keys,
|
|
350
|
+
lease.id,
|
|
351
|
+
String(lease.fence),
|
|
352
|
+
JSON.stringify(document),
|
|
353
|
+
indexMember,
|
|
354
|
+
String(this.retentionMs),
|
|
355
|
+
String(this.metadataRetentionMs)
|
|
356
|
+
]);
|
|
357
|
+
if (result === "stored" || result === "superseded") {
|
|
358
|
+
return result;
|
|
359
|
+
}
|
|
360
|
+
throw new Error("[furin-page-cache-redis] Invalid cache commit response.");
|
|
361
|
+
}
|
|
362
|
+
async invalidate(input) {
|
|
363
|
+
if (input.kind === "path") {
|
|
364
|
+
const path = normalizeInvalidationPath(input.path);
|
|
365
|
+
const result = stringArrayResult(await this.client.send("EVAL", [
|
|
366
|
+
INVALIDATE_PAGE_CACHE_PATH_SCRIPT,
|
|
367
|
+
"3",
|
|
368
|
+
this.versionsKey(input.scope),
|
|
369
|
+
this.pathsKey(input.scope),
|
|
370
|
+
this.leasesKey(input.scope),
|
|
371
|
+
`${input.type}:${path}`,
|
|
372
|
+
path,
|
|
373
|
+
input.type,
|
|
374
|
+
String(this.metadataRetentionMs)
|
|
375
|
+
]), "path invalidation");
|
|
376
|
+
return { invalidated: result.length > 0, paths: result };
|
|
377
|
+
}
|
|
378
|
+
const tags = [...new Set(input.tags)];
|
|
379
|
+
const keys = [
|
|
380
|
+
this.versionsKey(input.scope),
|
|
381
|
+
this.pathsKey(input.scope),
|
|
382
|
+
this.leasesKey(input.scope),
|
|
383
|
+
...tags.map((tag) => this.tagPathsKey(input.scope, tag)),
|
|
384
|
+
...tags.map((tag) => this.tagLeasesKey(input.scope, tag))
|
|
385
|
+
];
|
|
386
|
+
const result = stringArrayResult(await this.client.send("EVAL", [
|
|
387
|
+
INVALIDATE_PAGE_CACHE_TAGS_SCRIPT,
|
|
388
|
+
String(keys.length),
|
|
389
|
+
...keys,
|
|
390
|
+
JSON.stringify(tags),
|
|
391
|
+
String(this.metadataRetentionMs)
|
|
392
|
+
]), "tag invalidation");
|
|
393
|
+
return { invalidated: result.length > 0, paths: result };
|
|
394
|
+
}
|
|
395
|
+
async read(identity) {
|
|
396
|
+
const raw = await this.client.send("EVAL", [
|
|
397
|
+
READ_PAGE_CACHE_ENTRY_SCRIPT,
|
|
398
|
+
"2",
|
|
399
|
+
this.entryKey(identity),
|
|
400
|
+
this.versionsKey(identity.scope)
|
|
401
|
+
]);
|
|
402
|
+
if (raw === null) {
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
return parseEntry(stringResult(raw, "cache read"));
|
|
406
|
+
}
|
|
407
|
+
async release({
|
|
408
|
+
identity,
|
|
409
|
+
lease
|
|
410
|
+
}) {
|
|
411
|
+
await this.client.send("EVAL", [
|
|
412
|
+
RELEASE_PAGE_CACHE_LEASE_SCRIPT,
|
|
413
|
+
"2",
|
|
414
|
+
this.leaseKey(identity),
|
|
415
|
+
this.leasesKey(identity.scope),
|
|
416
|
+
lease.id,
|
|
417
|
+
String(lease.fence)
|
|
418
|
+
]);
|
|
419
|
+
}
|
|
420
|
+
entryKey(identity) {
|
|
421
|
+
return `${this.prefix}:entry:${identityDigest(identity)}`;
|
|
422
|
+
}
|
|
423
|
+
fenceKey(identity) {
|
|
424
|
+
return `${this.prefix}:fence:${identityDigest(identity)}`;
|
|
425
|
+
}
|
|
426
|
+
leaseKey(identity) {
|
|
427
|
+
return `${this.prefix}:lease:${identityDigest(identity)}`;
|
|
428
|
+
}
|
|
429
|
+
pathsKey(scope) {
|
|
430
|
+
return `${this.prefix}:paths:${digest(scope)}`;
|
|
431
|
+
}
|
|
432
|
+
leasesKey(scope) {
|
|
433
|
+
return `${this.prefix}:leases:${digest(scope)}`;
|
|
434
|
+
}
|
|
435
|
+
tagPathsKey(scope, tag) {
|
|
436
|
+
return `${this.prefix}:tag-paths:${digest(scope)}:${digest(tag)}`;
|
|
437
|
+
}
|
|
438
|
+
tagLeasesKey(scope, tag) {
|
|
439
|
+
return `${this.prefix}:tag-leases:${digest(scope)}:${digest(tag)}`;
|
|
440
|
+
}
|
|
441
|
+
versionsKey(scope) {
|
|
442
|
+
return `${this.prefix}:versions:${digest(scope)}`;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
function redisPageCache(options) {
|
|
446
|
+
return new RedisPageCache(options);
|
|
447
|
+
}
|
|
448
|
+
export {
|
|
449
|
+
RedisPageCache,
|
|
450
|
+
redisPageCache
|
|
451
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const ACQUIRE_PAGE_CACHE_LEASE_SCRIPT = "\nlocal raw = redis.call('GET', KEYS[1])\nlocal now_parts = redis.call('TIME')\nlocal now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)\nif raw then\n local active = cjson.decode(raw)\n if active.expiresAt > now then return nil end\n if active.indexMember then redis.call('ZREM', KEYS[4], active.indexMember) end\n for _, key in ipairs(active.tagLeaseKeys or {}) do\n redis.call('ZREM', key, active.indexMember)\n end\nend\nlocal fence = redis.call('INCR', KEYS[2])\nredis.call('PEXPIRE', KEYS[2], ARGV[4])\nlocal fields = cjson.decode(ARGV[3])\nlocal values = {}\nfor index, field in ipairs(fields) do\n values[index] = tonumber(redis.call('HGET', KEYS[3], field) or '0')\nend\nredis.call('PEXPIRE', KEYS[3], ARGV[4])\nlocal tag_lease_keys = {}\nfor index = 5, #KEYS do table.insert(tag_lease_keys, KEYS[index]) end\nlocal lease = {\n tagLeaseKeys = tag_lease_keys,\n expiresAt = now + tonumber(ARGV[2]),\n fence = fence,\n fields = fields,\n id = ARGV[1],\n indexMember = cjson.encode({id = ARGV[1], path = ARGV[5], tags = cjson.decode(ARGV[6])}),\n values = values\n}\nredis.call('SET', KEYS[1], cjson.encode(lease), 'PX', ARGV[2])\nredis.call('ZREMRANGEBYSCORE', KEYS[4], '-inf', now)\nredis.call('ZADD', KEYS[4], lease.expiresAt, lease.indexMember)\nredis.call('PEXPIRE', KEYS[4], ARGV[4])\nfor _, key in ipairs(tag_lease_keys) do\n redis.call('ZREMRANGEBYSCORE', key, '-inf', now)\n redis.call('ZADD', key, lease.expiresAt, lease.indexMember)\n redis.call('PEXPIRE', key, ARGV[4])\nend\nreturn cjson.encode(lease)\n";
|
|
2
|
+
export declare const COMMIT_PAGE_CACHE_ENTRY_SCRIPT = "\nlocal raw = redis.call('GET', KEYS[1])\nif not raw then return 'superseded' end\nlocal lease = cjson.decode(raw)\nlocal now_parts = redis.call('TIME')\nlocal now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)\nif lease.id ~= ARGV[1] or lease.fence ~= tonumber(ARGV[2]) or lease.expiresAt <= now then\n return 'superseded'\nend\nfor index, field in ipairs(lease.fields) do\n local current = tonumber(redis.call('HGET', KEYS[3], field) or '0')\n if current ~= lease.values[index] then\n redis.call('DEL', KEYS[1])\n if lease.indexMember then redis.call('ZREM', KEYS[5], lease.indexMember) end\n for _, key in ipairs(lease.tagLeaseKeys or {}) do redis.call('ZREM', key, lease.indexMember) end\n return 'superseded'\n end\nend\nlocal previous_raw = redis.call('GET', KEYS[2])\nif previous_raw then\n local previous = cjson.decode(previous_raw)\n if previous.indexMember then\n redis.call('ZREM', previous.pathsKey, previous.indexMember)\n for _, tag_key in ipairs(previous.tagKeys) do\n redis.call('ZREM', tag_key, previous.indexMember)\n end\n end\nend\nlocal expires_at = now + tonumber(ARGV[5])\nredis.call('SET', KEYS[2], ARGV[3], 'PX', ARGV[5])\nredis.call('ZREMRANGEBYSCORE', KEYS[4], '-inf', now)\nredis.call('ZADD', KEYS[4], expires_at, ARGV[4])\nredis.call('PEXPIRE', KEYS[4], ARGV[6])\nfor index = 6, #KEYS do\n redis.call('ZREMRANGEBYSCORE', KEYS[index], '-inf', now)\n redis.call('ZADD', KEYS[index], expires_at, ARGV[4])\n redis.call('PEXPIRE', KEYS[index], ARGV[6])\nend\nredis.call('PEXPIRE', KEYS[3], ARGV[6])\nredis.call('DEL', KEYS[1])\nif lease.indexMember then redis.call('ZREM', KEYS[5], lease.indexMember) end\nfor _, key in ipairs(lease.tagLeaseKeys or {}) do redis.call('ZREM', key, lease.indexMember) end\nreturn 'stored'\n";
|
|
3
|
+
export declare const READ_PAGE_CACHE_ENTRY_SCRIPT = "\nlocal raw = redis.call('GET', KEYS[1])\nif not raw then return nil end\nlocal value = cjson.decode(raw)\nfor index, field in ipairs(value.fields) do\n local current = tonumber(redis.call('HGET', KEYS[2], field) or '0')\n if current ~= value.values[index] then\n redis.call('DEL', KEYS[1])\n if value.indexMember then\n redis.call('ZREM', value.pathsKey, value.indexMember)\n for _, tag_key in ipairs(value.tagKeys) do\n redis.call('ZREM', tag_key, value.indexMember)\n end\n end\n return nil\n end\nend\nreturn raw\n";
|
|
4
|
+
export declare const RELEASE_PAGE_CACHE_LEASE_SCRIPT = "\nlocal raw = redis.call('GET', KEYS[1])\nif not raw then return 0 end\nlocal lease = cjson.decode(raw)\nif lease.id == ARGV[1] and lease.fence == tonumber(ARGV[2]) then\n if lease.indexMember then redis.call('ZREM', KEYS[2], lease.indexMember) end\n for _, key in ipairs(lease.tagLeaseKeys or {}) do redis.call('ZREM', key, lease.indexMember) end\n return redis.call('DEL', KEYS[1])\nend\nreturn 0\n";
|
|
5
|
+
export declare const INVALIDATE_PAGE_CACHE_PATH_SCRIPT = "\nredis.call('HINCRBY', KEYS[1], ARGV[1], 1)\nredis.call('PEXPIRE', KEYS[1], ARGV[4])\nlocal now_parts = redis.call('TIME')\nlocal now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)\nredis.call('ZREMRANGEBYSCORE', KEYS[2], '-inf', now)\nlocal members = redis.call('ZRANGE', KEYS[2], 0, -1)\nlocal seen = {}\nlocal affected = {}\nlocal function matches_path(path)\n if path == ARGV[2] then return true end\n return ARGV[3] == 'layout' and (ARGV[2] == '/' or string.sub(path, 1, string.len(ARGV[2]) + 1) == ARGV[2] .. '/')\nend\nfor _, member in ipairs(members) do\n local index = cjson.decode(member)\n if matches_path(index.path) then\n redis.call('DEL', index.entryKey)\n redis.call('ZREM', index.pathsKey, member)\n for _, tag_key in ipairs(index.tagKeys) do\n redis.call('ZREM', tag_key, member)\n end\n if not seen[index.path] then\n seen[index.path] = true\n table.insert(affected, index.path)\n end\n end\nend\nredis.call('ZREMRANGEBYSCORE', KEYS[3], '-inf', now)\nfor _, member in ipairs(redis.call('ZRANGE', KEYS[3], 0, -1)) do\n local lease = cjson.decode(member)\n if matches_path(lease.path) and not seen[lease.path] then\n seen[lease.path] = true\n table.insert(affected, lease.path)\n end\nend\nreturn affected\n";
|
|
6
|
+
export declare const INVALIDATE_PAGE_CACHE_TAGS_SCRIPT = "\nlocal tags = cjson.decode(ARGV[1])\nfor _, tag in ipairs(tags) do\n redis.call('HINCRBY', KEYS[1], 'tag:' .. tag, 1)\nend\nredis.call('PEXPIRE', KEYS[1], ARGV[2])\nlocal now_parts = redis.call('TIME')\nlocal now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)\nlocal seen_members = {}\nlocal seen_paths = {}\nlocal affected = {}\nfor key_index = 4, 3 + #tags do\n redis.call('ZREMRANGEBYSCORE', KEYS[key_index], '-inf', now)\n local members = redis.call('ZRANGE', KEYS[key_index], 0, -1)\n for _, member in ipairs(members) do\n if not seen_members[member] then\n seen_members[member] = true\n local index = cjson.decode(member)\n redis.call('DEL', index.entryKey)\n redis.call('ZREM', index.pathsKey, member)\n for _, tag_key in ipairs(index.tagKeys) do\n redis.call('ZREM', tag_key, member)\n end\n if not seen_paths[index.path] then\n seen_paths[index.path] = true\n table.insert(affected, index.path)\n end\n end\n end\nend\nfor key_index = 4 + #tags, #KEYS do\n redis.call('ZREMRANGEBYSCORE', KEYS[key_index], '-inf', now)\n for _, member in ipairs(redis.call('ZRANGE', KEYS[key_index], 0, -1)) do\n local lease = cjson.decode(member)\n if not seen_paths[lease.path] then\n seen_paths[lease.path] = true\n table.insert(affected, lease.path)\n end\n end\nend\nreturn affected\n";
|
|
@@ -13,12 +13,12 @@ export { createLogger };
|
|
|
13
13
|
* Import from `@teyik0/furin` instead of `evlog/elysia` so this fallback chain
|
|
14
14
|
* applies in all rendering contexts.
|
|
15
15
|
*/
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function getLogger(): RequestLogger;
|
|
17
17
|
/**
|
|
18
18
|
* Runs `fn` inside a synthetic render scope.
|
|
19
19
|
*
|
|
20
20
|
* Creates a detached `createLogger()` instance for the duration of `fn`.
|
|
21
|
-
* `
|
|
21
|
+
* `getLogger()` calls inside `fn` (including user loaders) return this logger
|
|
22
22
|
* instead of throwing. On completion, the accumulated wide event is emitted to
|
|
23
23
|
* the global drain with the provided initial context (e.g. route pattern).
|
|
24
24
|
*
|
|
@@ -2,6 +2,7 @@ import { type AnyElysia } from "elysia";
|
|
|
2
2
|
import type { DevDiagnosticEvent } from "../../shared/dev-diagnostics.ts";
|
|
3
3
|
import type { FurinInstance } from "../instance.ts";
|
|
4
4
|
import { type DevDiagnosticStore } from "./diagnostics.ts";
|
|
5
|
+
export declare const extensionErrorFilterScript = "window.addEventListener(\"unhandledrejection\", (event) => {\n const stack = event.reason?.stack;\n if (typeof stack !== \"string\") return;\n const firstFrame = stack.match(/^(?:\\s*at [^\\n]*|[^\\n]*@[^\\n]*)/m)?.[0];\n if (firstFrame && /\\b(?:chrome|moz)-extension:\\/\\//.test(firstFrame)) {\n event.stopImmediatePropagation();\n }\n}, true);";
|
|
5
6
|
export declare function createDevDiagnosticPlugin(store: DevDiagnosticStore, instance: FurinInstance | undefined, reconcileRoutes: (() => Promise<void>) | undefined): AnyElysia;
|
|
6
7
|
export declare function injectDevDiagnosticClient(html: string, basePath: string): string;
|
|
7
8
|
export declare function renderDevDiagnosticResponse(event: Extract<DevDiagnosticEvent, {
|
|
@@ -2,4 +2,5 @@ import { type AnyElysia } from "elysia";
|
|
|
2
2
|
export declare function createDevDiagnosticPlugin(_store: undefined, _instance: unknown, _reconcileRoutes: unknown): AnyElysia;
|
|
3
3
|
export declare function createDevelopmentBrowserEventSources(_instance: unknown, _diagnostics: undefined): readonly never[];
|
|
4
4
|
export declare function devDiagnosticStore(): undefined;
|
|
5
|
+
export declare function devGraph(): never;
|
|
5
6
|
export declare function injectDevDiagnosticClient(html: string, _basePath: string): string;
|
|
@@ -53,6 +53,10 @@
|
|
|
53
53
|
* rewritten while string literals in non-import positions are left untouched.
|
|
54
54
|
*/
|
|
55
55
|
export declare const WORKSPACE_SOURCE_FILTER: RegExp;
|
|
56
|
+
interface CachedDevPageContents {
|
|
57
|
+
contents: string;
|
|
58
|
+
moduleIdentity: string;
|
|
59
|
+
}
|
|
56
60
|
/** Converts a native absolute path to Bun's cross-platform import format. */
|
|
57
61
|
export declare function toImportSpecifier(filePath: string): string;
|
|
58
62
|
/**
|
|
@@ -115,4 +119,7 @@ export declare function transformDevSource(raw: string, filePath: string, option
|
|
|
115
119
|
rewriteBareImports: boolean;
|
|
116
120
|
rewriteRelativeImports: boolean;
|
|
117
121
|
}): string;
|
|
122
|
+
/** @internal exported for testing */
|
|
123
|
+
export declare function loadDevPageContents(filePath: string, moduleIdentity: string, transformedSourceCache: Map<string, CachedDevPageContents>): Promise<string>;
|
|
118
124
|
export declare function registerDevPagePlugin(): void;
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RequestLogger } from "evlog";
|
|
2
|
+
import { type BaseEvlogOptions } from "evlog/toolkit";
|
|
3
|
+
export type FurinEvlogOptions = BaseEvlogOptions;
|
|
4
|
+
export declare const getRequestLogger: <T extends object = Record<string, unknown>>() => import("evlog").AuditableLogger<T>;
|
|
5
|
+
export declare function setRuntimeEvlogWaitUntil(waitUntil: NonNullable<FurinEvlogOptions["waitUntil"]>): () => void;
|
|
6
|
+
/** Elysia 2-native evlog integration built on evlog's public adapter toolkit. */
|
|
7
|
+
export declare function createFurinEvlog(options: FurinEvlogOptions): import("elysia/types").GlobalHookReturn<"", "local", import("elysia").DefaultSingleton, {
|
|
8
|
+
typebox: {};
|
|
9
|
+
error: [];
|
|
10
|
+
}, import("elysia").DefaultMetadata, {}, import("elysia").DefaultEphemeral, import("elysia").DefaultEphemeral, import("elysia/types").ExtractErrorFromHandle<{
|
|
11
|
+
readonly log: RequestLogger<Record<string, unknown>>;
|
|
12
|
+
}>, {
|
|
13
|
+
readonly log: RequestLogger<Record<string, unknown>>;
|
|
14
|
+
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AnyElysia } from "elysia";
|
|
2
2
|
import type { SsgCacheEntry } from "./cache/index.ts";
|
|
3
3
|
import { type RuntimeCacheProvider } from "./cache/runtime-cache.ts";
|
|
4
|
+
import { setRuntimeEvlogWaitUntil as installRuntimeEvlogWaitUntil } from "./evlog.ts";
|
|
4
5
|
import { restorePprResumeRequest as restoreResumeRequest } from "./render/ppr-request.ts";
|
|
5
6
|
export interface EmbeddedAppData {
|
|
6
7
|
clientDir: string;
|
|
@@ -13,8 +14,12 @@ export interface CompileContextRoute {
|
|
|
13
14
|
}
|
|
14
15
|
export interface CompileContext {
|
|
15
16
|
buildId?: string;
|
|
17
|
+
/** Runtime directory containing this app's disk-served client assets. */
|
|
18
|
+
clientDir?: string;
|
|
16
19
|
/** Whether the emitted hydration client sends browser log batches. */
|
|
17
20
|
clientLogging?: boolean;
|
|
21
|
+
/** Deployment adapter that owns public page caching for this build. */
|
|
22
|
+
deploymentTarget?: "vercel";
|
|
18
23
|
embedded?: EmbeddedAppData;
|
|
19
24
|
modules: Record<string, unknown>;
|
|
20
25
|
/** Elysia-native route tree generated for this mounted app. */
|
|
@@ -47,6 +52,7 @@ export declare function waitForPendingISRRevalidations(): Promise<void>;
|
|
|
47
52
|
export declare function hasPendingISRRevalidations(): boolean;
|
|
48
53
|
export declare function markExternalPrerenderRequest(request: Request): Request;
|
|
49
54
|
export declare function setRuntimeCacheProvider(provider: RuntimeCacheProvider): void;
|
|
55
|
+
export declare const setRuntimeEvlogWaitUntil: typeof installRuntimeEvlogWaitUntil;
|
|
50
56
|
export declare function setCacheTagPurger(purger: (tags: string[]) => Promise<void>): void;
|
|
51
57
|
export declare const restorePprResumeRequest: typeof restoreResumeRequest;
|
|
52
58
|
export declare function __setCompileContext(ctx: CompileContext): void;
|