@theia/plugin-utils 1.75.0-next.28

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.
Files changed (122) hide show
  1. package/README.md +30 -0
  2. package/lib/common/constants.d.ts +12 -0
  3. package/lib/common/constants.d.ts.map +1 -0
  4. package/lib/common/constants.js +30 -0
  5. package/lib/common/constants.js.map +1 -0
  6. package/lib/common/constants.spec.d.ts +2 -0
  7. package/lib/common/constants.spec.d.ts.map +1 -0
  8. package/lib/common/constants.spec.js +33 -0
  9. package/lib/common/constants.spec.js.map +1 -0
  10. package/lib/common/contribution-types.d.ts +648 -0
  11. package/lib/common/contribution-types.d.ts.map +1 -0
  12. package/lib/common/contribution-types.js +30 -0
  13. package/lib/common/contribution-types.js.map +1 -0
  14. package/lib/common/manifest-types.d.ts +105 -0
  15. package/lib/common/manifest-types.d.ts.map +1 -0
  16. package/lib/common/manifest-types.js +31 -0
  17. package/lib/common/manifest-types.js.map +1 -0
  18. package/lib/common/manifest-types.spec.d.ts +2 -0
  19. package/lib/common/manifest-types.spec.d.ts.map +1 -0
  20. package/lib/common/manifest-types.spec.js +35 -0
  21. package/lib/common/manifest-types.spec.js.map +1 -0
  22. package/lib/common/package-nls.d.ts +24 -0
  23. package/lib/common/package-nls.d.ts.map +1 -0
  24. package/lib/common/package-nls.js +82 -0
  25. package/lib/common/package-nls.js.map +1 -0
  26. package/lib/common/package-nls.spec.d.ts +2 -0
  27. package/lib/common/package-nls.spec.d.ts.map +1 -0
  28. package/lib/common/package-nls.spec.js +98 -0
  29. package/lib/common/package-nls.spec.js.map +1 -0
  30. package/lib/common/plugin-activation-events.d.ts +7 -0
  31. package/lib/common/plugin-activation-events.d.ts.map +1 -0
  32. package/lib/common/plugin-activation-events.js +95 -0
  33. package/lib/common/plugin-activation-events.js.map +1 -0
  34. package/lib/common/plugin-activation-events.spec.d.ts +2 -0
  35. package/lib/common/plugin-activation-events.spec.d.ts.map +1 -0
  36. package/lib/common/plugin-activation-events.spec.js +89 -0
  37. package/lib/common/plugin-activation-events.spec.js.map +1 -0
  38. package/lib/common/plugin-manifest.d.ts +10 -0
  39. package/lib/common/plugin-manifest.d.ts.map +1 -0
  40. package/lib/common/plugin-manifest.js +35 -0
  41. package/lib/common/plugin-manifest.js.map +1 -0
  42. package/lib/common/plugin-manifest.spec.d.ts +2 -0
  43. package/lib/common/plugin-manifest.spec.d.ts.map +1 -0
  44. package/lib/common/plugin-manifest.spec.js +83 -0
  45. package/lib/common/plugin-manifest.spec.js.map +1 -0
  46. package/lib/common/plugin-model.d.ts +33 -0
  47. package/lib/common/plugin-model.d.ts.map +1 -0
  48. package/lib/common/plugin-model.js +166 -0
  49. package/lib/common/plugin-model.js.map +1 -0
  50. package/lib/common/plugin-model.spec.d.ts +2 -0
  51. package/lib/common/plugin-model.spec.d.ts.map +1 -0
  52. package/lib/common/plugin-model.spec.js +204 -0
  53. package/lib/common/plugin-model.spec.js.map +1 -0
  54. package/lib/common/protocol-shims.d.ts +128 -0
  55. package/lib/common/protocol-shims.d.ts.map +1 -0
  56. package/lib/common/protocol-shims.js +29 -0
  57. package/lib/common/protocol-shims.js.map +1 -0
  58. package/lib/common/test-helpers.d.ts +5 -0
  59. package/lib/common/test-helpers.d.ts.map +1 -0
  60. package/lib/common/test-helpers.js +41 -0
  61. package/lib/common/test-helpers.js.map +1 -0
  62. package/lib/common/utils.d.ts +20 -0
  63. package/lib/common/utils.d.ts.map +1 -0
  64. package/lib/common/utils.js +74 -0
  65. package/lib/common/utils.js.map +1 -0
  66. package/lib/common/utils.spec.d.ts +2 -0
  67. package/lib/common/utils.spec.d.ts.map +1 -0
  68. package/lib/common/utils.spec.js +77 -0
  69. package/lib/common/utils.spec.js.map +1 -0
  70. package/lib/node/normalize-contributions.d.ts +54 -0
  71. package/lib/node/normalize-contributions.d.ts.map +1 -0
  72. package/lib/node/normalize-contributions.js +985 -0
  73. package/lib/node/normalize-contributions.js.map +1 -0
  74. package/lib/node/normalize-contributions.spec.d.ts +2 -0
  75. package/lib/node/normalize-contributions.spec.d.ts.map +1 -0
  76. package/lib/node/normalize-contributions.spec.js +850 -0
  77. package/lib/node/normalize-contributions.spec.js.map +1 -0
  78. package/lib/node/package-nls.d.ts +3 -0
  79. package/lib/node/package-nls.d.ts.map +1 -0
  80. package/lib/node/package-nls.js +45 -0
  81. package/lib/node/package-nls.js.map +1 -0
  82. package/lib/node/plugin-manifest.d.ts +6 -0
  83. package/lib/node/plugin-manifest.d.ts.map +1 -0
  84. package/lib/node/plugin-manifest.js +26 -0
  85. package/lib/node/plugin-manifest.js.map +1 -0
  86. package/lib/node/plugin-model.d.ts +5 -0
  87. package/lib/node/plugin-model.d.ts.map +1 -0
  88. package/lib/node/plugin-model.js +36 -0
  89. package/lib/node/plugin-model.js.map +1 -0
  90. package/lib/node/read-grammars.d.ts +10 -0
  91. package/lib/node/read-grammars.d.ts.map +1 -0
  92. package/lib/node/read-grammars.js +83 -0
  93. package/lib/node/read-grammars.js.map +1 -0
  94. package/lib/node/read-grammars.spec.d.ts +2 -0
  95. package/lib/node/read-grammars.spec.d.ts.map +1 -0
  96. package/lib/node/read-grammars.spec.js +109 -0
  97. package/lib/node/read-grammars.spec.js.map +1 -0
  98. package/package.json +42 -0
  99. package/src/common/constants.spec.ts +34 -0
  100. package/src/common/constants.ts +35 -0
  101. package/src/common/contribution-types.ts +677 -0
  102. package/src/common/manifest-types.spec.ts +36 -0
  103. package/src/common/manifest-types.ts +126 -0
  104. package/src/common/package-nls.spec.ts +122 -0
  105. package/src/common/package-nls.ts +95 -0
  106. package/src/common/plugin-activation-events.spec.ts +104 -0
  107. package/src/common/plugin-activation-events.ts +102 -0
  108. package/src/common/plugin-manifest.spec.ts +94 -0
  109. package/src/common/plugin-manifest.ts +44 -0
  110. package/src/common/plugin-model.spec.ts +246 -0
  111. package/src/common/plugin-model.ts +194 -0
  112. package/src/common/protocol-shims.ts +148 -0
  113. package/src/common/test-helpers.ts +44 -0
  114. package/src/common/utils.spec.ts +86 -0
  115. package/src/common/utils.ts +81 -0
  116. package/src/node/normalize-contributions.spec.ts +931 -0
  117. package/src/node/normalize-contributions.ts +1098 -0
  118. package/src/node/package-nls.ts +45 -0
  119. package/src/node/plugin-manifest.ts +30 -0
  120. package/src/node/plugin-model.ts +33 -0
  121. package/src/node/read-grammars.spec.ts +128 -0
  122. package/src/node/read-grammars.ts +97 -0
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 Maksim Kachurin 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
+ exports.PluginViewType = exports.CustomEditorPriority = void 0;
19
+ var CustomEditorPriority;
20
+ (function (CustomEditorPriority) {
21
+ CustomEditorPriority["default"] = "default";
22
+ CustomEditorPriority["builtin"] = "builtin";
23
+ CustomEditorPriority["option"] = "option";
24
+ })(CustomEditorPriority || (exports.CustomEditorPriority = CustomEditorPriority = {}));
25
+ var PluginViewType;
26
+ (function (PluginViewType) {
27
+ PluginViewType["Tree"] = "tree";
28
+ PluginViewType["Webview"] = "webview";
29
+ })(PluginViewType || (exports.PluginViewType = PluginViewType = {}));
30
+ //# sourceMappingURL=contribution-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contribution-types.js","sourceRoot":"","sources":["../../src/common/contribution-types.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,iDAAiD;AACjD,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;;;AAuLhF,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC5B,2CAAmB,CAAA;IACnB,2CAAmB,CAAA;IACnB,yCAAiB,CAAA;AACrB,CAAC,EAJW,oBAAoB,oCAApB,oBAAoB,QAI/B;AASD,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,+BAAa,CAAA;IACb,qCAAmB,CAAA;AACvB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB"}
@@ -0,0 +1,105 @@
1
+ import type { NormalizedPluginContribution, PluginManifestContribution } from './contribution-types';
2
+ export declare const PLUGIN_HOST_BACKEND: "main";
3
+ /** Whether a plugin is installed by the system or by a user. */
4
+ export declare enum PluginType {
5
+ System = 0,
6
+ User = 1
7
+ }
8
+ /** Same shape as `PluginPackage.capabilities` in `plugin-protocol.ts`. */
9
+ export interface PluginPackageCapabilities {
10
+ untrustedWorkspaces?: {
11
+ supported: boolean | 'limited';
12
+ description?: string;
13
+ restrictedConfigurations?: string[];
14
+ };
15
+ }
16
+ /**
17
+ * VS Code / Theia extension `package.json` manifest.
18
+ */
19
+ export interface PluginManifest {
20
+ name: string;
21
+ version: string;
22
+ publisher?: string;
23
+ displayName?: string;
24
+ description?: string;
25
+ l10n?: string;
26
+ packagePath: string;
27
+ packageUri?: string;
28
+ engines?: Record<string, string>;
29
+ theiaPlugin?: {
30
+ frontend?: string;
31
+ backend?: string;
32
+ headless?: string;
33
+ };
34
+ main?: string;
35
+ browser?: string;
36
+ extensionKind?: Array<'ui' | 'workspace'>;
37
+ icon?: string;
38
+ type?: 'module' | 'commonjs';
39
+ extensionDependencies?: string[];
40
+ extensionPack?: string[];
41
+ capabilities?: PluginPackageCapabilities;
42
+ /** Raw `contributes` section from `package.json` before normalization. */
43
+ contributes?: PluginManifestContribution;
44
+ activationEvents?: string[];
45
+ }
46
+ export declare function rawContributes(manifest: Pick<PluginManifest, 'contributes'>): PluginManifestContribution;
47
+ export interface PluginEntryPoint {
48
+ frontend?: string;
49
+ backend?: string;
50
+ headless?: string;
51
+ }
52
+ /** Plugin model populated from `package.json`. */
53
+ export interface PluginModel {
54
+ id: string;
55
+ name: string;
56
+ publisher: string;
57
+ version: string;
58
+ displayName: string;
59
+ description: string;
60
+ engine: {
61
+ type: string;
62
+ version: string;
63
+ };
64
+ entryPoint: PluginEntryPoint;
65
+ packageUri: string;
66
+ /**
67
+ * @deprecated since 1.1.0 - because it lead to problems with getting a relative path
68
+ * needed by Icon Themes to correctly load Fonts, use packageUri instead.
69
+ */
70
+ packagePath: string;
71
+ iconUrl?: string;
72
+ l10n?: string;
73
+ readmeUrl?: string;
74
+ licenseUrl?: string;
75
+ untrustedWorkspacesSupport?: boolean | 'limited';
76
+ }
77
+ export interface PluginLifecycle {
78
+ startMethod: string;
79
+ stopMethod: string;
80
+ /** Frontend module name; the frontend plugin should expose this name. */
81
+ frontendModuleName?: string;
82
+ /** Script run before the frontend plugin is loaded. */
83
+ frontendInitPath?: string;
84
+ /** Script run before the backend plugin is loaded. */
85
+ backendInitPath?: string;
86
+ }
87
+ export interface PluginMetadata {
88
+ /** Plugin host id used for RPC routing (e.g. {@link PLUGIN_HOST_BACKEND}). */
89
+ host: string;
90
+ model: PluginModel;
91
+ lifecycle: PluginLifecycle;
92
+ outOfSync: boolean;
93
+ /** Set when the plugin is loaded from a development workspace (e.g. plugin-dev). */
94
+ isUnderDevelopment?: boolean;
95
+ }
96
+ /**
97
+ * Deployed plugin descriptor (runtime + browser-only `list.json`).
98
+ */
99
+ export interface DeployedPlugin<TContributes = NormalizedPluginContribution> {
100
+ /** Defaults to {@link PluginType.System}. */
101
+ type?: PluginType;
102
+ metadata: PluginMetadata;
103
+ contributes?: TContributes;
104
+ }
105
+ //# sourceMappingURL=manifest-types.d.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AC5B,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC3B,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,eAAe,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,oFAAoF;IACpF,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,YAAY,GAAG,4BAA4B;IACvE,6CAA6C;IAC7C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,cAAc,CAAC;IACzB,WAAW,CAAC,EAAE,YAAY,CAAC;CAC9B"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 Maksim Kachurin 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
+ exports.PluginType = exports.PLUGIN_HOST_BACKEND = void 0;
19
+ exports.rawContributes = rawContributes;
20
+ const utils_1 = require("./utils");
21
+ exports.PLUGIN_HOST_BACKEND = 'main';
22
+ /** Whether a plugin is installed by the system or by a user. */
23
+ var PluginType;
24
+ (function (PluginType) {
25
+ PluginType[PluginType["System"] = 0] = "System";
26
+ PluginType[PluginType["User"] = 1] = "User";
27
+ })(PluginType || (exports.PluginType = PluginType = {}));
28
+ function rawContributes(manifest) {
29
+ return (0, utils_1.isObject)(manifest.contributes) ? manifest.contributes : {};
30
+ }
31
+ //# sourceMappingURL=manifest-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-types.js","sourceRoot":"","sources":["../../src/common/manifest-types.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,iDAAiD;AACjD,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;;;AAiDhF,wCAEC;AAjDD,mCAAmC;AAGtB,QAAA,mBAAmB,GAAG,MAAe,CAAC;AAEnD,gEAAgE;AAChE,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,+CAAU,CAAA;IACV,2CAAQ,CAAA;AACZ,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAsCD,SAAgB,cAAc,CAAC,QAA6C;IACxE,OAAO,IAAA,gBAAQ,EAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAyC,CAAC,CAAC,CAAC,EAAE,CAAC;AACpG,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=manifest-types.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-types.spec.d.ts","sourceRoot":"","sources":["../../src/common/manifest-types.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 Maksim Kachurin 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 chai_1 = require("chai");
19
+ const manifest_types_1 = require("./manifest-types");
20
+ describe('manifest-types', () => {
21
+ describe('rawContributes', () => {
22
+ it('returns contributes object when present', () => {
23
+ const contributes = { commands: [{ command: 'x', title: 'X' }] };
24
+ (0, chai_1.expect)((0, manifest_types_1.rawContributes)({ contributes })).to.equal(contributes);
25
+ });
26
+ it('returns empty object when contributes is missing or invalid', () => {
27
+ (0, chai_1.expect)((0, manifest_types_1.rawContributes)({})).to.deep.equal({});
28
+ // eslint-disable-next-line no-null/no-null
29
+ (0, chai_1.expect)((0, manifest_types_1.rawContributes)({ contributes: null })).to.deep.equal({});
30
+ (0, chai_1.expect)((0, manifest_types_1.rawContributes)({ contributes: undefined })).to.deep.equal({});
31
+ (0, chai_1.expect)((0, manifest_types_1.rawContributes)({ contributes: 'invalid' })).to.deep.equal({});
32
+ });
33
+ });
34
+ });
35
+ //# sourceMappingURL=manifest-types.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-types.spec.js","sourceRoot":"","sources":["../../src/common/manifest-types.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,iDAAiD;AACjD,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,+BAA8B;AAC9B,qDAAkD;AAElD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAE5B,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;YAC/C,MAAM,WAAW,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YACjE,IAAA,aAAM,EAAC,IAAA,+BAAc,EAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;YACnE,IAAA,aAAM,EAAC,IAAA,+BAAc,EAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC7C,2CAA2C;YAC3C,IAAA,aAAM,EAAC,IAAA,+BAAc,EAAC,EAAE,WAAW,EAAE,IAA4B,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACxF,IAAA,aAAM,EAAC,IAAA,+BAAc,EAAC,EAAE,WAAW,EAAE,SAAiC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC7F,IAAA,aAAM,EAAC,IAAA,+BAAc,EAAC,EAAE,WAAW,EAAE,SAAiC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjG,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ export interface PackageTranslation {
2
+ translation?: Record<string, string>;
3
+ default?: Record<string, string>;
4
+ }
5
+ interface LocalizeInfo {
6
+ message: string;
7
+ comment?: string;
8
+ }
9
+ export declare function coerceLocalizations(translations: Record<string, string | LocalizeInfo>): Record<string, string>;
10
+ /**
11
+ * Recursively walks `value` and replaces strings matching `%key%` with the result of `resolve(key)`.
12
+ * If `resolve(key)` returns `undefined` or an empty string, the original `%key%` is kept
13
+ * (same as the former worker `localize`: `translations[key] || value`).
14
+ */
15
+ export declare function localizeWithResolver<T>(value: T, resolve: (key: string) => string | undefined): T;
16
+ export type LocalizePackageCallback = (key: string, defaultValue: string) => string;
17
+ /**
18
+ * Recursively replaces %key% strings in value with translations.
19
+ * callback is used when only default (package.nls.json) exists; e.g. backend passes
20
+ * Theia's Localization.localize for fallback, build-time can use (_, d) => d.
21
+ */
22
+ export declare function localizePackage<T>(value: T, translations: PackageTranslation, callback: LocalizePackageCallback): T;
23
+ export {};
24
+ //# sourceMappingURL=package-nls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-nls.d.ts","sourceRoot":"","sources":["../../src/common/package-nls.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,kBAAkB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,UAAU,YAAY;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAa/G;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAAG,CAAC,CAmBjG;AAED,MAAM,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;AAEpF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,YAAY,EAAE,kBAAkB,EAChC,QAAQ,EAAE,uBAAuB,GAClC,CAAC,CAUH"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2021 TypeFox 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
+ exports.coerceLocalizations = coerceLocalizations;
19
+ exports.localizeWithResolver = localizeWithResolver;
20
+ exports.localizePackage = localizePackage;
21
+ const utils_1 = require("./utils");
22
+ function isLocalizeInfo(obj) {
23
+ return (0, utils_1.isObject)(obj) && 'message' in obj && typeof obj.message === 'string';
24
+ }
25
+ function coerceLocalizations(translations) {
26
+ const result = {};
27
+ for (const [key, value] of Object.entries(translations)) {
28
+ if (typeof value === 'string') {
29
+ result[key] = value;
30
+ }
31
+ else if (isLocalizeInfo(value)) {
32
+ result[key] = value.message;
33
+ }
34
+ else {
35
+ // Only strings or LocalizeInfo values are valid
36
+ result[key] = 'INVALID TRANSLATION VALUE';
37
+ }
38
+ }
39
+ return result;
40
+ }
41
+ /**
42
+ * Recursively walks `value` and replaces strings matching `%key%` with the result of `resolve(key)`.
43
+ * If `resolve(key)` returns `undefined` or an empty string, the original `%key%` is kept
44
+ * (same as the former worker `localize`: `translations[key] || value`).
45
+ */
46
+ function localizeWithResolver(value, resolve) {
47
+ if (typeof value === 'string') {
48
+ if (value.length > 2 && value.startsWith('%') && value.endsWith('%')) {
49
+ const replaced = resolve(value.slice(1, -1));
50
+ return (replaced || value);
51
+ }
52
+ return value;
53
+ }
54
+ if (Array.isArray(value)) {
55
+ return value.map(item => localizeWithResolver(item, resolve));
56
+ }
57
+ if ((0, utils_1.isObject)(value)) {
58
+ const result = {};
59
+ for (const [name, item] of Object.entries(value)) {
60
+ result[name] = localizeWithResolver(item, resolve);
61
+ }
62
+ return result;
63
+ }
64
+ return value;
65
+ }
66
+ /**
67
+ * Recursively replaces %key% strings in value with translations.
68
+ * callback is used when only default (package.nls.json) exists; e.g. backend passes
69
+ * Theia's Localization.localize for fallback, build-time can use (_, d) => d.
70
+ */
71
+ function localizePackage(value, translations, callback) {
72
+ return localizeWithResolver(value, key => {
73
+ if (translations.translation && key in translations.translation) {
74
+ return translations.translation[key];
75
+ }
76
+ if (translations.default && key in translations.default) {
77
+ return callback(key, translations.default[key]);
78
+ }
79
+ return undefined;
80
+ });
81
+ }
82
+ //# sourceMappingURL=package-nls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-nls.js","sourceRoot":"","sources":["../../src/common/package-nls.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,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;;AAkBhF,kDAaC;AAOD,oDAmBC;AASD,0CAcC;AA9ED,mCAAmC;AAYnC,SAAS,cAAc,CAAC,GAAY;IAChC,OAAO,IAAA,gBAAQ,EAAC,GAAG,CAAC,IAAI,SAAS,IAAI,GAAG,IAAI,OAAQ,GAA6B,CAAC,OAAO,KAAK,QAAQ,CAAC;AAC3G,CAAC;AAED,SAAgB,mBAAmB,CAAC,YAAmD;IACnF,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1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IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,MAAM,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,MAAW,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAID;;;;GAIG;AACH,SAAgB,eAAe,CAC3B,KAAQ,EACR,YAAgC,EAChC,QAAiC;IAEjC,OAAO,oBAAoB,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;QACrC,IAAI,YAAY,CAAC,WAAW,IAAI,GAAG,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC;YAC9D,OAAO,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,YAAY,CAAC,OAAO,IAAI,GAAG,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;YACtD,OAAO,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=package-nls.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-nls.spec.d.ts","sourceRoot":"","sources":["../../src/common/package-nls.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 Maksim Kachurin 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 chai_1 = require("chai");
19
+ const fs = require("fs-extra");
20
+ const os = require("os");
21
+ const path = require("path");
22
+ const package_nls_1 = require("./package-nls");
23
+ const package_nls_2 = require("../node/package-nls");
24
+ describe('package-nls', () => {
25
+ describe('coerceLocalizations', () => {
26
+ it('passes through string values', () => {
27
+ (0, chai_1.expect)((0, package_nls_1.coerceLocalizations)({ key: 'value' })).to.deep.equal({ key: 'value' });
28
+ });
29
+ it('extracts message from LocalizeInfo objects', () => {
30
+ (0, chai_1.expect)((0, package_nls_1.coerceLocalizations)({ key: { message: 'Hello', comment: 'greeting' } })).to.deep.equal({ key: 'Hello' });
31
+ });
32
+ it('marks invalid values explicitly', () => {
33
+ (0, chai_1.expect)((0, package_nls_1.coerceLocalizations)({ key: 42 })).to.deep.equal({ key: 'INVALID TRANSLATION VALUE' });
34
+ });
35
+ });
36
+ describe('localizeWithResolver', () => {
37
+ it('localizes nested structures and leaves unknown keys unchanged', () => {
38
+ const localized = (0, package_nls_1.localizeWithResolver)({
39
+ title: '%title.key%',
40
+ nested: [{ label: '%nested.key%' }],
41
+ plain: 'unchanged'
42
+ }, key => (key === 'title.key' ? 'Title' : undefined));
43
+ (0, chai_1.expect)(localized).to.deep.equal({
44
+ title: 'Title',
45
+ nested: [{ label: '%nested.key%' }],
46
+ plain: 'unchanged'
47
+ });
48
+ });
49
+ it('keeps %key% when resolve returns undefined or an empty string', () => {
50
+ (0, chai_1.expect)((0, package_nls_1.localizeWithResolver)('%missing.key%', () => undefined)).to.equal('%missing.key%');
51
+ (0, chai_1.expect)((0, package_nls_1.localizeWithResolver)('%empty.key%', () => '')).to.equal('%empty.key%');
52
+ });
53
+ it('ignores strings that are not %key% placeholders', () => {
54
+ (0, chai_1.expect)((0, package_nls_1.localizeWithResolver)('%not-closed', () => 'x')).to.equal('%not-closed');
55
+ (0, chai_1.expect)((0, package_nls_1.localizeWithResolver)('100%', () => 'x')).to.equal('100%');
56
+ });
57
+ });
58
+ describe('localizePackage', () => {
59
+ it('uses translation bundle before default bundle', () => {
60
+ const localized = (0, package_nls_1.localizePackage)({ displayName: '%name.key%' }, {
61
+ translation: { 'name.key': 'Translated' },
62
+ default: { 'name.key': 'Default' }
63
+ }, () => 'callback-should-not-run');
64
+ (0, chai_1.expect)(localized).to.deep.equal({ displayName: 'Translated' });
65
+ });
66
+ it('invokes callback for default bundle when translation is missing', () => {
67
+ const localized = (0, package_nls_1.localizePackage)({ displayName: '%name.key%' }, { default: { 'name.key': 'Default value' } }, (_key, defaultValue) => `from-default:${defaultValue}`);
68
+ (0, chai_1.expect)(localized).to.deep.equal({ displayName: 'from-default:Default value' });
69
+ });
70
+ });
71
+ describe('loadPackageTranslations', () => {
72
+ let pluginRoot;
73
+ beforeEach(async () => {
74
+ pluginRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'package-nls-load-'));
75
+ });
76
+ afterEach(async () => {
77
+ await fs.remove(pluginRoot);
78
+ });
79
+ it('returns an empty object when package.nls.json is missing', async () => {
80
+ (0, chai_1.expect)(await (0, package_nls_2.loadPackageTranslations)(pluginRoot)).to.deep.equal({});
81
+ });
82
+ it('loads the default bundle without a locale', async () => {
83
+ await fs.writeJson(path.join(pluginRoot, 'package.nls.json'), { 'display.name': 'Sample' });
84
+ (0, chai_1.expect)(await (0, package_nls_2.loadPackageTranslations)(pluginRoot)).to.deep.equal({
85
+ default: { 'display.name': 'Sample' }
86
+ });
87
+ });
88
+ it('loads locale-specific translations when present', async () => {
89
+ await fs.writeJson(path.join(pluginRoot, 'package.nls.json'), { 'display.name': 'Sample' });
90
+ await fs.writeJson(path.join(pluginRoot, 'package.nls.de.json'), { 'display.name': 'Beispiel' });
91
+ (0, chai_1.expect)(await (0, package_nls_2.loadPackageTranslations)(pluginRoot, 'de')).to.deep.equal({
92
+ default: { 'display.name': 'Sample' },
93
+ translation: { 'display.name': 'Beispiel' }
94
+ });
95
+ });
96
+ });
97
+ });
98
+ //# sourceMappingURL=package-nls.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-nls.spec.js","sourceRoot":"","sources":["../../src/common/package-nls.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,iDAAiD;AACjD,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,+BAA8B;AAC9B,+BAA+B;AAC/B,yBAAyB;AACzB,6BAA6B;AAC7B,+CAA2F;AAC3F,qDAA8D;AAE9D,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAEzB,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;YACpC,IAAA,aAAM,EAAC,IAAA,iCAAmB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;QAClF,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YAClD,IAAA,aAAM,EAAC,IAAA,iCAAmB,EAAC,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;QACpH,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;YACvC,IAAA,aAAM,EAAC,IAAA,iCAAmB,EAAC,E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AAA,aAAM,EAAC,MAAM,IAAA,qCAAuB,EAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBAClE,OAAO,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE;gBACrC,WAAW,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE;aAC9C,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type PluginManifest } from './manifest-types';
2
+ /**
3
+ * Most activation events can be automatically deduced from the package manifest.
4
+ * This function will update the manifest based on the plugin contributions.
5
+ */
6
+ export declare function updateActivationEvents(manifest: Pick<PluginManifest, 'contributes' | 'activationEvents'>): void;
7
+ //# sourceMappingURL=plugin-activation-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-activation-events.d.ts","sourceRoot":"","sources":["../../src/common/plugin-activation-events.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvE;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,aAAa,GAAG,kBAAkB,CAAC,GAAG,IAAI,CA8B/G"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 TypeFox 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
+ exports.updateActivationEvents = updateActivationEvents;
19
+ const utils_1 = require("./utils");
20
+ const manifest_types_1 = require("./manifest-types");
21
+ /**
22
+ * Most activation events can be automatically deduced from the package manifest.
23
+ * This function will update the manifest based on the plugin contributions.
24
+ */
25
+ function updateActivationEvents(manifest) {
26
+ if (!(0, utils_1.isObject)(manifest) || !(0, utils_1.isObject)(manifest.contributes) || !manifest.contributes) {
27
+ return;
28
+ }
29
+ const activationEvents = new Set((0, utils_1.isStringArray)(manifest.activationEvents) ? manifest.activationEvents : []);
30
+ const contributes = (0, manifest_types_1.rawContributes)(manifest);
31
+ if (contributes.commands) {
32
+ const commands = Array.isArray(contributes.commands) ? contributes.commands : [contributes.commands];
33
+ updateCommandsContributions(commands, activationEvents);
34
+ }
35
+ if ((0, utils_1.isObject)(contributes.views) && !Array.isArray(contributes.views)) {
36
+ const views = (0, utils_1.flatten)(Object.values(contributes.views));
37
+ updateViewsContribution(views, activationEvents);
38
+ }
39
+ if (Array.isArray(contributes.customEditors)) {
40
+ updateCustomEditorsContribution(contributes.customEditors, activationEvents);
41
+ }
42
+ if (Array.isArray(contributes.authentication)) {
43
+ updateAuthenticationProviderContributions(contributes.authentication, activationEvents);
44
+ }
45
+ if (Array.isArray(contributes.languages)) {
46
+ updateLanguageContributions(contributes.languages, activationEvents);
47
+ }
48
+ if (Array.isArray(contributes.notebooks)) {
49
+ updateNotebookContributions(contributes.notebooks, activationEvents);
50
+ }
51
+ manifest.activationEvents = Array.from(activationEvents);
52
+ }
53
+ function updateViewsContribution(views, activationEvents) {
54
+ for (const view of views) {
55
+ if ((0, utils_1.isObject)(view) && typeof view.id === 'string') {
56
+ activationEvents.add(`onView:${view.id}`);
57
+ }
58
+ }
59
+ }
60
+ function updateCustomEditorsContribution(customEditors, activationEvents) {
61
+ for (const customEditor of customEditors) {
62
+ if ((0, utils_1.isObject)(customEditor) && typeof customEditor.viewType === 'string') {
63
+ activationEvents.add(`onCustomEditor:${customEditor.viewType}`);
64
+ }
65
+ }
66
+ }
67
+ function updateCommandsContributions(commands, activationEvents) {
68
+ for (const command of commands) {
69
+ if ((0, utils_1.isObject)(command) && typeof command.command === 'string') {
70
+ activationEvents.add(`onCommand:${command.command}`);
71
+ }
72
+ }
73
+ }
74
+ function updateAuthenticationProviderContributions(authProviders, activationEvents) {
75
+ for (const authProvider of authProviders) {
76
+ if ((0, utils_1.isObject)(authProvider) && typeof authProvider.id === 'string') {
77
+ activationEvents.add(`onAuthenticationRequest:${authProvider.id}`);
78
+ }
79
+ }
80
+ }
81
+ function updateLanguageContributions(languages, activationEvents) {
82
+ for (const language of languages) {
83
+ if ((0, utils_1.isObject)(language) && typeof language.id === 'string') {
84
+ activationEvents.add(`onLanguage:${language.id}`);
85
+ }
86
+ }
87
+ }
88
+ function updateNotebookContributions(notebooks, activationEvents) {
89
+ for (const notebook of notebooks) {
90
+ if ((0, utils_1.isObject)(notebook) && typeof notebook.type === 'string') {
91
+ activationEvents.add(`onNotebookSerializer:${notebook.type}`);
92
+ }
93
+ }
94
+ }
95
+ //# sourceMappingURL=plugin-activation-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-activation-events.js","sourceRoot":"","sources":["../../src/common/plugin-activation-events.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,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;;AAShF,wDA8BC;AArCD,mCAA2D;AAC3D,qDAAuE;AAEvE;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,QAAkE;IACrG,IAAI,CAAC,IAAA,gBAAQ,EAAC,QAAQ,CAAC,IAAI,CAAC,IAAA,gBAAQ,EAAC,QAAQ,CAAC,WAAW,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L,CAAC;AACL,CAAC;AAED,SAAS,yCAAyC,CAAC,aAAwB,EAAE,gBAA6B;IACtG,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACvC,IAAI,IAAA,gBAAQ,EAAC,YAAY,CAAC,IAAI,OAAO,YAAY,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YAChE,gBAAgB,CAAC,GAAG,CAAC,2BAA2B,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;QACvE,CAAC;IACL,CAAC;AACL,CAAC;AAED,SAAS,2BAA2B,CAAC,SAAoB,EAAE,gBAA6B;IACpF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAC/B,IAAI,IAAA,gBAAQ,EAAC,QAAQ,CAAC,IAAI,OAAO,QAAQ,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YACxD,gBAAgB,CAAC,GAAG,CAAC,cAAc,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;AACL,CAAC;AAED,SAAS,2BAA2B,CAAC,SAAoB,EAAE,gBAA6B;IACpF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAC/B,IAAI,IAAA,gBAAQ,EAAC,QAAQ,CAAC,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1D,gBAAgB,CAAC,GAAG,CAAC,wBAAwB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plugin-activation-events.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-activation-events.spec.d.ts","sourceRoot":"","sources":["../../src/common/plugin-activation-events.spec.ts"],"names":[],"mappings":""}