@theia/plugin-metrics 1.77.0-next.43 → 1.77.0-next.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-metrics.d.ts","sourceRoot":"","sources":["../../src/node/plugin-metrics.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAEnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAExE,qBACa,yBAA0B,YAAW,mBAAmB;IAGjE,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,wBAAwB,CAAC;IAGhE,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,2BAA2B,CAAC;IAEhE,OAAO,CAAC,OAAO,CAAS;IAExB,UAAU,IAAI,MAAM;IAIpB,eAAe,IAAI,IAAI;CAM1B"}
1
+ {"version":3,"file":"plugin-metrics.d.ts","sourceRoot":"","sources":["../../src/node/plugin-metrics.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAEnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAExE,qBACa,yBAA0B,YAAW,mBAAmB;IAGjE,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,wBAAwB,CAAC;IAGhE,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,2BAA2B,CAAC;IAEhE,OAAO,CAAC,OAAO,CAAM;IAErB,UAAU,IAAI,MAAM;IAIpB,eAAe,IAAI,IAAI;CAM1B"}
@@ -22,6 +22,9 @@ const metrics_protocol_1 = require("../common/metrics-protocol");
22
22
  const metrics_contributor_1 = require("./metrics-contributor");
23
23
  const metric_string_generator_1 = require("./metric-string-generator");
24
24
  let PluginMetricsContribution = class PluginMetricsContribution {
25
+ constructor() {
26
+ this.metrics = '';
27
+ }
25
28
  getMetrics() {
26
29
  return this.metrics;
27
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-metrics.js","sourceRoot":"","sources":["../../src/node/plugin-metrics.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAkE;AAElE,iEAA6D;AAC7D,+DAAiE;AACjE,uEAAwE;AAGjE,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAUlC,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,eAAe;QACX,WAAW,CAAC,GAAG,EAAE;YACb,MAAM,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC;YAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;QAC5E,CAAC,EAAE,kCAAe,CAAC,CAAC;IACxB,CAAC;CACJ,CAAA;AApBY,8DAAyB;AAGf;IADlB,IAAA,kBAAM,EAAC,8CAAwB,CAAC;sCACM,8CAAwB;qEAAC;AAG7C;IADlB,IAAA,kBAAM,EAAC,qDAA2B,CAAC;sCACA,qDAA2B;kEAAC;oCANvD,yBAAyB;IADrC,IAAA,sBAAU,GAAE;GACA,yBAAyB,CAoBrC"}
1
+ {"version":3,"file":"plugin-metrics.js","sourceRoot":"","sources":["../../src/node/plugin-metrics.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAkE;AAElE,iEAA6D;AAC7D,+DAAiE;AACjE,uEAAwE;AAGjE,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAA/B;QAQK,YAAO,GAAG,EAAE,CAAC;IAYzB,CAAC;IAVG,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,eAAe;QACX,WAAW,CAAC,GAAG,EAAE;YACb,MAAM,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC;YAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;QAC5E,CAAC,EAAE,kCAAe,CAAC,CAAC;IACxB,CAAC;CACJ,CAAA;AApBY,8DAAyB;AAGf;IADlB,IAAA,kBAAM,EAAC,8CAAwB,CAAC;sCACM,8CAAwB;qEAAC;AAG7C;IADlB,IAAA,kBAAM,EAAC,qDAA2B,CAAC;sCACA,qDAA2B;kEAAC;oCANvD,yBAAyB;IADrC,IAAA,sBAAU,GAAE;GACA,yBAAyB,CAoBrC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plugin-metrics.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-metrics.spec.d.ts","sourceRoot":"","sources":["../../src/node/plugin-metrics.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 Sahil Gupta and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const inversify_1 = require("@theia/core/shared/inversify");
19
+ const plugin_metrics_1 = require("./plugin-metrics");
20
+ const metrics_contributor_1 = require("./metrics-contributor");
21
+ const metric_string_generator_1 = require("./metric-string-generator");
22
+ const metrics_protocol_1 = require("../common/metrics-protocol");
23
+ const assert = require("assert");
24
+ const sinon = require("sinon");
25
+ const COLLECTED_METRICS = 'test_metric 42\n';
26
+ describe('PluginMetricsContribution:', () => {
27
+ let testContainer;
28
+ let contribution;
29
+ let clock;
30
+ beforeEach(() => {
31
+ clock = sinon.useFakeTimers();
32
+ testContainer = new inversify_1.Container();
33
+ // Stub dependencies
34
+ const stubContributor = {
35
+ reconcile: () => ({})
36
+ };
37
+ const stubGenerator = {
38
+ getMetricsString: () => COLLECTED_METRICS
39
+ };
40
+ const module = new inversify_1.ContainerModule(bind => {
41
+ bind(metrics_contributor_1.PluginMetricsContributor).toConstantValue(stubContributor);
42
+ bind(metric_string_generator_1.PluginMetricStringGenerator).toConstantValue(stubGenerator);
43
+ bind(plugin_metrics_1.PluginMetricsContribution).toSelf().inSingletonScope();
44
+ });
45
+ testContainer.load(module);
46
+ contribution = testContainer.get(plugin_metrics_1.PluginMetricsContribution);
47
+ });
48
+ afterEach(() => {
49
+ clock.restore();
50
+ });
51
+ describe('getMetrics:', () => {
52
+ it('should return empty string instead of undefined before startCollecting runs', () => {
53
+ // When getMetrics is called before the interval has collected any data
54
+ const metrics = contribution.getMetrics();
55
+ // Then it returns an empty string, not undefined
56
+ assert.strictEqual(metrics, '');
57
+ assert.strictEqual(typeof metrics, 'string');
58
+ });
59
+ it('should return the collected metrics once the collection interval has elapsed', () => {
60
+ contribution.startCollecting();
61
+ // The interval has not yet fired, so nothing has been collected
62
+ assert.strictEqual(contribution.getMetrics(), '');
63
+ clock.tick(metrics_protocol_1.METRICS_TIMEOUT);
64
+ // The interval has fired, so the generated metrics string is returned
65
+ assert.strictEqual(contribution.getMetrics(), COLLECTED_METRICS);
66
+ });
67
+ });
68
+ });
69
+ //# sourceMappingURL=plugin-metrics.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-metrics.spec.js","sourceRoot":"","sources":["../../src/node/plugin-metrics.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,6CAA6C;AAC7C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA0E;AAC1E,qDAA6D;AAC7D,+DAAiE;AACjE,uEAAwE;AACxE,iEAA6D;AAC7D,iCAAiC;AACjC,+BAA+B;AAE/B,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAE7C,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACxC,IAAI,aAAwB,CAAC;IAC7B,IAAI,YAAuC,CAAC;IAC5C,IAAI,KAA4B,CAAC;IAEjC,UAAU,CAAC,GAAG,EAAE;QACZ,KAAK,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QAC9B,aAAa,GAAG,IAAI,qBAAS,EAAE,CAAC;QAEhC,oBAAoB;QACpB,MAAM,eAAe,GAAsC;YACvD,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;SACxB,CAAC;QACF,MAAM,aAAa,GAAyC;YACxD,gBAAgB,EAAE,GAAG,EAAE,CAAC,iBAAiB;SAC5C,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;YACt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theia/plugin-metrics",
3
- "version": "1.77.0-next.43+5dbb84a9f",
3
+ "version": "1.77.0-next.49+19f3aa746",
4
4
  "description": "Theia - Plugin Metrics",
5
5
  "dependencies": {
6
- "@theia/core": "1.77.0-next.43+5dbb84a9f",
7
- "@theia/metrics": "1.77.0-next.43+5dbb84a9f",
6
+ "@theia/core": "1.77.0-next.49+19f3aa746",
7
+ "@theia/metrics": "1.77.0-next.49+19f3aa746",
8
8
  "@theia/monaco-editor-core": "1.108.201",
9
- "@theia/plugin": "1.77.0-next.43+5dbb84a9f",
10
- "@theia/plugin-ext": "1.77.0-next.43+5dbb84a9f",
9
+ "@theia/plugin": "1.77.0-next.49+19f3aa746",
10
+ "@theia/plugin-ext": "1.77.0-next.49+19f3aa746",
11
11
  "tslib": "^2.8.1"
12
12
  },
13
13
  "publishConfig": {
@@ -50,5 +50,5 @@
50
50
  "nyc": {
51
51
  "extends": "../../configs/nyc.json"
52
52
  },
53
- "gitHead": "5dbb84a9f43e9287fe3d6f0f52ee1dd2c3c4a20f"
53
+ "gitHead": "19f3aa746ad23091ba655bc1509d18e4f961fb39"
54
54
  }
@@ -0,0 +1,80 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2026 Sahil Gupta and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { Container, ContainerModule } from '@theia/core/shared/inversify';
18
+ import { PluginMetricsContribution } from './plugin-metrics';
19
+ import { PluginMetricsContributor } from './metrics-contributor';
20
+ import { PluginMetricStringGenerator } from './metric-string-generator';
21
+ import { METRICS_TIMEOUT } from '../common/metrics-protocol';
22
+ import * as assert from 'assert';
23
+ import * as sinon from 'sinon';
24
+
25
+ const COLLECTED_METRICS = 'test_metric 42\n';
26
+
27
+ describe('PluginMetricsContribution:', () => {
28
+ let testContainer: Container;
29
+ let contribution: PluginMetricsContribution;
30
+ let clock: sinon.SinonFakeTimers;
31
+
32
+ beforeEach(() => {
33
+ clock = sinon.useFakeTimers();
34
+ testContainer = new Container();
35
+
36
+ // Stub dependencies
37
+ const stubContributor: Partial<PluginMetricsContributor> = {
38
+ reconcile: () => ({})
39
+ };
40
+ const stubGenerator: Partial<PluginMetricStringGenerator> = {
41
+ getMetricsString: () => COLLECTED_METRICS
42
+ };
43
+
44
+ const module = new ContainerModule(bind => {
45
+ bind(PluginMetricsContributor).toConstantValue(stubContributor as unknown as PluginMetricsContributor);
46
+ bind(PluginMetricStringGenerator).toConstantValue(stubGenerator as unknown as PluginMetricStringGenerator);
47
+ bind(PluginMetricsContribution).toSelf().inSingletonScope();
48
+ });
49
+
50
+ testContainer.load(module);
51
+ contribution = testContainer.get(PluginMetricsContribution);
52
+ });
53
+
54
+ afterEach(() => {
55
+ clock.restore();
56
+ });
57
+
58
+ describe('getMetrics:', () => {
59
+ it('should return empty string instead of undefined before startCollecting runs', () => {
60
+ // When getMetrics is called before the interval has collected any data
61
+ const metrics = contribution.getMetrics();
62
+
63
+ // Then it returns an empty string, not undefined
64
+ assert.strictEqual(metrics, '');
65
+ assert.strictEqual(typeof metrics, 'string');
66
+ });
67
+
68
+ it('should return the collected metrics once the collection interval has elapsed', () => {
69
+ contribution.startCollecting();
70
+
71
+ // The interval has not yet fired, so nothing has been collected
72
+ assert.strictEqual(contribution.getMetrics(), '');
73
+
74
+ clock.tick(METRICS_TIMEOUT);
75
+
76
+ // The interval has fired, so the generated metrics string is returned
77
+ assert.strictEqual(contribution.getMetrics(), COLLECTED_METRICS);
78
+ });
79
+ });
80
+ });
@@ -29,7 +29,7 @@ export class PluginMetricsContribution implements MetricsContribution {
29
29
  @inject(PluginMetricStringGenerator)
30
30
  protected readonly stringGenerator: PluginMetricStringGenerator;
31
31
 
32
- private metrics: string;
32
+ private metrics = '';
33
33
 
34
34
  getMetrics(): string {
35
35
  return this.metrics;