@pipelab/shared 1.0.0-beta.1 → 1.0.0-beta.11
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/.oxfmtrc.json +1 -1
- package/CHANGELOG.md +82 -0
- package/dist/index.d.mts +467 -153
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +440 -188
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
- package/src/apis.ts +40 -13
- package/src/build-history.ts +2 -0
- package/src/config/connections-definition.ts +3 -0
- package/src/config/migrators.ts +227 -85
- package/src/config/settings-definition.ts +2 -0
- package/src/config.schema.ts +71 -2
- package/src/graph.ts +2 -70
- package/src/i18n/de_DE.json +5 -1
- package/src/i18n/en_US.json +18 -3
- package/src/i18n/es_ES.json +5 -1
- package/src/i18n/fr_FR.json +5 -1
- package/src/i18n/pt_BR.json +5 -1
- package/src/i18n/zh_CN.json +5 -1
- package/src/index.ts +19 -0
- package/src/ipc.types.ts +2 -0
- package/src/model.test.ts +313 -1
- package/src/model.ts +54 -43
- package/src/plugins/definitions.ts +25 -55
- package/src/plugins.ts +10 -1
- package/src/utils.ts +26 -0
- package/tsconfig.json +1 -3
package/src/model.ts
CHANGED
|
@@ -32,6 +32,14 @@ export type Position = {
|
|
|
32
32
|
export const OriginValidator = object({
|
|
33
33
|
pluginId: string(),
|
|
34
34
|
nodeId: string(),
|
|
35
|
+
version: optional(
|
|
36
|
+
pipe(
|
|
37
|
+
string(),
|
|
38
|
+
description(
|
|
39
|
+
'Pinned version of the plugin for this block. Falls back to "latest" when absent.',
|
|
40
|
+
),
|
|
41
|
+
),
|
|
42
|
+
),
|
|
35
43
|
});
|
|
36
44
|
|
|
37
45
|
export type Origin = InferOutput<typeof OriginValidator>;
|
|
@@ -49,7 +57,7 @@ export type EditorParam = InferOutput<typeof EditorParamValidatorV3>;
|
|
|
49
57
|
const BlockActionValidatorV3 = object({
|
|
50
58
|
type: literal("action"),
|
|
51
59
|
uid: string(),
|
|
52
|
-
name: pipe(
|
|
60
|
+
name: optional(pipe(string(), description("A custom name provided by the user"))),
|
|
53
61
|
disabled: optional(boolean()),
|
|
54
62
|
params: record(
|
|
55
63
|
string(),
|
|
@@ -61,39 +69,6 @@ const BlockActionValidatorV3 = object({
|
|
|
61
69
|
origin: OriginValidator,
|
|
62
70
|
});
|
|
63
71
|
|
|
64
|
-
export type BlockCondition = {
|
|
65
|
-
type: "condition";
|
|
66
|
-
uid: string;
|
|
67
|
-
origin: Origin;
|
|
68
|
-
params: Record<string, any>;
|
|
69
|
-
branchTrue: Array<Block>;
|
|
70
|
-
branchFalse: Array<Block>;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const BlockConditionValidator: GenericSchema<BlockCondition> = object({
|
|
74
|
-
type: literal("condition"),
|
|
75
|
-
uid: string(),
|
|
76
|
-
origin: OriginValidator,
|
|
77
|
-
params: record(string(), any()),
|
|
78
|
-
branchTrue: lazy(() => array(BlockValidator)),
|
|
79
|
-
branchFalse: lazy(() => array(BlockValidator)),
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
export type BlockLoop = {
|
|
83
|
-
type: "loop";
|
|
84
|
-
uid: string;
|
|
85
|
-
origin: Origin;
|
|
86
|
-
params: Record<string, any>;
|
|
87
|
-
children: Array<Block>;
|
|
88
|
-
};
|
|
89
|
-
const BlockLoopValidator: GenericSchema<BlockLoop> = object({
|
|
90
|
-
type: literal("loop"),
|
|
91
|
-
uid: string(),
|
|
92
|
-
origin: OriginValidator,
|
|
93
|
-
params: record(string(), any()),
|
|
94
|
-
children: lazy(() => array(BlockValidator)),
|
|
95
|
-
});
|
|
96
|
-
|
|
97
72
|
const BlockEventValidator = object({
|
|
98
73
|
type: literal("event"),
|
|
99
74
|
uid: string(),
|
|
@@ -180,20 +155,22 @@ export const SavedFileValidatorV3 = object({
|
|
|
180
155
|
variables: array(VariableValidatorV1),
|
|
181
156
|
});
|
|
182
157
|
|
|
183
|
-
export const
|
|
158
|
+
export const SavedFileDefaultValidatorV4 = object({
|
|
184
159
|
version: literal("4.0.0"),
|
|
185
160
|
type: literal("default"),
|
|
186
161
|
name: string(),
|
|
187
162
|
description: string(),
|
|
163
|
+
plugins: optional(record(string(), string())),
|
|
188
164
|
canvas: CanvasValidatorV3,
|
|
189
165
|
variables: array(VariableValidatorV1),
|
|
190
166
|
});
|
|
191
167
|
|
|
192
|
-
export const
|
|
168
|
+
export const SavedFileSimpleValidatorV4 = object({
|
|
193
169
|
version: literal("4.0.0"),
|
|
194
170
|
type: literal("simple"),
|
|
195
171
|
name: string(),
|
|
196
172
|
description: string(),
|
|
173
|
+
plugins: optional(record(string(), string())),
|
|
197
174
|
source: object({
|
|
198
175
|
type: union([literal("c3-html"), literal("c3-nwjs"), literal("godot"), literal("html")]),
|
|
199
176
|
path: string(),
|
|
@@ -208,19 +185,53 @@ export const SavedFileSimpleValidator = object({
|
|
|
208
185
|
}),
|
|
209
186
|
});
|
|
210
187
|
|
|
211
|
-
export
|
|
212
|
-
|
|
213
|
-
|
|
188
|
+
export const SavedFileDefaultValidatorV5 = object({
|
|
189
|
+
version: literal("5.0.0"),
|
|
190
|
+
name: string(),
|
|
191
|
+
description: string(),
|
|
192
|
+
canvas: CanvasValidatorV3,
|
|
193
|
+
variables: array(VariableValidatorV1),
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
export const SavedFileSimpleValidatorV5 = object({
|
|
197
|
+
version: literal("5.0.0"),
|
|
198
|
+
type: literal("simple"),
|
|
199
|
+
name: string(),
|
|
200
|
+
description: string(),
|
|
201
|
+
plugins: record(string(), string()),
|
|
202
|
+
source: object({
|
|
203
|
+
type: union([literal("c3-html"), literal("c3-nwjs"), literal("godot"), literal("html")]),
|
|
204
|
+
path: string(),
|
|
205
|
+
}),
|
|
206
|
+
packaging: object({
|
|
207
|
+
enabled: boolean(),
|
|
208
|
+
}),
|
|
209
|
+
publishing: object({
|
|
210
|
+
steam: object({ enabled: boolean(), appId: optional(string()) }),
|
|
211
|
+
itch: object({ enabled: boolean(), project: optional(string()) }),
|
|
212
|
+
poki: object({ enabled: boolean(), gameId: optional(string()) }),
|
|
213
|
+
}),
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
export type SavedFileDefault = InferOutput<typeof SavedFileDefaultValidatorV5>;
|
|
217
|
+
export type SavedFileSimple = InferOutput<typeof SavedFileSimpleValidatorV5>;
|
|
218
|
+
|
|
219
|
+
export const SavedFileValidatorV4 = union([
|
|
220
|
+
SavedFileDefaultValidatorV4,
|
|
221
|
+
SavedFileSimpleValidatorV4,
|
|
222
|
+
]);
|
|
223
|
+
export const SavedFileValidatorV5 = SavedFileDefaultValidatorV5;
|
|
214
224
|
|
|
215
225
|
export type SavedFileV1 = InferOutput<typeof SavedFileValidatorV1>;
|
|
216
226
|
export type SavedFileV2 = InferOutput<typeof SavedFileValidatorV2>;
|
|
217
227
|
export type SavedFileV3 = InferOutput<typeof SavedFileValidatorV3>;
|
|
218
228
|
export type SavedFileV4 = InferOutput<typeof SavedFileValidatorV4>;
|
|
219
|
-
export type
|
|
220
|
-
export
|
|
229
|
+
export type SavedFileV5 = InferOutput<typeof SavedFileValidatorV5>;
|
|
230
|
+
export type SavedFile = SavedFileV5;
|
|
231
|
+
export const SavedFileValidator = SavedFileValidatorV5;
|
|
221
232
|
|
|
222
233
|
export type Preset = SavedFile;
|
|
223
|
-
export type PresetResult = { data:
|
|
234
|
+
export type PresetResult = { data: Preset; hightlight?: boolean; disabled?: boolean };
|
|
224
235
|
export type PresetFn = () => Promise<PresetResult>;
|
|
225
236
|
|
|
226
237
|
export type Steps = Record<
|
|
@@ -230,4 +241,4 @@ export type Steps = Record<
|
|
|
230
241
|
}
|
|
231
242
|
>;
|
|
232
243
|
|
|
233
|
-
export type EnhancedFile<T
|
|
244
|
+
export type EnhancedFile<T = SavedFile> = WithId<SaveLocation> & { content: T };
|
|
@@ -154,18 +154,36 @@ export type IconType =
|
|
|
154
154
|
icon: string;
|
|
155
155
|
};
|
|
156
156
|
export interface PluginDefinition {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
icon: IconType;
|
|
160
|
-
description: string;
|
|
157
|
+
packageName?: string;
|
|
158
|
+
version?: string;
|
|
161
159
|
}
|
|
162
160
|
|
|
163
161
|
export type RendererNodeDefinition = {
|
|
164
162
|
node: PipelabNode;
|
|
165
163
|
};
|
|
166
164
|
|
|
165
|
+
export interface IntegrationField {
|
|
166
|
+
key: string;
|
|
167
|
+
label: string;
|
|
168
|
+
type: "text" | "password" | "file" | "directory";
|
|
169
|
+
placeholder?: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface IntegrationDefinition {
|
|
173
|
+
name: string;
|
|
174
|
+
fields: IntegrationField[];
|
|
175
|
+
}
|
|
176
|
+
|
|
167
177
|
export interface RendererPluginDefinition extends PluginDefinition {
|
|
178
|
+
id: string;
|
|
179
|
+
name: string;
|
|
180
|
+
icon: IconType;
|
|
181
|
+
description: string;
|
|
182
|
+
isOfficial: boolean;
|
|
183
|
+
packageName: string;
|
|
184
|
+
version: string;
|
|
168
185
|
nodes: Array<RendererNodeDefinition>;
|
|
186
|
+
integrations?: Array<IntegrationDefinition>;
|
|
169
187
|
}
|
|
170
188
|
|
|
171
189
|
export interface MainPluginDefinition extends PluginDefinition {
|
|
@@ -177,6 +195,7 @@ export interface MainPluginDefinition extends PluginDefinition {
|
|
|
177
195
|
description: string;
|
|
178
196
|
validator: (options: any) => any;
|
|
179
197
|
}>;
|
|
198
|
+
integrations?: Array<IntegrationDefinition>;
|
|
180
199
|
}
|
|
181
200
|
|
|
182
201
|
export const createNodeDefinition = (def: MainPluginDefinition) => {
|
|
@@ -203,10 +222,7 @@ export type SetOutputActionFn<T extends Action> = (
|
|
|
203
222
|
key: keyof T["outputs"],
|
|
204
223
|
value: T["outputs"][typeof key]["value"],
|
|
205
224
|
) => void;
|
|
206
|
-
|
|
207
|
-
key: keyof T["outputs"],
|
|
208
|
-
value: T["outputs"][typeof key]["value"],
|
|
209
|
-
) => void;
|
|
225
|
+
|
|
210
226
|
export type SetOutputExpressionFn<T extends Expression> = (
|
|
211
227
|
key: keyof T["outputs"],
|
|
212
228
|
value: T["outputs"][typeof key]["value"],
|
|
@@ -244,12 +260,6 @@ export type ExtractInputsFromAction<ACTION extends Action> = {
|
|
|
244
260
|
[index in keyof ACTION["params"]]: ACTION["params"][index]["value"];
|
|
245
261
|
};
|
|
246
262
|
|
|
247
|
-
export type ExtractInputsFromCondition<CONDITION extends Condition> = {
|
|
248
|
-
[index in keyof CONDITION["params"]]: CONDITION["params"][index]["value"];
|
|
249
|
-
};
|
|
250
|
-
export type ExtractInputsFromLoop<LOOP extends Loop> = {
|
|
251
|
-
[index in keyof LOOP["params"]]: LOOP["params"][index]["value"];
|
|
252
|
-
};
|
|
253
263
|
export type ExtractInputsFromEvent<EVENT extends Event> = {
|
|
254
264
|
[index in keyof EVENT["params"]]: EVENT["params"][index]["value"];
|
|
255
265
|
};
|
|
@@ -257,32 +267,6 @@ export type ExtractInputsFromExpression<EXPRESSION extends Expression> = {
|
|
|
257
267
|
[index in keyof EXPRESSION["params"]]: EXPRESSION["params"][index]["value"];
|
|
258
268
|
};
|
|
259
269
|
|
|
260
|
-
export interface Condition extends BaseNode {
|
|
261
|
-
id: string;
|
|
262
|
-
type: "condition";
|
|
263
|
-
version?: number;
|
|
264
|
-
displayString: string;
|
|
265
|
-
icon: string;
|
|
266
|
-
name: string;
|
|
267
|
-
description: string;
|
|
268
|
-
params: InputsDefinition;
|
|
269
|
-
meta?: Meta;
|
|
270
|
-
platforms?: NodeJS.Platform[];
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export interface Loop extends BaseNode {
|
|
274
|
-
id: string;
|
|
275
|
-
type: "loop";
|
|
276
|
-
version?: number;
|
|
277
|
-
displayString: string;
|
|
278
|
-
icon: string;
|
|
279
|
-
name: string;
|
|
280
|
-
description: string;
|
|
281
|
-
params: InputsDefinition;
|
|
282
|
-
meta?: Meta;
|
|
283
|
-
outputs: OutputsDefinition;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
270
|
export interface Expression extends BaseNode {
|
|
287
271
|
id: string;
|
|
288
272
|
type: "expression";
|
|
@@ -309,7 +293,7 @@ export interface Event extends BaseNode {
|
|
|
309
293
|
platforms?: NodeJS.Platform[];
|
|
310
294
|
}
|
|
311
295
|
|
|
312
|
-
export type PipelabNode = Event |
|
|
296
|
+
export type PipelabNode = Event | Expression | Action;
|
|
313
297
|
|
|
314
298
|
export const createDefinition = <T extends MainPluginDefinition>(definition: T) => {
|
|
315
299
|
return definition satisfies T;
|
|
@@ -450,20 +434,6 @@ export const createExpression = <T extends Omit<Expression, "type">>(expression:
|
|
|
450
434
|
} satisfies Expression;
|
|
451
435
|
};
|
|
452
436
|
|
|
453
|
-
export const createCondition = <T extends Omit<Condition, "type">>(condition: T) => {
|
|
454
|
-
return {
|
|
455
|
-
...condition,
|
|
456
|
-
type: "condition",
|
|
457
|
-
} satisfies Condition;
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
export const createLoop = <T extends Omit<Loop, "type">>(loop: T) => {
|
|
461
|
-
return {
|
|
462
|
-
...loop,
|
|
463
|
-
type: "loop",
|
|
464
|
-
} satisfies Loop;
|
|
465
|
-
};
|
|
466
|
-
|
|
467
437
|
export const createEvent = <T extends Omit<Event, "type">>(event: T) => {
|
|
468
438
|
return {
|
|
469
439
|
...event,
|
package/src/plugins.ts
CHANGED
|
@@ -9,7 +9,16 @@ export const usePlugins = () => {
|
|
|
9
9
|
const load = () => {};
|
|
10
10
|
|
|
11
11
|
const registerPlugins = (newPlugins: Plugin[]) => {
|
|
12
|
-
plugins.value
|
|
12
|
+
const current = [...plugins.value];
|
|
13
|
+
for (const np of newPlugins) {
|
|
14
|
+
const idx = current.findIndex((p) => p.id === np.id);
|
|
15
|
+
if (idx !== -1) {
|
|
16
|
+
current[idx] = np;
|
|
17
|
+
} else {
|
|
18
|
+
current.push(np);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
plugins.value = current;
|
|
13
22
|
};
|
|
14
23
|
|
|
15
24
|
return {
|
package/src/utils.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
export const foo = "bar";
|
|
2
2
|
|
|
3
3
|
export type WithId<T> = T extends string | number ? never : T & { id: string };
|
|
4
|
+
|
|
5
|
+
export const transformUrl = (url: string | undefined | null): string => {
|
|
6
|
+
if (url && typeof url === "string") {
|
|
7
|
+
const getHost = (): string => {
|
|
8
|
+
if (typeof window !== "undefined") {
|
|
9
|
+
const isDev = window.location.port === "5173";
|
|
10
|
+
if (isDev) {
|
|
11
|
+
return `http://${window.location.hostname}:33753`;
|
|
12
|
+
} else {
|
|
13
|
+
return `${window.location.protocol}//${window.location.host}`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return "http://localhost:33753";
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (url.startsWith("file://")) {
|
|
20
|
+
const filePath = url.substring("file://".length);
|
|
21
|
+
return `${getHost()}/media-file/${encodeURIComponent(filePath)}`;
|
|
22
|
+
}
|
|
23
|
+
if (url.startsWith("media://")) {
|
|
24
|
+
const filePath = url.replace(/^media:\/\/+/, "/");
|
|
25
|
+
return `${getHost()}/media-file/${encodeURIComponent(filePath)}`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return url || "";
|
|
29
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"emitDeclarationOnly": true,
|
|
5
5
|
"outDir": "dist",
|
|
6
|
-
"baseUrl": "."
|
|
7
|
-
"typeRoots": ["./src"],
|
|
8
|
-
"types": ["global.d.ts", "wasm.d.ts"]
|
|
6
|
+
"baseUrl": "."
|
|
9
7
|
},
|
|
10
8
|
"include": ["src/**/*", "tests/**/*", "*.ts", "src/**/*.json"],
|
|
11
9
|
"exclude": ["node_modules", "dist"],
|