ds-one 0.2.0-alpha.2 → 0.2.0-alpha.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.
@@ -1 +1 @@
1
- {"version":3,"file":"cdn-loader.d.ts","sourceRoot":"","sources":["../../DS1/utils/cdn-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9C,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAEtD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,mBAAmB,CAAC,EAAE,cAAc,CAAC;QACrC,wBAAwB,CAAC,EAAE,MAAM,CAAC;KACnC;CACF;AA2JD;;GAEG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,OAAO,CAAC,CA8CjE"}
1
+ {"version":3,"file":"cdn-loader.d.ts","sourceRoot":"","sources":["../../DS1/utils/cdn-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9C,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAEtD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,mBAAmB,CAAC,EAAE,cAAc,CAAC;QACrC,wBAAwB,CAAC,EAAE,MAAM,CAAC;KACnC;CACF;AAmID;;GAEG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,OAAO,CAAC,CA8CjE"}
@@ -5,20 +5,7 @@
5
5
  */
6
6
  // Track if we've already attempted to load
7
7
  let loadAttempted = false;
8
- const DEFAULT_TRANSLATION_FILES = [
9
- "./keys.json",
10
- "./tekst.json",
11
- "./tekster.json",
12
- "./language.json",
13
- "./languages.json",
14
- "./translations.json",
15
- "./translate.json",
16
- "./i18n.json",
17
- "./locales.json",
18
- "./strings.json",
19
- "./text.json",
20
- "./texts.json",
21
- ];
8
+ const DEFAULT_TRANSLATION_FILE = "./translations.json";
22
9
  function normalizeCandidate(path) {
23
10
  if (!path) {
24
11
  return null;
@@ -59,20 +46,23 @@ function findAttributeCandidate() {
59
46
  return null;
60
47
  }
61
48
  function resolveTranslationSources() {
62
- const candidates = new Set();
49
+ const candidates = [];
63
50
  const windowCandidate = typeof window !== "undefined" ? window.DS_ONE_TRANSLATIONS_FILE : null;
64
51
  const attributeCandidate = findAttributeCandidate();
65
- const addCandidate = (candidate) => {
66
- const normalized = normalizeCandidate(candidate ?? "");
67
- if (normalized) {
68
- candidates.add(normalized);
69
- }
70
- };
71
- addCandidate(windowCandidate ?? null);
72
- addCandidate(attributeCandidate);
73
- // Always include defaults as fallback so existing behaviour keeps working
74
- DEFAULT_TRANSLATION_FILES.forEach((file) => addCandidate(file));
75
- return Array.from(candidates);
52
+ // Only use explicitly configured paths, or the single default
53
+ const windowNormalized = normalizeCandidate(windowCandidate ?? "");
54
+ if (windowNormalized) {
55
+ candidates.push(windowNormalized);
56
+ }
57
+ const attrNormalized = normalizeCandidate(attributeCandidate ?? "");
58
+ if (attrNormalized && !candidates.includes(attrNormalized)) {
59
+ candidates.push(attrNormalized);
60
+ }
61
+ // Only try default if no explicit path was configured
62
+ if (candidates.length === 0) {
63
+ candidates.push(DEFAULT_TRANSLATION_FILE);
64
+ }
65
+ return candidates;
76
66
  }
77
67
  function validateTranslationMap(candidate) {
78
68
  if (!candidate || typeof candidate !== "object") {
@@ -82,14 +72,12 @@ function validateTranslationMap(candidate) {
82
72
  }
83
73
  async function fetchTranslationFile(source) {
84
74
  try {
85
- console.log(`[DS one] Attempting to fetch translations from: ${source}`);
86
75
  const response = await fetch(source);
87
76
  if (!response.ok) {
88
- console.log(`[DS one] Failed to fetch ${source} (${response.status})`);
77
+ // 404 is expected if no translations file exists - don't log as error
89
78
  return null;
90
79
  }
91
80
  const translations = await response.json();
92
- console.log(`[DS one] Successfully fetched JSON from ${source}`);
93
81
  if (!validateTranslationMap(translations)) {
94
82
  console.warn(`[DS one] Invalid translation format in ${source}. Expected object with language codes as keys.`);
95
83
  return null;
@@ -99,16 +87,10 @@ async function fetchTranslationFile(source) {
99
87
  console.warn(`[DS one] No languages found in ${source}`);
100
88
  return null;
101
89
  }
102
- console.log(`[DS one] Valid translations found: ${languages.join(", ")}`);
103
90
  return translations;
104
91
  }
105
- catch (error) {
106
- if (error instanceof TypeError &&
107
- error.message.includes("Failed to fetch")) {
108
- console.log(`[DS one] Network error fetching ${source}`);
109
- return null;
110
- }
111
- console.error(`[DS one] Error loading external translations from ${source}:`, error);
92
+ catch {
93
+ // Silently fail - file likely doesn't exist or isn't valid JSON
112
94
  return null;
113
95
  }
114
96
  }
@@ -142,7 +124,7 @@ export async function loadExternalTranslations() {
142
124
  window.dispatchEvent(new CustomEvent("translations-ready"));
143
125
  return true;
144
126
  }
145
- console.info(`[DS one] No external translations found. Looked in: ${sources.join(", ")}. Using bundled translations.`);
127
+ console.info(`[DS one] No external translations found at ${sources[0] ?? DEFAULT_TRANSLATION_FILE}. Using bundled translations.`);
146
128
  return false;
147
129
  }
148
130
  // Auto-load translations when this module is imported (for CDN bundle)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ds-one",
3
- "version": "0.2.0-alpha.2",
3
+ "version": "0.2.0-alpha.3",
4
4
  "description": "A component-based design system built with TypeScript and LitElement that provides reusable UI components with built-in theming, internationalization, and accessibility features.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",