update
This commit is contained in:
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"2":"C L M G N O P","1025":"0 9 d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","1537":"Q H R S T U V W X Y Z a b c"},C:{"2":"nC","932":"1 2 3 4 5 6 7 8 LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B qC rC","2308":"0 9 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC"},D:{"2":"1 2 J PB K D E F A B C L M G N O P QB","545":"3 4 5 6 7 8 RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB","1025":"0 9 d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","1537":"jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c"},E:{"1":"IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K sC SC tC","516":"B C L M G FC GC xC yC zC UC VC HC 0C","548":"F A wC TC","676":"D E uC vC"},F:{"2":"F B C 4C 5C 6C 7C FC kC 8C GC","513":"XB","545":"1 2 3 4 5 6 7 8 G N O P QB RB SB TB UB VB","1025":"0 e f g h i j k l m n o p q r s t u v w x y z","1537":"WB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d"},G:{"1":"IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"SC 9C lC AD BD","516":"QD RD SD UC VC HC TD","548":"ED FD GD HD ID JD KD LD MD ND OD PD","676":"E CD DD"},H:{"2":"WD"},I:{"2":"LC J XD YD ZD aD lC","545":"bD cD","1025":"I"},J:{"2":"D","545":"A"},K:{"2":"A B C FC kC GC","1025":"H"},L:{"1025":"I"},M:{"2308":"EC"},N:{"2":"A B"},O:{"1537":"HC"},P:{"545":"J","1025":"1 2 3 4 5 6 7 8 JC KC nD","1537":"dD eD fD gD hD TC iD jD kD lD mD IC"},Q:{"1537":"oD"},R:{"1537":"pD"},S:{"932":"qD","2308":"rD"}},B:5,C:"Intrinsic & Extrinsic Sizing",D:true};
|
||||
@@ -0,0 +1 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).invariant=n()}(this,(function(){"use strict";return function(e,n){if(!e)throw new Error("Invariant failed")}}));
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _classPrivateFieldInitSpec;
|
||||
var _checkPrivateRedeclaration = require("./checkPrivateRedeclaration.js");
|
||||
function _classPrivateFieldInitSpec(obj, privateMap, value) {
|
||||
(0, _checkPrivateRedeclaration.default)(obj, privateMap);
|
||||
privateMap.set(obj, value);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=classPrivateFieldInitSpec.js.map
|
||||
@@ -0,0 +1,59 @@
|
||||
# 0.9.0
|
||||
- update dependencies, in particular `levn` and `type-check` - this could affect behaviour of argument parsing
|
||||
|
||||
# 0.8.3
|
||||
- changes dependency from `wordwrap` to `word-wrap` due to license issue
|
||||
- update dependencies
|
||||
|
||||
# 0.8.2
|
||||
- fix bug #18 - detect missing value when flag is last item
|
||||
- update dependencies
|
||||
|
||||
# 0.8.1
|
||||
- update `fast-levenshtein` dependency
|
||||
|
||||
# 0.8.0
|
||||
- update `levn` dependency - supplying a float value to an option with type `Int` now throws an error, instead of silently converting to an `Int`
|
||||
|
||||
# 0.7.1
|
||||
- fix bug with use of `defaults` and `concatRepeatedArrays` or `mergeRepeatedObjects`
|
||||
|
||||
# 0.7.0
|
||||
- added `concatrepeatedarrays` option: `oneValuePerFlag`, only allows one array value per flag
|
||||
- added `typeAliases` option
|
||||
- added `parseArgv` which takes an array and parses with the first two items sliced off
|
||||
- changed enum help style
|
||||
- bug fixes (#12)
|
||||
- use of `concatRepeatedArrays` and `mergeRepeatedObjects` at the top level is deprecated, use it as either a per-option option, or set them in the `defaults` object to set them for all objects
|
||||
|
||||
# 0.6.0
|
||||
- added `defaults` lib-option flag, allowing one to set default properties for all options
|
||||
- added `concatRepeatedArrays` and `mergeRepeatedObjects` as option level properties, allowing you to turn this feature on for specific options only
|
||||
|
||||
# 0.5.0
|
||||
- `Boolean` flags with `default: 'true'`, and no short aliases, will by default show the `--no` version in help
|
||||
|
||||
# 0.4.0
|
||||
- add `mergeRepeatedObjects` setting
|
||||
|
||||
# 0.3.0
|
||||
- add `concatRepeatedArrays` setting
|
||||
- add `overrideRequired` option setting
|
||||
- use just Levenshtein string compare algo rather than Levenshtein Damerau to due dependency license issue
|
||||
|
||||
# 0.2.2
|
||||
- bug fixes
|
||||
|
||||
# 0.2.1
|
||||
- improved interpolation
|
||||
- added changelog
|
||||
|
||||
# 0.2.0
|
||||
- add dependency checks to options - added `dependsOn` as an option property
|
||||
- add interpolation for `prepend` and `append` text with new `generateHelp` option, `interpolate`
|
||||
|
||||
# 0.1.1
|
||||
- update dependencies
|
||||
|
||||
# 0.1.0
|
||||
- initial release
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017–2024 Wojciech Maj
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_toSetter","fn","args","thisArg","l","length","Object","defineProperty","set","v","apply"],"sources":["../../src/helpers/toSetter.ts"],"sourcesContent":["/* @minVersion 7.24.0 */\n\nexport default function _toSetter(fn: Function, args: any[], thisArg: any) {\n if (!args) args = [];\n var l = args.length++;\n return Object.defineProperty({}, \"_\", {\n set: function (v) {\n args[l] = v;\n fn.apply(thisArg, args);\n },\n });\n}\n"],"mappings":";;;;;;AAEe,SAASA,SAASA,CAACC,EAAY,EAAEC,IAAW,EAAEC,OAAY,EAAE;EACzE,IAAI,CAACD,IAAI,EAAEA,IAAI,GAAG,EAAE;EACpB,IAAIE,CAAC,GAAGF,IAAI,CAACG,MAAM,EAAE;EACrB,OAAOC,MAAM,CAACC,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE;IACpCC,GAAG,EAAE,SAAAA,CAAUC,CAAC,EAAE;MAChBP,IAAI,CAACE,CAAC,CAAC,GAAGK,CAAC;MACXR,EAAE,CAACS,KAAK,CAACP,OAAO,EAAED,IAAI,CAAC;IACzB;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["shallowEqual","actual","expected","keys","Object","key"],"sources":["../../src/utils/shallowEqual.ts"],"sourcesContent":["export default function shallowEqual<T extends object>(\n actual: object,\n expected: T,\n): actual is T {\n const keys = Object.keys(expected) as (keyof T)[];\n\n for (const key of keys) {\n if (\n // @ts-expect-error maybe we should check whether key exists first\n actual[key] !== expected[key]\n ) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;;;;;AAAe,SAASA,YAAYA,CAClCC,MAAc,EACdC,QAAW,EACE;EACb,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,QAAQ,CAAgB;EAEjD,KAAK,MAAMG,GAAG,IAAIF,IAAI,EAAE;IACtB,IAEEF,MAAM,CAACI,GAAG,CAAC,KAAKH,QAAQ,CAACG,GAAG,CAAC,EAC7B;MACA,OAAO,KAAK;IACd;EACF;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
module.exports={C:{"50":0.00399,"51":0.00399,"52":0.00399,"53":0.00399,"56":0.00399,"106":0.00399,"107":0.00399,"108":0.00399,"109":0.00399,"110":0.00399,"111":0.00399,"115":0.05186,"125":0.00399,"128":0.00798,"131":0.00798,"135":0.09175,"136":0.30715,"137":0.00399,"138":0.00399,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 54 55 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 112 113 114 116 117 118 119 120 121 122 123 124 126 127 129 130 132 133 134 139 140 3.5 3.6"},D:{"42":0.01197,"48":0.00399,"71":0.00399,"77":0.00399,"79":0.00798,"80":0.00399,"81":0.01197,"86":0.00399,"87":0.01197,"89":0.00399,"91":0.00798,"94":0.00399,"96":0.00399,"97":0.00798,"98":0.00399,"100":0.00399,"101":0.00399,"102":0.00399,"103":0.01596,"104":0.01995,"105":0.01197,"106":0.09175,"107":0.04787,"108":0.06382,"109":0.49464,"110":0.03989,"111":0.69808,"112":0.04388,"113":0.00399,"114":0.01197,"116":0.02792,"117":0.00399,"118":0.00798,"119":0.01197,"120":0.01596,"121":0.03989,"122":0.03989,"123":0.02792,"124":0.03191,"125":0.02393,"126":0.03989,"127":0.25929,"128":0.05186,"129":0.03191,"130":0.24333,"131":0.18748,"132":0.25131,"133":7.45943,"134":16.13152,"135":0.01596,"136":0.00798,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 43 44 45 46 47 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 72 73 74 75 76 78 83 84 85 88 90 92 93 95 99 115 137 138"},F:{"79":0.00399,"87":0.01596,"88":0.00399,"93":0.00399,"94":0.00399,"95":0.00399,"116":0.00798,"117":0.17552,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 82 83 84 85 86 89 90 91 92 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"18":0.00399,"90":0.00399,"92":0.00798,"103":0.00399,"105":0.00399,"106":0.00798,"107":0.01596,"108":0.00798,"109":0.0718,"110":0.00798,"111":0.00798,"112":0.01197,"113":0.00399,"114":0.00798,"115":0.00399,"116":0.00399,"117":0.00399,"118":0.00399,"119":0.00798,"120":0.01197,"121":0.00798,"122":0.00798,"123":0.00798,"124":0.01197,"125":0.00798,"126":0.01995,"127":0.01596,"128":0.02393,"129":0.01596,"130":0.02792,"131":0.06781,"132":0.05984,"133":1.81101,"134":4.8586,_:"12 13 14 15 16 17 79 80 81 83 84 85 86 87 88 89 91 93 94 95 96 97 98 99 100 101 102 104"},E:{_:"0 4 5 6 7 8 9 10 11 12 13 14 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1 12.1 15.1 15.2-15.3","13.1":0.00399,"14.1":0.00798,"15.4":0.00399,"15.5":0.00399,"15.6":0.0359,"16.0":0.00399,"16.1":0.00399,"16.2":0.00798,"16.3":0.00798,"16.4":0.00399,"16.5":0.00399,"16.6":0.03191,"17.0":0.00399,"17.1":0.01596,"17.2":0.00798,"17.3":0.00399,"17.4":0.01995,"17.5":0.02393,"17.6":0.05984,"18.0":0.01197,"18.1":0.03191,"18.2":0.02393,"18.3":0.43081,"18.4":0.01596},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00212,"5.0-5.1":0,"6.0-6.1":0.00637,"7.0-7.1":0.00425,"8.1-8.4":0,"9.0-9.2":0.00318,"9.3":0.01486,"10.0-10.2":0.00106,"10.3":0.02441,"11.0-11.2":0.1125,"11.3-11.4":0.00743,"12.0-12.1":0.00425,"12.2-12.5":0.10508,"13.0-13.1":0.00212,"13.2":0.00318,"13.3":0.00425,"13.4-13.7":0.01486,"14.0-14.4":0.03715,"14.5-14.8":0.04458,"15.0-15.1":0.02441,"15.2-15.3":0.02441,"15.4":0.02972,"15.5":0.03396,"15.6-15.8":0.41818,"16.0":0.05944,"16.1":0.12206,"16.2":0.06368,"16.3":0.11038,"16.4":0.02441,"16.5":0.04564,"16.6-16.7":0.49566,"17.0":0.02972,"17.1":0.05307,"17.2":0.04033,"17.3":0.05625,"17.4":0.1125,"17.5":0.25048,"17.6-17.7":0.72704,"18.0":0.20378,"18.1":0.66654,"18.2":0.29824,"18.3":6.2334,"18.4":0.09234},P:{"21":0.02029,"22":0.05073,"23":0.03044,"24":0.10147,"25":0.07103,"26":0.14205,"27":14.50978,_:"4 20 5.0-5.4 6.2-6.4 7.2-7.4 8.2 9.2 10.1 11.1-11.2 12.0 14.0 15.0 16.0","13.0":0.01015,"17.0":0.01015,"18.0":0.01015,"19.0":0.01015},I:{"0":0.13194,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00004,"4.4":0,"4.4.3-4.4.4":0.00015},K:{"0":0.14424,_:"10 11 12 11.1 11.5 12.1"},A:{"10":0.00545,"11":0.1581,_:"6 7 8 9 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.19833},Q:{"14.9":0.01202},O:{"0":0.07212},H:{"0":0},L:{"0":28.46616}};
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @fileoverview Utilities to operate on option objects.
|
||||
* @author Josh Goldberg
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Determines whether any of input's properties are different
|
||||
* from values that already exist in original.
|
||||
* @template T
|
||||
* @param {Partial<T>} input New value.
|
||||
* @param {T} original Original value.
|
||||
* @returns {boolean} Whether input includes an explicit difference.
|
||||
*/
|
||||
function containsDifferentProperty(input, original) {
|
||||
if (input === original) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
typeof input !== typeof original ||
|
||||
Array.isArray(input) !== Array.isArray(original)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Array.isArray(input)) {
|
||||
return (
|
||||
input.length !== original.length ||
|
||||
input.some((value, i) =>
|
||||
containsDifferentProperty(value, original[i]),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof input === "object") {
|
||||
if (input === null || original === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const inputKeys = Object.keys(input);
|
||||
const originalKeys = Object.keys(original);
|
||||
|
||||
return (
|
||||
inputKeys.length !== originalKeys.length ||
|
||||
inputKeys.some(
|
||||
inputKey =>
|
||||
!Object.hasOwn(original, inputKey) ||
|
||||
containsDifferentProperty(
|
||||
input[inputKey],
|
||||
original[inputKey],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
containsDifferentProperty,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"8":"K D E F A B mC"},B:{"1":"0 9 C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"1":"0 9 SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","4":"8 RB","8":"1 2 3 4 5 6 7 nC LC J PB K D E F A B C L M G N O P QB qC rC"},D:{"1":"0 9 WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","4":"VB","8":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB"},E:{"1":"E F A B C L M G vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","8":"J PB K D sC SC tC uC"},F:{"1":"0 1 2 3 4 5 6 7 8 RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","4":"QB","8":"F B C G N O P 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"E DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","8":"SC 9C lC AD BD CD"},H:{"8":"WD"},I:{"1":"I cD","8":"LC J XD YD ZD aD lC bD"},J:{"8":"D A"},K:{"1":"H","8":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"8":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"qD rD"}},B:6,C:"Promises",D:true};
|
||||
@@ -0,0 +1,28 @@
|
||||
import * as pdfjs from 'pdfjs-dist';
|
||||
|
||||
import Document from './Document.js';
|
||||
import Outline from './Outline.js';
|
||||
import Page from './Page.js';
|
||||
import Thumbnail from './Thumbnail.js';
|
||||
|
||||
import useDocumentContext from './shared/hooks/useDocumentContext.js';
|
||||
import useOutlineContext from './shared/hooks/useOutlineContext.js';
|
||||
import usePageContext from './shared/hooks/usePageContext.js';
|
||||
|
||||
export type { DocumentProps } from './Document.js';
|
||||
export type { OutlineProps } from './Outline.js';
|
||||
export type { PageProps } from './Page.js';
|
||||
export type { ThumbnailProps } from './Thumbnail.js';
|
||||
|
||||
import './pdf.worker.entry.js';
|
||||
|
||||
export {
|
||||
pdfjs,
|
||||
Document,
|
||||
Outline,
|
||||
Page,
|
||||
Thumbnail,
|
||||
useDocumentContext,
|
||||
useOutlineContext,
|
||||
usePageContext,
|
||||
};
|
||||
Binary file not shown.
@@ -0,0 +1,154 @@
|
||||
# clsx [](https://github.com/lukeed/clsx/actions?query=workflow%3ACI) [](https://codecov.io/gh/lukeed/clsx) [](https://licenses.dev/npm/clsx)
|
||||
|
||||
> A tiny (239B) utility for constructing `className` strings conditionally.<Br>Also serves as a [faster](bench) & smaller drop-in replacement for the `classnames` module.
|
||||
|
||||
This module is available in three formats:
|
||||
|
||||
* **ES Module**: `dist/clsx.mjs`
|
||||
* **CommonJS**: `dist/clsx.js`
|
||||
* **UMD**: `dist/clsx.min.js`
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save clsx
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import clsx from 'clsx';
|
||||
// or
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
// Strings (variadic)
|
||||
clsx('foo', true && 'bar', 'baz');
|
||||
//=> 'foo bar baz'
|
||||
|
||||
// Objects
|
||||
clsx({ foo:true, bar:false, baz:isTrue() });
|
||||
//=> 'foo baz'
|
||||
|
||||
// Objects (variadic)
|
||||
clsx({ foo:true }, { bar:false }, null, { '--foobar':'hello' });
|
||||
//=> 'foo --foobar'
|
||||
|
||||
// Arrays
|
||||
clsx(['foo', 0, false, 'bar']);
|
||||
//=> 'foo bar'
|
||||
|
||||
// Arrays (variadic)
|
||||
clsx(['foo'], ['', 0, false, 'bar'], [['baz', [['hello'], 'there']]]);
|
||||
//=> 'foo bar baz hello there'
|
||||
|
||||
// Kitchen sink (with nesting)
|
||||
clsx('foo', [1 && 'bar', { baz:false, bat:null }, ['hello', ['world']]], 'cya');
|
||||
//=> 'foo bar hello world cya'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### clsx(...input)
|
||||
Returns: `String`
|
||||
|
||||
#### input
|
||||
Type: `Mixed`
|
||||
|
||||
The `clsx` function can take ***any*** number of arguments, each of which can be an Object, Array, Boolean, or String.
|
||||
|
||||
> **Important:** _Any_ falsey values are discarded!<br>Standalone Boolean values are discarded as well.
|
||||
|
||||
```js
|
||||
clsx(true, false, '', null, undefined, 0, NaN);
|
||||
//=> ''
|
||||
```
|
||||
|
||||
## Modes
|
||||
|
||||
There are multiple "versions" of `clsx` available, which allows you to bring only the functionality you need!
|
||||
|
||||
#### `clsx`
|
||||
> **Size (gzip):** 239 bytes<br>
|
||||
> **Availability:** CommonJS, ES Module, UMD
|
||||
|
||||
The default `clsx` module; see [API](#API) for info.
|
||||
|
||||
```js
|
||||
import { clsx } from 'clsx';
|
||||
// or
|
||||
import clsx from 'clsx';
|
||||
```
|
||||
|
||||
#### `clsx/lite`
|
||||
> **Size (gzip):** 140 bytes<br>
|
||||
> **Availability:** CommonJS, ES Module<br>
|
||||
> **CAUTION:** Accepts **ONLY** string arguments!
|
||||
|
||||
Ideal for applications that ***only*** use the string-builder pattern.
|
||||
|
||||
Any non-string arguments are ignored!
|
||||
|
||||
```js
|
||||
import { clsx } from 'clsx/lite';
|
||||
// or
|
||||
import clsx from 'clsx/lite';
|
||||
|
||||
// string
|
||||
clsx('hello', true && 'foo', false && 'bar');
|
||||
// => "hello foo"
|
||||
|
||||
// NOTE: Any non-string input(s) ignored
|
||||
clsx({ foo: true });
|
||||
//=> ""
|
||||
```
|
||||
|
||||
## Benchmarks
|
||||
|
||||
For snapshots of cross-browser results, check out the [`bench`](bench) directory~!
|
||||
|
||||
## Support
|
||||
|
||||
All versions of Node.js are supported.
|
||||
|
||||
All browsers that support [`Array.isArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray#Browser_compatibility) are supported (IE9+).
|
||||
|
||||
>**Note:** For IE8 support and older, please install `clsx@1.0.x` and beware of [#17](https://github.com/lukeed/clsx/issues/17).
|
||||
|
||||
## Tailwind Support
|
||||
|
||||
Here some additional (optional) steps to enable classes autocompletion using `clsx` with Tailwind CSS.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Visual Studio Code
|
||||
</summary>
|
||||
|
||||
1. [Install the "Tailwind CSS IntelliSense" Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)
|
||||
|
||||
2. Add the following to your [`settings.json`](https://code.visualstudio.com/docs/getstarted/settings):
|
||||
|
||||
```json
|
||||
{
|
||||
"tailwindCSS.experimental.classRegex": [
|
||||
["clsx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
|
||||
]
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
You may find the [`clsx/lite`](#clsxlite) module useful within Tailwind contexts. This is especially true if/when your application **only** composes classes in this pattern:
|
||||
|
||||
```js
|
||||
clsx('text-base', props.active && 'text-primary', props.className);
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [obj-str](https://github.com/lukeed/obj-str) - A smaller (96B) and similiar utility that only works with Objects.
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Backend.h"
|
||||
#include <napi.h>
|
||||
|
||||
class ImageBackend : public Napi::ObjectWrap<ImageBackend>, public Backend
|
||||
{
|
||||
private:
|
||||
cairo_surface_t* createSurface();
|
||||
void destroySurface();
|
||||
cairo_format_t format = DEFAULT_FORMAT;
|
||||
|
||||
public:
|
||||
ImageBackend(Napi::CallbackInfo& info);
|
||||
|
||||
cairo_format_t getFormat();
|
||||
void setFormat(cairo_format_t format);
|
||||
|
||||
int32_t approxBytesPerPixel();
|
||||
|
||||
static Napi::FunctionReference constructor;
|
||||
static void Initialize(Napi::Object target);
|
||||
const static cairo_format_t DEFAULT_FORMAT = CAIRO_FORMAT_ARGB32;
|
||||
};
|
||||
Binary file not shown.
Reference in New Issue
Block a user