@vettvangur/vanilla 0.0.49 → 0.0.51
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/dist/dom.esm.js +0 -1
- package/dist/index.esm.js +7 -377
- package/dist/string.esm.js +3 -0
- package/dist/types/index.d.ts +0 -19
- package/package.json +3 -8
package/dist/dom.esm.js
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -253,6 +253,9 @@ function getTemplate(alias, templates) {
|
|
|
253
253
|
* getBlock(alias, blocks)
|
|
254
254
|
*/
|
|
255
255
|
function getBlock(alias, blocks) {
|
|
256
|
+
if (!blocks) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
256
259
|
const block = blocks[capitalize(alias)];
|
|
257
260
|
if (!block) {
|
|
258
261
|
return null;
|
|
@@ -291,7 +294,6 @@ function isEmpty(value) {
|
|
|
291
294
|
* preloadTimeout()
|
|
292
295
|
*/
|
|
293
296
|
function preloadTimeout() {
|
|
294
|
-
console.log('PRELOAD');
|
|
295
297
|
const body = document.querySelector('.body');
|
|
296
298
|
if (!body) {
|
|
297
299
|
return;
|
|
@@ -386,6 +388,9 @@ const Umbraco = Object.freeze({
|
|
|
386
388
|
* getTranslation(key, translations)
|
|
387
389
|
*/
|
|
388
390
|
function getTranslation(key, translations) {
|
|
391
|
+
if (!translations) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
389
394
|
const translation = translations[key];
|
|
390
395
|
if (!translation) {
|
|
391
396
|
console.error(`[vettvangur-vanilla :: getTranslation] No translation for key ${key} found.`);
|
|
@@ -411,379 +416,4 @@ function getCulture(path) {
|
|
|
411
416
|
return match ? match[1].toLowerCase() : null;
|
|
412
417
|
}
|
|
413
418
|
|
|
414
|
-
|
|
415
|
-
* Init hyphenation.
|
|
416
|
-
*
|
|
417
|
-
* @param {Document | ParentNode} [root=document]
|
|
418
|
-
* Root node to scope the query to.
|
|
419
|
-
*
|
|
420
|
-
* - Use `document` to scan the whole page.
|
|
421
|
-
* - Use an element (or other `ParentNode`) to scope hyphenation to a subtree.
|
|
422
|
-
* @param {{ classes?: string[] }} [options={}]
|
|
423
|
-
* Configuration options.
|
|
424
|
-
*
|
|
425
|
-
* - `options.classes`: array of class tokens or prefixes to match.
|
|
426
|
-
* Each token matches either an exact class or a prefix (e.g. `headline` matches `headline` and `headline-xl`).
|
|
427
|
-
* If omitted, defaults to targeting elements matching `[class*="headline"]`.
|
|
428
|
-
* @returns {Promise<void>} Nothing.
|
|
429
|
-
*/
|
|
430
|
-
async function initHyphenation$1(root = document, options = {}) {
|
|
431
|
-
const mod = await Promise.resolve().then(function () { return hyphen; });
|
|
432
|
-
return mod.initHyphenation(root, options);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Lazy-loaded hyphenation functions. Loaded on-demand so consumers that
|
|
437
|
-
* do not use hyphenation do not pay the bundle cost.
|
|
438
|
-
*/
|
|
439
|
-
|
|
440
|
-
/** @type {Promise<((word: string) => Promise<string>) | null> | null} */
|
|
441
|
-
let hyphenateEnPromise = null;
|
|
442
|
-
/** @type {Promise<((word: string) => Promise<string>) | null> | null} */
|
|
443
|
-
let hyphenateIsPromise = null;
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Stores the original (non-hyphenated) text content for elements.
|
|
447
|
-
* Used to ensure idempotent re-runs on resize/font load.
|
|
448
|
-
* @type {WeakMap<HTMLElement, string>}
|
|
449
|
-
*/
|
|
450
|
-
const originalText = new WeakMap();
|
|
451
|
-
let resizeListenerBound = false;
|
|
452
|
-
let resizeTimer;
|
|
453
|
-
/** @type {HyphenationOptions | undefined} */
|
|
454
|
-
let resizeOptions;
|
|
455
|
-
let fontsListenerBound = false;
|
|
456
|
-
const HYHEN_CLASS_MANUAL = 'js-hyphen-manual';
|
|
457
|
-
const HYPHEN_CLASS_EMERGENCY = 'js-hyphen-emergency';
|
|
458
|
-
|
|
459
|
-
/** @type {CanvasRenderingContext2D | null} */
|
|
460
|
-
let measureCtx = null;
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Gets (and lazily creates) the canvas context used for text measurement.
|
|
464
|
-
*
|
|
465
|
-
* @returns {CanvasRenderingContext2D | null}
|
|
466
|
-
*/
|
|
467
|
-
function getMeasureCtx() {
|
|
468
|
-
if (measureCtx) {
|
|
469
|
-
return measureCtx;
|
|
470
|
-
}
|
|
471
|
-
if (typeof document === 'undefined') {
|
|
472
|
-
return null;
|
|
473
|
-
}
|
|
474
|
-
const canvas = document.createElement('canvas');
|
|
475
|
-
measureCtx = canvas.getContext('2d');
|
|
476
|
-
return measureCtx;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Loads the `hyphen` package module and extracts a `hyphenate()` function,
|
|
481
|
-
* handling common CJS/ESM interop shapes.
|
|
482
|
-
*
|
|
483
|
-
* @param {string} moduleId
|
|
484
|
-
* @returns {Promise<((word: string) => Promise<string>) | null>}
|
|
485
|
-
*/
|
|
486
|
-
async function loadHyphenate(moduleId) {
|
|
487
|
-
try {
|
|
488
|
-
var _ref, _mod$hyphenate, _mod$default, _mod$default2;
|
|
489
|
-
const mod = await import(moduleId);
|
|
490
|
-
const hyphenate = (_ref = (_mod$hyphenate = mod === null || mod === void 0 ? void 0 : mod.hyphenate) !== null && _mod$hyphenate !== void 0 ? _mod$hyphenate : mod === null || mod === void 0 || (_mod$default = mod.default) === null || _mod$default === void 0 ? void 0 : _mod$default.hyphenate) !== null && _ref !== void 0 ? _ref : mod === null || mod === void 0 || (_mod$default2 = mod.default) === null || _mod$default2 === void 0 || (_mod$default2 = _mod$default2.default) === null || _mod$default2 === void 0 ? void 0 : _mod$default2.hyphenate;
|
|
491
|
-
if (typeof hyphenate === 'function') {
|
|
492
|
-
return hyphenate;
|
|
493
|
-
}
|
|
494
|
-
console.error('[vanilla] initHyphenation: hyphenate() export not found (CJS/ESM interop issue).', {
|
|
495
|
-
moduleId,
|
|
496
|
-
availableKeys: mod ? Object.keys(mod) : null,
|
|
497
|
-
defaultKeys: mod !== null && mod !== void 0 && mod.default && typeof mod.default === 'object' ? Object.keys(mod.default) : null
|
|
498
|
-
});
|
|
499
|
-
return null;
|
|
500
|
-
} catch (error) {
|
|
501
|
-
console.error('[vanilla] initHyphenation: failed to load hyphenation module.', {
|
|
502
|
-
moduleId,
|
|
503
|
-
error
|
|
504
|
-
});
|
|
505
|
-
return null;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
* @param {string} lang
|
|
511
|
-
* @returns {Promise<((word: string) => Promise<string>) | null>}
|
|
512
|
-
*/
|
|
513
|
-
function getHyphenateForLang(lang) {
|
|
514
|
-
const isIcelandic = lang.startsWith('is');
|
|
515
|
-
if (isIcelandic) {
|
|
516
|
-
if (!hyphenateIsPromise) {
|
|
517
|
-
hyphenateIsPromise = loadHyphenate('hyphen/is/index.js');
|
|
518
|
-
}
|
|
519
|
-
return hyphenateIsPromise;
|
|
520
|
-
}
|
|
521
|
-
if (!hyphenateEnPromise) {
|
|
522
|
-
hyphenateEnPromise = loadHyphenate('hyphen/en/index.js');
|
|
523
|
-
}
|
|
524
|
-
return hyphenateEnPromise;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* Applies a CSS-like text-transform to a string.
|
|
529
|
-
*
|
|
530
|
-
* @param {string} text
|
|
531
|
-
* @param {string} transform
|
|
532
|
-
* @returns {string}
|
|
533
|
-
*/
|
|
534
|
-
function applyTextTransform(text, transform) {
|
|
535
|
-
switch (transform) {
|
|
536
|
-
case 'uppercase':
|
|
537
|
-
return text.toUpperCase();
|
|
538
|
-
case 'lowercase':
|
|
539
|
-
return text.toLowerCase();
|
|
540
|
-
default:
|
|
541
|
-
return text;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Measures rendered text width using canvas, approximating letter-spacing.
|
|
547
|
-
*
|
|
548
|
-
* @param {string} text
|
|
549
|
-
* @param {CSSStyleDeclaration} style
|
|
550
|
-
* @returns {number}
|
|
551
|
-
*/
|
|
552
|
-
function measureTextWidth(text, style) {
|
|
553
|
-
const ctx = getMeasureCtx();
|
|
554
|
-
if (!ctx) {
|
|
555
|
-
return 0;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// `style.font` is a computed shorthand like "700 16px/20px Foo".
|
|
559
|
-
ctx.font = style.font;
|
|
560
|
-
const transformed = applyTextTransform(text, style.textTransform);
|
|
561
|
-
const metrics = ctx.measureText(transformed);
|
|
562
|
-
let width = metrics.width;
|
|
563
|
-
|
|
564
|
-
// Canvas does not support letter-spacing; approximate when it's a pixel value.
|
|
565
|
-
if (style.letterSpacing && style.letterSpacing !== 'normal') {
|
|
566
|
-
const ls = Number.parseFloat(style.letterSpacing);
|
|
567
|
-
if (Number.isFinite(ls) && transformed.length > 1) {
|
|
568
|
-
width += (transformed.length - 1) * ls;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
return width;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* Options for initHyphenation.
|
|
576
|
-
*
|
|
577
|
-
* @typedef {Object} HyphenationOptions
|
|
578
|
-
* @property {string[]} [classes]
|
|
579
|
-
* Class names or prefixes to target. If omitted, defaults to `[class*="headline"]`.
|
|
580
|
-
*/
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Escapes a string for use inside a CSS attribute selector.
|
|
584
|
-
*
|
|
585
|
-
* @param {string} value
|
|
586
|
-
* @returns {string}
|
|
587
|
-
*/
|
|
588
|
-
function escapeForCssAttrValue(value) {
|
|
589
|
-
return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* Normalizes a class token by trimming and removing a leading dot.
|
|
594
|
-
*
|
|
595
|
-
* @param {string} className
|
|
596
|
-
* @returns {string}
|
|
597
|
-
*/
|
|
598
|
-
function normalizeClassToken(className) {
|
|
599
|
-
return className.trim().replace(/^\./, '');
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* Finds the element that defines the usable line width.
|
|
604
|
-
* Inline elements are walked upward until a non-inline ancestor is found.
|
|
605
|
-
*
|
|
606
|
-
* @param {HTMLElement} el
|
|
607
|
-
* @returns {HTMLElement}
|
|
608
|
-
*/
|
|
609
|
-
function findLineWidthElement(el) {
|
|
610
|
-
let current = el;
|
|
611
|
-
while (current) {
|
|
612
|
-
const display = getComputedStyle(current).display;
|
|
613
|
-
if (display !== 'inline') {
|
|
614
|
-
return current;
|
|
615
|
-
}
|
|
616
|
-
current = current.parentElement;
|
|
617
|
-
}
|
|
618
|
-
return el;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* Computes the available line width for an element, excluding horizontal padding.
|
|
623
|
-
*
|
|
624
|
-
* @param {HTMLElement} el
|
|
625
|
-
* @returns {number}
|
|
626
|
-
*/
|
|
627
|
-
function getAvailableLineWidth(el) {
|
|
628
|
-
const widthEl = findLineWidthElement(el);
|
|
629
|
-
const rectWidth = widthEl.getBoundingClientRect().width;
|
|
630
|
-
const base = widthEl.clientWidth || rectWidth;
|
|
631
|
-
if (!base) {
|
|
632
|
-
return 0;
|
|
633
|
-
}
|
|
634
|
-
const style = getComputedStyle(widthEl);
|
|
635
|
-
const paddingLeft = Number.parseFloat(style.paddingLeft) || 0;
|
|
636
|
-
const paddingRight = Number.parseFloat(style.paddingRight) || 0;
|
|
637
|
-
return Math.max(0, Math.floor(base - paddingLeft - paddingRight));
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Removes legacy inline hyphenation styles so class-based styling can take over.
|
|
642
|
-
*
|
|
643
|
-
* @param {HTMLElement} el
|
|
644
|
-
*/
|
|
645
|
-
function removeLegacyInlineHyphenStyles(el) {
|
|
646
|
-
el.style.removeProperty('hyphens');
|
|
647
|
-
el.style.removeProperty('overflow-wrap');
|
|
648
|
-
el.style.removeProperty('word-break');
|
|
649
|
-
const styleAttr = el.getAttribute('style');
|
|
650
|
-
if (styleAttr != null && styleAttr.trim() === '') {
|
|
651
|
-
el.removeAttribute('style');
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* Initializes responsive, language-aware hyphenation for text elements.
|
|
657
|
-
*
|
|
658
|
-
* - Inserts soft hyphens for words that cannot fit on a line by themselves.
|
|
659
|
-
* - Re-runs on window resize and font loading when called on `document`.
|
|
660
|
-
* - Adds `js-hyphen-manual` when soft hyphens are inserted.
|
|
661
|
-
* - Adds `js-hyphen-emergency` as a last-resort overflow fallback.
|
|
662
|
-
*
|
|
663
|
-
* @param {Document | ParentNode} [root=document]
|
|
664
|
-
* Root node to scope the query to.
|
|
665
|
-
*
|
|
666
|
-
* - Use `document` to scan the whole page and enable auto re-runs on resize/font load.
|
|
667
|
-
* - Use an element (or other `ParentNode`) to scope hyphenation to a subtree (no global listeners).
|
|
668
|
-
* @param {HyphenationOptions} [options={}]
|
|
669
|
-
* Configuration options.
|
|
670
|
-
*
|
|
671
|
-
* - `options.classes`: array of class tokens or prefixes to match.
|
|
672
|
-
* Each token matches either an exact class or a prefix (e.g. `headline` matches `headline` and `headline-xl`).
|
|
673
|
-
* If omitted, defaults to targeting elements matching `[class*="headline"]`.
|
|
674
|
-
* @returns {Promise<void>}
|
|
675
|
-
*/
|
|
676
|
-
async function initHyphenation(root = document, options = {}) {
|
|
677
|
-
var _options$classes;
|
|
678
|
-
if (typeof document === 'undefined') {
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
if (root === document) {
|
|
682
|
-
resizeOptions = options;
|
|
683
|
-
if (!resizeListenerBound) {
|
|
684
|
-
resizeListenerBound = true;
|
|
685
|
-
window.addEventListener('resize', () => {
|
|
686
|
-
if (resizeTimer) {
|
|
687
|
-
window.clearTimeout(resizeTimer);
|
|
688
|
-
}
|
|
689
|
-
resizeTimer = window.setTimeout(() => {
|
|
690
|
-
initHyphenation(document, resizeOptions || {}).catch(e => console.error('hyphenation', e));
|
|
691
|
-
}, 150);
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
if (!fontsListenerBound && 'fonts' in document) {
|
|
695
|
-
var _fontSet$ready;
|
|
696
|
-
fontsListenerBound = true;
|
|
697
|
-
const fontSet = document.fonts;
|
|
698
|
-
fontSet === null || fontSet === void 0 || (_fontSet$ready = fontSet.ready) === null || _fontSet$ready === void 0 || _fontSet$ready.then(() => initHyphenation(document, resizeOptions || {})).catch(e => console.error('hyphenation fonts', e));
|
|
699
|
-
try {
|
|
700
|
-
var _fontSet$addEventList;
|
|
701
|
-
fontSet === null || fontSet === void 0 || (_fontSet$addEventList = fontSet.addEventListener) === null || _fontSet$addEventList === void 0 || _fontSet$addEventList.call(fontSet, 'loadingdone', () => {
|
|
702
|
-
initHyphenation(document, resizeOptions || {}).catch(e => console.error('hyphenation fonts', e));
|
|
703
|
-
});
|
|
704
|
-
} catch (_unused) {
|
|
705
|
-
// ignore
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
const candidates = (_options$classes = options.classes) !== null && _options$classes !== void 0 && _options$classes.length ? Array.from(options.classes.reduce((acc, className) => {
|
|
710
|
-
const token = normalizeClassToken(className);
|
|
711
|
-
if (!token) {
|
|
712
|
-
return acc;
|
|
713
|
-
}
|
|
714
|
-
const escaped = escapeForCssAttrValue(token);
|
|
715
|
-
root.querySelectorAll(`[class*="${escaped}"]`).forEach(el => {
|
|
716
|
-
const matches = Array.from(el.classList).some(cls => cls === token || cls.startsWith(token));
|
|
717
|
-
if (matches) {
|
|
718
|
-
acc.add(el);
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
return acc;
|
|
722
|
-
}, new Set())) : Array.from(root.querySelectorAll('[class*="headline"]'));
|
|
723
|
-
if (candidates.length === 0) {
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
|
-
await Promise.all(candidates.map(async el => {
|
|
727
|
-
var _el$closest;
|
|
728
|
-
removeLegacyInlineHyphenStyles(el);
|
|
729
|
-
el.classList.remove(HYHEN_CLASS_MANUAL, HYPHEN_CLASS_EMERGENCY);
|
|
730
|
-
const current = (el.textContent || '').replace(/\u00ad/g, '');
|
|
731
|
-
const stored = originalText.get(el);
|
|
732
|
-
const text = stored && stored === current ? stored : current;
|
|
733
|
-
originalText.set(el, text);
|
|
734
|
-
if (!text.trim()) {
|
|
735
|
-
return;
|
|
736
|
-
}
|
|
737
|
-
if (el.textContent !== text) {
|
|
738
|
-
el.textContent = text;
|
|
739
|
-
}
|
|
740
|
-
const availableWidth = getAvailableLineWidth(el);
|
|
741
|
-
if (!availableWidth) {
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
const lang = (((_el$closest = el.closest('[lang]')) === null || _el$closest === void 0 ? void 0 : _el$closest.lang) || document.documentElement.lang || 'en-us').toLowerCase();
|
|
745
|
-
const style = getComputedStyle(el);
|
|
746
|
-
const parts = text.split(/(\s+)/);
|
|
747
|
-
let didChange = false;
|
|
748
|
-
let needsEmergencyBreak = false;
|
|
749
|
-
|
|
750
|
-
/** @type {((word: string) => Promise<string>) | null} */
|
|
751
|
-
let hyphenFn = null;
|
|
752
|
-
for (let i = 0; i < parts.length; i++) {
|
|
753
|
-
const part = parts[i];
|
|
754
|
-
if (!part || /^\s+$/.test(part)) {
|
|
755
|
-
continue;
|
|
756
|
-
}
|
|
757
|
-
if (measureTextWidth(part, style) <= availableWidth) {
|
|
758
|
-
continue;
|
|
759
|
-
}
|
|
760
|
-
if (!hyphenFn) {
|
|
761
|
-
hyphenFn = await getHyphenateForLang(lang);
|
|
762
|
-
if (!hyphenFn) {
|
|
763
|
-
return;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
const hyphenatedWord = await hyphenFn(part);
|
|
767
|
-
if (hyphenatedWord !== part) {
|
|
768
|
-
parts[i] = hyphenatedWord;
|
|
769
|
-
didChange = true;
|
|
770
|
-
} else {
|
|
771
|
-
needsEmergencyBreak = true;
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
if (didChange) {
|
|
775
|
-
el.classList.add(HYHEN_CLASS_MANUAL);
|
|
776
|
-
el.textContent = parts.join('');
|
|
777
|
-
}
|
|
778
|
-
if (needsEmergencyBreak) {
|
|
779
|
-
el.classList.add(HYPHEN_CLASS_EMERGENCY);
|
|
780
|
-
}
|
|
781
|
-
}));
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
var hyphen = /*#__PURE__*/Object.freeze({
|
|
785
|
-
__proto__: null,
|
|
786
|
-
initHyphenation: initHyphenation
|
|
787
|
-
});
|
|
788
|
-
|
|
789
|
-
export { Umbraco, capitalize, clickOutside, getBlock as default, dictionary, fetcher, flatten, getBlock, getCulture, getTemplate, getTranslation, initHyphenation$1 as initHyphenation, isEmpty, preloadTimeout, regexr };
|
|
419
|
+
export { Umbraco, capitalize, clickOutside, getBlock as default, dictionary, fetcher, flatten, getBlock, getCulture, getTemplate, getTranslation, isEmpty, preloadTimeout, regexr };
|
package/dist/string.esm.js
CHANGED
|
@@ -97,6 +97,9 @@ function isEmpty(value) {
|
|
|
97
97
|
* getTranslation(key, translations)
|
|
98
98
|
*/
|
|
99
99
|
function getTranslation(key, translations) {
|
|
100
|
+
if (!translations) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
100
103
|
const translation = translations[key];
|
|
101
104
|
if (!translation) {
|
|
102
105
|
console.error(`[vettvangur-vanilla :: getTranslation] No translation for key ${key} found.`);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -154,25 +154,6 @@ export function getTranslation(key: any, translations: any): any;
|
|
|
154
154
|
* getCulture(path)
|
|
155
155
|
*/
|
|
156
156
|
export function getCulture(path: any): any;
|
|
157
|
-
/**
|
|
158
|
-
* Init hyphenation.
|
|
159
|
-
*
|
|
160
|
-
* @param {Document | ParentNode} [root=document]
|
|
161
|
-
* Root node to scope the query to.
|
|
162
|
-
*
|
|
163
|
-
* - Use `document` to scan the whole page.
|
|
164
|
-
* - Use an element (or other `ParentNode`) to scope hyphenation to a subtree.
|
|
165
|
-
* @param {{ classes?: string[] }} [options={}]
|
|
166
|
-
* Configuration options.
|
|
167
|
-
*
|
|
168
|
-
* - `options.classes`: array of class tokens or prefixes to match.
|
|
169
|
-
* Each token matches either an exact class or a prefix (e.g. `headline` matches `headline` and `headline-xl`).
|
|
170
|
-
* If omitted, defaults to targeting elements matching `[class*="headline"]`.
|
|
171
|
-
* @returns {Promise<void>} Nothing.
|
|
172
|
-
*/
|
|
173
|
-
export function initHyphenation(root?: Document | ParentNode, options?: {
|
|
174
|
-
classes?: string[];
|
|
175
|
-
}): Promise<void>;
|
|
176
157
|
export namespace regexr {
|
|
177
158
|
/**
|
|
178
159
|
* Tests whether a given value matches a regex pattern.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vettvangur/vanilla",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.51",
|
|
4
4
|
"description": "Vettvangur | Vanilla JS Utility Library",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"type": "module",
|
|
@@ -30,18 +30,13 @@
|
|
|
30
30
|
"types": "./dist/types/data.d.ts",
|
|
31
31
|
"default": "./dist/data.esm.js"
|
|
32
32
|
},
|
|
33
|
-
"./hyphenation": {
|
|
34
|
-
"types": "./dist/types/hyphenation.d.ts",
|
|
35
|
-
"default": "./dist/hyphenation.esm.js"
|
|
36
|
-
},
|
|
37
33
|
"./server": {
|
|
38
34
|
"types": "./dist/types/server.d.ts",
|
|
39
35
|
"default": "./dist/server.esm.js"
|
|
40
36
|
}
|
|
41
37
|
},
|
|
42
38
|
"dependencies": {
|
|
43
|
-
"dotenv": "17.2.3"
|
|
44
|
-
"hyphen": "1.10.6"
|
|
39
|
+
"dotenv": "17.2.3"
|
|
45
40
|
},
|
|
46
41
|
"devDependencies": {
|
|
47
42
|
"@babel/plugin-syntax-dynamic-import": "7.8.3",
|
|
@@ -59,6 +54,6 @@
|
|
|
59
54
|
"scripts": {
|
|
60
55
|
"bundle": "pnpm types & rollup -c",
|
|
61
56
|
"dist": "pnpm publish",
|
|
62
|
-
"types": "tsc -p tsconfig.json && shx mv dist/types/index.d.mts dist/types/index.d.ts && shx mv dist/types/dom.d.mts dist/types/dom.d.ts && shx mv dist/types/string.d.mts dist/types/string.d.ts && shx mv dist/types/data.d.mts dist/types/data.d.ts && shx mv dist/types/
|
|
57
|
+
"types": "tsc -p tsconfig.json && shx mv dist/types/index.d.mts dist/types/index.d.ts && shx mv dist/types/dom.d.mts dist/types/dom.d.ts && shx mv dist/types/string.d.mts dist/types/string.d.ts && shx mv dist/types/data.d.mts dist/types/data.d.ts && shx mv dist/types/server/index.d.mts dist/types/server.d.ts"
|
|
63
58
|
}
|
|
64
59
|
}
|