@norskvideo/norsk-studio-built-ins 1.27.0-2025-07-09-1c530503 → 1.27.0-2025-07-09-d12abafa

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.
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FileInput = void 0;
7
+ const runtime_types_1 = require("@norskvideo/norsk-studio/lib/extension/runtime-types");
8
+ const logging_1 = require("@norskvideo/norsk-studio/lib/server/logging");
9
+ const util_1 = require("@norskvideo/norsk-studio/lib/shared/util");
10
+ const path_1 = __importDefault(require("path"));
11
+ const schemas_1 = require("../shared/schemas");
12
+ const api_1 = require("@norskvideo/norsk-studio/lib/server/api");
13
+ const info_1 = require("./info");
14
+ class FileInput {
15
+ id;
16
+ relatedMediaNodes = new runtime_types_1.RelatedMediaNodes();
17
+ norsk;
18
+ cfg;
19
+ currentNode;
20
+ initialised;
21
+ updates;
22
+ static async create(norsk, cfg, updates) {
23
+ const node = new FileInput(norsk, cfg, updates);
24
+ await node.initialised;
25
+ return node;
26
+ }
27
+ constructor(norsk, cfg, updates) {
28
+ this.cfg = cfg;
29
+ this.id = cfg.id;
30
+ this.norsk = norsk;
31
+ this.updates = updates;
32
+ this.initialised = this.initialise();
33
+ }
34
+ async initialise() {
35
+ await this.relatedMediaNodes.setup(this.norsk, this, this.cfg.streamMappings ?? (0, info_1.defaultStreamMapping)(this.cfg));
36
+ }
37
+ async play(filePath) {
38
+ const currentState = this.updates.latest();
39
+ if (currentState.status === 'playing') {
40
+ throw new Error('Already playing a file');
41
+ }
42
+ const ext = path_1.default.extname(filePath).toLowerCase();
43
+ this.updates.raiseEvent({
44
+ type: 'playback-started',
45
+ filePath
46
+ });
47
+ try {
48
+ if (ext === '.mp4') {
49
+ this.currentNode = await this.norsk.input.fileMp4({
50
+ id: `${this.cfg.id}-file`,
51
+ sourceName: this.cfg.sourceName,
52
+ fileName: filePath,
53
+ loop: false,
54
+ onClose: () => {
55
+ (0, logging_1.debuglog)('File playback completed');
56
+ this.currentNode = undefined;
57
+ this.cleanup().then(() => {
58
+ this.updates.raiseEvent({
59
+ type: 'playback-completed',
60
+ filePath: this.updates.latest().currentFile || ''
61
+ });
62
+ }).catch(error => {
63
+ (0, logging_1.errorlog)('Error during cleanup:', error);
64
+ });
65
+ }
66
+ });
67
+ }
68
+ else if (ext === '.ts') {
69
+ this.currentNode = await this.norsk.input.fileTs({
70
+ id: `${this.cfg.id}-file`,
71
+ sourceName: this.cfg.sourceName,
72
+ fileName: filePath,
73
+ loop: false,
74
+ onClose: () => {
75
+ (0, logging_1.debuglog)('TS file playback completed');
76
+ this.currentNode = undefined;
77
+ this.cleanup().then(() => {
78
+ this.updates.raiseEvent({
79
+ type: 'playback-completed',
80
+ filePath: this.updates.latest().currentFile || ''
81
+ });
82
+ }).catch(error => {
83
+ (0, logging_1.errorlog)('Error during cleanup:', error);
84
+ });
85
+ }
86
+ });
87
+ }
88
+ else {
89
+ throw new Error(`Unsupported file type: ${ext}`);
90
+ }
91
+ this.relatedMediaNodes.addOutput(this.currentNode);
92
+ (0, logging_1.infolog)(`Started playing file: ${filePath}`);
93
+ }
94
+ catch (error) {
95
+ (0, logging_1.errorlog)(`Failed to create file input for ${filePath}:`, error);
96
+ this.updates.raiseEvent({
97
+ type: 'playback-error',
98
+ error: `Failed to create file input: ${error instanceof Error ? error.message : String(error)}`,
99
+ filePath
100
+ });
101
+ throw error;
102
+ }
103
+ }
104
+ async stop() {
105
+ const currentState = this.updates.latest();
106
+ if (currentState.status !== 'playing') {
107
+ return;
108
+ }
109
+ (0, logging_1.debuglog)('Stopping file playback');
110
+ await this.cleanup();
111
+ this.updates.raiseEvent({
112
+ type: 'playback-stopped'
113
+ });
114
+ }
115
+ async cleanup() {
116
+ if (this.currentNode) {
117
+ try {
118
+ await this.currentNode.close();
119
+ this.currentNode = undefined;
120
+ }
121
+ catch (error) {
122
+ (0, logging_1.errorlog)('Error closing file input node:', error);
123
+ }
124
+ this.currentNode = undefined;
125
+ }
126
+ (0, logging_1.debuglog)('File input cleanup completed');
127
+ }
128
+ async close() {
129
+ await this.cleanup();
130
+ }
131
+ }
132
+ exports.FileInput = FileInput;
133
+ class FileInputDefinition {
134
+ async create(norsk, cfg, cb, runtime) {
135
+ const node = await FileInput.create(norsk, cfg, runtime.updates);
136
+ cb(node);
137
+ }
138
+ async handleCommand(node, command) {
139
+ const commandType = command.type;
140
+ switch (commandType) {
141
+ case 'play':
142
+ await node.play(command.filePath);
143
+ break;
144
+ case 'stop':
145
+ await node.stop();
146
+ break;
147
+ default:
148
+ (0, util_1.assertUnreachable)(commandType);
149
+ }
150
+ }
151
+ async schemas() {
152
+ return (0, schemas_1.schemaFromTypes)(path_1.default.join(__dirname, 'types.yaml'), {
153
+ config: 'Config',
154
+ state: 'State'
155
+ });
156
+ }
157
+ async instanceRoutes() {
158
+ return (0, api_1.defineApi)(path_1.default.join(__dirname, 'types.yaml'), {
159
+ '/play': {
160
+ post: ({ runtime }) => async (req, res) => {
161
+ try {
162
+ const { filePath } = req.body;
163
+ if (!filePath) {
164
+ return res.status(400).json({ error: 'filePath is required' });
165
+ }
166
+ runtime.updates.sendCommand({
167
+ type: 'play',
168
+ filePath
169
+ });
170
+ res.json({ status: 'playing', filePath });
171
+ }
172
+ catch (error) {
173
+ (0, logging_1.errorlog)('Error in play handler:', error);
174
+ res.status(500).json({ error: 'Failed to start playback' });
175
+ }
176
+ }
177
+ },
178
+ '/stop': {
179
+ post: ({ runtime }) => async (req, res) => {
180
+ try {
181
+ runtime.updates.sendCommand({
182
+ type: 'stop'
183
+ });
184
+ res.json({ status: 'stopped' });
185
+ }
186
+ catch (error) {
187
+ (0, logging_1.errorlog)('Error in stop handler:', error);
188
+ res.status(500).json({ error: 'Failed to stop playback' });
189
+ }
190
+ }
191
+ },
192
+ '/status': {
193
+ get: ({ runtime }) => async (req, res) => {
194
+ try {
195
+ const state = runtime.updates.latest();
196
+ res.json(state);
197
+ }
198
+ catch (error) {
199
+ (0, logging_1.errorlog)('Error in status handler:', error);
200
+ res.status(500).json({ error: 'Failed to get status' });
201
+ }
202
+ }
203
+ }
204
+ });
205
+ }
206
+ }
207
+ exports.default = FileInputDefinition;
208
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/input.file/runtime.ts"],"names":[],"mappings":";;;;;;AACA,wFAAmM;AACnM,yEAA0F;AAC1F,mEAA6E;AAC7E,gDAAwB;AAExB,+CAAoD;AACpD,iEAAoE;AACpE,iCAA8C;AAU9C,MAAa,SAAS;IACpB,EAAE,CAAS;IACX,iBAAiB,GAAsB,IAAI,iCAAiB,EAAE,CAAC;IAE/D,KAAK,CAAQ;IACb,GAAG,CAAoB;IAEvB,WAAW,CAAsC;IAEjD,WAAW,CAAgB;IAE3B,OAAO,CAAmE;IAE1E,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAY,EAAE,GAAsB,EAAE,OAAyE;QACjI,MAAM,IAAI,GAAG,IAAI,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAChD,MAAM,IAAI,CAAC,WAAW,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,KAAY,EAAE,GAAsB,EAAE,OAAyE;QACzH,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,iBAAiB,CAAC,KAA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C;wBACvC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAClB,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,IAAA,kBAAQ,EAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;wBAC5C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC,CAAC;oBAC1D,CAAC;gBACH,CAAC;aACF;SACF,CAAC,CAAC;IACP,CAAC;CACF;AAhFD,sCAgFC"}
@@ -0,0 +1,234 @@
1
+ export interface paths {
2
+ "/play": {
3
+ parameters: {
4
+ query?: never;
5
+ header?: never;
6
+ path?: never;
7
+ cookie?: never;
8
+ };
9
+ get?: never;
10
+ put?: never;
11
+ post: {
12
+ parameters: {
13
+ query?: never;
14
+ header?: never;
15
+ path?: never;
16
+ cookie?: never;
17
+ };
18
+ requestBody?: {
19
+ content: {
20
+ "application/json": {
21
+ filePath: string;
22
+ };
23
+ };
24
+ };
25
+ responses: {
26
+ 200: {
27
+ headers: {
28
+ [name: string]: unknown;
29
+ };
30
+ content: {
31
+ "application/json": {
32
+ status?: "playing";
33
+ filePath?: string;
34
+ };
35
+ };
36
+ };
37
+ 400: {
38
+ headers: {
39
+ [name: string]: unknown;
40
+ };
41
+ content: {
42
+ "application/json": {
43
+ error?: string;
44
+ };
45
+ };
46
+ };
47
+ 500: {
48
+ headers: {
49
+ [name: string]: unknown;
50
+ };
51
+ content: {
52
+ "application/json": {
53
+ error?: string;
54
+ };
55
+ };
56
+ };
57
+ };
58
+ };
59
+ delete?: never;
60
+ options?: never;
61
+ head?: never;
62
+ patch?: never;
63
+ trace?: never;
64
+ };
65
+ "/stop": {
66
+ parameters: {
67
+ query?: never;
68
+ header?: never;
69
+ path?: never;
70
+ cookie?: never;
71
+ };
72
+ get?: never;
73
+ put?: never;
74
+ post: {
75
+ parameters: {
76
+ query?: never;
77
+ header?: never;
78
+ path?: never;
79
+ cookie?: never;
80
+ };
81
+ requestBody?: never;
82
+ responses: {
83
+ 200: {
84
+ headers: {
85
+ [name: string]: unknown;
86
+ };
87
+ content: {
88
+ "application/json": {
89
+ status?: "stopped";
90
+ };
91
+ };
92
+ };
93
+ 500: {
94
+ headers: {
95
+ [name: string]: unknown;
96
+ };
97
+ content: {
98
+ "application/json": {
99
+ error?: string;
100
+ };
101
+ };
102
+ };
103
+ };
104
+ };
105
+ delete?: never;
106
+ options?: never;
107
+ head?: never;
108
+ patch?: never;
109
+ trace?: never;
110
+ };
111
+ "/status": {
112
+ parameters: {
113
+ query?: never;
114
+ header?: never;
115
+ path?: never;
116
+ cookie?: never;
117
+ };
118
+ get: {
119
+ parameters: {
120
+ query?: never;
121
+ header?: never;
122
+ path?: never;
123
+ cookie?: never;
124
+ };
125
+ requestBody?: never;
126
+ responses: {
127
+ 200: {
128
+ headers: {
129
+ [name: string]: unknown;
130
+ };
131
+ content: {
132
+ "application/json": {
133
+ status: "idle" | "playing" | "error";
134
+ currentFile: string | null;
135
+ error: string | null;
136
+ };
137
+ };
138
+ };
139
+ };
140
+ };
141
+ put?: never;
142
+ post?: never;
143
+ delete?: never;
144
+ options?: never;
145
+ head?: never;
146
+ patch?: never;
147
+ trace?: never;
148
+ };
149
+ }
150
+ export type webhooks = Record<string, never>;
151
+ export interface components {
152
+ schemas: {
153
+ Config: {
154
+ id: string;
155
+ displayName: string;
156
+ notes?: string;
157
+ sourceName: string;
158
+ streamMappings?: {
159
+ streams: {
160
+ outputKey: {
161
+ streamId: number;
162
+ programNumber: number;
163
+ sourceName: string;
164
+ renditionName: string;
165
+ };
166
+ displayName?: string;
167
+ media: "video" | "audio" | "subtitle" | "ancillary" | "playlist";
168
+ filters?: ({
169
+ type: "sourceName" | "language" | "codec" | "renditionName";
170
+ value: string;
171
+ } | {
172
+ type: "streamId" | "programNumber";
173
+ value: number;
174
+ })[];
175
+ missingBehaviour?: "fill" | "skip";
176
+ }[];
177
+ };
178
+ };
179
+ State: {
180
+ status: "idle" | "playing" | "error";
181
+ currentFile: string | null;
182
+ error: string | null;
183
+ };
184
+ Commands: {
185
+ type: "play";
186
+ filePath: string;
187
+ } | {
188
+ type: "stop";
189
+ };
190
+ PlayCommand: {
191
+ type: "play";
192
+ filePath: string;
193
+ };
194
+ StopCommand: {
195
+ type: "stop";
196
+ };
197
+ Events: {
198
+ type: "playback-started";
199
+ filePath: string;
200
+ } | {
201
+ type: "playback-completed";
202
+ filePath: string;
203
+ } | {
204
+ type: "playback-stopped";
205
+ } | {
206
+ type: "playback-error";
207
+ error: string;
208
+ filePath?: string | null;
209
+ };
210
+ PlaybackStartedEvent: {
211
+ type: "playback-started";
212
+ filePath: string;
213
+ };
214
+ PlaybackCompletedEvent: {
215
+ type: "playback-completed";
216
+ filePath: string;
217
+ };
218
+ PlaybackStoppedEvent: {
219
+ type: "playback-stopped";
220
+ };
221
+ PlaybackErrorEvent: {
222
+ type: "playback-error";
223
+ error: string;
224
+ filePath?: string | null;
225
+ };
226
+ };
227
+ responses: never;
228
+ parameters: never;
229
+ requestBodies: never;
230
+ headers: never;
231
+ pathItems: never;
232
+ }
233
+ export type $defs = Record<string, never>;
234
+ export type operations = Record<string, never>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/input.file/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,227 @@
1
+ openapi: 3.0.0
2
+ info:
3
+ title: File Input Component
4
+ version: 1.0.0
5
+
6
+ paths:
7
+ /play:
8
+ post:
9
+ summary: Start playing a file
10
+ description: Dynamically creates a file input node and starts playback
11
+ x-route-type: instance
12
+ requestBody:
13
+ description: The file to play
14
+ content:
15
+ application/json:
16
+ schema:
17
+ type: object
18
+ required: ['filePath']
19
+ properties:
20
+ filePath:
21
+ type: string
22
+ description: Absolute path to the file to play
23
+ example: /media/video.mp4
24
+ responses:
25
+ 200:
26
+ description: Playback started successfully
27
+ content:
28
+ application/json:
29
+ schema:
30
+ type: object
31
+ properties:
32
+ status:
33
+ type: string
34
+ enum: ["playing"]
35
+ filePath:
36
+ type: string
37
+ 400:
38
+ description: Invalid request or already playing
39
+ content:
40
+ application/json:
41
+ schema:
42
+ type: object
43
+ properties:
44
+ error:
45
+ type: string
46
+ description: A description of the error
47
+ 500:
48
+ description: Failed to start playback
49
+ content:
50
+ application/json:
51
+ schema:
52
+ type: object
53
+ properties:
54
+ error:
55
+ type: string
56
+ description: A description of the error
57
+
58
+ /stop:
59
+ post:
60
+ summary: Stop current playback
61
+ description: Stops the current file playback and cleans up resources
62
+ x-route-type: instance
63
+ responses:
64
+ 200:
65
+ description: Playback stopped successfully
66
+ content:
67
+ application/json:
68
+ schema:
69
+ type: object
70
+ properties:
71
+ status:
72
+ type: string
73
+ enum: ["stopped"]
74
+ 500:
75
+ description: Failed to stop playback
76
+ content:
77
+ application/json:
78
+ schema:
79
+ type: object
80
+ properties:
81
+ error:
82
+ type: string
83
+ description: A description of the error
84
+
85
+ /status:
86
+ get:
87
+ summary: Get current playback status
88
+ description: Returns the current state of the file input component
89
+ x-route-type: instance
90
+ responses:
91
+ 200:
92
+ description: Current status
93
+ content:
94
+ application/json:
95
+ schema:
96
+ $ref: '#/components/schemas/State'
97
+
98
+ components:
99
+ schemas:
100
+ Config:
101
+ type: object
102
+ properties:
103
+ id:
104
+ type: string
105
+ description: Component ID
106
+ displayName:
107
+ type: string
108
+ description: Component display name
109
+ notes:
110
+ type: string
111
+ description: Optional notes about the component
112
+ sourceName:
113
+ type: string
114
+ description: Source name for output streams
115
+ streamMappings:
116
+ $ref: '../../../core/src/types/base.yml#/components/schemas/StreamMappingConfiguration'
117
+ required:
118
+ - id
119
+ - displayName
120
+ - sourceName
121
+
122
+ State:
123
+ type: object
124
+ properties:
125
+ status:
126
+ type: string
127
+ enum: ["idle", "playing", "error"]
128
+ description: Current playback status
129
+ currentFile:
130
+ type: string
131
+ nullable: true
132
+ description: Path to currently playing file
133
+ error:
134
+ type: string
135
+ nullable: true
136
+ description: Error message if status is error
137
+ required:
138
+ - status
139
+ - currentFile
140
+ - error
141
+
142
+ Commands:
143
+ oneOf:
144
+ - $ref: '#/components/schemas/PlayCommand'
145
+ - $ref: '#/components/schemas/StopCommand'
146
+
147
+ PlayCommand:
148
+ type: object
149
+ properties:
150
+ type:
151
+ type: string
152
+ enum: ["play"]
153
+ filePath:
154
+ type: string
155
+ description: Absolute path to the file to play
156
+ required:
157
+ - type
158
+ - filePath
159
+
160
+ StopCommand:
161
+ type: object
162
+ properties:
163
+ type:
164
+ type: string
165
+ enum: ["stop"]
166
+ required:
167
+ - type
168
+
169
+ Events:
170
+ oneOf:
171
+ - $ref: '#/components/schemas/PlaybackStartedEvent'
172
+ - $ref: '#/components/schemas/PlaybackCompletedEvent'
173
+ - $ref: '#/components/schemas/PlaybackStoppedEvent'
174
+ - $ref: '#/components/schemas/PlaybackErrorEvent'
175
+
176
+ PlaybackStartedEvent:
177
+ type: object
178
+ properties:
179
+ type:
180
+ type: string
181
+ enum: ["playback-started"]
182
+ filePath:
183
+ type: string
184
+ description: Path to the file that started playing
185
+ required:
186
+ - type
187
+ - filePath
188
+
189
+ PlaybackCompletedEvent:
190
+ type: object
191
+ properties:
192
+ type:
193
+ type: string
194
+ enum: ["playback-completed"]
195
+ filePath:
196
+ type: string
197
+ description: Path to the file that completed
198
+ required:
199
+ - type
200
+ - filePath
201
+
202
+ PlaybackStoppedEvent:
203
+ type: object
204
+ properties:
205
+ type:
206
+ type: string
207
+ enum: ["playback-stopped"]
208
+ required:
209
+ - type
210
+
211
+ PlaybackErrorEvent:
212
+ type: object
213
+ properties:
214
+ type:
215
+ type: string
216
+ enum: ["playback-error"]
217
+ error:
218
+ type: string
219
+ description: Error description
220
+ filePath:
221
+ type: string
222
+ nullable: true
223
+ description: Path to the file that caused the error
224
+ required:
225
+ - type
226
+ - error
227
+