@hackbuild/ai-views 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/single/index.iife.js +19 -6
- package/dist/single/index.js +19 -6
- package/package.json +2 -2
|
@@ -13727,7 +13727,7 @@ var HackbuildAiViews = (function(exports) {
|
|
|
13727
13727
|
if (n > 0) reading.set(emb, n);
|
|
13728
13728
|
else {
|
|
13729
13729
|
reading.delete(emb);
|
|
13730
|
-
if (evicted.delete(emb)) o.release?.(emb);
|
|
13730
|
+
if (evicted.delete(emb) && !own.holds(emb)) o.release?.(emb);
|
|
13731
13731
|
}
|
|
13732
13732
|
}
|
|
13733
13733
|
for (const m of masks) if (m.score !== void 0) m.score = Math.min(1, Math.max(0, m.score));
|
|
@@ -13735,7 +13735,7 @@ var HackbuildAiViews = (function(exports) {
|
|
|
13735
13735
|
}
|
|
13736
13736
|
};
|
|
13737
13737
|
seg.dispose = () => {
|
|
13738
|
-
own.clear();
|
|
13738
|
+
if (!o.cache) own.clear();
|
|
13739
13739
|
return o.dispose?.();
|
|
13740
13740
|
};
|
|
13741
13741
|
return seg;
|
|
@@ -13746,6 +13746,7 @@ var HackbuildAiViews = (function(exports) {
|
|
|
13746
13746
|
max;
|
|
13747
13747
|
onEvict;
|
|
13748
13748
|
m = /* @__PURE__ */ new Map();
|
|
13749
|
+
got = /* @__PURE__ */ new WeakMap();
|
|
13749
13750
|
hits = 0;
|
|
13750
13751
|
misses = 0;
|
|
13751
13752
|
/** `onEvict` gets each embedding that leaves the cache (pushed out, deleted, cleared or replaced), to free it. */
|
|
@@ -13756,9 +13757,20 @@ var HackbuildAiViews = (function(exports) {
|
|
|
13756
13757
|
out(p) {
|
|
13757
13758
|
if (p && this.onEvict) {
|
|
13758
13759
|
const f = this.onEvict;
|
|
13759
|
-
p.then(
|
|
13760
|
+
p.then((e) => {
|
|
13761
|
+
if (!this.holds(e)) f(e);
|
|
13762
|
+
}, () => {});
|
|
13760
13763
|
}
|
|
13761
13764
|
}
|
|
13765
|
+
/** True when the embedding is still in the cache under some key. */
|
|
13766
|
+
holds(e) {
|
|
13767
|
+
for (const q of this.m.values()) if (this.got.get(q) === e) return true;
|
|
13768
|
+
return false;
|
|
13769
|
+
}
|
|
13770
|
+
keep(p) {
|
|
13771
|
+
p.then((e) => this.got.set(p, e), () => {});
|
|
13772
|
+
return p;
|
|
13773
|
+
}
|
|
13762
13774
|
has(key) {
|
|
13763
13775
|
return this.m.has(key);
|
|
13764
13776
|
}
|
|
@@ -13767,7 +13779,8 @@ var HackbuildAiViews = (function(exports) {
|
|
|
13767
13779
|
return this.m.get(key);
|
|
13768
13780
|
}
|
|
13769
13781
|
set(key, v) {
|
|
13770
|
-
const p = Promise.resolve(v);
|
|
13782
|
+
const p = this.keep(Promise.resolve(v));
|
|
13783
|
+
if (!(v instanceof Promise)) this.got.set(p, v);
|
|
13771
13784
|
const was = this.m.get(key);
|
|
13772
13785
|
this.m.delete(key);
|
|
13773
13786
|
this.m.set(key, p);
|
|
@@ -13788,7 +13801,7 @@ var HackbuildAiViews = (function(exports) {
|
|
|
13788
13801
|
return v;
|
|
13789
13802
|
}
|
|
13790
13803
|
this.misses++;
|
|
13791
|
-
const p = make();
|
|
13804
|
+
const p = this.keep(make());
|
|
13792
13805
|
this.set(key, p);
|
|
13793
13806
|
p.catch(() => {
|
|
13794
13807
|
if (this.m.get(key) === p) this.m.delete(key);
|
|
@@ -13956,7 +13969,7 @@ var HackbuildAiViews = (function(exports) {
|
|
|
13956
13969
|
}
|
|
13957
13970
|
return res;
|
|
13958
13971
|
} finally {
|
|
13959
|
-
release(p,
|
|
13972
|
+
release(p, masks, ...Object.values(out));
|
|
13960
13973
|
}
|
|
13961
13974
|
},
|
|
13962
13975
|
release: (e) => release(e.emb),
|
package/dist/single/index.js
CHANGED
|
@@ -13725,7 +13725,7 @@ function promptSegmenter(o) {
|
|
|
13725
13725
|
if (n > 0) reading.set(emb, n);
|
|
13726
13726
|
else {
|
|
13727
13727
|
reading.delete(emb);
|
|
13728
|
-
if (evicted.delete(emb)) o.release?.(emb);
|
|
13728
|
+
if (evicted.delete(emb) && !own.holds(emb)) o.release?.(emb);
|
|
13729
13729
|
}
|
|
13730
13730
|
}
|
|
13731
13731
|
for (const m of masks) if (m.score !== void 0) m.score = Math.min(1, Math.max(0, m.score));
|
|
@@ -13733,7 +13733,7 @@ function promptSegmenter(o) {
|
|
|
13733
13733
|
}
|
|
13734
13734
|
};
|
|
13735
13735
|
seg.dispose = () => {
|
|
13736
|
-
own.clear();
|
|
13736
|
+
if (!o.cache) own.clear();
|
|
13737
13737
|
return o.dispose?.();
|
|
13738
13738
|
};
|
|
13739
13739
|
return seg;
|
|
@@ -13744,6 +13744,7 @@ var init_segment = __esmMin((() => {
|
|
|
13744
13744
|
max;
|
|
13745
13745
|
onEvict;
|
|
13746
13746
|
m = /* @__PURE__ */ new Map();
|
|
13747
|
+
got = /* @__PURE__ */ new WeakMap();
|
|
13747
13748
|
hits = 0;
|
|
13748
13749
|
misses = 0;
|
|
13749
13750
|
/** `onEvict` gets each embedding that leaves the cache (pushed out, deleted, cleared or replaced), to free it. */
|
|
@@ -13754,9 +13755,20 @@ var init_segment = __esmMin((() => {
|
|
|
13754
13755
|
out(p) {
|
|
13755
13756
|
if (p && this.onEvict) {
|
|
13756
13757
|
const f = this.onEvict;
|
|
13757
|
-
p.then(
|
|
13758
|
+
p.then((e) => {
|
|
13759
|
+
if (!this.holds(e)) f(e);
|
|
13760
|
+
}, () => {});
|
|
13758
13761
|
}
|
|
13759
13762
|
}
|
|
13763
|
+
/** True when the embedding is still in the cache under some key. */
|
|
13764
|
+
holds(e) {
|
|
13765
|
+
for (const q of this.m.values()) if (this.got.get(q) === e) return true;
|
|
13766
|
+
return false;
|
|
13767
|
+
}
|
|
13768
|
+
keep(p) {
|
|
13769
|
+
p.then((e) => this.got.set(p, e), () => {});
|
|
13770
|
+
return p;
|
|
13771
|
+
}
|
|
13760
13772
|
has(key) {
|
|
13761
13773
|
return this.m.has(key);
|
|
13762
13774
|
}
|
|
@@ -13765,7 +13777,8 @@ var init_segment = __esmMin((() => {
|
|
|
13765
13777
|
return this.m.get(key);
|
|
13766
13778
|
}
|
|
13767
13779
|
set(key, v) {
|
|
13768
|
-
const p = Promise.resolve(v);
|
|
13780
|
+
const p = this.keep(Promise.resolve(v));
|
|
13781
|
+
if (!(v instanceof Promise)) this.got.set(p, v);
|
|
13769
13782
|
const was = this.m.get(key);
|
|
13770
13783
|
this.m.delete(key);
|
|
13771
13784
|
this.m.set(key, p);
|
|
@@ -13786,7 +13799,7 @@ var init_segment = __esmMin((() => {
|
|
|
13786
13799
|
return v;
|
|
13787
13800
|
}
|
|
13788
13801
|
this.misses++;
|
|
13789
|
-
const p = make();
|
|
13802
|
+
const p = this.keep(make());
|
|
13790
13803
|
this.set(key, p);
|
|
13791
13804
|
p.catch(() => {
|
|
13792
13805
|
if (this.m.get(key) === p) this.m.delete(key);
|
|
@@ -13954,7 +13967,7 @@ async function samLoader(ctx) {
|
|
|
13954
13967
|
}
|
|
13955
13968
|
return res;
|
|
13956
13969
|
} finally {
|
|
13957
|
-
release(p,
|
|
13970
|
+
release(p, masks, ...Object.values(out));
|
|
13958
13971
|
}
|
|
13959
13972
|
},
|
|
13960
13973
|
release: (e) => release(e.emb),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hackbuild/ai-views",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Views that bind the browser AI packages to hackbuild-ui: a model picker per job, a chat pane and composer, a drop first transcriber, a mask studio, a frame view and a camera feed. Each ships as a Vue component and a custom element.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@hackbuild/models": "0.2.5",
|
|
52
52
|
"@hackbuild/speak": "0.1.7",
|
|
53
53
|
"@hackbuild/transcribe": "0.1.7",
|
|
54
|
-
"@hackbuild/vision": "0.3.
|
|
54
|
+
"@hackbuild/vision": "0.3.2",
|
|
55
55
|
"@hackbuild/weights": "0.1.4"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|