1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { Logger } from '../../common/types';
|
17 | import { Stats } from '../../stats/types';
|
18 | import * as modelTypes from '../model/types';
|
19 | import * as types from './types';
|
20 |
|
21 |
|
22 |
|
23 | export interface ModuleExportsMapping {
|
24 | [key: string]: any;
|
25 | }
|
26 |
|
27 | export declare abstract class BasePlugin implements types.Plugin {
|
28 |
|
29 | protected moduleExports: any;
|
30 |
|
31 | protected moduleName: string;
|
32 |
|
33 | protected tracer: modelTypes.Tracer;
|
34 |
|
35 | protected version: string;
|
36 |
|
37 | protected logger: Logger;
|
38 |
|
39 | protected readonly internalFileList: types.PluginInternalFiles;
|
40 |
|
41 | protected internalFilesExports: ModuleExportsMapping;
|
42 |
|
43 | protected basedir: string;
|
44 |
|
45 | protected options: types.PluginConfig;
|
46 |
|
47 | protected stats?: Stats;
|
48 | |
49 |
|
50 |
|
51 |
|
52 | constructor(moduleName: string);
|
53 | /**
|
54 | * Sets modified plugin to the context.
|
55 | * @param moduleExports nodejs module exports to set as context
|
56 | * @param tracer tracer relating to context
|
57 | * @param version module version description
|
58 | * @param options plugin options
|
59 | * @param basedir module absolute path
|
60 | * @param stats a stats instance
|
61 | */
|
62 | private setPluginContext;
|
63 | /**
|
64 | * Method that enables the instrumentation patch.
|
65 | *
|
66 | * This method implements the GoF Template Method Pattern
|
67 | * 'enable' is the invariant part of the pattern and
|
68 | * 'applyPatch' the variant.
|
69 | *
|
70 | * @param moduleExports nodejs module exports from the module to patch
|
71 | * @param tracer a tracer instance
|
72 | * @param version version of the current instaled module to patch
|
73 | * @param options plugin options
|
74 | * @param basedir an optional module absolute path
|
75 | * @param stats an optional stats instance
|
76 | */
|
77 | enable<T>(moduleExports: T, tracer: modelTypes.Tracer, version: string, options: types.PluginConfig, basedir?: string, stats?: Stats): any;
|
78 | /** Method to disable the instrumentation */
|
79 | disable(): void;
|
80 | /**
|
81 | * This method implements the GoF Template Method Pattern,
|
82 | * 'applyPatch' is the variant part, each instrumentation should
|
83 | * implement its own version, 'enable' method is the invariant.
|
84 | * It will be called when enable is called.
|
85 | *
|
86 | */
|
87 | protected abstract applyPatch(): any;
|
88 | protected abstract applyUnpatch(): void;
|
89 | /**
|
90 | * Load internal files according to version range
|
91 | */
|
92 | private loadInternalFiles;
|
93 | /**
|
94 | * Load internal files from a module and set internalFilesExports
|
95 | */
|
96 | private loadInternalModuleFiles;
|
97 | }
|