@odoo/o-spreadsheet
Version:
A spreadsheet component
86 lines (85 loc) • 3.49 kB
TypeScript
/**
* Owl 2 → Owl 3 compatibility layer.
*
* This file patches Owl 3 so that existing Owl 2 code can continue to run
* with minimal changes. It is intended as a temporary bridge to ease
* incremental migration from Owl 2 to Owl 3.
*
* ---------------------------------------------------------------------------
* Setup (required to run Owl 2 code on Owl 3)
* ---------------------------------------------------------------------------
*
* 1. Update template directives:
* - replace `t-portal` → `t-custom-portal`
* - replace `t-model` → `t-custom-model`
*
* 2. Load this file immediately after Owl 3.
*
* 3. Update hooks:
* - replace all `useEffect` with `useLayoutEffect`
* import { useLayoutEffect } from "@odoo/owl";
*
* ---------------------------------------------------------------------------
* Migration (once the app builds successfully)
* ---------------------------------------------------------------------------
*
* Gradually remove the compatibility layer by migrating to native Owl 3:
*
* - replace `t-custom-portal` with proper Owl 3 portal usage
* - replace `t-custom-model` with `t-model` + signals
* - convert `useLayoutEffect` back to `useEffect` where appropriate
*
* The end goal is to eliminate all compatibility shims.
*/
import * as owl from "@odoo/owl";
declare const OwlApp: typeof owl.App, OwlComponent: typeof owl.Component, Plugin: typeof owl.Plugin;
export interface ComponentConstructor<Env = any> {
new (...args: any[]): any;
template: string;
}
declare class _Component<Env = any> extends OwlComponent {
static template: string;
env: Env;
constructor(node: any);
setup(): void;
render(deep?: boolean): void;
}
declare function _useComponent(): any;
declare function _useExternalListener(target: any, eventName: any, handler: any, eventParams?: any): void;
declare function _useLayoutEffect(effect: any, computeDependencies?: () => any): void;
declare class _EnvPlugin extends Plugin {
static id: string;
env: any;
}
declare function _useEnv(): any;
declare function _useSubEnv(extension: any): void;
declare function _useChildSubEnv(extension: any): void;
declare function _useChildEnv(): any;
declare class _App extends OwlApp {
/**
* @param {any} config
*/
constructor(config: any);
createRoot(component: any, config?: {}): owl.Root<any>;
}
declare const Component: typeof _Component;
declare const useComponent: typeof _useComponent;
declare const useExternalListener: typeof _useExternalListener;
declare const useLayoutEffect: typeof _useLayoutEffect;
declare const EnvPlugin: typeof _EnvPlugin;
declare const useEnv: typeof _useEnv;
declare const useSubEnv: typeof _useSubEnv;
declare const useChildEnv: typeof _useChildEnv;
declare const useChildSubEnv: typeof _useChildSubEnv;
declare const App: typeof _App;
export { App, Component, EnvPlugin, useChildEnv, useChildSubEnv, useComponent, useEnv, useExternalListener, useLayoutEffect, useSubEnv, };
export type Component<Env = any> = _Component<Env>;
export type useComponent = () => any;
export type useExternalListener = (target: any, eventName: any, handler: any, eventParams?: any) => void;
export type useLayoutEffect = (effect: any, computeDependencies: () => any) => void;
export type EnvPlugin = _EnvPlugin;
export type useEnv = () => any;
export type useSubEnv = () => any;
export type useChildEnv = () => any;
export type useChildSubEnv = () => any;
export type App = _App;