@adeficior/data-modifier-recipes 2.0.2 → 2.1.0
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/emitter.d.ts +13 -26
- package/dist/emitter.js +32 -75
- package/dist/emitter.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +2 -2
- package/dist/loader.js +2 -2
- package/dist/loader.js.map +1 -1
- package/dist/module.d.ts +2 -0
- package/dist/module.js +11 -8
- package/dist/module.js.map +1 -1
- package/dist/rule.d.ts +33 -14
- package/dist/rule.js +54 -22
- package/dist/rule.js.map +1 -1
- package/dist/schema.d.ts +2 -1
- package/dist/schema.js +6 -7
- package/dist/schema.js.map +1 -1
- package/dist/serializer/holder.d.ts +26 -1
- package/dist/serializer/holder.js +37 -0
- package/dist/serializer/holder.js.map +1 -1
- package/dist/serializer/impl.js +4 -1
- package/dist/serializer/impl.js.map +1 -1
- package/dist/serializer/index.d.ts +1 -1
- package/dist/serializer/index.js +1 -1
- package/dist/serializer/index.js.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/mocks.d.ts +3 -0
- package/dist/testing/mocks.js +7 -0
- package/dist/testing/mocks.js.map +1 -0
- package/dist/testing/setup.js +5 -3
- package/dist/testing/setup.js.map +1 -1
- package/package.json +5 -5
package/dist/emitter.d.ts
CHANGED
|
@@ -1,46 +1,33 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { Conditions, IdInput, NormalizedId, RegistryProvider, SemVerInput } from "@adeficior/data-modifier-core";
|
|
2
|
+
import { SimpleEmitter } from "@adeficior/data-modifier-core";
|
|
3
3
|
import type { IngredientFilter, IngredientInput, IngredientSerializer, Predicates, ResultInput, ResultSerializer } from "@adeficior/data-modifier-ingredients";
|
|
4
4
|
import type { RecipeSerializerId } from "@adeficior/data-modifier/generated";
|
|
5
5
|
import type { Logger } from "@adeficior/pack-resolver";
|
|
6
6
|
import type { Recipe } from "./model";
|
|
7
|
+
import type { RecipeFilter, RecipeRules } from "./rule";
|
|
7
8
|
import type { RecipeDefinition } from "./schema";
|
|
8
9
|
import type { RecipesSerializer } from "./serializer/abstract";
|
|
9
10
|
import { RecipeHolder } from "./serializer/holder";
|
|
10
|
-
export type RecipeTest = Readonly<{
|
|
11
|
-
id?: CommonFilter<NormalizedId>;
|
|
12
|
-
type?: CommonFilter<NormalizedId<RecipeSerializerId>>;
|
|
13
|
-
namespace?: string;
|
|
14
|
-
output?: IngredientFilter;
|
|
15
|
-
input?: IngredientFilter;
|
|
16
|
-
}>;
|
|
17
11
|
export type RecipeEmitter = {
|
|
18
|
-
replaceResult(
|
|
19
|
-
replaceIngredient(
|
|
12
|
+
replaceResult(filter: IngredientFilter, value: ResultInput, additionalFilters?: RecipeFilter): void;
|
|
13
|
+
replaceIngredient(filter: IngredientFilter, value: IngredientInput, additionalFilters?: RecipeFilter): void;
|
|
20
14
|
add(id: IdInput, value: RecipeDefinition): NormalizedId;
|
|
21
15
|
add(id: IdInput, type: IdInput<RecipeSerializerId>, value: Recipe, conditions?: Conditions): NormalizedId;
|
|
22
|
-
remove(
|
|
16
|
+
remove(filter: RecipeFilter): void;
|
|
23
17
|
};
|
|
24
18
|
export declare const EMPTY_RECIPE: RecipeDefinition;
|
|
25
|
-
export declare class RecipeEmitterImpl implements RecipeEmitter
|
|
19
|
+
export declare class RecipeEmitterImpl extends SimpleEmitter<RecipeHolder, RecipeDefinition> implements RecipeEmitter {
|
|
26
20
|
private readonly logger;
|
|
27
21
|
private readonly packFormat;
|
|
28
|
-
private readonly registry;
|
|
29
22
|
private readonly resultSerializer;
|
|
30
23
|
private readonly ingredientSerializer;
|
|
31
24
|
private readonly predicates;
|
|
25
|
+
private readonly rules;
|
|
32
26
|
private readonly serializer;
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
constructor(logger: Logger, packFormat: SemVerInput, registry: RegistryProvider<RecipeHolder>, resultSerializer: ResultSerializer, ingredientSerializer: IngredientSerializer, predicates: Predicates, serializer: RecipesSerializer);
|
|
36
|
-
resolver(context: LoaderContext): import("@adeficior/pack-resolver").Resolver<import("@adeficior/pack-resolver").Acceptable, import("@adeficior/pack-resolver").BaseContext>;
|
|
37
|
-
private createIngredientPredicate;
|
|
38
|
-
private createResultPredicate;
|
|
39
|
-
private resolveRecipeTest;
|
|
27
|
+
constructor(logger: Logger, packFormat: SemVerInput, registry: RegistryProvider<RecipeHolder>, resultSerializer: ResultSerializer, ingredientSerializer: IngredientSerializer, predicates: Predicates, rules: RecipeRules, serializer: RecipesSerializer);
|
|
28
|
+
private addHolder;
|
|
40
29
|
add(id: IdInput, arg: RecipeDefinition | IdInput<RecipeSerializerId>, arg2?: Recipe, conditions?: Conditions): NormalizedId;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
replaceIngredient(test: IngredientFilter, input: IngredientInput, additionalTest?: RecipeTest): void;
|
|
45
|
-
clear(): void;
|
|
30
|
+
remove(filter: RecipeFilter): void;
|
|
31
|
+
replaceResult(filter: IngredientFilter, input: ResultInput, additionalFilters?: RecipeFilter): void;
|
|
32
|
+
replaceIngredient(filter: IngredientFilter, input: IngredientInput, additionalFilters?: RecipeFilter): void;
|
|
46
33
|
}
|
package/dist/emitter.js
CHANGED
|
@@ -1,111 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createReplacer
|
|
3
|
-
import { combineResolvers, notNull } from "@adeficior/pack-resolver";
|
|
4
|
-
import { RecipeRule } from "./rule";
|
|
1
|
+
import { encodeId, SimpleEmitter, withDisabledConditions, } from "@adeficior/data-modifier-core";
|
|
2
|
+
import { createReplacer } from "@adeficior/data-modifier-core/serializer";
|
|
5
3
|
import { recipePath } from "./schema";
|
|
6
|
-
import { RecipeHolder } from "./serializer/holder";
|
|
4
|
+
import { createFakeHolder, RecipeHolder } from "./serializer/holder";
|
|
7
5
|
export const EMPTY_RECIPE = withDisabledConditions({
|
|
8
6
|
type: "minecraft:disabled",
|
|
9
7
|
});
|
|
10
|
-
export class RecipeEmitterImpl {
|
|
8
|
+
export class RecipeEmitterImpl extends SimpleEmitter {
|
|
11
9
|
logger;
|
|
12
10
|
packFormat;
|
|
13
|
-
registry;
|
|
14
11
|
resultSerializer;
|
|
15
12
|
ingredientSerializer;
|
|
16
13
|
predicates;
|
|
14
|
+
rules;
|
|
17
15
|
serializer;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
constructor(
|
|
21
|
-
// TODO inject
|
|
22
|
-
logger, packFormat, registry, resultSerializer, ingredientSerializer, predicates, serializer) {
|
|
16
|
+
constructor(logger, packFormat, registry, resultSerializer, ingredientSerializer, predicates, rules, serializer) {
|
|
17
|
+
super("recipes", registry, (it) => recipePath(this.packFormat, it), EMPTY_RECIPE, (it) => this.serializer.serialize(it));
|
|
23
18
|
this.logger = logger;
|
|
24
19
|
this.packFormat = packFormat;
|
|
25
|
-
this.registry = registry;
|
|
26
20
|
this.resultSerializer = resultSerializer;
|
|
27
21
|
this.ingredientSerializer = ingredientSerializer;
|
|
28
22
|
this.predicates = predicates;
|
|
23
|
+
this.rules = rules;
|
|
29
24
|
this.serializer = serializer;
|
|
30
|
-
this.ruled = new RuledEmitter(this.registry, (id) => recipePath(packFormat, id), EMPTY_RECIPE, (it) => this.serializer.serialize(it), (id) => this.custom.has(id));
|
|
31
25
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return this.predicates.ingredient(filter);
|
|
39
|
-
}
|
|
40
|
-
createResultPredicate(filter) {
|
|
41
|
-
if (!filter)
|
|
42
|
-
return () => true;
|
|
43
|
-
return this.predicates.result(filter);
|
|
44
|
-
}
|
|
45
|
-
resolveRecipeTest(test) {
|
|
46
|
-
const id = [];
|
|
47
|
-
const type = [];
|
|
48
|
-
const ingredient = [];
|
|
49
|
-
const result = [];
|
|
50
|
-
if (test.id)
|
|
51
|
-
id.push(resolveIdTest(test.id));
|
|
52
|
-
if (test.type)
|
|
53
|
-
type.push(resolveIdTest(test.type));
|
|
54
|
-
if (test.namespace)
|
|
55
|
-
id.push((id) => id.namespace === test.namespace);
|
|
56
|
-
if (test.output)
|
|
57
|
-
result.push(this.createResultPredicate(test.output));
|
|
58
|
-
if (test.input)
|
|
59
|
-
ingredient.push(this.createIngredientPredicate(test.input));
|
|
60
|
-
return { id, type, ingredient, result };
|
|
26
|
+
addHolder(id, holder) {
|
|
27
|
+
if (this.custom.has(id))
|
|
28
|
+
this.logger.error(`Overwriting custom recipe with ID ${encodeId(id)}`);
|
|
29
|
+
// TODO add to custom registry so recipe graph can use it
|
|
30
|
+
this.custom.add(id, holder);
|
|
31
|
+
return encodeId(id);
|
|
61
32
|
}
|
|
62
33
|
add(id, arg, arg2, conditions) {
|
|
63
34
|
if (typeof arg === "string" || "namespace" in arg) {
|
|
64
35
|
const holder = RecipeHolder.of(arg, arg2, conditions);
|
|
65
|
-
|
|
66
|
-
return this.add(id, serialized);
|
|
36
|
+
return this.addHolder(id, holder);
|
|
67
37
|
}
|
|
68
38
|
else {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// TODO add to custom registry so recipe graph can use it
|
|
73
|
-
this.custom.add(id, value);
|
|
74
|
-
return encodeId(id);
|
|
39
|
+
const definition = arg;
|
|
40
|
+
const holder = createFakeHolder(definition);
|
|
41
|
+
return this.addHolder(id, holder);
|
|
75
42
|
}
|
|
76
43
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this.ruled.addRule(new RecipeRule(context, recipePredicates.id, recipePredicates.type, [ingredientTests.ingredient, ...recipePredicates.ingredient].filter(notNull), [ingredientTests.result, ...recipePredicates.result].filter(notNull), modifier));
|
|
44
|
+
remove(filter) {
|
|
45
|
+
this.ruled.addRemoval(this.rules.resolve(filter), { filter });
|
|
80
46
|
}
|
|
81
|
-
|
|
82
|
-
this.addRule({ operation: "remove", test }, () => null, test);
|
|
83
|
-
}
|
|
84
|
-
replaceResult(test, input, additionalTest) {
|
|
85
|
-
const predicate = this.createResultPredicate(test);
|
|
47
|
+
replaceResult(filter, input, additionalFilters) {
|
|
86
48
|
const value = this.resultSerializer.deserialize(input);
|
|
87
|
-
const replace = createReplacer(
|
|
88
|
-
this.addRule({
|
|
49
|
+
const replace = createReplacer(this.predicates.result(filter), value);
|
|
50
|
+
this.ruled.addRule(this.rules.resolve(additionalFilters, { result: filter }), (recipe) => recipe.replaceResult(replace), {
|
|
89
51
|
operation: "replace result",
|
|
90
|
-
from:
|
|
52
|
+
from: filter,
|
|
91
53
|
to: value,
|
|
92
|
-
|
|
93
|
-
}
|
|
54
|
+
filter: additionalFilters,
|
|
55
|
+
});
|
|
94
56
|
}
|
|
95
|
-
replaceIngredient(
|
|
96
|
-
const predicate = this.createIngredientPredicate(test);
|
|
57
|
+
replaceIngredient(filter, input, additionalFilters) {
|
|
97
58
|
const value = this.ingredientSerializer.deserialize(input);
|
|
98
|
-
const replace = createReplacer(
|
|
99
|
-
this.addRule({
|
|
59
|
+
const replace = createReplacer(this.predicates.ingredient(filter), value);
|
|
60
|
+
this.ruled.addRule(this.rules.resolve(additionalFilters, { ingredient: filter }), (recipe) => recipe.replaceIngredient(replace), {
|
|
100
61
|
operation: "replace ingredient",
|
|
101
|
-
from:
|
|
62
|
+
from: filter,
|
|
102
63
|
to: value,
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
clear() {
|
|
107
|
-
this.custom.clear();
|
|
108
|
-
this.ruled.clear();
|
|
64
|
+
filter: additionalFilters,
|
|
65
|
+
});
|
|
109
66
|
}
|
|
110
67
|
}
|
|
111
68
|
//# sourceMappingURL=emitter.js.map
|
package/dist/emitter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../src/emitter.ts"],"names":[],"mappings":"
|
|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C,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EACzC;YACE,SAAS,EAAE,gBAAgB;YAC3B,IAAI,EAAE,MAAM;YACZ,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,iBAAiB;SAC1B,CACF,CAAC;IACJ,CAAC;IAED,iBAAiB,CACf,MAAwB,EACxB,KAAsB,EACtB,iBAAgC;QAEhC,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;QAE1E,IAAI,CAAC,KAAK,CAAC,OAAO,CAChB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,EAC7D,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAC7C;YACE,SAAS,EAAE,oBAAoB;YAC/B,IAAI,EAAE,MAAM;YACZ,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,iBAAiB;SAC1B,CACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { EMPTY_RECIPE, type RecipeEmitter
|
|
1
|
+
export { EMPTY_RECIPE, type RecipeEmitter } from "./emitter";
|
|
2
2
|
export type { VanillaRecipeHelper } from "./helper/vanilla";
|
|
3
3
|
export type * from "./hooks";
|
|
4
4
|
export type { RecipeLoader } from "./loader";
|
|
5
5
|
export type * from "./model";
|
|
6
6
|
export { default } from "./module";
|
|
7
|
+
export type { RecipeFilter, RecipeRules } from "./rule";
|
|
7
8
|
export * from "./schema";
|
|
8
9
|
export type { RecipesSerializer } from "./serializer/abstract";
|
|
9
10
|
export * from "./serializer/forge/conditional";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsB,MAAM,WAAW,CAAC;AAK7D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,cAAc,UAAU,CAAC;AAEzB,cAAc,gCAAgC,CAAC;AAE/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC"}
|
package/dist/loader.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConditionContext, RegistryProvider } from "@adeficior/data-modifier-core";
|
|
1
|
+
import type { ConditionContext, RegistryProvider, ResourceFolder } from "@adeficior/data-modifier-core";
|
|
2
2
|
import { JsonLoader } from "@adeficior/data-modifier-core";
|
|
3
3
|
import type { RecipeDefinition } from "./schema";
|
|
4
4
|
import type { RecipesSerializer } from "./serializer/abstract";
|
|
@@ -9,7 +9,7 @@ export type RecipeLoader = {
|
|
|
9
9
|
export declare class RecipeLoaderImpl extends JsonLoader<RecipeHolder> implements RecipeLoader {
|
|
10
10
|
private readonly serializer;
|
|
11
11
|
private readonly ignoredRecipeTypePatterns;
|
|
12
|
-
constructor(serializer: RecipesSerializer, context?: ConditionContext);
|
|
12
|
+
constructor(serializer: RecipesSerializer, folder: ResourceFolder, context?: ConditionContext);
|
|
13
13
|
ignoreType(pattern: string): void;
|
|
14
14
|
parse(definition: RecipeDefinition): RecipeHolder | null;
|
|
15
15
|
}
|
package/dist/loader.js
CHANGED
|
@@ -4,8 +4,8 @@ import { minimatch } from "minimatch";
|
|
|
4
4
|
export class RecipeLoaderImpl extends JsonLoader {
|
|
5
5
|
serializer;
|
|
6
6
|
ignoredRecipeTypePatterns = [];
|
|
7
|
-
constructor(serializer, context) {
|
|
8
|
-
super(context);
|
|
7
|
+
constructor(serializer, folder, context) {
|
|
8
|
+
super(folder, context);
|
|
9
9
|
this.serializer = serializer;
|
|
10
10
|
this.ignoreType("jeed:*");
|
|
11
11
|
}
|
package/dist/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAStC,MAAM,OAAO,gBACX,SAAQ,UAAwB;IAMb;IAHF,yBAAyB,GAAa,EAAE,CAAC;IAE1D,YACmB,UAA6B,EAC9C,MAAsB,EACtB,OAA0B;QAE1B,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAJN,eAAU,GAAV,UAAU,CAAmB;QAM9C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,UAAU,CAAC,OAAe;QACxB,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAEQ,KAAK,CAAC,UAA4B;QACzC,IACE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CACzC,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAC/B,EACD,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,CACxB,UAAU,EACV,MAAM,EACN,UAAU,EACV,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,CACtB,CAAC;QAEF,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEzD,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;CACF"}
|
package/dist/module.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { RecipeEmitter } from "./emitter";
|
|
|
2
2
|
import type { VanillaRecipeHelper } from "./helper/vanilla";
|
|
3
3
|
import type { RegisterRecipeSerializer } from "./hooks";
|
|
4
4
|
import type { RecipeLoader } from "./loader";
|
|
5
|
+
import type { RecipeRules } from "./rule";
|
|
5
6
|
import type { RecipesSerializer } from "./serializer/abstract";
|
|
6
7
|
declare const _default: import("@adeficior/data-modifier-core").ModuleConfig<{
|
|
7
8
|
hooks: {
|
|
@@ -15,6 +16,7 @@ declare const _default: import("@adeficior/data-modifier-core").ModuleConfig<{
|
|
|
15
16
|
};
|
|
16
17
|
services: {
|
|
17
18
|
"serializer:recipes": RecipesSerializer;
|
|
19
|
+
"rules:recipes": RecipeRules;
|
|
18
20
|
"helper:recipes:vanilla": VanillaRecipeHelper;
|
|
19
21
|
};
|
|
20
22
|
}>;
|
package/dist/module.js
CHANGED
|
@@ -3,7 +3,8 @@ import { name } from "../package.json";
|
|
|
3
3
|
import { RecipeEmitterImpl } from "./emitter";
|
|
4
4
|
import { VanillaRecipeHelperImpl } from "./helper/vanilla";
|
|
5
5
|
import { RecipeLoaderImpl } from "./loader";
|
|
6
|
-
import {
|
|
6
|
+
import { RecipeRulesImpl } from "./rule";
|
|
7
|
+
import { recipeFolder, recipePattern } from "./schema";
|
|
7
8
|
import { registerDefaultSerializers } from "./serializer/default";
|
|
8
9
|
import { RecipeSerializerImpl } from "./serializer/impl";
|
|
9
10
|
export default defineModule({
|
|
@@ -23,6 +24,7 @@ export default defineModule({
|
|
|
23
24
|
},
|
|
24
25
|
services: {
|
|
25
26
|
"serializer:recipes": "RecipesSerializer",
|
|
27
|
+
"rules:recipes": "RecipeRules",
|
|
26
28
|
"helper:recipes:vanilla": "VanillaRecipeHelper",
|
|
27
29
|
},
|
|
28
30
|
},
|
|
@@ -30,13 +32,14 @@ export default defineModule({
|
|
|
30
32
|
{ service: "emitter:recipes", key: "recipes" },
|
|
31
33
|
{ service: "helper:recipes:vanilla", key: "recipes.vanilla" },
|
|
32
34
|
],
|
|
33
|
-
setup: (
|
|
34
|
-
const serializer =
|
|
35
|
-
const loader =
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
setup: (instance) => {
|
|
36
|
+
const serializer = instance.service("serializer:recipes", (container) => new RecipeSerializerImpl(container.get("serializer:results"), container.get("serializer:ingredients")));
|
|
37
|
+
const loader = instance.loader("recipes", () => new RecipeLoaderImpl(serializer(), recipeFolder(instance.options.packFormat)), recipePattern(instance.options.packFormat));
|
|
38
|
+
const rules = instance.service("rules:recipes", (container) => new RecipeRulesImpl(container.get("predicates")));
|
|
39
|
+
const emitter = instance.emitter("recipes", (container) => new RecipeEmitterImpl(container.get("logger"), instance.options.packFormat, loader(), container.get("serializer:results"), container.get("serializer:ingredients"), container.get("predicates"), rules(), serializer()));
|
|
40
|
+
instance.service("helper:recipes:vanilla", (container) => new VanillaRecipeHelperImpl(emitter(), container.get("serializer:ingredients"), container.get("serializer:results")));
|
|
41
|
+
instance.hook("recipes:register-serializer", registerDefaultSerializers);
|
|
42
|
+
instance.hook("setup:after", ({ callHook }) => {
|
|
40
43
|
callHook("recipes:register-serializer", serializer().createEvent());
|
|
41
44
|
});
|
|
42
45
|
},
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAA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CAAC,aAAa,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC5C,QAAQ,CAAC,6BAA6B,EAAE,UAAU,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
package/dist/rule.d.ts
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
import type { Id,
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { ContextLike, Logger } from "@adeficior/pack-resolver";
|
|
1
|
+
import type { Id, NormalizedId, Rule } from "@adeficior/data-modifier-core";
|
|
2
|
+
import type { CommonFilter, Predicate } from "@adeficior/data-modifier-core/serializer";
|
|
3
|
+
import type { Ingredient, IngredientFilter, Predicates, Result } from "@adeficior/data-modifier-ingredients";
|
|
4
|
+
import type { RecipeSerializerId } from "@adeficior/data-modifier/generated";
|
|
6
5
|
import type { RecipeHolder } from "./serializer/holder";
|
|
7
|
-
|
|
8
|
-
private readonly
|
|
9
|
-
private readonly
|
|
10
|
-
private readonly
|
|
11
|
-
private readonly
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
matches(id: Id, recipe: RecipeHolder): boolean;
|
|
15
|
-
printWarning(logger: Logger): void;
|
|
6
|
+
declare class RecipeRule implements Rule<RecipeHolder> {
|
|
7
|
+
private readonly idPredicate;
|
|
8
|
+
private readonly typePredicate;
|
|
9
|
+
private readonly ingredientsPredicate;
|
|
10
|
+
private readonly resultsPredicate;
|
|
11
|
+
constructor(idPredicate: Predicate<Id>, typePredicate: Predicate<Id>, ingredientsPredicate: Predicate<Ingredient[]>, resultsPredicate: Predicate<Result[]>);
|
|
12
|
+
matches(id: Id, value: RecipeHolder): boolean;
|
|
16
13
|
}
|
|
14
|
+
export type RecipeFilter = Readonly<{
|
|
15
|
+
id?: CommonFilter<NormalizedId>;
|
|
16
|
+
type?: CommonFilter<NormalizedId<RecipeSerializerId>>;
|
|
17
|
+
namespace?: string;
|
|
18
|
+
output?: IngredientFilter;
|
|
19
|
+
input?: IngredientFilter;
|
|
20
|
+
}>;
|
|
21
|
+
type SubjectFilters = {
|
|
22
|
+
ingredient?: IngredientFilter;
|
|
23
|
+
result?: IngredientFilter;
|
|
24
|
+
};
|
|
25
|
+
export type RecipeRules = {
|
|
26
|
+
resolve(filter?: RecipeFilter, subjectFilters?: SubjectFilters): Rule<RecipeHolder>;
|
|
27
|
+
};
|
|
28
|
+
export declare class RecipeRulesImpl implements RecipeRules {
|
|
29
|
+
private readonly predicates;
|
|
30
|
+
constructor(predicates: Predicates);
|
|
31
|
+
private resolveRecipeFilter;
|
|
32
|
+
private resolveSubjectFilters;
|
|
33
|
+
resolve(filter?: RecipeFilter, subjectFilters?: SubjectFilters): RecipeRule;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
package/dist/rule.js
CHANGED
|
@@ -1,27 +1,59 @@
|
|
|
1
|
-
import { createId
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.resultTests = resultTests;
|
|
1
|
+
import { createId } from "@adeficior/data-modifier-core";
|
|
2
|
+
import { always, every, resolveIdTest, some, } from "@adeficior/data-modifier-core/serializer";
|
|
3
|
+
import { notNull } from "@adeficior/pack-resolver";
|
|
4
|
+
class RecipeRule {
|
|
5
|
+
idPredicate;
|
|
6
|
+
typePredicate;
|
|
7
|
+
ingredientsPredicate;
|
|
8
|
+
resultsPredicate;
|
|
9
|
+
constructor(idPredicate, typePredicate, ingredientsPredicate, resultsPredicate) {
|
|
10
|
+
this.idPredicate = idPredicate;
|
|
11
|
+
this.typePredicate = typePredicate;
|
|
12
|
+
this.ingredientsPredicate = ingredientsPredicate;
|
|
13
|
+
this.resultsPredicate = resultsPredicate;
|
|
15
14
|
}
|
|
16
|
-
matches(id,
|
|
17
|
-
const types =
|
|
18
|
-
return (this.
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
15
|
+
matches(id, value) {
|
|
16
|
+
const types = value.getTypes().map(createId);
|
|
17
|
+
return (this.idPredicate(id) &&
|
|
18
|
+
types.some((it) => this.typePredicate(it)) &&
|
|
19
|
+
this.ingredientsPredicate(value.getIngredients()) &&
|
|
20
|
+
this.resultsPredicate(value.getResults()));
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
}
|
|
23
|
+
export class RecipeRulesImpl {
|
|
24
|
+
predicates;
|
|
25
|
+
constructor(predicates) {
|
|
26
|
+
this.predicates = predicates;
|
|
27
|
+
}
|
|
28
|
+
resolveRecipeFilter(test) {
|
|
29
|
+
const id = [];
|
|
30
|
+
const type = [];
|
|
31
|
+
const ingredient = [];
|
|
32
|
+
const result = [];
|
|
33
|
+
if (test.id)
|
|
34
|
+
id.push(resolveIdTest(test.id));
|
|
35
|
+
if (test.type)
|
|
36
|
+
type.push(resolveIdTest(test.type));
|
|
37
|
+
if (test.namespace)
|
|
38
|
+
id.push((id) => id.namespace === test.namespace);
|
|
39
|
+
if (test.output)
|
|
40
|
+
result.push(this.predicates.result(test.output));
|
|
41
|
+
if (test.input)
|
|
42
|
+
ingredient.push(this.predicates.ingredient(test.input));
|
|
43
|
+
return { id, type, ingredient, result };
|
|
44
|
+
}
|
|
45
|
+
resolveSubjectFilters({ ingredient, result }) {
|
|
46
|
+
return {
|
|
47
|
+
ingredient: notNull(ingredient)
|
|
48
|
+
? this.predicates.ingredient(ingredient)
|
|
49
|
+
: always(),
|
|
50
|
+
result: notNull(result) ? this.predicates.result(result) : always(),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
resolve(filter = {}, subjectFilters = {}) {
|
|
54
|
+
const recipePredicates = this.resolveRecipeFilter(filter);
|
|
55
|
+
const subjectPredicates = this.resolveSubjectFilters(subjectFilters);
|
|
56
|
+
return new RecipeRule(every(recipePredicates.id), every(recipePredicates.type), every([subjectPredicates.ingredient, ...recipePredicates.ingredient].map(some)), every([subjectPredicates.result, ...recipePredicates.result].map(some)));
|
|
25
57
|
}
|
|
26
58
|
}
|
|
27
59
|
//# sourceMappingURL=rule.js.map
|
package/dist/rule.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../src/rule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../src/rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAMzD,OAAO,EACL,MAAM,EACN,KAAK,EACL,aAAa,EACb,IAAI,GACL,MAAM,0CAA0C,CAAC;AAQlD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGnD,MAAM,UAAU;IAEK;IACA;IACA;IACA;IAJnB,YACmB,WAA0B,EAC1B,aAA4B,EAC5B,oBAA6C,EAC7C,gBAAqC;QAHrC,gBAAW,GAAX,WAAW,CAAe;QAC1B,kBAAa,GAAb,aAAa,CAAe;QAC5B,yBAAoB,GAApB,oBAAoB,CAAyB;QAC7C,qBAAgB,GAAhB,gBAAgB,CAAqB;IACrD,CAAC;IAEJ,OAAO,CAAC,EAAM,EAAE,KAAmB;QACjC,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE7C,OAAO,CACL,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YACpB,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAC1C,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;YACjD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAC1C,CAAC;IACJ,C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C,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;SACpE,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,SAAuB,EAAE,EAAE,iBAAiC,EAAE;QACpE,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC1D,MAAM,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;QAErE,OAAO,IAAI,UAAU,CACnB,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAC1B,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAC5B,KAAK,CACH,CAAC,iBAAiB,CAAC,UAAU,EAAE,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,GAAG,CAChE,IAAI,CACL,CACF,EACD,KAAK,CAAC,CAAC,iBAAiB,CAAC,MAAM,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CACxE,CAAC;IACJ,CAAC;CACF"}
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { IdInput, SemVerInput, WithConditions } from "@adeficior/data-modifier-core";
|
|
1
|
+
import type { IdInput, ResourceFolder, SemVerInput, WithConditions } from "@adeficior/data-modifier-core";
|
|
2
2
|
import type { RecipeSerializerId } from "@adeficior/data-modifier/generated";
|
|
3
3
|
export type RecipeDefinition = WithConditions<Readonly<{
|
|
4
4
|
type: RecipeSerializerId;
|
|
5
5
|
}>>;
|
|
6
|
+
export declare function recipeFolder(packFormat: SemVerInput): ResourceFolder;
|
|
6
7
|
export declare function recipePath(packFormat: SemVerInput, id: IdInput): string;
|
|
7
8
|
export declare function recipePattern(packFormat: SemVerInput): string;
|
package/dist/schema.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function recipeFolder(packFormat) {
|
|
3
|
-
|
|
1
|
+
import { isAtLeastVersion, jsonFilePath, jsonFilePattern, } from "@adeficior/data-modifier-core";
|
|
2
|
+
export function recipeFolder(packFormat) {
|
|
3
|
+
const folder = isAtLeastVersion(packFormat, "44") ? "recipe" : "recipes";
|
|
4
|
+
return { packType: "data", folder };
|
|
4
5
|
}
|
|
5
6
|
export function recipePath(packFormat, id) {
|
|
6
|
-
|
|
7
|
-
const { namespace, path } = createId(id);
|
|
8
|
-
return `data/${namespace}/${folder}/${path}.json`;
|
|
7
|
+
return jsonFilePath(recipeFolder(packFormat), id);
|
|
9
8
|
}
|
|
10
9
|
export function recipePattern(packFormat) {
|
|
11
|
-
return jsonFilePattern(
|
|
10
|
+
return jsonFilePattern(recipeFolder(packFormat));
|
|
12
11
|
}
|
|
13
12
|
//# sourceMappingURL=schema.js.map
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,eAAe,GAChB,MAAM,+BAA+B,CAAC;AASvC,MAAM,UAAU,YAAY,CAAC,UAAuB;IAClD,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,UAAuB,EAAE,EAAW;IAC7D,OAAO,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,UAAuB;IACnD,OAAO,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -3,9 +3,19 @@ import type { Replacer } from "@adeficior/data-modifier-core/serializer";
|
|
|
3
3
|
import type { Ingredient, Result } from "@adeficior/data-modifier-ingredients";
|
|
4
4
|
import type { RecipeSerializerId } from "@adeficior/data-modifier/generated";
|
|
5
5
|
import type { Recipe } from "../model";
|
|
6
|
+
import type { RecipeDefinition } from "../schema";
|
|
6
7
|
import type { RecipeParseContext } from "./context";
|
|
7
8
|
import type { RecipeModifier } from "./modifier";
|
|
8
|
-
|
|
9
|
+
type CommonRecipeHolder = {
|
|
10
|
+
serialize(context: RecipeParseContext): RecipeDefinition;
|
|
11
|
+
getIngredients(): Ingredient[];
|
|
12
|
+
getResults(): Result[];
|
|
13
|
+
modify(modifier: RecipeModifier): RecipeHolder;
|
|
14
|
+
replaceIngredient(replace: Replacer<Ingredient>): RecipeHolder;
|
|
15
|
+
replaceResult(replace: Replacer<Result>): RecipeHolder;
|
|
16
|
+
getTypes(): NormalizedId[];
|
|
17
|
+
};
|
|
18
|
+
export declare class RecipeHolder implements CommonRecipeHolder {
|
|
9
19
|
private readonly definition;
|
|
10
20
|
readonly recipe: Recipe;
|
|
11
21
|
readonly serializerType: NormalizedId;
|
|
@@ -24,3 +34,18 @@ export declare class RecipeHolder {
|
|
|
24
34
|
getTypes(): NormalizedId[];
|
|
25
35
|
static of(type: IdInput<RecipeSerializerId>, recipe: Recipe, conditions?: Conditions): RecipeHolder;
|
|
26
36
|
}
|
|
37
|
+
declare class FakeRecipeHolder implements CommonRecipeHolder {
|
|
38
|
+
private readonly definition;
|
|
39
|
+
constructor(definition: RecipeDefinition);
|
|
40
|
+
getIngredients(): Ingredient[];
|
|
41
|
+
getResults(): Result[];
|
|
42
|
+
getTypes(): NormalizedId[];
|
|
43
|
+
cast(): RecipeHolder;
|
|
44
|
+
modify(): RecipeHolder;
|
|
45
|
+
replaceIngredient(): RecipeHolder;
|
|
46
|
+
replaceResult(): RecipeHolder;
|
|
47
|
+
serialize(): RecipeDefinition;
|
|
48
|
+
}
|
|
49
|
+
export declare function isFakeHolder(holder: unknown): holder is FakeRecipeHolder;
|
|
50
|
+
export declare function createFakeHolder(definition: RecipeDefinition): RecipeHolder;
|
|
51
|
+
export {};
|
|
@@ -55,4 +55,41 @@ export class RecipeHolder {
|
|
|
55
55
|
return new RecipeHolder({ type: encodeId(type), ...conditions }, recipe);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
class FakeRecipeHolder {
|
|
59
|
+
definition;
|
|
60
|
+
constructor(definition) {
|
|
61
|
+
this.definition = definition;
|
|
62
|
+
}
|
|
63
|
+
getIngredients() {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
getResults() {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
getTypes() {
|
|
70
|
+
return [encodeId(this.definition.type)];
|
|
71
|
+
}
|
|
72
|
+
cast() {
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
modify() {
|
|
76
|
+
return this.cast();
|
|
77
|
+
}
|
|
78
|
+
replaceIngredient() {
|
|
79
|
+
return this.cast();
|
|
80
|
+
}
|
|
81
|
+
replaceResult() {
|
|
82
|
+
return this.cast();
|
|
83
|
+
}
|
|
84
|
+
serialize() {
|
|
85
|
+
return this.definition;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function isFakeHolder(holder) {
|
|
89
|
+
return holder instanceof FakeRecipeHolder;
|
|
90
|
+
}
|
|
91
|
+
export function createFakeHolder(definition) {
|
|
92
|
+
const fake = new FakeRecipeHolder(definition);
|
|
93
|
+
return fake.cast();
|
|
94
|
+
}
|
|
58
95
|
//# sourceMappingURL=holder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"holder.js","sourceRoot":"","sources":["../../src/serializer/holder.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AASzD,SAAS,IA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;IAC1C,CAAC;IAED,IAAI;QACF,OAAO,IAA+B,CAAC;IACzC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,OAAO,MAAM,YAAY,gBAAgB,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,UAA4B;IAC3D,MAAM,IAAI,GAAG,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;AACrB,CAAC"}
|
package/dist/serializer/impl.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { encodeId } from "@adeficior/data-modifier-core";
|
|
2
2
|
import { IllegalShapeError, UnknownRegistryEntry, } from "@adeficior/data-modifier-core/serializer";
|
|
3
|
-
import { RecipeHolder } from "./holder";
|
|
3
|
+
import { isFakeHolder, RecipeHolder } from "./holder";
|
|
4
4
|
export class RecipeSerializerImpl {
|
|
5
5
|
resultSerializer;
|
|
6
6
|
ingredientSerializer;
|
|
@@ -24,6 +24,9 @@ export class RecipeSerializerImpl {
|
|
|
24
24
|
throw new UnknownRegistryEntry(`no serializer registered for ${id}`, "minecraft:recipe_serializer", id);
|
|
25
25
|
}
|
|
26
26
|
serialize(holder, recipe) {
|
|
27
|
+
if (isFakeHolder(holder)) {
|
|
28
|
+
return holder.serialize();
|
|
29
|
+
}
|
|
27
30
|
if (holder instanceof RecipeHolder) {
|
|
28
31
|
const parser = this.typeSerializers.get(holder.serializerType);
|
|
29
32
|
if (!parser)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impl.js","sourceRoot":"","sources":["../../src/serializer/impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,0CAA0C,CAAC;AAYlD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"impl.js","sourceRoot":"","sources":["../../src/serializer/impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,0CAA0C,CAAC;AAYlD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,OAAO,oBAAoB;IAIZ;IACA;IAJF,eAAe,GAAG,IAAI,GAAG,EAAgC,CAAC;IAE3E,YACmB,gBAAkC,EAClC,oBAA0C;QAD1C,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,yBAAoB,GAApB,oBAAoB,CAAsB;IAC1D,CAAC;IAEI,kBAAkB,CACxB,MAA6B;QAE7B,OAAO;YACL,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,IAAI,CAAC,oBAAoB,CAAC,YAAY,CACjD,MAAM,CAAC,iBAAiB,EAAE,CAC3B;YACD,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;SACpE,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,IAAiC;QACnC,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5C,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAC1B,MAAM,IAAI,oBAAoB,CAC5B,gCAAgC,EAAE,EAAE,EACpC,6BAA6B,EAC7B,EA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AAC;QAED,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CACnC,UAAU,EACV,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CACpC,CAAC;QAEF,OAAO,YAAY,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC9D,CAAC;IAED,WAAW;QACT,OAAO;YACL,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;gBACzB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACzC,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/serializer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/serializer/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/serializer/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/testing/index.d.ts
CHANGED
package/dist/testing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/testing/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhC,MAAM,UAAU,SAAS;IACvB,OAAO;QACL,OAAO,EAAE,IAAI,EAAE;KACM,CAAC;AAC1B,CAAC"}
|
package/dist/testing/setup.js
CHANGED
|
@@ -6,7 +6,8 @@ import { createTestDataResolver, setupLookup } from "@adeficior/testing";
|
|
|
6
6
|
import { afterAll, afterEach, beforeAll } from "bun:test";
|
|
7
7
|
import { RecipeEmitterImpl } from "../emitter";
|
|
8
8
|
import { RecipeLoaderImpl } from "../loader";
|
|
9
|
-
import {
|
|
9
|
+
import { RecipeRulesImpl } from "../rule";
|
|
10
|
+
import { recipeFolder, recipePattern } from "../schema";
|
|
10
11
|
import { registerDefaultSerializers } from "../serializer/default";
|
|
11
12
|
import { RecipeSerializerImpl } from "../serializer/impl";
|
|
12
13
|
export function setupRecipeSerializer(version, options) {
|
|
@@ -22,7 +23,7 @@ export function setupRecipeSerializer(version, options) {
|
|
|
22
23
|
}
|
|
23
24
|
export function setupRecipeLoader(version, { mods = [], parsers, ...resolverOptions } = {}) {
|
|
24
25
|
const { lookup, serializer } = setupRecipeSerializer(version, { parsers });
|
|
25
|
-
const loader = new RecipeLoaderImpl(serializer, {
|
|
26
|
+
const loader = new RecipeLoaderImpl(serializer, recipeFolder(packFormatOf(version)), {
|
|
26
27
|
mods: ["minecraft", ...mods],
|
|
27
28
|
});
|
|
28
29
|
const logger = createTestLogger();
|
|
@@ -50,8 +51,9 @@ export function setupRecipeEmitter(version, options) {
|
|
|
50
51
|
const ingredients = setupIngredientSerializer(version, lookup);
|
|
51
52
|
const tags = setupTagRegistry(version, options);
|
|
52
53
|
const predicates = setupPredicates(lookup, tags, ingredients);
|
|
54
|
+
const rules = new RecipeRulesImpl(predicates);
|
|
53
55
|
const logger = createTestLogger();
|
|
54
|
-
const emitter = new RecipeEmitterImpl(logger, packFormatOf(version), loader, results, ingredients, predicates, serializer);
|
|
56
|
+
const emitter = new RecipeEmitterImpl(logger, packFormatOf(version), loader, results, ingredients, predicates, rules, serializer);
|
|
55
57
|
const resolver = emitter.resolver({ logger });
|
|
56
58
|
afterEach(() => {
|
|
57
59
|
emitter.clear();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/testing/setup.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EACL,yBAAyB,EACzB,eAAe,EACf,qBAAqB,GACtB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/testing/setup.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EACL,yBAAyB,EACzB,eAAe,EACf,qBAAqB,GACtB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAM1D,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf,OAAqC;IAErC,MAAM,MA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mBAAmB,CACjC,GAAW,EACX,OAA2C;IAE3C,OAAO;QACL,OAAO;QACP,IAAI,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC;QACtB,IAAI,EAAE,CAAC,GAAG,CAAC;KACZ,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adeficior/data-modifier-recipes",
|
|
3
3
|
"description": "data-modifier module for recipes",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
7
7
|
"./serializer": "./dist/serializer/index.js",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@types/lodash-es": "^4.17.12",
|
|
14
|
-
"@adeficior/data-modifier-ingredients": "^2.0.
|
|
14
|
+
"@adeficior/data-modifier-ingredients": "^2.0.3"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@adeficior/pack-resolver": "^2.0.1",
|
|
18
18
|
"typescript": "^5",
|
|
19
19
|
"minimatch": "^10.2.6",
|
|
20
20
|
"lodash-es": "^4.18.1",
|
|
21
|
-
"@adeficior/data-modifier-core": "^2.0
|
|
22
|
-
"@adeficior/data-modifier-ingredients": "^2.0.
|
|
23
|
-
"@adeficior/data-modifier-tags": "^2.0.
|
|
21
|
+
"@adeficior/data-modifier-core": "^2.1.0",
|
|
22
|
+
"@adeficior/data-modifier-ingredients": "^2.0.3",
|
|
23
|
+
"@adeficior/data-modifier-tags": "^2.0.3"
|
|
24
24
|
},
|
|
25
25
|
"typesVersions": {
|
|
26
26
|
"*": {
|