lightnet 4.0.2 → 4.0.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # lightnet
2
2
 
3
+ ## 4.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#372](https://github.com/LightNetDev/LightNet/pull/372) [`e5eb8b0`](https://github.com/LightNetDev/LightNet/commit/e5eb8b06a7684bf5d9090f885e04fcc5eea417ac) Thanks [@smn-cds](https://github.com/smn-cds)! - Fix dev translation HMR so editing `src/translations/*.yml` invalidates the full SSR importer chain and refreshes translated UI content.
8
+
9
+ - [#372](https://github.com/LightNetDev/LightNet/pull/372) [`e5eb8b0`](https://github.com/LightNetDev/LightNet/commit/e5eb8b06a7684bf5d9090f885e04fcc5eea417ac) Thanks [@smn-cds](https://github.com/smn-cds)! - Restore Language type export from "lightnet"
10
+
3
11
  ## 4.0.2
4
12
 
5
13
  ### Patch Changes
package/exports/index.ts CHANGED
@@ -1,2 +1,6 @@
1
- export { type LightnetConfig, type Link } from "../src/astro-integration/config"
1
+ export {
2
+ type Language,
3
+ type LightnetConfig,
4
+ type Link,
5
+ } from "../src/astro-integration/config"
2
6
  export { lightnet as default } from "../src/astro-integration/integration"
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "LightNet makes it easy to run your own digital media library.",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
- "version": "4.0.2",
6
+ "version": "4.0.3",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/LightNetDev/lightnet",
@@ -40,22 +40,14 @@ export function vitePluginLightnetConfig(
40
40
  const module = VIRTUAL_MODULES.find((m) => m === id)
41
41
  if (module) return `\0${module}`
42
42
  },
43
- handleHotUpdate({ file, modules, server }) {
43
+ handleHotUpdate({ file, server }) {
44
44
  const srcPath = resolve(fileURLToPath(root), "src/translations/")
45
45
  if (
46
46
  (file.endsWith(".yml") || file.endsWith(".yaml")) &&
47
47
  file.startsWith(srcPath)
48
48
  ) {
49
- const affectedModules = [
50
- ...modules,
51
- ...TRANSLATION_RUNTIME_MODULES.flatMap((id) => {
52
- const module = server.moduleGraph.getModuleById(id)
53
- return module ? [module] : []
54
- }),
55
- ]
56
-
57
- for (const module of affectedModules) {
58
- server.moduleGraph.invalidateModule(module)
49
+ for (const filePath of [file, ...TRANSLATION_RUNTIME_MODULES]) {
50
+ server.moduleGraph.onFileChange(filePath)
59
51
  }
60
52
 
61
53
  logger.info(`Update translations ${file.slice(srcPath.length)}`)
@@ -31,7 +31,11 @@ const languageCodes = [
31
31
  ),
32
32
  ]
33
33
 
34
- const i18nextTranslations = lazy(async () => {
34
+ // In dev we avoid memoizing translations so YAML edits are reflected after HMR.
35
+ const cacheInProduction = <TReturn>(compute: () => TReturn) =>
36
+ import.meta.env.DEV ? { get: compute } : lazy(compute)
37
+
38
+ const i18nextTranslations = cacheInProduction(async () => {
35
39
  const result: Record<string, { translation: Record<string, string> }> = {}
36
40
  for (const bcp47 of languageCodes) {
37
41
  result[bcp47] = {
@@ -41,7 +45,7 @@ const i18nextTranslations = lazy(async () => {
41
45
  return result
42
46
  })
43
47
 
44
- const translationKeys = lazy(async () => {
48
+ const translationKeys = cacheInProduction(async () => {
45
49
  const translations = await i18nextTranslations.get()
46
50
  return [
47
51
  ...new Set(