retouche-dev 0.1.2 → 0.1.3
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/PROMPT.md +1 -1
- package/dist/cli.js +3 -3
- package/dist/{clock-BJi08VJS.js → clock-Bmj-zl7l.js} +2 -1
- package/dist/{follow-files-Dcya6bMQ.js → follow-files-BiRHzUhr.js} +1 -1
- package/dist/{handler-CoK5CtV4.js → handler-CcFK8fJV.js} +31 -224
- package/dist/index.js +1 -1
- package/dist/{layer-Bw5Xt2p7.js → layer-Ed1eBWo9.js} +4263 -4197
- package/dist/next.js +1 -1
- package/dist/spoken-timeline-CICeK4bI.js +286 -0
- package/dist/vite.js +3 -3
- package/dist/{voice-markdown-BiOKT1SX.js → voice-markdown-0BKH9ewO.js} +1 -1
- package/package.json +1 -1
- package/dist/spoken-timeline-1xtFghWv.js +0 -72
package/dist/next.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as appEnvs, i as appEnvFolders, t as createRouteHandler } from "./handler-
|
|
1
|
+
import { a as appEnvs, i as appEnvFolders, t as createRouteHandler } from "./handler-CcFK8fJV.js";
|
|
2
2
|
// src/server/next.ts
|
|
3
3
|
function createRoute(options = {}) {
|
|
4
4
|
let handler = null;
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
// src/source/jsx-range.ts
|
|
2
|
+
const FAILED = -1;
|
|
3
|
+
const MAX_TAG_LOOKBACK = 2;
|
|
4
|
+
const TAG_NAME_START = /[A-Za-z_$]/;
|
|
5
|
+
const TAG_NAME_CHAR = /[\w$.:-]/;
|
|
6
|
+
const IDENTIFIER_CHAR = /[\w$]/;
|
|
7
|
+
const WHITESPACE = /\s/;
|
|
8
|
+
const JSX_EXPRESSION_LEAD = /[([{,;=?:&|!>]/;
|
|
9
|
+
const JSX_KEYWORD_LEADS = /* @__PURE__ */ new Set([
|
|
10
|
+
"return",
|
|
11
|
+
"yield",
|
|
12
|
+
"default",
|
|
13
|
+
"await"
|
|
14
|
+
]);
|
|
15
|
+
function isTagStart(code, index) {
|
|
16
|
+
if (code.charAt(index) !== "<") return false;
|
|
17
|
+
const next = code.charAt(index + 1);
|
|
18
|
+
return next === ">" || TAG_NAME_START.test(next);
|
|
19
|
+
}
|
|
20
|
+
function startsJsxInExpression(code, index) {
|
|
21
|
+
let cursor = index - 1;
|
|
22
|
+
while (cursor >= 0 && WHITESPACE.test(code.charAt(cursor))) cursor -= 1;
|
|
23
|
+
if (cursor < 0) return true;
|
|
24
|
+
const previous = code.charAt(cursor);
|
|
25
|
+
if (JSX_EXPRESSION_LEAD.test(previous)) return true;
|
|
26
|
+
let wordStart = cursor;
|
|
27
|
+
while (wordStart > 0 && IDENTIFIER_CHAR.test(code.charAt(wordStart - 1))) wordStart -= 1;
|
|
28
|
+
return JSX_KEYWORD_LEADS.has(code.slice(wordStart, cursor + 1));
|
|
29
|
+
}
|
|
30
|
+
function skipJsString(code, index) {
|
|
31
|
+
const quote = code.charAt(index);
|
|
32
|
+
let cursor = index + 1;
|
|
33
|
+
while (cursor < code.length) {
|
|
34
|
+
const char = code.charAt(cursor);
|
|
35
|
+
if (char === "\\") cursor += 2;
|
|
36
|
+
else if (char === quote) return cursor + 1;
|
|
37
|
+
else if (char === "\n") return index + 1;
|
|
38
|
+
else cursor += 1;
|
|
39
|
+
}
|
|
40
|
+
return index + 1;
|
|
41
|
+
}
|
|
42
|
+
function skipTemplate(code, index) {
|
|
43
|
+
let cursor = index + 1;
|
|
44
|
+
while (cursor < code.length) {
|
|
45
|
+
const char = code.charAt(cursor);
|
|
46
|
+
if (char === "\\") cursor += 2;
|
|
47
|
+
else if (char === "`") return cursor + 1;
|
|
48
|
+
else if (char === "$" && code.charAt(cursor + 1) === "{") {
|
|
49
|
+
cursor = skipJsExpression(code, cursor + 1);
|
|
50
|
+
if (cursor === FAILED) return FAILED;
|
|
51
|
+
} else cursor += 1;
|
|
52
|
+
}
|
|
53
|
+
return FAILED;
|
|
54
|
+
}
|
|
55
|
+
function skipJsToken(code, index) {
|
|
56
|
+
const char = code.charAt(index);
|
|
57
|
+
const next = code.charAt(index + 1);
|
|
58
|
+
if (char === "\"" || char === "'") return skipJsString(code, index);
|
|
59
|
+
if (char === "`") return skipTemplate(code, index);
|
|
60
|
+
if (char === "/" && next === "/") {
|
|
61
|
+
const lineEnd = code.indexOf("\n", index);
|
|
62
|
+
return lineEnd === -1 ? code.length : lineEnd;
|
|
63
|
+
}
|
|
64
|
+
if (char === "/" && next === "*") {
|
|
65
|
+
const commentEnd = code.indexOf("*/", index + 2);
|
|
66
|
+
return commentEnd === -1 ? FAILED : commentEnd + 2;
|
|
67
|
+
}
|
|
68
|
+
if (isTagStart(code, index) && startsJsxInExpression(code, index)) return skipElement(code, index);
|
|
69
|
+
return index + 1;
|
|
70
|
+
}
|
|
71
|
+
function skipJsExpression(code, index) {
|
|
72
|
+
let depth = 0;
|
|
73
|
+
let cursor = index;
|
|
74
|
+
while (cursor < code.length) {
|
|
75
|
+
const char = code.charAt(cursor);
|
|
76
|
+
if (char === "{" || char === "}") {
|
|
77
|
+
depth += char === "{" ? 1 : -1;
|
|
78
|
+
cursor += 1;
|
|
79
|
+
if (depth === 0) return cursor;
|
|
80
|
+
} else {
|
|
81
|
+
cursor = skipJsToken(code, cursor);
|
|
82
|
+
if (cursor === FAILED) return FAILED;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return FAILED;
|
|
86
|
+
}
|
|
87
|
+
function skipTypeArguments(code, index) {
|
|
88
|
+
let depth = 0;
|
|
89
|
+
for (let cursor = index; cursor < code.length; cursor += 1) {
|
|
90
|
+
const char = code.charAt(cursor);
|
|
91
|
+
if (char === "<") depth += 1;
|
|
92
|
+
else if (char === ">") {
|
|
93
|
+
depth -= 1;
|
|
94
|
+
if (depth === 0) return cursor + 1;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return FAILED;
|
|
98
|
+
}
|
|
99
|
+
function skipAttributeToken(code, index) {
|
|
100
|
+
const char = code.charAt(index);
|
|
101
|
+
if (char === "{") return skipJsExpression(code, index);
|
|
102
|
+
if (char === "\"" || char === "'") {
|
|
103
|
+
const closingQuote = code.indexOf(char, index + 1);
|
|
104
|
+
return closingQuote === -1 ? FAILED : closingQuote + 1;
|
|
105
|
+
}
|
|
106
|
+
return index + 1;
|
|
107
|
+
}
|
|
108
|
+
function readTagName(code, index) {
|
|
109
|
+
let cursor = index;
|
|
110
|
+
while (TAG_NAME_CHAR.test(code.charAt(cursor))) cursor += 1;
|
|
111
|
+
return cursor;
|
|
112
|
+
}
|
|
113
|
+
function readOpeningTag(code, index) {
|
|
114
|
+
const nameEnd = readTagName(code, index + 1);
|
|
115
|
+
const name = code.slice(index + 1, nameEnd);
|
|
116
|
+
let cursor = code.charAt(nameEnd) === "<" ? skipTypeArguments(code, nameEnd) : nameEnd;
|
|
117
|
+
while (cursor !== FAILED && cursor < code.length) {
|
|
118
|
+
const char = code.charAt(cursor);
|
|
119
|
+
if (char === ">") return {
|
|
120
|
+
end: cursor + 1,
|
|
121
|
+
name,
|
|
122
|
+
selfClosing: false
|
|
123
|
+
};
|
|
124
|
+
if (char === "/" && code.charAt(cursor + 1) === ">") return {
|
|
125
|
+
end: cursor + 2,
|
|
126
|
+
name,
|
|
127
|
+
selfClosing: true
|
|
128
|
+
};
|
|
129
|
+
cursor = skipAttributeToken(code, cursor);
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
function readClosingTagEnd(code, index, name) {
|
|
134
|
+
let cursor = index + 2;
|
|
135
|
+
while (WHITESPACE.test(code.charAt(cursor))) cursor += 1;
|
|
136
|
+
const nameEnd = readTagName(code, cursor);
|
|
137
|
+
if (code.slice(cursor, nameEnd) !== name) return FAILED;
|
|
138
|
+
cursor = nameEnd;
|
|
139
|
+
while (WHITESPACE.test(code.charAt(cursor))) cursor += 1;
|
|
140
|
+
return code.charAt(cursor) === ">" ? cursor + 1 : FAILED;
|
|
141
|
+
}
|
|
142
|
+
function skipChildren(code, index, name) {
|
|
143
|
+
let cursor = index;
|
|
144
|
+
while (cursor !== FAILED && cursor < code.length) {
|
|
145
|
+
const char = code.charAt(cursor);
|
|
146
|
+
if (char === "<" && code.charAt(cursor + 1) === "/") return readClosingTagEnd(code, cursor, name);
|
|
147
|
+
if (char === "{") cursor = skipJsExpression(code, cursor);
|
|
148
|
+
else if (isTagStart(code, cursor)) cursor = skipElement(code, cursor);
|
|
149
|
+
else cursor += 1;
|
|
150
|
+
}
|
|
151
|
+
return FAILED;
|
|
152
|
+
}
|
|
153
|
+
function skipElement(code, index) {
|
|
154
|
+
const tag = readOpeningTag(code, index);
|
|
155
|
+
if (!tag) return FAILED;
|
|
156
|
+
return tag.selfClosing ? tag.end : skipChildren(code, tag.end, tag.name);
|
|
157
|
+
}
|
|
158
|
+
function lineOffset(code, line) {
|
|
159
|
+
if (!Number.isInteger(line) || line < 1) return FAILED;
|
|
160
|
+
let offset = 0;
|
|
161
|
+
for (let current = 1; current < line; current += 1) {
|
|
162
|
+
const newline = code.indexOf("\n", offset);
|
|
163
|
+
if (newline === -1) return FAILED;
|
|
164
|
+
offset = newline + 1;
|
|
165
|
+
}
|
|
166
|
+
return offset;
|
|
167
|
+
}
|
|
168
|
+
function findTagStart(code, { column, lineEnd, lineStart }) {
|
|
169
|
+
const origin = Math.min(lineStart + Math.max(column, 0), lineEnd);
|
|
170
|
+
for (let back = 0; back <= MAX_TAG_LOOKBACK; back += 1) {
|
|
171
|
+
const candidate = origin - back;
|
|
172
|
+
if (candidate >= lineStart && isTagStart(code, candidate)) return candidate;
|
|
173
|
+
}
|
|
174
|
+
for (let candidate = origin + 1; candidate < lineEnd; candidate += 1) if (isTagStart(code, candidate)) return candidate;
|
|
175
|
+
return FAILED;
|
|
176
|
+
}
|
|
177
|
+
function countNewlines(code, from, to) {
|
|
178
|
+
let count = 0;
|
|
179
|
+
let newline = code.indexOf("\n", from);
|
|
180
|
+
while (newline !== -1 && newline < to) {
|
|
181
|
+
count += 1;
|
|
182
|
+
newline = code.indexOf("\n", newline + 1);
|
|
183
|
+
}
|
|
184
|
+
return count;
|
|
185
|
+
}
|
|
186
|
+
function jsxElementLines(code, line, column) {
|
|
187
|
+
const lineStart = lineOffset(code, line);
|
|
188
|
+
if (lineStart === FAILED) return null;
|
|
189
|
+
const newline = code.indexOf("\n", lineStart);
|
|
190
|
+
const tagStart = findTagStart(code, {
|
|
191
|
+
column,
|
|
192
|
+
lineEnd: newline === -1 ? code.length : newline,
|
|
193
|
+
lineStart
|
|
194
|
+
});
|
|
195
|
+
if (tagStart === FAILED) return null;
|
|
196
|
+
const elementEnd = skipElement(code, tagStart);
|
|
197
|
+
if (elementEnd === FAILED) return null;
|
|
198
|
+
return {
|
|
199
|
+
end: line + countNewlines(code, tagStart, elementEnd - 1),
|
|
200
|
+
start: line
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function elementPlace(code, at) {
|
|
204
|
+
if (at.line === null) return {
|
|
205
|
+
column: at.column,
|
|
206
|
+
elementLines: null
|
|
207
|
+
};
|
|
208
|
+
const text = code.split("\n")[at.line - 1] ?? "";
|
|
209
|
+
const column = at.column !== null && at.column < text.length ? at.column : null;
|
|
210
|
+
return {
|
|
211
|
+
column,
|
|
212
|
+
elementLines: jsxElementLines(code, at.line, column ?? 0)
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
// src/voice/spoken-timeline.ts
|
|
216
|
+
const WORD = /\S+/g;
|
|
217
|
+
const FULL_HOLD_MS = 2e3;
|
|
218
|
+
const HOLD_HEAD_START_MS = 400;
|
|
219
|
+
const SAID_BEFORE_MS = 400;
|
|
220
|
+
const SAID_AFTER_MS = 1200;
|
|
221
|
+
const KIND_WEIGHTS = {
|
|
222
|
+
click: 1,
|
|
223
|
+
point: .7
|
|
224
|
+
};
|
|
225
|
+
function spokenWords(text) {
|
|
226
|
+
return text.match(WORD) ?? [];
|
|
227
|
+
}
|
|
228
|
+
function momentWeight(moment) {
|
|
229
|
+
const hold = Math.min(1, (moment.durationMs + HOLD_HEAD_START_MS) / FULL_HOLD_MS);
|
|
230
|
+
return KIND_WEIGHTS[moment.kind] * hold;
|
|
231
|
+
}
|
|
232
|
+
function spread(words, passage) {
|
|
233
|
+
const total = words.reduce((sum, word) => sum + word.length, 0);
|
|
234
|
+
const span = passage.endMs - passage.startMs;
|
|
235
|
+
let said = 0;
|
|
236
|
+
return words.map((word) => {
|
|
237
|
+
const atMs = passage.startMs + span * said / total;
|
|
238
|
+
said += word.length;
|
|
239
|
+
return atMs;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
function wordTimes(passage) {
|
|
243
|
+
const words = spokenWords(passage.text);
|
|
244
|
+
const { endMs, startMs, wordMs = [] } = passage;
|
|
245
|
+
if (wordMs.length !== words.length) return spread(words, passage);
|
|
246
|
+
let earliest = startMs;
|
|
247
|
+
return wordMs.map((atMs) => {
|
|
248
|
+
earliest = Math.min(endMs, Math.max(earliest, atMs));
|
|
249
|
+
return earliest;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function nearness(moment, atMs) {
|
|
253
|
+
const endMs = moment.atMs + moment.durationMs;
|
|
254
|
+
if (atMs < moment.atMs) return 1 - (moment.atMs - atMs) / SAID_BEFORE_MS;
|
|
255
|
+
if (atMs > endMs) return 1 - (atMs - endMs) / SAID_AFTER_MS;
|
|
256
|
+
return 1;
|
|
257
|
+
}
|
|
258
|
+
function wordOwners(moments, times) {
|
|
259
|
+
return times.map((atMs) => {
|
|
260
|
+
let owner = null;
|
|
261
|
+
let best = 0;
|
|
262
|
+
for (const moment of moments) {
|
|
263
|
+
const score = momentWeight(moment) * nearness(moment, atMs);
|
|
264
|
+
if (score > best) {
|
|
265
|
+
best = score;
|
|
266
|
+
owner = moment.id;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return owner;
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function passageRuns(passage, moments) {
|
|
273
|
+
const owners = wordOwners(moments.filter(({ id }) => passage.momentIds.includes(id)), wordTimes(passage));
|
|
274
|
+
const runs = [];
|
|
275
|
+
for (const [index, word] of spokenWords(passage.text).entries()) {
|
|
276
|
+
const momentId = owners[index] ?? null;
|
|
277
|
+
const last = runs.at(-1);
|
|
278
|
+
if (last?.momentId === momentId) last.text = `${last.text} ${word}`;
|
|
279
|
+
else runs.push({
|
|
280
|
+
momentId,
|
|
281
|
+
text: word
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
return runs;
|
|
285
|
+
}
|
|
286
|
+
export { wordTimes as a, wordOwners as i, passageRuns as n, elementPlace as o, spokenWords as r, momentWeight as t };
|
package/dist/vite.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as ROUTE_BASE } from "./clock-
|
|
2
|
-
import { a as appEnvs, n as BODY_LIMIT_ERROR, o as isLoopbackAddress, t as createRouteHandler } from "./handler-
|
|
3
|
-
import { g as errorResponse, h as deferred } from "./follow-files-
|
|
1
|
+
import { d as ROUTE_BASE } from "./clock-Bmj-zl7l.js";
|
|
2
|
+
import { a as appEnvs, n as BODY_LIMIT_ERROR, o as isLoopbackAddress, t as createRouteHandler } from "./handler-CcFK8fJV.js";
|
|
3
|
+
import { g as errorResponse, h as deferred } from "./follow-files-BiRHzUhr.js";
|
|
4
4
|
import { loadEnv } from "vite";
|
|
5
5
|
// src/server/node-http.ts
|
|
6
6
|
async function readBody(request) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as recordedMs, r as pendingPassages, t as clock } from "./clock-
|
|
1
|
+
import { n as recordedMs, r as pendingPassages, t as clock } from "./clock-Bmj-zl7l.js";
|
|
2
2
|
// src/voice/follow-prompt.ts
|
|
3
3
|
const FOLLOW_TOOL = "next_feedback";
|
|
4
4
|
const FOLLOW_PROMPT = "follow";
|
package/package.json
CHANGED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// src/voice/spoken-timeline.ts
|
|
2
|
-
const WORD = /\S+/g;
|
|
3
|
-
const FULL_HOLD_MS = 2e3;
|
|
4
|
-
const HOLD_HEAD_START_MS = 400;
|
|
5
|
-
const SAID_BEFORE_MS = 400;
|
|
6
|
-
const SAID_AFTER_MS = 1200;
|
|
7
|
-
const KIND_WEIGHTS = {
|
|
8
|
-
click: 1,
|
|
9
|
-
point: .7
|
|
10
|
-
};
|
|
11
|
-
function spokenWords(text) {
|
|
12
|
-
return text.match(WORD) ?? [];
|
|
13
|
-
}
|
|
14
|
-
function momentWeight(moment) {
|
|
15
|
-
const hold = Math.min(1, (moment.durationMs + HOLD_HEAD_START_MS) / FULL_HOLD_MS);
|
|
16
|
-
return KIND_WEIGHTS[moment.kind] * hold;
|
|
17
|
-
}
|
|
18
|
-
function spread(words, passage) {
|
|
19
|
-
const total = words.reduce((sum, word) => sum + word.length, 0);
|
|
20
|
-
const span = passage.endMs - passage.startMs;
|
|
21
|
-
let said = 0;
|
|
22
|
-
return words.map((word) => {
|
|
23
|
-
const atMs = passage.startMs + span * said / total;
|
|
24
|
-
said += word.length;
|
|
25
|
-
return atMs;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function wordTimes(passage) {
|
|
29
|
-
const words = spokenWords(passage.text);
|
|
30
|
-
const { endMs, startMs, wordMs = [] } = passage;
|
|
31
|
-
if (wordMs.length !== words.length) return spread(words, passage);
|
|
32
|
-
let earliest = startMs;
|
|
33
|
-
return wordMs.map((atMs) => {
|
|
34
|
-
earliest = Math.min(endMs, Math.max(earliest, atMs));
|
|
35
|
-
return earliest;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
function nearness(moment, atMs) {
|
|
39
|
-
const endMs = moment.atMs + moment.durationMs;
|
|
40
|
-
if (atMs < moment.atMs) return 1 - (moment.atMs - atMs) / SAID_BEFORE_MS;
|
|
41
|
-
if (atMs > endMs) return 1 - (atMs - endMs) / SAID_AFTER_MS;
|
|
42
|
-
return 1;
|
|
43
|
-
}
|
|
44
|
-
function wordOwners(moments, times) {
|
|
45
|
-
return times.map((atMs) => {
|
|
46
|
-
let owner = null;
|
|
47
|
-
let best = 0;
|
|
48
|
-
for (const moment of moments) {
|
|
49
|
-
const score = momentWeight(moment) * nearness(moment, atMs);
|
|
50
|
-
if (score > best) {
|
|
51
|
-
best = score;
|
|
52
|
-
owner = moment.id;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return owner;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
function passageRuns(passage, moments) {
|
|
59
|
-
const owners = wordOwners(moments.filter(({ id }) => passage.momentIds.includes(id)), wordTimes(passage));
|
|
60
|
-
const runs = [];
|
|
61
|
-
for (const [index, word] of spokenWords(passage.text).entries()) {
|
|
62
|
-
const momentId = owners[index] ?? null;
|
|
63
|
-
const last = runs.at(-1);
|
|
64
|
-
if (last?.momentId === momentId) last.text = `${last.text} ${word}`;
|
|
65
|
-
else runs.push({
|
|
66
|
-
momentId,
|
|
67
|
-
text: word
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return runs;
|
|
71
|
-
}
|
|
72
|
-
export { wordTimes as a, wordOwners as i, passageRuns as n, spokenWords as r, momentWeight as t };
|