@riebeckite/core 0.0.18 → 0.0.19

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.d.ts CHANGED
@@ -44,8 +44,8 @@ export type { CreatePluginMemoOptions, PluginMemo, } from "./src/plugin/plugin_m
44
44
  export { createPluginMemo, stableStringify, } from "./src/plugin/plugin_memo.js";
45
45
  export { resolveBuildOutputDirectory, resolveManagedStateRoot, } from "./src/project/project_layout.js";
46
46
  export type { ConfigValidationIssue, PluginOptionsValidator, } from "./src/types/config_validation.js";
47
- export type { ContentAsset, ContentBodySlot, ContentLink, ContentLinkKind, ContentLocationInput, ContentManifest, ContentManifestEntry, ContentManifestPluginClientEntry, ContentPublicLocation, ContentRedirect, FolderLocation, PluginPageRoute, } from "./src/types/content_manifest.js";
48
- export { appendContentBodySlot } from "./src/types/content_manifest.js";
47
+ export type { ContentAsset, ContentBodySlot, ContentBodySlots, ContentLink, ContentLinkKind, ContentLocationInput, ContentManifest, ContentManifestEntry, ContentManifestPluginClientEntry, ContentPublicLocation, ContentRedirect, FolderLocation, PluginPageRoute, } from "./src/types/content_manifest.js";
48
+ export { ARTICLE_SLOT, appendContentBodySlot, } from "./src/types/content_manifest.js";
49
49
  export type { Diagnostic, DiagnosticCode, DiagnosticSeverity, } from "./src/types/diagnostic.js";
50
50
  export type { ContentAssetOutputInput, GeneratedOutput, GeneratedOutputContent, GeneratedOutputInput, GeneratedOutputSink, } from "./src/types/generated_output.js";
51
51
  export { createUnavailableGeneratedOutputSink, normalizeContentAssetOutputPath, normalizeGeneratedOutputPath, } from "./src/types/generated_output.js";
package/dist/index.js CHANGED
@@ -1766,7 +1766,14 @@ function createPersistentContentCache(options) {
1766
1766
  );
1767
1767
  return void 0;
1768
1768
  }
1769
- throw error;
1769
+ logger?.warn(
1770
+ "Persistent content cache entry could not be read and will be ignored.",
1771
+ {
1772
+ key,
1773
+ error: error instanceof Error ? error.message : String(error)
1774
+ }
1775
+ );
1776
+ return void 0;
1770
1777
  }
1771
1778
  },
1772
1779
  async set(key, value) {
@@ -1778,8 +1785,18 @@ function createPersistentContentCache(options) {
1778
1785
  "Persistent content cache values must be JSON serializable."
1779
1786
  );
1780
1787
  }
1781
- await writeAtomically(filePath, versionDir, serialized);
1782
- tracer?.event("persistentContentCache.write", { key });
1788
+ try {
1789
+ await writeAtomically(filePath, versionDir, serialized);
1790
+ tracer?.event("persistentContentCache.write", { key });
1791
+ } catch (error) {
1792
+ logger?.warn(
1793
+ "Persistent content cache entry could not be written and will be ignored.",
1794
+ {
1795
+ key,
1796
+ error: error instanceof Error ? error.message : String(error)
1797
+ }
1798
+ );
1799
+ }
1783
1800
  },
1784
1801
  async clear() {
1785
1802
  try {
@@ -3680,9 +3697,14 @@ var ContentEntryReader = class {
3680
3697
  if (cached) return cached;
3681
3698
  const content = this.source.read(entry).then(
3682
3699
  (value) => typeof value === "string" ? value : new TextDecoder().decode(value)
3683
- ).finally(() => this.texts.delete(entry.path));
3684
- this.texts.set(entry.path, content);
3685
- return content;
3700
+ );
3701
+ const retain = entry.path.endsWith(".md");
3702
+ const tracked = retain ? content : content.finally(() => this.texts.delete(entry.path));
3703
+ this.texts.set(entry.path, tracked);
3704
+ return tracked;
3705
+ }
3706
+ clearReadCache() {
3707
+ this.texts.clear();
3686
3708
  }
3687
3709
  };
3688
3710
 
@@ -4650,6 +4672,7 @@ var ContentManager = class {
4650
4672
  return { entries, contentIndex, diagnostics };
4651
4673
  }
4652
4674
  async dispose() {
4675
+ this.entryReader.clearReadCache();
4653
4676
  if (!this.contentIndex) return;
4654
4677
  await this.pluginRuntime.dispose(this.contentIndex);
4655
4678
  }
