1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 02:39:46 +02:00

Libs updates and new version with option to pin videos on channel

This commit is contained in:
Daniel Neto 2024-08-05 11:37:04 -03:00
parent e1f2188de0
commit 1beab3b1c0
8565 changed files with 149805 additions and 165674 deletions

View file

@ -28,10 +28,19 @@ class CompletionContext {
only return completions when either there is part of a
completable entity before the cursor, or `explicit` is true.
*/
explicit) {
explicit,
/**
The editor view. May be undefined if the context was created
in a situation where there is no such view available, such as
in synchronous updates via
[`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update)
or when called by test code.
*/
view) {
this.state = state;
this.pos = pos;
this.explicit = explicit;
this.view = view;
/**
@internal
*/
@ -348,6 +357,7 @@ const completionConfig = state.Facet.define({
combine(configs) {
return state.combineConfig(configs, {
activateOnTyping: true,
activateOnCompletion: () => false,
activateOnTypingDelay: 100,
selectOnOpen: true,
override: null,
@ -851,7 +861,7 @@ class CompletionState {
return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open);
}
get tooltip() { return this.open ? this.open.tooltip : null; }
get attrs() { return this.open ? this.open.attrs : baseAttrs; }
get attrs() { return this.open ? this.open.attrs : this.active.length ? baseAttrs : noAttrs; }
}
function sameResults(a, b) {
if (a == b)
@ -871,6 +881,7 @@ function sameResults(a, b) {
const baseAttrs = {
"aria-autocomplete": "list"
};
const noAttrs = {};
function makeAttrs(id, selected) {
let result = {
"aria-autocomplete": "list",
@ -882,8 +893,18 @@ function makeAttrs(id, selected) {
return result;
}
const none = [];
function getUserEvent(tr) {
return tr.isUserEvent("input.type") ? "input" : tr.isUserEvent("delete.backward") ? "delete" : null;
function getUpdateType(tr, conf) {
if (tr.isUserEvent("input.complete")) {
let completion = tr.annotation(pickedCompletion);
if (completion && conf.activateOnCompletion(completion))
return 4 /* UpdateType.Activate */ | 8 /* UpdateType.Reset */;
}
let typing = tr.isUserEvent("input.type");
return typing && conf.activateOnTyping ? 4 /* UpdateType.Activate */ | 1 /* UpdateType.Typing */
: typing ? 1 /* UpdateType.Typing */
: tr.isUserEvent("delete.backward") ? 2 /* UpdateType.Backspacing */
: tr.selection ? 8 /* UpdateType.Reset */
: tr.docChanged ? 16 /* UpdateType.ResetIfTouching */ : 0 /* UpdateType.None */;
}
class ActiveSource {
constructor(source, state, explicitPos = -1) {
@ -893,13 +914,12 @@ class ActiveSource {
}
hasResult() { return false; }
update(tr, conf) {
let event = getUserEvent(tr), value = this;
if (event)
value = value.handleUserEvent(tr, event, conf);
else if (tr.docChanged)
value = value.handleChange(tr);
else if (tr.selection && value.state != 0 /* State.Inactive */)
let type = getUpdateType(tr, conf), value = this;
if ((type & 8 /* UpdateType.Reset */) || (type & 16 /* UpdateType.ResetIfTouching */) && this.touches(tr))
value = new ActiveSource(value.source, 0 /* State.Inactive */);
if ((type & 4 /* UpdateType.Activate */) && value.state == 0 /* State.Inactive */)
value = new ActiveSource(this.source, 1 /* State.Pending */);
value = value.updateFor(tr, type);
for (let effect of tr.effects) {
if (effect.is(startCompletionEffect))
value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value ? cur(tr.state) : -1);
@ -912,15 +932,13 @@ class ActiveSource {
}
return value;
}
handleUserEvent(tr, type, conf) {
return type == "delete" || !conf.activateOnTyping ? this.map(tr.changes) : new ActiveSource(this.source, 1 /* State.Pending */);
}
handleChange(tr) {
return tr.changes.touchesRange(cur(tr.startState)) ? new ActiveSource(this.source, 0 /* State.Inactive */) : this.map(tr.changes);
}
updateFor(tr, type) { return this.map(tr.changes); }
map(changes) {
return changes.empty || this.explicitPos < 0 ? this : new ActiveSource(this.source, this.state, changes.mapPos(this.explicitPos));
}
touches(tr) {
return tr.changes.touchesRange(cur(tr.state));
}
}
class ActiveResult extends ActiveSource {
constructor(source, explicitPos, result, from, to) {
@ -930,8 +948,10 @@ class ActiveResult extends ActiveSource {
this.to = to;
}
hasResult() { return true; }
handleUserEvent(tr, type, conf) {
updateFor(tr, type) {
var _a;
if (!(type & 3 /* UpdateType.SimpleInteraction */))
return this.map(tr.changes);
let result = this.result;
if (result.map && !tr.changes.empty)
result = result.map(result, tr.changes);
@ -939,8 +959,8 @@ class ActiveResult extends ActiveSource {
let pos = cur(tr.state);
if ((this.explicitPos < 0 ? pos <= from : pos < this.from) ||
pos > to || !result ||
type == "delete" && cur(tr.startState) == this.from)
return new ActiveSource(this.source, type == "input" && conf.activateOnTyping ? 1 /* State.Pending */ : 0 /* State.Inactive */);
(type & 2 /* UpdateType.Backspacing */) && cur(tr.startState) == this.from)
return new ActiveSource(this.source, type & 4 /* UpdateType.Activate */ ? 1 /* State.Pending */ : 0 /* State.Inactive */);
let explicitPos = this.explicitPos < 0 ? -1 : tr.changes.mapPos(this.explicitPos);
if (checkValid(result.validFor, tr.state, from, to))
return new ActiveResult(this.source, explicitPos, result, from, to);
@ -949,9 +969,6 @@ class ActiveResult extends ActiveSource {
return new ActiveResult(this.source, explicitPos, result, result.from, (_a = result.to) !== null && _a !== void 0 ? _a : cur(tr.state));
return new ActiveSource(this.source, 1 /* State.Pending */, explicitPos);
}
handleChange(tr) {
return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource(this.source, 0 /* State.Inactive */) : this.map(tr.changes);
}
map(mapping) {
if (mapping.empty)
return this;
@ -960,6 +977,9 @@ class ActiveResult extends ActiveSource {
return new ActiveSource(this.source, 0 /* State.Inactive */);
return new ActiveResult(this.source, this.explicitPos < 0 ? -1 : mapping.mapPos(this.explicitPos), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
}
touches(tr) {
return tr.changes.touchesRange(this.from, this.to);
}
}
function checkValid(validFor, state, from, to) {
if (!validFor)
@ -1072,10 +1092,12 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
}
update(update) {
let cState = update.state.field(completionState);
let conf = update.state.facet(completionConfig);
if (!update.selectionSet && !update.docChanged && update.startState.field(completionState) == cState)
return;
let doesReset = update.transactions.some(tr => {
return (tr.selection || tr.docChanged) && !getUserEvent(tr);
let type = getUpdateType(tr, conf);
return (type & 8 /* UpdateType.Reset */) || (tr.selection || tr.docChanged) && !(type & 3 /* UpdateType.SimpleInteraction */);
});
for (let i = 0; i < this.running.length; i++) {
let query = this.running[i];
@ -1100,12 +1122,12 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
clearTimeout(this.debounceUpdate);
if (update.transactions.some(tr => tr.effects.some(e => e.is(startCompletionEffect))))
this.pendingStart = true;
let delay = this.pendingStart ? 50 : update.state.facet(completionConfig).activateOnTypingDelay;
let delay = this.pendingStart ? 50 : conf.activateOnTypingDelay;
this.debounceUpdate = cState.active.some(a => a.state == 1 /* State.Pending */ && !this.running.some(q => q.active.source == a.source))
? setTimeout(() => this.startUpdate(), delay) : -1;
if (this.composing != 0 /* CompositionState.None */)
for (let tr of update.transactions) {
if (getUserEvent(tr) == "input")
if (tr.isUserEvent("input.type"))
this.composing = 2 /* CompositionState.Changed */;
else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection)
this.composing = 3 /* CompositionState.ChangedAndMoved */;
@ -1122,7 +1144,7 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
}
startQuery(active) {
let { state } = this.view, pos = cur(state);
let context = new CompletionContext(state, pos, active.explicitPos == pos);
let context = new CompletionContext(state, pos, active.explicitPos == pos, this.view);
let pending = new RunningQuery(active, context);
this.running.push(pending);
Promise.resolve(active.source(context)).then(result => {
@ -1394,8 +1416,9 @@ class Snippet {
let fields = [];
let lines = [], positions = [], m;
for (let line of template.split(/\r\n?|\n/)) {
while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(line)) {
let seq = m[1] ? +m[1] : null, name = m[2] || m[3] || "", found = -1;
while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(line)) {
let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
let name = rawName.replace(/\\[{}]/g, m => m[1]);
for (let i = 0; i < fields.length; i++) {
if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
found = i;
@ -1411,16 +1434,16 @@ class Snippet {
pos.field++;
}
positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
line = line.slice(0, m.index) + rawName + line.slice(m.index + m[0].length);
}
for (let esc; esc = /\\([{}])/.exec(line);) {
line = line.slice(0, esc.index) + esc[1] + line.slice(esc.index + esc[0].length);
line = line.replace(/\\([{}])/g, (_, brace, index) => {
for (let pos of positions)
if (pos.line == lines.length && pos.from > esc.index) {
if (pos.line == lines.length && pos.from > index) {
pos.from--;
pos.to--;
}
}
return brace;
});
lines.push(line);
}
return new Snippet(lines, positions);