@sigma-file-manager/api 1.5.0 → 1.7.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/README.md CHANGED
@@ -1,52 +1,59 @@
1
- # @sigma-file-manager/api
2
-
3
- Types and manifest schema for Sigma File Manager extensions.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install -D @sigma-file-manager/api
9
- ```
10
-
11
- ## Use in JavaScript extensions
12
-
13
- Use `// @ts-check` and JSDoc imports from the package:
14
-
15
- ```js
16
- // @ts-check
17
-
18
- /**
19
- * @typedef {import('@sigma-file-manager/api').ExtensionActivationContext} ExtensionActivationContext
20
- */
21
-
22
- /**
23
- * @param {ExtensionActivationContext} context
24
- */
25
- async function activate(context) {
26
- console.log(context.extensionPath);
27
- }
28
- ```
29
-
30
- Bundled English defaults with locale JSON from `mergeFromPath`:
31
-
32
- ```js
33
- import { extensionMessages } from './messages.js';
34
-
35
- export const t = sigma.i18n.createExtensionTranslator(extensionMessages);
36
- ```
37
-
38
- `formatMessage` for `{placeholder}` strings is available as `sigma.i18n.formatMessage` when needed.
39
-
40
- ## Manifest schema
41
-
42
- Use this schema URL in your extension `package.json`:
43
-
44
- ```json
45
- {
46
- "$schema": "https://raw.githubusercontent.com/aleksey-hoffman/sigma-file-manager/main/packages/api/manifest.schema.json"
47
- }
48
- ```
49
-
50
- ## Release
51
-
52
- API package versions are independent from app versions and tagged as `api-vX.Y.Z`.
1
+ # @sigma-file-manager/api
2
+
3
+ Type definitions and the extension manifest JSON schema for [Sigma File Manager](https://github.com/aleksey-hoffman/sigma-file-manager) extensions.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -D @sigma-file-manager/api
9
+ ```
10
+
11
+ Add a `devDependency` only; the host does not run `npm install` for installed extensions.
12
+
13
+ ## TypeScript
14
+
15
+ Import types for entrypoints and helpers. The global `sigma` object is declared in this package.
16
+
17
+ ```ts
18
+ import type { ExtensionActivationContext, ExtensionContextEntry, UIElement } from '@sigma-file-manager/api';
19
+
20
+ export async function activate(context: ExtensionActivationContext): Promise<void> {
21
+ await sigma.i18n.mergeFromPath('locales');
22
+ }
23
+
24
+ export async function deactivate(): Promise<void> {}
25
+ ```
26
+
27
+ When the extension runs code, point `package.json` `"main"` at your compiled file (for example `dist/index.js`), set `"type": "module"`, and build with `tsc` or your bundler. Manifest-only API extensions that only contribute themes can omit `"main"`. Commit build output if installs come from a Git tag archive without running a build on the client.
28
+
29
+ ## i18n
30
+
31
+ Keep strings in `locales/*.json`, merge every locale from the extension root, and alias `sigma.i18n.extensionT` for extension-local keys:
32
+
33
+ ```ts
34
+ const t = sigma.i18n.extensionT;
35
+ ```
36
+
37
+ Call `await sigma.i18n.mergeFromPath('locales')` in `activate` before registering UI that uses `t`.
38
+
39
+ `sigma.i18n.formatMessage` is available when you need `{placeholder}` formatting outside the translator.
40
+
41
+ ## Manifest schema
42
+
43
+ In extension `package.json`:
44
+
45
+ ```json
46
+ {
47
+ "$schema": "./node_modules/@sigma-file-manager/api/manifest.schema.json"
48
+ }
49
+ ```
50
+
51
+ Run `npm install` first so the local schema file exists.
52
+
53
+ ## Release
54
+
55
+ API package versions are independent from app releases and are published to npm as `@sigma-file-manager/api`.
56
+
57
+ ## Resources
58
+
59
+ **[Docs](https://github.com/sigma-hub/sfm-marketplace/wiki)** - documentation for extension development