agnostics 0.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 (68) hide show
  1. package/README.md +3 -0
  2. package/lib/helpers/_Express.js +30 -0
  3. package/lib/helpers/_Parsers.js +73 -0
  4. package/lib/helpers/_Window.js +0 -0
  5. package/lib/helpers/_Yargs.js +328 -0
  6. package/lib/helpers/index.js +9 -0
  7. package/lib/index.js +11 -0
  8. package/lib/inputs/_Callers.js +122 -0
  9. package/lib/inputs/_Checker.js +3 -0
  10. package/lib/inputs/_Native.js +223 -0
  11. package/lib/inputs/_Types.js +112 -0
  12. package/lib/inputs/index.js +10 -0
  13. package/lib/logger/_ASCII.js +39 -0
  14. package/lib/logger/_Defs.js +55 -0
  15. package/lib/logger/_Logger.js +159 -0
  16. package/lib/logger/_Settings.js +52 -0
  17. package/lib/logger/_System.js +191 -0
  18. package/lib/logger/chars.js +730 -0
  19. package/lib/logger/index.js +5 -0
  20. package/lib/schema/_Schema.js +33 -0
  21. package/lib/schema/index.js +16 -0
  22. package/lib/specification/_Properties.js +144 -0
  23. package/lib/specification/index.js +9 -0
  24. package/package.json +32 -0
  25. package/types/helpers/_Express.d.ts +2 -0
  26. package/types/helpers/_Express.d.ts.map +1 -0
  27. package/types/helpers/_Parsers.d.ts +2 -0
  28. package/types/helpers/_Parsers.d.ts.map +1 -0
  29. package/types/helpers/_Window.d.ts +2 -0
  30. package/types/helpers/_Window.d.ts.map +1 -0
  31. package/types/helpers/_Yargs.d.ts +44 -0
  32. package/types/helpers/_Yargs.d.ts.map +1 -0
  33. package/types/helpers/index.d.ts +2 -0
  34. package/types/helpers/index.d.ts.map +1 -0
  35. package/types/index.d.ts +4 -0
  36. package/types/index.d.ts.map +1 -0
  37. package/types/inputs/_Callers.d.ts +14 -0
  38. package/types/inputs/_Callers.d.ts.map +1 -0
  39. package/types/inputs/_Checker.d.ts +2 -0
  40. package/types/inputs/_Checker.d.ts.map +1 -0
  41. package/types/inputs/_Native.d.ts +212 -0
  42. package/types/inputs/_Native.d.ts.map +1 -0
  43. package/types/inputs/_Types.d.ts +34 -0
  44. package/types/inputs/_Types.d.ts.map +1 -0
  45. package/types/inputs/index.d.ts +3 -0
  46. package/types/inputs/index.d.ts.map +1 -0
  47. package/types/logger/_ASCII.d.ts +2 -0
  48. package/types/logger/_ASCII.d.ts.map +1 -0
  49. package/types/logger/_Defs.d.ts +54 -0
  50. package/types/logger/_Defs.d.ts.map +1 -0
  51. package/types/logger/_Logger.d.ts +5 -0
  52. package/types/logger/_Logger.d.ts.map +1 -0
  53. package/types/logger/_Settings.d.ts +24 -0
  54. package/types/logger/_Settings.d.ts.map +1 -0
  55. package/types/logger/_System.d.ts +10 -0
  56. package/types/logger/_System.d.ts.map +1 -0
  57. package/types/logger/chars.d.ts +93 -0
  58. package/types/logger/chars.d.ts.map +1 -0
  59. package/types/logger/index.d.ts +6 -0
  60. package/types/logger/index.d.ts.map +1 -0
  61. package/types/schema/_Schema.d.ts +11 -0
  62. package/types/schema/_Schema.d.ts.map +1 -0
  63. package/types/schema/index.d.ts +3 -0
  64. package/types/schema/index.d.ts.map +1 -0
  65. package/types/specification/_Properties.d.ts +158 -0
  66. package/types/specification/_Properties.d.ts.map +1 -0
  67. package/types/specification/index.d.ts +2 -0
  68. package/types/specification/index.d.ts.map +1 -0
