mirror of
https://github.com/svemagie/obsidian-micropub.git
synced 2026-05-14 19:38:50 +02:00
feat: IndieAuth PKCE sign-in + GitHub Pages relay callback
- Add IndieAuth.ts: full PKCE sign-in flow via GitHub Pages relay - Add docs/index.html: client_id page fetched by IndieKit for app info - Add docs/callback/index.html: relay that forwards to obsidian:// URI - Update SettingsTab.ts: signed-in/signed-out UI, Sign In button - Update types.ts: authorizationEndpoint, tokenEndpoint, me fields - Update main.ts: register obsidian://micropub-auth protocol handler
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"micropubEndpoint": "https://blog.giersig.eu/micropub",
|
||||
"mediaEndpoint": "https://blog.giersig.eu/media",
|
||||
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZSI6Imh0dHBzOi8vYmxvZy5naWVyc2lnLmV1Iiwic2NvcGUiOiJjcmVhdGUgdXBkYXRlIG1lZGlhIiwiaWF0IjoxNzczNTA1OTI2LCJleHAiOjE3ODEyODE5MjZ9.AaxtwgiQYbU7iWQt9GCResGK-DVfa0r7q2CHr_ibdFM",
|
||||
"defaultSyndicateTo": [],
|
||||
"autoDiscover": false,
|
||||
"siteUrl": "https://blog.giersig.eu",
|
||||
"authorizationEndpoint": "https://blog.giersig.eu/auth",
|
||||
"tokenEndpoint": "https://blog.giersig.eu/auth/token",
|
||||
"me": "https://blog.giersig.eu",
|
||||
"writeUrlToFrontmatter": true,
|
||||
"mapGardenTags": true,
|
||||
"defaultVisibility": "public"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
../esbuild/bin/esbuild
|
||||
+1
@@ -0,0 +1 @@
|
||||
../typescript/bin/tsc
|
||||
+1
@@ -0,0 +1 @@
|
||||
../typescript/bin/tsserver
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
{
|
||||
"name": "obsidian-micropub",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@codemirror/state": {
|
||||
"version": "6.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.0.tgz",
|
||||
"integrity": "sha512-MwBHVK60IiIHDcoMet78lxt6iw5gJOGSbNbOIVBHWVXIH4/Nq1+GQgLLGgI1KlnN86WDXsPudVaqYHKBIx7Eyw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@marijn/find-cluster-break": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/view": {
|
||||
"version": "6.38.6",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.38.6.tgz",
|
||||
"integrity": "sha512-qiS0z1bKs5WOvHIAC0Cybmv4AJSkAXgX5aD6Mqd2epSLlVJsQl8NG23jCVouIgkh4All/mrbdsf2UOLFnJw0tw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.5.0",
|
||||
"crelt": "^1.0.6",
|
||||
"style-mod": "^4.1.0",
|
||||
"w3c-keyname": "^2.2.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-arm64": {
|
||||
"version": "0.25.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz",
|
||||
"integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@marijn/find-cluster-break": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz",
|
||||
"integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/@types/codemirror": {
|
||||
"version": "5.60.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-5.60.8.tgz",
|
||||
"integrity": "sha512-VjFgDF/eB+Aklcy15TtOTLQeMjTo07k7KAjql8OK5Dirr7a6sJY4T1uVBDuTVG9VEmn1uUsohOpYnVfgC6/jyw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/tern": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
|
||||
"integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.19.37",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.37.tgz",
|
||||
"integrity": "sha512-8kzdPJ3FsNsVIurqBs7oodNnCEVbni9yUEkaHbgptDACOPW04jimGagZ51E6+lXUwJjgnBw+hyko/lkFWCldqw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/qrcode": {
|
||||
"version": "1.5.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz",
|
||||
"integrity": "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/tern": {
|
||||
"version": "0.23.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.9.tgz",
|
||||
"integrity": "sha512-ypzHFE/wBzh+BlH6rrBgS5I/Z7RD21pGhZ2rltb/+ZrVM1awdZwjx7hE5XfuYgHWk9uvV5HLZN3SloevCAp3Bw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/builtin-modules": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-4.0.0.tgz",
|
||||
"integrity": "sha512-p1n8zyCkt1BVrKNFymOHjcDSAl7oq/gUvfgULv2EblgpPVQlQr9yHnWjg9IJ2MhfwPqiYqMMrr01OY7yQoK2yA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.20"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/crelt": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz",
|
||||
"integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.25.12",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz",
|
||||
"integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.25.12",
|
||||
"@esbuild/android-arm": "0.25.12",
|
||||
"@esbuild/android-arm64": "0.25.12",
|
||||
"@esbuild/android-x64": "0.25.12",
|
||||
"@esbuild/darwin-arm64": "0.25.12",
|
||||
"@esbuild/darwin-x64": "0.25.12",
|
||||
"@esbuild/freebsd-arm64": "0.25.12",
|
||||
"@esbuild/freebsd-x64": "0.25.12",
|
||||
"@esbuild/linux-arm": "0.25.12",
|
||||
"@esbuild/linux-arm64": "0.25.12",
|
||||
"@esbuild/linux-ia32": "0.25.12",
|
||||
"@esbuild/linux-loong64": "0.25.12",
|
||||
"@esbuild/linux-mips64el": "0.25.12",
|
||||
"@esbuild/linux-ppc64": "0.25.12",
|
||||
"@esbuild/linux-riscv64": "0.25.12",
|
||||
"@esbuild/linux-s390x": "0.25.12",
|
||||
"@esbuild/linux-x64": "0.25.12",
|
||||
"@esbuild/netbsd-arm64": "0.25.12",
|
||||
"@esbuild/netbsd-x64": "0.25.12",
|
||||
"@esbuild/openbsd-arm64": "0.25.12",
|
||||
"@esbuild/openbsd-x64": "0.25.12",
|
||||
"@esbuild/openharmony-arm64": "0.25.12",
|
||||
"@esbuild/sunos-x64": "0.25.12",
|
||||
"@esbuild/win32-arm64": "0.25.12",
|
||||
"@esbuild/win32-ia32": "0.25.12",
|
||||
"@esbuild/win32-x64": "0.25.12"
|
||||
}
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.29.4",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
|
||||
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/obsidian": {
|
||||
"version": "1.12.3",
|
||||
"resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.12.3.tgz",
|
||||
"integrity": "sha512-HxWqe763dOqzXjnNiHmAJTRERN8KILBSqxDSEqbeSr7W8R8Jxezzbca+nz1LiiqXnMpM8lV2jzAezw3CZ4xNUw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/codemirror": "5.60.8",
|
||||
"moment": "2.29.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@codemirror/state": "6.5.0",
|
||||
"@codemirror/view": "6.38.6"
|
||||
}
|
||||
},
|
||||
"node_modules/style-mod": {
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz",
|
||||
"integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"dev": true,
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/w3c-keyname": {
|
||||
"version": "2.2.8",
|
||||
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
|
||||
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
+274
@@ -0,0 +1,274 @@
|
||||
## 6.5.0 (2024-12-09)
|
||||
|
||||
### New features
|
||||
|
||||
`RangeSet.compare` now supports a `boundChange` callback that is called when there's a change in the way ranges are split.
|
||||
|
||||
## 6.4.1 (2024-02-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that caused widgets at the end of a mark decoration to be rendered in their own separate mark DOM element.
|
||||
|
||||
## 6.4.0 (2023-12-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When multiple ranges in a single range set overlap, put the smaller ones inside the bigger ones, so that overlapping decorations don't break up each other's elements when coming from the same source.
|
||||
|
||||
### New features
|
||||
|
||||
Selection and selection range `eq` methods now support an optional argument that makes them also compare by cursor associativity.
|
||||
|
||||
The `RangeSet.join` function can be used to join multiple range sets together.
|
||||
|
||||
## 6.3.3 (2023-12-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where `Text.slice` and `Text.replace` could return objects with incorrect `length` when the given `from`/`to` values were out of range for the text.
|
||||
|
||||
## 6.3.2 (2023-11-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure transactions cannot add multiple selections when `allowMultipleSelections` is false.
|
||||
|
||||
Fix a bug that caused `Text.iterLines` to not return empty lines at the end of the iterated ranges.
|
||||
|
||||
## 6.3.1 (2023-10-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Give the tag property on `FacetReader` the type of the output type parameter to force TypeScript to infer the proper type when converting from `Facet` to `FacetReader`.
|
||||
|
||||
## 6.3.0 (2023-10-12)
|
||||
|
||||
### New features
|
||||
|
||||
The new `FacetReader` type provides a way to export a read-only handle to a `Facet`.
|
||||
|
||||
## 6.2.1 (2023-05-23)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that could cause `RangeSet.compare` to miss changes in the set of active ranges around a point range.
|
||||
|
||||
## 6.2.0 (2022-12-26)
|
||||
|
||||
### New features
|
||||
|
||||
`EditorSelection.range` now accepts an optional 4th argument to specify the bidi level of the range's head position.
|
||||
|
||||
## 6.1.4 (2022-11-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused the `openStart` value passed to span iterators to be incorrect around widgets in some circumstances.
|
||||
|
||||
## 6.1.3 (2022-11-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid unnecessary calls to computed facet getters when a state is reconfigured but no dependencies of the computed facet change.
|
||||
|
||||
Fix an infinite loop in `RangeSet.eq` when the `to` parameter isn't given.
|
||||
|
||||
## 6.1.2 (2022-09-21)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where, when multiple transaction extenders took effect, only the highest-precedence one was actually included in the transaction.
|
||||
|
||||
## 6.1.1 (2022-08-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug in range set span iteration that would cause decorations to be inappropriately split in some situations.
|
||||
|
||||
## 6.1.0 (2022-06-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Refine change mapping to preserve insertions made by concurrent changes.
|
||||
|
||||
### New features
|
||||
|
||||
The `enables` option to `Facet.define` may now take a function, which will be called with the facet value to create the extensions.
|
||||
|
||||
## 6.0.1 (2022-06-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a problem that caused effects' `map` methods to be called with an incorrect change set when filtering changes.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 6.0.0
|
||||
|
||||
## 0.20.1 (2022-06-02)
|
||||
|
||||
### New features
|
||||
|
||||
`EditorView.phrase` now accepts additional arguments, which it will interpolate into the phrase in the place of `$` markers.
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The deprecated precedence names `fallback`, `extend`, and `override` were removed from the library.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where, if an extension value occurs multiple times, its lowest, rather than highest precedence is used.
|
||||
|
||||
Fix an issue where facets with computed inputs would unneccesarily have their outputs recreated on state reconfiguration.
|
||||
|
||||
Fix a bug in the order in which new values for state fields and facets were computed, which could cause dynamic facets to hold the wrong value in some situations.
|
||||
|
||||
### New features
|
||||
|
||||
The exports from @codemirror/rangeset now live in this package.
|
||||
|
||||
The exports from @codemirror/text now live in this package.
|
||||
|
||||
## 0.19.9 (2022-02-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Mapping a non-empty selection range now always puts any newly inserted text on the sides of the range outside of the mapped version.
|
||||
|
||||
## 0.19.8 (2022-02-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where facet values with computed inputs could incorrectly retain their old value on reconfiguration.
|
||||
|
||||
## 0.19.7 (2022-02-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid recomputing facets on state reconfiguration if that facet's inputs stayed precisely the same.
|
||||
|
||||
Selection ranges created with `EditorSelection.range` will now have an assoc pointing at their anchor, when non-empty.
|
||||
|
||||
## 0.19.6 (2021-11-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused facet compare functions to be called with an invalid value in some situations.
|
||||
|
||||
Fix a bug that caused dynamic facet values to be incorrectly kept unchanged when reconfiguration changed one of their dependencies.
|
||||
|
||||
## 0.19.5 (2021-11-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that would cause dynamic facet values influenced by a state reconfiguration to not properly recompute.
|
||||
|
||||
## 0.19.4 (2021-11-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When reconfiguring a state, effects from the reconfiguring transaction can now be seen by newly added state fields.
|
||||
|
||||
## 0.19.3 (2021-11-03)
|
||||
|
||||
### New features
|
||||
|
||||
The precedence levels (under `Prec`) now have more generic names, because their 'meaningful' names were entirely inappropriate in many situations.
|
||||
|
||||
## 0.19.2 (2021-09-13)
|
||||
|
||||
### New features
|
||||
|
||||
The editor state now has a `readOnly` property with a matching facet to control its value.
|
||||
|
||||
## 0.19.1 (2021-08-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where `wordAt` never returned a useful result.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
User event strings now work differently—the events emitted by the core packages follow a different system, and hierarchical event tags can be created by separating the words with dots.
|
||||
|
||||
### New features
|
||||
|
||||
`languageDataAt` now takes an optional `side` argument to specificy which side of the position you're interested in.
|
||||
|
||||
It is now possible to add a user event annotation with a direct `userEvent` property on a transaction spec.
|
||||
|
||||
Transactions now have an `isUserEvent` method that can be used to check if it is (a subtype of) some user event type.
|
||||
|
||||
## 0.18.7 (2021-05-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where state fields might be initialized with a state that they aren't actually part of during reconfiguration.
|
||||
|
||||
## 0.18.6 (2021-04-12)
|
||||
|
||||
### New features
|
||||
|
||||
The new `EditorState.wordAt` method finds the word at a given position.
|
||||
|
||||
## 0.18.5 (2021-04-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue in the compiled output that would break the code when minified with terser.
|
||||
|
||||
## 0.18.4 (2021-04-06)
|
||||
|
||||
### New features
|
||||
|
||||
The new `Transaction.remote` annotation can be used to mark and recognize transactions created by other actors.
|
||||
|
||||
## 0.18.3 (2021-03-23)
|
||||
|
||||
### New features
|
||||
|
||||
The `ChangeDesc` class now has `toJSON` and `fromJSON` methods.
|
||||
|
||||
## 0.18.2 (2021-03-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix unintended ES2020 output (the package contains ES6 code again).
|
||||
|
||||
## 0.18.1 (2021-03-10)
|
||||
|
||||
### New features
|
||||
|
||||
The new `Compartment.get` method can be used to get the content of a compartment in a given state.
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
`tagExtension` and the `reconfigure` transaction spec property have been replaced with the concept of configuration compartments and reconfiguration effects (see `Compartment`, `StateEffect.reconfigure`, and `StateEffect.appendConfig`).
|
||||
|
||||
## 0.17.2 (2021-02-19)
|
||||
|
||||
### New features
|
||||
|
||||
`EditorSelection.map` and `SelectionRange.map` now take an optional second argument to indicate which direction to map to.
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
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.
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
# @codemirror/state [](https://www.npmjs.org/package/@codemirror/state)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#state) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/state/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements the editor state data structures for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/state/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
+3906
File diff suppressed because it is too large
Load Diff
+1700
File diff suppressed because it is too large
Load Diff
+1700
File diff suppressed because it is too large
Load Diff
+3876
File diff suppressed because it is too large
Load Diff
+38
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@codemirror/state",
|
||||
"version": "6.5.0",
|
||||
"description": "Editor state data structures for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/index.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@marijn/find-cluster-break": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/state.git"
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
+2084
File diff suppressed because it is too large
Load Diff
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
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.
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
# @codemirror/view [](https://www.npmjs.org/package/@codemirror/view)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#view) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/view/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements the DOM view component for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/view/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import {EditorView} from "@codemirror/view"
|
||||
import {basicSetup} from "codemirror"
|
||||
|
||||
const view = new EditorView({
|
||||
parent: document.querySelector("#some-node"),
|
||||
doc: "Content text",
|
||||
extensions: [basicSetup /* ... */]
|
||||
})
|
||||
```
|
||||
|
||||
Add additional extensions, such as a [language
|
||||
mode](https://codemirror.net/#languages), to configure the editor.
|
||||
Call
|
||||
[`view.dispatch`](https://codemirror.net/docs/ref/#view.EditorView.dispatch)
|
||||
to update the editor's state.
|
||||
+11496
File diff suppressed because it is too large
Load Diff
+2306
File diff suppressed because it is too large
Load Diff
+2306
File diff suppressed because it is too large
Load Diff
+11446
File diff suppressed because it is too large
Load Diff
+41
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "@codemirror/view",
|
||||
"version": "6.38.6",
|
||||
"description": "DOM view component for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/index.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.5.0",
|
||||
"crelt": "^1.0.6",
|
||||
"style-mod": "^4.1.0",
|
||||
"w3c-keyname": "^2.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/view.git"
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# esbuild
|
||||
|
||||
This is the macOS ARM 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
||||
BIN
Binary file not shown.
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@esbuild/darwin-arm64",
|
||||
"version": "0.25.12",
|
||||
"description": "The macOS ARM 64-bit binary for esbuild, a JavaScript bundler.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/evanw/esbuild.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"preferUnplugged": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
]
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2024 by Marijn Haverbeke <marijn@haverbeke.berlin>
|
||||
|
||||
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.
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
# @marijn/find-cluster-break
|
||||
|
||||
Small JavaScript module for finding grapheme cluster breaks in
|
||||
strings, scanning from a given position.
|
||||
|
||||
```javascript
|
||||
import {findClusterBreak} from "@marijn/find-cluster-break"
|
||||
console.log(findClusterBreak("💪🏽🦋", 0))
|
||||
// → 4
|
||||
```
|
||||
|
||||
This code is open source, released under an MIT license.
|
||||
|
||||
## Documentation
|
||||
|
||||
**`findClusterBreak`**`(str: string, pos: number, forward = true, includeExtending = true): number`
|
||||
|
||||
Returns a next grapheme cluster break _after_ (not equal to) `pos`,
|
||||
if `forward` is true, or before otherwise. Returns `pos` itself if no
|
||||
further cluster break is available in the string. Moves across
|
||||
surrogate pairs, extending characters (when `includeExtending` is
|
||||
true, which is the default), characters joined with zero-width joiners,
|
||||
and flag emoji.
|
||||
|
||||
**`isExtendingChar`**`(code: number): boolean`
|
||||
|
||||
Query whether the given character has a `Grapheme_Cluster_Break` value
|
||||
of `Extend` in Unicode.
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
'use strict';
|
||||
|
||||
// These are filled with ranges (rangeFrom[i] up to but not including
|
||||
// rangeTo[i]) of code points that count as extending characters.
|
||||
let rangeFrom = [], rangeTo = []
|
||||
|
||||
;(() => {
|
||||
// Compressed representation of the Grapheme_Cluster_Break=Extend
|
||||
// information from
|
||||
// http://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
|
||||
// Each pair of elements represents a range, as an offet from the
|
||||
// previous range and a length. Numbers are in base-36, with the empty
|
||||
// string being a shorthand for 1.
|
||||
let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
|
||||
for (let i = 0, n = 0; i < numbers.length; i++)
|
||||
(i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i]);
|
||||
})();
|
||||
|
||||
function isExtendingChar(code) {
|
||||
if (code < 768) return false
|
||||
for (let from = 0, to = rangeFrom.length;;) {
|
||||
let mid = (from + to) >> 1;
|
||||
if (code < rangeFrom[mid]) to = mid;
|
||||
else if (code >= rangeTo[mid]) from = mid + 1;
|
||||
else return true
|
||||
if (from == to) return false
|
||||
}
|
||||
}
|
||||
|
||||
function isRegionalIndicator(code) {
|
||||
return code >= 0x1F1E6 && code <= 0x1F1FF
|
||||
}
|
||||
|
||||
const ZWJ = 0x200d;
|
||||
|
||||
function findClusterBreak(str, pos, forward = true, includeExtending = true) {
|
||||
return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)
|
||||
}
|
||||
|
||||
function nextClusterBreak(str, pos, includeExtending) {
|
||||
if (pos == str.length) return pos
|
||||
// If pos is in the middle of a surrogate pair, move to its start
|
||||
if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1))) pos--;
|
||||
let prev = codePointAt(str, pos);
|
||||
pos += codePointSize(prev);
|
||||
while (pos < str.length) {
|
||||
let next = codePointAt(str, pos);
|
||||
if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
|
||||
pos += codePointSize(next);
|
||||
prev = next;
|
||||
} else if (isRegionalIndicator(next)) {
|
||||
let countBefore = 0, i = pos - 2;
|
||||
while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) { countBefore++; i -= 2; }
|
||||
if (countBefore % 2 == 0) break
|
||||
else pos += 2;
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return pos
|
||||
}
|
||||
|
||||
function prevClusterBreak(str, pos, includeExtending) {
|
||||
while (pos > 0) {
|
||||
let found = nextClusterBreak(str, pos - 2, includeExtending);
|
||||
if (found < pos) return found
|
||||
pos--;
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function codePointAt(str, pos) {
|
||||
let code0 = str.charCodeAt(pos);
|
||||
if (!surrogateHigh(code0) || pos + 1 == str.length) return code0
|
||||
let code1 = str.charCodeAt(pos + 1);
|
||||
if (!surrogateLow(code1)) return code0
|
||||
return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000
|
||||
}
|
||||
|
||||
function surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000 }
|
||||
function surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00 }
|
||||
function codePointSize(code) { return code < 0x10000 ? 1 : 2 }
|
||||
|
||||
exports.findClusterBreak = findClusterBreak;
|
||||
exports.isExtendingChar = isExtendingChar;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
Query whether the given character has a `Grapheme_Cluster_Break`
|
||||
value of `Extend` in Unicode.
|
||||
*/
|
||||
export declare function isExtendingChar(code: number): boolean
|
||||
|
||||
/**
|
||||
Returns a next grapheme cluster break _after_ (not equal to) `pos`,
|
||||
if `forward` is true, or before otherwise. Returns `pos` itself if no
|
||||
further cluster break is available in the string. Moves across
|
||||
surrogate pairs, extending characters (when `includeExtending` is
|
||||
true, which is the default), characters joined with zero-width joiners,
|
||||
and flag emoji.
|
||||
*/
|
||||
export declare function findClusterBreak(str: string, pos: number, forward?: boolean, includeExtending?: boolean): number
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@marijn/find-cluster-break",
|
||||
"version": "1.0.2",
|
||||
"type": "module",
|
||||
"description": "Find the position of grapheme cluster breaks in a string",
|
||||
"main": "src/index.js",
|
||||
"exports": {
|
||||
"import": "./src/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/*.js",
|
||||
"prepare": "rollup -c"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/marijnh/find-cluster-break.git"
|
||||
},
|
||||
"keywords": [
|
||||
"unicode",
|
||||
"grapheme",
|
||||
"cluster",
|
||||
"break"
|
||||
],
|
||||
"author": "Marijn Haverbeke <marijn@haverbeke.berlin>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/marijnh/find-cluster-break/issues"
|
||||
},
|
||||
"homepage": "https://github.com/marijnh/find-cluster-break#readme",
|
||||
"devDependencies": {
|
||||
"mocha": "^10.7.3",
|
||||
"rollup": "^4.28.1"
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export default {
|
||||
input: "src/index.js",
|
||||
output: {
|
||||
file: "dist/index.cjs",
|
||||
format: "cjs"
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
Query whether the given character has a `Grapheme_Cluster_Break`
|
||||
value of `Extend` in Unicode.
|
||||
*/
|
||||
export declare function isExtendingChar(code: number): boolean
|
||||
|
||||
/**
|
||||
Returns a next grapheme cluster break _after_ (not equal to) `pos`,
|
||||
if `forward` is true, or before otherwise. Returns `pos` itself if no
|
||||
further cluster break is available in the string. Moves across
|
||||
surrogate pairs, extending characters (when `includeExtending` is
|
||||
true, which is the default), characters joined with zero-width joiners,
|
||||
and flag emoji.
|
||||
*/
|
||||
export declare function findClusterBreak(str: string, pos: number, forward?: boolean, includeExtending?: boolean): number
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
// These are filled with ranges (rangeFrom[i] up to but not including
|
||||
// rangeTo[i]) of code points that count as extending characters.
|
||||
let rangeFrom = [], rangeTo = []
|
||||
|
||||
;(() => {
|
||||
// Compressed representation of the Grapheme_Cluster_Break=Extend
|
||||
// information from
|
||||
// http://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
|
||||
// Each pair of elements represents a range, as an offet from the
|
||||
// previous range and a length. Numbers are in base-36, with the empty
|
||||
// string being a shorthand for 1.
|
||||
let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1)
|
||||
for (let i = 0, n = 0; i < numbers.length; i++)
|
||||
(i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i])
|
||||
})()
|
||||
|
||||
export function isExtendingChar(code) {
|
||||
if (code < 768) return false
|
||||
for (let from = 0, to = rangeFrom.length;;) {
|
||||
let mid = (from + to) >> 1
|
||||
if (code < rangeFrom[mid]) to = mid
|
||||
else if (code >= rangeTo[mid]) from = mid + 1
|
||||
else return true
|
||||
if (from == to) return false
|
||||
}
|
||||
}
|
||||
|
||||
function isRegionalIndicator(code) {
|
||||
return code >= 0x1F1E6 && code <= 0x1F1FF
|
||||
}
|
||||
|
||||
function check(code) {
|
||||
for (let i = 0; i < rangeFrom.length; i++) {
|
||||
if (rangeTo[i] > code) return rangeFrom[i] <= code
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const ZWJ = 0x200d
|
||||
|
||||
export function findClusterBreak(str, pos, forward = true, includeExtending = true) {
|
||||
return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)
|
||||
}
|
||||
|
||||
function nextClusterBreak(str, pos, includeExtending) {
|
||||
if (pos == str.length) return pos
|
||||
// If pos is in the middle of a surrogate pair, move to its start
|
||||
if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1))) pos--
|
||||
let prev = codePointAt(str, pos)
|
||||
pos += codePointSize(prev)
|
||||
while (pos < str.length) {
|
||||
let next = codePointAt(str, pos)
|
||||
if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
|
||||
pos += codePointSize(next)
|
||||
prev = next
|
||||
} else if (isRegionalIndicator(next)) {
|
||||
let countBefore = 0, i = pos - 2
|
||||
while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) { countBefore++; i -= 2 }
|
||||
if (countBefore % 2 == 0) break
|
||||
else pos += 2
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return pos
|
||||
}
|
||||
|
||||
function prevClusterBreak(str, pos, includeExtending) {
|
||||
while (pos > 0) {
|
||||
let found = nextClusterBreak(str, pos - 2, includeExtending)
|
||||
if (found < pos) return found
|
||||
pos--
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function codePointAt(str, pos) {
|
||||
let code0 = str.charCodeAt(pos)
|
||||
if (!surrogateHigh(code0) || pos + 1 == str.length) return code0
|
||||
let code1 = str.charCodeAt(pos + 1)
|
||||
if (!surrogateLow(code1)) return code0
|
||||
return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000
|
||||
}
|
||||
|
||||
function surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000 }
|
||||
function surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00 }
|
||||
function codePointSize(code) { return code < 0x10000 ? 1 : 2 }
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
import {findClusterBreak} from "../src/index.js"
|
||||
|
||||
function assertEq(a, b) {
|
||||
if (a !== b) throw new Error(`${a} !== ${b}`)
|
||||
}
|
||||
|
||||
describe("findClusterBreak", () => {
|
||||
function test(spec) {
|
||||
it(spec, () => {
|
||||
let breaks = [], next
|
||||
while ((next = spec.indexOf("|")) > -1) {
|
||||
breaks.push(next)
|
||||
spec = spec.slice(0, next) + spec.slice(next + 1)
|
||||
}
|
||||
let found = []
|
||||
for (let i = 0;;) {
|
||||
let next = findClusterBreak(spec, i)
|
||||
if (next == spec.length) break
|
||||
found.push(i = next)
|
||||
}
|
||||
assertEq(found.join(","), breaks.join(","))
|
||||
})
|
||||
}
|
||||
|
||||
test("a|b|c|d")
|
||||
test("a|é̠|ő|x")
|
||||
test("😎|🙉")
|
||||
test("👨🎤|💪🏽|👩👩👧👦|❤")
|
||||
test("🇩🇪|🇫🇷|🇪🇸|x|🇮🇹")
|
||||
})
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
# Installation
|
||||
> `npm install --save @types/codemirror`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for codemirror (https://github.com/codemirror/CodeMirror).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/codemirror.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Tue, 06 Jun 2023 01:03:06 GMT
|
||||
* Dependencies: [@types/tern](https://npmjs.com/package/@types/tern)
|
||||
* Global values: `CodeMirror`
|
||||
|
||||
# Credits
|
||||
These definitions were written by [mihailik](https://github.com/mihailik), [nrbernard](https://github.com/nrbernard), [Pr1st0n](https://github.com/Pr1st0n), [rileymiller](https://github.com/rileymiller), [toddself](https://github.com/toddself), [ysulyma](https://github.com/ysulyma), [azoson](https://github.com/azoson), [kylesferrazza](https://github.com/kylesferrazza), [fityocsaba96](https://github.com/fityocsaba96), [koddsson](https://github.com/koddsson), and [ficristo](https://github.com/ficristo).
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface Editor {
|
||||
/** Tries to uncomment the current selection, and if that fails, line-comments it. */
|
||||
toggleComment(options?: CommentOptions): void;
|
||||
/** Set the lines in the given range to be line comments. Will fall back to `blockComment` when no line comment style is defined for the mode. */
|
||||
lineComment(from: Position, to: Position, options?: CommentOptions): void;
|
||||
/** Wrap the code in the given range in a block comment. Will fall back to `lineComment` when no block comment style is defined for the mode. */
|
||||
blockComment(from: Position, to: Position, options?: CommentOptions): void;
|
||||
/** Try to uncomment the given range. Returns `true` if a comment range was found and removed, `false` otherwise. */
|
||||
uncomment(from: Position, to: Position, options?: CommentOptions): boolean;
|
||||
}
|
||||
|
||||
interface CommentOptions {
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
blockCommentStart?: string | undefined;
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
blockCommentEnd?: string | undefined;
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
blockCommentLead?: string | undefined;
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
lineComment?: string | undefined;
|
||||
/** A string that will be inserted after opening and leading markers, and before closing comment markers. Defaults to a single space. */
|
||||
padding?: string | null | undefined;
|
||||
/** Whether, when adding line comments, to also comment lines that contain only whitespace. */
|
||||
commentBlankLines?: boolean | undefined;
|
||||
/** When adding line comments and this is turned on, it will align the comment block to the current indentation of the first line of the block. */
|
||||
indent?: boolean | undefined;
|
||||
/** When block commenting, this controls whether the whole lines are indented, or only the precise range that is given. Defaults to `true`. */
|
||||
fullLines?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface CommandActions {
|
||||
toggleComment(cm: Editor): void;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* if true, the editor will make the next line continue a comment when
|
||||
* pressing the Enter key. If set to a string, it will continue comments
|
||||
* using a custom shortcut.
|
||||
*/
|
||||
continueComments?: boolean | string | { key: string, continueLineComment?: boolean | undefined } | undefined;
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import '../../';
|
||||
|
||||
export type DialogCloseFunction = () => void;
|
||||
|
||||
export interface DialogOptions {
|
||||
bottom?: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface OpenDialogOptions extends DialogOptions {
|
||||
/** If true, the dialog will be closed when the user presses enter in the input. Defaults to true. */
|
||||
closeOnEnter?: boolean | undefined;
|
||||
/** Determines whether the dialog is closed when it loses focus. Defaults to true. */
|
||||
closeOnBlur?: boolean | undefined;
|
||||
/** An event handler that will be called whenever keydown fires in the dialog's input. If the callback returns true, the dialog will not do any further processing of the event. */
|
||||
onKeyDown?(event: KeyboardEvent, value: string, close: DialogCloseFunction): boolean | undefined;
|
||||
/** An event handler that will be called whenever keyup fires in the dialog's input. If the callback returns true, the dialog will not do any further processing of the event. */
|
||||
onKeyUp?(event: KeyboardEvent, value: string, close: DialogCloseFunction): boolean | undefined;
|
||||
/** An event handler that will be called whenever input fires in the dialog's input. If the callback returns true, the dialog will not do any further processing of the event. */
|
||||
onInput?(event: KeyboardEvent, value: string, close: DialogCloseFunction): boolean | undefined;
|
||||
/** A callback that will be called after the dialog has been closed and removed from the DOM. */
|
||||
onClose?(instance: HTMLElement): void;
|
||||
}
|
||||
|
||||
export interface OpenNotificationOptions extends DialogOptions {
|
||||
duration?: number | undefined;
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
interface Editor {
|
||||
/** Provides a very simple way to query users for text input. */
|
||||
openDialog(template: string | Node, callback: (value: string, e: Event) => void, options?: OpenDialogOptions): DialogCloseFunction;
|
||||
openNotification(template: string | Node, options?: OpenNotificationOptions): DialogCloseFunction;
|
||||
openConfirm(template: string | Node, callbacks: ReadonlyArray<(editor: Editor) => void>, options?: DialogOptions): DialogCloseFunction;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface EditorConfiguration {
|
||||
// if true, it will be refreshed the first time the editor becomes visible.
|
||||
// you can pass delay (msec) time as polling duration
|
||||
autoRefresh?: boolean | { delay: number } | undefined;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* When set to true, will make the editor full-screen (as in, taking up the whole browser window).
|
||||
* Depends on fullscreen.css
|
||||
* @see {@link https://codemirror.net/doc/manual.html#addon_fullscreen}
|
||||
* @default false
|
||||
*/
|
||||
fullScreen?: boolean | undefined;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface Panel {
|
||||
/** Removes the panel from the editor */
|
||||
clear(): void;
|
||||
/** Notifies panel that height of DOM node has changed */
|
||||
changed(height?: number): void;
|
||||
}
|
||||
|
||||
interface ShowPanelOptions {
|
||||
/**
|
||||
* Controls the position of the newly added panel. The following values are recognized:
|
||||
* `top` (default): Adds the panel at the very top.
|
||||
* `after-top`: Adds the panel at the bottom of the top panels.
|
||||
* `bottom`: Adds the panel at the very bottom.
|
||||
* `before-bottom`: Adds the panel at the top of the bottom panels.
|
||||
*/
|
||||
position?: 'top' | 'after-top' | 'bottom' | 'before-bottom' | undefined;
|
||||
/** The new panel will be added before the given panel. */
|
||||
before?: Panel | undefined;
|
||||
/** The new panel will be added after the given panel. */
|
||||
after?: Panel | undefined;
|
||||
/** The new panel will replace the given panel. */
|
||||
replace?: Panel | undefined;
|
||||
/** Whether to scroll the editor to keep the text's vertical position stable, when adding a panel above it. Defaults to false. */
|
||||
stable?: boolean | undefined;
|
||||
/** The initial height of the panel. Defaults to the offsetHeight of the node. */
|
||||
height?: number | undefined;
|
||||
}
|
||||
|
||||
interface Editor {
|
||||
/**
|
||||
* Places a DOM node above or below an editor and shrinks the editor to make room for the node.
|
||||
* When using the `after`, `before` or `replace` options, if the panel doesn't exists or has been removed, the value of the `position` option will be used as a fallback.
|
||||
* @param node the DOM node
|
||||
* @param options optional options object
|
||||
*/
|
||||
addPanel(node: HTMLElement, options?: ShowPanelOptions): Panel;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Adds a placeholder option that can be used to make content appear in the editor when it is empty and not focused.
|
||||
* It can hold either a string or a DOM node. Also gives the editor a CodeMirror-empty CSS class whenever it doesn't contain any text.
|
||||
*/
|
||||
placeholder?: string | Node | undefined;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import '../../';
|
||||
|
||||
export interface Ruler {
|
||||
column: number;
|
||||
className?: string | undefined;
|
||||
color?: string | undefined;
|
||||
lineStyle?: string | undefined;
|
||||
width?: string | undefined;
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
interface EditorConfiguration {
|
||||
/** show one or more vertical rulers in the editor. */
|
||||
rulers?: false | ReadonlyArray<number | Ruler> | undefined;
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface AutoCloseBrackets {
|
||||
/**
|
||||
* String containing pairs of matching characters.
|
||||
*/
|
||||
pairs?: string | undefined;
|
||||
|
||||
/**
|
||||
* If the next character is in the string, opening a bracket should be auto-closed.
|
||||
*/
|
||||
closeBefore?: string | undefined;
|
||||
|
||||
/**
|
||||
* String containing chars that could do a triple quote.
|
||||
*/
|
||||
triples?: string | undefined;
|
||||
|
||||
/**
|
||||
* explode should be a similar string that gives the pairs of characters that, when enter is pressed between them, should have the second character also moved to its own line.
|
||||
*/
|
||||
explode?: string | undefined;
|
||||
|
||||
/**
|
||||
* By default, if the active mode has a closeBrackets property, that overrides the configuration given in the option.
|
||||
* But you can add an override property with a truthy value to override mode-specific configuration.
|
||||
*/
|
||||
override?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Will auto-close brackets and quotes when typed.
|
||||
* By default, it'll auto-close ()[]{}''"", but you can pass it a string similar to that (containing pairs of matching characters),
|
||||
* or an object with pairs and optionally explode properties to customize it.
|
||||
*/
|
||||
autoCloseBrackets?: AutoCloseBrackets | boolean | string | undefined;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface CommandActions {
|
||||
closeTag(cm: Editor): void;
|
||||
}
|
||||
|
||||
interface AutoCloseTags {
|
||||
/**
|
||||
* Whether to autoclose when the '/' of a closing tag is typed. (default true)
|
||||
*/
|
||||
whenClosing?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Whether to autoclose the tag when the final '>' of an opening tag is typed. (default true)
|
||||
*/
|
||||
whenOpening?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* An array of tag names that should not be autoclosed. (default is empty tags for HTML, none for XML)
|
||||
*/
|
||||
dontCloseTags?: ReadonlyArray<string> | undefined;
|
||||
|
||||
/**
|
||||
* An array of tag names that should, when opened, cause a
|
||||
* blank line to be added inside the tag, and the blank line and
|
||||
* closing line to be indented. (default is block tags for HTML, none for XML)
|
||||
*/
|
||||
indentTags?: ReadonlyArray<string> | undefined;
|
||||
|
||||
/**
|
||||
* An array of XML tag names that should be autoclosed with '/>'. (default is none)
|
||||
*/
|
||||
emptyTags: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Will auto-close XML tags when '>' or '/' is typed.
|
||||
* Depends on the fold/xml-fold.js addon.
|
||||
*/
|
||||
autoCloseTags?: AutoCloseTags | boolean | undefined;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface CommandActions {
|
||||
newlineAndIndentContinueMarkdownList(cm: Editor): void | typeof Pass;
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface MatchBrackets {
|
||||
/**
|
||||
* Only use the character after the start position, never the one before it.
|
||||
*/
|
||||
afterCursor?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Causes only matches where both brackets are at the same side of the start position to be considered.
|
||||
*/
|
||||
strict?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Stop after scanning this amount of lines without a successful match. Defaults to 1000.
|
||||
*/
|
||||
maxScanLines?: number | undefined;
|
||||
|
||||
/**
|
||||
* Ignore lines longer than this. Defaults to 10000.
|
||||
*/
|
||||
maxScanLineLength?: number | undefined;
|
||||
|
||||
/**
|
||||
* Don't highlight a bracket in a line longer than this. Defaults to 1000.
|
||||
*/
|
||||
maxHighlightLineLength?: number | undefined;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
// When set to true or an options object, causes matching brackets to be highlighted whenever the cursor is next to them.
|
||||
matchBrackets?: MatchBrackets | boolean | undefined;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface CommandActions {
|
||||
/**
|
||||
* You can bind a key to in order to jump to the tag matching the one under the cursor.
|
||||
*/
|
||||
toMatchingTag(cm: Editor): void;
|
||||
}
|
||||
|
||||
interface MatchTags {
|
||||
/**
|
||||
* Highlight both matching tags.
|
||||
*/
|
||||
bothTags?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* When enabled will cause the tags around the cursor to be highlighted (using the CodeMirror-matchingtag class).
|
||||
* Depends on the addon/fold/xml-fold.js addon.
|
||||
*/
|
||||
matchTags?: MatchTags | boolean | undefined;
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface EditorConfiguration {
|
||||
/** when enabled, adds the CSS class cm-trailingspace to stretches of whitespace at the end of lines. */
|
||||
showTrailingSpace?: boolean | undefined;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import './foldcode';
|
||||
|
||||
declare module './foldcode' {
|
||||
interface FoldHelpers {
|
||||
brace: FoldRangeFinder;
|
||||
import: FoldRangeFinder;
|
||||
include: FoldRangeFinder;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import './foldcode';
|
||||
|
||||
declare module './foldcode' {
|
||||
interface FoldHelpers {
|
||||
comment: FoldRangeFinder;
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_foldcode
|
||||
|
||||
import * as CodeMirror from '../../';
|
||||
|
||||
export type FoldRangeFinder = (cm: CodeMirror.Editor, pos: CodeMirror.Position) => CodeMirror.FoldRange | undefined;
|
||||
|
||||
export interface FoldHelpers {
|
||||
combine: (...finders: FoldRangeFinder[]) => FoldRangeFinder;
|
||||
auto: FoldRangeFinder;
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
interface Editor {
|
||||
/**
|
||||
* Helps with code folding. Adds a foldCode method to editor instances, which will try to do a code fold starting at the given line,
|
||||
* or unfold the fold that is already present.
|
||||
* The method takes as first argument the position that should be folded (may be a line number or a Pos), and as second optional argument either a
|
||||
* range-finder function, or an options object.
|
||||
*/
|
||||
foldCode: (
|
||||
lineOrPos: number | Position,
|
||||
rangeFindeOrFoldOptions?: FoldRangeFinder | FoldOptions,
|
||||
force?: 'fold' | 'unfold',
|
||||
) => void;
|
||||
isFolded(pos: Position): boolean | undefined;
|
||||
foldOption<K extends keyof FoldOptions>(option: K): FoldOptions[K];
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
foldOptions?: FoldOptions | undefined;
|
||||
}
|
||||
|
||||
interface FoldOptions {
|
||||
/**
|
||||
* The function that is used to find foldable ranges. If this is not directly passed, it will default to CodeMirror.fold.auto,
|
||||
* which uses getHelpers with a "fold" type to find folding functions appropriate for the local mode.
|
||||
* There are files in the addon/fold/ directory providing CodeMirror.fold.brace, which finds blocks in brace languages (JavaScript, C, Java, etc),
|
||||
* CodeMirror.fold.indent, for languages where indentation determines block structure (Python, Haskell), and CodeMirror.fold.xml, for XML-style languages,
|
||||
* and CodeMirror.fold.comment, for folding comment blocks.
|
||||
*/
|
||||
rangeFinder?: FoldRangeFinder | undefined;
|
||||
|
||||
/**
|
||||
* The widget to show for folded ranges. Can be either a string, in which case it'll become a span with class CodeMirror-foldmarker, or a DOM node.
|
||||
* To dynamically generate the widget, this can be a function that returns a string or DOM node, which will then render as described.
|
||||
* The function will be invoked with parameters identifying the range to be folded.
|
||||
*/
|
||||
widget?: string | Element | ((from: Position, to: Position) => string | Element) | undefined;
|
||||
|
||||
/**
|
||||
* When true (default is false), the addon will try to find foldable ranges on the lines above the current one if there isn't an eligible one on the given line.
|
||||
*/
|
||||
scanUp?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* The minimum amount of lines that a fold should span to be accepted. Defaults to 0, which also allows single-line folds.
|
||||
*/
|
||||
minFoldSize?: number | undefined;
|
||||
|
||||
clearOnEnter?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface FoldRange {
|
||||
from: Position;
|
||||
to: Position;
|
||||
}
|
||||
|
||||
interface CommandActions {
|
||||
toggleFold(cm: Editor): void;
|
||||
fold(cm: Editor): void;
|
||||
unfold(cm: Editor): void;
|
||||
foldAll(cm: Editor): void;
|
||||
unfoldAll(cm: Editor): void;
|
||||
}
|
||||
|
||||
const fold: FoldHelpers;
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_foldgutter
|
||||
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Provides an option foldGutter, which can be used to create a gutter with markers indicating the blocks that can be folded.
|
||||
*/
|
||||
foldGutter?: boolean | FoldGutterOptions | undefined;
|
||||
}
|
||||
|
||||
interface FoldRange {
|
||||
from: Position;
|
||||
to: Position;
|
||||
}
|
||||
|
||||
interface FoldGutterOptions {
|
||||
/**
|
||||
* The CSS class of the gutter. Defaults to "CodeMirror-foldgutter". You will have to style this yourself to give it a width (and possibly a background).
|
||||
*/
|
||||
gutter?: string | undefined;
|
||||
|
||||
/**
|
||||
* A CSS class or DOM element to be used as the marker for open, foldable blocks. Defaults to "CodeMirror-foldgutter-open".
|
||||
*/
|
||||
indicatorOpen?: string | Element | undefined;
|
||||
|
||||
/**
|
||||
* A CSS class or DOM element to be used as the marker for folded blocks. Defaults to "CodeMirror-foldgutter-folded".
|
||||
*/
|
||||
indicatorFolded?: string | Element | undefined;
|
||||
|
||||
/*
|
||||
* The range-finder function to use when determining whether something can be folded.
|
||||
* When not given, CodeMirror.fold.auto will be used as default.
|
||||
*/
|
||||
rangeFinder?: (cm: Editor, pos: Position) => FoldRange | undefined;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import './foldcode';
|
||||
|
||||
declare module './foldcode' {
|
||||
interface FoldHelpers {
|
||||
indent: FoldRangeFinder;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import './foldcode';
|
||||
|
||||
declare module './foldcode' {
|
||||
interface FoldHelpers {
|
||||
markdown: FoldRangeFinder;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import * as CodeMirror from '../../';
|
||||
import './foldcode';
|
||||
|
||||
export interface XmlTag {
|
||||
from: CodeMirror.Position;
|
||||
to: CodeMirror.Position;
|
||||
tag: string;
|
||||
}
|
||||
|
||||
declare module './foldcode' {
|
||||
interface FoldHelpers {
|
||||
xml: FoldRangeFinder;
|
||||
}
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
function findMatchingTag(cm: Editor, pos: Position, range: Range): {open: XmlTag, close: XmlTag | null | undefined, at: 'open' | 'close'} | undefined;
|
||||
|
||||
function findEnclosingTag(cm: Editor, pos: Position, range: Range, tag: string): {open: XmlTag, close: XmlTag} | undefined;
|
||||
|
||||
function scanForClosingTag(cm: Editor, pos: Position, name: string, end?: Position): XmlTag | null | undefined;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import './show-hint';
|
||||
|
||||
declare module '../../' {
|
||||
interface HintHelpers {
|
||||
anyword: HintFunction;
|
||||
}
|
||||
|
||||
interface ShowHintOptions {
|
||||
word?: RegExp | undefined;
|
||||
range?: number | undefined;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import './show-hint';
|
||||
|
||||
declare module '../../' {
|
||||
interface HintHelpers {
|
||||
css: HintFunction;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import './xml-hint';
|
||||
|
||||
declare module '../../' {
|
||||
interface HintHelpers {
|
||||
html: HintFunction;
|
||||
}
|
||||
|
||||
const htmlSchema: any;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import './show-hint';
|
||||
|
||||
declare module '../../' {
|
||||
interface HintHelpers {
|
||||
javascript: HintFunction;
|
||||
coffeescript: HintFunction;
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
/**
|
||||
* Provides a framework for showing autocompletion hints. Defines editor.showHint, which takes an optional
|
||||
* options object, and pops up a widget that allows the user to select a completion. Finding hints is done with
|
||||
* a hinting functions (the hint option), which is a function that take an editor instance and options object,
|
||||
* and return a {list, from, to} object, where list is an array of strings or objects (the completions), and
|
||||
* from and to give the start and end of the token that is being completed as {line, ch} objects. An optional
|
||||
* selectedHint property (an integer) can be added to the completion object to control the initially selected hint.
|
||||
*/
|
||||
function showHint(cm: Editor, hinter?: HintFunction, options?: ShowHintOptions): void;
|
||||
|
||||
function on<T extends keyof CompletionEventMap>(hints: Hints, eventName: T, handler: CompletionEventMap[T]): void;
|
||||
function off<T extends keyof CompletionEventMap>(hints: Hints, eventName: T, handler: CompletionEventMap[T]): void;
|
||||
function signal<T extends keyof CompletionEventMap>(hints: Hints, eventName: T, ...args: Parameters<CompletionEventMap[T]>): void;
|
||||
|
||||
interface CompletionEventMap {
|
||||
shown: () => void;
|
||||
select: (completion: Hint | string, element: Element) => void;
|
||||
pick: (completion: Hint | string) => void;
|
||||
close: () => void;
|
||||
}
|
||||
|
||||
interface Hints {
|
||||
from: Position;
|
||||
to: Position;
|
||||
list: Array<Hint | string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used by showHint.js Codemirror add-on
|
||||
* When completions aren't simple strings, they should be objects with the following properties:
|
||||
*/
|
||||
interface Hint {
|
||||
text: string;
|
||||
className?: string | undefined;
|
||||
displayText?: string | undefined;
|
||||
from?: Position | undefined;
|
||||
/** Called if a completion is picked. If provided *you* are responsible for applying the completion */
|
||||
hint?: ((cm: Editor, data: Hints, cur: Hint) => void) | undefined;
|
||||
render?: ((element: HTMLLIElement, data: Hints, cur: Hint) => void) | undefined;
|
||||
to?: Position | undefined;
|
||||
}
|
||||
|
||||
interface EditorEventMap {
|
||||
startCompletion: (instance: Editor) => void;
|
||||
endCompletion: (instance: Editor) => void;
|
||||
}
|
||||
|
||||
interface Editor {
|
||||
showHint(options?: ShowHintOptions): void;
|
||||
closeHint(): void;
|
||||
}
|
||||
|
||||
interface CommandActions {
|
||||
/* An extension of the existing CodeMirror typings for the autocomplete command */
|
||||
autocomplete: typeof showHint;
|
||||
}
|
||||
|
||||
interface HintFunction {
|
||||
(cm: Editor, options: ShowHintOptions): Hints | null | undefined | PromiseLike<Hints | null | undefined>;
|
||||
}
|
||||
|
||||
interface AsyncHintFunction {
|
||||
(cm: Editor, callback: (hints: Hints | null | undefined) => void, options: ShowHintOptions): void;
|
||||
async: true;
|
||||
}
|
||||
|
||||
interface HintFunctionResolver {
|
||||
resolve(cm: Editor, post: Position): HintFunction | AsyncHintFunction;
|
||||
}
|
||||
|
||||
interface ShowHintOptions {
|
||||
completeSingle?: boolean | undefined;
|
||||
hint?: HintFunction | AsyncHintFunction | HintFunctionResolver | undefined;
|
||||
alignWithWord?: boolean | undefined;
|
||||
closeCharacters?: RegExp | undefined;
|
||||
closeOnPick?: boolean | undefined;
|
||||
closeOnUnfocus?: boolean | undefined;
|
||||
updateOnCursorActivity?: boolean | undefined;
|
||||
completeOnSingleClick?: boolean | undefined;
|
||||
container?: HTMLElement | null | undefined;
|
||||
customKeys?: { [key: string]: ((editor: Editor, handle: CompletionHandle) => void) | string } | null | undefined;
|
||||
extraKeys?: { [key: string]: ((editor: Editor, handle: CompletionHandle) => void) | string } | null | undefined;
|
||||
scrollMargin?: number | undefined;
|
||||
paddingForScrollbar?: boolean | undefined;
|
||||
moveOnOverlap?: boolean | undefined;
|
||||
words?: ReadonlyArray<string> | undefined; // used by fromList
|
||||
}
|
||||
|
||||
/** The Handle used to interact with the autocomplete dialog box. */
|
||||
interface CompletionHandle {
|
||||
moveFocus(n: number, avoidWrap: boolean): void;
|
||||
setFocus(n: number): void;
|
||||
menuSize(): number;
|
||||
length: number;
|
||||
close(): void;
|
||||
pick(): void;
|
||||
data: any;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
showHint?: boolean | undefined;
|
||||
hintOptions?: ShowHintOptions | undefined;
|
||||
}
|
||||
|
||||
interface HintHelpers {
|
||||
auto: HintFunctionResolver;
|
||||
fromList: HintFunction;
|
||||
}
|
||||
|
||||
const hint: HintHelpers;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import './show-hint';
|
||||
|
||||
declare module '../../' {
|
||||
interface HintHelpers {
|
||||
sql: HintFunction;
|
||||
}
|
||||
|
||||
interface SqlHintTable {
|
||||
columns: string[];
|
||||
}
|
||||
|
||||
interface ShowHintOptions {
|
||||
tables?: ReadonlyArray<string | { text: string, columns: string[] }> | Record<string, string[] | { columns: string[] }> | undefined;
|
||||
defaultTable?: string | undefined;
|
||||
disableKeywords?: boolean | undefined;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import './show-hint';
|
||||
|
||||
declare module '../../' {
|
||||
interface HintHelpers {
|
||||
xml: HintFunction;
|
||||
}
|
||||
|
||||
interface ShowHintOptions {
|
||||
schemaInfo?: any;
|
||||
quoteChar?: string | undefined;
|
||||
matchInMiddle?: boolean | undefined;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { Linter } from './lint';
|
||||
|
||||
declare module '../../' {
|
||||
namespace lint {
|
||||
const coffeescript: Linter<{}>;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { Linter } from './lint';
|
||||
|
||||
declare module '../../' {
|
||||
namespace lint {
|
||||
const css: Linter<any>;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { Linter } from './lint';
|
||||
|
||||
declare module '../../' {
|
||||
namespace lint {
|
||||
const html: Linter<any>;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { Linter } from './lint';
|
||||
|
||||
declare module '../../' {
|
||||
namespace lint {
|
||||
const javascript: Linter<any>;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { Linter } from './lint';
|
||||
|
||||
declare module '../../' {
|
||||
namespace lint {
|
||||
const json: Linter<{}>;
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
import * as CodeMirror from '../../';
|
||||
|
||||
export interface BaseLintStateOptions<T> {
|
||||
/** debounce delay before linting onChange */
|
||||
delay?: number | undefined;
|
||||
|
||||
/** callback to modify an annotation before display */
|
||||
formatAnnotation?: ((annotation: Annotation) => Annotation) | undefined;
|
||||
|
||||
/** whether to lint onChange event */
|
||||
lintOnChange?: boolean | undefined;
|
||||
|
||||
selfContain?: boolean | undefined;
|
||||
|
||||
/** callback after linter completes */
|
||||
onUpdateLinting?(annotationsNotSorted: Annotation[], annotations: Annotation[], codeMirror: CodeMirror.Editor): void;
|
||||
|
||||
/**
|
||||
* Passing rules in `options` property prevents JSHint (and other linters) from complaining
|
||||
* about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
|
||||
*/
|
||||
options?: T | undefined;
|
||||
|
||||
/** controls display of lint tooltips */
|
||||
tooltips?: boolean | 'gutter' | undefined;
|
||||
}
|
||||
|
||||
export interface SyncLintStateOptions<T> extends BaseLintStateOptions<T> {
|
||||
async?: false | undefined;
|
||||
getAnnotations?: Linter<T> | undefined;
|
||||
}
|
||||
|
||||
export interface AsyncLintStateOptions<T> extends BaseLintStateOptions<T> {
|
||||
/** specifies that the lint process runs asynchronously */
|
||||
async: true;
|
||||
getAnnotations?: AsyncLinter<T> | undefined;
|
||||
}
|
||||
|
||||
export type LintStateOptions<T> = SyncLintStateOptions<T> | AsyncLintStateOptions<T>;
|
||||
|
||||
/**
|
||||
* A function that return errors found during the linting process.
|
||||
*/
|
||||
export interface Linter<T> {
|
||||
(content: string, options: T, codeMirror: CodeMirror.Editor):
|
||||
| Annotation[]
|
||||
| PromiseLike<Annotation[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that calls the updateLintingCallback with any errors found during the linting process.
|
||||
*/
|
||||
export interface AsyncLinter<T> {
|
||||
(
|
||||
content: string,
|
||||
updateLintingCallback: UpdateLintingCallback,
|
||||
options: T,
|
||||
codeMirror: CodeMirror.Editor,
|
||||
): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that, given an array of annotations, updates the CodeMirror linting GUI with those annotations
|
||||
*/
|
||||
export interface UpdateLintingCallback {
|
||||
(annotations: Annotation[]): void;
|
||||
(codeMirror: CodeMirror.Editor, annotations: Annotation[]): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* An annotation contains a description of a lint error, detailing the location of the error within the code, the severity of the error,
|
||||
* and an explaination as to why the error was thrown.
|
||||
*/
|
||||
export interface Annotation {
|
||||
from: CodeMirror.Position;
|
||||
message?: string | undefined;
|
||||
severity?: string | undefined;
|
||||
to?: CodeMirror.Position | undefined;
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
interface Editor {
|
||||
performLint: () => void;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/** Optional lint configuration to be used in conjunction with CodeMirror's linter addon. */
|
||||
lint?: boolean | LintStateOptions<any> | Linter<any> | undefined;
|
||||
}
|
||||
|
||||
namespace lint {}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { Linter } from './lint';
|
||||
|
||||
declare module '../../' {
|
||||
namespace lint {
|
||||
const yaml: Linter<{}>;
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
import * as CodeMirror from '../../';
|
||||
|
||||
/**
|
||||
* Tracks changes in chunks from original to new.
|
||||
*/
|
||||
export interface MergeViewDiffChunk {
|
||||
editFrom: number;
|
||||
editTo: number;
|
||||
origFrom: number;
|
||||
origTo: number;
|
||||
}
|
||||
|
||||
export interface DiffView {
|
||||
/**
|
||||
* Forces the view to reload.
|
||||
*/
|
||||
forceUpdate(): (mode: string) => void;
|
||||
|
||||
/**
|
||||
* Sets whether or not the merge view should show the differences between the editor views.
|
||||
*/
|
||||
setShowDifferences(showDifferences: boolean): void;
|
||||
}
|
||||
|
||||
export interface MergeView {
|
||||
/**
|
||||
* Returns the editor instance.
|
||||
*/
|
||||
editor(): CodeMirror.Editor;
|
||||
|
||||
/**
|
||||
* Left side of the merge view.
|
||||
*/
|
||||
left?: DiffView | undefined;
|
||||
leftChunks(): MergeViewDiffChunk[] | undefined;
|
||||
leftOriginal(): CodeMirror.Editor | undefined;
|
||||
|
||||
/**
|
||||
* Right side of the merge view.
|
||||
*/
|
||||
right?: DiffView | undefined;
|
||||
rightChunks(): MergeViewDiffChunk[] | undefined;
|
||||
rightOriginal(): CodeMirror.Editor | undefined;
|
||||
|
||||
/**
|
||||
* Sets whether or not the merge view should show the differences between the editor views.
|
||||
*/
|
||||
setShowDifferences(showDifferences: boolean): void;
|
||||
}
|
||||
|
||||
export interface MergeViewConstructor {
|
||||
new (element: HTMLElement, options?: MergeViewConfiguration): MergeView;
|
||||
(element: HTMLElement, options?: MergeViewConfiguration): MergeView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options available to MergeView.
|
||||
*/
|
||||
export interface MergeViewConfiguration extends CodeMirror.EditorConfiguration {
|
||||
/**
|
||||
* Determines whether the original editor allows editing. Defaults to false.
|
||||
*/
|
||||
allowEditingOriginals?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* When true stretches of unchanged text will be collapsed. When a number is given, this indicates the amount
|
||||
* of lines to leave visible around such stretches (which defaults to 2). Defaults to false.
|
||||
*/
|
||||
collapseIdentical?: boolean | number | undefined;
|
||||
|
||||
/**
|
||||
* Sets the style used to connect changed chunks of code. By default, connectors are drawn. When this is set to "align",
|
||||
* the smaller chunk is padded to align with the bigger chunk instead.
|
||||
*/
|
||||
connect?: string | undefined;
|
||||
|
||||
/**
|
||||
* Callback for when stretches of unchanged text are collapsed.
|
||||
*/
|
||||
onCollapse?(mergeView: MergeView, line: number, size: number, mark: CodeMirror.TextMarker<CodeMirror.MarkerRange>): void;
|
||||
|
||||
/**
|
||||
* Provides original version of the document to be shown on the right of the editor.
|
||||
*/
|
||||
orig?: string | undefined;
|
||||
|
||||
/**
|
||||
* Provides original version of the document to be shown on the left of the editor.
|
||||
* To create a 2-way (as opposed to 3-way) merge view, provide only one of origLeft and origRight.
|
||||
*/
|
||||
origLeft?: string | undefined;
|
||||
|
||||
/**
|
||||
* Provides original version of document to be shown on the right of the editor.
|
||||
* To create a 2-way (as opposed to 3-way) merge view, provide only one of origLeft and origRight.
|
||||
*/
|
||||
origRight?: string | undefined;
|
||||
|
||||
/**
|
||||
* Determines whether buttons that allow the user to revert changes are shown. Defaults to true.
|
||||
*/
|
||||
revertButtons?: boolean | undefined;
|
||||
|
||||
revertChunk?: ((
|
||||
mv: MergeView,
|
||||
from: CodeMirror.Editor,
|
||||
fromStart: CodeMirror.Position,
|
||||
fromEnd: CodeMirror.Position,
|
||||
to: CodeMirror.Editor,
|
||||
toStart: CodeMirror.Position,
|
||||
toEnd: CodeMirror.Position
|
||||
) => void) | undefined;
|
||||
|
||||
/**
|
||||
* When true, changed pieces of text are highlighted. Defaults to true.
|
||||
*/
|
||||
showDifferences?: boolean | undefined;
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
const MergeView: MergeViewConstructor;
|
||||
|
||||
interface CommandActions {
|
||||
/** Move cursor to the next diff */
|
||||
goNextDiff(cm: Editor): void;
|
||||
|
||||
/** Move cursor to the previous diff */
|
||||
goPrevDiff(cm: Editor): void;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import '../../';
|
||||
|
||||
export interface RequireModeOptions {
|
||||
path?(mode: string): string;
|
||||
loadMode?(file: string, callback: () => void): void;
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
let modeURL: string;
|
||||
|
||||
function requireMode(mode: string | { name: string }, callback: () => void, options?: RequireModeOptions): void;
|
||||
|
||||
function autoLoadMode(instance: Editor, mode: string, options?: RequireModeOptions): void;
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
import * as CodeMirror from '../../';
|
||||
|
||||
export interface MultiplexedInnerMode {
|
||||
open: string;
|
||||
close: string;
|
||||
mode: CodeMirror.Mode<any>;
|
||||
parseDelimiters?: boolean | undefined;
|
||||
delimStyle?: string | undefined;
|
||||
innerStyle?: string | undefined;
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
/**
|
||||
* Mode combinator that can be used to easily 'multiplex' between several modes.
|
||||
* When given as first argument a mode object, and as other arguments any number of
|
||||
* {open, close, mode [, delimStyle, innerStyle, parseDelimiters]} objects, it will return a mode object that starts parsing
|
||||
* using the mode passed as first argument, but will switch to another mode as soon as it encounters a string that occurs in
|
||||
* one of the open fields of the passed objects. When in a sub-mode, it will go back to the top mode again when the close
|
||||
* string is encountered. Pass "\n" for open or close if you want to switch on a blank line.
|
||||
*
|
||||
* When delimStyle is specified, it will be the token style returned for the delimiter tokens (as well as [delimStyle]-open on
|
||||
* the opening token and [delimStyle]-close on the closing token).
|
||||
* When innerStyle is specified, it will be the token style added for each inner mode token.
|
||||
* When parseDelimiters is true, the content of the delimiters will also be passed to the inner mode. (And delimStyle is ignored.)
|
||||
*
|
||||
* The outer mode will not see the content between the delimiters.
|
||||
*/
|
||||
function multiplexingMode(outer: Mode<any>, ...others: MultiplexedInnerMode[]): Mode<any>;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
/**
|
||||
* Mode combinator that can be used to extend a mode with an 'overlay' — a secondary mode is run over the stream,
|
||||
* along with the base mode, and can color specific pieces of text without interfering with the base mode.
|
||||
*/
|
||||
function overlayMode(base: Mode<any>, overlay: Mode<any>, combine?: boolean): Mode<any>;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
// Based on https://codemirror.net/demo/simplemode.html
|
||||
interface Rule {
|
||||
regex?: string | RegExp | undefined;
|
||||
token?: string | string[] | null | undefined;
|
||||
sol?: boolean | undefined;
|
||||
next?: string | undefined;
|
||||
push?: string | undefined;
|
||||
pop?: boolean | undefined;
|
||||
mode?: {
|
||||
spec: string | ModeSpec<any>;
|
||||
end?: RegExp | undefined;
|
||||
persistent?: boolean | undefined;
|
||||
} | undefined;
|
||||
indent?: boolean | undefined;
|
||||
dedent?: boolean | undefined;
|
||||
dedentIfLineStart?: boolean | undefined;
|
||||
}
|
||||
|
||||
function defineSimpleMode<K extends string>(
|
||||
name: string,
|
||||
// eslint-disable-next-line no-unnecessary-generics
|
||||
mode: { [P in K]: P extends 'meta' ? Record<string, any> : Rule[] } & { start: Rule[] },
|
||||
): void;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
/**
|
||||
* Provides a convenient way to syntax-highlight code snippets in a webpage. Depends on the runmode addon (or its standalone variant).
|
||||
* Can be called with an array (or other array-ish collection) of DOM nodes that represent the code snippets. By default, it'll get all pre tags.
|
||||
* Will read the data-lang attribute of these nodes to figure out their language, and syntax-color their content using the relevant CodeMirror
|
||||
* mode (you'll have to load the scripts for the relevant modes yourself).
|
||||
* A second argument may be provided to give a default mode, used when no language attribute is found for a node.
|
||||
*/
|
||||
function colorize(collection?: ArrayLike<Element>, defaultMode?: string): void;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
/**
|
||||
* Runs a CodeMirror mode over text without opening an editor instance.
|
||||
*
|
||||
* @param text The document to run through the highlighter.
|
||||
* @param mode The mode to use (must be loaded as normal).
|
||||
* @param callback If this is a function, it will be called for each token with
|
||||
* five arguments, the token's text, the token's style class (may be null for unstyled tokens),
|
||||
* the number of row of the token, the column position of token and the state of mode.
|
||||
* If it is a DOM node, the tokens will be converted to span elements as in an editor,
|
||||
* and inserted into the node (through innerHTML).
|
||||
*/
|
||||
function runMode(
|
||||
text: string,
|
||||
mode: string | ModeSpec<unknown>,
|
||||
callback:
|
||||
| HTMLElement
|
||||
| ((text: string, style?: string | null, row?: number, column?: number, state?: any) => void),
|
||||
options?: { tabSize?: number | undefined; state?: any },
|
||||
): void;
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import * as CodeMirror from '../..';
|
||||
import './searchcursor';
|
||||
|
||||
export interface Annotation {
|
||||
clear(): void;
|
||||
/**
|
||||
* Updates the ranges to be highlighted. The array must be sorted.
|
||||
*/
|
||||
update(annotations: Array<{ from: CodeMirror.Position, to: CodeMirror.Position }>): void;
|
||||
}
|
||||
|
||||
export interface AnnotateScrollbarOptions {
|
||||
className: string;
|
||||
scrollButtonHeight?: number | undefined;
|
||||
listenForChanges?: boolean | undefined;
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
interface Editor {
|
||||
annotateScrollbar(options: string | AnnotateScrollbarOptions): Annotation;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
scrollButtonHeight?: number | undefined;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* When the end of the file is reached it allows you to keep scrolling so that your last few lines of code are not stuck at the bottom of the editor.
|
||||
*/
|
||||
scrollPastEnd?: boolean | undefined;
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface ScrollbarModels {
|
||||
simple: ScrollbarModelConstructor;
|
||||
overlay: ScrollbarModelConstructor;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import '../..';
|
||||
import '../dialog/dialog';
|
||||
|
||||
declare module '../../' {
|
||||
interface CommandActions {
|
||||
jumpToLine(cm: Editor): void;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
search?: {
|
||||
bottom: boolean;
|
||||
} | undefined;
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_match-highlighter
|
||||
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface HighlightSelectionMatches {
|
||||
/**
|
||||
* Minimum amount of selected characters that triggers a highlight (default 2).
|
||||
*/
|
||||
minChars?: number | undefined;
|
||||
|
||||
/**
|
||||
* The style to be used to highlight the matches (default "matchhighlight", which will correspond to CSS class cm-matchhighlight).
|
||||
*/
|
||||
style?: string | undefined;
|
||||
|
||||
/**
|
||||
* Controls whether whitespace is trimmed from the selection.
|
||||
*/
|
||||
trim?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Can be set to true or to a regexp matching the characters that make up a word.
|
||||
*/
|
||||
showToken?: boolean | RegExp | undefined;
|
||||
|
||||
/**
|
||||
* Used to specify how much time to wait, in milliseconds, before highlighting the matches (default is 100).
|
||||
*/
|
||||
delay?: number | undefined;
|
||||
|
||||
/**
|
||||
* If wordsOnly is enabled, the matches will be highlighted only if the selected text is a word.
|
||||
*/
|
||||
wordsOnly?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* If annotateScrollbar is enabled, the occurences will be highlighted on the scrollbar via the matchesonscrollbar addon.
|
||||
*/
|
||||
annotateScrollbar?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Adds a highlightSelectionMatches option that can be enabled to highlight all instances of a currently selected word.
|
||||
* When enabled, it causes the current word to be highlighted when nothing is selected (defaults to off).
|
||||
*/
|
||||
highlightSelectionMatches?: HighlightSelectionMatches | boolean | undefined;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import '../..';
|
||||
import './searchcursor';
|
||||
|
||||
export interface SearchAnnotation {
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
interface Editor {
|
||||
showMatchesOnScrollbar(query: string | RegExp, caseFold?: boolean, className?: string): SearchAnnotation;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import '../../';
|
||||
import './searchcursor';
|
||||
import '../dialog/dialog';
|
||||
|
||||
declare module '../../' {
|
||||
interface CommandActions {
|
||||
find(cm: Editor): void;
|
||||
findPersistent(cm: Editor): void;
|
||||
findPersistentNext(cm: Editor): void;
|
||||
findPersistentPrev(cm: Editor): void;
|
||||
findNext(cm: Editor): void;
|
||||
findPrev(cm: Editor): void;
|
||||
clearSearch(cm: Editor): void;
|
||||
replace(cm: Editor): void;
|
||||
replaceAll(cm: Editor): void;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
search?: {
|
||||
bottom: boolean;
|
||||
} | undefined;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface DocOrEditor {
|
||||
/**
|
||||
* This method can be used to implement search/replace functionality.
|
||||
* `query`: This can be a regular * expression or a string (only strings will match across lines -
|
||||
* if they contain newlines).
|
||||
* `start`: This provides the starting position of the search. It can be a `{line, ch} object,
|
||||
* or can be left off to default to the start of the document
|
||||
* `caseFold`: This is only relevant when matching a string. IT will cause the search to be case-insenstive
|
||||
*/
|
||||
getSearchCursor(query: string | RegExp, start?: Position, caseFold?: boolean): SearchCursor;
|
||||
}
|
||||
|
||||
interface SearchCursor {
|
||||
/**
|
||||
* Searches forward or backward from the current position. The return value indicates whether a match was
|
||||
* found. If matching a regular expression, the return value will be the array returned by the match method, in case
|
||||
* you want to extract matched groups
|
||||
*/
|
||||
find(reverse: boolean): boolean | RegExpMatchArray;
|
||||
|
||||
/**
|
||||
* Searches forward from the current position. The return value indicates whether a match was
|
||||
* found. If matching a regular expression, the return value will be the array returned by the match method, in case
|
||||
* you want to extract matched groups
|
||||
*/
|
||||
findNext(): boolean | RegExpMatchArray;
|
||||
|
||||
/**
|
||||
* Searches backward from the current position. The return value indicates whether a match was
|
||||
* found. If matching a regular expression, the return value will be the array returned by the match method, in case
|
||||
* you want to extract matched groups
|
||||
*/
|
||||
findPrevious(): boolean | RegExpMatchArray;
|
||||
|
||||
/**
|
||||
* Only valid when the last call to find, findNext, or findPrevious did not return false. Returns {line, ch}
|
||||
* objects pointing the start of the match.
|
||||
*/
|
||||
from(): Position;
|
||||
|
||||
/**
|
||||
* Only valid when the last call to find, findNext, or findPrevious did not return false. Returns {line, ch}
|
||||
* objects pointing the end of the match.
|
||||
*/
|
||||
to(): Position;
|
||||
|
||||
/** Replaces the currently found match with the given text and adjusts the cursor position to reflect the deplacement. */
|
||||
replace(text: string, origin?: string): void;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface StyleActiveLine {
|
||||
/**
|
||||
* Controls whether single-line selections, or just cursor selections, are styled. Defaults to false (only cursor selections).
|
||||
*/
|
||||
nonEmpty: boolean;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* When enabled gives the wrapper of the line that contains the cursor the class CodeMirror-activeline,
|
||||
* adds a background with the class CodeMirror-activeline-background, and adds the class CodeMirror-activeline-gutter to the line's gutter space is enabled.
|
||||
*/
|
||||
styleActiveLine?: StyleActiveLine | boolean | undefined;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Causes the selected text to be marked with the CSS class CodeMirror-selectedtext or a custom class when the styleSelectedText option is enabled.
|
||||
* Useful to change the colour of the selection (in addition to the background).
|
||||
*/
|
||||
styleSelectedText?: boolean | string | undefined;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Controls the mouse cursor appearance when hovering over the selection. It can be set to a string, like "pointer", or to true,
|
||||
* in which case the "default" (arrow) cursor will be used.
|
||||
*/
|
||||
selectionPointer?: boolean | string | undefined;
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_tern and https://codemirror.net/addon/tern/tern.js (comments in the beginning of the file)
|
||||
// Docs for tern itself might also be helpful: http://ternjs.net/doc/manual.html
|
||||
|
||||
import * as Tern from 'tern';
|
||||
import '../../';
|
||||
|
||||
declare module '../../' {
|
||||
class TernServer {
|
||||
constructor(options?: TernOptions);
|
||||
|
||||
readonly options: TernOptions;
|
||||
readonly docs: {
|
||||
readonly [key: string]: {
|
||||
doc: Doc;
|
||||
name: string;
|
||||
changed: {
|
||||
from: number;
|
||||
to: number;
|
||||
} | null;
|
||||
};
|
||||
};
|
||||
readonly server: Tern.Server;
|
||||
addDoc(
|
||||
name: string,
|
||||
doc: Doc,
|
||||
): { doc: Doc; name: string; changed: { from: number; to: number } | null };
|
||||
delDoc(id: string | Editor | Doc): void;
|
||||
hideDoc(id: string | Editor | Doc): void;
|
||||
complete(cm: Editor): void;
|
||||
showType(cm: Editor, pos?: Position, callback?: () => void): void;
|
||||
showDocs(cm: Editor, pos?: Position, callback?: () => void): void;
|
||||
updateArgHints(cm: Editor): void;
|
||||
jumpToDef(cm: Editor): void;
|
||||
jumpBack(cm: Editor): void;
|
||||
rename(cm: Editor): void;
|
||||
selectName(cm: Editor): void;
|
||||
request<Q extends Tern.Query>(
|
||||
cm: Doc,
|
||||
query: Q,
|
||||
callback: (error?: Error, data?: Tern.QueryResult<Q>) => void,
|
||||
pos?: Position,
|
||||
): void;
|
||||
request<Q extends Tern.Query['type']>(
|
||||
cm: Doc,
|
||||
query: Q,
|
||||
callback: (error?: Error, data?: Tern.QueryRegistry[Q]['result']) => void,
|
||||
pos?: Position,
|
||||
): void;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
interface TernOptions {
|
||||
/** An object mapping plugin names to configuration options. */
|
||||
plugins?: Tern.ConstructorOptions['plugins'] | undefined;
|
||||
/** An array of JSON definition data structures. */
|
||||
defs?: Tern.Def[] | undefined;
|
||||
/**
|
||||
* Can be used to access files in
|
||||
* the project that haven't been loaded yet. Simply do callback(null) to
|
||||
* indicate that a file is not available.
|
||||
*/
|
||||
getFile?(name: string, callback: (docValue: string | null) => any): any;
|
||||
/**
|
||||
* This function will be applied
|
||||
* to documents before passing them on to Tern.
|
||||
*/
|
||||
fileFilter?(value: string, docName: string, doc: Doc): string;
|
||||
/** This function should, when providing a multi-file view, switch the view or focus to the named file. */
|
||||
switchToDoc?(name: string, doc: Doc): void;
|
||||
/** Can be used to override the way errors are displayed. */
|
||||
showError?(editor: Editor, message: Error | string): void;
|
||||
/**
|
||||
* Customize the content in tooltips for completions.
|
||||
* Is passed a single argument — the completion's data as returned by
|
||||
* Tern — and may return a string, DOM node, or null to indicate that
|
||||
* no tip should be shown. By default the docstring is shown.
|
||||
*/
|
||||
completionTip?(data: Tern.CompletionsQueryResult): string | HTMLElement | null;
|
||||
/** Like completionTip, but for the tooltips shown for type queries. */
|
||||
typeTip?(data: Tern.TypeQueryResult): string | HTMLElement | null;
|
||||
/** This function will be applied to the Tern responses before treating them */
|
||||
responseFilter?<Q extends Tern.Query>(
|
||||
doc: Doc,
|
||||
query: Q,
|
||||
request: Tern.Document,
|
||||
error: Error | undefined,
|
||||
data: Tern.QueryResult<Q> | undefined,
|
||||
): Tern.QueryResult<Q> | undefined;
|
||||
/**
|
||||
* Set to true to enable web worker mode. You'll probably
|
||||
* want to feature detect the actual value you use here, for example
|
||||
* !!window.Worker.
|
||||
*/
|
||||
useWorker?: boolean | undefined;
|
||||
/** The main script of the worker. Point this to wherever you are hosting worker.js from this directory. */
|
||||
workerScript?: string | undefined;
|
||||
/**
|
||||
* An array of paths pointing (relative to workerScript)
|
||||
* to the Acorn and Tern libraries and any Tern plugins you want to
|
||||
* load. Or, if you minified those into a single script and included
|
||||
* them in the workerScript, simply leave this undefined.
|
||||
*/
|
||||
workerDeps?: string[] | undefined;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import '../../';
|
||||
|
||||
export interface HardwrapOptions {
|
||||
column?: number | undefined;
|
||||
paragraphStart?: RegExp | undefined;
|
||||
paragraphEnd?: RegExp | undefined;
|
||||
wrapOn?: RegExp | undefined;
|
||||
killTrailingSpace?: boolean | undefined;
|
||||
forceBreak?: boolean | undefined;
|
||||
}
|
||||
|
||||
declare module '../../' {
|
||||
interface CommandActions {
|
||||
wrapLines(cm: Editor): void;
|
||||
}
|
||||
|
||||
interface Editor {
|
||||
/** Wraps the paragraph at the given position. If pos is not given, it defaults to the cursor position. */
|
||||
wrapParagraph(pos?: Position, options?: HardwrapOptions): void;
|
||||
/** Wraps the given range as one big paragraph. */
|
||||
wrapRange(from: Position, to: Position, options?: HardwrapOptions): void;
|
||||
/** Wraps the paragraphs in (and overlapping with) the given range individually. */
|
||||
wrapParagraphsInRange(from: Position, to: Position, options?: HardwrapOptions): void;
|
||||
}
|
||||
}
|
||||
+2018
File diff suppressed because it is too large
Load Diff
+19
@@ -0,0 +1,19 @@
|
||||
import '../';
|
||||
|
||||
export interface ModeInfo {
|
||||
name: string;
|
||||
mime?: string | undefined;
|
||||
mimes?: string[] | undefined;
|
||||
mode: string;
|
||||
file?: RegExp | undefined;
|
||||
ext?: string[] | undefined;
|
||||
alias?: string[] | undefined;
|
||||
}
|
||||
|
||||
declare module '../' {
|
||||
const modeInfo: ModeInfo[];
|
||||
function findModeByMIME(mime: string): ModeInfo | undefined;
|
||||
function findModeByExtension(ext: string): ModeInfo | undefined;
|
||||
function findModeByFileName(filename: string): ModeInfo | undefined;
|
||||
function findModeByName(name: string): ModeInfo | undefined;
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"name": "@types/codemirror",
|
||||
"version": "5.60.8",
|
||||
"description": "TypeScript definitions for codemirror",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/codemirror",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "mihailik",
|
||||
"url": "https://github.com/mihailik",
|
||||
"githubUsername": "mihailik"
|
||||
},
|
||||
{
|
||||
"name": "nrbernard",
|
||||
"url": "https://github.com/nrbernard",
|
||||
"githubUsername": "nrbernard"
|
||||
},
|
||||
{
|
||||
"name": "Pr1st0n",
|
||||
"url": "https://github.com/Pr1st0n",
|
||||
"githubUsername": "Pr1st0n"
|
||||
},
|
||||
{
|
||||
"name": "rileymiller",
|
||||
"url": "https://github.com/rileymiller",
|
||||
"githubUsername": "rileymiller"
|
||||
},
|
||||
{
|
||||
"name": "toddself",
|
||||
"url": "https://github.com/toddself",
|
||||
"githubUsername": "toddself"
|
||||
},
|
||||
{
|
||||
"name": "ysulyma",
|
||||
"url": "https://github.com/ysulyma",
|
||||
"githubUsername": "ysulyma"
|
||||
},
|
||||
{
|
||||
"name": "azoson",
|
||||
"url": "https://github.com/azoson",
|
||||
"githubUsername": "azoson"
|
||||
},
|
||||
{
|
||||
"name": "kylesferrazza",
|
||||
"url": "https://github.com/kylesferrazza",
|
||||
"githubUsername": "kylesferrazza"
|
||||
},
|
||||
{
|
||||
"name": "fityocsaba96",
|
||||
"url": "https://github.com/fityocsaba96",
|
||||
"githubUsername": "fityocsaba96"
|
||||
},
|
||||
{
|
||||
"name": "koddsson",
|
||||
"url": "https://github.com/koddsson",
|
||||
"githubUsername": "koddsson"
|
||||
},
|
||||
{
|
||||
"name": "ficristo",
|
||||
"url": "https://github.com/ficristo",
|
||||
"githubUsername": "ficristo"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/codemirror"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"@types/tern": "*"
|
||||
},
|
||||
"typesPublisherContentHash": "64b28144f15e38a052d3e147287e7458a3164d122c8eab6ab7efda34dd9aa41d",
|
||||
"typeScriptVersion": "5.0"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
# Installation
|
||||
> `npm install --save @types/estree`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for estree (https://github.com/estree/estree).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Fri, 06 Jun 2025 00:04:33 GMT
|
||||
* Dependencies: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [RReverser](https://github.com/RReverser).
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
declare namespace ESTree {
|
||||
interface FlowTypeAnnotation extends Node {}
|
||||
|
||||
interface FlowBaseTypeAnnotation extends FlowTypeAnnotation {}
|
||||
|
||||
interface FlowLiteralTypeAnnotation extends FlowTypeAnnotation, Literal {}
|
||||
|
||||
interface FlowDeclaration extends Declaration {}
|
||||
|
||||
interface AnyTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface ArrayTypeAnnotation extends FlowTypeAnnotation {
|
||||
elementType: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface BooleanLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
||||
|
||||
interface BooleanTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface ClassImplements extends Node {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterInstantiation | null;
|
||||
}
|
||||
|
||||
interface ClassProperty {
|
||||
key: Expression;
|
||||
value?: Expression | null;
|
||||
typeAnnotation?: TypeAnnotation | null;
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface DeclareClass extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
body: ObjectTypeAnnotation;
|
||||
extends: InterfaceExtends[];
|
||||
}
|
||||
|
||||
interface DeclareFunction extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface DeclareModule extends FlowDeclaration {
|
||||
id: Literal | Identifier;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
interface DeclareVariable extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface FunctionTypeAnnotation extends FlowTypeAnnotation {
|
||||
params: FunctionTypeParam[];
|
||||
returnType: FlowTypeAnnotation;
|
||||
rest?: FunctionTypeParam | null;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
}
|
||||
|
||||
interface FunctionTypeParam {
|
||||
name: Identifier;
|
||||
typeAnnotation: FlowTypeAnnotation;
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
interface GenericTypeAnnotation extends FlowTypeAnnotation {
|
||||
id: Identifier | QualifiedTypeIdentifier;
|
||||
typeParameters?: TypeParameterInstantiation | null;
|
||||
}
|
||||
|
||||
interface InterfaceExtends extends Node {
|
||||
id: Identifier | QualifiedTypeIdentifier;
|
||||
typeParameters?: TypeParameterInstantiation | null;
|
||||
}
|
||||
|
||||
interface InterfaceDeclaration extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
extends: InterfaceExtends[];
|
||||
body: ObjectTypeAnnotation;
|
||||
}
|
||||
|
||||
interface IntersectionTypeAnnotation extends FlowTypeAnnotation {
|
||||
types: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface MixedTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface NullableTypeAnnotation extends FlowTypeAnnotation {
|
||||
typeAnnotation: TypeAnnotation;
|
||||
}
|
||||
|
||||
interface NumberLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
||||
|
||||
interface NumberTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface StringLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
||||
|
||||
interface StringTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface TupleTypeAnnotation extends FlowTypeAnnotation {
|
||||
types: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface TypeofTypeAnnotation extends FlowTypeAnnotation {
|
||||
argument: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeAlias extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
right: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeAnnotation extends Node {
|
||||
typeAnnotation: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeCastExpression extends Expression {
|
||||
expression: Expression;
|
||||
typeAnnotation: TypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeParameterDeclaration extends Node {
|
||||
params: Identifier[];
|
||||
}
|
||||
|
||||
interface TypeParameterInstantiation extends Node {
|
||||
params: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface ObjectTypeAnnotation extends FlowTypeAnnotation {
|
||||
properties: ObjectTypeProperty[];
|
||||
indexers: ObjectTypeIndexer[];
|
||||
callProperties: ObjectTypeCallProperty[];
|
||||
}
|
||||
|
||||
interface ObjectTypeCallProperty extends Node {
|
||||
value: FunctionTypeAnnotation;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface ObjectTypeIndexer extends Node {
|
||||
id: Identifier;
|
||||
key: FlowTypeAnnotation;
|
||||
value: FlowTypeAnnotation;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface ObjectTypeProperty extends Node {
|
||||
key: Expression;
|
||||
value: FlowTypeAnnotation;
|
||||
optional: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface QualifiedTypeIdentifier extends Node {
|
||||
qualification: Identifier | QualifiedTypeIdentifier;
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface UnionTypeAnnotation extends FlowTypeAnnotation {
|
||||
types: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface VoidTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
}
|
||||
+694
@@ -0,0 +1,694 @@
|
||||
// This definition file follows a somewhat unusual format. ESTree allows
|
||||
// runtime type checks based on the `type` parameter. In order to explain this
|
||||
// to typescript we want to use discriminated union types:
|
||||
// https://github.com/Microsoft/TypeScript/pull/9163
|
||||
//
|
||||
// For ESTree this is a bit tricky because the high level interfaces like
|
||||
// Node or Function are pulling double duty. We want to pass common fields down
|
||||
// to the interfaces that extend them (like Identifier or
|
||||
// ArrowFunctionExpression), but you can't extend a type union or enforce
|
||||
// common fields on them. So we've split the high level interfaces into two
|
||||
// types, a base type which passes down inherited fields, and a type union of
|
||||
// all types which extend the base type. Only the type union is exported, and
|
||||
// the union is how other types refer to the collection of inheriting types.
|
||||
//
|
||||
// This makes the definitions file here somewhat more difficult to maintain,
|
||||
// but it has the notable advantage of making ESTree much easier to use as
|
||||
// an end user.
|
||||
|
||||
export interface BaseNodeWithoutComments {
|
||||
// Every leaf interface that extends BaseNode must specify a type property.
|
||||
// The type property should be a string literal. For example, Identifier
|
||||
// has: `type: "Identifier"`
|
||||
type: string;
|
||||
loc?: SourceLocation | null | undefined;
|
||||
range?: [number, number] | undefined;
|
||||
}
|
||||
|
||||
export interface BaseNode extends BaseNodeWithoutComments {
|
||||
leadingComments?: Comment[] | undefined;
|
||||
trailingComments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
export interface NodeMap {
|
||||
AssignmentProperty: AssignmentProperty;
|
||||
CatchClause: CatchClause;
|
||||
Class: Class;
|
||||
ClassBody: ClassBody;
|
||||
Expression: Expression;
|
||||
Function: Function;
|
||||
Identifier: Identifier;
|
||||
Literal: Literal;
|
||||
MethodDefinition: MethodDefinition;
|
||||
ModuleDeclaration: ModuleDeclaration;
|
||||
ModuleSpecifier: ModuleSpecifier;
|
||||
Pattern: Pattern;
|
||||
PrivateIdentifier: PrivateIdentifier;
|
||||
Program: Program;
|
||||
Property: Property;
|
||||
PropertyDefinition: PropertyDefinition;
|
||||
SpreadElement: SpreadElement;
|
||||
Statement: Statement;
|
||||
Super: Super;
|
||||
SwitchCase: SwitchCase;
|
||||
TemplateElement: TemplateElement;
|
||||
VariableDeclarator: VariableDeclarator;
|
||||
}
|
||||
|
||||
export type Node = NodeMap[keyof NodeMap];
|
||||
|
||||
export interface Comment extends BaseNodeWithoutComments {
|
||||
type: "Line" | "Block";
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface SourceLocation {
|
||||
source?: string | null | undefined;
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
/** >= 1 */
|
||||
line: number;
|
||||
/** >= 0 */
|
||||
column: number;
|
||||
}
|
||||
|
||||
export interface Program extends BaseNode {
|
||||
type: "Program";
|
||||
sourceType: "script" | "module";
|
||||
body: Array<Directive | Statement | ModuleDeclaration>;
|
||||
comments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
export interface Directive extends BaseNode {
|
||||
type: "ExpressionStatement";
|
||||
expression: Literal;
|
||||
directive: string;
|
||||
}
|
||||
|
||||
export interface BaseFunction extends BaseNode {
|
||||
params: Pattern[];
|
||||
generator?: boolean | undefined;
|
||||
async?: boolean | undefined;
|
||||
// The body is either BlockStatement or Expression because arrow functions
|
||||
// can have a body that's either. FunctionDeclarations and
|
||||
// FunctionExpressions have only BlockStatement bodies.
|
||||
body: BlockStatement | Expression;
|
||||
}
|
||||
|
||||
export type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
||||
|
||||
export type Statement =
|
||||
| ExpressionStatement
|
||||
| BlockStatement
|
||||
| StaticBlock
|
||||
| EmptyStatement
|
||||
| DebuggerStatement
|
||||
| WithStatement
|
||||
| ReturnStatement
|
||||
| LabeledStatement
|
||||
| BreakStatement
|
||||
| ContinueStatement
|
||||
| IfStatement
|
||||
| SwitchStatement
|
||||
| ThrowStatement
|
||||
| TryStatement
|
||||
| WhileStatement
|
||||
| DoWhileStatement
|
||||
| ForStatement
|
||||
| ForInStatement
|
||||
| ForOfStatement
|
||||
| Declaration;
|
||||
|
||||
export interface BaseStatement extends BaseNode {}
|
||||
|
||||
export interface EmptyStatement extends BaseStatement {
|
||||
type: "EmptyStatement";
|
||||
}
|
||||
|
||||
export interface BlockStatement extends BaseStatement {
|
||||
type: "BlockStatement";
|
||||
body: Statement[];
|
||||
innerComments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
export interface StaticBlock extends Omit<BlockStatement, "type"> {
|
||||
type: "StaticBlock";
|
||||
}
|
||||
|
||||
export interface ExpressionStatement extends BaseStatement {
|
||||
type: "ExpressionStatement";
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface IfStatement extends BaseStatement {
|
||||
type: "IfStatement";
|
||||
test: Expression;
|
||||
consequent: Statement;
|
||||
alternate?: Statement | null | undefined;
|
||||
}
|
||||
|
||||
export interface LabeledStatement extends BaseStatement {
|
||||
type: "LabeledStatement";
|
||||
label: Identifier;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface BreakStatement extends BaseStatement {
|
||||
type: "BreakStatement";
|
||||
label?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
export interface ContinueStatement extends BaseStatement {
|
||||
type: "ContinueStatement";
|
||||
label?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
export interface WithStatement extends BaseStatement {
|
||||
type: "WithStatement";
|
||||
object: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface SwitchStatement extends BaseStatement {
|
||||
type: "SwitchStatement";
|
||||
discriminant: Expression;
|
||||
cases: SwitchCase[];
|
||||
}
|
||||
|
||||
export interface ReturnStatement extends BaseStatement {
|
||||
type: "ReturnStatement";
|
||||
argument?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
export interface ThrowStatement extends BaseStatement {
|
||||
type: "ThrowStatement";
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
export interface TryStatement extends BaseStatement {
|
||||
type: "TryStatement";
|
||||
block: BlockStatement;
|
||||
handler?: CatchClause | null | undefined;
|
||||
finalizer?: BlockStatement | null | undefined;
|
||||
}
|
||||
|
||||
export interface WhileStatement extends BaseStatement {
|
||||
type: "WhileStatement";
|
||||
test: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface DoWhileStatement extends BaseStatement {
|
||||
type: "DoWhileStatement";
|
||||
body: Statement;
|
||||
test: Expression;
|
||||
}
|
||||
|
||||
export interface ForStatement extends BaseStatement {
|
||||
type: "ForStatement";
|
||||
init?: VariableDeclaration | Expression | null | undefined;
|
||||
test?: Expression | null | undefined;
|
||||
update?: Expression | null | undefined;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface BaseForXStatement extends BaseStatement {
|
||||
left: VariableDeclaration | Pattern;
|
||||
right: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface ForInStatement extends BaseForXStatement {
|
||||
type: "ForInStatement";
|
||||
}
|
||||
|
||||
export interface DebuggerStatement extends BaseStatement {
|
||||
type: "DebuggerStatement";
|
||||
}
|
||||
|
||||
export type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
|
||||
|
||||
export interface BaseDeclaration extends BaseStatement {}
|
||||
|
||||
export interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
|
||||
type: "FunctionDeclaration";
|
||||
/** It is null when a function declaration is a part of the `export default function` statement */
|
||||
id: Identifier | null;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
export interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
export interface VariableDeclaration extends BaseDeclaration {
|
||||
type: "VariableDeclaration";
|
||||
declarations: VariableDeclarator[];
|
||||
kind: "var" | "let" | "const" | "using" | "await using";
|
||||
}
|
||||
|
||||
export interface VariableDeclarator extends BaseNode {
|
||||
type: "VariableDeclarator";
|
||||
id: Pattern;
|
||||
init?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
export interface ExpressionMap {
|
||||
ArrayExpression: ArrayExpression;
|
||||
ArrowFunctionExpression: ArrowFunctionExpression;
|
||||
AssignmentExpression: AssignmentExpression;
|
||||
AwaitExpression: AwaitExpression;
|
||||
BinaryExpression: BinaryExpression;
|
||||
CallExpression: CallExpression;
|
||||
ChainExpression: ChainExpression;
|
||||
ClassExpression: ClassExpression;
|
||||
ConditionalExpression: ConditionalExpression;
|
||||
FunctionExpression: FunctionExpression;
|
||||
Identifier: Identifier;
|
||||
ImportExpression: ImportExpression;
|
||||
Literal: Literal;
|
||||
LogicalExpression: LogicalExpression;
|
||||
MemberExpression: MemberExpression;
|
||||
MetaProperty: MetaProperty;
|
||||
NewExpression: NewExpression;
|
||||
ObjectExpression: ObjectExpression;
|
||||
SequenceExpression: SequenceExpression;
|
||||
TaggedTemplateExpression: TaggedTemplateExpression;
|
||||
TemplateLiteral: TemplateLiteral;
|
||||
ThisExpression: ThisExpression;
|
||||
UnaryExpression: UnaryExpression;
|
||||
UpdateExpression: UpdateExpression;
|
||||
YieldExpression: YieldExpression;
|
||||
}
|
||||
|
||||
export type Expression = ExpressionMap[keyof ExpressionMap];
|
||||
|
||||
export interface BaseExpression extends BaseNode {}
|
||||
|
||||
export type ChainElement = SimpleCallExpression | MemberExpression;
|
||||
|
||||
export interface ChainExpression extends BaseExpression {
|
||||
type: "ChainExpression";
|
||||
expression: ChainElement;
|
||||
}
|
||||
|
||||
export interface ThisExpression extends BaseExpression {
|
||||
type: "ThisExpression";
|
||||
}
|
||||
|
||||
export interface ArrayExpression extends BaseExpression {
|
||||
type: "ArrayExpression";
|
||||
elements: Array<Expression | SpreadElement | null>;
|
||||
}
|
||||
|
||||
export interface ObjectExpression extends BaseExpression {
|
||||
type: "ObjectExpression";
|
||||
properties: Array<Property | SpreadElement>;
|
||||
}
|
||||
|
||||
export interface PrivateIdentifier extends BaseNode {
|
||||
type: "PrivateIdentifier";
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Property extends BaseNode {
|
||||
type: "Property";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value: Expression | Pattern; // Could be an AssignmentProperty
|
||||
kind: "init" | "get" | "set";
|
||||
method: boolean;
|
||||
shorthand: boolean;
|
||||
computed: boolean;
|
||||
}
|
||||
|
||||
export interface PropertyDefinition extends BaseNode {
|
||||
type: "PropertyDefinition";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value?: Expression | null | undefined;
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
export interface FunctionExpression extends BaseFunction, BaseExpression {
|
||||
id?: Identifier | null | undefined;
|
||||
type: "FunctionExpression";
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
export interface SequenceExpression extends BaseExpression {
|
||||
type: "SequenceExpression";
|
||||
expressions: Expression[];
|
||||
}
|
||||
|
||||
export interface UnaryExpression extends BaseExpression {
|
||||
type: "UnaryExpression";
|
||||
operator: UnaryOperator;
|
||||
prefix: true;
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
export interface BinaryExpression extends BaseExpression {
|
||||
type: "BinaryExpression";
|
||||
operator: BinaryOperator;
|
||||
left: Expression | PrivateIdentifier;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export interface AssignmentExpression extends BaseExpression {
|
||||
type: "AssignmentExpression";
|
||||
operator: AssignmentOperator;
|
||||
left: Pattern | MemberExpression;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export interface UpdateExpression extends BaseExpression {
|
||||
type: "UpdateExpression";
|
||||
operator: UpdateOperator;
|
||||
argument: Expression;
|
||||
prefix: boolean;
|
||||
}
|
||||
|
||||
export interface LogicalExpression extends BaseExpression {
|
||||
type: "LogicalExpression";
|
||||
operator: LogicalOperator;
|
||||
left: Expression;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export interface ConditionalExpression extends BaseExpression {
|
||||
type: "ConditionalExpression";
|
||||
test: Expression;
|
||||
alternate: Expression;
|
||||
consequent: Expression;
|
||||
}
|
||||
|
||||
export interface BaseCallExpression extends BaseExpression {
|
||||
callee: Expression | Super;
|
||||
arguments: Array<Expression | SpreadElement>;
|
||||
}
|
||||
export type CallExpression = SimpleCallExpression | NewExpression;
|
||||
|
||||
export interface SimpleCallExpression extends BaseCallExpression {
|
||||
type: "CallExpression";
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
export interface NewExpression extends BaseCallExpression {
|
||||
type: "NewExpression";
|
||||
}
|
||||
|
||||
export interface MemberExpression extends BaseExpression, BasePattern {
|
||||
type: "MemberExpression";
|
||||
object: Expression | Super;
|
||||
property: Expression | PrivateIdentifier;
|
||||
computed: boolean;
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
export type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
|
||||
|
||||
export interface BasePattern extends BaseNode {}
|
||||
|
||||
export interface SwitchCase extends BaseNode {
|
||||
type: "SwitchCase";
|
||||
test?: Expression | null | undefined;
|
||||
consequent: Statement[];
|
||||
}
|
||||
|
||||
export interface CatchClause extends BaseNode {
|
||||
type: "CatchClause";
|
||||
param: Pattern | null;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
export interface Identifier extends BaseNode, BaseExpression, BasePattern {
|
||||
type: "Identifier";
|
||||
name: string;
|
||||
}
|
||||
|
||||
export type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
|
||||
|
||||
export interface SimpleLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value: string | boolean | number | null;
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
export interface RegExpLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value?: RegExp | null | undefined;
|
||||
regex: {
|
||||
pattern: string;
|
||||
flags: string;
|
||||
};
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
export interface BigIntLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value?: bigint | null | undefined;
|
||||
bigint: string;
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
||||
|
||||
export type BinaryOperator =
|
||||
| "=="
|
||||
| "!="
|
||||
| "==="
|
||||
| "!=="
|
||||
| "<"
|
||||
| "<="
|
||||
| ">"
|
||||
| ">="
|
||||
| "<<"
|
||||
| ">>"
|
||||
| ">>>"
|
||||
| "+"
|
||||
| "-"
|
||||
| "*"
|
||||
| "/"
|
||||
| "%"
|
||||
| "**"
|
||||
| "|"
|
||||
| "^"
|
||||
| "&"
|
||||
| "in"
|
||||
| "instanceof";
|
||||
|
||||
export type LogicalOperator = "||" | "&&" | "??";
|
||||
|
||||
export type AssignmentOperator =
|
||||
| "="
|
||||
| "+="
|
||||
| "-="
|
||||
| "*="
|
||||
| "/="
|
||||
| "%="
|
||||
| "**="
|
||||
| "<<="
|
||||
| ">>="
|
||||
| ">>>="
|
||||
| "|="
|
||||
| "^="
|
||||
| "&="
|
||||
| "||="
|
||||
| "&&="
|
||||
| "??=";
|
||||
|
||||
export type UpdateOperator = "++" | "--";
|
||||
|
||||
export interface ForOfStatement extends BaseForXStatement {
|
||||
type: "ForOfStatement";
|
||||
await: boolean;
|
||||
}
|
||||
|
||||
export interface Super extends BaseNode {
|
||||
type: "Super";
|
||||
}
|
||||
|
||||
export interface SpreadElement extends BaseNode {
|
||||
type: "SpreadElement";
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
|
||||
type: "ArrowFunctionExpression";
|
||||
expression: boolean;
|
||||
body: BlockStatement | Expression;
|
||||
}
|
||||
|
||||
export interface YieldExpression extends BaseExpression {
|
||||
type: "YieldExpression";
|
||||
argument?: Expression | null | undefined;
|
||||
delegate: boolean;
|
||||
}
|
||||
|
||||
export interface TemplateLiteral extends BaseExpression {
|
||||
type: "TemplateLiteral";
|
||||
quasis: TemplateElement[];
|
||||
expressions: Expression[];
|
||||
}
|
||||
|
||||
export interface TaggedTemplateExpression extends BaseExpression {
|
||||
type: "TaggedTemplateExpression";
|
||||
tag: Expression;
|
||||
quasi: TemplateLiteral;
|
||||
}
|
||||
|
||||
export interface TemplateElement extends BaseNode {
|
||||
type: "TemplateElement";
|
||||
tail: boolean;
|
||||
value: {
|
||||
/** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
|
||||
cooked?: string | null | undefined;
|
||||
raw: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AssignmentProperty extends Property {
|
||||
value: Pattern;
|
||||
kind: "init";
|
||||
method: boolean; // false
|
||||
}
|
||||
|
||||
export interface ObjectPattern extends BasePattern {
|
||||
type: "ObjectPattern";
|
||||
properties: Array<AssignmentProperty | RestElement>;
|
||||
}
|
||||
|
||||
export interface ArrayPattern extends BasePattern {
|
||||
type: "ArrayPattern";
|
||||
elements: Array<Pattern | null>;
|
||||
}
|
||||
|
||||
export interface RestElement extends BasePattern {
|
||||
type: "RestElement";
|
||||
argument: Pattern;
|
||||
}
|
||||
|
||||
export interface AssignmentPattern extends BasePattern {
|
||||
type: "AssignmentPattern";
|
||||
left: Pattern;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export type Class = ClassDeclaration | ClassExpression;
|
||||
export interface BaseClass extends BaseNode {
|
||||
superClass?: Expression | null | undefined;
|
||||
body: ClassBody;
|
||||
}
|
||||
|
||||
export interface ClassBody extends BaseNode {
|
||||
type: "ClassBody";
|
||||
body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
|
||||
}
|
||||
|
||||
export interface MethodDefinition extends BaseNode {
|
||||
type: "MethodDefinition";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value: FunctionExpression;
|
||||
kind: "constructor" | "method" | "get" | "set";
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
export interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
|
||||
type: "ClassDeclaration";
|
||||
/** It is null when a class declaration is a part of the `export default class` statement */
|
||||
id: Identifier | null;
|
||||
}
|
||||
|
||||
export interface ClassDeclaration extends MaybeNamedClassDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
export interface ClassExpression extends BaseClass, BaseExpression {
|
||||
type: "ClassExpression";
|
||||
id?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
export interface MetaProperty extends BaseExpression {
|
||||
type: "MetaProperty";
|
||||
meta: Identifier;
|
||||
property: Identifier;
|
||||
}
|
||||
|
||||
export type ModuleDeclaration =
|
||||
| ImportDeclaration
|
||||
| ExportNamedDeclaration
|
||||
| ExportDefaultDeclaration
|
||||
| ExportAllDeclaration;
|
||||
export interface BaseModuleDeclaration extends BaseNode {}
|
||||
|
||||
export type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
|
||||
export interface BaseModuleSpecifier extends BaseNode {
|
||||
local: Identifier;
|
||||
}
|
||||
|
||||
export interface ImportDeclaration extends BaseModuleDeclaration {
|
||||
type: "ImportDeclaration";
|
||||
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
|
||||
attributes: ImportAttribute[];
|
||||
source: Literal;
|
||||
}
|
||||
|
||||
export interface ImportSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportSpecifier";
|
||||
imported: Identifier | Literal;
|
||||
}
|
||||
|
||||
export interface ImportAttribute extends BaseNode {
|
||||
type: "ImportAttribute";
|
||||
key: Identifier | Literal;
|
||||
value: Literal;
|
||||
}
|
||||
|
||||
export interface ImportExpression extends BaseExpression {
|
||||
type: "ImportExpression";
|
||||
source: Expression;
|
||||
options?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportDefaultSpecifier";
|
||||
}
|
||||
|
||||
export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportNamespaceSpecifier";
|
||||
}
|
||||
|
||||
export interface ExportNamedDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportNamedDeclaration";
|
||||
declaration?: Declaration | null | undefined;
|
||||
specifiers: ExportSpecifier[];
|
||||
attributes: ImportAttribute[];
|
||||
source?: Literal | null | undefined;
|
||||
}
|
||||
|
||||
export interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
|
||||
type: "ExportSpecifier";
|
||||
local: Identifier | Literal;
|
||||
exported: Identifier | Literal;
|
||||
}
|
||||
|
||||
export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportDefaultDeclaration";
|
||||
declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression;
|
||||
}
|
||||
|
||||
export interface ExportAllDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportAllDeclaration";
|
||||
exported: Identifier | Literal | null;
|
||||
attributes: ImportAttribute[];
|
||||
source: Literal;
|
||||
}
|
||||
|
||||
export interface AwaitExpression extends BaseExpression {
|
||||
type: "AwaitExpression";
|
||||
argument: Expression;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user