@gjsify/diagnostics_channel 0.3.21 → 0.4.3
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/lib/esm/_virtual/_rolldown/runtime.js +1 -0
- package/lib/esm/index.js +1 -1
- package/package.json +39 -36
- package/src/index.spec.ts +0 -934
- package/src/index.ts +0 -339
- package/src/test.mts +0 -6
- package/tsconfig.json +0 -29
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0});export{__name};
|
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=new Map;var Channel=class{name;_subscribers=[];constructor(e){this.name=e}get hasSubscribers(){return this._subscribers.length>0}publish(e){if(this._subscribers.length===0)return;let t=this._subscribers;for(let n=0;n<t.length;n++)try{t[n](e,this.name)}catch(e){Promise.resolve().then(()=>{throw e})}}subscribe(e){if(typeof e!=`function`)throw TypeError(`The "subscription" argument must be of type function`);this._subscribers=[...this._subscribers,e]}unsubscribe(e){let t=this._subscribers.indexOf(e);return t===-1?!1:(this._subscribers=[...this._subscribers.slice(0,t),...this._subscribers.slice(t+1)],!0)}runStores(e,t,n,...r){return this.publish(e),t.apply(n,r)}bindStore(e,t){}unbindStore(e){}};function channel(t){if(typeof t!=`string`&&typeof t!=`symbol`)throw TypeError(`The "channel" argument must be of type string or symbol`);let n=e.get(t);return n||(n=new Channel(t),e.set(t,n)),n}function hasSubscribers(t){let n=e.get(t);return n?n.hasSubscribers:!1}function subscribe(e,t){channel(e).subscribe(t)}function unsubscribe(e,t){return channel(e).unsubscribe(t)}var TracingChannel=class{start;end;asyncStart;asyncEnd;error;constructor(e){if(typeof e==`string`){let t=e;this.start=channel(`tracing:${t}:start`),this.end=channel(`tracing:${t}:end`),this.asyncStart=channel(`tracing:${t}:asyncStart`),this.asyncEnd=channel(`tracing:${t}:asyncEnd`),this.error=channel(`tracing:${t}:error`)}else if(typeof e==`object`&&e){for(let t of[`start`,`end`,`asyncStart`,`asyncEnd`,`error`])if(!(e[t]instanceof Channel))throw TypeError(`The "nameOrChannels.${t}" property must be an instance of Channel`);this.start=e.start,this.end=e.end,this.asyncStart=e.asyncStart,this.asyncEnd=e.asyncEnd,this.error=e.error}else throw TypeError(`The "nameOrChannels" argument must be of type string or an instance of TracingChannel or Object`)}get hasSubscribers(){return this.start.hasSubscribers||this.end.hasSubscribers||this.asyncStart.hasSubscribers||this.asyncEnd.hasSubscribers||this.error.hasSubscribers}subscribe(e){e.start&&this.start.subscribe(e.start),e.end&&this.end.subscribe(e.end),e.asyncStart&&this.asyncStart.subscribe(e.asyncStart),e.asyncEnd&&this.asyncEnd.subscribe(e.asyncEnd),e.error&&this.error.subscribe(e.error)}unsubscribe(e){let t=!0;return e.start&&!this.start.unsubscribe(e.start)&&(t=!1),e.end&&!this.end.unsubscribe(e.end)&&(t=!1),e.asyncStart&&!this.asyncStart.unsubscribe(e.asyncStart)&&(t=!1),e.asyncEnd&&!this.asyncEnd.unsubscribe(e.asyncEnd)&&(t=!1),e.error&&!this.error.unsubscribe(e.error)&&(t=!1),t}traceSync(e,t={},n,...r){if(!this.hasSubscribers)return e.apply(n,r);let{start:i,end:a,error:o}=this;i.publish(t);try{let i=e.apply(n,r);return t.result=i,i}catch(e){throw t.error=e,o.publish(t),e}finally{a.publish(t)}}tracePromise(e,t={},n,...r){if(!this.hasSubscribers)return e.apply(n,r);let{start:i,end:a,asyncStart:o,asyncEnd:s,error:c}=this;function resolve(e){return t.result=e,o.publish(t),s.publish(t),e}function reject(e){throw t.error=e,c.publish(t),o.publish(t),s.publish(t),e}i.publish(t);try{let i=e.apply(n,r);return typeof i?.then==`function`?i.then(resolve,reject):(t.result=i,i)}catch(e){throw t.error=e,c.publish(t),e}finally{a.publish(t)}}traceCallback(e,t=-1,n={},r,...i){if(!this.hasSubscribers)return e.apply(r,i);let{start:a,end:o,asyncStart:s,asyncEnd:c,error:l}=this,u=t<0?i.length+t:t,d=i[u];if(typeof d!=`function`)throw TypeError(`The "callback" argument must be of type function`);function wrappedCallback(e,t){e?(n.error=e,l.publish(n)):n.result=t,s.publish(n);try{return d.apply(this,arguments)}finally{c.publish(n)}}let f=[...i];f[u]=wrappedCallback,a.publish(n);try{return e.apply(r,f)}catch(e){throw n.error=e,l.publish(n),e}finally{o.publish(n)}}};function tracingChannel(e){return new TracingChannel(e)}var t={Channel,channel,hasSubscribers,subscribe,unsubscribe,TracingChannel,tracingChannel};export{Channel,TracingChannel,channel,t as default,hasSubscribers,subscribe,tracingChannel,unsubscribe};
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";const e=new Map;var Channel=class{name;_subscribers=[];constructor(e){this.name=e}get hasSubscribers(){return this._subscribers.length>0}publish(e){if(this._subscribers.length===0)return;let t=this._subscribers;for(let n=0;n<t.length;n++)try{t[n](e,this.name)}catch(e){Promise.resolve().then(()=>{throw e})}}subscribe(e){if(typeof e!=`function`)throw TypeError(`The "subscription" argument must be of type function`);this._subscribers=[...this._subscribers,e]}unsubscribe(e){let t=this._subscribers.indexOf(e);return t===-1?!1:(this._subscribers=[...this._subscribers.slice(0,t),...this._subscribers.slice(t+1)],!0)}runStores(e,t,n,...r){return this.publish(e),t.apply(n,r)}bindStore(e,t){}unbindStore(e){}};function channel(t){if(typeof t!=`string`&&typeof t!=`symbol`)throw TypeError(`The "channel" argument must be of type string or symbol`);let n=e.get(t);return n||(n=new Channel(t),e.set(t,n)),n}function hasSubscribers(t){let n=e.get(t);return n?n.hasSubscribers:!1}function subscribe(e,t){channel(e).subscribe(t)}function unsubscribe(e,t){return channel(e).unsubscribe(t)}var TracingChannel=class{start;end;asyncStart;asyncEnd;error;constructor(e){if(typeof e==`string`){let t=e;this.start=channel(`tracing:${t}:start`),this.end=channel(`tracing:${t}:end`),this.asyncStart=channel(`tracing:${t}:asyncStart`),this.asyncEnd=channel(`tracing:${t}:asyncEnd`),this.error=channel(`tracing:${t}:error`)}else if(typeof e==`object`&&e){for(let t of[`start`,`end`,`asyncStart`,`asyncEnd`,`error`])if(!(e[t]instanceof Channel))throw TypeError(`The "nameOrChannels.${t}" property must be an instance of Channel`);this.start=e.start,this.end=e.end,this.asyncStart=e.asyncStart,this.asyncEnd=e.asyncEnd,this.error=e.error}else throw TypeError(`The "nameOrChannels" argument must be of type string or an instance of TracingChannel or Object`)}get hasSubscribers(){return this.start.hasSubscribers||this.end.hasSubscribers||this.asyncStart.hasSubscribers||this.asyncEnd.hasSubscribers||this.error.hasSubscribers}subscribe(e){e.start&&this.start.subscribe(e.start),e.end&&this.end.subscribe(e.end),e.asyncStart&&this.asyncStart.subscribe(e.asyncStart),e.asyncEnd&&this.asyncEnd.subscribe(e.asyncEnd),e.error&&this.error.subscribe(e.error)}unsubscribe(e){let t=!0;return e.start&&!this.start.unsubscribe(e.start)&&(t=!1),e.end&&!this.end.unsubscribe(e.end)&&(t=!1),e.asyncStart&&!this.asyncStart.unsubscribe(e.asyncStart)&&(t=!1),e.asyncEnd&&!this.asyncEnd.unsubscribe(e.asyncEnd)&&(t=!1),e.error&&!this.error.unsubscribe(e.error)&&(t=!1),t}traceSync(e,t={},n,...r){if(!this.hasSubscribers)return e.apply(n,r);let{start:i,end:a,error:o}=this;i.publish(t);try{let i=e.apply(n,r);return t.result=i,i}catch(e){throw t.error=e,o.publish(t),e}finally{a.publish(t)}}tracePromise(e,t={},n,...r){if(!this.hasSubscribers)return e.apply(n,r);let{start:i,end:a,asyncStart:o,asyncEnd:s,error:c}=this;function resolve(e){return t.result=e,o.publish(t),s.publish(t),e}function reject(e){throw t.error=e,c.publish(t),o.publish(t),s.publish(t),e}i.publish(t);try{let i=e.apply(n,r);return typeof i?.then==`function`?i.then(resolve,reject):(t.result=i,i)}catch(e){throw t.error=e,c.publish(t),e}finally{a.publish(t)}}traceCallback(e,t=-1,n={},r,...i){if(!this.hasSubscribers)return e.apply(r,i);let{start:a,end:o,asyncStart:s,asyncEnd:c,error:l}=this,u=t<0?i.length+t:t,d=i[u];if(typeof d!=`function`)throw TypeError(`The "callback" argument must be of type function`);function wrappedCallback(e,t){e?(n.error=e,l.publish(n)):n.result=t,s.publish(n);try{return d.apply(this,arguments)}finally{c.publish(n)}}let f=[...i];f[u]=wrappedCallback,a.publish(n);try{return e.apply(r,f)}catch(e){throw n.error=e,l.publish(n),e}finally{o.publish(n)}}};function tracingChannel(e){return new TracingChannel(e)}var t={Channel,channel,hasSubscribers,subscribe,unsubscribe,TracingChannel,tracingChannel};export{Channel,TracingChannel,channel,t as default,hasSubscribers,subscribe,tracingChannel,unsubscribe};
|
package/package.json
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"name": "@gjsify/diagnostics_channel",
|
|
3
|
+
"version": "0.4.3",
|
|
4
|
+
"description": "Node.js diagnostics_channel module for Gjs",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "lib/esm/index.js",
|
|
7
|
+
"types": "lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"default": "./lib/esm/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"lib"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"clear": "rm -rf lib tsconfig.tsbuildinfo tsconfig.types.tsbuildinfo test.gjs.mjs test.node.mjs || exit 0",
|
|
19
|
+
"check": "tsc --noEmit",
|
|
20
|
+
"build": "gjsify run build:gjsify && gjsify run build:types",
|
|
21
|
+
"build:gjsify": "gjsify build --library 'src/**/*.{ts,js}' --exclude 'src/**/*.spec.{mts,ts}' 'src/test.{mts,ts}'",
|
|
22
|
+
"build:types": "tsc",
|
|
23
|
+
"build:test": "gjsify run build:test:gjs && gjsify run build:test:node",
|
|
24
|
+
"build:test:gjs": "gjsify build src/test.mts --app gjs --outfile test.gjs.mjs",
|
|
25
|
+
"build:test:node": "gjsify build src/test.mts --app node --outfile test.node.mjs",
|
|
26
|
+
"test": "gjsify run build:gjsify && gjsify run build:test && gjsify run test:node && gjsify run test:gjs",
|
|
27
|
+
"test:gjs": "gjsify run test.gjs.mjs",
|
|
28
|
+
"test:node": "node test.node.mjs"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"gjs",
|
|
32
|
+
"node",
|
|
33
|
+
"diagnostics_channel"
|
|
34
|
+
],
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@gjsify/cli": "workspace:^",
|
|
37
|
+
"@gjsify/unit": "workspace:^",
|
|
38
|
+
"@types/node": "^25.6.2",
|
|
39
|
+
"typescript": "^6.0.3"
|
|
12
40
|
}
|
|
13
|
-
|
|
14
|
-
"scripts": {
|
|
15
|
-
"clear": "rm -rf lib tsconfig.tsbuildinfo tsconfig.types.tsbuildinfo test.gjs.mjs test.node.mjs || exit 0",
|
|
16
|
-
"check": "tsc --noEmit",
|
|
17
|
-
"build": "yarn build:gjsify && yarn build:types",
|
|
18
|
-
"build:gjsify": "gjsify build --library 'src/**/*.{ts,js}' --exclude 'src/**/*.spec.{mts,ts}' 'src/test.{mts,ts}'",
|
|
19
|
-
"build:types": "tsc",
|
|
20
|
-
"build:test": "yarn build:test:gjs && yarn build:test:node",
|
|
21
|
-
"build:test:gjs": "gjsify build src/test.mts --app gjs --outfile test.gjs.mjs",
|
|
22
|
-
"build:test:node": "gjsify build src/test.mts --app node --outfile test.node.mjs",
|
|
23
|
-
"test": "yarn build:gjsify && yarn build:test && yarn test:node && yarn test:gjs",
|
|
24
|
-
"test:gjs": "gjsify run test.gjs.mjs",
|
|
25
|
-
"test:node": "node test.node.mjs"
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"gjs",
|
|
29
|
-
"node",
|
|
30
|
-
"diagnostics_channel"
|
|
31
|
-
],
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@gjsify/cli": "^0.3.21",
|
|
34
|
-
"@gjsify/unit": "^0.3.21",
|
|
35
|
-
"@types/node": "^25.6.2",
|
|
36
|
-
"typescript": "^6.0.3"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
41
|
+
}
|