@@ -5148,6 +5171,14 @@ function resolveBuildOutputDirectory(config) {
5148
5171
  }
5149
5172
 
5150
5173
  // src/types/content_manifest.ts
5174
+ var ARTICLE_SLOT = {
5175
+ header: "article.header",
5176
+ metadata: "article.metadata",
5177
+ aside: "article.aside",
5178
+ beforeContent: "article.before-content",
5179
+ afterContent: "article.after-content",
5180
+ footer: "article.footer"
5181
+ };
5151
5182
  function appendContentBodySlot(entry, slot, html) {
5152
5183
  if (!html.trim()) return;
5153
5184
  const previous = entry.bodySlots?.[slot];
@@ -5199,6 +5230,7 @@ function calculateReadingTime(html) {
5199
5230
  return Math.max(1, Math.ceil(cjkCharacters / 500 + latinWords / 220));
5200
5231
  }
5201
5232
  export {
5233
+ ARTICLE_SLOT,
5202
5234
  ATTACHMENTS_BASE_PATH,
5203
5235
  CompositeTraceSink,
5204
5236
  ConfigValidationError,
@@ -11,4 +11,5 @@ export declare class ContentEntryReader {
11
11
  getEntries(): Promise<readonly ContentSourceEntry[]>;
12
12
  readText(logicalPath: string): Promise<string>;
13
13
  read(entry: ContentSourceEntry): Promise<string>;
14
+ clearReadCache(): void;
14
15
  }
@@ -18,13 +18,36 @@ export type ContentAsset = {
18
18
  export type ContentManifestPluginAsset = PluginAsset & {
19
19
  path: string;
20
20
  };
21
+ /**
22
+ * The standard `article.*` positions the article consumer recognizes.
23
+ *
24
+ * These constants are a convenience for Sites that prefer named references;
25
+ * writing the slot string inline (for example `name="article.metadata"`) stays
26
+ * the recommended, most readable form in TSX layouts.
27
+ */
28
+ export declare const ARTICLE_SLOT: {
29
+ readonly header: "article.header";
30
+ readonly metadata: "article.metadata";
31
+ readonly aside: "article.aside";
32
+ readonly beforeContent: "article.before-content";
33
+ readonly afterContent: "article.after-content";
34
+ readonly footer: "article.footer";
35
+ };
21
36
  /**
22
37
  * A semantic position in a Site-owned article layout.
23
38
  *
24
39
  * The standard article consumer recognizes the `article.*` positions below.
25
40
  * Other names remain valid so a custom Site can define its own layout slots.
26
41
  */
27
- export type ContentBodySlot = "article.header" | "article.metadata" | "article.aside" | "article.before-content" | "article.after-content" | "article.footer" | (string & {});
42
+ export type ContentBodySlot = (typeof ARTICLE_SLOT)[keyof typeof ARTICLE_SLOT] | (string & {});
43
+ /**
44
+ * A map of Plugin-provided HTML fragments keyed by slot name.
45
+ *
46
+ * The standard `article.*` names autocomplete while any custom slot name
47
+ * remains valid, so custom Plugins keep working. A slot is considered empty
48
+ * when its value is missing or whitespace-only.
49
+ */
50
+ export type ContentBodySlots = Partial<Record<(typeof ARTICLE_SLOT)[keyof typeof ARTICLE_SLOT], string>> & Readonly<Record<string, string | undefined>>;
28
51
  /** Client entries and their explicitly public configuration. */
29
52
  export type ContentManifestPluginClientEntry = PluginClientEntry;
30
53
  export type ContentManifestEntry = {
@@ -18,7 +18,11 @@ export type PluginPage = {
18
18
  language?: string;
19
19
  };
20
20
  export type PluginPageContext = PluginContext & {
21
- /** The public manifest. Unpublished content is not exposed through pages. */
21
+ /**
22
+ * The resolved manifest. `manifest.entries` still contains `draft` and
23
+ * `scheduled` entries, so page output must read `publicEntries` (routable) or
24
+ * `discoverableEntries` (public only) instead of `entries`.
25
+ */
22
26
  manifest: ContentManifest;
23
27
  /** Request pathname, normalized to an absolute path. */
24
28
  pathname: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/core",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "tsx": "^4.22.4",
52
- "@riebeckite/test": "0.0.18"
52
+ "@riebeckite/test": "0.0.19"
53
53
  },
54
54
  "repository": {
55
55
  "type": "git",