@tickernelz/paperclip-pro-server 2026.926.2 → 2026.926.4
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/dist/build-info.json +1 -1
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +18 -4
- package/dist/routes/agents.js.map +1 -1
- package/dist/routes/issues.d.ts.map +1 -1
- package/dist/routes/issues.js +7 -0
- package/dist/routes/issues.js.map +1 -1
- package/dist/routes/openapi.d.ts.map +1 -1
- package/dist/routes/openapi.js +21 -8
- package/dist/routes/openapi.js.map +1 -1
- package/dist/routes/paperclip-mcp.d.ts.map +1 -1
- package/dist/routes/paperclip-mcp.js +23 -2
- package/dist/routes/paperclip-mcp.js.map +1 -1
- package/dist/services/issues.d.ts +5 -0
- package/dist/services/issues.d.ts.map +1 -1
- package/dist/services/issues.js +15 -1
- package/dist/services/issues.js.map +1 -1
- package/node_modules/micromark/dev/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/compile.js +14 -4
- package/node_modules/micromark/dev/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/create-tokenizer.js +7 -6
- package/node_modules/micromark/dev/lib/initialize/document.js +25 -21
- package/node_modules/micromark/dev/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/initialize/text.js +10 -6
- package/node_modules/micromark/dev/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/preprocess.js +19 -21
- package/node_modules/micromark/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/lib/compile.js +37 -29
- package/node_modules/micromark/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/lib/create-tokenizer.js +37 -35
- package/node_modules/micromark/lib/initialize/document.js +21 -13
- package/node_modules/micromark/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/lib/initialize/text.js +7 -3
- package/node_modules/micromark/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/lib/preprocess.js +16 -19
- package/node_modules/micromark/package.json +2 -15
- package/node_modules/micromark-core-commonmark/dev/lib/attention.js +18 -24
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.js +1 -43
- package/node_modules/micromark-core-commonmark/dev/lib/code-indented.js +19 -43
- package/node_modules/micromark-core-commonmark/dev/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.js +2 -53
- package/node_modules/micromark-core-commonmark/dev/lib/label-end.js +14 -12
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.js +67 -0
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.js +8 -5
- package/node_modules/micromark-core-commonmark/lib/attention.js +14 -24
- package/node_modules/micromark-core-commonmark/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/code-fenced.js +1 -39
- package/node_modules/micromark-core-commonmark/lib/code-indented.js +11 -29
- package/node_modules/micromark-core-commonmark/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/html-flow.js +2 -51
- package/node_modules/micromark-core-commonmark/lib/label-end.js +11 -10
- package/node_modules/micromark-core-commonmark/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-image.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-link.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
- package/node_modules/micromark-core-commonmark/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/setext-underline.js +7 -5
- package/node_modules/micromark-core-commonmark/package.json +4 -16
- package/node_modules/micromark-factory-space/dev/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/dev/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/dev/index.js +58 -3
- package/node_modules/micromark-factory-space/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/index.js +55 -3
- package/node_modules/micromark-factory-space/package.json +1 -10
- package/node_modules/micromark-factory-space/readme.md +25 -25
- package/node_modules/micromark-util-edit-map/dev/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/dev/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/dev/index.js +237 -0
- package/node_modules/micromark-util-edit-map/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/index.js +225 -0
- package/node_modules/micromark-util-edit-map/license +22 -0
- package/node_modules/micromark-util-edit-map/package.json +48 -0
- package/node_modules/micromark-util-edit-map/readme.md +234 -0
- package/node_modules/micromark-util-types/index.d.ts +6 -3
- package/node_modules/micromark-util-types/package.json +2 -36
- package/node_modules/ws/lib/websocket.js +17 -3
- package/node_modules/ws/package.json +1 -1
- package/package.json +20 -20
- package/skills/paperclip/references/api-reference.md +2 -2
- package/ui-dist/assets/{Agents.production-5Tba_pW_.js → Agents.production-DYgcR2ZQ.js} +2 -2
- package/ui-dist/assets/{CompanyActivity.production-CONFWTe1.js → CompanyActivity.production-MiS7fCCl.js} +1 -1
- package/ui-dist/assets/{CompanyExport-CiOVCS4y.js → CompanyExport-C-7PQaz8.js} +1 -1
- package/ui-dist/assets/{CompanySkills.production-gv4ej6PI.js → CompanySkills.production-D3xms9bg.js} +1 -1
- package/ui-dist/assets/{Costs.production-C6rOIGNV.js → Costs.production-DdIIwVUT.js} +1 -1
- package/ui-dist/assets/{OrgChart.production-DYeuFtY_.js → OrgChart.production-hVW6TgEL.js} +1 -1
- package/ui-dist/assets/{RoutineDetail.production-Bt4IHfSD.js → RoutineDetail.production-MBJ3aeg2.js} +1 -1
- package/ui-dist/assets/{Routines.production-BBxSwg2A.js → Routines.production-LQRGr5dX.js} +1 -1
- package/ui-dist/assets/{definition-B49KTmLW.js → definition-INtTKxdn.js} +1 -1
- package/ui-dist/assets/{index-BRCs87uX.js → index-DbWxivZc.js} +161 -161
- package/ui-dist/index.html +1 -1
- package/ui-dist/sw.js +1 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Event} from 'micromark-util-types'
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {[number, number, Array<Event>]} Change
|
|
7
|
+
* @typedef {[number, number, number]} Jump
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Tracks a bunch of edits.
|
|
12
|
+
*
|
|
13
|
+
* Port of `edit_map.rs` from `markdown-rs`:
|
|
14
|
+
* <https://github.com/wooorm/markdown-rs/blob/1506572f/src/util/edit_map.rs>.
|
|
15
|
+
*
|
|
16
|
+
* Deal with several changes in events, batching them together.
|
|
17
|
+
*
|
|
18
|
+
* Preferably, changes should be kept to a minimum.
|
|
19
|
+
* Sometimes, it’s needed to change the list of events, because parsing can be
|
|
20
|
+
* messy, and it helps to expose a cleaner interface of events to the compiler
|
|
21
|
+
* and other users.
|
|
22
|
+
* It can also help to merge many adjacent similar events.
|
|
23
|
+
* And, in other cases, it’s needed to parse subcontent: pass some events
|
|
24
|
+
* through another tokenizer and inject the result.
|
|
25
|
+
*/
|
|
26
|
+
export class EditMap {
|
|
27
|
+
/**
|
|
28
|
+
* Create a new edit map.
|
|
29
|
+
*
|
|
30
|
+
* @returns
|
|
31
|
+
* New instance.
|
|
32
|
+
*/
|
|
33
|
+
constructor() {
|
|
34
|
+
/**
|
|
35
|
+
* Changes by index, so `add` does not need to scan `map` (which is
|
|
36
|
+
* quadratic for documents with many edits at different places).
|
|
37
|
+
*
|
|
38
|
+
* @type {Map<number, Change>}
|
|
39
|
+
*/
|
|
40
|
+
this.index = new Map()
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Record of changes.
|
|
44
|
+
*
|
|
45
|
+
* @type {Array<Change>}
|
|
46
|
+
*/
|
|
47
|
+
this.map = []
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Create an edit: a remove and/or add at a certain place.
|
|
52
|
+
*
|
|
53
|
+
* @param {number} index
|
|
54
|
+
* Index at which to apply the edit.
|
|
55
|
+
* @param {number} remove
|
|
56
|
+
* Count of items to remove at the index.
|
|
57
|
+
* @param {Array<Event>} add
|
|
58
|
+
* Items to add at the index.
|
|
59
|
+
* @returns {undefined}
|
|
60
|
+
* Nothing.
|
|
61
|
+
*/
|
|
62
|
+
add(index, remove, add) {
|
|
63
|
+
addImplementation(this, index, remove, add, false)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create an edit: but insert `add` before existing additions, instead of
|
|
68
|
+
* after them.
|
|
69
|
+
*
|
|
70
|
+
* @param {number} index
|
|
71
|
+
* Index at which to apply the edit.
|
|
72
|
+
* @param {number} remove
|
|
73
|
+
* Count of items to remove at the index.
|
|
74
|
+
* @param {Array<Event>} add
|
|
75
|
+
* Items to add at the index.
|
|
76
|
+
* @returns {undefined}
|
|
77
|
+
* Nothing.
|
|
78
|
+
*/
|
|
79
|
+
addBefore(index, remove, add) {
|
|
80
|
+
addImplementation(this, index, remove, add, true)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Done, change the events.
|
|
85
|
+
*
|
|
86
|
+
* @param {Array<Event>} events
|
|
87
|
+
* List of events to apply the edits to.
|
|
88
|
+
* @returns {undefined}
|
|
89
|
+
* Nothing.
|
|
90
|
+
*/
|
|
91
|
+
consume(events) {
|
|
92
|
+
this.map.sort(function (a, b) {
|
|
93
|
+
return a[0] - b[0]
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
if (this.map.length === 0) {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// To do: if links are added in events, like they are in `markdown-rs`,
|
|
101
|
+
// this is needed.
|
|
102
|
+
// // Calculate jumps: where items in the current list move to.
|
|
103
|
+
// /** @type {Array<Jump>} */
|
|
104
|
+
// const jumps = []
|
|
105
|
+
// let index = 0
|
|
106
|
+
// let addAcc = 0
|
|
107
|
+
// let removeAcc = 0
|
|
108
|
+
// while (index < this.map.length) {
|
|
109
|
+
// const [at, remove, add] = this.map[index]
|
|
110
|
+
// removeAcc += remove
|
|
111
|
+
// addAcc += add.length
|
|
112
|
+
// jumps.push([at, removeAcc, addAcc])
|
|
113
|
+
// index += 1
|
|
114
|
+
// }
|
|
115
|
+
//
|
|
116
|
+
// shiftLinks(events, jumps)
|
|
117
|
+
|
|
118
|
+
let index = this.map.length
|
|
119
|
+
/** @type {Array<Array<Event>>} */
|
|
120
|
+
const vecs = []
|
|
121
|
+
while (index > 0) {
|
|
122
|
+
index -= 1
|
|
123
|
+
vecs.push(
|
|
124
|
+
events.slice(this.map[index][0] + this.map[index][1]),
|
|
125
|
+
this.map[index][2]
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
// Truncate rest.
|
|
129
|
+
events.length = this.map[index][0]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
vecs.push(events.slice())
|
|
133
|
+
events.length = 0
|
|
134
|
+
|
|
135
|
+
let slice = vecs.pop()
|
|
136
|
+
|
|
137
|
+
while (slice) {
|
|
138
|
+
for (const element of slice) {
|
|
139
|
+
events.push(element)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
slice = vecs.pop()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Truncate everything.
|
|
146
|
+
this.map.length = 0
|
|
147
|
+
this.index.clear()
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Create an edit.
|
|
153
|
+
*
|
|
154
|
+
* @param {EditMap} editMap
|
|
155
|
+
* Edit map to apply to.
|
|
156
|
+
* @param {number} at
|
|
157
|
+
* Index at which to apply the edit.
|
|
158
|
+
* @param {number} remove
|
|
159
|
+
* Count of items to remove at the index.
|
|
160
|
+
* @param {Array<Event>} add
|
|
161
|
+
* Items to add at the index.
|
|
162
|
+
* @param {boolean} before
|
|
163
|
+
* Insert `add` before existing additions at `at`, instead of after them.
|
|
164
|
+
* @returns {undefined}
|
|
165
|
+
* Nothing.
|
|
166
|
+
*/
|
|
167
|
+
function addImplementation(editMap, at, remove, add, before) {
|
|
168
|
+
if (remove === 0 && add.length === 0) {
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const existing = editMap.index.get(at)
|
|
173
|
+
|
|
174
|
+
if (existing) {
|
|
175
|
+
existing[1] += remove
|
|
176
|
+
|
|
177
|
+
if (before) {
|
|
178
|
+
add.push(...existing[2])
|
|
179
|
+
existing[2] = add
|
|
180
|
+
} else {
|
|
181
|
+
existing[2].push(...add)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** @type {Change} */
|
|
188
|
+
const change = [at, remove, add]
|
|
189
|
+
editMap.map.push(change)
|
|
190
|
+
editMap.index.set(at, change)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// /**
|
|
194
|
+
// * Shift `previous` and `next` links according to `jumps`.
|
|
195
|
+
// *
|
|
196
|
+
// * This fixes links in case there are events removed or added between them.
|
|
197
|
+
// *
|
|
198
|
+
// * @param {Array<Event>} events
|
|
199
|
+
// * @param {Array<Jump>} jumps
|
|
200
|
+
// */
|
|
201
|
+
// function shiftLinks(events, jumps) {
|
|
202
|
+
// let jumpIndex = 0
|
|
203
|
+
// let index = 0
|
|
204
|
+
// let add = 0
|
|
205
|
+
// let rm = 0
|
|
206
|
+
|
|
207
|
+
// while (index < events.length) {
|
|
208
|
+
// const rmCurr = rm
|
|
209
|
+
|
|
210
|
+
// while (jumpIndex < jumps.length && jumps[jumpIndex][0] <= index) {
|
|
211
|
+
// add = jumps[jumpIndex][2]
|
|
212
|
+
// rm = jumps[jumpIndex][1]
|
|
213
|
+
// jumpIndex += 1
|
|
214
|
+
// }
|
|
215
|
+
|
|
216
|
+
// // Ignore items that will be removed.
|
|
217
|
+
// if (rm > rmCurr) {
|
|
218
|
+
// index += rm - rmCurr
|
|
219
|
+
// } else {
|
|
220
|
+
// // ?
|
|
221
|
+
// // if let Some(link) = &events[index].link {
|
|
222
|
+
// // if let Some(next) = link.next {
|
|
223
|
+
// // events[next].link.as_mut().unwrap().previous = Some(index + add - rm);
|
|
224
|
+
// // while jumpIndex < jumps.len() && jumps[jumpIndex].0 <= next {
|
|
225
|
+
// // add = jumps[jumpIndex].2;
|
|
226
|
+
// // rm = jumps[jumpIndex].1;
|
|
227
|
+
// // jumpIndex += 1;
|
|
228
|
+
// // }
|
|
229
|
+
// // events[index].link.as_mut().unwrap().next = Some(next + add - rm);
|
|
230
|
+
// // index = next;
|
|
231
|
+
// // continue;
|
|
232
|
+
// // }
|
|
233
|
+
// // }
|
|
234
|
+
// index += 1
|
|
235
|
+
// }
|
|
236
|
+
// }
|
|
237
|
+
// }
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Event} from 'micromark-util-types'
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {[number, number, Array<Event>]} Change
|
|
6
|
+
* @typedef {[number, number, number]} Jump
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Tracks a bunch of edits.
|
|
10
|
+
*
|
|
11
|
+
* Port of `edit_map.rs` from `markdown-rs`:
|
|
12
|
+
* <https://github.com/wooorm/markdown-rs/blob/1506572f/src/util/edit_map.rs>.
|
|
13
|
+
*
|
|
14
|
+
* Deal with several changes in events, batching them together.
|
|
15
|
+
*
|
|
16
|
+
* Preferably, changes should be kept to a minimum.
|
|
17
|
+
* Sometimes, it’s needed to change the list of events, because parsing can be
|
|
18
|
+
* messy, and it helps to expose a cleaner interface of events to the compiler
|
|
19
|
+
* and other users.
|
|
20
|
+
* It can also help to merge many adjacent similar events.
|
|
21
|
+
* And, in other cases, it’s needed to parse subcontent: pass some events
|
|
22
|
+
* through another tokenizer and inject the result.
|
|
23
|
+
*/
|
|
24
|
+
export class EditMap {
|
|
25
|
+
/**
|
|
26
|
+
* Changes by index, so `add` does not need to scan `map` (which is
|
|
27
|
+
* quadratic for documents with many edits at different places).
|
|
28
|
+
*
|
|
29
|
+
* @type {Map<number, Change>}
|
|
30
|
+
*/
|
|
31
|
+
index: Map<number, Change>;
|
|
32
|
+
/**
|
|
33
|
+
* Record of changes.
|
|
34
|
+
*
|
|
35
|
+
* @type {Array<Change>}
|
|
36
|
+
*/
|
|
37
|
+
map: Array<Change>;
|
|
38
|
+
/**
|
|
39
|
+
* Create an edit: a remove and/or add at a certain place.
|
|
40
|
+
*
|
|
41
|
+
* @param {number} index
|
|
42
|
+
* Index at which to apply the edit.
|
|
43
|
+
* @param {number} remove
|
|
44
|
+
* Count of items to remove at the index.
|
|
45
|
+
* @param {Array<Event>} add
|
|
46
|
+
* Items to add at the index.
|
|
47
|
+
* @returns {undefined}
|
|
48
|
+
* Nothing.
|
|
49
|
+
*/
|
|
50
|
+
add(index: number, remove: number, add: Array<Event>): undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Create an edit: but insert `add` before existing additions, instead of
|
|
53
|
+
* after them.
|
|
54
|
+
*
|
|
55
|
+
* @param {number} index
|
|
56
|
+
* Index at which to apply the edit.
|
|
57
|
+
* @param {number} remove
|
|
58
|
+
* Count of items to remove at the index.
|
|
59
|
+
* @param {Array<Event>} add
|
|
60
|
+
* Items to add at the index.
|
|
61
|
+
* @returns {undefined}
|
|
62
|
+
* Nothing.
|
|
63
|
+
*/
|
|
64
|
+
addBefore(index: number, remove: number, add: Array<Event>): undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Done, change the events.
|
|
67
|
+
*
|
|
68
|
+
* @param {Array<Event>} events
|
|
69
|
+
* List of events to apply the edits to.
|
|
70
|
+
* @returns {undefined}
|
|
71
|
+
* Nothing.
|
|
72
|
+
*/
|
|
73
|
+
consume(events: Array<Event>): undefined;
|
|
74
|
+
}
|
|
75
|
+
export type Change = [number, number, Array<Event>];
|
|
76
|
+
export type Jump = [number, number, number];
|
|
77
|
+
import type { Event } from 'micromark-util-types';
|
|
78
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AACH;IAQI;;;;;OAKG;IACH,OAFU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAEP;IAEtB;;;;OAIG;IACH,KAFU,KAAK,CAAC,MAAM,CAAC,CAEV;IAGf;;;;;;;;;;;OAWG;IACH,WATW,MAAM,UAEN,MAAM,OAEN,KAAK,CAAC,KAAK,CAAC,GAEV,SAAS,CAKrB;IAED;;;;;;;;;;;;OAYG;IACH,iBATW,MAAM,UAEN,MAAM,OAEN,KAAK,CAAC,KAAK,CAAC,GAEV,SAAS,CAKrB;IAED;;;;;;;OAOG;IACH,gBALW,KAAK,CAAC,KAAK,CAAC,GAEV,SAAS,CA4DrB;CACF;qBA/IY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;mBAC9B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;2BALb,sBAAsB"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Event} from 'micromark-util-types'
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {[number, number, Array<Event>]} Change
|
|
7
|
+
* @typedef {[number, number, number]} Jump
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Tracks a bunch of edits.
|
|
12
|
+
*
|
|
13
|
+
* Port of `edit_map.rs` from `markdown-rs`:
|
|
14
|
+
* <https://github.com/wooorm/markdown-rs/blob/1506572f/src/util/edit_map.rs>.
|
|
15
|
+
*
|
|
16
|
+
* Deal with several changes in events, batching them together.
|
|
17
|
+
*
|
|
18
|
+
* Preferably, changes should be kept to a minimum.
|
|
19
|
+
* Sometimes, it’s needed to change the list of events, because parsing can be
|
|
20
|
+
* messy, and it helps to expose a cleaner interface of events to the compiler
|
|
21
|
+
* and other users.
|
|
22
|
+
* It can also help to merge many adjacent similar events.
|
|
23
|
+
* And, in other cases, it’s needed to parse subcontent: pass some events
|
|
24
|
+
* through another tokenizer and inject the result.
|
|
25
|
+
*/
|
|
26
|
+
export class EditMap {
|
|
27
|
+
/**
|
|
28
|
+
* Create a new edit map.
|
|
29
|
+
*
|
|
30
|
+
* @returns
|
|
31
|
+
* New instance.
|
|
32
|
+
*/
|
|
33
|
+
constructor() {
|
|
34
|
+
/**
|
|
35
|
+
* Changes by index, so `add` does not need to scan `map` (which is
|
|
36
|
+
* quadratic for documents with many edits at different places).
|
|
37
|
+
*
|
|
38
|
+
* @type {Map<number, Change>}
|
|
39
|
+
*/
|
|
40
|
+
this.index = new Map();
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Record of changes.
|
|
44
|
+
*
|
|
45
|
+
* @type {Array<Change>}
|
|
46
|
+
*/
|
|
47
|
+
this.map = [];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Create an edit: a remove and/or add at a certain place.
|
|
52
|
+
*
|
|
53
|
+
* @param {number} index
|
|
54
|
+
* Index at which to apply the edit.
|
|
55
|
+
* @param {number} remove
|
|
56
|
+
* Count of items to remove at the index.
|
|
57
|
+
* @param {Array<Event>} add
|
|
58
|
+
* Items to add at the index.
|
|
59
|
+
* @returns {undefined}
|
|
60
|
+
* Nothing.
|
|
61
|
+
*/
|
|
62
|
+
add(index, remove, add) {
|
|
63
|
+
addImplementation(this, index, remove, add, false);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create an edit: but insert `add` before existing additions, instead of
|
|
68
|
+
* after them.
|
|
69
|
+
*
|
|
70
|
+
* @param {number} index
|
|
71
|
+
* Index at which to apply the edit.
|
|
72
|
+
* @param {number} remove
|
|
73
|
+
* Count of items to remove at the index.
|
|
74
|
+
* @param {Array<Event>} add
|
|
75
|
+
* Items to add at the index.
|
|
76
|
+
* @returns {undefined}
|
|
77
|
+
* Nothing.
|
|
78
|
+
*/
|
|
79
|
+
addBefore(index, remove, add) {
|
|
80
|
+
addImplementation(this, index, remove, add, true);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Done, change the events.
|
|
85
|
+
*
|
|
86
|
+
* @param {Array<Event>} events
|
|
87
|
+
* List of events to apply the edits to.
|
|
88
|
+
* @returns {undefined}
|
|
89
|
+
* Nothing.
|
|
90
|
+
*/
|
|
91
|
+
consume(events) {
|
|
92
|
+
this.map.sort(function (a, b) {
|
|
93
|
+
return a[0] - b[0];
|
|
94
|
+
});
|
|
95
|
+
if (this.map.length === 0) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// To do: if links are added in events, like they are in `markdown-rs`,
|
|
100
|
+
// this is needed.
|
|
101
|
+
// // Calculate jumps: where items in the current list move to.
|
|
102
|
+
// /** @type {Array<Jump>} */
|
|
103
|
+
// const jumps = []
|
|
104
|
+
// let index = 0
|
|
105
|
+
// let addAcc = 0
|
|
106
|
+
// let removeAcc = 0
|
|
107
|
+
// while (index < this.map.length) {
|
|
108
|
+
// const [at, remove, add] = this.map[index]
|
|
109
|
+
// removeAcc += remove
|
|
110
|
+
// addAcc += add.length
|
|
111
|
+
// jumps.push([at, removeAcc, addAcc])
|
|
112
|
+
// index += 1
|
|
113
|
+
// }
|
|
114
|
+
//
|
|
115
|
+
// shiftLinks(events, jumps)
|
|
116
|
+
|
|
117
|
+
let index = this.map.length;
|
|
118
|
+
/** @type {Array<Array<Event>>} */
|
|
119
|
+
const vecs = [];
|
|
120
|
+
while (index > 0) {
|
|
121
|
+
index -= 1;
|
|
122
|
+
vecs.push(events.slice(this.map[index][0] + this.map[index][1]), this.map[index][2]);
|
|
123
|
+
|
|
124
|
+
// Truncate rest.
|
|
125
|
+
events.length = this.map[index][0];
|
|
126
|
+
}
|
|
127
|
+
vecs.push(events.slice());
|
|
128
|
+
events.length = 0;
|
|
129
|
+
let slice = vecs.pop();
|
|
130
|
+
while (slice) {
|
|
131
|
+
for (const element of slice) {
|
|
132
|
+
events.push(element);
|
|
133
|
+
}
|
|
134
|
+
slice = vecs.pop();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Truncate everything.
|
|
138
|
+
this.map.length = 0;
|
|
139
|
+
this.index.clear();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Create an edit.
|
|
145
|
+
*
|
|
146
|
+
* @param {EditMap} editMap
|
|
147
|
+
* Edit map to apply to.
|
|
148
|
+
* @param {number} at
|
|
149
|
+
* Index at which to apply the edit.
|
|
150
|
+
* @param {number} remove
|
|
151
|
+
* Count of items to remove at the index.
|
|
152
|
+
* @param {Array<Event>} add
|
|
153
|
+
* Items to add at the index.
|
|
154
|
+
* @param {boolean} before
|
|
155
|
+
* Insert `add` before existing additions at `at`, instead of after them.
|
|
156
|
+
* @returns {undefined}
|
|
157
|
+
* Nothing.
|
|
158
|
+
*/
|
|
159
|
+
function addImplementation(editMap, at, remove, add, before) {
|
|
160
|
+
if (remove === 0 && add.length === 0) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const existing = editMap.index.get(at);
|
|
164
|
+
if (existing) {
|
|
165
|
+
existing[1] += remove;
|
|
166
|
+
if (before) {
|
|
167
|
+
add.push(...existing[2]);
|
|
168
|
+
existing[2] = add;
|
|
169
|
+
} else {
|
|
170
|
+
existing[2].push(...add);
|
|
171
|
+
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** @type {Change} */
|
|
176
|
+
const change = [at, remove, add];
|
|
177
|
+
editMap.map.push(change);
|
|
178
|
+
editMap.index.set(at, change);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// /**
|
|
182
|
+
// * Shift `previous` and `next` links according to `jumps`.
|
|
183
|
+
// *
|
|
184
|
+
// * This fixes links in case there are events removed or added between them.
|
|
185
|
+
// *
|
|
186
|
+
// * @param {Array<Event>} events
|
|
187
|
+
// * @param {Array<Jump>} jumps
|
|
188
|
+
// */
|
|
189
|
+
// function shiftLinks(events, jumps) {
|
|
190
|
+
// let jumpIndex = 0
|
|
191
|
+
// let index = 0
|
|
192
|
+
// let add = 0
|
|
193
|
+
// let rm = 0
|
|
194
|
+
|
|
195
|
+
// while (index < events.length) {
|
|
196
|
+
// const rmCurr = rm
|
|
197
|
+
|
|
198
|
+
// while (jumpIndex < jumps.length && jumps[jumpIndex][0] <= index) {
|
|
199
|
+
// add = jumps[jumpIndex][2]
|
|
200
|
+
// rm = jumps[jumpIndex][1]
|
|
201
|
+
// jumpIndex += 1
|
|
202
|
+
// }
|
|
203
|
+
|
|
204
|
+
// // Ignore items that will be removed.
|
|
205
|
+
// if (rm > rmCurr) {
|
|
206
|
+
// index += rm - rmCurr
|
|
207
|
+
// } else {
|
|
208
|
+
// // ?
|
|
209
|
+
// // if let Some(link) = &events[index].link {
|
|
210
|
+
// // if let Some(next) = link.next {
|
|
211
|
+
// // events[next].link.as_mut().unwrap().previous = Some(index + add - rm);
|
|
212
|
+
// // while jumpIndex < jumps.len() && jumps[jumpIndex].0 <= next {
|
|
213
|
+
// // add = jumps[jumpIndex].2;
|
|
214
|
+
// // rm = jumps[jumpIndex].1;
|
|
215
|
+
// // jumpIndex += 1;
|
|
216
|
+
// // }
|
|
217
|
+
// // events[index].link.as_mut().unwrap().next = Some(next + add - rm);
|
|
218
|
+
// // index = next;
|
|
219
|
+
// // continue;
|
|
220
|
+
// // }
|
|
221
|
+
// // }
|
|
222
|
+
// index += 1
|
|
223
|
+
// }
|
|
224
|
+
// }
|
|
225
|
+
// }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "micromark-util-edit-map",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "micromark utility to batch changes to lists of events",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"micromark",
|
|
8
|
+
"util",
|
|
9
|
+
"utility",
|
|
10
|
+
"edit",
|
|
11
|
+
"map",
|
|
12
|
+
"splice"
|
|
13
|
+
],
|
|
14
|
+
"repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-util-edit-map",
|
|
15
|
+
"bugs": "https://github.com/micromark/micromark/issues",
|
|
16
|
+
"funding": [
|
|
17
|
+
{
|
|
18
|
+
"type": "GitHub Sponsors",
|
|
19
|
+
"url": "https://github.com/sponsors/unifiedjs"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "OpenCollective",
|
|
23
|
+
"url": "https://opencollective.com/unified"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
|
27
|
+
"contributors": [
|
|
28
|
+
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"type": "module",
|
|
32
|
+
"files": [
|
|
33
|
+
"dev/",
|
|
34
|
+
"index.d.ts.map",
|
|
35
|
+
"index.d.ts",
|
|
36
|
+
"index.js"
|
|
37
|
+
],
|
|
38
|
+
"exports": {
|
|
39
|
+
"development": "./dev/index.js",
|
|
40
|
+
"default": "./index.js"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"micromark-util-types": "^2.0.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "micromark-build"
|
|
47
|
+
}
|
|
48
|
+
}
|