@odoo/owl 3.0.0-alpha.20 → 3.0.0-alpha.21

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.
Files changed (61) hide show
  1. package/README.md +100 -110
  2. package/dist/compile_templates.mjs +84 -80
  3. package/dist/compiler.js +2356 -2356
  4. package/dist/owl-devtools.zip +0 -0
  5. package/dist/owl.cjs.js +1596 -1459
  6. package/dist/owl.cjs.runtime.js +4362 -3952
  7. package/dist/owl.es.js +1596 -1459
  8. package/dist/owl.es.runtime.js +4360 -3950
  9. package/dist/owl.iife.js +1596 -1459
  10. package/dist/owl.iife.min.js +1 -1
  11. package/dist/owl.iife.runtime.js +4363 -3953
  12. package/dist/owl.iife.runtime.min.js +1 -1
  13. package/dist/types/common/types.d.ts +1 -1
  14. package/dist/types/compiler/code_generator.d.ts +1 -2
  15. package/dist/types/compiler/inline_expressions.d.ts +7 -24
  16. package/dist/types/compiler/parser.d.ts +3 -8
  17. package/dist/types/owl.d.ts +33 -27
  18. package/dist/types/runtime/blockdom/attributes.d.ts +2 -0
  19. package/dist/types/runtime/component_node.d.ts +2 -0
  20. package/dist/types/runtime/error_handling.d.ts +13 -13
  21. package/dist/types/runtime/fibers.d.ts +37 -37
  22. package/dist/types/runtime/plugin_manager.d.ts +2 -0
  23. package/dist/types/runtime/portal.d.ts +15 -12
  24. package/dist/types/runtime/reactivity/computations.d.ts +1 -0
  25. package/dist/types/runtime/reactivity.d.ts +57 -57
  26. package/dist/types/runtime/rendering/scheduler.d.ts +1 -1
  27. package/dist/types/runtime/rendering/template_helpers.d.ts +2 -2
  28. package/dist/types/runtime/scheduler.d.ts +21 -21
  29. package/dist/types/runtime/types.d.ts +3 -0
  30. package/dist/types/version.d.ts +1 -1
  31. package/package.json +24 -1
  32. package/dist/types/runtime/cancellableContext.d.ts +0 -15
  33. package/dist/types/runtime/cancellablePromise.d.ts +0 -15
  34. package/dist/types/runtime/executionContext.d.ts +0 -0
  35. package/dist/types/runtime/listOperation.d.ts +0 -1
  36. package/dist/types/runtime/model.d.ts +0 -48
  37. package/dist/types/runtime/plugins.d.ts +0 -36
  38. package/dist/types/runtime/reactivity/async_computed.d.ts +0 -1
  39. package/dist/types/runtime/reactivity/derived.d.ts +0 -7
  40. package/dist/types/runtime/reactivity/reactivity.d.ts +0 -46
  41. package/dist/types/runtime/reactivity/signals.d.ts +0 -30
  42. package/dist/types/runtime/reactivity/state.d.ts +0 -48
  43. package/dist/types/runtime/relationalModel/discussModel.d.ts +0 -19
  44. package/dist/types/runtime/relationalModel/discussModelTypes.d.ts +0 -22
  45. package/dist/types/runtime/relationalModel/field.d.ts +0 -20
  46. package/dist/types/runtime/relationalModel/model.d.ts +0 -59
  47. package/dist/types/runtime/relationalModel/modelData.d.ts +0 -18
  48. package/dist/types/runtime/relationalModel/modelRegistry.d.ts +0 -3
  49. package/dist/types/runtime/relationalModel/modelUtils.d.ts +0 -4
  50. package/dist/types/runtime/relationalModel/store.d.ts +0 -16
  51. package/dist/types/runtime/relationalModel/types.d.ts +0 -83
  52. package/dist/types/runtime/relationalModel/util.d.ts +0 -1
  53. package/dist/types/runtime/relationalModel/web/WebDataPoint.d.ts +0 -25
  54. package/dist/types/runtime/relationalModel/web/WebRecord.d.ts +0 -131
  55. package/dist/types/runtime/relationalModel/web/WebStaticList.d.ts +0 -63
  56. package/dist/types/runtime/relationalModel/web/webModel.d.ts +0 -5
  57. package/dist/types/runtime/relationalModel/web/webModelTypes.d.ts +0 -139
  58. package/dist/types/runtime/signals.d.ts +0 -19
  59. package/dist/types/runtime/suspense.d.ts +0 -5
  60. package/dist/types/runtime/task.d.ts +0 -12
  61. package/dist/types/utils/registry.d.ts +0 -15