@@ -0,0 +1,223 @@
1
+ //////////////////////////////////////////
2
+ // //
3
+ // //
4
+ // INPUTS //
5
+ // //
6
+ // //
7
+ //////////////////////////////////////////
8
+
9
+ import {
10
+ MinMaxCaller,
11
+ DefaultCaller,
12
+ ObjCaller,
13
+ ArrCaller,
14
+ EnumCaller,
15
+ EventCaller
16
+ } from './_Callers.js'
17
+ // --------- BUTTON ---------
18
+
19
+ export const Button = (event, schema) => EventCaller(event, { type: 'boolean', gui: 'button', ...schema })
20
+ export const ButtonHtml = def => ({ nodeName: 'input', type: 'button' })
21
+
22
+ // --------- CHECKBOX ---------
23
+
24
+ export const Checkbox = (value, schema) => DefaultCaller(value, { type: 'boolean', gui: 'checkbox', ...schema })
25
+ export const CheckboxHtml = def => ({ nodeName: 'input', type: 'checkbox' })
26
+
27
+ // --------- COLOR ---------
28
+
29
+ export const ColorPicker = (value, schema) => DefaultCaller(value, { type: 'color', gui: 'colorpicker', ...schema })
30
+ export const ColorPickerHtml = def => ({ nodeName: 'input', type: 'color' })
31
+
32
+ // --------- DATE ---------
33
+
34
+ export const Date = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'date', ...schema })
35
+ export const DateHtml = def => ({ nodeName: 'input', type: 'date' })
36
+
37
+ // --------- DATETIME ---------
38
+
39
+ export const Datetime = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'datetime', ...schema })
40
+ export const DatetimeHtml = def => ({ nodeName: 'input', type: 'datetime-local' })
41
+
42
+ // --------- EMAIL ---------
43
+
44
+ export const Email = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'email', ...schema })
45
+ export const EmailHtml = def => ({ nodeName: 'input', type: 'email' })
46
+
47
+ // --------- FILE ---------
48
+
49
+ export const File = (value, schema) => DefaultCaller(value, { type: 'buffer', gui: 'file', ...schema })
50
+ export const FileHtml = def => ({ accept: def.accept, nodeName: 'input', type: 'file' })
51
+
52
+ // --------- FILES ---------
53
+
54
+ export const Files = (value, schema) => DefaultCaller(value, { type: 'array', gui: 'files', ...schema })
55
+ export const FilesHtml = def => ({ accept: def.accept, multiple: true, nodeName: 'input', type: 'file' })
56
+
57
+ // --------- HIDDEN ---------
58
+
59
+ export const Hidden = (value, items, schema) => ArrCaller(value, items, { type: 'array', gui: 'files', ...schema })
60
+ export const HiddenHtml = def => ({ nodeName: 'input', type: 'hidden' })
61
+
62
+ // --------- MONTH ---------
63
+
64
+ export const Month = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'month', ...schema })
65
+ export const MonthHtml = def => ({ nodeName: 'input', type: 'month' })
66
+
67
+ // --------- NUMBER ---------
68
+
69
+ export const Number = (value, schema) => DefaultCaller(value, { type: 'number', gui: 'number', ...schema })
70
+ export const NumberHtml = def => ({ nodeName: 'input', type: 'number' })
71
+
72
+ // --------- PASSWORD ---------
73
+
74
+ export const Password = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'password', ...schema })
75
+ export const PasswordHtml = def => ({ nodeName: 'input', type: 'password' })
76
+
77
+ // --------- RADIO ---------
78
+
79
+ export const Radio = (value, enumOptions, schema) => EnumCaller(value, enumOptions, { type: 'enumeration', gui: 'radio', ...schema })
80
+ export const RadioHtml = def => ({
81
+ nodeName: 'fieldset',
82
+ children: def.enum.map(item => ({ nodeName: 'input', type: 'radio' }))
83
+ })
84
+
85
+ // --------- RANGE ---------
86
+
87
+ export const Range = (value, min, max, schema) => MinMaxCaller(value, min, max, { type: 'number', gui: 'range', ...schema })
88
+ export const RangeHtml = def => ({
89
+ nodeName: 'input', type: 'range', min: def.min, max: def.max, step: def.step,
90
+ aria: { formValuemin: def.min, formValuemax: def.max }
91
+ })
92
+
93
+ // --------- RESET ---------
94
+
95
+ export const Reset = (event, schema) => EventCaller(event, { type: 'boolean', gui: 'reset', ...schema })
96
+ export const ResetHtml = def => ({ nodeName: 'input', type: 'reset' })
97
+
98
+ // --------- SEARCH ---------
99
+
100
+ export const Search = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'search', ...schema })
101
+ export const SearchHtml = def => ({ nodeName: 'input', type: 'search' })
102
+
103
+ // --------- SELECT ---------
104
+
105
+ export const Select = (value, enumOptions, schema) => EnumCaller(value, enumOptions, { type: 'enumeration', gui: 'select', ...schema })
106
+ export const SelectHtml = def => ({
107
+ nodeName: 'select',
108
+ children: def.enum.map(item => ({ nodeName: 'option' }))
109
+ })
110
+
111
+ // --------- MULTISELECT ---------
112
+
113
+ export const Multiselect = (value, enumOptions, schema) => EnumCaller(value, enumOptions, { type: 'array', gui: 'multiselect', ...schema })
114
+ export const MultiselectHtml = def => ({
115
+ nodeName: 'select', multiple: true,
116
+ children: def.enum.map(item => ({ nodeName: 'option' }))
117
+ })
118
+
119
+ // --------- SUBMIT ---------
120
+
121
+ export const Submit = (event, schema) => EventCaller(event, { type: 'boolean', gui: 'submit', ...schema })
122
+ export const SubmitHtml = def => ({ nodeName: 'input', type: 'submit' })
123
+
124
+ // --------- TEL ---------
125
+
126
+ export const Tel = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'tel', ...schema })
127
+ export const TelHtml = def => ({ nodeName: 'input', type: 'tel' })
128
+
129
+ // --------- TEXT ---------
130
+
131
+ export const Text = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'text', ...schema })
132
+ export const TextHtml = def => ({
133
+ nodeName: 'input', type: 'text', placeholder: def.placeholder,
134
+ pattern: def.pattern, minlength: def.min, maxlength: def.max
135
+ })
136
+
137
+ // --------- TEXTAREA ---------
138
+
139
+ export const Textarea = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'textarea', ...schema })
140
+ export const TextareaHtml = def => ({
141
+ nodeName: 'textarea', placeholder: def.placeholder,
142
+ minlength: def.min, maxlength: def.max, rows: def.size,
143
+ aria: { multiline: true }
144
+ })
145
+
146
+ // --------- TIME ---------
147
+
148
+ export const Time = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'time', ...schema })
149
+ export const TimeHtml = def => ({ nodeName: 'input', type: 'time' })
150
+
151
+ // --------- URL ---------
152
+
153
+ export const Url = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'url', ...schema })
154
+ export const UrlHtml = def => ({ nodeName: 'input', type: 'url' })
155
+
156
+ // --------- WEEK ---------
157
+
158
+ export const Week = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'week', ...schema })
159
+ export const WeekHtml = def => ({ nodeName: 'input', type: 'week' })
160
+
161
+ // --------- METER ---------
162
+
163
+ export const Meter = (value, schema) => DefaultCaller(value, { type: 'number', gui: 'meter', ...schema })
164
+ export const MeterHtml = def => ({ nodeName: 'meter', min: def.min, max: def.max, low: def.min, high: def.max })
165
+
166
+ // --------- FIELDSET ---------
167
+
168
+ export const Fieldset = (properties, schema) => ObjCaller(properties, { type: 'object', gui: 'fieldset', ...schema })
169
+ export const FieldsetHtml = def => ({ nodeName: 'fieldset' })
170
+
171
+ // --------- FORM ---------
172
+
173
+ export const Form = (properties, schema) => ObjCaller(properties, { type: 'object', gui: 'form', ...schema })
174
+ export const FormHtml = def => ({ nodeName: 'form' })
175
+
176
+ // --------- DATA ---------
177
+
178
+ export const Data = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'data', ...schema })
179
+ export const DataHtml = def => ({ nodeName: 'data' })
180
+
181
+ // --------- VEC4 ---------
182
+
183
+ export const XY = (value, enumOptions, schema) => EnumCaller(value, enumOptions, { type: 'vec2', gui: 'xy', ...schema })
184
+ export const XYHtml = def => ({
185
+ nodeName: 'fieldset',
186
+ children: ['x', 'y'].map(() => RangeHtml(def))
187
+ })
188
+
189
+ // --------- VEC3 ---------
190
+
191
+ export const XYZ = (value, enumOptions, schema) => EnumCaller(value, enumOptions, { type: 'vec3', gui: 'xyz', ...schema })
192
+ export const XYZHtml = def => ({
193
+ nodeName: 'fieldset',
194
+ children: ['x', 'y', 'z'].map(() => RangeHtml(def))
195
+ })
196
+
197
+ // --------- VVEC4 ---------
198
+
199
+ export const XYZW = (value, enumOptions, schema) => EnumCaller(value, enumOptions, { type: 'vec4', gui: 'xyzw', ...schema })
200
+ export const XYZWHtml = def => ({
201
+ nodeName: 'fieldset',
202
+ children: ['x', 'y', 'z', 'w'].map(() => RangeHtml(def))
203
+ })
204
+
205
+ /* MISC GUI
206
+
207
+ <optgroup> / <option> difference
208
+ <details> / <summary> list group dropdown (native)
209
+ <dialog>
210
+ <map> / <area> quite nice
211
+ <progress> similar to meter
212
+
213
+ */
214
+
215
+
216
+ /*
217
+
218
+ CSSGUI =
219
+ DIV :hover / :focus / :active based dropdown
220
+ SELECT "base-select" https://caniuse.com/mdn-css_properties_appearance_base-select
221
+ Popover API - this is the one for dropdowns etc
222
+
223
+ */
@@ -0,0 +1,112 @@
1
+ //////////////////////////////////////////
2
+ // //
3
+ // //
4
+ // TYPES //
5
+ // //
6
+ // //
7
+ //////////////////////////////////////////
8
+
9
+ import {
10
+ MinMaxCaller,
11
+ DefaultCaller,
12
+ ObjCaller,
13
+ ArrCaller,
14
+ EnumCaller,
15
+ EventCaller
16
+ } from './_Callers.js'
17
+
18
+
19
+
20
+ // ========= TYPES =========
21
+
22
+ // --------- BANG ---------
23
+
24
+ export const isBang = type => type.startsWith('bang')
25
+ export const Bang = (event, schema) => EventCaller(event, { type: 'bang', gui: 'button', ...schema })
26
+
27
+ // --------- INT ---------
28
+
29
+ export const isInt = type => type.startsWith('int')
30
+ export const Int = (value, min, max, schema) => MinMaxCaller(value, min, max, { type: 'integer', gui: 'number', ...schema })
31
+
32
+ // --------- FLOAT ---------
33
+
34
+ export const isFloat = type => type.startsWith('float') || type.startsWith('doubl')
35
+ export const Float = (value, min, max, schema) => MinMaxCaller(value, min, max, { type: 'float', gui: 'number', ...schema })
36
+
37
+ // --------- NUM ---------
38
+
39
+ export const isNum = type =>
40
+ type.startsWith('num') ||
41
+ type.startsWith('int') ||
42
+ type.startsWith('float') ||
43
+ type.startsWith('doubl')
44
+ export const Num = (value, min, max, schema) => MinMaxCaller(value, min, max, { type: 'number', gui: 'number', ...schema })
45
+
46
+ // --------- ENUM ---------
47
+
48
+ export const isEnum = type => type.startsWith('enum')
49
+ export const Enum = (value, enumOptions, schema) => EnumCaller(value, enumOptions, { type: 'enumeration', gui: 'select', ...schema })
50
+
51
+ // --------- ARR ---------
52
+
53
+ export const isArr = type => type.startsWith('arr')
54
+ export const Arr = (value, items, schema) => ArrCaller(value, items, { type: 'array', gui: 'multiselect', ...schema })
55
+
56
+ // --------- OBJ ---------
57
+
58
+ export const isObj = type =>
59
+ type.startsWith('obj') ||
60
+ type.startsWith('map') ||
61
+ type.startsWith('dict')
62
+ export const Obj = (properties, schema) => ObjCaller(properties, { type: 'object', gui: 'fieldset', ...schema })
63
+
64
+ // --------- STR ---------
65
+
66
+ export const isStr = type => type.startsWith('str')
67
+ export const Str = (value, schema) => DefaultCaller(value, { type: 'string', gui: 'text', ...schema })
68
+
69
+ // --------- BOOL ---------
70
+
71
+ export const isBool = type => type.startsWith('bool')
72
+ export const Bool = (value, schema) => DefaultCaller(value, { type: 'boolean', gui: 'checkbox', ...schema })
73
+
74
+ // --------- COLOR ---------
75
+
76
+ export const isColor = type =>
77
+ type.startsWith('colo') ||
78
+ type.startsWith('hsl') ||
79
+ type.startsWith('rgb') ||
80
+ type.startsWith('hsv')
81
+ export const Color = (value, schema) => DefaultCaller(value, { type: 'color', gui: 'color', ...schema })
82
+
83
+ // --------- VEC2 ---------
84
+
85
+ export const isVec2 = type => type.startsWith('vec') && type.endsWith('2')
86
+ export const Vec2 = (value, schema) => DefaultCaller(value, { type: 'vec2', gui: 'xy', ...schema })
87
+
88
+ // --------- VEC3 ---------
89
+
90
+ export const isVec3 = type => type.startsWith('vec') && type.endsWith('3')
91
+ export const Vec3 = (value, schema) => DefaultCaller(value, { type: 'vec3', gui: 'xyz', ...schema })
92
+
93
+ // --------- VEC4 ---------
94
+
95
+ export const isVec4 = type => type.startsWith('vec') && type.endsWith('4')
96
+ export const Vec4 = (value, schema) => DefaultCaller(value, { type: 'vec4', gui: 'xyzw', ...schema })
97
+
98
+ // --------- BUFFER ---------
99
+
100
+ export const BUFF = 'buffer'
101
+ export const isBuff = type => type.startsWith('buff') || type.startsWith('base')
102
+ export const Buff = (value, schema) => DefaultCaller(value, { type: 'buffer', gui: 'data', ...schema })
103
+
104
+ // --------- TEXTURE ---------
105
+
106
+ export const isTex = type => type.startsWith('tex') || type.startsWith('samp')
107
+ export const Tex = (value, schema) => DefaultCaller(value, { type: 'texture', gui: 'data', ...schema })
108
+
109
+ // --------- ANY ---------
110
+
111
+ export const isAny = type => true
112
+ export const Any = (value, schema) => DefaultCaller(value, { type: 'any', gui: 'data', ...schema })
@@ -0,0 +1,10 @@
1
+ //////////////////////////////////////////
2
+ // //
3
+ // //
4
+ // INPUTS //
5
+ // //
6
+ // //
7
+ //////////////////////////////////////////
8
+
9
+ export * from './_Types.js'
10
+ export * from './_Native.js'
@@ -0,0 +1,39 @@
1
+
2
+ //////////////////////////////////////////
3
+ // //
4
+ // //
5
+ // ASCII //
6
+ // //
7
+ // //
8
+ //////////////////////////////////////////
9
+
10
+ import chars from './chars.js'
11
+
12
+
13
+ export function BigText( string ) {
14
+
15
+
16
+ const height = chars?.[0].length
17
+ const spacing = 1
18
+
19
+
20
+ let text = ''
21
+
22
+ for (let y = 0; y < height; y++) {
23
+ for (let i = 0; i < string.length; i++) {
24
+
25
+ const letter = string[i]
26
+ const line = chars[letter][y]
27
+ text += line
28
+ text += ('').padEnd(spacing)
29
+ }
30
+
31
+ text += '\n'
32
+ }
33
+
34
+ return text
35
+
36
+
37
+ }
38
+
39
+ // looks great whatever it is
@@ -0,0 +1,55 @@
1
+ //////////////////////////////////////////
2
+ // //
3
+ // //
4
+ // DEFS //
5
+ // //
6
+ // //
7
+ //////////////////////////////////////////
8
+
9
+ export const Timestamp = ( from = 0, to = 3, space = '-' ) => {
10
+
11
+ const str = new Date().toISOString()
12
+ from = from > 0 ? 5 + ((from-1) * 3) : 0
13
+ to = to > 0 ? 4 + ((to-1) * 3) : 0
14
+ return str.slice(from, to).replace(/[:T]/g, space)
15
+ }
16
+
17
+ export const ANSI = {
18
+ reset: "\x1b[0m",
19
+ black: "\x1b[30m",
20
+ gray: "\x1b[90m",
21
+ red: "\x1b[91m",
22
+ green: "\x1b[92m",
23
+ yellow: "\x1b[93m",
24
+ blue: "\x1b[94m",
25
+ magenta: "\x1b[95m",
26
+ cyan: "\x1b[96m",
27
+ white: "\x1b[97m",
28
+ }
29
+
30
+
31
+ export const ANSIDark = {
32
+ black: 'rgb(120, 120, 120)',
33
+ gray: 'rgb(180,180,180)',
34
+ red: 'rgb(255,140,140)',
35
+ green: 'rgb(130,255,130)',
36
+ yellow: 'rgb(255,255,120)',
37
+ blue: 'rgb(200,200,255)',
38
+ magenta: 'rgb(255,160,255)',
39
+ cyan: 'rgb(120,255,255)',
40
+ white: 'rgb(255,255,255)',
41
+ }
42
+
43
+
44
+ export const ANSILight = {
45
+ white: 'rgb(0, 0, 0)',
46
+ gray: 'rgb(120,120,120)',
47
+ red: 'rgb(255,30,30)',
48
+ green: 'rgb(40,190,80)',
49
+ yellow: 'rgb(255,180,0)',
50
+ blue: 'rgb(0,80,250)',
51
+ magenta: 'rgb(240,80,240)',
52
+ cyan: 'rgb(40,180,180)',
53
+ black: 'rgb(200,200,200)',
54
+ }
55
+
@@ -0,0 +1,159 @@
1
+ //////////////////////////////////////////
2
+ // //
3
+ // //
4
+ // LOGGER //
5
+ // //
6
+ // //
7
+ //////////////////////////////////////////
8
+
9
+ import { ANSI, ANSIDark, ANSILight, Timestamp } from './_Defs.js'
10
+ import { Settings } from './_Settings.js'
11
+
12
+ export function ExtractMetaName( url ) {
13
+
14
+ return url.split('/').reverse().slice(0,2).map( str => {
15
+ if (str.charAt(0) == '_' || str.charAt(0) == '$') str = str.substring(1)
16
+ let split = str.split('.')
17
+ split = split.slice(0,Math.max(split.length-1,1))
18
+ return split.join('')
19
+
20
+ }).reverse().join(':')
21
+ }
22
+
23
+ function CreateMethod( method, name, filename, timestamp, prepend, color, log, trace ) {
24
+
25
+ return (...args) => {
26
+
27
+ const ts = timestamp ? Timestamp(...timestamp) + ' ' : ''
28
+ const label = name ? `[${name}] ` : ''
29
+
30
+ if (typeof process !== 'undefined') {
31
+
32
+ const ansiColor = ANSI[color] || ANSI.gray
33
+
34
+ let text = `${ansiColor}${ts}${label}${prepend || ''}`
35
+
36
+ let first = true
37
+ const rest = [];
38
+
39
+ for (const arg of args) {
40
+ if (first && typeof arg === 'string') {
41
+ text += arg + ' '
42
+ first = false;
43
+ } else {
44
+ rest.push(arg);
45
+ }
46
+ }
47
+
48
+ text = text.trimEnd() + ANSI.reset
49
+
50
+ if (log) globalThis.SAYLogger[method](text, ...rest)
51
+
52
+ } else {
53
+
54
+ const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
55
+ const cssColor = isDarkMode ? ANSIDark[color] : ANSILight[color]
56
+
57
+ const parts = [`%c${ts}${label}${prepend || ''}`, `color:${cssColor}`]
58
+
59
+ let i = 0;
60
+ for (const arg of args) {
61
+ if (i === 0 && typeof arg === 'string') {
62
+ parts[0] += arg + ' '
63
+ } else {
64
+ parts[0] += '%o '
65
+ parts.push(arg)
66
+ }
67
+ i++
68
+ }
69
+
70
+ if (log) globalThis.SAYLogger[method](...parts)
71
+ }
72
+
73
+ if (globalThis.SAYBuffer) globalThis.SAYBuffer[method](...args)
74
+
75
+ }
76
+
77
+
78
+ }
79
+
80
+ export function CreateLogger( filename, overrides = {} ) {
81
+
82
+ const name = ExtractMetaName( filename )
83
+ const config = { ...Settings, ...overrides }
84
+
85
+ if (!globalThis.SAYLogger) {
86
+ globalThis.SAYLogger = {
87
+ log: console.log,
88
+ info: console.info,
89
+ error: console.error,
90
+ warn: console.warn,
91
+ trace: console.trace,
92
+ }
93
+ }
94
+
95
+ const output = {
96
+ [config.infoName]: CreateMethod(
97
+ 'info',
98
+ name,
99
+ filename,
100
+ config.timestamp,
101
+ config.infoPrepend,
102
+ config.infoColor,
103
+ config.verbose,
104
+ false
105
+ ),
106
+
107
+ [config.warnName]: CreateMethod(
108
+ 'warn',
109
+ name,
110
+ filename,
111
+ config.timestamp,
112
+ config.warnPrepend,
113
+ config.warnColor,
114
+ config.verbose,
115
+ false
116
+ ),
117
+
118
+ [config.successName]: CreateMethod(
119
+ 'log',
120
+ name,
121
+ filename,
122
+ config.timestamp,
123
+ config.successPrepend,
124
+ config.successColor,
125
+ config.verbose || config.info,
126
+ false
127
+ ),
128
+
129
+ [config.errorName]: CreateMethod(
130
+ 'error',
131
+ name,
132
+ filename,
133
+ config.timestamp,
134
+ config.errorPrepend,
135
+ config.errorColor,
136
+ true,
137
+ config.verbose
138
+ ),
139
+
140
+ [config.debugName]: CreateMethod(
141
+ 'log',
142
+ name,
143
+ filename,
144
+ config.timestamp,
145
+ config.debugPrepend,
146
+ config.debugColor,
147
+ config.debug || config.verbose,
148
+ false
149
+ )
150
+ }
151
+
152
+ output[config.infoName][config.warnName] = output[config.warnName]
153
+ output[config.infoName][config.successName] = output[config.successName]
154
+ output[config.infoName][config.errorName] = output[config.errorName]
155
+ output[config.infoName][config.debugName] = output[config.debugName]
156
+
157
+ return output
158
+
159
+ }
@@ -0,0 +1,52 @@
1
+ //////////////////////////////////////////
2
+ // //
3
+ // //
4
+ // SETTINGS //
5
+ // //
6
+ // //
7
+ //////////////////////////////////////////
8
+
9
+ /*
10
+
11
+ follows usual patterns:
12
+
13
+ standard
14
+ warning
15
+ error
16
+ success
17
+
18
+ additionally:
19
+
20
+ debug
21
+
22
+ for additional visual formatting
23
+
24
+ */
25
+
26
+ export const Settings = {
27
+ verbose: true, // shows all
28
+ info: true, // shows warnings + success
29
+ timestamp: null, // [3, 7, '-'],
30
+
31
+ infoPrepend: '⬤ ',
32
+ debugPrepend: '⬤ ',
33
+ warnPrepend: '⬤ ',
34
+ errorPrepend: '⬤ ',
35
+ successPrepend: '⬤ ',
36
+
37
+ infoName: 'SAY',
38
+ debugName: 'HUH',
39
+ warnName: 'HMM',
40
+ errorName: 'ERR',
41
+ successName: 'YAY',
42
+
43
+ infoColor: 'blue',
44
+ debugColor: 'magenta',
45
+ warnColor: 'yellow',
46
+ errorColor: 'red',
47
+ successColor: 'green',
48
+
49
+ onCrash: null,
50
+ onExit: null,
51
+ filename: '.logs/$TIMESTAMP.log'
52
+ }