wakeb-clients 2.0.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/index.mjs +225 -115
  2. package/package.json +2 -1
package/index.mjs CHANGED
@@ -1,115 +1,225 @@
1
- import { copyFileSync, existsSync, mkdirSync, readdirSync } from "fs";
2
- import { dirname, join, resolve } from "path";
3
- import { fileURLToPath } from "url";
4
-
5
- const __dirname = dirname(fileURLToPath(import.meta.url));
6
- const ASSETS_DIR = join(__dirname, "assets");
7
-
8
- const FALLBACKS = {
9
- website_dark_logo_large: ["dark.svg", "logo.svg"],
10
- website_logo_large: ["light.svg", "logo.svg"],
11
- website_dark_logo_small: ["sm_dark.svg", "sm_logo.svg"],
12
- website_logo_small: ["sm_light.svg", "sm_logo.svg"],
13
- };
14
-
15
- /**
16
- * Returns logo assets for a given client.
17
- * @param {string} clientName - The folder name under assets/
18
- * @returns {{ website_dark_logo_small: string|null, website_dark_logo_large: string|null, website_logo_small: string|null, website_logo_large: string|null }}
19
- */
20
- export function getClientAssets(clientName) {
21
- const clientDir = join(ASSETS_DIR, clientName);
22
-
23
- if (!existsSync(clientDir)) {
24
- throw new Error(`Client "${clientName}" not found in assets.`);
25
- }
26
-
27
- const result = {
28
- website_dark_logo_small: null,
29
- website_dark_logo_large: null,
30
- website_logo_small: null,
31
- website_logo_large: null,
32
- };
33
-
34
- for (const [key, candidates] of Object.entries(FALLBACKS)) {
35
- for (const fileName of candidates) {
36
- const filePath = join(clientDir, fileName);
37
- if (existsSync(filePath)) {
38
- result[key] = filePath;
39
- break;
40
- }
41
- }
42
- }
43
-
44
- return result;
45
- }
46
-
47
- /**
48
- * Lists all available client names.
49
- * @returns {string[]}
50
- */
51
- export function getAvailableClients() {
52
- return readdirSync(ASSETS_DIR, { withFileTypes: true })
53
- .filter((d) => d.isDirectory())
54
- .map((d) => d.name);
55
- }
56
-
57
- const VALID_KEYS = [
58
- "website_dark_logo_large",
59
- "website_logo_large",
60
- "website_dark_logo_small",
61
- "website_logo_small",
62
- ];
63
-
64
- const KEY_TO_FILE = {
65
- website_dark_logo_large: "dark.svg",
66
- website_logo_large: "light.svg",
67
- website_dark_logo_small: "sm_dark.svg",
68
- website_logo_small: "sm_light.svg",
69
- };
70
-
71
- /**
72
- * Adds a new client by copying logo files into the package assets.
73
- * Skips if the client already exists.
74
- * @param {string} clientName - The folder name to create under assets/
75
- * @param {Record<string, string>} logos - Map of logo keys to source file paths
76
- * Keys: website_dark_logo_large, website_logo_large, website_dark_logo_small, website_logo_small
77
- * @returns {{ created: boolean, path: string }}
78
- */
79
- export function addClient(clientName, logos) {
80
- if (!clientName || typeof clientName !== "string") {
81
- throw new Error("clientName must be a non-empty string.");
82
- }
83
- if (!/^[a-z0-9-]+$/.test(clientName)) {
84
- throw new Error("clientName must contain only lowercase letters, numbers, and hyphens.");
85
- }
86
-
87
- const clientDir = join(ASSETS_DIR, clientName);
88
-
89
- if (existsSync(clientDir)) {
90
- return { created: false, path: clientDir };
91
- }
92
-
93
- if (!logos || typeof logos !== "object" || Object.keys(logos).length === 0) {
94
- throw new Error("logos must be a non-empty object mapping logo keys to file paths.");
95
- }
96
-
97
- for (const key of Object.keys(logos)) {
98
- if (!VALID_KEYS.includes(key)) {
99
- throw new Error(`Invalid logo key "${key}". Valid keys: ${VALID_KEYS.join(", ")}`);
100
- }
101
- const src = resolve(logos[key]);
102
- if (!existsSync(src)) {
103
- throw new Error(`Source file not found: ${src}`);
104
- }
105
- }
106
-
107
- mkdirSync(clientDir, { recursive: true });
108
-
109
- for (const [key, srcPath] of Object.entries(logos)) {
110
- const dest = join(clientDir, KEY_TO_FILE[key]);
111
- copyFileSync(resolve(srcPath), dest);
112
- }
113
-
114
- return { created: true, path: clientDir };
115
- }
1
+ // Auto-generated by scripts/generate-esm.mjs DO NOT EDIT MANUALLY
2
+ // Run: node scripts/generate-esm.mjs
3
+
4
+ const REGISTRY = {
5
+ "aldrees": {
6
+ website_dark_logo_large: new URL('./assets/aldrees/dark.svg', import.meta.url).href,
7
+ website_logo_large: new URL('./assets/aldrees/light.svg', import.meta.url).href,
8
+ website_dark_logo_small: null,
9
+ website_logo_small: null
10
+ },
11
+ "alfanar": {
12
+ website_dark_logo_large: new URL('./assets/alfanar/dark.svg', import.meta.url).href,
13
+ website_logo_large: new URL('./assets/alfanar/light.svg', import.meta.url).href,
14
+ website_dark_logo_small: new URL('./assets/alfanar/sm_dark.svg', import.meta.url).href,
15
+ website_logo_small: new URL('./assets/alfanar/sm_light.svg', import.meta.url).href
16
+ },
17
+ "aramco": {
18
+ website_dark_logo_large: new URL('./assets/aramco/dark.svg', import.meta.url).href,
19
+ website_logo_large: new URL('./assets/aramco/light.svg', import.meta.url).href,
20
+ website_dark_logo_small: new URL('./assets/aramco/sm_dark.svg', import.meta.url).href,
21
+ website_logo_small: new URL('./assets/aramco/sm_light.svg', import.meta.url).href
22
+ },
23
+ "autism": {
24
+ website_dark_logo_large: new URL('./assets/autism/dark.svg', import.meta.url).href,
25
+ website_logo_large: new URL('./assets/autism/light.svg', import.meta.url).href,
26
+ website_dark_logo_small: null,
27
+ website_logo_small: null
28
+ },
29
+ "civil-defense": {
30
+ website_dark_logo_large: new URL('./assets/civil-defense/logo.svg', import.meta.url).href,
31
+ website_logo_large: new URL('./assets/civil-defense/logo.svg', import.meta.url).href,
32
+ website_dark_logo_small: null,
33
+ website_logo_small: null
34
+ },
35
+ "dga": {
36
+ website_dark_logo_large: new URL('./assets/dga/dark.svg', import.meta.url).href,
37
+ website_logo_large: new URL('./assets/dga/light.svg', import.meta.url).href,
38
+ website_dark_logo_small: new URL('./assets/dga/sm_dark.svg', import.meta.url).href,
39
+ website_logo_small: new URL('./assets/dga/sm_light.svg', import.meta.url).href
40
+ },
41
+ "eastern-province": {
42
+ website_dark_logo_large: new URL('./assets/eastern-province/dark.svg', import.meta.url).href,
43
+ website_logo_large: new URL('./assets/eastern-province/light.svg', import.meta.url).href,
44
+ website_dark_logo_small: new URL('./assets/eastern-province/sm_dark.svg', import.meta.url).href,
45
+ website_logo_small: new URL('./assets/eastern-province/sm_light.svg', import.meta.url).href
46
+ },
47
+ "fikra": {
48
+ website_dark_logo_large: new URL('./assets/fikra/dark.svg', import.meta.url).href,
49
+ website_logo_large: new URL('./assets/fikra/logo.svg', import.meta.url).href,
50
+ website_dark_logo_small: null,
51
+ website_logo_small: null
52
+ },
53
+ "gadd": {
54
+ website_dark_logo_large: new URL('./assets/gadd/dark.svg', import.meta.url).href,
55
+ website_logo_large: new URL('./assets/gadd/light.svg', import.meta.url).href,
56
+ website_dark_logo_small: new URL('./assets/gadd/sm_dark.svg', import.meta.url).href,
57
+ website_logo_small: new URL('./assets/gadd/sm_light.svg', import.meta.url).href
58
+ },
59
+ "gadd-new": {
60
+ website_dark_logo_large: new URL('./assets/gadd-new/dark.svg', import.meta.url).href,
61
+ website_logo_large: new URL('./assets/gadd-new/light.svg', import.meta.url).href,
62
+ website_dark_logo_small: new URL('./assets/gadd-new/sm_dark.svg', import.meta.url).href,
63
+ website_logo_small: new URL('./assets/gadd-new/sm_light.svg', import.meta.url).href
64
+ },
65
+ "guard": {
66
+ website_dark_logo_large: new URL('./assets/guard/logo.svg', import.meta.url).href,
67
+ website_logo_large: new URL('./assets/guard/logo.svg', import.meta.url).href,
68
+ website_dark_logo_small: null,
69
+ website_logo_small: null
70
+ },
71
+ "hajj": {
72
+ website_dark_logo_large: new URL('./assets/hajj/dark.svg', import.meta.url).href,
73
+ website_logo_large: new URL('./assets/hajj/light.svg', import.meta.url).href,
74
+ website_dark_logo_small: new URL('./assets/hajj/sm_dark.svg', import.meta.url).href,
75
+ website_logo_small: new URL('./assets/hajj/sm_light.svg', import.meta.url).href
76
+ },
77
+ "haramain": {
78
+ website_dark_logo_large: new URL('./assets/haramain/dark.svg', import.meta.url).href,
79
+ website_logo_large: new URL('./assets/haramain/light.svg', import.meta.url).href,
80
+ website_dark_logo_small: new URL('./assets/haramain/sm_dark.svg', import.meta.url).href,
81
+ website_logo_small: new URL('./assets/haramain/sm_light.svg', import.meta.url).href
82
+ },
83
+ "jeddah": {
84
+ website_dark_logo_large: new URL('./assets/jeddah/logo.svg', import.meta.url).href,
85
+ website_logo_large: new URL('./assets/jeddah/logo.svg', import.meta.url).href,
86
+ website_dark_logo_small: null,
87
+ website_logo_small: null
88
+ },
89
+ "kfu": {
90
+ website_dark_logo_large: new URL('./assets/kfu/logo.svg', import.meta.url).href,
91
+ website_logo_large: new URL('./assets/kfu/logo.svg', import.meta.url).href,
92
+ website_dark_logo_small: null,
93
+ website_logo_small: null
94
+ },
95
+ "mada": {
96
+ website_dark_logo_large: new URL('./assets/mada/logo.svg', import.meta.url).href,
97
+ website_logo_large: new URL('./assets/mada/logo.svg', import.meta.url).href,
98
+ website_dark_logo_small: null,
99
+ website_logo_small: null
100
+ },
101
+ "makkah": {
102
+ website_dark_logo_large: new URL('./assets/makkah/dark.svg', import.meta.url).href,
103
+ website_logo_large: new URL('./assets/makkah/light.svg', import.meta.url).href,
104
+ website_dark_logo_small: new URL('./assets/makkah/sm_dark.svg', import.meta.url).href,
105
+ website_logo_small: new URL('./assets/makkah/sm_light.svg', import.meta.url).href
106
+ },
107
+ "mujib": {
108
+ website_dark_logo_large: new URL('./assets/mujib/logo.svg', import.meta.url).href,
109
+ website_logo_large: new URL('./assets/mujib/logo.svg', import.meta.url).href,
110
+ website_dark_logo_small: null,
111
+ website_logo_small: null
112
+ },
113
+ "national-guard": {
114
+ website_dark_logo_large: new URL('./assets/national-guard/logo.svg', import.meta.url).href,
115
+ website_logo_large: new URL('./assets/national-guard/logo.svg', import.meta.url).href,
116
+ website_dark_logo_small: null,
117
+ website_logo_small: null
118
+ },
119
+ "ncms": {
120
+ website_dark_logo_large: new URL('./assets/ncms/logo.svg', import.meta.url).href,
121
+ website_logo_large: new URL('./assets/ncms/logo.svg', import.meta.url).href,
122
+ website_dark_logo_small: null,
123
+ website_logo_small: null
124
+ },
125
+ "ncpd": {
126
+ website_dark_logo_large: new URL('./assets/ncpd/dark.svg', import.meta.url).href,
127
+ website_logo_large: new URL('./assets/ncpd/light.svg', import.meta.url).href,
128
+ website_dark_logo_small: new URL('./assets/ncpd/sm_dark.svg', import.meta.url).href,
129
+ website_logo_small: new URL('./assets/ncpd/sm_light.svg', import.meta.url).href
130
+ },
131
+ "neom": {
132
+ website_dark_logo_large: new URL('./assets/neom/dark.svg', import.meta.url).href,
133
+ website_logo_large: new URL('./assets/neom/light.svg', import.meta.url).href,
134
+ website_dark_logo_small: new URL('./assets/neom/sm_dark.svg', import.meta.url).href,
135
+ website_logo_small: new URL('./assets/neom/sm_light.svg', import.meta.url).href
136
+ },
137
+ "nwc": {
138
+ website_dark_logo_large: new URL('./assets/nwc/dark.svg', import.meta.url).href,
139
+ website_logo_large: new URL('./assets/nwc/light.svg', import.meta.url).href,
140
+ website_dark_logo_small: null,
141
+ website_logo_small: null
142
+ },
143
+ "rcjy": {
144
+ website_dark_logo_large: new URL('./assets/rcjy/dark.svg', import.meta.url).href,
145
+ website_logo_large: new URL('./assets/rcjy/light.svg', import.meta.url).href,
146
+ website_dark_logo_small: new URL('./assets/rcjy/sm_dark.svg', import.meta.url).href,
147
+ website_logo_small: new URL('./assets/rcjy/sm_light.svg', import.meta.url).href
148
+ },
149
+ "redf": {
150
+ website_dark_logo_large: new URL('./assets/redf/dark.svg', import.meta.url).href,
151
+ website_logo_large: new URL('./assets/redf/light.svg', import.meta.url).href,
152
+ website_dark_logo_small: new URL('./assets/redf/sm_dark.svg', import.meta.url).href,
153
+ website_logo_small: new URL('./assets/redf/sm_light.svg', import.meta.url).href
154
+ },
155
+ "sabic": {
156
+ website_dark_logo_large: new URL('./assets/sabic/dark.svg', import.meta.url).href,
157
+ website_logo_large: new URL('./assets/sabic/light.svg', import.meta.url).href,
158
+ website_dark_logo_small: null,
159
+ website_logo_small: null
160
+ },
161
+ "sar": {
162
+ website_dark_logo_large: new URL('./assets/sar/dark.svg', import.meta.url).href,
163
+ website_logo_large: new URL('./assets/sar/light.svg', import.meta.url).href,
164
+ website_dark_logo_small: new URL('./assets/sar/sm_dark.svg', import.meta.url).href,
165
+ website_logo_small: new URL('./assets/sar/sm_light.svg', import.meta.url).href
166
+ },
167
+ "savola": {
168
+ website_dark_logo_large: new URL('./assets/savola/dark.svg', import.meta.url).href,
169
+ website_logo_large: new URL('./assets/savola/light.svg', import.meta.url).href,
170
+ website_dark_logo_small: null,
171
+ website_logo_small: null
172
+ },
173
+ "stc": {
174
+ website_dark_logo_large: new URL('./assets/stc/dark.svg', import.meta.url).href,
175
+ website_logo_large: new URL('./assets/stc/light.svg', import.meta.url).href,
176
+ website_dark_logo_small: null,
177
+ website_logo_small: null
178
+ },
179
+ "swcc": {
180
+ website_dark_logo_large: new URL('./assets/swcc/dark.svg', import.meta.url).href,
181
+ website_logo_large: new URL('./assets/swcc/light.svg', import.meta.url).href,
182
+ website_dark_logo_small: new URL('./assets/swcc/sm_dark.svg', import.meta.url).href,
183
+ website_logo_small: new URL('./assets/swcc/sm_light.svg', import.meta.url).href
184
+ },
185
+ "trendy": {
186
+ website_dark_logo_large: new URL('./assets/trendy/dark.svg', import.meta.url).href,
187
+ website_logo_large: new URL('./assets/trendy/light.svg', import.meta.url).href,
188
+ website_dark_logo_small: new URL('./assets/trendy/sm_dark.svg', import.meta.url).href,
189
+ website_logo_small: new URL('./assets/trendy/sm_light.svg', import.meta.url).href
190
+ },
191
+ "wakeb": {
192
+ website_dark_logo_large: new URL('./assets/wakeb/dark.svg', import.meta.url).href,
193
+ website_logo_large: new URL('./assets/wakeb/light.svg', import.meta.url).href,
194
+ website_dark_logo_small: new URL('./assets/wakeb/sm_dark.svg', import.meta.url).href,
195
+ website_logo_small: new URL('./assets/wakeb/sm_light.svg', import.meta.url).href
196
+ }
197
+ };
198
+
199
+ /**
200
+ * Returns logo asset URLs for a given client.
201
+ * @param {string} clientName - The folder name under assets/
202
+ * @returns {{ website_dark_logo_small: string|null, website_dark_logo_large: string|null, website_logo_small: string|null, website_logo_large: string|null }}
203
+ */
204
+ export function getClientAssets(clientName) {
205
+ const assets = REGISTRY[clientName];
206
+ if (!assets) {
207
+ throw new Error(`Client "${clientName}" not found in assets.`);
208
+ }
209
+ return { ...assets };
210
+ }
211
+
212
+ /**
213
+ * Lists all available client names.
214
+ * @returns {string[]}
215
+ */
216
+ export function getAvailableClients() {
217
+ return Object.keys(REGISTRY);
218
+ }
219
+
220
+ /**
221
+ * addClient is only available in Node.js (CommonJS). Use require('wakeb-clients') instead.
222
+ */
223
+ export function addClient() {
224
+ throw new Error("addClient() is only available in Node.js. Use require('wakeb-clients') instead.");
225
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wakeb-clients",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Wakeb client logos and assets",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -17,6 +17,7 @@
17
17
  "assets/"
18
18
  ],
19
19
  "scripts": {
20
+ "build": "node scripts/generate-esm.mjs",
20
21
  "docs:dev": "vitepress dev docs",
21
22
  "docs:build": "vitepress build docs",
22
23
  "docs:preview": "vitepress preview docs",