Initial import of Indiekit server
This commit is contained in:
2
custom-server.js
Normal file
2
custom-server.js
Normal file
@@ -0,0 +1,2 @@
|
||||
require('dotenv').config();
|
||||
require('indiekit').serve();
|
||||
75
indiekit.config.mjs
Normal file
75
indiekit.config.mjs
Normal file
@@ -0,0 +1,75 @@
|
||||
export default {
|
||||
url: "https://blog.giersig.eu",
|
||||
debug: "indiekit:*",
|
||||
application: {
|
||||
name: "Indiekit",
|
||||
admin: {
|
||||
username: "admin@blog.giersig.eu",
|
||||
password: "accus3D23"
|
||||
}
|
||||
},
|
||||
"@indiekit/endpoint-auth": {
|
||||
publicUrl: "https://blog.giersig.eu"
|
||||
},
|
||||
publication: {
|
||||
me: "https://blog.giersig.eu",
|
||||
postTypes: [
|
||||
{
|
||||
type: "article",
|
||||
name: "Artikel",
|
||||
post: {
|
||||
path: "src/posts/{slug}.md",
|
||||
url: "https://blog.giersig.eu/posts/{slug}/",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "note",
|
||||
name: "Notiz",
|
||||
post: {
|
||||
path: "src/notes/{slug}.md",
|
||||
url: "https://blog.giersig.eu/notes/{slug}/",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "bookmark",
|
||||
name: "Lesezeichen",
|
||||
post: {
|
||||
path: "src/bookmarks/{slug}.md",
|
||||
url: "https://blog.giersig.eu/bookmarks/{slug}/",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
secret: process.env.SECRET,
|
||||
mongodbUrl: `mongodb://indiekit:${process.env.MONGO_PASSWORD}@10.100.0.20:27017/indiekit`,
|
||||
plugins: [
|
||||
"@indiekit/store-github",
|
||||
"@rmdes/indiekit-endpoint-posts",
|
||||
"@rmdes/indiekit-endpoint-auth",
|
||||
"@rmdes/indiekit-endpoint-share",
|
||||
"@rmdes/indiekit-endpoint-github",
|
||||
"@rmdes/indiekit-endpoint-webmention-io",
|
||||
"@rmdes/indiekit-endpoint-conversations",
|
||||
//"@rmdes/indiekit-endpoint-activitypub",
|
||||
],
|
||||
"@indiekit/store-github": {
|
||||
user: "svemagie",
|
||||
repo: "blog",
|
||||
branch: "main",
|
||||
},
|
||||
"@rmdes/indiekit-endpoint-github": {
|
||||
token: process.env.GITHUB_TOKEN,
|
||||
user: "svemagie",
|
||||
},
|
||||
"@rmdes/indiekit-endpoint-webmention-io": {
|
||||
token: process.env.WEBMENTION_IO_TOKEN,
|
||||
},
|
||||
"@rmdes/indiekit-endpoint-conversations": {
|
||||
enabled: true,
|
||||
},
|
||||
"@rmdes/indiekit-endpoint-activitypub": {
|
||||
username: "blog.giersig.eu",
|
||||
},
|
||||
};
|
||||
|
||||
1
node_modules/.bin/acorn
generated
vendored
Symbolic link
1
node_modules/.bin/acorn
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../acorn/bin/acorn
|
||||
1
node_modules/.bin/esbuild
generated
vendored
Symbolic link
1
node_modules/.bin/esbuild
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../esbuild/bin/esbuild
|
||||
1
node_modules/.bin/indiekit
generated
vendored
Symbolic link
1
node_modules/.bin/indiekit
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../@indiekit/indiekit/bin/cli.js
|
||||
1
node_modules/.bin/ipx
generated
vendored
Symbolic link
1
node_modules/.bin/ipx
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../ipx/bin/ipx.mjs
|
||||
1
node_modules/.bin/is-docker
generated
vendored
Symbolic link
1
node_modules/.bin/is-docker
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../is-docker/cli.js
|
||||
1
node_modules/.bin/is-inside-container
generated
vendored
Symbolic link
1
node_modules/.bin/is-inside-container
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../is-inside-container/cli.js
|
||||
1
node_modules/.bin/jiti
generated
vendored
Symbolic link
1
node_modules/.bin/jiti
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jiti/lib/jiti-cli.mjs
|
||||
1
node_modules/.bin/js-yaml
generated
vendored
Symbolic link
1
node_modules/.bin/js-yaml
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../js-yaml/bin/js-yaml.js
|
||||
1
node_modules/.bin/listen
generated
vendored
Symbolic link
1
node_modules/.bin/listen
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../listhen/bin/listhen.mjs
|
||||
1
node_modules/.bin/listhen
generated
vendored
Symbolic link
1
node_modules/.bin/listhen
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../listhen/bin/listhen.mjs
|
||||
1
node_modules/.bin/markdown-it
generated
vendored
Symbolic link
1
node_modules/.bin/markdown-it
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../markdown-it/bin/markdown-it.mjs
|
||||
1
node_modules/.bin/marked
generated
vendored
Symbolic link
1
node_modules/.bin/marked
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../marked/bin/marked.js
|
||||
1
node_modules/.bin/mustache
generated
vendored
Symbolic link
1
node_modules/.bin/mustache
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../mustache/bin/mustache
|
||||
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../nanoid/bin/nanoid.cjs
|
||||
1
node_modules/.bin/node-gyp
generated
vendored
Symbolic link
1
node_modules/.bin/node-gyp
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../node-gyp/bin/node-gyp.js
|
||||
1
node_modules/.bin/node-gyp-build
generated
vendored
Symbolic link
1
node_modules/.bin/node-gyp-build
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../node-gyp-build/bin.js
|
||||
1
node_modules/.bin/node-gyp-build-optional
generated
vendored
Symbolic link
1
node_modules/.bin/node-gyp-build-optional
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../node-gyp-build/optional.js
|
||||
1
node_modules/.bin/node-gyp-build-test
generated
vendored
Symbolic link
1
node_modules/.bin/node-gyp-build-test
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../node-gyp-build/build-test.js
|
||||
1
node_modules/.bin/node-which
generated
vendored
Symbolic link
1
node_modules/.bin/node-which
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../which/bin/which.js
|
||||
1
node_modules/.bin/nopt
generated
vendored
Symbolic link
1
node_modules/.bin/nopt
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../nopt/bin/nopt.js
|
||||
1
node_modules/.bin/nunjucks-precompile
generated
vendored
Symbolic link
1
node_modules/.bin/nunjucks-precompile
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../nunjucks/bin/precompile
|
||||
1
node_modules/.bin/semver
generated
vendored
Symbolic link
1
node_modules/.bin/semver
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../semver/bin/semver.js
|
||||
1
node_modules/.bin/svgo
generated
vendored
Symbolic link
1
node_modules/.bin/svgo
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../svgo/bin/svgo.js
|
||||
1
node_modules/.bin/untun
generated
vendored
Symbolic link
1
node_modules/.bin/untun
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../untun/bin/untun.mjs
|
||||
1
node_modules/.bin/xss
generated
vendored
Symbolic link
1
node_modules/.bin/xss
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../xss/bin/xss
|
||||
1
node_modules/.bin/yaml
generated
vendored
Symbolic link
1
node_modules/.bin/yaml
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../yaml/bin.mjs
|
||||
4766
node_modules/.package-lock.json
generated
vendored
Normal file
4766
node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
node_modules/@accessible-components/tag-input/CHANGELOG.md
generated
vendored
Normal file
24
node_modules/@accessible-components/tag-input/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [0.2.0](https://github.com/accessible-components/tag-input/compare/v0.1.1...v0.2.0) (2020-11-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add onInit public method ([478b4c6](https://github.com/accessible-components/tag-input/commit/478b4c6132cda5283182cbd003cf07438c761b50))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix bug with form submission ([687c93a](https://github.com/accessible-components/tag-input/commit/687c93a4cf676bbe54fed2bbeb8105eadc189af8))
|
||||
|
||||
### [0.1.1](https://github.com/accessible-components/tag-input/compare/v0.1.0...v0.1.1) (2020-11-23)
|
||||
|
||||
## 0.1.0 (2020-11-23)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add basic functionality ([17f7903](https://github.com/accessible-components/tag-input/commit/17f79035f11547d06ea94095c5726b256e2e583f))
|
||||
9
node_modules/@accessible-components/tag-input/LICENSE.md
generated
vendored
Normal file
9
node_modules/@accessible-components/tag-input/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# The MIT License
|
||||
|
||||
Copyright © 2020 Sergei Kriger, https://sergeikriger.com/
|
||||
|
||||
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.
|
||||
238
node_modules/@accessible-components/tag-input/README.md
generated
vendored
Normal file
238
node_modules/@accessible-components/tag-input/README.md
generated
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
# Tag Input
|
||||
|
||||
[](https://www.npmjs.com/package/@accessible-components/tag-input)
|
||||
[](https://github.com/accessible-components/tag-input/blob/master/LICENSE.md)
|
||||
[](https://www.w3.org/WAI/WCAG21/quickref/)
|
||||
|
||||
|
||||
Simple and accessible component for creating tags. Check out a [demo page](https://tag-input.netlify.app/).
|
||||
|
||||
## Features
|
||||
|
||||
* Tags can be added both manually and dynamically.
|
||||
* Fully accessible for keyboard and assistive technologies.
|
||||
* Cusomisable styles.
|
||||
|
||||

|
||||
|
||||
## Browser support
|
||||
|
||||
All modern browsers. _IE11_ is not supported.
|
||||
|
||||
### Tested in
|
||||
|
||||
| OS | Browser | Screen reader |
|
||||
| -- | ------- | ------------- |
|
||||
| macOS | Safari | VoiceOver |
|
||||
| iOS | Safari | VoiceOver |
|
||||
| Windows | Chrome | JAWS |
|
||||
| Windows | Firefox | NVDA |
|
||||
| Android | Chrome | Talkback |
|
||||
|
||||
## Installation
|
||||
|
||||
### `npm`
|
||||
|
||||
```
|
||||
npm install @accessible-components/tag-input
|
||||
```
|
||||
|
||||
Then import `build/tag-input.min.js` and `build/tag-input.min.css` from `node_modules`.
|
||||
|
||||
### Static sites
|
||||
|
||||
Copy `build/tag-input.min.js` and `build/tag-input.min.css` to your project and include them in your HTML:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="./path/to/file/tag-input.min.css" />
|
||||
...
|
||||
<script src="./path/to/file/tag-input.min.js"></script>
|
||||
```
|
||||
|
||||
### Locally
|
||||
|
||||
```
|
||||
git clone https://github.com/accessible-components/tag-input.git
|
||||
cd tag-input/
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
Open http://localhost:8080/ in your browser to open the demo page.
|
||||
|
||||
## Keyboard support
|
||||
|
||||
Once focused on the input field, following keyboard shortcuts are available:
|
||||
|
||||
| Shortcut | Input field | Tag selected | Action |
|
||||
| -------- | ----------- | ------------ | ------ |
|
||||
| `ArrowLeft`, `ArrowRight` | Empty | - | Navigate through tags if they exist. Selected tag is visually highlighted as well as anounced for screen reader users. |
|
||||
| `Delete` | Empty | No | Deletes the last tag. |
|
||||
| `Enter` | Empty | Yes | Makes selected tag editable. |
|
||||
| `ESC` | Empty | Yes | Resets edited tag (before it saved) to the prevous state. |
|
||||
| `Enter`, `Tab` | Filled | No | Creates a new tag. |
|
||||
|
||||
### Some thoughts to `Backspace` key
|
||||
|
||||
Although, many similar tag input components use `Backspace` key for deleting tags (if an input field is empty), after testing `TagInput` with blind users we decided not to support this shortcut because of following reasons:
|
||||
|
||||
* Many screen reader users once focused on the input field want to be sure that it's empty (often some sample text is already prefilled). For that instead of reading the content they simply delete it with `Backspace` key, so using this key for other actions may confuse screen reader users.
|
||||
|
||||
* Some of the blind testers used devices with so called _Perkins Style Braille Keyboard_ where `SwipeLeft` triggers `Backspace`, wich may cause unexpected behaviour.
|
||||
|
||||
For deleting tags use `Delete` key.
|
||||
|
||||
## Accessibility
|
||||
|
||||
`TagInput` is fully accessible for a keyboard, screen readers and other assistive technologies. It was tested by people who use these technologies on everyday basis.
|
||||
|
||||
## Usage
|
||||
|
||||
Create an empty element:
|
||||
|
||||
```html
|
||||
<div id="colors"></div>
|
||||
```
|
||||
|
||||
Create `TagInput` instance:
|
||||
|
||||
```js
|
||||
const colors = document.getElementById('colors');
|
||||
|
||||
const colorsTagInput = new TagInput(colors, {
|
||||
tags: ['red', 'green', 'blue'],
|
||||
label: 'Colors',
|
||||
placeholder: 'Add colors',
|
||||
// other options
|
||||
|
||||
onTagAdd: (tag, tags) => {
|
||||
// do something
|
||||
},
|
||||
onTagRemove: (tag, tags) => {
|
||||
// do something
|
||||
},
|
||||
onTagUpdate: (oldTag, newTag, tags) => {
|
||||
// do something
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Custom styles
|
||||
|
||||
You can easily adjust `TagInput` styles.
|
||||
|
||||

|
||||
|
||||
To change colors you can simply update following CSS custom variables:
|
||||
|
||||
```css
|
||||
.tag-input {
|
||||
/* input */
|
||||
--text: inherit;
|
||||
--bg: #fff;
|
||||
--bg-disabled: #f9f9f9;
|
||||
--border: rgba(121, 121, 121, 0.23);
|
||||
--border-hover: rgba(121, 121, 121, 0.4);
|
||||
--border-focus: rgba(45, 146, 255, 0.7);
|
||||
--border-focus-light: rgba(190, 221, 255, 0.5);
|
||||
|
||||
/* tag */
|
||||
--tag-text: #164172;
|
||||
--tag-bg: #e5f1ff;
|
||||
--tag-border: #e5f1ff;
|
||||
--tag-remove-button: transparent;
|
||||
--tag-remove-icon: #2e91fd;
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
> See all CSS properties in `tag-input.css`.
|
||||
|
||||
To update other styles (`paddings`, `margins` etc.), you may simply override css styles. `TagInput` has following HTML structure:
|
||||
|
||||
```html
|
||||
<div class="tag-input-container">
|
||||
<label class="tag-input-label">Colors</label>
|
||||
<div class="tag-input">
|
||||
<div class="tag-input__tag">
|
||||
<span class="tag-input__text">red</span> <!-- Shown -->
|
||||
<input class="tag-input__edit" /> <!-- Hidden -->
|
||||
<button class="tag-input__remove">
|
||||
<svg class="tag-input__remove-icon">...</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="tag-input__tag tag-input__tag--editable">
|
||||
<span class="tag-input__text">green</span> <!-- Hidden -->
|
||||
<input class="tag-input__edit" /> <!-- Shown -->
|
||||
<button class="tag-input__remove">
|
||||
<svg class="tag-input__remove-icon">...</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="tag-input__tag">
|
||||
<span class="tag-input__text">blue</span> <!-- Shown -->
|
||||
<input class="tag-input__edit" /> <!-- Hidden -->
|
||||
<button class="tag-input__remove">
|
||||
<svg class="tag-input__remove-icon">...</svg>
|
||||
</button>
|
||||
</div>
|
||||
<input class="tag-input__input" placeholder="Add colors" />
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
| ------ | ---- | ------- | ----------- |
|
||||
| **tags** | `String[]` | `[]` | Tags provided on initialization. |
|
||||
| **prefix** | `Type` | `tag-input` | Unique prefix for class names and IDs inside the component. |
|
||||
| **disabled** | `Boolean` | `false` | `disabled` attribute for the input element. Also makes tags not editable. |
|
||||
| **name** | `String` | `tag-input` | `name` atribute for the input field to be accessed on form submit. |
|
||||
| **placeholder** | `String` | `Add tags` | `placeholder` attribute for the input element. |
|
||||
| **label** | `String` | `Tags` | Label text. |
|
||||
| **hiddenLabel** | `Boolean` | `false` | Hides the label visually, but keeps it accessible for screen readers. |
|
||||
| **onInit** | `Function` | `undefined` | Runs after tag input init. Parameters: `tags` (list of tags). |
|
||||
| **onTagAdd** | `Function` | `undefined` | Runs after a new tag was added. Parameters: `tag` (added tag), `tags` (list of tags after adding). |
|
||||
| **onTagUpdate** | `Function` | `undefined` | Runs after a tag was updated. Parameters: `oldTag` (a tag before update), `newTag` (a tag after update), `tags` (list of tags after updating). |
|
||||
| **onTagRemove** | `Function` | `undefined` | Runs after a tag was removed. Parameters: `tag` (removed tag), `tags` (list of tags after removing). |
|
||||
| **ariaTag** | `String` | `Tag {{TAG}}.` | Adds `aria-label` to the tag element. |
|
||||
| **ariaEditTag** | `String` | `Edit tag.` | Adds label text to the editable tag. |
|
||||
| **ariaDeleteTag** | `String` | `Delete tag {{TAG}}.` | Adds `aria-label` to the tag delete button. |
|
||||
| **ariaTagAdded** | `String` | `Tag {{TAG}} added.` | Will be pronounced to screen reader users after a new tag was created. |
|
||||
| **ariaTagUpdated** | `String` | `Tag updated to {{TAG}}.` | Will be pronounced to screen reader users after a tag was updated. |
|
||||
| **ariaTagDeleted** | `String` | `Tag {{TAG}} deleted.` | Will be pronounced to screen reader users after a tag was deleted. |
|
||||
| **ariaTagSelected** | `String` | `Tag {{TAG}} selected. Press enter to edit, delete to delete.` | Will be pronounced to screen reader users after a tag was selected (by bavigating with arrow keys). |
|
||||
| **ariaNoTagsSelected** | `String` | `No tags selected.` | Will be pronounced to screen reader users after a selected tag was unselected (by clicking on ESC key, for example). |
|
||||
| **ariaInputLabel** | `String` | `{{TAGS}} tags. Use left and right arrow keys to navigate, enter or tab to create, delete to delete tags.` | Will be pronounced to screen reader users once the input element is focused. |
|
||||
|
||||
> Options with prefix `aria` add ARIA attributes to some elements with instructions and other valueable info for screen reader users. ARIA text is not visible.
|
||||
|
||||
> Please keep placeholder text such as `{{TAG}}` or `{{TAGS}}` as it is. It will be replaced with proper text.
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Argument | Return | Description |
|
||||
| ------ | ----------- | -------- | ------ |
|
||||
| **addTag** | `String` | `undefined` | Adds a new tag. No duplicates allowed. |
|
||||
| **removeTag** | `String` | `undefined` | Removes a tag if it exists. |
|
||||
| **getTags** | - | `String[]` | Gets the tag array. |
|
||||
|
||||
## Contributing
|
||||
|
||||
Everyone is welcome to contribute.
|
||||
|
||||
* If you found a bug or have an idea how to improve the component, please submit an [issue](https://github.com/accessible-components/tag-input/issues).
|
||||
* You may test our component on different devices and give us your feedback.
|
||||
|
||||
## Ideas for the next features
|
||||
|
||||
* Min/max tags specified vis options.
|
||||
* Custom tag validation before `addTag`
|
||||
* Tag autocomplete
|
||||
* Custome _remove tag_ icon provided via options.
|
||||
* Translate ARIA and other text and provide downloadable JSON files with translations.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE.md)
|
||||
283
node_modules/@accessible-components/tag-input/build/tag-input.css
generated
vendored
Normal file
283
node_modules/@accessible-components/tag-input/build/tag-input.css
generated
vendored
Normal file
@@ -0,0 +1,283 @@
|
||||
|
||||
/**
|
||||
* @accessible-components/tag-input - Simple and accessible component for creating tags.
|
||||
* @version v0.2.0
|
||||
* @link https://github.com/accessible-components/tag-input
|
||||
* @copyright 2020 Sergei Kriger, https://sergeikriger.com/
|
||||
* @license MIT
|
||||
*/
|
||||
.tag-input-container {
|
||||
--container-text: #152538;
|
||||
|
||||
margin: 0;
|
||||
color: var(--container-text);
|
||||
}
|
||||
|
||||
/* Label */
|
||||
.tag-input-label {
|
||||
margin-bottom: 12px;
|
||||
display: block;
|
||||
color: inherit;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Tag input */
|
||||
.tag-input * {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.tag-input {
|
||||
/* input */
|
||||
--text: inherit;
|
||||
--bg: #fff;
|
||||
--bg-disabled: #f9f9f9;
|
||||
--bd: rgba(121, 121, 121, 0.23);
|
||||
--bd-hover: rgba(121, 121, 121, 0.4);
|
||||
--bd-focus: rgba(45, 146, 255, 0.7);
|
||||
--bd-focus-light: rgba(190, 221, 255, 0.5);
|
||||
|
||||
/* tag */
|
||||
--tag-text: #164172;
|
||||
--tag-bg: #e5f1ff;
|
||||
--tag-bd: #e5f1ff;
|
||||
--tag-remove-button: transparent;
|
||||
--tag-remove-icon: #2e91fd;
|
||||
|
||||
/* tag: hover */
|
||||
--tag-hover-text: #164172;
|
||||
--tag-hover-bg: #d1e6ff;
|
||||
--tag-hover-bd: #d1e6ff;
|
||||
--tag-hover-remove-button: transparent;
|
||||
--tag-hover-remove-icon: #2e91fd;
|
||||
--tag-hover-remove-button-hover: #b3d6ff;
|
||||
--tag-hover-remove-icon-hover: #2e91fd;
|
||||
|
||||
/* tag: selected */
|
||||
--tag-selected-text: #fff;
|
||||
--tag-selected-bg: #2e91fd;
|
||||
--tag-selected-bd: #2e91fd;
|
||||
--tag-selected-remove-button: transparent;
|
||||
--tag-selected-remove-icon: #fff;
|
||||
|
||||
/* tag: selected, hover */
|
||||
--tag-selected-hover-text: #fff;
|
||||
--tag-selected-hover-bg: #2e91fd;
|
||||
--tag-selected-hover-bd: #2e91fd;
|
||||
--tag-selected-hover-remove-button: transparent;
|
||||
--tag-selected-hover-remove-icon: #fff;
|
||||
--tag-selected-hover-remove-button-hover: #fff;
|
||||
--tag-selected-hover-remove-icon-hover: #2e91fd;
|
||||
|
||||
/* tag: disabled */
|
||||
--tag-disabled-text: #164172;
|
||||
--tag-disabled-bg: #e4e4e4;
|
||||
--tag-disabled-bd: #e4e4e4;
|
||||
|
||||
/* tag: editable */
|
||||
--tag-editable-text: #164172;
|
||||
--tag-editable-bg: #fff;
|
||||
--tag-editable-bd: #76aefa;
|
||||
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-content: flex-start;
|
||||
padding: 4px;
|
||||
background-color: var(--bg);
|
||||
font-size: 16px;
|
||||
font-family: sans-serif;
|
||||
line-height: 1.4;
|
||||
color: var(--text);
|
||||
border-radius: 4px;
|
||||
box-shadow: 0px 0px 0px 2px var(--bd);
|
||||
cursor: default;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.tag-input:hover {
|
||||
box-shadow: 0px 0px 0px 2px var(--bd-hover);
|
||||
}
|
||||
|
||||
.tag-input:focus-within {
|
||||
box-shadow: 0px 0px 0px 2px var(--bd-focus), 0px 0px 0px 4px var(--bd-focus-light);
|
||||
}
|
||||
|
||||
.tag-input--disabled,
|
||||
.tag-input--disabled:hover,
|
||||
.tag-input--disabled:focus-within {
|
||||
background-color: var(--bg-disabled);
|
||||
box-shadow: 0px 0px 0px 2px var(--bd);
|
||||
}
|
||||
|
||||
/* Tag */
|
||||
.tag-input__tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
margin: 6px;
|
||||
border-radius: 6px;
|
||||
border: 2px solid var(--tag-bd);
|
||||
background-color: var(--tag-bg);
|
||||
color: var(--tag-text);
|
||||
}
|
||||
|
||||
.tag-input__tag:hover {
|
||||
border: 2px solid var(--tag-hover-bd);
|
||||
background-color: var(--tag-hover-bg);
|
||||
color: var(--tag-hover-text);
|
||||
}
|
||||
|
||||
.tag-input--disabled .tag-input__tag {
|
||||
border: 2px solid var(--tag-disabled-bd);
|
||||
background-color: var(--tag-disabled-bg);
|
||||
color: var(--tag-disabled-text);
|
||||
}
|
||||
|
||||
.tag-input--disabled .tag-input__tag:hover {
|
||||
border: 2px solid var(--tag-disabled-bd);
|
||||
background-color: var(--tag-disabled-bg);
|
||||
}
|
||||
|
||||
.tag-input__tag--selected {
|
||||
border: 2px solid var(--tag-selected-bd);
|
||||
background-color: var(--tag-selected-bg);
|
||||
color: var(--tag-selected-text);
|
||||
}
|
||||
|
||||
.tag-input__tag--selected:hover {
|
||||
border: 2px solid var(--tag-selected-hover-bd);
|
||||
background-color: var(--tag-selected-hover-bg);
|
||||
color: var(--tag-selected-hover-text);
|
||||
}
|
||||
|
||||
.tag-input__tag--editable,
|
||||
.tag-input__tag--editable:hover {
|
||||
background-color: var(--tag-editable-bg);
|
||||
border: 2px solid var(--tag-editable-bd);
|
||||
}
|
||||
|
||||
/* Tag text */
|
||||
.tag-input__tag--editable .tag-input__text {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
z-index: -1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Tag edit */
|
||||
.tag-input__edit {
|
||||
font-size: inherit;
|
||||
padding: 0;
|
||||
border: none;
|
||||
font-family: inherit;
|
||||
background-color: var(--tag-editable-bg);
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.tag-input__edit:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.tag-input__tag--editable .tag-input__edit {
|
||||
position: static;
|
||||
opacity: 1;
|
||||
z-index: initial;
|
||||
color: var(--tag-editable-text);
|
||||
}
|
||||
|
||||
/* Remove button */
|
||||
.tag-input__remove-button {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border: none;
|
||||
padding: 4px;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
background-color: var(--tag-remove-button);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-left: 8px;
|
||||
margin-right: -4px;
|
||||
}
|
||||
|
||||
.tag-input__tag:hover .tag-input__remove-button {
|
||||
background-color: var(--tag-hover-remove-button);
|
||||
}
|
||||
|
||||
.tag-input__tag:hover .tag-input__remove-button:hover,
|
||||
.tag-input__tag:hover .tag-input__remove-button:focus {
|
||||
outline: none;
|
||||
background-color: var(--tag-hover-remove-button-hover);
|
||||
}
|
||||
|
||||
.tag-input__tag--selected .tag-input__remove-button {
|
||||
background-color: var(--tag-selected-remove-button);
|
||||
}
|
||||
|
||||
.tag-input__tag--selected:hover .tag-input__remove-button {
|
||||
background-color: var(--tag-selected-hover-remove-button);
|
||||
}
|
||||
|
||||
.tag-input__tag--selected:hover .tag-input__remove-button:hover {
|
||||
background-color: var(--tag-selected-hover-remove-button-hover);
|
||||
}
|
||||
|
||||
.tag-input__tag--editable .tag-input__remove-button {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/* Remove button icon */
|
||||
.tag-input__remove-icon {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.tag-input__remove-icon line {
|
||||
stroke: var(--tag-remove-icon);
|
||||
}
|
||||
|
||||
.tag-input__tag:hover .tag-input__remove-icon line {
|
||||
stroke: var(--tag-hover-remove-icon);
|
||||
}
|
||||
|
||||
.tag-input__tag:hover .tag-input__remove-button:hover .tag-input__remove-icon line,
|
||||
.tag-input__tag:hover .tag-input__remove-button:focus .tag-input__remove-icon line {
|
||||
stroke: var(--tag-hover-remove-icon-hover);
|
||||
}
|
||||
|
||||
.tag-input__tag--selected .tag-input__remove-icon line {
|
||||
stroke: var(--tag-selected-remove-icon);
|
||||
}
|
||||
|
||||
.tag-input__tag--selected:hover .tag-input__remove-icon line {
|
||||
stroke: var(--tag-selected-hover-remove-icon);
|
||||
}
|
||||
|
||||
.tag-input__tag--selected:hover .tag-input__remove-button:hover .tag-input__remove-icon line,
|
||||
.tag-input__tag--selected:hover .tag-input__remove-button:focus .tag-input__remove-icon line {
|
||||
stroke: var(--tag-selected-hover-remove-icon-hover);
|
||||
}
|
||||
|
||||
/* Input */
|
||||
.tag-input__input {
|
||||
font-size: inherit;
|
||||
line-height: 1.4;
|
||||
padding: var(--tag-padding);
|
||||
padding: 6px 8px 6px 0;
|
||||
margin: 6px;
|
||||
flex: 1;
|
||||
color: var(--text);
|
||||
background-color: var(--bg);
|
||||
border: 2px solid transparent;
|
||||
}
|
||||
|
||||
.tag-input__input:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.tag-input__input:disabled {
|
||||
background-color: inherit;
|
||||
}
|
||||
675
node_modules/@accessible-components/tag-input/build/tag-input.js
generated
vendored
Normal file
675
node_modules/@accessible-components/tag-input/build/tag-input.js
generated
vendored
Normal file
@@ -0,0 +1,675 @@
|
||||
|
||||
/**
|
||||
* @accessible-components/tag-input - Simple and accessible component for creating tags.
|
||||
* @version v0.2.0
|
||||
* @link https://github.com/accessible-components/tag-input
|
||||
* @copyright 2020 Sergei Kriger, https://sergeikriger.com/
|
||||
* @license MIT
|
||||
*/
|
||||
function _typeof(obj) {"@babel/helpers - typeof";if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {_typeof = function _typeof(obj) {return typeof obj;};} else {_typeof = function _typeof(obj) {return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;};}return _typeof(obj);}(function (global) {
|
||||
var iconTmpl = "\n <svg viewBox=\"0 0 100 100\">\n <line x1=\"10\" y1=\"10\" x2=\"90\" y2=\"90\" stroke-width=\"20\" stroke-linecap=\"round\" />\n <line x1=\"10\" y1=\"90\" x2=\"90\" y2=\"10\" stroke-width=\"20\" stroke-linecap=\"round\" />\n </svg>\n ";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var key = {
|
||||
ENTER: 13,
|
||||
ESC: 27,
|
||||
ARROW_LEFT: 37,
|
||||
ARROW_RIGHT: 39,
|
||||
TAB: 9,
|
||||
DELETE: 46 };
|
||||
|
||||
|
||||
/**
|
||||
* TagInput constructor.
|
||||
*
|
||||
* @constructor
|
||||
* @param {HTMLElement} el Container element.
|
||||
* @param {object} options Options.
|
||||
*/
|
||||
function TagInput(el, options) {
|
||||
if (!el) {
|
||||
throw new Error('Element not found.');
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
|
||||
this.settings = {
|
||||
tags: [],
|
||||
prefix: 'tag-input',
|
||||
disabled: false,
|
||||
name: 'tag-input',
|
||||
placeholder: 'Add tags',
|
||||
label: 'Tags',
|
||||
ariaTag: 'Tag {{TAG}}.',
|
||||
ariaEditTag: 'Edit tag.',
|
||||
ariaDeleteTag: 'Delete tag {{TAG}}.',
|
||||
ariaTagAdded: 'Tag {{TAG}} added.',
|
||||
ariaTagUpdated: 'Tag updated to {{TAG}}.',
|
||||
ariaTagDeleted: 'Tag {{TAG}} deleted.',
|
||||
ariaTagSelected: 'Tag {{TAG}} selected. Press enter to edit, delete to delete.',
|
||||
ariaNoTagsSelected: 'No tags selected.',
|
||||
ariaInputLabel:
|
||||
'{{TAGS}} tags. Use left and right arrow keys to navigate, enter or tab to create, delete to delete tags.' };
|
||||
|
||||
|
||||
for (var setting in options) {
|
||||
if (options.hasOwnProperty(setting)) {
|
||||
this.settings[setting] = options[setting];
|
||||
}
|
||||
}
|
||||
|
||||
this.tags = [];
|
||||
this.id = rand();
|
||||
this.value = '';
|
||||
|
||||
init.call(this, el);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new tag. Skips 'onTagAdd' callback when running on init.
|
||||
*
|
||||
* @param {string} str New tag to be added.
|
||||
* @param {boolean} init Adding tags on init from settings (see init).
|
||||
* @returns {undefined}
|
||||
*/
|
||||
TagInput.prototype.addTag = function (str, init) {var _this = this;var
|
||||
settings = this.settings;
|
||||
var tag = typeof str === 'string' ? sanitize(str) : null;
|
||||
|
||||
if (!tag || this.tags.indexOf(tag) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// *** Tag ***
|
||||
var tagEl = document.createElement('div');
|
||||
|
||||
tagEl.classList.add("".concat(settings.prefix, "__tag"));
|
||||
tagEl.setAttribute('aria-label', settings.ariaTag.replace('{{TAG}}', tag));
|
||||
tagEl.dataset.tagValue = tag;
|
||||
|
||||
// *** Tag text ***
|
||||
var textEl = document.createElement('span');
|
||||
|
||||
textEl.classList.add("".concat(settings.prefix, "__text"));
|
||||
textEl.textContent = tag;
|
||||
textEl.setAttribute('aria-hidden', true);
|
||||
tagEl.appendChild(textEl);
|
||||
|
||||
if (!settings.disabled) {
|
||||
textEl.addEventListener('dblclick', function (e) {
|
||||
makeTagEditable.call(_this, e.target.parentNode.dataset.tagValue);
|
||||
});
|
||||
}
|
||||
|
||||
// *** Tag label ***
|
||||
var tagEditLabelEl = document.createElement('label');
|
||||
var tagId = "tag-id-".concat(rand());
|
||||
|
||||
tagEditLabelEl.htmlFor = tagId;
|
||||
tagEditLabelEl.textContent = settings.ariaEditTag;
|
||||
tagEditLabelEl.classList.add("".concat(settings.prefix, "__edit-label"));
|
||||
tagEditLabelEl.setAttribute('aria-hidden', true);
|
||||
visuallyHide(tagEditLabelEl);
|
||||
tagEl.appendChild(tagEditLabelEl);
|
||||
|
||||
// *** Tag edit ***
|
||||
var tagEditEl = document.createElement('input');
|
||||
var handleTagEditKeyup = onTagEditKeyup.bind(this);
|
||||
var handleTagEditKeydown = onTagEditKeydown.bind(this);
|
||||
var handleTagEditInput = onTagEditInput.bind(this);
|
||||
|
||||
tagEditEl.classList.add("".concat(settings.prefix, "__edit"));
|
||||
tagEditEl.setAttribute('tabindex', -1);
|
||||
tagEditEl.setAttribute('type', 'text');
|
||||
tagEditEl.setAttribute('aria-hidden', true);
|
||||
tagEditEl.value = tag;
|
||||
tagEditEl.id = tagId;
|
||||
tagEl.appendChild(tagEditEl);
|
||||
|
||||
tagEditEl.addEventListener('focus', function () {
|
||||
document.addEventListener('keyup', handleTagEditKeyup);
|
||||
document.addEventListener('keydown', handleTagEditKeydown);
|
||||
document.addEventListener('input', handleTagEditInput);
|
||||
});
|
||||
|
||||
tagEditEl.addEventListener('blur', function (e) {
|
||||
document.removeEventListener('keyup', handleTagEditKeyup);
|
||||
document.removeEventListener('keydown', handleTagEditKeydown);
|
||||
document.removeEventListener('input', handleTagEditInput);
|
||||
|
||||
// All clean up is done here to handle the case
|
||||
// when user clicks outside of tag-input.
|
||||
tagEl.classList.remove("".concat(settings.prefix, "__tag--editable"));
|
||||
tagEditEl.setAttribute('aria-hidden', true);
|
||||
tagEditLabelEl.setAttribute('aria-hidden', true);
|
||||
|
||||
if (e.target.value !== tagEl.dataset.tagValue) {
|
||||
textEl.textContent = tagEl.dataset.tagValue;
|
||||
tagEditEl.value = tagEl.dataset.tagValue;
|
||||
}
|
||||
|
||||
resetSelected.call(_this);
|
||||
});
|
||||
|
||||
// *** Remove button ***
|
||||
var inputEl = this.inputEl;
|
||||
|
||||
if (!settings.disabled) {
|
||||
var removeBtn = document.createElement('button');
|
||||
var removeTag = this.removeTag.bind(this);
|
||||
var talk = say.bind(this);
|
||||
|
||||
removeBtn.classList.add("".concat(settings.prefix, "__remove-button"));
|
||||
removeBtn.setAttribute('tabindex', -1);
|
||||
removeBtn.setAttribute('type', 'button');
|
||||
removeBtn.setAttribute('aria-label', settings.ariaDeleteTag.replace('{{TAG}}', tag));
|
||||
removeBtn.innerHTML = iconTmpl;
|
||||
tagEl.appendChild(removeBtn);
|
||||
|
||||
removeBtn.addEventListener('click', function () {
|
||||
var tag = this.parentNode.dataset.tagValue;
|
||||
|
||||
removeTag(tag);
|
||||
talk(settings.ariaTagDeleted.replace('{{TAG}}', tag));
|
||||
inputEl.focus();
|
||||
});
|
||||
|
||||
// *** Close icon ***
|
||||
var iconEl = removeBtn.querySelector('svg');
|
||||
iconEl.classList.add("".concat(settings.prefix, "__remove-icon"));
|
||||
}
|
||||
|
||||
// Add tag
|
||||
this.tagInput.insertBefore(tagEl, inputEl);
|
||||
this.tags.push(tag);
|
||||
setInputValue.call(this);
|
||||
updateInputLabel.call(this);
|
||||
|
||||
// Run callback
|
||||
if (!init && settings.onTagAdd) {
|
||||
settings.onTagAdd(tag, this.tags);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a tag.
|
||||
*
|
||||
* @param {string} tag Tag.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
TagInput.prototype.removeTag = function (tag) {
|
||||
var tagEl = getTagEl.call(this, tag);
|
||||
|
||||
if (tagEl) {
|
||||
tagEl.remove();
|
||||
this.tags = this.tags.filter(function (t) {return t !== tag;});
|
||||
setInputValue.call(this);
|
||||
updateInputLabel.call(this);
|
||||
|
||||
if (this.settings.onTagRemove) {
|
||||
this.settings.onTagRemove(tag, this.tags);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an array of tags.
|
||||
*
|
||||
* @returns {array}
|
||||
*/
|
||||
TagInput.prototype.getTags = function () {
|
||||
return this.tags;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates HTML elements. Adds event listeners.
|
||||
*
|
||||
* @param {HTMLElement} el Container element.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function init(el) {var _this2 = this;
|
||||
// *** Container ***
|
||||
el.classList.add("".concat(this.settings.prefix, "-container"));
|
||||
|
||||
// *** Label ***
|
||||
var labelEl = document.createElement('label');
|
||||
|
||||
labelEl.classList.add("".concat(this.settings.prefix, "-label"));
|
||||
labelEl.htmlFor = "".concat(this.settings.prefix, "-").concat(this.id);
|
||||
labelEl.textContent = this.settings.label;
|
||||
|
||||
if (this.settings.hiddenLabel) {
|
||||
visuallyHide(labelEl);
|
||||
}
|
||||
|
||||
el.appendChild(labelEl);
|
||||
|
||||
// *** Hidden label ***
|
||||
// Holds some instructions for screen reader users.
|
||||
var labelHiddenEl = document.createElement('span');
|
||||
|
||||
visuallyHide(labelHiddenEl);
|
||||
labelEl.appendChild(labelHiddenEl);
|
||||
|
||||
// *** Tag input ***
|
||||
var tagInputEl = document.createElement('div');
|
||||
|
||||
tagInputEl.classList.add(this.settings.prefix);
|
||||
this.tagInput = tagInputEl;
|
||||
|
||||
if (this.settings.disabled) {
|
||||
tagInputEl.classList.add("".concat(this.settings.prefix, "--disabled"));
|
||||
}
|
||||
|
||||
el.appendChild(tagInputEl);
|
||||
|
||||
// *** Input ***
|
||||
var inputEl = document.createElement('input');
|
||||
var inputKeyupHandler = onInputKeyup.bind(this);
|
||||
var inputKeydownHandler = onInputKeydown.bind(this);
|
||||
|
||||
inputEl.setAttribute('type', 'text');
|
||||
inputEl.setAttribute('placeholder', this.settings.placeholder);
|
||||
inputEl.classList.add("".concat(this.settings.prefix, "__input"));
|
||||
inputEl.id = "".concat(this.settings.prefix, "-").concat(this.id);
|
||||
this.inputEl = inputEl;
|
||||
this.value = this.inputEl.value;
|
||||
|
||||
if (this.settings.disabled) {
|
||||
inputEl.setAttribute('disabled', true);
|
||||
}
|
||||
|
||||
inputEl.addEventListener('focus', function () {
|
||||
document.addEventListener('keyup', inputKeyupHandler);
|
||||
document.addEventListener('keydown', inputKeydownHandler);
|
||||
});
|
||||
|
||||
inputEl.addEventListener('blur', function () {
|
||||
document.removeEventListener('keyup', inputKeyupHandler);
|
||||
document.removeEventListener('keydown', inputKeydownHandler);
|
||||
|
||||
resetSelected.call(_this2);
|
||||
});
|
||||
|
||||
this.tagInput.appendChild(inputEl);
|
||||
|
||||
// *** Hidden input (holds tags value) ***
|
||||
var _inputEl = document.createElement('input');
|
||||
|
||||
_inputEl.setAttribute('type', 'hidden');
|
||||
_inputEl.setAttribute('name', this.settings.name);
|
||||
this._inputEl = _inputEl;
|
||||
this.tagInput.appendChild(_inputEl);
|
||||
|
||||
// *** Live region ***
|
||||
var liveRegionEl = document.createElement('span');
|
||||
|
||||
visuallyHide(liveRegionEl);
|
||||
liveRegionEl.id = "".concat(this.settings.prefix, "-live-region-").concat(rand());
|
||||
el.appendChild(liveRegionEl);
|
||||
|
||||
// *** Tags ***
|
||||
this.settings.tags.forEach(function (tag) {
|
||||
_this2.addTag(tag, true);
|
||||
});
|
||||
|
||||
if (this.settings.onInit) {
|
||||
this.settings.onInit(this.tags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles keydowns from on the input element.
|
||||
* All "safe" actions handeled here, because it's faster than keyup.
|
||||
*
|
||||
* @param {event} e Keydown event.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function onInputKeydown(e) {
|
||||
switch (e.keyCode) {
|
||||
case key.TAB:
|
||||
case key.ENTER:
|
||||
if (e.target.value || this._selected) {
|
||||
e.preventDefault();
|
||||
}
|
||||
break;
|
||||
|
||||
case key.ARROW_LEFT:
|
||||
if (this.tags.length && !e.target.value) {
|
||||
var i = this.tags.indexOf(this._selected);
|
||||
var last = this.tags[this.tags.length - 1];
|
||||
var previous = this.tags[i - 1];
|
||||
|
||||
if (previous) {
|
||||
setSelected.call(this, previous);
|
||||
say.call(this, this.settings.ariaTagSelected.replace('{{TAG}}', previous));
|
||||
} else if (i !== 0) {
|
||||
setSelected.call(this, last);
|
||||
say.call(this, this.settings.ariaTagSelected.replace('{{TAG}}', last));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case key.ARROW_RIGHT:
|
||||
if (this.tags.length && !e.target.value) {
|
||||
var _i = this.tags.indexOf(this._selected);
|
||||
var next = this.tags[_i + 1];
|
||||
|
||||
if (next && _i >= 0) {
|
||||
setSelected.call(this, next);
|
||||
say.call(this, this.settings.ariaTagSelected.replace('{{TAG}}', next));
|
||||
} else if (_i === this.tags.length - 1) {
|
||||
resetSelected.call(this);
|
||||
say.call(this, this.settings.ariaNoTagsSelected);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case key.ESC:
|
||||
if (this._selected) {
|
||||
resetSelected.call(this);
|
||||
say.call(this, this.settings.ariaNoTagsSelected);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles keyups on the input element.
|
||||
*
|
||||
* In comparison to keydown, keyup is more accessible, since it gives users
|
||||
* a possibility to move cursor away from the element clicked by mistake.
|
||||
*
|
||||
* @param {event} e Keyup event.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function onInputKeyup(e) {
|
||||
if (e.target.value) {
|
||||
resetSelected.call(this);
|
||||
}
|
||||
|
||||
switch (e.keyCode) {
|
||||
case key.ENTER:
|
||||
if (e.target.value) {
|
||||
this.addTag(e.target.value);
|
||||
say.call(this, this.settings.ariaTagAdded.replace('{{TAG}}', e.target.value));
|
||||
this.inputEl.value = '';
|
||||
} else if (this._selected) {
|
||||
makeTagEditable.call(this, this._selected);
|
||||
}
|
||||
break;
|
||||
|
||||
case key.TAB:
|
||||
if (e.target.value) {
|
||||
this.addTag(e.target.value);
|
||||
say.call(this, this.settings.ariaTagAdded.replace('{{TAG}}', e.target.value));
|
||||
this.inputEl.value = '';
|
||||
}
|
||||
break;
|
||||
|
||||
case key.DELETE:
|
||||
if (!this.value) {
|
||||
if (this._selected) {
|
||||
this.removeTag(this._selected);
|
||||
say.call(this, this.settings.ariaTagDeleted.replace('{{TAG}}', this._selected));
|
||||
resetSelected.call(this);
|
||||
} else if (this.tags.length) {
|
||||
var last = this.tags[this.tags.length - 1];
|
||||
|
||||
this.removeTag(last);
|
||||
say.call(this, this.settings.ariaTagDeleted.replace('{{TAG}}', last));
|
||||
resetSelected.call(this);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;}
|
||||
|
||||
|
||||
this.value = this.inputEl.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles keyups for an input element in the tag.
|
||||
*
|
||||
* @param {event} e Keydown event.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function onTagEditKeydown(e) {
|
||||
switch (e.keyCode) {
|
||||
// Prevents form submit
|
||||
case key.ENTER:
|
||||
e.preventDefault();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles keyups for an input element in the tag.
|
||||
*
|
||||
* @param {event} e Keyup event.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function onTagEditKeyup(e) {
|
||||
var tagEl = e.target.parentNode;
|
||||
var tag = tagEl.dataset.tagValue;
|
||||
|
||||
switch (e.keyCode) {
|
||||
case key.ESC:
|
||||
this.inputEl.focus();
|
||||
break;
|
||||
|
||||
case key.ENTER:
|
||||
var value = sanitize(e.target.value);
|
||||
|
||||
if (!value) {
|
||||
this.removeTag(tagEl.dataset.tagValue);
|
||||
this.inputEl.focus();
|
||||
say.call(this, this.settings.ariaTagDeleted.replace('{{TAG}}', tagEl.dataset.tagValue));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.tags = this.tags.map(function (t) {
|
||||
return t === tag ? value : t;
|
||||
});
|
||||
|
||||
setInputValue.call(this);
|
||||
say.call(this, this.settings.ariaTagUpdated.replace('{{TAG}}', value));
|
||||
tagEl.dataset.tagValue = value;
|
||||
this.inputEl.focus();
|
||||
|
||||
if (this.settings.onTagUpdate) {
|
||||
this.settings.onTagUpdate(tag, value, this.tags);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects a text into a hidden non-editable tag, takes a width from it
|
||||
* and sets this width to the editable input element.
|
||||
*
|
||||
* @param {event} e Input event.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function onTagEditInput(e) {
|
||||
var tagEl = e.target.parentNode;
|
||||
var textEl = tagEl.querySelector(".".concat(this.settings.prefix, "__text"));
|
||||
var editEl = tagEl.querySelector(".".concat(this.settings.prefix, "__edit"));
|
||||
|
||||
textEl.textContent = e.target.value;
|
||||
editEl.style.width = "".concat(textEl.getBoundingClientRect().width, "px");
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides an element visually, but keeps it accessible for screen readers.
|
||||
*
|
||||
* @param {HTMLElement} el Element.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function visuallyHide(el) {
|
||||
el.style.clip = '1px, 1px, 1px, 1px';
|
||||
el.style.height = '1px';
|
||||
el.style.width = '1px';
|
||||
el.style.overflow = 'hidden';
|
||||
el.style.position = 'absolute';
|
||||
el.style.whiteSpace = 'nowrap';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares tags passed from the input field.
|
||||
*
|
||||
* @param {string} tag Tag.
|
||||
* @returns {string}
|
||||
*/
|
||||
function sanitize(tag) {
|
||||
return tag.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value from tags to the hidden input field.
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function setInputValue() {
|
||||
this._inputEl.value = JSON.stringify(this.tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces screen reader to pronounce the phrase.
|
||||
* This is a simplified version of https://github.com/Heydon/on-demand-live-region
|
||||
*
|
||||
* @param {string} phrase Phrase to be said by screen readers.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function say(phrase) {
|
||||
var container = this.tagInput.parentNode;
|
||||
var oldRegion = container.querySelector("[id^=\"".concat(this.settings.prefix, "-live-region-\"]"));
|
||||
|
||||
if (oldRegion) {
|
||||
container.removeChild(oldRegion);
|
||||
}
|
||||
|
||||
var newRegion = document.createElement('span');
|
||||
|
||||
newRegion.id = "".concat(this.settings.prefix, "-live-region-").concat(rand());
|
||||
newRegion.setAttribute('aria-live', 'assertive');
|
||||
newRegion.setAttribute('role', 'alert');
|
||||
visuallyHide(newRegion);
|
||||
container.appendChild(newRegion);
|
||||
newRegion.textContent = phrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates hidden text for screen readers with meta information.
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function updateInputLabel() {
|
||||
var containerEl = this.tagInput.parentNode;
|
||||
var hiddenLabelEl = containerEl.querySelector(".".concat(this.settings.prefix, "-label span"));
|
||||
|
||||
hiddenLabelEl.textContent = ", ".concat(this.settings.ariaInputLabel.replace(
|
||||
'{{TAGS}}',
|
||||
this.tags.length));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a tag editable. Width for input is taken from non-editable span (see onTagEditInput).
|
||||
*
|
||||
* @param {string} tag Tag.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function makeTagEditable(tag) {
|
||||
var tagEl = getTagEl.call(this, tag);
|
||||
var textEl = tagEl.querySelector(".".concat(this.settings.prefix, "__text"));
|
||||
var editEl = tagEl.querySelector(".".concat(this.settings.prefix, "__edit"));
|
||||
var editLabelEl = tagEl.querySelector(".".concat(this.settings.prefix, "__edit-label"));
|
||||
|
||||
tagEl.classList.add("".concat(this.settings.prefix, "__tag--editable"));
|
||||
editEl.style.width = "".concat(textEl.getBoundingClientRect().width, "px");
|
||||
editEl.removeAttribute('aria-hidden');
|
||||
editLabelEl.removeAttribute('aria-hidden');
|
||||
|
||||
editEl.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a tag element found by passed tag string.
|
||||
*
|
||||
* @param {string} tag Tag.
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
function getTagEl(tag) {
|
||||
return this.tagInput.querySelector("[data-tag-value=\"".concat(tag, "\"]"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets selected tag.
|
||||
*
|
||||
* @param {string} tag Tag.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function setSelected(tag) {
|
||||
if (this._selected !== tag) {
|
||||
resetSelected.call(this);
|
||||
}
|
||||
|
||||
var tagEl = getTagEl.call(this, tag);
|
||||
|
||||
if (tagEl) {
|
||||
tagEl.classList.add("".concat(this.settings.prefix, "__tag--selected"));
|
||||
this._selected = tag;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets selected tag.
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function resetSelected() {
|
||||
var selectedEl = this.tagInput.querySelector(".".concat(this.settings.prefix, "__tag--selected"));
|
||||
|
||||
if (selectedEl) {
|
||||
selectedEl.classList.remove("".concat(this.settings.prefix, "__tag--selected"));
|
||||
}
|
||||
|
||||
this._selected = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple random number generator.
|
||||
*
|
||||
* @returns {number}
|
||||
*/
|
||||
function rand() {
|
||||
return Math.floor(Math.random() * 10000);
|
||||
}
|
||||
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
module.exports = TagInput;
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
define('TagInput', [], function () {
|
||||
return TagInput;
|
||||
});
|
||||
} else if (_typeof(global) === 'object') {
|
||||
global.TagInput = TagInput;
|
||||
}
|
||||
})(this);
|
||||
9
node_modules/@accessible-components/tag-input/build/tag-input.min.css
generated
vendored
Normal file
9
node_modules/@accessible-components/tag-input/build/tag-input.min.css
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/@accessible-components/tag-input/build/tag-input.min.js
generated
vendored
Normal file
9
node_modules/@accessible-components/tag-input/build/tag-input.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
55
node_modules/@accessible-components/tag-input/package.json
generated
vendored
Normal file
55
node_modules/@accessible-components/tag-input/package.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "@accessible-components/tag-input",
|
||||
"version": "0.2.0",
|
||||
"private": false,
|
||||
"description": "Simple and accessible component for creating tags.",
|
||||
"author": {
|
||||
"name": "Sergei Kriger",
|
||||
"url": "https://sergeikriger.com/"
|
||||
},
|
||||
"homepage": "https://github.com/accessible-components/tag-input",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/accessible-components/tag-input.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/accessible-components/tag-input/issues"
|
||||
},
|
||||
"main": "./build/tag-input.js",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"build/tag-input.*"
|
||||
],
|
||||
"keywords": [
|
||||
"tags",
|
||||
"tag input",
|
||||
"accessibility",
|
||||
"a11y"
|
||||
],
|
||||
"scripts": {
|
||||
"start": "gulp",
|
||||
"build": "gulp build",
|
||||
"serve:build": "gulp serveBuild",
|
||||
"clean": "gulp clean",
|
||||
"release": "standard-version"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.7",
|
||||
"@babel/preset-env": "^7.12.7",
|
||||
"browser-sync": "^2.26.13",
|
||||
"del": "^5.1.0",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-autoprefixer": "^7.0.1",
|
||||
"gulp-babel": "^8.0.0",
|
||||
"gulp-clean-css": "^4.3.0",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-header": "^2.0.9",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-replace": "^1.0.0",
|
||||
"gulp-terser": "^2.0.0",
|
||||
"standard-version": "^9.0.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"yargs-parser": "^20.2.4"
|
||||
}
|
||||
}
|
||||
22
node_modules/@babel/code-frame/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/code-frame/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
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.
|
||||
19
node_modules/@babel/code-frame/README.md
generated
vendored
Normal file
19
node_modules/@babel/code-frame/README.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# @babel/code-frame
|
||||
|
||||
> Generate errors that contain a code frame that point to source locations.
|
||||
|
||||
See our website [@babel/code-frame](https://babeljs.io/docs/babel-code-frame) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/code-frame
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/code-frame --dev
|
||||
```
|
||||
217
node_modules/@babel/code-frame/lib/index.js
generated
vendored
Normal file
217
node_modules/@babel/code-frame/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var picocolors = require('picocolors');
|
||||
var jsTokens = require('js-tokens');
|
||||
var helperValidatorIdentifier = require('@babel/helper-validator-identifier');
|
||||
|
||||
function isColorSupported() {
|
||||
return (typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? false : picocolors.isColorSupported
|
||||
);
|
||||
}
|
||||
const compose = (f, g) => v => f(g(v));
|
||||
function buildDefs(colors) {
|
||||
return {
|
||||
keyword: colors.cyan,
|
||||
capitalized: colors.yellow,
|
||||
jsxIdentifier: colors.yellow,
|
||||
punctuator: colors.yellow,
|
||||
number: colors.magenta,
|
||||
string: colors.green,
|
||||
regex: colors.magenta,
|
||||
comment: colors.gray,
|
||||
invalid: compose(compose(colors.white, colors.bgRed), colors.bold),
|
||||
gutter: colors.gray,
|
||||
marker: compose(colors.red, colors.bold),
|
||||
message: compose(colors.red, colors.bold),
|
||||
reset: colors.reset
|
||||
};
|
||||
}
|
||||
const defsOn = buildDefs(picocolors.createColors(true));
|
||||
const defsOff = buildDefs(picocolors.createColors(false));
|
||||
function getDefs(enabled) {
|
||||
return enabled ? defsOn : defsOff;
|
||||
}
|
||||
|
||||
const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
|
||||
const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
|
||||
const BRACKET = /^[()[\]{}]$/;
|
||||
let tokenize;
|
||||
const JSX_TAG = /^[a-z][\w-]*$/i;
|
||||
const getTokenType = function (token, offset, text) {
|
||||
if (token.type === "name") {
|
||||
const tokenValue = token.value;
|
||||
if (helperValidatorIdentifier.isKeyword(tokenValue) || helperValidatorIdentifier.isStrictReservedWord(tokenValue, true) || sometimesKeywords.has(tokenValue)) {
|
||||
return "keyword";
|
||||
}
|
||||
if (JSX_TAG.test(tokenValue) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")) {
|
||||
return "jsxIdentifier";
|
||||
}
|
||||
const firstChar = String.fromCodePoint(tokenValue.codePointAt(0));
|
||||
if (firstChar !== firstChar.toLowerCase()) {
|
||||
return "capitalized";
|
||||
}
|
||||
}
|
||||
if (token.type === "punctuator" && BRACKET.test(token.value)) {
|
||||
return "bracket";
|
||||
}
|
||||
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
|
||||
return "punctuator";
|
||||
}
|
||||
return token.type;
|
||||
};
|
||||
tokenize = function* (text) {
|
||||
let match;
|
||||
while (match = jsTokens.default.exec(text)) {
|
||||
const token = jsTokens.matchToToken(match);
|
||||
yield {
|
||||
type: getTokenType(token, match.index, text),
|
||||
value: token.value
|
||||
};
|
||||
}
|
||||
};
|
||||
function highlight(text) {
|
||||
if (text === "") return "";
|
||||
const defs = getDefs(true);
|
||||
let highlighted = "";
|
||||
for (const {
|
||||
type,
|
||||
value
|
||||
} of tokenize(text)) {
|
||||
if (type in defs) {
|
||||
highlighted += value.split(NEWLINE$1).map(str => defs[type](str)).join("\n");
|
||||
} else {
|
||||
highlighted += value;
|
||||
}
|
||||
}
|
||||
return highlighted;
|
||||
}
|
||||
|
||||
let deprecationWarningShown = false;
|
||||
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
||||
function getMarkerLines(loc, source, opts, startLineBaseZero) {
|
||||
const startLoc = Object.assign({
|
||||
column: 0,
|
||||
line: -1
|
||||
}, loc.start);
|
||||
const endLoc = Object.assign({}, startLoc, loc.end);
|
||||
const {
|
||||
linesAbove = 2,
|
||||
linesBelow = 3
|
||||
} = opts || {};
|
||||
const startLine = startLoc.line - startLineBaseZero;
|
||||
const startColumn = startLoc.column;
|
||||
const endLine = endLoc.line - startLineBaseZero;
|
||||
const endColumn = endLoc.column;
|
||||
let start = Math.max(startLine - (linesAbove + 1), 0);
|
||||
let end = Math.min(source.length, endLine + linesBelow);
|
||||
if (startLine === -1) {
|
||||
start = 0;
|
||||
}
|
||||
if (endLine === -1) {
|
||||
end = source.length;
|
||||
}
|
||||
const lineDiff = endLine - startLine;
|
||||
const markerLines = {};
|
||||
if (lineDiff) {
|
||||
for (let i = 0; i <= lineDiff; i++) {
|
||||
const lineNumber = i + startLine;
|
||||
if (!startColumn) {
|
||||
markerLines[lineNumber] = true;
|
||||
} else if (i === 0) {
|
||||
const sourceLength = source[lineNumber - 1].length;
|
||||
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
|
||||
} else if (i === lineDiff) {
|
||||
markerLines[lineNumber] = [0, endColumn];
|
||||
} else {
|
||||
const sourceLength = source[lineNumber - i].length;
|
||||
markerLines[lineNumber] = [0, sourceLength];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (startColumn === endColumn) {
|
||||
if (startColumn) {
|
||||
markerLines[startLine] = [startColumn, 0];
|
||||
} else {
|
||||
markerLines[startLine] = true;
|
||||
}
|
||||
} else {
|
||||
markerLines[startLine] = [startColumn, endColumn - startColumn];
|
||||
}
|
||||
}
|
||||
return {
|
||||
start,
|
||||
end,
|
||||
markerLines
|
||||
};
|
||||
}
|
||||
function codeFrameColumns(rawLines, loc, opts = {}) {
|
||||
const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;
|
||||
const startLineBaseZero = (opts.startLine || 1) - 1;
|
||||
const defs = getDefs(shouldHighlight);
|
||||
const lines = rawLines.split(NEWLINE);
|
||||
const {
|
||||
start,
|
||||
end,
|
||||
markerLines
|
||||
} = getMarkerLines(loc, lines, opts, startLineBaseZero);
|
||||
const hasColumns = loc.start && typeof loc.start.column === "number";
|
||||
const numberMaxWidth = String(end + startLineBaseZero).length;
|
||||
const highlightedLines = shouldHighlight ? highlight(rawLines) : rawLines;
|
||||
let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
|
||||
const number = start + 1 + index;
|
||||
const paddedNumber = ` ${number + startLineBaseZero}`.slice(-numberMaxWidth);
|
||||
const gutter = ` ${paddedNumber} |`;
|
||||
const hasMarker = markerLines[number];
|
||||
const lastMarkerLine = !markerLines[number + 1];
|
||||
if (hasMarker) {
|
||||
let markerLine = "";
|
||||
if (Array.isArray(hasMarker)) {
|
||||
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
|
||||
const numberOfMarkers = hasMarker[1] || 1;
|
||||
markerLine = ["\n ", defs.gutter(gutter.replace(/\d/g, " ")), " ", markerSpacing, defs.marker("^").repeat(numberOfMarkers)].join("");
|
||||
if (lastMarkerLine && opts.message) {
|
||||
markerLine += " " + defs.message(opts.message);
|
||||
}
|
||||
}
|
||||
return [defs.marker(">"), defs.gutter(gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
|
||||
} else {
|
||||
return ` ${defs.gutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
|
||||
}
|
||||
}).join("\n");
|
||||
if (opts.message && !hasColumns) {
|
||||
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
||||
}
|
||||
if (shouldHighlight) {
|
||||
return defs.reset(frame);
|
||||
} else {
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
function index (rawLines, lineNumber, colNumber, opts = {}) {
|
||||
if (!deprecationWarningShown) {
|
||||
deprecationWarningShown = true;
|
||||
const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
|
||||
if (process.emitWarning) {
|
||||
process.emitWarning(message, "DeprecationWarning");
|
||||
} else {
|
||||
const deprecationError = new Error(message);
|
||||
deprecationError.name = "DeprecationWarning";
|
||||
console.warn(new Error(message));
|
||||
}
|
||||
}
|
||||
colNumber = Math.max(colNumber, 0);
|
||||
const location = {
|
||||
start: {
|
||||
column: colNumber,
|
||||
line: lineNumber
|
||||
}
|
||||
};
|
||||
return codeFrameColumns(rawLines, location, opts);
|
||||
}
|
||||
|
||||
exports.codeFrameColumns = codeFrameColumns;
|
||||
exports.default = index;
|
||||
exports.highlight = highlight;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@babel/code-frame/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/code-frame/lib/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
32
node_modules/@babel/code-frame/package.json
generated
vendored
Normal file
32
node_modules/@babel/code-frame/package.json
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@babel/code-frame",
|
||||
"version": "7.29.0",
|
||||
"description": "Generate errors that contain a code frame that point to source locations.",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-code-frame",
|
||||
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-code-frame"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-validator-identifier": "^7.28.5",
|
||||
"js-tokens": "^4.0.0",
|
||||
"picocolors": "^1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"charcodes": "^0.2.0",
|
||||
"import-meta-resolve": "^4.1.0",
|
||||
"strip-ansi": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"type": "commonjs"
|
||||
}
|
||||
22
node_modules/@babel/helper-validator-identifier/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/helper-validator-identifier/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
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.
|
||||
19
node_modules/@babel/helper-validator-identifier/README.md
generated
vendored
Normal file
19
node_modules/@babel/helper-validator-identifier/README.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# @babel/helper-validator-identifier
|
||||
|
||||
> Validate identifier/keywords name
|
||||
|
||||
See our website [@babel/helper-validator-identifier](https://babeljs.io/docs/babel-helper-validator-identifier) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-validator-identifier
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/helper-validator-identifier
|
||||
```
|
||||
70
node_modules/@babel/helper-validator-identifier/lib/identifier.js
generated
vendored
Normal file
70
node_modules/@babel/helper-validator-identifier/lib/identifier.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isIdentifierChar = isIdentifierChar;
|
||||
exports.isIdentifierName = isIdentifierName;
|
||||
exports.isIdentifierStart = isIdentifierStart;
|
||||
let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088f\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5c\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdc-\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c8a\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7dc\ua7f1-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
|
||||
let nonASCIIidentifierChars = "\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0897-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1add\u1ae0-\u1aeb\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65";
|
||||
const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
|
||||
const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
||||
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
|
||||
const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 7, 25, 39, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 5, 57, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 200, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 24, 43, 261, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 33, 24, 3, 24, 45, 74, 6, 0, 67, 12, 65, 1, 2, 0, 15, 4, 10, 7381, 42, 31, 98, 114, 8702, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 208, 30, 2, 2, 2, 1, 2, 6, 3, 4, 10, 1, 225, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4381, 3, 5773, 3, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 8489];
|
||||
const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 78, 5, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 199, 7, 137, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 55, 9, 266, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 233, 0, 3, 0, 8, 1, 6, 0, 475, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
|
||||
function isInAstralSet(code, set) {
|
||||
let pos = 0x10000;
|
||||
for (let i = 0, length = set.length; i < length; i += 2) {
|
||||
pos += set[i];
|
||||
if (pos > code) return false;
|
||||
pos += set[i + 1];
|
||||
if (pos >= code) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isIdentifierStart(code) {
|
||||
if (code < 65) return code === 36;
|
||||
if (code <= 90) return true;
|
||||
if (code < 97) return code === 95;
|
||||
if (code <= 122) return true;
|
||||
if (code <= 0xffff) {
|
||||
return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
|
||||
}
|
||||
return isInAstralSet(code, astralIdentifierStartCodes);
|
||||
}
|
||||
function isIdentifierChar(code) {
|
||||
if (code < 48) return code === 36;
|
||||
if (code < 58) return true;
|
||||
if (code < 65) return false;
|
||||
if (code <= 90) return true;
|
||||
if (code < 97) return code === 95;
|
||||
if (code <= 122) return true;
|
||||
if (code <= 0xffff) {
|
||||
return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
|
||||
}
|
||||
return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
|
||||
}
|
||||
function isIdentifierName(name) {
|
||||
let isFirst = true;
|
||||
for (let i = 0; i < name.length; i++) {
|
||||
let cp = name.charCodeAt(i);
|
||||
if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
|
||||
const trail = name.charCodeAt(++i);
|
||||
if ((trail & 0xfc00) === 0xdc00) {
|
||||
cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
|
||||
}
|
||||
}
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
if (!isIdentifierStart(cp)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!isIdentifierChar(cp)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !isFirst;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=identifier.js.map
|
||||
1
node_modules/@babel/helper-validator-identifier/lib/identifier.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-validator-identifier/lib/identifier.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
57
node_modules/@babel/helper-validator-identifier/lib/index.js
generated
vendored
Normal file
57
node_modules/@babel/helper-validator-identifier/lib/index.js
generated
vendored
Normal file
@@ -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
|
||||
1
node_modules/@babel/helper-validator-identifier/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-validator-identifier/lib/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_identifier","require","_keyword"],"sources":["../src/index.ts"],"sourcesContent":["export {\n isIdentifierName,\n isIdentifierChar,\n isIdentifierStart,\n} from \"./identifier.ts\";\nexport {\n isReservedWord,\n isStrictBindOnlyReservedWord,\n isStrictBindReservedWord,\n isStrictReservedWord,\n isKeyword,\n} from \"./keyword.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA","ignoreList":[]}
|
||||
35
node_modules/@babel/helper-validator-identifier/lib/keyword.js
generated
vendored
Normal file
35
node_modules/@babel/helper-validator-identifier/lib/keyword.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isKeyword = isKeyword;
|
||||
exports.isReservedWord = isReservedWord;
|
||||
exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
|
||||
exports.isStrictBindReservedWord = isStrictBindReservedWord;
|
||||
exports.isStrictReservedWord = isStrictReservedWord;
|
||||
const reservedWords = {
|
||||
keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
|
||||
strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
|
||||
strictBind: ["eval", "arguments"]
|
||||
};
|
||||
const keywords = new Set(reservedWords.keyword);
|
||||
const reservedWordsStrictSet = new Set(reservedWords.strict);
|
||||
const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
|
||||
function isReservedWord(word, inModule) {
|
||||
return inModule && word === "await" || word === "enum";
|
||||
}
|
||||
function isStrictReservedWord(word, inModule) {
|
||||
return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
|
||||
}
|
||||
function isStrictBindOnlyReservedWord(word) {
|
||||
return reservedWordsStrictBindSet.has(word);
|
||||
}
|
||||
function isStrictBindReservedWord(word, inModule) {
|
||||
return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
|
||||
}
|
||||
function isKeyword(word) {
|
||||
return keywords.has(word);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=keyword.js.map
|
||||
1
node_modules/@babel/helper-validator-identifier/lib/keyword.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-validator-identifier/lib/keyword.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["reservedWords","keyword","strict","strictBind","keywords","Set","reservedWordsStrictSet","reservedWordsStrictBindSet","isReservedWord","word","inModule","isStrictReservedWord","has","isStrictBindOnlyReservedWord","isStrictBindReservedWord","isKeyword"],"sources":["../src/keyword.ts"],"sourcesContent":["const reservedWords = {\n keyword: [\n \"break\",\n \"case\",\n \"catch\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"do\",\n \"else\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"return\",\n \"switch\",\n \"throw\",\n \"try\",\n \"var\",\n \"const\",\n \"while\",\n \"with\",\n \"new\",\n \"this\",\n \"super\",\n \"class\",\n \"extends\",\n \"export\",\n \"import\",\n \"null\",\n \"true\",\n \"false\",\n \"in\",\n \"instanceof\",\n \"typeof\",\n \"void\",\n \"delete\",\n ],\n strict: [\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n \"yield\",\n ],\n strictBind: [\"eval\", \"arguments\"],\n};\nconst keywords = new Set(reservedWords.keyword);\nconst reservedWordsStrictSet = new Set(reservedWords.strict);\nconst reservedWordsStrictBindSet = new Set(reservedWords.strictBind);\n\n/**\n * Checks if word is a reserved word in non-strict mode\n */\nexport function isReservedWord(word: string, inModule: boolean): boolean {\n return (inModule && word === \"await\") || word === \"enum\";\n}\n\n/**\n * Checks if word is a reserved word in non-binding strict mode\n *\n * Includes non-strict reserved words\n */\nexport function isStrictReservedWord(word: string, inModule: boolean): boolean {\n return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode, but it is allowed as\n * a normal identifier.\n */\nexport function isStrictBindOnlyReservedWord(word: string): boolean {\n return reservedWordsStrictBindSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode\n *\n * Includes non-strict reserved words and non-binding strict reserved words\n */\nexport function isStrictBindReservedWord(\n word: string,\n inModule: boolean,\n): boolean {\n return (\n isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word)\n );\n}\n\nexport function isKeyword(word: string): boolean {\n return keywords.has(word);\n}\n"],"mappings":";;;;;;;;;;AAAA,MAAMA,aAAa,GAAG;EACpBC,OAAO,EAAE,CACP,OAAO,EACP,MAAM,EACN,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS,EACT,IAAI,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,CACT;EACDC,MAAM,EAAE,CACN,YAAY,EACZ,WAAW,EACX,KAAK,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,OAAO,CACR;EACDC,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW;AAClC,CAAC;AACD,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAACL,aAAa,CAACC,OAAO,CAAC;AAC/C,MAAMK,sBAAsB,GAAG,IAAID,GAAG,CAACL,aAAa,CAACE,MAAM,CAAC;AAC5D,MAAMK,0BAA0B,GAAG,IAAIF,GAAG,CAACL,aAAa,CAACG,UAAU,CAAC;AAK7D,SAASK,cAAcA,CAACC,IAAY,EAAEC,QAAiB,EAAW;EACvE,OAAQA,QAAQ,IAAID,IAAI,KAAK,OAAO,IAAKA,IAAI,KAAK,MAAM;AAC1D;AAOO,SAASE,oBAAoBA,CAACF,IAAY,EAAEC,QAAiB,EAAW;EAC7E,OAAOF,cAAc,CAACC,IAAI,EAAEC,QAAQ,CAAC,IAAIJ,sBAAsB,CAACM,GAAG,CAACH,IAAI,CAAC;AAC3E;AAMO,SAASI,4BAA4BA,CAACJ,IAAY,EAAW;EAClE,OAAOF,0BAA0B,CAACK,GAAG,CAACH,IAAI,CAAC;AAC7C;AAOO,SAASK,wBAAwBA,CACtCL,IAAY,EACZC,QAAiB,EACR;EACT,OACEC,oBAAoB,CAACF,IAAI,EAAEC,QAAQ,CAAC,IAAIG,4BAA4B,CAACJ,IAAI,CAAC;AAE9E;AAEO,SAASM,SAASA,CAACN,IAAY,EAAW;EAC/C,OAAOL,QAAQ,CAACQ,GAAG,CAACH,IAAI,CAAC;AAC3B","ignoreList":[]}
|
||||
31
node_modules/@babel/helper-validator-identifier/package.json
generated
vendored
Normal file
31
node_modules/@babel/helper-validator-identifier/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@babel/helper-validator-identifier",
|
||||
"version": "7.28.5",
|
||||
"description": "Validate identifier/keywords name",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-helper-validator-identifier"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/index.d.ts",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@unicode/unicode-17.0.0": "^1.6.10",
|
||||
"charcodes": "^0.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
||||
9
node_modules/@borewit/text-codec/LICENSE.txt
generated
vendored
Normal file
9
node_modules/@borewit/text-codec/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2025 Borewit
|
||||
|
||||
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.
|
||||
96
node_modules/@borewit/text-codec/README.md
generated
vendored
Normal file
96
node_modules/@borewit/text-codec/README.md
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
[](https://github.com/Borewit/text-codec/actions/workflows/ci.yml)
|
||||
[](https://www.npmjs.com/package/@borewit/text-codec)
|
||||
[](https://npmcharts.com/compare/@borewit/text-codec?interval=30)
|
||||

|
||||
[](LICENSE.txt)
|
||||
|
||||
# `@borewit/text-codec`
|
||||
|
||||
A **lightweight alternative implementation** of `TextEncoder` / `TextDecoder` supporting common encodings missing in some JavaScript engines and Node.js builds.
|
||||
Works in environments like **Hermes** (React Native) or **Small-ICU Node.js** where only UTF-8 and UTF-16LE are available.
|
||||
|
||||
| Encoding | Hermes — **Encode** | Hermes — **Decode** | Small-ICU Node.js — **Encode** | Small-ICU Node.js — **Decode** |
|
||||
|---------------------------|---------------------|---------------------|--------------------------------|--------------------------------|
|
||||
| **utf-8** / `utf8` | ➕ | Native | Native | Native |
|
||||
| **utf-16le** | ➕ | ➕ | Native | Native |
|
||||
| **ascii** | ➕ | ➕ | ➕ | ➕ |
|
||||
| **latin1** / `iso-8859-1` | ➕ | ➕ | ➕ | Native (sometimes) |
|
||||
| **windows-1252** | ➕ | ➕ | ➕ | ➕ |
|
||||
|
||||
**Legend:**
|
||||
- **Native** — Supported natively by the JavaScript engine.
|
||||
- **➕** — Support added by this module.
|
||||
- **Native (sometimes)** — Available in some builds (e.g., certain Small-ICU Node.js builds).
|
||||
---
|
||||
|
||||
When your project needs to handle encodings like `latin1` / `iso-8859-1` or `windows-1252` in these environments,
|
||||
native `TextDecoder` / `TextEncoder` may throw an error or return incorrect results.
|
||||
|
||||
## ✨ Features
|
||||
|
||||
- Decoding and encoding
|
||||
- Lightweight
|
||||
- Typed
|
||||
|
||||
### Supported encodings:
|
||||
- `utf-8` / `utf8`
|
||||
- `utf-16le`
|
||||
- `ascii`
|
||||
- `latin1` / `iso-8859-1`
|
||||
- `windows-1252`
|
||||
|
||||
---
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
```sh
|
||||
npm install @borewit/text-codec
|
||||
```
|
||||
|
||||
|
||||
# 📚 API Documentation
|
||||
|
||||
## `textDecode(bytes, encoding): string`
|
||||
|
||||
Decodes binary data into a JavaScript string using the specified encoding.
|
||||
|
||||
**Parameters**
|
||||
- `bytes` (`Uint8Array`) — The binary data to decode.
|
||||
- `encoding` (`SupportedEncoding`, optional) — Encoding type. Defaults to `"utf-8"`.
|
||||
|
||||
**Returns**
|
||||
- `string` — The decoded text.
|
||||
|
||||
**Example**
|
||||
```js
|
||||
import { textDecode } from "@borewit/text-encode";
|
||||
|
||||
const bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
|
||||
const text = textDecode(bytes, "ascii");
|
||||
console.log(text); // "Hello"
|
||||
```
|
||||
Encodes a JavaScript string into binary form using the specified encoding.
|
||||
|
||||
## `textEncode(input, encoding): Uint8Array`
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `input` (`string`) — The string to encode.
|
||||
- `encoding` (`SupportedEncoding`, optional) — Encoding type. Defaults to `"utf-8"`.
|
||||
|
||||
**Returns**
|
||||
|
||||
`Uint8Array` — The encoded binary data.
|
||||
|
||||
Example:
|
||||
```js
|
||||
import { textEncode } from "@borewit/text-encode";
|
||||
|
||||
const bytes = textEncode("Hello", "utf-16le");
|
||||
console.log(bytes); // Uint8Array([...])
|
||||
```
|
||||
|
||||
## 📜 Licence
|
||||
|
||||
This project is licensed under the [MIT License](LICENSE.txt). Feel free to use, modify, and distribute as needed.
|
||||
|
||||
8
node_modules/@borewit/text-codec/lib/index.d.ts
generated
vendored
Normal file
8
node_modules/@borewit/text-codec/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export type SupportedEncoding = "utf-8" | "utf8" | "utf-16le" | "us-ascii" | "ascii" | "latin1" | "iso-8859-1" | "windows-1252";
|
||||
/**
|
||||
* Decode text from binary data
|
||||
* @param bytes Binary data
|
||||
* @param encoding Encoding
|
||||
*/
|
||||
export declare function textDecode(bytes: Uint8Array, encoding?: SupportedEncoding): string;
|
||||
export declare function textEncode(input?: string, encoding?: SupportedEncoding): Uint8Array;
|
||||
236
node_modules/@borewit/text-codec/lib/index.js
generated
vendored
Normal file
236
node_modules/@borewit/text-codec/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
const WINDOWS_1252_EXTRA = {
|
||||
0x80: "€", 0x82: "‚", 0x83: "ƒ", 0x84: "„", 0x85: "…", 0x86: "†",
|
||||
0x87: "‡", 0x88: "ˆ", 0x89: "‰", 0x8a: "Š", 0x8b: "‹", 0x8c: "Œ",
|
||||
0x8e: "Ž", 0x91: "‘", 0x92: "’", 0x93: "“", 0x94: "”", 0x95: "•",
|
||||
0x96: "–", 0x97: "—", 0x98: "˜", 0x99: "™", 0x9a: "š", 0x9b: "›",
|
||||
0x9c: "œ", 0x9e: "ž", 0x9f: "Ÿ",
|
||||
};
|
||||
const WINDOWS_1252_REVERSE = {};
|
||||
for (const [code, char] of Object.entries(WINDOWS_1252_EXTRA)) {
|
||||
WINDOWS_1252_REVERSE[char] = Number.parseInt(code, 10);
|
||||
}
|
||||
// ---------- Cached decoders/encoders ----------
|
||||
let _utf8Decoder;
|
||||
let _utf8Encoder;
|
||||
function utf8Decoder() {
|
||||
if (typeof globalThis.TextDecoder === "undefined")
|
||||
return undefined;
|
||||
return (_utf8Decoder !== null && _utf8Decoder !== void 0 ? _utf8Decoder : (_utf8Decoder = new globalThis.TextDecoder("utf-8")));
|
||||
}
|
||||
function utf8Encoder() {
|
||||
if (typeof globalThis.TextEncoder === "undefined")
|
||||
return undefined;
|
||||
return (_utf8Encoder !== null && _utf8Encoder !== void 0 ? _utf8Encoder : (_utf8Encoder = new globalThis.TextEncoder()));
|
||||
}
|
||||
// Safe chunk size well under your measured ~105k cliff.
|
||||
// 32k keeps memory reasonable and is plenty fast.
|
||||
const CHUNK = 32 * 1024;
|
||||
/**
|
||||
* Decode text from binary data
|
||||
* @param bytes Binary data
|
||||
* @param encoding Encoding
|
||||
*/
|
||||
export function textDecode(bytes, encoding = "utf-8") {
|
||||
switch (encoding.toLowerCase()) {
|
||||
case "utf-8":
|
||||
case "utf8": {
|
||||
const dec = utf8Decoder();
|
||||
return dec ? dec.decode(bytes) : decodeUTF8(bytes);
|
||||
}
|
||||
case "utf-16le":
|
||||
return decodeUTF16LE(bytes);
|
||||
case "us-ascii":
|
||||
case "ascii":
|
||||
return decodeASCII(bytes);
|
||||
case "latin1":
|
||||
case "iso-8859-1":
|
||||
return decodeLatin1(bytes);
|
||||
case "windows-1252":
|
||||
return decodeWindows1252(bytes);
|
||||
default:
|
||||
throw new RangeError(`Encoding '${encoding}' not supported`);
|
||||
}
|
||||
}
|
||||
export function textEncode(input = "", encoding = "utf-8") {
|
||||
switch (encoding.toLowerCase()) {
|
||||
case "utf-8":
|
||||
case "utf8": {
|
||||
const enc = utf8Encoder();
|
||||
return enc ? enc.encode(input) : encodeUTF8(input);
|
||||
}
|
||||
case "utf-16le":
|
||||
return encodeUTF16LE(input);
|
||||
case "us-ascii":
|
||||
case "ascii":
|
||||
return encodeASCII(input);
|
||||
case "latin1":
|
||||
case "iso-8859-1":
|
||||
return encodeLatin1(input);
|
||||
case "windows-1252":
|
||||
return encodeWindows1252(input);
|
||||
default:
|
||||
throw new RangeError(`Encoding '${encoding}' not supported`);
|
||||
}
|
||||
}
|
||||
// --- Internal helpers ---
|
||||
function decodeUTF8(bytes) {
|
||||
const parts = [];
|
||||
let out = "";
|
||||
let i = 0;
|
||||
while (i < bytes.length) {
|
||||
const b1 = bytes[i++];
|
||||
if (b1 < 0x80) {
|
||||
out += String.fromCharCode(b1);
|
||||
}
|
||||
else if (b1 < 0xe0) {
|
||||
const b2 = bytes[i++] & 0x3f;
|
||||
out += String.fromCharCode(((b1 & 0x1f) << 6) | b2);
|
||||
}
|
||||
else if (b1 < 0xf0) {
|
||||
const b2 = bytes[i++] & 0x3f;
|
||||
const b3 = bytes[i++] & 0x3f;
|
||||
out += String.fromCharCode(((b1 & 0x0f) << 12) | (b2 << 6) | b3);
|
||||
}
|
||||
else {
|
||||
const b2 = bytes[i++] & 0x3f;
|
||||
const b3 = bytes[i++] & 0x3f;
|
||||
const b4 = bytes[i++] & 0x3f;
|
||||
let cp = ((b1 & 0x07) << 18) | (b2 << 12) | (b3 << 6) | b4;
|
||||
cp -= 0x10000;
|
||||
out += String.fromCharCode(0xd800 + ((cp >> 10) & 0x3ff), 0xdc00 + (cp & 0x3ff));
|
||||
}
|
||||
if (out.length >= CHUNK) {
|
||||
parts.push(out);
|
||||
out = "";
|
||||
}
|
||||
}
|
||||
if (out)
|
||||
parts.push(out);
|
||||
return parts.join("");
|
||||
}
|
||||
function decodeUTF16LE(bytes) {
|
||||
// Use chunked fromCharCode on 16-bit code units.
|
||||
// If odd length, ignore trailing byte (common behavior).
|
||||
const len = bytes.length & ~1;
|
||||
if (len === 0)
|
||||
return "";
|
||||
const parts = [];
|
||||
// Build a temporary code-unit array per chunk.
|
||||
const maxUnits = CHUNK; // CHUNK code units per chunk
|
||||
for (let i = 0; i < len;) {
|
||||
const unitsThis = Math.min(maxUnits, (len - i) >> 1);
|
||||
const units = new Array(unitsThis);
|
||||
for (let j = 0; j < unitsThis; j++, i += 2) {
|
||||
units[j] = bytes[i] | (bytes[i + 1] << 8);
|
||||
}
|
||||
parts.push(String.fromCharCode.apply(null, units));
|
||||
}
|
||||
return parts.join("");
|
||||
}
|
||||
function decodeASCII(bytes) {
|
||||
// 7-bit ASCII: mask high bit. (Kept to match your original semantics.)
|
||||
const parts = [];
|
||||
for (let i = 0; i < bytes.length; i += CHUNK) {
|
||||
const end = Math.min(bytes.length, i + CHUNK);
|
||||
const codes = new Array(end - i);
|
||||
for (let j = i, k = 0; j < end; j++, k++) {
|
||||
codes[k] = bytes[j] & 0x7f;
|
||||
}
|
||||
parts.push(String.fromCharCode.apply(null, codes));
|
||||
}
|
||||
return parts.join("");
|
||||
}
|
||||
function decodeLatin1(bytes) {
|
||||
// Latin-1 is 0x00..0xFF direct mapping; avoid spread.
|
||||
const parts = [];
|
||||
for (let i = 0; i < bytes.length; i += CHUNK) {
|
||||
const end = Math.min(bytes.length, i + CHUNK);
|
||||
const codes = new Array(end - i);
|
||||
for (let j = i, k = 0; j < end; j++, k++) {
|
||||
codes[k] = bytes[j];
|
||||
}
|
||||
parts.push(String.fromCharCode.apply(null, codes));
|
||||
}
|
||||
return parts.join("");
|
||||
}
|
||||
function decodeWindows1252(bytes) {
|
||||
// Only 0x80..0x9F need mapping; others are direct 1-byte codes.
|
||||
const parts = [];
|
||||
let out = "";
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
const b = bytes[i];
|
||||
const extra = b >= 0x80 && b <= 0x9f ? WINDOWS_1252_EXTRA[b] : undefined;
|
||||
out += extra !== null && extra !== void 0 ? extra : String.fromCharCode(b);
|
||||
if (out.length >= CHUNK) {
|
||||
parts.push(out);
|
||||
out = "";
|
||||
}
|
||||
}
|
||||
if (out)
|
||||
parts.push(out);
|
||||
return parts.join("");
|
||||
}
|
||||
function encodeUTF8(str) {
|
||||
const out = [];
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
let cp = str.charCodeAt(i);
|
||||
// surrogate pair
|
||||
if (cp >= 0xd800 && cp <= 0xdbff && i + 1 < str.length) {
|
||||
const lo = str.charCodeAt(i + 1);
|
||||
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
||||
cp = 0x10000 + ((cp - 0xd800) << 10) + (lo - 0xdc00);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (cp < 0x80) {
|
||||
out.push(cp);
|
||||
}
|
||||
else if (cp < 0x800) {
|
||||
out.push(0xc0 | (cp >> 6), 0x80 | (cp & 0x3f));
|
||||
}
|
||||
else if (cp < 0x10000) {
|
||||
out.push(0xe0 | (cp >> 12), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));
|
||||
}
|
||||
else {
|
||||
out.push(0xf0 | (cp >> 18), 0x80 | ((cp >> 12) & 0x3f), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));
|
||||
}
|
||||
}
|
||||
return new Uint8Array(out);
|
||||
}
|
||||
function encodeUTF16LE(str) {
|
||||
const out = new Uint8Array(str.length * 2);
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const code = str.charCodeAt(i);
|
||||
const o = i * 2;
|
||||
out[o] = code & 0xff;
|
||||
out[o + 1] = code >>> 8;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function encodeASCII(str) {
|
||||
// 7-bit ASCII: mask high bit
|
||||
const out = new Uint8Array(str.length);
|
||||
for (let i = 0; i < str.length; i++)
|
||||
out[i] = str.charCodeAt(i) & 0x7f;
|
||||
return out;
|
||||
}
|
||||
function encodeLatin1(str) {
|
||||
const out = new Uint8Array(str.length);
|
||||
for (let i = 0; i < str.length; i++)
|
||||
out[i] = str.charCodeAt(i) & 0xff;
|
||||
return out;
|
||||
}
|
||||
function encodeWindows1252(str) {
|
||||
const out = new Uint8Array(str.length);
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const ch = str[i];
|
||||
const code = ch.charCodeAt(0);
|
||||
if (code <= 0xff) {
|
||||
out[i] = code;
|
||||
continue;
|
||||
}
|
||||
const mapped = WINDOWS_1252_REVERSE[ch];
|
||||
out[i] = mapped !== undefined ? mapped : 0x3f; // '?'
|
||||
}
|
||||
return out;
|
||||
}
|
||||
70
node_modules/@borewit/text-codec/package.json
generated
vendored
Normal file
70
node_modules/@borewit/text-codec/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "@borewit/text-codec",
|
||||
"version": "0.2.1",
|
||||
"description": "Text Decoder",
|
||||
"type": "module",
|
||||
"exports": "./lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"files": [
|
||||
"lib/index.js",
|
||||
"lib/index.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map",
|
||||
"build": "npm run compile",
|
||||
"prepublishOnly": "npm run build",
|
||||
"compile:src": "tsc --p lib --sourceMap false",
|
||||
"compile:test": "tsc --p test",
|
||||
"compile": "npm run compile:src && npm run compile:test",
|
||||
"lint": "biome check",
|
||||
"test": "mocha",
|
||||
"update-biome": "npm install --save-dev --save-exact @biomejs/biome@latest && npx @biomejs/biome migrate --write"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "2.3.10",
|
||||
"@types/chai": "^5.2.2",
|
||||
"@types/mocha": "^10.0.10",
|
||||
"chai": "^5.2.1",
|
||||
"mocha": "^11.7.5",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"keywords": [
|
||||
"TextDecoder",
|
||||
"TextEncoder",
|
||||
"decoder",
|
||||
"decoding",
|
||||
"encod",
|
||||
"encoding",
|
||||
"decode",
|
||||
"text",
|
||||
"ascii",
|
||||
"utf-8",
|
||||
"utf8",
|
||||
"utf-16le",
|
||||
"latin1",
|
||||
"iso-8859-1",
|
||||
"windows-1252",
|
||||
"charset",
|
||||
"encoding",
|
||||
"decoding",
|
||||
"polyfill",
|
||||
"character-set",
|
||||
"latin",
|
||||
"hermes",
|
||||
"react"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Borewit/text-codec.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Borewit",
|
||||
"url": "https://github.com/Borewit"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/Borewit"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
93
node_modules/@date-fns/tz/CHANGELOG.md
generated
vendored
Normal file
93
node_modules/@date-fns/tz/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning].
|
||||
|
||||
This change log follows the format documented in [Keep a CHANGELOG].
|
||||
|
||||
[semantic versioning]: http://semver.org/
|
||||
[keep a changelog]: http://keepachangelog.com/
|
||||
|
||||
## v1.4.1 - 2025-08-12
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed incorrect `package.json` published with `@date-fns/tz@1.4.0`.
|
||||
|
||||
## v1.4.0 - 2025-08-12
|
||||
|
||||
### Added
|
||||
|
||||
- [Added support for time zones with seconds offset](https://github.com/date-fns/tz/pull/47). It allows to handle dates before the implementation of the GMT system in 1883. Huge kudos to [@GianlucaWassermeyer](https://github.com/GianlucaWassermeyer)!
|
||||
|
||||
## v1.3.1 - 2025-08-01
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed TypeScript definitions missing in `@date-fns@1.3.0`.
|
||||
|
||||
## v1.3.0 - 2025-08-01
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Format.JS support when running in Hermes engine (React Native). Ensured compatibility with JavaScriptCore engine (Safari).
|
||||
|
||||
- Fixed TypeScript `node16` module resolution [#59](https://github.com/date-fns/tz/pull/59). Thanks to [@samchungy](https://github.com/samchungy).
|
||||
|
||||
### Added
|
||||
|
||||
- Added `tzName` function that formats time zone name in given date time and format. It supports `"short"`, `"long"`, `"shortGeneric"`, and `"longGeneric"` formats, corresponding to TR35 tokens `z..zzz`, `zzzz`, `v`, and `vvvv` respectively. See [README](./README.md) for more details.
|
||||
|
||||
## v1.2.0 - 2024-10-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed issue with `setTime` not syncing the value to the internal date resulting in incorrect behavior [#16](https://github.com/date-fns/tz/issues/16), [#24](https://github.com/date-fns/tz/issues/24).
|
||||
|
||||
## v1.1.2 - 2024-09-24
|
||||
|
||||
### Fixed
|
||||
|
||||
- Improved compatibility with FormatJS Intl polifyll [#8](https://github.com/date-fns/tz/issues/8). Thanks to [@kevin-abiera](https://github.com/kevin-abiera).
|
||||
|
||||
## v1.1.1 - 2024-09-23
|
||||
|
||||
### Fixed
|
||||
|
||||
- Reworked DST handling to fix various bugs and edge cases. There might still be some issues, but I'm actively working on improving test coverage.
|
||||
|
||||
## v1.1.0 - 2024-09-22
|
||||
|
||||
This is yet another critical bug-fix release. Thank you to all the people who sent PRs and reported their issues. Special thanks to [@huextrat](https://github.com/huextrat), [@allohamora](https://github.com/allohamora) and [@lhermann](https://github.com/lhermann).
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Fixed negative fractional time zones like `America/St_Johns`](https://github.com/date-fns/tz/pull/7) [@allohamora](https://github.com/allohamora).
|
||||
|
||||
- Fixed the DST bug when creating a date in the DST transition hour.
|
||||
|
||||
### Added
|
||||
|
||||
- Added support for `±HH:MM/±HHMM/±HH` time zone formats for Node.js below v22 (and other environments that has this problem) [#3](https://github.com/date-fns/tz/issues/3)
|
||||
|
||||
## v1.0.2 - 2024-09-14
|
||||
|
||||
This release fixes a couple of critical bugs in the previous release.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed UTC setters functions generation.
|
||||
|
||||
- Create `Invalid Date` instead of throwing an error on invalid arguments.
|
||||
|
||||
- Make all the number getters return `NaN` when the date or time zone is invalid.
|
||||
|
||||
- Make `tzOffset` return `NaN` when the date or the time zone is invalid.
|
||||
|
||||
## v1.0.1 - 2024-09-13
|
||||
|
||||
Initial version
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
9
node_modules/@date-fns/tz/LICENSE.md
generated
vendored
Normal file
9
node_modules/@date-fns/tz/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright © 2024 Sasha Koss
|
||||
|
||||
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.
|
||||
287
node_modules/@date-fns/tz/README.md
generated
vendored
Normal file
287
node_modules/@date-fns/tz/README.md
generated
vendored
Normal file
@@ -0,0 +1,287 @@
|
||||
# @date-fns/tz
|
||||
|
||||
The package provides `Date` extensions `TZDate` and `TZDateMini` that perform all calculations in the given time zone rather than the system time zone.
|
||||
|
||||
Using it makes [date-fns](https://github.com/date-fns/date-fns) operate in given time zone but can also be used without it.
|
||||
|
||||
Like everything else in the date-fns ecosystem, the library is build-size aware. The smallest component, `TZDateMini,` is only `916 B`.
|
||||
|
||||
**Need only UTC?** See [@date-fns/utc](https://github.com/date-fns/utc) that provides lighter solution.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @date-fns/tz --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`TZDate` and `TZDateMini` have API similar to `Date`, but perform all calculations in the given time zone, which might be essential when operating across different time zones, calculating dates for users in different regions, or rendering chart or calendar component:
|
||||
|
||||
```ts
|
||||
import { TZDate } from "@date-fns/tz";
|
||||
import { addHours } from "date-fns";
|
||||
|
||||
// Given that the system time zone is America/Los_Angeles
|
||||
// where DST happens at Sunday, 13 March 2022, 02:00:00
|
||||
|
||||
// Using system time zone will produce 03:00 instead of 02:00 because of DST:
|
||||
const date = new Date(2022, 2, 13);
|
||||
addHours(date, 2).toString();
|
||||
//=> 'Sun Mar 13 2022 03:00:00 GMT-0700 (Pacific Daylight Time)'
|
||||
|
||||
// Using Asia/Singapore will provide expected 02:00:
|
||||
const tzDate = new TZDate(2022, 2, 13, "Asia/Singapore");
|
||||
addHours(tzDate, 2).toString();
|
||||
//=> 'Sun Mar 13 2022 02:00:00 GMT+0800 (Singapore Standard Time)'
|
||||
```
|
||||
|
||||
### Accepted time zone formats
|
||||
|
||||
You can pass IANA time zone name ("Asia/Singapore", "America/New_York", etc.) or UTC offset ("+01:00", "-2359", or "+23"):
|
||||
|
||||
```ts
|
||||
new TZDate(2022, 2, 13, "Asia/Singapore");
|
||||
|
||||
new TZDate(2022, 2, 13, "+08:00");
|
||||
|
||||
new TZDate(2022, 2, 13, "-2359");
|
||||
```
|
||||
|
||||
### Difference between `TZDate` and `TZDateMini`
|
||||
|
||||
The main difference between `TZDate` and `TZDateMini` is the build footprint. The `TZDateMini` is `916 B`, and the `TZDate` is `1.2 kB`. While the difference is slight it might be essential in some environments and use cases.
|
||||
|
||||
Unlike `TZDateMini` which implements only getters, setters, and `getTimezoneOffset`, `TZDate` also provides formatter functions, mirroring all original `Date` functionality:
|
||||
|
||||
```ts
|
||||
import { TZDateMini, TZDate } from "@date-fns/tz";
|
||||
|
||||
// TZDateMini will format date-time in the system time zone:
|
||||
new TZDateMini(2022, 2, 13).toString();
|
||||
//=> 'Sat Mar 12 2022 16:00:00 GMT-0800 (Pacific Standard Time)'
|
||||
|
||||
// TZDate will format date-time in the Singapore time zone, like expected:
|
||||
new TZDate(2022, 2, 13).toString();
|
||||
//=> 'Sun Mar 13 2022 00:00:00 GMT+0800 (Singapore Standard Time)'
|
||||
```
|
||||
|
||||
Even though `TZDate` has a complete API, developers rarely use the formatter functions outside of debugging, so we recommend you pick the more lightweight `TZDateMini` for internal use. However, in environments you don't control, i.e., when you expose the date from a library, using `TZDate` will be a safer choice.
|
||||
|
||||
### React Native / Hermes JS Engine
|
||||
|
||||
Starting with [v1.3.0](https://github.com/date-fns/tz/releases/tag/v1.3.0), `@date-fns/tz` supports [Format.JS polyfills](https://formatjs.github.io/docs/polyfills/intl-datetimeformat/) that are required for [Hermes JS Engine](https://github.com/facebook/hermes/blob/main/README.md) powering React Native runtime to work correctly.
|
||||
|
||||
To use it, you need to import the following polyfills in your entry point:
|
||||
|
||||
```ts
|
||||
import "@formatjs/intl-getcanonicallocales/polyfill";
|
||||
import "@formatjs/intl-locale/polyfill";
|
||||
import "@formatjs/intl-pluralrules/polyfill";
|
||||
import "@formatjs/intl-numberformat/polyfill";
|
||||
import "@formatjs/intl-numberformat/locale-data/en";
|
||||
import "@formatjs/intl-datetimeformat/polyfill";
|
||||
import "@formatjs/intl-datetimeformat/locale-data/en";
|
||||
import "@formatjs/intl-datetimeformat/add-golden-tz"; // or: "@formatjs/intl-datetimeformat/add-all-tz"
|
||||
```
|
||||
|
||||
[The JavaScriptCore engine](https://github.com/apple-opensource/JavaScriptCore) is also supported and tested but does not require any polyfills.
|
||||
|
||||
## API
|
||||
|
||||
- [`TZDate`](#tzdate)
|
||||
- [`tz`](#tz)
|
||||
- [`tzOffset`](#tzoffset)
|
||||
- [`tzScan`](#tzscan)
|
||||
|
||||
### `TZDate`
|
||||
|
||||
All the `TZDate` docs are also true for `TZDateMini`.
|
||||
|
||||
#### Constructor
|
||||
|
||||
When creating `TZDate`, you can pass the time zone as the last argument:
|
||||
|
||||
```ts
|
||||
new TZDate(2022, 2, "Asia/Singapore");
|
||||
|
||||
new TZDate(timestamp, "Asia/Singapore");
|
||||
|
||||
new TZDate("2024-09-12T00:00:00Z", "Asia/Singapore");
|
||||
```
|
||||
|
||||
The constructor mirrors the original `Date` parameters except for the last time zone parameter.
|
||||
|
||||
#### `TZDate.tz`
|
||||
|
||||
The static `tz` function allows to construct `TZDate` instance with just a time zone:
|
||||
|
||||
```ts
|
||||
// Create now in Singapore time zone:
|
||||
TZDate.tz("Asia/Singapore");
|
||||
|
||||
// ❌ This will not work, as TZDate expects a date string:
|
||||
new TZDate("Asia/Singapore");
|
||||
//=> Invalid Date
|
||||
```
|
||||
|
||||
Just like the constructor, the function accepts all parameters variants:
|
||||
|
||||
```ts
|
||||
TZDate.tz("Asia/Singapore", 2022, 2);
|
||||
|
||||
TZDate.tz("Asia/Singapore", timestamp);
|
||||
|
||||
TZDate.tz("Asia/Singapore", "2024-09-12T00:00:00Z");
|
||||
```
|
||||
|
||||
#### `timeZone`
|
||||
|
||||
The readonly `timeZone` property returns the time zone name assigned to the instance:
|
||||
|
||||
```ts
|
||||
new TZDate(2022, 2, 13, "Asia/Singapore").timeZone;
|
||||
// "Asia/Singapore"
|
||||
```
|
||||
|
||||
The property might be `undefined` when created without a time zone:
|
||||
|
||||
```ts
|
||||
new TZDate().timeZone;
|
||||
// undefined
|
||||
```
|
||||
|
||||
#### `withTimeZone`
|
||||
|
||||
The `withTimeZone` method allows to create a new `TZDate` instance with a different time zone:
|
||||
|
||||
```ts
|
||||
const sg = new TZDate(2022, 2, 13, "Asia/Singapore");
|
||||
const ny = sg.withTimeZone("America/New_York");
|
||||
|
||||
sg.toString();
|
||||
//=> 'Sun Mar 13 2022 00:00:00 GMT+0800 (Singapore Standard Time)'
|
||||
|
||||
ny.toString();
|
||||
//=> 'Sat Mar 12 2022 11:00:00 GMT-0500 (Eastern Standard Time)'
|
||||
```
|
||||
|
||||
#### `[Symbol.for("constructDateFrom")]`
|
||||
|
||||
The `TZDate` instance also exposes a method to construct a `Date` instance in the same time zone:
|
||||
|
||||
```ts
|
||||
const sg = TZDate.tz("Asia/Singapore");
|
||||
|
||||
// Given that the system time zone is America/Los_Angeles
|
||||
|
||||
const date = sg[Symbol.for("constructDateFrom")](new Date(2024, 0, 1));
|
||||
|
||||
date.toString();
|
||||
//=> 'Mon Jan 01 2024 16:00:00 GMT+0800 (Singapore Standard Time)'
|
||||
```
|
||||
|
||||
It's created for date-fns but can be used in any context. You can access it via `Symbol.for("constructDateFrom")` or import it from the package:
|
||||
|
||||
```ts
|
||||
import { constructFromSymbol } from "@date-fns/tz";
|
||||
```
|
||||
|
||||
### `tz`
|
||||
|
||||
The `tz` function allows to specify the context for the [date-fns] functions (**starting from date-fns@4**):
|
||||
|
||||
```ts
|
||||
import { isSameDay } from "date-fns";
|
||||
import { tz } from "@date-fns/tz";
|
||||
|
||||
isSameDay("2024-09-09T23:00:00-04:00", "2024-09-10T10:00:00+08:00", {
|
||||
in: tz("Europe/Prague"),
|
||||
});
|
||||
//=> true
|
||||
```
|
||||
|
||||
### `tzOffset`
|
||||
|
||||
The `tzOffset` function allows to get the time zone UTC offset in minutes from the given time zone and a date:
|
||||
|
||||
```ts
|
||||
import { tzOffset } from "@date-fns/tz";
|
||||
|
||||
const date = new Date("2020-01-15T00:00:00Z");
|
||||
|
||||
tzOffset("Asia/Singapore", date);
|
||||
//=> 480
|
||||
|
||||
tzOffset("America/New_York", date);
|
||||
//=> -300
|
||||
|
||||
// Summer time:
|
||||
tzOffset("America/New_York", "2020-01-15T00:00:00Z");
|
||||
//=> -240
|
||||
```
|
||||
|
||||
Unlike `Date.prototype.getTimezoneOffset`, this function returns the value mirrored to the sign of the offset in the time zone. For Asia/Singapore (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.
|
||||
|
||||
### `tzScan`
|
||||
|
||||
The function scans the time zone for changes in the given interval. It returns an array of objects with the date of the change, the offset change, and the new offset:
|
||||
|
||||
```ts
|
||||
import { tzScan } from "@date-fns/tz";
|
||||
|
||||
tzScan("America/New_York", {
|
||||
start: new Date("2020-01-01T00:00:00Z"),
|
||||
end: new Date("2024-01-01T00:00:00Z"),
|
||||
});
|
||||
//=> [
|
||||
//=> { date: 2020-03-08T07:00:00.000Z, change: 60, offset: -240 },
|
||||
//=> { date: 2020-11-01T06:00:00.000Z, change: -60, offset: -300 },
|
||||
//=> { date: 2021-03-14T07:00:00.000Z, change: 60, offset: -240 },
|
||||
//=> { date: 2021-11-07T06:00:00.000Z, change: -60, offset: -300 },
|
||||
//=> { date: 2022-03-13T07:00:00.000Z, change: 60, offset: -240 },
|
||||
//=> { date: 2022-11-06T06:00:00.000Z, change: -60, offset: -300 },
|
||||
//=> { date: 2023-03-12T07:00:00.000Z, change: 60, offset: -240 },
|
||||
//=> { date: 2023-11-05T06:00:00.000Z, change: -60, offset: -300 }
|
||||
//=> ]
|
||||
```
|
||||
|
||||
### `tzName`
|
||||
|
||||
The function returns time zone name in human-readable format, e.g. `"Singapore Standard Time"` in the give date and time.
|
||||
|
||||
```ts
|
||||
import { tzName } from "@date-fns/tz";
|
||||
|
||||
tzName("Asia/Singapore", new Date("2020-01-01T00:00:00Z"));
|
||||
//=> "Singapore Standard Time"
|
||||
```
|
||||
|
||||
It is possible to specify the format as the third argument using one of the following options:
|
||||
|
||||
- `"short"`e.g., `"EDT"` or "GMT+8"`.
|
||||
- `"long"`: e.g., `"Eastern Daylight Time"` or `"Singapore Standard Time"`.
|
||||
- `"shortGeneric"`: e.g., `"ET"` or `"Singapore Time"`.
|
||||
- `"longGeneric"`: e.g., `"Eastern Time"` or `"Singapore Standard Time"`.
|
||||
|
||||
These options correspond to [TR35 tokens](https://www.unicode.org/reports/tr35/tr35-dates.html#dfst-zone) `z..zzz`, `zzzz`, `v`, and `vvvv` respectively.
|
||||
|
||||
```ts
|
||||
import { tzName } from "@date-fns/tz";
|
||||
|
||||
const date = new Date("2020-01-01T00:00:00.000Z");
|
||||
|
||||
tzName("America/New_York", date, "short");
|
||||
//=> "EST"
|
||||
|
||||
tzName("America/New_York", date, "shortGeneric");
|
||||
//=> "ET"
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
See [the changelog](./CHANGELOG.md).
|
||||
|
||||
## License
|
||||
|
||||
[MIT © Sasha Koss](https://kossnocorp.mit-license.org/)
|
||||
8
node_modules/@date-fns/tz/constants/index.cjs
generated
vendored
Normal file
8
node_modules/@date-fns/tz/constants/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
exports.constructFromSymbol = void 0;
|
||||
/**
|
||||
* The symbol to access the `TZDate`'s function to construct a new instance from
|
||||
* the provided value. It helps date-fns to inherit the time zone.
|
||||
*/
|
||||
const constructFromSymbol = exports.constructFromSymbol = Symbol.for("constructDateFrom");
|
||||
6
node_modules/@date-fns/tz/constants/index.d.cts
generated
vendored
Normal file
6
node_modules/@date-fns/tz/constants/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* The symbol to access the `TZDate`'s function to construct a new instance from
|
||||
* the provided value. It helps date-fns to inherit the time zone.
|
||||
*/
|
||||
export declare const constructFromSymbol: unique symbol;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
6
node_modules/@date-fns/tz/constants/index.d.ts
generated
vendored
Normal file
6
node_modules/@date-fns/tz/constants/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* The symbol to access the `TZDate`'s function to construct a new instance from
|
||||
* the provided value. It helps date-fns to inherit the time zone.
|
||||
*/
|
||||
export declare const constructFromSymbol: unique symbol;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@date-fns/tz/constants/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@date-fns/tz/constants/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,mBAAmB,eAAkC,CAAC"}
|
||||
5
node_modules/@date-fns/tz/constants/index.js
generated
vendored
Normal file
5
node_modules/@date-fns/tz/constants/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* The symbol to access the `TZDate`'s function to construct a new instance from
|
||||
* the provided value. It helps date-fns to inherit the time zone.
|
||||
*/
|
||||
export const constructFromSymbol = Symbol.for("constructDateFrom");
|
||||
84
node_modules/@date-fns/tz/date/index.cjs
generated
vendored
Normal file
84
node_modules/@date-fns/tz/date/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
|
||||
exports.TZDate = void 0;
|
||||
var _index = require("../tzName/index.cjs");
|
||||
var _mini = require("./mini.cjs");
|
||||
class TZDate extends _mini.TZDateMini {
|
||||
//#region static
|
||||
|
||||
static tz(tz, ...args) {
|
||||
return args.length ? new TZDate(...args, tz) : new TZDate(Date.now(), tz);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region representation
|
||||
|
||||
toISOString() {
|
||||
const [sign, hours, minutes] = this.tzComponents();
|
||||
const tz = `${sign}${hours}:${minutes}`;
|
||||
return this.internal.toISOString().slice(0, -1) + tz;
|
||||
}
|
||||
toString() {
|
||||
// "Tue Aug 13 2024 07:50:19 GMT+0800 (Singapore Standard Time)";
|
||||
return `${this.toDateString()} ${this.toTimeString()}`;
|
||||
}
|
||||
toDateString() {
|
||||
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
||||
const [day, date, month, year] = this.internal.toUTCString().split(" ");
|
||||
// "Tue Aug 13 2024"
|
||||
return `${day?.slice(0, -1) /* Remove "," */} ${month} ${date} ${year}`;
|
||||
}
|
||||
toTimeString() {
|
||||
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
||||
const time = this.internal.toUTCString().split(" ")[4];
|
||||
const [sign, hours, minutes] = this.tzComponents();
|
||||
// "07:42:23 GMT+0800 (Singapore Standard Time)"
|
||||
return `${time} GMT${sign}${hours}${minutes} (${(0, _index.tzName)(this.timeZone, this)})`;
|
||||
}
|
||||
toLocaleString(locales, options) {
|
||||
return Date.prototype.toLocaleString.call(this, locales, {
|
||||
...options,
|
||||
timeZone: options?.timeZone || this.timeZone
|
||||
});
|
||||
}
|
||||
toLocaleDateString(locales, options) {
|
||||
return Date.prototype.toLocaleDateString.call(this, locales, {
|
||||
...options,
|
||||
timeZone: options?.timeZone || this.timeZone
|
||||
});
|
||||
}
|
||||
toLocaleTimeString(locales, options) {
|
||||
return Date.prototype.toLocaleTimeString.call(this, locales, {
|
||||
...options,
|
||||
timeZone: options?.timeZone || this.timeZone
|
||||
});
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region private
|
||||
|
||||
tzComponents() {
|
||||
const offset = this.getTimezoneOffset();
|
||||
const sign = offset > 0 ? "-" : "+";
|
||||
const hours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0");
|
||||
const minutes = String(Math.abs(offset) % 60).padStart(2, "0");
|
||||
return [sign, hours, minutes];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
withTimeZone(timeZone) {
|
||||
return new TZDate(+this, timeZone);
|
||||
}
|
||||
|
||||
//#region date-fns integration
|
||||
|
||||
[Symbol.for("constructDateFrom")](date) {
|
||||
return new TZDate(+new Date(date), this.timeZone);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
exports.TZDate = TZDate;
|
||||
308
node_modules/@date-fns/tz/date/index.d.cts
generated
vendored
Normal file
308
node_modules/@date-fns/tz/date/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,308 @@
|
||||
import { constructFromSymbol } from "../constants/index.cts";
|
||||
|
||||
/**
|
||||
* Time zone date class. It overrides original Date functions making them
|
||||
* to perform all the calculations in the given time zone.
|
||||
*
|
||||
* It also provides new functions useful when working with time zones.
|
||||
*
|
||||
* Combined with date-fns, it allows using the class the same way as
|
||||
* the original date class.
|
||||
*
|
||||
* This complete version provides formatter functions, mirroring all original
|
||||
* methods of the `Date` class. It's build-size-heavier than `TZDateMini` and
|
||||
* should be used when you need to format a string or in an environment you
|
||||
* don't fully control (a library).
|
||||
*
|
||||
* For the minimal version, see `TZDateMini`.
|
||||
*/
|
||||
export class TZDate extends Date {
|
||||
/**
|
||||
* Constructs a new `TZDate` instance in the system time zone.
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the date time string and time zone.
|
||||
*
|
||||
* @param dateStr - Date time string to create a new instance from
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(dateStr: string, timeZone?: string);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the date object and time zone.
|
||||
*
|
||||
* @param date - Date object to create a new instance from
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(date: Date, timeZone?: string);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the Unix timestamp in milliseconds
|
||||
* and time zone.
|
||||
*
|
||||
* @param timestamp - Unix timestamp in milliseconds to create a new instance from
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(timestamp: number, timeZone?: string);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(year: number, month: number, timeZone?: string);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, date and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(year: number, month: number, date: number, timeZone?: string);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, date, hours
|
||||
* and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
timeZone?: string,
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, date, hours,
|
||||
* minutes and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
timeZone?: string,
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, date, hours,
|
||||
* minutes, seconds and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
* @param seconds - Seconds
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
seconds: number,
|
||||
timeZone?: string,
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, date, hours,
|
||||
* minutes, seconds, milliseconds and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
* @param seconds - Seconds
|
||||
* @param milliseconds - Milliseconds
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
seconds: number,
|
||||
milliseconds: number,
|
||||
timeZone?: string,
|
||||
);
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
static tz(tz: string): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the Unix
|
||||
* timestamp in milliseconds.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param timestamp - Unix timestamp in milliseconds
|
||||
*/
|
||||
static tz(tz: string, timestamp: number): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the date time
|
||||
* string.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param dateStr - Date time string
|
||||
*/
|
||||
static tz(tz: string, dateStr: string): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the date object.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param date - Date object
|
||||
*/
|
||||
static tz(tz: string, date: Date): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year
|
||||
* and month.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
*/
|
||||
static tz(tz: string, year: number, month: number): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year,
|
||||
* month and date.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
*/
|
||||
static tz(tz: string, year: number, month: number, date: number): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year,
|
||||
* month, date and hours.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
*/
|
||||
static tz(
|
||||
tz: string,
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year,
|
||||
* month, date, hours and minutes.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
*/
|
||||
static tz(
|
||||
tz: string,
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year,
|
||||
* month, date, hours, minutes and seconds.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
* @param seconds - Seconds
|
||||
*/
|
||||
static tz(
|
||||
tz: string,
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
seconds: number,
|
||||
): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year,
|
||||
* month, date, hours, minutes, seconds and milliseconds.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
* @param seconds - Seconds
|
||||
* @param milliseconds - Milliseconds
|
||||
*/
|
||||
static tz(
|
||||
tz: string,
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
seconds: number,
|
||||
milliseconds: number,
|
||||
): TZDate;
|
||||
|
||||
/**
|
||||
* The current time zone of the date.
|
||||
*/
|
||||
readonly timeZone: string | undefined;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone.
|
||||
*/
|
||||
withTimeZone(timeZone: string): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the current instance time zone and
|
||||
* the specified date time value.
|
||||
*
|
||||
* @param date - Date value to create a new instance from
|
||||
*/
|
||||
[constructFromSymbol](date: Date | number | string): TZDate;
|
||||
}
|
||||
308
node_modules/@date-fns/tz/date/index.d.ts
generated
vendored
Normal file
308
node_modules/@date-fns/tz/date/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,308 @@
|
||||
import { constructFromSymbol } from "../constants/index.ts";
|
||||
|
||||
/**
|
||||
* Time zone date class. It overrides original Date functions making them
|
||||
* to perform all the calculations in the given time zone.
|
||||
*
|
||||
* It also provides new functions useful when working with time zones.
|
||||
*
|
||||
* Combined with date-fns, it allows using the class the same way as
|
||||
* the original date class.
|
||||
*
|
||||
* This complete version provides formatter functions, mirroring all original
|
||||
* methods of the `Date` class. It's build-size-heavier than `TZDateMini` and
|
||||
* should be used when you need to format a string or in an environment you
|
||||
* don't fully control (a library).
|
||||
*
|
||||
* For the minimal version, see `TZDateMini`.
|
||||
*/
|
||||
export class TZDate extends Date {
|
||||
/**
|
||||
* Constructs a new `TZDate` instance in the system time zone.
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the date time string and time zone.
|
||||
*
|
||||
* @param dateStr - Date time string to create a new instance from
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(dateStr: string, timeZone?: string);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the date object and time zone.
|
||||
*
|
||||
* @param date - Date object to create a new instance from
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(date: Date, timeZone?: string);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the Unix timestamp in milliseconds
|
||||
* and time zone.
|
||||
*
|
||||
* @param timestamp - Unix timestamp in milliseconds to create a new instance from
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(timestamp: number, timeZone?: string);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(year: number, month: number, timeZone?: string);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, date and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(year: number, month: number, date: number, timeZone?: string);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, date, hours
|
||||
* and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
timeZone?: string,
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, date, hours,
|
||||
* minutes and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
timeZone?: string,
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, date, hours,
|
||||
* minutes, seconds and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
* @param seconds - Seconds
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
seconds: number,
|
||||
timeZone?: string,
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructs a new `TZDate` instance from the year, month, date, hours,
|
||||
* minutes, seconds, milliseconds and time zone.
|
||||
*
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
* @param seconds - Seconds
|
||||
* @param milliseconds - Milliseconds
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
constructor(
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
seconds: number,
|
||||
milliseconds: number,
|
||||
timeZone?: string,
|
||||
);
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
*/
|
||||
static tz(tz: string): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the Unix
|
||||
* timestamp in milliseconds.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param timestamp - Unix timestamp in milliseconds
|
||||
*/
|
||||
static tz(tz: string, timestamp: number): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the date time
|
||||
* string.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param dateStr - Date time string
|
||||
*/
|
||||
static tz(tz: string, dateStr: string): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the date object.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param date - Date object
|
||||
*/
|
||||
static tz(tz: string, date: Date): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year
|
||||
* and month.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
*/
|
||||
static tz(tz: string, year: number, month: number): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year,
|
||||
* month and date.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
*/
|
||||
static tz(tz: string, year: number, month: number, date: number): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year,
|
||||
* month, date and hours.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
*/
|
||||
static tz(
|
||||
tz: string,
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year,
|
||||
* month, date, hours and minutes.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
*/
|
||||
static tz(
|
||||
tz: string,
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year,
|
||||
* month, date, hours, minutes and seconds.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
* @param seconds - Seconds
|
||||
*/
|
||||
static tz(
|
||||
tz: string,
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
seconds: number,
|
||||
): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone from the year,
|
||||
* month, date, hours, minutes, seconds and milliseconds.
|
||||
*
|
||||
* @param tz - Time zone name (IANA or UTC offset)
|
||||
* @param year - Year
|
||||
* @param month - Month (0-11)
|
||||
* @param date - Date
|
||||
* @param hours - Hours
|
||||
* @param minutes - Minutes
|
||||
* @param seconds - Seconds
|
||||
* @param milliseconds - Milliseconds
|
||||
*/
|
||||
static tz(
|
||||
tz: string,
|
||||
year: number,
|
||||
month: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
seconds: number,
|
||||
milliseconds: number,
|
||||
): TZDate;
|
||||
|
||||
/**
|
||||
* The current time zone of the date.
|
||||
*/
|
||||
readonly timeZone: string | undefined;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the given time zone.
|
||||
*/
|
||||
withTimeZone(timeZone: string): TZDate;
|
||||
|
||||
/**
|
||||
* Creates a new `TZDate` instance in the current instance time zone and
|
||||
* the specified date time value.
|
||||
*
|
||||
* @param date - Date value to create a new instance from
|
||||
*/
|
||||
[constructFromSymbol](date: Date | number | string): TZDate;
|
||||
}
|
||||
80
node_modules/@date-fns/tz/date/index.js
generated
vendored
Normal file
80
node_modules/@date-fns/tz/date/index.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
import { tzName } from "../tzName/index.js";
|
||||
import { TZDateMini } from "./mini.js";
|
||||
export class TZDate extends TZDateMini {
|
||||
//#region static
|
||||
|
||||
static tz(tz, ...args) {
|
||||
return args.length ? new TZDate(...args, tz) : new TZDate(Date.now(), tz);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region representation
|
||||
|
||||
toISOString() {
|
||||
const [sign, hours, minutes] = this.tzComponents();
|
||||
const tz = `${sign}${hours}:${minutes}`;
|
||||
return this.internal.toISOString().slice(0, -1) + tz;
|
||||
}
|
||||
toString() {
|
||||
// "Tue Aug 13 2024 07:50:19 GMT+0800 (Singapore Standard Time)";
|
||||
return `${this.toDateString()} ${this.toTimeString()}`;
|
||||
}
|
||||
toDateString() {
|
||||
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
||||
const [day, date, month, year] = this.internal.toUTCString().split(" ");
|
||||
// "Tue Aug 13 2024"
|
||||
return `${day?.slice(0, -1) /* Remove "," */} ${month} ${date} ${year}`;
|
||||
}
|
||||
toTimeString() {
|
||||
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
||||
const time = this.internal.toUTCString().split(" ")[4];
|
||||
const [sign, hours, minutes] = this.tzComponents();
|
||||
// "07:42:23 GMT+0800 (Singapore Standard Time)"
|
||||
return `${time} GMT${sign}${hours}${minutes} (${tzName(this.timeZone, this)})`;
|
||||
}
|
||||
toLocaleString(locales, options) {
|
||||
return Date.prototype.toLocaleString.call(this, locales, {
|
||||
...options,
|
||||
timeZone: options?.timeZone || this.timeZone
|
||||
});
|
||||
}
|
||||
toLocaleDateString(locales, options) {
|
||||
return Date.prototype.toLocaleDateString.call(this, locales, {
|
||||
...options,
|
||||
timeZone: options?.timeZone || this.timeZone
|
||||
});
|
||||
}
|
||||
toLocaleTimeString(locales, options) {
|
||||
return Date.prototype.toLocaleTimeString.call(this, locales, {
|
||||
...options,
|
||||
timeZone: options?.timeZone || this.timeZone
|
||||
});
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region private
|
||||
|
||||
tzComponents() {
|
||||
const offset = this.getTimezoneOffset();
|
||||
const sign = offset > 0 ? "-" : "+";
|
||||
const hours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0");
|
||||
const minutes = String(Math.abs(offset) % 60).padStart(2, "0");
|
||||
return [sign, hours, minutes];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
withTimeZone(timeZone) {
|
||||
return new TZDate(+this, timeZone);
|
||||
}
|
||||
|
||||
//#region date-fns integration
|
||||
|
||||
[Symbol.for("constructDateFrom")](date) {
|
||||
return new TZDate(+new Date(date), this.timeZone);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
236
node_modules/@date-fns/tz/date/mini.cjs
generated
vendored
Normal file
236
node_modules/@date-fns/tz/date/mini.cjs
generated
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
"use strict";
|
||||
|
||||
exports.TZDateMini = void 0;
|
||||
var _index = require("../tzOffset/index.cjs");
|
||||
class TZDateMini extends Date {
|
||||
//#region static
|
||||
|
||||
constructor(...args) {
|
||||
super();
|
||||
if (args.length > 1 && typeof args[args.length - 1] === "string") {
|
||||
this.timeZone = args.pop();
|
||||
}
|
||||
this.internal = new Date();
|
||||
if (isNaN((0, _index.tzOffset)(this.timeZone, this))) {
|
||||
this.setTime(NaN);
|
||||
} else {
|
||||
if (!args.length) {
|
||||
this.setTime(Date.now());
|
||||
} else if (typeof args[0] === "number" && (args.length === 1 || args.length === 2 && typeof args[1] !== "number")) {
|
||||
this.setTime(args[0]);
|
||||
} else if (typeof args[0] === "string") {
|
||||
this.setTime(+new Date(args[0]));
|
||||
} else if (args[0] instanceof Date) {
|
||||
this.setTime(+args[0]);
|
||||
} else {
|
||||
this.setTime(+new Date(...args));
|
||||
adjustToSystemTZ(this, NaN);
|
||||
syncToInternal(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
static tz(tz, ...args) {
|
||||
return args.length ? new TZDateMini(...args, tz) : new TZDateMini(Date.now(), tz);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region time zone
|
||||
|
||||
withTimeZone(timeZone) {
|
||||
return new TZDateMini(+this, timeZone);
|
||||
}
|
||||
getTimezoneOffset() {
|
||||
const offset = -(0, _index.tzOffset)(this.timeZone, this);
|
||||
// Remove the seconds offset
|
||||
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
||||
return offset > 0 ? Math.floor(offset) : Math.ceil(offset);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region time
|
||||
|
||||
setTime(time) {
|
||||
Date.prototype.setTime.apply(this, arguments);
|
||||
syncToInternal(this);
|
||||
return +this;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region date-fns integration
|
||||
|
||||
[Symbol.for("constructDateFrom")](date) {
|
||||
return new TZDateMini(+new Date(date), this.timeZone);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
||||
// Assign getters and setters
|
||||
exports.TZDateMini = TZDateMini;
|
||||
const re = /^(get|set)(?!UTC)/;
|
||||
Object.getOwnPropertyNames(Date.prototype).forEach(method => {
|
||||
if (!re.test(method)) return;
|
||||
const utcMethod = method.replace(re, "$1UTC");
|
||||
// Filter out methods without UTC counterparts
|
||||
if (!TZDateMini.prototype[utcMethod]) return;
|
||||
if (method.startsWith("get")) {
|
||||
// Delegate to internal date's UTC method
|
||||
TZDateMini.prototype[method] = function () {
|
||||
return this.internal[utcMethod]();
|
||||
};
|
||||
} else {
|
||||
// Assign regular setter
|
||||
TZDateMini.prototype[method] = function () {
|
||||
Date.prototype[utcMethod].apply(this.internal, arguments);
|
||||
syncFromInternal(this);
|
||||
return +this;
|
||||
};
|
||||
|
||||
// Assign UTC setter
|
||||
TZDateMini.prototype[utcMethod] = function () {
|
||||
Date.prototype[utcMethod].apply(this, arguments);
|
||||
syncToInternal(this);
|
||||
return +this;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Function syncs time to internal date, applying the time zone offset.
|
||||
*
|
||||
* @param {Date} date - Date to sync
|
||||
*/
|
||||
function syncToInternal(date) {
|
||||
date.internal.setTime(+date);
|
||||
date.internal.setUTCSeconds(date.internal.getUTCSeconds() - Math.round(-(0, _index.tzOffset)(date.timeZone, date) * 60));
|
||||
}
|
||||
|
||||
/**
|
||||
* Function syncs the internal date UTC values to the date. It allows to get
|
||||
* accurate timestamp value.
|
||||
*
|
||||
* @param {Date} date - The date to sync
|
||||
*/
|
||||
function syncFromInternal(date) {
|
||||
// First we transpose the internal values
|
||||
Date.prototype.setFullYear.call(date, date.internal.getUTCFullYear(), date.internal.getUTCMonth(), date.internal.getUTCDate());
|
||||
Date.prototype.setHours.call(date, date.internal.getUTCHours(), date.internal.getUTCMinutes(), date.internal.getUTCSeconds(), date.internal.getUTCMilliseconds());
|
||||
|
||||
// Now we have to adjust the date to the system time zone
|
||||
adjustToSystemTZ(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function adjusts the date to the system time zone. It uses the time zone
|
||||
* differences to calculate the offset and adjust the date.
|
||||
*
|
||||
* @param {Date} date - Date to adjust
|
||||
*/
|
||||
function adjustToSystemTZ(date) {
|
||||
// Save the time zone offset before all the adjustments
|
||||
const baseOffset = (0, _index.tzOffset)(date.timeZone, date);
|
||||
// Remove the seconds offset
|
||||
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
||||
const offset = baseOffset > 0 ? Math.floor(baseOffset) : Math.ceil(baseOffset);
|
||||
//#region System DST adjustment
|
||||
|
||||
// The biggest problem with using the system time zone is that when we create
|
||||
// a date from internal values stored in UTC, the system time zone might end
|
||||
// up on the DST hour:
|
||||
//
|
||||
// $ TZ=America/New_York node
|
||||
// > new Date(2020, 2, 8, 1).toString()
|
||||
// 'Sun Mar 08 2020 01:00:00 GMT-0500 (Eastern Standard Time)'
|
||||
// > new Date(2020, 2, 8, 2).toString()
|
||||
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
||||
// > new Date(2020, 2, 8, 3).toString()
|
||||
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
||||
// > new Date(2020, 2, 8, 4).toString()
|
||||
// 'Sun Mar 08 2020 04:00:00 GMT-0400 (Eastern Daylight Time)'
|
||||
//
|
||||
// Here we get the same hour for both 2 and 3, because the system time zone
|
||||
// has DST beginning at 8 March 2020, 2 a.m. and jumps to 3 a.m. So we have
|
||||
// to adjust the internal date to reflect that.
|
||||
//
|
||||
// However we want to adjust only if that's the DST hour the change happenes,
|
||||
// not the hour where DST moves to.
|
||||
|
||||
// We calculate the previous hour to see if the time zone offset has changed
|
||||
// and we have landed on the DST hour.
|
||||
const prevHour = new Date(+date);
|
||||
// We use UTC methods here as we don't want to land on the same hour again
|
||||
// in case of DST.
|
||||
prevHour.setUTCHours(prevHour.getUTCHours() - 1);
|
||||
|
||||
// Calculate if we are on the system DST hour.
|
||||
const systemOffset = -new Date(+date).getTimezoneOffset();
|
||||
const prevHourSystemOffset = -new Date(+prevHour).getTimezoneOffset();
|
||||
const systemDSTChange = systemOffset - prevHourSystemOffset;
|
||||
// Detect the DST shift. System DST change will occur both on
|
||||
const dstShift = Date.prototype.getHours.apply(date) !== date.internal.getUTCHours();
|
||||
|
||||
// Move the internal date when we are on the system DST hour.
|
||||
if (systemDSTChange && dstShift) date.internal.setUTCMinutes(date.internal.getUTCMinutes() + systemDSTChange);
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region System diff adjustment
|
||||
|
||||
// Now we need to adjust the date, since we just applied internal values.
|
||||
// We need to calculate the difference between the system and date time zones
|
||||
// and apply it to the date.
|
||||
|
||||
const offsetDiff = systemOffset - offset;
|
||||
if (offsetDiff) Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Seconds System diff adjustment
|
||||
|
||||
const systemDate = new Date(+date);
|
||||
// Set the UTC seconds to 0 to isolate the timezone offset in seconds.
|
||||
systemDate.setUTCSeconds(0);
|
||||
// For negative systemOffset, invert the seconds.
|
||||
const systemSecondsOffset = systemOffset > 0 ? systemDate.getSeconds() : (systemDate.getSeconds() - 60) % 60;
|
||||
|
||||
// Calculate the seconds offset based on the timezone offset.
|
||||
const secondsOffset = Math.round(-((0, _index.tzOffset)(date.timeZone, date) * 60)) % 60;
|
||||
if (secondsOffset || systemSecondsOffset) {
|
||||
date.internal.setUTCSeconds(date.internal.getUTCSeconds() + secondsOffset);
|
||||
Date.prototype.setUTCSeconds.call(date, Date.prototype.getUTCSeconds.call(date) + secondsOffset + systemSecondsOffset);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Post-adjustment DST fix
|
||||
|
||||
const postBaseOffset = (0, _index.tzOffset)(date.timeZone, date);
|
||||
// Remove the seconds offset
|
||||
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
||||
const postOffset = postBaseOffset > 0 ? Math.floor(postBaseOffset) : Math.ceil(postBaseOffset);
|
||||
const postSystemOffset = -new Date(+date).getTimezoneOffset();
|
||||
const postOffsetDiff = postSystemOffset - postOffset;
|
||||
const offsetChanged = postOffset !== offset;
|
||||
const postDiff = postOffsetDiff - offsetDiff;
|
||||
if (offsetChanged && postDiff) {
|
||||
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + postDiff);
|
||||
|
||||
// Now we need to check if got offset change during the post-adjustment.
|
||||
// If so, we also need both dates to reflect that.
|
||||
|
||||
const newBaseOffset = (0, _index.tzOffset)(date.timeZone, date);
|
||||
// Remove the seconds offset
|
||||
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
||||
const newOffset = newBaseOffset > 0 ? Math.floor(newBaseOffset) : Math.ceil(newBaseOffset);
|
||||
const offsetChange = postOffset - newOffset;
|
||||
if (offsetChange) {
|
||||
date.internal.setUTCMinutes(date.internal.getUTCMinutes() + offsetChange);
|
||||
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetChange);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
17
node_modules/@date-fns/tz/date/mini.d.cts
generated
vendored
Normal file
17
node_modules/@date-fns/tz/date/mini.d.cts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { TZDate } from "./index.cjs";
|
||||
|
||||
/**
|
||||
* Time zone date class. It overrides original Date functions making them
|
||||
* to perform all the calculations in the given time zone.
|
||||
*
|
||||
* It also provides new functions useful when working with time zones.
|
||||
*
|
||||
* Combined with date-fns, it allows using the class the same way as
|
||||
* the original date class.
|
||||
*
|
||||
* This minimal version provides complete functionality required for date-fns
|
||||
* and excludes build-size-heavy formatter functions.
|
||||
*
|
||||
* For the complete version, see `TZDate`.
|
||||
*/
|
||||
export const TZDateMini: typeof TZDate;
|
||||
17
node_modules/@date-fns/tz/date/mini.d.ts
generated
vendored
Normal file
17
node_modules/@date-fns/tz/date/mini.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { TZDate } from "./index.js";
|
||||
|
||||
/**
|
||||
* Time zone date class. It overrides original Date functions making them
|
||||
* to perform all the calculations in the given time zone.
|
||||
*
|
||||
* It also provides new functions useful when working with time zones.
|
||||
*
|
||||
* Combined with date-fns, it allows using the class the same way as
|
||||
* the original date class.
|
||||
*
|
||||
* This minimal version provides complete functionality required for date-fns
|
||||
* and excludes build-size-heavy formatter functions.
|
||||
*
|
||||
* For the complete version, see `TZDate`.
|
||||
*/
|
||||
export const TZDateMini: typeof TZDate;
|
||||
232
node_modules/@date-fns/tz/date/mini.js
generated
vendored
Normal file
232
node_modules/@date-fns/tz/date/mini.js
generated
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
import { tzOffset } from "../tzOffset/index.js";
|
||||
export class TZDateMini extends Date {
|
||||
//#region static
|
||||
|
||||
constructor(...args) {
|
||||
super();
|
||||
if (args.length > 1 && typeof args[args.length - 1] === "string") {
|
||||
this.timeZone = args.pop();
|
||||
}
|
||||
this.internal = new Date();
|
||||
if (isNaN(tzOffset(this.timeZone, this))) {
|
||||
this.setTime(NaN);
|
||||
} else {
|
||||
if (!args.length) {
|
||||
this.setTime(Date.now());
|
||||
} else if (typeof args[0] === "number" && (args.length === 1 || args.length === 2 && typeof args[1] !== "number")) {
|
||||
this.setTime(args[0]);
|
||||
} else if (typeof args[0] === "string") {
|
||||
this.setTime(+new Date(args[0]));
|
||||
} else if (args[0] instanceof Date) {
|
||||
this.setTime(+args[0]);
|
||||
} else {
|
||||
this.setTime(+new Date(...args));
|
||||
adjustToSystemTZ(this, NaN);
|
||||
syncToInternal(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
static tz(tz, ...args) {
|
||||
return args.length ? new TZDateMini(...args, tz) : new TZDateMini(Date.now(), tz);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region time zone
|
||||
|
||||
withTimeZone(timeZone) {
|
||||
return new TZDateMini(+this, timeZone);
|
||||
}
|
||||
getTimezoneOffset() {
|
||||
const offset = -tzOffset(this.timeZone, this);
|
||||
// Remove the seconds offset
|
||||
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
||||
return offset > 0 ? Math.floor(offset) : Math.ceil(offset);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region time
|
||||
|
||||
setTime(time) {
|
||||
Date.prototype.setTime.apply(this, arguments);
|
||||
syncToInternal(this);
|
||||
return +this;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region date-fns integration
|
||||
|
||||
[Symbol.for("constructDateFrom")](date) {
|
||||
return new TZDateMini(+new Date(date), this.timeZone);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
||||
// Assign getters and setters
|
||||
const re = /^(get|set)(?!UTC)/;
|
||||
Object.getOwnPropertyNames(Date.prototype).forEach(method => {
|
||||
if (!re.test(method)) return;
|
||||
const utcMethod = method.replace(re, "$1UTC");
|
||||
// Filter out methods without UTC counterparts
|
||||
if (!TZDateMini.prototype[utcMethod]) return;
|
||||
if (method.startsWith("get")) {
|
||||
// Delegate to internal date's UTC method
|
||||
TZDateMini.prototype[method] = function () {
|
||||
return this.internal[utcMethod]();
|
||||
};
|
||||
} else {
|
||||
// Assign regular setter
|
||||
TZDateMini.prototype[method] = function () {
|
||||
Date.prototype[utcMethod].apply(this.internal, arguments);
|
||||
syncFromInternal(this);
|
||||
return +this;
|
||||
};
|
||||
|
||||
// Assign UTC setter
|
||||
TZDateMini.prototype[utcMethod] = function () {
|
||||
Date.prototype[utcMethod].apply(this, arguments);
|
||||
syncToInternal(this);
|
||||
return +this;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Function syncs time to internal date, applying the time zone offset.
|
||||
*
|
||||
* @param {Date} date - Date to sync
|
||||
*/
|
||||
function syncToInternal(date) {
|
||||
date.internal.setTime(+date);
|
||||
date.internal.setUTCSeconds(date.internal.getUTCSeconds() - Math.round(-tzOffset(date.timeZone, date) * 60));
|
||||
}
|
||||
|
||||
/**
|
||||
* Function syncs the internal date UTC values to the date. It allows to get
|
||||
* accurate timestamp value.
|
||||
*
|
||||
* @param {Date} date - The date to sync
|
||||
*/
|
||||
function syncFromInternal(date) {
|
||||
// First we transpose the internal values
|
||||
Date.prototype.setFullYear.call(date, date.internal.getUTCFullYear(), date.internal.getUTCMonth(), date.internal.getUTCDate());
|
||||
Date.prototype.setHours.call(date, date.internal.getUTCHours(), date.internal.getUTCMinutes(), date.internal.getUTCSeconds(), date.internal.getUTCMilliseconds());
|
||||
|
||||
// Now we have to adjust the date to the system time zone
|
||||
adjustToSystemTZ(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function adjusts the date to the system time zone. It uses the time zone
|
||||
* differences to calculate the offset and adjust the date.
|
||||
*
|
||||
* @param {Date} date - Date to adjust
|
||||
*/
|
||||
function adjustToSystemTZ(date) {
|
||||
// Save the time zone offset before all the adjustments
|
||||
const baseOffset = tzOffset(date.timeZone, date);
|
||||
// Remove the seconds offset
|
||||
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
||||
const offset = baseOffset > 0 ? Math.floor(baseOffset) : Math.ceil(baseOffset);
|
||||
//#region System DST adjustment
|
||||
|
||||
// The biggest problem with using the system time zone is that when we create
|
||||
// a date from internal values stored in UTC, the system time zone might end
|
||||
// up on the DST hour:
|
||||
//
|
||||
// $ TZ=America/New_York node
|
||||
// > new Date(2020, 2, 8, 1).toString()
|
||||
// 'Sun Mar 08 2020 01:00:00 GMT-0500 (Eastern Standard Time)'
|
||||
// > new Date(2020, 2, 8, 2).toString()
|
||||
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
||||
// > new Date(2020, 2, 8, 3).toString()
|
||||
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
||||
// > new Date(2020, 2, 8, 4).toString()
|
||||
// 'Sun Mar 08 2020 04:00:00 GMT-0400 (Eastern Daylight Time)'
|
||||
//
|
||||
// Here we get the same hour for both 2 and 3, because the system time zone
|
||||
// has DST beginning at 8 March 2020, 2 a.m. and jumps to 3 a.m. So we have
|
||||
// to adjust the internal date to reflect that.
|
||||
//
|
||||
// However we want to adjust only if that's the DST hour the change happenes,
|
||||
// not the hour where DST moves to.
|
||||
|
||||
// We calculate the previous hour to see if the time zone offset has changed
|
||||
// and we have landed on the DST hour.
|
||||
const prevHour = new Date(+date);
|
||||
// We use UTC methods here as we don't want to land on the same hour again
|
||||
// in case of DST.
|
||||
prevHour.setUTCHours(prevHour.getUTCHours() - 1);
|
||||
|
||||
// Calculate if we are on the system DST hour.
|
||||
const systemOffset = -new Date(+date).getTimezoneOffset();
|
||||
const prevHourSystemOffset = -new Date(+prevHour).getTimezoneOffset();
|
||||
const systemDSTChange = systemOffset - prevHourSystemOffset;
|
||||
// Detect the DST shift. System DST change will occur both on
|
||||
const dstShift = Date.prototype.getHours.apply(date) !== date.internal.getUTCHours();
|
||||
|
||||
// Move the internal date when we are on the system DST hour.
|
||||
if (systemDSTChange && dstShift) date.internal.setUTCMinutes(date.internal.getUTCMinutes() + systemDSTChange);
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region System diff adjustment
|
||||
|
||||
// Now we need to adjust the date, since we just applied internal values.
|
||||
// We need to calculate the difference between the system and date time zones
|
||||
// and apply it to the date.
|
||||
|
||||
const offsetDiff = systemOffset - offset;
|
||||
if (offsetDiff) Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Seconds System diff adjustment
|
||||
|
||||
const systemDate = new Date(+date);
|
||||
// Set the UTC seconds to 0 to isolate the timezone offset in seconds.
|
||||
systemDate.setUTCSeconds(0);
|
||||
// For negative systemOffset, invert the seconds.
|
||||
const systemSecondsOffset = systemOffset > 0 ? systemDate.getSeconds() : (systemDate.getSeconds() - 60) % 60;
|
||||
|
||||
// Calculate the seconds offset based on the timezone offset.
|
||||
const secondsOffset = Math.round(-(tzOffset(date.timeZone, date) * 60)) % 60;
|
||||
if (secondsOffset || systemSecondsOffset) {
|
||||
date.internal.setUTCSeconds(date.internal.getUTCSeconds() + secondsOffset);
|
||||
Date.prototype.setUTCSeconds.call(date, Date.prototype.getUTCSeconds.call(date) + secondsOffset + systemSecondsOffset);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Post-adjustment DST fix
|
||||
|
||||
const postBaseOffset = tzOffset(date.timeZone, date);
|
||||
// Remove the seconds offset
|
||||
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
||||
const postOffset = postBaseOffset > 0 ? Math.floor(postBaseOffset) : Math.ceil(postBaseOffset);
|
||||
const postSystemOffset = -new Date(+date).getTimezoneOffset();
|
||||
const postOffsetDiff = postSystemOffset - postOffset;
|
||||
const offsetChanged = postOffset !== offset;
|
||||
const postDiff = postOffsetDiff - offsetDiff;
|
||||
if (offsetChanged && postDiff) {
|
||||
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + postDiff);
|
||||
|
||||
// Now we need to check if got offset change during the post-adjustment.
|
||||
// If so, we also need both dates to reflect that.
|
||||
|
||||
const newBaseOffset = tzOffset(date.timeZone, date);
|
||||
// Remove the seconds offset
|
||||
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
||||
const newOffset = newBaseOffset > 0 ? Math.floor(newBaseOffset) : Math.ceil(newBaseOffset);
|
||||
const offsetChange = postOffset - newOffset;
|
||||
if (offsetChange) {
|
||||
date.internal.setUTCMinutes(date.internal.getUTCMinutes() + offsetChange);
|
||||
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetChange);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
79
node_modules/@date-fns/tz/index.cjs
generated
vendored
Normal file
79
node_modules/@date-fns/tz/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
|
||||
var _index = require("./constants/index.cjs");
|
||||
Object.keys(_index).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _index[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _index2 = require("./date/index.cjs");
|
||||
Object.keys(_index2).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _index2[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index2[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _mini = require("./date/mini.cjs");
|
||||
Object.keys(_mini).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _mini[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _mini[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _index3 = require("./tz/index.cjs");
|
||||
Object.keys(_index3).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _index3[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index3[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _index4 = require("./tzOffset/index.cjs");
|
||||
Object.keys(_index4).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _index4[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index4[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _index5 = require("./tzScan/index.cjs");
|
||||
Object.keys(_index5).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _index5[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index5[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _index6 = require("./tzName/index.cjs");
|
||||
Object.keys(_index6).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _index6[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index6[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
8
node_modules/@date-fns/tz/index.d.cts
generated
vendored
Normal file
8
node_modules/@date-fns/tz/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export * from "./constants/index.cts";
|
||||
export * from "./date/index.cjs";
|
||||
export * from "./date/mini.cjs";
|
||||
export * from "./tz/index.cts";
|
||||
export * from "./tzOffset/index.cts";
|
||||
export * from "./tzScan/index.cts";
|
||||
export * from "./tzName/index.cts";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
8
node_modules/@date-fns/tz/index.d.ts
generated
vendored
Normal file
8
node_modules/@date-fns/tz/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export * from "./constants/index.ts";
|
||||
export * from "./date/index.js";
|
||||
export * from "./date/mini.js";
|
||||
export * from "./tz/index.ts";
|
||||
export * from "./tzOffset/index.ts";
|
||||
export * from "./tzScan/index.ts";
|
||||
export * from "./tzName/index.ts";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@date-fns/tz/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@date-fns/tz/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
||||
7
node_modules/@date-fns/tz/index.js
generated
vendored
Normal file
7
node_modules/@date-fns/tz/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export * from "./constants/index.js";
|
||||
export * from "./date/index.js";
|
||||
export * from "./date/mini.js";
|
||||
export * from "./tz/index.js";
|
||||
export * from "./tzOffset/index.js";
|
||||
export * from "./tzScan/index.js";
|
||||
export * from "./tzName/index.js";
|
||||
134
node_modules/@date-fns/tz/package.json
generated
vendored
Normal file
134
node_modules/@date-fns/tz/package.json
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"name": "@date-fns/tz",
|
||||
"version": "1.4.1",
|
||||
"description": "date-fns timezone utils",
|
||||
"type": "module",
|
||||
"main": "index.cjs",
|
||||
"module": "index.js",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"require": {
|
||||
"types": "./index.d.cts",
|
||||
"default": "./index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
}
|
||||
},
|
||||
"./tzOffset": {
|
||||
"require": {
|
||||
"types": "./tzOffset/index.d.cts",
|
||||
"default": "./tzOffset/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./tzOffset/index.d.ts",
|
||||
"default": "./tzOffset/index.js"
|
||||
}
|
||||
},
|
||||
"./tzScan": {
|
||||
"require": {
|
||||
"types": "./tzScan/index.d.cts",
|
||||
"default": "./tzScan/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./tzScan/index.d.ts",
|
||||
"default": "./tzScan/index.js"
|
||||
}
|
||||
},
|
||||
"./tzName": {
|
||||
"require": {
|
||||
"types": "./tzName/index.d.cts",
|
||||
"default": "./tzName/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./tzName/index.d.ts",
|
||||
"default": "./tzName/index.js"
|
||||
}
|
||||
},
|
||||
"./date": {
|
||||
"require": {
|
||||
"types": "./date/index.d.cts",
|
||||
"default": "./date/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./date/index.d.ts",
|
||||
"default": "./date/index.js"
|
||||
}
|
||||
},
|
||||
"./date/mini": {
|
||||
"require": {
|
||||
"types": "./date/mini.d.cts",
|
||||
"default": "./date/mini.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./date/mini.d.ts",
|
||||
"default": "./date/mini.js"
|
||||
}
|
||||
},
|
||||
"./tz": {
|
||||
"require": {
|
||||
"types": "./tz/index.d.cts",
|
||||
"default": "./tz/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./tz/index.d.ts",
|
||||
"default": "./tz/index.js"
|
||||
}
|
||||
},
|
||||
"./constants": {
|
||||
"require": {
|
||||
"types": "./constants/index.d.cts",
|
||||
"default": "./constants/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./constants/index.d.ts",
|
||||
"default": "./constants/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/date-fns/tz.git"
|
||||
},
|
||||
"keywords": [
|
||||
"date-fns",
|
||||
"tz",
|
||||
"timezones",
|
||||
"date",
|
||||
"time",
|
||||
"datetime"
|
||||
],
|
||||
"author": "Sasha Koss <koss@nocorp.me>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/date-fns/tz/issues"
|
||||
},
|
||||
"homepage": "https://github.com/date-fns/tz#readme",
|
||||
"devDependencies": {
|
||||
"@arethetypeswrong/cli": "^0.18.2",
|
||||
"@babel/cli": "^7.28.0",
|
||||
"@babel/core": "^7.28.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
|
||||
"@babel/preset-env": "^7.28.0",
|
||||
"@babel/preset-typescript": "^7.27.1",
|
||||
"@parcel/watcher": "^2.4.1",
|
||||
"@sinonjs/fake-timers": "^11.2.2",
|
||||
"@swc/core": "^1.4.13",
|
||||
"@types/sinonjs__fake-timers": "^8.1.5",
|
||||
"babel-plugin-replace-import-extension": "^1.1.5",
|
||||
"bytes-iec": "^3.1.1",
|
||||
"date-fns": "4.0.0-alpha.1",
|
||||
"glob": "^10.3.12",
|
||||
"minimatch": "^10.0.1",
|
||||
"picocolors": "^1.0.0",
|
||||
"prettier": "^3.6.2",
|
||||
"tinybench": "^2.7.0",
|
||||
"typescript": "5.9.2",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vitest run"
|
||||
}
|
||||
}
|
||||
15
node_modules/@date-fns/tz/tz/index.cjs
generated
vendored
Normal file
15
node_modules/@date-fns/tz/tz/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
exports.tz = void 0;
|
||||
var _index = require("../date/index.cjs");
|
||||
/**
|
||||
* The function creates accepts a time zone and returns a function that creates
|
||||
* a new `TZDate` instance in the time zone from the provided value. Use it to
|
||||
* provide the context for the date-fns functions, via the `in` option.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*
|
||||
* @returns Function that creates a new `TZDate` instance in the time zone
|
||||
*/
|
||||
const tz = timeZone => value => _index.TZDate.tz(timeZone, +new Date(value));
|
||||
exports.tz = tz;
|
||||
12
node_modules/@date-fns/tz/tz/index.d.cts
generated
vendored
Normal file
12
node_modules/@date-fns/tz/tz/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { TZDate } from "../date/index.cjs";
|
||||
/**
|
||||
* The function creates accepts a time zone and returns a function that creates
|
||||
* a new `TZDate` instance in the time zone from the provided value. Use it to
|
||||
* provide the context for the date-fns functions, via the `in` option.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*
|
||||
* @returns Function that creates a new `TZDate` instance in the time zone
|
||||
*/
|
||||
export declare const tz: (timeZone: string) => (value: Date | number | string) => TZDate;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
12
node_modules/@date-fns/tz/tz/index.d.ts
generated
vendored
Normal file
12
node_modules/@date-fns/tz/tz/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { TZDate } from "../date/index.js";
|
||||
/**
|
||||
* The function creates accepts a time zone and returns a function that creates
|
||||
* a new `TZDate` instance in the time zone from the provided value. Use it to
|
||||
* provide the context for the date-fns functions, via the `in` option.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*
|
||||
* @returns Function that creates a new `TZDate` instance in the time zone
|
||||
*/
|
||||
export declare const tz: (timeZone: string) => (value: Date | number | string) => TZDate;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@date-fns/tz/tz/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@date-fns/tz/tz/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tz/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C;;;;;;;;GAQG;AACH,eAAO,MAAM,EAAE,GAAI,UAAU,MAAM,MAAM,OAAO,IAAI,GAAG,MAAM,GAAG,MAAM,WAC/B,CAAC"}
|
||||
12
node_modules/@date-fns/tz/tz/index.js
generated
vendored
Normal file
12
node_modules/@date-fns/tz/tz/index.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { TZDate } from "../date/index.js";
|
||||
|
||||
/**
|
||||
* The function creates accepts a time zone and returns a function that creates
|
||||
* a new `TZDate` instance in the time zone from the provided value. Use it to
|
||||
* provide the context for the date-fns functions, via the `in` option.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
*
|
||||
* @returns Function that creates a new `TZDate` instance in the time zone
|
||||
*/
|
||||
export const tz = timeZone => value => TZDate.tz(timeZone, +new Date(value));
|
||||
40
node_modules/@date-fns/tz/tzName/index.cjs
generated
vendored
Normal file
40
node_modules/@date-fns/tz/tzName/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
exports.tzName = tzName;
|
||||
/**
|
||||
* Time zone name format.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function returns the time zone name for the given date in the specified
|
||||
* time zone.
|
||||
*
|
||||
* It uses the `Intl.DateTimeFormat` API and by default outputs the time zone
|
||||
* name in a long format, e.g. "Pacific Standard Time" or
|
||||
* "Singapore Standard Time".
|
||||
*
|
||||
* It is possible to specify the format as the third argument using one of the following options
|
||||
*
|
||||
* - "short": e.g. "EDT" or "GMT+8".
|
||||
* - "long": e.g. "Eastern Daylight Time".
|
||||
* - "shortGeneric": e.g. "ET" or "Singapore Time".
|
||||
* - "longGeneric": e.g. "Eastern Time" or "Singapore Standard Time".
|
||||
*
|
||||
* These options correspond to TR35 tokens `z..zzz`, `zzzz`, `v`, and `vvvv` respectively: https://www.unicode.org/reports/tr35/tr35-dates.html#dfst-zone
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param date - Date object to get the time zone name for
|
||||
* @param format - Optional format of the time zone name. Defaults to "long". Can be "short", "long", "shortGeneric", or "longGeneric".
|
||||
*
|
||||
* @returns Time zone name (e.g. "Singapore Standard Time")
|
||||
*/
|
||||
function tzName(timeZone, date, format = "long") {
|
||||
return new Intl.DateTimeFormat("en-US", {
|
||||
// Enforces engine to render the time. Without the option JavaScriptCore omits it.
|
||||
hour: "numeric",
|
||||
timeZone: timeZone,
|
||||
timeZoneName: format
|
||||
}).format(date).split(/\s/g) // Format.JS uses non-breaking spaces
|
||||
.slice(2) // Skip the hour and AM/PM parts
|
||||
.join(" ");
|
||||
}
|
||||
29
node_modules/@date-fns/tz/tzName/index.d.cts
generated
vendored
Normal file
29
node_modules/@date-fns/tz/tzName/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Time zone name format.
|
||||
*/
|
||||
export type TZNameFormat = "short" | "long" | "shortGeneric" | "longGeneric";
|
||||
/**
|
||||
* The function returns the time zone name for the given date in the specified
|
||||
* time zone.
|
||||
*
|
||||
* It uses the `Intl.DateTimeFormat` API and by default outputs the time zone
|
||||
* name in a long format, e.g. "Pacific Standard Time" or
|
||||
* "Singapore Standard Time".
|
||||
*
|
||||
* It is possible to specify the format as the third argument using one of the following options
|
||||
*
|
||||
* - "short": e.g. "EDT" or "GMT+8".
|
||||
* - "long": e.g. "Eastern Daylight Time".
|
||||
* - "shortGeneric": e.g. "ET" or "Singapore Time".
|
||||
* - "longGeneric": e.g. "Eastern Time" or "Singapore Standard Time".
|
||||
*
|
||||
* These options correspond to TR35 tokens `z..zzz`, `zzzz`, `v`, and `vvvv` respectively: https://www.unicode.org/reports/tr35/tr35-dates.html#dfst-zone
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param date - Date object to get the time zone name for
|
||||
* @param format - Optional format of the time zone name. Defaults to "long". Can be "short", "long", "shortGeneric", or "longGeneric".
|
||||
*
|
||||
* @returns Time zone name (e.g. "Singapore Standard Time")
|
||||
*/
|
||||
export declare function tzName(timeZone: string, date: Date, format?: TZNameFormat): string;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
29
node_modules/@date-fns/tz/tzName/index.d.ts
generated
vendored
Normal file
29
node_modules/@date-fns/tz/tzName/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Time zone name format.
|
||||
*/
|
||||
export type TZNameFormat = "short" | "long" | "shortGeneric" | "longGeneric";
|
||||
/**
|
||||
* The function returns the time zone name for the given date in the specified
|
||||
* time zone.
|
||||
*
|
||||
* It uses the `Intl.DateTimeFormat` API and by default outputs the time zone
|
||||
* name in a long format, e.g. "Pacific Standard Time" or
|
||||
* "Singapore Standard Time".
|
||||
*
|
||||
* It is possible to specify the format as the third argument using one of the following options
|
||||
*
|
||||
* - "short": e.g. "EDT" or "GMT+8".
|
||||
* - "long": e.g. "Eastern Daylight Time".
|
||||
* - "shortGeneric": e.g. "ET" or "Singapore Time".
|
||||
* - "longGeneric": e.g. "Eastern Time" or "Singapore Standard Time".
|
||||
*
|
||||
* These options correspond to TR35 tokens `z..zzz`, `zzzz`, `v`, and `vvvv` respectively: https://www.unicode.org/reports/tr35/tr35-dates.html#dfst-zone
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param date - Date object to get the time zone name for
|
||||
* @param format - Optional format of the time zone name. Defaults to "long". Can be "short", "long", "shortGeneric", or "longGeneric".
|
||||
*
|
||||
* @returns Time zone name (e.g. "Singapore Standard Time")
|
||||
*/
|
||||
export declare function tzName(timeZone: string, date: Date, format?: TZNameFormat): string;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@date-fns/tz/tzName/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@date-fns/tz/tzName/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tzName/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,cAAc,GAAG,aAAa,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,EACV,MAAM,GAAE,YAAqB,GAC5B,MAAM,CAWR"}
|
||||
37
node_modules/@date-fns/tz/tzName/index.js
generated
vendored
Normal file
37
node_modules/@date-fns/tz/tzName/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Time zone name format.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function returns the time zone name for the given date in the specified
|
||||
* time zone.
|
||||
*
|
||||
* It uses the `Intl.DateTimeFormat` API and by default outputs the time zone
|
||||
* name in a long format, e.g. "Pacific Standard Time" or
|
||||
* "Singapore Standard Time".
|
||||
*
|
||||
* It is possible to specify the format as the third argument using one of the following options
|
||||
*
|
||||
* - "short": e.g. "EDT" or "GMT+8".
|
||||
* - "long": e.g. "Eastern Daylight Time".
|
||||
* - "shortGeneric": e.g. "ET" or "Singapore Time".
|
||||
* - "longGeneric": e.g. "Eastern Time" or "Singapore Standard Time".
|
||||
*
|
||||
* These options correspond to TR35 tokens `z..zzz`, `zzzz`, `v`, and `vvvv` respectively: https://www.unicode.org/reports/tr35/tr35-dates.html#dfst-zone
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param date - Date object to get the time zone name for
|
||||
* @param format - Optional format of the time zone name. Defaults to "long". Can be "short", "long", "shortGeneric", or "longGeneric".
|
||||
*
|
||||
* @returns Time zone name (e.g. "Singapore Standard Time")
|
||||
*/
|
||||
export function tzName(timeZone, date, format = "long") {
|
||||
return new Intl.DateTimeFormat("en-US", {
|
||||
// Enforces engine to render the time. Without the option JavaScriptCore omits it.
|
||||
hour: "numeric",
|
||||
timeZone: timeZone,
|
||||
timeZoneName: format
|
||||
}).format(date).split(/\s/g) // Format.JS uses non-breaking spaces
|
||||
.slice(2) // Skip the hour and AM/PM parts
|
||||
.join(" ");
|
||||
}
|
||||
45
node_modules/@date-fns/tz/tzOffset/index.cjs
generated
vendored
Normal file
45
node_modules/@date-fns/tz/tzOffset/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
|
||||
exports.tzOffset = tzOffset;
|
||||
const offsetFormatCache = {};
|
||||
const offsetCache = {};
|
||||
|
||||
/**
|
||||
* The function extracts UTC offset in minutes from the given date in specified
|
||||
* time zone.
|
||||
*
|
||||
* Unlike `Date.prototype.getTimezoneOffset`, this function returns the value
|
||||
* mirrored to the sign of the offset in the time zone. For Asia/Singapore
|
||||
* (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param date - Date to check the offset for
|
||||
*
|
||||
* @returns UTC offset in minutes
|
||||
*/
|
||||
function tzOffset(timeZone, date) {
|
||||
try {
|
||||
const format = offsetFormatCache[timeZone] ||= new Intl.DateTimeFormat("en-US", {
|
||||
timeZone,
|
||||
timeZoneName: "longOffset"
|
||||
}).format;
|
||||
const offsetStr = format(date).split("GMT")[1];
|
||||
if (offsetStr in offsetCache) return offsetCache[offsetStr];
|
||||
return calcOffset(offsetStr, offsetStr.split(":"));
|
||||
} catch {
|
||||
// Fallback to manual parsing if the runtime doesn't support ±HH:MM/±HHMM/±HH
|
||||
// See: https://github.com/nodejs/node/issues/53419
|
||||
if (timeZone in offsetCache) return offsetCache[timeZone];
|
||||
const captures = timeZone?.match(offsetRe);
|
||||
if (captures) return calcOffset(timeZone, captures.slice(1));
|
||||
return NaN;
|
||||
}
|
||||
}
|
||||
const offsetRe = /([+-]\d\d):?(\d\d)?/;
|
||||
function calcOffset(cacheStr, values) {
|
||||
const hours = +(values[0] || 0);
|
||||
const minutes = +(values[1] || 0);
|
||||
// Convert seconds to minutes by dividing by 60 to keep the function return in minutes.
|
||||
const seconds = +(values[2] || 0) / 60;
|
||||
return offsetCache[cacheStr] = hours * 60 + minutes > 0 ? hours * 60 + minutes + seconds : hours * 60 - minutes - seconds;
|
||||
}
|
||||
15
node_modules/@date-fns/tz/tzOffset/index.d.cts
generated
vendored
Normal file
15
node_modules/@date-fns/tz/tzOffset/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* The function extracts UTC offset in minutes from the given date in specified
|
||||
* time zone.
|
||||
*
|
||||
* Unlike `Date.prototype.getTimezoneOffset`, this function returns the value
|
||||
* mirrored to the sign of the offset in the time zone. For Asia/Singapore
|
||||
* (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param date - Date to check the offset for
|
||||
*
|
||||
* @returns UTC offset in minutes
|
||||
*/
|
||||
export declare function tzOffset(timeZone: string | undefined, date: Date): number;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
15
node_modules/@date-fns/tz/tzOffset/index.d.ts
generated
vendored
Normal file
15
node_modules/@date-fns/tz/tzOffset/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* The function extracts UTC offset in minutes from the given date in specified
|
||||
* time zone.
|
||||
*
|
||||
* Unlike `Date.prototype.getTimezoneOffset`, this function returns the value
|
||||
* mirrored to the sign of the offset in the time zone. For Asia/Singapore
|
||||
* (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param date - Date to check the offset for
|
||||
*
|
||||
* @returns UTC offset in minutes
|
||||
*/
|
||||
export declare function tzOffset(timeZone: string | undefined, date: Date): number;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@date-fns/tz/tzOffset/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@date-fns/tz/tzOffset/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tzOffset/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAoBzE"}
|
||||
42
node_modules/@date-fns/tz/tzOffset/index.js
generated
vendored
Normal file
42
node_modules/@date-fns/tz/tzOffset/index.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
const offsetFormatCache = {};
|
||||
const offsetCache = {};
|
||||
|
||||
/**
|
||||
* The function extracts UTC offset in minutes from the given date in specified
|
||||
* time zone.
|
||||
*
|
||||
* Unlike `Date.prototype.getTimezoneOffset`, this function returns the value
|
||||
* mirrored to the sign of the offset in the time zone. For Asia/Singapore
|
||||
* (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param date - Date to check the offset for
|
||||
*
|
||||
* @returns UTC offset in minutes
|
||||
*/
|
||||
export function tzOffset(timeZone, date) {
|
||||
try {
|
||||
const format = offsetFormatCache[timeZone] ||= new Intl.DateTimeFormat("en-US", {
|
||||
timeZone,
|
||||
timeZoneName: "longOffset"
|
||||
}).format;
|
||||
const offsetStr = format(date).split("GMT")[1];
|
||||
if (offsetStr in offsetCache) return offsetCache[offsetStr];
|
||||
return calcOffset(offsetStr, offsetStr.split(":"));
|
||||
} catch {
|
||||
// Fallback to manual parsing if the runtime doesn't support ±HH:MM/±HHMM/±HH
|
||||
// See: https://github.com/nodejs/node/issues/53419
|
||||
if (timeZone in offsetCache) return offsetCache[timeZone];
|
||||
const captures = timeZone?.match(offsetRe);
|
||||
if (captures) return calcOffset(timeZone, captures.slice(1));
|
||||
return NaN;
|
||||
}
|
||||
}
|
||||
const offsetRe = /([+-]\d\d):?(\d\d)?/;
|
||||
function calcOffset(cacheStr, values) {
|
||||
const hours = +(values[0] || 0);
|
||||
const minutes = +(values[1] || 0);
|
||||
// Convert seconds to minutes by dividing by 60 to keep the function return in minutes.
|
||||
const seconds = +(values[2] || 0) / 60;
|
||||
return offsetCache[cacheStr] = hours * 60 + minutes > 0 ? hours * 60 + minutes + seconds : hours * 60 - minutes - seconds;
|
||||
}
|
||||
75
node_modules/@date-fns/tz/tzScan/index.cjs
generated
vendored
Normal file
75
node_modules/@date-fns/tz/tzScan/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
|
||||
exports.tzScan = tzScan;
|
||||
var _index = require("../tzOffset/index.cjs");
|
||||
/**
|
||||
* Time interval.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time zone change record.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function scans the time zone for changes in the given interval.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param interval - Time interval to scan for changes
|
||||
*
|
||||
* @returns Array of time zone changes
|
||||
*/
|
||||
function tzScan(timeZone, interval) {
|
||||
const changes = [];
|
||||
const monthDate = new Date(interval.start);
|
||||
monthDate.setUTCSeconds(0, 0);
|
||||
const endDate = new Date(interval.end);
|
||||
endDate.setUTCSeconds(0, 0);
|
||||
const endMonthTime = +endDate;
|
||||
let lastOffset = (0, _index.tzOffset)(timeZone, monthDate);
|
||||
while (+monthDate < endMonthTime) {
|
||||
// Month forward
|
||||
monthDate.setUTCMonth(monthDate.getUTCMonth() + 1);
|
||||
|
||||
// Find the month where the offset changes
|
||||
const offset = (0, _index.tzOffset)(timeZone, monthDate);
|
||||
if (offset != lastOffset) {
|
||||
// Rewind a month back to find the day where the offset changes
|
||||
const dayDate = new Date(monthDate);
|
||||
dayDate.setUTCMonth(dayDate.getUTCMonth() - 1);
|
||||
const endDayTime = +monthDate;
|
||||
lastOffset = (0, _index.tzOffset)(timeZone, dayDate);
|
||||
while (+dayDate < endDayTime) {
|
||||
// Day forward
|
||||
dayDate.setUTCDate(dayDate.getUTCDate() + 1);
|
||||
|
||||
// Find the day where the offset changes
|
||||
const offset = (0, _index.tzOffset)(timeZone, dayDate);
|
||||
if (offset != lastOffset) {
|
||||
// Rewind a day back to find the time where the offset changes
|
||||
const hourDate = new Date(dayDate);
|
||||
hourDate.setUTCDate(hourDate.getUTCDate() - 1);
|
||||
const endHourTime = +dayDate;
|
||||
lastOffset = (0, _index.tzOffset)(timeZone, hourDate);
|
||||
while (+hourDate < endHourTime) {
|
||||
// Hour forward
|
||||
hourDate.setUTCHours(hourDate.getUTCHours() + 1);
|
||||
|
||||
// Find the hour where the offset changes
|
||||
const hourOffset = (0, _index.tzOffset)(timeZone, hourDate);
|
||||
if (hourOffset !== lastOffset) {
|
||||
changes.push({
|
||||
date: new Date(hourDate),
|
||||
change: hourOffset - lastOffset,
|
||||
offset: hourOffset
|
||||
});
|
||||
}
|
||||
lastOffset = hourOffset;
|
||||
}
|
||||
}
|
||||
lastOffset = offset;
|
||||
}
|
||||
}
|
||||
lastOffset = offset;
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
30
node_modules/@date-fns/tz/tzScan/index.d.cts
generated
vendored
Normal file
30
node_modules/@date-fns/tz/tzScan/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Time interval.
|
||||
*/
|
||||
export interface TZChangeInterval {
|
||||
/** Start date. */
|
||||
start: Date;
|
||||
/** End date. */
|
||||
end: Date;
|
||||
}
|
||||
/**
|
||||
* Time zone change record.
|
||||
*/
|
||||
export interface TZChange {
|
||||
/** Date time the change occurs */
|
||||
date: Date;
|
||||
/** Offset change in minutes */
|
||||
change: number;
|
||||
/** New UTC offset in minutes */
|
||||
offset: number;
|
||||
}
|
||||
/**
|
||||
* The function scans the time zone for changes in the given interval.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param interval - Time interval to scan for changes
|
||||
*
|
||||
* @returns Array of time zone changes
|
||||
*/
|
||||
export declare function tzScan(timeZone: string, interval: TZChangeInterval): TZChange[];
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
30
node_modules/@date-fns/tz/tzScan/index.d.ts
generated
vendored
Normal file
30
node_modules/@date-fns/tz/tzScan/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Time interval.
|
||||
*/
|
||||
export interface TZChangeInterval {
|
||||
/** Start date. */
|
||||
start: Date;
|
||||
/** End date. */
|
||||
end: Date;
|
||||
}
|
||||
/**
|
||||
* Time zone change record.
|
||||
*/
|
||||
export interface TZChange {
|
||||
/** Date time the change occurs */
|
||||
date: Date;
|
||||
/** Offset change in minutes */
|
||||
change: number;
|
||||
/** New UTC offset in minutes */
|
||||
offset: number;
|
||||
}
|
||||
/**
|
||||
* The function scans the time zone for changes in the given interval.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param interval - Time interval to scan for changes
|
||||
*
|
||||
* @returns Array of time zone changes
|
||||
*/
|
||||
export declare function tzScan(timeZone: string, interval: TZChangeInterval): TZChange[];
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@date-fns/tz/tzScan/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@date-fns/tz/tzScan/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tzScan/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB;IAClB,KAAK,EAAE,IAAI,CAAC;IACZ,gBAAgB;IAChB,GAAG,EAAE,IAAI,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,kCAAkC;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,gBAAgB,GACzB,QAAQ,EAAE,CA+DZ"}
|
||||
73
node_modules/@date-fns/tz/tzScan/index.js
generated
vendored
Normal file
73
node_modules/@date-fns/tz/tzScan/index.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
import { tzOffset } from "../tzOffset/index.js";
|
||||
|
||||
/**
|
||||
* Time interval.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time zone change record.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function scans the time zone for changes in the given interval.
|
||||
*
|
||||
* @param timeZone - Time zone name (IANA or UTC offset)
|
||||
* @param interval - Time interval to scan for changes
|
||||
*
|
||||
* @returns Array of time zone changes
|
||||
*/
|
||||
export function tzScan(timeZone, interval) {
|
||||
const changes = [];
|
||||
const monthDate = new Date(interval.start);
|
||||
monthDate.setUTCSeconds(0, 0);
|
||||
const endDate = new Date(interval.end);
|
||||
endDate.setUTCSeconds(0, 0);
|
||||
const endMonthTime = +endDate;
|
||||
let lastOffset = tzOffset(timeZone, monthDate);
|
||||
while (+monthDate < endMonthTime) {
|
||||
// Month forward
|
||||
monthDate.setUTCMonth(monthDate.getUTCMonth() + 1);
|
||||
|
||||
// Find the month where the offset changes
|
||||
const offset = tzOffset(timeZone, monthDate);
|
||||
if (offset != lastOffset) {
|
||||
// Rewind a month back to find the day where the offset changes
|
||||
const dayDate = new Date(monthDate);
|
||||
dayDate.setUTCMonth(dayDate.getUTCMonth() - 1);
|
||||
const endDayTime = +monthDate;
|
||||
lastOffset = tzOffset(timeZone, dayDate);
|
||||
while (+dayDate < endDayTime) {
|
||||
// Day forward
|
||||
dayDate.setUTCDate(dayDate.getUTCDate() + 1);
|
||||
|
||||
// Find the day where the offset changes
|
||||
const offset = tzOffset(timeZone, dayDate);
|
||||
if (offset != lastOffset) {
|
||||
// Rewind a day back to find the time where the offset changes
|
||||
const hourDate = new Date(dayDate);
|
||||
hourDate.setUTCDate(hourDate.getUTCDate() - 1);
|
||||
const endHourTime = +dayDate;
|
||||
lastOffset = tzOffset(timeZone, hourDate);
|
||||
while (+hourDate < endHourTime) {
|
||||
// Hour forward
|
||||
hourDate.setUTCHours(hourDate.getUTCHours() + 1);
|
||||
|
||||
// Find the hour where the offset changes
|
||||
const hourOffset = tzOffset(timeZone, hourDate);
|
||||
if (hourOffset !== lastOffset) {
|
||||
changes.push({
|
||||
date: new Date(hourDate),
|
||||
change: hourOffset - lastOffset,
|
||||
offset: hourOffset
|
||||
});
|
||||
}
|
||||
lastOffset = hourOffset;
|
||||
}
|
||||
}
|
||||
lastOffset = offset;
|
||||
}
|
||||
}
|
||||
lastOffset = offset;
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
3
node_modules/@esbuild/freebsd-x64/README.md
generated
vendored
Normal file
3
node_modules/@esbuild/freebsd-x64/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# esbuild
|
||||
|
||||
This is the FreeBSD 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
||||
BIN
node_modules/@esbuild/freebsd-x64/bin/esbuild
generated
vendored
Executable file
BIN
node_modules/@esbuild/freebsd-x64/bin/esbuild
generated
vendored
Executable file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user