@@ -1,57 +1,57 @@
1
- import type { Callback } from "./utils";
2
- declare type Target = object;
3
- declare type Reactive<T extends Target> = T;
4
- /**
5
- * Mark an object or array so that it is ignored by the reactivity system
6
- *
7
- * @param value the value to mark
8
- * @returns the object itself
9
- */
10
- export declare function markRaw<T extends Target>(value: T): T;
11
- /**
12
- * Given a reactive objet, return the raw (non reactive) underlying object
13
- *
14
- * @param value a reactive value
15
- * @returns the underlying value
16
- */
17
- export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
18
- /**
19
- * Clears all subscriptions of the Reactives associated with a given callback.
20
- *
21
- * @param callback the callback for which the reactives need to be cleared
22
- */
23
- export declare function clearReactivesForCallback(callback: Callback): void;
24
- export declare function getSubscriptions(callback: Callback): {
25
- target: object;
26
- keys: (string | number | symbol)[];
27
- }[];
28
- export declare const targets: WeakMap<object, object>;
29
- /**
30
- * Creates a reactive proxy for an object. Reading data on the reactive object
31
- * subscribes to changes to the data. Writing data on the object will cause the
32
- * notify callback to be called if there are suscriptions to that data. Nested
33
- * objects and arrays are automatically made reactive as well.
34
- *
35
- * Whenever you are notified of a change, all subscriptions are cleared, and if
36
- * you would like to be notified of any further changes, you should go read
37
- * the underlying data again. We assume that if you don't go read it again after
38
- * being notified, it means that you are no longer interested in that data.
39
- *
40
- * Subscriptions:
41
- * + Reading a property on an object will subscribe you to changes in the value
42
- * of that property.
43
- * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
44
- * subscribe you to the creation/deletion of keys. Checking the presence of a
45
- * key on the object with 'in' has the same effect.
46
- * - getOwnPropertyDescriptor does not currently subscribe you to the property.
47
- * This is a choice that was made because changing a key's value will trigger
48
- * this trap and we do not want to subscribe by writes. This also means that
49
- * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
50
- *
51
- * @param target the object for which to create a reactive proxy
52
- * @param callback the function to call when an observed property of the
53
- * reactive has changed
54
- * @returns a proxy that tracks changes to it
55
- */
56
- export declare function reactive<T extends Target>(target: T, callback?: Callback): T;
57
- export {};
1
+ import type { Callback } from "./utils";
2
+ type Target = object;
3
+ type Reactive<T extends Target> = T;
4
+ /**
5
+ * Mark an object or array so that it is ignored by the reactivity system
6
+ *
7
+ * @param value the value to mark
8
+ * @returns the object itself
9
+ */
10
+ export declare function markRaw<T extends Target>(value: T): T;
11
+ /**
12
+ * Given a reactive objet, return the raw (non reactive) underlying object
13
+ *
14
+ * @param value a reactive value
15
+ * @returns the underlying value
16
+ */
17
+ export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
18
+ /**
19
+ * Clears all subscriptions of the Reactives associated with a given callback.
20
+ *
21
+ * @param callback the callback for which the reactives need to be cleared
22
+ */
23
+ export declare function clearReactivesForCallback(callback: Callback): void;
24
+ export declare function getSubscriptions(callback: Callback): {
25
+ target: object;
26
+ keys: (string | number | symbol)[];
27
+ }[];
28
+ export declare const targets: WeakMap<object, object>;
29
+ /**
30
+ * Creates a reactive proxy for an object. Reading data on the reactive object
31
+ * subscribes to changes to the data. Writing data on the object will cause the
32
+ * notify callback to be called if there are suscriptions to that data. Nested
33
+ * objects and arrays are automatically made reactive as well.
34
+ *
35
+ * Whenever you are notified of a change, all subscriptions are cleared, and if
36
+ * you would like to be notified of any further changes, you should go read
37
+ * the underlying data again. We assume that if you don't go read it again after
38
+ * being notified, it means that you are no longer interested in that data.
39
+ *
40
+ * Subscriptions:
41
+ * + Reading a property on an object will subscribe you to changes in the value
42
+ * of that property.
43
+ * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
44
+ * subscribe you to the creation/deletion of keys. Checking the presence of a
45
+ * key on the object with 'in' has the same effect.
46
+ * - getOwnPropertyDescriptor does not currently subscribe you to the property.
47
+ * This is a choice that was made because changing a key's value will trigger
48
+ * this trap and we do not want to subscribe by writes. This also means that
49
+ * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
50
+ *
51
+ * @param target the object for which to create a reactive proxy
52
+ * @param callback the function to call when an observed property of the
53
+ * reactive has changed
54
+ * @returns a proxy that tracks changes to it
55
+ */
56
+ export declare function reactive<T extends Target>(target: T, callback?: Callback): T;
57
+ export {};
@@ -1,7 +1,7 @@
1
1
  import type { ComponentNode } from "../component_node";
