@rimori/client 1.0.2 → 1.0.4

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 (135) hide show
  1. package/README.md +51 -0
  2. package/dist/components/CRUDModal.js +0 -1
  3. package/dist/components/ai/Assistant.d.ts +9 -0
  4. package/dist/components/ai/Assistant.js +59 -0
  5. package/dist/components/ai/Avatar.d.ts +11 -0
  6. package/dist/components/ai/Avatar.js +39 -0
  7. package/dist/components/ai/EmbeddedAssistent/AudioInputField.d.ts +7 -0
  8. package/dist/components/ai/EmbeddedAssistent/AudioInputField.js +38 -0
  9. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +7 -0
  10. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +59 -0
  11. package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +19 -0
  12. package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.js +86 -0
  13. package/dist/components/ai/EmbeddedAssistent/TTS/Player.d.ts +25 -0
  14. package/dist/components/ai/EmbeddedAssistent/TTS/Player.js +180 -0
  15. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +7 -0
  16. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +45 -0
  17. package/dist/components/ai/utils.d.ts +6 -0
  18. package/dist/components/ai/utils.js +14 -0
  19. package/dist/components/audio/Playbutton.js +4 -5
  20. package/dist/components/avatar/Assistant.d.ts +9 -0
  21. package/dist/components/avatar/Assistant.js +59 -0
  22. package/dist/components/avatar/Avatar.d.ts +12 -0
  23. package/dist/components/avatar/Avatar.js +42 -0
  24. package/dist/components/avatar/EmbeddedAssistent/AudioInputField.d.ts +7 -0
  25. package/dist/components/avatar/EmbeddedAssistent/AudioInputField.js +38 -0
  26. package/dist/components/avatar/EmbeddedAssistent/CircleAudioAvatar.d.ts +7 -0
  27. package/dist/components/avatar/EmbeddedAssistent/CircleAudioAvatar.js +59 -0
  28. package/dist/components/avatar/EmbeddedAssistent/TTS/MessageSender.d.ts +19 -0
  29. package/dist/components/avatar/EmbeddedAssistent/TTS/MessageSender.js +84 -0
  30. package/dist/components/avatar/EmbeddedAssistent/TTS/Player.d.ts +25 -0
  31. package/dist/components/avatar/EmbeddedAssistent/TTS/Player.js +180 -0
  32. package/dist/components/avatar/EmbeddedAssistent/VoiceRecoder.d.ts +7 -0
  33. package/dist/components/avatar/EmbeddedAssistent/VoiceRecoder.js +45 -0
  34. package/dist/components/avatar/utils.d.ts +6 -0
  35. package/dist/components/avatar/utils.js +14 -0
  36. package/dist/components.d.ts +9 -0
  37. package/dist/components.js +10 -0
  38. package/dist/controller/AIController.d.ts +4 -3
  39. package/dist/controller/AIController.js +32 -8
  40. package/dist/controller/ObjectController.d.ts +2 -2
  41. package/dist/controller/ObjectController.js +4 -5
  42. package/dist/controller/SettingsController.d.ts +3 -1
  43. package/dist/controller/SettingsController.js +9 -0
  44. package/dist/controller/SharedContentController.js +6 -6
  45. package/dist/controller/SidePluginController.d.ts +14 -0
  46. package/dist/{plugin/VoiceController.js → controller/SidePluginController.js} +18 -15
  47. package/dist/controller/VoiceController.js +1 -1
  48. package/dist/core.d.ts +9 -0
  49. package/dist/core.js +10 -0
  50. package/dist/hooks/UseChatHook.js +2 -2
  51. package/dist/index.d.ts +3 -2
  52. package/dist/index.js +4 -2
  53. package/dist/plugin/PluginController.d.ts +4 -12
  54. package/dist/plugin/PluginController.js +43 -70
  55. package/dist/plugin/RimoriClient.d.ts +87 -27
  56. package/dist/plugin/RimoriClient.js +101 -67
  57. package/dist/plugin/fromRimori/EventBus.d.ts +98 -0
  58. package/dist/plugin/fromRimori/EventBus.js +240 -0
  59. package/dist/providers/PluginProvider.d.ts +1 -0
  60. package/dist/providers/PluginProvider.js +64 -12
  61. package/dist/worker/WorkerSetup.d.ts +6 -0
  62. package/dist/worker/WorkerSetup.js +79 -0
  63. package/package.json +16 -3
  64. package/src/components/CRUDModal.tsx +1 -3
  65. package/src/components/ai/Assistant.tsx +96 -0
  66. package/src/components/ai/Avatar.tsx +61 -0
  67. package/src/components/ai/EmbeddedAssistent/AudioInputField.tsx +64 -0
  68. package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +75 -0
  69. package/src/components/ai/EmbeddedAssistent/TTS/MessageSender.ts +91 -0
  70. package/src/components/ai/EmbeddedAssistent/TTS/Player.ts +192 -0
  71. package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +56 -0
  72. package/src/components/ai/utils.ts +23 -0
  73. package/src/components/audio/Playbutton.tsx +4 -5
  74. package/src/components.ts +10 -0
  75. package/src/controller/AIController.ts +84 -60
  76. package/src/controller/ObjectController.ts +4 -6
  77. package/src/controller/SettingsController.ts +10 -1
  78. package/src/controller/SharedContentController.ts +6 -6
  79. package/src/controller/SidePluginController.ts +36 -0
  80. package/src/controller/VoiceController.ts +1 -1
  81. package/src/core.ts +10 -0
  82. package/src/hooks/UseChatHook.ts +2 -2
  83. package/src/index.ts +4 -2
  84. package/src/plugin/PluginController.ts +46 -76
  85. package/src/plugin/RimoriClient.ts +151 -76
  86. package/src/plugin/fromRimori/EventBus.ts +301 -0
  87. package/src/plugin/fromRimori/readme.md +2 -0
  88. package/src/providers/PluginProvider.tsx +70 -14
  89. package/src/worker/WorkerSetup.ts +80 -0
  90. package/dist/CRUDModal.d.ts +0 -16
  91. package/dist/CRUDModal.js +0 -31
  92. package/dist/MarkdownEditor.d.ts +0 -8
  93. package/dist/MarkdownEditor.js +0 -46
  94. package/dist/audio/Playbutton.d.ts +0 -14
  95. package/dist/audio/Playbutton.js +0 -73
  96. package/dist/components/hooks/UseChatHook.d.ts +0 -15
  97. package/dist/components/hooks/UseChatHook.js +0 -21
  98. package/dist/plugin/AIController copy.d.ts +0 -22
  99. package/dist/plugin/AIController copy.js +0 -68
  100. package/dist/plugin/AIController.d.ts +0 -22
  101. package/dist/plugin/AIController.js +0 -68
  102. package/dist/plugin/ObjectController.d.ts +0 -34
  103. package/dist/plugin/ObjectController.js +0 -77
  104. package/dist/plugin/SettingController.d.ts +0 -13
  105. package/dist/plugin/SettingController.js +0 -55
  106. package/dist/plugin/VoiceController.d.ts +0 -2
  107. package/dist/providers/EventEmitter.d.ts +0 -11
  108. package/dist/providers/EventEmitter.js +0 -41
  109. package/dist/providers/EventEmitterContext.d.ts +0 -6
  110. package/dist/providers/EventEmitterContext.js +0 -19
  111. package/dist/utils/DifficultyConverter.d.ts +0 -3
  112. package/dist/utils/DifficultyConverter.js +0 -7
  113. package/dist/utils/constants.d.ts +0 -4
  114. package/dist/utils/constants.js +0 -12
  115. package/dist/utils/plugin/Client.d.ts +0 -72
  116. package/dist/utils/plugin/Client.js +0 -118
  117. package/dist/utils/plugin/PluginController.d.ts +0 -36
  118. package/dist/utils/plugin/PluginController.js +0 -119
  119. package/dist/utils/plugin/PluginUtils.d.ts +0 -2
  120. package/dist/utils/plugin/PluginUtils.js +0 -23
  121. package/dist/utils/plugin/RimoriClient.d.ts +0 -72
  122. package/dist/utils/plugin/RimoriClient.js +0 -118
  123. package/dist/utils/plugin/ThemeSetter.d.ts +0 -1
  124. package/dist/utils/plugin/ThemeSetter.js +0 -13
  125. package/dist/utils/plugin/WhereClauseBuilder.d.ts +0 -24
  126. package/dist/utils/plugin/WhereClauseBuilder.js +0 -79
  127. package/dist/utils/plugin/providers/EventEmitter.d.ts +0 -11
  128. package/dist/utils/plugin/providers/EventEmitter.js +0 -41
  129. package/dist/utils/plugin/providers/EventEmitterContext.d.ts +0 -6
  130. package/dist/utils/plugin/providers/EventEmitterContext.js +0 -19
  131. package/dist/utils/plugin/providers/PluginProvider.d.ts +0 -8
  132. package/dist/utils/plugin/providers/PluginProvider.js +0 -49
  133. package/src/providers/EventEmitter.ts +0 -48
  134. package/src/providers/EventEmitterContext.tsx +0 -27
  135. package/src/utils/constants.ts +0 -18
@@ -1,79 +0,0 @@
1
- export class WhereClauseBuilder {
2
- constructor() {
3
- this.conditions = [];
4
- }
5
- // Add AND condition
6
- // and(): WhereClauseBuilder {
7
- // const builder = new WhereClauseBuilder();
8
- // this.conditions.push({ AND: builder.conditions });
9
- // return builder;
10
- // }
11
- // Add OR condition
12
- // or(): WhereClauseBuilder {
13
- // const builder = new WhereClauseBuilder();
14
- // this.conditions.push({ OR: builder.conditions });
15
- // return builder;
16
- // }
17
- // Equality check
18
- eq(column, value) {
19
- this.conditions.push({ column, operator: "eq", value });
20
- return this;
21
- }
22
- // Not equal check
23
- neq(column, value) {
24
- this.conditions.push({ column, operator: "neq", value });
25
- return this;
26
- }
27
- // Greater than
28
- gt(column, value) {
29
- this.conditions.push({ column, operator: "gt", value });
30
- return this;
31
- }
32
- // Less than
33
- lt(column, value) {
34
- this.conditions.push({ column, operator: "lt", value });
35
- return this;
36
- }
37
- // Greater than or equal to
38
- gte(column, value) {
39
- this.conditions.push({ column, operator: "gte", value });
40
- return this;
41
- }
42
- // Less than or equal to
43
- lte(column, value) {
44
- this.conditions.push({ column, operator: "lte", value });
45
- return this;
46
- }
47
- // LIKE (pattern match)
48
- like(column, pattern) {
49
- this.conditions.push({ column, operator: "like", value: pattern });
50
- return this;
51
- }
52
- // IN (for multiple values)
53
- in(column, values) {
54
- this.conditions.push({ column, operator: "in", value: values });
55
- return this;
56
- }
57
- // IS NULL
58
- isNull(column) {
59
- this.conditions.push({ column, operator: "is", value: null });
60
- return this;
61
- }
62
- // IS NOT NULL
63
- isNotNull(column) {
64
- this.conditions.push({ column, operator: "is", value: { not: null } });
65
- return this;
66
- }
67
- // BETWEEN (for range checking)
68
- between(column, start, end) {
69
- this.conditions.push({ column, operator: "between", value: [start, end] });
70
- return this;
71
- }
72
- // Build and return the final condition object
73
- build() {
74
- // if (this.conditions.length === 1) {
75
- // return this.conditions; // Direct return if only one condition
76
- // }
77
- return { AND: this.conditions }; // If multiple conditions, combine using AND
78
- }
79
- }
@@ -1,11 +0,0 @@
1
- type Listener<T = any> = (event: T) => void;
2
- export declare class EventEmitter {
3
- private events;
4
- constructor();
5
- on<T = any>(eventName: string, listener: Listener<T>): void;
6
- once<T = any>(eventName: string, listener: Listener<T>): void;
7
- removeListener<T = any>(eventName: string, listener: Listener<T>): void;
8
- emit<T = any>(eventName: string, data?: T): void;
9
- }
10
- export declare const EmitterSingleton: EventEmitter;
11
- export {};
@@ -1,41 +0,0 @@
1
- export class EventEmitter {
2
- constructor() {
3
- this.events = new Map();
4
- this.on = this.on.bind(this);
5
- this.once = this.once.bind(this);
6
- this.emit = this.emit.bind(this);
7
- this.removeListener = this.removeListener.bind(this);
8
- }
9
- // Subscribe to an event
10
- on(eventName, listener) {
11
- if (!this.events.has(eventName)) {
12
- this.events.set(eventName, []);
13
- }
14
- this.events.get(eventName).push(listener);
15
- }
16
- // Subscribe to an event for a single invocation
17
- once(eventName, listener) {
18
- const onceWrapper = (event) => {
19
- this.removeListener(eventName, onceWrapper);
20
- listener(event);
21
- };
22
- this.on(eventName, onceWrapper);
23
- }
24
- // Remove a specific listener
25
- removeListener(eventName, listener) {
26
- const listeners = this.events.get(eventName);
27
- if (!listeners)
28
- return;
29
- this.events.set(eventName, listeners.filter((l) => l !== listener));
30
- }
31
- // Emit an event
32
- emit(eventName, data) {
33
- const listeners = this.events.get(eventName);
34
- console.log("emit", eventName, data, listeners);
35
- if (!listeners)
36
- return;
37
- listeners.forEach((listener) => listener(data));
38
- }
39
- }
40
- const emitter = new EventEmitter();
41
- export const EmitterSingleton = emitter;
@@ -1,6 +0,0 @@
1
- import React from "react";
2
- import { EventEmitter } from "./EventEmitter";
3
- export declare const EventEmitterProvider: React.FC<{
4
- children: React.ReactNode;
5
- }>;
6
- export declare const useEventEmitter: () => EventEmitter;
@@ -1,19 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createContext, useContext, useRef } from "react";
4
- import { EmitterSingleton } from "./EventEmitter";
5
- // Create the Context
6
- const EventEmitterContext = createContext(null);
7
- // Provider Component
8
- export const EventEmitterProvider = ({ children }) => {
9
- const eventEmitterRef = useRef(EmitterSingleton);
10
- return (_jsx(EventEmitterContext.Provider, { value: eventEmitterRef.current, children: children }));
11
- };
12
- // Hook to use the EventEmitter
13
- export const useEventEmitter = () => {
14
- const context = useContext(EventEmitterContext);
15
- if (!context) {
16
- throw new Error("useEventEmitter must be used within an EventEmitterProvider");
17
- }
18
- return context;
19
- };
@@ -1,8 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { RimoriClient } from '../RimoriClient';
3
- interface PluginProviderProps {
4
- children: ReactNode;
5
- }
6
- export declare const PluginProvider: React.FC<PluginProviderProps>;
7
- export declare const usePlugin: () => RimoriClient;
8
- export {};
@@ -1,49 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext, useEffect, useState } from 'react';
3
- import { PluginController } from '../PluginController';
4
- const PluginContext = createContext(null);
5
- export const PluginProvider = ({ children }) => {
6
- const [plugin, setPlugin] = useState(null);
7
- //route change
8
- useEffect(() => {
9
- let lastHash = window.location.hash;
10
- setInterval(() => {
11
- if (lastHash !== window.location.hash) {
12
- lastHash = window.location.hash;
13
- console.log('url changed:', lastHash);
14
- plugin === null || plugin === void 0 ? void 0 : plugin.emit('urlChange', window.location.hash);
15
- }
16
- }, 100);
17
- PluginController.getInstance().then(setPlugin);
18
- }, []);
19
- //context menu
20
- useEffect(() => {
21
- let isOpen = false;
22
- const handleContextMenu = (e) => {
23
- var _a;
24
- const selection = (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString().trim();
25
- if (selection) {
26
- e.preventDefault();
27
- // console.log('context menu', selection);
28
- plugin === null || plugin === void 0 ? void 0 : plugin.emit('contextMenu', { text: selection, x: e.clientX, y: e.clientY, open: true });
29
- isOpen = true;
30
- }
31
- };
32
- // Hide the menu on click outside
33
- const handleClick = () => isOpen && (plugin === null || plugin === void 0 ? void 0 : plugin.emit('contextMenu', { text: '', x: 0, y: 0, open: false }));
34
- document.addEventListener("click", handleClick);
35
- document.addEventListener('contextmenu', handleContextMenu);
36
- return () => {
37
- document.removeEventListener("click", handleClick);
38
- document.removeEventListener('contextmenu', handleContextMenu);
39
- };
40
- }, [plugin]);
41
- return (_jsx(PluginContext.Provider, { value: plugin, children: children }));
42
- };
43
- export const usePlugin = () => {
44
- const context = useContext(PluginContext);
45
- if (context === null) {
46
- throw new Error('usePlugin must be used within an PluginProvider');
47
- }
48
- return context;
49
- };
@@ -1,48 +0,0 @@
1
- type Listener<T = any> = (event: T) => void;
2
-
3
- export class EventEmitter {
4
- private events: Map<string, Listener[]> = new Map();
5
-
6
- constructor() {
7
- this.on = this.on.bind(this);
8
- this.once = this.once.bind(this);
9
- this.emit = this.emit.bind(this);
10
- this.removeListener = this.removeListener.bind(this);
11
- }
12
-
13
- // Subscribe to an event
14
- on<T = any>(eventName: string, listener: Listener<T>): void {
15
- if (!this.events.has(eventName)) {
16
- this.events.set(eventName, []);
17
- }
18
- this.events.get(eventName)!.push(listener);
19
- }
20
-
21
- // Subscribe to an event for a single invocation
22
- once<T = any>(eventName: string, listener: Listener<T>): void {
23
- const onceWrapper: Listener<T> = (event) => {
24
- this.removeListener(eventName, onceWrapper);
25
- listener(event);
26
- };
27
- this.on(eventName, onceWrapper);
28
- }
29
-
30
- // Remove a specific listener
31
- removeListener<T = any>(eventName: string, listener: Listener<T>): void {
32
- const listeners = this.events.get(eventName);
33
- if (!listeners) return;
34
-
35
- this.events.set(eventName, listeners.filter((l) => l !== listener));
36
- }
37
-
38
- // Emit an event
39
- emit<T = any>(eventName: string, data?: T): void {
40
- const listeners = this.events.get(eventName);
41
- console.log("emit", eventName, data, listeners);
42
- if (!listeners) return;
43
-
44
- listeners.forEach((listener) => listener(data));
45
- }
46
- }
47
- const emitter = new EventEmitter();
48
- export const EmitterSingleton = emitter;
@@ -1,27 +0,0 @@
1
- "use client";
2
-
3
- import React, { createContext, useContext, useRef } from "react";
4
- import { EmitterSingleton, EventEmitter } from "./EventEmitter";
5
-
6
- // Create the Context
7
- const EventEmitterContext = createContext<EventEmitter | null>(null);
8
-
9
- // Provider Component
10
- export const EventEmitterProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
11
- const eventEmitterRef = useRef(EmitterSingleton);
12
-
13
- return (
14
- <EventEmitterContext.Provider value={eventEmitterRef.current}>
15
- {children}
16
- </EventEmitterContext.Provider>
17
- );
18
- };
19
-
20
- // Hook to use the EventEmitter
21
- export const useEventEmitter = (): EventEmitter => {
22
- const context = useContext(EventEmitterContext);
23
- if (!context) {
24
- throw new Error("useEventEmitter must be used within an EventEmitterProvider");
25
- }
26
- return context;
27
- };
@@ -1,18 +0,0 @@
1
- // import { unstable_noStore as noStore } from 'next/cache';
2
-
3
- // noStore();
4
-
5
- export type Env = typeof env;
6
-
7
- export const env = {
8
- // SUPABASE_URL: process?.env?.SUPABASE_URL || "https://pheptqdoqsdnadgoihvr.supabase.co",
9
- SUPABASE_URL: "https://pheptqdoqsdnadgoihvr.supabase.co",
10
- // SUPABASE_ANON_KEY: process.env.SUPABASE_ANON_KEY,
11
- };
12
-
13
- // Validate all environment variables are set
14
- Object.entries(env).forEach(([key, value]) => {
15
- if (!value) {
16
- throw new Error(`${key} is not set`);
17
- }
18
- });