@inglorious/ssx 2.3.2 → 2.4.0

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.
@@ -14,7 +14,7 @@ export async function loadConfig(options) {
14
14
  const configFile = path.resolve(rootDir, "src", configPath)
15
15
 
16
16
  if (!existsSync(configFile)) {
17
- return {} // Default config
17
+ return {}
18
18
  }
19
19
 
20
20
  const config = /\.[cm]?ts$/.test(configFile)
@@ -9,8 +9,6 @@ describe("loadConfig", () => {
9
9
  let rootDir
10
10
 
11
11
  beforeEach(() => {
12
- // Inside the package: Vitest's module loader only imports files under
13
- // the project root.
14
12
  rootDir = mkdtempSync(path.join(import.meta.dirname, ".tmp-config-"))
15
13
  mkdirSync(path.join(rootDir, "src"))
16
14
  })
package/src/utils/i18n.js CHANGED
@@ -10,7 +10,6 @@ export function getLocaleFromPath(
10
10
  return defaultLocale
11
11
  }
12
12
 
13
- // Scripts written right to left, by their ISO 15924 code.
14
13
  const RTL_SCRIPTS = new Set([
15
14
  "Adlm",
16
15
  "Arab",
@@ -39,12 +38,10 @@ export function getTextDirection(locale) {
39
38
  const { script } = new Intl.Locale(locale).maximize()
40
39
  return RTL_SCRIPTS.has(script) ? "rtl" : "ltr"
41
40
  } catch {
42
- // Not a valid language tag.
43
41
  return "ltr"
44
42
  }
45
43
  }
46
44
 
47
- // The entity of an app that translates with @inglorious/i18n, by that package's convention.
48
45
  const TRANSLATOR_ID = "i18n"
49
46
 
50
47
  /**
@@ -8,7 +8,6 @@ import {
8
8
  waitForLocale,
9
9
  } from "./i18n"
10
10
 
11
- // Stands in for @inglorious/i18n: Italian loads later, English is loaded already.
12
11
  function createTranslatorStore({ loads = {} } = {}) {
13
12
  const loaded = new Set(["en"])
14
13
  const I18n = {
@@ -8,7 +8,6 @@ import texmath from "markdown-it-texmath"
8
8
 
9
9
  export function renderMarkdown(markdown) {
10
10
  const md = createMarkdownRenderer()
11
- // gray-matter gives an error on the client, so we are going to use a simpler way to extract content
12
11
  const content = markdown.replace(/^---[\s\S]*?---\n/, "")
13
12
  return md.render(content)
14
13
  }
@@ -23,7 +22,6 @@ export function markdownPlugin(options = {}) {
23
22
  async transform(code, id) {
24
23
  if (!id.endsWith(".md")) return
25
24
 
26
- // prevents importing gray-matter on the client
27
25
  const matter = (await import("gray-matter")).default
28
26
  const { content, data } = matter(code)
29
27
  const htmlContent = md.render(content)
@@ -73,11 +71,10 @@ function createMarkdownRenderer() {
73
71
  console.error(err)
74
72
  }
75
73
  }
76
- return "" // use external default escaping
74
+ return ""
77
75
  },
78
76
  })
79
77
 
80
- // Add LaTeX support
81
78
  md.use(texmath, {
82
79
  engine: katex,
83
80
  delimiters: "dollars",
@@ -89,8 +86,6 @@ function createMarkdownRenderer() {
89
86
  ((tokens, idx, options, env, self) =>
90
87
  self.renderToken(tokens, idx, options, env, self))
91
88
 
92
- // Render mermaid fences as standalone blocks (not nested in <pre><code>),
93
- // avoiding invalid HTML that can cause hydration mismatches.
94
89
  md.renderer.rules.fence = (tokens, idx, options, env, self) => {
95
90
  const token = tokens[idx]
96
91
  const lang = token.info?.trim().split(/\s+/)[0]
@@ -73,7 +73,6 @@ function readPageHead(store, modules) {
73
73
  meta: getPageOption("meta", DEFAULT_OPTIONS),
74
74
  }
75
75
  } catch {
76
- // Metadata computed from entity data throws until that data arrives.
77
76
  return null
78
77
  }
79
78
  }
@@ -91,8 +90,6 @@ function applyHead(head, previous) {
91
90
  root.dir = head.dir
92
91
  }
93
92
 
94
- // Only tags named by this page or the previous one are touched, so those the
95
- // layout writes on its own stay as they are.
96
93
  const names = new Set([
97
94
  ...Object.keys(previous?.meta ?? {}),
98
95
  ...Object.keys(head.meta),
@@ -103,7 +100,6 @@ function applyHead(head, previous) {
103
100
  }
104
101
 
105
102
  function applyMeta(name, content) {
106
- // The server writes Open Graph style names, such as og:image, as `property`.
107
103
  const attribute = name.includes(":") ? "property" : "name"
108
104
  let tag = [...document.head.querySelectorAll("meta")].find(
109
105
  (meta) => meta.getAttribute(attribute) === name,
@@ -63,7 +63,6 @@ describe("syncPageHead", () => {
63
63
  })
64
64
  }
65
65
 
66
- // Navigates the way the router does: the history entry first, then the state change.
67
66
  const navigate = (store, route, path) => {
68
67
  window.history.pushState(null, "", path)
69
68
  store.notify("#router:navigate", { route, path })
@@ -39,7 +39,7 @@ describe("createGetPageOption", () => {
39
39
  })
40
40
 
41
41
  it("should use defaults when metadata is missing", () => {
42
- const module = {} // No metadata export
42
+ const module = {}
43
43
 
44
44
  const getOption = createGetPageOption(mockStore, module, mockEntity)
45
45
  const defaults = { title: "Default Title" }