@companion-surface/base 0.0.1

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 (48) hide show
  1. package/README.md +46 -0
  2. package/assets/manifest.schema.json +113 -0
  3. package/assets/surface-layout.schema.json +109 -0
  4. package/dist/main.d.ts +4 -0
  5. package/dist/main.d.ts.map +1 -0
  6. package/dist/main.js +3 -0
  7. package/dist/main.js.map +1 -0
  8. package/dist/manifest.d.ts +5 -0
  9. package/dist/manifest.d.ts.map +1 -0
  10. package/dist/manifest.js +32 -0
  11. package/dist/manifest.js.map +1 -0
  12. package/dist/surface-api/cards.d.ts +7 -0
  13. package/dist/surface-api/cards.d.ts.map +1 -0
  14. package/dist/surface-api/cards.js +2 -0
  15. package/dist/surface-api/cards.js.map +1 -0
  16. package/dist/surface-api/context.d.ts +14 -0
  17. package/dist/surface-api/context.d.ts.map +1 -0
  18. package/dist/surface-api/context.js +2 -0
  19. package/dist/surface-api/context.js.map +1 -0
  20. package/dist/surface-api/enums.d.ts +2 -0
  21. package/dist/surface-api/enums.d.ts.map +1 -0
  22. package/dist/surface-api/enums.js +2 -0
  23. package/dist/surface-api/enums.js.map +1 -0
  24. package/dist/surface-api/index.d.ts +8 -0
  25. package/dist/surface-api/index.d.ts.map +1 -0
  26. package/dist/surface-api/index.js +8 -0
  27. package/dist/surface-api/index.js.map +1 -0
  28. package/dist/surface-api/instance.d.ts +52 -0
  29. package/dist/surface-api/instance.d.ts.map +1 -0
  30. package/dist/surface-api/instance.js +2 -0
  31. package/dist/surface-api/instance.js.map +1 -0
  32. package/dist/surface-api/pincode.d.ts +40 -0
  33. package/dist/surface-api/pincode.d.ts.map +1 -0
  34. package/dist/surface-api/pincode.js +2 -0
  35. package/dist/surface-api/pincode.js.map +1 -0
  36. package/dist/surface-api/plugin.d.ts +75 -0
  37. package/dist/surface-api/plugin.d.ts.map +1 -0
  38. package/dist/surface-api/plugin.js +2 -0
  39. package/dist/surface-api/plugin.js.map +1 -0
  40. package/dist/surface-api/types.d.ts +85 -0
  41. package/dist/surface-api/types.d.ts.map +1 -0
  42. package/dist/surface-api/types.js +2 -0
  43. package/dist/surface-api/types.js.map +1 -0
  44. package/generated/manifest.d.ts +75 -0
  45. package/generated/surface-layout.d.ts +82 -0
  46. package/generated/validate_manifest.js +1 -0
  47. package/generated/validate_surface_layout.js +1 -0
  48. package/package.json +38 -0
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @companion-surface/base
2
+
3
+ Plugin API for writing surface integrations for [Companion](https://github.com/bitfocus/companion).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ yarn add @companion-surface/base
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Implement the `SurfacePlugin` interface to create a surface integration. Your plugin handles all surfaces of a given type.
14
+
15
+ ```typescript
16
+ import { SurfacePlugin, SurfaceContext } from '@companion-surface/base'
17
+
18
+ export const MySurfacePlugin: SurfacePlugin = {
19
+ async init(): Promise<void> {
20
+ // Initialize your plugin
21
+ }
22
+
23
+ async destroy(): Promise<void> {
24
+ // Clean up
25
+ }
26
+
27
+ // Implement detection or manual connection methods
28
+ }
29
+ ```
30
+
31
+ Check the [template repository](https://github.com/bitfocus/companion-surface-template-ts) for a complete example.
32
+
33
+ ## Supported Versions
34
+
35
+ | Companion | Module-base |
36
+ | --------- | ----------- |
37
+ | v4.x | v1.0 |
38
+
39
+ ## Documentation
40
+
41
+ - [Generated API docs](https://bitfocus.github.io/companion-surface-api/)
42
+ - [Wiki](https://github.com/bitfocus/companion-surface-api/wiki)
43
+
44
+ ## Development
45
+
46
+ This package is part of a monorepo. See the root README for development instructions.
@@ -0,0 +1,113 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "title": "SurfaceModuleManifest",
5
+ "properties": {
6
+ "$schema": {
7
+ "type": "string"
8
+ },
9
+ "type": {
10
+ "type": "string",
11
+ "enum": ["surface"],
12
+ "description": "Type of module. Must be: surface"
13
+ },
14
+ "id": {
15
+ "type": "string",
16
+ "description": "Unique identifier for the module"
17
+ },
18
+ "name": {
19
+ "type": "string",
20
+ "description": "Name of the module"
21
+ },
22
+ "description": {
23
+ "type": "string",
24
+ "description": "Description of the module "
25
+ },
26
+ "version": {
27
+ "type": "string",
28
+ "description": "Current version of the module"
29
+ },
30
+ "isPrerelease": {
31
+ "type": "boolean",
32
+ "description": "Is this a pre-release version"
33
+ },
34
+ "license": {
35
+ "type": "string",
36
+ "description": "SPDX identifier for license of the module"
37
+ },
38
+ "repository": {
39
+ "type": "string",
40
+ "description": "URL to the source repository"
41
+ },
42
+ "bugs": {
43
+ "type": "string",
44
+ "description": "URL to bug tracker"
45
+ },
46
+ "maintainers": {
47
+ "type": "array",
48
+ "description": "List of active maintiners",
49
+ "uniqueItems": true,
50
+ "items": {
51
+ "type": "object",
52
+ "title": "SurfaceModuleManifestMaintainer",
53
+ "properties": {
54
+ "name": {
55
+ "type": "string"
56
+ },
57
+ "email": {
58
+ "type": "string"
59
+ },
60
+ "github": {
61
+ "type": "string"
62
+ },
63
+ "url": {
64
+ "type": "string"
65
+ }
66
+ },
67
+ "required": ["name"],
68
+ "additionalProperties": false
69
+ }
70
+ },
71
+ "runtime": {
72
+ "type": "object",
73
+ "title": "SurfaceModuleManifestRuntime",
74
+ "description": "Information on how to execute the module",
75
+ "properties": {
76
+ "type": {
77
+ "type": "string",
78
+ "description": "Type of the module. Must be: node18 or node22",
79
+ "enum": ["node22"]
80
+ },
81
+ "apiVersion": {
82
+ "type": "string",
83
+ "description": "The version of the host-api used"
84
+ },
85
+ "entrypoint": {
86
+ "type": "string",
87
+ "description": "Entrypoint to pass to the runtime. eg index.js"
88
+ }
89
+ },
90
+ "required": ["type", "apiVersion", "entrypoint"]
91
+ },
92
+ "keywords": {
93
+ "type": "array",
94
+ "uniqueItems": true,
95
+ "items": {
96
+ "type": "string"
97
+ }
98
+ }
99
+ },
100
+ "required": [
101
+ "type",
102
+ "id",
103
+ "name",
104
+ "description",
105
+ "version",
106
+ "license",
107
+ "repository",
108
+ "bugs",
109
+ "maintainers",
110
+ "runtime",
111
+ "keywords"
112
+ ]
113
+ }
@@ -0,0 +1,109 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "SurfaceSchemaLayoutDefinition",
4
+ "description": "Schema describing a surface layout: default styling and a map of controls with positions and optional style overrides.",
5
+ "type": "object",
6
+ "$defs": {
7
+ "size": {
8
+ "title": "SurfaceSchemaBitmapConfig",
9
+ "description": "Bitmap content dimensions and format.",
10
+ "type": "object",
11
+ "properties": {
12
+ "w": {
13
+ "description": "Width in pixels (non-negative).",
14
+ "type": "number",
15
+ "minimum": 0
16
+ },
17
+ "h": {
18
+ "description": "Height in pixels (non-negative).",
19
+ "type": "number",
20
+ "minimum": 0
21
+ },
22
+ "format": {
23
+ "description": "Buffer pixel format",
24
+ "type": "string",
25
+ "title": "SurfaceSchemaPixelFormat",
26
+ "enum": ["rgb", "rgba", "bgr", "bgra"],
27
+ "default": "rgb"
28
+ }
29
+ },
30
+ "required": ["w", "h"],
31
+ "additionalProperties": false
32
+ },
33
+ "stylePreset": {
34
+ "title": "SurfaceSchemaControlStylePreset",
35
+ "description": "Styling options that can be applied to controls. Can be used as the default style or as per-control overrides.",
36
+ "type": "object",
37
+ "properties": {
38
+ "bitmap": {
39
+ "description": "If set, bitmaps of the specified size will be reported.",
40
+ "$ref": "#/$defs/size"
41
+ },
42
+ "text": {
43
+ "description": "If true, the control requests text to be reported.",
44
+ "type": "boolean"
45
+ },
46
+ "textStyle": {
47
+ "description": "If true, the control requests text style properties to be reported",
48
+ "type": "boolean"
49
+ },
50
+ "colors": {
51
+ "description": "If set, the control requests colours to be reported.",
52
+ "type": "string",
53
+ "enum": ["hex", "rgb"]
54
+ }
55
+ },
56
+ "additionalProperties": false
57
+ }
58
+ },
59
+ "properties": {
60
+ "stylePresets": {
61
+ "description": "Named collection of style presets. The preset named `default` is required and is used as the fallback style for controls when no `stylePreset` is specified.",
62
+ "type": "object",
63
+ "properties": {
64
+ "default": {
65
+ "$ref": "#/$defs/stylePreset"
66
+ }
67
+ },
68
+ "patternProperties": {
69
+ "^.+$": {
70
+ "$ref": "#/$defs/stylePreset"
71
+ }
72
+ },
73
+ "required": ["default"],
74
+ "additionalProperties": false
75
+ },
76
+ "controls": {
77
+ "type": "object",
78
+ "patternProperties": {
79
+ "^[a-zA-Z0-9\\-\\/]+$": {
80
+ "title": "SurfaceSchemaControlDefinition",
81
+ "description": "Single control definition. The id must be unique and may be user facing in logs. Typically the id would be in the form of 1/0, matching the row/column of the control.",
82
+ "type": "object",
83
+ "properties": {
84
+ "row": {
85
+ "description": "Zero-based row index for layout placement.",
86
+ "type": "number",
87
+ "minimum": 0
88
+ },
89
+ "column": {
90
+ "description": "Zero-based column index for layout placement.",
91
+ "type": "number",
92
+ "minimum": 0
93
+ },
94
+ "stylePreset": {
95
+ "description": "Optional name of a style preset defined in `stylePresets`. If present, the control will use the named preset instead of the default style.",
96
+ "type": "string",
97
+ "pattern": "^.+$"
98
+ }
99
+ },
100
+ "required": ["row", "column"],
101
+ "additionalProperties": false
102
+ }
103
+ },
104
+ "additionalProperties": false
105
+ }
106
+ },
107
+ "required": ["stylePresets", "controls"],
108
+ "additionalProperties": false
109
+ }
package/dist/main.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './manifest.js';
2
+ export * from './surface-api/index.js';
3
+ export type * from '../generated/surface-layout.d.ts';
4
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,wBAAwB,CAAA;AAEtC,mBAAmB,kCAAkC,CAAA"}
package/dist/main.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './manifest.js';
2
+ export * from './surface-api/index.js';
3
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,wBAAwB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { SurfaceModuleManifest, SurfaceModuleManifestMaintainer, SurfaceModuleManifestRuntime } from '../generated/manifest.d.ts';
2
+ export { SurfaceModuleManifest, SurfaceModuleManifestMaintainer, SurfaceModuleManifestRuntime };
3
+ /** Validate that a manifest looks correctly populated */
4
+ export declare function validateSurfaceManifest(manifest: SurfaceModuleManifest, looseChecks: boolean): void;
5
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,qBAAqB,EACrB,+BAA+B,EAC/B,4BAA4B,EAC5B,MAAM,4BAA4B,CAAA;AAKnC,OAAO,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,CAAA;AAE/F,yDAAyD;AACzD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI,CAiCnG"}
@@ -0,0 +1,32 @@
1
+ // @ts-expect-error no typings
2
+ // eslint-disable-next-line n/no-missing-import
3
+ import validateSurfaceManifestSchema from '../generated/validate_manifest.js';
4
+ /** Validate that a manifest looks correctly populated */
5
+ export function validateSurfaceManifest(manifest, looseChecks) {
6
+ if (manifest.type !== 'surface')
7
+ throw new Error(`Manifest 'type' must be 'surface'`);
8
+ if (!looseChecks) {
9
+ const manifestStr = JSON.stringify(manifest);
10
+ if (manifestStr.includes('companion-module-your-module-name'))
11
+ throw new Error(`Manifest incorrectly references template module 'companion-module-your-module-name'`);
12
+ if (manifestStr.includes('module-shortname'))
13
+ throw new Error(`Manifest incorrectly references template module 'module-shortname'`);
14
+ if (manifestStr.includes('A short one line description of your module'))
15
+ throw new Error(`Manifest incorrectly references template module 'A short one line description of your module'`);
16
+ if (manifestStr.includes('Your name'))
17
+ throw new Error(`Manifest incorrectly references template module 'Your name'`);
18
+ if (manifestStr.includes('Your email'))
19
+ throw new Error(`Manifest incorrectly references template module 'Your email'`);
20
+ if (manifestStr.includes('Your company'))
21
+ throw new Error(`Manifest incorrectly references template module 'Your company'`);
22
+ if (manifestStr.includes('Your product'))
23
+ throw new Error(`Manifest incorrectly references template module 'Your product'`);
24
+ }
25
+ if (!validateSurfaceManifestSchema(manifest)) {
26
+ const errors = validateSurfaceManifestSchema.errors;
27
+ if (!errors)
28
+ throw new Error(`Manifest failed validation with unknown reason`);
29
+ throw new Error(`Manifest validation failed: ${JSON.stringify(errors)}`);
30
+ }
31
+ }
32
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAKA,8BAA8B;AAC9B,+CAA+C;AAC/C,OAAO,6BAA6B,MAAM,mCAAmC,CAAA;AAI7E,yDAAyD;AACzD,MAAM,UAAU,uBAAuB,CAAC,QAA+B,EAAE,WAAoB;IAC5F,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;IAErF,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;QAC5C,IAAI,WAAW,CAAC,QAAQ,CAAC,mCAAmC,CAAC;YAC5D,MAAM,IAAI,KAAK,CAAC,qFAAqF,CAAC,CAAA;QAEvG,IAAI,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAA;QAEtF,IAAI,WAAW,CAAC,QAAQ,CAAC,6CAA6C,CAAC;YACtE,MAAM,IAAI,KAAK,CAAC,+FAA+F,CAAC,CAAA;QAEjH,IAAI,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAA;QAE/E,IAAI,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAA;QAEhF,IAAI,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;QAElF,IAAI,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;IACnF,CAAC;IAED,IAAI,CAAC,6BAA6B,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,6BAA6B,CAAC,MAAM,CAAA;QACnD,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;QAE9E,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACzE,CAAC;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { SurfaceSchemaPixelFormat } from '../../generated/surface-layout.d.ts';
2
+ export interface CardGenerator {
3
+ generateBasicCard(width: number, height: number, pixelFormat: SurfaceSchemaPixelFormat): Promise<Uint8Array>;
4
+ generateLcdStripCard(width: number, height: number, pixelFormat: SurfaceSchemaPixelFormat): Promise<Uint8Array>;
5
+ generateLogoCard(width: number, height: number, pixelFormat: SurfaceSchemaPixelFormat): Promise<Uint8Array>;
6
+ }
7
+ //# sourceMappingURL=cards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/surface-api/cards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AAEnF,MAAM,WAAW,aAAa;IAC7B,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAG5G,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAE/G,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAC3G"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cards.js","sourceRoot":"","sources":["../../src/surface-api/cards.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ export interface HostCapabilities {
2
+ }
3
+ export interface SurfaceContext {
4
+ get isLocked(): boolean;
5
+ get capabilities(): HostCapabilities;
6
+ disconnect(error: Error): void;
7
+ keyDownById(controlId: string): void;
8
+ keyUpById(controlId: string): void;
9
+ keyDownUpById(controlId: string): void;
10
+ rotateLeftById(controlId: string): void;
11
+ rotateRightById(controlId: string): void;
12
+ sendVariableValue(variable: string, value: any): void;
13
+ }
14
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/surface-api/context.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,gBAAgB;CAGhC;AAED,MAAM,WAAW,cAAc;IAC9B,IAAI,QAAQ,IAAI,OAAO,CAAA;IAEvB,IAAI,YAAY,IAAI,gBAAgB,CAAA;IAEpC,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IAE9B,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACtC,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACvC,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IAExC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAA;CACrD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/surface-api/context.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type LogLevel = 'info' | 'warn' | 'error' | 'debug';
2
+ //# sourceMappingURL=enums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/surface-api/enums.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.js","sourceRoot":"","sources":["../../src/surface-api/enums.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export * from './cards.js';
2
+ export * from './context.js';
3
+ export * from './enums.js';
4
+ export * from './instance.js';
5
+ export * from './pincode.js';
6
+ export * from './plugin.js';
7
+ export * from './types.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/surface-api/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,8 @@
1
+ export * from './cards.js';
2
+ export * from './context.js';
3
+ export * from './enums.js';
4
+ export * from './instance.js';
5
+ export * from './pincode.js';
6
+ export * from './plugin.js';
7
+ export * from './types.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/surface-api/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,52 @@
1
+ import type { CardGenerator } from './cards.js';
2
+ import type { SurfaceDrawProps, SurfaceId } from './types.js';
3
+ export interface SurfaceInstance {
4
+ /**
5
+ * A unique ID for this surface instance
6
+ * This is typically the serial number
7
+ */
8
+ readonly surfaceId: SurfaceId;
9
+ /**
10
+ * A user-friendly name for this surface
11
+ * This should be the product name of the device
12
+ */
13
+ readonly productName: string;
14
+ /**
15
+ * Initialize the surface for use, called after creation
16
+ */
17
+ init(): Promise<void>;
18
+ /**
19
+ * Clean up any resources, and close the surface
20
+ */
21
+ close(): Promise<void>;
22
+ /**
23
+ * When the surface transitions into the ready state
24
+ * This means that it is about to begin drawing
25
+ */
26
+ ready(): Promise<void>;
27
+ /**
28
+ * Set the brightness of the display
29
+ * @param percent 0-100
30
+ */
31
+ setBrightness(percent: number): Promise<void>;
32
+ /**
33
+ * Clear the display, setting all pixels to black/off
34
+ */
35
+ blank(): Promise<void>;
36
+ /**
37
+ * Draw to the device
38
+ * @param signal AbortSignal to cancel the draw operation
39
+ * @param drawProps Data to draw
40
+ */
41
+ draw(signal: AbortSignal, drawProps: SurfaceDrawProps): Promise<void>;
42
+ onVariableValue?(name: string, value: any): void;
43
+ showLockedStatus?(locked: boolean, characterCount: number): void;
44
+ /**
45
+ * Show a status image on the device, instead of the normal operation
46
+ * This is typically used for Satellite to show the "connecting" state
47
+ * @param signal AbortSignal to cancel the status display
48
+ * @param cardGenerator Card generator to create the status image(s)
49
+ */
50
+ showStatus(signal: AbortSignal, cardGenerator: CardGenerator, statusMessage: string): Promise<void>;
51
+ }
52
+ //# sourceMappingURL=instance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/surface-api/instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE7D,MAAM,WAAW,eAAe;IAC/B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAE5B;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAErB;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtB;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAItB;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7C;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtB;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAErE,eAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAA;IAEhD,gBAAgB,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAEhE;;;;;OAKG;IACH,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACnG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.js","sourceRoot":"","sources":["../../src/surface-api/instance.ts"],"names":[],"mappings":""}
@@ -0,0 +1,40 @@
1
+ import type { ControlId } from './types.js';
2
+ /**
3
+ * Describe the pincode map for a surface
4
+ */
5
+ export type SurfacePincodeMap = SurfacePincodeMapPageSingle | SurfacePincodeMapPageMultiple | SurfacePincodeMapCustom;
6
+ /**
7
+ * An empty pincode map, for surfaces which do a custom pincode entry arrangement
8
+ */
9
+ export interface SurfacePincodeMapCustom {
10
+ type: 'custom';
11
+ }
12
+ /**
13
+ * A pincode map with a single page of buttons
14
+ */
15
+ export interface SurfacePincodeMapPageSingle extends SurfacePincodeMapPageEntry {
16
+ type: 'single-page';
17
+ pincode: ControlId | null;
18
+ }
19
+ /**
20
+ * A pincode map with multiple pages of buttons
21
+ */
22
+ export interface SurfacePincodeMapPageMultiple {
23
+ type: 'multiple-page';
24
+ pincode: ControlId;
25
+ nextPage: ControlId;
26
+ pages: Partial<SurfacePincodeMapPageEntry>[];
27
+ }
28
+ export interface SurfacePincodeMapPageEntry {
29
+ 0: ControlId;
30
+ 1: ControlId;
31
+ 2: ControlId;
32
+ 3: ControlId;
33
+ 4: ControlId;
34
+ 5: ControlId;
35
+ 6: ControlId;
36
+ 7: ControlId;
37
+ 8: ControlId;
38
+ 9: ControlId;
39
+ }
40
+ //# sourceMappingURL=pincode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pincode.d.ts","sourceRoot":"","sources":["../../src/surface-api/pincode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,2BAA2B,GAAG,6BAA6B,GAAG,uBAAuB,CAAA;AAErH;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,IAAI,EAAE,QAAQ,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,0BAA0B;IAC9E,IAAI,EAAE,aAAa,CAAA;IACnB,OAAO,EAAE,SAAS,GAAG,IAAI,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC7C,IAAI,EAAE,eAAe,CAAA;IACrB,OAAO,EAAE,SAAS,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;IACnB,KAAK,EAAE,OAAO,CAAC,0BAA0B,CAAC,EAAE,CAAA;CAC5C;AAED,MAAM,WAAW,0BAA0B;IAC1C,CAAC,EAAE,SAAS,CAAA;IACZ,CAAC,EAAE,SAAS,CAAA;IACZ,CAAC,EAAE,SAAS,CAAA;IACZ,CAAC,EAAE,SAAS,CAAA;IACZ,CAAC,EAAE,SAAS,CAAA;IACZ,CAAC,EAAE,SAAS,CAAA;IACZ,CAAC,EAAE,SAAS,CAAA;IACZ,CAAC,EAAE,SAAS,CAAA;IACZ,CAAC,EAAE,SAAS,CAAA;IACZ,CAAC,EAAE,SAAS,CAAA;CACZ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pincode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pincode.js","sourceRoot":"","sources":["../../src/surface-api/pincode.ts"],"names":[],"mappings":""}
@@ -0,0 +1,75 @@
1
+ import type EventEmitter from 'node:events';
2
+ import type { HIDDevice, OpenSurfaceResult, SurfaceId } from './types.js';
3
+ import { SurfaceContext } from './context.js';
4
+ export interface DiscoveredSurfaceInfo<TInfo> {
5
+ surfaceId: string;
6
+ description: string;
7
+ pluginInfo: TInfo;
8
+ }
9
+ export interface SurfacePluginDetectionEvents<TInfo> {
10
+ surfacesAdded: [surfaceInfos: DiscoveredSurfaceInfo<TInfo>[]];
11
+ surfacesRemoved: [surfaceIds: SurfaceId[]];
12
+ }
13
+ /**
14
+ * For some plugins which only support using a builtin detection mechanism, this can be used to provide the detection info
15
+ */
16
+ export interface SurfacePluginDetection<TInfo> extends EventEmitter<SurfacePluginDetectionEvents<TInfo>> {
17
+ /**
18
+ * Trigger this plugin to perform a scan for any connected surfaces.
19
+ * This is used when the user triggers a scan, so should refresh any caches when possible
20
+ */
21
+ triggerScan(): Promise<void>;
22
+ /**
23
+ * When a surface is discovered, but the application has chosen not to open it, this function is called to inform the detection mechanism
24
+ * You can use this to cleanup any resources/handles for this surface, as it will not be used further
25
+ * @param surfaceInfo The info about the surface which was rejected
26
+ */
27
+ rejectSurface(surfaceInfo: DiscoveredSurfaceInfo<TInfo>): void;
28
+ }
29
+ /**
30
+ * The base SurfacePlugin interface, for all surface plugins
31
+ */
32
+ export interface SurfacePlugin<TInfo> {
33
+ /**
34
+ * Some plugins are forced to use a builtin detection mechanism by their surfaces or inner library
35
+ * In this case, this property should be set to an instance of SurfacePluginDetection
36
+ *
37
+ * It is preferred that plugins to NOT use this, and to instead use the abtractions we provide to reduce the cost of scanning and detection
38
+ * Note: it is important that no events are emitted from this until after init() has been invoked, or they will be lost
39
+ */
40
+ readonly detection?: SurfacePluginDetection<TInfo>;
41
+ /**
42
+ * Initialize the plugin
43
+ *
44
+ * This will be called once when the plugin is loaded, before any surfaces or events are used
45
+ */
46
+ init(): Promise<void>;
47
+ /**
48
+ * Uninitialise the plugin
49
+ *
50
+ * This will be called once when the plugin is about to be unloaded. You should reset and close any surfaces here, and prepare for being terminated
51
+ */
52
+ destroy(): Promise<void>;
53
+ /**
54
+ * Check if a HID device is supported by this plugin
55
+ * Note: This must not open the device, just perform checks based on the provided info to see if it is supported
56
+ * @param device HID device to check
57
+ * @returns Info about the device if it is supported, otherwise null
58
+ */
59
+ checkSupportsHidDevice?: (device: HIDDevice) => DiscoveredSurfaceInfo<TInfo> | null;
60
+ /**
61
+ * Perform a scan for devices, but not open them
62
+ * Note: This should only be used if the plugin uses a protocol where we don't have other handling for
63
+ */
64
+ scanForSurfaces?: () => Promise<DiscoveredSurfaceInfo<TInfo>[]>;
65
+ /**
66
+ * Open a discovered/known surface
67
+ * This can be called for multiple surfaces in parallel
68
+ * @param surfaceId Id of the surface
69
+ * @param pluginInfo Plugin specific info about the surface
70
+ * @param context Context for the surface
71
+ * @returns Instance of the surface
72
+ */
73
+ openSurface: (surfaceId: string, pluginInfo: TInfo, context: SurfaceContext) => Promise<OpenSurfaceResult>;
74
+ }
75
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/surface-api/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,WAAW,qBAAqB,CAAC,KAAK;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,KAAK,CAAA;CACjB;AAED,MAAM,WAAW,4BAA4B,CAAC,KAAK;IAClD,aAAa,EAAE,CAAC,YAAY,EAAE,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC7D,eAAe,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,CAAA;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,KAAK,CAAE,SAAQ,YAAY,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;IACvG;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5B;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,qBAAqB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;CAC9D;AAED;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,KAAK;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAA;IAElD;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAErB;;;;OAIG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAExB;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,qBAAqB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;IAEnF;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAE/D;;;;;;;OAOG;IACH,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAA;CAC1G"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/surface-api/plugin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,85 @@
1
+ import type { SurfacePincodeMap } from './pincode.js';
2
+ import type { SurfaceInstance } from './instance.js';
3
+ import type { SurfaceSchemaLayoutDefinition } from '../../generated/surface-layout.d.ts';
4
+ /**
5
+ * A representation of a HID device
6
+ * A simplified form of the HIDDevice from node-hid
7
+ */
8
+ export interface HIDDevice {
9
+ vendorId: number;
10
+ productId: number;
11
+ serialNumber?: string | undefined;
12
+ manufacturer?: string | undefined;
13
+ product?: string | undefined;
14
+ release: number;
15
+ interface: number;
16
+ usagePage?: number | undefined;
17
+ usage?: number | undefined;
18
+ }
19
+ export type SurfaceId = string;
20
+ export type ControlId = string;
21
+ export interface SurfaceInputVariable {
22
+ id: string;
23
+ type: 'input';
24
+ name: string;
25
+ description?: string;
26
+ }
27
+ export interface SurfaceOutputVariable {
28
+ id: string;
29
+ type: 'output';
30
+ name: string;
31
+ description?: string;
32
+ }
33
+ /**
34
+ * Describes the capabilities of a surface when it is registered
35
+ */
36
+ export interface SurfaceRegisterProps {
37
+ /**
38
+ * Whether the surface supports setting brightness
39
+ */
40
+ brightness: boolean;
41
+ /**
42
+ * The definition of the controls on the surface and the properties needed for drawing
43
+ */
44
+ surfaceLayout: SurfaceSchemaLayoutDefinition;
45
+ /**
46
+ * Describes any custom input or output variables for the surface
47
+ * These are typically used for reporting values such as a tbar or battery level.
48
+ * Or for providing non-button values such as leds next to a tbar
49
+ */
50
+ transferVariables?: Array<SurfaceInputVariable | SurfaceOutputVariable>;
51
+ /**
52
+ * If the surface supports pincode entry, this is the desired arrangement of the pin entry buttons
53
+ */
54
+ pincodeMap: SurfacePincodeMap | null;
55
+ }
56
+ export interface SurfaceRegisterPropsComplete extends SurfaceRegisterProps {
57
+ gridSize: GridSize;
58
+ fallbackBitmapSize: number;
59
+ }
60
+ export interface OpenSurfaceResult {
61
+ surface: SurfaceInstance;
62
+ registerProps: SurfaceRegisterProps;
63
+ }
64
+ export interface SurfaceDrawProps {
65
+ controlId: string;
66
+ /**
67
+ * If the surface requested an image to be drawn, this Uint8Array will contain the pixel data in the requested dimensions and format
68
+ */
69
+ image?: Uint8Array;
70
+ /**
71
+ * If the surface requested a background color, this is the color to display
72
+ * This is typically only used for surfaces which have buttons with a RGB backlight
73
+ */
74
+ color?: string;
75
+ /**
76
+ * If the surface requested button text, this is the text to draw
77
+ * This is typically only used for surfaces which have buttons with text-only displays
78
+ */
79
+ text?: string;
80
+ }
81
+ export interface GridSize {
82
+ rows: number;
83
+ columns: number;
84
+ }
85
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/surface-api/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAA;AAExF;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAC9B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAE9B,MAAM,WAAW,oBAAoB;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AACD,MAAM,WAAW,qBAAqB;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,UAAU,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,aAAa,EAAE,6BAA6B,CAAA;IAC5C;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,oBAAoB,GAAG,qBAAqB,CAAC,CAAA;IACvE;;OAEG;IACH,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAA;CACpC;AAED,MAAM,WAAW,4BAA6B,SAAQ,oBAAoB;IACzE,QAAQ,EAAE,QAAQ,CAAA;IAClB,kBAAkB,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,eAAe,CAAA;IACxB,aAAa,EAAE,oBAAoB,CAAA;CACnC;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,UAAU,CAAA;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,QAAQ;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/surface-api/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,75 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+
8
+ export interface SurfaceModuleManifest {
9
+ $schema?: string;
10
+ /**
11
+ * Type of module. Must be: surface
12
+ */
13
+ type: "surface";
14
+ /**
15
+ * Unique identifier for the module
16
+ */
17
+ id: string;
18
+ /**
19
+ * Name of the module
20
+ */
21
+ name: string;
22
+ /**
23
+ * Description of the module
24
+ */
25
+ description: string;
26
+ /**
27
+ * Current version of the module
28
+ */
29
+ version: string;
30
+ /**
31
+ * Is this a pre-release version
32
+ */
33
+ isPrerelease?: boolean;
34
+ /**
35
+ * SPDX identifier for license of the module
36
+ */
37
+ license: string;
38
+ /**
39
+ * URL to the source repository
40
+ */
41
+ repository: string;
42
+ /**
43
+ * URL to bug tracker
44
+ */
45
+ bugs: string;
46
+ /**
47
+ * List of active maintiners
48
+ */
49
+ maintainers: SurfaceModuleManifestMaintainer[];
50
+ runtime: SurfaceModuleManifestRuntime;
51
+ keywords: string[];
52
+ }
53
+ export interface SurfaceModuleManifestMaintainer {
54
+ name: string;
55
+ email?: string;
56
+ github?: string;
57
+ url?: string;
58
+ }
59
+ /**
60
+ * Information on how to execute the module
61
+ */
62
+ export interface SurfaceModuleManifestRuntime {
63
+ /**
64
+ * Type of the module. Must be: node18 or node22
65
+ */
66
+ type: "node22";
67
+ /**
68
+ * The version of the host-api used
69
+ */
70
+ apiVersion: string;
71
+ /**
72
+ * Entrypoint to pass to the runtime. eg index.js
73
+ */
74
+ entrypoint: string;
75
+ }
@@ -0,0 +1,82 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+
8
+ /**
9
+ * Buffer pixel format
10
+ */
11
+ export type SurfaceSchemaPixelFormat = "rgb" | "rgba" | "bgr" | "bgra";
12
+
13
+ /**
14
+ * Schema describing a surface layout: default styling and a map of controls with positions and optional style overrides.
15
+ */
16
+ export interface SurfaceSchemaLayoutDefinition {
17
+ /**
18
+ * Named collection of style presets. The preset named `default` is required and is used as the fallback style for controls when no `stylePreset` is specified.
19
+ */
20
+ stylePresets: {
21
+ default: SurfaceSchemaControlStylePreset;
22
+ [k: string]: SurfaceSchemaControlStylePreset;
23
+ };
24
+ controls: {
25
+ [k: string]: SurfaceSchemaControlDefinition;
26
+ };
27
+ }
28
+ /**
29
+ * Styling options that can be applied to controls. Can be used as the default style or as per-control overrides.
30
+ *
31
+ * This interface was referenced by `undefined`'s JSON-Schema definition
32
+ * via the `patternProperty` "^.+$".
33
+ */
34
+ export interface SurfaceSchemaControlStylePreset {
35
+ bitmap?: SurfaceSchemaBitmapConfig;
36
+ /**
37
+ * If true, the control requests text to be reported.
38
+ */
39
+ text?: boolean;
40
+ /**
41
+ * If true, the control requests text style properties to be reported
42
+ */
43
+ textStyle?: boolean;
44
+ /**
45
+ * If set, the control requests colours to be reported.
46
+ */
47
+ colors?: "hex" | "rgb";
48
+ }
49
+ /**
50
+ * If set, bitmaps of the specified size will be reported.
51
+ */
52
+ export interface SurfaceSchemaBitmapConfig {
53
+ /**
54
+ * Width in pixels (non-negative).
55
+ */
56
+ w: number;
57
+ /**
58
+ * Height in pixels (non-negative).
59
+ */
60
+ h: number;
61
+ format?: SurfaceSchemaPixelFormat;
62
+ }
63
+ /**
64
+ * Single control definition. The id must be unique and may be user facing in logs. Typically the id would be in the form of 1/0, matching the row/column of the control.
65
+ *
66
+ * This interface was referenced by `undefined`'s JSON-Schema definition
67
+ * via the `patternProperty` "^[a-zA-Z0-9\-\/]+$".
68
+ */
69
+ export interface SurfaceSchemaControlDefinition {
70
+ /**
71
+ * Zero-based row index for layout placement.
72
+ */
73
+ row: number;
74
+ /**
75
+ * Zero-based column index for layout placement.
76
+ */
77
+ column: number;
78
+ /**
79
+ * Optional name of a style preset defined in `stylePresets`. If present, the control will use the named preset instead of the default style.
80
+ */
81
+ stylePreset?: string;
82
+ }
@@ -0,0 +1 @@
1
+ import { createRequire } from 'module';const require = createRequire(import.meta.url);"use strict";export const validate = validate20;export default validate20;const schema31 = {"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","title":"SurfaceModuleManifest","properties":{"$schema":{"type":"string"},"type":{"type":"string","enum":["surface"],"description":"Type of module. Must be: surface"},"id":{"type":"string","description":"Unique identifier for the module"},"name":{"type":"string","description":"Name of the module"},"description":{"type":"string","description":"Description of the module "},"version":{"type":"string","description":"Current version of the module"},"isPrerelease":{"type":"boolean","description":"Is this a pre-release version"},"license":{"type":"string","description":"SPDX identifier for license of the module"},"repository":{"type":"string","description":"URL to the source repository"},"bugs":{"type":"string","description":"URL to bug tracker"},"maintainers":{"type":"array","description":"List of active maintiners","uniqueItems":true,"items":{"type":"object","title":"SurfaceModuleManifestMaintainer","properties":{"name":{"type":"string"},"email":{"type":"string"},"github":{"type":"string"},"url":{"type":"string"}},"required":["name"],"additionalProperties":false}},"runtime":{"type":"object","title":"SurfaceModuleManifestRuntime","description":"Information on how to execute the module","properties":{"type":{"type":"string","description":"Type of the module. Must be: node18 or node22","enum":["node22"]},"apiVersion":{"type":"string","description":"The version of the host-api used"},"entrypoint":{"type":"string","description":"Entrypoint to pass to the runtime. eg index.js"}},"required":["type","apiVersion","entrypoint"]},"keywords":{"type":"array","uniqueItems":true,"items":{"type":"string"}}},"required":["type","id","name","description","version","license","repository","bugs","maintainers","runtime","keywords"]};const func0 = require("ajv/dist/runtime/equal").default;function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((((((((((data.type === undefined) && (missing0 = "type")) || ((data.id === undefined) && (missing0 = "id"))) || ((data.name === undefined) && (missing0 = "name"))) || ((data.description === undefined) && (missing0 = "description"))) || ((data.version === undefined) && (missing0 = "version"))) || ((data.license === undefined) && (missing0 = "license"))) || ((data.repository === undefined) && (missing0 = "repository"))) || ((data.bugs === undefined) && (missing0 = "bugs"))) || ((data.maintainers === undefined) && (missing0 = "maintainers"))) || ((data.runtime === undefined) && (missing0 = "runtime"))) || ((data.keywords === undefined) && (missing0 = "keywords"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.$schema !== undefined){const _errs1 = errors;if(typeof data.$schema !== "string"){validate20.errors = [{instancePath:instancePath+"/$schema",schemaPath:"#/properties/%24schema/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.type !== undefined){let data1 = data.type;const _errs3 = errors;if(typeof data1 !== "string"){validate20.errors = [{instancePath:instancePath+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(data1 === "surface")){validate20.errors = [{instancePath:instancePath+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues: schema31.properties.type.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.id !== undefined){const _errs5 = errors;if(typeof data.id !== "string"){validate20.errors = [{instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.name !== undefined){const _errs7 = errors;if(typeof data.name !== "string"){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.description !== undefined){const _errs9 = errors;if(typeof data.description !== "string"){validate20.errors = [{instancePath:instancePath+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.version !== undefined){const _errs11 = errors;if(typeof data.version !== "string"){validate20.errors = [{instancePath:instancePath+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.isPrerelease !== undefined){const _errs13 = errors;if(typeof data.isPrerelease !== "boolean"){validate20.errors = [{instancePath:instancePath+"/isPrerelease",schemaPath:"#/properties/isPrerelease/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}if(valid0){if(data.license !== undefined){const _errs15 = errors;if(typeof data.license !== "string"){validate20.errors = [{instancePath:instancePath+"/license",schemaPath:"#/properties/license/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs15 === errors;}else {var valid0 = true;}if(valid0){if(data.repository !== undefined){const _errs17 = errors;if(typeof data.repository !== "string"){validate20.errors = [{instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs17 === errors;}else {var valid0 = true;}if(valid0){if(data.bugs !== undefined){const _errs19 = errors;if(typeof data.bugs !== "string"){validate20.errors = [{instancePath:instancePath+"/bugs",schemaPath:"#/properties/bugs/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs19 === errors;}else {var valid0 = true;}if(valid0){if(data.maintainers !== undefined){let data10 = data.maintainers;const _errs21 = errors;if(errors === _errs21){if(Array.isArray(data10)){var valid1 = true;const len0 = data10.length;for(let i0=0; i0<len0; i0++){let data11 = data10[i0];const _errs23 = errors;if(errors === _errs23){if(data11 && typeof data11 == "object" && !Array.isArray(data11)){let missing1;if((data11.name === undefined) && (missing1 = "name")){validate20.errors = [{instancePath:instancePath+"/maintainers/" + i0,schemaPath:"#/properties/maintainers/items/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {const _errs25 = errors;for(const key0 in data11){if(!((((key0 === "name") || (key0 === "email")) || (key0 === "github")) || (key0 === "url"))){validate20.errors = [{instancePath:instancePath+"/maintainers/" + i0,schemaPath:"#/properties/maintainers/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}];return false;break;}}if(_errs25 === errors){if(data11.name !== undefined){const _errs26 = errors;if(typeof data11.name !== "string"){validate20.errors = [{instancePath:instancePath+"/maintainers/" + i0+"/name",schemaPath:"#/properties/maintainers/items/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid2 = _errs26 === errors;}else {var valid2 = true;}if(valid2){if(data11.email !== undefined){const _errs28 = errors;if(typeof data11.email !== "string"){validate20.errors = [{instancePath:instancePath+"/maintainers/" + i0+"/email",schemaPath:"#/properties/maintainers/items/properties/email/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid2 = _errs28 === errors;}else {var valid2 = true;}if(valid2){if(data11.github !== undefined){const _errs30 = errors;if(typeof data11.github !== "string"){validate20.errors = [{instancePath:instancePath+"/maintainers/" + i0+"/github",schemaPath:"#/properties/maintainers/items/properties/github/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid2 = _errs30 === errors;}else {var valid2 = true;}if(valid2){if(data11.url !== undefined){const _errs32 = errors;if(typeof data11.url !== "string"){validate20.errors = [{instancePath:instancePath+"/maintainers/" + i0+"/url",schemaPath:"#/properties/maintainers/items/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid2 = _errs32 === errors;}else {var valid2 = true;}}}}}}}else {validate20.errors = [{instancePath:instancePath+"/maintainers/" + i0,schemaPath:"#/properties/maintainers/items/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid1 = _errs23 === errors;if(!valid1){break;}}if(valid1){let i1 = data10.length;let j0;if(i1 > 1){outer0:for(;i1--;){for(j0 = i1; j0--;){if(func0(data10[i1], data10[j0])){validate20.errors = [{instancePath:instancePath+"/maintainers",schemaPath:"#/properties/maintainers/uniqueItems",keyword:"uniqueItems",params:{i: i1, j: j0},message:"must NOT have duplicate items (items ## "+j0+" and "+i1+" are identical)"}];return false;break outer0;}}}}}}else {validate20.errors = [{instancePath:instancePath+"/maintainers",schemaPath:"#/properties/maintainers/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs21 === errors;}else {var valid0 = true;}if(valid0){if(data.runtime !== undefined){let data16 = data.runtime;const _errs34 = errors;if(errors === _errs34){if(data16 && typeof data16 == "object" && !Array.isArray(data16)){let missing2;if((((data16.type === undefined) && (missing2 = "type")) || ((data16.apiVersion === undefined) && (missing2 = "apiVersion"))) || ((data16.entrypoint === undefined) && (missing2 = "entrypoint"))){validate20.errors = [{instancePath:instancePath+"/runtime",schemaPath:"#/properties/runtime/required",keyword:"required",params:{missingProperty: missing2},message:"must have required property '"+missing2+"'"}];return false;}else {if(data16.type !== undefined){let data17 = data16.type;const _errs36 = errors;if(typeof data17 !== "string"){validate20.errors = [{instancePath:instancePath+"/runtime/type",schemaPath:"#/properties/runtime/properties/type/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(data17 === "node22")){validate20.errors = [{instancePath:instancePath+"/runtime/type",schemaPath:"#/properties/runtime/properties/type/enum",keyword:"enum",params:{allowedValues: schema31.properties.runtime.properties.type.enum},message:"must be equal to one of the allowed values"}];return false;}var valid4 = _errs36 === errors;}else {var valid4 = true;}if(valid4){if(data16.apiVersion !== undefined){const _errs38 = errors;if(typeof data16.apiVersion !== "string"){validate20.errors = [{instancePath:instancePath+"/runtime/apiVersion",schemaPath:"#/properties/runtime/properties/apiVersion/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid4 = _errs38 === errors;}else {var valid4 = true;}if(valid4){if(data16.entrypoint !== undefined){const _errs40 = errors;if(typeof data16.entrypoint !== "string"){validate20.errors = [{instancePath:instancePath+"/runtime/entrypoint",schemaPath:"#/properties/runtime/properties/entrypoint/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid4 = _errs40 === errors;}else {var valid4 = true;}}}}}else {validate20.errors = [{instancePath:instancePath+"/runtime",schemaPath:"#/properties/runtime/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs34 === errors;}else {var valid0 = true;}if(valid0){if(data.keywords !== undefined){let data20 = data.keywords;const _errs42 = errors;if(errors === _errs42){if(Array.isArray(data20)){var valid5 = true;const len1 = data20.length;for(let i2=0; i2<len1; i2++){const _errs44 = errors;if(typeof data20[i2] !== "string"){validate20.errors = [{instancePath:instancePath+"/keywords/" + i2,schemaPath:"#/properties/keywords/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid5 = _errs44 === errors;if(!valid5){break;}}if(valid5){let i3 = data20.length;let j1;if(i3 > 1){const indices0 = {};for(;i3--;){let item0 = data20[i3];if(typeof item0 !== "string"){continue;}if(typeof indices0[item0] == "number"){j1 = indices0[item0];validate20.errors = [{instancePath:instancePath+"/keywords",schemaPath:"#/properties/keywords/uniqueItems",keyword:"uniqueItems",params:{i: i3, j: j1},message:"must NOT have duplicate items (items ## "+j1+" and "+i3+" are identical)"}];return false;break;}indices0[item0] = i3;}}}}else {validate20.errors = [{instancePath:instancePath+"/keywords",schemaPath:"#/properties/keywords/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs42 === errors;}else {var valid0 = true;}}}}}}}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}validate20.evaluated = {"props":{"$schema":true,"type":true,"id":true,"name":true,"description":true,"version":true,"isPrerelease":true,"license":true,"repository":true,"bugs":true,"maintainers":true,"runtime":true,"keywords":true},"dynamicProps":false,"dynamicItems":false};
@@ -0,0 +1 @@
1
+ "use strict";export const validate = validate20;export default validate20;const schema31 = {"$schema":"https://json-schema.org/draft/2020-12/schema","title":"SurfaceSchemaLayoutDefinition","description":"Schema describing a surface layout: default styling and a map of controls with positions and optional style overrides.","type":"object","$defs":{"size":{"title":"SurfaceSchemaBitmapConfig","description":"Bitmap content dimensions and format.","type":"object","properties":{"w":{"description":"Width in pixels (non-negative).","type":"number","minimum":0},"h":{"description":"Height in pixels (non-negative).","type":"number","minimum":0},"format":{"description":"Buffer pixel format","type":"string","title":"SurfaceSchemaPixelFormat","enum":["rgb","rgba","bgr","bgra"],"default":"rgb"}},"required":["w","h"],"additionalProperties":false},"stylePreset":{"title":"SurfaceSchemaControlStylePreset","description":"Styling options that can be applied to controls. Can be used as the default style or as per-control overrides.","type":"object","properties":{"bitmap":{"description":"If set, bitmaps of the specified size will be reported.","$ref":"#/$defs/size"},"text":{"description":"If true, the control requests text to be reported.","type":"boolean"},"textStyle":{"description":"If true, the control requests text style properties to be reported","type":"boolean"},"colors":{"description":"If set, the control requests colours to be reported.","type":"string","enum":["hex","rgb"]}},"additionalProperties":false}},"properties":{"stylePresets":{"description":"Named collection of style presets. The preset named `default` is required and is used as the fallback style for controls when no `stylePreset` is specified.","type":"object","properties":{"default":{"$ref":"#/$defs/stylePreset"}},"patternProperties":{"^.+$":{"$ref":"#/$defs/stylePreset"}},"required":["default"],"additionalProperties":false},"controls":{"type":"object","patternProperties":{"^[a-zA-Z0-9\\-\\/]+$":{"title":"SurfaceSchemaControlDefinition","description":"Single control definition. The id must be unique and may be user facing in logs. Typically the id would be in the form of 1/0, matching the row/column of the control.","type":"object","properties":{"row":{"description":"Zero-based row index for layout placement.","type":"number","minimum":0},"column":{"description":"Zero-based column index for layout placement.","type":"number","minimum":0},"stylePreset":{"description":"Optional name of a style preset defined in `stylePresets`. If present, the control will use the named preset instead of the default style.","type":"string","pattern":"^.+$"}},"required":["row","column"],"additionalProperties":false}},"additionalProperties":false}},"required":["stylePresets","controls"],"additionalProperties":false};const pattern4 = new RegExp("^.+$", "u");const pattern6 = new RegExp("^[a-zA-Z0-9\\-\\/]+$", "u");const schema32 = {"title":"SurfaceSchemaControlStylePreset","description":"Styling options that can be applied to controls. Can be used as the default style or as per-control overrides.","type":"object","properties":{"bitmap":{"description":"If set, bitmaps of the specified size will be reported.","$ref":"#/$defs/size"},"text":{"description":"If true, the control requests text to be reported.","type":"boolean"},"textStyle":{"description":"If true, the control requests text style properties to be reported","type":"boolean"},"colors":{"description":"If set, the control requests colours to be reported.","type":"string","enum":["hex","rgb"]}},"additionalProperties":false};const schema33 = {"title":"SurfaceSchemaBitmapConfig","description":"Bitmap content dimensions and format.","type":"object","properties":{"w":{"description":"Width in pixels (non-negative).","type":"number","minimum":0},"h":{"description":"Height in pixels (non-negative).","type":"number","minimum":0},"format":{"description":"Buffer pixel format","type":"string","title":"SurfaceSchemaPixelFormat","enum":["rgb","rgba","bgr","bgra"],"default":"rgb"}},"required":["w","h"],"additionalProperties":false};function validate21(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate21.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){const _errs1 = errors;for(const key0 in data){if(!((((key0 === "bitmap") || (key0 === "text")) || (key0 === "textStyle")) || (key0 === "colors"))){validate21.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}];return false;break;}}if(_errs1 === errors){if(data.bitmap !== undefined){let data0 = data.bitmap;const _errs2 = errors;const _errs3 = errors;if(errors === _errs3){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing0;if(((data0.w === undefined) && (missing0 = "w")) || ((data0.h === undefined) && (missing0 = "h"))){validate21.errors = [{instancePath:instancePath+"/bitmap",schemaPath:"#/$defs/size/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {const _errs5 = errors;for(const key1 in data0){if(!(((key1 === "w") || (key1 === "h")) || (key1 === "format"))){validate21.errors = [{instancePath:instancePath+"/bitmap",schemaPath:"#/$defs/size/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"}];return false;break;}}if(_errs5 === errors){if(data0.w !== undefined){let data1 = data0.w;const _errs6 = errors;if(errors === _errs6){if((typeof data1 == "number") && (isFinite(data1))){if(data1 < 0 || isNaN(data1)){validate21.errors = [{instancePath:instancePath+"/bitmap/w",schemaPath:"#/$defs/size/properties/w/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"}];return false;}}else {validate21.errors = [{instancePath:instancePath+"/bitmap/w",schemaPath:"#/$defs/size/properties/w/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}}var valid2 = _errs6 === errors;}else {var valid2 = true;}if(valid2){if(data0.h !== undefined){let data2 = data0.h;const _errs8 = errors;if(errors === _errs8){if((typeof data2 == "number") && (isFinite(data2))){if(data2 < 0 || isNaN(data2)){validate21.errors = [{instancePath:instancePath+"/bitmap/h",schemaPath:"#/$defs/size/properties/h/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"}];return false;}}else {validate21.errors = [{instancePath:instancePath+"/bitmap/h",schemaPath:"#/$defs/size/properties/h/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}}var valid2 = _errs8 === errors;}else {var valid2 = true;}if(valid2){if(data0.format !== undefined){let data3 = data0.format;const _errs10 = errors;if(typeof data3 !== "string"){validate21.errors = [{instancePath:instancePath+"/bitmap/format",schemaPath:"#/$defs/size/properties/format/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!((((data3 === "rgb") || (data3 === "rgba")) || (data3 === "bgr")) || (data3 === "bgra"))){validate21.errors = [{instancePath:instancePath+"/bitmap/format",schemaPath:"#/$defs/size/properties/format/enum",keyword:"enum",params:{allowedValues: schema33.properties.format.enum},message:"must be equal to one of the allowed values"}];return false;}var valid2 = _errs10 === errors;}else {var valid2 = true;}}}}}}else {validate21.errors = [{instancePath:instancePath+"/bitmap",schemaPath:"#/$defs/size/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs2 === errors;}else {var valid0 = true;}if(valid0){if(data.text !== undefined){const _errs12 = errors;if(typeof data.text !== "boolean"){validate21.errors = [{instancePath:instancePath+"/text",schemaPath:"#/properties/text/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs12 === errors;}else {var valid0 = true;}if(valid0){if(data.textStyle !== undefined){const _errs14 = errors;if(typeof data.textStyle !== "boolean"){validate21.errors = [{instancePath:instancePath+"/textStyle",schemaPath:"#/properties/textStyle/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs14 === errors;}else {var valid0 = true;}if(valid0){if(data.colors !== undefined){let data6 = data.colors;const _errs16 = errors;if(typeof data6 !== "string"){validate21.errors = [{instancePath:instancePath+"/colors",schemaPath:"#/properties/colors/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!((data6 === "hex") || (data6 === "rgb"))){validate21.errors = [{instancePath:instancePath+"/colors",schemaPath:"#/properties/colors/enum",keyword:"enum",params:{allowedValues: schema32.properties.colors.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs16 === errors;}else {var valid0 = true;}}}}}}else {validate21.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate21.errors = vErrors;return errors === 0;}validate21.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if(((data.stylePresets === undefined) && (missing0 = "stylePresets")) || ((data.controls === undefined) && (missing0 = "controls"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {const _errs1 = errors;for(const key0 in data){if(!((key0 === "stylePresets") || (key0 === "controls"))){validate20.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}];return false;break;}}if(_errs1 === errors){if(data.stylePresets !== undefined){let data0 = data.stylePresets;const _errs2 = errors;if(errors === _errs2){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if((data0.default === undefined) && (missing1 = "default")){validate20.errors = [{instancePath:instancePath+"/stylePresets",schemaPath:"#/properties/stylePresets/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {const _errs4 = errors;for(const key1 in data0){if(!((key1 === "default") || (pattern4.test(key1)))){validate20.errors = [{instancePath:instancePath+"/stylePresets",schemaPath:"#/properties/stylePresets/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"}];return false;break;}}if(_errs4 === errors){if(data0.default !== undefined){const _errs5 = errors;if(!(validate21(data0.default, {instancePath:instancePath+"/stylePresets/default",parentData:data0,parentDataProperty:"default",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate21.errors : vErrors.concat(validate21.errors);errors = vErrors.length;}var valid1 = _errs5 === errors;}else {var valid1 = true;}if(valid1){var valid2 = true;for(const key2 in data0){if(pattern4.test(key2)){const _errs6 = errors;if(!(validate21(data0[key2], {instancePath:instancePath+"/stylePresets/" + key2.replace(/~/g, "~0").replace(/\//g, "~1"),parentData:data0,parentDataProperty:key2,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate21.errors : vErrors.concat(validate21.errors);errors = vErrors.length;}var valid2 = _errs6 === errors;if(!valid2){break;}}}}}}}else {validate20.errors = [{instancePath:instancePath+"/stylePresets",schemaPath:"#/properties/stylePresets/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs2 === errors;}else {var valid0 = true;}if(valid0){if(data.controls !== undefined){let data3 = data.controls;const _errs7 = errors;if(errors === _errs7){if(data3 && typeof data3 == "object" && !Array.isArray(data3)){const _errs9 = errors;for(const key3 in data3){if(!(pattern6.test(key3))){validate20.errors = [{instancePath:instancePath+"/controls",schemaPath:"#/properties/controls/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"}];return false;break;}}if(_errs9 === errors){var valid3 = true;for(const key4 in data3){if(pattern6.test(key4)){let data4 = data3[key4];const _errs10 = errors;if(errors === _errs10){if(data4 && typeof data4 == "object" && !Array.isArray(data4)){let missing2;if(((data4.row === undefined) && (missing2 = "row")) || ((data4.column === undefined) && (missing2 = "column"))){validate20.errors = [{instancePath:instancePath+"/controls/" + key4.replace(/~/g, "~0").replace(/\//g, "~1"),schemaPath:"#/properties/controls/patternProperties/%5E%5Ba-zA-Z0-9%5C-%5C~1%5D%2B%24/required",keyword:"required",params:{missingProperty: missing2},message:"must have required property '"+missing2+"'"}];return false;}else {const _errs12 = errors;for(const key5 in data4){if(!(((key5 === "row") || (key5 === "column")) || (key5 === "stylePreset"))){validate20.errors = [{instancePath:instancePath+"/controls/" + key4.replace(/~/g, "~0").replace(/\//g, "~1"),schemaPath:"#/properties/controls/patternProperties/%5E%5Ba-zA-Z0-9%5C-%5C~1%5D%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"}];return false;break;}}if(_errs12 === errors){if(data4.row !== undefined){let data5 = data4.row;const _errs13 = errors;if(errors === _errs13){if((typeof data5 == "number") && (isFinite(data5))){if(data5 < 0 || isNaN(data5)){validate20.errors = [{instancePath:instancePath+"/controls/" + key4.replace(/~/g, "~0").replace(/\//g, "~1")+"/row",schemaPath:"#/properties/controls/patternProperties/%5E%5Ba-zA-Z0-9%5C-%5C~1%5D%2B%24/properties/row/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/controls/" + key4.replace(/~/g, "~0").replace(/\//g, "~1")+"/row",schemaPath:"#/properties/controls/patternProperties/%5E%5Ba-zA-Z0-9%5C-%5C~1%5D%2B%24/properties/row/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}}var valid4 = _errs13 === errors;}else {var valid4 = true;}if(valid4){if(data4.column !== undefined){let data6 = data4.column;const _errs15 = errors;if(errors === _errs15){if((typeof data6 == "number") && (isFinite(data6))){if(data6 < 0 || isNaN(data6)){validate20.errors = [{instancePath:instancePath+"/controls/" + key4.replace(/~/g, "~0").replace(/\//g, "~1")+"/column",schemaPath:"#/properties/controls/patternProperties/%5E%5Ba-zA-Z0-9%5C-%5C~1%5D%2B%24/properties/column/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/controls/" + key4.replace(/~/g, "~0").replace(/\//g, "~1")+"/column",schemaPath:"#/properties/controls/patternProperties/%5E%5Ba-zA-Z0-9%5C-%5C~1%5D%2B%24/properties/column/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}}var valid4 = _errs15 === errors;}else {var valid4 = true;}if(valid4){if(data4.stylePreset !== undefined){let data7 = data4.stylePreset;const _errs17 = errors;if(errors === _errs17){if(typeof data7 === "string"){if(!pattern4.test(data7)){validate20.errors = [{instancePath:instancePath+"/controls/" + key4.replace(/~/g, "~0").replace(/\//g, "~1")+"/stylePreset",schemaPath:"#/properties/controls/patternProperties/%5E%5Ba-zA-Z0-9%5C-%5C~1%5D%2B%24/properties/stylePreset/pattern",keyword:"pattern",params:{pattern: "^.+$"},message:"must match pattern \""+"^.+$"+"\""}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/controls/" + key4.replace(/~/g, "~0").replace(/\//g, "~1")+"/stylePreset",schemaPath:"#/properties/controls/patternProperties/%5E%5Ba-zA-Z0-9%5C-%5C~1%5D%2B%24/properties/stylePreset/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid4 = _errs17 === errors;}else {var valid4 = true;}}}}}}else {validate20.errors = [{instancePath:instancePath+"/controls/" + key4.replace(/~/g, "~0").replace(/\//g, "~1"),schemaPath:"#/properties/controls/patternProperties/%5E%5Ba-zA-Z0-9%5C-%5C~1%5D%2B%24/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid3 = _errs10 === errors;if(!valid3){break;}}}}}else {validate20.errors = [{instancePath:instancePath+"/controls",schemaPath:"#/properties/controls/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs7 === errors;}else {var valid0 = true;}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}validate20.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@companion-surface/base",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "repository": "https://github.com/bitfocus/companion-surface-api",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/main.js",
10
+ "require": "./dist/main.js"
11
+ },
12
+ "./package.json": {
13
+ "import": "./package.json",
14
+ "require": "./package.json"
15
+ }
16
+ },
17
+ "scripts": {
18
+ "docs:html": "typedoc --tsconfig tsconfig.build.json --entryPoints src/main.ts --excludePrivate --theme default --out docs"
19
+ },
20
+ "engines": {
21
+ "node": "^22.14"
22
+ },
23
+ "files": [
24
+ "README.md",
25
+ "CHANGELOG.md",
26
+ "dist",
27
+ "generated",
28
+ "assets",
29
+ "lib"
30
+ ],
31
+ "dependencies": {
32
+ "ajv": "^8.17.1",
33
+ "tslib": "^2.8.1"
34
+ },
35
+ "devDependencies": {
36
+ "typedoc": "^0.28.14"
37
+ }
38
+ }