microboard-temp 0.1.21 → 0.1.22

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/esm/index.js CHANGED
@@ -7986,7 +7986,7 @@ var Browser = /* @__PURE__ */ function() {
7986
7986
  }();
7987
7987
  Browser.type = "languageDetector";
7988
7988
 
7989
- // src/api/initI18N.ts
7989
+ // src/api/initDefaultI18N.ts
7990
7990
  var defaultNS = "default";
7991
7991
  var resources = {
7992
7992
  en: {
@@ -7996,7 +7996,7 @@ var resources = {
7996
7996
  default: {}
7997
7997
  }
7998
7998
  };
7999
- function initI18N(isNode = false) {
7999
+ function initDefaultI18N() {
8000
8000
  instance.use(Browser).init({
8001
8001
  debug: conf2.debug,
8002
8002
  detection: {
@@ -8353,7 +8353,7 @@ var conf2 = {
8353
8353
  FALLBACK_LNG: "en",
8354
8354
  cursorsMap
8355
8355
  };
8356
- initI18N();
8356
+ initDefaultI18N();
8357
8357
 
8358
8358
  // src/Items/Transformation/Matrix.ts
8359
8359
  class Matrix2 {
@@ -26663,8 +26663,6 @@ function setNodeStyles({
26663
26663
  }
26664
26664
 
26665
26665
  // src/Items/RichText/editorHelpers/markdown/markdownProcessor.ts
26666
- var { i18n: i18n2 } = conf2;
26667
-
26668
26666
  class MarkdownProcessor {
26669
26667
  chunksQueue = [];
26670
26668
  isProcessingChunk = false;
@@ -26695,7 +26693,7 @@ class MarkdownProcessor {
26695
26693
  this.subject.publish(this);
26696
26694
  return true;
26697
26695
  }
26698
- if (i18n2.t && text3.startsWith(i18n2.t("AIInput.generatingResponse"))) {
26696
+ if (text3.startsWith(conf2.i18n.t("AIInput.generatingResponse"))) {
26699
26697
  return true;
26700
26698
  }
26701
26699
  const isPrevTextEmpty = isTextEmpty(this.editor.children);
@@ -26753,7 +26751,7 @@ class MarkdownProcessor {
26753
26751
  return;
26754
26752
  }
26755
26753
  const prevText = this.getText()?.[this.getText().length - 1]?.children[0]?.text;
26756
- if (i18n2.t && prevText?.startsWith(i18n2.t("AIInput.generatingResponse"))) {
26754
+ if (prevText?.startsWith(conf2.i18n.t("AIInput.generatingResponse"))) {
26757
26755
  clearText(this.editor);
26758
26756
  }
26759
26757
  if (chunk.includes(`
@@ -29038,7 +29036,6 @@ class BaseItem extends Mbr {
29038
29036
  }
29039
29037
 
29040
29038
  // src/Items/RichText/RichText.ts
29041
- var { i18n: i18n3 } = conf2;
29042
29039
  var isEditInProcessValue = false;
29043
29040
  var counter = 0;
29044
29041
 
@@ -29074,7 +29071,7 @@ class RichText extends BaseItem {
29074
29071
  shrinkWidth = false;
29075
29072
  prevMbr = null;
29076
29073
  rtCounter = 0;
29077
- constructor(board, container, id = "", transformation = new Transformation(id, board.events), linkTo, placeholderText = i18n3?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf2.DEFAULT_TEXT_STYLES) {
29074
+ constructor(board, container, id = "", transformation = new Transformation(id, board.events), linkTo, placeholderText = conf2.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf2.DEFAULT_TEXT_STYLES) {
29078
29075
  super(board, id);
29079
29076
  this.container = container;
29080
29077
  this.transformation = transformation;
@@ -44210,7 +44207,6 @@ function getLine(lineStyle, start2, end2, middle) {
44210
44207
  }
44211
44208
  }
44212
44209
  // src/Items/Connector/Connector.ts
44213
- var { i18n: i18n4 } = conf2;
44214
44210
  var ConnectionLineWidths = [1, 2, 3, 4, 5, 6, 7, 8, 12];
44215
44211
  var CONNECTOR_COLOR = "rgb(20, 21, 26)";
44216
44212
  var CONNECTOR_LINE_WIDTH = 1;
@@ -44265,7 +44261,7 @@ class Connector2 extends BaseItem {
44265
44261
  this.lineColor = lineColor ?? CONNECTOR_COLOR;
44266
44262
  this.lineWidth = lineWidth ?? CONNECTOR_LINE_WIDTH;
44267
44263
  this.borderStyle = strokeStyle ?? CONNECTOR_BORDER_STYLE;
44268
- this.text = new RichText(board, this.getMbr(), this.id, new Transformation, this.linkTo, i18n4.t("connector.textPlaceholder", {
44264
+ this.text = new RichText(board, this.getMbr(), this.id, new Transformation, this.linkTo, conf2.i18n.t("connector.textPlaceholder", {
44269
44265
  ns: "default"
44270
44266
  }), true, false, "Connector", {
44271
44267
  ...conf2.DEFAULT_TEXT_STYLES,
@@ -63999,54 +63995,26 @@ function handleChatChunk(chunk, board) {
63999
63995
  const item = board.items.getById(itemId);
64000
63996
  switch (chunk.type) {
64001
63997
  case "chunk":
64002
- if (!item || item.itemType !== "AINode") {
63998
+ if (!item2 || item2.itemType !== "AINode") {
64003
63999
  return;
64004
64000
  }
64005
- item.text.editor.markdownProcessor.processMarkdown(chunk.content || "");
64001
+ item2.getRichText()?.editor.markdownProcessor.processMarkdown(chunk.content || "");
64006
64002
  break;
64007
64003
  case "done":
64008
- if (!item || item.itemType !== "AINode") {
64004
+ if (!item2 || item2.itemType !== "AINode") {
64009
64005
  board.aiGeneratingOnItem = undefined;
64010
64006
  return;
64011
64007
  }
64012
- item.getRichText().editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
64008
+ item2.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
64013
64009
  break;
64014
64010
  case "end":
64015
- if (!item || item.itemType !== "AINode") {
64011
+ if (!item2 || item2.itemType !== "AINode") {
64016
64012
  board.aiGeneratingOnItem = undefined;
64017
64013
  return;
64018
64014
  }
64019
- item.getRichText().editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
64015
+ item2.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
64020
64016
  break;
64021
64017
  case "error":
64022
- board.camera.unsubscribeFromItem();
64023
- if (board.aiGeneratingOnItem) {
64024
- const item2 = board.items.getById(board.aiGeneratingOnItem);
64025
- if (item2) {
64026
- board.selection.removeAll();
64027
- board.selection.add(item2);
64028
- if (item2.itemType === "AINode") {
64029
- item2.getRichText().editor.markdownProcessor.setStopProcessingMarkDownCb(null);
64030
- if (chunk.isExternalApiError) {
64031
- const editor = item2.getRichText().editor;
64032
- editor.clearText();
64033
- editor.insertCopiedText(conf2.i18n.t("AIInput.nodeErrorText"));
64034
- }
64035
- }
64036
- board.camera.zoomToFit(item2.getMbr(), 20);
64037
- }
64038
- }
64039
- console.log("Error AI generate", chunk.error);
64040
- if (!chunk.isExternalApiError) {
64041
- conf2.notify({
64042
- header: conf2.i18n.t("AIInput.textGenerationError.header"),
64043
- body: conf2.i18n.t("AIInput.textGenerationError.body"),
64044
- variant: "error",
64045
- duration: 4000
64046
- });
64047
- }
64048
- board.aiGeneratingOnItem = undefined;
64049
- break;
64050
64018
  default:
64051
64019
  board.camera.unsubscribeFromItem();
64052
64020
  if (!chunk.isExternalApiError) {
@@ -64057,23 +64025,23 @@ function handleChatChunk(chunk, board) {
64057
64025
  duration: 4000
64058
64026
  });
64059
64027
  }
64060
- if (board.aiGeneratingOnItem) {
64061
- const item2 = board.items.getById(board.aiGeneratingOnItem);
64062
- if (item2) {
64063
- board.selection.removeAll();
64064
- board.selection.add(item2);
64065
- if (item2.itemType === "AINode") {
64066
- item2.getRichText().editor.markdownProcessor.setStopProcessingMarkDownCb(null);
64067
- if (chunk.isExternalApiError) {
64068
- const editor = item2.getRichText().editor;
64069
- editor.clearText();
64070
- editor.insertCopiedText(conf2.i18n.t("AIInput.nodeErrorText"));
64071
- }
64028
+ const item2 = board.items.getById(board.aiGeneratingOnItem || "");
64029
+ if (board.aiGeneratingOnItem && item2) {
64030
+ board.selection.removeAll();
64031
+ board.selection.add(item2);
64032
+ const rt = item2?.getRichText();
64033
+ if (item2.itemType === "AINode" && rt) {
64034
+ const editor = rt.editor;
64035
+ editor.markdownProcessor.setStopProcessingMarkDownCb(null);
64036
+ if (chunk.isExternalApiError) {
64037
+ editor.clearText();
64038
+ editor.insertCopiedText(conf2.i18n.t("AIInput.nodeErrorText"));
64072
64039
  }
64073
- board.camera.zoomToFit(item2.getMbr(), 20);
64074
64040
  }
64041
+ board.camera.zoomToFit(item2.getMbr(), 20);
64075
64042
  }
64076
64043
  board.aiGeneratingOnItem = undefined;
64044
+ break;
64077
64045
  }
64078
64046
  }
64079
64047
  function handleAudioGenerate(response, board) {
@@ -64464,6 +64432,15 @@ messageRouter.addHandler("AiChat", handleAiChatMassage);
64464
64432
  messageRouter.addHandler("Mode", handleModeMessage);
64465
64433
  messageRouter.addHandler("PresenceEvent", handlePresenceEventMessage);
64466
64434
  messageRouter.addHandler("UserJoin", handleUserJoinMessage);
64435
+ // src/api/initI18N.ts
64436
+ function initI18N(i18nInstance) {
64437
+ conf2.i18n = i18nInstance;
64438
+ conf2.planNames = {
64439
+ basic: i18nInstance.t("userPlan.plans.basic.name"),
64440
+ plus: i18nInstance.t("userPlan.plans.plus.name")
64441
+ };
64442
+ return i18nInstance;
64443
+ }
64467
64444
  export {
64468
64445
  validateRichTextData,
64469
64446
  validateMediaFile,
@@ -64505,6 +64482,7 @@ export {
64505
64482
  isHotkeyPushed,
64506
64483
  isFiniteNumber,
64507
64484
  isControlCharacter,
64485
+ initI18N,
64508
64486
  getYouTubeVideoPreview,
64509
64487
  getYouTubeThumbnail,
64510
64488
  getVideoMetadata,
package/dist/esm/node.js CHANGED
@@ -22807,7 +22807,7 @@ var Browser = /* @__PURE__ */ function() {
22807
22807
  }();
22808
22808
  Browser.type = "languageDetector";
22809
22809
 
22810
- // src/api/initI18N.ts
22810
+ // src/api/initDefaultI18N.ts
22811
22811
  var defaultNS = "default";
22812
22812
  var resources = {
22813
22813
  en: {
@@ -22817,7 +22817,7 @@ var resources = {
22817
22817
  default: {}
22818
22818
  }
22819
22819
  };
22820
- function initI18N(isNode = false) {
22820
+ function initDefaultI18N() {
22821
22821
  instance.use(Browser).init({
22822
22822
  debug: conf2.debug,
22823
22823
  detection: {
@@ -23174,7 +23174,7 @@ var conf2 = {
23174
23174
  FALLBACK_LNG: "en",
23175
23175
  cursorsMap
23176
23176
  };
23177
- initI18N();
23177
+ initDefaultI18N();
23178
23178
 
23179
23179
  // src/Items/Transformation/Matrix.ts
23180
23180
  class Matrix2 {
@@ -35143,8 +35143,6 @@ function setNodeStyles({
35143
35143
  }
35144
35144
 
35145
35145
  // src/Items/RichText/editorHelpers/markdown/markdownProcessor.ts
35146
- var { i18n: i18n2 } = conf2;
35147
-
35148
35146
  class MarkdownProcessor {
35149
35147
  chunksQueue = [];
35150
35148
  isProcessingChunk = false;
@@ -35175,7 +35173,7 @@ class MarkdownProcessor {
35175
35173
  this.subject.publish(this);
35176
35174
  return true;
35177
35175
  }
35178
- if (i18n2.t && text3.startsWith(i18n2.t("AIInput.generatingResponse"))) {
35176
+ if (text3.startsWith(conf2.i18n.t("AIInput.generatingResponse"))) {
35179
35177
  return true;
35180
35178
  }
35181
35179
  const isPrevTextEmpty = isTextEmpty(this.editor.children);
@@ -35233,7 +35231,7 @@ class MarkdownProcessor {
35233
35231
  return;
35234
35232
  }
35235
35233
  const prevText = this.getText()?.[this.getText().length - 1]?.children[0]?.text;
35236
- if (i18n2.t && prevText?.startsWith(i18n2.t("AIInput.generatingResponse"))) {
35234
+ if (prevText?.startsWith(conf2.i18n.t("AIInput.generatingResponse"))) {
35237
35235
  clearText(this.editor);
35238
35236
  }
35239
35237
  if (chunk.includes(`
@@ -37541,7 +37539,6 @@ class BaseItem extends Mbr {
37541
37539
  }
37542
37540
 
37543
37541
  // src/Items/RichText/RichText.ts
37544
- var { i18n: i18n3 } = conf2;
37545
37542
  var isEditInProcessValue = false;
37546
37543
  var counter = 0;
37547
37544
 
@@ -37577,7 +37574,7 @@ class RichText extends BaseItem {
37577
37574
  shrinkWidth = false;
37578
37575
  prevMbr = null;
37579
37576
  rtCounter = 0;
37580
- constructor(board, container, id = "", transformation = new Transformation(id, board.events), linkTo, placeholderText = i18n3?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf2.DEFAULT_TEXT_STYLES) {
37577
+ constructor(board, container, id = "", transformation = new Transformation(id, board.events), linkTo, placeholderText = conf2.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf2.DEFAULT_TEXT_STYLES) {
37581
37578
  super(board, id);
37582
37579
  this.container = container;
37583
37580
  this.transformation = transformation;
@@ -52714,7 +52711,6 @@ function getLine(lineStyle, start, end, middle) {
52714
52711
  }
52715
52712
  }
52716
52713
  // src/Items/Connector/Connector.ts
52717
- var { i18n: i18n4 } = conf2;
52718
52714
  var ConnectionLineWidths = [1, 2, 3, 4, 5, 6, 7, 8, 12];
52719
52715
  var CONNECTOR_COLOR = "rgb(20, 21, 26)";
52720
52716
  var CONNECTOR_LINE_WIDTH = 1;
@@ -52769,7 +52765,7 @@ class Connector2 extends BaseItem {
52769
52765
  this.lineColor = lineColor ?? CONNECTOR_COLOR;
52770
52766
  this.lineWidth = lineWidth ?? CONNECTOR_LINE_WIDTH;
52771
52767
  this.borderStyle = strokeStyle ?? CONNECTOR_BORDER_STYLE;
52772
- this.text = new RichText(board, this.getMbr(), this.id, new Transformation, this.linkTo, i18n4.t("connector.textPlaceholder", {
52768
+ this.text = new RichText(board, this.getMbr(), this.id, new Transformation, this.linkTo, conf2.i18n.t("connector.textPlaceholder", {
52773
52769
  ns: "default"
52774
52770
  }), true, false, "Connector", {
52775
52771
  ...conf2.DEFAULT_TEXT_STYLES,
@@ -72464,54 +72460,26 @@ function handleChatChunk(chunk, board) {
72464
72460
  const item = board.items.getById(itemId);
72465
72461
  switch (chunk.type) {
72466
72462
  case "chunk":
72467
- if (!item || item.itemType !== "AINode") {
72463
+ if (!item2 || item2.itemType !== "AINode") {
72468
72464
  return;
72469
72465
  }
72470
- item.text.editor.markdownProcessor.processMarkdown(chunk.content || "");
72466
+ item2.getRichText()?.editor.markdownProcessor.processMarkdown(chunk.content || "");
72471
72467
  break;
72472
72468
  case "done":
72473
- if (!item || item.itemType !== "AINode") {
72469
+ if (!item2 || item2.itemType !== "AINode") {
72474
72470
  board.aiGeneratingOnItem = undefined;
72475
72471
  return;
72476
72472
  }
72477
- item.getRichText().editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
72473
+ item2.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
72478
72474
  break;
72479
72475
  case "end":
72480
- if (!item || item.itemType !== "AINode") {
72476
+ if (!item2 || item2.itemType !== "AINode") {
72481
72477
  board.aiGeneratingOnItem = undefined;
72482
72478
  return;
72483
72479
  }
72484
- item.getRichText().editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
72480
+ item2.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
72485
72481
  break;
72486
72482
  case "error":
72487
- board.camera.unsubscribeFromItem();
72488
- if (board.aiGeneratingOnItem) {
72489
- const item2 = board.items.getById(board.aiGeneratingOnItem);
72490
- if (item2) {
72491
- board.selection.removeAll();
72492
- board.selection.add(item2);
72493
- if (item2.itemType === "AINode") {
72494
- item2.getRichText().editor.markdownProcessor.setStopProcessingMarkDownCb(null);
72495
- if (chunk.isExternalApiError) {
72496
- const editor = item2.getRichText().editor;
72497
- editor.clearText();
72498
- editor.insertCopiedText(conf2.i18n.t("AIInput.nodeErrorText"));
72499
- }
72500
- }
72501
- board.camera.zoomToFit(item2.getMbr(), 20);
72502
- }
72503
- }
72504
- console.log("Error AI generate", chunk.error);
72505
- if (!chunk.isExternalApiError) {
72506
- conf2.notify({
72507
- header: conf2.i18n.t("AIInput.textGenerationError.header"),
72508
- body: conf2.i18n.t("AIInput.textGenerationError.body"),
72509
- variant: "error",
72510
- duration: 4000
72511
- });
72512
- }
72513
- board.aiGeneratingOnItem = undefined;
72514
- break;
72515
72483
  default:
72516
72484
  board.camera.unsubscribeFromItem();
72517
72485
  if (!chunk.isExternalApiError) {
@@ -72522,23 +72490,23 @@ function handleChatChunk(chunk, board) {
72522
72490
  duration: 4000
72523
72491
  });
72524
72492
  }
72525
- if (board.aiGeneratingOnItem) {
72526
- const item2 = board.items.getById(board.aiGeneratingOnItem);
72527
- if (item2) {
72528
- board.selection.removeAll();
72529
- board.selection.add(item2);
72530
- if (item2.itemType === "AINode") {
72531
- item2.getRichText().editor.markdownProcessor.setStopProcessingMarkDownCb(null);
72532
- if (chunk.isExternalApiError) {
72533
- const editor = item2.getRichText().editor;
72534
- editor.clearText();
72535
- editor.insertCopiedText(conf2.i18n.t("AIInput.nodeErrorText"));
72536
- }
72493
+ const item2 = board.items.getById(board.aiGeneratingOnItem || "");
72494
+ if (board.aiGeneratingOnItem && item2) {
72495
+ board.selection.removeAll();
72496
+ board.selection.add(item2);
72497
+ const rt = item2?.getRichText();
72498
+ if (item2.itemType === "AINode" && rt) {
72499
+ const editor = rt.editor;
72500
+ editor.markdownProcessor.setStopProcessingMarkDownCb(null);
72501
+ if (chunk.isExternalApiError) {
72502
+ editor.clearText();
72503
+ editor.insertCopiedText(conf2.i18n.t("AIInput.nodeErrorText"));
72537
72504
  }
72538
- board.camera.zoomToFit(item2.getMbr(), 20);
72539
72505
  }
72506
+ board.camera.zoomToFit(item2.getMbr(), 20);
72540
72507
  }
72541
72508
  board.aiGeneratingOnItem = undefined;
72509
+ break;
72542
72510
  }
72543
72511
  }
72544
72512
  function handleAudioGenerate(response, board) {
@@ -72929,6 +72897,15 @@ messageRouter.addHandler("AiChat", handleAiChatMassage);
72929
72897
  messageRouter.addHandler("Mode", handleModeMessage);
72930
72898
  messageRouter.addHandler("PresenceEvent", handlePresenceEventMessage);
72931
72899
  messageRouter.addHandler("UserJoin", handleUserJoinMessage);
72900
+ // src/api/initI18N.ts
72901
+ function initI18N(i18nInstance) {
72902
+ conf2.i18n = i18nInstance;
72903
+ conf2.planNames = {
72904
+ basic: i18nInstance.t("userPlan.plans.basic.name"),
72905
+ plus: i18nInstance.t("userPlan.plans.plus.name")
72906
+ };
72907
+ return i18nInstance;
72908
+ }
72932
72909
  // src/api/NodeDOMParser.ts
72933
72910
  function getNodeDOMParser() {
72934
72911
  const { JSDOM } = __require("jsdom");
@@ -73125,6 +73102,7 @@ export {
73125
73102
  isHotkeyPushed,
73126
73103
  isFiniteNumber,
73127
73104
  isControlCharacter,
73105
+ initI18N,
73128
73106
  getYouTubeVideoPreview,
73129
73107
  getYouTubeThumbnail,
73130
73108
  getVideoMetadata,
@@ -0,0 +1,11 @@
1
+ import i18n from "i18next";
2
+ export declare const defaultNS = "default";
3
+ export declare const resources: {
4
+ en: {
5
+ default: {};
6
+ };
7
+ ru: {
8
+ default: {};
9
+ };
10
+ };
11
+ export declare function initDefaultI18N(): typeof i18n;
@@ -1,11 +1,6 @@
1
- import i18n from "i18next";
2
- export declare const defaultNS = "default";
3
- export declare const resources: {
4
- en: {
5
- default: {};
6
- };
7
- ru: {
8
- default: {};
9
- };
10
- };
11
- export declare function initI18N(isNode?: boolean): typeof i18n;
1
+ import type { i18n as I18nType } from "i18next";
2
+ /**
3
+ * Registers a pre-configured i18next instance on the global Settings.
4
+ * @param i18nInstance - An initialized i18next instance, already configured with plugins and options.
5
+ */
6
+ export declare function initI18N(i18nInstance: I18nType): I18nType;
@@ -22,3 +22,4 @@ export * from "./itemFactories";
22
22
  export * from "./parserHTML";
23
23
  export * from "./sha256";
24
24
  export * from "./lib";
25
+ export { initI18N } from "api/initI18N";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,2 +0,0 @@
1
- import i18n from "i18next";
2
- export declare function initI18NReact(isNode?: boolean): typeof i18n;