@symbo.ls/scratch 3.0.2 → 3.1.2

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.
@@ -25,16 +25,16 @@ __export(sprite_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(sprite_exports);
27
27
 
28
- // ../../node_modules/@domql/utils/globals.js
28
+ // ../../../domql/packages/utils/globals.js
29
29
  var window2 = globalThis;
30
30
  var document2 = window2.document;
31
31
 
32
- // ../../node_modules/@domql/utils/node.js
32
+ // ../../../domql/packages/utils/node.js
33
33
  var isDOMNode = (obj) => {
34
34
  return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
35
35
  };
36
36
 
37
- // ../../node_modules/@domql/utils/types.js
37
+ // ../../../domql/packages/utils/types.js
38
38
  var isString = (arg) => typeof arg === "string";
39
39
  var isFunction = (arg) => typeof arg === "function";
40
40
  var isNull = (arg) => arg === null;
@@ -47,7 +47,7 @@ var isUndefined = (arg) => {
47
47
  return arg === void 0;
48
48
  };
49
49
 
50
- // ../../node_modules/@domql/utils/array.js
50
+ // ../../../domql/packages/utils/array.js
51
51
  var unstackArrayOfObjects = (arr, exclude = []) => {
52
52
  return arr.reduce(
53
53
  (a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
@@ -55,7 +55,7 @@ var unstackArrayOfObjects = (arr, exclude = []) => {
55
55
  );
56
56
  };
57
57
 
58
- // ../../node_modules/@domql/utils/keys.js
58
+ // ../../../domql/packages/utils/keys.js
59
59
  var STATE_METHODS = [
60
60
  "update",
61
61
  "parse",
@@ -126,7 +126,7 @@ var METHODS_EXL = [
126
126
  ...PROPS_METHODS
127
127
  ];
128
128
 
129
- // ../../node_modules/@domql/utils/object.js
129
+ // ../../../domql/packages/utils/object.js
130
130
  var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
131
131
  for (const e in extend) {
132
132
  const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e);
@@ -193,9 +193,84 @@ var deepClone = (obj, options = {}) => {
193
193
  return clone;
194
194
  };
195
195
 
196
- // ../../node_modules/@domql/utils/cookie.js
196
+ // ../../../domql/packages/utils/cookie.js
197
197
  var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
198
198
 
199
+ // ../../../domql/packages/event/dist/esm/keys.js
200
+ var STATE_METHODS2 = [
201
+ "update",
202
+ "parse",
203
+ "clean",
204
+ "create",
205
+ "destroy",
206
+ "add",
207
+ "toggle",
208
+ "remove",
209
+ "apply",
210
+ "set",
211
+ "reset",
212
+ "replace",
213
+ "quietReplace",
214
+ "quietUpdate",
215
+ "applyReplace",
216
+ "applyFunction",
217
+ "keys",
218
+ "values",
219
+ "ref",
220
+ "rootUpdate",
221
+ "parentUpdate",
222
+ "parent",
223
+ "__element",
224
+ "__depends",
225
+ "__ref",
226
+ "__children",
227
+ "root",
228
+ "setByPath",
229
+ "setPathCollection",
230
+ "removeByPath",
231
+ "removePathCollection",
232
+ "getByPath"
233
+ ];
234
+ var PROPS_METHODS2 = ["update", "__element"];
235
+ var METHODS2 = [
236
+ "set",
237
+ "reset",
238
+ "update",
239
+ "remove",
240
+ "updateContent",
241
+ "removeContent",
242
+ "lookup",
243
+ "lookdown",
244
+ "lookdownAll",
245
+ "getRef",
246
+ "getPath",
247
+ "setNodeStyles",
248
+ "spotByPath",
249
+ "keys",
250
+ "parse",
251
+ "setProps",
252
+ "parseDeep",
253
+ "variables",
254
+ "if",
255
+ "log",
256
+ "verbose",
257
+ "warn",
258
+ "error",
259
+ "call",
260
+ "nextElement",
261
+ "previousElement"
262
+ ];
263
+ var METHODS_EXL2 = [
264
+ ...["node", "context", "extends", "__element", "__ref"],
265
+ ...METHODS2,
266
+ ...STATE_METHODS2,
267
+ ...PROPS_METHODS2
268
+ ];
269
+
270
+ // ../../../domql/packages/event/dist/esm/globals.js
271
+ var window3 = globalThis;
272
+ var document3 = window3.document;
273
+
199
274
  // src/defaultConfig/index.js
200
275
  var defaultConfig_exports = {};
201
276
  __export(defaultConfig_exports, {
@@ -418,6 +493,8 @@ var getActiveConfig = (def) => {
418
493
  };
419
494
 
420
495
  // src/utils/sprite.js
496
+ var ENV = "development";
497
+ var isDev = ENV === "development" || ENV === "testing";
421
498
  var generateSprite = (icons) => {
422
499
  const CONFIG2 = getActiveConfig();
423
500
  let sprite = "";
@@ -431,7 +508,8 @@ var generateSprite = (icons) => {
431
508
  var parseRootAttributes = (htmlString) => {
432
509
  const val = htmlString.default || htmlString;
433
510
  if (!isString(val)) {
434
- return console.warn(`parseRootAttributes: ${val} is not a string`);
511
+ if (isDev) console.warn("parseRootAttributes:", val, "is not a string");
512
+ return;
435
513
  }
436
514
  const match = val.match(/<svg\s+(.*?)>/);
437
515
  if (!match || !match[1]) {
@@ -473,3 +551,4 @@ var convertSvgToSymbol = (key, code) => {
473
551
  symbol = symbol.replace("</svg", "</symbol");
474
552
  return symbol;
475
553
  };
554
+ // @preserve-env
@@ -83,7 +83,7 @@ var require_cjs = __commonJS({
83
83
  var isString2 = (arg) => typeof arg === "string";
84
84
  var isNumber2 = (arg) => typeof arg === "number";
85
85
  var isArray2 = (arg) => Array.isArray(arg);
86
- var STATE_METHODS2 = [
86
+ var STATE_METHODS3 = [
87
87
  "update",
88
88
  "parse",
89
89
  "clean",
@@ -117,8 +117,8 @@ var require_cjs = __commonJS({
117
117
  "removePathCollection",
118
118
  "getByPath"
119
119
  ];
120
- var PROPS_METHODS2 = ["update", "__element"];
121
- var METHODS2 = [
120
+ var PROPS_METHODS3 = ["update", "__element"];
121
+ var METHODS3 = [
122
122
  "set",
123
123
  "reset",
124
124
  "update",
@@ -146,13 +146,84 @@ var require_cjs = __commonJS({
146
146
  "nextElement",
147
147
  "previousElement"
148
148
  ];
149
- var METHODS_EXL2 = [
149
+ var METHODS_EXL3 = [
150
150
  ...["node", "context", "extends", "__element", "__ref"],
151
- ...METHODS2,
152
- ...STATE_METHODS2,
153
- ...PROPS_METHODS2
151
+ ...METHODS3,
152
+ ...STATE_METHODS3,
153
+ ...PROPS_METHODS3
154
154
  ];
155
155
  var isMobile2 = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
156
+ var STATE_METHODS22 = [
157
+ "update",
158
+ "parse",
159
+ "clean",
160
+ "create",
161
+ "destroy",
162
+ "add",
163
+ "toggle",
164
+ "remove",
165
+ "apply",
166
+ "set",
167
+ "reset",
168
+ "replace",
169
+ "quietReplace",
170
+ "quietUpdate",
171
+ "applyReplace",
172
+ "applyFunction",
173
+ "keys",
174
+ "values",
175
+ "ref",
176
+ "rootUpdate",
177
+ "parentUpdate",
178
+ "parent",
179
+ "__element",
180
+ "__depends",
181
+ "__ref",
182
+ "__children",
183
+ "root",
184
+ "setByPath",
185
+ "setPathCollection",
186
+ "removeByPath",
187
+ "removePathCollection",
188
+ "getByPath"
189
+ ];
190
+ var PROPS_METHODS22 = ["update", "__element"];
191
+ var METHODS22 = [
192
+ "set",
193
+ "reset",
194
+ "update",
195
+ "remove",
196
+ "updateContent",
197
+ "removeContent",
198
+ "lookup",
199
+ "lookdown",
200
+ "lookdownAll",
201
+ "getRef",
202
+ "getPath",
203
+ "setNodeStyles",
204
+ "spotByPath",
205
+ "keys",
206
+ "parse",
207
+ "setProps",
208
+ "parseDeep",
209
+ "variables",
210
+ "if",
211
+ "log",
212
+ "verbose",
213
+ "warn",
214
+ "error",
215
+ "call",
216
+ "nextElement",
217
+ "previousElement"
218
+ ];
219
+ var METHODS_EXL22 = [
220
+ ...["node", "context", "extends", "__element", "__ref"],
221
+ ...METHODS22,
222
+ ...STATE_METHODS22,
223
+ ...PROPS_METHODS22
224
+ ];
225
+ var window32 = globalThis;
226
+ var document32 = window32.document;
156
227
  async function toggleFullscreen(opts) {
157
228
  if (!document.fullscreenElement) {
158
229
  try {
@@ -333,16 +404,16 @@ __export(var_exports, {
333
404
  });
334
405
  module.exports = __toCommonJS(var_exports);
335
406
 
336
- // ../../node_modules/@domql/utils/globals.js
407
+ // ../../../domql/packages/utils/globals.js
337
408
  var window2 = globalThis;
338
409
  var document2 = window2.document;
339
410
 
340
- // ../../node_modules/@domql/utils/node.js
411
+ // ../../../domql/packages/utils/node.js
341
412
  var isDOMNode = (obj) => {
342
413
  return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
343
414
  };
344
415
 
345
- // ../../node_modules/@domql/utils/types.js
416
+ // ../../../domql/packages/utils/types.js
346
417
  var isFunction = (arg) => typeof arg === "function";
347
418
  var isNull = (arg) => arg === null;
348
419
  var isArray = (arg) => Array.isArray(arg);
@@ -354,7 +425,7 @@ var isUndefined = (arg) => {
354
425
  return arg === void 0;
355
426
  };
356
427
 
357
- // ../../node_modules/@domql/utils/array.js
428
+ // ../../../domql/packages/utils/array.js
358
429
  var unstackArrayOfObjects = (arr, exclude = []) => {
359
430
  return arr.reduce(
360
431
  (a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
@@ -362,7 +433,7 @@ var unstackArrayOfObjects = (arr, exclude = []) => {
362
433
  );
363
434
  };
364
435
 
365
- // ../../node_modules/@domql/utils/keys.js
436
+ // ../../../domql/packages/utils/keys.js
366
437
  var STATE_METHODS = [
367
438
  "update",
368
439
  "parse",
@@ -433,7 +504,7 @@ var METHODS_EXL = [
433
504
  ...PROPS_METHODS
434
505
  ];
435
506
 
436
- // ../../node_modules/@domql/utils/object.js
507
+ // ../../../domql/packages/utils/object.js
437
508
  var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
438
509
  for (const e in extend) {
439
510
  const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e);
@@ -500,9 +571,84 @@ var deepClone = (obj, options = {}) => {
500
571
  return clone;
501
572
  };
502
573
 
503
- // ../../node_modules/@domql/utils/cookie.js
574
+ // ../../../domql/packages/utils/cookie.js
504
575
  var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
505
576
 
577
+ // ../../../domql/packages/event/dist/esm/keys.js
578
+ var STATE_METHODS2 = [
579
+ "update",
580
+ "parse",
581
+ "clean",
582
+ "create",
583
+ "destroy",
584
+ "add",
585
+ "toggle",
586
+ "remove",
587
+ "apply",
588
+ "set",
589
+ "reset",
590
+ "replace",
591
+ "quietReplace",
592
+ "quietUpdate",
593
+ "applyReplace",
594
+ "applyFunction",
595
+ "keys",
596
+ "values",
597
+ "ref",
598
+ "rootUpdate",
599
+ "parentUpdate",
600
+ "parent",
601
+ "__element",
602
+ "__depends",
603
+ "__ref",
604
+ "__children",
605
+ "root",
606
+ "setByPath",
607
+ "setPathCollection",
608
+ "removeByPath",
609
+ "removePathCollection",
610
+ "getByPath"
611
+ ];
612
+ var PROPS_METHODS2 = ["update", "__element"];
613
+ var METHODS2 = [
614
+ "set",
615
+ "reset",
616
+ "update",
617
+ "remove",
618
+ "updateContent",
619
+ "removeContent",
620
+ "lookup",
621
+ "lookdown",
622
+ "lookdownAll",
623
+ "getRef",
624
+ "getPath",
625
+ "setNodeStyles",
626
+ "spotByPath",
627
+ "keys",
628
+ "parse",
629
+ "setProps",
630
+ "parseDeep",
631
+ "variables",
632
+ "if",
633
+ "log",
634
+ "verbose",
635
+ "warn",
636
+ "error",
637
+ "call",
638
+ "nextElement",
639
+ "previousElement"
640
+ ];
641
+ var METHODS_EXL2 = [
642
+ ...["node", "context", "extends", "__element", "__ref"],
643
+ ...METHODS2,
644
+ ...STATE_METHODS2,
645
+ ...PROPS_METHODS2
646
+ ];
647
+
648
+ // ../../../domql/packages/event/dist/esm/globals.js
649
+ var window3 = globalThis;
650
+ var document3 = window3.document;
651
+
506
652
  // src/defaultConfig/index.js
507
653
  var defaultConfig_exports = {};
508
654
  __export(defaultConfig_exports, {
@@ -725,7 +871,7 @@ var getActiveConfig = (def) => {
725
871
  };
726
872
 
727
873
  // src/utils/sequence.js
728
- var import_utils5 = __toESM(require_cjs(), 1);
874
+ var import_utils4 = __toESM(require_cjs(), 1);
729
875
 
730
876
  // src/utils/unit.js
731
877
  var isScalingUnit = (unit) => {
@@ -818,3 +964,4 @@ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
818
964
  CSS_VARS2[item.variable + "_" + mediaName] = value;
819
965
  }
820
966
  };
967
+ // @preserve-env
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/scratch",
3
3
  "description": "Φ / CSS framework and methodology.",
4
4
  "author": "symbo.ls",
5
- "version": "3.0.2",
5
+ "version": "3.1.2",
6
6
  "files": [
7
7
  "src",
8
8
  "dist"
@@ -25,10 +25,9 @@
25
25
  "prepublish": "rimraf -I dist && npm run build && npm run copy:package:cjs"
26
26
  },
27
27
  "dependencies": {
28
- "@domql/globals": "latest",
29
- "@domql/utils": "^3.0.0",
30
- "@symbo.ls/utils": "^3.0.2",
28
+ "@domql/utils": "^3.1.2",
29
+ "@symbo.ls/utils": "^3.1.2",
31
30
  "color-contrast-checker": "^1.5.0"
32
31
  },
33
- "gitHead": "c4dacc88fa3a65574680d11e320307dd2a22e6e9"
32
+ "gitHead": "429b36616aa04c8587a26ce3c129815115e35897"
34
33
  }
package/src/set.js CHANGED
@@ -78,7 +78,14 @@ export const setEach = (factoryName, props) => {
78
78
  const CONFIG = getActiveConfig()
79
79
  const FACTORY_NAME = factoryName.toUpperCase()
80
80
  const keys = Object.keys(props)
81
- keys.map(key => setValue(FACTORY_NAME, props[key], key))
81
+
82
+ keys.forEach((key) => {
83
+ try {
84
+ return setValue(FACTORY_NAME, props[key], key)
85
+ } catch (error) {
86
+ if (CONFIG.verbose) console.warn('Error setting', FACTORY_NAME, 'value', props[key], key, error)
87
+ }
88
+ })
82
89
 
83
90
  return CONFIG[FACTORY_NAME]
84
91
  }
@@ -125,9 +132,21 @@ export const set = (recivedConfig, options = SET_OPTIONS) => {
125
132
  keys.map(key => setEach(key, config[key]))
126
133
 
127
134
  // apply generic configs
128
- if (config.TYPOGRAPHY) applyTypographySequence()
129
- if (config.SPACING) applySpacingSequence()
130
- if (config.TIMING) applyTimingSequence()
135
+ if (config.TYPOGRAPHY) {
136
+ try { applyTypographySequence() } catch (e) {
137
+ if (CONFIG.verbose) console.warn('Error applying typography sequence', e)
138
+ }
139
+ }
140
+ if (config.SPACING) {
141
+ try { applySpacingSequence() } catch (e) {
142
+ if (CONFIG.verbose) console.warn('Error applying typography sequence', e)
143
+ }
144
+ }
145
+ if (config.TIMING) {
146
+ try { applyTimingSequence() } catch (e) {
147
+ if (CONFIG.verbose) console.warn('Error applying typography sequence', e)
148
+ }
149
+ }
131
150
  applyDocument()
132
151
  applyReset()
133
152
 
@@ -76,8 +76,9 @@ export const applyHeadings = (props) => {
76
76
  for (const k in HEADINGS) {
77
77
  const headerName = `h${parseInt(k) + 1}`
78
78
  const headerStyle = templates[headerName]
79
+ if (!HEADINGS[k]) continue
79
80
  templates[headerName] = {
80
- fontSize: CONFIG.useVariable ? `var(${HEADINGS[k].variable})` : `${HEADINGS[k].scaling}${unit}`,
81
+ fontSize: CONFIG.useVariable ? `var(${HEADINGS[k]?.variable})` : `${HEADINGS[k].scaling}${unit}`,
81
82
  margin: headerStyle ? headerStyle.margin : 0,
82
83
  lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
83
84
  letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
@@ -151,7 +151,7 @@ export const mixTwoRgba = (colorA, colorB, range = 0.5) => {
151
151
  export const opacify = (color, opacity) => {
152
152
  const arr = colorStringToRgbaArray(color)
153
153
  if (!arr) {
154
- if (ENV === 'test' || ENV === 'development') console.warn(color + ' color is not rgba')
154
+ if (ENV === 'testing' || ENV === 'development') console.warn(color + ' color is not rgba')
155
155
  return
156
156
  }
157
157
  arr[3] = opacity
@@ -170,8 +170,13 @@ export const generateSequence = (sequenceProps) => {
170
170
 
171
171
  export const generateSequencePosition = (sequenceProps, position = 0) => {
172
172
  const { type, base, ratio, subSequence } = sequenceProps
173
- const letterKey = this.call("isString", position) ? position : numToLetterMap[position]
174
-
173
+ const letterKey = isString(position) ? position : numToLetterMap[position]
174
+ const index = isString(position)
175
+ ? Object.entries(numToLetterMap).find(
176
+ ([, value]) => value === position
177
+ )?.[0]
178
+ : position
179
+
175
180
  if (!letterKey) {
176
181
  console.warn(`Position ${position} is out of range in numToLetterMap`)
177
182
  return null
@@ -184,11 +189,11 @@ export const generateSequencePosition = (sequenceProps, position = 0) => {
184
189
  ...sequenceProps
185
190
  }
186
191
 
187
- const value = base * Math.pow(ratio, position)
192
+ const value = base * Math.pow(ratio, index)
188
193
  const scaling = ~~((value / base) * 100) / 100
189
194
  const prefix = '--' + (type && type.replace('.', '-')) + '-'
190
195
  const variable = prefix + letterKey
191
- const scalingVariable = setScalingVar(position, sequenceProps)
196
+ const scalingVariable = setScalingVar(index, sequenceProps)
192
197
 
193
198
  const props = {
194
199
  key: letterKey,
@@ -198,7 +203,7 @@ export const generateSequencePosition = (sequenceProps, position = 0) => {
198
203
  scaling,
199
204
  scalingVariable,
200
205
  ratio,
201
- index: position
206
+ index
202
207
  }
203
208
 
204
209
  setSequenceValue(props, result)
@@ -3,6 +3,9 @@
3
3
  import { isArray, isString } from '@domql/utils'
4
4
  import { getActiveConfig } from '../factory'
5
5
 
6
+ const ENV = process.env.NODE_ENV || 'development'
7
+ const isDev = ENV === 'development' || ENV === 'testing'
8
+
6
9
  export const generateSprite = (icons) => {
7
10
  const CONFIG = getActiveConfig()
8
11
 
@@ -20,7 +23,8 @@ export const generateSprite = (icons) => {
20
23
  const parseRootAttributes = (htmlString) => {
21
24
  const val = htmlString.default || htmlString
22
25
  if (!isString(val)) {
23
- return console.warn(`parseRootAttributes: ${val} is not a string`)
26
+ if (isDev) console.warn('parseRootAttributes:', val, 'is not a string')
27
+ return
24
28
  }
25
29
 
26
30
  const match = val.match(/<svg\s+(.*?)>/)