« get me outta code hell

language: drop externalLinkSpec prop, just import directly - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-10-20 13:09:58 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-10-20 13:09:58 -0300
commitc3b4b0bebca07a69f6c47d680f0c18d859cb599c (patch)
tree0dcdc81d6d421b1decb1ee66d018de70e3c566f8
parent2374124f0b9f758021648e8bd3d99c205b2e3aea (diff)
language: drop externalLinkSpec prop, just import directly preview
this lets us totally drop "internal" but exported function
initializeLanguageObject - we'll still need to provide the
external link spec in essentially the exact same way in the
future, when external link spec is dynamic, but presently
there's no need for this function or providing at all.
-rw-r--r--src/data/language.js13
-rw-r--r--src/data/things/language.js17
2 files changed, 5 insertions, 25 deletions
diff --git a/src/data/language.js b/src/data/language.js
index 8dc06e7e..e97267c0 100644
--- a/src/data/language.js
+++ b/src/data/language.js
@@ -8,7 +8,6 @@ import yaml from 'js-yaml';
 
 import {annotateError, annotateErrorWithFile, showAggregate, withAggregate}
   from '#aggregate';
-import {externalLinkSpec} from '#external-links';
 import {colors, logWarn} from '#cli';
 import {empty, splitKeys, withEntries} from '#sugar';
 import T from '#things';
@@ -247,16 +246,8 @@ async function processLanguageSpecFromFile(file, processLanguageSpecOpts) {
   }
 }
 
-export function initializeLanguageObject() {
-  const language = new Language();
-
-  language.externalLinkSpec = externalLinkSpec;
-
-  return language;
-}
-
 export async function processLanguageFile(file) {
-  const language = initializeLanguageObject();
+  const language = new Language()
   const properties = await processLanguageSpecFromFile(file);
   return Object.assign(language, properties);
 }
@@ -267,7 +258,7 @@ export function watchLanguageFile(file, {
   const basename = path.basename(file);
 
   const events = new EventEmitter();
-  const language = initializeLanguageObject();
+  const language = new Language();
 
   let emittedReady = false;
   let successfullyAppliedLanguage = false;
diff --git a/src/data/things/language.js b/src/data/things/language.js
index 997cf31e..631df94d 100644
--- a/src/data/things/language.js
+++ b/src/data/things/language.js
@@ -10,10 +10,10 @@ import Thing from '#thing';
 import {languageOptionRegex} from '#wiki-data';
 
 import {
+  externalLinkSpec,
   getExternalLinkStringOfStyleFromDescriptors,
   getExternalLinkStringsFromDescriptors,
   isExternalLinkContext,
-  isExternalLinkSpec,
   isExternalLinkStyle,
 } from '#external-links';
 
@@ -82,13 +82,6 @@ export class Language extends Thing {
       update: {validate: (t) => typeof t === 'object'},
     },
 
-    // List of descriptors for providing to external link utilities when using
-    // language.formatExternalLink - refer to #external-links for info.
-    externalLinkSpec: {
-      flags: {update: true, expose: true},
-      update: {validate: isExternalLinkSpec},
-    },
-
     // Expose only
 
     isLanguage: [
@@ -648,10 +641,6 @@ export class Language extends Thing {
     style = 'platform',
     context = 'generic',
   } = {}) {
-    if (!this.externalLinkSpec) {
-      throw new TypeError(`externalLinkSpec unavailable`);
-    }
-
     // Null or undefined url is blank content.
     if (url === null || url === undefined) {
       return html.blank();
@@ -660,7 +649,7 @@ export class Language extends Thing {
     isExternalLinkContext(context);
 
     if (style === 'all') {
-      return getExternalLinkStringsFromDescriptors(url, this.externalLinkSpec, {
+      return getExternalLinkStringsFromDescriptors(url, externalLinkSpec, {
         language: this,
         context,
       });
@@ -669,7 +658,7 @@ export class Language extends Thing {
     isExternalLinkStyle(style);
 
     const result =
-      getExternalLinkStringOfStyleFromDescriptors(url, style, this.externalLinkSpec, {
+      getExternalLinkStringOfStyleFromDescriptors(url, style, externalLinkSpec, {
         language: this,
         context,
       });