@magmamath/students-features 0.9.97 → 0.9.98-rc.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/.editorconfig +15 -0
- package/.eslintignore +2 -0
- package/.eslintrc +22 -0
- package/.gitattributes +3 -0
- package/.github/actions/setup/action.yml +37 -0
- package/.github/workflows/ci.yml +73 -0
- package/.gitignore +84 -0
- package/.nvmrc +1 -0
- package/.prettierrc +11 -0
- package/.release-it.json +17 -0
- package/.watchmanconfig +1 -0
- package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +541 -0
- package/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs +28 -0
- package/.yarn/releases/yarn-3.6.1.cjs +874 -0
- package/babel.config.js +5 -0
- package/bob.config.js +25 -0
- package/dist/commonjs/features/chatbot/components/Chatbot.js +2 -2
- package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js +8 -6
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
- package/dist/module/features/chatbot/components/Chatbot.js +2 -2
- package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotModel.js +8 -6
- package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/module/features/chatbot/types/model.types.js.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +8 -7
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +3 -1
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +8 -7
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts +3 -1
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
- package/example/app.json +30 -0
- package/example/assets/adaptive-icon.png +0 -0
- package/example/assets/favicon.png +0 -0
- package/example/assets/icon.png +0 -0
- package/example/assets/splash-icon.png +0 -0
- package/example/babel.config.js +28 -0
- package/example/index.js +8 -0
- package/example/metro.config.js +18 -0
- package/example/package.json +25 -0
- package/example/src/App.tsx +8 -0
- package/example/tsconfig.json +6 -0
- package/package.json +1 -1
- package/src/features/chatbot/components/Chatbot.tsx +2 -2
- package/src/features/chatbot/model/ChatBotModel.ts +10 -5
- package/src/features/chatbot/types/model.types.ts +3 -1
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +34 -0
- package/yarn.lock +8623 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const { getConfig } = require('react-native-builder-bob/babel-config')
|
|
3
|
+
const pkg = require('../package.json')
|
|
4
|
+
|
|
5
|
+
const root = path.resolve(__dirname, '..')
|
|
6
|
+
|
|
7
|
+
module.exports = function (api) {
|
|
8
|
+
api.cache(true)
|
|
9
|
+
|
|
10
|
+
return getConfig(
|
|
11
|
+
{
|
|
12
|
+
presets: ['babel-preset-expo'],
|
|
13
|
+
plugins: [
|
|
14
|
+
[
|
|
15
|
+
'module-resolver',
|
|
16
|
+
{
|
|
17
|
+
extensions: ['.tsx', '.ts', '.js', '.json'],
|
|
18
|
+
alias: {
|
|
19
|
+
[pkg.name]: path.join(__dirname, '../', pkg.source),
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
['@babel/plugin-transform-private-methods', { loose: true }],
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
{ root, pkg },
|
|
27
|
+
)
|
|
28
|
+
}
|
package/example/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { registerRootComponent } from 'expo';
|
|
2
|
+
|
|
3
|
+
import App from './src/App';
|
|
4
|
+
|
|
5
|
+
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
|
|
6
|
+
// It also ensures that whether you load the app in Expo Go or in a native build,
|
|
7
|
+
// the environment is set up appropriately
|
|
8
|
+
registerRootComponent(App);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { getDefaultConfig } = require('@expo/metro-config');
|
|
3
|
+
const { getConfig } = require('react-native-builder-bob/metro-config');
|
|
4
|
+
const pkg = require('../package.json');
|
|
5
|
+
|
|
6
|
+
const root = path.resolve(__dirname, '..');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Metro configuration
|
|
10
|
+
* https://facebook.github.io/metro/docs/configuration
|
|
11
|
+
*
|
|
12
|
+
* @type {import('metro-config').MetroConfig}
|
|
13
|
+
*/
|
|
14
|
+
module.exports = getConfig(getDefaultConfig(__dirname), {
|
|
15
|
+
root,
|
|
16
|
+
pkg,
|
|
17
|
+
project: __dirname,
|
|
18
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@magmamath/students-features-example",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"start": "expo start",
|
|
7
|
+
"android": "expo start --android",
|
|
8
|
+
"ios": "expo start --ios",
|
|
9
|
+
"web": "expo start --web"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@expo/metro-runtime": "~4.0.0",
|
|
13
|
+
"expo": "~52.0.11",
|
|
14
|
+
"expo-status-bar": "~2.0.0",
|
|
15
|
+
"react": "18.3.1",
|
|
16
|
+
"react-dom": "18.3.1",
|
|
17
|
+
"react-native": "0.76.3",
|
|
18
|
+
"react-native-web": "~0.19.13"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@babel/core": "^7.20.0",
|
|
22
|
+
"react-native-builder-bob": "^0.33.3"
|
|
23
|
+
},
|
|
24
|
+
"private": true
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -30,14 +30,14 @@ export const Chatbot = ({
|
|
|
30
30
|
iconSize,
|
|
31
31
|
colorScheme = ColorScheme.Blue,
|
|
32
32
|
}: ChatbotProps) => {
|
|
33
|
-
const
|
|
33
|
+
const isChatAllowed = useUnit(model.$chatAccess)
|
|
34
34
|
const isAvailable = useStoreMap(model.$currentChatData, ({ isAvailable }) => isAvailable)
|
|
35
35
|
model.t2s.setAudioConfig(textToSpeechConfig ?? null)
|
|
36
36
|
|
|
37
37
|
const openChat = () => model.setIsOpen(true)
|
|
38
38
|
const closeChat = () => model.setIsOpen(false)
|
|
39
39
|
|
|
40
|
-
if (!isAvailable ||
|
|
40
|
+
if (!isAvailable || !isChatAllowed) {
|
|
41
41
|
return null
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
restore,
|
|
8
8
|
sample,
|
|
9
9
|
type Store,
|
|
10
|
+
StoreWritable
|
|
10
11
|
} from 'effector'
|
|
11
12
|
import {
|
|
12
13
|
ChatbotContext,
|
|
@@ -74,14 +75,18 @@ export class ChatbotModel {
|
|
|
74
75
|
|
|
75
76
|
private readonly cache = new ChatsCacheModel()
|
|
76
77
|
|
|
78
|
+
public readonly $chatAccess: StoreWritable<boolean>
|
|
79
|
+
|
|
77
80
|
public readonly $currentChatData = combine(
|
|
78
81
|
{ data: this.cache.$data, key: this.$currentKey },
|
|
79
82
|
({ data, key }) => (data[key] ? { ...data[key], key } : { ...defaultChatData(), key }),
|
|
80
83
|
)
|
|
81
84
|
|
|
82
|
-
constructor({ api, $key, threadMessagesLimit, settings = {} }: ChatbotModelProps) {
|
|
85
|
+
constructor({ api, $key, threadMessagesLimit, settings = {}, chatAccess }: ChatbotModelProps) {
|
|
83
86
|
this.api = new ChatbotAPI({ ...api, postMessage: this.threadManager.postMessage })
|
|
84
87
|
|
|
88
|
+
this.$chatAccess = chatAccess
|
|
89
|
+
|
|
85
90
|
this.threadManager.setApi({ getHint: api.requestHint, sendMessage: api.sendMessage })
|
|
86
91
|
if (threadMessagesLimit) {
|
|
87
92
|
this.threadManager.setMessagesLimit(threadMessagesLimit)
|
|
@@ -145,16 +150,16 @@ export class ChatbotModel {
|
|
|
145
150
|
}
|
|
146
151
|
|
|
147
152
|
this.startConversation = attach({
|
|
148
|
-
source: { currentChatData: this.$currentChatData,
|
|
153
|
+
source: { currentChatData: this.$currentChatData, chatAccess: this.$chatAccess },
|
|
149
154
|
mapParams: (props: StartConversationProps | void, source) => ({
|
|
150
155
|
...props,
|
|
151
156
|
...source,
|
|
152
157
|
}),
|
|
153
158
|
effect: createEffect(
|
|
154
|
-
({ currentChatData,
|
|
159
|
+
({ currentChatData, initOnly, chatAccess }: StartConversationFxData) => {
|
|
155
160
|
const { key, messages } = currentChatData
|
|
156
161
|
|
|
157
|
-
if (!
|
|
162
|
+
if (!chatAccess) return
|
|
158
163
|
|
|
159
164
|
if (messages.length) {
|
|
160
165
|
if (initOnly) return
|
|
@@ -171,7 +176,7 @@ export class ChatbotModel {
|
|
|
171
176
|
|
|
172
177
|
this.api.getAlternativesFx.doneData.watch((alternatives) => {
|
|
173
178
|
// Use short text for another hint option if openChatEnabled
|
|
174
|
-
if (alternatives?.
|
|
179
|
+
if (alternatives?.isOpenChatEnabled && IS_WEB) {
|
|
175
180
|
this.textManager.update((creator) => ({
|
|
176
181
|
anotherHintOption: creator.createOption('chat.giveHintOpenChat'),
|
|
177
182
|
}))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Store } from 'effector'
|
|
1
|
+
import type { Store, StoreWritable } from 'effector'
|
|
2
2
|
import {
|
|
3
3
|
ChatHintPayload,
|
|
4
4
|
ChatHintResponse,
|
|
@@ -52,6 +52,7 @@ export type ChatbotModelProps = {
|
|
|
52
52
|
requestHint: (props: ChatHintPayload) => Promise<ChatHintResponse>
|
|
53
53
|
}
|
|
54
54
|
threadMessagesLimit?: number
|
|
55
|
+
chatAccess: StoreWritable<boolean>
|
|
55
56
|
settings?: ChatbotSettings
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -82,6 +83,7 @@ export type StartConversationFxData = {
|
|
|
82
83
|
messages: ConversationMessage[]
|
|
83
84
|
}
|
|
84
85
|
alternatives?: GetAlternativesResponse | null
|
|
86
|
+
chatAccess: boolean
|
|
85
87
|
} & StartConversationProps
|
|
86
88
|
|
|
87
89
|
export enum MessageVariant {
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"paths": {
|
|
4
|
+
"@magmamath/students-features": ["./src/index"]
|
|
5
|
+
},
|
|
6
|
+
"target": "esnext",
|
|
7
|
+
"baseUrl": "./",
|
|
8
|
+
"lib": [
|
|
9
|
+
"dom",
|
|
10
|
+
"dom.iterable",
|
|
11
|
+
"esnext"
|
|
12
|
+
],
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"allowJs": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"allowSyntheticDefaultImports": true,
|
|
18
|
+
"strict": true,
|
|
19
|
+
"forceConsistentCasingInFileNames": true,
|
|
20
|
+
"module": "esnext",
|
|
21
|
+
"moduleResolution": "node",
|
|
22
|
+
"resolveJsonModule": true,
|
|
23
|
+
"isolatedModules": true,
|
|
24
|
+
"jsx": "react",
|
|
25
|
+
"experimentalDecorators": true
|
|
26
|
+
},
|
|
27
|
+
"include": [
|
|
28
|
+
"src"
|
|
29
|
+
],
|
|
30
|
+
"exclude": [
|
|
31
|
+
"node_modules",
|
|
32
|
+
"example"
|
|
33
|
+
]
|
|
34
|
+
}
|