@deslop/stash 0.1.1082 → 0.1.1085
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/README.md +1 -1
- package/dist/cli.js +88 -19
- package/dist/{contracts-Cc_B2S3-.mjs → contracts-B0mJTvsC.mjs} +150 -71
- package/dist/server.js +204 -290
- package/package.json +2 -1
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --max-old-space-size=16384 --heapsnapshot-near-heap-limit=3 --report-on-fatalerror
|
|
2
|
-
import { $ as CloseEvent, $c as close, $d as isNotUndefined, $i as offer, $n as setAll, $o as orDie, $r as failCause$3, $s as includes, $t as decodeEffect, $u as getOrUndefinedUnsafe, A as withDefault, Aa as formatIp, Ac as hasInterruptsOnly, Ad as flip, Ai as runLast, An as withDecodingDefaultKey, Ao as interrupt, Ar as resolveDescription, As as try_, At as Json, Au as empty$12, B as constEof, Ba as isUnicast, Bc as effectDiscard, Bd as BaseProto, Bn as unwrap$1, Bo as map$1, Br as toEpochMillis, Bs as withFiberSucceed, Bt as Redacted, Bu as succeed, C as Redacted$1, Ca as DnsError, Cd as orElse$2, Ci as pipeThroughChannel, Cl as effectIsExit, Cn as toCodecJson, Cr as decodeTo$1, Cs as tapCause, Ct as Defect, Cu as takeRight, D as option, Da as domainNameFromStringUnsafe, Dc as fromReasons, Dd as Number$1, Di as runForEach, Dl as makeSpanUnsafe, Dn as toType, Do as gen, Dr as null_, Ds as timeoutOrElse, Du as keys, E as map$7, Ea as nameServerFromInput, Ed as toArray$1, Ei as runCollect, El as forkUnsafe, En as toJsonSchemaDocument, Eo as fromResult, Er as mapOrSame, Es as timeoutOption, Et as Exit$1, Eu as has$3, F as json$1, Fa as ipv4ToOctets, Fc as squash, Fd as contE, Fi as tap, Fl as make$41, Fn as CurrentRedactedNames$1, Fr as transform$1, Fs as useSpan, Ft as NonEmptyArray, Fu as fromOption$1, G as isWrapper, Ga as annotateCurrentSpan, Gc as provide, Gd as format$1, Gi as pipeTo, Gl as drop, Gn as CurrentRedactedNames, Go as matchCauseEffectEager, Gr as catchTags$1, Gt as Tuple, Gu as seconds, H as constPong, Ha as acquireRelease, Hc as launch, Hd as NodeInspectSymbol, Hi as map$5, Hl as contains$1, Hn as has$4, Ho as mapError, Hr as Path, Hs as withParentSpan, Ht as Struct, Hu as format$2, I as layerJson, Ia as isInetAddressV6, Ic as CurrentMemoMap, Ii as toReadableStreamEffect, Il as nativeTracer, In as empty$7, Io as logFatal, Ir as transformOptional, Is as void_, It as Null, Iu as isFailure, J as isStreamSchema, Ja as asSome, Jc as succeedContext, Jd as hash, Jl as every, Jn as fromRecordUnsafe, Jo as onError, Jr as decodeText, Js as catchDone, Jt as Uint8Array$2, Ju as Service, K as ClientAbort$1, Ka as annotateLogs, Kc as provideMerge, Kd as redact, Ki as make$32, Kl as empty$11, Kn as empty$8, Ko as matchEffect, Kr as catch_$1, Kt as URL$3, Ku as toMillis, L as layerSchemaBinary, La as isLinkLocal, Lc as buildWithMemoMap, Ld as assignProperty, Ll as Error$1, Ln as fromInput, Lo as logInfo, Lr as encode, Ls as when$2, Lt as NullOr, Lu as isResult, M as withRun, Ma as inetAddressFromIpString, Mc as isNoSuchElementError, Md as Prototype, Mi as succeed$3, Ml as ParentSpan, Mn as omit, Mo as isEffect, Mr as string, Ms as uninterruptibleMask, Mt as Literals, Mu as make$40, Na as ipFromString, Nc as makeDieReason, Nd as PipeInspectableProto, Ni as suspend$1, Nl as Tracer, Nn as getReferenceKey, No as log, Nr as toEncoded, Ns as updateContext, Nt as MutableJson, Nu as fail, O as succeed$5, Oa as NetAddressError, Oc as hasDies, Od as String$3, Oi as runForEachArray, Ol as onExitUnsafe, On as withConstructorDefault, Oo as ignore$1, Or as optionalKey$1, Os as transposeOption, Ot as Finite, Ou as map$6, P as RpcSerialization, Pa as ipFromStringUnsafe, Pc as prettyErrors, Pd as contA, Pi as takeUntil, Pl as externalSpan, Pn as encodeUnknownEffect, Po as logDebug, Pr as passthrough, Ps as updateService, Pt as Never, Pu as failVoid, Q as makeCollectorUnsafe, Qa as catchCause, Qc as addFinalizerExit, Qd as isNotNullish, Qi as make$34, Ql as findFirstIndex, Qn as set$1, Qo as option$1, Qr as fail$2, Qs as endsWith, Qt as Unknown, Qu as getOrUndefined$1, R as RequestId, Ra as isLoopback, Rc as effect, Rd as getStackTraceLimit, Ri as unwrap$2, Rl as TaggedClass, Rn as redactUrl, Ro as logWarning, Rr as formatIso, Rs as whileLoop, Rt as Number$2, Ru as isSuccess, S as Port, Sa as Dns, Sc as die$1, Sd as none, Si as orDie$1, Sn as tag, So as forkChild, Sr as Union$1, Ss as tap$1, St as DateTimeUtcFromString, Su as take$1, T as URL$4, Ta as makeRecordUnsafe, Tc as filterInterruptors, Td as some$1, Ti as run$3, Tl as fiberEnterUninterruptibleUnsafe, Tn as toEncoded$1, To as fromOption, Tr as isOptional, Ts as timeout, Tt as Error$2, Tu as get$8, U as ServerClient, Ua as all, Uc as merge$3, Ud as toJson, Ul as dedupe, Un as fromIterable$2, Ur as FileSystem, Us as withSpan, Ut as TaggedError$1, Uu as millis, Va as unixPathAddress, Vc as empty$13, Vd as Class, Vi as fromTransform, Vl as appendAll, Vn as fromIterable$3, Vo as mapEager, Vr as defaultFormatter, Vs as withLogSpan, Vt as String$1, Vu as try_$1, W as exitSchema, Wa as andThen, Wc as mergeAll, Wd as toStringUnknown, Wl as dedupeAdjacentWith, Wn as get$7, Wo as matchCauseEffect, Wr as catchReason$1, Ws as zipWith, Wu as parts, X as spanName, Xa as cached, Xc as Scope, Xd as isIterable, Xi as end$1, Xl as filterMap, Xn as merge$2, Xo as onExitPrimitive, Xr as empty$10, Xs as Random$2, Xt as UndefinedOr, Y as spanAttributes, Ya as asVoid, Yc as unwrap$3, Yd as hasProperty, Yi as collect, Yl as filter$4, Yn as isRedactedName, Yo as onExit, Yr as die$3, Yt as Uint8ArrayFromBase64, Yu as add$1, Z as Collector, Za as callback, Zc as addFinalizer, Zd as isNotNull, Zi as failCause$2, Zl as findFirst, Zn as remove$3, Zo as onInterrupt, Zr as ensuring, Zs as camelToSnake, Zt as Union, Zu as get$5, _a as fromInput$2, _c as Clock, _d as isSome, _i as mapError$1, _l as interrupt$1, _n as make$37, _o as flatMapEager, _r as FilterGroup, _s as serviceOption, _t as ArraySchema, _u as prepend$2, a as ImageType, aa as takeAll, ac as repeat$1, ad as contains$2, af as constTrue, ai as fromEffect, al as CurrentLogAnnotations, an as encodeSync, ao as catchTags, ar as isEmpty$1, as as provideServiceEffect, at as fromWebSocket, au as groupBy, b as layer$12, ba as mebibytes, bc as annotate, bd as map$4, bi as mkUint8Array, bl as isSuccess$1, bn as optional$1, bo as forEach, br as PropertySignature, bs as suspend, bt as Class$1, bu as some$2, c as NotesError, ca as makeUnsafe$5, cc as slice$2, cd as flatMap$2, cf as constant, ci as fromQueue, cl as TracerTimingEnabled, cn as fromJsonString, co as contextWith, cr as fromReadable, cs as result$1, ct as DecodeError, cu as isArrayNonEmpty, d as layer$14, da as interrupt$2, dc as toLowerCase, dd as fromNullishOr, df as identity, di as limitBytes, dl as into, dn as isInt, do as ensuring$1, dr as toUint8Array$1, ds as runFork, dt as HttpClientError, du as join$1, ea as offerAll, ec as isEmpty$2, ed as getUnsafe, ef as isObject, ei as filter$6, el as closeUnsafe, en as decodeSync, eo as catchDefect, er as isRedacted, es as orElseSucceed, eu as flatMap$1, f as make$42, fa as interruptAll, fc as trim, fd as fromUndefinedOr, ff as pipe, fi as map$2, fl as isDeferred, fn as isMaxLength, fo as exit, fr as fromWritable, fs as runForkWith, fu as last$1, g as layer$13, ga as badArgument, gd as isNone, gi as mapEffect, gl as failCause$1, gn as isSchemaError$1, go as flatMap, gr as Filter, gs as service, gt as Any, gu as of, ha as runIn, hc as parse$10, hd as getOrUndefined, hi as mapArrayEffect, hl as fail$3, hn as isSchema, ho as filterOrFail, hr as Arrays, hs as scoped, ht as TransportError, i as FileType, ia as take, ic as padStart, id as all$1, if as constFalse, il as provide$1, in as encodeEffect, io as catchTag, ir as fromSetCookie, is as provideService, iu as getUnsafe$1, ja as formatUrlUnsafe, jd as mapInput, ji as scan, jl as DisablePropagation, jn as isSchemaError, jo as interruptible, jr as resolveIdentifier, js as uninterruptible, jt as Literal$1, ju as headUnsafe, k as unwrap$4, ka as formatInet, kc as hasInterrupts, kd as combine$1, kl as reportCauseUnsafe, kn as withDecodingDefault, kr as replaceChecks, ks as tryPromise, kt as Int, ku as toEntries, l as Organization, la as await_, lc as split, ld as flatMapNullishOr, lf as dual, li as fromReadableStream, ll as _await, ln as is$4, lr as pipeThroughDuplex, ls as retry, lt as EmptyBodyError, lu as isReadonlyArrayEmpty, ma as interruptAs, mc as max$1, md as getOrNull, mi as mapArray, ml as die, mn as isPattern, mo as failCause, mr as ChildProcessSpawner, ms as scope, mt as StatusCodeError, mu as map$3, n as Capture, na as shutdown, nc as length, nd as makeUnsafe$3, nf as isUndefined, ni as flattenIterable, nl as make$33, nn as decodeUnknownEffect, no as catchIf, nr as value$2, ns as provide$2, nu as get$6, o as Note, oa as publishUnsafe, oc as replace$1, od as exists, of as constUndefined, oi as fromIterable, ol as CurrentLogSpans, on as encodeTo, oo as catch_, or as parseHeader, os as raceFirst, ou as head, p as runMain, pa as interruptAllAs, pc as trimEnd, pd as getOrElse, pf as pipeArguments, pi as mapAccum, pl as makeUnsafe$4, pn as isMinLength, po as fail$1, pr as make$36, ps as runSync, pt as InvalidUrlError, pu as lastNonEmpty, q as getStreamSchemas, qa as as$1, qc as succeed$2, qd as equals, qi as makeUnsafe$6, ql as ensure, qn as fromInput$1, qo as never, qr as concat, qt as URLFromString, qu as Reference, r as Extraction, rc as match$2, rd as merge$1, rf as compose$1, ri as fromArray, rl as makeUnsafe$2, rn as decodeUnknownOption, ro as catchReason, rr as empty$9, rs as provideContext, rt as SocketOpenError, ru as getSomes, s as NoteId, sa as unbounded, sc as replaceAll, sd as filter$5, sf as constVoid, si as fromPubSub, sn as encodeUnknownEffect$1, so as context$1, sr as toSetCookieHeaders, ss as repeat, su as headNonEmpty, t as RpcContracts, ta as offerUnsafe, tc as isNonEmpty$1, td as make$38, tf as isTagged, ti as flatMap$3, tl as forkUnsafe$1, tn as decodeTo, tr as make$39, ts as promise, tt as SocketError, tu as fromIterable$1, ua as getCurrent, uc as startsWith, ud as flatten, uf as flow, ui as groupedWithin, ul as doneUnsafe, un as isGreaterThanOrEqualTo, uo as die$2, ur as toArrayBuffer, ut as EncodeError, uu as isReadonlyArrayNonEmpty, va as fromInputUnsafe, vd as liftPredicate, vi as mergeAll$1, vl as isExit, vn as makeFilter, vo as fn$1, vr as Literal$2, vs as succeed$1, vt as Boolean$2, vu as reduce, w as String$2, wa as make$35, wc as fail$4, wd as orElseSome, wi as provideService$1, wl as fiberEnterInterruptibleUnsafe, wo as forkScoped, wr as isNever, ws as tapError, wt as Duration, wu as assignProperty$1, xa as zero, xc as combine, xd as match$1, xi as onEnd, xl as succeed$4, xn as optionalKey, xr as Suspend, xs as sync, xt as DateTimeUtc, xu as sort, ya as gibibytes, yc as StackTrace, yd as liftThrowable, yi as mkString, yl as isFailure$1, yn as mutable, yo as fnUntraced, yr as Objects, ys as succeedNone, yu as reverse, z as ResponseDefectEncoded, za as isPrivate, zc as effectContext, zd as setStackTraceLimit, zi as last$2, zl as TaggedError, zn as setAll$1, zo as makeSpanScoped, zr as now, zs as withFiber, zt as Record, zu as match$3 } from "./contracts-Cc_B2S3-.mjs";
|
|
2
|
+
import { $ as ServerClient, $a as all, $c as merge$3, $d as toStringUnknown, $l as dedupe, $n as fromIterable$2, $r as FileSystem, $s as withSpan, $t as TaggedError$1, $u as parts, A as layer$12, Aa as mebibytes, Ac as annotate, Ad as match$1, Ai as mkUint8Array, Al as isSuccess$1, An as optional$1, Ao as forEach, Ar as PropertySignature, As as suspend, At as Class$1, Au as some$2, B as withDefault, Ba as formatIp, Bc as hasInterruptsOnly, Bd as mapInput, Bi as runLast, Bn as withDecodingDefaultKey, Bo as interrupt, Br as resolveDescription, Bs as try_, Bt as Json, Bu as headUnsafe, C as runMain, Ca as interruptAllAs, Cc as trimEnd, Cd as getOrNull, Ci as mapAccum, Cl as makeUnsafe$4, Cn as isMinLength, Co as fail$1, Cr as make$36, Cs as runSync, Ct as InvalidUrlError, Cu as lastNonEmpty, Da as fromInput$2, Dc as Clock, Dd as liftPredicate, Di as mapError$1, Dl as interrupt$1, Dn as make$37, Do as flatMapEager, Dr as FilterGroup, Ds as serviceOption, Dt as ArraySchema, Du as prepend$2, E as layer$13, Ea as badArgument, Ed as isSome, Ei as mapEffect, El as failCause$1, En as isSchemaError$1, Eo as flatMap, Er as Filter, Es as service, Et as Any, Eu as of, F as URL$4, Fa as makeRecordUnsafe, Fc as filterInterruptors, Fd as toArray$1, Fi as run$3, Fl as fiberEnterUninterruptibleUnsafe, Fn as toEncoded$1, Fo as fromOption, Fr as isOptional, Fs as timeout, Ft as Error$2, Fu as has$3, G as json$1, Ga as ipv4ToOctets, Gc as squash, Gi as tap, Gl as make$41, Gn as CurrentRedactedNames$1, Gr as transform$1, Gs as useSpan, Gt as NonEmptyArray, Gu as isFailure, H as withRun, Ha as inetAddressFromIpString, Hc as isNoSuchElementError, Hd as PipeInspectableProto, Hi as succeed$3, Hl as ParentSpan, Hn as omit, Ho as isEffect, Hr as string, Hs as uninterruptibleMask, Ht as Literals, Hu as fail, I as map$7, Ia as nameServerFromInput, Id as Number$1, Ii as runCollect, Il as forkUnsafe, In as toJsonSchemaDocument, Io as fromResult, Ir as mapOrSame, Is as timeoutOption, It as Exit$1, Iu as keys, J as RequestId, Ja as isLoopback, Jc as effect, Jd as setStackTraceLimit, Ji as unwrap$2, Jl as TaggedClass, Jn as redactUrl, Jo as logWarning, Jr as formatIso, Js as whileLoop, Jt as Number$2, Ju as match$3, K as layerJson, Ka as isInetAddressV6, Kc as CurrentMemoMap, Kd as assignProperty, Ki as toReadableStreamEffect, Kl as nativeTracer, Kn as empty$7, Ko as logFatal, Kr as transformOptional, Ks as void_, Kt as Null, Ku as isResult, L as option, La as domainNameFromStringUnsafe, Lc as fromReasons, Ld as String$3, Li as runForEach, Ll as makeSpanUnsafe, Ln as toType, Lo as gen, Lr as null_, Ls as timeoutOrElse, Lu as map$6, M as Port, Ma as Dns, Mc as die$1, Md as orElse$2, Mi as orDie$1, Mn as tag, Mo as forkChild, Mr as Union$1, Ms as tap$1, Mt as DateTimeUtcFromString, Mu as take$1, N as Redacted$1, Na as DnsError, Nd as orElseSome, Ni as pipeThroughChannel, Nl as effectIsExit, Nn as toCodecJson, Nr as decodeTo$1, Ns as tapCause, Nt as Defect, Nu as takeRight, Oa as fromInputUnsafe, Od as liftThrowable, Oi as mergeAll$1, Ol as isExit, On as makeFilter, Oo as fn$1, Or as Literal$2, Os as succeed$1, Ot as Boolean$2, Ou as reduce, P as String$2, Pa as make$35, Pc as fail$4, Pd as some$1, Pi as provideService$1, Pl as fiberEnterInterruptibleUnsafe, Po as forkScoped, Pr as isNever, Ps as tapError, Pt as Duration, Pu as assignProperty$1, Q as constPong, Qa as acquireRelease, Qc as launch, Qd as toJson, Qi as map$5, Ql as contains$2, Qn as has$4, Qo as mapError, Qr as Path, Qs as withParentSpan, Qt as Struct, Qu as millis, R as succeed$5, Ra as NetAddressError, Rc as hasDies, Rd as combine$1, Ri as runForEachArray, Rl as onExitUnsafe, Rn as withConstructorDefault, Ro as ignore$1, Rr as optionalKey$1, Rs as transposeOption, Rt as Finite, Ru as toEntries, S as make$42, Sa as interruptAll, Sc as trim, Sd as getOrElse, Sf as pipeArguments, Si as map$2, Sl as isDeferred, Sn as isMaxLength, So as exit, Sr as fromWritable, Ss as runForkWith, Su as last$1, Ta as runIn, Tc as parse$10, Td as isNone, Ti as mapArrayEffect, Tl as fail$3, Tn as isSchema, To as filterOrFail, Tr as Arrays, Ts as scoped, Tt as TransportError, Ua as ipFromString, Uc as makeDieReason, Ud as contA, Ui as suspend$1, Ul as Tracer, Un as getReferenceKey, Uo as log, Ur as toEncoded, Us as updateContext, Ut as MutableJson, Uu as failVoid, Va as formatUrlUnsafe, Vd as Prototype, Vi as scan, Vl as DisablePropagation, Vn as isSchemaError, Vo as interruptible, Vr as resolveIdentifier, Vs as uninterruptible, Vt as Literal$1, Vu as make$40, W as RpcSerialization, Wa as ipFromStringUnsafe, Wc as prettyErrors, Wd as contE, Wi as takeUntil, Wl as externalSpan, Wn as encodeUnknownEffect, Wo as logDebug, Wr as passthrough, Ws as updateService, Wt as Never, Wu as fromOption$1, X as constEof, Xa as isUnicast, Xc as effectDiscard, Xd as Class, Xn as unwrap$1, Xo as map$1, Xr as toEpochMillis, Xs as withFiberSucceed, Xt as Redacted, Xu as try_$1, Y as ResponseDefectEncoded, Ya as isPrivate, Yc as effectContext, Yd as BaseProto, Yi as last$2, Yl as TaggedError, Yn as setAll$1, Yo as makeSpanScoped, Yr as now, Ys as withFiber, Yt as Record, Yu as succeed, Za as unixPathAddress, Zc as empty$13, Zd as NodeInspectSymbol, Zi as fromTransform, Zl as appendAll, Zn as fromIterable$3, Zo as mapEager, Zr as defaultFormatter, Zs as withLogSpan, Zt as String$1, Zu as format$2, _ as Organization, _a as unbounded, _c as replaceAll, _d as flatMap$2, _f as constant, _i as fromPubSub, _n as encodeUnknownEffect$1, _o as context$1, _r as toSetCookieHeaders, _s as repeat, _u as headNonEmpty, a as FxConversation, aa as collect, af as isIterable, ai as die$3, al as unwrap$3, an as Uint8ArrayFromBase64, ao as asVoid, ar as isRedactedName, as as onExit, at as spanAttributes, au as filter$4, ba as getCurrent, bc as startsWith, bd as fromNullishOr, bf as identity, bi as groupedWithin, bl as doneUnsafe, bn as isGreaterThanOrEqualTo, bo as die$2, br as toArrayBuffer, bt as EncodeError, bu as isReadonlyArrayNonEmpty, c as GitHubIssue, ca as make$34, cc as endsWith, cd as getOrUndefinedUnsafe, cf as isNotUndefined, ci as fail$2, cl as addFinalizerExit, cn as Unknown, co as catchCause, cr as set$1, cs as option$1, ct as makeCollectorUnsafe, cu as findFirstIndex, d as ImageType, da as offerUnsafe, dc as isNonEmpty$1, dd as makeUnsafe$3, df as isUndefined, di as flatMap$3, dl as forkUnsafe$1, dn as decodeTo, dr as make$39, ds as promise, dt as SocketError, du as fromIterable$1, ec as zipWith, ed as seconds, ef as format$1, ei as catchReason$1, el as mergeAll, eo as andThen, er as get$7, es as matchCauseEffect, et as exitSchema, eu as dedupeAdjacentWith, f as Note, fa as shutdown, fc as length, fd as merge$1, ff as compose$1, fi as flattenIterable, fl as make$33, fn as decodeUnknownEffect, fo as catchIf, fr as value$2, fs as provide$2, fu as get$6, g as OEmbed, ga as publishUnsafe, gc as replace$1, gd as filter$5, gf as constVoid, gi as fromIterable, gl as CurrentLogSpans, gn as encodeTo, go as catch_, gr as parseHeader, gs as raceFirst, gu as head, h as NotesError, ha as takeAll, hc as repeat$1, hd as exists, hf as constUndefined, hi as fromEffect, hl as CurrentLogAnnotations, hn as encodeSync, ho as catchTags, hr as isEmpty$1, hs as provideServiceEffect, ht as fromWebSocket, hu as groupBy, i as FileType, ic as catchDone, id as add$1, if as hasProperty, ii as decodeText, il as succeedContext, in as Uint8Array$2, io as asSome, ir as fromRecordUnsafe, is as onError, it as isStreamSchema, iu as every, ja as zero, jc as combine, jd as none, ji as onEnd, jl as succeed$4, jn as optionalKey, jr as Suspend, js as sync, jt as DateTimeUtc, ju as sort, ka as gibibytes, kc as StackTrace, kd as map$4, ki as mkString, kl as isFailure$1, kn as mutable, ko as fnUntraced, kr as Objects, ks as succeedNone, ku as reverse, l as GitHubReadme, la as offer, lc as includes, ld as getUnsafe, lf as isObject, li as failCause$3, ll as close, ln as decodeEffect, lr as setAll, ls as orDie, lt as CloseEvent, m as NoteJson, ma as take, mc as padStart, md as contains$1, mf as constTrue, ml as provide$1, mn as encodeEffect, mo as catchTag, mr as fromSetCookie, ms as provideService, mu as getUnsafe$1, n as Capture, na as make$32, nd as Reference, nf as equals, ni as catch_$1, nl as provideMerge, nn as URL$3, no as annotateLogs, nr as empty$8, ns as matchEffect, nt as ClientAbort$1, nu as empty$11, o as FxStatus, oa as end$1, oc as Random$2, od as get$5, of as isNotNull, oi as empty$10, ol as Scope, on as UndefinedOr, oo as cached, or as merge$2, os as onExitPrimitive, ot as spanName, ou as filterMap, p as NoteId, pc as match$2, pd as all$1, pf as constFalse, pi as fromArray, pl as makeUnsafe$2, pn as decodeUnknownOption, po as catchReason, pr as empty$9, ps as provideContext, pt as SocketOpenError, pu as getSomes, q as layerSchemaBinary, qa as isLinkLocal, qc as buildWithMemoMap, qd as getStackTraceLimit, ql as Error$1, qn as fromInput, qo as logInfo, qr as encode, qs as when$2, qt as NullOr, qu as isSuccess, r as Extraction, ra as makeUnsafe$6, rd as Service, rf as hash, ri as concat, rl as succeed$2, rn as URLFromString, ro as as$1, rr as fromInput$1, rs as never, rt as getStreamSchemas, ru as ensure, s as GitHubComment, sa as failCause$2, sc as camelToSnake, sd as getOrUndefined$1, sf as isNotNullish, si as ensuring, sl as addFinalizer, sn as Union, so as callback, sr as remove$3, ss as onInterrupt, st as Collector, su as findFirst, t as RpcContracts, ta as pipeTo, td as toMillis, tf as redact, ti as catchTags$1, tl as provide, tn as Tuple, to as annotateCurrentSpan, tr as CurrentRedactedNames, ts as matchCauseEffectEager, tt as isWrapper, tu as drop, u as GitHubRepo, ua as offerAll, uc as isEmpty$2, ud as make$38, uf as isTagged, ui as filter$6, ul as closeUnsafe, un as decodeSync, uo as catchDefect, ur as isRedacted, us as orElseSucceed, uu as flatMap$1, v as Reader, va as makeUnsafe$5, vc as slice$2, vd as flatMapNullishOr, vf as dual, vi as fromQueue, vl as TracerTimingEnabled, vn as fromJsonString, vo as contextWith, vr as fromReadable, vs as result$1, vt as DecodeError, vu as isArrayNonEmpty, wa as interruptAs, wc as max$1, wd as getOrUndefined, wi as mapArray, wl as die, wn as isPattern, wo as failCause, wr as ChildProcessSpawner, ws as scope, wt as StatusCodeError, wu as map$3, x as layer$14, xa as interrupt$2, xc as toLowerCase, xd as fromUndefinedOr, xf as pipe, xi as limitBytes, xl as into, xn as isInt, xo as ensuring$1, xr as toUint8Array$1, xs as runFork, xt as HttpClientError, xu as join$1, y as TikTokPage, ya as await_, yc as split, yd as flatten, yf as flow, yi as fromReadableStream, yl as _await, yn as is$4, yr as pipeThroughDuplex, ys as retry, yt as EmptyBodyError, yu as isReadonlyArrayEmpty, z as unwrap$4, za as formatInet, zc as hasInterrupts, zd as flip, zl as reportCauseUnsafe, zn as withDecodingDefault, zr as replaceChecks, zs as tryPromise, zt as Int, zu as empty$12 } from "./contracts-B0mJTvsC.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { Duplex, Readable, pipeline } from "node:stream";
|
|
5
5
|
import * as Http from "node:http";
|
|
@@ -44065,6 +44065,7 @@ function captionTranscript(input) {
|
|
|
44065
44065
|
onSome: (previous) => input.authored || previous.text !== cue.text || previous.end < cue.start
|
|
44066
44066
|
}))), (cue) => `[${clock(cue.start)}] ${cue.text}\n`), "");
|
|
44067
44067
|
}
|
|
44068
|
+
const spoken = replace$1(/^\[[^\]]+\] /u, "");
|
|
44068
44069
|
function speechOnly(transcript) {
|
|
44069
44070
|
const lines = pipe(split(transcript, "\n"), filter$4(isNonEmpty$1), dedupeAdjacentWith((left, right) => spoken(left) === spoken(right)), filter$4((line) => {
|
|
44070
44071
|
const words = wordsOf(spoken(line));
|
|
@@ -44075,7 +44076,6 @@ function speechOnly(transcript) {
|
|
|
44075
44076
|
if (words.length < 8 || words.length * 60 < 40 * max$1(seconds, 15)) return none();
|
|
44076
44077
|
return some$1(join$1(map$3(lines, (line) => `${line}\n`), ""));
|
|
44077
44078
|
}
|
|
44078
|
-
const spoken = replace$1(/^\[[^\]]+\] /u, "");
|
|
44079
44079
|
function wordsOf(text) {
|
|
44080
44080
|
return pipe(text, toLowerCase, split(/[^\p{L}\p{N}']+/u), filter$4(isNonEmpty$1));
|
|
44081
44081
|
}
|
|
@@ -44085,8 +44085,6 @@ var MediaError = class extends TaggedError$1()("MediaError", {
|
|
|
44085
44085
|
cause: optional$1(Defect()),
|
|
44086
44086
|
message: String$1
|
|
44087
44087
|
}) {};
|
|
44088
|
-
//#endregion
|
|
44089
|
-
//#region src/services/media/service.ts
|
|
44090
44088
|
const Metadata = Struct({
|
|
44091
44089
|
_type: optionalKey(String$1),
|
|
44092
44090
|
automatic_captions: optionalKey(NullOr(Record(String$1, Unknown))),
|
|
@@ -44106,8 +44104,10 @@ const Transcription = Struct({ chunks: ArraySchema(Struct({
|
|
|
44106
44104
|
text: String$1,
|
|
44107
44105
|
timestamp: Tuple([Finite, NullOr(Finite)])
|
|
44108
44106
|
})) });
|
|
44109
|
-
|
|
44110
|
-
|
|
44107
|
+
//#endregion
|
|
44108
|
+
//#region src/services/media/service.ts
|
|
44109
|
+
const MAX_WHISPER_SECONDS = 7200;
|
|
44110
|
+
const BLOCKED_ANSWER = /not a bot|requir(?:es|ing) login|login required|CONNECT tunnel failed|ProxyError|HTTP Error (?:403|429|5\d\d)|Requested format is not available|timed out/iu;
|
|
44111
44111
|
const run = fnUntraced(function* (command, args) {
|
|
44112
44112
|
const handle = yield* make$36(command, args, {
|
|
44113
44113
|
stderr: "pipe",
|
|
@@ -44135,7 +44135,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
44135
44135
|
];
|
|
44136
44136
|
const exit = yield* sourceProxy;
|
|
44137
44137
|
const fetch = fnUntraced(function* (args) {
|
|
44138
|
-
|
|
44138
|
+
return yield* repeat(gen(function* () {
|
|
44139
44139
|
const session = `${yield* nextIntBetween(1e7, 99999999)}`;
|
|
44140
44140
|
return yield* run("yt-dlp", match$1(exit, {
|
|
44141
44141
|
onNone: () => args,
|
|
@@ -44145,13 +44145,12 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
44145
44145
|
...args
|
|
44146
44146
|
]
|
|
44147
44147
|
}));
|
|
44148
|
-
})
|
|
44149
|
-
return yield* repeat(attempt, {
|
|
44148
|
+
}), {
|
|
44150
44149
|
times: match(isSome(exit), {
|
|
44151
44150
|
onFalse: () => 0,
|
|
44152
44151
|
onTrue: () => 2
|
|
44153
44152
|
}),
|
|
44154
|
-
while: (result) => result.exitCode !== 0 && isSome(match$2(
|
|
44153
|
+
while: (result) => result.exitCode !== 0 && isSome(match$2(BLOCKED_ANSWER)(result.stderr))
|
|
44155
44154
|
});
|
|
44156
44155
|
});
|
|
44157
44156
|
function withProcesses(effect) {
|
|
@@ -44160,52 +44159,6 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
44160
44159
|
message: "Cannot extract the media"
|
|
44161
44160
|
})))));
|
|
44162
44161
|
}
|
|
44163
|
-
const transcribe = fnUntraced(function* (link, media) {
|
|
44164
|
-
const work = yield* fs.makeTempDirectoryScoped({ prefix: "deslop-media-" });
|
|
44165
|
-
const language = pipe(fromNullishOr(media.automatic_captions), flatMap$2((captions) => findFirst(keys(captions), endsWith("-orig"))), map$4(replace$1(/-orig$/u, "")), orElse$2(() => fromNullishOr(media.language)), getOrElse(() => "en"));
|
|
44166
|
-
yield* fetch([
|
|
44167
|
-
...ytDlpArgs,
|
|
44168
|
-
"--skip-download",
|
|
44169
|
-
"--write-subs",
|
|
44170
|
-
"--write-auto-subs",
|
|
44171
|
-
"--sub-langs",
|
|
44172
|
-
language,
|
|
44173
|
-
"--sub-format",
|
|
44174
|
-
"vtt",
|
|
44175
|
-
"--convert-subs",
|
|
44176
|
-
"vtt",
|
|
44177
|
-
"-o",
|
|
44178
|
-
path.join(work, "captions"),
|
|
44179
|
-
link
|
|
44180
|
-
]);
|
|
44181
|
-
const captions = `captions.${language}.vtt`;
|
|
44182
|
-
if (contains$1(yield* fs.readDirectory(work), captions)) return some$1(captionTranscript({
|
|
44183
|
-
authored: exists(fromNullishOr(media.subtitles), (subtitles) => has$3(subtitles, language)),
|
|
44184
|
-
vtt: yield* fs.readFileString(path.join(work, captions))
|
|
44185
|
-
}));
|
|
44186
|
-
if (!exists(fromNullishOr(media.duration), (seconds) => seconds <= maxWhisperSeconds)) {
|
|
44187
|
-
yield* logInfo("No captions, and the audio is too long or of unknown length for Whisper");
|
|
44188
|
-
return none();
|
|
44189
|
-
}
|
|
44190
|
-
const download = yield* fetch([
|
|
44191
|
-
...ytDlpArgs,
|
|
44192
|
-
"-f",
|
|
44193
|
-
"bestaudio/best",
|
|
44194
|
-
"-o",
|
|
44195
|
-
path.join(work, "audio.%(ext)s"),
|
|
44196
|
-
link
|
|
44197
|
-
]);
|
|
44198
|
-
if (download.exitCode !== 0) return yield* MediaError.make({ message: `yt-dlp cannot download the audio: ${download.stderr}` });
|
|
44199
|
-
const audio = path.join(work, yield* pipe(findFirst(yield* fs.readDirectory(work), startsWith("audio.")), fromOption, mapError((cause) => MediaError.make({
|
|
44200
|
-
cause,
|
|
44201
|
-
message: "yt-dlp downloaded no audio"
|
|
44202
|
-
}))));
|
|
44203
|
-
return yield* listen({
|
|
44204
|
-
file: audio,
|
|
44205
|
-
language: some$1(language),
|
|
44206
|
-
seconds: fromNullishOr(media.duration)
|
|
44207
|
-
});
|
|
44208
|
-
});
|
|
44209
44162
|
const listen = fnUntraced(function* (input) {
|
|
44210
44163
|
const pcm = yield* run("ffmpeg", [
|
|
44211
44164
|
"-v",
|
|
@@ -44226,14 +44179,14 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
44226
44179
|
]);
|
|
44227
44180
|
if (pcm.exitCode !== 0) return yield* MediaError.make({ message: `ffmpeg cannot decode the audio: ${pcm.stderr}` });
|
|
44228
44181
|
const samples = Float32Array.from(new Int16Array(pcm.stdout.buffer, pcm.stdout.byteOffset, pcm.stdout.byteLength / 2), (sample) => sample / 32768);
|
|
44229
|
-
if (samples.length / 16e3 >
|
|
44182
|
+
if (samples.length / 16e3 > MAX_WHISPER_SECONDS) {
|
|
44230
44183
|
yield* logInfo(`${clock(samples.length / 16e3)} of audio is too long for Whisper`);
|
|
44231
44184
|
return none();
|
|
44232
44185
|
}
|
|
44233
44186
|
if (samples.length < 16e3) return none();
|
|
44234
44187
|
env.cacheDir = path.join(cache, "models");
|
|
44235
44188
|
const spoken = map$4(input.language, (language) => pipe(language, split("-"), headNonEmpty));
|
|
44236
|
-
const english = contains$
|
|
44189
|
+
const english = contains$1(spoken, "en");
|
|
44237
44190
|
const model = match(english, {
|
|
44238
44191
|
onFalse: () => "onnx-community/whisper-small",
|
|
44239
44192
|
onTrue: () => "onnx-community/whisper-small.en"
|
|
@@ -44256,6 +44209,52 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
44256
44209
|
})));
|
|
44257
44210
|
return speechOnly(join$1(map$3(transcription.chunks, (chunk) => `[${clock(chunk.timestamp[0])}] ${trim(chunk.text)}\n`), ""));
|
|
44258
44211
|
});
|
|
44212
|
+
const transcribe = fnUntraced(function* (link, media) {
|
|
44213
|
+
const work = yield* fs.makeTempDirectoryScoped({ prefix: "deslop-media-" });
|
|
44214
|
+
const language = pipe(fromNullishOr(media.automatic_captions), flatMap$2((captions) => findFirst(keys(captions), endsWith("-orig"))), map$4(replace$1(/-orig$/u, "")), orElse$2(() => fromNullishOr(media.language)), getOrElse(() => "en"));
|
|
44215
|
+
yield* fetch([
|
|
44216
|
+
...ytDlpArgs,
|
|
44217
|
+
"--skip-download",
|
|
44218
|
+
"--write-subs",
|
|
44219
|
+
"--write-auto-subs",
|
|
44220
|
+
"--sub-langs",
|
|
44221
|
+
language,
|
|
44222
|
+
"--sub-format",
|
|
44223
|
+
"vtt",
|
|
44224
|
+
"--convert-subs",
|
|
44225
|
+
"vtt",
|
|
44226
|
+
"-o",
|
|
44227
|
+
path.join(work, "captions"),
|
|
44228
|
+
link
|
|
44229
|
+
]);
|
|
44230
|
+
const captions = `captions.${language}.vtt`;
|
|
44231
|
+
if (contains$2(yield* fs.readDirectory(work), captions)) return some$1(captionTranscript({
|
|
44232
|
+
authored: exists(fromNullishOr(media.subtitles), (subtitles) => has$3(subtitles, language)),
|
|
44233
|
+
vtt: yield* fs.readFileString(path.join(work, captions))
|
|
44234
|
+
}));
|
|
44235
|
+
if (!exists(fromNullishOr(media.duration), (seconds) => seconds <= MAX_WHISPER_SECONDS)) {
|
|
44236
|
+
yield* logInfo("No captions, and the audio is too long or of unknown length for Whisper");
|
|
44237
|
+
return none();
|
|
44238
|
+
}
|
|
44239
|
+
const download = yield* fetch([
|
|
44240
|
+
...ytDlpArgs,
|
|
44241
|
+
"-f",
|
|
44242
|
+
"bestaudio/best",
|
|
44243
|
+
"-o",
|
|
44244
|
+
path.join(work, "audio.%(ext)s"),
|
|
44245
|
+
link
|
|
44246
|
+
]);
|
|
44247
|
+
if (download.exitCode !== 0) return yield* MediaError.make({ message: `yt-dlp cannot download the audio: ${download.stderr}` });
|
|
44248
|
+
const audio = path.join(work, yield* pipe(findFirst(yield* fs.readDirectory(work), startsWith("audio.")), fromOption, mapError((cause) => MediaError.make({
|
|
44249
|
+
cause,
|
|
44250
|
+
message: "yt-dlp downloaded no audio"
|
|
44251
|
+
}))));
|
|
44252
|
+
return yield* listen({
|
|
44253
|
+
file: audio,
|
|
44254
|
+
language: some$1(language),
|
|
44255
|
+
seconds: fromNullishOr(media.duration)
|
|
44256
|
+
});
|
|
44257
|
+
});
|
|
44259
44258
|
const sample = fnUntraced(function* (video, work) {
|
|
44260
44259
|
const probe = yield* run("ffprobe", [
|
|
44261
44260
|
"-v",
|
|
@@ -44281,7 +44280,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
44281
44280
|
path.join(work, "frame-%02d.jpg")
|
|
44282
44281
|
]);
|
|
44283
44282
|
if (sampled.exitCode !== 0) return yield* MediaError.make({ message: `ffmpeg cannot sample the video: ${sampled.stderr}` });
|
|
44284
|
-
return yield* forEach(sort(filter$4(yield* fs.readDirectory(work), startsWith("frame-")), String$3), (file) => fs.readFile(path.join(work, file)));
|
|
44283
|
+
return yield* forEach(sort(filter$4(yield* fs.readDirectory(work), startsWith("frame-")), String$3), (file) => fs.readFile(path.join(work, file)), { concurrency: "unbounded" });
|
|
44285
44284
|
});
|
|
44286
44285
|
return Media.of({
|
|
44287
44286
|
fileFrames: fn$1("Media.fileFrames")(function* (file) {
|
|
@@ -44324,11 +44323,11 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
44324
44323
|
if (dump.exitCode !== 0) return yield* MediaError.make({ message: `yt-dlp cannot read the video: ${replace$1(/https?:\/\/\S+/gu, "<link>")(dump.stderr)}` });
|
|
44325
44324
|
const media = yield* decodeEffect(fromJsonString(Metadata))(new TextDecoder().decode(dump.stdout));
|
|
44326
44325
|
if (media._type === "playlist") return yield* MediaError.make({ message: "The link holds several videos." });
|
|
44327
|
-
const details =
|
|
44328
|
-
media.uploader
|
|
44329
|
-
|
|
44330
|
-
|
|
44331
|
-
], isNonEmpty$1);
|
|
44326
|
+
const details = pipe([
|
|
44327
|
+
fromNullishOr(media.uploader),
|
|
44328
|
+
map$4(fromNullishOr(media.upload_date), replace$1(/^(\d{4})(\d{2})(\d{2})$/u, "$1-$2-$3")),
|
|
44329
|
+
map$4(fromNullishOr(media.duration), clock)
|
|
44330
|
+
], getSomes, filter$4(isNonEmpty$1));
|
|
44332
44331
|
return {
|
|
44333
44332
|
info: join$1(getSomes([
|
|
44334
44333
|
some$1(`# ${media.title}\n\n${join$1(details, ", ")}\n${link}`),
|
|
@@ -90831,8 +90830,8 @@ require_undici();
|
|
|
90831
90830
|
require_mime_type();
|
|
90832
90831
|
//#endregion
|
|
90833
90832
|
//#region src/services/notes/lib/utils.ts
|
|
90834
|
-
const
|
|
90835
|
-
const
|
|
90833
|
+
const URL_PATTERN = /https?:\/\/[^\s<>"]+/iu;
|
|
90834
|
+
const X_HOSTS = [
|
|
90836
90835
|
"twitter.com",
|
|
90837
90836
|
"www.twitter.com",
|
|
90838
90837
|
"mobile.twitter.com",
|
|
@@ -90840,9 +90839,7 @@ const xHosts = [
|
|
|
90840
90839
|
"www.x.com",
|
|
90841
90840
|
"mobile.x.com"
|
|
90842
90841
|
];
|
|
90843
|
-
const
|
|
90844
|
-
const instagramHosts = /(?:^|\.)instagram\.com$/u;
|
|
90845
|
-
const trackingParameters = [
|
|
90842
|
+
const TRACKING_PARAMETERS = [
|
|
90846
90843
|
"fbclid",
|
|
90847
90844
|
"gclid",
|
|
90848
90845
|
"igsh",
|
|
@@ -90864,31 +90861,31 @@ function withoutTrailingPunctuation(link) {
|
|
|
90864
90861
|
}
|
|
90865
90862
|
function canonicalUrl(link) {
|
|
90866
90863
|
const url = new URL(link);
|
|
90867
|
-
if (contains$
|
|
90868
|
-
if (sourceFor(url.href) === "Website") for (const key of
|
|
90864
|
+
if (contains$2(X_HOSTS, url.hostname)) url.hostname = "x.com";
|
|
90865
|
+
if (sourceFor(url.href) === "Website") for (const key of TRACKING_PARAMETERS) url.searchParams.delete(key);
|
|
90869
90866
|
else url.search = "";
|
|
90870
90867
|
url.hash = "";
|
|
90871
90868
|
return url.href;
|
|
90872
90869
|
}
|
|
90873
90870
|
function captureUrl(text) {
|
|
90874
|
-
return pipe(match$2(
|
|
90871
|
+
return pipe(match$2(URL_PATTERN)(text), flatMap$2(head), map$4(withoutTrailingPunctuation), flatMap$2(liftThrowable(canonicalUrl)), getOrUndefined);
|
|
90875
90872
|
}
|
|
90876
90873
|
function sourceFor(url) {
|
|
90877
90874
|
const host = new URL(url).hostname;
|
|
90878
|
-
if (contains$
|
|
90875
|
+
if (contains$2(X_HOSTS, host) || host === "t.co") return "X";
|
|
90879
90876
|
if (host === "tiktok.com" || endsWith(".tiktok.com")(host)) return "TikTok";
|
|
90880
90877
|
return "Website";
|
|
90881
90878
|
}
|
|
90882
90879
|
function isYouTube(url) {
|
|
90883
|
-
return
|
|
90880
|
+
return isSome(match$2(/(?:^|\.)(?:youtube\.com|youtu\.be)$/u)(new URL(url).hostname));
|
|
90884
90881
|
}
|
|
90885
90882
|
function hasVideo(url) {
|
|
90886
90883
|
const link = new URL(url);
|
|
90887
90884
|
if (sourceFor(url) === "TikTok") return !includes("/photo/")(link.pathname);
|
|
90888
|
-
return sourceFor(url) === "X" || isYouTube(url) ||
|
|
90885
|
+
return sourceFor(url) === "X" || isYouTube(url) || isSome(match$2(/(?:^|\.)instagram\.com$/u)(link.hostname));
|
|
90889
90886
|
}
|
|
90890
90887
|
function commentFor(text) {
|
|
90891
|
-
return pipe(text, replace$1(new RegExp(
|
|
90888
|
+
return pipe(text, replace$1(new RegExp(URL_PATTERN.source, "giu"), ""), plainText);
|
|
90892
90889
|
}
|
|
90893
90890
|
function plainText(text) {
|
|
90894
90891
|
return pipe(text, replace$1(/\s+/gu, " "), trim);
|
|
@@ -90916,29 +90913,41 @@ function findNotes(notes, query) {
|
|
|
90916
90913
|
const terms = filter$4(words, (word) => !startsWith("#")(word));
|
|
90917
90914
|
if (isReadonlyArrayEmpty(words)) return notes;
|
|
90918
90915
|
return filter$4(notes, (note) => {
|
|
90919
|
-
if (!every(tags, (tag) => contains$
|
|
90916
|
+
if (!every(tags, (tag) => contains$2(note.tags, tag))) return false;
|
|
90920
90917
|
const haystack = pipe([
|
|
90921
90918
|
note.title,
|
|
90922
90919
|
note.summary,
|
|
90923
90920
|
note.author,
|
|
90924
90921
|
note.text,
|
|
90925
90922
|
note.content,
|
|
90926
|
-
note.topics
|
|
90927
|
-
note.body
|
|
90928
|
-
note.screenText
|
|
90929
|
-
note.transcript
|
|
90930
|
-
note.url
|
|
90923
|
+
note.topics,
|
|
90924
|
+
note.body,
|
|
90925
|
+
note.screenText,
|
|
90926
|
+
note.transcript,
|
|
90927
|
+
note.url,
|
|
90931
90928
|
...note.tags
|
|
90932
|
-
], join$1(" "), toLowerCase);
|
|
90929
|
+
], filter$4(isNotUndefined), join$1(" "), toLowerCase);
|
|
90933
90930
|
return every(terms, (term) => includes(term)(haystack));
|
|
90934
90931
|
});
|
|
90935
90932
|
}
|
|
90936
90933
|
//#endregion
|
|
90937
90934
|
//#region src/services/notes/lib/extraction.ts
|
|
90938
|
-
const
|
|
90939
|
-
|
|
90940
|
-
|
|
90941
|
-
"
|
|
90935
|
+
const CHALLENGE = /Just a moment\.\.\.|Verify you are human|Attention Required! \| Cloudflare|Enable JavaScript and cookies to continue|Performing security verification/u;
|
|
90936
|
+
const UNREACHABLE = "The link could not be loaded.";
|
|
90937
|
+
const BLOCK_TAGS = [
|
|
90938
|
+
"article",
|
|
90939
|
+
"aside",
|
|
90940
|
+
"blockquote",
|
|
90941
|
+
"dd",
|
|
90942
|
+
"details",
|
|
90943
|
+
"div",
|
|
90944
|
+
"dl",
|
|
90945
|
+
"dt",
|
|
90946
|
+
"figure",
|
|
90947
|
+
"main",
|
|
90948
|
+
"p",
|
|
90949
|
+
"section",
|
|
90950
|
+
"table"
|
|
90942
90951
|
];
|
|
90943
90952
|
const Exit = Reference("@deslop/stash/services/notes/lib/extraction/Exit", { defaultValue: none });
|
|
90944
90953
|
function timeLimit(duration, message) {
|
|
@@ -90947,87 +90956,6 @@ function timeLimit(duration, message) {
|
|
|
90947
90956
|
orElse: () => fail$1(NotesError.make({ message }))
|
|
90948
90957
|
});
|
|
90949
90958
|
}
|
|
90950
|
-
const FxPost = Struct({
|
|
90951
|
-
author: Struct({
|
|
90952
|
-
id: String$1,
|
|
90953
|
-
name: String$1,
|
|
90954
|
-
screen_name: String$1
|
|
90955
|
-
}),
|
|
90956
|
-
created_timestamp: Finite,
|
|
90957
|
-
id: String$1,
|
|
90958
|
-
media: optionalKey(Struct({ all: optionalKey(ArraySchema(Struct({
|
|
90959
|
-
thumbnail_url: optionalKey(String$1),
|
|
90960
|
-
type: String$1,
|
|
90961
|
-
url: String$1
|
|
90962
|
-
}))) })),
|
|
90963
|
-
raw_text: optionalKey(Struct({ facets: ArraySchema(Struct({ replacement: optionalKey(String$1) })) })),
|
|
90964
|
-
text: String$1
|
|
90965
|
-
});
|
|
90966
|
-
const FxArticle = Struct({
|
|
90967
|
-
content: Struct({
|
|
90968
|
-
blocks: ArraySchema(Struct({
|
|
90969
|
-
entityRanges: ArraySchema(Struct({ key: Finite })),
|
|
90970
|
-
text: String$1,
|
|
90971
|
-
type: String$1
|
|
90972
|
-
})),
|
|
90973
|
-
entityMap: ArraySchema(Struct({
|
|
90974
|
-
key: String$1,
|
|
90975
|
-
value: Struct({
|
|
90976
|
-
data: Struct({
|
|
90977
|
-
markdown: optionalKey(String$1),
|
|
90978
|
-
url: optionalKey(String$1)
|
|
90979
|
-
}),
|
|
90980
|
-
type: String$1
|
|
90981
|
-
})
|
|
90982
|
-
}))
|
|
90983
|
-
}),
|
|
90984
|
-
title: String$1
|
|
90985
|
-
});
|
|
90986
|
-
const FxStatus = Struct({ status: Struct({
|
|
90987
|
-
...FxPost.fields,
|
|
90988
|
-
article: optionalKey(FxArticle),
|
|
90989
|
-
quote: optionalKey(FxPost)
|
|
90990
|
-
}) });
|
|
90991
|
-
const FxConversation = Struct({
|
|
90992
|
-
...FxStatus.fields,
|
|
90993
|
-
replies: optionalKey(ArraySchema(FxPost)),
|
|
90994
|
-
thread: optionalKey(ArraySchema(FxPost))
|
|
90995
|
-
});
|
|
90996
|
-
const OEmbed = Struct({
|
|
90997
|
-
author_name: optionalKey(String$1),
|
|
90998
|
-
html: optionalKey(String$1),
|
|
90999
|
-
thumbnail_url: optionalKey(String$1),
|
|
91000
|
-
title: optionalKey(String$1)
|
|
91001
|
-
});
|
|
91002
|
-
const TikTokPage = Struct({ __DEFAULT_SCOPE__: Struct({ "webapp.video-detail": Struct({ itemInfo: Struct({ itemStruct: Struct({
|
|
91003
|
-
author: Struct({ nickname: String$1 }),
|
|
91004
|
-
desc: String$1,
|
|
91005
|
-
imagePost: Struct({
|
|
91006
|
-
images: ArraySchema(Struct({ imageURL: Struct({ urlList: ArraySchema(String$1) }) })),
|
|
91007
|
-
title: optionalKey(String$1)
|
|
91008
|
-
})
|
|
91009
|
-
}) }) }) }) });
|
|
91010
|
-
const GitHubRepo = Struct({
|
|
91011
|
-
description: NullOr(String$1),
|
|
91012
|
-
full_name: String$1,
|
|
91013
|
-
homepage: optionalKey(NullOr(String$1)),
|
|
91014
|
-
owner: Struct({ login: String$1 }),
|
|
91015
|
-
topics: optionalKey(ArraySchema(String$1))
|
|
91016
|
-
});
|
|
91017
|
-
const GitHubComment = Struct({
|
|
91018
|
-
body: NullOr(String$1),
|
|
91019
|
-
user: Struct({ login: String$1 })
|
|
91020
|
-
});
|
|
91021
|
-
const GitHubIssue = Struct({
|
|
91022
|
-
...GitHubComment.fields,
|
|
91023
|
-
state: String$1,
|
|
91024
|
-
title: String$1
|
|
91025
|
-
});
|
|
91026
|
-
const Reader = Struct({ data: Struct({
|
|
91027
|
-
content: String$1,
|
|
91028
|
-
title: String$1
|
|
91029
|
-
}) });
|
|
91030
|
-
const challenge = /Just a moment\.\.\.|Verify you are human|Attention Required! \| Cloudflare|Enable JavaScript and cookies to continue|Performing security verification/u;
|
|
91031
90959
|
function isPublic(address) {
|
|
91032
90960
|
const octets = ipv4ToOctets(address);
|
|
91033
90961
|
return isUnicast(address) && !isPrivate(address) && !isLoopback(address) && !isLinkLocal(address) && octets[0] !== 0 && octets[0] < 224 && !(octets[0] === 100 && octets[1] >= 64 && octets[1] < 128) && !(octets[0] === 192 && octets[1] === 0 && (octets[2] === 0 || octets[2] === 2)) && !(octets[0] === 198 && (octets[1] === 18 || octets[1] === 19)) && !(octets[0] === 198 && octets[1] === 51 && octets[2] === 100) && !(octets[0] === 203 && octets[1] === 0 && octets[2] === 113);
|
|
@@ -91062,37 +90990,35 @@ const load = fnUntraced(function* (url, read) {
|
|
|
91062
90990
|
location: response.headers["location"],
|
|
91063
90991
|
status: response.status,
|
|
91064
90992
|
type: response.headers["content-type"] ?? ""
|
|
91065
|
-
}))), scoped, provide$2(pipe(layerNodeHttpNoAgent, provide(
|
|
91066
|
-
onNone: () => ({
|
|
90993
|
+
}))), scoped, provide$2(pipe(layerNodeHttpNoAgent, provide(match$1(proxy, {
|
|
90994
|
+
onNone: () => layerAgentOptions({
|
|
91067
90995
|
autoSelectFamily: false,
|
|
91068
90996
|
lookup: (_hostname, _options, callback) => callback(null, address, 4)
|
|
91069
90997
|
}),
|
|
91070
|
-
onSome: (exit) => ({ proxyEnv: {
|
|
90998
|
+
onSome: (exit) => layerAgentOptions({ proxyEnv: {
|
|
91071
90999
|
HTTP_PROXY: exit,
|
|
91072
91000
|
HTTPS_PROXY: exit,
|
|
91073
91001
|
NODE_ENV: "production"
|
|
91074
91002
|
} })
|
|
91075
|
-
}))))
|
|
91003
|
+
})))), provideService(TracerDisabledWhen$1, () => true), mapError((cause) => pipe(liftPredicate(cause, is$4(NotesError)), getOrElse(() => NotesError.make({
|
|
91076
91004
|
cause,
|
|
91077
|
-
message:
|
|
91005
|
+
message: UNREACHABLE
|
|
91078
91006
|
})))));
|
|
91079
91007
|
});
|
|
91080
|
-
const blockedStatuses = [
|
|
91081
|
-
403,
|
|
91082
|
-
429,
|
|
91083
|
-
500,
|
|
91084
|
-
502,
|
|
91085
|
-
503
|
|
91086
|
-
];
|
|
91087
|
-
const unreachable = "The link could not be loaded.";
|
|
91088
91008
|
const follow = fnUntraced(function* (url, read, hops) {
|
|
91089
91009
|
const proxied = isSome(yield* Exit);
|
|
91090
|
-
const answer = yield* pipe(load(url, read), filterOrFail((found) => !proxied || !contains$
|
|
91010
|
+
const answer = yield* pipe(load(url, read), filterOrFail((found) => !proxied || !contains$2([
|
|
91011
|
+
403,
|
|
91012
|
+
429,
|
|
91013
|
+
500,
|
|
91014
|
+
502,
|
|
91015
|
+
503
|
|
91016
|
+
], found.status), () => NotesError.make({ message: UNREACHABLE })), timeLimit("15 seconds", UNREACHABLE), retry({
|
|
91091
91017
|
times: match(proxied, {
|
|
91092
91018
|
onFalse: () => 0,
|
|
91093
91019
|
onTrue: () => 2
|
|
91094
91020
|
}),
|
|
91095
|
-
while: (error) => error.message ===
|
|
91021
|
+
while: (error) => error.message === UNREACHABLE
|
|
91096
91022
|
}));
|
|
91097
91023
|
if (answer.status >= 300 && answer.status < 400 && answer.location !== void 0) {
|
|
91098
91024
|
if (hops === 5) return yield* NotesError.make({ message: "The link redirects too often." });
|
|
@@ -91114,7 +91040,11 @@ const decode$1 = fnUntraced(function* (schema, url) {
|
|
|
91114
91040
|
})));
|
|
91115
91041
|
});
|
|
91116
91042
|
const resolve = fnUntraced(function* (url, hops) {
|
|
91117
|
-
if (!contains$
|
|
91043
|
+
if (!contains$2([
|
|
91044
|
+
"vm.tiktok.com",
|
|
91045
|
+
"vt.tiktok.com",
|
|
91046
|
+
"t.co"
|
|
91047
|
+
], url.hostname)) return url;
|
|
91118
91048
|
const answer = yield* load(url, () => void_);
|
|
91119
91049
|
if (answer.location === void 0 || hops === 5) return yield* NotesError.make({ message: "The short link leads to no post." });
|
|
91120
91050
|
return yield* resolve(new URL(answer.location, url), hops + 1);
|
|
@@ -91125,7 +91055,7 @@ function canonical(url) {
|
|
|
91125
91055
|
const fromOEmbed = fnUntraced(function* (endpoint, url, title) {
|
|
91126
91056
|
const embed = yield* decode$1(OEmbed, new URL(`${endpoint}${encodeURIComponent(url.href)}`));
|
|
91127
91057
|
return Extraction.make({
|
|
91128
|
-
author: embed.author_name
|
|
91058
|
+
author: fromUndefinedOr(embed.author_name),
|
|
91129
91059
|
image: fromNullishOr(embed.thumbnail_url),
|
|
91130
91060
|
text: plainText(embed.title ?? ""),
|
|
91131
91061
|
title: title(embed),
|
|
@@ -91135,7 +91065,7 @@ const fromOEmbed = fnUntraced(function* (endpoint, url, title) {
|
|
|
91135
91065
|
const xOEmbed = fnUntraced(function* (url) {
|
|
91136
91066
|
const embed = yield* decode$1(OEmbed, new URL(`https://publish.x.com/oembed?omit_script=true&dnt=true&url=${encodeURIComponent(url.href)}`));
|
|
91137
91067
|
return Extraction.make({
|
|
91138
|
-
author: embed.author_name
|
|
91068
|
+
author: fromUndefinedOr(embed.author_name),
|
|
91139
91069
|
image: none(),
|
|
91140
91070
|
text: plainText(load$1(embed.html ?? "")("blockquote p").text()),
|
|
91141
91071
|
title: `${embed.author_name ?? "A post"} on X`,
|
|
@@ -91169,9 +91099,9 @@ const xThread = fnUntraced(function* (url) {
|
|
|
91169
91099
|
const quote = fromNullishOr(status.quote);
|
|
91170
91100
|
const media = flatMap$1([status, ...toArray$1(quote)], (post) => post.media?.all ?? []);
|
|
91171
91101
|
const replies = conversation.replies ?? [];
|
|
91172
|
-
const linked = yield* forEach(pipe(status.raw_text?.facets ?? [], filterMap((facet) => fromOption$1(pipe(fromNullishOr(facet.replacement), flatMap$2(match$2(/(?:x|twitter)\.com\/[^/]+\/status\/(\d+)/u)), flatMap$2((match) => get$6(match, 1))), () => void 0)), filter$4((linkedId) => linkedId !== status.id && !exists(quote, (post) => post.id === linkedId)), dedupe, take$1(5)), (linkedId) => option$1(map$1(decode$1(FxStatus, new URL(`https://api.fxtwitter.com/2/status/${linkedId}`)), (found) => found.status)));
|
|
91102
|
+
const linked = yield* forEach(pipe(status.raw_text?.facets ?? [], filterMap((facet) => fromOption$1(pipe(fromNullishOr(facet.replacement), flatMap$2(match$2(/(?:x|twitter)\.com\/[^/]+\/status\/(\d+)/u)), flatMap$2((match) => get$6(match, 1))), () => void 0)), filter$4((linkedId) => linkedId !== status.id && !exists(quote, (post) => post.id === linkedId)), dedupe, take$1(5)), (linkedId) => option$1(map$1(decode$1(FxStatus, new URL(`https://api.fxtwitter.com/2/status/${linkedId}`)), (found) => found.status)), { concurrency: "unbounded" });
|
|
91173
91103
|
return Extraction.make({
|
|
91174
|
-
author: status.author.name,
|
|
91104
|
+
author: some$1(status.author.name),
|
|
91175
91105
|
image: map$4(head(media), (item) => item.thumbnail_url ?? item.url),
|
|
91176
91106
|
text: pipe([
|
|
91177
91107
|
section("Earlier in the conversation", sort(filter$4(conversation.thread ?? [], (post) => post.id !== status.id), byTime)),
|
|
@@ -91204,10 +91134,10 @@ const tikTokPhotos = fnUntraced(function* (url) {
|
|
|
91204
91134
|
})))).__DEFAULT_SCOPE__["webapp.video-detail"].itemInfo.itemStruct;
|
|
91205
91135
|
const images = filterMap(item.imagePost.images, (image) => fromOption$1(head(image.imageURL.urlList), () => void 0));
|
|
91206
91136
|
return Extraction.make({
|
|
91207
|
-
author: item.author.nickname,
|
|
91137
|
+
author: some$1(item.author.nickname),
|
|
91208
91138
|
image: head(images),
|
|
91209
91139
|
slides: drop(images, 1),
|
|
91210
|
-
text: pipe([item.imagePost.title
|
|
91140
|
+
text: pipe([item.imagePost.title, item.desc], filter$4(isNotUndefined), map$3(plainText), filter$4(isNonEmpty$1), join$1("\n")),
|
|
91211
91141
|
title: `${item.author.nickname} on TikTok`,
|
|
91212
91142
|
url: canonical(url)
|
|
91213
91143
|
});
|
|
@@ -91216,32 +91146,25 @@ const issue = fnUntraced(function* (url, repository, number) {
|
|
|
91216
91146
|
const found = yield* decode$1(GitHubIssue, new URL(`https://api.github.com/repos/${repository}/issues/${number}`));
|
|
91217
91147
|
const comments = yield* decode$1(ArraySchema(GitHubComment), new URL(`https://api.github.com/repos/${repository}/issues/${number}/comments?per_page=100`));
|
|
91218
91148
|
return Extraction.make({
|
|
91219
|
-
author: found.user.login,
|
|
91149
|
+
author: some$1(found.user.login),
|
|
91220
91150
|
image: some$1(`https://opengraph.githubassets.com/1/${repository}/issues/${number}`),
|
|
91221
|
-
text: pipe([
|
|
91222
|
-
`# ${found.title} (${found.state})`,
|
|
91223
|
-
`**${found.user.login}**: ${found.body ?? ""}`,
|
|
91224
|
-
...map$3(comments, (comment) => `**${comment.user.login}**: ${comment.body ?? ""}`)
|
|
91225
|
-
], join$1("\n\n")),
|
|
91151
|
+
text: pipe([found, ...comments], map$3((post) => map$4(fromNullishOr(post.body), (body) => `**${post.user.login}**: ${body}`)), getSomes, prepend$2(`# ${found.title} (${found.state})`), join$1("\n\n")),
|
|
91226
91152
|
title: found.title,
|
|
91227
91153
|
url: canonical(url)
|
|
91228
91154
|
});
|
|
91229
91155
|
});
|
|
91230
91156
|
const repository = fnUntraced(function* (url, name) {
|
|
91231
91157
|
const found = yield* decode$1(GitHubRepo, new URL(`https://api.github.com/repos/${name}`));
|
|
91232
|
-
const readme = yield* pipe(decode$1(
|
|
91158
|
+
const readme = yield* pipe(decode$1(GitHubReadme, new URL(`https://api.github.com/repos/${name}/readme`)), flatMap((file) => follow(new URL(file.download_url), api, 0)), map$1((file) => file.body), option$1);
|
|
91233
91159
|
return Extraction.make({
|
|
91234
|
-
author: found.owner.login,
|
|
91160
|
+
author: some$1(found.owner.login),
|
|
91235
91161
|
image: some$1(`https://opengraph.githubassets.com/1/${name}`),
|
|
91236
91162
|
text: pipe([
|
|
91237
|
-
found.description
|
|
91238
|
-
pipe(fromNullishOr(found.topics), filter$5(isReadonlyArrayNonEmpty),
|
|
91239
|
-
|
|
91240
|
-
onSome: (topics) => `Topics: ${join$1(topics, ", ")}`
|
|
91241
|
-
})),
|
|
91242
|
-
found.homepage ?? "",
|
|
91163
|
+
fromNullishOr(found.description),
|
|
91164
|
+
pipe(fromNullishOr(found.topics), filter$5(isReadonlyArrayNonEmpty), map$4((topics) => `Topics: ${join$1(topics, ", ")}`)),
|
|
91165
|
+
fromNullishOr(found.homepage),
|
|
91243
91166
|
readme
|
|
91244
|
-
], filter$4(isNonEmpty$1), join$1("\n\n")),
|
|
91167
|
+
], getSomes, filter$4(isNonEmpty$1), join$1("\n\n")),
|
|
91245
91168
|
title: found.full_name,
|
|
91246
91169
|
url: canonical(url)
|
|
91247
91170
|
});
|
|
@@ -91255,34 +91178,18 @@ const gitHub = fnUntraced(function* (url) {
|
|
|
91255
91178
|
onSome: (parts) => issue(url, name, parts[1])
|
|
91256
91179
|
}));
|
|
91257
91180
|
});
|
|
91258
|
-
const headings = {
|
|
91259
|
-
h1: 1,
|
|
91260
|
-
h2: 2,
|
|
91261
|
-
h3: 3,
|
|
91262
|
-
h4: 4,
|
|
91263
|
-
h5: 5,
|
|
91264
|
-
h6: 6
|
|
91265
|
-
};
|
|
91266
|
-
const blockTags = [
|
|
91267
|
-
"article",
|
|
91268
|
-
"aside",
|
|
91269
|
-
"blockquote",
|
|
91270
|
-
"dd",
|
|
91271
|
-
"details",
|
|
91272
|
-
"div",
|
|
91273
|
-
"dl",
|
|
91274
|
-
"dt",
|
|
91275
|
-
"figure",
|
|
91276
|
-
"main",
|
|
91277
|
-
"p",
|
|
91278
|
-
"section",
|
|
91279
|
-
"table"
|
|
91280
|
-
];
|
|
91281
91181
|
function markdown($, node, base) {
|
|
91282
91182
|
if (node.nodeType === 3) return replace$1(/\s+/gu, " ")(node.data);
|
|
91283
91183
|
if (!hasProperty(node, "tagName")) return "";
|
|
91284
91184
|
const inner = pipe($(node).contents().toArray(), map$3((child) => markdown($, child, base)), join$1(""));
|
|
91285
|
-
return pipe(
|
|
91185
|
+
return pipe(findFirstIndex([
|
|
91186
|
+
"h1",
|
|
91187
|
+
"h2",
|
|
91188
|
+
"h3",
|
|
91189
|
+
"h4",
|
|
91190
|
+
"h5",
|
|
91191
|
+
"h6"
|
|
91192
|
+
], (heading) => heading === node.tagName), map$4((index) => `\n\n${repeat$1(index + 1)("#")} ${trim(inner)}\n\n`), getOrElse(() => element($, {
|
|
91286
91193
|
base,
|
|
91287
91194
|
inner,
|
|
91288
91195
|
node,
|
|
@@ -91290,18 +91197,17 @@ function markdown($, node, base) {
|
|
|
91290
91197
|
})));
|
|
91291
91198
|
}
|
|
91292
91199
|
function element($, input) {
|
|
91293
|
-
const node = input.node;
|
|
91294
91200
|
const text = trim(input.inner);
|
|
91295
91201
|
return pipe(value(input.tag), when("li", () => {
|
|
91296
|
-
const marker = match($(node).parent().is("ol"), {
|
|
91202
|
+
const marker = match($(input.node).parent().is("ol"), {
|
|
91297
91203
|
onFalse: () => "-",
|
|
91298
|
-
onTrue: () => `${$(node).index() + 1}.`
|
|
91204
|
+
onTrue: () => `${$(input.node).index() + 1}.`
|
|
91299
91205
|
});
|
|
91300
|
-
return `\n${repeat$1($(node).parents("ul, ol").length - 1)(" ")}${marker} ${text}`;
|
|
91301
|
-
}), when("pre", () => `\n\n\`\`\`\n${$(node).text()}\n\`\`\`\n\n`), when("code", () => `\`${text}\``), when("br", () => "\n"), when("tr", () => `\n${text}`), when((name) => name === "td" || name === "th", () => `${text} | `), when("a", () => pipe(fromNullishOr($(node).attr("href")), flatMap$2(liftThrowable((href) => new URL(href, input.base))), filter$5((link) => (link.protocol === "https:" || link.protocol === "http:") && isNonEmpty$1(text)), match$1({
|
|
91206
|
+
return `\n${repeat$1($(input.node).parents("ul, ol").length - 1)(" ")}${marker} ${text}`;
|
|
91207
|
+
}), when("pre", () => `\n\n\`\`\`\n${$(input.node).text()}\n\`\`\`\n\n`), when("code", () => `\`${text}\``), when("br", () => "\n"), when("tr", () => `\n${text}`), when((name) => name === "td" || name === "th", () => `${text} | `), when("a", () => pipe(fromNullishOr($(input.node).attr("href")), flatMap$2(liftThrowable((href) => new URL(href, input.base))), filter$5((link) => (link.protocol === "https:" || link.protocol === "http:") && isNonEmpty$1(text)), match$1({
|
|
91302
91208
|
onNone: () => input.inner,
|
|
91303
91209
|
onSome: (link) => `[${text}](${link.href})`
|
|
91304
|
-
}))), when((name) => contains$
|
|
91210
|
+
}))), when((name) => contains$2(BLOCK_TAGS, name), () => `\n\n${text}\n\n`), orElse(() => input.inner));
|
|
91305
91211
|
}
|
|
91306
91212
|
function pageText(html, url) {
|
|
91307
91213
|
const $ = load$1(html);
|
|
@@ -91317,18 +91223,18 @@ function pageText(html, url) {
|
|
|
91317
91223
|
onTrue: () => part
|
|
91318
91224
|
})), join$1("```"), trim);
|
|
91319
91225
|
return Extraction.make({
|
|
91320
|
-
author:
|
|
91226
|
+
author: pipe(fromUndefinedOr($("meta[property=\"og:site_name\"]").attr("content")), map$4(plainText), filter$5(isNonEmpty$1), orElseSome(() => url.hostname)),
|
|
91321
91227
|
image: pipe(fromNullishOr($("meta[property=\"og:image\"]").attr("content") ?? $("meta[name=\"twitter:image\"]").attr("content")), flatMap$2(liftThrowable((image) => new URL(image, url).href))),
|
|
91322
|
-
text: pipe([
|
|
91228
|
+
text: pipe([map$4(fromUndefinedOr(description), plainText), some$1(body)], getSomes, filter$4(isNonEmpty$1), join$1("\n\n")),
|
|
91323
91229
|
title: plainText($("meta[property=\"og:title\"]").attr("content") ?? $("title").first().text()),
|
|
91324
91230
|
url: canonical(url)
|
|
91325
91231
|
});
|
|
91326
91232
|
}
|
|
91327
91233
|
const reader = fnUntraced(function* (url) {
|
|
91328
91234
|
const answer = yield* pipe(decode$1(Reader, new URL(`https://r.jina.ai/${url.href}`)), timeLimit("30 seconds", "The reader took too long."));
|
|
91329
|
-
if (
|
|
91235
|
+
if (CHALLENGE.test(answer.data.content) || isEmpty$2(trim(answer.data.content))) return yield* NotesError.make({ message: "The site blocks automated reading." });
|
|
91330
91236
|
return Extraction.make({
|
|
91331
|
-
author: url.hostname,
|
|
91237
|
+
author: some$1(url.hostname),
|
|
91332
91238
|
image: none(),
|
|
91333
91239
|
text: answer.data.content,
|
|
91334
91240
|
title: plainText(answer.data.title),
|
|
@@ -91340,7 +91246,7 @@ function readable(found) {
|
|
|
91340
91246
|
return liftPredicate(pageText(found.body, found.url), (extraction) => isNonEmpty$1(extraction.text));
|
|
91341
91247
|
}
|
|
91342
91248
|
const readPage = fnUntraced(function* (url) {
|
|
91343
|
-
const loaded = yield* pipe(follow(url, page, 0), filterOrFail((found) => !
|
|
91249
|
+
const loaded = yield* pipe(follow(url, page, 0), filterOrFail((found) => !CHALLENGE.test(found.body), () => NotesError.make({ message: "The site answered with a bot check." })), map$1(readable), result$1);
|
|
91344
91250
|
return yield* match$3(loaded, {
|
|
91345
91251
|
onFailure: (error) => mapError(reader(url), () => error),
|
|
91346
91252
|
onSuccess: match$1({
|
|
@@ -102012,7 +101918,7 @@ const transformToolCallParams = /*#__PURE__*/ fnUntraced(function* (options, too
|
|
|
102012
101918
|
});
|
|
102013
101919
|
//#endregion
|
|
102014
101920
|
//#region src/services/notes/lib/organization.ts
|
|
102015
|
-
const
|
|
101921
|
+
const INSTRUCTIONS = pipe([
|
|
102016
101922
|
"You organize entries in one person's private notes, so they find each entry again by search and learn what it holds without opening it.",
|
|
102017
101923
|
"An entry is a link (a TikTok, an X post, a YouTube video or a web page), a written note, a photo, a screenshot or a video file.",
|
|
102018
101924
|
"The images are the saved photo, or the link's preview image followed by stills sampled evenly across the video.",
|
|
@@ -102043,7 +101949,7 @@ const instructions = [
|
|
|
102043
101949
|
"For a photo or screenshot, the body says what it shows and keeps the information worth acting on; the verbatim words belong in screenText.",
|
|
102044
101950
|
"The body is empty only when the entry holds nothing beyond the title and summary.",
|
|
102045
101951
|
"screenText: every readable word in the images, verbatim and in reading order, one line per block of text. Skip the status bar, app buttons and repeated captions. Empty when the images show no words."
|
|
102046
|
-
];
|
|
101952
|
+
], join$1(" "));
|
|
102047
101953
|
var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/lib/organization/Organizer") {
|
|
102048
101954
|
static layer = effect(this, gen(function* () {
|
|
102049
101955
|
const key = yield* option(Redacted$1("ANTHROPIC_API_KEY"));
|
|
@@ -102060,16 +101966,16 @@ var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/
|
|
|
102060
101966
|
`Source: ${input.note.source}`,
|
|
102061
101967
|
`Link: ${input.note.url ?? "none"}`,
|
|
102062
101968
|
`Saved file: ${input.note.file ?? "none"}`,
|
|
102063
|
-
`Author: ${input.note.author}`,
|
|
101969
|
+
`Author: ${input.note.author ?? "none"}`,
|
|
102064
101970
|
`Existing tags: ${join$1(take$1(input.tags, 80), ", ")}`,
|
|
102065
101971
|
`Link title: ${input.note.title}`,
|
|
102066
101972
|
`Saved text: ${input.note.text}`,
|
|
102067
101973
|
`Link content: ${slice$2(0, 15e4)(input.note.content)}`,
|
|
102068
|
-
`Video transcript: ${slice$2(0, 15e4)(
|
|
101974
|
+
`Video transcript: ${pipe(fromUndefinedOr(input.note.transcript), map$4(slice$2(0, 15e4)), getOrElse(() => "none"))}`
|
|
102069
101975
|
], "\n");
|
|
102070
101976
|
const response = yield* model.generateObject({
|
|
102071
101977
|
prompt: [{
|
|
102072
|
-
content:
|
|
101978
|
+
content: INSTRUCTIONS,
|
|
102073
101979
|
role: "system"
|
|
102074
101980
|
}, {
|
|
102075
101981
|
content: [...map$3(input.images, (image) => ({
|
|
@@ -102096,7 +102002,6 @@ var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/
|
|
|
102096
102002
|
};
|
|
102097
102003
|
//#endregion
|
|
102098
102004
|
//#region src/services/notes/lib/store.ts
|
|
102099
|
-
const NoteJson = fromJsonString(Note);
|
|
102100
102005
|
const failed = mapError((cause) => NotesError.make({
|
|
102101
102006
|
cause,
|
|
102102
102007
|
message: "The notes database failed."
|
|
@@ -102110,13 +102015,13 @@ const openStore = fnUntraced(function* (path) {
|
|
|
102110
102015
|
const upsert = database.prepare("insert into notes (id, created_at, json) values (?, ?, ?) on conflict (id) do update set created_at = excluded.created_at, json = excluded.json");
|
|
102111
102016
|
const remove = database.prepare("delete from notes where id = ?");
|
|
102112
102017
|
return {
|
|
102113
|
-
load: pipe(try_(() => database.prepare("select json from notes order by created_at desc").all()), flatMap(forEach((row) => decodeUnknownEffect(NoteJson)(row["json"]))), failed),
|
|
102018
|
+
load: pipe(try_(() => database.prepare("select json from notes order by created_at desc").all()), flatMap(forEach((row) => decodeUnknownEffect(NoteJson)(row["json"]), { concurrency: "unbounded" })), failed),
|
|
102114
102019
|
save: fnUntraced(function* (previous, next) {
|
|
102115
102020
|
const changes = diff(previous, next);
|
|
102116
102021
|
const rows = yield* pipe(forEach(changes.upserted, (note) => map$1(encodeEffect(NoteJson)(note), (json) => ({
|
|
102117
102022
|
json,
|
|
102118
102023
|
note
|
|
102119
|
-
}))), failed);
|
|
102024
|
+
})), { concurrency: "unbounded" }), failed);
|
|
102120
102025
|
yield* pipe(try_(() => {
|
|
102121
102026
|
database.exec("begin");
|
|
102122
102027
|
try {
|
|
@@ -102135,7 +102040,7 @@ const openStore = fnUntraced(function* (path) {
|
|
|
102135
102040
|
//#region src/services/notes/service.ts
|
|
102136
102041
|
function withWords(note, text) {
|
|
102137
102042
|
const known = pipe(note.text, toLowerCase, split(/\s+/u));
|
|
102138
|
-
const added = pipe(commentFor(text), split(" "), filter$4((word) => isNonEmpty$1(word) && !contains$
|
|
102043
|
+
const added = pipe(commentFor(text), split(" "), filter$4((word) => isNonEmpty$1(word) && !contains$2(known, toLowerCase(word))));
|
|
102139
102044
|
if (isReadonlyArrayEmpty(added)) return note;
|
|
102140
102045
|
return {
|
|
102141
102046
|
...note,
|
|
@@ -102158,9 +102063,6 @@ function changeNote(notes, id, change) {
|
|
|
102158
102063
|
function optional(message, fallback) {
|
|
102159
102064
|
return (effect) => pipe(effect, tapError((error) => logWarning(message, error)), orElseSucceed(fallback));
|
|
102160
102065
|
}
|
|
102161
|
-
function skip(message) {
|
|
102162
|
-
return (effect) => catch_(effect, (error) => logWarning(message, error));
|
|
102163
|
-
}
|
|
102164
102066
|
var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/Notes") {
|
|
102165
102067
|
static layer = effect(this, gen(function* () {
|
|
102166
102068
|
const fs = yield* FileSystem;
|
|
@@ -102208,17 +102110,13 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102208
102110
|
}));
|
|
102209
102111
|
});
|
|
102210
102112
|
const tagNote = fnUntraced(function* (note, stills) {
|
|
102211
|
-
const
|
|
102212
|
-
const pictures = [...yield* pipe(forEach(toArray$1(fromNullishOr(note.image)), (type) => map$1(fs.readFile(path.join(images, id)), (bytes) => ({
|
|
102113
|
+
const pictures = [...yield* pipe(forEach(toArray$1(fromNullishOr(note.image)), (type) => map$1(fs.readFile(path.join(images, note.id)), (bytes) => ({
|
|
102213
102114
|
bytes,
|
|
102214
102115
|
type
|
|
102215
|
-
}))), optional("The preview could not be read", empty$11)), ...stills];
|
|
102216
|
-
if (isEmpty$2(note.content) &&
|
|
102116
|
+
})), { concurrency: "unbounded" }), optional("The preview could not be read", empty$11)), ...stills];
|
|
102117
|
+
if (isEmpty$2(note.content) && !exists(fromUndefinedOr(note.transcript), isNonEmpty$1) && isEmpty$2(commentFor(note.text)) && isReadonlyArrayEmpty(pictures)) return yield* updateNote(note.id, (item) => ({
|
|
102217
102118
|
...item,
|
|
102218
|
-
issue:
|
|
102219
|
-
onFalse: () => item.issue,
|
|
102220
|
-
onTrue: () => "Nothing to read at this link."
|
|
102221
|
-
}),
|
|
102119
|
+
issue: item.issue ?? "Nothing to read at this link.",
|
|
102222
102120
|
status: "failed"
|
|
102223
102121
|
}));
|
|
102224
102122
|
const outcome = yield* result$1(organizer.organize({
|
|
@@ -102226,7 +102124,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102226
102124
|
note,
|
|
102227
102125
|
tags: map$3(tagCounts(yield* get$1(state)), (entry) => entry.tag)
|
|
102228
102126
|
}));
|
|
102229
|
-
yield* updateNote(id, (item) => match$3(outcome, {
|
|
102127
|
+
yield* updateNote(note.id, (item) => match$3(outcome, {
|
|
102230
102128
|
onFailure: (error) => ({
|
|
102231
102129
|
...item,
|
|
102232
102130
|
issue: error.message,
|
|
@@ -102246,25 +102144,33 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102246
102144
|
}));
|
|
102247
102145
|
}
|
|
102248
102146
|
const keepImages = fnUntraced(function* (note, page) {
|
|
102249
|
-
yield* pipe(forEach(toArray$1(filter$5(page.image, () => note.image === void 0)), (image) => flatMap(sources.image(image), (bytes) => storeImage(note.id, bytes)), {
|
|
102250
|
-
|
|
102147
|
+
yield* pipe(forEach(toArray$1(filter$5(page.image, () => note.image === void 0)), (image) => flatMap(sources.image(image), (bytes) => storeImage(note.id, bytes)), {
|
|
102148
|
+
concurrency: "unbounded",
|
|
102149
|
+
discard: true
|
|
102150
|
+
}), ignore$1({
|
|
102151
|
+
log: "Warn",
|
|
102152
|
+
message: "The preview image was not kept"
|
|
102153
|
+
}));
|
|
102154
|
+
const slides = yield* forEach(page.slides ?? [], (image) => pipe(sources.image(image), asSome, optional("A slide was not read", none)), { concurrency: 1 });
|
|
102251
102155
|
return getSomes(slides);
|
|
102252
102156
|
});
|
|
102253
102157
|
const organizeLink = fnUntraced(function* (note, link) {
|
|
102254
102158
|
const extraction = yield* result$1(sources.extract(link));
|
|
102255
102159
|
yield* updateNote(note.id, (item) => match$3(extraction, {
|
|
102256
|
-
onFailure: (error) => ({
|
|
102257
|
-
|
|
102258
|
-
|
|
102259
|
-
|
|
102260
|
-
|
|
102160
|
+
onFailure: (error) => match(isEmpty$2(item.content), {
|
|
102161
|
+
onFalse: () => item,
|
|
102162
|
+
onTrue: () => ({
|
|
102163
|
+
...item,
|
|
102164
|
+
issue: error.message
|
|
102261
102165
|
})
|
|
102262
102166
|
}),
|
|
102263
102167
|
onSuccess: (page) => ({
|
|
102264
|
-
...item,
|
|
102265
|
-
|
|
102168
|
+
...omit(item, ["issue"]),
|
|
102169
|
+
...match$1(filter$5(page.author, isNonEmpty$1), {
|
|
102170
|
+
onNone: () => ({}),
|
|
102171
|
+
onSome: (author) => ({ author })
|
|
102172
|
+
}),
|
|
102266
102173
|
content: page.text,
|
|
102267
|
-
issue: "",
|
|
102268
102174
|
title: match(isNonEmpty$1(page.title) && item.title === item.url, {
|
|
102269
102175
|
onFalse: () => item.title,
|
|
102270
102176
|
onTrue: () => page.title
|
|
@@ -102287,12 +102193,11 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102287
102193
|
const read = yield* pipe(media.read(video), asSome, optional("The video could not be read", none));
|
|
102288
102194
|
const transcript = yield* pipe(filter$5(read, () => note.transcript === void 0), map$4((details) => pipe(details.transcript, optional("No transcript", none))), transposeOption, map$1(flatten));
|
|
102289
102195
|
yield* updateNote(note.id, (item) => ({
|
|
102290
|
-
...item,
|
|
102291
102196
|
...match$1(filter$5(read, () => sourceFor(url) !== "X" || isFailure(extraction)), {
|
|
102292
|
-
onNone: () =>
|
|
102197
|
+
onNone: () => item,
|
|
102293
102198
|
onSome: (details) => ({
|
|
102294
|
-
|
|
102295
|
-
|
|
102199
|
+
...omit(item, ["issue"]),
|
|
102200
|
+
content: details.info
|
|
102296
102201
|
})
|
|
102297
102202
|
}),
|
|
102298
102203
|
...match$1(transcript, {
|
|
@@ -102306,10 +102211,13 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102306
102211
|
if (!isVideo(type)) return yield* tag(note.id, []);
|
|
102307
102212
|
const stored = path.join(files, note.id);
|
|
102308
102213
|
const stills = yield* pipe(media.fileFrames(stored), optional("No video frames", empty$11));
|
|
102309
|
-
yield* match$1(head(stills), {
|
|
102214
|
+
yield* pipe(match$1(head(stills), {
|
|
102310
102215
|
onNone: () => void_,
|
|
102311
|
-
onSome: (bytes) =>
|
|
102312
|
-
})
|
|
102216
|
+
onSome: (bytes) => storeImage(note.id, still(bytes))
|
|
102217
|
+
}), ignore$1({
|
|
102218
|
+
log: "Warn",
|
|
102219
|
+
message: "The video preview was not kept"
|
|
102220
|
+
}));
|
|
102313
102221
|
yield* match$1(yield* pipe(media.fileTranscript(stored), optional("No transcript", none)), {
|
|
102314
102222
|
onNone: () => void_,
|
|
102315
102223
|
onSome: (text) => updateNote(note.id, (item) => ({
|
|
@@ -102334,11 +102242,17 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102334
102242
|
issue: "Tagging stopped before it finished.",
|
|
102335
102243
|
status: "failed"
|
|
102336
102244
|
})
|
|
102337
|
-
})),
|
|
102245
|
+
})), ignore$1({
|
|
102246
|
+
log: "Warn",
|
|
102247
|
+
message: "A stopped tagging run could not be recorded"
|
|
102248
|
+
})),
|
|
102338
102249
|
onTrue: () => void_
|
|
102339
102250
|
})), (effect) => run$1(runs, note.id, effect), asVoid);
|
|
102340
102251
|
}
|
|
102341
|
-
yield* forEach(filter$4(yield* get$1(state), (note) => note.status === "organizing"), start, {
|
|
102252
|
+
yield* forEach(filter$4(yield* get$1(state), (note) => note.status === "organizing"), start, {
|
|
102253
|
+
concurrency: 1,
|
|
102254
|
+
discard: true
|
|
102255
|
+
});
|
|
102342
102256
|
const missing = mapError(() => NotesError.make({ message: "This note no longer exists." }));
|
|
102343
102257
|
const receive = fnUntraced(function* (input) {
|
|
102344
102258
|
const stored = path.join(match(isVideo(input.type), {
|
|
@@ -102352,10 +102266,12 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102352
102266
|
})), limitBytes(gibibytes(1), () => fail$2(NotesError.make({ message: "The file is larger than 1 GiB." }))), run$3(fs.sink(partial, { mode: 384 })), catchTag("PlatformError", (cause) => fail$1(NotesError.make({
|
|
102353
102267
|
cause,
|
|
102354
102268
|
message: "The upload could not be written."
|
|
102355
|
-
}))), onError(() => pipe(fs.remove(partial, { force: true }),
|
|
102269
|
+
}))), onError(() => pipe(fs.remove(partial, { force: true }), ignore$1({
|
|
102270
|
+
log: "Warn",
|
|
102271
|
+
message: "A broken upload stays on disk"
|
|
102272
|
+
}))));
|
|
102356
102273
|
yield* pipe(fs.rename(partial, stored), storageFailed);
|
|
102357
102274
|
const note = Note.make({
|
|
102358
|
-
author: "",
|
|
102359
102275
|
content: "",
|
|
102360
102276
|
createdAt: toEpochMillis(yield* now),
|
|
102361
102277
|
file: input.type,
|
|
@@ -102367,13 +102283,11 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102367
102283
|
title: "image"
|
|
102368
102284
|
})
|
|
102369
102285
|
})),
|
|
102370
|
-
issue: "",
|
|
102371
102286
|
source: "Note",
|
|
102372
102287
|
status: "organizing",
|
|
102373
102288
|
summary: "",
|
|
102374
102289
|
tags: [],
|
|
102375
|
-
text: ""
|
|
102376
|
-
url: null
|
|
102290
|
+
text: ""
|
|
102377
102291
|
});
|
|
102378
102292
|
const earlier = yield* transact((current) => match$1(findFirst(current, (item) => item.id === input.id), {
|
|
102379
102293
|
onNone: () => make$40(none(), prepend$2(current, note)),
|
|
@@ -102393,11 +102307,9 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102393
102307
|
const saved = yield* transact((current) => match$1(findFirst(current, (note) => note.id === input.id || exists(url, (link) => note.url === link)), {
|
|
102394
102308
|
onNone: () => {
|
|
102395
102309
|
const note = Note.make({
|
|
102396
|
-
author: "",
|
|
102397
102310
|
content: "",
|
|
102398
102311
|
createdAt,
|
|
102399
102312
|
id: input.id,
|
|
102400
|
-
issue: "",
|
|
102401
102313
|
source: match$1(url, {
|
|
102402
102314
|
onNone: () => "Note",
|
|
102403
102315
|
onSome: sourceFor
|
|
@@ -102407,7 +102319,10 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102407
102319
|
tags: [],
|
|
102408
102320
|
text,
|
|
102409
102321
|
title: pipe(liftPredicate(commentFor(text), isNonEmpty$1), orElse$2(() => url), getOrElse(() => text), slice$2(0, 200)),
|
|
102410
|
-
url
|
|
102322
|
+
...match$1(url, {
|
|
102323
|
+
onNone: () => ({}),
|
|
102324
|
+
onSome: (link) => ({ url: link })
|
|
102325
|
+
})
|
|
102411
102326
|
});
|
|
102412
102327
|
return make$40({
|
|
102413
102328
|
fresh: true,
|
|
@@ -102467,8 +102382,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
102467
102382
|
onNone: () => make$40(none(), current),
|
|
102468
102383
|
onSome: (found) => {
|
|
102469
102384
|
const next = {
|
|
102470
|
-
...omit(found, ["transcript"]),
|
|
102471
|
-
issue: "",
|
|
102385
|
+
...omit(found, ["issue", "transcript"]),
|
|
102472
102386
|
status: "organizing"
|
|
102473
102387
|
};
|
|
102474
102388
|
return make$40(some$1(next), changeNote(current, input.id, () => next));
|