@gorilla-engine-sdk/ge-session-presets-lib 0.5.13

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,57 @@
1
+ import * as React from 'react';
2
+ import { IPresetManager } from '../types/IPresetManager';
3
+ import { SessionAndPresetsConfig } from '../types/SessionAndPresetsConfig';
4
+ import { SessionAndPresetsState } from './SessionAndPresetsState';
5
+ /**
6
+ * Props for {@link SessionAndPresetsStateProvider}.
7
+ */
8
+ type SessionAndPresetsStateProviderProps = {
9
+ /** Initial state override — defaults to {@link defaultSessionAndPresetsState} */
10
+ state?: SessionAndPresetsState;
11
+ /** Configuration override — defaults to {@link defaultSessionAndPresetsConfig} */
12
+ config?: SessionAndPresetsConfig;
13
+ /**
14
+ * Custom preset manager — if omitted a default {@link PresetManager} is created
15
+ * from the provided `config`.
16
+ */
17
+ presetManager?: IPresetManager;
18
+ /** The Gorilla Engine instrument instance, typically obtained from `useInstrument` */
19
+ instrument?: GorillaEngine.Instrument;
20
+ children?: React.ReactNode;
21
+ };
22
+ /**
23
+ * React context provider that supplies the session and preset state tree to
24
+ * all child components.
25
+ *
26
+ * Place this at the top of your plugin component tree, above
27
+ * {@link SessionAndPresetsWrapper}.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * const config: SessionAndPresetsConfig = {
32
+ * presetFileSuffix: '.patch',
33
+ * factoryPresetType: 'FACTORY',
34
+ * factoryPresetPath: factoryPresetsDir,
35
+ * userPresetType: 'USER',
36
+ * userPresetPath: userPresetsDir,
37
+ * handleSession: true,
38
+ * handlePresets: true,
39
+ * autoLoadPresets: true,
40
+ * loadInitialPreset: true,
41
+ * handleErrors: true,
42
+ * blockAAXInitialSession: false,
43
+ * };
44
+ *
45
+ * function Root({ instrument }: { instrument: GorillaEngine.Instrument }) {
46
+ * return (
47
+ * <SessionAndPresetsStateProvider config={config} instrument={instrument}>
48
+ * <SessionAndPresetsWrapper>
49
+ * <App />
50
+ * </SessionAndPresetsWrapper>
51
+ * </SessionAndPresetsStateProvider>
52
+ * );
53
+ * }
54
+ * ```
55
+ */
56
+ export declare function SessionAndPresetsStateProvider(props: SessionAndPresetsStateProviderProps): React.JSX.Element;
57
+ export {};
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SessionAndPresetsStateProvider = SessionAndPresetsStateProvider;
37
+ const React = __importStar(require("react"));
38
+ const react_1 = require("react");
39
+ const SessionAndPresetsState_1 = require("./SessionAndPresetsState");
40
+ const PresetManager_1 = require("../PresetManager");
41
+ const defaultSessionAndPresetsConfig_1 = require("../defaultSessionAndPresetsConfig");
42
+ const defaultSessionAndPresetsState_1 = require("../defaultSessionAndPresetsState");
43
+ const __1 = require("..");
44
+ /**
45
+ * React context provider that supplies the session and preset state tree to
46
+ * all child components.
47
+ *
48
+ * Place this at the top of your plugin component tree, above
49
+ * {@link SessionAndPresetsWrapper}.
50
+ *
51
+ * @example
52
+ * ```tsx
53
+ * const config: SessionAndPresetsConfig = {
54
+ * presetFileSuffix: '.patch',
55
+ * factoryPresetType: 'FACTORY',
56
+ * factoryPresetPath: factoryPresetsDir,
57
+ * userPresetType: 'USER',
58
+ * userPresetPath: userPresetsDir,
59
+ * handleSession: true,
60
+ * handlePresets: true,
61
+ * autoLoadPresets: true,
62
+ * loadInitialPreset: true,
63
+ * handleErrors: true,
64
+ * blockAAXInitialSession: false,
65
+ * };
66
+ *
67
+ * function Root({ instrument }: { instrument: GorillaEngine.Instrument }) {
68
+ * return (
69
+ * <SessionAndPresetsStateProvider config={config} instrument={instrument}>
70
+ * <SessionAndPresetsWrapper>
71
+ * <App />
72
+ * </SessionAndPresetsWrapper>
73
+ * </SessionAndPresetsStateProvider>
74
+ * );
75
+ * }
76
+ * ```
77
+ */
78
+ function SessionAndPresetsStateProvider(props) {
79
+ const [state] = (0, react_1.useState)(props.state ? props.state : defaultSessionAndPresetsState_1.defaultSessionAndPresetsState);
80
+ const [config] = (0, react_1.useState)(props.config ? props.config : defaultSessionAndPresetsConfig_1.defaultSessionAndPresetsConfig);
81
+ const [SessionAndPresets, dispatch] = (0, react_1.useReducer)(SessionAndPresetsState_1.SessionAndPresetsReducer, state);
82
+ const sessionAndPresetStateDispath = (0, SessionAndPresetsState_1.useSessionAndPresetsStateDispatch)();
83
+ const [presetManagerInstance, setPresetManagerInstance] = (0, react_1.useState)(undefined);
84
+ /**
85
+ * Initial useEffect - makes sure that either the provided PresetManger or the default PresetManager is getting set
86
+ */
87
+ (0, react_1.useEffect)(() => {
88
+ config.pluginType = GorillaEngine.getPluginType();
89
+ const pm = props.presetManager ? props.presetManager : new PresetManager_1.PresetManager(props.config);
90
+ pm.setState(props.state ? props.state : defaultSessionAndPresetsState_1.defaultSessionAndPresetsState);
91
+ setPresetManagerInstance(pm);
92
+ }, []);
93
+ /**
94
+ * is getting triggered when props.instrument change & dispatches to state.
95
+ * The dispatch can be alternatively triggered at any place inside plugin. E.g.
96
+ * - in App.tsx
97
+ * - in a plugin that changes blobs & instruments during runtime
98
+ */
99
+ (0, react_1.useEffect)(() => {
100
+ if (config.debug)
101
+ console.log(`${__1.GE_SESSION_PRESETS_LIB} SessionAndPresetsStateProvider: useEffect [props.instrument]`);
102
+ if (props.instrument) {
103
+ sessionAndPresetStateDispath({
104
+ type: SessionAndPresetsState_1.SessionAndPresetsDispatchTypes.setInstrument,
105
+ payload: {
106
+ instrument: props.instrument,
107
+ },
108
+ });
109
+ }
110
+ }, [props.instrument]);
111
+ return (React.createElement(SessionAndPresetsState_1.SessionAndPresetsConfigContext.Provider, { value: config },
112
+ React.createElement(SessionAndPresetsState_1.SessionAndPresetsManagerContext.Provider, { value: presetManagerInstance },
113
+ React.createElement(SessionAndPresetsState_1.SessionAndPresetsStateContext.Provider, { value: SessionAndPresets },
114
+ React.createElement(SessionAndPresetsState_1.SessionAndPresetsStateDispatchContext.Provider, { value: dispatch },
115
+ React.createElement(Wrapper, null, props.children))))));
116
+ }
117
+ /**
118
+ * Makes sure that changes to SessionAndPresetsState are updateing PresetManager internal State
119
+ * @param props
120
+ * @returns
121
+ */
122
+ function Wrapper(props) {
123
+ const presetManager = (0, SessionAndPresetsState_1.useSessionAndPresetsManager)();
124
+ const sessionAndPresetState = (0, SessionAndPresetsState_1.useSessionAndPresetsState)();
125
+ (0, react_1.useEffect)(() => {
126
+ if (sessionAndPresetState && presetManager)
127
+ presetManager.setState(sessionAndPresetState);
128
+ }, [sessionAndPresetState]);
129
+ return React.createElement(React.Fragment, null, props.children);
130
+ }
131
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjo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FBQyx1REFBOEIsQ0FBQyxRQUFRLElBQUMsS0FBSyxFQUFFLE1BQU07UUFDcEQsb0JBQUMsd0RBQStCLENBQUMsUUFBUSxJQUFDLEtBQUssRUFBRSxxQkFBcUI7WUFDcEUsb0JBQUMsc0RBQTZCLENBQUMsUUFBUSxJQUFDLEtBQUssRUFBRSxpQkFBaUI7Z0JBQzlELG9CQUFDLDhEQUFxQyxDQUFDLFFBQVEsSUFBQyxLQUFLLEVBQUUsUUFBUTtvQkFDN0Qsb0JBQUMsT0FBTyxRQUFFLEtBQUssQ0FBQyxRQUFRLENBQVcsQ0FDWSxDQUNWLENBQ0EsQ0FDSCxDQUMzQyxDQUFDO0FBQ0osQ0FBQztBQUVEOzs7O0dBSUc7QUFDSCxTQUFTLE9BQU8sQ0FBQyxLQUFLO0lBQ3BCLE1BQU0sYUFBYSxHQUFtQixJQUFBLG9EQUEyQixHQUFFLENBQUM7SUFDcEUsTUFBTSxxQkFBcUIsR0FBMkIsSUFBQSxrREFBeUIsR0FBRSxDQUFDO0lBRWxGLElBQUEsaUJBQVMsRUFBQyxHQUFHLEVBQUU7UUFDYixJQUFJLHFCQUFxQixJQUFJLGFBQWE7WUFBRSxhQUFhLENBQUMsUUFBUSxDQUFDLHFCQUFxQixDQUFDLENBQUM7SUFDNUYsQ0FBQyxFQUFFLENBQUMscUJBQXFCLENBQUMsQ0FBQyxDQUFDO0lBRTVCLE9BQU8sMENBQUcsS0FBSyxDQUFDLFFBQVEsQ0FBSSxDQUFDO0FBQy9CLENBQUMifQ==
@@ -0,0 +1,266 @@
1
+ import { SessionAndPresetsState } from '../state/SessionAndPresetsState';
2
+ import { Preset } from './Preset';
3
+ import { SessionAndPresetsConfig } from './SessionAndPresetsConfig';
4
+ export type AdditionalSaveSessionSignature = (instrument: GorillaEngine.Instrument, sessionJSON: any) => any;
5
+ export type AdditionalPreLoadSessionSignature = (instrument: GorillaEngine.Instrument, sessionJSON: any) => Promise<any>;
6
+ export type AdditionalLoadSessionSignature = (instrument: GorillaEngine.Instrument, sessionJSON: any, isDirtySessionLoad: boolean) => Promise<any>;
7
+ export type AdditionalCreatePresetItemSignature = (preset: Preset) => Promise<any>;
8
+ export type AdditionalPreLoadPresetSignature = (instrument: GorillaEngine.Instrument, presetItem: Preset, presetObj: any, sessionRestore?: boolean) => Promise<any>;
9
+ export type AdditionalLoadPresetSignature = (instrument: GorillaEngine.Instrument, presetObj: any, sessionRestore?: boolean) => Promise<any>;
10
+ export type AdditionalPreLoadPresetFromSourceSignature = (instrument: GorillaEngine.Instrument, preset: Preset, presetObj: any, isInitialPreset: boolean) => Promise<any>;
11
+ export type AdditionalLoadPresetFromSourceSignature = (instrument: GorillaEngine.Instrument, preset: Preset, presetObj: any, isInitialPreset: boolean) => Promise<any>;
12
+ export type AdditionalCreatePresetSignature = (instrument: GorillaEngine.Instrument, presetObj: any, sessionRestore: boolean) => any;
13
+ export type AdditionalGetInstrumentParamSignature = (instrument: GorillaEngine.Instrument, key: string, savePropsObj: any, sessionRestore: boolean) => boolean;
14
+ export type AdditionalSetInstrumentParamSignature = (instrument: GorillaEngine.Instrument, key: string, instStateFromPreset: any, sessionRestore: boolean) => boolean;
15
+ export type AdditionalPreSavePresetSignature = (instrument: GorillaEngine.Instrument, fileObj: {
16
+ filePath: string;
17
+ }) => Promise<any>;
18
+ export type AdditionalSavePresetSignature = (instrument: GorillaEngine.Instrument, presetObj: any, fileObj: {
19
+ filePath: string;
20
+ }) => Promise<any>;
21
+ export type AdditionalDeletePresetSignature = (instrument: GorillaEngine.Instrument) => Promise<any>;
22
+ /**
23
+ * The core contract for preset and session management. The default
24
+ * {@link PresetManager} class implements this interface. You can extend it or
25
+ * replace it entirely by passing a custom instance to
26
+ * {@link SessionAndPresetsStateProvider}.
27
+ *
28
+ * Use the `setAdditional*` / `removeAdditional*` methods to hook into specific
29
+ * lifecycle points without subclassing `PresetManager`.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * class MyPresetManager extends PresetManager {
34
+ * constructor(config: SessionAndPresetsConfig) {
35
+ * super(config);
36
+ * // Hook into preset load to apply sample paths
37
+ * this.setAdditionalLoadPreset(async (instrument, presetObj) => {
38
+ * await applySamplePaths(instrument, presetObj);
39
+ * });
40
+ * }
41
+ * }
42
+ * ```
43
+ */
44
+ export type IPresetManager = IPresetManagerCallbacks & {
45
+ config: SessionAndPresetsConfig;
46
+ /**
47
+ * Boolean flag, indicating if a session-loading is in progress
48
+ */
49
+ get isLoadingSession(): boolean;
50
+ /**
51
+ * Boolean flag indicating if the plugin instance loaded a session
52
+ */
53
+ get loadedSession(): boolean;
54
+ /**
55
+ * Boolean flag indicating if session loading affected this instance
56
+ */
57
+ get sessionInvolved(): boolean;
58
+ /**
59
+ * Boolean flag indicating if other concurrently running logic might have destroyed/overriden session-loading
60
+ */
61
+ get isDirtySessionLoad(): boolean;
62
+ set isDirtySessionLoad(dirty: boolean);
63
+ /** Number of session-load attempts that have occurred since the plugin was instantiated */
64
+ get sessionCount(): number;
65
+ /** Increments the internal session-load counter */
66
+ incrementSessionCount(): void;
67
+ /**
68
+ * Updates the internal reference to state
69
+ *
70
+ * @param state
71
+ * @returns
72
+ */
73
+ setState: (state: SessionAndPresetsState) => void;
74
+ /**
75
+ * Registered/assigned to GorillaEngine.setSessionSaveCallback
76
+ *
77
+ * @param instrument current instrument instance
78
+ * @param additionalStateString the stateString coming from DAW
79
+ * @param preset - the currently loaded preset
80
+ * @returns
81
+ */
82
+ saveSession: (additionalStateString: string, preset: Preset) => string;
83
+ /**
84
+ * Loading the previously stored stateString, only called if stateString exists
85
+ * General initialization logic:
86
+ * - get everything ready (e.g. load presets)
87
+ * - when we are ready to go, wait one second (yeah, i know...)
88
+ * - check if session stageString exists
89
+ * - if exists -> load plugin from session
90
+ * - if not exist -> load plugin from initial preset
91
+ *
92
+ * @param instrument
93
+ * @param stateString
94
+ * @returns
95
+ */
96
+ loadSession: (stateJSON: JSON) => Promise<any>;
97
+ /**
98
+ * Loading all presets in the given dirs
99
+ * - factory preset location
100
+ * - user preset location
101
+ *
102
+ * @param dirs
103
+ * @returns
104
+ */
105
+ loadPresets: (dirs: any[]) => Promise<Preset[]>;
106
+ /**
107
+ * Loads a preset-object - used by all loadPreset-default-implemented methods
108
+ * - loadPresetFromSource
109
+ * - loadPresetFromSession
110
+ *
111
+ * @param presetObj
112
+ * @param sessionRestore
113
+ * @returns
114
+ */
115
+ loadPreset: (presetObj: any, presetItem: Preset, sessionRestore?: boolean) => Promise<any>;
116
+ /**
117
+ * Load Preset from source in default PresetManager it loads from file-system.
118
+ * Can be overridden if need to load from web/database as source of preset
119
+ *
120
+ * @param source
121
+ * @returns
122
+ */
123
+ loadPresetFromSource: (source: any, isInitialPreset: boolean, instStateToRetain?: any[]) => Promise<any>;
124
+ /**
125
+ * Creates a preset with default-content, returns it as object
126
+ *
127
+ * default-content:
128
+ * general: { pluginVersion: '0.0.1', buildNumber: 'manual' },
129
+ * instrument: { ... } -> instrument-properties as normValue
130
+ * preset: "presetName" -> TODO: revise what this best is
131
+ *
132
+ * @param instrument
133
+ * @returns
134
+ */
135
+ createPreset: (sessionRestore?: boolean) => Promise<any>;
136
+ createPresetInstrumentState: (instrument: GorillaEngine.Instrument, sessionRestore: boolean) => any[];
137
+ applyPresetInstrumentState: (instrument: GorillaEngine.Instrument, instStateFromPreset: any[], sessionRestore: boolean, isInitialPreset: boolean) => void;
138
+ /**
139
+ * Saves a preset to file-system
140
+ *
141
+ * @param filePath
142
+ * @returns
143
+ */
144
+ savePreset: (filePath: string) => Promise<any>;
145
+ /**
146
+ *
147
+ * @param instrument
148
+ * @param filePath
149
+ * @returns
150
+ */
151
+ saveAsPreset: (filePath: string) => Promise<any>;
152
+ /**
153
+ * Deletes a preset at given path
154
+ * @param filePath
155
+ * @returns
156
+ */
157
+ deletePreset: (filePath: string) => Promise<any>;
158
+ };
159
+ export type IPresetManagerCallbacks = {
160
+ /**
161
+ * Assign a function that gets called after the session-object is created & filled with default information, apply additional logic here, e.g.
162
+ * - save plugin specific ui-state ( e.g. masterViewWisible = true)
163
+ *
164
+ * @param instrument
165
+ * @param sessionJSON
166
+ * @returns
167
+ */
168
+ setAdditionalSaveSession: (additionalSaveSession: AdditionalSaveSessionSignature) => void;
169
+ removeAdditionalSaveSession: (additionalSaveSession: AdditionalSaveSessionSignature) => void;
170
+ /**
171
+ * Assign a function that gets called before the sessionJSON is applied, any additional sanitiy checks & plugin secific error throwing should happen here, e.g.
172
+ *
173
+ * @param instrument
174
+ * @param sessionJSON
175
+ * @returns
176
+ */
177
+ setAdditionalPreLoadSession: (additionalPreLoadSession: AdditionalPreLoadSessionSignature) => void;
178
+ removeAdditionalPreLoadSession: (additionalPreLoadSession: AdditionalPreLoadSessionSignature) => void;
179
+ /**
180
+ *
181
+ * Assign a function that gets called when session loading has finished, apply additional data here, e.g.
182
+ * - restore ui-state saved with session
183
+ *
184
+ * @param instrument
185
+ * @param sessionJSON
186
+ * @returns
187
+ */
188
+ setAdditionalLoadSession: (additionalLoadSession: AdditionalLoadSessionSignature) => void;
189
+ removeAdditionalLoadSession: (additionalLoadSession: AdditionalLoadSessionSignature) => void;
190
+ /**
191
+ *
192
+ * @param preset
193
+ * @returns
194
+ */
195
+ setAdditionalCreatePresetItem: (additionalCreatePresetItem: AdditionalCreatePresetItemSignature) => void;
196
+ removeAdditionalCreatePresetItem: (additionalCreatePresetItem: AdditionalCreatePresetItemSignature) => void;
197
+ /**
198
+ * Assign a function that gets called before any preset data is applied, pre-checks inside the presetObj could be applied here, e.g.
199
+ * - check included path to sample if exists
200
+ * - check if preset is missing plugin specific information
201
+ *
202
+ * @param instrument
203
+ * @param presetObj
204
+ * @param sessionRestore
205
+ * @returns
206
+ */
207
+ setAdditionalPreLoadPreset: (additionalPreLoadPreset: AdditionalPreLoadPresetSignature) => void;
208
+ removeAdditionalPreLoadPreset: (additionalPreLoadPreset: AdditionalPreLoadPresetSignature) => void;
209
+ /**
210
+ * Assign a function that gets called after setting preset data, apply further plugin specific preset logic, e.g.
211
+ * - load the sample referenced in the preset
212
+ * - apply slice data included in the preset
213
+ * - apply sequencer pattern stored in the preset
214
+ *
215
+ * @param instrument
216
+ * @param presetObj
217
+ * @param sessionRestore
218
+ * @returns
219
+ */
220
+ setAdditionalLoadPreset: (additionalLoadPreset: AdditionalLoadPresetSignature) => void;
221
+ removeAdditionalLoadPreset: (additionalLoadPreset: AdditionalLoadPresetSignature) => void;
222
+ /**
223
+ * Assign a function that gets called when loading a preset from source (e.g. file-system), after the source returned the preset data parsed as json/js-object,
224
+ * do further plugin specific checks/conversions, e.g.
225
+ * - if preset if factory preset, manipulate sample path (simple sampler, factory presets can not store abolute path)
226
+ *
227
+ * @param instrument
228
+ * @param preset
229
+ * @param presetObj
230
+ * @returns
231
+ */
232
+ setAdditionalPreLoadPresetFromSource: (additionalPreLoadPresetFromSource: AdditionalPreLoadPresetFromSourceSignature) => void;
233
+ removeAdditionalPreLoadPresetFromSource: (additionalPreLoadPresetFromSource: AdditionalPreLoadPresetFromSourceSignature) => void;
234
+ /**
235
+ * Assign a function that gets called after all of load from source logic has been applied
236
+ *
237
+ * @param instrument
238
+ * @param preset
239
+ * @param presetObj
240
+ * @returns
241
+ */
242
+ setAdditionalLoadPresetFromSource: (additionalLoadPresetFromSource: AdditionalLoadPresetFromSourceSignature) => void;
243
+ removeAdditionalLoadPresetFromSource: (additionalLoadPresetFromSource: AdditionalLoadPresetFromSourceSignature) => void;
244
+ /**
245
+ * Assign a function that gets called after the preset object got created & populated. Additional plugin specific data can be added to the preset here, e.g.
246
+ * - save sample path
247
+ * - add slice data
248
+ * - add sequencer steps
249
+ *
250
+ * @param instrument
251
+ * @param presetObj
252
+ * @returns
253
+ */
254
+ setAdditionalCreatePreset: (additionalCreatePreset: AdditionalCreatePresetSignature) => void;
255
+ removeAdditionalCreatePreset: (additionalCreatePreset: AdditionalCreatePresetSignature) => void;
256
+ setAdditionalGetInstrumentParam: (additionalGetInstrumentParam: AdditionalGetInstrumentParamSignature) => void;
257
+ removeAdditionalGetInstrumentParam: (additionalGetInstrumentParam: AdditionalGetInstrumentParamSignature) => void;
258
+ setAdditionalSetInstrumentParam: (additionalSetInstrumentParam: AdditionalSetInstrumentParamSignature) => void;
259
+ removeAdditionalSetInstrumentParam: (additionalSetInstrumentParam: AdditionalSetInstrumentParamSignature) => void;
260
+ setAdditionalPreSavePreset: (additionalSavePreset: AdditionalPreSavePresetSignature) => void;
261
+ removeAdditionalPreSavePreset: (additionalSavePreset: AdditionalPreSavePresetSignature) => void;
262
+ setAdditionalSavePreset: (additionalSavePreset: AdditionalSavePresetSignature) => void;
263
+ removeAdditionalSavePreset: (additionalSavePreset: AdditionalSavePresetSignature) => void;
264
+ setAdditionalDeletePreset: (additionalDeletePreset: AdditionalDeletePresetSignature) => void;
265
+ removeAdditionalDeletePreset: (additionalDeletePreset: AdditionalDeletePresetSignature) => void;
266
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSVByZXNldE1hbmFnZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvSVByZXNldE1hbmFnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Represents a single preset item discovered on the file system.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const preset: Preset = {
7
+ * uuid: 'abc123',
8
+ * type: 'FACTORY',
9
+ * filePath: '/Library/Application Support/MyPlugin/Presets/Kick.patch',
10
+ * fileName: 'Kick.patch',
11
+ * name: 'Kick',
12
+ * subFolderPath: 'Drums',
13
+ * category: 'Drums',
14
+ * };
15
+ * ```
16
+ */
17
+ export type Preset = {
18
+ /** Stable hash derived from the preset file path, used as a unique identifier */
19
+ uuid: string;
20
+ /** Preset type — matches `factoryPresetType` or `userPresetType` from {@link SessionAndPresetsConfig} */
21
+ type: string;
22
+ /** Absolute path to the preset file on disk */
23
+ filePath: string;
24
+ /** File name including extension (e.g. `"Kick.patch"`) */
25
+ fileName: string;
26
+ /** Display name without extension (e.g. `"Kick"`) */
27
+ name: string;
28
+ /** Path relative to the preset root directory, without leading separator */
29
+ subFolderPath?: string;
30
+ /**
31
+ * Category string derived from the sub-folder structure.
32
+ * Nested folders are joined with `|` (e.g. `"Drums|808"`).
33
+ */
34
+ category?: string;
35
+ /** Parsed preset JSON, populated lazily when the preset file is read */
36
+ json?: any;
37
+ /** Arbitrary per-directory metadata passed through from the preset scan configuration */
38
+ additionalData?: any;
39
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUHJlc2V0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL1ByZXNldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Configuration object passed to {@link SessionAndPresetsStateProvider} to
3
+ * control how sessions and presets are managed.
4
+ *
5
+ * Provide this to customise preset file extensions, directory paths, session
6
+ * handling behaviour, and debugging output. Defaults are available via
7
+ * {@link defaultSessionAndPresetsConfig}.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const config: SessionAndPresetsConfig = {
12
+ * presetFileSuffix: '.patch',
13
+ * factoryPresetType: 'FACTORY',
14
+ * factoryPresetPath: path.join(GorillaEngine.getResourcePath(), 'Presets'),
15
+ * userPresetType: 'USER',
16
+ * userPresetPath: path.join(userDataPath, 'Presets'),
17
+ * handleSession: true,
18
+ * handlePresets: true,
19
+ * autoLoadPresets: true,
20
+ * loadInitialPreset: true,
21
+ * handleErrors: true,
22
+ * blockAAXInitialSession: false,
23
+ * debug: false,
24
+ * };
25
+ * ```
26
+ */
27
+ export type SessionAndPresetsConfig = {
28
+ /**
29
+ * A string used to identify a factory preset
30
+ */
31
+ presetFileSuffix: string;
32
+ /**
33
+ * A string used to identify a factory preset
34
+ */
35
+ factoryPresetType: string;
36
+ /**
37
+ * The path to the factory-presets / factory-presets location
38
+ */
39
+ factoryPresetPath?: string;
40
+ /**
41
+ * A string used to identify a user preset
42
+ */
43
+ userPresetType: string;
44
+ /**
45
+ * The path to the user-presets / user-presets location
46
+ */
47
+ userPresetPath?: string;
48
+ /**
49
+ * Boolean flag indicating if the library should handle sessions
50
+ */
51
+ handleSession: boolean;
52
+ /**
53
+ * Boolean flag indicating if the library should handle presets
54
+ */
55
+ handlePresets: boolean;
56
+ /**
57
+ * Boolean flag indicating if presets should be loaded automatically by the library
58
+ */
59
+ autoLoadPresets: boolean;
60
+ /**
61
+ * Boolean flag indicating if ui-scale should be stored & applied, only works if window is of id "root"
62
+ */
63
+ retainUIScale?: boolean;
64
+ /**
65
+ * Boolean flag indicating if an initial preset should be loaded.
66
+ * - If @initialPresetName is set & valid - this preset will be loaded
67
+ * - If @initialPresetName is not set - the first preset in presets-array will be loaded
68
+ */
69
+ loadInitialPreset: boolean;
70
+ /**
71
+ * Boolean flag indicating if error handling/displaying should be done by lib, set to false & implment custom error handling if needed
72
+ */
73
+ handleErrors: boolean;
74
+ /**
75
+ * Boolean flag indicating if next/prev-functionality should roundtrip, e.g. when next is clicked & last preset is loaded, load first preset
76
+ */
77
+ roundtripPresets?: boolean;
78
+ flagPresetChanged?: boolean;
79
+ /**
80
+ * Boolean flag indicating if there is a prefix for categories to influence sorting
81
+ */
82
+ stripCategoryPrefix?: boolean;
83
+ /**
84
+ * Category prefix to detect
85
+ */
86
+ categoryPrefix?: string;
87
+ /**
88
+ * The type of plugin (VST, AAX...)
89
+ */
90
+ pluginType?: string;
91
+ blockAAXInitialSession: boolean;
92
+ /**
93
+ * Boolean flag indicating if debug output to console is active
94
+ */
95
+ debug?: boolean;
96
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2Vzc2lvbkFuZFByZXNldHNDb25maWcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvU2Vzc2lvbkFuZFByZXNldHNDb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -0,0 +1 @@
1
+ export declare const createHash: (s: string) => string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createHash = void 0;
4
+ const crypto = require("crypto");
5
+ const createHash = (s) => {
6
+ return crypto.createHash('md5').update(s).digest('hex');
7
+ };
8
+ exports.createHash = createHash;
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsaUNBQWtDO0FBRzNCLE1BQU0sVUFBVSxHQUFHLENBQUMsQ0FBUSxFQUFFLEVBQUU7SUFDckMsT0FBTyxNQUFNLENBQUMsVUFBVSxDQUFDLEtBQUssQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLENBQUE7QUFDekQsQ0FBQyxDQUFBO0FBRlksUUFBQSxVQUFVLGNBRXRCIn0=
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@gorilla-engine-sdk/ge-session-presets-lib",
3
+ "version": "0.5.13",
4
+ "description": "Session and preset management library for Gorilla Engine React audio plugins.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md",
10
+ "LICENSE.md"
11
+ ],
12
+ "scripts": {
13
+ "test": "echo \"No tests specified for ge-session-presets-lib\"",
14
+ "prepack": "npx tsc",
15
+ "start": "tsc -w",
16
+ "build": "npx tsc --declaration",
17
+ "ci:publish": "node ../../scripts/ci-publish.js"
18
+ },
19
+ "author": "UJAM Inc.",
20
+ "license": "SEE LICENSE IN LICENSE.md",
21
+ "peerDependencies": {
22
+ "@gorilla-engine-sdk/ge-dialogs-lib": "0.x",
23
+ "@gorilla-engine-sdk/gorilla-engine-react": "^1.6.1",
24
+ "react": "^19.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@gorilla-engine-sdk/ge-dialogs-lib": "0.x",
28
+ "@gorilla-engine-sdk/gorilla-engine-react": "^1.6.1",
29
+ "@types/node": "^22.0.0",
30
+ "@types/react": "^19.2.16",
31
+ "@types/react-reconciler": "^0.33.0",
32
+ "react": "^19.0.0",
33
+ "typescript": "^6.0.3"
34
+ },
35
+ "dependencies": {
36
+ "@types/gorilla-engine": "^1.1.11",
37
+ "fs-extra": "^11.3.5"
38
+ },
39
+ "homepage": "https://www.gorilla-engine.com/",
40
+ "keywords": [
41
+ "gorilla-engine",
42
+ "UJAM"
43
+ ],
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "registry": "https://registry.npmjs.org/"
47
+ }
48
+ }