@tstdl/base 0.84.4 → 0.84.6
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/browser/document-controller.d.ts +1 -1
- package/browser/document-controller.js +1 -1
- package/browser/page-controller.d.ts +1 -1
- package/browser/page-controller.js +1 -1
- package/package.json +2 -1
- package/signals/api.d.ts +15 -0
- package/signals/api.js +40 -0
- package/signals/computed-with-dependencies.d.ts +2 -0
- package/signals/computed-with-dependencies.js +36 -0
- package/signals/implementation/api.d.ts +62 -0
- package/signals/implementation/api.js +43 -0
- package/signals/implementation/computed.d.ts +25 -0
- package/signals/implementation/computed.js +118 -0
- package/signals/implementation/configure.d.ts +1 -0
- package/signals/implementation/configure.js +38 -0
- package/signals/implementation/effect.d.ts +54 -0
- package/signals/implementation/effect.js +82 -0
- package/signals/implementation/errors.d.ts +9 -0
- package/signals/implementation/errors.js +41 -0
- package/signals/implementation/graph.d.ts +108 -0
- package/signals/implementation/graph.js +155 -0
- package/signals/implementation/index.d.ts +8 -0
- package/signals/implementation/index.js +25 -0
- package/signals/implementation/signal.d.ts +53 -0
- package/signals/implementation/signal.js +117 -0
- package/signals/implementation/untracked.d.ts +14 -0
- package/signals/implementation/untracked.js +39 -0
- package/signals/implementation/watch.d.ts +44 -0
- package/signals/implementation/watch.js +84 -0
- package/signals/index.d.ts +5 -0
- package/signals/index.js +22 -0
- package/signals/pipe.d.ts +7 -0
- package/signals/pipe.js +30 -0
- package/signals/to-observable.d.ts +16 -0
- package/signals/to-observable.js +38 -0
- package/signals/to-signal.d.ts +84 -0
- package/signals/to-signal.js +67 -0
|
@@ -21,6 +21,6 @@ export declare class DocumentController extends LocatorController {
|
|
|
21
21
|
waitForLoadState(...args: Parameters<Page['waitForLoadState']>): Promise<void>;
|
|
22
22
|
waitForUrl(...args: Parameters<Page['waitForURL']>): Promise<void>;
|
|
23
23
|
waitForElement(selector: string, options?: Parameters<Page['waitForSelector']>[1]): Promise<ElementHandle>;
|
|
24
|
-
|
|
24
|
+
locateInFrame(frameSelector: string): LocatorController;
|
|
25
25
|
waitForFrame(selector: string, options?: Parameters<Page['waitForSelector']>[1]): Promise<FrameController>;
|
|
26
26
|
}
|
|
@@ -61,7 +61,7 @@ class DocumentController extends import_locator_controller.LocatorController {
|
|
|
61
61
|
}
|
|
62
62
|
return element;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
locateInFrame(frameSelector) {
|
|
65
65
|
const locator = this.document.frameLocator(frameSelector);
|
|
66
66
|
return new import_locator_controller.LocatorController(locator, this.elementControllerOptions);
|
|
67
67
|
}
|
|
@@ -23,7 +23,7 @@ export declare class PageController extends DocumentController implements AsyncD
|
|
|
23
23
|
* @param frameSelector frame name, url or url predicate
|
|
24
24
|
* @returns
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
frame(frameSelector: Parameters<Page['frame']>[0]): FrameController;
|
|
27
27
|
renderPdf(options?: PdfRenderOptions & Abortable): Promise<Uint8Array>;
|
|
28
28
|
renderPdfStream(options?: PdfRenderOptions & Abortable): ReadableStream<Uint8Array>;
|
|
29
29
|
}
|
|
@@ -59,7 +59,7 @@ class PageController extends import_document_controller.DocumentController {
|
|
|
59
59
|
* @param frameSelector frame name, url or url predicate
|
|
60
60
|
* @returns
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
frame(frameSelector) {
|
|
63
63
|
const frame = this.page.frame(frameSelector);
|
|
64
64
|
if ((0, import_type_guards.isNull)(frame)) {
|
|
65
65
|
throw new Error("Frame not found.");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.84.
|
|
3
|
+
"version": "0.84.6",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"tsc-alias:watch": "tsc-alias --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@angular/core": "^16.0.0",
|
|
23
24
|
"luxon": "^3.3",
|
|
24
25
|
"reflect-metadata": "^0.1",
|
|
25
26
|
"rxjs": "^7.8",
|
package/signals/api.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as Types from './implementation/index.js';
|
|
2
|
+
export type { CreateComputedOptions, CreateEffectOptions, CreateSignalOptions, EffectRef, Signal, WritableSignal } from './implementation/index.js';
|
|
3
|
+
export type SignalsConfiguration = {
|
|
4
|
+
signal: typeof Types.signal;
|
|
5
|
+
computed: typeof Types.computed;
|
|
6
|
+
effect: typeof Types.effect;
|
|
7
|
+
untracked: typeof Types.untracked;
|
|
8
|
+
isSignal: typeof Types.isSignal;
|
|
9
|
+
};
|
|
10
|
+
export declare let signal: typeof Types.signal;
|
|
11
|
+
export declare let computed: typeof Types.computed;
|
|
12
|
+
export declare let effect: typeof Types.effect;
|
|
13
|
+
export declare let untracked: typeof Types.untracked;
|
|
14
|
+
export declare let isSignal: typeof Types.isSignal;
|
|
15
|
+
export declare function configureSignals(configuration: SignalsConfiguration): void;
|
package/signals/api.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var api_exports = {};
|
|
20
|
+
__export(api_exports, {
|
|
21
|
+
computed: () => computed,
|
|
22
|
+
configureSignals: () => configureSignals,
|
|
23
|
+
effect: () => effect,
|
|
24
|
+
isSignal: () => isSignal,
|
|
25
|
+
signal: () => signal,
|
|
26
|
+
untracked: () => untracked
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(api_exports);
|
|
29
|
+
let signal;
|
|
30
|
+
let computed;
|
|
31
|
+
let effect;
|
|
32
|
+
let untracked;
|
|
33
|
+
let isSignal;
|
|
34
|
+
function configureSignals(configuration) {
|
|
35
|
+
signal = configuration.signal;
|
|
36
|
+
computed = configuration.computed;
|
|
37
|
+
effect = configuration.effect;
|
|
38
|
+
untracked = configuration.untracked;
|
|
39
|
+
isSignal = configuration.isSignal;
|
|
40
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var computed_with_dependencies_exports = {};
|
|
20
|
+
__export(computed_with_dependencies_exports, {
|
|
21
|
+
computedWithDependencies: () => computedWithDependencies
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(computed_with_dependencies_exports);
|
|
24
|
+
var import_api = require("./api.js");
|
|
25
|
+
function computedWithDependencies(computation, dependencies, options = {}) {
|
|
26
|
+
if (dependencies.length == 0) {
|
|
27
|
+
throw new Error("No additional dependencies provided.");
|
|
28
|
+
}
|
|
29
|
+
function actualComputation() {
|
|
30
|
+
for (const dependency of dependencies) {
|
|
31
|
+
dependency();
|
|
32
|
+
}
|
|
33
|
+
return computation();
|
|
34
|
+
}
|
|
35
|
+
return (0, import_api.computed)(actualComputation, options);
|
|
36
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import type { ReactiveNode } from './graph.js';
|
|
9
|
+
/**
|
|
10
|
+
* Symbol used to tell `Signal`s apart from other functions.
|
|
11
|
+
*
|
|
12
|
+
* This can be used to auto-unwrap signals in various cases, or to auto-wrap non-signal values.
|
|
13
|
+
*/
|
|
14
|
+
declare const SIGNAL: unique symbol;
|
|
15
|
+
/**
|
|
16
|
+
* A reactive value which notifies consumers of any changes.
|
|
17
|
+
*
|
|
18
|
+
* Signals are functions which returns their current value. To access the current value of a signal,
|
|
19
|
+
* call it.
|
|
20
|
+
*
|
|
21
|
+
* Ordinary values can be turned into `Signal`s with the `signal` function.
|
|
22
|
+
*/
|
|
23
|
+
export interface Signal<T> {
|
|
24
|
+
(): T;
|
|
25
|
+
[SIGNAL]?: unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Checks if the given `value` function is a reactive `Signal`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isSignal(value: Function): value is Signal<unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Converts `fn` into a marked signal function (where `isSignal(fn)` will be `true`).
|
|
33
|
+
*
|
|
34
|
+
* @param fn A zero-argument function which will be converted into a `Signal`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSignalFromFunction<T>(node: ReactiveNode, fn: () => T): Signal<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Converts `fn` into a marked signal function (where `isSignal(fn)` will be `true`), and
|
|
39
|
+
* potentially add some set of extra properties (passed as an object record `extraApi`).
|
|
40
|
+
*
|
|
41
|
+
* @param fn A zero-argument function which will be converted into a `Signal`.
|
|
42
|
+
* @param extraApi An object whose properties will be copied onto `fn` in order to create a specific
|
|
43
|
+
* desired interface for the `Signal`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createSignalFromFunction<T, U extends Record<string, unknown>>(node: ReactiveNode, fn: () => T, extraApi: U): Signal<T> & U;
|
|
46
|
+
/**
|
|
47
|
+
* A comparison function which can determine if two values are equal.
|
|
48
|
+
*
|
|
49
|
+
* @developerPreview
|
|
50
|
+
*/
|
|
51
|
+
export type ValueEqualityFn<T> = (a: T, b: T) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The default equality function used for `signal` and `computed`, which treats objects and arrays
|
|
54
|
+
* as never equal, and all other primitive values using identity semantics.
|
|
55
|
+
*
|
|
56
|
+
* This allows signals to hold non-primitive values (arrays, objects, other collections) and still
|
|
57
|
+
* propagate change notification upon explicit mutation without identity change.
|
|
58
|
+
*
|
|
59
|
+
* @developerPreview
|
|
60
|
+
*/
|
|
61
|
+
export declare function defaultEquals<T>(a: T, b: T): boolean;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var api_exports = {};
|
|
20
|
+
__export(api_exports, {
|
|
21
|
+
createSignalFromFunction: () => createSignalFromFunction,
|
|
22
|
+
defaultEquals: () => defaultEquals,
|
|
23
|
+
isSignal: () => isSignal
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(api_exports);
|
|
26
|
+
/**
|
|
27
|
+
* @license
|
|
28
|
+
* Copyright Google LLC All Rights Reserved.
|
|
29
|
+
*
|
|
30
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
31
|
+
* found in the LICENSE file at https://angular.io/license
|
|
32
|
+
*/
|
|
33
|
+
const SIGNAL = Symbol("SIGNAL");
|
|
34
|
+
function isSignal(value) {
|
|
35
|
+
return value[SIGNAL] !== void 0;
|
|
36
|
+
}
|
|
37
|
+
function createSignalFromFunction(node, fn, extraApi = {}) {
|
|
38
|
+
fn[SIGNAL] = node;
|
|
39
|
+
return Object.assign(fn, extraApi);
|
|
40
|
+
}
|
|
41
|
+
function defaultEquals(a, b) {
|
|
42
|
+
return (a === null || typeof a !== "object") && Object.is(a, b);
|
|
43
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import type { Signal, ValueEqualityFn } from './api.js';
|
|
9
|
+
/**
|
|
10
|
+
* Options passed to the `computed` creation function.
|
|
11
|
+
*
|
|
12
|
+
* @developerPreview
|
|
13
|
+
*/
|
|
14
|
+
export interface CreateComputedOptions<T> {
|
|
15
|
+
/**
|
|
16
|
+
* A comparison function which defines equality for computed values.
|
|
17
|
+
*/
|
|
18
|
+
equal?: ValueEqualityFn<T>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a computed `Signal` which derives a reactive value from an expression.
|
|
22
|
+
*
|
|
23
|
+
* @developerPreview
|
|
24
|
+
*/
|
|
25
|
+
export declare function computed<T>(computation: () => T, options?: CreateComputedOptions<T>): Signal<T>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var computed_exports = {};
|
|
20
|
+
__export(computed_exports, {
|
|
21
|
+
computed: () => computed
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(computed_exports);
|
|
24
|
+
var import_api = require("./api.js");
|
|
25
|
+
var import_graph = require("./graph.js");
|
|
26
|
+
/**
|
|
27
|
+
* @license
|
|
28
|
+
* Copyright Google LLC All Rights Reserved.
|
|
29
|
+
*
|
|
30
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
31
|
+
* found in the LICENSE file at https://angular.io/license
|
|
32
|
+
*/
|
|
33
|
+
function computed(computation, options = {}) {
|
|
34
|
+
const node = new ComputedImpl(computation, options.equal ?? import_api.defaultEquals);
|
|
35
|
+
return (0, import_api.createSignalFromFunction)(node, node.signal.bind(node));
|
|
36
|
+
}
|
|
37
|
+
const UNSET = Symbol("UNSET");
|
|
38
|
+
const COMPUTING = Symbol("COMPUTING");
|
|
39
|
+
const ERRORED = Symbol("ERRORED");
|
|
40
|
+
class ComputedImpl extends import_graph.ReactiveNode {
|
|
41
|
+
computation;
|
|
42
|
+
equal;
|
|
43
|
+
constructor(computation, equal) {
|
|
44
|
+
super();
|
|
45
|
+
this.computation = computation;
|
|
46
|
+
this.equal = equal;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Current value of the computation.
|
|
50
|
+
*
|
|
51
|
+
* This can also be one of the special values `UNSET`, `COMPUTING`, or `ERRORED`.
|
|
52
|
+
*/
|
|
53
|
+
value = UNSET;
|
|
54
|
+
/**
|
|
55
|
+
* If `value` is `ERRORED`, the error caught from the last computation attempt which will
|
|
56
|
+
* be re-thrown.
|
|
57
|
+
*/
|
|
58
|
+
error = null;
|
|
59
|
+
/**
|
|
60
|
+
* Flag indicating that the computation is currently stale, meaning that one of the
|
|
61
|
+
* dependencies has notified of a potential change.
|
|
62
|
+
*
|
|
63
|
+
* It's possible that no dependency has _actually_ changed, in which case the `stale`
|
|
64
|
+
* state can be resolved without recomputing the value.
|
|
65
|
+
*/
|
|
66
|
+
stale = true;
|
|
67
|
+
consumerAllowSignalWrites = false;
|
|
68
|
+
onConsumerDependencyMayHaveChanged() {
|
|
69
|
+
if (this.stale) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.stale = true;
|
|
73
|
+
this.producerMayHaveChanged();
|
|
74
|
+
}
|
|
75
|
+
onProducerUpdateValueVersion() {
|
|
76
|
+
if (!this.stale) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (this.value !== UNSET && this.value !== COMPUTING && !this.consumerPollProducersForChange()) {
|
|
80
|
+
this.stale = false;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.recomputeValue();
|
|
84
|
+
}
|
|
85
|
+
recomputeValue() {
|
|
86
|
+
if (this.value === COMPUTING) {
|
|
87
|
+
throw new Error("Detected cycle in computations.");
|
|
88
|
+
}
|
|
89
|
+
const oldValue = this.value;
|
|
90
|
+
this.value = COMPUTING;
|
|
91
|
+
this.trackingVersion++;
|
|
92
|
+
const prevConsumer = (0, import_graph.setActiveConsumer)(this);
|
|
93
|
+
let newValue;
|
|
94
|
+
try {
|
|
95
|
+
newValue = this.computation();
|
|
96
|
+
} catch (err) {
|
|
97
|
+
newValue = ERRORED;
|
|
98
|
+
this.error = err;
|
|
99
|
+
} finally {
|
|
100
|
+
(0, import_graph.setActiveConsumer)(prevConsumer);
|
|
101
|
+
}
|
|
102
|
+
this.stale = false;
|
|
103
|
+
if (oldValue !== UNSET && oldValue !== ERRORED && newValue !== ERRORED && this.equal(oldValue, newValue)) {
|
|
104
|
+
this.value = oldValue;
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.value = newValue;
|
|
108
|
+
this.valueVersion++;
|
|
109
|
+
}
|
|
110
|
+
signal() {
|
|
111
|
+
this.onProducerUpdateValueVersion();
|
|
112
|
+
this.producerAccessed();
|
|
113
|
+
if (this.value === ERRORED) {
|
|
114
|
+
throw this.error;
|
|
115
|
+
}
|
|
116
|
+
return this.value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function configureDefaultSignalsImplementation(): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var configure_exports = {};
|
|
20
|
+
__export(configure_exports, {
|
|
21
|
+
configureDefaultSignalsImplementation: () => configureDefaultSignalsImplementation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(configure_exports);
|
|
24
|
+
var import_api = require("../api.js");
|
|
25
|
+
var import_api2 = require("./api.js");
|
|
26
|
+
var import_computed = require("./computed.js");
|
|
27
|
+
var import_effect = require("./effect.js");
|
|
28
|
+
var import_signal = require("./signal.js");
|
|
29
|
+
var import_untracked = require("./untracked.js");
|
|
30
|
+
function configureDefaultSignalsImplementation() {
|
|
31
|
+
(0, import_api.configureSignals)({
|
|
32
|
+
signal: import_signal.signal,
|
|
33
|
+
computed: import_computed.computed,
|
|
34
|
+
effect: import_effect.effect,
|
|
35
|
+
untracked: import_untracked.untracked,
|
|
36
|
+
isSignal: import_api2.isSignal
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A global reactive effect, which can be manually destroyed.
|
|
10
|
+
*/
|
|
11
|
+
export interface EffectRef {
|
|
12
|
+
/**
|
|
13
|
+
* Shut down the effect, removing it from any upcoming scheduled executions.
|
|
14
|
+
*/
|
|
15
|
+
destroy(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An effect can, optionally, register a cleanup function. If registered, the cleanup is executed
|
|
19
|
+
* before the next effect run. The cleanup function makes it possible to "cancel" any work that the
|
|
20
|
+
* previous effect run might have started.
|
|
21
|
+
*/
|
|
22
|
+
export type EffectCleanupFn = () => void;
|
|
23
|
+
/**
|
|
24
|
+
* A callback passed to the effect function that makes it possible to register cleanup logic.
|
|
25
|
+
*/
|
|
26
|
+
export type EffectCleanupRegisterFn = (cleanupFn: EffectCleanupFn) => void;
|
|
27
|
+
export type CreateEffectOptions = {
|
|
28
|
+
/**
|
|
29
|
+
* Whether the `effect` should allow writing to signals.
|
|
30
|
+
*
|
|
31
|
+
* Using effects to synchronize data by writing to signals can lead to confusing and potentially
|
|
32
|
+
* incorrect behavior, and should be enabled only when necessary.
|
|
33
|
+
*/
|
|
34
|
+
allowSignalWrites?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Immediately run effect after creation without scheduling - for advanced use cases.
|
|
37
|
+
*/
|
|
38
|
+
runImmediately?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Tracks all effects registered within a given application and runs them via `flush`.
|
|
42
|
+
*/
|
|
43
|
+
export declare class EffectManager {
|
|
44
|
+
private readonly all;
|
|
45
|
+
private readonly queue;
|
|
46
|
+
private pendingFlush;
|
|
47
|
+
create(effectFn: (onCleanup: (cleanupFn: EffectCleanupFn) => void) => void, { allowSignalWrites, runImmediately }?: CreateEffectOptions): EffectRef;
|
|
48
|
+
flush(): void;
|
|
49
|
+
get isQueueEmpty(): boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a global `Effect` for the given reactive function.
|
|
53
|
+
*/
|
|
54
|
+
export declare function effect(effectFn: (onCleanup: EffectCleanupRegisterFn) => void, options?: CreateEffectOptions): EffectRef;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var effect_exports = {};
|
|
20
|
+
__export(effect_exports, {
|
|
21
|
+
EffectManager: () => EffectManager,
|
|
22
|
+
effect: () => effect
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(effect_exports);
|
|
25
|
+
var import_watch = require("./watch.js");
|
|
26
|
+
/**
|
|
27
|
+
* @license
|
|
28
|
+
* Copyright Google LLC All Rights Reserved.
|
|
29
|
+
*
|
|
30
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
31
|
+
* found in the LICENSE file at https://angular.io/license
|
|
32
|
+
*/
|
|
33
|
+
class EffectManager {
|
|
34
|
+
all = /* @__PURE__ */ new Set();
|
|
35
|
+
queue = /* @__PURE__ */ new Set();
|
|
36
|
+
pendingFlush;
|
|
37
|
+
create(effectFn, { allowSignalWrites = false, runImmediately = false } = {}) {
|
|
38
|
+
const watch = new import_watch.Watch(effectFn, (watch2) => {
|
|
39
|
+
if (!this.all.has(watch2)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.queue.add(watch2);
|
|
43
|
+
if (!this.pendingFlush) {
|
|
44
|
+
this.pendingFlush = true;
|
|
45
|
+
queueMicrotask(() => {
|
|
46
|
+
this.pendingFlush = false;
|
|
47
|
+
this.flush();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}, allowSignalWrites);
|
|
51
|
+
this.all.add(watch);
|
|
52
|
+
if (runImmediately) {
|
|
53
|
+
watch.run();
|
|
54
|
+
} else {
|
|
55
|
+
watch.notify();
|
|
56
|
+
}
|
|
57
|
+
const destroy = () => {
|
|
58
|
+
watch.cleanup();
|
|
59
|
+
this.all.delete(watch);
|
|
60
|
+
this.queue.delete(watch);
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
destroy
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
flush() {
|
|
67
|
+
if (this.queue.size === 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
for (const watch of this.queue) {
|
|
71
|
+
this.queue.delete(watch);
|
|
72
|
+
watch.run();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
get isQueueEmpty() {
|
|
76
|
+
return this.queue.size === 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const effectManager = new EffectManager();
|
|
80
|
+
function effect(effectFn, options) {
|
|
81
|
+
return effectManager.create(effectFn, options);
|
|
82
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
export declare function throwInvalidWriteToSignalError(): void;
|
|
9
|
+
export declare function setThrowInvalidWriteToSignalError(fn: () => never): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var errors_exports = {};
|
|
20
|
+
__export(errors_exports, {
|
|
21
|
+
setThrowInvalidWriteToSignalError: () => setThrowInvalidWriteToSignalError,
|
|
22
|
+
throwInvalidWriteToSignalError: () => throwInvalidWriteToSignalError
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(errors_exports);
|
|
25
|
+
/**
|
|
26
|
+
* @license
|
|
27
|
+
* Copyright Google LLC All Rights Reserved.
|
|
28
|
+
*
|
|
29
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
30
|
+
* found in the LICENSE file at https://angular.io/license
|
|
31
|
+
*/
|
|
32
|
+
function defaultThrowError() {
|
|
33
|
+
throw new Error();
|
|
34
|
+
}
|
|
35
|
+
let throwInvalidWriteToSignalErrorFn = defaultThrowError;
|
|
36
|
+
function throwInvalidWriteToSignalError() {
|
|
37
|
+
throwInvalidWriteToSignalErrorFn();
|
|
38
|
+
}
|
|
39
|
+
function setThrowInvalidWriteToSignalError(fn) {
|
|
40
|
+
throwInvalidWriteToSignalErrorFn = fn;
|
|
41
|
+
}
|