@norskvideo/norsk-studio-built-ins 1.0.1 → 1.0.2
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/client/info.js +46 -12
- package/lib/processor.dynamicBug/info.d.ts +1 -1
- package/lib/processor.dynamicBug/info.js +10 -1
- package/lib/processor.dynamicBug/info.js.map +1 -1
- package/lib/processor.dynamicBug/runtime.d.ts +6 -2
- package/lib/processor.dynamicBug/runtime.js +132 -47
- package/lib/processor.dynamicBug/runtime.js.map +1 -1
- package/lib/processor.dynamicBug/summary-view.js +41 -14
- package/lib/processor.dynamicBug/summary-view.js.map +1 -1
- package/package.json +3 -1
package/client/info.js
CHANGED
@@ -1498,26 +1498,51 @@ function SummaryView7({ state, config, sendCommand }) {
|
|
1498
1498
|
const [bug, setBug] = (0, import_react34.useState)(state.activeBug?.file ?? config.defaultBug);
|
1499
1499
|
const [orientation, setOrientation] = (0, import_react34.useState)(state.activeBug?.orientation ?? config.defaultOrientation);
|
1500
1500
|
const [bugs, setBugs] = (0, import_react34.useState)([]);
|
1501
|
+
const [fileToUpload, setFileToUpload] = (0, import_react34.useState)(void 0);
|
1502
|
+
async function updateBugs() {
|
1503
|
+
const result2 = await fetch("components/processor.dynamicBug/bugs");
|
1504
|
+
if (result2.ok && result2.body) {
|
1505
|
+
const bugs2 = await result2.json();
|
1506
|
+
setBugs(bugs2);
|
1507
|
+
} else {
|
1508
|
+
const text = await result2.text();
|
1509
|
+
throw new Error(text);
|
1510
|
+
}
|
1511
|
+
}
|
1501
1512
|
(0, import_react34.useEffect)(() => {
|
1502
1513
|
const fn = async () => {
|
1503
|
-
|
1504
|
-
if (result2.ok && result2.body) {
|
1505
|
-
const bugs2 = await result2.json();
|
1506
|
-
setBugs(bugs2);
|
1507
|
-
} else {
|
1508
|
-
const text = await result2.text();
|
1509
|
-
throw new Error(text);
|
1510
|
-
}
|
1514
|
+
await updateBugs();
|
1511
1515
|
};
|
1512
1516
|
fn().catch(console.error);
|
1513
1517
|
}, []);
|
1518
|
+
function onFileChange(e) {
|
1519
|
+
if (e.target.files?.[0])
|
1520
|
+
setFileToUpload(e.target.files[0]);
|
1521
|
+
}
|
1514
1522
|
return (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [(0, import_jsx_runtime32.jsx)("h2", { children: "Controls" }), (0, import_jsx_runtime32.jsx)("label", { htmlFor: "select-preview", className: "mt-2", children: "Source" }), (0, import_jsx_runtime32.jsxs)("select", { id: "select-bug", className: "mt-2 node-editor-select-input", onChange: (e) => {
|
1515
1523
|
setBug(e.currentTarget.value);
|
1516
|
-
}, children: [(0, import_jsx_runtime32.jsx)("option", { selected: bug === void 0, children: "---" }), bugs.map((s, i) => (0, import_jsx_runtime32.jsx)("option", { selected: bug == s, value: s, children: s }, i))] }), (0, import_jsx_runtime32.jsxs)("select", { id: "select-orientation", className: "mt-2 node-editor-select-input", onChange: (e) => {
|
1524
|
+
}, children: [(0, import_jsx_runtime32.jsx)("option", { selected: bug === void 0, children: "---" }), (0, import_jsx_runtime32.jsx)("option", { value: "new", selected: bug === "new", children: "New" }), bugs.map((s, i) => (0, import_jsx_runtime32.jsx)("option", { selected: bug == s, value: s, children: s }, i))] }), (0, import_jsx_runtime32.jsx)("form", { style: { display: bug === "new" ? "block" : "none" }, onSubmit: (e) => e.preventDefault(), children: (0, import_jsx_runtime32.jsx)("input", { type: "file", id: "file", name: "filename", onChange: onFileChange }) }), (0, import_jsx_runtime32.jsxs)("select", { id: "select-orientation", className: "mt-2 node-editor-select-input", onChange: (e) => {
|
1517
1525
|
setOrientation(e.currentTarget.value);
|
1518
|
-
}, children: [(0, import_jsx_runtime32.jsx)("option", { selected: orientation === void 0, children: "---" }), (0, import_jsx_runtime32.jsx)("option", { value: "topleft", selected: orientation === "topleft", children: "Top Left" }), (0, import_jsx_runtime32.jsx)("option", { value: "topright", selected: orientation === "topright", children: "Top Right" }), (0, import_jsx_runtime32.jsx)("option", { value: "bottomleft", selected: orientation === "bottomleft", children: "Bottom Left" }), (0, import_jsx_runtime32.jsx)("option", { value: "bottomright", selected: orientation === "bottomright", children: "Bottom Right" })] }), bug != state.activeBug?.file || orientation != state.activeBug?.orientation ? (0, import_jsx_runtime32.jsx)("button", { type: "button", className: "mt-2 mb-2 text-white w-full justify-center bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800", onClick: (e) => {
|
1526
|
+
}, children: [(0, import_jsx_runtime32.jsx)("option", { selected: orientation === void 0, children: "---" }), (0, import_jsx_runtime32.jsx)("option", { value: "topleft", selected: orientation === "topleft", children: "Top Left" }), (0, import_jsx_runtime32.jsx)("option", { value: "topright", selected: orientation === "topright", children: "Top Right" }), (0, import_jsx_runtime32.jsx)("option", { value: "bottomleft", selected: orientation === "bottomleft", children: "Bottom Left" }), (0, import_jsx_runtime32.jsx)("option", { value: "bottomright", selected: orientation === "bottomright", children: "Bottom Right" })] }), bug != state.activeBug?.file || orientation != state.activeBug?.orientation || fileToUpload ? (0, import_jsx_runtime32.jsx)("button", { type: "button", className: "mt-2 mb-2 text-white w-full justify-center bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800", onClick: async (e) => {
|
1519
1527
|
e.preventDefault();
|
1520
|
-
|
1528
|
+
if (fileToUpload && bug === "new") {
|
1529
|
+
const form = new FormData();
|
1530
|
+
const url = `http://${document.location.hostname}:${config.apiPort}/bugs`;
|
1531
|
+
form.append("file", fileToUpload);
|
1532
|
+
await fetch(url, {
|
1533
|
+
method: "POST",
|
1534
|
+
body: form
|
1535
|
+
});
|
1536
|
+
setTimeout(async () => {
|
1537
|
+
await updateBugs();
|
1538
|
+
sendCommand({ type: "change-bug", file: fileToUpload.name, orientation });
|
1539
|
+
setBug(fileToUpload.name);
|
1540
|
+
setFileToUpload(void 0);
|
1541
|
+
return;
|
1542
|
+
}, 500);
|
1543
|
+
} else {
|
1544
|
+
sendCommand({ type: "change-bug", file: bug, orientation });
|
1545
|
+
}
|
1521
1546
|
}, children: "Commit" }) : (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, {})] });
|
1522
1547
|
}
|
1523
1548
|
var import_jsx_runtime32, import_react34, summary_view_default5;
|
@@ -17637,7 +17662,7 @@ function assertUnreachable10(_) {
|
|
17637
17662
|
// build/processor.dynamicBug/info.js
|
17638
17663
|
var import_config5 = __toESM(require_config());
|
17639
17664
|
var import_react35 = __toESM(require_react());
|
17640
|
-
function info_default22({ defineComponent, Video }) {
|
17665
|
+
function info_default22({ defineComponent, Video, validation: { Port, unique } }) {
|
17641
17666
|
const BugSelection2 = import_react35.default.lazy(async () => Promise.resolve().then(() => (init_bug_selection(), bug_selection_exports)));
|
17642
17667
|
const SummaryView8 = import_react35.default.lazy(async () => Promise.resolve().then(() => (init_summary_view5(), summary_view_exports5)));
|
17643
17668
|
return defineComponent({
|
@@ -17700,6 +17725,15 @@ function info_default22({ defineComponent, Video }) {
|
|
17700
17725
|
{ value: "bottomright", display: "Bottom Right" }
|
17701
17726
|
]
|
17702
17727
|
}
|
17728
|
+
},
|
17729
|
+
apiPort: {
|
17730
|
+
help: "Port to open the API on",
|
17731
|
+
hint: {
|
17732
|
+
type: "numeric",
|
17733
|
+
defaultValue: 5e3,
|
17734
|
+
validation: Port,
|
17735
|
+
global: unique("port")
|
17736
|
+
}
|
17703
17737
|
}
|
17704
17738
|
}
|
17705
17739
|
}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import type Registration from "@norskvideo/norsk-studio/lib/extension/registration";
|
2
2
|
import type { DynamicBugCommand, DynamicBugConfig, DynamicBugEvent, DynamicBugState } from "./runtime";
|
3
|
-
export default function ({ defineComponent, Video }: Registration): import("@norskvideo/norsk-studio/lib/extension/client-types").NodeInfo<DynamicBugConfig, DynamicBugState, DynamicBugCommand, DynamicBugEvent>;
|
3
|
+
export default function ({ defineComponent, Video, validation: { Port, unique } }: Registration): import("@norskvideo/norsk-studio/lib/extension/client-types").NodeInfo<DynamicBugConfig, DynamicBugState, DynamicBugCommand, DynamicBugEvent>;
|
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
const config_1 = require("@norskvideo/norsk-studio/lib/shared/config");
|
30
30
|
const react_1 = __importDefault(require("react"));
|
31
|
-
function default_1({ defineComponent, Video }) {
|
31
|
+
function default_1({ defineComponent, Video, validation: { Port, unique } }) {
|
32
32
|
const BugSelection = react_1.default.lazy(async () => Promise.resolve().then(() => __importStar(require('./bug-selection'))));
|
33
33
|
const SummaryView = react_1.default.lazy(async () => Promise.resolve().then(() => __importStar(require('./summary-view'))));
|
34
34
|
return defineComponent({
|
@@ -90,6 +90,15 @@ function default_1({ defineComponent, Video }) {
|
|
90
90
|
{ value: 'bottomright', display: 'Bottom Right' }
|
91
91
|
]
|
92
92
|
}
|
93
|
+
},
|
94
|
+
apiPort: {
|
95
|
+
help: "Port to open the API on",
|
96
|
+
hint: {
|
97
|
+
type: 'numeric',
|
98
|
+
defaultValue: 5000,
|
99
|
+
validation: Port,
|
100
|
+
global: unique('port')
|
101
|
+
}
|
93
102
|
}
|
94
103
|
}
|
95
104
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/processor.dynamicBug/info.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uEAA+E;AAC/E,kDAA0B;AAG1B,mBAAwB,EACtB,eAAe,EACf,KAAK,
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/processor.dynamicBug/info.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uEAA+E;A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AA;gBAE7B,CAAC;YACH,CAAC;SACF;QACD,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,QAAQ,EAAE,IAAA,0BAAiB,GAAE;aAC9B;YACD,IAAI,EAAE;gBACJ,UAAU,EAAE;oBACV,IAAI,EAAE,iDAAiD;oBACvD,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,SAAS,EAAE,YAAY;qBACxB;iBACF;gBACD,kBAAkB,EAAE;oBAClB,IAAI,EAAE,2CAA2C;oBACjD,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,IAAI;wBACd,OAAO,EAAE;4BACP,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE;4BACzC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE;4BAC3C,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE;4BAC/C,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE;yBAClD;qBACF;iBACF;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,yBAAyB;oBAC/B,IAAI,EAAE;wBACJ,IAAI,EAAE,SAAS;wBACf,YAAY,EAAE,IAAI;wBAClB,UAAU,EAAE,IAAI;wBAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;qBACvB;iBACF;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAnFD,4BAmFC;AAED,SAAS,iBAAiB,CAAC,CAAQ;IACjC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC/C,CAAC"}
|
@@ -12,6 +12,7 @@ export type DynamicBugConfig = {
|
|
12
12
|
displayName: string;
|
13
13
|
defaultBug?: string;
|
14
14
|
defaultOrientation?: DynamicBugOrientation;
|
15
|
+
apiPort: number;
|
15
16
|
};
|
16
17
|
export type DynamicBugState = {
|
17
18
|
activeBug?: {
|
@@ -39,6 +40,8 @@ export declare class DynamicBug implements CreatedMediaNode, SubscribeDestinatio
|
|
39
40
|
relatedMediaNodes: RelatedMediaNodes;
|
40
41
|
norsk: Norsk;
|
41
42
|
cfg: DynamicBugConfig;
|
43
|
+
bug?: string;
|
44
|
+
orientation?: DynamicBugOrientation;
|
42
45
|
videoSource?: StudioNodeSubscriptionSource;
|
43
46
|
composeNode?: VideoComposeNode<"video" | "bug">;
|
44
47
|
imageSource?: FileImageInputNode;
|
@@ -47,9 +50,10 @@ export declare class DynamicBug implements CreatedMediaNode, SubscribeDestinatio
|
|
47
50
|
static create(norsk: Norsk, cfg: DynamicBugConfig, updates: RuntimeUpdates<DynamicBugState, DynamicBugEvent>): Promise<DynamicBug>;
|
48
51
|
constructor(norsk: Norsk, cfg: DynamicBugConfig, updates: RuntimeUpdates<DynamicBugState, DynamicBugEvent>);
|
49
52
|
sourceContextChange(_responseCallback: (error?: SubscriptionError | undefined) => void): Promise<boolean>;
|
53
|
+
doSubs(): void;
|
50
54
|
setupBug(bug?: string, orientation?: DynamicBugOrientation): Promise<void>;
|
51
|
-
imagePart(orientation: DynamicBugOrientation): ComposePart<"bug">;
|
52
|
-
videoPart(): ComposePart<"video">;
|
55
|
+
imagePart(orientation: DynamicBugOrientation, videoWidth: number, videoHeight: number, imageWidth: number, imageHeight: number): ComposePart<"bug">;
|
56
|
+
videoPart(videoWidth: number, videoHeight: number): ComposePart<"video">;
|
53
57
|
initialise(): Promise<void>;
|
54
58
|
subscribe(sources: StudioNodeSubscriptionSource[]): void;
|
55
59
|
}
|
@@ -9,24 +9,77 @@ const runtime_types_1 = require("@norskvideo/norsk-studio/lib/extension/runtime-
|
|
9
9
|
const logging_1 = require("@norskvideo/norsk-studio/lib/server/logging");
|
10
10
|
const config_1 = require("@norskvideo/norsk-studio/lib/shared/config");
|
11
11
|
const util_1 = require("@norskvideo/norsk-studio/lib/shared/util");
|
12
|
-
const express_1 = __importDefault(require("express"));
|
13
12
|
const promises_1 = __importDefault(require("fs/promises"));
|
14
13
|
const path_1 = __importDefault(require("path"));
|
14
|
+
const cors_1 = __importDefault(require("cors"));
|
15
|
+
const body_parser_1 = __importDefault(require("body-parser"));
|
16
|
+
const express_1 = __importDefault(require("express"));
|
17
|
+
const multer_1 = __importDefault(require("multer"));
|
15
18
|
function bugDir() {
|
16
|
-
return path_1.default.resolve(process.env.
|
19
|
+
return path_1.default.resolve(process.env.norsk_data_dir || "data/bugs");
|
20
|
+
}
|
21
|
+
async function getBugs() {
|
22
|
+
const files = await promises_1.default.readdir(bugDir());
|
23
|
+
const images = files.filter((f) => {
|
24
|
+
return f.endsWith(".png") || f.endsWith(".jpg");
|
25
|
+
});
|
26
|
+
return images;
|
17
27
|
}
|
18
28
|
class DynamicBugDefinition {
|
19
29
|
async create(norsk, cfg, cb, runtime) {
|
20
30
|
const node = await DynamicBug.create(norsk, cfg, runtime.updates);
|
21
31
|
cb(node);
|
32
|
+
const expressApp = (0, express_1.default)();
|
33
|
+
expressApp.use(express_1.default.json());
|
34
|
+
expressApp.use((0, cors_1.default)());
|
35
|
+
expressApp.get("/active-bug", async (_req, res) => {
|
36
|
+
res.writeHead(200);
|
37
|
+
res.end(JSON.stringify({
|
38
|
+
bug: node.bug,
|
39
|
+
orientation: node.orientation
|
40
|
+
}));
|
41
|
+
});
|
42
|
+
expressApp.post("/active-bug", async (req, res) => {
|
43
|
+
if (!["topleft", "topright", "bottomleft", "bottomright"].includes(req.body.orientation)) {
|
44
|
+
res.writeHead(400);
|
45
|
+
res.end("bad orientation");
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
const images = await getBugs();
|
49
|
+
if (!images.includes(req.body.bug)) {
|
50
|
+
res.writeHead(400);
|
51
|
+
res.end("bad bug");
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
await node.setupBug(req.body.bug, req.body.orientation);
|
55
|
+
res.writeHead(200);
|
56
|
+
res.end("ok");
|
57
|
+
});
|
58
|
+
const storage = multer_1.default.diskStorage({
|
59
|
+
destination: bugDir(),
|
60
|
+
filename: function (_req, file, cb) {
|
61
|
+
cb(null, path_1.default.basename(file.originalname));
|
62
|
+
}
|
63
|
+
});
|
64
|
+
const upload = (0, multer_1.default)({ storage });
|
65
|
+
expressApp.post('/bugs', upload.single('file'), (_req, res) => {
|
66
|
+
res.send('File uploaded successfully');
|
67
|
+
});
|
68
|
+
expressApp.get("/bugs", (0, cors_1.default)({
|
69
|
+
origin: '*',
|
70
|
+
optionsSuccessStatus: 200
|
71
|
+
}), async (_req, res) => {
|
72
|
+
const images = await getBugs();
|
73
|
+
res.writeHead(200);
|
74
|
+
res.end(JSON.stringify(images));
|
75
|
+
});
|
76
|
+
expressApp.listen(cfg.apiPort);
|
22
77
|
}
|
23
78
|
routes() {
|
24
79
|
const router = express_1.default.Router();
|
80
|
+
router.use(body_parser_1.default.json());
|
25
81
|
router.get("/bugs", async (_req, res) => {
|
26
|
-
const
|
27
|
-
const images = files.filter((f) => {
|
28
|
-
return f.endsWith(".png") || f.endsWith(".jpg");
|
29
|
-
});
|
82
|
+
const images = await getBugs();
|
30
83
|
res.writeHead(200);
|
31
84
|
res.end(JSON.stringify(images));
|
32
85
|
});
|
@@ -49,6 +102,8 @@ class DynamicBug {
|
|
49
102
|
relatedMediaNodes = new runtime_types_1.RelatedMediaNodes();
|
50
103
|
norsk;
|
51
104
|
cfg;
|
105
|
+
bug;
|
106
|
+
orientation;
|
52
107
|
videoSource;
|
53
108
|
composeNode;
|
54
109
|
imageSource;
|
@@ -61,16 +116,15 @@ class DynamicBug {
|
|
61
116
|
}
|
62
117
|
constructor(norsk, cfg, updates) {
|
63
118
|
this.cfg = cfg;
|
119
|
+
this.bug = cfg.defaultBug;
|
120
|
+
this.orientation = cfg.defaultOrientation;
|
64
121
|
this.id = cfg.id;
|
65
122
|
this.norsk = norsk;
|
66
123
|
this.initialised = this.initialise();
|
67
124
|
this.updates = updates;
|
68
125
|
}
|
69
126
|
async sourceContextChange(_responseCallback) {
|
70
|
-
if (this.composeNode)
|
71
|
-
return false;
|
72
127
|
if (!this.videoSource) {
|
73
|
-
(0, logging_1.errorlog)("Context received by node, but no video source is presently active", { id: this.id });
|
74
128
|
return false;
|
75
129
|
}
|
76
130
|
const videoStream = this.videoSource.latestStreams()[0];
|
@@ -81,71 +135,102 @@ class DynamicBug {
|
|
81
135
|
(0, logging_1.errorlog)("Media other than video received in dynamicBug node??", { id: this.id, metadata: videoStream.metadata });
|
82
136
|
return false;
|
83
137
|
}
|
84
|
-
this.composeNode
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
138
|
+
if (!this.composeNode) {
|
139
|
+
this.composeNode = await this.norsk.processor.transform.videoCompose({
|
140
|
+
id: `${this.id}-compose`,
|
141
|
+
referenceStream: 'video',
|
142
|
+
hardwareAcceleration: (0, config_1.contractHardwareAcceleration)(this.cfg.__global.hardware, ["nvidia"]),
|
143
|
+
outputResolution: {
|
144
|
+
width: videoStream.metadata.message.value.width,
|
145
|
+
height: videoStream.metadata.message.value.height
|
146
|
+
},
|
147
|
+
parts: [
|
148
|
+
this.videoPart(videoStream.metadata.message.value.width, videoStream.metadata.message.value.height),
|
149
|
+
]
|
150
|
+
});
|
151
|
+
this.composeNode.subscribeToPins(this.videoSource.selectVideoToPin("video"));
|
152
|
+
this.relatedMediaNodes.addOutput(this.composeNode);
|
153
|
+
this.relatedMediaNodes.addInput(this.composeNode);
|
154
|
+
}
|
155
|
+
if (this.imageSource) {
|
156
|
+
const imageStream = this.imageSource.outputStreams[0];
|
157
|
+
if (imageStream && imageStream.message.case == 'video') {
|
158
|
+
this.composeNode?.updateConfig({
|
159
|
+
parts: [
|
160
|
+
this.videoPart(videoStream.metadata.message.value.width, videoStream.metadata.message.value.height),
|
161
|
+
this.imagePart(this.orientation ?? 'topleft', videoStream.metadata.message.value.width, videoStream.metadata.message.value.height, imageStream.message.value.width, imageStream.message.value.height)
|
162
|
+
]
|
163
|
+
});
|
164
|
+
}
|
165
|
+
else {
|
166
|
+
this.composeNode?.updateConfig({
|
167
|
+
parts: [
|
168
|
+
this.videoPart(videoStream.metadata.message.value.width, videoStream.metadata.message.value.height),
|
169
|
+
]
|
170
|
+
});
|
171
|
+
}
|
172
|
+
}
|
173
|
+
this.doSubs();
|
99
174
|
return false;
|
100
175
|
}
|
101
|
-
|
102
|
-
if (!
|
176
|
+
doSubs() {
|
177
|
+
if (!this.imageSource) {
|
103
178
|
this.composeNode?.subscribeToPins(this.videoSource?.selectVideoToPin("video") || []);
|
104
|
-
this.updates.raiseEvent({ type: 'bug-changed' });
|
105
|
-
return;
|
106
179
|
}
|
180
|
+
else {
|
181
|
+
this.composeNode?.subscribeToPins((this.videoSource?.selectVideoToPin("video") ?? []).concat([
|
182
|
+
{ source: this.imageSource, sourceSelector: (0, norsk_sdk_1.videoToPin)("bug") }
|
183
|
+
]));
|
184
|
+
}
|
185
|
+
}
|
186
|
+
async setupBug(bug, orientation) {
|
107
187
|
if (this.imageSource) {
|
108
188
|
await this.imageSource.close();
|
189
|
+
this.imageSource = undefined;
|
190
|
+
}
|
191
|
+
if (!bug) {
|
192
|
+
this.doSubs();
|
193
|
+
this.updates.raiseEvent({ type: 'bug-changed' });
|
194
|
+
return;
|
109
195
|
}
|
110
196
|
this.imageSource = await this.norsk.input.fileImage({
|
111
197
|
sourceName: `${this.id}-bug`,
|
112
198
|
fileName: path_1.default.join(bugDir(), bug)
|
113
199
|
});
|
114
|
-
this.
|
115
|
-
|
116
|
-
|
117
|
-
this.imagePart(orientation ?? 'topleft')
|
118
|
-
]
|
119
|
-
});
|
120
|
-
this.composeNode?.subscribeToPins((this.videoSource?.selectVideoToPin("video") ?? []).concat([
|
121
|
-
{ source: this.imageSource, sourceSelector: (0, norsk_sdk_1.videoToPin)("bug") }
|
122
|
-
]));
|
200
|
+
this.imageSource.registerForContextChange(this);
|
201
|
+
this.bug = bug;
|
202
|
+
this.orientation = orientation;
|
123
203
|
this.updates.raiseEvent({ type: 'bug-changed', file: bug, orientation });
|
124
204
|
}
|
125
|
-
imagePart(orientation) {
|
126
|
-
|
205
|
+
imagePart(orientation, videoWidth, videoHeight, imageWidth, imageHeight) {
|
206
|
+
imageWidth = Math.min(videoWidth - 100, imageWidth);
|
207
|
+
imageHeight = Math.min(videoHeight - 100, imageHeight);
|
208
|
+
const foo = {
|
127
209
|
id: "bug",
|
128
210
|
zIndex: 1,
|
129
|
-
sourceRect: { x: 0, y: 0, width:
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
211
|
+
sourceRect: { x: 0, y: 0, width: videoWidth, height: videoHeight },
|
212
|
+
referenceResolution: undefined,
|
213
|
+
destRect: (orientation == 'topleft' ? { x: 5, y: 5, width: imageWidth, height: imageHeight } :
|
214
|
+
orientation == 'topright' ? { x: videoWidth - imageWidth - 5, y: 5, width: imageWidth, height: imageHeight } :
|
215
|
+
orientation == 'bottomleft' ? { x: 5, y: videoHeight - imageHeight - 5, width: imageWidth, height: imageHeight } :
|
216
|
+
{ x: videoWidth - imageWidth - 5, y: videoHeight - imageHeight - 5, width: imageWidth, height: imageHeight }),
|
134
217
|
opacity: 1.0,
|
135
218
|
pin: "bug"
|
136
219
|
};
|
220
|
+
return foo;
|
137
221
|
}
|
138
|
-
videoPart() {
|
222
|
+
videoPart(videoWidth, videoHeight) {
|
139
223
|
return {
|
140
224
|
id: "video",
|
141
225
|
zIndex: 0,
|
142
|
-
sourceRect: { x: 0, y: 0, width:
|
143
|
-
destRect: { x: 0, y: 0, width:
|
226
|
+
sourceRect: { x: 0, y: 0, width: videoWidth, height: videoHeight },
|
227
|
+
destRect: { x: 0, y: 0, width: videoWidth, height: videoHeight },
|
144
228
|
opacity: 1.0,
|
145
229
|
pin: "video"
|
146
230
|
};
|
147
231
|
}
|
148
232
|
async initialise() {
|
233
|
+
await this.setupBug(this.cfg.defaultBug, this.cfg.defaultOrientation);
|
149
234
|
}
|
150
235
|
subscribe(sources) {
|
151
236
|
this.videoSource = sources[0];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/processor.dynamicBug/runtime.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAsJ;AAEtJ,wFAA8M;AAC9M,yEAAuE;AACvE,uEAAoH;AACpH,mEAA6E;AAE7E,
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/processor.dynamicBug/runtime.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAsJ;AAEtJ,wFAA8M;AAC9M,yEAAuE;AACvE,uEAAoH;AACpH,mEAA6E;AAE7E,2DAA6B;AAC7B,gDAAwB;AACxB,gDAAwB;AAExB,8DAAqC;AACrC,sDAA6B;AAC7B,oDAA4B;AAyC5B,SAAS,MAAM;IACb,OAAO,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,WAAW,CAAC,CAAC;AACjE,CAAC;AAED,KAAK,UAAU,OAAO;IACpB,MAAM,KAAK,GAAG,MAAM,kBAAE,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QAChC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAGD,MAAqB,oBAAoB;IACvC,KAAK,CAAC,MAAM,CAAC,KAAY,EAAE,GAAqB,EAAE,EAAyB,EAAE,OAAwD;QACnI,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAClE,EAAE,CAAC,IAAI,CAAC,CAAC;QAIT,MAAM,UAAU,GAAG,IAAA,iBAAO,GAAE,CAAC;QAC7B,UAAU,CA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AAC;IAClD,CAAC;CACF;AAlLD,gCAkLC"}
|
@@ -6,28 +6,55 @@ function SummaryView({ state, config, sendCommand }) {
|
|
6
6
|
const [bug, setBug] = (0, react_1.useState)(state.activeBug?.file ?? config.defaultBug);
|
7
7
|
const [orientation, setOrientation] = (0, react_1.useState)(state.activeBug?.orientation ?? config.defaultOrientation);
|
8
8
|
const [bugs, setBugs] = (0, react_1.useState)([]);
|
9
|
+
const [fileToUpload, setFileToUpload] = (0, react_1.useState)(undefined);
|
10
|
+
async function updateBugs() {
|
11
|
+
const result = await fetch('components/processor.dynamicBug/bugs');
|
12
|
+
if (result.ok && result.body) {
|
13
|
+
const bugs = await result.json();
|
14
|
+
setBugs(bugs);
|
15
|
+
}
|
16
|
+
else {
|
17
|
+
const text = await result.text();
|
18
|
+
throw new Error(text);
|
19
|
+
}
|
20
|
+
}
|
9
21
|
(0, react_1.useEffect)(() => {
|
10
22
|
const fn = async () => {
|
11
|
-
|
12
|
-
if (result.ok && result.body) {
|
13
|
-
const bugs = await result.json();
|
14
|
-
setBugs(bugs);
|
15
|
-
}
|
16
|
-
else {
|
17
|
-
const text = await result.text();
|
18
|
-
throw new Error(text);
|
19
|
-
}
|
23
|
+
await updateBugs();
|
20
24
|
};
|
21
25
|
fn().catch(console.error);
|
22
26
|
}, []);
|
27
|
+
function onFileChange(e) {
|
28
|
+
if (e.target.files?.[0])
|
29
|
+
setFileToUpload(e.target.files[0]);
|
30
|
+
}
|
23
31
|
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h2", { children: "Controls" }), (0, jsx_runtime_1.jsx)("label", { htmlFor: "select-preview", className: "mt-2", children: "Source" }), (0, jsx_runtime_1.jsxs)("select", { id: "select-bug", className: "mt-2 node-editor-select-input", onChange: (e) => {
|
24
32
|
setBug(e.currentTarget.value);
|
25
|
-
}, children: [(0, jsx_runtime_1.jsx)("option", { selected: bug === undefined, children: "---" }), bugs.map((s, i) => (0, jsx_runtime_1.jsx)("option", { selected: bug == s, value: s, children: s }, i))] }), (0, jsx_runtime_1.jsxs)("select", { id: "select-orientation", className: "mt-2 node-editor-select-input", onChange: (e) => {
|
33
|
+
}, children: [(0, jsx_runtime_1.jsx)("option", { selected: bug === undefined, children: "---" }), (0, jsx_runtime_1.jsx)("option", { value: 'new', selected: bug === 'new', children: "New" }), bugs.map((s, i) => (0, jsx_runtime_1.jsx)("option", { selected: bug == s, value: s, children: s }, i))] }), (0, jsx_runtime_1.jsx)("form", { style: { display: bug === 'new' ? 'block' : 'none' }, onSubmit: (e) => e.preventDefault(), children: (0, jsx_runtime_1.jsx)("input", { type: "file", id: "file", name: "filename", onChange: onFileChange }) }), (0, jsx_runtime_1.jsxs)("select", { id: "select-orientation", className: "mt-2 node-editor-select-input", onChange: (e) => {
|
26
34
|
setOrientation(e.currentTarget.value);
|
27
|
-
}, children: [(0, jsx_runtime_1.jsx)("option", { selected: orientation === undefined, children: "---" }), (0, jsx_runtime_1.jsx)("option", { value: 'topleft', selected: orientation === 'topleft', children: "Top Left" }), (0, jsx_runtime_1.jsx)("option", { value: 'topright', selected: orientation === 'topright', children: "Top Right" }), (0, jsx_runtime_1.jsx)("option", { value: 'bottomleft', selected: orientation === 'bottomleft', children: "Bottom Left" }), (0, jsx_runtime_1.jsx)("option", { value: 'bottomright', selected: orientation === 'bottomright', children: "Bottom Right" })] }), (bug != state.activeBug?.file || orientation != state.activeBug?.orientation
|
28
|
-
|
29
|
-
|
30
|
-
|
35
|
+
}, children: [(0, jsx_runtime_1.jsx)("option", { selected: orientation === undefined, children: "---" }), (0, jsx_runtime_1.jsx)("option", { value: 'topleft', selected: orientation === 'topleft', children: "Top Left" }), (0, jsx_runtime_1.jsx)("option", { value: 'topright', selected: orientation === 'topright', children: "Top Right" }), (0, jsx_runtime_1.jsx)("option", { value: 'bottomleft', selected: orientation === 'bottomleft', children: "Bottom Left" }), (0, jsx_runtime_1.jsx)("option", { value: 'bottomright', selected: orientation === 'bottomright', children: "Bottom Right" })] }), (bug != state.activeBug?.file || orientation != state.activeBug?.orientation || fileToUpload) ?
|
36
|
+
(0, jsx_runtime_1.jsx)("button", { type: "button", className: "mt-2 mb-2 text-white w-full justify-center bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800", onClick: async (e) => {
|
37
|
+
e.preventDefault();
|
38
|
+
if (fileToUpload && bug === 'new') {
|
39
|
+
const form = new FormData();
|
40
|
+
const url = `http://${document.location.hostname}:${config.apiPort}/bugs`;
|
41
|
+
form.append('file', fileToUpload);
|
42
|
+
await fetch(url, {
|
43
|
+
method: 'POST',
|
44
|
+
body: form
|
45
|
+
});
|
46
|
+
setTimeout(async () => {
|
47
|
+
await updateBugs();
|
48
|
+
sendCommand({ type: "change-bug", file: fileToUpload.name, orientation });
|
49
|
+
setBug(fileToUpload.name);
|
50
|
+
setFileToUpload(undefined);
|
51
|
+
return;
|
52
|
+
}, 500);
|
53
|
+
}
|
54
|
+
else {
|
55
|
+
sendCommand({ type: "change-bug", file: bug, orientation });
|
56
|
+
}
|
57
|
+
}, children: "Commit" }) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {})] });
|
31
58
|
}
|
32
59
|
exports.default = SummaryView;
|
33
60
|
//# sourceMappingURL=summary-view.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"summary-view.js","sourceRoot":"","sources":["../../src/processor.dynamicBug/summary-view.tsx"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"summary-view.js","sourceRoot":"","sources":["../../src/processor.dynamicBug/summary-view.tsx"],"names":[],"mappings":";;;AAAA,iCAAyD;AAGzD,SAAS,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAuG;IAEtJ,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAA,gBAAQ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AAI,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;wBAC9D,CAAC;oBAEH,CAAC,uBAAiB,CAAC,CAAC,CAAC,kDAAK,IAE/B,CAAA;AACL,CAAC;AAED,kBAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@norskvideo/norsk-studio-built-ins",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2",
|
4
4
|
"description": "",
|
5
5
|
"scripts": {
|
6
6
|
"clean": "rm -rf lib",
|
@@ -26,12 +26,14 @@
|
|
26
26
|
"@norskvideo/norsk-sdk": "^1.0.360",
|
27
27
|
"@norskvideo/norsk-studio": "^1.0.4",
|
28
28
|
"@norskvideo/webrtc-client": "^0.1.2",
|
29
|
+
"cors": "^2.8.5",
|
29
30
|
"express": "^4.18.2",
|
30
31
|
"express-ws": "^5.0.2"
|
31
32
|
},
|
32
33
|
"main": "lib/index.js",
|
33
34
|
"devDependencies": {
|
34
35
|
"@types/chai": "^4.3.11",
|
36
|
+
"@types/cors": "^2.8.17",
|
35
37
|
"@types/express": "^4.17.20",
|
36
38
|
"@types/express-ws": "^3.0.3",
|
37
39
|
"@types/hls-parser": "^0.8.7",
|