@g9tm/lynxcontrols-studio 0.0.0-stage → 2.8.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.
- package/README.md +184 -2
- package/catalog/cards/G9NleTimeline.md +17 -0
- package/catalog/cards/G9Surface.md +16 -0
- package/catalog/cards/G9TransformBox.md +17 -0
- package/catalog/catalog.json +2255 -0
- package/catalog/index.md +7 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.jsx +3 -0
- package/dist/nle-timeline/core.d.ts +5 -0
- package/dist/nle-timeline/core.d.ts.map +1 -0
- package/dist/nle-timeline/core.js +4 -0
- package/dist/nle-timeline/core.jsx +4 -0
- package/dist/nle-timeline/edits.d.ts +65 -0
- package/dist/nle-timeline/edits.d.ts.map +1 -0
- package/dist/nle-timeline/edits.js +344 -0
- package/dist/nle-timeline/edits.js.map +1 -0
- package/dist/nle-timeline/edits.jsx +342 -0
- package/dist/nle-timeline/engine.d.ts +159 -0
- package/dist/nle-timeline/engine.d.ts.map +1 -0
- package/dist/nle-timeline/engine.js +899 -0
- package/dist/nle-timeline/engine.js.map +1 -0
- package/dist/nle-timeline/engine.jsx +897 -0
- package/dist/nle-timeline/index.d.ts +6 -0
- package/dist/nle-timeline/index.d.ts.map +1 -0
- package/dist/nle-timeline/index.jsx +5 -0
- package/dist/nle-timeline/layout.d.ts +116 -0
- package/dist/nle-timeline/layout.d.ts.map +1 -0
- package/dist/nle-timeline/layout.js +310 -0
- package/dist/nle-timeline/layout.js.map +1 -0
- package/dist/nle-timeline/layout.jsx +308 -0
- package/dist/nle-timeline/model.d.ts +140 -0
- package/dist/nle-timeline/model.d.ts.map +1 -0
- package/dist/nle-timeline/model.js +155 -0
- package/dist/nle-timeline/model.js.map +1 -0
- package/dist/nle-timeline/model.jsx +153 -0
- package/dist/nle-timeline/nle.d.ts +72 -0
- package/dist/nle-timeline/nle.d.ts.map +1 -0
- package/dist/nle-timeline/nle.jsx +92 -0
- package/dist/surface/core.d.ts +2 -0
- package/dist/surface/core.d.ts.map +1 -0
- package/dist/surface/core.js +1 -0
- package/dist/surface/core.jsx +1 -0
- package/dist/surface/index.d.ts +3 -0
- package/dist/surface/index.d.ts.map +1 -0
- package/dist/surface/index.jsx +2 -0
- package/dist/surface/protocol.d.ts +40 -0
- package/dist/surface/protocol.d.ts.map +1 -0
- package/dist/surface/protocol.js +19 -0
- package/dist/surface/protocol.js.map +1 -0
- package/dist/surface/protocol.jsx +17 -0
- package/dist/surface/surface.d.ts +53 -0
- package/dist/surface/surface.d.ts.map +1 -0
- package/dist/surface/surface.jsx +62 -0
- package/dist/transform-box/core.d.ts +3 -0
- package/dist/transform-box/core.d.ts.map +1 -0
- package/dist/transform-box/core.js +2 -0
- package/dist/transform-box/core.jsx +2 -0
- package/dist/transform-box/engine.d.ts +152 -0
- package/dist/transform-box/engine.d.ts.map +1 -0
- package/dist/transform-box/engine.js +636 -0
- package/dist/transform-box/engine.js.map +1 -0
- package/dist/transform-box/engine.jsx +634 -0
- package/dist/transform-box/geometry.d.ts +129 -0
- package/dist/transform-box/geometry.d.ts.map +1 -0
- package/dist/transform-box/geometry.js +506 -0
- package/dist/transform-box/geometry.js.map +1 -0
- package/dist/transform-box/geometry.jsx +504 -0
- package/dist/transform-box/index.d.ts +4 -0
- package/dist/transform-box/index.d.ts.map +1 -0
- package/dist/transform-box/index.jsx +3 -0
- package/dist/transform-box/transform-box.d.ts +65 -0
- package/dist/transform-box/transform-box.d.ts.map +1 -0
- package/dist/transform-box/transform-box.jsx +104 -0
- package/package.json +56 -4
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
const NLE_DEFAULT_FPS = 30;
|
|
2
|
+
function createNleDoc() {
|
|
3
|
+
return {
|
|
4
|
+
duration: 0,
|
|
5
|
+
fps: NLE_DEFAULT_FPS,
|
|
6
|
+
lanes: [],
|
|
7
|
+
clips: new Map(),
|
|
8
|
+
keys: new Map(),
|
|
9
|
+
markers: [],
|
|
10
|
+
beats: [],
|
|
11
|
+
beatsPerBar: 4,
|
|
12
|
+
range: null,
|
|
13
|
+
playhead: 0,
|
|
14
|
+
selection: [],
|
|
15
|
+
version: 0,
|
|
16
|
+
index: null,
|
|
17
|
+
keyIndex: null
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function beatsOfTempo(tempo, duration) {
|
|
21
|
+
var _tempo_offset, _tempo_offset1;
|
|
22
|
+
const out = [];
|
|
23
|
+
if (!(tempo.bpm > 0)) return out;
|
|
24
|
+
const step = 60 / tempo.bpm;
|
|
25
|
+
const end = Math.max(duration, 0);
|
|
26
|
+
for(let t = null != (_tempo_offset = tempo.offset) ? _tempo_offset : 0, i = 0; t <= end + 1e-9 && i < 20000; i++, t = (null != (_tempo_offset1 = tempo.offset) ? _tempo_offset1 : 0) + i * step)if (t >= 0) out.push(t);
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
function isTempo(beats) {
|
|
30
|
+
return !Array.isArray(beats) && 'number' == typeof beats.bpm;
|
|
31
|
+
}
|
|
32
|
+
function applyNlePatch(doc, patch) {
|
|
33
|
+
if (patch.reset) {
|
|
34
|
+
doc.duration = 0;
|
|
35
|
+
doc.fps = NLE_DEFAULT_FPS;
|
|
36
|
+
doc.lanes = [];
|
|
37
|
+
doc.clips.clear();
|
|
38
|
+
doc.keys.clear();
|
|
39
|
+
doc.markers = [];
|
|
40
|
+
doc.beats = [];
|
|
41
|
+
doc.beatsPerBar = 4;
|
|
42
|
+
doc.range = null;
|
|
43
|
+
doc.playhead = 0;
|
|
44
|
+
doc.selection = [];
|
|
45
|
+
}
|
|
46
|
+
if (void 0 !== patch.duration) doc.duration = Math.max(0, patch.duration);
|
|
47
|
+
if (void 0 !== patch.fps) doc.fps = Math.max(0, patch.fps);
|
|
48
|
+
if (patch.lanes) doc.lanes = patch.lanes.slice();
|
|
49
|
+
if (patch.clips) for (const clip of patch.clips)doc.clips.set(clip.id, clip);
|
|
50
|
+
if (patch.removeClips) for (const id of patch.removeClips)doc.clips.delete(id);
|
|
51
|
+
if (patch.keys) for (const key of patch.keys)doc.keys.set(key.id, key);
|
|
52
|
+
if (patch.removeKeys) for (const id of patch.removeKeys)doc.keys.delete(id);
|
|
53
|
+
if (patch.markers) doc.markers = patch.markers.slice().sort((a, b)=>a.time - b.time);
|
|
54
|
+
if (void 0 !== patch.beatsPerBar) doc.beatsPerBar = Math.max(1, Math.round(patch.beatsPerBar));
|
|
55
|
+
if (patch.beats) doc.beats = isTempo(patch.beats) ? beatsOfTempo(patch.beats, doc.duration) : patch.beats.slice().sort((a, b)=>a - b);
|
|
56
|
+
if (void 0 !== patch.range) doc.range = patch.range ? normRange(patch.range) : null;
|
|
57
|
+
if (void 0 !== patch.playhead) doc.playhead = Math.max(0, patch.playhead);
|
|
58
|
+
if (patch.selection) doc.selection = patch.selection.slice();
|
|
59
|
+
if (patch.removeClips || patch.removeKeys) {
|
|
60
|
+
var _patch_removeClips, _patch_removeKeys;
|
|
61
|
+
const gone = new Set([
|
|
62
|
+
...null != (_patch_removeClips = patch.removeClips) ? _patch_removeClips : [],
|
|
63
|
+
...null != (_patch_removeKeys = patch.removeKeys) ? _patch_removeKeys : []
|
|
64
|
+
]);
|
|
65
|
+
doc.selection = doc.selection.filter((id)=>!gone.has(id));
|
|
66
|
+
}
|
|
67
|
+
if (patch.reset || patch.clips || patch.removeClips || patch.lanes) doc.index = null;
|
|
68
|
+
if (patch.reset || patch.keys || patch.removeKeys || patch.lanes) doc.keyIndex = null;
|
|
69
|
+
doc.version++;
|
|
70
|
+
}
|
|
71
|
+
function normRange(range) {
|
|
72
|
+
const start = Math.max(0, Math.min(range.start, range.end));
|
|
73
|
+
return {
|
|
74
|
+
start,
|
|
75
|
+
end: Math.max(start, Math.max(range.start, range.end))
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function nleSnapshot(doc) {
|
|
79
|
+
return {
|
|
80
|
+
reset: true,
|
|
81
|
+
duration: doc.duration,
|
|
82
|
+
fps: doc.fps,
|
|
83
|
+
lanes: doc.lanes.slice(),
|
|
84
|
+
clips: [
|
|
85
|
+
...doc.clips.values()
|
|
86
|
+
],
|
|
87
|
+
keys: [
|
|
88
|
+
...doc.keys.values()
|
|
89
|
+
],
|
|
90
|
+
markers: doc.markers.slice(),
|
|
91
|
+
beats: doc.beats.slice(),
|
|
92
|
+
beatsPerBar: doc.beatsPerBar,
|
|
93
|
+
range: doc.range,
|
|
94
|
+
playhead: doc.playhead,
|
|
95
|
+
selection: doc.selection.slice()
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function laneClips(doc, laneId) {
|
|
99
|
+
var _doc_index_get;
|
|
100
|
+
if (!doc.index) {
|
|
101
|
+
const index = new Map();
|
|
102
|
+
for (const clip of doc.clips.values()){
|
|
103
|
+
let list = index.get(clip.lane);
|
|
104
|
+
if (!list) {
|
|
105
|
+
list = [];
|
|
106
|
+
index.set(clip.lane, list);
|
|
107
|
+
}
|
|
108
|
+
list.push(clip);
|
|
109
|
+
}
|
|
110
|
+
for (const list of index.values())list.sort((a, b)=>a.start - b.start || (a.id < b.id ? -1 : 1));
|
|
111
|
+
doc.index = index;
|
|
112
|
+
}
|
|
113
|
+
return null != (_doc_index_get = doc.index.get(laneId)) ? _doc_index_get : EMPTY;
|
|
114
|
+
}
|
|
115
|
+
function laneKeys(doc, laneId) {
|
|
116
|
+
var _doc_keyIndex_get;
|
|
117
|
+
if (!doc.keyIndex) {
|
|
118
|
+
const index = new Map();
|
|
119
|
+
for (const key of doc.keys.values()){
|
|
120
|
+
let list = index.get(key.lane);
|
|
121
|
+
if (!list) {
|
|
122
|
+
list = [];
|
|
123
|
+
index.set(key.lane, list);
|
|
124
|
+
}
|
|
125
|
+
list.push(key);
|
|
126
|
+
}
|
|
127
|
+
for (const list of index.values())list.sort((a, b)=>a.time - b.time);
|
|
128
|
+
doc.keyIndex = index;
|
|
129
|
+
}
|
|
130
|
+
return null != (_doc_keyIndex_get = doc.keyIndex.get(laneId)) ? _doc_keyIndex_get : EMPTY_KEYS;
|
|
131
|
+
}
|
|
132
|
+
const EMPTY = [];
|
|
133
|
+
const EMPTY_KEYS = [];
|
|
134
|
+
function laneById(doc, id) {
|
|
135
|
+
for (const lane of doc.lanes)if (lane.id === id) return lane;
|
|
136
|
+
}
|
|
137
|
+
function compatible(a, b) {
|
|
138
|
+
if ('keys' === a.kind || 'keys' === b.kind) return false;
|
|
139
|
+
return 'audio' === a.kind === ('audio' === b.kind);
|
|
140
|
+
}
|
|
141
|
+
function contentEnd(doc) {
|
|
142
|
+
let end = doc.duration;
|
|
143
|
+
for (const clip of doc.clips.values())end = Math.max(end, clip.start + clip.duration);
|
|
144
|
+
return end;
|
|
145
|
+
}
|
|
146
|
+
function quantize(doc, t) {
|
|
147
|
+
if (!(doc.fps > 0)) return t;
|
|
148
|
+
return Math.round(t * doc.fps) / doc.fps;
|
|
149
|
+
}
|
|
150
|
+
function frameOf(doc) {
|
|
151
|
+
return doc.fps > 0 ? 1 / doc.fps : 1 / NLE_DEFAULT_FPS;
|
|
152
|
+
}
|
|
153
|
+
export { NLE_DEFAULT_FPS, applyNlePatch, beatsOfTempo, compatible, contentEnd, createNleDoc, frameOf, laneById, laneClips, laneKeys, nleSnapshot, normRange, quantize };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type ReactNode } from '@lynx-js/react';
|
|
2
|
+
import type { NodesRef } from '@lynx-js/types';
|
|
3
|
+
import type { NleEvents, NleTool } from './engine.js';
|
|
4
|
+
import { type NleDoc, type NlePatch } from './model.js';
|
|
5
|
+
/** The page's way to the element: create one per timeline, pass it to {@link G9NleTimeline}. */
|
|
6
|
+
export declare class G9NlePort {
|
|
7
|
+
private target;
|
|
8
|
+
/** What the page has sent so far. */
|
|
9
|
+
readonly doc: NleDoc;
|
|
10
|
+
/** Sends a patch (kept, and replayed on the next mount). */
|
|
11
|
+
apply: (patch: NlePatch) => void;
|
|
12
|
+
/** The element mounted (or went away). */
|
|
13
|
+
attach(target: NodesRef | null): void;
|
|
14
|
+
get attached(): boolean;
|
|
15
|
+
/** Keeps the port's copy in step with an edit the element already shows (moves, trims and key drags are optimistic). */
|
|
16
|
+
note(patch: NlePatch): void;
|
|
17
|
+
private send;
|
|
18
|
+
}
|
|
19
|
+
type Handler<K extends keyof NleEvents> = (detail: NleEvents[K]) => void;
|
|
20
|
+
/** Props of {@link G9NleTimeline}. */
|
|
21
|
+
export interface G9NleTimelineProps {
|
|
22
|
+
/** Logical id; the element carries its safe form (tests find `#id`). */
|
|
23
|
+
readonly id?: string;
|
|
24
|
+
readonly port: G9NlePort;
|
|
25
|
+
/** `select` (default) or `blade`: a click splits. */
|
|
26
|
+
readonly tool?: NleTool;
|
|
27
|
+
/** Snapping to the playhead, edges, beats, markers and the range. Default true. */
|
|
28
|
+
readonly snap?: boolean;
|
|
29
|
+
/** False: look and scrub only. Default true. */
|
|
30
|
+
readonly editable?: boolean;
|
|
31
|
+
/** Lane heads' side: `rtl` puts them on the right. Time always runs left to right. */
|
|
32
|
+
readonly direction?: 'ltr' | 'rtl';
|
|
33
|
+
/** Show the lane heads' column. Default true. */
|
|
34
|
+
readonly heads?: boolean;
|
|
35
|
+
/** The app's theme; a change makes the element read the theme's colour tokens again. */
|
|
36
|
+
readonly theme?: 'light' | 'dark';
|
|
37
|
+
readonly className?: string;
|
|
38
|
+
readonly style?: Record<string, string | number>;
|
|
39
|
+
readonly onSelect?: Handler<'nleselect'>;
|
|
40
|
+
readonly onEdit?: Handler<'nleedit'>;
|
|
41
|
+
readonly onAdd?: Handler<'nleadd'>;
|
|
42
|
+
readonly onOpen?: Handler<'nleopen'>;
|
|
43
|
+
readonly onSeek?: Handler<'nleseek'>;
|
|
44
|
+
readonly onRange?: Handler<'nlerange'>;
|
|
45
|
+
readonly onView?: Handler<'nleview'>;
|
|
46
|
+
readonly onCommand?: Handler<'nlecommand'>;
|
|
47
|
+
}
|
|
48
|
+
/** Element props (strings, as the host gets them). */
|
|
49
|
+
export interface G9NleElementProps {
|
|
50
|
+
readonly ref?: unknown;
|
|
51
|
+
readonly id?: string;
|
|
52
|
+
readonly className?: string;
|
|
53
|
+
readonly style?: Record<string, string | number>;
|
|
54
|
+
readonly tool?: string;
|
|
55
|
+
readonly snap?: string;
|
|
56
|
+
readonly editable?: string;
|
|
57
|
+
readonly dir?: string;
|
|
58
|
+
readonly heads?: string;
|
|
59
|
+
readonly theme?: string;
|
|
60
|
+
readonly [event: `bind${string}`]: ((e: {
|
|
61
|
+
detail: unknown;
|
|
62
|
+
}) => void) | undefined;
|
|
63
|
+
}
|
|
64
|
+
declare module '@lynx-js/types' {
|
|
65
|
+
interface IntrinsicElements {
|
|
66
|
+
'g9-nle': G9NleElementProps;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** The editing timeline. */
|
|
70
|
+
export declare function G9NleTimeline(props: G9NleTimelineProps): ReactNode;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=nle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nle.d.ts","sourceRoot":"","sources":["../../src/nle-timeline/nle.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAA+B,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAe,MAAM,SAAS,CAAC;AAE/F,gGAAgG;AAChG,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAyB;IACvC,qCAAqC;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAkB;IAEtC,4DAA4D;IAC5D,KAAK,GAAI,OAAO,QAAQ,KAAG,IAAI,CAG7B;IAEF,0CAA0C;IAC1C,MAAM,CAAC,MAAM,EA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 +1,92 @@
|
|
|
1
|
+
import { g9IdProps } from "@g9tm/lynxcontrols/base";
|
|
2
|
+
import { useEffect, useRef } from "@lynx-js/react";
|
|
3
|
+
import { applyNlePatch, createNleDoc, nleSnapshot } from "./model.jsx";
|
|
4
|
+
function _define_property(obj, key, value) {
|
|
5
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
6
|
+
value: value,
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true
|
|
10
|
+
});
|
|
11
|
+
else obj[key] = value;
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
class G9NlePort {
|
|
15
|
+
attach(target) {
|
|
16
|
+
this.target = target;
|
|
17
|
+
if (target) this.send(nleSnapshot(this.doc));
|
|
18
|
+
}
|
|
19
|
+
get attached() {
|
|
20
|
+
return null !== this.target;
|
|
21
|
+
}
|
|
22
|
+
note(patch) {
|
|
23
|
+
applyNlePatch(this.doc, patch);
|
|
24
|
+
}
|
|
25
|
+
send(patch) {
|
|
26
|
+
var _this_target;
|
|
27
|
+
null == (_this_target = this.target) || _this_target.invoke({
|
|
28
|
+
method: 'apply',
|
|
29
|
+
params: {
|
|
30
|
+
json: JSON.stringify(patch)
|
|
31
|
+
}
|
|
32
|
+
}).exec();
|
|
33
|
+
}
|
|
34
|
+
constructor(){
|
|
35
|
+
_define_property(this, "target", null);
|
|
36
|
+
_define_property(this, "doc", createNleDoc());
|
|
37
|
+
_define_property(this, "apply", (patch)=>{
|
|
38
|
+
applyNlePatch(this.doc, patch);
|
|
39
|
+
this.send(patch);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function G9NleTimeline(props) {
|
|
44
|
+
var _props_tool, _props_direction, _props_theme;
|
|
45
|
+
const { port } = props;
|
|
46
|
+
const ref = useRef(null);
|
|
47
|
+
useEffect(()=>{
|
|
48
|
+
port.attach(ref.current);
|
|
49
|
+
return ()=>port.attach(null);
|
|
50
|
+
}, [
|
|
51
|
+
port
|
|
52
|
+
]);
|
|
53
|
+
const on = (handler, keep)=>(e)=>{
|
|
54
|
+
const detail = e.detail;
|
|
55
|
+
null == keep || keep(detail);
|
|
56
|
+
null == handler || handler(detail);
|
|
57
|
+
};
|
|
58
|
+
return <g9-nle ref={ref} {...g9IdProps(props.id)} className={`g9-nle${props.className ? ` ${props.className}` : ''}`} {...props.style ? {
|
|
59
|
+
style: props.style
|
|
60
|
+
} : {}} tool={null != (_props_tool = props.tool) ? _props_tool : 'select'} snap={false === props.snap ? 'off' : 'on'} editable={false === props.editable ? 'false' : 'true'} dir={null != (_props_direction = props.direction) ? _props_direction : 'ltr'} heads={false === props.heads ? 'false' : 'true'} theme={null != (_props_theme = props.theme) ? _props_theme : 'light'} bindnleselect={on(props.onSelect, (d)=>port.note({
|
|
61
|
+
selection: d.ids
|
|
62
|
+
}))} bindnleedit={on(props.onEdit, (d)=>{
|
|
63
|
+
if (d.changes) port.note({
|
|
64
|
+
clips: d.changes.map((c)=>{
|
|
65
|
+
var _port_doc_clips_get;
|
|
66
|
+
return {
|
|
67
|
+
...null != (_port_doc_clips_get = port.doc.clips.get(c.id)) ? _port_doc_clips_get : {
|
|
68
|
+
id: c.id
|
|
69
|
+
},
|
|
70
|
+
...c
|
|
71
|
+
};
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
if (d.keys) port.note({
|
|
75
|
+
keys: d.keys.map((k)=>{
|
|
76
|
+
var _port_doc_keys_get;
|
|
77
|
+
return {
|
|
78
|
+
...null != (_port_doc_keys_get = port.doc.keys.get(k.id)) ? _port_doc_keys_get : {
|
|
79
|
+
id: k.id,
|
|
80
|
+
lane: ''
|
|
81
|
+
},
|
|
82
|
+
time: k.time
|
|
83
|
+
};
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
})} bindnleadd={on(props.onAdd)} bindnleopen={on(props.onOpen)} bindnleseek={on(props.onSeek, (d)=>port.note({
|
|
87
|
+
playhead: d.time
|
|
88
|
+
}))} bindnlerange={on(props.onRange, (d)=>port.note({
|
|
89
|
+
range: d.range
|
|
90
|
+
}))} bindnleview={on(props.onView)} bindnlecommand={on(props.onCommand)}/>;
|
|
91
|
+
}
|
|
92
|
+
export { G9NlePort, G9NleTimeline };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/surface/core.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./protocol.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./protocol.jsx";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/surface/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,KAAK,qBAAqB,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Why a surface cannot draw. Typed, never a silent no-op. */
|
|
2
|
+
export type G9SurfaceErrorCode =
|
|
3
|
+
/** No driver of that name is registered on the host page. */
|
|
4
|
+
'unknown_driver'
|
|
5
|
+
/** The driver threw while mounting or handling a message. */
|
|
6
|
+
| 'driver_failed'
|
|
7
|
+
/** The host cannot show this surface (for example a second surface on a host that shows one at a time). */
|
|
8
|
+
| 'unsupported';
|
|
9
|
+
/** `<g9-surface>`'s events by name, with each one's `detail`. */
|
|
10
|
+
export interface G9SurfaceEvents {
|
|
11
|
+
/** The driver mounted and drew its first frame's worth of setup. */
|
|
12
|
+
sfready: {
|
|
13
|
+
driver: string;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
dpr: number;
|
|
17
|
+
};
|
|
18
|
+
sfresize: {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
dpr: number;
|
|
22
|
+
};
|
|
23
|
+
sferror: {
|
|
24
|
+
code: G9SurfaceErrorCode;
|
|
25
|
+
driver: string;
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
/** Anything the driver emits (`ctx.emit(name, detail)`), wrapped. */
|
|
29
|
+
sfevent: {
|
|
30
|
+
name: string;
|
|
31
|
+
detail: unknown;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** A typed surface failure, thrown by a host or a driver and reported as `sferror`. */
|
|
35
|
+
export declare class G9SurfaceError extends Error {
|
|
36
|
+
readonly code: G9SurfaceErrorCode;
|
|
37
|
+
readonly driver: string;
|
|
38
|
+
constructor(code: G9SurfaceErrorCode, driver: string, message: string);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/surface/protocol.ts"],"names":[],"mappings":"AAGA,8DAA8D;AAC9D,MAAM,MAAM,kBAAkB;AAC5B,6DAA6D;AAC3D,gBAAgB;AAClB,6DAA6D;GAC3D,eAAe;AACjB,2GAA2G;GACzG,aAAa,CAAC;AAElB,iEAAiE;AACjE,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACxE,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,OAAO,EAAE;QAAE,IAAI,EAAE,kBAAkB,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACvE,qEAAqE;IACrE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;CAC5C;AAED,uFAAuF;AACvF,qBAAa,cAAe,SAAQ,KAAK;IAErC,QAAQ,CAAC,IAAI,EAAE,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM;CAKlB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
3
|
+
value: value,
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true
|
|
7
|
+
});
|
|
8
|
+
else obj[key] = value;
|
|
9
|
+
return obj;
|
|
10
|
+
}
|
|
11
|
+
class G9SurfaceError extends Error {
|
|
12
|
+
constructor(code, driver, message){
|
|
13
|
+
super(message), _define_property(this, "code", void 0), _define_property(this, "driver", void 0), this.code = code, this.driver = driver;
|
|
14
|
+
this.name = 'G9SurfaceError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export { G9SurfaceError };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface/protocol.js","sources":["../../src/surface/protocol.ts"],"sourcesContent":["// The `<g9-surface>` protocol, shared by the Lynx page and every host: attributes, the `apply` method and the events.\n// A surface is a viewport a registered driver draws into; the driver (the host page's code) gives it meaning.\n\n/** Why a surface cannot draw. Typed, never a silent no-op. */\nexport type G9SurfaceErrorCode =\n /** No driver of that name is registered on the host page. */\n | 'unknown_driver'\n /** The driver threw while mounting or handling a message. */\n | 'driver_failed'\n /** The host cannot show this surface (for example a second surface on a host that shows one at a time). */\n | 'unsupported';\n\n/** `<g9-surface>`'s events by name, with each one's `detail`. */\nexport interface G9SurfaceEvents {\n /** The driver mounted and drew its first frame's worth of setup. */\n sfready: { driver: string; width: number; height: number; dpr: number };\n sfresize: { width: number; height: number; dpr: number };\n sferror: { code: G9SurfaceErrorCode; driver: string; message: string };\n /** Anything the driver emits (`ctx.emit(name, detail)`), wrapped. */\n sfevent: { name: string; detail: unknown };\n}\n\n/** A typed surface failure, thrown by a host or a driver and reported as `sferror`. */\nexport class G9SurfaceError extends Error {\n constructor(\n readonly code: G9SurfaceErrorCode,\n readonly driver: string,\n message: string,\n ) {\n super(message);\n this.name = 'G9SurfaceError';\n }\n}\n"],"names":["G9SurfaceError","Error","code","driver","message"],"mappings":"AAG4D;;;;;;;;;;AAoBrD,MAAMA,uBAAuBC;IAClC,YACWC,IAAwB,EACxBC,MAAc,EACvBC,OAAe,CACf;QACA,KAAK,CAACA,UAAAA,iBAAAA,IAAAA,EAAAA,QAAAA,KAAAA,IAAAA,iBAAAA,IAAAA,EAAAA,UAAAA,KAAAA,IAAAA,IAAAA,CAJGF,IAAI,GAAJA,MAAAA,IAAAA,CACAC,MAAM,GAANA;QAIT,IAAI,CAAC,IAAI,GAAG;IACd;AACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
3
|
+
value: value,
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true
|
|
7
|
+
});
|
|
8
|
+
else obj[key] = value;
|
|
9
|
+
return obj;
|
|
10
|
+
}
|
|
11
|
+
class G9SurfaceError extends Error {
|
|
12
|
+
constructor(code, driver, message){
|
|
13
|
+
super(message), _define_property(this, "code", void 0), _define_property(this, "driver", void 0), this.code = code, this.driver = driver;
|
|
14
|
+
this.name = 'G9SurfaceError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export { G9SurfaceError };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type ReactNode } from '@lynx-js/react';
|
|
2
|
+
import type { NodesRef } from '@lynx-js/types';
|
|
3
|
+
import type { G9SurfaceEvents } from './protocol.js';
|
|
4
|
+
/** The page's way to the driver behind one surface. */
|
|
5
|
+
export declare class G9SurfacePort {
|
|
6
|
+
private target;
|
|
7
|
+
private queue;
|
|
8
|
+
/** A JSON message for the driver; kept (up to 256) until the element exists. */
|
|
9
|
+
send: (message: unknown) => void;
|
|
10
|
+
attach(target: NodesRef | null): void;
|
|
11
|
+
get attached(): boolean;
|
|
12
|
+
/** Messages waiting for an element. */
|
|
13
|
+
get pending(): number;
|
|
14
|
+
}
|
|
15
|
+
type Handler<K extends keyof G9SurfaceEvents> = (detail: G9SurfaceEvents[K]) => void;
|
|
16
|
+
/** Props of {@link G9Surface}. */
|
|
17
|
+
export interface G9SurfaceProps {
|
|
18
|
+
readonly id?: string;
|
|
19
|
+
/** A driver the host page registered (`registerG9Surface({ drivers })`). */
|
|
20
|
+
readonly driver: string;
|
|
21
|
+
/** Given to the driver at mount and on change (JSON). */
|
|
22
|
+
readonly params?: Record<string, unknown>;
|
|
23
|
+
readonly port?: G9SurfacePort;
|
|
24
|
+
readonly className?: string;
|
|
25
|
+
readonly style?: Record<string, string | number>;
|
|
26
|
+
readonly onReady?: Handler<'sfready'>;
|
|
27
|
+
readonly onResize?: Handler<'sfresize'>;
|
|
28
|
+
/** Typed: `unknown_driver`, `driver_failed`, `unsupported`. */
|
|
29
|
+
readonly onError?: Handler<'sferror'>;
|
|
30
|
+
/** The driver's own events. */
|
|
31
|
+
readonly onEvent?: Handler<'sfevent'>;
|
|
32
|
+
}
|
|
33
|
+
/** The `<g9-surface>` host element's attributes and events, as G9Surface sets them. */
|
|
34
|
+
export interface G9SurfaceElementProps {
|
|
35
|
+
readonly ref?: unknown;
|
|
36
|
+
readonly id?: string;
|
|
37
|
+
readonly className?: string;
|
|
38
|
+
readonly style?: Record<string, string | number>;
|
|
39
|
+
readonly driver?: string;
|
|
40
|
+
readonly params?: string;
|
|
41
|
+
readonly [event: `bind${string}`]: ((e: {
|
|
42
|
+
detail: unknown;
|
|
43
|
+
}) => void) | undefined;
|
|
44
|
+
}
|
|
45
|
+
declare module '@lynx-js/types' {
|
|
46
|
+
interface IntrinsicElements {
|
|
47
|
+
'g9-surface': G9SurfaceElementProps;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** A viewport a driver registered by the host page draws into (`<g9-surface>`): the page names the driver, sends it JSON through the port and hears its events. Nothing crosses the threads per frame. */
|
|
51
|
+
export declare function G9Surface(props: G9SurfaceProps): ReactNode;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../../src/surface/surface.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,uDAAuD;AACvD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,KAAK,CAAiB;IAE9B,gFAAgF;IAChF,IAAI,GAAI,SAAS,OAAO,KAAG,IAAI,CAO7B;IAEF,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI;IAQrC,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,uCAAuC;IACvC,IAAI,OAAO,IAAI,MAAM,CAEpB;CACF;AAED,KAAK,OAAO,CAAC,CAAC,SAAS,MAAM,eAAe,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAErF,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,QAAQ,CAAC,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AqB,CAAC;KACrC;CACF;AAED,0MAA0M;AAC1M,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CA0B1D"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { g9IdProps } from "@g9tm/lynxcontrols/base";
|
|
2
|
+
import { useEffect, useRef } from "@lynx-js/react";
|
|
3
|
+
function _define_property(obj, key, value) {
|
|
4
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
5
|
+
value: value,
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true
|
|
9
|
+
});
|
|
10
|
+
else obj[key] = value;
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
const QUEUE_MAX = 256;
|
|
14
|
+
class G9SurfacePort {
|
|
15
|
+
attach(target) {
|
|
16
|
+
this.target = target;
|
|
17
|
+
if (!target) return;
|
|
18
|
+
const queued = this.queue;
|
|
19
|
+
this.queue = [];
|
|
20
|
+
for (const message of queued)this.send(message);
|
|
21
|
+
}
|
|
22
|
+
get attached() {
|
|
23
|
+
return null !== this.target;
|
|
24
|
+
}
|
|
25
|
+
get pending() {
|
|
26
|
+
return this.queue.length;
|
|
27
|
+
}
|
|
28
|
+
constructor(){
|
|
29
|
+
_define_property(this, "target", null);
|
|
30
|
+
_define_property(this, "queue", []);
|
|
31
|
+
_define_property(this, "send", (message)=>{
|
|
32
|
+
if (!this.target) {
|
|
33
|
+
if (this.queue.length >= QUEUE_MAX) this.queue.shift();
|
|
34
|
+
this.queue.push(message);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.target.invoke({
|
|
38
|
+
method: 'apply',
|
|
39
|
+
params: {
|
|
40
|
+
json: JSON.stringify(message)
|
|
41
|
+
}
|
|
42
|
+
}).exec();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function G9Surface(props) {
|
|
47
|
+
var _props_params;
|
|
48
|
+
const { port } = props;
|
|
49
|
+
const ref = useRef(null);
|
|
50
|
+
useEffect(()=>{
|
|
51
|
+
if (!port) return;
|
|
52
|
+
port.attach(ref.current);
|
|
53
|
+
return ()=>port.attach(null);
|
|
54
|
+
}, [
|
|
55
|
+
port
|
|
56
|
+
]);
|
|
57
|
+
const on = (handler)=>(e)=>null == handler ? void 0 : handler(e.detail);
|
|
58
|
+
return <g9-surface ref={ref} {...g9IdProps(props.id)} className={`g9-surface${props.className ? ` ${props.className}` : ''}`} {...props.style ? {
|
|
59
|
+
style: props.style
|
|
60
|
+
} : {}} driver={props.driver} params={JSON.stringify(null != (_props_params = props.params) ? _props_params : {})} bindsfready={on(props.onReady)} bindsfresize={on(props.onResize)} bindsferror={on(props.onError)} bindsfevent={on(props.onEvent)}/>;
|
|
61
|
+
}
|
|
62
|
+
export { G9Surface, G9SurfacePort };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/transform-box/core.ts"],"names":[],"mappings":"AAEA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|