@moon-inferno/core 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Moon-Inferno Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ KEYS: () => KEYS,
24
+ colors: () => colors,
25
+ createFocusStore: () => createFocusStore,
26
+ getCSSVariableObject: () => getCSSVariableObject,
27
+ getCSSVariableString: () => getCSSVariableString,
28
+ getFocusableElements: () => getFocusableElements,
29
+ isActionKey: () => isActionKey,
30
+ isKey: () => isKey,
31
+ isReducedMotionPreferred: () => isReducedMotionPreferred,
32
+ onReducedMotionChange: () => onReducedMotionChange,
33
+ radii: () => radii,
34
+ retroEffects: () => retroEffects,
35
+ shadows: () => shadows,
36
+ spacing: () => spacing,
37
+ trapFocus: () => trapFocus,
38
+ typography: () => typography,
39
+ zIndex: () => zIndex
40
+ });
41
+ module.exports = __toCommonJS(index_exports);
42
+
43
+ // src/tokens.ts
44
+ var colors = {
45
+ // Infernal Palette (Solar Fire / Lava / Amber)
46
+ inferno: {
47
+ 50: "#FFF5F0",
48
+ 100: "#FFE6D9",
49
+ 200: "#FFBF9B",
50
+ 300: "#FF975E",
51
+ 400: "#FF7026",
52
+ 500: "#FF4D00",
53
+ // Primary Inferno Orange
54
+ 600: "#FF2E00",
55
+ // Crimson Fire
56
+ 700: "#CC1F00",
57
+ 800: "#991200",
58
+ 900: "#660900",
59
+ 950: "#3D0300"
60
+ },
61
+ // Lunar Palette (Platinum / Silver / Ethereal Cyan)
62
+ moon: {
63
+ 50: "#F8FAFC",
64
+ 100: "#F1F5F9",
65
+ // Primary Text Light
66
+ 200: "#E2E8F0",
67
+ 300: "#CBD5E1",
68
+ 400: "#94A3B8",
69
+ 500: "#64748B",
70
+ 600: "#475569",
71
+ 700: "#334155",
72
+ 800: "#1E293B",
73
+ 900: "#0F172A",
74
+ 950: "#020617"
75
+ },
76
+ // Obsidian Palette (Deep Space / CRT Backlight / Magma Shadow)
77
+ obsidian: {
78
+ 900: "#120F16",
79
+ 950: "#0A090D"
80
+ // Primary Dark Background
81
+ },
82
+ // Retro CRT Status Colors
83
+ status: {
84
+ success: "#00FF66",
85
+ // Neon Terminal Green
86
+ warning: "#FFCC00",
87
+ // Amber Warning
88
+ error: "#FF0033",
89
+ // Cyber Red
90
+ info: "#00E5FF"
91
+ // Neon Cyan
92
+ }
93
+ };
94
+ var typography = {
95
+ fontFamily: {
96
+ sans: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
97
+ mono: '"JetBrains Mono", "Fira Code", "Courier New", Courier, monospace',
98
+ pixel: '"Press Start 2P", "VT323", "Courier New", monospace'
99
+ },
100
+ fontSize: {
101
+ xs: "0.75rem",
102
+ // 12px
103
+ sm: "0.875rem",
104
+ // 14px
105
+ base: "1rem",
106
+ // 16px
107
+ lg: "1.125rem",
108
+ // 18px
109
+ xl: "1.25rem",
110
+ // 20px
111
+ "2xl": "1.5rem",
112
+ // 24px
113
+ "3xl": "1.875rem",
114
+ // 30px
115
+ "4xl": "2.25rem"
116
+ // 36px
117
+ },
118
+ fontWeight: {
119
+ normal: "400",
120
+ medium: "500",
121
+ semibold: "600",
122
+ bold: "700"
123
+ },
124
+ lineHeight: {
125
+ tight: "1.2",
126
+ normal: "1.5",
127
+ relaxed: "1.75"
128
+ }
129
+ };
130
+ var spacing = {
131
+ 0: "0px",
132
+ 1: "0.25rem",
133
+ // 4px
134
+ 2: "0.5rem",
135
+ // 8px
136
+ 3: "0.75rem",
137
+ // 12px
138
+ 4: "1rem",
139
+ // 16px
140
+ 5: "1.25rem",
141
+ // 20px
142
+ 6: "1.5rem",
143
+ // 24px
144
+ 8: "2rem",
145
+ // 32px
146
+ 10: "2.5rem",
147
+ // 40px
148
+ 12: "3rem",
149
+ // 48px
150
+ 16: "4rem"
151
+ // 64px
152
+ };
153
+ var radii = {
154
+ none: "0px",
155
+ sm: "2px",
156
+ base: "4px",
157
+ md: "6px",
158
+ lg: "8px",
159
+ full: "9999px"
160
+ };
161
+ var shadows = {
162
+ none: "none",
163
+ infernoGlow: "0 0 12px rgba(255, 77, 0, 0.4), 0 0 24px rgba(255, 77, 0, 0.15)",
164
+ cyanGlow: "0 0 12px rgba(0, 229, 255, 0.4), 0 0 24px rgba(0, 229, 255, 0.15)",
165
+ pixelShadow: "3px 3px 0px #0A090D",
166
+ retroBox: "4px 4px 0px rgba(0, 0, 0, 0.9), inset -2px -2px 0px rgba(255, 255, 255, 0.1)"
167
+ };
168
+ var retroEffects = {
169
+ scanlineOpacity: "0.15",
170
+ crtFlickerSpeed: "0.15s",
171
+ pixelBorderWidth: "2px"
172
+ };
173
+ var zIndex = {
174
+ hide: -1,
175
+ auto: "auto",
176
+ base: 0,
177
+ docked: 10,
178
+ dropdown: 1e3,
179
+ sticky: 1100,
180
+ banner: 1200,
181
+ overlay: 1300,
182
+ modal: 1400,
183
+ popover: 1500,
184
+ skipLink: 1600,
185
+ toast: 1700,
186
+ tooltip: 1800
187
+ };
188
+
189
+ // src/css-variables.ts
190
+ function getCSSVariableObject() {
191
+ return {
192
+ // Colors - Inferno
193
+ "--mi-color-inferno-50": colors.inferno[50],
194
+ "--mi-color-inferno-100": colors.inferno[100],
195
+ "--mi-color-inferno-500": colors.inferno[500],
196
+ "--mi-color-inferno-600": colors.inferno[600],
197
+ "--mi-color-inferno-900": colors.inferno[900],
198
+ // Colors - Moon & Obsidian
199
+ "--mi-color-moon-50": colors.moon[50],
200
+ "--mi-color-moon-100": colors.moon[100],
201
+ "--mi-color-moon-400": colors.moon[400],
202
+ "--mi-color-moon-900": colors.moon[900],
203
+ "--mi-color-obsidian-900": colors.obsidian[900],
204
+ "--mi-color-obsidian-950": colors.obsidian[950],
205
+ // Status
206
+ "--mi-color-success": colors.status.success,
207
+ "--mi-color-warning": colors.status.warning,
208
+ "--mi-color-error": colors.status.error,
209
+ "--mi-color-info": colors.status.info,
210
+ // Typography
211
+ "--mi-font-sans": typography.fontFamily.sans,
212
+ "--mi-font-mono": typography.fontFamily.mono,
213
+ "--mi-font-pixel": typography.fontFamily.pixel,
214
+ // Spacing
215
+ "--mi-space-1": spacing[1],
216
+ "--mi-space-2": spacing[2],
217
+ "--mi-space-3": spacing[3],
218
+ "--mi-space-4": spacing[4],
219
+ "--mi-space-6": spacing[6],
220
+ "--mi-space-8": spacing[8],
221
+ // Radii
222
+ "--mi-radius-sm": radii.sm,
223
+ "--mi-radius-base": radii.base,
224
+ "--mi-radius-md": radii.md,
225
+ "--mi-radius-full": radii.full,
226
+ // Shadows & Glows
227
+ "--mi-shadow-glow": shadows.infernoGlow,
228
+ "--mi-shadow-pixel": shadows.pixelShadow,
229
+ // Focus Ring
230
+ "--mi-focus-ring-color": colors.inferno[500],
231
+ "--mi-focus-ring-width": "2px",
232
+ "--mi-focus-ring-offset": "2px",
233
+ // Z-Indices
234
+ "--mi-z-modal": String(zIndex.modal),
235
+ "--mi-z-toast": String(zIndex.toast),
236
+ "--mi-z-tooltip": String(zIndex.tooltip)
237
+ };
238
+ }
239
+ function getCSSVariableString() {
240
+ const vars = getCSSVariableObject();
241
+ return Object.entries(vars).map(([key, val]) => `${key}: ${val};`).join("\n ");
242
+ }
243
+
244
+ // src/a11y/focus.ts
245
+ var TABBABLE_SELECTOR = `
246
+ a[href],
247
+ button:not([disabled]),
248
+ area[href],
249
+ input:not([disabled]):not([type="hidden"]),
250
+ select:not([disabled]),
251
+ textarea:not([disabled]),
252
+ iframe,
253
+ object,
254
+ embed,
255
+ [tabindex]:not([tabindex="-1"]),
256
+ [contenteditable]
257
+ `;
258
+ function getFocusableElements(container) {
259
+ const elements = Array.from(container.querySelectorAll(TABBABLE_SELECTOR));
260
+ return elements.filter((el) => {
261
+ return (el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0) && getComputedStyle(el).visibility !== "hidden";
262
+ });
263
+ }
264
+ function trapFocus(container, event) {
265
+ if (event.key !== "Tab") return;
266
+ const focusables = getFocusableElements(container);
267
+ if (focusables.length === 0) {
268
+ event.preventDefault();
269
+ return;
270
+ }
271
+ const first = focusables[0];
272
+ const last = focusables[focusables.length - 1];
273
+ const active = document.activeElement;
274
+ if (event.shiftKey) {
275
+ if (active === first || !container.contains(active)) {
276
+ last?.focus();
277
+ event.preventDefault();
278
+ }
279
+ } else {
280
+ if (active === last || !container.contains(active)) {
281
+ first?.focus();
282
+ event.preventDefault();
283
+ }
284
+ }
285
+ }
286
+ function createFocusStore() {
287
+ let previousElement = null;
288
+ return {
289
+ save() {
290
+ if (document.activeElement instanceof HTMLElement) {
291
+ previousElement = document.activeElement;
292
+ }
293
+ },
294
+ restore() {
295
+ if (previousElement && typeof previousElement.focus === "function") {
296
+ previousElement.focus();
297
+ previousElement = null;
298
+ }
299
+ }
300
+ };
301
+ }
302
+
303
+ // src/a11y/motion.ts
304
+ var REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
305
+ function isReducedMotionPreferred() {
306
+ if (typeof window === "undefined" || !window.matchMedia) {
307
+ return false;
308
+ }
309
+ return window.matchMedia(REDUCED_MOTION_QUERY).matches;
310
+ }
311
+ function onReducedMotionChange(callback) {
312
+ if (typeof window === "undefined" || !window.matchMedia) {
313
+ return () => {
314
+ };
315
+ }
316
+ const mediaQuery = window.matchMedia(REDUCED_MOTION_QUERY);
317
+ const listener = (event) => callback(event.matches);
318
+ if (mediaQuery.addEventListener) {
319
+ mediaQuery.addEventListener("change", listener);
320
+ return () => mediaQuery.removeEventListener("change", listener);
321
+ }
322
+ return () => {
323
+ };
324
+ }
325
+
326
+ // src/a11y/keys.ts
327
+ var KEYS = {
328
+ ENTER: "Enter",
329
+ SPACE: " ",
330
+ ESCAPE: "Escape",
331
+ TAB: "Tab",
332
+ ARROW_UP: "ArrowUp",
333
+ ARROW_DOWN: "ArrowDown",
334
+ ARROW_LEFT: "ArrowLeft",
335
+ ARROW_RIGHT: "ArrowRight",
336
+ HOME: "Home",
337
+ END: "End"
338
+ };
339
+ function isKey(event, key) {
340
+ return event.key === KEYS[key];
341
+ }
342
+ function isActionKey(event) {
343
+ return event.key === KEYS.ENTER || event.key === KEYS.SPACE;
344
+ }
345
+ // Annotate the CommonJS export names for ESM import in node:
346
+ 0 && (module.exports = {
347
+ KEYS,
348
+ colors,
349
+ createFocusStore,
350
+ getCSSVariableObject,
351
+ getCSSVariableString,
352
+ getFocusableElements,
353
+ isActionKey,
354
+ isKey,
355
+ isReducedMotionPreferred,
356
+ onReducedMotionChange,
357
+ radii,
358
+ retroEffects,
359
+ shadows,
360
+ spacing,
361
+ trapFocus,
362
+ typography,
363
+ zIndex
364
+ });
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Moon-Inferno Core Design Tokens
3
+ * Framework-independent token definitions for colors, typography, spacing, shadows, and retro visual effects.
4
+ */
5
+ declare const colors: {
6
+ readonly inferno: {
7
+ readonly 50: "#FFF5F0";
8
+ readonly 100: "#FFE6D9";
9
+ readonly 200: "#FFBF9B";
10
+ readonly 300: "#FF975E";
11
+ readonly 400: "#FF7026";
12
+ readonly 500: "#FF4D00";
13
+ readonly 600: "#FF2E00";
14
+ readonly 700: "#CC1F00";
15
+ readonly 800: "#991200";
16
+ readonly 900: "#660900";
17
+ readonly 950: "#3D0300";
18
+ };
19
+ readonly moon: {
20
+ readonly 50: "#F8FAFC";
21
+ readonly 100: "#F1F5F9";
22
+ readonly 200: "#E2E8F0";
23
+ readonly 300: "#CBD5E1";
24
+ readonly 400: "#94A3B8";
25
+ readonly 500: "#64748B";
26
+ readonly 600: "#475569";
27
+ readonly 700: "#334155";
28
+ readonly 800: "#1E293B";
29
+ readonly 900: "#0F172A";
30
+ readonly 950: "#020617";
31
+ };
32
+ readonly obsidian: {
33
+ readonly 900: "#120F16";
34
+ readonly 950: "#0A090D";
35
+ };
36
+ readonly status: {
37
+ readonly success: "#00FF66";
38
+ readonly warning: "#FFCC00";
39
+ readonly error: "#FF0033";
40
+ readonly info: "#00E5FF";
41
+ };
42
+ };
43
+ declare const typography: {
44
+ readonly fontFamily: {
45
+ readonly sans: "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif";
46
+ readonly mono: "\"JetBrains Mono\", \"Fira Code\", \"Courier New\", Courier, monospace";
47
+ readonly pixel: "\"Press Start 2P\", \"VT323\", \"Courier New\", monospace";
48
+ };
49
+ readonly fontSize: {
50
+ readonly xs: "0.75rem";
51
+ readonly sm: "0.875rem";
52
+ readonly base: "1rem";
53
+ readonly lg: "1.125rem";
54
+ readonly xl: "1.25rem";
55
+ readonly '2xl': "1.5rem";
56
+ readonly '3xl': "1.875rem";
57
+ readonly '4xl': "2.25rem";
58
+ };
59
+ readonly fontWeight: {
60
+ readonly normal: "400";
61
+ readonly medium: "500";
62
+ readonly semibold: "600";
63
+ readonly bold: "700";
64
+ };
65
+ readonly lineHeight: {
66
+ readonly tight: "1.2";
67
+ readonly normal: "1.5";
68
+ readonly relaxed: "1.75";
69
+ };
70
+ };
71
+ declare const spacing: {
72
+ readonly 0: "0px";
73
+ readonly 1: "0.25rem";
74
+ readonly 2: "0.5rem";
75
+ readonly 3: "0.75rem";
76
+ readonly 4: "1rem";
77
+ readonly 5: "1.25rem";
78
+ readonly 6: "1.5rem";
79
+ readonly 8: "2rem";
80
+ readonly 10: "2.5rem";
81
+ readonly 12: "3rem";
82
+ readonly 16: "4rem";
83
+ };
84
+ declare const radii: {
85
+ readonly none: "0px";
86
+ readonly sm: "2px";
87
+ readonly base: "4px";
88
+ readonly md: "6px";
89
+ readonly lg: "8px";
90
+ readonly full: "9999px";
91
+ };
92
+ declare const shadows: {
93
+ readonly none: "none";
94
+ readonly infernoGlow: "0 0 12px rgba(255, 77, 0, 0.4), 0 0 24px rgba(255, 77, 0, 0.15)";
95
+ readonly cyanGlow: "0 0 12px rgba(0, 229, 255, 0.4), 0 0 24px rgba(0, 229, 255, 0.15)";
96
+ readonly pixelShadow: "3px 3px 0px #0A090D";
97
+ readonly retroBox: "4px 4px 0px rgba(0, 0, 0, 0.9), inset -2px -2px 0px rgba(255, 255, 255, 0.1)";
98
+ };
99
+ declare const retroEffects: {
100
+ readonly scanlineOpacity: "0.15";
101
+ readonly crtFlickerSpeed: "0.15s";
102
+ readonly pixelBorderWidth: "2px";
103
+ };
104
+ declare const zIndex: {
105
+ readonly hide: -1;
106
+ readonly auto: "auto";
107
+ readonly base: 0;
108
+ readonly docked: 10;
109
+ readonly dropdown: 1000;
110
+ readonly sticky: 1100;
111
+ readonly banner: 1200;
112
+ readonly overlay: 1300;
113
+ readonly modal: 1400;
114
+ readonly popover: 1500;
115
+ readonly skipLink: 1600;
116
+ readonly toast: 1700;
117
+ readonly tooltip: 1800;
118
+ };
119
+
120
+ /**
121
+ * Generates Moon-Inferno CSS Custom Property key-value pairs.
122
+ */
123
+ declare function getCSSVariableObject(): Record<string, string>;
124
+ /**
125
+ * Converts CSS variable object to string format for CSS rules.
126
+ */
127
+ declare function getCSSVariableString(): string;
128
+
129
+ /**
130
+ * Accessibility Focus Utilities
131
+ * Provides helpers for focus containment (focus traps), focus restoration, and tabbable elements.
132
+ */
133
+ /**
134
+ * Returns all focusable elements within a given container.
135
+ */
136
+ declare function getFocusableElements(container: HTMLElement): HTMLElement[];
137
+ /**
138
+ * Traps focus within a given container element.
139
+ * Useful for modal dialogs, drawers, and overlay menus.
140
+ */
141
+ declare function trapFocus(container: HTMLElement, event: KeyboardEvent): void;
142
+ /**
143
+ * Stores the previously focused element and provides a restoration function.
144
+ */
145
+ declare function createFocusStore(): {
146
+ save(): void;
147
+ restore(): void;
148
+ };
149
+
150
+ /**
151
+ * Reduced Motion Helper
152
+ * Utility to check if user prefers reduced motion.
153
+ */
154
+ /**
155
+ * Returns true if user has enabled prefers-reduced-motion in OS settings.
156
+ */
157
+ declare function isReducedMotionPreferred(): boolean;
158
+ /**
159
+ * Subscribes to changes in reduced motion user preferences.
160
+ */
161
+ declare function onReducedMotionChange(callback: (reduced: boolean) => void): () => void;
162
+
163
+ /**
164
+ * Keyboard Key Constants & Event Helpers
165
+ */
166
+ declare const KEYS: {
167
+ readonly ENTER: "Enter";
168
+ readonly SPACE: " ";
169
+ readonly ESCAPE: "Escape";
170
+ readonly TAB: "Tab";
171
+ readonly ARROW_UP: "ArrowUp";
172
+ readonly ARROW_DOWN: "ArrowDown";
173
+ readonly ARROW_LEFT: "ArrowLeft";
174
+ readonly ARROW_RIGHT: "ArrowRight";
175
+ readonly HOME: "Home";
176
+ readonly END: "End";
177
+ };
178
+ declare function isKey(event: KeyboardEvent, key: keyof typeof KEYS): boolean;
179
+ declare function isActionKey(event: KeyboardEvent): boolean;
180
+
181
+ export { KEYS, colors, createFocusStore, getCSSVariableObject, getCSSVariableString, getFocusableElements, isActionKey, isKey, isReducedMotionPreferred, onReducedMotionChange, radii, retroEffects, shadows, spacing, trapFocus, typography, zIndex };