@nil-/doc 0.2.37 → 0.2.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -54
- package/components/Layout.svelte +20 -2
- package/components/block/Block.svelte +1 -1
- package/components/block/Template.svelte +2 -6
- package/components/block/controls/misc/Styler.svelte +1 -0
- package/components/etc/ThemeIcon.svelte +1 -7
- package/components/navigation/Nav.svelte +12 -8
- package/components/navigation/Nav.svelte.d.ts +1 -3
- package/components/navigation/Node.svelte +1 -1
- package/components/navigation/Tree.svelte +1 -1
- package/components/navigation/utils/fuzz.d.ts +1 -0
- package/components/navigation/utils/fuzz.js +119 -0
- package/components/navigation/utils/renamer.d.ts +9 -0
- package/components/navigation/utils/renamer.js +15 -0
- package/components/navigation/utils/sort.d.ts +2 -0
- package/components/navigation/utils/sort.js +3 -0
- package/components/navigation/{utils.d.ts → utils/sorter.d.ts} +2 -12
- package/components/navigation/{utils.js → utils/sorter.js} +1 -17
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
# @nil-/doc
|
|
2
2
|
|
|
3
|
+
## 0.2.38
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [doc][new] added fuzzy match for nav filter ([#59](https://github.com/njaldea/mono/pull/59))
|
|
8
|
+
|
|
3
9
|
## 0.2.37
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
6
12
|
|
|
7
13
|
- [doc][fix] params prop is now reactive ([#57](https://github.com/njaldea/mono/pull/57))
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- [doc][cleanup] refactored Instance/Template/Params ([#57](https://github.com/njaldea/mono/pull/57))
|
|
14
|
+
- [doc][docu] added component documentation link to deployment ([#57](https://github.com/njaldea/mono/pull/57))
|
|
15
|
+
- [doc][patch] removed inRoot ([#57](https://github.com/njaldea/mono/pull/57))
|
|
16
|
+
- [doc][patch] refactored Instance/Template/Params ([#57](https://github.com/njaldea/mono/pull/57))
|
|
12
17
|
|
|
13
18
|
## 0.2.36
|
|
14
19
|
|
|
15
20
|
### Patch Changes
|
|
16
21
|
|
|
17
22
|
- [doc][fix] color changes and transition ([#55](https://github.com/njaldea/mono/pull/55))
|
|
18
|
-
|
|
19
|
-
- [all] added html meta details ([#55](https://github.com/njaldea/mono/pull/55))
|
|
23
|
+
- [doc][patch] added html meta details ([#55](https://github.com/njaldea/mono/pull/55))
|
|
20
24
|
|
|
21
25
|
## 0.2.35
|
|
22
26
|
|
|
23
27
|
### Patch Changes
|
|
24
28
|
|
|
25
|
-
- [doc] changed Control "side" flag to "position" prop ([#53](https://github.com/njaldea/mono/pull/53))
|
|
26
|
-
|
|
27
|
-
- [misc] added nil icon ([#53](https://github.com/njaldea/mono/pull/53))
|
|
29
|
+
- [doc][break] changed Control "side" flag to "position" prop ([#53](https://github.com/njaldea/mono/pull/53))
|
|
30
|
+
- [doc][new] added nil icon ([#53](https://github.com/njaldea/mono/pull/53))
|
|
28
31
|
|
|
29
32
|
## 0.2.34
|
|
30
33
|
|
|
@@ -38,21 +41,20 @@
|
|
|
38
41
|
|
|
39
42
|
### Patch Changes
|
|
40
43
|
|
|
41
|
-
- [doc] update formatting (camel case use) ([#49](https://github.com/njaldea/mono/pull/49))
|
|
44
|
+
- [doc][patch] update formatting (camel case use) ([#49](https://github.com/njaldea/mono/pull/49))
|
|
42
45
|
|
|
43
46
|
## 0.2.32
|
|
44
47
|
|
|
45
48
|
### Patch Changes
|
|
46
49
|
|
|
47
|
-
- [doc] relaxed file extension for sveltekit helper ([#47](https://github.com/njaldea/mono/pull/47))
|
|
50
|
+
- [doc][new] relaxed file extension for sveltekit helper ([#47](https://github.com/njaldea/mono/pull/47))
|
|
48
51
|
|
|
49
52
|
## 0.2.31
|
|
50
53
|
|
|
51
54
|
### Patch Changes
|
|
52
55
|
|
|
53
|
-
- [doc] better container style ([#45](https://github.com/njaldea/mono/pull/45))
|
|
54
|
-
|
|
55
|
-
- [doc] improved ThemeIcon ([#45](https://github.com/njaldea/mono/pull/45))
|
|
56
|
+
- [doc][patch] better container style ([#45](https://github.com/njaldea/mono/pull/45))
|
|
57
|
+
- [doc][patch] improved ThemeIcon ([#45](https://github.com/njaldea/mono/pull/45))
|
|
56
58
|
|
|
57
59
|
## 0.2.30
|
|
58
60
|
|
|
@@ -79,56 +81,56 @@
|
|
|
79
81
|
|
|
80
82
|
### Patch Changes
|
|
81
83
|
|
|
82
|
-
- [doc] fix fira code css import ([#35](https://github.com/njaldea/mono/pull/35))
|
|
84
|
+
- [doc][fix] fix fira code css import ([#35](https://github.com/njaldea/mono/pull/35))
|
|
83
85
|
|
|
84
86
|
## 0.2.26
|
|
85
87
|
|
|
86
88
|
### Patch Changes
|
|
87
89
|
|
|
88
|
-
- [doc] removed fallback page in documentation ([#30](https://github.com/njaldea/mono/pull/30))
|
|
90
|
+
- [doc][docu] removed fallback page in documentation ([#30](https://github.com/njaldea/mono/pull/30))
|
|
89
91
|
|
|
90
92
|
## 0.2.25
|
|
91
93
|
|
|
92
94
|
### Patch Changes
|
|
93
95
|
|
|
94
|
-
- 186187c: [doc][
|
|
95
|
-
- 186187c: [doc] fix range tooltip styling
|
|
96
|
-
- a82c0de: [doc] support dark/light mode
|
|
96
|
+
- 186187c: [doc][new] removed layout slot prop for content. all unnamed slots will be part of the default slot
|
|
97
|
+
- 186187c: [doc][fix] fix range tooltip styling
|
|
98
|
+
- a82c0de: [doc][new] support dark/light mode
|
|
97
99
|
|
|
98
100
|
## 0.2.24
|
|
99
101
|
|
|
100
102
|
### Patch Changes
|
|
101
103
|
|
|
102
|
-
- 782e6fa: [doc][
|
|
103
|
-
- 782e6fa: [doc] added documentation to public methods
|
|
104
|
+
- 782e6fa: [doc][new] simplified sveltekit glue layer
|
|
105
|
+
- 782e6fa: [doc][docu] added documentation to public methods
|
|
104
106
|
|
|
105
107
|
## 0.2.23
|
|
106
108
|
|
|
107
109
|
### Patch Changes
|
|
108
110
|
|
|
109
|
-
- 5655f86: [
|
|
110
|
-
- 5655f86: [
|
|
111
|
+
- 5655f86: [doc][new] added slot prop `key` to Template component
|
|
112
|
+
- 5655f86: [doc][patch] moved some devDependencies to peerDependencies
|
|
111
113
|
|
|
112
114
|
## 0.2.22
|
|
113
115
|
|
|
114
116
|
### Patch Changes
|
|
115
117
|
|
|
116
|
-
- 3ce0a62: [doc] support for touch event via pointerevent (draggable container)
|
|
118
|
+
- 3ce0a62: [doc][new] support for touch event via pointerevent (draggable container)
|
|
117
119
|
|
|
118
120
|
## 0.2.21
|
|
119
121
|
|
|
120
122
|
### Patch Changes
|
|
121
123
|
|
|
122
124
|
- 0398a72: [doc][fix] remove dependency on box-sizing
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
- 0398a72: [doc][fix] control min width
|
|
126
|
+
- 0398a72: [doc][new] made template configurable by column prop
|
|
125
127
|
|
|
126
128
|
## 0.2.20
|
|
127
129
|
|
|
128
130
|
### Patch Changes
|
|
129
131
|
|
|
130
132
|
- 3eee0ce: [doc][fix] removed setting of margin/padding
|
|
131
|
-
|
|
133
|
+
- 3eee0ce: [doc][fix] only propagate box-sizing (inherit)
|
|
132
134
|
|
|
133
135
|
## 0.2.19
|
|
134
136
|
|
|
@@ -146,68 +148,62 @@
|
|
|
146
148
|
|
|
147
149
|
### Patch Changes
|
|
148
150
|
|
|
149
|
-
- af86341: [doc] moved default mapping in a common lib
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
- af86341: [doc][fix] moved default mapping in a common lib
|
|
152
|
+
- af86341: [doc][fix] fix typing
|
|
153
|
+
- af86341: [doc][patch] if Param's tag is not provided, use stringified id
|
|
152
154
|
|
|
153
155
|
## 0.2.16
|
|
154
156
|
|
|
155
157
|
### Patch Changes
|
|
156
158
|
|
|
157
|
-
- 650eb4b: [doc] revived proper ordering of params
|
|
158
|
-
|
|
159
|
+
- 650eb4b: [doc][fix] revived proper ordering of params
|
|
160
|
+
- 650eb4b: [doc][new] each param now has its own defaults (which is resolved from template's default and pram's props)
|
|
159
161
|
|
|
160
162
|
## 0.2.15
|
|
161
163
|
|
|
162
164
|
### Patch Changes
|
|
163
165
|
|
|
164
|
-
- 44a7113: [doc] added documentation for internal Container
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
- 44a7113: [doc][docu] added documentation for internal Container
|
|
167
|
+
- 44a7113: [doc][new] adjusted api for load (now `routes`)
|
|
168
|
+
- 44a7113: [doc][fix] fix for layout group route
|
|
167
169
|
|
|
168
170
|
## 0.2.14
|
|
169
171
|
|
|
170
172
|
### Patch Changes
|
|
171
173
|
|
|
172
|
-
- 6265fa6: [doc] added Tuple and Object Controls
|
|
173
|
-
|
|
174
|
+
- 6265fa6: [doc][new] added Tuple and Object Controls
|
|
175
|
+
- 6265fa6: [doc][docu] added temporary internal doc
|
|
174
176
|
|
|
175
177
|
## 0.2.13
|
|
176
178
|
|
|
177
179
|
### Patch Changes
|
|
178
180
|
|
|
179
|
-
- 39dbce9: [doc] navigation now automatically opens when redirected to a route that is still collapsed
|
|
181
|
+
- 39dbce9: [doc][new] navigation now automatically opens when redirected to a route that is still collapsed
|
|
180
182
|
|
|
181
183
|
## 0.2.12
|
|
182
184
|
|
|
183
185
|
### Patch Changes
|
|
184
186
|
|
|
185
|
-
- 6c2d946: [fix] Nav now is not scrollable
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
## 0.2.11
|
|
194
|
-
|
|
195
|
-
### Patch Changes
|
|
196
|
-
|
|
197
|
-
- 8d16322: noop
|
|
187
|
+
- 6c2d946: [doc][fix] Nav now is not scrollable
|
|
188
|
+
- 6c2d946: [doc][fix] Removes Container's "reversed" flag
|
|
189
|
+
- 6c2d946: [doc][fix] Adds "secondary" flag to Container
|
|
190
|
+
- 6c2d946: [doc][fix] Changes Container slot name (primary is top or left, seconadry is bottom or right)
|
|
191
|
+
- 6c2d946: [doc][fix] load now removes routes with parameters
|
|
192
|
+
- 6c2d946: [doc][fix] Template now supports `noreset`
|
|
193
|
+
- 6c2d946: [doc][fix] Updates documentation
|
|
198
194
|
|
|
199
195
|
## 0.2.10
|
|
200
196
|
|
|
201
197
|
### Patch Changes
|
|
202
198
|
|
|
203
|
-
- c6de380: [
|
|
204
|
-
|
|
199
|
+
- c6de380: [doc][new] container collapsing now supported
|
|
200
|
+
- c6de380: [doc][patch] styling of container now uses grid for easier handling
|
|
205
201
|
|
|
206
202
|
## 0.2.9
|
|
207
203
|
|
|
208
204
|
### Patch Changes
|
|
209
205
|
|
|
210
|
-
- 5c10f11: [
|
|
206
|
+
- 5c10f11: [doc][patch] layout fill height
|
|
211
207
|
|
|
212
208
|
## 0.2.8
|
|
213
209
|
|
package/components/Layout.svelte
CHANGED
|
@@ -27,6 +27,16 @@
|
|
|
27
27
|
overflow: hidden;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
.icon {
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
transition: transform 350ms;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.icon:hover {
|
|
37
|
+
transform: scale(1.5);
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
.content {
|
|
31
41
|
height: 100%;
|
|
32
42
|
padding: 5px;
|
|
@@ -94,8 +104,16 @@ $:
|
|
|
94
104
|
<div class="layout" class:dark={$dark}>
|
|
95
105
|
<div class="top">
|
|
96
106
|
<slot name="title"><span>@nil-/doc</span></slot>
|
|
97
|
-
<
|
|
98
|
-
|
|
107
|
+
<div class="icon" on:click={() => ($dark = !$dark)} on:keypress={null}>
|
|
108
|
+
<ThemeIcon bind:dark={$dark} />
|
|
109
|
+
</div>
|
|
110
|
+
<div
|
|
111
|
+
class="icon"
|
|
112
|
+
title="Double click to open repo: https://github.com/njaldea/mono"
|
|
113
|
+
on:dblclick={() => window.open("https://github.com/njaldea/mono", "_blank")}
|
|
114
|
+
>
|
|
115
|
+
<NilIcon />
|
|
116
|
+
</div>
|
|
99
117
|
</div>
|
|
100
118
|
<div class="main">
|
|
101
119
|
<Container offset={250} vertical b>
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
<script>import { beforeUpdate } from "svelte";
|
|
3
|
-
import {
|
|
4
|
-
getDefaults,
|
|
5
|
-
getParams,
|
|
6
|
-
getOrientation
|
|
7
|
-
} from "./context";
|
|
3
|
+
import { getDefaults, getParams, getOrientation } from "./context";
|
|
8
4
|
import { resolve } from "./utils";
|
|
9
5
|
import Instance from "./Instance.svelte";
|
|
10
6
|
const params = getParams();
|
|
@@ -17,9 +13,9 @@ $:
|
|
|
17
13
|
$defaultsStore = defaults ?? {};
|
|
18
14
|
$:
|
|
19
15
|
$orientation = columns;
|
|
20
|
-
const resolveArgs = resolve;
|
|
21
16
|
let key = false;
|
|
22
17
|
beforeUpdate(() => key = !key);
|
|
18
|
+
const resolveArgs = resolve;
|
|
23
19
|
const cast = (t) => t;
|
|
24
20
|
</script>
|
|
25
21
|
<!--
|
|
@@ -44,13 +44,7 @@ const vdark = {
|
|
|
44
44
|
v: 1
|
|
45
45
|
};
|
|
46
46
|
</script>
|
|
47
|
-
<svg
|
|
48
|
-
class:dark
|
|
49
|
-
viewBox="-25 -25 50 50"
|
|
50
|
-
transform={`rotate(${$values.rotate})`}
|
|
51
|
-
on:click={() => (dark = !dark)}
|
|
52
|
-
on:keypress={null}
|
|
53
|
-
>
|
|
47
|
+
<svg class:dark viewBox="-25 -25 50 50" transform={`rotate(${$values.rotate})`}>
|
|
54
48
|
<mask id={`nil_doc_theme_icon_${index}`}>
|
|
55
49
|
<rect x="-25" y="-25" fill="white" />
|
|
56
50
|
<circle cy={$values.mcy} r="11" />
|
|
@@ -3,20 +3,22 @@
|
|
|
3
3
|
width: 100%;
|
|
4
4
|
height: 100%;
|
|
5
5
|
min-width: 200px;
|
|
6
|
-
gap: 10px;
|
|
7
6
|
display: flex;
|
|
8
7
|
flex-direction: column;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
.logo,
|
|
12
10
|
.search-bar {
|
|
13
|
-
padding
|
|
14
|
-
padding-right: 20px;
|
|
11
|
+
padding: 5px;
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
input {
|
|
18
|
-
height:
|
|
15
|
+
height: 30px;
|
|
19
16
|
width: 100%;
|
|
17
|
+
padding: 0px 10px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
input:focus {
|
|
21
|
+
outline: none;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
* {
|
|
@@ -26,7 +28,8 @@
|
|
|
26
28
|
}
|
|
27
29
|
</style>
|
|
28
30
|
|
|
29
|
-
<script context="module">
|
|
31
|
+
<script context="module">import { fuzz } from "./utils/fuzz";
|
|
32
|
+
const apply = (paths, init, pre, next, post) => {
|
|
30
33
|
const retval = {};
|
|
31
34
|
for (const path of paths) {
|
|
32
35
|
const parts = path.split("/");
|
|
@@ -51,7 +54,9 @@
|
|
|
51
54
|
}
|
|
52
55
|
return retval;
|
|
53
56
|
};
|
|
54
|
-
const filt = (path, filter, renamer) =>
|
|
57
|
+
const filt = (path, filter, renamer) => {
|
|
58
|
+
return fuzz(path, filter) || fuzz(path.split("/").map(renamer).join("/"), filter);
|
|
59
|
+
};
|
|
55
60
|
const populate = (filter, info, renamer) => apply(
|
|
56
61
|
filter.length > 0 ? info.filter((path) => filt(path, filter, renamer)) : info,
|
|
57
62
|
() => ({ url: null, sub: {} }),
|
|
@@ -91,7 +96,6 @@ $:
|
|
|
91
96
|
update(selected);
|
|
92
97
|
</script>
|
|
93
98
|
<div class="nav">
|
|
94
|
-
<div class="logo"><slot /></div>
|
|
95
99
|
<div class="search-bar">
|
|
96
100
|
<input bind:value={filter} type="text" />
|
|
97
101
|
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fuzz: (target: string, query: string) => boolean;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* See License.txt in https://github.com/microsoft/vscode/blob/main/LICENSE.txt
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/*
|
|
7
|
+
* This implementation is inspired by:
|
|
8
|
+
* https://github.com/microsoft/vscode/blob/main/src/vs/base/common/fuzzyScorer.ts
|
|
9
|
+
*
|
|
10
|
+
* It is simplified to fit the use case for @nil-/doc
|
|
11
|
+
*/
|
|
12
|
+
const isUpper = (code) => {
|
|
13
|
+
// A == 65
|
|
14
|
+
// Z == 90
|
|
15
|
+
return 65 <= code && code <= 90;
|
|
16
|
+
};
|
|
17
|
+
const scoreSeparatorAtPos = (charCode) => {
|
|
18
|
+
switch (charCode) {
|
|
19
|
+
case 47: // Slash
|
|
20
|
+
// prefer path separators...
|
|
21
|
+
return 5;
|
|
22
|
+
case 95: // Underline
|
|
23
|
+
case 45: // Dash
|
|
24
|
+
case 46: // Period
|
|
25
|
+
case 32: // Space
|
|
26
|
+
case 58: // Colon:
|
|
27
|
+
// ...over other separators
|
|
28
|
+
return 4;
|
|
29
|
+
default:
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const computeCharScore = (queryCharAtIndex, queryLowerCharAtIndex, target, targetLower, targetIndex, matchesSequenceLength) => {
|
|
34
|
+
let score = 0;
|
|
35
|
+
if (queryLowerCharAtIndex !== targetLower[targetIndex]) {
|
|
36
|
+
// no match of characters
|
|
37
|
+
return score;
|
|
38
|
+
}
|
|
39
|
+
// Character match bonus
|
|
40
|
+
score += 1;
|
|
41
|
+
// Consecutive match bonus
|
|
42
|
+
if (matchesSequenceLength > 0) {
|
|
43
|
+
score += matchesSequenceLength * 5;
|
|
44
|
+
}
|
|
45
|
+
// Same case bonus
|
|
46
|
+
if (queryCharAtIndex === target[targetIndex]) {
|
|
47
|
+
score += 1;
|
|
48
|
+
}
|
|
49
|
+
// Start of word bonus
|
|
50
|
+
if (0 === targetIndex) {
|
|
51
|
+
score += 8;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const separatorBonus = scoreSeparatorAtPos(target.charCodeAt(targetIndex - 1));
|
|
55
|
+
if (separatorBonus) {
|
|
56
|
+
score += separatorBonus;
|
|
57
|
+
}
|
|
58
|
+
else if (isUpper(target.charCodeAt(targetIndex)) && 0 === matchesSequenceLength) {
|
|
59
|
+
score += 2;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return score;
|
|
63
|
+
};
|
|
64
|
+
const doScoreFuzzy = (query, queryLower, queryLength, target, targetLower, targetLength) => {
|
|
65
|
+
const scores = [];
|
|
66
|
+
const matches = [];
|
|
67
|
+
for (let queryIndex = 0; queryIndex < queryLength; queryIndex++) {
|
|
68
|
+
const queryIndexOffset = queryIndex * targetLength;
|
|
69
|
+
const queryIndexPreviousOffset = queryIndexOffset - targetLength;
|
|
70
|
+
const queryIndexGtNull = queryIndex > 0;
|
|
71
|
+
const queryCharAtIndex = query[queryIndex];
|
|
72
|
+
const queryLowerCharAtIndex = queryLower[queryIndex];
|
|
73
|
+
for (let targetIndex = 0; targetIndex < targetLength; targetIndex++) {
|
|
74
|
+
const targetIndexGtNull = targetIndex > 0;
|
|
75
|
+
const currentIndex = queryIndexOffset + targetIndex;
|
|
76
|
+
const leftIndex = currentIndex - 1;
|
|
77
|
+
const diagIndex = queryIndexPreviousOffset + targetIndex - 1;
|
|
78
|
+
const leftScore = targetIndexGtNull ? scores[leftIndex] : 0;
|
|
79
|
+
const diagScore = queryIndexGtNull && targetIndexGtNull ? scores[diagIndex] : 0;
|
|
80
|
+
const matchesSequenceLength = queryIndexGtNull && targetIndexGtNull ? matches[diagIndex] : 0;
|
|
81
|
+
const score = !diagScore && queryIndexGtNull
|
|
82
|
+
? 0
|
|
83
|
+
: computeCharScore(queryCharAtIndex, queryLowerCharAtIndex, target, targetLower, targetIndex, matchesSequenceLength);
|
|
84
|
+
const isValidScore = score && diagScore + score >= leftScore;
|
|
85
|
+
if (isValidScore) {
|
|
86
|
+
matches[currentIndex] = matchesSequenceLength + 1;
|
|
87
|
+
scores[currentIndex] = diagScore + score;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
matches[currentIndex] = 0;
|
|
91
|
+
scores[currentIndex] = leftScore;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const positions = [];
|
|
96
|
+
let queryIndex = queryLength - 1;
|
|
97
|
+
let targetIndex = targetLength - 1;
|
|
98
|
+
while (queryIndex >= 0 && targetIndex >= 0) {
|
|
99
|
+
const currentIndex = queryIndex * targetLength + targetIndex;
|
|
100
|
+
const match = matches[currentIndex];
|
|
101
|
+
if (0 === match) {
|
|
102
|
+
targetIndex--;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
positions.push(targetIndex);
|
|
106
|
+
queryIndex--;
|
|
107
|
+
targetIndex--;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return [scores[queryLength * targetLength - 1], positions.reverse()];
|
|
111
|
+
};
|
|
112
|
+
export const fuzz = (target, query) => {
|
|
113
|
+
const targetLength = target.length;
|
|
114
|
+
const queryLength = query.length;
|
|
115
|
+
if (targetLength < queryLength) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return (doScoreFuzzy(query, query.toLowerCase(), queryLength, target, target.toLowerCase(), targetLength)[0] > 0);
|
|
119
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const match = /(\d+)-(.+)/;
|
|
2
|
+
/**
|
|
3
|
+
* If a text follows `<I>-<Name>` format,
|
|
4
|
+
* this method simply removes the Prefix.
|
|
5
|
+
*
|
|
6
|
+
* @param text
|
|
7
|
+
* @returns `<Name>`
|
|
8
|
+
*/
|
|
9
|
+
export const renamer = (text) => {
|
|
10
|
+
const m = match.exec(text);
|
|
11
|
+
if (m) {
|
|
12
|
+
return m[2];
|
|
13
|
+
}
|
|
14
|
+
return text;
|
|
15
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Sorter } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Compares two texts for sorting.
|
|
4
4
|
*
|
|
@@ -14,14 +14,4 @@ import type { Tree, Sorter, Renamer } from "./types";
|
|
|
14
14
|
* @param r - right operand
|
|
15
15
|
* @returns `-1 | 0 | +1`
|
|
16
16
|
*/
|
|
17
|
-
declare const sorter: Sorter;
|
|
18
|
-
/**
|
|
19
|
-
* If a text follows `<I>-<Name>` format,
|
|
20
|
-
* this method simply removes the Prefix.
|
|
21
|
-
*
|
|
22
|
-
* @param text
|
|
23
|
-
* @returns `<Name>`
|
|
24
|
-
*/
|
|
25
|
-
declare const renamer: Renamer;
|
|
26
|
-
export declare const sort: (t: Record<string, Tree>, order: (l: string, r: string) => 1 | 0 | -1) => [string, Tree][];
|
|
27
|
-
export { sorter, renamer };
|
|
17
|
+
export declare const sorter: Sorter;
|
|
@@ -23,7 +23,7 @@ const sorterT = (l, r) => {
|
|
|
23
23
|
* @param r - right operand
|
|
24
24
|
* @returns `-1 | 0 | +1`
|
|
25
25
|
*/
|
|
26
|
-
const sorter = (l, r) => {
|
|
26
|
+
export const sorter = (l, r) => {
|
|
27
27
|
const lmatch = match.exec(l);
|
|
28
28
|
const rmatch = match.exec(r);
|
|
29
29
|
if (null == lmatch && null == rmatch) {
|
|
@@ -37,19 +37,3 @@ const sorter = (l, r) => {
|
|
|
37
37
|
}
|
|
38
38
|
return sorterT(parseInt(lmatch[1]), parseInt(rmatch[1]));
|
|
39
39
|
};
|
|
40
|
-
/**
|
|
41
|
-
* If a text follows `<I>-<Name>` format,
|
|
42
|
-
* this method simply removes the Prefix.
|
|
43
|
-
*
|
|
44
|
-
* @param text
|
|
45
|
-
* @returns `<Name>`
|
|
46
|
-
*/
|
|
47
|
-
const renamer = (text) => {
|
|
48
|
-
const m = match.exec(text);
|
|
49
|
-
if (m) {
|
|
50
|
-
return m[2];
|
|
51
|
-
}
|
|
52
|
-
return text;
|
|
53
|
-
};
|
|
54
|
-
export const sort = (t, order) => Object.entries(t).sort(([l], [r]) => order(l, r));
|
|
55
|
-
export { sorter, renamer };
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { renamer
|
|
1
|
+
export { renamer } from "./components/navigation/utils/renamer";
|
|
2
|
+
export { sorter } from "./components/navigation/utils/sorter";
|
|
2
3
|
export type { Control } from "./components/block/controls/types";
|
|
3
4
|
export { default as Layout } from "./components/Layout.svelte";
|
|
4
5
|
export { default as Instance } from "./components/block/Instance.svelte";
|
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { renamer
|
|
1
|
+
export { renamer } from "./components/navigation/utils/renamer";
|
|
2
|
+
export { sorter } from "./components/navigation/utils/sorter";
|
|
2
3
|
export { default as Layout } from "./components/Layout.svelte";
|
|
3
4
|
export { default as Instance } from "./components/block/Instance.svelte";
|
|
4
5
|
export { default as Block } from "./components/block/Block.svelte";
|