2
2
  import { Fiber, RootFiber } from "./fibers";
3
3
  export declare class Scheduler {
4
- static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
4
+ static requestAnimationFrame: (callback: FrameRequestCallback) => number;
5
5
  tasks: Set<RootFiber>;
6
6
  requestAnimationFrame: Window["requestAnimationFrame"];
7
7
  frame: number;
@@ -2,7 +2,6 @@ import { OwlError } from "../../common/owl_error";
2
2
  import { App } from "../app";
3
3
  import { BDom, createCatcher, toggler } from "../blockdom";
4
4
  import { ComponentNode } from "../component_node";
5
- import { Portal } from "../portal";
6
5
  import { markRaw } from "../reactivity/proxy";
7
6
  /**
8
7
  * This file contains utility functions that will be injected in each template,
@@ -26,6 +25,7 @@ declare class LazyValue {
26
25
  }
27
26
  export declare function safeOutput(value: any, defaultValue?: any): ReturnType<typeof toggler>;
28
27
  declare function createRef(ref: any): (el: HTMLElement | null, previousEl: HTMLElement | null) => void;
28
+ declare function callHandler(fn: any, ctx: any, ev: Event): void;
29
29
  declare function modelExpr(value: any): any;
30
30
  declare function createComponent<P extends Record<string, any>>(app: App, name: string | null, isStatic: boolean, hasSlotsProp: boolean, hasDynamicPropList: boolean, propList: string[]): (props: P, key: string, ctx: ComponentNode, parent: any, C: any) => any;
31
31
  declare function callTemplate(subTemplate: string, owner: any, app: App, ctx: any, parent: any, key: any): any;
@@ -45,7 +45,7 @@ export declare const helpers: {
45
45
  createRef: typeof createRef;
46
46
  modelExpr: typeof modelExpr;
47
47
  createComponent: typeof createComponent;
48
- Portal: typeof Portal;
49
48
  callTemplate: typeof callTemplate;
49
+ callHandler: typeof callHandler;
50
50
  };
51
51
  export {};
@@ -1,21 +1,21 @@
1
- import type { ComponentNode } from "./component_node";
2
- import { Fiber, RootFiber } from "./fibers";
3
- export declare class Scheduler {
4
- static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
5
- tasks: Set<RootFiber>;
6
- requestAnimationFrame: Window["requestAnimationFrame"];
7
- frame: number;
8
- delayedRenders: Fiber[];
9
- cancelledNodes: Set<ComponentNode>;
10
- processing: boolean;
11
- constructor();
12
- addFiber(fiber: Fiber): void;
13
- scheduleDestroy(node: ComponentNode): void;
14
- /**
15
- * Process all current tasks. This only applies to the fibers that are ready.
16
- * Other tasks are left unchanged.
17
- */
18
- flush(): void;
19
- processTasks(): void;
20
- processFiber(fiber: RootFiber): void;
21
- }
1
+ import type { ComponentNode } from "./component_node";
2
+ import { Fiber, RootFiber } from "./fibers";
3
+ export declare class Scheduler {
4
+ static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
5
+ tasks: Set<RootFiber>;
6
+ requestAnimationFrame: Window["requestAnimationFrame"];
7
+ frame: number;
8
+ delayedRenders: Fiber[];
9
+ cancelledNodes: Set<ComponentNode>;
10
+ processing: boolean;
11
+ constructor();
12
+ addFiber(fiber: Fiber): void;
13
+ scheduleDestroy(node: ComponentNode): void;
14
+ /**
15
+ * Process all current tasks. This only applies to the fibers that are ready.
16
+ * Other tasks are left unchanged.
17
+ */
18
+ flush(): void;
19
+ processTasks(): void;
20
+ processFiber(fiber: RootFiber): void;
21
+ }
@@ -33,6 +33,8 @@ declare function literalSelection<const T extends LiteralTypes>(literals: T[]):
33
33
  declare function objectType(): Record<string, any>;
