@utk09/ui-observability 0.9.5 → 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.
- package/CHANGELOG.md +52 -0
- package/README.md +315 -99
- package/bin/uiobs.mjs +8 -0
- package/dist/{batch-BQFtb3i5.cjs → batch-C8OcWR2L.cjs} +2 -2
- package/dist/{batch-BQFtb3i5.cjs.map → batch-C8OcWR2L.cjs.map} +1 -1
- package/dist/{batch-BUJh-1jZ.js → batch-CL9uWYY3.js} +5 -6
- package/dist/{batch-BUJh-1jZ.js.map → batch-CL9uWYY3.js.map} +1 -1
- package/dist/bus/bus.d.ts +15 -0
- package/dist/{bus-DeOPHWaD.js → bus-BZ0GldpT.js} +125 -112
- package/dist/bus-BZ0GldpT.js.map +1 -0
- package/dist/bus-VWlmM5xs.cjs +2 -0
- package/dist/bus-VWlmM5xs.cjs.map +1 -0
- package/dist/capture/interactions.d.ts +18 -0
- package/dist/capture/lifecycle.d.ts +20 -0
- package/dist/capture/reports.d.ts +17 -0
- package/dist/capture/resource-timing.d.ts +14 -0
- package/dist/capture/server-timing.d.ts +19 -0
- package/dist/capture/types.d.ts +13 -0
- package/dist/capture/unclean-exit.d.ts +31 -0
- package/dist/capture/user-timing.d.ts +22 -0
- package/dist/console-BPZCuSLc.cjs +2 -0
- package/dist/console-BPZCuSLc.cjs.map +1 -0
- package/dist/{console-DbAZYJuy.js → console-BeCF7n59.js} +20 -20
- package/dist/{console-DbAZYJuy.js.map → console-BeCF7n59.js.map} +1 -1
- package/dist/constants-DqKJH_MP.cjs +2 -0
- package/dist/constants-DqKJH_MP.cjs.map +1 -0
- package/dist/constants-zyrqveN4.js +304 -0
- package/dist/constants-zyrqveN4.js.map +1 -0
- package/dist/constants.d.ts +58 -2
- package/dist/context-storage-BjzeBSxH.cjs.map +1 -1
- package/dist/{context-storage-DxZf4Gfh.js → context-storage-BzkoHzkQ.js} +2 -3
- package/dist/{context-storage-DxZf4Gfh.js.map → context-storage-BzkoHzkQ.js.map} +1 -1
- package/dist/core/debug-buffer.d.ts +34 -0
- package/dist/core/debug-bundle.d.ts +12 -0
- package/dist/core/deferred.d.ts +7 -0
- package/dist/core/logger.d.ts +7 -2
- package/dist/core/measure.d.ts +19 -0
- package/dist/core/pipeline.d.ts +6 -1
- package/dist/core/record.d.ts +20 -1
- package/dist/core/remote-sampling.d.ts +5 -1
- package/dist/core/runtime.d.ts +45 -2
- package/dist/core/sampling.d.ts +5 -4
- package/dist/core/sender.d.ts +3 -1
- package/dist/core/spans.d.ts +5 -0
- package/dist/{deadline-5_PecIl5.js → deadline-BOjOxNHj.js} +3 -5
- package/dist/{deadline-5_PecIl5.js.map → deadline-BOjOxNHj.js.map} +1 -1
- package/dist/deadline-XSnm95pg.cjs.map +1 -1
- package/dist/debug-bundle-BzJNpbF0.cjs +2 -0
- package/dist/debug-bundle-BzJNpbF0.cjs.map +1 -0
- package/dist/debug-bundle-C7UkHZ-q.js +25 -0
- package/dist/debug-bundle-C7UkHZ-q.js.map +1 -0
- package/dist/doctor.cjs +2 -0
- package/dist/doctor.cjs.map +1 -0
- package/dist/doctor.d.ts +23 -0
- package/dist/doctor.js +98 -0
- package/dist/doctor.js.map +1 -0
- package/dist/{emergency-queue-Cs1hrjsC.cjs → emergency-queue-CNTRui5t.cjs} +2 -2
- package/dist/{emergency-queue-Cs1hrjsC.cjs.map → emergency-queue-CNTRui5t.cjs.map} +1 -1
- package/dist/{emergency-queue-BYUyDHGD.js → emergency-queue-Zy6lNafo.js} +17 -19
- package/dist/{emergency-queue-BYUyDHGD.js.map → emergency-queue-Zy6lNafo.js.map} +1 -1
- package/dist/{error-like-Ywo5uRHo.js → error-like-B11pB4aL.js} +2 -3
- package/dist/{error-like-Ywo5uRHo.js.map → error-like-B11pB4aL.js.map} +1 -1
- package/dist/error-like-gGRx2s36.cjs.map +1 -1
- package/dist/{errors-BhC7HTSt.js → errors-Dh7kef0i.js} +5 -6
- package/dist/{errors-BhC7HTSt.js.map → errors-Dh7kef0i.js.map} +1 -1
- package/dist/{errors-CgY633cG.cjs → errors-tfEr48bS.cjs} +2 -2
- package/dist/{errors-CgY633cG.cjs.map → errors-tfEr48bS.cjs.map} +1 -1
- package/dist/{factory-C5TujXlU.js → factory-BonqI3NL.js} +16 -20
- package/dist/{factory-C5TujXlU.js.map → factory-BonqI3NL.js.map} +1 -1
- package/dist/{factory-CNj4DH3n.cjs → factory-CJXVYp0R.cjs} +2 -2
- package/dist/{factory-CNj4DH3n.cjs.map → factory-CJXVYp0R.cjs.map} +1 -1
- package/dist/fixed-window-CvESpFYV.cjs.map +1 -1
- package/dist/{fixed-window-CtaFHanJ.js → fixed-window-Dq3MLUUv.js} +2 -3
- package/dist/{fixed-window-CtaFHanJ.js.map → fixed-window-Dq3MLUUv.js.map} +1 -1
- package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
- package/dist/{global-scope-dp2jADRl.js → global-scope-D9I8s-oN.js} +2 -3
- package/dist/{global-scope-dp2jADRl.js.map → global-scope-D9I8s-oN.js.map} +1 -1
- package/dist/guards-Cidk71ME.js +7 -0
- package/dist/guards-Cidk71ME.js.map +1 -0
- package/dist/guards-nJ70syPt.cjs +2 -0
- package/dist/guards-nJ70syPt.cjs.map +1 -0
- package/dist/{identity-Da9TkuKd.cjs → identity-Cxgj6pZX.cjs} +2 -2
- package/dist/{identity-Da9TkuKd.cjs.map → identity-Cxgj6pZX.cjs.map} +1 -1
- package/dist/{identity-8vKkyAWm.js → identity-DT5VmvXy.js} +15 -16
- package/dist/{identity-8vKkyAWm.js.map → identity-DT5VmvXy.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +27 -7
- package/dist/index.js +980 -604
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-CCA1LvtO.js → indexeddb-storage-BJVtiQKm.js} +29 -30
- package/dist/{indexeddb-storage-CCA1LvtO.js.map → indexeddb-storage-BJVtiQKm.js.map} +1 -1
- package/dist/{indexeddb-storage-BTfIFRHF.cjs → indexeddb-storage-CIoW21Xd.cjs} +2 -2
- package/dist/{indexeddb-storage-BTfIFRHF.cjs.map → indexeddb-storage-CIoW21Xd.cjs.map} +1 -1
- package/dist/interactions-DTgKy_6K.js +119 -0
- package/dist/interactions-DTgKy_6K.js.map +1 -0
- package/dist/interactions-fEN6FbVo.cjs +2 -0
- package/dist/interactions-fEN6FbVo.cjs.map +1 -0
- package/dist/{journey-BUJ4WJxP.js → journey-CuJrHzEg.js} +18 -19
- package/dist/{journey-BUJ4WJxP.js.map → journey-CuJrHzEg.js.map} +1 -1
- package/dist/{journey-B_tTnvac.cjs → journey-pffMVMfa.cjs} +2 -2
- package/dist/{journey-B_tTnvac.cjs.map → journey-pffMVMfa.cjs.map} +1 -1
- package/dist/keys-BHhw_0Wh.cjs.map +1 -1
- package/dist/{keys-D5r_GH9q.js → keys-BU9j5YqW.js} +2 -3
- package/dist/{keys-D5r_GH9q.js.map → keys-BU9j5YqW.js.map} +1 -1
- package/dist/library-console-C1m6g1BR.js +13 -0
- package/dist/library-console-C1m6g1BR.js.map +1 -0
- package/dist/library-console-D2GY9Or6.cjs +2 -0
- package/dist/library-console-D2GY9Or6.cjs.map +1 -0
- package/dist/{library-request-BaZOi4eg.cjs → library-request-1BX_UlaX.cjs} +2 -2
- package/dist/{library-request-BaZOi4eg.cjs.map → library-request-1BX_UlaX.cjs.map} +1 -1
- package/dist/library-request-BQBT9N9Q.js +24 -0
- package/dist/{library-request-BKOcaKtQ.js.map → library-request-BQBT9N9Q.js.map} +1 -1
- package/dist/lifecycle-2EtUaRpo.cjs +2 -0
- package/dist/lifecycle-2EtUaRpo.cjs.map +1 -0
- package/dist/lifecycle-BaKx_-32.js +55 -0
- package/dist/lifecycle-BaKx_-32.js.map +1 -0
- package/dist/log-record-CAoGBBf3.js +16 -0
- package/dist/log-record-CAoGBBf3.js.map +1 -0
- package/dist/log-record-i9zOTkpQ.cjs +2 -0
- package/dist/log-record-i9zOTkpQ.cjs.map +1 -0
- package/dist/{long-frames-CF3qiSAX.cjs → long-frames-BVg4i5SC.cjs} +2 -2
- package/dist/{long-frames-CF3qiSAX.cjs.map → long-frames-BVg4i5SC.cjs.map} +1 -1
- package/dist/{long-frames-DI5ypfAF.js → long-frames-Czk7IupC.js} +4 -5
- package/dist/{long-frames-DI5ypfAF.js.map → long-frames-Czk7IupC.js.map} +1 -1
- package/dist/models/config.d.ts +168 -4
- package/dist/models/health.d.ts +25 -0
- package/dist/models/metric.d.ts +13 -0
- package/dist/models/storage.d.ts +5 -0
- package/dist/{network-DdzXDI3J.js → network-DBNwApoF.js} +117 -70
- package/dist/network-DBNwApoF.js.map +1 -0
- package/dist/network-xbbuvG_6.cjs +2 -0
- package/dist/network-xbbuvG_6.cjs.map +1 -0
- package/dist/openfin-Bxelt0yg.js +7 -0
- package/dist/{openfin-BwEN0uj4.js.map → openfin-Bxelt0yg.js.map} +1 -1
- package/dist/openfin-DtH2f7zX.cjs.map +1 -1
- package/dist/otlp-BDvFrLnc.cjs +2 -0
- package/dist/otlp-BDvFrLnc.cjs.map +1 -0
- package/dist/otlp-BTJdIa6F.js +81 -0
- package/dist/otlp-BTJdIa6F.js.map +1 -0
- package/dist/patch-BX8KrPCT.cjs.map +1 -1
- package/dist/{patch-CCWfuEY7.js → patch-UdPz1ea8.js} +2 -3
- package/dist/{patch-CCWfuEY7.js.map → patch-UdPz1ea8.js.map} +1 -1
- package/dist/{platform-DBSKTvFn.cjs → platform-C2Ez5kDc.cjs} +2 -2
- package/dist/{platform-DBSKTvFn.cjs.map → platform-C2Ez5kDc.cjs.map} +1 -1
- package/dist/{platform-Bw1btWCT.js → platform-DkcuXwe-.js} +5 -6
- package/dist/{platform-Bw1btWCT.js.map → platform-DkcuXwe-.js.map} +1 -1
- package/dist/remote-rules-Cfb4K-Nl.js +98 -0
- package/dist/remote-rules-Cfb4K-Nl.js.map +1 -0
- package/dist/remote-rules-vzvk7aKf.cjs +2 -0
- package/dist/remote-rules-vzvk7aKf.cjs.map +1 -0
- package/dist/reports-Dk2YhKIh.cjs +2 -0
- package/dist/reports-Dk2YhKIh.cjs.map +1 -0
- package/dist/reports-TA-zInnq.js +70 -0
- package/dist/reports-TA-zInnq.js.map +1 -0
- package/dist/resource-timing-BLv3EA2A.js +76 -0
- package/dist/resource-timing-BLv3EA2A.js.map +1 -0
- package/dist/resource-timing-Cysw1S1f.cjs +2 -0
- package/dist/resource-timing-Cysw1S1f.cjs.map +1 -0
- package/dist/sampling-C4VV-1MS.js +60 -0
- package/dist/sampling-C4VV-1MS.js.map +1 -0
- package/dist/sampling-Ckh2yW9k.cjs +2 -0
- package/dist/sampling-Ckh2yW9k.cjs.map +1 -0
- package/dist/sanitize-6ymPlVvP.js +112 -0
- package/dist/sanitize-6ymPlVvP.js.map +1 -0
- package/dist/sanitize-BAWzkZt0.cjs +2 -0
- package/dist/sanitize-BAWzkZt0.cjs.map +1 -0
- package/dist/select-ZF4by-lF.cjs +3 -0
- package/dist/select-ZF4by-lF.cjs.map +1 -0
- package/dist/select-xtQaenIi.js +270 -0
- package/dist/select-xtQaenIi.js.map +1 -0
- package/dist/{sender-DUUmSglb.js → sender-CiMHC9YG.js} +202 -509
- package/dist/sender-CiMHC9YG.js.map +1 -0
- package/dist/sender-D5wBoXA8.cjs +2 -0
- package/dist/sender-D5wBoXA8.cjs.map +1 -0
- package/dist/storage/persistence.d.ts +8 -0
- package/dist/storage-BA9RqRO-.cjs.map +1 -1
- package/dist/{storage-w7Tslvlq.js → storage-DZwed89z.js} +2 -3
- package/dist/storage-DZwed89z.js.map +1 -0
- package/dist/storm-CYi9Swpx.cjs +2 -0
- package/dist/{storm-CNZjsw4T.cjs.map → storm-CYi9Swpx.cjs.map} +1 -1
- package/dist/{storm-Daq2jGHU.js → storm-VR024_QN.js} +4 -5
- package/dist/{storm-Daq2jGHU.js.map → storm-VR024_QN.js.map} +1 -1
- package/dist/transport/headers.d.ts +8 -0
- package/dist/transport/http-transport.d.ts +2 -6
- package/dist/transport/serializers/otlp.d.ts +14 -0
- package/dist/transport/status-transport.d.ts +5 -2
- package/dist/transport/worker-client.d.ts +14 -0
- package/dist/transport/worker-entry.d.ts +5 -0
- package/dist/transport/worker-protocol.d.ts +36 -0
- package/dist/transport/worker-server.d.ts +3 -0
- package/dist/transport/worker-transport.d.ts +9 -0
- package/dist/{types-BR9t_w28.js → types-BAerHgCq.js} +2 -3
- package/dist/types-BAerHgCq.js.map +1 -0
- package/dist/types-C7WNpnG1.cjs.map +1 -1
- package/dist/unclean-exit-CwcUhFOn.js +62 -0
- package/dist/unclean-exit-CwcUhFOn.js.map +1 -0
- package/dist/unclean-exit-DFUN57wY.cjs +2 -0
- package/dist/unclean-exit-DFUN57wY.cjs.map +1 -0
- package/dist/user-timing-C9kfRq3J.cjs +2 -0
- package/dist/user-timing-C9kfRq3J.cjs.map +1 -0
- package/dist/user-timing-_jZIhDKI.js +63 -0
- package/dist/user-timing-_jZIhDKI.js.map +1 -0
- package/dist/{web-socket-BacvKOvD.cjs → web-socket-BWUoqBh8.cjs} +2 -2
- package/dist/{web-socket-BacvKOvD.cjs.map → web-socket-BWUoqBh8.cjs.map} +1 -1
- package/dist/{web-socket-CpsD8WAa.js → web-socket-CV7yIMnm.js} +7 -8
- package/dist/{web-socket-CpsD8WAa.js.map → web-socket-CV7yIMnm.js.map} +1 -1
- package/dist/{web-vitals-Bflr5jSA.js → web-vitals-Bq4WFHQo.js} +2 -3
- package/dist/{web-vitals-Bflr5jSA.js.map → web-vitals-Bq4WFHQo.js.map} +1 -1
- package/dist/web-vitals-DFuoTQbZ.cjs.map +1 -1
- package/dist/worker-protocol-Bai7GAIA.cjs +2 -0
- package/dist/worker-protocol-Bai7GAIA.cjs.map +1 -0
- package/dist/worker-protocol-CrsdSDLn.js +49 -0
- package/dist/worker-protocol-CrsdSDLn.js.map +1 -0
- package/dist/worker-server-BrIYkfoa.cjs +2 -0
- package/dist/worker-server-BrIYkfoa.cjs.map +1 -0
- package/dist/worker-server-Dp5HYm4b.js +83 -0
- package/dist/worker-server-Dp5HYm4b.js.map +1 -0
- package/dist/worker-transport-Bwej4N2e.cjs +2 -0
- package/dist/worker-transport-Bwej4N2e.cjs.map +1 -0
- package/dist/worker-transport-D6jtgpqN.js +199 -0
- package/dist/worker-transport-D6jtgpqN.js.map +1 -0
- package/package.json +31 -41
- package/dist/bus-BW6N-pY8.cjs +0 -2
- package/dist/bus-BW6N-pY8.cjs.map +0 -1
- package/dist/bus-DeOPHWaD.js.map +0 -1
- package/dist/console-Ce6heqZZ.cjs +0 -2
- package/dist/console-Ce6heqZZ.cjs.map +0 -1
- package/dist/constants-CN7GE1Lt.js +0 -246
- package/dist/constants-CN7GE1Lt.js.map +0 -1
- package/dist/constants-CW-MlHdY.cjs +0 -2
- package/dist/constants-CW-MlHdY.cjs.map +0 -1
- package/dist/interactions-BUDLxbv1.js +0 -74
- package/dist/interactions-BUDLxbv1.js.map +0 -1
- package/dist/interactions-NHbLKrqe.cjs +0 -2
- package/dist/interactions-NHbLKrqe.cjs.map +0 -1
- package/dist/library-request-BKOcaKtQ.js +0 -25
- package/dist/network-CF8UO5PK.cjs +0 -2
- package/dist/network-CF8UO5PK.cjs.map +0 -1
- package/dist/network-DdzXDI3J.js.map +0 -1
- package/dist/openfin-BwEN0uj4.js +0 -8
- package/dist/remote-rules-DIcC5vVC.js +0 -91
- package/dist/remote-rules-DIcC5vVC.js.map +0 -1
- package/dist/remote-rules-DpFmOef2.cjs +0 -2
- package/dist/remote-rules-DpFmOef2.cjs.map +0 -1
- package/dist/sampling-BVjspJWu.cjs +0 -2
- package/dist/sampling-BVjspJWu.cjs.map +0 -1
- package/dist/sampling-Cm3WhI0a.js +0 -76
- package/dist/sampling-Cm3WhI0a.js.map +0 -1
- package/dist/sanitize-C-ahCFsG.js +0 -123
- package/dist/sanitize-C-ahCFsG.js.map +0 -1
- package/dist/sanitize-DHucKGdi.cjs +0 -2
- package/dist/sanitize-DHucKGdi.cjs.map +0 -1
- package/dist/sender-D3fRCR8d.cjs +0 -3
- package/dist/sender-D3fRCR8d.cjs.map +0 -1
- package/dist/sender-DUUmSglb.js.map +0 -1
- package/dist/storage-w7Tslvlq.js.map +0 -1
- package/dist/storm-CNZjsw4T.cjs +0 -2
- package/dist/types-BR9t_w28.js.map +0 -1
package/bin/uiobs.mjs
ADDED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants-
|
|
2
|
-
//# sourceMappingURL=batch-
|
|
1
|
+
const e=require("./constants-DqKJH_MP.cjs"),t=require("./identity-Cxgj6pZX.cjs");function n(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`id`),n=Reflect.get(e,`createdAt`),r=Reflect.get(e,`attempts`),i=Reflect.get(e,`records`);return typeof t==`string`&&typeof n==`number`&&typeof r==`number`&&Array.isArray(i)}function r(e,n){if(e.records.length<2)return null;let r=Math.floor(e.records.length/2),i=r=>({id:t.i(n),records:r,createdAt:e.createdAt,attempts:e.attempts,routingContextId:e.routingContextId,persistenceNamespace:e.persistenceNamespace});return[i(e.records.slice(0,r)),i(e.records.slice(r))]}function i(e,t){let n=e;if(typeof n!=`object`||!n)return;let r=Reflect.get(n,`attributes`);if(typeof r==`object`&&r)return Reflect.get(r,t)}function a(t){return i(t,e.g)===e.Ot}function o(e){return e.reduce((e,t)=>e+t.records.length,0)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
|
2
|
+
//# sourceMappingURL=batch-C8OcWR2L.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-
|
|
1
|
+
{"version":3,"file":"batch-C8OcWR2L.cjs","names":["newId","ATTR_LOG_TYPE","LOG_TYPE_ACTION","require_constants","require_identity","isLogBatch","value","id","createdAt","attempts","records","splitBatch","batch","middle","halve","diagnostics","attributeOf","record","attributes","key","isActionRecord","countRecords","batches","total"],"sources":["../src/models/batch.ts"],"sourcesContent":["// src/models/batch.ts\n//\n// A batch of log records for delivery to the ingest endpoint.\n\nimport { ATTR_LOG_TYPE, LOG_TYPE_ACTION } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { newId } from \"../utils/identity\";\nimport type { LogRecord } from \"./log-record\";\n\n/**\n * A batch of records with a stable id used for server-side deduplication across retries.\n * @see {@link splitBatch}\n */\nexport interface LogBatch {\n /** Application namespace that owns this stored batch. */\n readonly persistenceNamespace?: string;\n /** Delivery context id. It does not change. With isolation, a batch without this id stays stored. */\n readonly routingContextId?: string;\n /** Deduplication key. It stays the same across retries and reloads. */\n id: string;\n /** Records to deliver, in log order. */\n records: LogRecord[];\n /** Batch creation time, in epoch milliseconds. */\n createdAt: number;\n /** Delivery attempts so far. */\n attempts: number;\n}\n\n/**\n * Tells if a value from storage has all fields of a batch. `keyOf` cannot match\n * an entry without `id` after delivery. The library then retries that entry with no\n * end, and the entry blocks each batch behind it. An entry without `attempts` counts\n * as NaN. That count never reaches `maxAttempts`. Thus the library never drops the\n * entry as a dead letter.\n * @param value Parsed storage entry.\n * @returns True when each required field is present and has the correct type.\n */\nexport function isLogBatch(value: unknown): value is LogBatch {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const id: unknown = Reflect.get(value, \"id\");\n const createdAt: unknown = Reflect.get(value, \"createdAt\");\n const attempts: unknown = Reflect.get(value, \"attempts\");\n const records: unknown = Reflect.get(value, \"records\");\n\n return (\n typeof id === \"string\" &&\n typeof createdAt === \"number\" &&\n typeof attempts === \"number\" &&\n Array.isArray(records)\n );\n}\n\n/**\n * Splits a batch that the server rejected as too large into two halves.\n * Each half gets a new id. Each half keeps the age and attempts of the original batch.\n * @param batch The rejected batch.\n * @param diagnostics Diagnostics reporter for the new batch ids.\n * @returns Two batches, or `null` if a single record is already over the limit.\n */\nexport function splitBatch(batch: LogBatch, diagnostics: Diagnostics): [LogBatch, LogBatch] | null {\n if (batch.records.length < 2) {\n return null;\n }\n\n const middle = Math.floor(batch.records.length / 2);\n const halve = (records: LogRecord[]): LogBatch => ({\n id: newId(diagnostics),\n records,\n createdAt: batch.createdAt,\n attempts: batch.attempts,\n routingContextId: batch.routingContextId,\n persistenceNamespace: batch.persistenceNamespace,\n });\n\n return [halve(batch.records.slice(0, middle)), halve(batch.records.slice(middle))];\n}\n\n/**\n * Reads one attribute of a record. A record from storage can be corrupt. It can be null or have\n * no attributes.\n * @param record Record to read.\n * @param key Attribute key.\n * @returns The attribute value, or undefined for a corrupt record.\n */\nexport function attributeOf(record: LogRecord, key: string): unknown {\n const value: unknown = record;\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n\n const attributes: unknown = Reflect.get(value, \"attributes\");\n if (typeof attributes !== \"object\" || attributes === null) {\n return undefined;\n }\n\n return Reflect.get(attributes, key);\n}\n\n/**\n * Tests if a record is an action. A corrupt record from storage is not an action.\n * @param record Record to test.\n * @returns True for an action record.\n */\nexport function isActionRecord(record: LogRecord): boolean {\n return attributeOf(record, ATTR_LOG_TYPE) === LOG_TYPE_ACTION;\n}\n\n/**\n * Returns the total record count of the batches.\n * @param batches Batches to measure.\n * @returns Total record count.\n */\nexport function countRecords(batches: readonly LogBatch[]): number {\n return batches.reduce((total, batch) => total + batch.records.length, 0);\n}\n"],"mappings":"A,iFAqCA,SAAgBK,EAAW,EAAmC,CAC5D,GAAI,OAAOC,GAAU,WAAYA,EAC/B,MAAO,GAGT,IAAMC,EAAc,QAAQ,IAAID,EAAO,IAAI,EACrCE,EAAqB,QAAQ,IAAIF,EAAO,WAAW,EACnDG,EAAoB,QAAQ,IAAIH,EAAO,UAAU,EACjDI,EAAmB,QAAQ,IAAIJ,EAAO,SAAS,EAErD,OACE,OAAOC,GAAO,UACd,OAAOC,GAAc,UACrB,OAAOC,GAAa,UACpB,MAAM,QAAQC,CAAO,CAEzB,CASA,SAAgBC,EAAW,EAAiB,EAAuD,CACjG,GAAIC,EAAM,QAAQ,OAAS,EACzB,OAAO,KAGT,IAAMC,EAAS,KAAK,MAAMD,EAAM,QAAQ,OAAS,CAAC,EAC5CE,EAAS,IAAoC,CACjD,GAAId,EAAAA,EAAMe,CAAW,EACrB,UACA,UAAWH,EAAM,UACjB,SAAUA,EAAM,SAChB,iBAAkBA,EAAM,iBACxB,qBAAsBA,EAAM,oBAC9B,GAEA,MAAO,CAACE,EAAMF,EAAM,QAAQ,MAAM,EAAGC,CAAM,CAAC,EAAGC,EAAMF,EAAM,QAAQ,MAAMC,CAAM,CAAC,CAAC,CACnF,CASA,SAAgBG,EAAY,EAAmB,EAAsB,CACnE,IAAMV,EAAiBW,EACvB,GAAI,OAAOX,GAAU,WAAYA,EAC/B,OAGF,IAAMY,EAAsB,QAAQ,IAAIZ,EAAO,YAAY,EAC3D,GAAI,OAAOY,GAAe,UAAYA,EAItC,OAAO,QAAQ,IAAIA,EAAYC,CAAG,CACpC,CAOA,SAAgBC,EAAe,EAA4B,CACzD,OAAOJ,EAAYC,EAAQhB,EAAAA,CAAa,IAAMC,EAAAA,EAChD,CAOA,SAAgBmB,EAAa,EAAsC,CACjE,OAAOC,EAAQ,QAAQ,EAAO,IAAUC,EAAQX,EAAM,QAAQ,OAAQ,CAAC,CACzE,C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as n } from "./identity-
|
|
3
|
-
|
|
1
|
+
import { Ot as e, g as t } from "./constants-zyrqveN4.js";
|
|
2
|
+
import { i as n } from "./identity-DT5VmvXy.js";
|
|
3
|
+
// src/models/batch.ts
|
|
4
4
|
function r(e) {
|
|
5
5
|
if (typeof e != "object" || !e) return !1;
|
|
6
6
|
let t = Reflect.get(e, "id"), n = Reflect.get(e, "createdAt"), r = Reflect.get(e, "attempts"), i = Reflect.get(e, "records");
|
|
@@ -25,12 +25,11 @@ function a(e, t) {
|
|
|
25
25
|
if (typeof r == "object" && r) return Reflect.get(r, t);
|
|
26
26
|
}
|
|
27
27
|
function o(n) {
|
|
28
|
-
return a(n,
|
|
28
|
+
return a(n, t) === e;
|
|
29
29
|
}
|
|
30
30
|
function s(e) {
|
|
31
31
|
return e.reduce((e, t) => e + t.records.length, 0);
|
|
32
32
|
}
|
|
33
|
-
//#endregion
|
|
34
33
|
export { i as a, r as i, s as n, o as r, a as t };
|
|
35
34
|
|
|
36
|
-
//# sourceMappingURL=batch-
|
|
35
|
+
//# sourceMappingURL=batch-CL9uWYY3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-
|
|
1
|
+
{"version":3,"file":"batch-CL9uWYY3.js","names":["LOG_TYPE_ACTION","ATTR_LOG_TYPE","newId","isLogBatch","value","id","createdAt","attempts","records","splitBatch","batch","middle","halve","diagnostics","attributeOf","record","attributes","key","isActionRecord","countRecords","batches","total"],"sources":["../src/models/batch.ts"],"sourcesContent":["// src/models/batch.ts\n//\n// A batch of log records for delivery to the ingest endpoint.\n\nimport { ATTR_LOG_TYPE, LOG_TYPE_ACTION } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { newId } from \"../utils/identity\";\nimport type { LogRecord } from \"./log-record\";\n\n/**\n * A batch of records with a stable id used for server-side deduplication across retries.\n * @see {@link splitBatch}\n */\nexport interface LogBatch {\n /** Application namespace that owns this stored batch. */\n readonly persistenceNamespace?: string;\n /** Delivery context id. It does not change. With isolation, a batch without this id stays stored. */\n readonly routingContextId?: string;\n /** Deduplication key. It stays the same across retries and reloads. */\n id: string;\n /** Records to deliver, in log order. */\n records: LogRecord[];\n /** Batch creation time, in epoch milliseconds. */\n createdAt: number;\n /** Delivery attempts so far. */\n attempts: number;\n}\n\n/**\n * Tells if a value from storage has all fields of a batch. `keyOf` cannot match\n * an entry without `id` after delivery. The library then retries that entry with no\n * end, and the entry blocks each batch behind it. An entry without `attempts` counts\n * as NaN. That count never reaches `maxAttempts`. Thus the library never drops the\n * entry as a dead letter.\n * @param value Parsed storage entry.\n * @returns True when each required field is present and has the correct type.\n */\nexport function isLogBatch(value: unknown): value is LogBatch {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const id: unknown = Reflect.get(value, \"id\");\n const createdAt: unknown = Reflect.get(value, \"createdAt\");\n const attempts: unknown = Reflect.get(value, \"attempts\");\n const records: unknown = Reflect.get(value, \"records\");\n\n return (\n typeof id === \"string\" &&\n typeof createdAt === \"number\" &&\n typeof attempts === \"number\" &&\n Array.isArray(records)\n );\n}\n\n/**\n * Splits a batch that the server rejected as too large into two halves.\n * Each half gets a new id. Each half keeps the age and attempts of the original batch.\n * @param batch The rejected batch.\n * @param diagnostics Diagnostics reporter for the new batch ids.\n * @returns Two batches, or `null` if a single record is already over the limit.\n */\nexport function splitBatch(batch: LogBatch, diagnostics: Diagnostics): [LogBatch, LogBatch] | null {\n if (batch.records.length < 2) {\n return null;\n }\n\n const middle = Math.floor(batch.records.length / 2);\n const halve = (records: LogRecord[]): LogBatch => ({\n id: newId(diagnostics),\n records,\n createdAt: batch.createdAt,\n attempts: batch.attempts,\n routingContextId: batch.routingContextId,\n persistenceNamespace: batch.persistenceNamespace,\n });\n\n return [halve(batch.records.slice(0, middle)), halve(batch.records.slice(middle))];\n}\n\n/**\n * Reads one attribute of a record. A record from storage can be corrupt. It can be null or have\n * no attributes.\n * @param record Record to read.\n * @param key Attribute key.\n * @returns The attribute value, or undefined for a corrupt record.\n */\nexport function attributeOf(record: LogRecord, key: string): unknown {\n const value: unknown = record;\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n\n const attributes: unknown = Reflect.get(value, \"attributes\");\n if (typeof attributes !== \"object\" || attributes === null) {\n return undefined;\n }\n\n return Reflect.get(attributes, key);\n}\n\n/**\n * Tests if a record is an action. A corrupt record from storage is not an action.\n * @param record Record to test.\n * @returns True for an action record.\n */\nexport function isActionRecord(record: LogRecord): boolean {\n return attributeOf(record, ATTR_LOG_TYPE) === LOG_TYPE_ACTION;\n}\n\n/**\n * Returns the total record count of the batches.\n * @param batches Batches to measure.\n * @returns Total record count.\n */\nexport function countRecords(batches: readonly LogBatch[]): number {\n return batches.reduce((total, batch) => total + batch.records.length, 0);\n}\n"],"mappings":";;;AAqCA,SAAgBG,EAAW,GAAmC;CAC5D,IAAI,OAAOC,KAAU,aAAYA,GAC/B,OAAO;CAGT,IAAMC,IAAc,QAAQ,IAAID,GAAO,IAAI,GACrCE,IAAqB,QAAQ,IAAIF,GAAO,WAAW,GACnDG,IAAoB,QAAQ,IAAIH,GAAO,UAAU,GACjDI,IAAmB,QAAQ,IAAIJ,GAAO,SAAS;CAErD,OACE,OAAOC,KAAO,YACd,OAAOC,KAAc,YACrB,OAAOC,KAAa,YACpB,MAAM,QAAQC,CAAO;AAEzB;AASA,SAAgBC,EAAW,GAAiB,GAAuD;CACjG,IAAIC,EAAM,QAAQ,SAAS,GACzB,OAAO;CAGT,IAAMC,IAAS,KAAK,MAAMD,EAAM,QAAQ,SAAS,CAAC,GAC5CE,KAAS,OAAoC;EACjD,IAAIV,EAAMW,CAAW;EACrB;EACA,WAAWH,EAAM;EACjB,UAAUA,EAAM;EAChB,kBAAkBA,EAAM;EACxB,sBAAsBA,EAAM;CAC9B;CAEA,OAAO,CAACE,EAAMF,EAAM,QAAQ,MAAM,GAAGC,CAAM,CAAC,GAAGC,EAAMF,EAAM,QAAQ,MAAMC,CAAM,CAAC,CAAC;AACnF;AASA,SAAgBG,EAAY,GAAmB,GAAsB;CACnE,IAAMV,IAAiBW;CACvB,IAAI,OAAOX,KAAU,aAAYA,GAC/B;CAGF,IAAMY,IAAsB,QAAQ,IAAIZ,GAAO,YAAY;CAC3D,IAAI,OAAOY,KAAe,YAAYA,GAItC,OAAO,QAAQ,IAAIA,GAAYC,CAAG;AACpC;AAOA,SAAgBC,EAAe,GAA4B;CACzD,OAAOJ,EAAYC,GAAQd,CAAa,MAAMD;AAChD;AAOA,SAAgBmB,EAAa,GAAsC;CACjE,OAAOC,EAAQ,QAAQ,GAAO,MAAUC,IAAQX,EAAM,QAAQ,QAAQ,CAAC;AACzE"}
|
package/dist/bus/bus.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export declare class Bus {
|
|
|
46
46
|
private readonly rates;
|
|
47
47
|
/** Message counts for each named source or link in the current rate window. */
|
|
48
48
|
private readonly channelRates;
|
|
49
|
+
/** Reply of each same-origin child on the direct link. A weak reply frees a navigated frame. */
|
|
50
|
+
private readonly directReplies;
|
|
49
51
|
/**
|
|
50
52
|
* Checks if this source can receive a control message. A window can read a message
|
|
51
53
|
* even when its address names another window.
|
|
@@ -78,6 +80,19 @@ export declare class Bus {
|
|
|
78
80
|
* @param openFin True to send it to OpenFin views too.
|
|
79
81
|
*/
|
|
80
82
|
private passContext;
|
|
83
|
+
/**
|
|
84
|
+
* Sends a security context message to each same-origin child on the direct link.
|
|
85
|
+
* It drops a child that is closed, freed or no longer permitted.
|
|
86
|
+
* @param message Security context message.
|
|
87
|
+
*/
|
|
88
|
+
private postToDirectChildren;
|
|
89
|
+
/**
|
|
90
|
+
* Keeps the reply of a direct child for the next context id. It drops each closed child.
|
|
91
|
+
* A removed frame then does not keep its document in memory.
|
|
92
|
+
* @param peer Window of the child.
|
|
93
|
+
* @param reply Reply callback of the child.
|
|
94
|
+
*/
|
|
95
|
+
private keepDirectReply;
|
|
81
96
|
/** Current bus role. The default is "sender". */
|
|
82
97
|
private role;
|
|
83
98
|
/** Upstream forwarding link, or null when acting as sender. */
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { n as
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
function g(
|
|
10
|
-
if (typeof
|
|
11
|
-
let n =
|
|
1
|
+
import { M as e, O as t, Xt as n, bn as r, dn as i, j as a, k as o } from "./constants-zyrqveN4.js";
|
|
2
|
+
import { r as s } from "./journey-CuJrHzEg.js";
|
|
3
|
+
import { n as c, t as l } from "./remote-rules-Cfb4K-Nl.js";
|
|
4
|
+
import { n as u, t as d } from "./log-record-CAoGBBf3.js";
|
|
5
|
+
import { t as f } from "./openfin-Bxelt0yg.js";
|
|
6
|
+
import { n as p, t as m } from "./fixed-window-Dq3MLUUv.js";
|
|
7
|
+
import { r as h } from "./deadline-BOjOxNHj.js";
|
|
8
|
+
// src/bus/validation.ts
|
|
9
|
+
function g(t) {
|
|
10
|
+
if (typeof t != "object" || !t) return !1;
|
|
11
|
+
let n = t;
|
|
12
12
|
if (typeof n.from != "string" || !n.from || typeof n.t != "string") return !1;
|
|
13
|
-
let
|
|
13
|
+
let i = (e) => typeof n[e] == "string";
|
|
14
14
|
switch (n.t) {
|
|
15
|
-
case
|
|
16
|
-
case
|
|
17
|
-
case
|
|
18
|
-
case
|
|
19
|
-
case
|
|
20
|
-
case
|
|
21
|
-
case
|
|
22
|
-
case
|
|
23
|
-
case
|
|
15
|
+
case e.hello:
|
|
16
|
+
case e.tab: return i("tabId");
|
|
17
|
+
case e.welcome: return i("to") && i("tabId") && (n.routingContextId === void 0 || i("routingContextId"));
|
|
18
|
+
case e.journeyRequest:
|
|
19
|
+
case e.samplingRequest: return !0;
|
|
20
|
+
case e.securityContext: return i("id") && n.id !== "";
|
|
21
|
+
case e.journey: return (n.to === void 0 || i("to")) && "journey" in n;
|
|
22
|
+
case e.sampling: return i("to") && "rules" in n;
|
|
23
|
+
case e.records: return Array.isArray(n.records) && (n.routingContextId === void 0 || i("routingContextId")) && n.records.every((e) => !u(e) || !d(e.severityText) ? !1 : !Array.isArray(e.attributes) && !Array.isArray(e.resource) && /^\d+$/.test(e.timeUnixNano) && (e.observedTimeUnixNano === void 0 || /^\d+$/.test(e.observedTimeUnixNano)) && typeof e.traceId == "string" && /^(?:[a-f\d]{32})?$/.test(e.traceId) && typeof e.spanId == "string" && /^(?:[a-f\d]{16})?$/.test(e.spanId) && Number.isInteger(e.traceFlags) && e.traceFlags >= 0 && e.traceFlags <= 255 && e.severityNumber === r[e.severityText]);
|
|
24
24
|
default: return !1;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function _(t) {
|
|
27
|
+
// src/models/bus.ts
|
|
28
|
+
function _(e) {
|
|
30
29
|
return {
|
|
31
|
-
p:
|
|
32
|
-
m:
|
|
30
|
+
p: a,
|
|
31
|
+
m: e
|
|
33
32
|
};
|
|
34
33
|
}
|
|
35
34
|
function v(e) {
|
|
@@ -39,9 +38,8 @@ function v(e) {
|
|
|
39
38
|
let n = t.m;
|
|
40
39
|
return typeof n.t == "string" ? n : null;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var y = Symbol.for(n), b = "null";
|
|
41
|
+
// src/bus/links.ts
|
|
42
|
+
var y = Symbol.for(i), b = "null";
|
|
45
43
|
function x(e, t) {
|
|
46
44
|
return e === b ? `The bus ignored ${t} from a sandboxed frame. The frame has an opaque origin. Set bus.mode: "sender" in the frame. Add allow-same-origin to the sandbox attribute only for content that you trust.` : `The bus ignored ${t} from ${e}. If you own this origin, add it to bus.trustedOrigins.`;
|
|
47
45
|
}
|
|
@@ -183,7 +181,7 @@ function E(e, t, n) {
|
|
|
183
181
|
}) : null;
|
|
184
182
|
}
|
|
185
183
|
function D(e, t, n, r) {
|
|
186
|
-
let i =
|
|
184
|
+
let i = f()?.InterApplicationBus;
|
|
187
185
|
if (!i) return null;
|
|
188
186
|
if (!t) return r.report("openfin.unavailable", "OpenFin gives no application uuid. The InterApplicationBus link stays closed."), null;
|
|
189
187
|
let a = `${e}.${t}`;
|
|
@@ -241,10 +239,9 @@ function k(e, t, n) {
|
|
|
241
239
|
}
|
|
242
240
|
};
|
|
243
241
|
}
|
|
244
|
-
|
|
245
|
-
//#region src/bus/bus.ts
|
|
242
|
+
// src/bus/bus.ts
|
|
246
243
|
var A = {
|
|
247
|
-
timeoutMs:
|
|
244
|
+
timeoutMs: o,
|
|
248
245
|
maxAttempts: 3
|
|
249
246
|
}, j = [
|
|
250
247
|
"children",
|
|
@@ -261,9 +258,10 @@ var A = {
|
|
|
261
258
|
sources = /* @__PURE__ */ new Map();
|
|
262
259
|
rates = /* @__PURE__ */ new WeakMap();
|
|
263
260
|
channelRates = /* @__PURE__ */ new Map();
|
|
264
|
-
|
|
261
|
+
directReplies = /* @__PURE__ */ new Map();
|
|
262
|
+
mayPost(t, n) {
|
|
265
263
|
let r = this.sources.get(n)?.permissions;
|
|
266
|
-
return r ?
|
|
264
|
+
return r ? t.t === e.journey ? r.includes("journey:read") : t.t === e.journeyRequest ? r.includes("journey:write") : t.t !== e.sampling || r.includes("sampling:read") : this.config.bus.sourcePolicy === "trusted-origin";
|
|
267
265
|
}
|
|
268
266
|
registerFrame(e, t) {
|
|
269
267
|
let n = typeof HTMLIFrameElement > "u" ? void 0 : HTMLIFrameElement, r = n && e instanceof n ? e.contentWindow : e;
|
|
@@ -284,13 +282,29 @@ var A = {
|
|
|
284
282
|
rotateContext() {
|
|
285
283
|
this.passContext(this.role === "sender");
|
|
286
284
|
}
|
|
287
|
-
passContext(
|
|
285
|
+
passContext(t) {
|
|
288
286
|
let n = {
|
|
289
|
-
t:
|
|
287
|
+
t: e.securityContext,
|
|
290
288
|
from: this.contextId,
|
|
291
289
|
id: this.config.securityContext.id
|
|
292
290
|
};
|
|
293
|
-
this.postOver("children", n), this.postOver("worker", n),
|
|
291
|
+
this.postOver("children", n), this.postOver("worker", n), this.postToDirectChildren(n), t && this.postOver("openfin", n);
|
|
292
|
+
}
|
|
293
|
+
postToDirectChildren(e) {
|
|
294
|
+
for (let [t, n] of this.directReplies) {
|
|
295
|
+
let r = n.deref();
|
|
296
|
+
!r || t.closed || !this.isRegistered(t, location.origin) ? this.directReplies.delete(t) : this.diagnostics.guard("bus.send_failed", "The reply to a direct child failed.", () => {
|
|
297
|
+
r(e, {
|
|
298
|
+
link: "direct",
|
|
299
|
+
origin: "same-origin",
|
|
300
|
+
peer: t
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
keepDirectReply(e, t) {
|
|
306
|
+
for (let e of this.directReplies.keys()) e.closed && this.directReplies.delete(e);
|
|
307
|
+
this.directReplies.set(e, new WeakRef(t));
|
|
294
308
|
}
|
|
295
309
|
role = "sender";
|
|
296
310
|
upstream = null;
|
|
@@ -330,25 +344,25 @@ var A = {
|
|
|
330
344
|
via: i ? n.kind : "none"
|
|
331
345
|
}), this.announce(), this.role;
|
|
332
346
|
}
|
|
333
|
-
sendRecords(
|
|
334
|
-
let { maxRecordsPerMessage: n, maxMessageBytes: r } = this.config.bus, i = new TextEncoder(), a = (e) => r ? i.encode(JSON.stringify(e)).length : 0, o = (
|
|
335
|
-
t:
|
|
347
|
+
sendRecords(t) {
|
|
348
|
+
let { maxRecordsPerMessage: n, maxMessageBytes: r } = this.config.bus, i = new TextEncoder(), a = (e) => r ? i.encode(JSON.stringify(e)).length : 0, o = (t) => ({
|
|
349
|
+
t: e.records,
|
|
336
350
|
from: this.contextId,
|
|
337
|
-
records:
|
|
351
|
+
records: t,
|
|
338
352
|
routingContextId: this.config.securityContext.id || void 0
|
|
339
353
|
}), s = a(o([])), c = [], l = s;
|
|
340
|
-
for (let
|
|
341
|
-
let
|
|
342
|
-
if (r && s +
|
|
354
|
+
for (let e of t) {
|
|
355
|
+
let t = a(e);
|
|
356
|
+
if (r && s + t > r) {
|
|
343
357
|
this.diagnostics.count("bus.rejected_message");
|
|
344
358
|
continue;
|
|
345
359
|
}
|
|
346
360
|
let i = +(c.length > 0);
|
|
347
|
-
(n && c.length >= n || r && l + i +
|
|
361
|
+
(n && c.length >= n || r && l + i + t > r) && (this.upstream?.post(o(c)), c = [], l = s), l += +(c.length > 0) + t, c.push(e);
|
|
348
362
|
}
|
|
349
363
|
c.length > 0 && this.upstream?.post(o(c));
|
|
350
364
|
}
|
|
351
|
-
acceptDirect(
|
|
365
|
+
acceptDirect(t, n, r) {
|
|
352
366
|
let i = {
|
|
353
367
|
link: "direct",
|
|
354
368
|
origin: "same-origin",
|
|
@@ -359,11 +373,11 @@ var A = {
|
|
|
359
373
|
n(e, i);
|
|
360
374
|
}
|
|
361
375
|
};
|
|
362
|
-
this.acceptsMessage(
|
|
363
|
-
t:
|
|
376
|
+
this.acceptsMessage(t, a, !0) && t.from !== this.contextId && (r && this.keepDirectReply(r, n), t.t === e.samplingRequest ? n(this.rulesAnswer(t.from), i) : (t.t === e.records && !this.awaitingWelcome && t.routingContextId !== this.config.securityContext.id && n({
|
|
377
|
+
t: e.securityContext,
|
|
364
378
|
from: this.contextId,
|
|
365
379
|
id: this.config.securityContext.id
|
|
366
|
-
}, i), this.routeMessage(
|
|
380
|
+
}, i), this.routeMessage(t, a)));
|
|
367
381
|
}
|
|
368
382
|
attachWorker(e, t = {}) {
|
|
369
383
|
let n = {
|
|
@@ -383,15 +397,15 @@ var A = {
|
|
|
383
397
|
t >= 0 && this.links.splice(t, 1), this.sources.get(e) === n && this.sources.delete(e);
|
|
384
398
|
};
|
|
385
399
|
}
|
|
386
|
-
broadcastJourney(
|
|
400
|
+
broadcastJourney(t) {
|
|
387
401
|
this.postJourney({
|
|
388
|
-
t:
|
|
402
|
+
t: e.journey,
|
|
389
403
|
from: this.contextId,
|
|
390
|
-
journey:
|
|
404
|
+
journey: t
|
|
391
405
|
});
|
|
392
406
|
}
|
|
393
407
|
destroy() {
|
|
394
|
-
this.sources.clear(), this.destroyed = !0, clearInterval(this.rulesPoll), this.rulesPoll = void 0;
|
|
408
|
+
this.sources.clear(), this.directReplies.clear(), this.destroyed = !0, clearInterval(this.rulesPoll), this.rulesPoll = void 0;
|
|
395
409
|
for (let e of this.allLinks()) e.close();
|
|
396
410
|
this.links.length = 0, this.upstream = null, this.ownerId = null, this.openFinLink = null;
|
|
397
411
|
}
|
|
@@ -418,7 +432,7 @@ var A = {
|
|
|
418
432
|
}
|
|
419
433
|
return r || this.diagnostics.count("bus.rejected_message"), r;
|
|
420
434
|
}
|
|
421
|
-
passesChecks(
|
|
435
|
+
passesChecks(t, n, r) {
|
|
422
436
|
let { bus: i } = this.config, a = typeof n.peer == "object" ? this.sources.get(n.peer) : void 0;
|
|
423
437
|
if (r && i.sourcePolicy === "registered" && !a) return !1;
|
|
424
438
|
let o = typeof n.peer == "object" ? n.peer : void 0, s = typeof n.peer == "string" ? n.peer : n.link, c = Date.now(), l = (o ? this.rates.get(o) : this.channelRates.get(s)) ?? {
|
|
@@ -427,72 +441,72 @@ var A = {
|
|
|
427
441
|
};
|
|
428
442
|
if (o) this.rates.set(o, l);
|
|
429
443
|
else {
|
|
430
|
-
for (let [e, t] of this.channelRates)
|
|
444
|
+
for (let [e, t] of this.channelRates) p(t, 1e3, c) && this.channelRates.delete(e);
|
|
431
445
|
if (i.maxTrackedSources && this.channelRates.size >= i.maxTrackedSources && !this.channelRates.has(s)) return !1;
|
|
432
446
|
this.channelRates.set(s, l);
|
|
433
447
|
}
|
|
434
|
-
if (!
|
|
435
|
-
let u = JSON.stringify(
|
|
448
|
+
if (!m(l, i.maxMessagesPerSecond || Infinity, 1e3)) return !1;
|
|
449
|
+
let u = JSON.stringify(t, (e, t) => {
|
|
436
450
|
if (i.validation === "strict" && typeof t == "number" && !Number.isFinite(t)) throw Error("Non-finite value");
|
|
437
451
|
return t;
|
|
438
452
|
});
|
|
439
|
-
if (i.maxMessageBytes && new TextEncoder().encode(u).length > i.maxMessageBytes || i.validation === "strict" && !g(
|
|
453
|
+
if (i.maxMessageBytes && new TextEncoder().encode(u).length > i.maxMessageBytes || i.validation === "strict" && !g(t) || t.t === e.records && i.maxRecordsPerMessage && t.records.length > i.maxRecordsPerMessage) return !1;
|
|
440
454
|
if (a) {
|
|
441
|
-
let n =
|
|
455
|
+
let n = t.t === e.records ? "records" : t.t === e.journey ? "journey:write" : t.t === e.journeyRequest ? "journey:read" : t.t === e.samplingRequest ? "sampling:read" : void 0;
|
|
442
456
|
if (n && !a.permissions?.includes(n)) return !1;
|
|
443
457
|
}
|
|
444
|
-
return r && (
|
|
458
|
+
return r && (t.t === e.sampling || t.t === e.securityContext) ? !1 : i.sourcePolicy !== "registered" || n.link !== "broadcast" || t.t !== e.records;
|
|
445
459
|
}
|
|
446
|
-
routeMessage(
|
|
447
|
-
if (
|
|
448
|
-
case
|
|
460
|
+
routeMessage(t, n) {
|
|
461
|
+
if (t.from !== this.contextId) switch (t.t) {
|
|
462
|
+
case e.hello:
|
|
449
463
|
this.canOwn(n.link) && this.answer(n, {
|
|
450
|
-
t:
|
|
464
|
+
t: e.welcome,
|
|
451
465
|
from: this.contextId,
|
|
452
|
-
to:
|
|
466
|
+
to: t.from,
|
|
453
467
|
tabId: this.tabId,
|
|
454
468
|
routingContextId: this.awaitingWelcome ? void 0 : this.config.securityContext.id || void 0
|
|
455
469
|
});
|
|
456
470
|
break;
|
|
457
|
-
case
|
|
458
|
-
if (
|
|
471
|
+
case e.welcome:
|
|
472
|
+
if (t.to !== this.contextId) break;
|
|
459
473
|
if (this.awaitingWelcome?.link === n.link || this.upstream?.kind === n.link && this.ownerId === null) {
|
|
460
|
-
this.ownerId =
|
|
461
|
-
let
|
|
462
|
-
if (
|
|
463
|
-
this.config.securityContext.id !==
|
|
474
|
+
this.ownerId = t.from, this.ownerPeer = n.peer;
|
|
475
|
+
let e = this.config.securityContext.id;
|
|
476
|
+
if (t.routingContextId && this.handlers.onSecurityContext?.(t.routingContextId) === !1) break;
|
|
477
|
+
this.config.securityContext.id !== e && this.passContext(!1), this.awaitingWelcome?.settle(!0);
|
|
464
478
|
}
|
|
465
479
|
break;
|
|
466
|
-
case
|
|
467
|
-
if (this.config.securityContext.isolation && this.config.securityContext.id &&
|
|
480
|
+
case e.records:
|
|
481
|
+
if (this.config.securityContext.isolation && this.config.securityContext.id && t.routingContextId !== this.config.securityContext.id) {
|
|
468
482
|
this.diagnostics.count("security.context_mismatch");
|
|
469
483
|
break;
|
|
470
484
|
}
|
|
471
|
-
this.role === "sender" ? this.handlers.onRecords(
|
|
485
|
+
this.role === "sender" ? this.handlers.onRecords(t.records) : this.upstream && this.canRelay(n.link) && this.upstream.post(t);
|
|
472
486
|
break;
|
|
473
|
-
case
|
|
474
|
-
n.link === this.upstream?.kind && this.ownerId ===
|
|
487
|
+
case e.securityContext:
|
|
488
|
+
n.link === this.upstream?.kind && this.ownerId === t.from && this.ownerPeer === n.peer && this.handlers.onSecurityContext?.(t.id) !== !1 && this.rotateContext();
|
|
475
489
|
break;
|
|
476
|
-
case
|
|
477
|
-
this.acceptsJourney(
|
|
490
|
+
case e.journey:
|
|
491
|
+
this.acceptsJourney(t, n) && this.applyJourney(t.journey);
|
|
478
492
|
break;
|
|
479
|
-
case
|
|
493
|
+
case e.journeyRequest: {
|
|
480
494
|
let r = this.handlers.onJourneyRequest();
|
|
481
495
|
r && this.journeyLink(n.link) && this.answer(n, {
|
|
482
|
-
t:
|
|
496
|
+
t: e.journey,
|
|
483
497
|
from: this.contextId,
|
|
484
|
-
to:
|
|
498
|
+
to: t.from,
|
|
485
499
|
journey: r
|
|
486
500
|
});
|
|
487
501
|
break;
|
|
488
502
|
}
|
|
489
|
-
case
|
|
490
|
-
(this.role === "forwarder" ? n.link !== this.upstream?.kind : this.canOwn(n.link)) && this.answer(n, this.rulesAnswer(
|
|
503
|
+
case e.samplingRequest:
|
|
504
|
+
(this.role === "forwarder" ? n.link !== this.upstream?.kind : this.canOwn(n.link)) && this.answer(n, this.rulesAnswer(t.from));
|
|
491
505
|
break;
|
|
492
|
-
case
|
|
493
|
-
this.acceptsRules(
|
|
506
|
+
case e.sampling:
|
|
507
|
+
this.acceptsRules(t.to, n) && this.applyRules(t.rules);
|
|
494
508
|
break;
|
|
495
|
-
case
|
|
509
|
+
case e.tab: n.link === "broadcast" && t.tabId === this.tabId && this.contextId > t.from && this.handlers.onTabConflict();
|
|
496
510
|
}
|
|
497
511
|
}
|
|
498
512
|
answer(e, t) {
|
|
@@ -508,7 +522,7 @@ var A = {
|
|
|
508
522
|
let e = this.config.bus.openFinRole;
|
|
509
523
|
if (e !== "auto") return e === "provider";
|
|
510
524
|
if (this.platform.platform !== "openfin" && this.platform.platform !== "openfin_web") return !1;
|
|
511
|
-
let t =
|
|
525
|
+
let t = f()?.me;
|
|
512
526
|
return !t?.identity || t.isView ? !1 : !!(t.identity.name && t.identity.name === t.identity.uuid);
|
|
513
527
|
}
|
|
514
528
|
orphanPolicy() {
|
|
@@ -529,7 +543,7 @@ var A = {
|
|
|
529
543
|
let e = (e) => {
|
|
530
544
|
e && this.links.push(e);
|
|
531
545
|
};
|
|
532
|
-
this.platform.isWorker || this.ensureChildrenLink(), this.platform.isTopLevelDocument && e(E(
|
|
546
|
+
this.platform.isWorker || this.ensureChildrenLink(), this.platform.isTopLevelDocument && e(E(t, this.receive, this.diagnostics)), (this.platform.platform === "openfin" || this.platform.platform === "openfin_web") && e(this.ensureOpenFinLink());
|
|
533
547
|
}
|
|
534
548
|
ensureChildrenLink() {
|
|
535
549
|
if (this.links.some((e) => e.kind === "children")) return;
|
|
@@ -545,22 +559,22 @@ var A = {
|
|
|
545
559
|
e && this.links.push(e);
|
|
546
560
|
}
|
|
547
561
|
ensureOpenFinLink() {
|
|
548
|
-
return this.openFinLink ??= D(
|
|
562
|
+
return this.openFinLink ??= D(t, this.platform.openfinUuid, this.receive, this.diagnostics), this.openFinLink;
|
|
549
563
|
}
|
|
550
|
-
handshake(
|
|
564
|
+
handshake(t) {
|
|
551
565
|
return new Promise((n) => {
|
|
552
566
|
let r = !1, i = (e) => {
|
|
553
567
|
r || (r = !0, this.awaitingWelcome = null, clearTimeout(a), n(e));
|
|
554
568
|
};
|
|
555
569
|
this.awaitingWelcome = {
|
|
556
|
-
link:
|
|
570
|
+
link: t.kind,
|
|
557
571
|
settle: i
|
|
558
572
|
};
|
|
559
573
|
let a = setTimeout(() => {
|
|
560
574
|
i(!1);
|
|
561
575
|
}, this.handshakeOptions.timeoutMs);
|
|
562
|
-
|
|
563
|
-
t:
|
|
576
|
+
h(a), t.post({
|
|
577
|
+
t: e.hello,
|
|
564
578
|
from: this.contextId,
|
|
565
579
|
tabId: this.tabId
|
|
566
580
|
});
|
|
@@ -568,15 +582,15 @@ var A = {
|
|
|
568
582
|
}
|
|
569
583
|
announce() {
|
|
570
584
|
this.postOver("broadcast", {
|
|
571
|
-
t:
|
|
585
|
+
t: e.tab,
|
|
572
586
|
from: this.contextId,
|
|
573
587
|
tabId: this.tabId
|
|
574
588
|
}), this.upstream && this.ownerId === null && this.upstream.post({
|
|
575
|
-
t:
|
|
589
|
+
t: e.hello,
|
|
576
590
|
from: this.contextId,
|
|
577
591
|
tabId: this.tabId
|
|
578
592
|
}), this.postJourney({
|
|
579
|
-
t:
|
|
593
|
+
t: e.journeyRequest,
|
|
580
594
|
from: this.contextId
|
|
581
595
|
}), this.pollRules(), this.passContext(!1);
|
|
582
596
|
}
|
|
@@ -601,15 +615,15 @@ var A = {
|
|
|
601
615
|
this.handlers.onJourney(null);
|
|
602
616
|
return;
|
|
603
617
|
}
|
|
604
|
-
let t =
|
|
618
|
+
let t = s(e);
|
|
605
619
|
t === null ? this.diagnostics.report("record.dropped_malformed", "The bus dropped a journey message. Its payload is not a journey.", { type: "journey" }) : this.handlers.onJourney(t);
|
|
606
620
|
}
|
|
607
|
-
rulesAnswer(
|
|
621
|
+
rulesAnswer(t) {
|
|
608
622
|
let n = this.handlers.remote.sampling?.wire() ?? null;
|
|
609
623
|
return {
|
|
610
|
-
t:
|
|
624
|
+
t: e.sampling,
|
|
611
625
|
from: this.contextId,
|
|
612
|
-
to:
|
|
626
|
+
to: t,
|
|
613
627
|
rules: n
|
|
614
628
|
};
|
|
615
629
|
}
|
|
@@ -623,25 +637,24 @@ var A = {
|
|
|
623
637
|
}
|
|
624
638
|
applyRules(e) {
|
|
625
639
|
if (e === null) {
|
|
626
|
-
|
|
640
|
+
l(this.handlers.remote, this.config, null);
|
|
627
641
|
return;
|
|
628
642
|
}
|
|
629
|
-
let t =
|
|
630
|
-
t &&
|
|
643
|
+
let t = c(e, this.diagnostics);
|
|
644
|
+
t && l(this.handlers.remote, this.config, t);
|
|
631
645
|
}
|
|
632
646
|
pollRules() {
|
|
633
|
-
let { upstream:
|
|
634
|
-
if (this.destroyed || this.role !== "forwarder" || !
|
|
635
|
-
let
|
|
636
|
-
this.config.sampling.remote &&
|
|
637
|
-
t:
|
|
647
|
+
let { upstream: t } = this;
|
|
648
|
+
if (this.destroyed || this.role !== "forwarder" || !t) return;
|
|
649
|
+
let r = () => {
|
|
650
|
+
this.config.sampling.remote && t.post({
|
|
651
|
+
t: e.samplingRequest,
|
|
638
652
|
from: this.contextId
|
|
639
653
|
});
|
|
640
654
|
};
|
|
641
|
-
|
|
655
|
+
r(), this.rulesPoll = setInterval(r, n), h(this.rulesPoll);
|
|
642
656
|
}
|
|
643
657
|
};
|
|
644
|
-
//#endregion
|
|
645
658
|
export { M as Bus };
|
|
646
659
|
|
|
647
|
-
//# sourceMappingURL=bus-
|
|
660
|
+
//# sourceMappingURL=bus-BZ0GldpT.js.map
|