update
This commit is contained in:
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"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 1 2 3 4 5 6 7 8 9 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 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","2":"nC LC J PB K D E F A B C L M qC rC"},D:{"1":"0 9 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":"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 VB WB XB YB ZB aB bB cB dB eB fB gB"},E:{"1":"F A B C L M G 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","4":"J PB K D E sC SC tC uC vC"},F:{"1":"0 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","2":"F B C 4C 5C 6C 7C FC kC 8C GC","4":"1 2 3 4 5 6 7 8 G N O P QB RB SB TB"},G:{"1":"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","4":"E SC 9C lC AD BD CD DD"},H:{"2":"WD"},I:{"1":"I","4":"LC J XD YD ZD aD lC bD cD"},J:{"4":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"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:4,C:"CSS3 word-break",D:true};
|
||||
@@ -0,0 +1,214 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const Keyv = require('keyv');
|
||||
const { writeJSON, tryParse } = require('./utils');
|
||||
const { del } = require('./del');
|
||||
|
||||
const cache = {
|
||||
/**
|
||||
* Load a cache identified by the given Id. If the element does not exists, then initialize an empty
|
||||
* cache storage. If specified `cacheDir` will be used as the directory to persist the data to. If omitted
|
||||
* then the cache module directory `./cache` will be used instead
|
||||
*
|
||||
* @method load
|
||||
* @param docId {String} the id of the cache, would also be used as the name of the file cache
|
||||
* @param [cacheDir] {String} directory for the cache entry
|
||||
*/
|
||||
load: function (docId, cacheDir) {
|
||||
const me = this;
|
||||
me.keyv = new Keyv();
|
||||
|
||||
me.__visited = {};
|
||||
me.__persisted = {};
|
||||
|
||||
me._pathToFile = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
|
||||
|
||||
if (fs.existsSync(me._pathToFile)) {
|
||||
me._persisted = tryParse(me._pathToFile, {});
|
||||
}
|
||||
},
|
||||
|
||||
get _persisted() {
|
||||
return this.__persisted;
|
||||
},
|
||||
|
||||
set _persisted(value) {
|
||||
this.__persisted = value;
|
||||
},
|
||||
|
||||
get _visited() {
|
||||
return this.__visited;
|
||||
},
|
||||
|
||||
set _visited(value) {
|
||||
this.__visited = value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Load the cache from the provided file
|
||||
* @method loadFile
|
||||
* @param {String} pathToFile the path to the file containing the info for the cache
|
||||
*/
|
||||
loadFile: function (pathToFile) {
|
||||
const me = this;
|
||||
const dir = path.dirname(pathToFile);
|
||||
const fName = path.basename(pathToFile);
|
||||
|
||||
me.load(fName, dir);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the entire persisted object
|
||||
* @method all
|
||||
* @returns {*}
|
||||
*/
|
||||
all: function () {
|
||||
return this._persisted;
|
||||
},
|
||||
|
||||
keys: function () {
|
||||
return Object.keys(this._persisted);
|
||||
},
|
||||
/**
|
||||
* sets a key to a given value
|
||||
* @method setKey
|
||||
* @param key {string} the key to set
|
||||
* @param value {object} the value of the key. Could be any object that can be serialized with JSON.stringify
|
||||
*/
|
||||
setKey: function (key, value) {
|
||||
this._visited[key] = true;
|
||||
this._persisted[key] = value;
|
||||
},
|
||||
/**
|
||||
* remove a given key from the cache
|
||||
* @method removeKey
|
||||
* @param key {String} the key to remove from the object
|
||||
*/
|
||||
removeKey: function (key) {
|
||||
delete this._visited[key]; // esfmt-ignore-line
|
||||
delete this._persisted[key]; // esfmt-ignore-line
|
||||
},
|
||||
/**
|
||||
* Return the value of the provided key
|
||||
* @method getKey
|
||||
* @param key {String} the name of the key to retrieve
|
||||
* @returns {*} the value from the key
|
||||
*/
|
||||
getKey: function (key) {
|
||||
this._visited[key] = true;
|
||||
return this._persisted[key];
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove keys that were not accessed/set since the
|
||||
* last time the `prune` method was called.
|
||||
* @method _prune
|
||||
* @private
|
||||
*/
|
||||
_prune: function () {
|
||||
const me = this;
|
||||
const obj = {};
|
||||
|
||||
const keys = Object.keys(me._visited);
|
||||
|
||||
// no keys visited for either get or set value
|
||||
if (keys.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
keys.forEach(function (key) {
|
||||
obj[key] = me._persisted[key];
|
||||
});
|
||||
|
||||
me._visited = {};
|
||||
me._persisted = obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* Save the state of the cache identified by the docId to disk
|
||||
* as a JSON structure
|
||||
* @param [noPrune=false] {Boolean} whether to remove from cache the non visited files
|
||||
* @method save
|
||||
*/
|
||||
save: function (noPrune) {
|
||||
const me = this;
|
||||
!noPrune && me._prune();
|
||||
writeJSON(me._pathToFile, me._persisted);
|
||||
},
|
||||
|
||||
/**
|
||||
* remove the file where the cache is persisted
|
||||
* @method removeCacheFile
|
||||
* @return {Boolean} true or false if the file was successfully deleted
|
||||
*/
|
||||
removeCacheFile: function () {
|
||||
return del(this._pathToFile);
|
||||
},
|
||||
/**
|
||||
* Destroy the file cache and cache content.
|
||||
* @method destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
const me = this;
|
||||
me._visited = {};
|
||||
me._persisted = {};
|
||||
|
||||
me.removeCacheFile();
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Alias for create. Should be considered depreacted. Will be removed in next releases
|
||||
*
|
||||
* @method load
|
||||
* @param docId {String} the id of the cache, would also be used as the name of the file cache
|
||||
* @param [cacheDir] {String} directory for the cache entry
|
||||
* @returns {cache} cache instance
|
||||
*/
|
||||
load: function (docId, cacheDir) {
|
||||
return this.create(docId, cacheDir);
|
||||
},
|
||||
|
||||
/**
|
||||
* Load a cache identified by the given Id. If the element does not exists, then initialize an empty
|
||||
* cache storage.
|
||||
*
|
||||
* @method create
|
||||
* @param docId {String} the id of the cache, would also be used as the name of the file cache
|
||||
* @param [cacheDir] {String} directory for the cache entry
|
||||
* @returns {cache} cache instance
|
||||
*/
|
||||
create: function (docId, cacheDir) {
|
||||
const obj = Object.create(cache);
|
||||
obj.load(docId, cacheDir);
|
||||
return obj;
|
||||
},
|
||||
|
||||
createFromFile: function (filePath) {
|
||||
const obj = Object.create(cache);
|
||||
obj.loadFile(filePath);
|
||||
return obj;
|
||||
},
|
||||
/**
|
||||
* Clear the cache identified by the given id. Caches stored in a different cache directory can be deleted directly
|
||||
*
|
||||
* @method clearCache
|
||||
* @param docId {String} the id of the cache, would also be used as the name of the file cache
|
||||
* @param cacheDir {String} the directory where the cache file was written
|
||||
* @returns {Boolean} true if the cache folder was deleted. False otherwise
|
||||
*/
|
||||
clearCacheById: function (docId, cacheDir) {
|
||||
const filePath = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
|
||||
return del(filePath);
|
||||
},
|
||||
/**
|
||||
* Remove all cache stored in the cache directory
|
||||
* @method clearAll
|
||||
* @returns {Boolean} true if the cache folder was deleted. False otherwise
|
||||
*/
|
||||
clearAll: function (cacheDir) {
|
||||
const filePath = cacheDir ? path.resolve(cacheDir) : path.resolve(__dirname, '../.cache/');
|
||||
return del(filePath);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 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","2":"C L M G N"},C:{"1":"0 1 2 3 4 5 6 7 8 9 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 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 qC rC","2":"nC LC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 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 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"},E:{"1":"jC 3C","2":"J PB K D E F A B C L M sC SC tC uC vC wC TC FC GC xC","260":"JC bC cC dC eC fC 2C KC gC hC iC","388":"G yC zC UC VC HC 0C IC WC XC YC ZC aC 1C"},F:{"1":"0 1 2 3 4 5 6 7 8 B C 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 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 6C 7C FC kC 8C GC","2":"F 4C 5C"},G:{"1":"jC","2":"E SC 9C lC AD BD CD 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","260":"eC fC VD KC gC hC iC"},H:{"2":"WD"},I:{"1":"LC J I ZD aD lC bD cD","16":"XD YD"},J:{"1":"A","2":"D"},K:{"1":"B C H FC kC GC","2":"A"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"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:"Ogg Vorbis audio format",D:true};
|
||||
@@ -0,0 +1,277 @@
|
||||
# CSSType
|
||||
|
||||
[](https://www.npmjs.com/package/csstype)
|
||||
|
||||
TypeScript and Flow definitions for CSS, generated by [data from MDN](https://github.com/mdn/data). It provides autocompletion and type checking for CSS properties and values.
|
||||
|
||||
**TypeScript**
|
||||
|
||||
```ts
|
||||
import type * as CSS from 'csstype';
|
||||
|
||||
const style: CSS.Properties = {
|
||||
colour: 'white', // Type error on property
|
||||
textAlign: 'middle', // Type error on value
|
||||
};
|
||||
```
|
||||
|
||||
**Flow**
|
||||
|
||||
```js
|
||||
// @flow strict
|
||||
import * as CSS from 'csstype';
|
||||
|
||||
const style: CSS.Properties<> = {
|
||||
colour: 'white', // Type error on property
|
||||
textAlign: 'middle', // Type error on value
|
||||
};
|
||||
```
|
||||
|
||||
_Further examples below will be in TypeScript!_
|
||||
|
||||
## Getting started
|
||||
|
||||
```sh
|
||||
$ npm install csstype
|
||||
```
|
||||
|
||||
## Table of content
|
||||
|
||||
- [Style types](#style-types)
|
||||
- [At-rule types](#at-rule-types)
|
||||
- [Pseudo types](#pseudo-types)
|
||||
- [Generics](#generics)
|
||||
- [Usage](#usage)
|
||||
- [What should I do when I get type errors?](#what-should-i-do-when-i-get-type-errors)
|
||||
- [Version 3.0](#version-30)
|
||||
- [Contributing](#contributing)
|
||||
|
||||
## Style types
|
||||
|
||||
Properties are categorized in different uses and in several technical variations to provide typings that suits as many as possible.
|
||||
|
||||
| | Default | `Hyphen` | `Fallback` | `HyphenFallback` |
|
||||
| -------------- | -------------------- | -------------------------- | ---------------------------- | ---------------------------------- |
|
||||
| **All** | `Properties` | `PropertiesHyphen` | `PropertiesFallback` | `PropertiesHyphenFallback` |
|
||||
| **`Standard`** | `StandardProperties` | `StandardPropertiesHyphen` | `StandardPropertiesFallback` | `StandardPropertiesHyphenFallback` |
|
||||
| **`Vendor`** | `VendorProperties` | `VendorPropertiesHyphen` | `VendorPropertiesFallback` | `VendorPropertiesHyphenFallback` |
|
||||
| **`Obsolete`** | `ObsoleteProperties` | `ObsoletePropertiesHyphen` | `ObsoletePropertiesFallback` | `ObsoletePropertiesHyphenFallback` |
|
||||
| **`Svg`** | `SvgProperties` | `SvgPropertiesHyphen` | `SvgPropertiesFallback` | `SvgPropertiesHyphenFallback` |
|
||||
|
||||
Categories:
|
||||
|
||||
- **All** - Includes `Standard`, `Vendor`, `Obsolete` and `Svg`
|
||||
- **`Standard`** - Current properties and extends subcategories `StandardLonghand` and `StandardShorthand` _(e.g. `StandardShorthandProperties`)_
|
||||
- **`Vendor`** - Vendor prefixed properties and extends subcategories `VendorLonghand` and `VendorShorthand` _(e.g. `VendorShorthandProperties`)_
|
||||
- **`Obsolete`** - Removed or deprecated properties
|
||||
- **`Svg`** - SVG-specific properties
|
||||
|
||||
Variations:
|
||||
|
||||
- **Default** - JavaScript (camel) cased property names
|
||||
- **`Hyphen`** - CSS (kebab) cased property names
|
||||
- **`Fallback`** - Also accepts array of values e.g. `string | string[]`
|
||||
|
||||
## At-rule types
|
||||
|
||||
At-rule interfaces with descriptors.
|
||||
|
||||
**TypeScript**: These will be found in the `AtRule` namespace, e.g. `AtRule.Viewport`.
|
||||
**Flow**: These will be prefixed with `AtRule$`, e.g. `AtRule$Viewport`.
|
||||
|
||||
| | Default | `Hyphen` | `Fallback` | `HyphenFallback` |
|
||||
| -------------------- | -------------- | -------------------- | ---------------------- | ---------------------------- |
|
||||
| **`@counter-style`** | `CounterStyle` | `CounterStyleHyphen` | `CounterStyleFallback` | `CounterStyleHyphenFallback` |
|
||||
| **`@font-face`** | `FontFace` | `FontFaceHyphen` | `FontFaceFallback` | `FontFaceHyphenFallback` |
|
||||
| **`@viewport`** | `Viewport` | `ViewportHyphen` | `ViewportFallback` | `ViewportHyphenFallback` |
|
||||
|
||||
## Pseudo types
|
||||
|
||||
String literals of pseudo classes and pseudo elements
|
||||
|
||||
- `Pseudos`
|
||||
|
||||
Extends:
|
||||
|
||||
- `AdvancedPseudos`
|
||||
|
||||
Function-like pseudos e.g. `:not(:first-child)`. The string literal contains the value excluding the parenthesis: `:not`. These are separated because they require an argument that results in infinite number of variations.
|
||||
|
||||
- `SimplePseudos`
|
||||
|
||||
Plain pseudos e.g. `:hover` that can only be **one** variation.
|
||||
|
||||
## Generics
|
||||
|
||||
All interfaces has two optional generic argument to define length and time: `CSS.Properties<TLength = string | 0, TTime = string>`
|
||||
|
||||
- **Length** is the first generic parameter and defaults to `string | 0` because `0` is the only [length where the unit identifier is optional](https://drafts.csswg.org/css-values-3/#lengths). You can specify this, e.g. `string | number`, for platforms and libraries that accepts any numeric value as length with a specific unit.
|
||||
```tsx
|
||||
const style: CSS.Properties<string | number> = {
|
||||
width: 100,
|
||||
};
|
||||
```
|
||||
- **Time** is the second generic argument and defaults to `string`. You can specify this, e.g. `string | number`, for platforms and libraries that accepts any numeric value as length with a specific unit.
|
||||
```tsx
|
||||
const style: CSS.Properties<string | number, number> = {
|
||||
transitionDuration: 1000,
|
||||
};
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import type * as CSS from 'csstype';
|
||||
|
||||
const style: CSS.Properties = {
|
||||
width: '10px',
|
||||
margin: '1em',
|
||||
};
|
||||
```
|
||||
|
||||
In some cases, like for CSS-in-JS libraries, an array of values is a way to provide fallback values in CSS. Using `CSS.PropertiesFallback` instead of `CSS.Properties` will add the possibility to use any property value as an array of values.
|
||||
|
||||
```ts
|
||||
import type * as CSS from 'csstype';
|
||||
|
||||
const style: CSS.PropertiesFallback = {
|
||||
display: ['-webkit-flex', 'flex'],
|
||||
color: 'white',
|
||||
};
|
||||
```
|
||||
|
||||
There's even string literals for pseudo selectors and elements.
|
||||
|
||||
```ts
|
||||
import type * as CSS from 'csstype';
|
||||
|
||||
const pseudos: { [P in CSS.SimplePseudos]?: CSS.Properties } = {
|
||||
':hover': {
|
||||
display: 'flex',
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
Hyphen cased (kebab cased) properties are provided in `CSS.PropertiesHyphen` and `CSS.PropertiesHyphenFallback`. It's not **not** added by default in `CSS.Properties`. To allow both of them, you can simply extend with `CSS.PropertiesHyphen` or/and `CSS.PropertiesHyphenFallback`.
|
||||
|
||||
```ts
|
||||
import type * as CSS from 'csstype';
|
||||
|
||||
interface Style extends CSS.Properties, CSS.PropertiesHyphen {}
|
||||
|
||||
const style: Style = {
|
||||
'flex-grow': 1,
|
||||
'flex-shrink': 0,
|
||||
'font-weight': 'normal',
|
||||
backgroundColor: 'white',
|
||||
};
|
||||
```
|
||||
|
||||
Adding type checked CSS properties to a `HTMLElement`.
|
||||
|
||||
```ts
|
||||
import type * as CSS from 'csstype';
|
||||
|
||||
const style: CSS.Properties = {
|
||||
color: 'red',
|
||||
margin: '1em',
|
||||
};
|
||||
|
||||
let button = document.createElement('button');
|
||||
|
||||
Object.assign(button.style, style);
|
||||
```
|
||||
|
||||
## What should I do when I get type errors?
|
||||
|
||||
The goal is to have as perfect types as possible and we're trying to do our best. But with CSS Custom Properties, the CSS specification changing frequently and vendors implementing their own specifications with new releases sometimes causes type errors even if it should work. Here's some steps you could take to get it fixed:
|
||||
|
||||
_If you're using CSS Custom Properties you can step directly to step 3._
|
||||
|
||||
1. **First of all, make sure you're doing it right.** A type error could also indicate that you're not :wink:
|
||||
|
||||
- Some CSS specs that some vendors has implemented could have been officially rejected or haven't yet received any official acceptance and are therefor not included
|
||||
- If you're using TypeScript, [type widening](https://blog.mariusschulz.com/2017/02/04/TypeScript-2-1-literal-type-widening) could be the reason you get `Type 'string' is not assignable to...` errors
|
||||
|
||||
2. **Have a look in [issues](https://github.com/frenic/csstype/issues) to see if an issue already has been filed. If not, create a new one.** To help us out, please refer to any information you have found.
|
||||
3. Fix the issue locally with **TypeScript** (Flow further down):
|
||||
|
||||
- The recommended way is to use **module augmentation**. Here's a few examples:
|
||||
|
||||
```ts
|
||||
// My css.d.ts file
|
||||
import type * as CSS from 'csstype';
|
||||
|
||||
declare module 'csstype' {
|
||||
interface Properties {
|
||||
// Add a missing property
|
||||
WebkitRocketLauncher?: string;
|
||||
|
||||
// Add a CSS Custom Property
|
||||
'--theme-color'?: 'black' | 'white';
|
||||
|
||||
// Allow namespaced CSS Custom Properties
|
||||
[index: `--theme-${string}`]: any;
|
||||
|
||||
// Allow any CSS Custom Properties
|
||||
[index: `--${string}`]: any;
|
||||
|
||||
// ...or allow any other property
|
||||
[index: string]: any;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- The alternative way is to use **type assertion**. Here's a few examples:
|
||||
|
||||
```ts
|
||||
const style: CSS.Properties = {
|
||||
// Add a missing property
|
||||
['WebkitRocketLauncher' as any]: 'launching',
|
||||
|
||||
// Add a CSS Custom Property
|
||||
['--theme-color' as any]: 'black',
|
||||
};
|
||||
```
|
||||
|
||||
Fix the issue locally with **Flow**:
|
||||
|
||||
- Use **type assertion**. Here's a few examples:
|
||||
|
||||
```js
|
||||
const style: $Exact<CSS.Properties<*>> = {
|
||||
// Add a missing property
|
||||
[('WebkitRocketLauncher': any)]: 'launching',
|
||||
|
||||
// Add a CSS Custom Property
|
||||
[('--theme-color': any)]: 'black',
|
||||
};
|
||||
```
|
||||
|
||||
## Version 3.0
|
||||
|
||||
- **All property types are exposed with namespace**
|
||||
TypeScript: `Property.AlignContent` (was `AlignContentProperty` before)
|
||||
Flow: `Property$AlignContent`
|
||||
- **All at-rules are exposed with namespace**
|
||||
TypeScript: `AtRule.FontFace` (was `FontFace` before)
|
||||
Flow: `AtRule$FontFace`
|
||||
- **Data types are NOT exposed**
|
||||
E.g. `Color` and `Box`. Because the generation of data types may suddenly be removed or renamed.
|
||||
- **TypeScript hack for autocompletion**
|
||||
Uses `(string & {})` for literal string unions and `(number & {})` for literal number unions ([related issue](https://github.com/microsoft/TypeScript/issues/29729)). Utilize `PropertyValue<T>` to unpack types from e.g. `(string & {})` to `string`.
|
||||
- **New generic for time**
|
||||
Read more on the ["Generics"](#generics) section.
|
||||
- **Flow types improvements**
|
||||
Flow Strict enabled and exact types are used.
|
||||
|
||||
## Contributing
|
||||
|
||||
**Never modify `index.d.ts` and `index.js.flow` directly. They are generated automatically and committed so that we can easily follow any change it results in.** Therefor it's important that you run `$ git config merge.ours.driver true` after you've forked and cloned. That setting prevents merge conflicts when doing rebase.
|
||||
|
||||
### Commands
|
||||
|
||||
- `npm run build` Generates typings and type checks them
|
||||
- `npm run watch` Runs build on each save
|
||||
- `npm run test` Runs the tests
|
||||
- `npm run lazy` Type checks, lints and formats everything
|
||||
@@ -0,0 +1,48 @@
|
||||
import * as React from 'react'
|
||||
|
||||
import { TSR_DEFERRED_PROMISE, defer } from '@tanstack/router-core'
|
||||
import type { DeferredPromise } from '@tanstack/router-core'
|
||||
|
||||
export type AwaitOptions<T> = {
|
||||
promise: Promise<T>
|
||||
}
|
||||
|
||||
export function useAwaited<T>({
|
||||
promise: _promise,
|
||||
}: AwaitOptions<T>): [T, DeferredPromise<T>] {
|
||||
const promise = defer(_promise)
|
||||
|
||||
if (promise[TSR_DEFERRED_PROMISE].status === 'pending') {
|
||||
throw promise
|
||||
}
|
||||
|
||||
if (promise[TSR_DEFERRED_PROMISE].status === 'error') {
|
||||
throw promise[TSR_DEFERRED_PROMISE].error
|
||||
}
|
||||
|
||||
return [promise[TSR_DEFERRED_PROMISE].data, promise]
|
||||
}
|
||||
|
||||
export function Await<T>(
|
||||
props: AwaitOptions<T> & {
|
||||
fallback?: React.ReactNode
|
||||
children: (result: T) => React.ReactNode
|
||||
},
|
||||
) {
|
||||
const inner = <AwaitInner {...props} />
|
||||
if (props.fallback) {
|
||||
return <React.Suspense fallback={props.fallback}>{inner}</React.Suspense>
|
||||
}
|
||||
return inner
|
||||
}
|
||||
|
||||
function AwaitInner<T>(
|
||||
props: AwaitOptions<T> & {
|
||||
fallback?: React.ReactNode
|
||||
children: (result: T) => React.ReactNode
|
||||
},
|
||||
): React.JSX.Element {
|
||||
const [data] = useAwaited(props)
|
||||
|
||||
return props.children(data) as React.JSX.Element
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "isIdentifierChar", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _identifier.isIdentifierChar;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isIdentifierName", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _identifier.isIdentifierName;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isIdentifierStart", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _identifier.isIdentifierStart;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isKeyword", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isKeyword;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isReservedWord;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isStrictBindOnlyReservedWord;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isStrictBindReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isStrictBindReservedWord;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isStrictReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isStrictReservedWord;
|
||||
}
|
||||
});
|
||||
var _identifier = require("./identifier.js");
|
||||
var _keyword = require("./keyword.js");
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"K D E F A B","16":"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 1 2 3 4 5 6 7 8 9 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 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","16":"nC LC qC rC"},D:{"1":"0 7 8 9 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 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","16":"1 2 3 4 5 6 J PB K D E F A B C L M G N O P QB"},E:{"1":"K D E F A B C L M G tC uC 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","16":"J PB sC SC"},F:{"1":"0 1 2 3 4 5 6 7 8 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 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","16":"F 4C","132":"B C 5C 6C 7C FC kC 8C GC"},G:{"1":"E CD 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","16":"SC 9C lC AD BD"},H:{"1":"WD"},I:{"1":"LC J I ZD aD lC bD cD","16":"XD YD"},J:{"1":"D A"},K:{"1":"H","132":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"257":"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:1,C:"readonly attribute of input and textarea elements",D:true};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"K D E F A B","16":"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 1 2 3 4 5 6 7 8 9 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 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 rC","2":"nC LC","16":"qC"},D:{"1":"0 9 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 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","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB"},E:{"1":"K D E F A B C L M G uC 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","2":"J PB sC SC tC"},F:{"1":"0 1 2 3 4 5 6 7 8 C 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 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 8C GC","2":"F B 4C 5C 6C 7C FC kC"},G:{"1":"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","2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD"},H:{"2":"WD"},I:{"1":"I bD cD","2":"LC J XD YD ZD aD lC"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"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:1,C:"indeterminate checkbox",D:true};
|
||||
@@ -0,0 +1,111 @@
|
||||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
exports.GREATEST_LOWER_BOUND = 1;
|
||||
exports.LEAST_UPPER_BOUND = 2;
|
||||
|
||||
/**
|
||||
* Recursive implementation of binary search.
|
||||
*
|
||||
* @param aLow Indices here and lower do not contain the needle.
|
||||
* @param aHigh Indices here and higher do not contain the needle.
|
||||
* @param aNeedle The element being searched for.
|
||||
* @param aHaystack The non-empty array being searched.
|
||||
* @param aCompare Function which takes two elements and returns -1, 0, or 1.
|
||||
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
|
||||
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||||
* closest element that is smaller than or greater than the one we are
|
||||
* searching for, respectively, if the exact element cannot be found.
|
||||
*/
|
||||
function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
|
||||
// This function terminates when one of the following is true:
|
||||
//
|
||||
// 1. We find the exact element we are looking for.
|
||||
//
|
||||
// 2. We did not find the exact element, but we can return the index of
|
||||
// the next-closest element.
|
||||
//
|
||||
// 3. We did not find the exact element, and there is no next-closest
|
||||
// element than the one we are searching for, so we return -1.
|
||||
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
|
||||
var cmp = aCompare(aNeedle, aHaystack[mid], true);
|
||||
if (cmp === 0) {
|
||||
// Found the element we are looking for.
|
||||
return mid;
|
||||
}
|
||||
else if (cmp > 0) {
|
||||
// Our needle is greater than aHaystack[mid].
|
||||
if (aHigh - mid > 1) {
|
||||
// The element is in the upper half.
|
||||
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
|
||||
}
|
||||
|
||||
// The exact needle element was not found in this haystack. Determine if
|
||||
// we are in termination case (3) or (2) and return the appropriate thing.
|
||||
if (aBias == exports.LEAST_UPPER_BOUND) {
|
||||
return aHigh < aHaystack.length ? aHigh : -1;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Our needle is less than aHaystack[mid].
|
||||
if (mid - aLow > 1) {
|
||||
// The element is in the lower half.
|
||||
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
|
||||
}
|
||||
|
||||
// we are in termination case (3) or (2) and return the appropriate thing.
|
||||
if (aBias == exports.LEAST_UPPER_BOUND) {
|
||||
return mid;
|
||||
} else {
|
||||
return aLow < 0 ? -1 : aLow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an implementation of binary search which will always try and return
|
||||
* the index of the closest element if there is no exact hit. This is because
|
||||
* mappings between original and generated line/col pairs are single points,
|
||||
* and there is an implicit region between each of them, so a miss just means
|
||||
* that you aren't on the very start of a region.
|
||||
*
|
||||
* @param aNeedle The element you are looking for.
|
||||
* @param aHaystack The array that is being searched.
|
||||
* @param aCompare A function which takes the needle and an element in the
|
||||
* array and returns -1, 0, or 1 depending on whether the needle is less
|
||||
* than, equal to, or greater than the element, respectively.
|
||||
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
|
||||
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||||
* closest element that is smaller than or greater than the one we are
|
||||
* searching for, respectively, if the exact element cannot be found.
|
||||
* Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
|
||||
*/
|
||||
exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
|
||||
if (aHaystack.length === 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
|
||||
aCompare, aBias || exports.GREATEST_LOWER_BOUND);
|
||||
if (index < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We have found either the exact element, or the next-closest element than
|
||||
// the one we are searching for. However, there may be more than one such
|
||||
// element. Make sure we always return the smallest of these.
|
||||
while (index - 1 >= 0) {
|
||||
if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
|
||||
break;
|
||||
}
|
||||
--index;
|
||||
}
|
||||
|
||||
return index;
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
throw new Error(
|
||||
'react-dom/server is not supported in React Server Components.'
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_buildMatchMemberExpression","require","isReactComponent","buildMatchMemberExpression","_default","exports","default"],"sources":["../../../src/validators/react/isReactComponent.ts"],"sourcesContent":["import buildMatchMemberExpression from \"../buildMatchMemberExpression.ts\";\n\nconst isReactComponent = buildMatchMemberExpression(\"React.Component\");\n\nexport default isReactComponent;\n"],"mappings":";;;;;;AAAA,IAAAA,2BAAA,GAAAC,OAAA;AAEA,MAAMC,gBAAgB,GAAG,IAAAC,mCAA0B,EAAC,iBAAiB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAExDJ,gBAAgB","ignoreList":[]}
|
||||
@@ -0,0 +1,114 @@
|
||||
"use strict";
|
||||
'use client';
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Outline;
|
||||
const jsx_runtime_1 = require("react/jsx-runtime");
|
||||
const react_1 = require("react");
|
||||
const make_cancellable_promise_1 = __importDefault(require("make-cancellable-promise"));
|
||||
const make_event_props_1 = __importDefault(require("make-event-props"));
|
||||
const clsx_1 = __importDefault(require("clsx"));
|
||||
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
||||
const warning_1 = __importDefault(require("warning"));
|
||||
const OutlineContext_js_1 = __importDefault(require("./OutlineContext.js"));
|
||||
const OutlineItem_js_1 = __importDefault(require("./OutlineItem.js"));
|
||||
const utils_js_1 = require("./shared/utils.js");
|
||||
const useDocumentContext_js_1 = __importDefault(require("./shared/hooks/useDocumentContext.js"));
|
||||
const useResolver_js_1 = __importDefault(require("./shared/hooks/useResolver.js"));
|
||||
/**
|
||||
* Displays an outline (table of contents).
|
||||
*
|
||||
* Should be placed inside `<Document />`. Alternatively, it can have `pdf` prop passed, which can be obtained from `<Document />`'s `onLoadSuccess` callback function.
|
||||
*/
|
||||
function Outline(props) {
|
||||
const documentContext = (0, useDocumentContext_js_1.default)();
|
||||
const mergedProps = Object.assign(Object.assign({}, documentContext), props);
|
||||
const { className, inputRef, onItemClick, onLoadError: onLoadErrorProps, onLoadSuccess: onLoadSuccessProps, pdf } = mergedProps, otherProps = __rest(mergedProps, ["className", "inputRef", "onItemClick", "onLoadError", "onLoadSuccess", "pdf"]);
|
||||
(0, tiny_invariant_1.default)(pdf, 'Attempted to load an outline, but no document was specified. Wrap <Outline /> in a <Document /> or pass explicit `pdf` prop.');
|
||||
const [outlineState, outlineDispatch] = (0, useResolver_js_1.default)();
|
||||
const { value: outline, error: outlineError } = outlineState;
|
||||
/**
|
||||
* Called when an outline is read successfully
|
||||
*/
|
||||
function onLoadSuccess() {
|
||||
if (typeof outline === 'undefined' || outline === false) {
|
||||
return;
|
||||
}
|
||||
if (onLoadSuccessProps) {
|
||||
onLoadSuccessProps(outline);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called when an outline failed to read successfully
|
||||
*/
|
||||
function onLoadError() {
|
||||
if (!outlineError) {
|
||||
// Impossible, but TypeScript doesn't know that
|
||||
return;
|
||||
}
|
||||
(0, warning_1.default)(false, outlineError.toString());
|
||||
if (onLoadErrorProps) {
|
||||
onLoadErrorProps(outlineError);
|
||||
}
|
||||
}
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: useEffect intentionally triggered on pdf change
|
||||
(0, react_1.useEffect)(function resetOutline() {
|
||||
outlineDispatch({ type: 'RESET' });
|
||||
}, [outlineDispatch, pdf]);
|
||||
(0, react_1.useEffect)(function loadOutline() {
|
||||
if (!pdf) {
|
||||
// Impossible, but TypeScript doesn't know that
|
||||
return;
|
||||
}
|
||||
const cancellable = (0, make_cancellable_promise_1.default)(pdf.getOutline());
|
||||
const runningTask = cancellable;
|
||||
cancellable.promise
|
||||
.then((nextOutline) => {
|
||||
outlineDispatch({ type: 'RESOLVE', value: nextOutline });
|
||||
})
|
||||
.catch((error) => {
|
||||
outlineDispatch({ type: 'REJECT', error });
|
||||
});
|
||||
return () => (0, utils_js_1.cancelRunningTask)(runningTask);
|
||||
}, [outlineDispatch, pdf]);
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: Ommitted callbacks so they are not called every time they change
|
||||
(0, react_1.useEffect)(() => {
|
||||
if (outline === undefined) {
|
||||
return;
|
||||
}
|
||||
if (outline === false) {
|
||||
onLoadError();
|
||||
return;
|
||||
}
|
||||
onLoadSuccess();
|
||||
}, [outline]);
|
||||
const childContext = (0, react_1.useMemo)(() => ({
|
||||
onItemClick,
|
||||
}), [onItemClick]);
|
||||
const eventProps = (0, react_1.useMemo)(() => (0, make_event_props_1.default)(otherProps, () => outline),
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: FIXME
|
||||
[otherProps, outline]);
|
||||
if (!outline) {
|
||||
return null;
|
||||
}
|
||||
function renderOutline() {
|
||||
if (!outline) {
|
||||
return null;
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)("ul", { children: outline.map((item, itemIndex) => ((0, jsx_runtime_1.jsx)(OutlineItem_js_1.default, { item: item, pdf: pdf }, typeof item.dest === 'string' ? item.dest : itemIndex))) }));
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, clsx_1.default)('react-pdf__Outline', className), ref: inputRef }, eventProps, { children: (0, jsx_runtime_1.jsx)(OutlineContext_js_1.default.Provider, { value: childContext, children: renderOutline() }) })));
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import Container from './container.js'
|
||||
import Node, { NodeProps } from './node.js'
|
||||
|
||||
declare namespace Comment {
|
||||
export interface CommentRaws extends Record<string, unknown> {
|
||||
/**
|
||||
* The space symbols before the node.
|
||||
*/
|
||||
before?: string
|
||||
|
||||
/**
|
||||
* The space symbols between `/*` and the comment’s text.
|
||||
*/
|
||||
left?: string
|
||||
|
||||
/**
|
||||
* The space symbols between the comment’s text.
|
||||
*/
|
||||
right?: string
|
||||
}
|
||||
|
||||
export interface CommentProps extends NodeProps {
|
||||
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
||||
raws?: CommentRaws
|
||||
/** Content of the comment. */
|
||||
text: string
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
export { Comment_ as default }
|
||||
}
|
||||
|
||||
/**
|
||||
* It represents a class that handles
|
||||
* [CSS comments](https://developer.mozilla.org/en-US/docs/Web/CSS/Comments)
|
||||
*
|
||||
* ```js
|
||||
* Once (root, { Comment }) {
|
||||
* const note = new Comment({ text: 'Note: …' })
|
||||
* root.append(note)
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Remember that CSS comments inside selectors, at-rule parameters,
|
||||
* or declaration values will be stored in the `raws` properties
|
||||
* explained above.
|
||||
*/
|
||||
declare class Comment_ extends Node {
|
||||
parent: Container | undefined
|
||||
raws: Comment.CommentRaws
|
||||
type: 'comment'
|
||||
/**
|
||||
* The comment's text.
|
||||
*/
|
||||
get text(): string
|
||||
|
||||
set text(value: string)
|
||||
|
||||
constructor(defaults?: Comment.CommentProps)
|
||||
assign(overrides: Comment.CommentProps | object): this
|
||||
clone(overrides?: Partial<Comment.CommentProps>): this
|
||||
cloneAfter(overrides?: Partial<Comment.CommentProps>): this
|
||||
cloneBefore(overrides?: Partial<Comment.CommentProps>): this
|
||||
}
|
||||
|
||||
declare class Comment extends Comment_ {}
|
||||
|
||||
export = Comment
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_validator","require","_findSuggestion"],"sources":["../src/index.ts"],"sourcesContent":["export { OptionValidator } from \"./validator.ts\";\nexport { findSuggestion } from \"./find-suggestion.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA","ignoreList":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"https.js","sourceRoot":"","sources":["../../../src/schemes/https.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,MAAM,OAAO,GAAoB;IAChC,MAAM,EAAG,OAAO;IAChB,UAAU,EAAG,IAAI,CAAC,UAAU;IAC5B,KAAK,EAAG,IAAI,CAAC,KAAK;IAClB,SAAS,EAAG,IAAI,CAAC,SAAS;CAC1B,CAAA;AAED,eAAe,OAAO,CAAC"}
|
||||
Reference in New Issue
Block a user