@myzonerocks/gosslens 0.10.0 → 0.11.0

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.
@@ -1,4 +1,4 @@
1
- import type { GossSession } from "./index";
1
+ import type { GossSession } from "./index.js";
2
2
  export declare class GossMicInput {
3
3
  private session;
4
4
  private context;
@@ -1 +1 @@
1
- {"version":3,"file":"mic-input.d.ts","sourceRoot":"","sources":["../../src/mic-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAiB3C,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,MAAM,CAA2C;IAEzD,YAAY,OAAO,EAAE,WAAW,EAE/B;IAKK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAuB3B;IAGK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAU1B;CACF"}
1
+ {"version":3,"file":"mic-input.d.ts","sourceRoot":"","sources":["../../src/mic-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAiB9C,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,MAAM,CAA2C;IAEzD,YAAY,OAAO,EAAE,WAAW,EAE/B;IAKK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAuB3B;IAGK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAU1B;CACF"}
@@ -1,4 +1,4 @@
1
- import type { GossSession } from "./index";
1
+ import type { GossSession } from "./index.js";
2
2
  export declare class GossVideoTexture {
3
3
  private session;
4
4
  private name;
@@ -1 +1 @@
1
- {"version":3,"file":"video-texture.d.ts","sourceRoot":"","sources":["../../src/video-texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,GAAG,CAAkC;IAC7C,OAAO,CAAC,OAAO,CAAS;IAExB,YAAY,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAU1D;IAIK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAK3B;IAKD,IAAI,IAAI,IAAI,CAYX;IAGD,IAAI,IAAI,IAAI,CAKX;CACF"}
1
+ {"version":3,"file":"video-texture.d.ts","sourceRoot":"","sources":["../../src/video-texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM9C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,GAAG,CAAkC;IAC7C,OAAO,CAAC,OAAO,CAAS;IAExB,YAAY,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAU1D;IAIK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAK3B;IAKD,IAAI,IAAI,IAAI,CAYX;IAGD,IAAI,IAAI,IAAI,CAKX;CACF"}
@@ -1,4 +1,4 @@
1
- import type { GossSession } from "./index";
1
+ import type { GossSession } from "./index.js";
2
2
  interface XRRigidTransformLike {
3
3
  matrix: Float32Array;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../src/world.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAwC,MAAM,SAAS,CAAC;AAIjF,UAAU,oBAAoB;IAC5B,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,UAAU,UAAU;IAClB,gBAAgB,EAAE,YAAY,CAAC;CAChC;AAED,UAAU,gBAAgB;IACxB,SAAS,EAAE,oBAAoB,CAAC;IAChC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,UAAU,WAAW;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,YAAY;IACpB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,UAAU;IAClB,SAAS,EAAE,oBAAoB,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,cAAc,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAChE,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAAC;IACpE,cAAc,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IAClC,cAAc,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;CACpC;AAED,qBAAa,oBAAoB;IAKnB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJpC,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,MAAM,CAAK;IAEnB,YAA6B,OAAO,EAAE,WAAW,EAAI;IAIrD,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CA6ClF;IAED,OAAO,CAAC,KAAK;CAQd"}
1
+ {"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../src/world.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAwC,MAAM,YAAY,CAAC;AAIpF,UAAU,oBAAoB;IAC5B,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,UAAU,UAAU;IAClB,gBAAgB,EAAE,YAAY,CAAC;CAChC;AAED,UAAU,gBAAgB;IACxB,SAAS,EAAE,oBAAoB,CAAC;IAChC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,UAAU,WAAW;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,YAAY;IACpB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,UAAU;IAClB,SAAS,EAAE,oBAAoB,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,cAAc,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAChE,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAAC;IACpE,cAAc,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IAClC,cAAc,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;CACpC;AAED,qBAAa,oBAAoB;IAKnB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJpC,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,MAAM,CAAK;IAEnB,YAA6B,OAAO,EAAE,WAAW,EAAI;IAIrD,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CA6ClF;IAED,OAAO,CAAC,KAAK;CAQd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myzonerocks/gosslens",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Web SDK for the gosslens camera and AR engine, over the wasm core.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1,4 +1,4 @@
1
- import type { GossSession } from "./index";
1
+ import type { GossSession } from "./index.js";
2
2
 
3
3
  /// The worklet drains chunks the page posts it, so the audio thread
4
4
  /// never touches the wasm heap and the engine's graph-thread pull
package/src/index.ts CHANGED
@@ -163,6 +163,28 @@ export interface GossPoseOut {
163
163
 
164
164
  export const GOSS_HAND_LANDMARK_COUNT = 21;
165
165
  export const GOSS_HAND_MAX = 2;
166
+
167
+ export const GOSS_CAP_TRACKING = 1 << 0;
168
+ export const GOSS_CAP_SEGMENTATION = 1 << 1;
169
+ export const GOSS_CAP_ML_INFER = 1 << 2;
170
+ export const GOSS_CAP_DIFFUSION = 1 << 3;
171
+ export const GOSS_CAP_BEAUTY = 1 << 4;
172
+ export const GOSS_CAP_PHYSICS = 1 << 5;
173
+ export const GOSS_CAP_VIDEO_TEXTURES = 1 << 6;
174
+ export const GOSS_CAP_PHOTO_CAPTURE = 1 << 7;
175
+ export const GOSS_CAP_RECORDING = 1 << 8;
176
+ export const GOSS_CAP_FILE_IO = 1 << 9;
177
+
178
+ /// A hand handed to submitHands: the tracker's presence, handedness, gesture,
179
+ /// and GOSS_HAND_LANDMARK_COUNT * 3 frame-pixel landmark floats. The shape
180
+ /// GossHandTracker.process returns plugs in directly.
181
+ export interface GossHandInput {
182
+ presence?: number;
183
+ handedness?: number;
184
+ gesture?: number;
185
+ gestureScore?: number;
186
+ landmarks: Float32Array | number[];
187
+ }
166
188
  const HAND_RESULT_BYTES = 560;
167
189
  const HAND_ONE_BYTES = 268;
168
190
 
@@ -371,6 +393,13 @@ export class Gosslens {
371
393
  return this.version;
372
394
  }
373
395
 
396
+ /// Which capabilities this build compiled real, as GOSS_CAP_* bits. A stub
397
+ /// build shares the full one's filename and abi version, so check the rail
398
+ /// you need here before feeding real bytes to an enable call.
399
+ capabilities(): number {
400
+ return this.mod.ccall("goss_capabilities", "number", [], []) as number;
401
+ }
402
+
374
403
  /// Loads gosslens_web.js and checks its ABI major version. A
375
404
  /// dynamic import, not static: bun's bundler would otherwise inline
376
405
  /// this file, breaking Emscripten's own import.meta.url-relative
@@ -1635,7 +1664,7 @@ export class GossSession {
1635
1664
  this.mod.ccall("goss_session_brush_clear", "number", ["number"], [this.handle]);
1636
1665
  }
1637
1666
 
1638
- /// The brush preset the next stroke opens with: 0 pen, 1 highlighter, 2 marker, 3 neon.
1667
+ /// The brush preset the next stroke opens with: 0 pen, 1 highlighter, 2 marker, 3 neon, 4 stamp.
1639
1668
  setBrushMode(mode: number): void {
1640
1669
  this.mod.ccall("goss_session_brush_set_mode", "number", ["number", "number"], [this.handle, mode]);
1641
1670
  }
@@ -1879,6 +1908,34 @@ export class GossSession {
1879
1908
  this.mod.ccall("goss_session_submit_bodies", "number", ["number", "number", "number"], [this.handle, ptr, bodies.length]);
1880
1909
  }
1881
1910
 
1911
+ /// Submits the hands tracked this frame from the page's own tracker (the
1912
+ /// GossHandTracker's result plugs in directly), so hands.gesture and
1913
+ /// hands.pinch lenses and handJoint work with no in-engine worker; the
1914
+ /// submitted hands win over the worker while set. Null clears the path.
1915
+ submitHands(hands: { hands: GossHandInput[]; timestampUs?: bigint } | null): void {
1916
+ if (hands === null) {
1917
+ this.mod.ccall("goss_session_submit_hands", "number", ["number", "number"], [this.handle, 0]);
1918
+ return;
1919
+ }
1920
+ const ptr = this.scratch(HAND_RESULT_BYTES);
1921
+ this.mod.HEAPU8.fill(0, ptr, ptr + HAND_RESULT_BYTES);
1922
+ const dv = new DataView(this.mod.HEAPU8.buffer, ptr, HAND_RESULT_BYTES);
1923
+ dv.setBigInt64(8, hands.timestampUs ?? 0n, true);
1924
+ const list = hands.hands.slice(0, GOSS_HAND_MAX);
1925
+ dv.setUint32(16, list.length, true);
1926
+ for (let i = 0; i < list.length; i += 1) {
1927
+ const off = 24 + i * HAND_ONE_BYTES;
1928
+ const h = list[i]!;
1929
+ dv.setFloat32(off, h.presence ?? 1, true);
1930
+ dv.setFloat32(off + 4, h.handedness ?? 0.5, true);
1931
+ dv.setUint32(off + 8, h.gesture ?? 0, true);
1932
+ dv.setFloat32(off + 12, h.gestureScore ?? 0, true);
1933
+ const floats = Math.min(h.landmarks.length, GOSS_HAND_LANDMARK_COUNT * 3);
1934
+ for (let k = 0; k < floats; k += 1) dv.setFloat32(off + 16 + k * 4, h.landmarks[k]!, true);
1935
+ }
1936
+ this.mod.ccall("goss_session_submit_hands", "number", ["number", "number"], [this.handle, ptr]);
1937
+ }
1938
+
1882
1939
  /// Submits one frame's depth map from the host AR backend (WebXR depth-
1883
1940
  /// sensing): width by height metres per pixel, row major, with the near and
1884
1941
  /// far metres that bound it. An empty array clears it. Kept for depth
@@ -2039,6 +2096,75 @@ export class GossSession {
2039
2096
  return result;
2040
2097
  }
2041
2098
 
2099
+ /// Hands the engine one bundle asset's bytes under its manifest name ahead
2100
+ /// of activateLens, so a lens's models, references, and label files load
2101
+ /// from memory - the door the web's inference nodes activate through. An
2102
+ /// empty array removes a staged name; the engine keeps its own copy.
2103
+ provideLensAsset(name: string, bytes: Uint8Array): void {
2104
+ const id = new TextEncoder().encode(name);
2105
+ const idPtr = this.mod.ccall("goss_alloc", "number", ["number"], [id.length || 1]) as number;
2106
+ this.mod.HEAPU8.set(id, idPtr);
2107
+ let bytesPtr = 0;
2108
+ if (bytes.length > 0) {
2109
+ bytesPtr = this.mod.ccall("goss_alloc", "number", ["number"], [bytes.length]) as number;
2110
+ this.mod.HEAPU8.set(bytes, bytesPtr);
2111
+ }
2112
+ const args = ["number", "number", "number", "number", "number"];
2113
+ const status = this.mod.ccall("goss_session_provide_lens_asset", "number", args, [this.handle, idPtr, id.length, bytesPtr, bytes.length]) as number;
2114
+ if (bytesPtr !== 0) this.mod.ccall("goss_free", null, ["number", "number"], [bytesPtr, bytes.length]);
2115
+ this.mod.ccall("goss_free", null, ["number", "number"], [idPtr, id.length || 1]);
2116
+ if (status !== 0) throw new Error(`provideLensAsset failed (${status})`);
2117
+ }
2118
+
2119
+ /// One ml.infer node's whole published output tensor, by the node's id and
2120
+ /// tensor index, or null before the model's first publish or when the node
2121
+ /// or tensor does not exist. A length probe sizes the read, so detections,
2122
+ /// embeddings, and logits come back at their own length.
2123
+ mlOutput(nodeId: string, tensor = 0): Float32Array | null {
2124
+ const id = new TextEncoder().encode(nodeId);
2125
+ const idPtr = this.mod.ccall("goss_alloc", "number", ["number"], [id.length || 1]) as number;
2126
+ this.mod.HEAPU8.set(id, idPtr);
2127
+ const lenPtr = this.mod.ccall("goss_alloc", "number", ["number"], [4]) as number;
2128
+ const readLen = () => new DataView(this.mod.HEAPU8.buffer, lenPtr, 4).getUint32(0, true);
2129
+ const args = ["number", "number", "number", "number", "number", "number", "number"];
2130
+ this.mod.ccall("goss_session_ml_output", "number", args, [this.handle, idPtr, id.length, tensor, 0, 0, lenPtr]);
2131
+ const needed = readLen();
2132
+ let result: Float32Array | null = null;
2133
+ if (needed > 0) {
2134
+ const outPtr = this.mod.ccall("goss_alloc", "number", ["number"], [needed * 4]) as number;
2135
+ const status = this.mod.ccall("goss_session_ml_output", "number", args, [this.handle, idPtr, id.length, tensor, outPtr, needed, lenPtr]) as number;
2136
+ if (status === 0) result = this.mod.HEAPF32.slice(outPtr >> 2, (outPtr >> 2) + needed);
2137
+ this.mod.ccall("goss_free", null, ["number", "number"], [outPtr, needed * 4]);
2138
+ }
2139
+ this.mod.ccall("goss_free", null, ["number", "number"], [lenPtr, 4]);
2140
+ this.mod.ccall("goss_free", null, ["number", "number"], [idPtr, id.length || 1]);
2141
+ return result;
2142
+ }
2143
+
2144
+ /// One ml.infer node's mask-bound output resampled to the fixed
2145
+ /// segmentation plane, or null when the node has no mask binding or the
2146
+ /// model has not published yet.
2147
+ mlMask(nodeId: string): Float32Array | null {
2148
+ const id = new TextEncoder().encode(nodeId);
2149
+ const idPtr = this.mod.ccall("goss_alloc", "number", ["number"], [id.length || 1]) as number;
2150
+ this.mod.HEAPU8.set(id, idPtr);
2151
+ const lenPtr = this.mod.ccall("goss_alloc", "number", ["number"], [4]) as number;
2152
+ const readLen = () => new DataView(this.mod.HEAPU8.buffer, lenPtr, 4).getUint32(0, true);
2153
+ const args = ["number", "number", "number", "number", "number", "number"];
2154
+ this.mod.ccall("goss_session_ml_mask", "number", args, [this.handle, idPtr, id.length, 0, 0, lenPtr]);
2155
+ const needed = readLen();
2156
+ let result: Float32Array | null = null;
2157
+ if (needed > 0) {
2158
+ const outPtr = this.mod.ccall("goss_alloc", "number", ["number"], [needed * 4]) as number;
2159
+ const status = this.mod.ccall("goss_session_ml_mask", "number", args, [this.handle, idPtr, id.length, outPtr, needed, lenPtr]) as number;
2160
+ if (status === 0) result = this.mod.HEAPF32.slice(outPtr >> 2, (outPtr >> 2) + needed);
2161
+ this.mod.ccall("goss_free", null, ["number", "number"], [outPtr, needed * 4]);
2162
+ }
2163
+ this.mod.ccall("goss_free", null, ["number", "number"], [lenPtr, 4]);
2164
+ this.mod.ccall("goss_free", null, ["number", "number"], [idPtr, id.length || 1]);
2165
+ return result;
2166
+ }
2167
+
2042
2168
  /// The recent diarized caption segment at index (0 the newest), or null when
2043
2169
  /// the index is past the segments held: the times it spanned, the speaker who
2044
2170
  /// spoke it, and its text, a speaker-tagged transcript for diarized subtitles.
@@ -2852,8 +2978,8 @@ export class GossPreviewSession {
2852
2978
  }
2853
2979
  }
2854
2980
 
2855
- export { GossWebXRWorldSource } from "./world";
2856
- export type { GossXRFrameLike } from "./world";
2857
- export { GossAudioOutput } from "./audio-output";
2858
- export { GossMicInput } from "./mic-input";
2859
- export { GossVideoTexture } from "./video-texture";
2981
+ export { GossWebXRWorldSource } from "./world.js";
2982
+ export type { GossXRFrameLike } from "./world.js";
2983
+ export { GossAudioOutput } from "./audio-output.js";
2984
+ export { GossMicInput } from "./mic-input.js";
2985
+ export { GossVideoTexture } from "./video-texture.js";
package/src/mic-input.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { GossSession } from "./index";
1
+ import type { GossSession } from "./index.js";
2
2
 
3
3
  /// Captures the microphone and feeds it to the engine's audio analysis,
4
4
  /// so the level and beat triggers a lens reads fire on web the same way
@@ -1,4 +1,4 @@
1
- import type { GossSession } from "./index";
1
+ import type { GossSession } from "./index.js";
2
2
 
3
3
  /// Plays an MP4 through a hidden video element, the browser's own
4
4
  /// decoder, and feeds each frame to a named engine source a lens
package/src/world.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  /// planes, and tracked anchors off each XR frame and feeds them into
3
3
  /// the session. The page owns the XR session; this source only reads.
4
4
 
5
- import type { GossSession, GossWorldPlane, GossWorldAnchorInput } from "./index";
5
+ import type { GossSession, GossWorldPlane, GossWorldAnchorInput } from "./index.js";
6
6
 
7
7
  // WebXR's types live outside the DOM lib; the narrow slice this source
8
8
  // reads is declared here so no type package enters the build.