@adeficior/data-modifier 1.0.0-rc.38 → 1.0.0-rc.40
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/dist/common/ingredient/index.d.ts +6 -0
- package/dist/common/ingredient/index.js +13 -0
- package/dist/common/ingredient/index.js.map +1 -1
- package/dist/common/result/index.d.ts +6 -0
- package/dist/common/result/index.js +13 -0
- package/dist/common/result/index.js.map +1 -1
- package/dist/error.js +11 -7
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/loader/context.d.ts +2 -2
- package/dist/loader/pack.d.ts +1 -1
- package/dist/loader/pack.js +4 -4
- package/dist/loader/pack.js.map +1 -1
- package/dist/loader/recipe.js +9 -5
- package/dist/loader/recipe.js.map +1 -1
- package/dist/parser/recipe/adAstra/inputOutput.js +1 -0
- package/dist/parser/recipe/adAstra/inputOutput.js.map +1 -1
- package/dist/parser/recipe/botania/blocks.d.ts +14 -8
- package/dist/parser/recipe/botania/blocks.js +39 -62
- package/dist/parser/recipe/botania/blocks.js.map +1 -1
- package/dist/parser/recipe/botania/gogWrapper.d.ts +2 -2
- package/dist/parser/recipe/botania/manaInfusion.d.ts +3 -0
- package/dist/parser/recipe/botania/manaInfusion.js +6 -5
- package/dist/parser/recipe/botania/manaInfusion.js.map +1 -1
- package/dist/parser/recipe/botania/nbtWrapper.d.ts +2 -2
- package/dist/parser/recipe/botania/pureDaisy.d.ts +4 -0
- package/dist/parser/recipe/botania/pureDaisy.js +15 -0
- package/dist/parser/recipe/botania/pureDaisy.js.map +1 -1
- package/dist/parser/recipe/create/assembly.d.ts +1 -0
- package/dist/parser/recipe/create/assembly.js +5 -2
- package/dist/parser/recipe/create/assembly.js.map +1 -1
- package/dist/parser/recipe/forge/conditional.d.ts +2 -2
- package/dist/parser/recipe/index.d.ts +9 -3
- package/dist/parser/recipe/index.js +17 -2
- package/dist/parser/recipe/index.js.map +1 -1
- package/dist/parser/recipe/ingredientMap.d.ts +2 -5
- package/dist/parser/recipe/ingredientMap.js +0 -3
- package/dist/parser/recipe/ingredientMap.js.map +1 -1
- package/dist/parser/recipe/thermal/index.d.ts +3 -0
- package/dist/parser/recipe/thermal/index.js +5 -3
- package/dist/parser/recipe/thermal/index.js.map +1 -1
- package/dist/parser/recipe/thermal/module.d.ts +4 -0
- package/dist/parser/recipe/thermal/module.js +36 -0
- package/dist/parser/recipe/thermal/module.js.map +1 -0
- package/dist/parser/recipe/vanilla/shaped.d.ts +1 -1
- package/dist/parser/recipe/vanilla/shaped.js +2 -2
- package/dist/parser/recipe/vanilla/shaped.js.map +1 -1
- package/dist/serializer/checks.d.ts +2 -0
- package/dist/serializer/checks.js +13 -0
- package/dist/serializer/checks.js.map +1 -0
- package/dist/serializer/index.d.ts +23 -0
- package/dist/serializer/index.js +19 -0
- package/dist/serializer/index.js.map +1 -0
- package/dist/serializer/ingredients/15.d.ts +2 -0
- package/dist/{common/ingredient/serializer.js → serializer/ingredients/15.js} +9 -26
- package/dist/serializer/ingredients/15.js.map +1 -0
- package/dist/serializer/ingredients/44.d.ts +2 -0
- package/dist/serializer/ingredients/44.js +46 -0
- package/dist/serializer/ingredients/44.js.map +1 -0
- package/dist/serializer/ingredients/common.d.ts +3 -0
- package/dist/serializer/ingredients/common.js +13 -0
- package/dist/serializer/ingredients/common.js.map +1 -0
- package/dist/serializer/ingredients/index.d.ts +20 -0
- package/dist/serializer/ingredients/index.js +36 -0
- package/dist/serializer/ingredients/index.js.map +1 -0
- package/dist/serializer/module.d.ts +23 -0
- package/dist/serializer/module.js +42 -0
- package/dist/serializer/module.js.map +1 -0
- package/dist/serializer/results/15.d.ts +2 -0
- package/dist/{common/result/serializer.js → serializer/results/15.js} +9 -14
- package/dist/serializer/results/15.js.map +1 -0
- package/dist/serializer/results/44.d.ts +2 -0
- package/dist/serializer/results/44.js +21 -0
- package/dist/serializer/results/44.js.map +1 -0
- package/dist/serializer/results/common.d.ts +3 -0
- package/dist/serializer/results/common.js +6 -0
- package/dist/serializer/results/common.js.map +1 -0
- package/dist/serializer/results/index.d.ts +6 -0
- package/dist/serializer/results/index.js +21 -0
- package/dist/serializer/results/index.js.map +1 -0
- package/dist/serializer/versioned.d.ts +19 -0
- package/dist/serializer/versioned.js +55 -0
- package/dist/serializer/versioned.js.map +1 -0
- package/dist/serializer/wrapped.d.ts +12 -0
- package/dist/serializer/wrapped.js +32 -0
- package/dist/serializer/wrapped.js.map +1 -0
- package/package.json +1 -1
- package/dist/common/ingredient/serializer.d.ts +0 -9
- package/dist/common/ingredient/serializer.js.map +0 -1
- package/dist/common/result/serializer.d.ts +0 -7
- package/dist/common/result/serializer.js.map +0 -1
- package/dist/common/serializer.d.ts +0 -35
- package/dist/common/serializer.js +0 -110
- package/dist/common/serializer.js.map +0 -1
- package/dist/parser/recipe/thermal/ingredient.d.ts +0 -4
- package/dist/parser/recipe/thermal/ingredient.js +0 -51
- package/dist/parser/recipe/thermal/ingredient.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pureDaisy.js","sourceRoot":"","sources":["../../../../src/parser/recipe/botania/pureDaisy.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,EAAE,EAEhC,MAAM,aAAa,CAAC;AAIrB,MAAM,OAAO,qBAAsB,SAAQ,wBAAmD;
|
|
1
|
+
{"version":3,"file":"pureDaisy.js","sourceRoot":"","sources":["../../../../src/parser/recipe/botania/pureDaisy.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAe,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,wBAAwB,EAAE,EAEhC,MAAM,aAAa,CAAC;AAIrB,MAAM,kBAAkB,GAAG,sBAAsB,CAAS,CAAC,OAAO,EAAE,EAAE;IACpE,OAAO,CAAC,QAAQ,CACd,WAAW,EACX,YAAY,CAAC,MAAM,CAAC,EACpB,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,QAAQ;KACf,CAAC,EACF,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,EACnC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAC3B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,OAAO,qBAAsB,SAAQ,wBAAmD;IACnF,aAAa;QACpB,OAAO;YACL,EAAE,EAAE,kBAAkB;SACvB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -6,6 +6,7 @@ import RecipeParser, { Recipe } from "../index.js";
|
|
|
6
6
|
export type AssemblyRecipeDefinition = RecipeDefinition & Readonly<{
|
|
7
7
|
ingredient: unknown;
|
|
8
8
|
transitionalItem: unknown;
|
|
9
|
+
transitional_item: unknown;
|
|
9
10
|
results: unknown[];
|
|
10
11
|
loops?: number;
|
|
11
12
|
sequence: RecipeDefinition[];
|
|
@@ -27,7 +27,7 @@ export class AssemblyRecipe extends Recipe {
|
|
|
27
27
|
serialize(context) {
|
|
28
28
|
return {
|
|
29
29
|
ingredient: context.ingredients.serialize(this.ingredient),
|
|
30
|
-
transitionalItem: context.
|
|
30
|
+
transitionalItem: context.results.serialize(this.transitionalItem.asResult()),
|
|
31
31
|
results: context.results.serializeList(this.results),
|
|
32
32
|
sequence: this.sequence.map((it) => context.recipes.serialize(it)),
|
|
33
33
|
};
|
|
@@ -36,7 +36,10 @@ export class AssemblyRecipe extends Recipe {
|
|
|
36
36
|
export class AssemblyRecipeParser extends RecipeParser {
|
|
37
37
|
deserialize(definition, context) {
|
|
38
38
|
const ingredient = context.ingredients.deserialize(definition.ingredient);
|
|
39
|
-
const
|
|
39
|
+
const rawTransitionalItem = definition.transitionalItem ?? definition.transitional_item;
|
|
40
|
+
const transitionalItem = context.results
|
|
41
|
+
.deserialize(rawTransitionalItem)
|
|
42
|
+
.asIngredient();
|
|
40
43
|
const results = context.results.deserializeList(definition.results);
|
|
41
44
|
const sequence = definition.sequence.map((it) => context.recipes.deserialize(it));
|
|
42
45
|
return new AssemblyRecipe(ingredient, transitionalItem, results, sequence);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assembly.js","sourceRoot":"","sources":["../../../../src/parser/recipe/create/assembly.ts"],"names":[],"mappings":"AAQA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"assembly.js","sourceRoot":"","sources":["../../../../src/parser/recipe/create/assembly.ts"],"names":[],"mappings":"AAQA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAYnD,MAAM,OAAO,cAAe,SAAQ,MAAM;IAErB;IACA;IACA;IACA;IAJnB,YACmB,UAAsB,EACtB,gBAA4B,EAC5B,OAAiB,EACjB,QAAwB;QAEzC,KAAK,EAAE,CAAC;QALS,eAAU,GAAV,UAAU,CAAY;QACtB,qBAAgB,GAAhB,gBAAgB,CAAY;QAC5B,YAAO,GAAP,OAAO,CAAU;QACjB,aAAQ,GAAR,QAAQ,CAAgB;IAG3C,CAAC;IAED,cAAc;QACZ,OAAO;YACL,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,gBAAgB;YACrB,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC;SACtD,CAAC;IACJ,CAAC;IAED,UAAU;QACR,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC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AY,EAAE,CAAC;QAClB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACpE,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAC9C,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAChC,CAAC;QACF,OAAO,IAAI,cAAc,CAAC,UAAU,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7E,CAAC;CACF"}
|
|
@@ -11,8 +11,8 @@ export type ForgeConditionalRecipeDefinition = RecipeDefinition & Readonly<{
|
|
|
11
11
|
export declare class ForgeConditionalRecipe extends Recipe {
|
|
12
12
|
private readonly recipes;
|
|
13
13
|
constructor(recipes: WithConditions<RecipeHolder>[]);
|
|
14
|
-
getIngredients(): import("../../../
|
|
15
|
-
getResults(): import("../../../
|
|
14
|
+
getIngredients(): import("../../../index.js").Ingredient[];
|
|
15
|
+
getResults(): import("../../../index.js").Result[];
|
|
16
16
|
modify(modifier: RecipeModifier): ForgeConditionalRecipe;
|
|
17
17
|
serialize(context: RecipeParseContext): Partial<ForgeConditionalRecipeDefinition>;
|
|
18
18
|
additionalTypes(): `${string}:${string}`[];
|
|
@@ -4,17 +4,19 @@ import type { Ingredient } from "../../common/ingredient/index.js";
|
|
|
4
4
|
import type { Result } from "../../common/result/index.js";
|
|
5
5
|
import type { PackContext } from "../../loader/context.js";
|
|
6
6
|
import type { RecipeDefinition } from "../../schema/data/recipe.js";
|
|
7
|
+
import type { WithSerializerModules } from "../../serializer/module.js";
|
|
7
8
|
export type Replacer<T> = (value: T) => T;
|
|
8
9
|
export declare function createReplacer<T>(from: Predicate<T>, to: T): Replacer<T>;
|
|
9
10
|
export type RecipeModifier = {
|
|
10
11
|
result: Replacer<Result>;
|
|
11
12
|
ingredient: Replacer<Ingredient>;
|
|
12
13
|
};
|
|
13
|
-
export declare class RecipeHolder {
|
|
14
|
+
export declare class RecipeHolder implements WithSerializerModules {
|
|
14
15
|
private readonly definition;
|
|
15
16
|
private readonly recipe;
|
|
17
|
+
private readonly modules?;
|
|
16
18
|
private readonly type;
|
|
17
|
-
constructor(definition: RecipeDefinition, recipe: Recipe);
|
|
19
|
+
constructor(definition: RecipeDefinition, recipe: Recipe, modules?: WithSerializerModules | undefined);
|
|
18
20
|
serialize(context: RecipeParseContext): {
|
|
19
21
|
type: import("@adeficior/data-modifier/generated").RecipeSerializerId;
|
|
20
22
|
conditions?: import("../../index.js").ForgeCondition[];
|
|
@@ -26,6 +28,8 @@ export declare class RecipeHolder {
|
|
|
26
28
|
replaceIngredient(replace: Replacer<Ingredient>): RecipeHolder;
|
|
27
29
|
replaceResult(replace: Replacer<Result>): RecipeHolder;
|
|
28
30
|
getTypes(): NormalizedId[];
|
|
31
|
+
ingredientModules(): Record<string, import("../../serializer/module.js").SerializerModule<Ingredient, unknown>>;
|
|
32
|
+
resultModules(): Record<string, import("../../serializer/module.js").SerializerModule<Result, unknown>>;
|
|
29
33
|
}
|
|
30
34
|
export declare abstract class Recipe {
|
|
31
35
|
abstract getIngredients(): Ingredient[];
|
|
@@ -41,6 +45,8 @@ export type RecipeSerializer = {
|
|
|
41
45
|
export type RecipeParseContext = Pick<PackContext, "ingredients" | "results"> & {
|
|
42
46
|
recipes: RecipeSerializer;
|
|
43
47
|
};
|
|
44
|
-
export default abstract class RecipeParser<TDefinition extends RecipeDefinition, TRecipe extends Recipe> {
|
|
48
|
+
export default abstract class RecipeParser<TDefinition extends RecipeDefinition = RecipeDefinition, TRecipe extends Recipe = Recipe> implements WithSerializerModules {
|
|
49
|
+
ingredientModules(): {};
|
|
50
|
+
resultModules(): {};
|
|
45
51
|
abstract deserialize(definition: TDefinition, context: RecipeParseContext): TRecipe;
|
|
46
52
|
}
|
|
@@ -12,10 +12,12 @@ function keep() {
|
|
|
12
12
|
export class RecipeHolder {
|
|
13
13
|
definition;
|
|
14
14
|
recipe;
|
|
15
|
+
modules;
|
|
15
16
|
type;
|
|
16
|
-
constructor(definition, recipe) {
|
|
17
|
+
constructor(definition, recipe, modules) {
|
|
17
18
|
this.definition = definition;
|
|
18
19
|
this.recipe = recipe;
|
|
20
|
+
this.modules = modules;
|
|
19
21
|
this.type = encodeId(definition.type);
|
|
20
22
|
}
|
|
21
23
|
serialize(context) {
|
|
@@ -32,7 +34,7 @@ export class RecipeHolder {
|
|
|
32
34
|
}
|
|
33
35
|
modify(modifier) {
|
|
34
36
|
const modified = this.recipe.modify(modifier);
|
|
35
|
-
return new RecipeHolder(this.definition, modified);
|
|
37
|
+
return new RecipeHolder(this.definition, modified, this.modules);
|
|
36
38
|
}
|
|
37
39
|
replaceIngredient(replace) {
|
|
38
40
|
return this.modify({
|
|
@@ -49,6 +51,13 @@ export class RecipeHolder {
|
|
|
49
51
|
getTypes() {
|
|
50
52
|
return [this.type, ...this.recipe.additionalTypes()];
|
|
51
53
|
}
|
|
54
|
+
ingredientModules() {
|
|
55
|
+
return this.modules?.ingredientModules() ?? {};
|
|
56
|
+
}
|
|
57
|
+
resultModules() {
|
|
58
|
+
// TODO this will not work with custom recipes, serialize needs to be done by RecipeParser
|
|
59
|
+
return this.modules?.resultModules() ?? {};
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
62
|
export class Recipe {
|
|
54
63
|
additionalTypes() {
|
|
@@ -56,5 +65,11 @@ export class Recipe {
|
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
67
|
export default class RecipeParser {
|
|
68
|
+
ingredientModules() {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
resultModules() {
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
59
74
|
}
|
|
60
75
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/parser/recipe/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAqB,MA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C;IAED,iBAAiB,CAAC,OAA6B;QAC7C,OAAO,IAAI,CAAC,MAAM,CAAC;YACjB,UAAU,EAAE,OAAO;YACnB,MAAM,EAAE,IAAI,EAAE;SACf,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,OAAyB;QACrC,OAAO,IAAI,CAAC,MAAM,CAAC;YACjB,UAAU,EAAE,IAAI,EAAE;YAClB,MAAM,EAAE,OAAO;SAChB,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;IACjD,CAAC;IAED,aAAa;QACX,0FAA0F;QAC1F,OAAO,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IAC7C,CAAC;CACF;AAED,MAAM,OAAgB,MAAM;IAO1B,eAAe;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;CAGF;AAcD,MAAM,CAAC,OAAO,OAAgB,YAAY;IAIxC,iBAAiB;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,aAAa;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;CAMF"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Replacer } from ".";
|
|
2
2
|
import type { Ingredient } from "../../common/ingredient";
|
|
3
3
|
export type IngredientMapInput = Record<string, unknown>;
|
|
4
4
|
export declare class IngredientMap {
|
|
5
|
-
|
|
5
|
+
readonly ingredients: Record<string, Ingredient>;
|
|
6
6
|
constructor(ingredients: Record<string, Ingredient>);
|
|
7
7
|
list(): Ingredient[];
|
|
8
8
|
replace(replace: Replacer<Ingredient>): IngredientMap;
|
|
9
|
-
serialize(context: RecipeParseContext): {
|
|
10
|
-
[x: string]: unknown;
|
|
11
|
-
};
|
|
12
9
|
}
|
|
@@ -10,8 +10,5 @@ export class IngredientMap {
|
|
|
10
10
|
replace(replace) {
|
|
11
11
|
return new IngredientMap(mapValues(this.ingredients, replace));
|
|
12
12
|
}
|
|
13
|
-
serialize(context) {
|
|
14
|
-
return mapValues(this.ingredients, (it) => context.ingredients.serialize(it));
|
|
15
|
-
}
|
|
16
13
|
}
|
|
17
14
|
//# sourceMappingURL=ingredientMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingredientMap.js","sourceRoot":"","sources":["../../../src/parser/recipe/ingredientMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAMtC,MAAM,OAAO,aAAa;
|
|
1
|
+
{"version":3,"file":"ingredientMap.js","sourceRoot":"","sources":["../../../src/parser/recipe/ingredientMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAMtC,MAAM,OAAO,aAAa;IACI;IAA5B,YAA4B,WAAuC;QAAvC,gBAAW,GAAX,WAAW,CAA4B;IAAG,CAAC;IAEvE,IAAI;QACF,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,OAA6B;QACnC,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -20,5 +20,8 @@ export declare class ThermalRecipe extends Recipe {
|
|
|
20
20
|
serialize(context: RecipeParseContext): Partial<ThermalRecipeDefinition>;
|
|
21
21
|
}
|
|
22
22
|
export declare class ThermalRecipeParser extends RecipeParser<ThermalRecipeDefinition, ThermalRecipe> {
|
|
23
|
+
ingredientModules(): {
|
|
24
|
+
15: import("../../../serializer/module.js").SerializerModule<Ingredient, unknown>;
|
|
25
|
+
};
|
|
23
26
|
deserialize(definition: ThermalRecipeDefinition, context: RecipeParseContext): ThermalRecipe;
|
|
24
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IllegalShapeError } from "../../../error.js";
|
|
2
2
|
import RecipeParser, { Recipe } from "../index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ingredientSerializerModules } from "./module.js";
|
|
4
4
|
export class ThermalRecipe extends Recipe {
|
|
5
5
|
ingredients;
|
|
6
6
|
results;
|
|
@@ -32,14 +32,16 @@ export class ThermalRecipe extends Recipe {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
export class ThermalRecipeParser extends RecipeParser {
|
|
35
|
+
ingredientModules() {
|
|
36
|
+
return ingredientSerializerModules;
|
|
37
|
+
}
|
|
35
38
|
deserialize(definition, context) {
|
|
36
|
-
// TODO map from and to thermals shape
|
|
37
39
|
const rawIngredients = definition.ingredient
|
|
38
40
|
? [definition.ingredient]
|
|
39
41
|
: (definition.ingredients ?? []);
|
|
40
42
|
if (rawIngredients.length === 0)
|
|
41
43
|
throw new IllegalShapeError("ingredients missing or empty", definition);
|
|
42
|
-
const ingredients =
|
|
44
|
+
const ingredients = context.ingredients.deserializeList(rawIngredients);
|
|
43
45
|
const results = Array.isArray(definition.result)
|
|
44
46
|
? context.results.deserializeList(definition.result)
|
|
45
47
|
: [context.results.deserialize(definition.result)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/parser/recipe/thermal/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/parser/recipe/thermal/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,YAAY,EAAE,EA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AAc,GAAG,UAAU,CAAC,UAAU;YAC1C,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;YACzB,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QAEnC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;YAC7B,MAAM,IAAI,iBAAiB,CAAC,8BAA8B,EAAE,UAAU,CAAC,CAAC;QAE1E,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAExE,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YAC9C,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC;YACpD,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAErD,OAAO,IAAI,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { AmountSchema, CountSchema } from "../../../common/fields.js";
|
|
3
|
+
import { IdSchema } from "../../../common/id.js";
|
|
4
|
+
import { FluidTagIngredient, ItemIngredient, ItemTagIngredient, ListIngredient, } from "../../../common/ingredient";
|
|
5
|
+
import { isObjectWith } from "../../../serializer/checks.js";
|
|
6
|
+
import { createSerializerModule } from "../../../serializer/module.js";
|
|
7
|
+
const ThermalFluidTagSchema = z.object({
|
|
8
|
+
fluid_tag: IdSchema,
|
|
9
|
+
amount: AmountSchema,
|
|
10
|
+
});
|
|
11
|
+
const ThermalItemEntry = z.object({
|
|
12
|
+
item: IdSchema,
|
|
13
|
+
});
|
|
14
|
+
const ThermalTagEntry = z.object({
|
|
15
|
+
tag: IdSchema,
|
|
16
|
+
});
|
|
17
|
+
const ThermalIngredientEntry = ThermalItemEntry.or(ThermalTagEntry);
|
|
18
|
+
const ThermalIngredientList = z.object({
|
|
19
|
+
value: z.array(ThermalIngredientEntry),
|
|
20
|
+
count: CountSchema,
|
|
21
|
+
});
|
|
22
|
+
const ingredientSerializer15 = createSerializerModule((builder) => {
|
|
23
|
+
builder.deserializer(isObjectWith("value"), (input) => {
|
|
24
|
+
const { value, count } = ThermalIngredientList.parse(input);
|
|
25
|
+
return new ListIngredient(value.map((it) => {
|
|
26
|
+
if ("item" in it)
|
|
27
|
+
return new ItemIngredient(it.item, count);
|
|
28
|
+
return new ItemTagIngredient(it.tag, count);
|
|
29
|
+
}));
|
|
30
|
+
});
|
|
31
|
+
builder.register(FluidTagIngredient, isObjectWith("fluid_tag"), ThermalFluidTagSchema, ({ fluid_tag, amount }) => new FluidTagIngredient(fluid_tag, amount), ({ tag, amount }) => ({ fluid_tag: tag, amount }));
|
|
32
|
+
});
|
|
33
|
+
export const ingredientSerializerModules = {
|
|
34
|
+
15: ingredientSerializer15,
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../src/parser/recipe/thermal/module.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,cAAc,GAEf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,SAAS,EAAE,QAAQ;IACnB,MAAM,EAAE,YAAY;CACrB,CAAC,CAAC;AAEH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EAAE,MAAM,EAAE,CAAC,CAClD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,EAAE,EAAE,sBAAsB;CAC3B,CAAC"}
|
|
@@ -12,7 +12,7 @@ export declare class ShapedRecipe extends Recipe {
|
|
|
12
12
|
private readonly ingredients;
|
|
13
13
|
private readonly result;
|
|
14
14
|
constructor(ingredients: IngredientMap, result: Result);
|
|
15
|
-
getIngredients(): import("../../../
|
|
15
|
+
getIngredients(): import("../../../index.js").Ingredient[];
|
|
16
16
|
getResults(): Result[];
|
|
17
17
|
modify(modifier: RecipeModifier): ShapedRecipe;
|
|
18
18
|
serialize(context: RecipeParseContext): Partial<ShapedRecipeDefinition>;
|
|
@@ -18,14 +18,14 @@ export class ShapedRecipe extends Recipe {
|
|
|
18
18
|
}
|
|
19
19
|
serialize(context) {
|
|
20
20
|
return {
|
|
21
|
-
key:
|
|
21
|
+
key: context.ingredients.serializeIngredientMap(this.ingredients),
|
|
22
22
|
result: context.results.serialize(this.result),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
export class ShapedParser extends RecipeParser {
|
|
27
27
|
deserialize(definition, context) {
|
|
28
|
-
const ingredients = context.ingredients.
|
|
28
|
+
const ingredients = context.ingredients.deserializeIngredientMap(definition.key);
|
|
29
29
|
const result = context.results.deserialize(definition.result);
|
|
30
30
|
return new ShapedRecipe(ingredients, result);
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaped.js","sourceRoot":"","sources":["../../../../src/parser/recipe/vanilla/shaped.ts"],"names":[],"mappings":"AAGA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUnD,MAAM,OAAO,YAAa,SAAQ,MAAM;IAEnB;IACA;IAFnB,YACmB,WAA0B,EAC1B,MAAc;QAE/B,KAAK,EAAE,CAAC;QAHS,gBAAW,GAAX,WAAW,CAAe;QA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,CAAC,WAAW,CAAC;YACjE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;SAC/C,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,YAGjC;IACC,WAAW,CACT,UAAkC,EAClC,OAA2B;QAE3B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,wBAAwB,CAC9D,UAAU,CAAC,GAAG,CACf,CAAC;QACF,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC9D,OAAO,IAAI,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function isObjectWith(property) {
|
|
2
|
+
return (input) => input !== undefined &&
|
|
3
|
+
input !== null &&
|
|
4
|
+
typeof input === "object" &&
|
|
5
|
+
property in input;
|
|
6
|
+
}
|
|
7
|
+
export function hasType(type) {
|
|
8
|
+
const hasType = isObjectWith("type");
|
|
9
|
+
return (input) => {
|
|
10
|
+
return hasType(input) && input.type === type;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src/serializer/checks.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,OAAO,CAAC,KAAc,EAAoC,EAAE,CAC1D,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,QAAQ,IAAI,KAAK,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACrC,OAAO,CAAC,KAAc,EAAoC,EAAE;QAC1D,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SerializerModule } from "./module";
|
|
2
|
+
export interface Serializer<Out, S extends Serializer<Out, S>> {
|
|
3
|
+
serialize(output: Out): unknown;
|
|
4
|
+
serializeList(outputs: Out[]): unknown[];
|
|
5
|
+
serializeOptional(output: Out | undefined): unknown;
|
|
6
|
+
deserialize(input: unknown): Out;
|
|
7
|
+
deserializeOptional(input: unknown): Out | undefined;
|
|
8
|
+
deserializeList(input: unknown[]): Out[];
|
|
9
|
+
validated<T extends Out>(output: T): T;
|
|
10
|
+
withModule(module: SerializerModule<Out>): S;
|
|
11
|
+
selectModule(module: Record<string, SerializerModule<Out, unknown>>): S;
|
|
12
|
+
}
|
|
13
|
+
export declare abstract class AbstractSerializer<Out, S extends Serializer<Out, S>> implements Serializer<Out, S> {
|
|
14
|
+
abstract serialize(output: Out): unknown;
|
|
15
|
+
abstract deserialize(input: unknown): Out;
|
|
16
|
+
abstract withModule(module: SerializerModule<Out, unknown>): S;
|
|
17
|
+
abstract selectModule(modules: Record<string, SerializerModule<Out, unknown>>): S;
|
|
18
|
+
abstract validated<T extends Out>(output: T): T;
|
|
19
|
+
serializeList(outputs: Out[]): unknown[];
|
|
20
|
+
serializeOptional(output: Out | undefined): unknown;
|
|
21
|
+
deserializeOptional(input: unknown): Out | undefined;
|
|
22
|
+
deserializeList(input: unknown[]): Out[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class AbstractSerializer {
|
|
2
|
+
serializeList(outputs) {
|
|
3
|
+
return outputs.map((it) => this.serialize(it));
|
|
4
|
+
}
|
|
5
|
+
serializeOptional(output) {
|
|
6
|
+
if (output === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
return this.serialize(output);
|
|
9
|
+
}
|
|
10
|
+
deserializeOptional(input) {
|
|
11
|
+
if (input === undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
return this.deserialize(input);
|
|
14
|
+
}
|
|
15
|
+
deserializeList(input) {
|
|
16
|
+
return input.map((it) => this.deserialize(it));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/serializer/index.ts"],"names":[],"mappings":"AAiBA,MAAM,OAAgB,kBAAkB;IAetC,aAAa,CAAC,OAAc;QAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,iBAAiB,CAAC,MAAuB;QACvC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,mBAAmB,CAAC,KAAc;QAChC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC1C,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,eAAe,CAAC,KAAgB;QAC9B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { mapValues } from "lodash-es";
|
|
2
1
|
import z from "zod";
|
|
3
|
-
import { BlockIngredient, BlockTagIngredient, FluidIngredient, FluidTagIngredient,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return new ItemTagIngredient(input);
|
|
12
|
-
}
|
|
13
|
-
return new ItemIngredient(input);
|
|
14
|
-
});
|
|
15
|
-
builder.serializer(ListIngredient, (it, serialize) => it.entries.flatMap(serialize));
|
|
16
|
-
builder.deserializer(Array.isArray, (it, deserialize) => new ListIngredient(it.map(deserialize)));
|
|
2
|
+
import { BlockIngredient, BlockTagIngredient, FluidIngredient, FluidTagIngredient, ItemIngredient, ItemTagIngredient, ToolActionIngredient, } from "../../";
|
|
3
|
+
import { AmountSchema, CountSchema } from "../../common/fields";
|
|
4
|
+
import { IdSchema, stripTag } from "../../common/id";
|
|
5
|
+
import { hasType, isObjectWith } from "../checks";
|
|
6
|
+
import { createSerializerModule } from "../module";
|
|
7
|
+
import commonSerialization from "./common";
|
|
8
|
+
export const serializer15 = createSerializerModule((builder) => {
|
|
9
|
+
commonSerialization(builder);
|
|
17
10
|
const toolActionType = "farmersdelight:tool_action";
|
|
18
11
|
builder.register(ToolActionIngredient, hasType(toolActionType), z.object({
|
|
19
12
|
type: z.literal(toolActionType),
|
|
@@ -43,14 +36,4 @@ const serializer15 = createSerializer((builder) => {
|
|
|
43
36
|
block: IdSchema,
|
|
44
37
|
}), (it) => new BlockIngredient(it.block), ({ id }) => ({ block: id }));
|
|
45
38
|
});
|
|
46
|
-
|
|
47
|
-
constructor(packFormat, lookup) {
|
|
48
|
-
super(packFormat, lookup, Ingredient, {
|
|
49
|
-
15: serializer15,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
ingredientMap(input) {
|
|
53
|
-
return new IngredientMap(mapValues(input, (it) => this.deserialize(it)));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=serializer.js.map
|
|
39
|
+
//# sourceMappingURL=15.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"15.js","sourceRoot":"","sources":["../../../src/serializer/ingredients/15.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf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EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,CAC7C,CAAC;IAEF,OAAO,CAAC,QAAQ,CACd,eAAe,EACf,YAAY,CAAC,OAAO,CAAC,EACrB,CAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,YAAY;KACrB,CAAC,EACF,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,EAChD,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,CAC9C,CAAC;IAEF,OAAO,CAAC,QAAQ,CACd,eAAe,EACf,YAAY,CAAC,OAAO,CAAC,EACrB,CAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,QAAQ;KAChB,CAAC,EACF,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,CAAC,KAAK,CAAC,EACrC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAC5B,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { FluidIngredient, FluidTagIngredient, IgnoredIngredient, ItemIngredient, ItemTagIngredient, ListIngredient, ToolActionIngredient, } from "../../";
|
|
3
|
+
import { AmountSchema, CountSchema } from "../../common/fields";
|
|
4
|
+
import { IdSchema, stripTag } from "../../common/id";
|
|
5
|
+
import { hasType, isObjectWith } from "../checks";
|
|
6
|
+
import { createSerializerModule } from "../module";
|
|
7
|
+
import commonSerialization from "./common";
|
|
8
|
+
export const serializer44 = createSerializerModule((builder) => {
|
|
9
|
+
commonSerialization(builder);
|
|
10
|
+
// Do I also need to serialize as this?
|
|
11
|
+
builder.deserializer(hasType("neoforge:compound"), (it, deserialize) => {
|
|
12
|
+
const { ingredients } = z
|
|
13
|
+
.object({
|
|
14
|
+
ingredients: z.array(z.any()),
|
|
15
|
+
})
|
|
16
|
+
.parse(it);
|
|
17
|
+
return new ListIngredient(ingredients.map(deserialize));
|
|
18
|
+
});
|
|
19
|
+
const toolActionType = "farmersdelight:tool_action";
|
|
20
|
+
builder.register(ToolActionIngredient, hasType(toolActionType), z.object({
|
|
21
|
+
type: z.literal(toolActionType),
|
|
22
|
+
action: z.string().nonempty(),
|
|
23
|
+
}), (it) => new ToolActionIngredient(it.action), ({ action }) => ({ action, type: toolActionType }));
|
|
24
|
+
builder.register(ItemTagIngredient, isObjectWith("tag"), z.object({
|
|
25
|
+
tag: IdSchema,
|
|
26
|
+
count: CountSchema,
|
|
27
|
+
}), (it) => new ItemTagIngredient(it.tag, it.count), ({ count, tag }) => ({ tag: stripTag(tag), count }));
|
|
28
|
+
builder.register(FluidTagIngredient, isObjectWith("fluidTag"), z.object({
|
|
29
|
+
fluidTag: IdSchema,
|
|
30
|
+
amount: AmountSchema,
|
|
31
|
+
}), (it) => new FluidTagIngredient(it.fluidTag, it.amount), ({ amount, tag }) => ({ fluidTag: stripTag(tag), amount }));
|
|
32
|
+
builder.register(ItemIngredient, isObjectWith("item"), z.object({
|
|
33
|
+
item: IdSchema,
|
|
34
|
+
count: CountSchema,
|
|
35
|
+
}), (it) => new ItemIngredient(it.item, it.count), ({ id, ...rest }) => ({ item: id, ...rest }));
|
|
36
|
+
// TODO "type": "neoforge:single",
|
|
37
|
+
builder.register(FluidIngredient, isObjectWith("fluid"), z.object({
|
|
38
|
+
fluid: IdSchema,
|
|
39
|
+
amount: AmountSchema,
|
|
40
|
+
}), (it) => new FluidIngredient(it.fluid, it.amount), ({ id, ...rest }) => ({ fluid: id, ...rest }));
|
|
41
|
+
// TODO add support for these?
|
|
42
|
+
builder.deserializer(hasType("neoforge:components"), (it) => new IgnoredIngredient(it));
|
|
43
|
+
builder.deserializer(hasType("neoforge:intersection"), (it) => new IgnoredIngredient(it));
|
|
44
|
+
builder.deserializer(hasType("neoforge:difference"), (it) => new IgnoredIngredient(it));
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=44.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"44.js","sourceRoot":"","sources":["../../../src/serializer/ingredients/44.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EAEjB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,oBAAoB,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,mBAAmB,MAAM,UAAU,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAa,CAAC,OAAO,EAAE,EAAE;IACzE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAE7B,uCAAuC;IACvC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE;QACrE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC;aACtB,MAAM,CAAC;YACN,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;SAC9B,CAAC;aACD,KAAK,CAAC,EAAE,CAAC,CAAC;QAEb,OAAO,IAAI,cAAc,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,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C,IAAI,iBAAiB,CAAC,EAAE,CAAC,CAClC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IgnoredIngredient, ItemIngredient, ItemTagIngredient, ListIngredient, } from "../../";
|
|
2
|
+
export default function commonSerialization(builder) {
|
|
3
|
+
builder.deserializer((it) => typeof it === "string", (input) => {
|
|
4
|
+
if (input.startsWith("#")) {
|
|
5
|
+
return new ItemTagIngredient(input);
|
|
6
|
+
}
|
|
7
|
+
return new ItemIngredient(input);
|
|
8
|
+
});
|
|
9
|
+
builder.serializer(ListIngredient, (it, serialize) => it.entries.flatMap(serialize));
|
|
10
|
+
builder.deserializer(Array.isArray, (it, deserialize) => new ListIngredient(it.map(deserialize)));
|
|
11
|
+
builder.serializer(IgnoredIngredient, (it) => it.raw);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/serializer/ingredients/common.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,cAAc,EACd,iBAAiB,EACjB,cAAc,GACf,MAAM,QAAQ,CAAC;AAGhB,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,OAAsC;IAEtC,OAAO,CAAC,YAAY,CAClB,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,EAC9B,CAAC,KAAK,EAAE,EAAE;QACR,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,CACF,CAAC;IAEF,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,CACnD,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAC9B,CAAC;IAEF,OAAO,CAAC,YAAY,CAClB,KAAK,CAAC,OAAO,EACb,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAC7D,CAAC;IAEF,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Serializer } from "..";
|
|
2
|
+
import { Ingredient } from "../../common/ingredient";
|
|
3
|
+
import type RegistryLookup from "../../loader/registry";
|
|
4
|
+
import type { SemVerInput } from "../../packFormat";
|
|
5
|
+
import { IngredientMap, type IngredientMapInput } from "../../parser/recipe/ingredientMap";
|
|
6
|
+
import type { SerializerModule } from "../module";
|
|
7
|
+
import { VersionedSerializer } from "../versioned";
|
|
8
|
+
export interface IngredientSerializer extends Serializer<Ingredient, IngredientSerializer> {
|
|
9
|
+
deserializeIngredientMap(input: IngredientMapInput): IngredientMap;
|
|
10
|
+
serializeIngredientMap(map: IngredientMap): IngredientMapInput;
|
|
11
|
+
}
|
|
12
|
+
export declare class IngredientSerializerImpl extends VersionedSerializer<Ingredient, IngredientSerializer> implements IngredientSerializer {
|
|
13
|
+
constructor(packFormat: SemVerInput, lookup: RegistryLookup);
|
|
14
|
+
deserializeIngredientMap(input: IngredientMapInput): IngredientMap;
|
|
15
|
+
serializeIngredientMap(map: IngredientMap): {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
withModule(module: SerializerModule<Ingredient>): IngredientSerializer;
|
|
19
|
+
}
|
|
20
|
+
export declare function createIngredientSerializer(packFormat: SemVerInput, lookup: RegistryLookup): IngredientSerializer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { mapValues } from "lodash-es";
|
|
2
|
+
import { Ingredient } from "../../common/ingredient";
|
|
3
|
+
import { IngredientMap, } from "../../parser/recipe/ingredientMap";
|
|
4
|
+
import { VersionedSerializer } from "../versioned";
|
|
5
|
+
import { WrapperSerializer } from "../wrapped";
|
|
6
|
+
import { serializer15 } from "./15";
|
|
7
|
+
import { serializer44 } from "./44";
|
|
8
|
+
export class IngredientSerializerImpl extends VersionedSerializer {
|
|
9
|
+
constructor(packFormat, lookup) {
|
|
10
|
+
super(packFormat, lookup, Ingredient, {
|
|
11
|
+
15: serializer15,
|
|
12
|
+
44: serializer44,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
deserializeIngredientMap(input) {
|
|
16
|
+
return new IngredientMap(mapValues(input, (it) => this.deserialize(it)));
|
|
17
|
+
}
|
|
18
|
+
serializeIngredientMap(map) {
|
|
19
|
+
return mapValues(map.ingredients, (it) => this.serialize(it));
|
|
20
|
+
}
|
|
21
|
+
withModule(module) {
|
|
22
|
+
return new WrappedIngredientSerializer(this, module);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class WrappedIngredientSerializer extends WrapperSerializer {
|
|
26
|
+
deserializeIngredientMap(input) {
|
|
27
|
+
return this.serializer.deserializeIngredientMap(input);
|
|
28
|
+
}
|
|
29
|
+
serializeIngredientMap(map) {
|
|
30
|
+
return this.serializer.serializeIngredientMap(map);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function createIngredientSerializer(packFormat, lookup) {
|
|
34
|
+
return new IngredientSerializerImpl(packFormat, lookup);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/serializer/ingredients/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EACL,aAAa,GAEd,MAAM,mCAAmC,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