@riebeckite/honox 0.0.50 → 0.0.51
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/index.js +51 -10
- package/dist/src/content_assets.d.ts +5 -0
- package/package.json +14 -9
package/dist/index.js
CHANGED
|
@@ -1915,17 +1915,27 @@ function riebeckiteContentAssets(options) {
|
|
|
1915
1915
|
let cachedManifest;
|
|
1916
1916
|
let cachedAssets = {
|
|
1917
1917
|
paths: /* @__PURE__ */ new Set(),
|
|
1918
|
-
generated: /* @__PURE__ */ new Map()
|
|
1918
|
+
generated: /* @__PURE__ */ new Map(),
|
|
1919
|
+
deferred: /* @__PURE__ */ new Map()
|
|
1919
1920
|
};
|
|
1921
|
+
const deferredContents = /* @__PURE__ */ new Map();
|
|
1920
1922
|
const resolvePublicAssets = async () => {
|
|
1921
1923
|
const module = await loadContentModule(server, options.appRoot());
|
|
1922
1924
|
const manifest = await module.content?.getManifest?.();
|
|
1923
|
-
if (!manifest)
|
|
1925
|
+
if (!manifest) {
|
|
1926
|
+
return {
|
|
1927
|
+
paths: /* @__PURE__ */ new Set(),
|
|
1928
|
+
generated: /* @__PURE__ */ new Map(),
|
|
1929
|
+
deferred: /* @__PURE__ */ new Map()
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1924
1932
|
if (manifest !== cachedManifest) {
|
|
1925
1933
|
cachedManifest = manifest;
|
|
1934
|
+
deferredContents.clear();
|
|
1926
1935
|
cachedAssets = {
|
|
1927
1936
|
paths: collectPublicImagePaths(manifest),
|
|
1928
|
-
generated: collectGeneratedImageContents(manifest)
|
|
1937
|
+
generated: collectGeneratedImageContents(manifest),
|
|
1938
|
+
deferred: collectDeferredGeneratedImages(manifest)
|
|
1929
1939
|
};
|
|
1930
1940
|
}
|
|
1931
1941
|
return cachedAssets;
|
|
@@ -1952,7 +1962,8 @@ function riebeckiteContentAssets(options) {
|
|
|
1952
1962
|
}
|
|
1953
1963
|
const available = await resolvePublicAssets();
|
|
1954
1964
|
const generated = available.generated.get(logicalPath);
|
|
1955
|
-
|
|
1965
|
+
const deferred = available.deferred.get(logicalPath);
|
|
1966
|
+
if (generated === void 0 && deferred === void 0 && !available.paths.has(logicalPath)) {
|
|
1956
1967
|
next();
|
|
1957
1968
|
return;
|
|
1958
1969
|
}
|
|
@@ -1964,6 +1975,15 @@ function riebeckiteContentAssets(options) {
|
|
|
1964
1975
|
sendImage(request, response, contentType, generated);
|
|
1965
1976
|
return;
|
|
1966
1977
|
}
|
|
1978
|
+
if (deferred !== void 0) {
|
|
1979
|
+
const content2 = await resolveDeferredImage(
|
|
1980
|
+
deferredContents,
|
|
1981
|
+
logicalPath,
|
|
1982
|
+
deferred
|
|
1983
|
+
);
|
|
1984
|
+
sendImage(request, response, contentType, content2);
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1967
1987
|
const file = path7.join(contentRoot, logicalPath);
|
|
1968
1988
|
if (!isPathInsideDirectory(contentRoot, file)) {
|
|
1969
1989
|
next();
|
|
@@ -2002,6 +2022,28 @@ function collectGeneratedImageContents(manifest) {
|
|
|
2002
2022
|
}
|
|
2003
2023
|
return contents;
|
|
2004
2024
|
}
|
|
2025
|
+
function collectDeferredGeneratedImages(manifest) {
|
|
2026
|
+
const outputs = /* @__PURE__ */ new Map();
|
|
2027
|
+
for (const output of manifest.generatedOutputs ?? []) {
|
|
2028
|
+
if (!output.generate) continue;
|
|
2029
|
+
const normalized = normalizeContentPath(output.path);
|
|
2030
|
+
if (!imageContentType(normalized)) continue;
|
|
2031
|
+
outputs.set(normalized, { generate: output.generate });
|
|
2032
|
+
}
|
|
2033
|
+
return outputs;
|
|
2034
|
+
}
|
|
2035
|
+
async function resolveDeferredImage(cache, logicalPath, output) {
|
|
2036
|
+
const cached = cache.get(logicalPath);
|
|
2037
|
+
if (cached) return await cached;
|
|
2038
|
+
const content = Promise.resolve().then(output.generate);
|
|
2039
|
+
cache.set(logicalPath, content);
|
|
2040
|
+
try {
|
|
2041
|
+
return await content;
|
|
2042
|
+
} catch (error) {
|
|
2043
|
+
cache.delete(logicalPath);
|
|
2044
|
+
throw error;
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2005
2047
|
async function collectSiteOwnedOutputPaths(publicDir) {
|
|
2006
2048
|
const paths = /* @__PURE__ */ new Set();
|
|
2007
2049
|
if (!publicDir) return paths;
|
|
@@ -3826,6 +3868,7 @@ function riebeckite(options = {}, onApplicationResolved) {
|
|
|
3826
3868
|
const { appRoot } = requireApplication(application);
|
|
3827
3869
|
if (!isContentModuleLoaded(server, appRoot)) return void 0;
|
|
3828
3870
|
const module = await loadContentModule(server, appRoot);
|
|
3871
|
+
await module.content?.getManifest?.();
|
|
3829
3872
|
return module.content?.getCompletedBuildSnapshot?.();
|
|
3830
3873
|
}
|
|
3831
3874
|
}),
|
|
@@ -3840,6 +3883,7 @@ function riebeckite(options = {}, onApplicationResolved) {
|
|
|
3840
3883
|
const { appRoot } = requireApplication(application);
|
|
3841
3884
|
if (!isContentModuleLoaded(server, appRoot)) return void 0;
|
|
3842
3885
|
const module = await loadContentModule(server, appRoot);
|
|
3886
|
+
await module.content?.getManifest?.();
|
|
3843
3887
|
return module.content?.getCompletedBuildSnapshot?.();
|
|
3844
3888
|
}
|
|
3845
3889
|
})
|
|
@@ -3854,12 +3898,9 @@ function riebeckiteContentWarmup(enabled, getApplication) {
|
|
|
3854
3898
|
server.httpServer.once("listening", () => {
|
|
3855
3899
|
const { appRoot } = getApplication();
|
|
3856
3900
|
void loadContentModule(server, appRoot).then(async (module) => await module.content?.getManifest?.()).catch((error) => {
|
|
3857
|
-
server.config.logger.error(
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
3861
|
-
}
|
|
3862
|
-
);
|
|
3901
|
+
server.config.logger.error("Riebeckite content warmup failed.", {
|
|
3902
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
3903
|
+
});
|
|
3863
3904
|
});
|
|
3864
3905
|
});
|
|
3865
3906
|
}
|
|
@@ -11,6 +11,10 @@ type ContentAssetEntry = {
|
|
|
11
11
|
type GeneratedOutputEntry = {
|
|
12
12
|
path: string;
|
|
13
13
|
content?: Uint8Array | string;
|
|
14
|
+
generate?: () => Uint8Array | string | Promise<Uint8Array | string>;
|
|
15
|
+
};
|
|
16
|
+
type DeferredGeneratedImage = {
|
|
17
|
+
generate: () => Uint8Array | string | Promise<Uint8Array | string>;
|
|
14
18
|
};
|
|
15
19
|
export type PublicContentManifest = {
|
|
16
20
|
publicEntries?: ReadonlyArray<ContentAssetEntry>;
|
|
@@ -19,6 +23,7 @@ export type PublicContentManifest = {
|
|
|
19
23
|
export declare function riebeckiteContentAssets(options: RiebeckiteContentAssetsOptions): Plugin;
|
|
20
24
|
export declare function collectPublicImagePaths(manifest: PublicContentManifest): Set<string>;
|
|
21
25
|
export declare function collectGeneratedImageContents(manifest: PublicContentManifest): Map<string, Uint8Array | string>;
|
|
26
|
+
export declare function collectDeferredGeneratedImages(manifest: PublicContentManifest): Map<string, DeferredGeneratedImage>;
|
|
22
27
|
export declare function collectSiteOwnedOutputPaths(publicDir: string | false | undefined): Promise<Set<string>>;
|
|
23
28
|
export declare function toContentPath(url: string | undefined, base: string): string | undefined;
|
|
24
29
|
export declare function imageContentType(logicalPath: string): string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/honox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.51",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,12 +44,16 @@
|
|
|
44
44
|
"hono": "^4.13.18",
|
|
45
45
|
"honox": "0.1.62",
|
|
46
46
|
"vite": "^8.3.5",
|
|
47
|
-
"@riebeckite/dev-inspector": "0.0.
|
|
48
|
-
"@riebeckite/
|
|
49
|
-
"@riebeckite/
|
|
50
|
-
"@riebeckite/
|
|
51
|
-
"@riebeckite/
|
|
52
|
-
"@riebeckite/
|
|
47
|
+
"@riebeckite/dev-inspector": "0.0.51",
|
|
48
|
+
"@riebeckite/plugin-color-mode": "0.0.51",
|
|
49
|
+
"@riebeckite/node": "0.0.51",
|
|
50
|
+
"@riebeckite/og-image": "0.0.51",
|
|
51
|
+
"@riebeckite/runtime": "0.0.51",
|
|
52
|
+
"@riebeckite/ui": "0.0.51",
|
|
53
|
+
"@riebeckite/spa": "0.0.51"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@riebeckite/core": "^0.0.51"
|
|
53
57
|
},
|
|
54
58
|
"devDependencies": {
|
|
55
59
|
"@d2lang/d2": "^0.1.34",
|
|
@@ -57,8 +61,9 @@
|
|
|
57
61
|
"@hono/vite-build": "^1.11.1",
|
|
58
62
|
"@marp-team/marp-core": "^4.4.0",
|
|
59
63
|
"tsx": "^4.22.4",
|
|
60
|
-
"@riebeckite/
|
|
61
|
-
"@riebeckite/plugin-bases": "0.0.
|
|
64
|
+
"@riebeckite/core": "0.0.51",
|
|
65
|
+
"@riebeckite/plugin-bases": "0.0.51",
|
|
66
|
+
"@riebeckite/test": "0.0.51"
|
|
62
67
|
},
|
|
63
68
|
"publishConfig": {
|
|
64
69
|
"access": "public"
|