repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
libro | github_2023 | weavefox | typescript | FocusTracker.isDisposed | get isDisposed(): boolean {
return this.counter < 0;
} | /**
* A flag indicating whether the tracker is disposed.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L42-L44 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.currentView | get currentView(): T | null {
return this._currentView;
} | /**
* The current view in the tracker.
*
* #### Notes
* The current view is the view among the tracked views which
* has the *descendant node* which has most recently been focused.
*
* The current view will not be updated if the node loses focus. It
* will only be updated when a different tracke... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L64-L66 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.activeView | get activeView(): T | null {
return this._activeView;
} | /**
* The active view in the tracker.
*
* #### Notes
* The active view is the view among the tracked views which
* has the *descendant node* which is currently focused.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L75-L77 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.views | get views(): readonly T[] {
return this._views;
} | /**
* A read only array of the views being tracked.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L82-L84 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.dispose | dispose(): void {
// Do nothing if the tracker is already disposed.
if (this.counter < 0) {
return;
}
// Mark the tracker as disposed.
this.counter = -1;
// Clear the listeners for the tracker.
this.activeChangedEmitter.dispose();
this.currentChangedEmitter.dispose();
// Rem... | /**
* Dispose of the resources held by the tracker.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L89-L114 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.focusNumber | focusNumber(view: T): number {
const n = this.numbers.get(view);
return n === undefined ? -1 : n;
} | /**
* Get the focus number for a particular view in the tracker.
*
* @param view - The view of interest.
*
* @returns The focus number for the given view, or `-1` if the
* view has not had focus since being added to the tracker, or
* is not contained by the tracker.
*
* #### Notes
* Th... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L135-L138 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.has | has(view: T): boolean {
return this.numbers.has(view);
} | /**
* Test whether the focus tracker contains a given view.
*
* @param view - The view of interest.
*
* @returns `true` if the view is tracked, `false` otherwise.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L147-L149 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.add | add(view: T): void {
// Do nothing if the view is already tracked.
if (this.numbers.has(view)) {
return;
}
// Test whether the view has focus.
const focused = view.container?.current?.contains(document.activeElement);
// Set up the initial focus number.
const n = focused ? this.count... | /**
* Add a view to the focus tracker.
*
* @param view - The view of interest.
*
* #### Notes
* A view will be automatically removed from the tracker if it
* is disposed after being added.
*
* If the view is already tracked, this is a no-op.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L162-L194 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.remove | remove(view: T): void {
// Bail early if the view is not tracked.
if (!this.numbers.has(view)) {
return;
}
// Disconnect the disposed signal handler.
// view.disposed.disconnect(this.onViewDisposed, this);
// Remove the event listeners.
view.container?.current?.removeEventListener('f... | /**
* Remove a view from the focus tracker.
*
* #### Notes
* If the view is the `currentView`, the previous current view
* will become the new `currentView`.
*
* A view will be automatically removed from the tracker if it
* is disposed after being added.
*
* If the view is not tracked, thi... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L208-L247 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.handleEvent | handleEvent(event: Event): void {
switch (event.type) {
case 'focus':
this.handleFocusEvent(event as FocusEvent);
break;
case 'blur':
this.handleBlurEvent(event as FocusEvent);
break;
}
} | /**
* Handle the DOM events for the focus tracker.
*
* @param event - The DOM event sent to the panel.
*
* #### Notes
* This method implements the DOM `EventListener` interface and is
* called in response to events on the tracked nodes. It should
* not be called directly by user code.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L259-L268 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.setViews | protected setViews(current: T | null, active: T | null): void {
// Swap the current view.
const oldCurrent = this._currentView;
this._currentView = current;
// Swap the active view.
const oldActive = this._activeView;
this._activeView = active;
// Emit the `currentChanged` signal if needed... | /**
* Set the current and active views for the tracker.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L273-L291 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.handleFocusEvent | protected handleFocusEvent(event: FocusEvent): void {
// Find the view which gained focus, which is known to exist.
const view = this.nodes.get(event.currentTarget as HTMLElement)!;
// Update the focus number if necessary.
if (view !== this._currentView) {
this.numbers.set(view, this.counter++);
... | /**
* Handle the `'focus'` event for a tracked view.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L296-L307 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.handleBlurEvent | protected handleBlurEvent(event: FocusEvent): void {
// Find the view which lost focus, which is known to exist.
const view = this.nodes.get(event.currentTarget as HTMLElement)!;
// Get the node which being focused after this blur.
const focusTarget = event.relatedTarget as HTMLElement;
// If no o... | /**
* Handle the `'blur'` event for a tracked view.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L312-L335 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FocusTracker.onViewDisposed | protected onViewDisposed(sender: T): void {
this.remove(sender);
} | /**
* Handle the `disposed` signal for a tracked view.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/focus-tracker.ts#L340-L342 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RootView.getStartupIndicator | protected getStartupIndicator(): HTMLElement | undefined {
if (this.container?.current) {
const startupElements =
this.container.current.getElementsByClassName('mana-preload');
return startupElements.length === 0
? undefined
: (startupElements[0] as HTMLElement);
}
return... | /**
* Return an HTML element that indicates the startup phase, e.g. with an animation or a splash screen.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/root-view.tsx#L73-L82 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RootView.hideLoading | protected hideLoading(): Promise<void> {
return new Promise((resolve) => {
window.requestAnimationFrame(async () => {
const startupElem = this.getStartupIndicator();
if (startupElem) {
startupElem.classList.add('mana-hidden');
const preloadStyle = window.getComputedStyle(st... | /**
* If a startup indicator is present, it is first hidden with the `mana-hidden` CSS class and then
* removed after a while. The delay until removal is taken from the CSS transition duration.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/core/view/root-view.tsx#L87-L101 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Register.resolveTarget | static resolveTarget<R>(
ictx: InversifyContext,
target: Syringe.Token<R>,
option: Syringe.TargetOption<R> = {},
): void {
try {
try {
const sideOption = Reflect.getMetadata(OptionSymbol, target);
if (sideOption) {
Register.resolveOption(ictx, sideOption);
}
... | /**
* 注册目标 token,合并 token 配置后基于配置注册
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/ioc/register.ts#L22-L67 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Register.resolveOption | static resolveOption<R>(
ictx: InversifyContext,
baseOption: Syringe.InjectOption<R>,
): void {
const parsedOption = Utils.toRegistryOption({
...Register.globalConfig,
...baseOption,
});
if (
parsedOption.useClass.length === 0 &&
parsedOption.useDynamic.length === 0 &&
... | /**
* 基于配置注册
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/ioc/register.ts#L71-L92 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Register.resolve | resolve(): void {
const { ictx } = this;
if (!isInversifyContext(ictx)) {
return;
}
if (this.mutiple) {
this.resolveMutilple(ictx);
} else {
this.resolveMono(ictx);
if (!this.named && this.option.contrib.length > 0) {
this.option.contrib.forEach((contribution) => {
... | /**
* multi or mono register
* priority: useValue > useDynamic > useFactory > useClass
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/ioc/register.ts#L121-L140 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Register.resolveMono | protected resolveMono(
ictx: InversifyContext,
): interfaces.BindingWhenOnSyntax<T> | undefined {
if ('useValue' in this.option) {
return bindMonoToken(this.generalToken, ictx).toConstantValue(
this.option.useValue!,
);
}
if (this.option.useDynamic.length > 0) {
const dynamic... | // eslint-disable-next-line consistent-return | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/ioc/register.ts#L142-L175 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DataModelManager.create | create(option: { data: number }) {
const data = this.dataModelFactory(option);
return data;
} | // Factory<DataModel> | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/ioc/features/auto-factory.spec.ts#L76-L79 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Localization.dependOn | dependOn(...modules: Localization[]) {
this.deps.push(...modules);
this.syncDepsLang();
} | /**
* 被依赖的l10n会同步主包的lang, 语言包是独立的
* 建议模块级别的l10n作为默认l10n的依赖,这样使用默认l10n可以统一的切换语言
* @param modules
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/l10n/l10n/index.ts#L84-L87 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Localization.syncDepsLang | syncDepsLang() {
this.deps.forEach((dep) => {
dep.changeLang(this.lang);
dep.syncDepsLang();
});
} | /**
*
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/l10n/l10n/index.ts#L92-L97 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Localization.loadLangBundles | loadLangBundles(bundles: LanguageBundles) {
for (const lang in bundles) {
this.loadLang(lang as L10nLang, { contents: bundles[lang as L10nLang] });
}
} | /**
* 加载语言文件包
* @param bundles
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/l10n/l10n/index.ts#L107-L111 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Localization.loadLang | loadLang(lang: L10nLang, option: { contents: string | l10nJsonFormat }) {
const bundle = this.load(option);
if (bundle) {
if (this.bundles.has(lang)) {
const current = this.bundles.get(lang);
this.bundles.set(lang, { ...current, ...bundle });
} else {
this.bundles.set(lang, b... | /**
* 加载单一语言
* @param lang
* @param option
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/l10n/l10n/index.ts#L118-L130 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Localization.load | protected load(option: {
contents: string | l10nJsonFormat;
}): l10nJsonFormat | undefined {
let bundle: l10nJsonFormat | undefined;
if ('contents' in option) {
if (typeof option.contents === 'string') {
bundle = JSON.parse(option.contents);
} else {
bundle = option.contents;
... | /**
* Loads the bundle from the given contents. Must be run before the first call to any `l10n.t()` variant.
* **Note** The best way to set this is to pass the value of the VS Code API `vscode.l10n.contents`
* to the process that uses `@vscode/l10n`.
* @param option - An object that contains one property, c... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/l10n/l10n/index.ts#L151-L163 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | format | function format(template: string, values: Record<string, unknown>): string {
return template.replace(
_format2Regexp,
(match, group) => (values[group] ?? match) as string,
);
} | /**
* Helper to create a string from a template and a string record.
* Similar to `format` but with objects instead of positional arguments.
*
* Copied from https://github.com/microsoft/vscode/blob/5dfca53892a1061b1c103542afe49d51f1041778/src/vs/base/common/strings.ts#L44
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/l10n/l10n/index.ts#L309-L314 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | AsyncEmitter.eventAsync | get eventAsync(): Event<T> {
if (!this._eventAsync) {
this._eventAsync = (listener: (e: T) => any, context?: any) => {
const callbacks = () => {
if (!this._asyncCallbacks) {
this._asyncCallbacks = new AsyncCallbackList();
}
return this._asyncCallbacks;
... | /**
* For the public to allow to subscribe
* to events from this Emitter
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/observable/async-event.ts#L52-L91 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | AsyncEmitter.fire | override fire(event: T): any {
super.fire(event);
if (this._asyncCallbacks) {
this._asyncCallbacks.invoke(event);
}
} | /**
* fire an event to subscribers
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/observable/async-event.ts#L96-L101 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Notifier.toEvent | static toEvent(target: any, prop?: any, async: boolean | null = false) {
const notifier = Notifier.find(target, prop);
if (notifier) {
if (async === null) {
return notifier.onChange;
}
if (async) {
return notifier.onChangeAsync;
} else {
return notifier.onChangeSy... | /**
* Get event from target
* @param target
* @param prop
* @param async false by default
* @returns
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/observable/notifier.ts#L112-L125 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | onChange | const onChange = () => {
if (ObservableConfig.paused) {
return;
}
Notifier.trigger(target, property);
}; | /**
* notify notifier when property changed
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/observable/observable.ts#L15-L20 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | handleValue | const handleValue = (value: any) => {
InstanceValue.set(target, property, value);
if (notifier) {
const last = Observability.getDisposable(propertyRelatedNotifier, notifier);
if (last) {
last.dispose();
}
}
if (Notifiable.is(value)) {
const valueNotifier = Notifiable.getN... | /**
* set observable property value and register onChange listener
* @param value
* @param notifier
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/observable/observable.ts#L26-L41 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.constructor | constructor(options: Poll.IOptions<T, U, V>) {
const frequency = options.frequency || {};
const max = Math.max(
frequency.interval || 0,
frequency.max || 0,
Private.DEFAULT_FREQUENCY.max,
);
this._frequency = { ...Private.DEFAULT_FREQUENCY, ...frequency, ...{ max } };
this._fact... | /**
* Instantiate a new poll with exponential backoff in case of failure.
*
* @param options - The poll instantiation options.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L39-L62 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.onDispose | get onDispose(): Event<void> {
return this.disposeEmitter.event;
} | /**
* A signal emitted when the poll is disposed.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L72-L74 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.frequency | get frequency(): IPoll.Frequency {
return this._frequency;
} | /**
* The polling frequency parameters.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L79-L81 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.isDisposed | get isDisposed(): boolean {
return this.state.phase === 'disposed';
} | /**
* Whether the poll is disposed.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L111-L113 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.standby | get standby(): Poll.Standby | (() => boolean | Poll.Standby) {
return this._standby;
} | /**
* Indicates when the poll switches to standby.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L118-L120 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.state | get state(): IPoll.State<T, U, V> {
return this._state;
} | /**
* The poll state, which is the content of the current poll tick.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L132-L134 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.tick | get tick(): Promise<this> {
return this._tick.promise;
} | /**
* A promise that resolves when the poll next ticks.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L139-L141 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.ticked | get ticked(): Event<IPoll.State<T, U, V>> {
return this.tickedEmitter.event;
} | /**
* A signal emitted when the poll ticks and fires off a new request.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L146-L148 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.dispose | dispose(): void {
if (this.isDisposed) {
return;
}
this._state = {
...Private.DISPOSED_STATE,
timestamp: new Date().getTime(),
};
this._tick.promise.catch(() => undefined);
this._tick.reject(new Error(`Poll (${this.name}) is disposed.`));
this.disposeEmitter.fire(undefined... | /**
* Dispose the poll.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L163-L178 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.refresh | refresh(): Promise<void> {
return this.schedule({
cancel: ({ phase }) => phase === 'refreshed',
interval: Poll.IMMEDIATE,
phase: 'refreshed',
});
} | /**
* Refreshes the poll. Schedules `refreshed` tick if necessary.
*
* @returns A promise that resolves after tick is scheduled and never rejects.
*
* #### Notes
* The returned promise resolves after the tick is scheduled, but before
* the polling action is run. To wait until after the poll action ... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L190-L196 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.schedule | async schedule(
next: Partial<
IPoll.State<T, U, V> & { cancel: (last: IPoll.State<T, U, V>) => boolean }
> = {},
): Promise<void> {
if (this.isDisposed) {
return;
}
// Check if the phase transition should be canceled.
if (next.cancel && next.cancel(this.state)) {
return;
... | /**
* Schedule the next poll tick.
*
* @param next - The next poll state data to schedule. Defaults to standby.
*
* @param next.cancel - Cancels state transition if function returns `true`.
*
* @returns A promise that resolves when the next poll state is active.
*
* #### Notes
* This metho... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L211-L260 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | execute | const execute = () => {
if (this.isDisposed || this.tick !== scheduled.promise) {
return;
}
this._execute();
}; | // Schedule next execution and cache its timeout handle. | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L252-L258 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.start | start(): Promise<void> {
return this.schedule({
cancel: ({ phase }) =>
phase !== 'constructed' && phase !== 'standby' && phase !== 'stopped',
interval: Poll.IMMEDIATE,
phase: 'started',
});
} | /**
* Starts the poll. Schedules `started` tick if necessary.
*
* @returns A promise that resolves after tick is scheduled and never rejects.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L267-L274 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll.stop | stop(): Promise<void> {
return this.schedule({
cancel: ({ phase }) => phase === 'stopped',
interval: Poll.NEVER,
phase: 'stopped',
});
} | /**
* Stops the poll. Schedules `stopped` tick if necessary.
*
* @returns A promise that resolves after tick is scheduled and never rejects.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L281-L287 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Poll._execute | protected _execute(): void {
let standby = typeof this.standby === 'function' ? this.standby() : this.standby;
switch (standby) {
case 'never':
standby = false;
break;
case 'when-hidden':
standby = !!(typeof document !== 'undefined' && document && document.hidden);
br... | /**
* Execute a new poll factory promise or stand by if necessary.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L292-L336 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | getRandomIntInclusive | function getRandomIntInclusive(min: number, max: number) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
} | /**
* Get a random integer between min and max, inclusive of both.
*
* #### Notes
* From
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#Getting_a_random_integer_between_two_values_inclusive
*
* From the MDN page: It might be tempting to use Math.round() to accompli... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/polling/poll.ts#L505-L509 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | open | function open(config: NotificationArgsProps) {
taskQueue.push({
type: 'open',
config,
});
flushNotice();
} | // ============================================================================== | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/react/notification/index.tsx#L162-L168 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | PurePanel | const PurePanel: React.FC<PurePanelProps> = (props) => {
const {
prefixCls = NOTIFICATION_PREFIX_CLS,
className,
icon,
type,
message,
description,
btn,
closable = true,
closeIcon,
className: notificationClassName,
...restProps
} = props;
return (
<div className={cl... | /** @private Internal Component. Do not use in your production. */ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/react/notification/pure-panel.tsx#L77-L117 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | modernUnmount | async function modernUnmount(container: ContainerType) {
// Delay to unmount to avoid React 18 sync warning
return Promise.resolve().then(() => {
container[MARK]?.unmount();
delete container[MARK];
return;
});
} | // ========================= Unmount ========================== | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/react/notification/render.ts#L71-L79 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | getStyle | const getStyle = (placement: NotificationPlacement): React.CSSProperties =>
getPlacementStyle(placement, top ?? DEFAULT_OFFSET, bottom ?? DEFAULT_OFFSET); | // =============================== Style =============================== | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/react/notification/use-notification.tsx#L58-L59 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | getNotificationMotion | const getNotificationMotion = () => getMotion(prefixCls); | // ============================== Motion =============================== | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/react/notification/use-notification.tsx#L68-L68 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | open | const open = (config: NotificationArgsProps) => {
if (!holderRef.current) {
return;
}
const { open: originOpen, prefixCls, notification } = holderRef.current;
const noticePrefixCls = `${prefixCls}-notice`;
const {
message,
description,
icon,
type,... | // Wrap with notification content | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/react/notification/use-notification.tsx#L101-L153 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | destroy | const destroy = (key?: React.Key) => {
if (key !== undefined) {
holderRef.current?.close(key);
} else {
holderRef.current?.destroy();
}
}; | // >>> destroy | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/react/notification/use-notification.tsx#L156-L162 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | handleZeroSize | const handleZeroSize = (prev: number, next: number) => {
// 对于设置为0的情况,一般认为是会需要完全隐藏对应元素,并且当前handle变为不可用
const prevEle = prevElement.current!;
const nextEle = nextElement.current!;
let hasZero = false;
if (prevEle) {
if (prev === 0) {
prevEle.classList.add('kt_display_none');
has... | /**
* 处理存在置0的情况
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/react/resize/index.tsx#L182-L210 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | setSize | const setSize = (prev: number, next: number, direction?: boolean) => {
const prevEle = props.findPrevElement
? props.findPrevElement(direction)
: prevElement.current!;
const nextEle = props.findNextElement
? props.findNextElement(direction)
: nextElement.current!;
if (!nextEle || !pr... | // direction: true为向下,false为向上 | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/react/resize/index.tsx#L424-L445 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | setAbsoluteSize | const setAbsoluteSize = (size: number, isLatter?: boolean, keep?: boolean) => {
const currentPrev = prevElement.current!.clientHeight;
const currentNext = nextElement.current!.clientHeight;
const totalSize = currentPrev + currentNext;
if (props.flexMode) {
const prevHeight =
props.flexMode... | // keep = true 左右侧面板使用,保证相邻节点的总宽度不变 | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/react/resize/index.tsx#L595-L639 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DefaultCollapseService.getCollapsibleChildNumber | getCollapsibleChildNumber(cell: CellView) {
return 0;
} | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/collapse-service.ts#L66-L68 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroModel.toJSON | toJSON(): INotebookContent {
return {
metadata: this.metadata,
nbformat_minor: this.nbformat_minor,
nbformat: this.nbformat,
cells: this.getCells().map((item) => item.toJSON()),
};
} | /**
* Serialize the model to JSON.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/libro-model.ts#L293-L300 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroModel.fromJSON | fromJSON(value: INotebookContent) {
this.sharedModel.transact(() => {
const useId = value.nbformat === 4 && value.nbformat_minor >= 5;
const ycells = value.cells.map((cell) => {
if (!useId) {
delete cell.id;
}
return cell;
});
if (!ycells.length) {
/... | /**
* Deserialize the model from JSON.
*
* #### Notes
* Should emit a [contentChanged] signal.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/libro-model.ts#L308-L325 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroModel.loadNotebookContent | async loadNotebookContent(): Promise<INotebookContent> {
return this.libroContentService.loadLibroContent(this.options, this);
} | /**
* override this method to load notebook from server
* @returns
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/libro-model.ts#L342-L344 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroModel.scrollToView | scrollToView(cell: CellView, cellOffset = 0) {
const virtualizedManager = this.virtualizedManagerHelper.getOrCreate(this);
if (virtualizedManager.isVirtualized) {
const cellIndex = this.cells.findIndex((_cell) => _cell.id === cell.id);
this.scrollToCellViewEmitter.fire({ cellIndex, cellOffset });
... | /**
* 自动滚动到可视范围内
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/libro-model.ts#L400-L441 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroModel.deleteCellView | protected deleteCellView(arg: string | number | CellView) {
if (arg === this.active?.id) {
// 如果删除项正好是选中项,则清空active
this.active = undefined;
}
return this.doDeleteCell(arg);
} | /**
* 删除 cell 节点
* @param arg id、index、cell
* @returns
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/libro-model.ts#L569-L575 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroModel.exchangeCellView | protected exchangeCellView(
source: string | number | CellView,
target: string | number | CellView,
) {
const sourceIndex = this.toCellIndex(source);
const targetIndex = this.toCellIndex(target);
if (sourceIndex !== undefined && targetIndex !== undefined) {
// 交换位置
const sourceItem = t... | /**
* 交换 cell 节点位置
* @param source id、index、cell
* @param target id、index、cell
* @returns
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/libro-model.ts#L661-L681 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroModel.enterCommandMode | enterCommandMode() {
if (this.active) {
this.commandMode = true;
this.onCommandModeChangedEmitter.fire(true);
this.active.blur();
}
} | /**
* 进入命令模式
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/libro-model.ts#L685-L691 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualizedManager.openVirtualized | openVirtualized = async (length: number, size?: number, path?: string) => {
this.isVirtualized = false;
return false;
// this.isVirtualized = true;
// return true;
// if (length > 100 || (size && size > 4)) {
// this.isVirtualized = true;
// return true;
// } else {
// this.isV... | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/virtualized-manager.ts | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroCellContribution.canHandle | canHandle(options: CellOptions): number {
return 1;
} | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/cell/libro-cell-contribution.ts#L26-L28 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroCellService.getOrCreateModel | async getOrCreateModel(options: CellOptions, cacheGroupId = ''): Promise<CellModel> {
let cellmodelCache = this.modelCache.get(cacheGroupId);
if (!cellmodelCache) {
cellmodelCache = new Map();
this.modelCache.set(cacheGroupId, cellmodelCache);
}
if (options.modelId) {
const exist = th... | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/cell/libro-cell-service.ts#L81-L101 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroCellView.calcEditorOffset | calcEditorOffset() {
return 16 + 1;
} | // 计算编辑器区相对于编辑器区垂直方向的偏移量 | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/cell/libro-cell-view.tsx#L109-L111 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroCellView.shouldEnterEditorMode | shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>) {
return false;
} | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/cell/libro-cell-view.tsx#L122-L124 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroCellView.focus | focus(isEdit: boolean) {
//
} | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/cell/libro-cell-view.tsx#L130-L132 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | calculateOverscanIndices | const calculateOverscanIndices = () => {
const _overscanCellsCount = Math.max(1, overscanCellsCount);
let overscanIndices = null;
if (scrollDirection === SCROLL_DIRECTION_FORWARD) {
overscanIndices = {
overscanStartIndex: Math.max(0, startIndex - 1),
overscanStopIndex: Math.min(cellC... | // Make sure we render at least 1 cell extra before and after (except near boundaries) | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/components/dnd-component/overscanIndices-getter.ts#L50-L68 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | checkCacheAndTimestamp | const checkCacheAndTimestamp = () => {
if (cellCount === 1) {
// 'horizontal' 方向 不用缓存
const overscanIndices = calculateOverscanIndices();
return overscanIndices;
}
if (overscanIndicesCache && Date.now() - overscanIndicesCache.timestamp < 500) {
return overscanIndicesCache.value;
... | // 检查缓存和时间戳函数 | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/components/dnd-component/overscanIndices-getter.ts#L71-L89 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualizedManager.openVirtualized | openVirtualized = async (length: number, size?: number) => {
this.isVirtualized = false;
return false;
// this.isVirtualized = true;
// return true;
// if (length > 100 || (size && size > 4)) {
// this.isVirtualized = true;
// return true;
// } else {
// this.isVirtualized = fa... | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/components/dnd-component/virtualized-manager.ts | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | OutputsScorllTooltip | function OutputsScorllTooltip({ libroService }: { libroService: LibroService }) {
const service = useObserve(libroService);
return (
<div className="libro-tooltip">
<span className="libro-tooltip-text">
{l10n.t(
service.active?.outputsScroll
? '取消固定 Output 展示高度'
... | // import { SideToolbarRunSelect } from './side-toolbar-run-select'; | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-core/src/toolbar/libro-toolbar.tsx#L23-L37 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroJupyterFileService.fileSaveError | get fileSaveError(): ManaEvent<Partial<IContentsModel>> {
return this.fileSaveErrorEmitter.event;
} | /**
* A signal emitted when the file save error.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/libro-jupyter-file-service.ts#L121-L123 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroJupyterOpenHandler.canHandle | canHandle(uri: URI, _options?: ViewOpenHandlerOptions) {
if (uri.scheme === 'file' && uri.path.ext === '.ipynb') {
return Priority.PRIOR + 1;
}
return Priority.IDLE;
} | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/file/open-handler-contribution.ts#L22-L27 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderedPlotly.constructor | constructor(options: IRendererPlotlyOptions) {
this._mimeType = options.mimeType;
this.node = options.host;
// Create image element
this._img_el = document.createElement('img');
this._img_el.className = 'plot-img';
this.node.appendChild(this._img_el);
// Install image hover callback
thi... | /**
* Create a new widget for rendering Plotly.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/rendermime/plotly-renderers.ts#L38-L50 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderedPlotly.renderModel | renderModel(model: BaseOutputView): Promise<void> {
if (this.hasGraphElement()) {
// We already have a graph, don't overwrite it
return Promise.resolve();
}
// Save off reference to model so that we can regenerate the plot later
this._model = model;
// Check for PNG data in mime bundle... | /**
* Render Plotly into this widget's node.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/rendermime/plotly-renderers.ts#L55-L74 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | loadPlotly | const loadPlotly = async (): Promise<void> => {
if (RenderedPlotly.Plotly === null) {
RenderedPlotly.Plotly = await import('plotly.js');
RenderedPlotly._resolveLoadingPlotly();
}
return RenderedPlotly.loadingPlotly;
}; | // Load plotly asynchronously | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/rendermime/plotly-renderers.ts#L126-L132 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Comm.comm_id | get comm_id(): string {
return this.jsServicesComm.commId;
} | /**
* Comm id
* @return {string}
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/comm.ts#L22-L24 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Comm.target_name | get target_name(): string {
return this.jsServicesComm.targetName;
} | /**
* Target name
* @return {string}
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/comm.ts#L30-L32 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Comm.open | open(
data: JSONObject,
callbacks?: ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[],
): string {
const future = this.jsServicesComm.open(data, metadata, buffers);
this._hookupCallbacks(future, callbacks);
return future.msg.header.msg_id;
} | /**
* Opens a sibling comm in the backend
* @param data
* @param callbacks
* @param metadata
* @return msg id
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/comm.ts#L41-L50 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Comm.send | send(
data: JSONObject,
callbacks?: ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[],
): string {
const future = this.jsServicesComm.send(data, metadata, buffers);
this._hookupCallbacks(future, callbacks);
return future.msg.header.msg_id;
} | /**
* Sends a message to the sibling comm in the backend
* @param data
* @param callbacks
* @param metadata
* @param buffers
* @return message id
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/comm.ts#L60-L69 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Comm.close | close(
data?: JSONObject,
callbacks?: ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[],
): string {
const future = this.jsServicesComm.close(data, metadata, buffers);
this._hookupCallbacks(future, callbacks);
return future.msg.header.msg_id;
} | /**
* Closes the sibling comm in the backend
* @param data
* @param callbacks
* @param metadata
* @return msg id
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/comm.ts#L78-L87 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Comm.onMsg | onMsg(callback: (x: any) => void): void {
this.jsServicesComm.onMsg = callback.bind(this);
} | /**
* Register a message handler
* @param callback, which is given a message
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/comm.ts#L93-L95 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Comm.onClose | onClose(callback: (x: any) => void): void {
this.jsServicesComm.onClose = callback.bind(this);
} | /**
* Register a handler for when the comm is closed by the backend
* @param callback, which is given a message
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/comm.ts#L101-L103 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Comm._hookupCallbacks | _hookupCallbacks(future: IShellFuture, callbacks?: ICallbacks): void {
if (callbacks) {
future.onReply = function (msg): void {
if (callbacks.shell && callbacks.shell['reply']) {
callbacks.shell['reply'](msg);
}
};
future.onStdin = function (msg): void {
if (call... | /**
* Hooks callback object up with @jupyterlab/services IKernelFuture
* @param @jupyterlab/services IKernelFuture instance
* @param callbacks
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/comm.ts#L110-L148 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroWidgets.createComm | async createComm(
comm_target_name: string,
model_id?: string,
data?: JSONObject,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[],
): Promise<IClassicComm> {
const kernel = this.kernelConnection;
if (!kernel) {
throw new Error('No current kernel');
}
const ... | /**
* Create a comm which can be used for communication for a widget.
*
* If the data/metadata is passed in, open the comm before returning (i.e.,
* send the comm_open message). If the data and metadata is undefined, we
* want to reconstruct a comm that already exists in the kernel, so do not
* open t... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/libro-widgets.ts#L73-L89 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroWidgets.getModel | getModel(model_id: string): WidgetView {
const model = this.models.get(model_id);
if (model === undefined) {
throw new Error('widget model not found');
}
return model;
} | /**
* Get a model by model id.
*
* #### Notes
* If the model is not found, throw error.
*
* If you would like to synchronously test if a model exists, use .hasModel().
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/libro-widgets.ts#L99-L105 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroWidgets.hasModel | hasModel(model_id: string): boolean {
return this.models.get(model_id) !== undefined;
} | /**
* Returns true if the given model is registered, otherwise false.
*
* #### Notes
* This is a synchronous way to check if a model is registered.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/libro-widgets.ts#L113-L115 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroWidgets.handleCommOpen | async handleCommOpen(
comm: IClassicComm,
msg: KernelMessage.ICommOpenMsg,
): Promise<WidgetView> {
const protocolVersion = ((msg.metadata || {})['version'] as string) || '';
if (protocolVersion.split('.', 1)[0] !== PROTOCOL_MAJOR_VERSION) {
const error = `Wrong widget protocol version: received... | /**
* Handle when a comm is opened.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/libro-widgets.ts#L120-L139 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroWidgets.clearState | clearState() {
this.models.clear();
} | /**
* Close all widgets and empty the widget state.
* @return Promise that resolves when the widget state is cleared.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/libro-widgets.ts#L191-L193 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroWidgets.disconnect | disconnect(): void {
// this.models.forEach(model => model.clear());
} | /**
* Disconnect the widget manager from the kernel, setting each model's comm
* as dead.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/libro-widgets.ts#L198-L200 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroWidgets.toJSON | toJSON(): string {
return JSON.stringify({
kc_id: this.kernelConnection.id,
id: this.id,
});
} | /**
* Serialize the model. See the deserialization function at the top of this file
* and the kernel-side serializer/deserializer.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/libro-widgets.ts#L217-L222 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | WidgetView.handleKernelChanged | handleKernelChanged = (): void => {
this.setState({ msg_id: undefined });
} | /**
* Send a custom msg over the comm.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/widget-view.tsx | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | WidgetView.resetMsgId | resetMsgId(): void {
this.toDisposeOnMsgChanged?.dispose();
const notebookModel = this.cell?.parent?.model;
if (notebookModel instanceof LibroJupyterModel) {
const kernel = notebookModel.kernelConnection;
if (kernel && this.state['msg_id']) {
this.toDisposeOnMsgChanged = kernel.register... | /**
* Reset the message id.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/widget-view.tsx#L130-L143 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | WidgetView.handleCommMsg | handleCommMsg(msg: KernelMessage.ICommMsgMsg): Promise<void> {
const data = msg.content.data as any;
const method = data.method;
switch (method) {
case 'update':
case 'echo_update':
this.setState(data.state);
}
return Promise.resolve();
} | /**
* Handle incoming comm msg.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/widget-view.tsx#L189-L198 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | WidgetView.setState | setState(state: Dict<any>): void {
for (const key in state) {
const oldMsgId = this.state['msg_id'];
this.state[key] = state[key];
if (key === 'msg_id' && oldMsgId !== state['msg_id']) {
this.resetMsgId();
}
}
} | /**
* Handle when a widget is updated from the backend.
*
* This function is meant for internal use only. Values set here will not be propagated on a sync.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/widget-view.tsx#L208-L216 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.