34
34
  declare function objectType<const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
35
35
  declare function objectType<Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
36
+ declare function strictObjectType<const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
37
+ declare function strictObjectType<Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
36
38
  declare function promiseType(): Promise<void>;
37
39
  declare function promiseType<T>(type: T): Promise<T>;
38
40
  declare function recordType(): Record<PropertyKey, any>;
@@ -61,6 +63,7 @@ export declare const types: {
61
63
  ref: typeof ref;
62
64
  selection: typeof literalSelection;
63
65
  signal: typeof reactiveValueType;
66
+ strictObject: typeof strictObjectType;
64
67
  string: string;
65
68
  tuple: typeof tuple;
66
69
  };
@@ -1 +1 @@
1
- export declare const version = "3.0.0-alpha";
1
+ export declare const version = "3.0.0-alpha.21";
package/package.json CHANGED
@@ -1,10 +1,20 @@
1
1
  {
2
2
  "name": "@odoo/owl",
3
- "version": "3.0.0-alpha.20",
3
+ "version": "3.0.0-alpha.21",
4
4
  "description": "Odoo Web Library (OWL)",
5
5
  "main": "dist/owl.cjs.js",
6
6
  "module": "dist/owl.es.js",
7
7
  "types": "dist/types/owl.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types/owl.d.ts",
11
+ "import": "./dist/owl.es.js",
12
+ "require": "./dist/owl.cjs.js",
13
+ "default": "./dist/owl.es.js"
14
+ },
15
+ "./dist/*": "./dist/*",
16
+ "./package.json": "./package.json"
17
+ },
8
18
  "type": "module",
9
19
  "files": [
10
20
  "dist"
@@ -49,6 +59,18 @@
49
59
  },
50
60
  "homepage": "https://github.com/odoo/owl#readme",
