@univerjs/core 0.22.0 → 0.22.1-insiders.20260515-225d350

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/lib/cjs/index.js CHANGED
@@ -3337,6 +3337,9 @@ let CommandService = class CommandService extends Disposable {
3337
3337
  disposed() {
3338
3338
  return this._disposed;
3339
3339
  }
3340
+ _warnCommandSkippedAfterDisposed(id) {
3341
+ this._logService.warn("[CommandService]", `command "${id}" skipped because CommandService is disposed.`);
3342
+ }
3340
3343
  hasCommand(commandId) {
3341
3344
  return this._commandRegistry.hasCommand(commandId);
3342
3345
  }
@@ -3382,6 +3385,10 @@ let CommandService = class CommandService extends Disposable {
3382
3385
  throw new Error("[CommandService]: could not add a collab mutation listener twice.");
3383
3386
  }
3384
3387
  async executeCommand(id, params, options) {
3388
+ if (this._disposed) {
3389
+ this._warnCommandSkippedAfterDisposed(id);
3390
+ return false;
3391
+ }
3385
3392
  try {
3386
3393
  const item = this._commandRegistry.getCommand(id);
3387
3394
  if (item) {
@@ -3394,6 +3401,11 @@ let CommandService = class CommandService extends Disposable {
3394
3401
  const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
3395
3402
  const _options = options !== null && options !== void 0 ? options : {};
3396
3403
  this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
3404
+ if (this._disposed) {
3405
+ stackItemDisposable.dispose();
3406
+ this._warnCommandSkippedAfterDisposed(id);
3407
+ return false;
3408
+ }
3397
3409
  const result = await this._execute(command, params, _options);
3398
3410
  if (_options.syncOnly) {
3399
3411
  if (command.type === 2) this._collabMutationListeners.forEach((listener) => listener(commandInfo, _options));
@@ -3411,6 +3423,10 @@ let CommandService = class CommandService extends Disposable {
3411
3423
  }
3412
3424
  }
3413
3425
  syncExecuteCommand(id, params, options) {
3426
+ if (this._disposed) {
3427
+ this._warnCommandSkippedAfterDisposed(id);
3428
+ return false;
3429
+ }
3414
3430
  try {
3415
3431
  const item = this._commandRegistry.getCommand(id);
3416
3432
  if (item) {
@@ -3431,6 +3447,11 @@ let CommandService = class CommandService extends Disposable {
3431
3447
  const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
3432
3448
  const _options = options !== null && options !== void 0 ? options : {};
3433
3449
  this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
3450
+ if (this._disposed) {
3451
+ stackItemDisposable.dispose();
3452
+ this._warnCommandSkippedAfterDisposed(id);
3453
+ return false;
3454
+ }
3434
3455
  const result = this._syncExecute(command, params, _options);
3435
3456
  if (_options.syncOnly) {
3436
3457
  if (command.type === 2) this._collabMutationListeners.forEach((listener) => listener(commandInfo, _options));
@@ -3602,7 +3623,12 @@ function afterTime(ms) {
3602
3623
  }
3603
3624
  function convertObservableToBehaviorSubject(observable, initValue) {
3604
3625
  const subject = new rxjs.BehaviorSubject(initValue);
3605
- observable.subscribe(subject);
3626
+ const subscription = observable.subscribe(subject);
3627
+ const originalComplete = subject.complete.bind(subject);
3628
+ subject.complete = () => {
3629
+ subscription.unsubscribe();
3630
+ originalComplete();
3631
+ };
3606
3632
  return subject;
3607
3633
  }
3608
3634
 
@@ -9569,7 +9595,7 @@ const PRESET_LIST_TYPE = {
9569
9595
  ["BULLET_LIST_4"]: {
9570
9596
  listType: "BULLET_LIST",
9571
9597
  nestingLevel: bulletListFactory([
9572
- "",
9598
+ "",
9573
9599
  "○",
9574
9600
  "■"
9575
9601
  ])
@@ -14758,7 +14784,7 @@ const IURLImageService = (0, _wendellhu_redi.createIdentifier)("core.url-image.s
14758
14784
  //#endregion
14759
14785
  //#region package.json
14760
14786
  var name = "@univerjs/core";
14761
- var version = "0.22.0";
14787
+ var version = "0.22.1-insiders.20260515-225d350";
14762
14788
 
14763
14789
  //#endregion
14764
14790
  //#region src/sheets/empty-snapshot.ts
@@ -17641,6 +17667,8 @@ var LocaleService = class extends Disposable {
17641
17667
  super();
17642
17668
  _defineProperty(this, "_currentLocale$", new rxjs.BehaviorSubject("zhCN"));
17643
17669
  _defineProperty(this, "currentLocale$", this._currentLocale$.asObservable());
17670
+ _defineProperty(this, "_direction$", new rxjs.BehaviorSubject("ltr"));
17671
+ _defineProperty(this, "direction$", this._direction$.asObservable());
17644
17672
  _defineProperty(this, "_locales", null);
17645
17673
  _defineProperty(this, "localeChanged$", new rxjs.Subject());
17646
17674
  _defineProperty(
@@ -17687,6 +17715,7 @@ var LocaleService = class extends Disposable {
17687
17715
  this.disposeWithMe(toDisposable(() => {
17688
17716
  this._locales = null;
17689
17717
  this._currentLocale$.complete();
17718
+ this._direction$.complete();
17690
17719
  this.localeChanged$.complete();
17691
17720
  }));
17692
17721
  }
@@ -17710,6 +17739,12 @@ var LocaleService = class extends Disposable {
17710
17739
  getCurrentLocale() {
17711
17740
  return this._currentLocale;
17712
17741
  }
17742
+ setDirection(direction) {
17743
+ this._direction$.next(direction);
17744
+ }
17745
+ getDirection() {
17746
+ return this._direction$.value;
17747
+ }
17713
17748
  resolveKeyPath(obj, keys) {
17714
17749
  const currentKey = keys.shift();
17715
17750
  if (currentKey && obj && currentKey in obj) {
@@ -19891,11 +19926,12 @@ var Univer = class {
19891
19926
  _defineProperty(this, "_injector", void 0);
19892
19927
  _defineProperty(this, "_disposingCallbacks", new DisposableCollection());
19893
19928
  const injector = this._injector = createUniverInjector(parentInjector, config === null || config === void 0 ? void 0 : config.override);
19894
- const { theme, darkMode, locale, locales, logLevel, logCommandExecution } = config;
19929
+ const { theme, darkMode, locale, locales, direction, logLevel, logCommandExecution } = config;
19895
19930
  if (theme) this._injector.get(ThemeService).setTheme(theme);
19896
19931
  if (darkMode) this._injector.get(ThemeService).setDarkMode(darkMode);
19897
19932
  if (locales) this._injector.get(LocaleService).load(locales);
19898
19933
  if (locale) this._injector.get(LocaleService).setLocale(locale);
19934
+ if (direction) this._injector.get(LocaleService).setDirection(direction);
19899
19935
  if (logLevel) this._injector.get(ILogService).setLogLevel(logLevel);
19900
19936
  if (logCommandExecution !== void 0) this._injector.get(IConfigService).setConfig(COMMAND_LOG_EXECUTION_CONFIG_KEY, logCommandExecution);
19901
19937
  this._init(injector);
package/lib/es/index.js CHANGED
@@ -3303,6 +3303,9 @@ let CommandService = class CommandService extends Disposable {
3303
3303
  disposed() {
3304
3304
  return this._disposed;
3305
3305
  }
3306
+ _warnCommandSkippedAfterDisposed(id) {
3307
+ this._logService.warn("[CommandService]", `command "${id}" skipped because CommandService is disposed.`);
3308
+ }
3306
3309
  hasCommand(commandId) {
3307
3310
  return this._commandRegistry.hasCommand(commandId);
3308
3311
  }
@@ -3348,6 +3351,10 @@ let CommandService = class CommandService extends Disposable {
3348
3351
  throw new Error("[CommandService]: could not add a collab mutation listener twice.");
3349
3352
  }
3350
3353
  async executeCommand(id, params, options) {
3354
+ if (this._disposed) {
3355
+ this._warnCommandSkippedAfterDisposed(id);
3356
+ return false;
3357
+ }
3351
3358
  try {
3352
3359
  const item = this._commandRegistry.getCommand(id);
3353
3360
  if (item) {
@@ -3360,6 +3367,11 @@ let CommandService = class CommandService extends Disposable {
3360
3367
  const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
3361
3368
  const _options = options !== null && options !== void 0 ? options : {};
3362
3369
  this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
3370
+ if (this._disposed) {
3371
+ stackItemDisposable.dispose();
3372
+ this._warnCommandSkippedAfterDisposed(id);
3373
+ return false;
3374
+ }
3363
3375
  const result = await this._execute(command, params, _options);
3364
3376
  if (_options.syncOnly) {
3365
3377
  if (command.type === 2) this._collabMutationListeners.forEach((listener) => listener(commandInfo, _options));
@@ -3377,6 +3389,10 @@ let CommandService = class CommandService extends Disposable {
3377
3389
  }
3378
3390
  }
3379
3391
  syncExecuteCommand(id, params, options) {
3392
+ if (this._disposed) {
3393
+ this._warnCommandSkippedAfterDisposed(id);
3394
+ return false;
3395
+ }
3380
3396
  try {
3381
3397
  const item = this._commandRegistry.getCommand(id);
3382
3398
  if (item) {
@@ -3397,6 +3413,11 @@ let CommandService = class CommandService extends Disposable {
3397
3413
  const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
3398
3414
  const _options = options !== null && options !== void 0 ? options : {};
3399
3415
  this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
3416
+ if (this._disposed) {
3417
+ stackItemDisposable.dispose();
3418
+ this._warnCommandSkippedAfterDisposed(id);
3419
+ return false;
3420
+ }
3400
3421
  const result = this._syncExecute(command, params, _options);
3401
3422
  if (_options.syncOnly) {
3402
3423
  if (command.type === 2) this._collabMutationListeners.forEach((listener) => listener(commandInfo, _options));
@@ -3568,7 +3589,12 @@ function afterTime(ms) {
3568
3589
  }
3569
3590
  function convertObservableToBehaviorSubject(observable, initValue) {
3570
3591
  const subject = new BehaviorSubject(initValue);
3571
- observable.subscribe(subject);
3592
+ const subscription = observable.subscribe(subject);
3593
+ const originalComplete = subject.complete.bind(subject);
3594
+ subject.complete = () => {
3595
+ subscription.unsubscribe();
3596
+ originalComplete();
3597
+ };
3572
3598
  return subject;
3573
3599
  }
3574
3600
 
@@ -9535,7 +9561,7 @@ const PRESET_LIST_TYPE = {
9535
9561
  ["BULLET_LIST_4"]: {
9536
9562
  listType: "BULLET_LIST",
9537
9563
  nestingLevel: bulletListFactory([
9538
- "",
9564
+ "",
9539
9565
  "○",
9540
9566
  "■"
9541
9567
  ])
@@ -14724,7 +14750,7 @@ const IURLImageService = createIdentifier("core.url-image.service");
14724
14750
  //#endregion
14725
14751
  //#region package.json
14726
14752
  var name = "@univerjs/core";
14727
- var version = "0.22.0";
14753
+ var version = "0.22.1-insiders.20260515-225d350";
14728
14754
 
14729
14755
  //#endregion
14730
14756
  //#region src/sheets/empty-snapshot.ts
@@ -17607,6 +17633,8 @@ var LocaleService = class extends Disposable {
17607
17633
  super();
17608
17634
  _defineProperty(this, "_currentLocale$", new BehaviorSubject("zhCN"));
17609
17635
  _defineProperty(this, "currentLocale$", this._currentLocale$.asObservable());
17636
+ _defineProperty(this, "_direction$", new BehaviorSubject("ltr"));
17637
+ _defineProperty(this, "direction$", this._direction$.asObservable());
17610
17638
  _defineProperty(this, "_locales", null);
17611
17639
  _defineProperty(this, "localeChanged$", new Subject());
17612
17640
  _defineProperty(
@@ -17653,6 +17681,7 @@ var LocaleService = class extends Disposable {
17653
17681
  this.disposeWithMe(toDisposable(() => {
17654
17682
  this._locales = null;
17655
17683
  this._currentLocale$.complete();
17684
+ this._direction$.complete();
17656
17685
  this.localeChanged$.complete();
17657
17686
  }));
17658
17687
  }
@@ -17676,6 +17705,12 @@ var LocaleService = class extends Disposable {
17676
17705
  getCurrentLocale() {
17677
17706
  return this._currentLocale;
17678
17707
  }
17708
+ setDirection(direction) {
17709
+ this._direction$.next(direction);
17710
+ }
17711
+ getDirection() {
17712
+ return this._direction$.value;
17713
+ }
17679
17714
  resolveKeyPath(obj, keys) {
17680
17715
  const currentKey = keys.shift();
17681
17716
  if (currentKey && obj && currentKey in obj) {
@@ -19857,11 +19892,12 @@ var Univer = class {
19857
19892
  _defineProperty(this, "_injector", void 0);
19858
19893
  _defineProperty(this, "_disposingCallbacks", new DisposableCollection());
19859
19894
  const injector = this._injector = createUniverInjector(parentInjector, config === null || config === void 0 ? void 0 : config.override);
19860
- const { theme, darkMode, locale, locales, logLevel, logCommandExecution } = config;
19895
+ const { theme, darkMode, locale, locales, direction, logLevel, logCommandExecution } = config;
19861
19896
  if (theme) this._injector.get(ThemeService).setTheme(theme);
19862
19897
  if (darkMode) this._injector.get(ThemeService).setDarkMode(darkMode);
19863
19898
  if (locales) this._injector.get(LocaleService).load(locales);
19864
19899
  if (locale) this._injector.get(LocaleService).setLocale(locale);
19900
+ if (direction) this._injector.get(LocaleService).setDirection(direction);
19865
19901
  if (logLevel) this._injector.get(ILogService).setLogLevel(logLevel);
19866
19902
  if (logCommandExecution !== void 0) this._injector.get(IConfigService).setConfig(COMMAND_LOG_EXECUTION_CONFIG_KEY, logCommandExecution);
19867
19903
  this._init(injector);
package/lib/index.js CHANGED
@@ -3303,6 +3303,9 @@ let CommandService = class CommandService extends Disposable {
3303
3303
  disposed() {
3304
3304
  return this._disposed;
3305
3305
  }
3306
+ _warnCommandSkippedAfterDisposed(id) {
3307
+ this._logService.warn("[CommandService]", `command "${id}" skipped because CommandService is disposed.`);
3308
+ }
3306
3309
  hasCommand(commandId) {
3307
3310
  return this._commandRegistry.hasCommand(commandId);
3308
3311
  }
@@ -3348,6 +3351,10 @@ let CommandService = class CommandService extends Disposable {
3348
3351
  throw new Error("[CommandService]: could not add a collab mutation listener twice.");
3349
3352
  }
3350
3353
  async executeCommand(id, params, options) {
3354
+ if (this._disposed) {
3355
+ this._warnCommandSkippedAfterDisposed(id);
3356
+ return false;
3357
+ }
3351
3358
  try {
3352
3359
  const item = this._commandRegistry.getCommand(id);
3353
3360
  if (item) {
@@ -3360,6 +3367,11 @@ let CommandService = class CommandService extends Disposable {
3360
3367
  const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
3361
3368
  const _options = options !== null && options !== void 0 ? options : {};
3362
3369
  this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
3370
+ if (this._disposed) {
3371
+ stackItemDisposable.dispose();
3372
+ this._warnCommandSkippedAfterDisposed(id);
3373
+ return false;
3374
+ }
3363
3375
  const result = await this._execute(command, params, _options);
3364
3376
  if (_options.syncOnly) {
3365
3377
  if (command.type === 2) this._collabMutationListeners.forEach((listener) => listener(commandInfo, _options));
@@ -3377,6 +3389,10 @@ let CommandService = class CommandService extends Disposable {
3377
3389
  }
3378
3390
  }
3379
3391
  syncExecuteCommand(id, params, options) {
3392
+ if (this._disposed) {
3393
+ this._warnCommandSkippedAfterDisposed(id);
3394
+ return false;
3395
+ }
3380
3396
  try {
3381
3397
  const item = this._commandRegistry.getCommand(id);
3382
3398
  if (item) {
@@ -3397,6 +3413,11 @@ let CommandService = class CommandService extends Disposable {
3397
3413
  const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
3398
3414
  const _options = options !== null && options !== void 0 ? options : {};
3399
3415
  this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
3416
+ if (this._disposed) {
3417
+ stackItemDisposable.dispose();
3418
+ this._warnCommandSkippedAfterDisposed(id);
3419
+ return false;
3420
+ }
3400
3421
  const result = this._syncExecute(command, params, _options);
3401
3422
  if (_options.syncOnly) {
3402
3423
  if (command.type === 2) this._collabMutationListeners.forEach((listener) => listener(commandInfo, _options));
@@ -3568,7 +3589,12 @@ function afterTime(ms) {
3568
3589
  }
3569
3590
  function convertObservableToBehaviorSubject(observable, initValue) {
3570
3591
  const subject = new BehaviorSubject(initValue);
3571
- observable.subscribe(subject);
3592
+ const subscription = observable.subscribe(subject);
3593
+ const originalComplete = subject.complete.bind(subject);
3594
+ subject.complete = () => {
3595
+ subscription.unsubscribe();
3596
+ originalComplete();
3597
+ };
3572
3598
  return subject;
3573
3599
  }
3574
3600
 
@@ -9535,7 +9561,7 @@ const PRESET_LIST_TYPE = {
9535
9561
  ["BULLET_LIST_4"]: {
9536
9562
  listType: "BULLET_LIST",
9537
9563
  nestingLevel: bulletListFactory([
9538
- "",
9564
+ "",
9539
9565
  "○",
9540
9566
  "■"
9541
9567
  ])
@@ -14724,7 +14750,7 @@ const IURLImageService = createIdentifier("core.url-image.service");
14724
14750
  //#endregion
14725
14751
  //#region package.json
14726
14752
  var name = "@univerjs/core";
14727
- var version = "0.22.0";
14753
+ var version = "0.22.1-insiders.20260515-225d350";
14728
14754
 
14729
14755
  //#endregion
14730
14756
  //#region src/sheets/empty-snapshot.ts
@@ -17607,6 +17633,8 @@ var LocaleService = class extends Disposable {
17607
17633
  super();
17608
17634
  _defineProperty(this, "_currentLocale$", new BehaviorSubject("zhCN"));
17609
17635
  _defineProperty(this, "currentLocale$", this._currentLocale$.asObservable());
17636
+ _defineProperty(this, "_direction$", new BehaviorSubject("ltr"));
17637
+ _defineProperty(this, "direction$", this._direction$.asObservable());
17610
17638
  _defineProperty(this, "_locales", null);
17611
17639
  _defineProperty(this, "localeChanged$", new Subject());
17612
17640
  _defineProperty(
@@ -17653,6 +17681,7 @@ var LocaleService = class extends Disposable {
17653
17681
  this.disposeWithMe(toDisposable(() => {
17654
17682
  this._locales = null;
17655
17683
  this._currentLocale$.complete();
17684
+ this._direction$.complete();
17656
17685
  this.localeChanged$.complete();
17657
17686
  }));
17658
17687
  }
@@ -17676,6 +17705,12 @@ var LocaleService = class extends Disposable {
17676
17705
  getCurrentLocale() {
17677
17706
  return this._currentLocale;
17678
17707
  }
17708
+ setDirection(direction) {
17709
+ this._direction$.next(direction);
17710
+ }
17711
+ getDirection() {
17712
+ return this._direction$.value;
17713
+ }
17679
17714
  resolveKeyPath(obj, keys) {
17680
17715
  const currentKey = keys.shift();
17681
17716
  if (currentKey && obj && currentKey in obj) {
@@ -19857,11 +19892,12 @@ var Univer = class {
19857
19892
  _defineProperty(this, "_injector", void 0);
19858
19893
  _defineProperty(this, "_disposingCallbacks", new DisposableCollection());
19859
19894
  const injector = this._injector = createUniverInjector(parentInjector, config === null || config === void 0 ? void 0 : config.override);
19860
- const { theme, darkMode, locale, locales, logLevel, logCommandExecution } = config;
19895
+ const { theme, darkMode, locale, locales, direction, logLevel, logCommandExecution } = config;
19861
19896
  if (theme) this._injector.get(ThemeService).setTheme(theme);
19862
19897
  if (darkMode) this._injector.get(ThemeService).setDarkMode(darkMode);
19863
19898
  if (locales) this._injector.get(LocaleService).load(locales);
19864
19899
  if (locale) this._injector.get(LocaleService).setLocale(locale);
19900
+ if (direction) this._injector.get(LocaleService).setDirection(direction);
19865
19901
  if (logLevel) this._injector.get(ILogService).setLogLevel(logLevel);
19866
19902
  if (logCommandExecution !== void 0) this._injector.get(IConfigService).setConfig(COMMAND_LOG_EXECUTION_CONFIG_KEY, logCommandExecution);
19867
19903
  this._init(injector);
@@ -271,6 +271,7 @@ export declare class CommandService extends Disposable implements ICommandServic
271
271
  constructor(_injector: Injector, _logService: ILogService, _configService: IConfigService);
272
272
  dispose(): void;
273
273
  disposed(): boolean;
274
+ private _warnCommandSkippedAfterDisposed;
274
275
  hasCommand(commandId: string): boolean;
275
276
  registerCommand(command: ICommand): IDisposable;
276
277
  unregisterCommand(commandId: string): void;
@@ -24,6 +24,8 @@ export declare class LocaleService extends Disposable {
24
24
  private _currentLocale$;
25
25
  readonly currentLocale$: import("rxjs").Observable<LocaleType>;
26
26
  private get _currentLocale();
27
+ private _direction$;
28
+ readonly direction$: import("rxjs").Observable<"ltr" | "rtl">;
27
29
  private _locales;
28
30
  localeChanged$: Subject<void>;
29
31
  constructor();
@@ -62,5 +64,7 @@ export declare class LocaleService extends Disposable {
62
64
  setLocale(locale: LocaleType): void;
63
65
  getLocales(): ILanguagePack | undefined;
64
66
  getCurrentLocale(): LocaleType;
67
+ setDirection(direction: 'ltr' | 'rtl'): void;
68
+ getDirection(): "ltr" | "rtl";
65
69
  resolveKeyPath(obj: ILanguagePack, keys: string[]): LanguageValue | null;
66
70
  }
@@ -37,6 +37,11 @@ export interface IUniverConfig {
37
37
  * The locale of the Univer instance.
38
38
  */
39
39
  locale?: LocaleType;
40
+ /**
41
+ * The direction of the Univer instance.
42
+ * @default 'ltr'
43
+ */
44
+ direction?: 'ltr' | 'rtl';
40
45
  /**
41
46
  * The locales to be used
42
47
  */