Created
April 8, 2024 03:20
-
-
Save guest271314/1e8fab96bd40dc7711b43f5d7faf239e to your computer and use it in GitHub Desktop.
Signals proposal polyfill bundled with Deno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vendor/esm.sh/v135/signal-polyfill@0.1.0/denonext/signal-polyfill.mjs | |
var $ = function(e, o) { | |
return Object.is(e, o); | |
}; | |
var N = function(e) { | |
let o = i; | |
return i = e, o; | |
}; | |
var ce = function() { | |
return i; | |
}; | |
var se = function() { | |
return T; | |
}; | |
var W = function(e) { | |
if (T) | |
throw new Error(typeof ngDevMode < "u" && ngDevMode ? "Assertion error: signal read during notification phase" : ""); | |
if (i === null) | |
return; | |
i.consumerOnSignalRead(e); | |
let o = i.nextProducerIndex++; | |
if (C(i), o < i.producerNode.length && i.producerNode[o] !== e && b(i)) { | |
let r = i.producerNode[o]; | |
R(r, i.producerIndexOfThis[o]); | |
} | |
i.producerNode[o] !== e && (i.producerNode[o] = e, i.producerIndexOfThis[o] = b(i) ? F(e, i, o) : 0), i.producerLastReadVersion[o] = e.version; | |
}; | |
var de = function() { | |
I++; | |
}; | |
var z = function(e) { | |
if (!(b(e) && !e.dirty) && !(!e.dirty && e.lastCleanEpoch === I)) { | |
if (!e.producerMustRecompute(e) && !fe(e)) { | |
e.dirty = false, e.lastCleanEpoch = I; | |
return; | |
} | |
e.producerRecomputeValue(e), e.dirty = false, e.lastCleanEpoch = I; | |
} | |
}; | |
var B = function(e) { | |
if (e.liveConsumerNode === undefined) | |
return; | |
let o = T; | |
T = true; | |
try { | |
for (let r of e.liveConsumerNode) | |
r.dirty || ae(r); | |
} finally { | |
T = o; | |
} | |
}; | |
var le = function() { | |
return i?.consumerAllowSignalWrites !== false; | |
}; | |
var ae = function(e) { | |
var o; | |
e.dirty = true, B(e), (o = e.consumerMarkedDirty) == null || o.call(e, e); | |
}; | |
var pe = function(e) { | |
return e && (e.nextProducerIndex = 0), N(e); | |
}; | |
var he = function(e, o) { | |
if (N(o), !(!e || e.producerNode === undefined || e.producerIndexOfThis === undefined || e.producerLastReadVersion === undefined)) { | |
if (b(e)) | |
for (let r = e.nextProducerIndex;r < e.producerNode.length; r++) | |
R(e.producerNode[r], e.producerIndexOfThis[r]); | |
for (;e.producerNode.length > e.nextProducerIndex; ) | |
e.producerNode.pop(), e.producerLastReadVersion.pop(), e.producerIndexOfThis.pop(); | |
} | |
}; | |
var fe = function(e) { | |
C(e); | |
for (let o = 0;o < e.producerNode.length; o++) { | |
let r = e.producerNode[o], d = e.producerLastReadVersion[o]; | |
if (d !== r.version || (z(r), d !== r.version)) | |
return true; | |
} | |
return false; | |
}; | |
var F = function(e, o, r) { | |
var d; | |
if (D(e), C(e), e.liveConsumerNode.length === 0) { | |
(d = e.watched) == null || d.call(e.wrapper); | |
for (let c = 0;c < e.producerNode.length; c++) | |
e.producerIndexOfThis[c] = F(e.producerNode[c], e, c); | |
} | |
return e.liveConsumerIndexOfThis.push(r), e.liveConsumerNode.push(o) - 1; | |
}; | |
var R = function(e, o) { | |
var r; | |
if (D(e), C(e), typeof ngDevMode < "u" && ngDevMode && o >= e.liveConsumerNode.length) | |
throw new Error(`Assertion error: active consumer index ${o} is out of bounds of ${e.liveConsumerNode.length} consumers)`); | |
if (e.liveConsumerNode.length === 1) { | |
(r = e.unwatched) == null || r.call(e.wrapper); | |
for (let c = 0;c < e.producerNode.length; c++) | |
R(e.producerNode[c], e.producerIndexOfThis[c]); | |
} | |
let d = e.liveConsumerNode.length - 1; | |
if (e.liveConsumerNode[o] = e.liveConsumerNode[d], e.liveConsumerIndexOfThis[o] = e.liveConsumerIndexOfThis[d], e.liveConsumerNode.length--, e.liveConsumerIndexOfThis.length--, o < e.liveConsumerNode.length) { | |
let c = e.liveConsumerIndexOfThis[o], m = e.liveConsumerNode[o]; | |
C(m), m.producerIndexOfThis[c] = o; | |
} | |
}; | |
var b = function(e) { | |
var o; | |
return e.consumerIsAlwaysLive || (((o = e?.liveConsumerNode) == null ? undefined : o.length) ?? 0) > 0; | |
}; | |
var C = function(e) { | |
e.producerNode ?? (e.producerNode = []), e.producerIndexOfThis ?? (e.producerIndexOfThis = []), e.producerLastReadVersion ?? (e.producerLastReadVersion = []); | |
}; | |
var D = function(e) { | |
e.liveConsumerNode ?? (e.liveConsumerNode = []), e.liveConsumerIndexOfThis ?? (e.liveConsumerIndexOfThis = []); | |
}; | |
var H = function(e) { | |
if (z(e), W(e), e.value === O) | |
throw e.error; | |
return e.value; | |
}; | |
var ve = function(e) { | |
let o = Object.create(we); | |
o.computation = e; | |
let r = () => H(o); | |
return r[E] = o, r; | |
}; | |
var me = function() { | |
throw new Error; | |
}; | |
var ye = function() { | |
ge(); | |
}; | |
var Ne = function(e) { | |
let o = Object.create(xe); | |
o.value = e; | |
let r = () => (W(o), o.value); | |
return r[E] = o, r; | |
}; | |
var Ce = function() { | |
return W(this), this.value; | |
}; | |
var Te = function(e, o) { | |
le() || ye(), e.equal.call(e.wrapper, e.value, o) || (e.value = o, Se(e)); | |
}; | |
var Se = function(e) { | |
e.version++, de(), B(e); | |
}; | |
var ne = Object.defineProperty; | |
var ue = (e, o, r) => (o in e) ? ne(e, o, { enumerable: true, configurable: true, writable: true, value: r }) : e[o] = r; | |
var L = (e, o, r) => (ue(e, typeof o != "symbol" ? o + "" : o, r), r); | |
var ie = (e, o, r) => { | |
if (!o.has(e)) | |
throw TypeError("Cannot " + r); | |
}; | |
var M = (e, o) => { | |
if (Object(o) !== o) | |
throw TypeError('Cannot use the "in" operator on this value'); | |
return e.has(o); | |
}; | |
var S = (e, o, r) => { | |
if (o.has(e)) | |
throw TypeError("Cannot add the same private member more than once"); | |
o instanceof WeakSet ? o.add(e) : o.set(e, r); | |
}; | |
var G = (e, o, r) => (ie(e, o, "access private method"), r); | |
var i = null; | |
var T = false; | |
var I = 1; | |
var E = Symbol("SIGNAL"); | |
var V = { version: 0, lastCleanEpoch: 0, dirty: false, producerNode: undefined, producerLastReadVersion: undefined, producerIndexOfThis: undefined, nextProducerIndex: 0, liveConsumerNode: undefined, liveConsumerIndexOfThis: undefined, consumerAllowSignalWrites: false, consumerIsAlwaysLive: false, producerMustRecompute: () => false, producerRecomputeValue: () => { | |
}, consumerMarkedDirty: () => { | |
}, consumerOnSignalRead: () => { | |
} }; | |
var A = Symbol("UNSET"); | |
var P = Symbol("COMPUTING"); | |
var O = Symbol("ERRORED"); | |
var we = { ...V, value: A, dirty: true, error: null, equal: $, producerMustRecompute(e) { | |
return e.value === A || e.value === P; | |
}, producerRecomputeValue(e) { | |
if (e.value === P) | |
throw new Error("Detected cycle in computations."); | |
let o = e.value; | |
e.value = P; | |
let r = pe(e), d; | |
try { | |
d = e.computation.call(e.wrapper); | |
} catch (c) { | |
d = O, e.error = c; | |
} finally { | |
he(e, r); | |
} | |
if (o !== A && o !== O && d !== O && e.equal.call(e.wrapper, o, d)) { | |
e.value = o; | |
return; | |
} | |
e.value = d, e.version++; | |
} }; | |
var ge = me; | |
var xe = { ...V, equal: $, value: undefined }; | |
var s = Symbol("node"); | |
var g; | |
var w; | |
var y; | |
var U; | |
((e) => { | |
var o, r, d, c, m, J; | |
class K { | |
constructor(v, a = {}) { | |
S(this, r), L(this, o); | |
let h = Ne(v)[E]; | |
if (this[s] = h, h.wrapper = this, a) { | |
let f = a.equals; | |
f && (h.equal = f), h.watched = a[e.subtle.watched], h.unwatched = a[e.subtle.unwatched]; | |
} | |
} | |
get() { | |
if (!g(this)) | |
throw new TypeError("Wrong receiver type for Signal.State.prototype.get"); | |
return Ce.call(this[s]); | |
} | |
set(v) { | |
if (!g(this)) | |
throw new TypeError("Wrong receiver type for Signal.State.prototype.set"); | |
if (se()) | |
throw new Error("Writes to signals not permitted during Watcher callback"); | |
let a = this[s]; | |
Te(a, v); | |
} | |
} | |
o = s, r = new WeakSet, d = function() { | |
}, g = (l) => M(r, l), e.State = K; | |
class Q { | |
constructor(v, a) { | |
S(this, m), L(this, c); | |
let h = ve(v)[E]; | |
if (h.consumerAllowSignalWrites = true, this[s] = h, h.wrapper = this, a) { | |
let f = a.equals; | |
f && (h.equal = f), h.watched = a[e.subtle.watched], h.unwatched = a[e.subtle.unwatched]; | |
} | |
} | |
get() { | |
if (!w(this)) | |
throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get"); | |
return H(this[s]); | |
} | |
} | |
c = s, m = new WeakSet, J = function() { | |
}, w = (l) => M(m, l), e.Computed = Q, ((l) => { | |
var v, a, h, f, k; | |
function X(u) { | |
let n, t = null; | |
try { | |
t = N(null), n = u(); | |
} finally { | |
N(t); | |
} | |
return n; | |
} | |
l.untrack = X; | |
function Y(u) { | |
var n; | |
if (!w(u) && !y(u)) | |
throw new TypeError("Called introspectSources without a Computed or Watcher argument"); | |
return ((n = u[s].producerNode) == null ? undefined : n.map((t) => t.wrapper)) ?? []; | |
} | |
l.introspectSources = Y; | |
function Z(u) { | |
var n; | |
if (!w(u) && !g(u)) | |
throw new TypeError("Called introspectSinks without a Signal argument"); | |
return ((n = u[s].liveConsumerNode) == null ? undefined : n.map((t) => t.wrapper)) ?? []; | |
} | |
l.introspectSinks = Z; | |
function _(u) { | |
if (!w(u) && !g(u)) | |
throw new TypeError("Called hasSinks without a Signal argument"); | |
let n = u[s].liveConsumerNode; | |
return n ? n.length > 0 : false; | |
} | |
l.hasSinks = _; | |
function ee(u) { | |
if (!w(u) && !y(u)) | |
throw new TypeError("Called hasSources without a Computed or Watcher argument"); | |
let n = u[s].producerNode; | |
return n ? n.length > 0 : false; | |
} | |
l.hasSources = ee; | |
class oe { | |
constructor(n) { | |
S(this, a), S(this, f), L(this, v); | |
let t = Object.create(V); | |
t.wrapper = this, t.consumerMarkedDirty = n, t.consumerIsAlwaysLive = true, t.consumerAllowSignalWrites = false, t.producerNode = [], this[s] = t; | |
} | |
watch(...n) { | |
if (!y(this)) | |
throw new TypeError("Called unwatch without Watcher receiver"); | |
G(this, f, k).call(this, n); | |
let t = this[s]; | |
t.dirty = false; | |
let x = N(t); | |
for (let p of n) | |
W(p[s]); | |
N(x); | |
} | |
unwatch(...n) { | |
if (!y(this)) | |
throw new TypeError("Called unwatch without Watcher receiver"); | |
G(this, f, k).call(this, n); | |
let t = this[s]; | |
C(t); | |
let x = []; | |
for (let p = 0;p < t.producerNode.length; p++) | |
n.includes(t.producerNode[p].wrapper) && (R(t.producerNode[p], t.producerIndexOfThis[p]), x.push(p)); | |
for (let p of x) { | |
let q = t.producerNode.length - 1; | |
if (t.producerNode[p] = t.producerNode[q], t.producerIndexOfThis[p] = t.producerIndexOfThis[q], t.producerNode.length--, t.producerIndexOfThis.length--, t.nextProducerIndex--, p < t.producerNode.length) { | |
let te = t.producerIndexOfThis[p], j = t.producerNode[p]; | |
D(j), j.liveConsumerIndexOfThis[te] = p; | |
} | |
} | |
} | |
getPending() { | |
if (!y(this)) | |
throw new TypeError("Called getPending without Watcher receiver"); | |
return this[s].producerNode.filter((n) => n.dirty).map((n) => n.wrapper); | |
} | |
} | |
v = s, a = new WeakSet, h = function() { | |
}, f = new WeakSet, k = function(u) { | |
for (let n of u) | |
if (!w(n) && !g(n)) | |
throw new TypeError("Called watch/unwatch without a Computed or State argument"); | |
}, y = (u) => M(a, u), l.Watcher = oe; | |
function re() { | |
var u; | |
return (u = ce()) == null ? undefined : u.wrapper; | |
} | |
l.currentComputed = re, l.watched = Symbol("watched"), l.unwatched = Symbol("unwatched"); | |
})(e.subtle || (e.subtle = {})); | |
})(U || (U = {})); | |
/*! Bundled license information: | |
signal-polyfill/dist/index.js: | |
(** | |
* @license | |
* Copyright Google LLC All Rights Reserved. | |
* | |
* Use of this source code is governed by an MIT-style license that can be | |
* found in the LICENSE file at https://angular.io/license | |
*) | |
(** | |
* @license | |
* Copyright 2024 Bloomberg Finance L.P. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*) | |
*/ | |
export { | |
U as Signal | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// deno-fmt-ignore-file | |
// deno-lint-ignore-file | |
// This code was bundled using `deno bundle` and it's not recommended to edit it manually | |
var ne = Object.defineProperty, ue = (e, o, r)=>o in e ? ne(e, o, { | |
enumerable: !0, | |
configurable: !0, | |
writable: !0, | |
value: r | |
}) : e[o] = r, L = (e, o, r)=>(ue(e, typeof o != "symbol" ? o + "" : o, r), r), ie = (e, o, r)=>{ | |
if (!o.has(e)) throw TypeError("Cannot " + r); | |
}, M = (e, o)=>{ | |
if (Object(o) !== o) throw TypeError('Cannot use the "in" operator on this value'); | |
return e.has(o); | |
}, S = (e, o, r)=>{ | |
if (o.has(e)) throw TypeError("Cannot add the same private member more than once"); | |
o instanceof WeakSet ? o.add(e) : o.set(e, r); | |
}, G = (e, o, r)=>(ie(e, o, "access private method"), r); | |
function $(e, o) { | |
return Object.is(e, o); | |
} | |
var i = null, T = !1, I = 1, E = Symbol("SIGNAL"); | |
function N(e) { | |
let o = i; | |
return i = e, o; | |
} | |
function ce() { | |
return i; | |
} | |
function se() { | |
return T; | |
} | |
var V = { | |
version: 0, | |
lastCleanEpoch: 0, | |
dirty: !1, | |
producerNode: void 0, | |
producerLastReadVersion: void 0, | |
producerIndexOfThis: void 0, | |
nextProducerIndex: 0, | |
liveConsumerNode: void 0, | |
liveConsumerIndexOfThis: void 0, | |
consumerAllowSignalWrites: !1, | |
consumerIsAlwaysLive: !1, | |
producerMustRecompute: ()=>!1, | |
producerRecomputeValue: ()=>{}, | |
consumerMarkedDirty: ()=>{}, | |
consumerOnSignalRead: ()=>{} | |
}; | |
function W(e) { | |
if (T) throw new Error(typeof ngDevMode < "u" && ngDevMode ? "Assertion error: signal read during notification phase" : ""); | |
if (i === null) return; | |
i.consumerOnSignalRead(e); | |
let o = i.nextProducerIndex++; | |
if (C(i), o < i.producerNode.length && i.producerNode[o] !== e && b(i)) { | |
let r = i.producerNode[o]; | |
R(r, i.producerIndexOfThis[o]); | |
} | |
i.producerNode[o] !== e && (i.producerNode[o] = e, i.producerIndexOfThis[o] = b(i) ? F(e, i, o) : 0), i.producerLastReadVersion[o] = e.version; | |
} | |
function de() { | |
I++; | |
} | |
function z(e) { | |
if (!(b(e) && !e.dirty) && !(!e.dirty && e.lastCleanEpoch === I)) { | |
if (!e.producerMustRecompute(e) && !fe(e)) { | |
e.dirty = !1, e.lastCleanEpoch = I; | |
return; | |
} | |
e.producerRecomputeValue(e), e.dirty = !1, e.lastCleanEpoch = I; | |
} | |
} | |
function B(e) { | |
if (e.liveConsumerNode === void 0) return; | |
let o = T; | |
T = !0; | |
try { | |
for (let r of e.liveConsumerNode)r.dirty || ae(r); | |
} finally{ | |
T = o; | |
} | |
} | |
function le() { | |
return i?.consumerAllowSignalWrites !== !1; | |
} | |
function ae(e) { | |
var o; | |
e.dirty = !0, B(e), (o = e.consumerMarkedDirty) == null || o.call(e, e); | |
} | |
function pe(e) { | |
return e && (e.nextProducerIndex = 0), N(e); | |
} | |
function he(e, o) { | |
if (N(o), !(!e || e.producerNode === void 0 || e.producerIndexOfThis === void 0 || e.producerLastReadVersion === void 0)) { | |
if (b(e)) for(let r = e.nextProducerIndex; r < e.producerNode.length; r++)R(e.producerNode[r], e.producerIndexOfThis[r]); | |
for(; e.producerNode.length > e.nextProducerIndex;)e.producerNode.pop(), e.producerLastReadVersion.pop(), e.producerIndexOfThis.pop(); | |
} | |
} | |
function fe(e) { | |
C(e); | |
for(let o = 0; o < e.producerNode.length; o++){ | |
let r = e.producerNode[o], d = e.producerLastReadVersion[o]; | |
if (d !== r.version || (z(r), d !== r.version)) return !0; | |
} | |
return !1; | |
} | |
function F(e, o, r) { | |
var d; | |
if (D(e), C(e), e.liveConsumerNode.length === 0) { | |
(d = e.watched) == null || d.call(e.wrapper); | |
for(let c = 0; c < e.producerNode.length; c++)e.producerIndexOfThis[c] = F(e.producerNode[c], e, c); | |
} | |
return e.liveConsumerIndexOfThis.push(r), e.liveConsumerNode.push(o) - 1; | |
} | |
function R(e, o) { | |
var r; | |
if (D(e), C(e), typeof ngDevMode < "u" && ngDevMode && o >= e.liveConsumerNode.length) throw new Error(`Assertion error: active consumer index ${o} is out of bounds of ${e.liveConsumerNode.length} consumers)`); | |
if (e.liveConsumerNode.length === 1) { | |
(r = e.unwatched) == null || r.call(e.wrapper); | |
for(let c = 0; c < e.producerNode.length; c++)R(e.producerNode[c], e.producerIndexOfThis[c]); | |
} | |
let d = e.liveConsumerNode.length - 1; | |
if (e.liveConsumerNode[o] = e.liveConsumerNode[d], e.liveConsumerIndexOfThis[o] = e.liveConsumerIndexOfThis[d], e.liveConsumerNode.length--, e.liveConsumerIndexOfThis.length--, o < e.liveConsumerNode.length) { | |
let c = e.liveConsumerIndexOfThis[o], m = e.liveConsumerNode[o]; | |
C(m), m.producerIndexOfThis[c] = o; | |
} | |
} | |
function b(e) { | |
var o; | |
return e.consumerIsAlwaysLive || (((o = e?.liveConsumerNode) == null ? void 0 : o.length) ?? 0) > 0; | |
} | |
function C(e) { | |
e.producerNode ?? (e.producerNode = []), e.producerIndexOfThis ?? (e.producerIndexOfThis = []), e.producerLastReadVersion ?? (e.producerLastReadVersion = []); | |
} | |
function D(e) { | |
e.liveConsumerNode ?? (e.liveConsumerNode = []), e.liveConsumerIndexOfThis ?? (e.liveConsumerIndexOfThis = []); | |
} | |
function H(e) { | |
if (z(e), W(e), e.value === O) throw e.error; | |
return e.value; | |
} | |
function ve(e) { | |
let o = Object.create(we); | |
o.computation = e; | |
let r = ()=>H(o); | |
return r[E] = o, r; | |
} | |
var A = Symbol("UNSET"), P = Symbol("COMPUTING"), O = Symbol("ERRORED"), we = { | |
...V, | |
value: A, | |
dirty: !0, | |
error: null, | |
equal: $, | |
producerMustRecompute (e) { | |
return e.value === A || e.value === P; | |
}, | |
producerRecomputeValue (e) { | |
if (e.value === P) throw new Error("Detected cycle in computations."); | |
let o = e.value; | |
e.value = P; | |
let r = pe(e), d; | |
try { | |
d = e.computation.call(e.wrapper); | |
} catch (c) { | |
d = O, e.error = c; | |
} finally{ | |
he(e, r); | |
} | |
if (o !== A && o !== O && d !== O && e.equal.call(e.wrapper, o, d)) { | |
e.value = o; | |
return; | |
} | |
e.value = d, e.version++; | |
} | |
}; | |
function me() { | |
throw new Error; | |
} | |
var ge = me; | |
function ye() { | |
ge(); | |
} | |
function Ne(e) { | |
let o = Object.create(xe); | |
o.value = e; | |
let r = ()=>(W(o), o.value); | |
return r[E] = o, r; | |
} | |
function Ce() { | |
return W(this), this.value; | |
} | |
function Te(e, o) { | |
le() || ye(), e.equal.call(e.wrapper, e.value, o) || (e.value = o, Se(e)); | |
} | |
var xe = { | |
...V, | |
equal: $, | |
value: void 0 | |
}; | |
function Se(e) { | |
e.version++, de(), B(e); | |
} | |
var s = Symbol("node"), g, w, y, U; | |
((e)=>{ | |
var o, r, c, m; | |
class K { | |
constructor(v, a = {}){ | |
S(this, r), L(this, o); | |
let h = Ne(v)[E]; | |
if (this[s] = h, h.wrapper = this, a) { | |
let f = a.equals; | |
f && (h.equal = f), h.watched = a[e.subtle.watched], h.unwatched = a[e.subtle.unwatched]; | |
} | |
} | |
get() { | |
if (!g(this)) throw new TypeError("Wrong receiver type for Signal.State.prototype.get"); | |
return Ce.call(this[s]); | |
} | |
set(v) { | |
if (!g(this)) throw new TypeError("Wrong receiver type for Signal.State.prototype.set"); | |
if (se()) throw new Error("Writes to signals not permitted during Watcher callback"); | |
let a = this[s]; | |
Te(a, v); | |
} | |
} | |
o = s, r = new WeakSet, g = (l)=>M(r, l), e.State = K; | |
class Q { | |
constructor(v, a){ | |
S(this, m), L(this, c); | |
let h = ve(v)[E]; | |
if (h.consumerAllowSignalWrites = !0, this[s] = h, h.wrapper = this, a) { | |
let f = a.equals; | |
f && (h.equal = f), h.watched = a[e.subtle.watched], h.unwatched = a[e.subtle.unwatched]; | |
} | |
} | |
get() { | |
if (!w(this)) throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get"); | |
return H(this[s]); | |
} | |
} | |
c = s, m = new WeakSet, w = (l)=>M(m, l), e.Computed = Q, ((l)=>{ | |
var v, a, f, k; | |
function X(u) { | |
let n, t = null; | |
try { | |
t = N(null), n = u(); | |
} finally{ | |
N(t); | |
} | |
return n; | |
} | |
l.untrack = X; | |
function Y(u) { | |
var n; | |
if (!w(u) && !y(u)) throw new TypeError("Called introspectSources without a Computed or Watcher argument"); | |
return ((n = u[s].producerNode) == null ? void 0 : n.map((t)=>t.wrapper)) ?? []; | |
} | |
l.introspectSources = Y; | |
function Z(u) { | |
var n; | |
if (!w(u) && !g(u)) throw new TypeError("Called introspectSinks without a Signal argument"); | |
return ((n = u[s].liveConsumerNode) == null ? void 0 : n.map((t)=>t.wrapper)) ?? []; | |
} | |
l.introspectSinks = Z; | |
function _(u) { | |
if (!w(u) && !g(u)) throw new TypeError("Called hasSinks without a Signal argument"); | |
let n = u[s].liveConsumerNode; | |
return n ? n.length > 0 : !1; | |
} | |
l.hasSinks = _; | |
function ee(u) { | |
if (!w(u) && !y(u)) throw new TypeError("Called hasSources without a Computed or Watcher argument"); | |
let n = u[s].producerNode; | |
return n ? n.length > 0 : !1; | |
} | |
l.hasSources = ee; | |
class oe { | |
constructor(n){ | |
S(this, a), S(this, f), L(this, v); | |
let t = Object.create(V); | |
t.wrapper = this, t.consumerMarkedDirty = n, t.consumerIsAlwaysLive = !0, t.consumerAllowSignalWrites = !1, t.producerNode = [], this[s] = t; | |
} | |
watch(...n) { | |
if (!y(this)) throw new TypeError("Called unwatch without Watcher receiver"); | |
G(this, f, k).call(this, n); | |
let t = this[s]; | |
t.dirty = !1; | |
let x = N(t); | |
for (let p of n)W(p[s]); | |
N(x); | |
} | |
unwatch(...n) { | |
if (!y(this)) throw new TypeError("Called unwatch without Watcher receiver"); | |
G(this, f, k).call(this, n); | |
let t = this[s]; | |
C(t); | |
let x = []; | |
for(let p = 0; p < t.producerNode.length; p++)n.includes(t.producerNode[p].wrapper) && (R(t.producerNode[p], t.producerIndexOfThis[p]), x.push(p)); | |
for (let p of x){ | |
let q = t.producerNode.length - 1; | |
if (t.producerNode[p] = t.producerNode[q], t.producerIndexOfThis[p] = t.producerIndexOfThis[q], t.producerNode.length--, t.producerIndexOfThis.length--, t.nextProducerIndex--, p < t.producerNode.length) { | |
let te = t.producerIndexOfThis[p], j = t.producerNode[p]; | |
D(j), j.liveConsumerIndexOfThis[te] = p; | |
} | |
} | |
} | |
getPending() { | |
if (!y(this)) throw new TypeError("Called getPending without Watcher receiver"); | |
return this[s].producerNode.filter((n)=>n.dirty).map((n)=>n.wrapper); | |
} | |
} | |
v = s, a = new WeakSet, f = new WeakSet, k = function(u) { | |
for (let n of u)if (!w(n) && !g(n)) throw new TypeError("Called watch/unwatch without a Computed or State argument"); | |
}, y = (u)=>M(a, u), l.Watcher = oe; | |
function re() { | |
var u; | |
return (u = ce()) == null ? void 0 : u.wrapper; | |
} | |
l.currentComputed = re, l.watched = Symbol("watched"), l.unwatched = Symbol("unwatched"); | |
})(e.subtle || (e.subtle = {})); | |
})(U || (U = {})); | |
export { U as Signal }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment