@bikdotai/bik-component-library 0.0.777-beta.22 → 0.0.777-beta.24
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/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.d.ts +8 -6
- package/dist/cjs/components/WhatsAppTextEditor/ai/aiTag.d.ts +15 -10
- package/dist/cjs/components/WhatsAppTextEditor/ai/aiTag.js +1 -1
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.d.ts +8 -6
- package/dist/esm/components/WhatsAppTextEditor/ai/aiTag.d.ts +15 -10
- package/dist/esm/components/WhatsAppTextEditor/ai/aiTag.js +1 -1
- package/package.json +1 -1
|
@@ -71,9 +71,10 @@ export type CustomEditorProps = React.TextareaHTMLAttributes<HTMLTextAreaElement
|
|
|
71
71
|
instructionSuggestions?: string[];
|
|
72
72
|
onAnalyticsEvent?: (name: AIEventName, payload: AIEventPayload) => void;
|
|
73
73
|
/**
|
|
74
|
-
* Fires
|
|
75
|
-
*
|
|
76
|
-
*
|
|
74
|
+
* Fires on AI-tag computations:
|
|
75
|
+
* - `source: "accept"` after accepting a suggestion (addition check: >=50% => true)
|
|
76
|
+
* - `source: "post_edit_debounce"` after edit idle/blur (retention check: <50% => true)
|
|
77
|
+
* Persist `payload.isAiTagged` (or full payload) in host state and send on save.
|
|
77
78
|
*/
|
|
78
79
|
onAITagComputed?: (payload: AITagPayload) => void;
|
|
79
80
|
/**
|
|
@@ -139,9 +140,10 @@ export declare const WhatsAppTextEditor: React.ForwardRefExoticComponent<React.T
|
|
|
139
140
|
instructionSuggestions?: string[] | undefined;
|
|
140
141
|
onAnalyticsEvent?: ((name: AIEventName, payload: AIEventPayload) => void) | undefined;
|
|
141
142
|
/**
|
|
142
|
-
* Fires
|
|
143
|
-
*
|
|
144
|
-
*
|
|
143
|
+
* Fires on AI-tag computations:
|
|
144
|
+
* - `source: "accept"` after accepting a suggestion (addition check: >=50% => true)
|
|
145
|
+
* - `source: "post_edit_debounce"` after edit idle/blur (retention check: <50% => true)
|
|
146
|
+
* Persist `payload.isAiTagged` (or full payload) in host state and send on save.
|
|
145
147
|
*/
|
|
146
148
|
onAITagComputed?: ((payload: AITagPayload) => void) | undefined;
|
|
147
149
|
/**
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AI
|
|
3
|
-
* (baseline) and what they accepted is at least half of the longer of the two strings.
|
|
2
|
+
* AI tag math shared by accept and post-edit flows.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* `changePercent` is always computed as:
|
|
5
|
+
* levenshteinDistance(aiBaseline, currentText) / max(len(aiBaseline), len(currentText), 1)
|
|
6
|
+
*
|
|
7
|
+
* `isAiTagged` interpretation is source-specific:
|
|
8
|
+
* - `accept`: addition check (`>= 50%` => true)
|
|
9
|
+
* - `post_edit_debounce`: retention check (`< 50%` => true)
|
|
9
10
|
*/
|
|
10
11
|
export declare const AI_TAG_CHANGE_RATIO_THRESHOLD = 0.5;
|
|
11
12
|
export type AITagPayload = {
|
|
12
13
|
changedCharacters: number;
|
|
13
14
|
templateLength: number;
|
|
14
15
|
changePercent: number;
|
|
15
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Interpretation depends on source:
|
|
18
|
+
* - `accept`: true when changedCharacters / templateLength >= threshold.
|
|
19
|
+
* - `post_edit_debounce`: true when changedCharacters / templateLength < threshold.
|
|
20
|
+
*/
|
|
16
21
|
isAiTagged: boolean;
|
|
17
22
|
/**
|
|
18
23
|
* True when this accept occurred during the “initial AI prefill” phase: the host
|
|
@@ -51,8 +56,8 @@ export declare function levenshteinDistance(a: string, b: string): number;
|
|
|
51
56
|
*/
|
|
52
57
|
export declare function computeAiTagOnAccept(input: ComputeAiTagOnAcceptInput): AITagPayload;
|
|
53
58
|
/**
|
|
54
|
-
* Computes AI tag after user edits
|
|
55
|
-
*
|
|
56
|
-
*
|
|
59
|
+
* Computes AI tag after user edits AI-derived text.
|
|
60
|
+
* Post-edit is a retention check: if drift from AI baseline reaches >= 50%,
|
|
61
|
+
* the text is treated as no longer AI-tagged.
|
|
57
62
|
*/
|
|
58
63
|
export declare function computeAiTagOnPostEdit(input: ComputeAiTagOnPostEditInput): AITagPayload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function e(e,t){const n=e.length,i=t.length,a=Array(i+1).fill(0).map(((e,t)=>t));for(let r=1;r<=n;r++){let n=a[0];a[0]=r;for(let c=1;c<=i;c++){const i=a[c];e[r-1]===t[c-1]?a[c]=n:a[c]=Math.min(a[c-1],a[c],n)+1,n=i}}return a[i]}exports.AI_TAG_CHANGE_RATIO_THRESHOLD=.5,exports.computeAiTagOnAccept=function(t){const{baselineText:n,acceptedText:i,initialAiPrefillPhase:a}=t,r=e(n,i),c=Math.max(n.length,i.length,1),l=r/c;return{changedCharacters:r,templateLength:c,changePercent:l,isAiTagged:l>=.5,initialAiPrefillPhase:a}},exports.computeAiTagOnPostEdit=function(t){const{acceptedAiText:n,currentEditedText:i}=t,a=e(n,i),r=Math.max(n.length,i.length,1),c=a/r;return{changedCharacters:a,templateLength:r,changePercent:c,isAiTagged:c
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function e(e,t){const n=e.length,i=t.length,a=Array(i+1).fill(0).map(((e,t)=>t));for(let r=1;r<=n;r++){let n=a[0];a[0]=r;for(let c=1;c<=i;c++){const i=a[c];e[r-1]===t[c-1]?a[c]=n:a[c]=Math.min(a[c-1],a[c],n)+1,n=i}}return a[i]}exports.AI_TAG_CHANGE_RATIO_THRESHOLD=.5,exports.computeAiTagOnAccept=function(t){const{baselineText:n,acceptedText:i,initialAiPrefillPhase:a}=t,r=e(n,i),c=Math.max(n.length,i.length,1),l=r/c;return{changedCharacters:r,templateLength:c,changePercent:l,isAiTagged:l>=.5,initialAiPrefillPhase:a}},exports.computeAiTagOnPostEdit=function(t){const{acceptedAiText:n,currentEditedText:i}=t,a=e(n,i),r=Math.max(n.length,i.length,1),c=a/r;return{changedCharacters:a,templateLength:r,changePercent:c,isAiTagged:c<.5,initialAiPrefillPhase:!1}},exports.levenshteinDistance=e;
|
|
@@ -71,9 +71,10 @@ export type CustomEditorProps = React.TextareaHTMLAttributes<HTMLTextAreaElement
|
|
|
71
71
|
instructionSuggestions?: string[];
|
|
72
72
|
onAnalyticsEvent?: (name: AIEventName, payload: AIEventPayload) => void;
|
|
73
73
|
/**
|
|
74
|
-
* Fires
|
|
75
|
-
*
|
|
76
|
-
*
|
|
74
|
+
* Fires on AI-tag computations:
|
|
75
|
+
* - `source: "accept"` after accepting a suggestion (addition check: >=50% => true)
|
|
76
|
+
* - `source: "post_edit_debounce"` after edit idle/blur (retention check: <50% => true)
|
|
77
|
+
* Persist `payload.isAiTagged` (or full payload) in host state and send on save.
|
|
77
78
|
*/
|
|
78
79
|
onAITagComputed?: (payload: AITagPayload) => void;
|
|
79
80
|
/**
|
|
@@ -139,9 +140,10 @@ export declare const WhatsAppTextEditor: React.ForwardRefExoticComponent<React.T
|
|
|
139
140
|
instructionSuggestions?: string[] | undefined;
|
|
140
141
|
onAnalyticsEvent?: ((name: AIEventName, payload: AIEventPayload) => void) | undefined;
|
|
141
142
|
/**
|
|
142
|
-
* Fires
|
|
143
|
-
*
|
|
144
|
-
*
|
|
143
|
+
* Fires on AI-tag computations:
|
|
144
|
+
* - `source: "accept"` after accepting a suggestion (addition check: >=50% => true)
|
|
145
|
+
* - `source: "post_edit_debounce"` after edit idle/blur (retention check: <50% => true)
|
|
146
|
+
* Persist `payload.isAiTagged` (or full payload) in host state and send on save.
|
|
145
147
|
*/
|
|
146
148
|
onAITagComputed?: ((payload: AITagPayload) => void) | undefined;
|
|
147
149
|
/**
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AI
|
|
3
|
-
* (baseline) and what they accepted is at least half of the longer of the two strings.
|
|
2
|
+
* AI tag math shared by accept and post-edit flows.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* `changePercent` is always computed as:
|
|
5
|
+
* levenshteinDistance(aiBaseline, currentText) / max(len(aiBaseline), len(currentText), 1)
|
|
6
|
+
*
|
|
7
|
+
* `isAiTagged` interpretation is source-specific:
|
|
8
|
+
* - `accept`: addition check (`>= 50%` => true)
|
|
9
|
+
* - `post_edit_debounce`: retention check (`< 50%` => true)
|
|
9
10
|
*/
|
|
10
11
|
export declare const AI_TAG_CHANGE_RATIO_THRESHOLD = 0.5;
|
|
11
12
|
export type AITagPayload = {
|
|
12
13
|
changedCharacters: number;
|
|
13
14
|
templateLength: number;
|
|
14
15
|
changePercent: number;
|
|
15
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Interpretation depends on source:
|
|
18
|
+
* - `accept`: true when changedCharacters / templateLength >= threshold.
|
|
19
|
+
* - `post_edit_debounce`: true when changedCharacters / templateLength < threshold.
|
|
20
|
+
*/
|
|
16
21
|
isAiTagged: boolean;
|
|
17
22
|
/**
|
|
18
23
|
* True when this accept occurred during the “initial AI prefill” phase: the host
|
|
@@ -51,8 +56,8 @@ export declare function levenshteinDistance(a: string, b: string): number;
|
|
|
51
56
|
*/
|
|
52
57
|
export declare function computeAiTagOnAccept(input: ComputeAiTagOnAcceptInput): AITagPayload;
|
|
53
58
|
/**
|
|
54
|
-
* Computes AI tag after user edits
|
|
55
|
-
*
|
|
56
|
-
*
|
|
59
|
+
* Computes AI tag after user edits AI-derived text.
|
|
60
|
+
* Post-edit is a retention check: if drift from AI baseline reaches >= 50%,
|
|
61
|
+
* the text is treated as no longer AI-tagged.
|
|
57
62
|
*/
|
|
58
63
|
export declare function computeAiTagOnPostEdit(input: ComputeAiTagOnPostEditInput): AITagPayload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=.5;function t(e,t){const n=e.length,a=t.length,i=Array(a+1).fill(0).map(((e,t)=>t));for(let l=1;l<=n;l++){let n=i[0];i[0]=l;for(let r=1;r<=a;r++){const a=i[r];e[l-1]===t[r-1]?i[r]=n:i[r]=Math.min(i[r-1],i[r],n)+1,n=a}}return i[a]}function n(e){const{baselineText:n,acceptedText:a,initialAiPrefillPhase:i}=e,l=t(n,a),r=Math.max(n.length,a.length,1),c=l/r;return{changedCharacters:l,templateLength:r,changePercent:c,isAiTagged:c>=.5,initialAiPrefillPhase:i}}function a(e){const{acceptedAiText:n,currentEditedText:a}=e,i=t(n,a),l=Math.max(n.length,a.length,1),r=i/l;return{changedCharacters:i,templateLength:l,changePercent:r,isAiTagged:r
|
|
1
|
+
const e=.5;function t(e,t){const n=e.length,a=t.length,i=Array(a+1).fill(0).map(((e,t)=>t));for(let l=1;l<=n;l++){let n=i[0];i[0]=l;for(let r=1;r<=a;r++){const a=i[r];e[l-1]===t[r-1]?i[r]=n:i[r]=Math.min(i[r-1],i[r],n)+1,n=a}}return i[a]}function n(e){const{baselineText:n,acceptedText:a,initialAiPrefillPhase:i}=e,l=t(n,a),r=Math.max(n.length,a.length,1),c=l/r;return{changedCharacters:l,templateLength:r,changePercent:c,isAiTagged:c>=.5,initialAiPrefillPhase:i}}function a(e){const{acceptedAiText:n,currentEditedText:a}=e,i=t(n,a),l=Math.max(n.length,a.length,1),r=i/l;return{changedCharacters:i,templateLength:l,changePercent:r,isAiTagged:r<.5,initialAiPrefillPhase:!1}}export{e as AI_TAG_CHANGE_RATIO_THRESHOLD,n as computeAiTagOnAccept,a as computeAiTagOnPostEdit,t as levenshteinDistance};
|