@sigma-file-manager/api 1.4.0 → 1.6.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,6 +1,6 @@
1
1
  # @sigma-file-manager/api
2
2
 
3
- Types and manifest schema for Sigma File Manager extensions.
3
+ Type definitions and the extension manifest JSON schema for [Sigma File Manager](https://github.com/aleksey-hoffman/sigma-file-manager) extensions.
4
4
 
5
5
  ## Install
6
6
 
@@ -8,35 +8,52 @@ Types and manifest schema for Sigma File Manager extensions.
8
8
  npm install -D @sigma-file-manager/api
9
9
  ```
10
10
 
11
- ## Use in JavaScript extensions
11
+ Add a `devDependency` only; the host does not run `npm install` for installed extensions.
12
12
 
13
- Use `// @ts-check` and JSDoc imports from the package:
13
+ ## TypeScript
14
14
 
15
- ```js
16
- // @ts-check
15
+ Import types for entrypoints and helpers. The global `sigma` object is declared in this package.
17
16
 
18
- /**
19
- * @typedef {import('@sigma-file-manager/api').ExtensionActivationContext} ExtensionActivationContext
20
- */
17
+ ```ts
18
+ import type { ExtensionActivationContext, ExtensionContextEntry, UIElement } from '@sigma-file-manager/api';
21
19
 
22
- /**
23
- * @param {ExtensionActivationContext} context
24
- */
25
- async function activate(context) {
26
- console.log(context.extensionPath);
20
+ export async function activate(context: ExtensionActivationContext): Promise<void> {
21
+ await sigma.i18n.mergeFromPath('locales');
27
22
  }
23
+
24
+ export async function deactivate(): Promise<void> {}
25
+ ```
26
+
27
+ Point `package.json` `"main"` at your compiled file (for example `dist/index.js`), set `"type": "module"`, and build with `tsc` or your bundler. 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;
28
35
  ```
29
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
+
30
41
  ## Manifest schema
31
42
 
32
- Use this schema URL in your extension `package.json`:
43
+ In extension `package.json`:
33
44
 
34
45
  ```json
35
46
  {
36
- "$schema": "https://raw.githubusercontent.com/aleksey-hoffman/sigma-file-manager/main/packages/api/manifest.schema.json"
47
+ "$schema": "./node_modules/@sigma-file-manager/api/manifest.schema.json"
37
48
  }
38
49
  ```
39
50
 
51
+ Run `npm install` first so the local schema file exists.
52
+
40
53
  ## Release
41
54
 
42
- API package versions are independent from app versions and tagged as `api-vX.Y.Z`.
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-extensions-registry/wiki)** - documentation for extension development
package/index.d.ts CHANGED
@@ -4,6 +4,9 @@ declare global {
4
4
 
5
5
  export type ExtensionType = 'api' | 'iframe' | 'webview';
6
6
 
7
+ /** Flat key–value map for one extension locale file (for example `locales/en.json`). */
8
+ export type ExtensionLocaleStrings = Record<string, string>;
9
+
7
10
  export type ExtensionPermission
8
11
  = | 'contextMenu'
9
12
  | 'sidebar'
@@ -149,6 +152,14 @@ export interface ManifestBinaryDefinition {
149
152
  assets: ManifestBinaryAsset[];
150
153
  }
151
154
 
155
+ export type ExtensionManifestMediaType = 'image' | 'video';
156
+
157
+ export interface ExtensionManifestMediaItem {
158
+ title: string;
159
+ src: string;
160
+ type: ExtensionManifestMediaType;
161
+ }
162
+
152
163
  export interface ExtensionManifest {
153
164
  id: string;
154
165
  name: string;
@@ -159,6 +170,7 @@ export interface ExtensionManifest {
159
170
  license: string;
160
171
  icon?: string;
161
172
  banner?: string;
173
+ media?: ExtensionManifestMediaItem[];
162
174
  categories?: string[];
163
175
  tags?: string[];
164
176
  extensionType: ExtensionType;
@@ -376,7 +388,12 @@ export interface SigmaExtensionAPI {
376
388
  t(key: string, params?: Record<string, string | number>): string;
377
389
  mergeMessages(messages: Record<string, Record<string, string>>): void;
378
390
  mergeFromPath(basePath: string): Promise<void>;
391
+ /**
392
+ * Resolves extension-localized strings under `extensions.<extensionId>.<key>`.
393
+ * When no translation exists, this returns `fallback` if provided, otherwise the original `key`.
394
+ */
379
395
  extensionT(key: string, params?: Record<string, string | number>, fallback?: string): string;
396
+ formatMessage(template: string, params?: Record<string, string | number>): string;
380
397
  };
381
398
  contextMenu: {
382
399
  registerItem(
@@ -69,6 +69,37 @@
69
69
  "type": "string",
70
70
  "description": "Relative path to banner image"
71
71
  },
72
+ "media": {
73
+ "type": "array",
74
+ "description": "Preview images or videos for the extension detail overview (paths relative to the extension root, or absolute http(s) URLs)",
75
+ "items": {
76
+ "type": "object",
77
+ "required": [
78
+ "title",
79
+ "src",
80
+ "type"
81
+ ],
82
+ "properties": {
83
+ "title": {
84
+ "type": "string",
85
+ "description": "Label shown under the preview"
86
+ },
87
+ "src": {
88
+ "type": "string",
89
+ "description": "Relative path to a file in the extension package, or an absolute http(s) URL"
90
+ },
91
+ "type": {
92
+ "type": "string",
93
+ "enum": [
94
+ "image",
95
+ "video"
96
+ ],
97
+ "description": "How the preview is rendered"
98
+ }
99
+ },
100
+ "additionalProperties": false
101
+ }
102
+ },
72
103
  "categories": {
73
104
  "type": "array",
74
105
  "description": "Categories for extension classification",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigma-file-manager/api",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "Type definitions and manifest schema for Sigma File Manager extensions",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {