mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Deployed e560baa2d to master with MkDocs 1.1.2 and mike 1.0.0
This commit is contained in:
1 parent
9d9348a4ff
commit
8dd3c37633
266 files changed
+7875
-4052
No files matched your search
@@ -665,6 +665,18 @@
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="../../guides/protocol-handlers/" class="md-nav__link">
|
||||
Protocol Handlers
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
</li>
|
||||
@@ -917,7 +929,8 @@
|
||||
|
||||
|
||||
<h1 id="extension-anatomy">Extension Anatomy<a class="headerlink" href="#extension-anatomy" title="Permanent link">#</a></h1>
|
||||
<p>In the <a href="../your-first-extension/">previous section</a> you learned how to create your first extension. In this section you will learn how this extension works under the hood.</p>
|
||||
<p>In the <a href="../your-first-extension/">previous section</a> you learned how to create your first extension.
|
||||
In this section you will learn how this extension works under the hood.</p>
|
||||
<p>The Hello World sample extension does three things:</p>
|
||||
<ul>
|
||||
<li>Implements <code>onActivate()</code> and outputs a message to the console.</li>
|
||||
@@ -938,11 +951,17 @@
|
||||
├── tsconfig.json // TypeScript configuration
|
||||
├── webpack.config.js // Webpack configuration
|
||||
</code></pre></div>
|
||||
<p>The extension directory contains the extension's entry files and a few configuration files. Three files: <code>package.json</code>, <code>main.ts</code> and <code>renderer.tsx</code> are essential to understanding the Hello World sample extension. We'll look at those first.</p>
|
||||
<p>The extension directory contains the extension's entry files and a few configuration files.
|
||||
Three files: <code>package.json</code>, <code>main.ts</code> and <code>renderer.tsx</code> are essential to understanding the Hello World sample extension.
|
||||
We'll look at those first.</p>
|
||||
<h3 id="extension-manifest">Extension Manifest<a class="headerlink" href="#extension-manifest" title="Permanent link">#</a></h3>
|
||||
<p>Each Lens extension must have a <code>package.json</code> file. It contains a mix of Node.js fields, including scripts and dependencies, and Lens-specific fields such as <code>publisher</code> and <code>contributes</code>. Some of the most-important fields include:</p>
|
||||
<p>Each Lens extension must have a <code>package.json</code> file.
|
||||
It contains a mix of Node.js fields, including scripts and dependencies, and Lens-specific fields such as <code>publisher</code> and <code>contributes</code>.
|
||||
Some of the most-important fields include:</p>
|
||||
<ul>
|
||||
<li><code>name</code> and <code>publisher</code>: Lens uses <code>@<publisher>/<name></code> as a unique ID for the extension. For example, the Hello World sample has the ID <code>@lensapp-samples/helloworld-sample</code>. Lens uses this ID to uniquely identify your extension.</li>
|
||||
<li><code>name</code> and <code>publisher</code>: Lens uses <code>@<publisher>/<name></code> as a unique ID for the extension.
|
||||
For example, the Hello World sample has the ID <code>@lensapp-samples/helloworld-sample</code>.
|
||||
Lens uses this ID to uniquely identify your extension.</li>
|
||||
<li><code>main</code>: the extension's entry point run in <code>main</code> process.</li>
|
||||
<li><code>renderer</code>: the extension's entry point run in <code>renderer</code> process.</li>
|
||||
<li><code>engines.lens</code>: the minimum version of Lens API that the extension depends upon.</li>
|
||||
@@ -978,9 +997,20 @@
|
||||
<span class="p">}</span>
|
||||
</code></pre></div>
|
||||
<h2 id="extension-entry-files">Extension Entry Files<a class="headerlink" href="#extension-entry-files" title="Permanent link">#</a></h2>
|
||||
<p>Lens extensions can have two separate entry files. One file is used in the <code>main</code> process of the Lens application and the other is used in the <code>renderer</code> process. The <code>main</code> entry file exports the class that extends <code>LensMainExtension</code>, and the <code>renderer</code> entry file exports the class that extends <code>LensRendererExtension</code>.</p>
|
||||
<p>Both extension classes have <code>onActivate</code> and <code>onDeactivate</code> methods. The <code>onActivate</code> method is executed when your extension is activated. If you need to initialize something in your extension, this is where such an operation should occur. The <code>onDeactivate</code> method gives you a chance to clean up before your extension becomes deactivated. For extensions where explicit cleanup is not required, you don't need to override this method. However, if an extension needs to perform an operation when Lens is shutting down (or if the extension is disabled or uninstalled), this is the method where such an operation should occur.</p>
|
||||
<p>The Hello World sample extension does not do anything on the <code>main</code> process, so we'll focus on the <code>renderer</code> process, instead. On the <code>renderer</code> entry point, the Hello World sample extension defines the <code>Cluster Page</code> object. The <code>Cluster Page</code> object registers the <code>/extension-example</code> path, and this path renders the <code>ExamplePage</code> React component. It also registers the <code>MenuItem</code> component that displays the <code>ExampleIcon</code> React component and the "Hello World" text in the left-side menu of the cluster dashboard. These React components are defined in the additional <code>./src/page.tsx</code> file.</p>
|
||||
<p>Lens extensions can have two separate entry files.
|
||||
One file is used in the <code>main</code> process of the Lens application and the other is used in the <code>renderer</code> process.
|
||||
The <code>main</code> entry file exports the class that extends <code>LensMainExtension</code>, and the <code>renderer</code> entry file exports the class that extends <code>LensRendererExtension</code>.</p>
|
||||
<p>Both extension classes have <code>onActivate</code> and <code>onDeactivate</code> methods.
|
||||
The <code>onActivate</code> method is executed when your extension is activated.
|
||||
If you need to initialize something in your extension, this is where such an operation should occur.
|
||||
The <code>onDeactivate</code> method gives you a chance to clean up before your extension becomes deactivated.
|
||||
For extensions where explicit cleanup is not required, you don't need to override this method.
|
||||
However, if an extension needs to perform an operation when Lens is shutting down (or if the extension is disabled or uninstalled), this is the method where such an operation should occur.</p>
|
||||
<p>The Hello World sample extension does not do anything on the <code>main</code> process, so we'll focus on the <code>renderer</code> process, instead.
|
||||
On the <code>renderer</code> entry point, the Hello World sample extension defines the <code>Cluster Page</code> object.
|
||||
The <code>Cluster Page</code> object registers the <code>/extension-example</code> path, and this path renders the <code>ExamplePage</code> React component.
|
||||
It also registers the <code>MenuItem</code> component that displays the <code>ExampleIcon</code> React component and the "Hello World" text in the left-side menu of the cluster dashboard.
|
||||
These React components are defined in the additional <code>./src/page.tsx</code> file.</p>
|
||||
<div class="highlight"><pre><span></span><code><span class="k">import</span> <span class="p">{</span> <span class="nx">LensRendererExtension</span> <span class="p">}</span> <span class="nx">from</span> <span class="s2">"@k8slens/extensions"</span><span class="p">;</span>
|
||||
<span class="k">import</span> <span class="p">{</span> <span class="nx">ExampleIcon</span><span class="p">,</span> <span class="nx">ExamplePage</span> <span class="p">}</span> <span class="nx">from</span> <span class="s2">"./page"</span>
|
||||
<span class="k">import</span> <span class="nx">React</span> <span class="nx">from</span> <span class="s2">"react"</span>
|
||||
@@ -996,7 +1026,8 @@
|
||||
<span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre></div>
|
||||
<p>The Hello World sample extension uses the <code>Cluster Page</code> capability, which is just one of the Lens extension API's capabilities. The <a href="../../capabilities/common-capabilities/">Common Capabilities</a> page will help you home in on the right capabilities to use with your own extensions.</p>
|
||||
<p>The Hello World sample extension uses the <code>Cluster Page</code> capability, which is just one of the Lens extension API's capabilities.
|
||||
The <a href="../../capabilities/common-capabilities/">Common Capabilities</a> page will help you home in on the right capabilities to use with your own extensions.</p>
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user