51
61
  "devDependencies": {
62
+ "@codemirror/autocomplete": "^6.20.1",
63
+ "@codemirror/commands": "^6.10.3",
64
+ "@codemirror/lang-css": "^6.3.1",
65
+ "@codemirror/lang-javascript": "^6.2.5",
66
+ "@codemirror/lang-markdown": "^6.5.0",
67
+ "@codemirror/lang-xml": "^6.1.0",
68
+ "@codemirror/language": "^6.12.2",
69
+ "@codemirror/state": "^6.6.0",
70
+ "@codemirror/theme-one-dark": "^6.1.3",
71
+ "@codemirror/view": "^6.40.0",
72
+ "@emmetio/codemirror6-plugin": "^0.4.0",
73
+ "@rollup/plugin-node-resolve": "^16.0.3",
52
74
  "@rollup/plugin-terser": "^0.4.4",
53
75
  "@types/jest": "^30.0.0",
54
76
  "@types/jsdom": "^21.1.7",
@@ -56,6 +78,7 @@
56
78
  "@typescript-eslint/eslint-plugin": "^8.54.0",
57
79
  "@typescript-eslint/parser": "^8.54.0",
58
80
  "chalk": "^3.0.0",
81
+ "codemirror": "^6.0.2",
59
82
  "current-git-branch": "^1.1.0",
60
83
  "eslint": "^9.39.2",
61
84
  "git-rev-sync": "^3.0.2",
@@ -1,15 +0,0 @@
1
- export declare type TaskContext = {
2
- isCancelled: boolean;
3
- cancel: () => void;
4
- meta: Record<string, any>;
5
- };
6
- export declare const taskContextStack: TaskContext[];
7
- export declare function getTaskContext(): TaskContext;
8
- export declare function makeTaskContext(): TaskContext;
9
- export declare function useTaskContext(ctx?: TaskContext): {
10
- ctx: TaskContext;
11
- cleanup: () => void;
12
- };
13
- export declare function pushTaskContext(context: TaskContext): void;
14
- export declare function popTaskContext(): void;
15
- export declare function taskEffect(fn: Function): TaskContext;
@@ -1,15 +0,0 @@
1
- export declare type PromiseExecContext = {
2
- cancelled: boolean;
3
- };
4
- export declare type CancellablePromise<T = any> = Promise<T> & {
5
- execContext?: PromiseExecContext;
6
- };
7
- export declare const setCancellableContext: (ctx: PromiseExecContext | undefined) => PromiseExecContext | undefined;
8
- export declare const resetCancellableContext: (ctx: PromiseExecContext | undefined) => void;
9
- export declare const _exec: (execContext: PromiseExecContext | undefined, cb: Function, args: any[]) => any;
10
- export declare function patchPromise(): void;
11
- export declare function restorePromise(): void;
12
- export declare function getCancellableTask(cb: Function): {
13
- cancel: () => boolean;
14
- readonly isCancel: boolean;
15
- };
File without changes
@@ -1 +0,0 @@
1
- export declare function reactiveMap<A, B>(arr: A[], fn: (a: A, index: number) => B): any;
@@ -1,48 +0,0 @@
1
- import { Signal } from "./reactivity/signal";
2
- type MClass<TFields extends Record<string, FieldDef>> = (new (...args: any[]) => Model<TFields>) & StaticModel<TFields>;
3
- type CharField = {
4
- type: "char";
5
- };
6
- type NumberField = {
7
- type: "number";
8
- };
9
- type Many2OneField<C extends MClass<any>> = {
10
- type: "many2one";
11
- comodel: () => C;
12
- };
13
- type FieldDef = CharField | NumberField | Many2OneField<MClass<any>>;
14
- type FieldValue<F extends FieldDef> = F extends CharField ? Signal<string> : F extends NumberField ? Signal<number> : F extends Many2OneField<infer C> ? Signal<InstanceType<C>> : never;
15
- type FieldsToData<F extends Record<string, FieldDef>> = {
16
- [K in keyof F]: FieldValue<F[K]>;
17
- };
18
- type FieldDescription = {
19
- type: "char";
20
- } | {
21
- type: "number";
22
- } | {
23
- type: "many2one";
24
- comodel: () => MClass<any>;
25
- };
26
- export type Fields = Record<string, FieldDescription>;
27
- interface StaticModel<F extends Record<string, FieldDef>> {
28
- fields: F;
29
- id: string;
30
- }
31
- type R<F extends Record<string, FieldDef>, C extends MClass<F>> = InstanceType<C>;
32
- export declare class Model<F extends Record<string, FieldDef> = any> {
33
- #private;
34
- static fields: Fields;
35
- readonly id: string;
36
- data: FieldsToData<F>;
37
- constructor(store: Store, id: string, data?: any);
38
- toObject(): Object;
39
- }
40
- export declare class Store {
41
- #private;
42
- static fromObject(obj: any, models: MClass<any>[]): Store;
43
- uuid(): string;
44
- create<F extends Record<string, FieldDef>, C extends MClass<F>>(M: C, initialState?: any): R<F, C>;
45
- toObject(): Object;
46
- getAll<F extends Record<string, FieldDef>, C extends MClass<F>>(M: C): R<F, C>[];
47
- }
48
- export {};
@@ -1,36 +0,0 @@
1
- import { Props, WithDefaults } from "./props";
2
- import { STATUS } from "./status";
3
- import { GetOptionalEntries } from "./types";
4
- export interface PluginConstructor {
5
- new (): Plugin;
6
- id: string;
7
- }
8
- export declare class Plugin {
9
- private static _shadowId;
10
- static get id(): string;
11
- static set id(shadowId: string);
12
- setup(): void;
13
- }
14
- interface PluginManagerOptions {
15
- parent?: PluginManager | null;
16
- plugins?: PluginConstructor[];
17
- pluginProps?: any;
18
- }
19
- export declare class PluginManager {
20
- static current: PluginManager | null;
21
- private children;
22
- private parent;
23
- private plugins;
24
- private onDestroyCb;
25
- status: STATUS;
26
- constructor(options?: PluginManagerOptions);
27
- destroy(): void;
28
- getPluginById<T extends Plugin>(id: string): T | null;
29
- getPlugin<T extends PluginConstructor>(pluginType: T): InstanceType<T> | null;
30
- startPlugins(pluginTypes: PluginConstructor[], pluginProps?: any): Plugin[];
31
- }
32
- export declare function plugin<T extends PluginConstructor>(pluginType: T): InstanceType<T>;
33
- export declare namespace plugin {
34
- var props: <P extends Record<string, any> = any, D extends GetOptionalEntries<P> = any>(type?: P, defaults?: D) => Props<WithDefaults<P, D>>;
35
- }
36
- export {};
@@ -1 +0,0 @@
1
- export declare function asyncComputed<T>(fn: () => Promise<T>): () => Promise<T>;
@@ -1,7 +0,0 @@
1
- import { Opts, Derived } from "./computations";
2
- import { ReactiveValue } from "./signal";
3
- export declare function derived<T>(fn: () => T, opts?: Opts): ReactiveValue<T>;
4
- export declare function setSignalHooks(hooks: {
5
- onDerived: (derived: Derived<any, any>) => void;
6
- }): void;
7
- export declare function resetSignalHooks(): void;
@@ -1,46 +0,0 @@
1
- type Target = object;
2
- type Reactive<T extends Target> = T;
3
- /**
4
- * Mark an object or array so that it is ignored by the reactivity system
5
- *
6
- * @param value the value to mark
7
- * @returns the object itself
8
- */
9
- export declare function markRaw<T extends Target>(value: T): T;
10
- /**
11
- * Given a proxy objet, return the raw (non proxy) underlying object
12
- *
13
- * @param value a proxy value
14
- * @returns the underlying value
15
- */
16
- export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
17
- export declare const targets: WeakMap<object, object>;
18
- /**
19
- * Creates a reactive proxy for an object. Reading data on the proxy object
20
- * subscribes to changes to the data. Writing data on the object will cause the
21
- * notify callback to be called if there are suscriptions to that data. Nested
22
- * objects and arrays are automatically made reactive as well.
23
- *
24
- * Whenever you are notified of a change, all subscriptions are cleared, and if
25
- * you would like to be notified of any further changes, you should go read
26
- * the underlying data again. We assume that if you don't go read it again after
27
- * being notified, it means that you are no longer interested in that data.
28
- *
29
- * Subscriptions:
30
- * + Reading a property on an object will subscribe you to changes in the value
31
- * of that property.
32
- * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
33
- * subscribe you to the creation/deletion of keys. Checking the presence of a
34
- * key on the object with 'in' has the same effect.
35
- * - getOwnPropertyDescriptor does not currently subscribe you to the property.
36
- * This is a choice that was made because changing a key's value will trigger
37
- * this trap and we do not want to subscribe by writes. This also means that
38
- * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
39
- *
40
- * @param target the object for which to create a proxy proxy
41
- * @param callback the function to call when an observed property of the
42
- * proxy has changed
43
- * @returns a proxy that tracks changes to it
44
- */
45
- export declare function proxy<T extends Target>(target: T): T;
46
- export {};
@@ -1,30 +0,0 @@
1
- import { Atom, Computation, Derived, Opts } from "../../common/types";
2
- type SignalFunction<T> = () => T;
3
- export interface Signal<T> extends SignalFunction<T> {
4
- /**
5
- * Update the value of the signal with a new value. If the new value is different
6
- * from the previous values, all computations that depends on this signal will
7
- * be invalidated, and effects will rerun.
8
- */
9
- set(value: T): void;
10
- /**
11
- * Call the updater function (if given) to update the signal value.
12
- * If the updater value is not given, then all computations that depends on
13
- * this signal will be invalidated and effects will rerun.
14
- */
15
- update(updater?: (value: T) => T): void;
16
- }
17
- export declare function signal<T>(value: T, opts?: Opts): Signal<T>;
18
- export declare function effect<T>(fn: () => T, opts?: Opts): () => void;
19
- export declare function derived<T>(fn: () => T, opts?: Opts): () => T;
20
- export declare function onReadAtom(atom: Atom): void;
21
- export declare function onWriteAtom(atom: Atom): void;
22
- export declare function withoutReactivity<T extends (...args: any[]) => any>(fn: T): ReturnType<T>;
23
- export declare function getCurrentComputation(): Computation<any> | undefined;
24
- export declare function setComputation(computation: Computation | undefined): void;
25
- export declare function runWithComputation<T>(computation: Computation, fn: () => T): T;
26
- export declare function setSignalHooks(hooks: {
27
- onDerived: (derived: Derived<any, any>) => void;
28
- }): void;
29
- export declare function resetSignalHooks(): void;
30
- export {};
@@ -1,48 +0,0 @@
1
- import { Atom } from "./computations";
2
- type Target = object;
3
- type Reactive<T extends Target> = T;
4
- /**
5
- * Mark an object or array so that it is ignored by the reactivity system
6
- *
7
- * @param value the value to mark
8
- * @returns the object itself
9
- */
10
- export declare function markRaw<T extends Target>(value: T): T;
11
- /**
12
- * Given a proxy objet, return the raw (non proxy) underlying object
13
- *
14
- * @param value a proxy value
15
- * @returns the underlying value
16
- */
17
- export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
18
- export declare const targets: WeakMap<object, object>;
19
- export declare function proxifyTarget<T extends Target>(target: T, atom: Atom | null): T;
20
- /**
21
- * Creates a reactive proxy for an object. Reading data on the proxy object
22
- * subscribes to changes to the data. Writing data on the object will cause the
23
- * notify callback to be called if there are suscriptions to that data. Nested
24
- * objects and arrays are automatically made reactive as well.
25
- *
26
- * Whenever you are notified of a change, all subscriptions are cleared, and if
27
- * you would like to be notified of any further changes, you should go read
28
- * the underlying data again. We assume that if you don't go read it again after
29
- * being notified, it means that you are no longer interested in that data.
30
- *
31
- * Subscriptions:
32
- * + Reading a property on an object will subscribe you to changes in the value
33
- * of that property.
34
- * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
35
- * subscribe you to the creation/deletion of keys. Checking the presence of a
36
- * key on the object with 'in' has the same effect.
37
- * - getOwnPropertyDescriptor does not currently subscribe you to the property.
38
- * This is a choice that was made because changing a key's value will trigger
39
- * this trap and we do not want to subscribe by writes. This also means that
40
- * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
41
- *
42
- * @param target the object for which to create a proxy proxy
43
- * @param callback the function to call when an observed property of the
44
- * proxy has changed
45
- * @returns a proxy that tracks changes to it
46
- */
47
- export declare function state<T extends Target>(target: T): T;
48
- export {};
@@ -1,19 +0,0 @@
1
- import { AttrParams, DateParams, DatetimeParams, HtmlParams, ManyParams, RelationParams } from "./discussModelTypes";
2
- import { Model } from "./model";
3
- import { FieldDefinition } from "./types";
4
- export declare class DiscussRecord {
5
- static Model: typeof Model;
6
- static fields: Record<string, FieldDefinition>;
7
- static register(): void;
8
- static insert(data: Partial<any>): any;
9
- record: Model;
10
- constructor();
11
- }
12
- export declare const fields: {
13
- One: (modelName: string, params?: RelationParams) => import("./types").FieldDefinitionMany2One;
14
- Many: (modelName: string, params?: ManyParams) => FieldDefinition;
15
- Attr: (defaultValue: string, params?: AttrParams) => import("./types").FieldDefinitionAny;
16
- Html: (defaultValue: string, params?: HtmlParams) => import("./types").FieldDefinitionAny;
17
- Date: (params?: DateParams) => import("./types").FieldDefinitionAny;
18
- Datetime: (params?: DatetimeParams) => import("./types").FieldDefinitionAny;
19
- };
@@ -1,22 +0,0 @@
1
- import { DiscussRecord } from "./discussModel";
2
- export declare type FieldCommonParams = {
3
- compute?: (record: DiscussRecord) => any;
4
- eager?: boolean;
5
- onUpdate?: (record: DiscussRecord) => void;
6
- };
7
- export declare type RelationParams = FieldCommonParams & {
8
- inverse?: string;
9
- onAdd?: (record: DiscussRecord) => void;
10
- onDelete?: (record: DiscussRecord) => void;
11
- };
12
- export declare type ManyParams = RelationParams & {
13
- sort?: (a: DiscussRecord, b: DiscussRecord) => number;
14
- };
15
- export declare type AttrParams = FieldCommonParams & {
16
- sort?: (a: DiscussRecord, b: DiscussRecord) => number;
17
- type?: string;
18
- };
19
- export declare type HtmlParams = FieldCommonParams;
20
- export declare type DateParams = FieldCommonParams;
21
- export declare type DatetimeParams = FieldCommonParams;
22
- export declare type DManyFn<T extends DiscussRecord> = () => T[];
@@ -1,20 +0,0 @@
1
- import { FieldDefinition, FieldDefinitionAny, FieldDefinitionChar, FieldDefinitionDate, FieldDefinitionDatetime, FieldDefinitionHtml, FieldDefinitionMany2One, FieldDefinitionMany2OneReference, FieldDefinitionNumber, FieldDefinitionOne2Many, FieldDefinitionProperties, FieldDefinitionReference, FieldDefinitionSelection, FieldDefinitionText, FieldTypes, ModelId } from "./types";
2
- export declare const fieldAny: () => FieldDefinitionAny;
3
- export declare const fieldNumber: () => FieldDefinitionNumber;
4
- export declare const fieldChar: () => FieldDefinitionChar;
5
- export declare const fieldText: () => FieldDefinitionText;
6
- export declare const fieldHtml: () => FieldDefinitionHtml;
7
- export declare const fieldDate: () => FieldDefinitionDate;
8
- export declare const fieldDatetime: () => FieldDefinitionDatetime;
9
- export declare const fieldSelection: (selection: any) => FieldDefinitionSelection;
10
- export declare const fieldReference: () => FieldDefinitionReference;
11
- export declare const fieldProperties: () => FieldDefinitionProperties;
12
- export declare const fieldOne2Many: (modelId: ModelId, { relatedField }?: {
13
- relatedField?: string | undefined;
14
- }) => FieldDefinitionOne2Many;
15
- export declare const fieldMany2One: (modelId: ModelId) => FieldDefinitionMany2One;
16
- export declare const fieldMany2Many: (modelId: ModelId, opts?: {
17
- relationTableName?: string;
18
- }) => FieldDefinition;
19
- export declare const fieldMany2OneReference: () => FieldDefinitionMany2OneReference;
20
- export declare const field: (type: FieldTypes, opts?: any) => FieldDefinition;