@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.
Files changed (52) hide show
  1. package/.editorconfig +15 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc +22 -0
  4. package/.gitattributes +3 -0
  5. package/.github/actions/setup/action.yml +37 -0
  6. package/.github/workflows/ci.yml +73 -0
  7. package/.gitignore +84 -0
  8. package/.nvmrc +1 -0
  9. package/.prettierrc +11 -0
  10. package/.release-it.json +17 -0
  11. package/.watchmanconfig +1 -0
  12. package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +541 -0
  13. package/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs +28 -0
  14. package/.yarn/releases/yarn-3.6.1.cjs +874 -0
  15. package/babel.config.js +5 -0
  16. package/bob.config.js +25 -0
  17. package/dist/commonjs/features/chatbot/components/Chatbot.js +2 -2
  18. package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
  19. package/dist/commonjs/features/chatbot/model/ChatBotModel.js +8 -6
  20. package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
  21. package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
  22. package/dist/module/features/chatbot/components/Chatbot.js +2 -2
  23. package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
  24. package/dist/module/features/chatbot/model/ChatBotModel.js +8 -6
  25. package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
  26. package/dist/module/features/chatbot/types/model.types.js.map +1 -1
  27. package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +8 -7
  28. package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
  29. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +3 -1
  30. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
  31. package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +8 -7
  32. package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
  33. package/dist/typescript/module/features/chatbot/types/model.types.d.ts +3 -1
  34. package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
  35. package/example/app.json +30 -0
  36. package/example/assets/adaptive-icon.png +0 -0
  37. package/example/assets/favicon.png +0 -0
  38. package/example/assets/icon.png +0 -0
  39. package/example/assets/splash-icon.png +0 -0
  40. package/example/babel.config.js +28 -0
  41. package/example/index.js +8 -0
  42. package/example/metro.config.js +18 -0
  43. package/example/package.json +25 -0
  44. package/example/src/App.tsx +8 -0
  45. package/example/tsconfig.json +6 -0
  46. package/package.json +1 -1
  47. package/src/features/chatbot/components/Chatbot.tsx +2 -2
  48. package/src/features/chatbot/model/ChatBotModel.ts +10 -5
  49. package/src/features/chatbot/types/model.types.ts +3 -1
  50. package/tsconfig.build.json +4 -0
  51. package/tsconfig.json +34 -0
  52. 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
+ }
@@ -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
+ }
@@ -0,0 +1,8 @@
1
+ import React from 'react'
2
+ import { Text } from 'react-native'
3
+
4
+ const App = () => {
5
+ return <Text>Hello</Text>
6
+ }
7
+
8
+ export default App
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../tsconfig",
3
+ "compilerOptions": {
4
+ // Avoid expo-cli auto-generating a tsconfig
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magmamath/students-features",
3
- "version": "0.9.97",
3
+ "version": "0.9.98-rc.0",
4
4
  "description": "Magmamath features library",
5
5
  "source": "src/index.ts",
6
6
  "main": "src/index.ts",
@@ -30,14 +30,14 @@ export const Chatbot = ({
30
30
  iconSize,
31
31
  colorScheme = ColorScheme.Blue,
32
32
  }: ChatbotProps) => {
33
- const alternatives = useUnit(model.$alternatives)
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 || alternatives?.chatAccess === false) {
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, alternatives: this.$alternatives },
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, alternatives, initOnly }: StartConversationFxData) => {
159
+ ({ currentChatData, initOnly, chatAccess }: StartConversationFxData) => {
155
160
  const { key, messages } = currentChatData
156
161
 
157
- if (!alternatives?.chatAccess) return
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?.chatAccess && alternatives?.isOpenChatEnabled && IS_WEB) {
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 {
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig",
3
+ "exclude": ["example", "dist"]
4
+ }
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
+ }