cereb 0.1.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.
- package/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/browser/dom-event/dom-event.d.ts +3 -0
- package/dist/browser/dom-event/dom-event.d.ts.map +1 -0
- package/dist/browser/dom-event/index.d.ts +5 -0
- package/dist/browser/dom-event/index.d.ts.map +1 -0
- package/dist/browser/dom-event/mouse-events.d.ts +3 -0
- package/dist/browser/dom-event/mouse-events.d.ts.map +1 -0
- package/dist/browser/dom-event/pointer-events.d.ts +3 -0
- package/dist/browser/dom-event/pointer-events.d.ts.map +1 -0
- package/dist/browser/dom-event/touch-events.d.ts +3 -0
- package/dist/browser/dom-event/touch-events.d.ts.map +1 -0
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/single-pointer/index.d.ts +5 -0
- package/dist/browser/single-pointer/index.d.ts.map +1 -0
- package/dist/browser/single-pointer/mouse-emitter.d.ts +15 -0
- package/dist/browser/single-pointer/mouse-emitter.d.ts.map +1 -0
- package/dist/browser/single-pointer/mouse.d.ts +4 -0
- package/dist/browser/single-pointer/mouse.d.ts.map +1 -0
- package/dist/browser/single-pointer/pointer-emitter.d.ts +19 -0
- package/dist/browser/single-pointer/pointer-emitter.d.ts.map +1 -0
- package/dist/browser/single-pointer/pointer.d.ts +4 -0
- package/dist/browser/single-pointer/pointer.d.ts.map +1 -0
- package/dist/browser/single-pointer/pool.d.ts +4 -0
- package/dist/browser/single-pointer/pool.d.ts.map +1 -0
- package/dist/browser/single-pointer/single-pointer.d.ts +22 -0
- package/dist/browser/single-pointer/single-pointer.d.ts.map +1 -0
- package/dist/browser/single-pointer/touch-emitter.d.ts +15 -0
- package/dist/browser/single-pointer/touch-emitter.d.ts.map +1 -0
- package/dist/browser/single-pointer/touch.d.ts +4 -0
- package/dist/browser/single-pointer/touch.d.ts.map +1 -0
- package/dist/browser/single-pointer/types.d.ts +5 -0
- package/dist/browser/single-pointer/types.d.ts.map +1 -0
- package/dist/factory/defer.d.ts +3 -0
- package/dist/factory/defer.d.ts.map +1 -0
- package/dist/factory/empty.d.ts +3 -0
- package/dist/factory/empty.d.ts.map +1 -0
- package/dist/factory/from-promise.d.ts +3 -0
- package/dist/factory/from-promise.d.ts.map +1 -0
- package/dist/factory/from.d.ts +3 -0
- package/dist/factory/from.d.ts.map +1 -0
- package/dist/factory/index.d.ts +10 -0
- package/dist/factory/index.d.ts.map +1 -0
- package/dist/factory/interval.d.ts +3 -0
- package/dist/factory/interval.d.ts.map +1 -0
- package/dist/factory/never.d.ts +3 -0
- package/dist/factory/never.d.ts.map +1 -0
- package/dist/factory/of.d.ts +3 -0
- package/dist/factory/of.d.ts.map +1 -0
- package/dist/factory/throw-error.d.ts +3 -0
- package/dist/factory/throw-error.d.ts.map +1 -0
- package/dist/factory/timer.d.ts +3 -0
- package/dist/factory/timer.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/object-pool.d.ts +15 -0
- package/dist/internal/object-pool.d.ts.map +1 -0
- package/dist/internal/subject.d.ts +17 -0
- package/dist/internal/subject.d.ts.map +1 -0
- package/dist/ochestrations/compose.d.ts +8 -0
- package/dist/ochestrations/compose.d.ts.map +1 -0
- package/dist/ochestrations/index.d.ts +3 -0
- package/dist/ochestrations/index.d.ts.map +1 -0
- package/dist/ochestrations/pipe.d.ts +12 -0
- package/dist/ochestrations/pipe.d.ts.map +1 -0
- package/dist/operators/buffer.d.ts +5 -0
- package/dist/operators/buffer.d.ts.map +1 -0
- package/dist/operators/combine.d.ts +8 -0
- package/dist/operators/combine.d.ts.map +1 -0
- package/dist/operators/debounce.d.ts +3 -0
- package/dist/operators/debounce.d.ts.map +1 -0
- package/dist/operators/distinct.d.ts +48 -0
- package/dist/operators/distinct.d.ts.map +1 -0
- package/dist/operators/filter.d.ts +3 -0
- package/dist/operators/filter.d.ts.map +1 -0
- package/dist/operators/index.d.ts +13 -0
- package/dist/operators/index.d.ts.map +1 -0
- package/dist/operators/map.d.ts +3 -0
- package/dist/operators/map.d.ts.map +1 -0
- package/dist/operators/merge.d.ts +4 -0
- package/dist/operators/merge.d.ts.map +1 -0
- package/dist/operators/share.d.ts +4 -0
- package/dist/operators/share.d.ts.map +1 -0
- package/dist/operators/skip.d.ts +5 -0
- package/dist/operators/skip.d.ts.map +1 -0
- package/dist/operators/spy.d.ts +29 -0
- package/dist/operators/spy.d.ts.map +1 -0
- package/dist/operators/take.d.ts +27 -0
- package/dist/operators/take.d.ts.map +1 -0
- package/dist/operators/throttle.d.ts +4 -0
- package/dist/operators/throttle.d.ts.map +1 -0
- package/dist/operators.cjs +2 -0
- package/dist/operators.cjs.map +1 -0
- package/dist/operators.d.ts +2 -0
- package/dist/operators.d.ts.map +1 -0
- package/dist/operators.js +444 -0
- package/dist/operators.js.map +1 -0
- package/dist/pointer-CX9qwBVm.cjs +2 -0
- package/dist/pointer-CX9qwBVm.cjs.map +1 -0
- package/dist/pointer-Cq2B2vwv.js +111 -0
- package/dist/pointer-Cq2B2vwv.js.map +1 -0
- package/dist/pool-CM9teIjt.js +42 -0
- package/dist/pool-CM9teIjt.js.map +1 -0
- package/dist/pool-Dr67Mz_1.cjs +2 -0
- package/dist/pool-Dr67Mz_1.cjs.map +1 -0
- package/dist/single-pointer/mouse.cjs +2 -0
- package/dist/single-pointer/mouse.cjs.map +1 -0
- package/dist/single-pointer/mouse.d.ts +2 -0
- package/dist/single-pointer/mouse.js +74 -0
- package/dist/single-pointer/mouse.js.map +1 -0
- package/dist/single-pointer/pointer.cjs +2 -0
- package/dist/single-pointer/pointer.cjs.map +1 -0
- package/dist/single-pointer/pointer.d.ts +2 -0
- package/dist/single-pointer/pointer.js +7 -0
- package/dist/single-pointer/pointer.js.map +1 -0
- package/dist/single-pointer/touch.cjs +2 -0
- package/dist/single-pointer/touch.cjs.map +1 -0
- package/dist/single-pointer/touch.d.ts +2 -0
- package/dist/single-pointer/touch.js +79 -0
- package/dist/single-pointer/touch.js.map +1 -0
- package/dist/stream/stream.d.ts +28 -0
- package/dist/stream/stream.d.ts.map +1 -0
- package/dist/stream-CDK0RZPi.js +33 -0
- package/dist/stream-CDK0RZPi.js.map +1 -0
- package/dist/stream-Cp6eCZs2.cjs +2 -0
- package/dist/stream-Cp6eCZs2.cjs.map +1 -0
- package/dist/types-Ccnqx90M.js +22 -0
- package/dist/types-Ccnqx90M.js.map +1 -0
- package/dist/types-DkXpfiI3.cjs +2 -0
- package/dist/types-DkXpfiI3.cjs.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function a(e, i, o = {}) {
|
|
2
|
+
const { initialSize: r = 0, maxSize: s = 100 } = o, n = [];
|
|
3
|
+
for (let t = 0; t < r; t++)
|
|
4
|
+
n.push(e());
|
|
5
|
+
return {
|
|
6
|
+
get size() {
|
|
7
|
+
return n.length;
|
|
8
|
+
},
|
|
9
|
+
acquire() {
|
|
10
|
+
return n.length > 0 ? n.pop() : e();
|
|
11
|
+
},
|
|
12
|
+
release(t) {
|
|
13
|
+
n.length < s && (i(t), n.push(t));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function u() {
|
|
18
|
+
return {
|
|
19
|
+
phase: "move",
|
|
20
|
+
x: 0,
|
|
21
|
+
y: 0,
|
|
22
|
+
pageX: 0,
|
|
23
|
+
pageY: 0,
|
|
24
|
+
pointerType: "unknown",
|
|
25
|
+
button: "none",
|
|
26
|
+
pressure: 0.5,
|
|
27
|
+
timestamp: 0,
|
|
28
|
+
deviceId: ""
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function l(e) {
|
|
32
|
+
e.phase = "move", e.x = 0, e.y = 0, e.pageX = 0, e.pageY = 0, e.pointerType = "unknown", e.button = "none", e.pressure = 0.5, e.timestamp = 0, e.deviceId = "";
|
|
33
|
+
}
|
|
34
|
+
const c = a(u, l, {
|
|
35
|
+
initialSize: 20,
|
|
36
|
+
maxSize: 100
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
a as c,
|
|
40
|
+
c as s
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=pool-CM9teIjt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-CM9teIjt.js","sources":["../src/internal/object-pool.ts","../src/browser/single-pointer/single-pointer.ts","../src/browser/single-pointer/pool.ts"],"sourcesContent":["export interface ObjectPool<T> {\n acquire(): T;\n release(item: T): void;\n readonly size: number;\n}\n\nexport interface ObjectPoolOptions {\n initialSize?: number;\n maxSize?: number;\n}\n\n/**\n * Generic object pool for reusing objects and reducing GC pressure.\n * Useful for high-frequency scenarios like pointer/touch events.\n */\nexport function createObjectPool<T>(\n create: () => T,\n reset: (item: T) => void,\n options: ObjectPoolOptions = {},\n): ObjectPool<T> {\n const { initialSize = 0, maxSize = 100 } = options;\n const pool: T[] = [];\n\n for (let i = 0; i < initialSize; i++) {\n pool.push(create());\n }\n\n return {\n get size() {\n return pool.length;\n },\n\n acquire(): T {\n if (pool.length > 0) {\n return pool.pop()!;\n }\n return create();\n },\n\n release(item: T): void {\n if (pool.length < maxSize) {\n reset(item);\n pool.push(item);\n }\n },\n };\n}\n","import type { PointerButton, PointerPhase, PointerType } from \"./types.js\";\n\n/**\n * Normalized pointer data representing a single point of contact.\n * Abstracts away differences between mouse, touch, and pointer events.\n */\nexport interface SinglePointer {\n phase: PointerPhase;\n x: number;\n y: number;\n pageX: number;\n pageY: number;\n pointerType: PointerType;\n button: PointerButton;\n /** 0.0 ~ 1.0, default 0.5 if unsupported */\n pressure: number;\n timestamp: number;\n deviceId: string;\n}\n\nexport function createDefaultSinglePointer(): SinglePointer {\n return {\n phase: \"move\",\n x: 0,\n y: 0,\n pageX: 0,\n pageY: 0,\n pointerType: \"unknown\",\n button: \"none\",\n pressure: 0.5,\n timestamp: 0,\n deviceId: \"\",\n };\n}\n\nexport function resetSinglePointer(p: SinglePointer): void {\n p.phase = \"move\";\n p.x = 0;\n p.y = 0;\n p.pageX = 0;\n p.pageY = 0;\n p.pointerType = \"unknown\";\n p.button = \"none\";\n p.pressure = 0.5;\n p.timestamp = 0;\n p.deviceId = \"\";\n}\n\nexport function isSinglePointer(value: unknown): value is SinglePointer {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"phase\" in value &&\n \"x\" in value &&\n \"y\" in value &&\n \"pointerType\" in value\n );\n}\n","import { createObjectPool } from \"../../internal/object-pool.js\";\nimport {\n createDefaultSinglePointer,\n resetSinglePointer,\n type SinglePointer,\n} from \"./single-pointer.js\";\n\nexport const singlePointerPool = createObjectPool(createDefaultSinglePointer, resetSinglePointer, {\n initialSize: 20,\n maxSize: 100,\n});\n\nexport function releaseSinglePointer(pointer: SinglePointer): void {\n singlePointerPool.release(pointer);\n}\n"],"names":["createObjectPool","create","reset","options","initialSize","maxSize","pool","i","item","createDefaultSinglePointer","resetSinglePointer","p","singlePointerPool"],"mappings":"AAeO,SAASA,EACdC,GACAC,GACAC,IAA6B,CAAA,GACd;AACf,QAAM,EAAE,aAAAC,IAAc,GAAG,SAAAC,IAAU,QAAQF,GACrCG,IAAY,CAAA;AAElB,WAASC,IAAI,GAAGA,IAAIH,GAAaG;AAC/B,IAAAD,EAAK,KAAKL,GAAQ;AAGpB,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAOK,EAAK;AAAA,IACd;AAAA,IAEA,UAAa;AACX,aAAIA,EAAK,SAAS,IACTA,EAAK,IAAA,IAEPL,EAAA;AAAA,IACT;AAAA,IAEA,QAAQO,GAAe;AACrB,MAAIF,EAAK,SAASD,MAChBH,EAAMM,CAAI,GACVF,EAAK,KAAKE,CAAI;AAAA,IAElB;AAAA,EAAA;AAEJ;AC1BO,SAASC,IAA4C;AAC1D,SAAO;AAAA,IACL,OAAO;AAAA,IACP,GAAG;AAAA,IACH,GAAG;AAAA,IACH,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,EAAA;AAEd;AAEO,SAASC,EAAmBC,GAAwB;AACzD,EAAAA,EAAE,QAAQ,QACVA,EAAE,IAAI,GACNA,EAAE,IAAI,GACNA,EAAE,QAAQ,GACVA,EAAE,QAAQ,GACVA,EAAE,cAAc,WAChBA,EAAE,SAAS,QACXA,EAAE,WAAW,KACbA,EAAE,YAAY,GACdA,EAAE,WAAW;AACf;ACvCO,MAAMC,IAAoBZ,EAAiBS,GAA4BC,GAAoB;AAAA,EAChG,aAAa;AAAA,EACb,SAAS;AACX,CAAC;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";function i(e,o,r={}){const{initialSize:s=0,maxSize:u=100}=r,n=[];for(let t=0;t<s;t++)n.push(e());return{get size(){return n.length},acquire(){return n.length>0?n.pop():e()},release(t){n.length<u&&(o(t),n.push(t))}}}function a(){return{phase:"move",x:0,y:0,pageX:0,pageY:0,pointerType:"unknown",button:"none",pressure:.5,timestamp:0,deviceId:""}}function l(e){e.phase="move",e.x=0,e.y=0,e.pageX=0,e.pageY=0,e.pointerType="unknown",e.button="none",e.pressure=.5,e.timestamp=0,e.deviceId=""}const c=i(a,l,{initialSize:20,maxSize:100});exports.createObjectPool=i;exports.singlePointerPool=c;
|
|
2
|
+
//# sourceMappingURL=pool-Dr67Mz_1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-Dr67Mz_1.cjs","sources":["../src/internal/object-pool.ts","../src/browser/single-pointer/single-pointer.ts","../src/browser/single-pointer/pool.ts"],"sourcesContent":["export interface ObjectPool<T> {\n acquire(): T;\n release(item: T): void;\n readonly size: number;\n}\n\nexport interface ObjectPoolOptions {\n initialSize?: number;\n maxSize?: number;\n}\n\n/**\n * Generic object pool for reusing objects and reducing GC pressure.\n * Useful for high-frequency scenarios like pointer/touch events.\n */\nexport function createObjectPool<T>(\n create: () => T,\n reset: (item: T) => void,\n options: ObjectPoolOptions = {},\n): ObjectPool<T> {\n const { initialSize = 0, maxSize = 100 } = options;\n const pool: T[] = [];\n\n for (let i = 0; i < initialSize; i++) {\n pool.push(create());\n }\n\n return {\n get size() {\n return pool.length;\n },\n\n acquire(): T {\n if (pool.length > 0) {\n return pool.pop()!;\n }\n return create();\n },\n\n release(item: T): void {\n if (pool.length < maxSize) {\n reset(item);\n pool.push(item);\n }\n },\n };\n}\n","import type { PointerButton, PointerPhase, PointerType } from \"./types.js\";\n\n/**\n * Normalized pointer data representing a single point of contact.\n * Abstracts away differences between mouse, touch, and pointer events.\n */\nexport interface SinglePointer {\n phase: PointerPhase;\n x: number;\n y: number;\n pageX: number;\n pageY: number;\n pointerType: PointerType;\n button: PointerButton;\n /** 0.0 ~ 1.0, default 0.5 if unsupported */\n pressure: number;\n timestamp: number;\n deviceId: string;\n}\n\nexport function createDefaultSinglePointer(): SinglePointer {\n return {\n phase: \"move\",\n x: 0,\n y: 0,\n pageX: 0,\n pageY: 0,\n pointerType: \"unknown\",\n button: \"none\",\n pressure: 0.5,\n timestamp: 0,\n deviceId: \"\",\n };\n}\n\nexport function resetSinglePointer(p: SinglePointer): void {\n p.phase = \"move\";\n p.x = 0;\n p.y = 0;\n p.pageX = 0;\n p.pageY = 0;\n p.pointerType = \"unknown\";\n p.button = \"none\";\n p.pressure = 0.5;\n p.timestamp = 0;\n p.deviceId = \"\";\n}\n\nexport function isSinglePointer(value: unknown): value is SinglePointer {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"phase\" in value &&\n \"x\" in value &&\n \"y\" in value &&\n \"pointerType\" in value\n );\n}\n","import { createObjectPool } from \"../../internal/object-pool.js\";\nimport {\n createDefaultSinglePointer,\n resetSinglePointer,\n type SinglePointer,\n} from \"./single-pointer.js\";\n\nexport const singlePointerPool = createObjectPool(createDefaultSinglePointer, resetSinglePointer, {\n initialSize: 20,\n maxSize: 100,\n});\n\nexport function releaseSinglePointer(pointer: SinglePointer): void {\n singlePointerPool.release(pointer);\n}\n"],"names":["createObjectPool","create","reset","options","initialSize","maxSize","pool","i","item","createDefaultSinglePointer","resetSinglePointer","p","singlePointerPool"],"mappings":"aAeO,SAASA,EACdC,EACAC,EACAC,EAA6B,CAAA,EACd,CACf,KAAM,CAAE,YAAAC,EAAc,EAAG,QAAAC,EAAU,KAAQF,EACrCG,EAAY,CAAA,EAElB,QAASC,EAAI,EAAGA,EAAIH,EAAaG,IAC/BD,EAAK,KAAKL,GAAQ,EAGpB,MAAO,CACL,IAAI,MAAO,CACT,OAAOK,EAAK,MACd,EAEA,SAAa,CACX,OAAIA,EAAK,OAAS,EACTA,EAAK,IAAA,EAEPL,EAAA,CACT,EAEA,QAAQO,EAAe,CACjBF,EAAK,OAASD,IAChBH,EAAMM,CAAI,EACVF,EAAK,KAAKE,CAAI,EAElB,CAAA,CAEJ,CC1BO,SAASC,GAA4C,CAC1D,MAAO,CACL,MAAO,OACP,EAAG,EACH,EAAG,EACH,MAAO,EACP,MAAO,EACP,YAAa,UACb,OAAQ,OACR,SAAU,GACV,UAAW,EACX,SAAU,EAAA,CAEd,CAEO,SAASC,EAAmBC,EAAwB,CACzDA,EAAE,MAAQ,OACVA,EAAE,EAAI,EACNA,EAAE,EAAI,EACNA,EAAE,MAAQ,EACVA,EAAE,MAAQ,EACVA,EAAE,YAAc,UAChBA,EAAE,OAAS,OACXA,EAAE,SAAW,GACbA,EAAE,UAAY,EACdA,EAAE,SAAW,EACf,CCvCO,MAAMC,EAAoBZ,EAAiBS,EAA4BC,EAAoB,CAChG,YAAa,GACb,QAAS,GACX,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("../stream-Cp6eCZs2.cjs"),l=require("../pool-Dr67Mz_1.cjs"),m=require("../types-DkXpfiI3.cjs");function d(a={}){const{deviceId:u,pooling:r=!1}=a;let t=null,n=u??"";function s(){return r?l.singlePointerPool.acquire():{phase:"move",x:0,y:0,pageX:0,pageY:0,pointerType:"mouse",button:"none",pressure:.5,timestamp:0,deviceId:""}}function c(){t&&r&&l.singlePointerPool.release(t),t=null}return{process(o){let i,p;switch(o.type){case"mousedown":i="start",p=m.toPointerButton(o.button);break;case"mouseup":i="end",p=m.toPointerButton(o.button);break;default:i="move",p="none"}const e=s();return e.timestamp=performance.now(),e.deviceId=n||(n="mouse-device"),e.phase=i,e.x=o.clientX,e.y=o.clientY,e.pageX=o.pageX,e.pageY=o.pageY,e.pointerType="mouse",e.button=p,e.pressure=i==="move"&&o.buttons===0?0:.5,c(),t=e,e},get isActive(){return t!==null},reset(){c(),n=u??""},dispose(){this.reset()}}}function b(a={}){return u=>g.createStream(r=>{const t=d(a),n=u.subscribe({next(s){const c=t.process(s);r.next(c)},error(s){r.error?.(s)},complete(){r.complete?.()}});return()=>{n(),t.dispose()}})}exports.createMouseEmitter=d;exports.mouseToSinglePointer=b;
|
|
2
|
+
//# sourceMappingURL=mouse.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mouse.cjs","sources":["../../src/browser/single-pointer/mouse-emitter.ts"],"sourcesContent":["import type { Operator } from \"../../stream/stream.js\";\nimport { createStream } from \"../../stream/stream.js\";\nimport { singlePointerPool } from \"./pool.js\";\nimport type { SinglePointer } from \"./single-pointer.js\";\nimport type { PointerButton, PointerPhase } from \"./types.js\";\nimport { toPointerButton } from \"./types.js\";\n\nexport interface MouseEmitterOptions {\n deviceId?: string;\n pooling?: boolean;\n}\n\nexport interface MouseEmitter {\n process(event: MouseEvent): SinglePointer;\n readonly isActive: boolean;\n reset(): void;\n dispose(): void;\n}\n\nexport function createMouseEmitter(options: MouseEmitterOptions = {}): MouseEmitter {\n const { deviceId: customDeviceId, pooling = false } = options;\n let current: SinglePointer | null = null;\n let resolvedDeviceId = customDeviceId ?? \"\";\n\n function acquirePointer(): SinglePointer {\n if (pooling) {\n return singlePointerPool.acquire();\n }\n return {\n phase: \"move\",\n x: 0,\n y: 0,\n pageX: 0,\n pageY: 0,\n pointerType: \"mouse\",\n button: \"none\",\n pressure: 0.5,\n timestamp: 0,\n deviceId: \"\",\n };\n }\n\n function releaseCurrentPointer(): void {\n if (current && pooling) {\n singlePointerPool.release(current);\n }\n current = null;\n }\n\n return {\n process(event: MouseEvent): SinglePointer {\n let phase: PointerPhase;\n let button: PointerButton;\n switch (event.type) {\n case \"mousedown\":\n phase = \"start\";\n button = toPointerButton(event.button);\n break;\n case \"mouseup\":\n phase = \"end\";\n button = toPointerButton(event.button);\n break;\n default:\n phase = \"move\";\n button = \"none\";\n }\n\n const pointer = acquirePointer();\n\n pointer.timestamp = performance.now();\n pointer.deviceId = resolvedDeviceId || (resolvedDeviceId = \"mouse-device\");\n pointer.phase = phase;\n pointer.x = event.clientX;\n pointer.y = event.clientY;\n pointer.pageX = event.pageX;\n pointer.pageY = event.pageY;\n pointer.pointerType = \"mouse\";\n pointer.button = button;\n pointer.pressure = phase === \"move\" && event.buttons === 0 ? 0 : 0.5;\n\n releaseCurrentPointer();\n current = pointer;\n return pointer;\n },\n\n get isActive(): boolean {\n return current !== null;\n },\n\n reset(): void {\n releaseCurrentPointer();\n resolvedDeviceId = customDeviceId ?? \"\";\n },\n\n dispose(): void {\n this.reset();\n },\n };\n}\n\nexport function mouseToSinglePointer(\n options: MouseEmitterOptions = {},\n): Operator<MouseEvent, SinglePointer> {\n return (source) =>\n createStream((observer) => {\n const emitter = createMouseEmitter(options);\n\n const unsub = source.subscribe({\n next(event) {\n const pointer = emitter.process(event);\n observer.next(pointer);\n },\n error(err) {\n observer.error?.(err);\n },\n complete() {\n observer.complete?.();\n },\n });\n\n return () => {\n unsub();\n emitter.dispose();\n };\n });\n}\n"],"names":["createMouseEmitter","options","customDeviceId","pooling","current","resolvedDeviceId","acquirePointer","singlePointerPool","releaseCurrentPointer","event","phase","button","toPointerButton","pointer","mouseToSinglePointer","source","createStream","observer","emitter","unsub","err"],"mappings":"+LAmBO,SAASA,EAAmBC,EAA+B,GAAkB,CAClF,KAAM,CAAE,SAAUC,EAAgB,QAAAC,EAAU,IAAUF,EACtD,IAAIG,EAAgC,KAChCC,EAAmBH,GAAkB,GAEzC,SAASI,GAAgC,CACvC,OAAIH,EACKI,EAAAA,kBAAkB,QAAA,EAEpB,CACL,MAAO,OACP,EAAG,EACH,EAAG,EACH,MAAO,EACP,MAAO,EACP,YAAa,QACb,OAAQ,OACR,SAAU,GACV,UAAW,EACX,SAAU,EAAA,CAEd,CAEA,SAASC,GAA8B,CACjCJ,GAAWD,GACbI,EAAAA,kBAAkB,QAAQH,CAAO,EAEnCA,EAAU,IACZ,CAEA,MAAO,CACL,QAAQK,EAAkC,CACxC,IAAIC,EACAC,EACJ,OAAQF,EAAM,KAAA,CACZ,IAAK,YACHC,EAAQ,QACRC,EAASC,EAAAA,gBAAgBH,EAAM,MAAM,EACrC,MACF,IAAK,UACHC,EAAQ,MACRC,EAASC,EAAAA,gBAAgBH,EAAM,MAAM,EACrC,MACF,QACEC,EAAQ,OACRC,EAAS,MAAA,CAGb,MAAME,EAAUP,EAAA,EAEhB,OAAAO,EAAQ,UAAY,YAAY,IAAA,EAChCA,EAAQ,SAAWR,IAAqBA,EAAmB,gBAC3DQ,EAAQ,MAAQH,EAChBG,EAAQ,EAAIJ,EAAM,QAClBI,EAAQ,EAAIJ,EAAM,QAClBI,EAAQ,MAAQJ,EAAM,MACtBI,EAAQ,MAAQJ,EAAM,MACtBI,EAAQ,YAAc,QACtBA,EAAQ,OAASF,EACjBE,EAAQ,SAAWH,IAAU,QAAUD,EAAM,UAAY,EAAI,EAAI,GAEjED,EAAA,EACAJ,EAAUS,EACHA,CACT,EAEA,IAAI,UAAoB,CACtB,OAAOT,IAAY,IACrB,EAEA,OAAc,CACZI,EAAA,EACAH,EAAmBH,GAAkB,EACvC,EAEA,SAAgB,CACd,KAAK,MAAA,CACP,CAAA,CAEJ,CAEO,SAASY,EACdb,EAA+B,GACM,CACrC,OAAQc,GACNC,eAAcC,GAAa,CACzB,MAAMC,EAAUlB,EAAmBC,CAAO,EAEpCkB,EAAQJ,EAAO,UAAU,CAC7B,KAAKN,EAAO,CACV,MAAMI,EAAUK,EAAQ,QAAQT,CAAK,EACrCQ,EAAS,KAAKJ,CAAO,CACvB,EACA,MAAMO,EAAK,CACTH,EAAS,QAAQG,CAAG,CACtB,EACA,UAAW,CACTH,EAAS,WAAA,CACX,CAAA,CACD,EAED,MAAO,IAAM,CACXE,EAAA,EACAD,EAAQ,QAAA,CACV,CACF,CAAC,CACL"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { c as d } from "../stream-CDK0RZPi.js";
|
|
2
|
+
import { s as m } from "../pool-CM9teIjt.js";
|
|
3
|
+
import { t as l } from "../types-Ccnqx90M.js";
|
|
4
|
+
function f(a = {}) {
|
|
5
|
+
const { deviceId: u, pooling: r = !1 } = a;
|
|
6
|
+
let t = null, n = u ?? "";
|
|
7
|
+
function s() {
|
|
8
|
+
return r ? m.acquire() : {
|
|
9
|
+
phase: "move",
|
|
10
|
+
x: 0,
|
|
11
|
+
y: 0,
|
|
12
|
+
pageX: 0,
|
|
13
|
+
pageY: 0,
|
|
14
|
+
pointerType: "mouse",
|
|
15
|
+
button: "none",
|
|
16
|
+
pressure: 0.5,
|
|
17
|
+
timestamp: 0,
|
|
18
|
+
deviceId: ""
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function c() {
|
|
22
|
+
t && r && m.release(t), t = null;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
process(o) {
|
|
26
|
+
let i, p;
|
|
27
|
+
switch (o.type) {
|
|
28
|
+
case "mousedown":
|
|
29
|
+
i = "start", p = l(o.button);
|
|
30
|
+
break;
|
|
31
|
+
case "mouseup":
|
|
32
|
+
i = "end", p = l(o.button);
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
i = "move", p = "none";
|
|
36
|
+
}
|
|
37
|
+
const e = s();
|
|
38
|
+
return e.timestamp = performance.now(), e.deviceId = n || (n = "mouse-device"), e.phase = i, e.x = o.clientX, e.y = o.clientY, e.pageX = o.pageX, e.pageY = o.pageY, e.pointerType = "mouse", e.button = p, e.pressure = i === "move" && o.buttons === 0 ? 0 : 0.5, c(), t = e, e;
|
|
39
|
+
},
|
|
40
|
+
get isActive() {
|
|
41
|
+
return t !== null;
|
|
42
|
+
},
|
|
43
|
+
reset() {
|
|
44
|
+
c(), n = u ?? "";
|
|
45
|
+
},
|
|
46
|
+
dispose() {
|
|
47
|
+
this.reset();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function h(a = {}) {
|
|
52
|
+
return (u) => d((r) => {
|
|
53
|
+
const t = f(a), n = u.subscribe({
|
|
54
|
+
next(s) {
|
|
55
|
+
const c = t.process(s);
|
|
56
|
+
r.next(c);
|
|
57
|
+
},
|
|
58
|
+
error(s) {
|
|
59
|
+
r.error?.(s);
|
|
60
|
+
},
|
|
61
|
+
complete() {
|
|
62
|
+
r.complete?.();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return () => {
|
|
66
|
+
n(), t.dispose();
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
f as createMouseEmitter,
|
|
72
|
+
h as mouseToSinglePointer
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=mouse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mouse.js","sources":["../../src/browser/single-pointer/mouse-emitter.ts"],"sourcesContent":["import type { Operator } from \"../../stream/stream.js\";\nimport { createStream } from \"../../stream/stream.js\";\nimport { singlePointerPool } from \"./pool.js\";\nimport type { SinglePointer } from \"./single-pointer.js\";\nimport type { PointerButton, PointerPhase } from \"./types.js\";\nimport { toPointerButton } from \"./types.js\";\n\nexport interface MouseEmitterOptions {\n deviceId?: string;\n pooling?: boolean;\n}\n\nexport interface MouseEmitter {\n process(event: MouseEvent): SinglePointer;\n readonly isActive: boolean;\n reset(): void;\n dispose(): void;\n}\n\nexport function createMouseEmitter(options: MouseEmitterOptions = {}): MouseEmitter {\n const { deviceId: customDeviceId, pooling = false } = options;\n let current: SinglePointer | null = null;\n let resolvedDeviceId = customDeviceId ?? \"\";\n\n function acquirePointer(): SinglePointer {\n if (pooling) {\n return singlePointerPool.acquire();\n }\n return {\n phase: \"move\",\n x: 0,\n y: 0,\n pageX: 0,\n pageY: 0,\n pointerType: \"mouse\",\n button: \"none\",\n pressure: 0.5,\n timestamp: 0,\n deviceId: \"\",\n };\n }\n\n function releaseCurrentPointer(): void {\n if (current && pooling) {\n singlePointerPool.release(current);\n }\n current = null;\n }\n\n return {\n process(event: MouseEvent): SinglePointer {\n let phase: PointerPhase;\n let button: PointerButton;\n switch (event.type) {\n case \"mousedown\":\n phase = \"start\";\n button = toPointerButton(event.button);\n break;\n case \"mouseup\":\n phase = \"end\";\n button = toPointerButton(event.button);\n break;\n default:\n phase = \"move\";\n button = \"none\";\n }\n\n const pointer = acquirePointer();\n\n pointer.timestamp = performance.now();\n pointer.deviceId = resolvedDeviceId || (resolvedDeviceId = \"mouse-device\");\n pointer.phase = phase;\n pointer.x = event.clientX;\n pointer.y = event.clientY;\n pointer.pageX = event.pageX;\n pointer.pageY = event.pageY;\n pointer.pointerType = \"mouse\";\n pointer.button = button;\n pointer.pressure = phase === \"move\" && event.buttons === 0 ? 0 : 0.5;\n\n releaseCurrentPointer();\n current = pointer;\n return pointer;\n },\n\n get isActive(): boolean {\n return current !== null;\n },\n\n reset(): void {\n releaseCurrentPointer();\n resolvedDeviceId = customDeviceId ?? \"\";\n },\n\n dispose(): void {\n this.reset();\n },\n };\n}\n\nexport function mouseToSinglePointer(\n options: MouseEmitterOptions = {},\n): Operator<MouseEvent, SinglePointer> {\n return (source) =>\n createStream((observer) => {\n const emitter = createMouseEmitter(options);\n\n const unsub = source.subscribe({\n next(event) {\n const pointer = emitter.process(event);\n observer.next(pointer);\n },\n error(err) {\n observer.error?.(err);\n },\n complete() {\n observer.complete?.();\n },\n });\n\n return () => {\n unsub();\n emitter.dispose();\n };\n });\n}\n"],"names":["createMouseEmitter","options","customDeviceId","pooling","current","resolvedDeviceId","acquirePointer","singlePointerPool","releaseCurrentPointer","event","phase","button","toPointerButton","pointer","mouseToSinglePointer","source","createStream","observer","emitter","unsub","err"],"mappings":";;;AAmBO,SAASA,EAAmBC,IAA+B,IAAkB;AAClF,QAAM,EAAE,UAAUC,GAAgB,SAAAC,IAAU,OAAUF;AACtD,MAAIG,IAAgC,MAChCC,IAAmBH,KAAkB;AAEzC,WAASI,IAAgC;AACvC,WAAIH,IACKI,EAAkB,QAAA,IAEpB;AAAA,MACL,OAAO;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,OAAO;AAAA,MACP,OAAO;AAAA,MACP,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,WAAW;AAAA,MACX,UAAU;AAAA,IAAA;AAAA,EAEd;AAEA,WAASC,IAA8B;AACrC,IAAIJ,KAAWD,KACbI,EAAkB,QAAQH,CAAO,GAEnCA,IAAU;AAAA,EACZ;AAEA,SAAO;AAAA,IACL,QAAQK,GAAkC;AACxC,UAAIC,GACAC;AACJ,cAAQF,EAAM,MAAA;AAAA,QACZ,KAAK;AACH,UAAAC,IAAQ,SACRC,IAASC,EAAgBH,EAAM,MAAM;AACrC;AAAA,QACF,KAAK;AACH,UAAAC,IAAQ,OACRC,IAASC,EAAgBH,EAAM,MAAM;AACrC;AAAA,QACF;AACE,UAAAC,IAAQ,QACRC,IAAS;AAAA,MAAA;AAGb,YAAME,IAAUP,EAAA;AAEhB,aAAAO,EAAQ,YAAY,YAAY,IAAA,GAChCA,EAAQ,WAAWR,MAAqBA,IAAmB,iBAC3DQ,EAAQ,QAAQH,GAChBG,EAAQ,IAAIJ,EAAM,SAClBI,EAAQ,IAAIJ,EAAM,SAClBI,EAAQ,QAAQJ,EAAM,OACtBI,EAAQ,QAAQJ,EAAM,OACtBI,EAAQ,cAAc,SACtBA,EAAQ,SAASF,GACjBE,EAAQ,WAAWH,MAAU,UAAUD,EAAM,YAAY,IAAI,IAAI,KAEjED,EAAA,GACAJ,IAAUS,GACHA;AAAA,IACT;AAAA,IAEA,IAAI,WAAoB;AACtB,aAAOT,MAAY;AAAA,IACrB;AAAA,IAEA,QAAc;AACZ,MAAAI,EAAA,GACAH,IAAmBH,KAAkB;AAAA,IACvC;AAAA,IAEA,UAAgB;AACd,WAAK,MAAA;AAAA,IACP;AAAA,EAAA;AAEJ;AAEO,SAASY,EACdb,IAA+B,IACM;AACrC,SAAO,CAACc,MACNC,EAAa,CAACC,MAAa;AACzB,UAAMC,IAAUlB,EAAmBC,CAAO,GAEpCkB,IAAQJ,EAAO,UAAU;AAAA,MAC7B,KAAKN,GAAO;AACV,cAAMI,IAAUK,EAAQ,QAAQT,CAAK;AACrC,QAAAQ,EAAS,KAAKJ,CAAO;AAAA,MACvB;AAAA,MACA,MAAMO,GAAK;AACT,QAAAH,EAAS,QAAQG,CAAG;AAAA,MACtB;AAAA,MACA,WAAW;AACT,QAAAH,EAAS,WAAA;AAAA,MACX;AAAA,IAAA,CACD;AAED,WAAO,MAAM;AACX,MAAAE,EAAA,GACAD,EAAQ,QAAA;AAAA,IACV;AAAA,EACF,CAAC;AACL;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../pointer-CX9qwBVm.cjs");exports.createPointerEmitter=e.createPointerEmitter;exports.singlePointer=e.singlePointer;exports.toSinglePointer=e.toSinglePointer;
|
|
2
|
+
//# sourceMappingURL=pointer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../stream-Cp6eCZs2.cjs"),p=require("../pool-Dr67Mz_1.cjs");function d(a={}){const{deviceId:u,pooling:r=!1}=a;let t=null,o=u??"";function c(){return r?p.singlePointerPool.acquire():{phase:"move",x:0,y:0,pageX:0,pageY:0,pointerType:"touch",button:"none",pressure:.5,timestamp:0,deviceId:""}}function i(){t&&r&&p.singlePointerPool.release(t),t=null}return{process(l){let s;switch(l.type){case"touchstart":s="start";break;case"touchend":s="end";break;case"touchcancel":s="cancel";break;default:s="move"}const n=l.touches[0]??l.changedTouches[0];if(!n)return t;const e=c();return e.timestamp=performance.now(),e.deviceId=o||(o="touch-device"),e.phase=s,e.x=n.clientX,e.y=n.clientY,e.pageX=n.pageX,e.pageY=n.pageY,e.pointerType="touch",e.button="none",e.pressure=n.force||.5,i(),t=e,e},get isActive(){return t!==null},reset(){i(),o=u??""},dispose(){this.reset()}}}function h(a={}){return u=>m.createStream(r=>{const t=d(a),o=u.subscribe({next(c){const i=t.process(c);i&&r.next(i)},error(c){r.error?.(c)},complete(){r.complete?.()}});return()=>{o(),t.dispose()}})}exports.createTouchEmitter=d;exports.singlePointerEmitter=h;
|
|
2
|
+
//# sourceMappingURL=touch.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touch.cjs","sources":["../../src/browser/single-pointer/touch-emitter.ts"],"sourcesContent":["import type { Operator } from \"../../stream/stream.js\";\nimport { createStream } from \"../../stream/stream.js\";\nimport { singlePointerPool } from \"./pool.js\";\nimport type { SinglePointer } from \"./single-pointer.js\";\nimport type { PointerPhase } from \"./types.js\";\n\nexport interface TouchEmitterOptions {\n deviceId?: string;\n pooling?: boolean;\n}\n\nexport interface TouchEmitter {\n process(event: TouchEvent): SinglePointer | null;\n readonly isActive: boolean;\n reset(): void;\n dispose(): void;\n}\n\nexport function createTouchEmitter(options: TouchEmitterOptions = {}): TouchEmitter {\n const { deviceId: customDeviceId, pooling = false } = options;\n let current: SinglePointer | null = null;\n let resolvedDeviceId = customDeviceId ?? \"\";\n\n function acquirePointer(): SinglePointer {\n if (pooling) {\n return singlePointerPool.acquire();\n }\n return {\n phase: \"move\",\n x: 0,\n y: 0,\n pageX: 0,\n pageY: 0,\n pointerType: \"touch\",\n button: \"none\",\n pressure: 0.5,\n timestamp: 0,\n deviceId: \"\",\n };\n }\n\n function releaseCurrentPointer(): void {\n if (current && pooling) {\n singlePointerPool.release(current);\n }\n current = null;\n }\n\n return {\n process(event: TouchEvent): SinglePointer | null {\n let phase: PointerPhase;\n switch (event.type) {\n case \"touchstart\":\n phase = \"start\";\n break;\n case \"touchend\":\n phase = \"end\";\n break;\n case \"touchcancel\":\n phase = \"cancel\";\n break;\n default:\n phase = \"move\";\n }\n\n const touch = event.touches[0] ?? event.changedTouches[0];\n\n if (!touch) {\n return current;\n }\n\n const pointer = acquirePointer();\n\n pointer.timestamp = performance.now();\n pointer.deviceId = resolvedDeviceId || (resolvedDeviceId = \"touch-device\");\n pointer.phase = phase;\n pointer.x = touch.clientX;\n pointer.y = touch.clientY;\n pointer.pageX = touch.pageX;\n pointer.pageY = touch.pageY;\n pointer.pointerType = \"touch\";\n pointer.button = \"none\";\n pointer.pressure = touch.force || 0.5;\n\n releaseCurrentPointer();\n current = pointer;\n return pointer;\n },\n\n get isActive(): boolean {\n return current !== null;\n },\n\n reset(): void {\n releaseCurrentPointer();\n resolvedDeviceId = customDeviceId ?? \"\";\n },\n\n dispose(): void {\n this.reset();\n },\n };\n}\n\nexport function singlePointerEmitter(\n options: TouchEmitterOptions = {},\n): Operator<TouchEvent, SinglePointer> {\n return (source) =>\n createStream((observer) => {\n const emitter = createTouchEmitter(options);\n\n const unsub = source.subscribe({\n next(event) {\n const pointer = emitter.process(event);\n if (pointer) {\n observer.next(pointer);\n }\n },\n error(err) {\n observer.error?.(err);\n },\n complete() {\n observer.complete?.();\n },\n });\n\n return () => {\n unsub();\n emitter.dispose();\n };\n });\n}\n"],"names":["createTouchEmitter","options","customDeviceId","pooling","current","resolvedDeviceId","acquirePointer","singlePointerPool","releaseCurrentPointer","event","phase","touch","pointer","singlePointerEmitter","source","createStream","observer","emitter","unsub","err"],"mappings":"4JAkBO,SAASA,EAAmBC,EAA+B,GAAkB,CAClF,KAAM,CAAE,SAAUC,EAAgB,QAAAC,EAAU,IAAUF,EACtD,IAAIG,EAAgC,KAChCC,EAAmBH,GAAkB,GAEzC,SAASI,GAAgC,CACvC,OAAIH,EACKI,EAAAA,kBAAkB,QAAA,EAEpB,CACL,MAAO,OACP,EAAG,EACH,EAAG,EACH,MAAO,EACP,MAAO,EACP,YAAa,QACb,OAAQ,OACR,SAAU,GACV,UAAW,EACX,SAAU,EAAA,CAEd,CAEA,SAASC,GAA8B,CACjCJ,GAAWD,GACbI,EAAAA,kBAAkB,QAAQH,CAAO,EAEnCA,EAAU,IACZ,CAEA,MAAO,CACL,QAAQK,EAAyC,CAC/C,IAAIC,EACJ,OAAQD,EAAM,KAAA,CACZ,IAAK,aACHC,EAAQ,QACR,MACF,IAAK,WACHA,EAAQ,MACR,MACF,IAAK,cACHA,EAAQ,SACR,MACF,QACEA,EAAQ,MAAA,CAGZ,MAAMC,EAAQF,EAAM,QAAQ,CAAC,GAAKA,EAAM,eAAe,CAAC,EAExD,GAAI,CAACE,EACH,OAAOP,EAGT,MAAMQ,EAAUN,EAAA,EAEhB,OAAAM,EAAQ,UAAY,YAAY,IAAA,EAChCA,EAAQ,SAAWP,IAAqBA,EAAmB,gBAC3DO,EAAQ,MAAQF,EAChBE,EAAQ,EAAID,EAAM,QAClBC,EAAQ,EAAID,EAAM,QAClBC,EAAQ,MAAQD,EAAM,MACtBC,EAAQ,MAAQD,EAAM,MACtBC,EAAQ,YAAc,QACtBA,EAAQ,OAAS,OACjBA,EAAQ,SAAWD,EAAM,OAAS,GAElCH,EAAA,EACAJ,EAAUQ,EACHA,CACT,EAEA,IAAI,UAAoB,CACtB,OAAOR,IAAY,IACrB,EAEA,OAAc,CACZI,EAAA,EACAH,EAAmBH,GAAkB,EACvC,EAEA,SAAgB,CACd,KAAK,MAAA,CACP,CAAA,CAEJ,CAEO,SAASW,EACdZ,EAA+B,GACM,CACrC,OAAQa,GACNC,eAAcC,GAAa,CACzB,MAAMC,EAAUjB,EAAmBC,CAAO,EAEpCiB,EAAQJ,EAAO,UAAU,CAC7B,KAAKL,EAAO,CACV,MAAMG,EAAUK,EAAQ,QAAQR,CAAK,EACjCG,GACFI,EAAS,KAAKJ,CAAO,CAEzB,EACA,MAAMO,EAAK,CACTH,EAAS,QAAQG,CAAG,CACtB,EACA,UAAW,CACTH,EAAS,WAAA,CACX,CAAA,CACD,EAED,MAAO,IAAM,CACXE,EAAA,EACAD,EAAQ,QAAA,CACV,CACF,CAAC,CACL"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { c as m } from "../stream-CDK0RZPi.js";
|
|
2
|
+
import { s as l } from "../pool-CM9teIjt.js";
|
|
3
|
+
function d(a = {}) {
|
|
4
|
+
const { deviceId: u, pooling: r = !1 } = a;
|
|
5
|
+
let t = null, o = u ?? "";
|
|
6
|
+
function c() {
|
|
7
|
+
return r ? l.acquire() : {
|
|
8
|
+
phase: "move",
|
|
9
|
+
x: 0,
|
|
10
|
+
y: 0,
|
|
11
|
+
pageX: 0,
|
|
12
|
+
pageY: 0,
|
|
13
|
+
pointerType: "touch",
|
|
14
|
+
button: "none",
|
|
15
|
+
pressure: 0.5,
|
|
16
|
+
timestamp: 0,
|
|
17
|
+
deviceId: ""
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function s() {
|
|
21
|
+
t && r && l.release(t), t = null;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
process(p) {
|
|
25
|
+
let i;
|
|
26
|
+
switch (p.type) {
|
|
27
|
+
case "touchstart":
|
|
28
|
+
i = "start";
|
|
29
|
+
break;
|
|
30
|
+
case "touchend":
|
|
31
|
+
i = "end";
|
|
32
|
+
break;
|
|
33
|
+
case "touchcancel":
|
|
34
|
+
i = "cancel";
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
i = "move";
|
|
38
|
+
}
|
|
39
|
+
const n = p.touches[0] ?? p.changedTouches[0];
|
|
40
|
+
if (!n)
|
|
41
|
+
return t;
|
|
42
|
+
const e = c();
|
|
43
|
+
return e.timestamp = performance.now(), e.deviceId = o || (o = "touch-device"), e.phase = i, e.x = n.clientX, e.y = n.clientY, e.pageX = n.pageX, e.pageY = n.pageY, e.pointerType = "touch", e.button = "none", e.pressure = n.force || 0.5, s(), t = e, e;
|
|
44
|
+
},
|
|
45
|
+
get isActive() {
|
|
46
|
+
return t !== null;
|
|
47
|
+
},
|
|
48
|
+
reset() {
|
|
49
|
+
s(), o = u ?? "";
|
|
50
|
+
},
|
|
51
|
+
dispose() {
|
|
52
|
+
this.reset();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function g(a = {}) {
|
|
57
|
+
return (u) => m((r) => {
|
|
58
|
+
const t = d(a), o = u.subscribe({
|
|
59
|
+
next(c) {
|
|
60
|
+
const s = t.process(c);
|
|
61
|
+
s && r.next(s);
|
|
62
|
+
},
|
|
63
|
+
error(c) {
|
|
64
|
+
r.error?.(c);
|
|
65
|
+
},
|
|
66
|
+
complete() {
|
|
67
|
+
r.complete?.();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return () => {
|
|
71
|
+
o(), t.dispose();
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
d as createTouchEmitter,
|
|
77
|
+
g as singlePointerEmitter
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=touch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touch.js","sources":["../../src/browser/single-pointer/touch-emitter.ts"],"sourcesContent":["import type { Operator } from \"../../stream/stream.js\";\nimport { createStream } from \"../../stream/stream.js\";\nimport { singlePointerPool } from \"./pool.js\";\nimport type { SinglePointer } from \"./single-pointer.js\";\nimport type { PointerPhase } from \"./types.js\";\n\nexport interface TouchEmitterOptions {\n deviceId?: string;\n pooling?: boolean;\n}\n\nexport interface TouchEmitter {\n process(event: TouchEvent): SinglePointer | null;\n readonly isActive: boolean;\n reset(): void;\n dispose(): void;\n}\n\nexport function createTouchEmitter(options: TouchEmitterOptions = {}): TouchEmitter {\n const { deviceId: customDeviceId, pooling = false } = options;\n let current: SinglePointer | null = null;\n let resolvedDeviceId = customDeviceId ?? \"\";\n\n function acquirePointer(): SinglePointer {\n if (pooling) {\n return singlePointerPool.acquire();\n }\n return {\n phase: \"move\",\n x: 0,\n y: 0,\n pageX: 0,\n pageY: 0,\n pointerType: \"touch\",\n button: \"none\",\n pressure: 0.5,\n timestamp: 0,\n deviceId: \"\",\n };\n }\n\n function releaseCurrentPointer(): void {\n if (current && pooling) {\n singlePointerPool.release(current);\n }\n current = null;\n }\n\n return {\n process(event: TouchEvent): SinglePointer | null {\n let phase: PointerPhase;\n switch (event.type) {\n case \"touchstart\":\n phase = \"start\";\n break;\n case \"touchend\":\n phase = \"end\";\n break;\n case \"touchcancel\":\n phase = \"cancel\";\n break;\n default:\n phase = \"move\";\n }\n\n const touch = event.touches[0] ?? event.changedTouches[0];\n\n if (!touch) {\n return current;\n }\n\n const pointer = acquirePointer();\n\n pointer.timestamp = performance.now();\n pointer.deviceId = resolvedDeviceId || (resolvedDeviceId = \"touch-device\");\n pointer.phase = phase;\n pointer.x = touch.clientX;\n pointer.y = touch.clientY;\n pointer.pageX = touch.pageX;\n pointer.pageY = touch.pageY;\n pointer.pointerType = \"touch\";\n pointer.button = \"none\";\n pointer.pressure = touch.force || 0.5;\n\n releaseCurrentPointer();\n current = pointer;\n return pointer;\n },\n\n get isActive(): boolean {\n return current !== null;\n },\n\n reset(): void {\n releaseCurrentPointer();\n resolvedDeviceId = customDeviceId ?? \"\";\n },\n\n dispose(): void {\n this.reset();\n },\n };\n}\n\nexport function singlePointerEmitter(\n options: TouchEmitterOptions = {},\n): Operator<TouchEvent, SinglePointer> {\n return (source) =>\n createStream((observer) => {\n const emitter = createTouchEmitter(options);\n\n const unsub = source.subscribe({\n next(event) {\n const pointer = emitter.process(event);\n if (pointer) {\n observer.next(pointer);\n }\n },\n error(err) {\n observer.error?.(err);\n },\n complete() {\n observer.complete?.();\n },\n });\n\n return () => {\n unsub();\n emitter.dispose();\n };\n });\n}\n"],"names":["createTouchEmitter","options","customDeviceId","pooling","current","resolvedDeviceId","acquirePointer","singlePointerPool","releaseCurrentPointer","event","phase","touch","pointer","singlePointerEmitter","source","createStream","observer","emitter","unsub","err"],"mappings":";;AAkBO,SAASA,EAAmBC,IAA+B,IAAkB;AAClF,QAAM,EAAE,UAAUC,GAAgB,SAAAC,IAAU,OAAUF;AACtD,MAAIG,IAAgC,MAChCC,IAAmBH,KAAkB;AAEzC,WAASI,IAAgC;AACvC,WAAIH,IACKI,EAAkB,QAAA,IAEpB;AAAA,MACL,OAAO;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,OAAO;AAAA,MACP,OAAO;AAAA,MACP,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,WAAW;AAAA,MACX,UAAU;AAAA,IAAA;AAAA,EAEd;AAEA,WAASC,IAA8B;AACrC,IAAIJ,KAAWD,KACbI,EAAkB,QAAQH,CAAO,GAEnCA,IAAU;AAAA,EACZ;AAEA,SAAO;AAAA,IACL,QAAQK,GAAyC;AAC/C,UAAIC;AACJ,cAAQD,EAAM,MAAA;AAAA,QACZ,KAAK;AACH,UAAAC,IAAQ;AACR;AAAA,QACF,KAAK;AACH,UAAAA,IAAQ;AACR;AAAA,QACF,KAAK;AACH,UAAAA,IAAQ;AACR;AAAA,QACF;AACE,UAAAA,IAAQ;AAAA,MAAA;AAGZ,YAAMC,IAAQF,EAAM,QAAQ,CAAC,KAAKA,EAAM,eAAe,CAAC;AAExD,UAAI,CAACE;AACH,eAAOP;AAGT,YAAMQ,IAAUN,EAAA;AAEhB,aAAAM,EAAQ,YAAY,YAAY,IAAA,GAChCA,EAAQ,WAAWP,MAAqBA,IAAmB,iBAC3DO,EAAQ,QAAQF,GAChBE,EAAQ,IAAID,EAAM,SAClBC,EAAQ,IAAID,EAAM,SAClBC,EAAQ,QAAQD,EAAM,OACtBC,EAAQ,QAAQD,EAAM,OACtBC,EAAQ,cAAc,SACtBA,EAAQ,SAAS,QACjBA,EAAQ,WAAWD,EAAM,SAAS,KAElCH,EAAA,GACAJ,IAAUQ,GACHA;AAAA,IACT;AAAA,IAEA,IAAI,WAAoB;AACtB,aAAOR,MAAY;AAAA,IACrB;AAAA,IAEA,QAAc;AACZ,MAAAI,EAAA,GACAH,IAAmBH,KAAkB;AAAA,IACvC;AAAA,IAEA,UAAgB;AACd,WAAK,MAAA;AAAA,IACP;AAAA,EAAA;AAEJ;AAEO,SAASW,EACdZ,IAA+B,IACM;AACrC,SAAO,CAACa,MACNC,EAAa,CAACC,MAAa;AACzB,UAAMC,IAAUjB,EAAmBC,CAAO,GAEpCiB,IAAQJ,EAAO,UAAU;AAAA,MAC7B,KAAKL,GAAO;AACV,cAAMG,IAAUK,EAAQ,QAAQR,CAAK;AACrC,QAAIG,KACFI,EAAS,KAAKJ,CAAO;AAAA,MAEzB;AAAA,MACA,MAAMO,GAAK;AACT,QAAAH,EAAS,QAAQG,CAAG;AAAA,MACtB;AAAA,MACA,WAAW;AACT,QAAAH,EAAS,WAAA;AAAA,MACX;AAAA,IAAA,CACD;AAED,WAAO,MAAM;AACX,MAAAE,EAAA,GACAD,EAAQ,QAAA;AAAA,IACV;AAAA,EACF,CAAC;AACL;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type Unsubscribe = () => void;
|
|
2
|
+
export interface Observer<T> {
|
|
3
|
+
next(value: T): void;
|
|
4
|
+
error?(err: unknown): void;
|
|
5
|
+
complete?(): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Stream is the core reactive abstraction in Cereb.
|
|
9
|
+
* All streams are blockable - when blocked, events are silently dropped.
|
|
10
|
+
* By default, streams support a single observer. Use share() for multicast.
|
|
11
|
+
*/
|
|
12
|
+
export interface Stream<T> {
|
|
13
|
+
subscribe(observer: Observer<T> | ((value: T) => void)): Unsubscribe;
|
|
14
|
+
/** Block event propagation. Events are dropped, not queued. */
|
|
15
|
+
block(): void;
|
|
16
|
+
/** Unblock event propagation, resuming normal flow. */
|
|
17
|
+
unblock(): void;
|
|
18
|
+
/** Returns true if the stream is currently blocked. */
|
|
19
|
+
readonly isBlocked: boolean;
|
|
20
|
+
}
|
|
21
|
+
export type Operator<T, R> = (source: Stream<T>) => Stream<R>;
|
|
22
|
+
export declare function toObserver<T>(observerOrNext: Observer<T> | ((value: T) => void)): Observer<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a Stream from a subscribe function.
|
|
25
|
+
* The stream can be blocked/unblocked to control event flow.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createStream<T>(subscribeFn: (observer: Observer<T>) => Unsubscribe | void): Stream<T>;
|
|
28
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream/stream.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,IAAI,IAAI,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,WAAW,CAAC;IAErE,+DAA+D;IAC/D,KAAK,IAAI,IAAI,CAAC;IAEd,uDAAuD;IACvD,OAAO,IAAI,IAAI,CAAC;IAEhB,uDAAuD;IACvD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC;AAE9D,wBAAgB,UAAU,CAAC,CAAC,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAK7F;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,WAAW,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,WAAW,GAAG,IAAI,GACzD,MAAM,CAAC,CAAC,CAAC,CAiCX"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function u(e) {
|
|
2
|
+
return typeof e == "function" ? { next: e } : e;
|
|
3
|
+
}
|
|
4
|
+
function s(e) {
|
|
5
|
+
let n = !1;
|
|
6
|
+
return {
|
|
7
|
+
get isBlocked() {
|
|
8
|
+
return n;
|
|
9
|
+
},
|
|
10
|
+
block() {
|
|
11
|
+
n = !0;
|
|
12
|
+
},
|
|
13
|
+
unblock() {
|
|
14
|
+
n = !1;
|
|
15
|
+
},
|
|
16
|
+
subscribe(r) {
|
|
17
|
+
const t = u(r), c = {
|
|
18
|
+
next(o) {
|
|
19
|
+
n || t.next(o);
|
|
20
|
+
},
|
|
21
|
+
error: t.error?.bind(t),
|
|
22
|
+
complete: t.complete?.bind(t)
|
|
23
|
+
};
|
|
24
|
+
return e(c) ?? (() => {
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
s as c,
|
|
31
|
+
u as t
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=stream-CDK0RZPi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-CDK0RZPi.js","sources":["../src/stream/stream.ts"],"sourcesContent":["export type Unsubscribe = () => void;\n\nexport interface Observer<T> {\n next(value: T): void;\n error?(err: unknown): void;\n complete?(): void;\n}\n\n/**\n * Stream is the core reactive abstraction in Cereb.\n * All streams are blockable - when blocked, events are silently dropped.\n * By default, streams support a single observer. Use share() for multicast.\n */\nexport interface Stream<T> {\n subscribe(observer: Observer<T> | ((value: T) => void)): Unsubscribe;\n\n /** Block event propagation. Events are dropped, not queued. */\n block(): void;\n\n /** Unblock event propagation, resuming normal flow. */\n unblock(): void;\n\n /** Returns true if the stream is currently blocked. */\n readonly isBlocked: boolean;\n}\n\nexport type Operator<T, R> = (source: Stream<T>) => Stream<R>;\n\nexport function toObserver<T>(observerOrNext: Observer<T> | ((value: T) => void)): Observer<T> {\n if (typeof observerOrNext === \"function\") {\n return { next: observerOrNext };\n }\n return observerOrNext;\n}\n\n/**\n * Creates a Stream from a subscribe function.\n * The stream can be blocked/unblocked to control event flow.\n */\nexport function createStream<T>(\n subscribeFn: (observer: Observer<T>) => Unsubscribe | void,\n): Stream<T> {\n let blocked = false;\n\n return {\n get isBlocked() {\n return blocked;\n },\n\n block() {\n blocked = true;\n },\n\n unblock() {\n blocked = false;\n },\n\n subscribe(observerOrNext) {\n const observer = toObserver(observerOrNext);\n\n const wrappedObserver: Observer<T> = {\n next(value) {\n if (!blocked) {\n observer.next(value);\n }\n },\n error: observer.error?.bind(observer),\n complete: observer.complete?.bind(observer),\n };\n\n const cleanup = subscribeFn(wrappedObserver);\n return cleanup ?? (() => {});\n },\n };\n}\n"],"names":["toObserver","observerOrNext","createStream","subscribeFn","blocked","observer","wrappedObserver","value"],"mappings":"AA4BO,SAASA,EAAcC,GAAiE;AAC7F,SAAI,OAAOA,KAAmB,aACrB,EAAE,MAAMA,EAAA,IAEVA;AACT;AAMO,SAASC,EACdC,GACW;AACX,MAAIC,IAAU;AAEd,SAAO;AAAA,IACL,IAAI,YAAY;AACd,aAAOA;AAAA,IACT;AAAA,IAEA,QAAQ;AACN,MAAAA,IAAU;AAAA,IACZ;AAAA,IAEA,UAAU;AACR,MAAAA,IAAU;AAAA,IACZ;AAAA,IAEA,UAAUH,GAAgB;AACxB,YAAMI,IAAWL,EAAWC,CAAc,GAEpCK,IAA+B;AAAA,QACnC,KAAKC,GAAO;AACV,UAAKH,KACHC,EAAS,KAAKE,CAAK;AAAA,QAEvB;AAAA,QACA,OAAOF,EAAS,OAAO,KAAKA,CAAQ;AAAA,QACpC,UAAUA,EAAS,UAAU,KAAKA,CAAQ;AAAA,MAAA;AAI5C,aADgBF,EAAYG,CAAe,MACxB,MAAM;AAAA,MAAC;AAAA,IAC5B;AAAA,EAAA;AAEJ;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";function n(e){return typeof e=="function"?{next:e}:e}function s(e){let t=!1;return{get isBlocked(){return t},block(){t=!0},unblock(){t=!1},subscribe(c){const r=n(c),o={next(u){t||r.next(u)},error:r.error?.bind(r),complete:r.complete?.bind(r)};return e(o)??(()=>{})}}}exports.createStream=s;exports.toObserver=n;
|
|
2
|
+
//# sourceMappingURL=stream-Cp6eCZs2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-Cp6eCZs2.cjs","sources":["../src/stream/stream.ts"],"sourcesContent":["export type Unsubscribe = () => void;\n\nexport interface Observer<T> {\n next(value: T): void;\n error?(err: unknown): void;\n complete?(): void;\n}\n\n/**\n * Stream is the core reactive abstraction in Cereb.\n * All streams are blockable - when blocked, events are silently dropped.\n * By default, streams support a single observer. Use share() for multicast.\n */\nexport interface Stream<T> {\n subscribe(observer: Observer<T> | ((value: T) => void)): Unsubscribe;\n\n /** Block event propagation. Events are dropped, not queued. */\n block(): void;\n\n /** Unblock event propagation, resuming normal flow. */\n unblock(): void;\n\n /** Returns true if the stream is currently blocked. */\n readonly isBlocked: boolean;\n}\n\nexport type Operator<T, R> = (source: Stream<T>) => Stream<R>;\n\nexport function toObserver<T>(observerOrNext: Observer<T> | ((value: T) => void)): Observer<T> {\n if (typeof observerOrNext === \"function\") {\n return { next: observerOrNext };\n }\n return observerOrNext;\n}\n\n/**\n * Creates a Stream from a subscribe function.\n * The stream can be blocked/unblocked to control event flow.\n */\nexport function createStream<T>(\n subscribeFn: (observer: Observer<T>) => Unsubscribe | void,\n): Stream<T> {\n let blocked = false;\n\n return {\n get isBlocked() {\n return blocked;\n },\n\n block() {\n blocked = true;\n },\n\n unblock() {\n blocked = false;\n },\n\n subscribe(observerOrNext) {\n const observer = toObserver(observerOrNext);\n\n const wrappedObserver: Observer<T> = {\n next(value) {\n if (!blocked) {\n observer.next(value);\n }\n },\n error: observer.error?.bind(observer),\n complete: observer.complete?.bind(observer),\n };\n\n const cleanup = subscribeFn(wrappedObserver);\n return cleanup ?? (() => {});\n },\n };\n}\n"],"names":["toObserver","observerOrNext","createStream","subscribeFn","blocked","observer","wrappedObserver","value"],"mappings":"aA4BO,SAASA,EAAcC,EAAiE,CAC7F,OAAI,OAAOA,GAAmB,WACrB,CAAE,KAAMA,CAAA,EAEVA,CACT,CAMO,SAASC,EACdC,EACW,CACX,IAAIC,EAAU,GAEd,MAAO,CACL,IAAI,WAAY,CACd,OAAOA,CACT,EAEA,OAAQ,CACNA,EAAU,EACZ,EAEA,SAAU,CACRA,EAAU,EACZ,EAEA,UAAUH,EAAgB,CACxB,MAAMI,EAAWL,EAAWC,CAAc,EAEpCK,EAA+B,CACnC,KAAKC,EAAO,CACLH,GACHC,EAAS,KAAKE,CAAK,CAEvB,EACA,MAAOF,EAAS,OAAO,KAAKA,CAAQ,EACpC,SAAUA,EAAS,UAAU,KAAKA,CAAQ,CAAA,EAI5C,OADgBF,EAAYG,CAAe,IACxB,IAAM,CAAC,EAC5B,CAAA,CAEJ"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function e(r) {
|
|
2
|
+
switch (r) {
|
|
3
|
+
case -1:
|
|
4
|
+
return "none";
|
|
5
|
+
case 0:
|
|
6
|
+
return "primary";
|
|
7
|
+
case 1:
|
|
8
|
+
return "auxiliary";
|
|
9
|
+
case 2:
|
|
10
|
+
return "secondary";
|
|
11
|
+
case 3:
|
|
12
|
+
return "back";
|
|
13
|
+
case 4:
|
|
14
|
+
return "forward";
|
|
15
|
+
default:
|
|
16
|
+
return "none";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
e as t
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=types-Ccnqx90M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-Ccnqx90M.js","sources":["../src/browser/single-pointer/types.ts"],"sourcesContent":["export type PointerType = \"touch\" | \"mouse\" | \"pen\" | \"unknown\";\n\nexport type PointerPhase = \"start\" | \"move\" | \"end\" | \"cancel\";\n\nexport type PointerButton = \"none\" | \"primary\" | \"secondary\" | \"auxiliary\" | \"back\" | \"forward\";\n\nexport function toPointerButton(button: number): PointerButton {\n switch (button) {\n case -1:\n return \"none\";\n case 0:\n return \"primary\";\n case 1:\n return \"auxiliary\";\n case 2:\n return \"secondary\";\n case 3:\n return \"back\";\n case 4:\n return \"forward\";\n default:\n return \"none\";\n }\n}\n"],"names":["toPointerButton","button"],"mappings":"AAMO,SAASA,EAAgBC,GAA+B;AAC7D,UAAQA,GAAA;AAAA,IACN,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EAAA;AAEb;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DkXpfiI3.cjs","sources":["../src/browser/single-pointer/types.ts"],"sourcesContent":["export type PointerType = \"touch\" | \"mouse\" | \"pen\" | \"unknown\";\n\nexport type PointerPhase = \"start\" | \"move\" | \"end\" | \"cancel\";\n\nexport type PointerButton = \"none\" | \"primary\" | \"secondary\" | \"auxiliary\" | \"back\" | \"forward\";\n\nexport function toPointerButton(button: number): PointerButton {\n switch (button) {\n case -1:\n return \"none\";\n case 0:\n return \"primary\";\n case 1:\n return \"auxiliary\";\n case 2:\n return \"secondary\";\n case 3:\n return \"back\";\n case 4:\n return \"forward\";\n default:\n return \"none\";\n }\n}\n"],"names":["toPointerButton","button"],"mappings":"aAMO,SAASA,EAAgBC,EAA+B,CAC7D,OAAQA,EAAA,CACN,IAAK,GACH,MAAO,OACT,IAAK,GACH,MAAO,UACT,IAAK,GACH,MAAO,YACT,IAAK,GACH,MAAO,YACT,IAAK,GACH,MAAO,OACT,IAAK,GACH,MAAO,UACT,QACE,MAAO,MAAA,CAEb"}
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cereb",
|
|
3
|
+
"description": "User input modeling and orchestration with a lightweight reactive stream library.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "devphilip21 <philip21.dev@gmail.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/devphilip21/cereb.git",
|
|
10
|
+
"directory": "packages/core"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/devphilip21/cereb/tree/main/packages/core",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/devphilip21/cereb/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"cereb",
|
|
18
|
+
"interaction",
|
|
19
|
+
"event",
|
|
20
|
+
"events",
|
|
21
|
+
"touch",
|
|
22
|
+
"pointer",
|
|
23
|
+
"gesture",
|
|
24
|
+
"reactive",
|
|
25
|
+
"stream",
|
|
26
|
+
"observable",
|
|
27
|
+
"input",
|
|
28
|
+
"user-input",
|
|
29
|
+
"high-performance",
|
|
30
|
+
"gc"
|
|
31
|
+
],
|
|
32
|
+
"type": "module",
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"main": "./dist/index.cjs",
|
|
35
|
+
"module": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/index.js",
|
|
41
|
+
"require": "./dist/index.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./operators": {
|
|
44
|
+
"types": "./dist/operators.d.ts",
|
|
45
|
+
"import": "./dist/operators.js",
|
|
46
|
+
"require": "./dist/operators.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./single-pointer/touch": {
|
|
49
|
+
"types": "./dist/single-pointer/touch.d.ts",
|
|
50
|
+
"import": "./dist/single-pointer/touch.js",
|
|
51
|
+
"require": "./dist/single-pointer/touch.cjs"
|
|
52
|
+
},
|
|
53
|
+
"./single-pointer/mouse": {
|
|
54
|
+
"types": "./dist/single-pointer/mouse.d.ts",
|
|
55
|
+
"import": "./dist/single-pointer/mouse.js",
|
|
56
|
+
"require": "./dist/single-pointer/mouse.cjs"
|
|
57
|
+
},
|
|
58
|
+
"./single-pointer/pointer": {
|
|
59
|
+
"types": "./dist/single-pointer/pointer.d.ts",
|
|
60
|
+
"import": "./dist/single-pointer/pointer.js",
|
|
61
|
+
"require": "./dist/single-pointer/pointer.cjs"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"files": [
|
|
65
|
+
"dist",
|
|
66
|
+
"README.md",
|
|
67
|
+
"LICENSE"
|
|
68
|
+
],
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "builder build",
|
|
71
|
+
"test": "vitest run",
|
|
72
|
+
"test:watch": "vitest",
|
|
73
|
+
"test:coverage": "vitest run --coverage"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@cereb/builder": "workspace:^",
|
|
77
|
+
"@vitest/coverage-v8": "*",
|
|
78
|
+
"jsdom": "*",
|
|
79
|
+
"vite": "*",
|
|
80
|
+
"vitest": "*"
|
|
81
|
+
}
|
|
82
|
+
}
|