@novely/dynamic-character 0.3.0 → 0.4.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/README.md +58 -37
- package/dist/actions.d.ts +7 -0
- package/dist/components/Picker.d.ts +19 -0
- package/dist/components/Slider.d.ts +12 -0
- package/dist/emotions.d.ts +1 -1
- package/dist/index.css +10 -26
- package/dist/index.d.ts +1 -6
- package/dist/index.jsx +332 -1293
- package/dist/picker.d.ts +2 -2
- package/dist/show.d.ts +2 -2
- package/dist/types.d.ts +65 -20
- package/dist/utils.d.ts +2 -1
- package/package.json +3 -3
- package/dist/slider.d.ts +0 -3
package/dist/picker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CustomHandler } from '@novely/core';
|
|
2
|
-
import type {
|
|
3
|
-
declare const showPicker: (this:
|
|
2
|
+
import type { AllThis, InternalShowPickerOptions } from './types';
|
|
3
|
+
declare const showPicker: (this: AllThis, options: InternalShowPickerOptions) => CustomHandler;
|
|
4
4
|
export { showPicker };
|
package/dist/show.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CustomHandler } from '@novely/core';
|
|
2
|
-
import type {
|
|
3
|
-
declare const showCharacter: (this:
|
|
2
|
+
import type { AllThis } from './types';
|
|
3
|
+
declare const showCharacter: (this: AllThis) => CustomHandler;
|
|
4
4
|
export { showCharacter };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import type { Character, Data, Lang, NovelyAsset, State, TypeEssentials } from '@novely/core';
|
|
1
|
+
import type { Character, Data, Lang, NovelyAsset, State, TypeEssentials, ValidAction } from '@novely/core';
|
|
2
2
|
type Attributes<BaseKeys extends string = string> = Record<string, Record<string, Record<BaseKeys, NovelyAsset | NovelyAsset[]>>>;
|
|
3
3
|
type EmotionsDefinition<BaseKeys extends string, Attribs extends Attributes<BaseKeys>> = {
|
|
4
4
|
base: Record<BaseKeys, NovelyAsset | NovelyAsset[]>;
|
|
5
5
|
attributes: Attribs;
|
|
6
|
+
pricing?: {
|
|
7
|
+
base: Record<BaseKeys, number>;
|
|
8
|
+
attributes: {
|
|
9
|
+
[Attribute in keyof Attribs]: Record<keyof Attribs[Attribute], number>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
6
12
|
};
|
|
7
13
|
/**
|
|
8
14
|
* Utilities
|
|
@@ -33,15 +39,27 @@ type ClothingData<BaseKeys extends string, Attribs extends Attributes<BaseKeys>>
|
|
|
33
39
|
attributes: {
|
|
34
40
|
[Attribute in keyof Attribs]: (keyof Attribs[Attribute] & string)[];
|
|
35
41
|
};
|
|
36
|
-
|
|
42
|
+
pricing?: {
|
|
43
|
+
base: Record<BaseKeys, number>;
|
|
44
|
+
attributes: {
|
|
45
|
+
[Attribute in keyof Attribs]: Record<keyof Attribs[Attribute], number>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
type CreateActionsFN<BaseKeys extends string, Attribs extends Attributes<BaseKeys>> = {
|
|
50
|
+
<Engine extends EngineInstance>(engine: Engine, options: AllOptions<NoInfer<Engine['typeEssentials']>, NoInfer<BaseKeys>, NoInfer<Attribs>>): {
|
|
51
|
+
showBasePicker: (options?: ShowPickerOptionsBase) => ValidAction;
|
|
52
|
+
showAttributePicker: (options: ShowPickerOptionsAttribute<Attribs>) => ValidAction;
|
|
53
|
+
showCharacter: () => ValidAction;
|
|
54
|
+
};
|
|
37
55
|
};
|
|
38
56
|
type EmotionsResult<BaseKeys extends string, Attribs extends Attributes<BaseKeys>> = {
|
|
39
57
|
emotions: GeneratedEmotions<BaseKeys, Attribs>;
|
|
40
|
-
|
|
58
|
+
createActions: CreateActionsFN<BaseKeys, Attribs>;
|
|
41
59
|
};
|
|
42
60
|
type Entries<T> = T extends Record<infer T, infer K> ? [T, K][] : never;
|
|
43
61
|
type DefaultTypeEssentials = TypeEssentials<Lang, State, Data, Record<string, Character>>;
|
|
44
|
-
type
|
|
62
|
+
type AllOptions<TE extends DefaultTypeEssentials, BaseKeys extends string, Attribs extends Attributes<BaseKeys>> = {
|
|
45
63
|
/**
|
|
46
64
|
* Character ID
|
|
47
65
|
*/
|
|
@@ -56,10 +74,6 @@ type DynCharacterOptions<TE extends DefaultTypeEssentials, BaseKeys extends stri
|
|
|
56
74
|
defaultAttributes: {
|
|
57
75
|
[Attribute in keyof Attribs]: keyof Attribs[Attribute] & string;
|
|
58
76
|
};
|
|
59
|
-
/**
|
|
60
|
-
* Attributes to exclude from picker
|
|
61
|
-
*/
|
|
62
|
-
excludeAttributes?: (keyof Attribs & string)[];
|
|
63
77
|
/**
|
|
64
78
|
* Translation
|
|
65
79
|
*/
|
|
@@ -80,16 +94,10 @@ type DynCharacterOptions<TE extends DefaultTypeEssentials, BaseKeys extends stri
|
|
|
80
94
|
[Base in BaseKeys]: string;
|
|
81
95
|
};
|
|
82
96
|
/**
|
|
83
|
-
*
|
|
97
|
+
* Title translations
|
|
84
98
|
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Base tab translation
|
|
88
|
-
*/
|
|
99
|
+
title: {
|
|
89
100
|
base: string;
|
|
90
|
-
/**
|
|
91
|
-
* Attribute translations
|
|
92
|
-
*/
|
|
93
101
|
attributes: {
|
|
94
102
|
[Attribute in keyof Attribs]: string;
|
|
95
103
|
};
|
|
@@ -98,22 +106,59 @@ type DynCharacterOptions<TE extends DefaultTypeEssentials, BaseKeys extends stri
|
|
|
98
106
|
* Translation of UI components
|
|
99
107
|
*/
|
|
100
108
|
ui: {
|
|
101
|
-
tablist: string;
|
|
102
109
|
variants: string;
|
|
103
110
|
slidesControl: string;
|
|
104
111
|
prevSlide: string;
|
|
105
112
|
nextSlide: string;
|
|
106
113
|
sumbit: string;
|
|
114
|
+
buy: string;
|
|
107
115
|
};
|
|
108
116
|
};
|
|
109
117
|
};
|
|
110
118
|
};
|
|
111
|
-
type
|
|
119
|
+
type AllThis = {
|
|
112
120
|
clothingData: ClothingData<string, Attributes>;
|
|
113
|
-
options:
|
|
121
|
+
options: AllOptions<DefaultTypeEssentials, string, Attributes>;
|
|
114
122
|
};
|
|
115
123
|
type EmotionObject = {
|
|
116
124
|
base: string;
|
|
117
125
|
attributes: Record<string, string>;
|
|
118
126
|
};
|
|
119
|
-
|
|
127
|
+
type InternalShowPickerBase = {
|
|
128
|
+
type: 'base';
|
|
129
|
+
};
|
|
130
|
+
type InternalShowPickerAttribute = {
|
|
131
|
+
type: 'attribute';
|
|
132
|
+
name: string;
|
|
133
|
+
};
|
|
134
|
+
type InternalShowPickerBuyOptions = {
|
|
135
|
+
buy: (variant: string) => Promise<boolean>;
|
|
136
|
+
isBought: (variant: string) => boolean;
|
|
137
|
+
};
|
|
138
|
+
type InternalShowPickerOptions = (InternalShowPickerBase | InternalShowPickerAttribute) & InternalShowPickerBuyOptions;
|
|
139
|
+
type ShowPickerBuyFunctions = {
|
|
140
|
+
/**
|
|
141
|
+
* Function to buy attribute variant
|
|
142
|
+
* @param variant Attribute variant
|
|
143
|
+
* @returns Boolean indicating is item bought or not
|
|
144
|
+
*/
|
|
145
|
+
buy?: (variant: string) => Promise<boolean>;
|
|
146
|
+
/**
|
|
147
|
+
* Function to check is attribute variant is bought
|
|
148
|
+
* @param variant Attribute variant
|
|
149
|
+
* @returns Boolean indicating is item bought or not
|
|
150
|
+
*/
|
|
151
|
+
isBought?: (variant: string) => boolean;
|
|
152
|
+
};
|
|
153
|
+
type ShowPickerOptionsAttribute<Attribs extends Attributes> = ShowPickerBuyFunctions & {
|
|
154
|
+
/**
|
|
155
|
+
* Name of the attribute
|
|
156
|
+
*/
|
|
157
|
+
name: keyof Attribs & string;
|
|
158
|
+
};
|
|
159
|
+
type ShowPickerOptionsBase = ShowPickerBuyFunctions;
|
|
160
|
+
type EngineInstance = {
|
|
161
|
+
action: Record<string, (...args: any[]) => ValidAction>;
|
|
162
|
+
typeEssentials: DefaultTypeEssentials;
|
|
163
|
+
};
|
|
164
|
+
export type { Entries, EmotionsDefinition, EmotionsResult, Attributes, ClothingData, EmotionObject, AllOptions, AllThis, DefaultTypeEssentials, InternalShowPickerOptions, ShowPickerOptionsAttribute, ShowPickerOptionsBase, EngineInstance, };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { StateFunction, State } from '@novely/core';
|
|
2
2
|
import type { EmotionObject, ClothingData, Attributes } from './types';
|
|
3
|
+
declare const once: (fn: () => void) => () => void;
|
|
3
4
|
declare const getEntries: <T extends PropertyKey, K>(object: Record<T, K>) => [T, K][];
|
|
4
5
|
declare const getKeys: <T extends PropertyKey>(object: Record<T, unknown>) => T[];
|
|
5
6
|
declare const toArray: <T>(target: T | T[]) => T[];
|
|
@@ -12,4 +13,4 @@ declare const getEmotionString: ({ base, attributes }: EmotionObject) => string;
|
|
|
12
13
|
*/
|
|
13
14
|
declare const getSavedEmotion: (state: StateFunction<State>, character: string, clothingData: ClothingData<string, Attributes>, fallback: EmotionObject) => EmotionObject;
|
|
14
15
|
declare const saveEmotion: (state: StateFunction<State>, character: string, emotion: EmotionObject) => void;
|
|
15
|
-
export { getEntries, getKeys, toArray, permutation, getEmotionString, saveEmotion, getSavedEmotion };
|
|
16
|
+
export { once, getEntries, getKeys, toArray, permutation, getEmotionString, saveEmotion, getSavedEmotion };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novely/dynamic-character",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"typescript": "^5.6.2"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"
|
|
18
|
+
"p-limit": "^6.1.0",
|
|
19
19
|
"solid-js": "~1.9.3",
|
|
20
|
-
"@novely/core": "0.
|
|
20
|
+
"@novely/core": "0.49.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@novely/core": "*",
|
package/dist/slider.d.ts
DELETED