@ember-data/tracking 5.4.0-alpha.30 → 5.4.0-alpha.31
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/tracking",
|
|
3
3
|
"description": "Tracking Primitives for controlling change notification of Tracked properties when working with EmberData",
|
|
4
|
-
"version": "5.4.0-alpha.
|
|
4
|
+
"version": "5.4.0-alpha.31",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
@@ -27,13 +27,14 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@ember-data/private-build-infra": "5.4.0-alpha.
|
|
30
|
+
"@ember-data/private-build-infra": "5.4.0-alpha.31",
|
|
31
31
|
"@embroider/macros": "^1.13.5",
|
|
32
32
|
"ember-cached-decorator-polyfill": "^1.0.2",
|
|
33
33
|
"ember-cli-babel": "^8.2.0",
|
|
34
34
|
"pnpm-sync-dependencies-meta-injected": "0.0.10"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
|
+
"unstable-preview-types",
|
|
37
38
|
"addon-main.cjs",
|
|
38
39
|
"addon",
|
|
39
40
|
"README.md",
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
"@glimmer/validator": "^0.88.1",
|
|
63
64
|
"@rollup/plugin-babel": "^6.0.4",
|
|
64
65
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
65
|
-
"@warp-drive/internal-config": "5.4.0-alpha.
|
|
66
|
+
"@warp-drive/internal-config": "5.4.0-alpha.31",
|
|
66
67
|
"ember-source": "~5.6.0",
|
|
67
68
|
"rollup": "^4.9.6",
|
|
68
69
|
"typescript": "^5.3.3",
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"scripts": {
|
|
75
76
|
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
|
|
76
77
|
"build:runtime": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
|
|
77
|
-
"build:types": "
|
|
78
|
+
"build:types": "tsc --build",
|
|
78
79
|
"_build": "bun run build:runtime && bun run build:types",
|
|
79
80
|
"_syncPnpm": "bun run sync-dependencies-meta-injected"
|
|
80
81
|
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/// <reference types="ember-source/types" />
|
|
2
|
+
/// <reference types="ember-source/types" />
|
|
3
|
+
import { tagForProperty } from '@ember/-internals/metal';
|
|
4
|
+
/**
|
|
5
|
+
* This package provides primitives that allow powerful low-level
|
|
6
|
+
* adjustments to change tracking notification behaviors.
|
|
7
|
+
*
|
|
8
|
+
* Typically you want to use these primitives when you want to divorce
|
|
9
|
+
* property accesses on EmberData provided objects from the current
|
|
10
|
+
* tracking context. Typically this sort of thing occurs when serializing
|
|
11
|
+
* tracked data to send in a request: the data itself is often ancillary
|
|
12
|
+
* to the thing which triggered the request in the first place and you
|
|
13
|
+
* would not want to re-trigger the request for any update to the data.
|
|
14
|
+
*
|
|
15
|
+
* @module @ember-data/tracking
|
|
16
|
+
* @main @ember-data/tracking
|
|
17
|
+
*/
|
|
18
|
+
type OpaqueFn = (...args: unknown[]) => unknown;
|
|
19
|
+
type Tag = {
|
|
20
|
+
ref: null;
|
|
21
|
+
t: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* If there is a current transaction, ensures that the relevant tag (and any
|
|
25
|
+
* array computed chains symbols, if applicable) will be consumed during the
|
|
26
|
+
* transaction.
|
|
27
|
+
*
|
|
28
|
+
* If there is no current transaction, will consume the tag(s) immediately.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
* @param obj
|
|
32
|
+
*/
|
|
33
|
+
export declare function subscribe(obj: Tag | Signal): void;
|
|
34
|
+
export declare function addToTransaction(obj: Tag | Signal): void;
|
|
35
|
+
export declare function addTransactionCB(method: OpaqueFn): void;
|
|
36
|
+
/**
|
|
37
|
+
* Run `method` without subscribing to any tracked properties
|
|
38
|
+
* controlled by EmberData.
|
|
39
|
+
*
|
|
40
|
+
* This should rarely be used except by libraries that really
|
|
41
|
+
* know what they are doing. It is most useful for wrapping
|
|
42
|
+
* certain kinds of fetch/query logic from within a `Resource`
|
|
43
|
+
* `hook` or other similar pattern.
|
|
44
|
+
*
|
|
45
|
+
* @function untracked
|
|
46
|
+
* @public
|
|
47
|
+
* @static
|
|
48
|
+
* @for @ember-data/tracking
|
|
49
|
+
* @param method
|
|
50
|
+
* @return result of invoking method
|
|
51
|
+
*/
|
|
52
|
+
export declare function untracked<T extends OpaqueFn>(method: T): ReturnType<T>;
|
|
53
|
+
/**
|
|
54
|
+
* Run the method, subscribing to any tracked properties
|
|
55
|
+
* managed by EmberData that were accessed or written during
|
|
56
|
+
* the method's execution as per-normal but while allowing
|
|
57
|
+
* interleaving of reads and writes.
|
|
58
|
+
*
|
|
59
|
+
* This is useful when for instance you want to perform
|
|
60
|
+
* a mutation based on existing state that must be read first.
|
|
61
|
+
*
|
|
62
|
+
* @function transact
|
|
63
|
+
* @public
|
|
64
|
+
* @static
|
|
65
|
+
* @for @ember-data/tracking
|
|
66
|
+
* @param method
|
|
67
|
+
* @return result of invoking method
|
|
68
|
+
*/
|
|
69
|
+
export declare function transact<T extends OpaqueFn>(method: T): ReturnType<T>;
|
|
70
|
+
/**
|
|
71
|
+
* A helpful utility for creating a new function that
|
|
72
|
+
* always runs in a transaction. E.G. this "memoizes"
|
|
73
|
+
* calling `transact(fn)`, currying args as necessary.
|
|
74
|
+
*
|
|
75
|
+
* @method memoTransact
|
|
76
|
+
* @public
|
|
77
|
+
* @static
|
|
78
|
+
* @for @ember-data/tracking
|
|
79
|
+
* @param method
|
|
80
|
+
* @return a function that will invoke method in a transaction with any provided args and return its result
|
|
81
|
+
*/
|
|
82
|
+
export declare function memoTransact<T extends OpaqueFn>(method: T): (...args: unknown[]) => ReturnType<T>;
|
|
83
|
+
export declare const Signals: unique symbol;
|
|
84
|
+
/**
|
|
85
|
+
* use to add a signal property to the prototype of something.
|
|
86
|
+
*
|
|
87
|
+
* First arg is the thing to define on
|
|
88
|
+
* Second arg is the property name
|
|
89
|
+
* Third agg is the initial value of the property if any.
|
|
90
|
+
*
|
|
91
|
+
* for instance
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* class Model {}
|
|
95
|
+
* defineSignal(Model.prototype, 'isLoading', false);
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* This is sort of like using a stage-3 decorator but works today
|
|
99
|
+
* while we are still on legacy decorators.
|
|
100
|
+
*
|
|
101
|
+
* e.g. it is equivalent to
|
|
102
|
+
*
|
|
103
|
+
* ```ts
|
|
104
|
+
* class Model {
|
|
105
|
+
* @signal accessor isLoading = false;
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
export declare function defineSignal<T extends object>(obj: T, key: string, v?: unknown): void;
|
|
112
|
+
export interface Signal {
|
|
113
|
+
/**
|
|
114
|
+
* Key on the associated object
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
key: string;
|
|
118
|
+
_debug_base?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Whether this signal is part of an active transaction.
|
|
121
|
+
* @internal
|
|
122
|
+
*/
|
|
123
|
+
t: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Whether to "bust" the lastValue cache
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
shouldReset: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* The framework specific "signal" e.g. glimmer "tracked"
|
|
131
|
+
* or starbeam "cell" to consume/invalidate when appropriate.
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
tag: ReturnType<typeof tagForProperty>;
|
|
136
|
+
/**
|
|
137
|
+
* In classic ember, arrays must entangle a `[]` symbol
|
|
138
|
+
* in addition to any other tag in order for array chains to work.
|
|
139
|
+
*
|
|
140
|
+
* Note, this symbol MUST be the one that ember itself generates
|
|
141
|
+
*
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
'[]': ReturnType<typeof tagForProperty> | null;
|
|
145
|
+
/**
|
|
146
|
+
* In classic ember, arrays must entangle a `@length` symbol
|
|
147
|
+
* in addition to any other tag in order for array chains to work.
|
|
148
|
+
*
|
|
149
|
+
* Note, this symbol MUST be the one that ember itself generates
|
|
150
|
+
*
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
153
|
+
'@length': ReturnType<typeof tagForProperty> | null;
|
|
154
|
+
/**
|
|
155
|
+
* The lastValue computed for this signal when
|
|
156
|
+
* a signal is also used for storage.
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
lastValue: unknown;
|
|
160
|
+
}
|
|
161
|
+
export declare function createArrayTags<T extends object>(obj: T, signal: Signal): void;
|
|
162
|
+
/**
|
|
163
|
+
* Create a signal for the key/object pairing.
|
|
164
|
+
*
|
|
165
|
+
* @internal
|
|
166
|
+
* @param obj Object we're creating the signal on
|
|
167
|
+
* @param key Key to create the signal for
|
|
168
|
+
* @return the signal
|
|
169
|
+
*/
|
|
170
|
+
export declare function createSignal<T extends object>(obj: T, key: string): Signal;
|
|
171
|
+
/**
|
|
172
|
+
* Create a signal for the key/object pairing and subscribes to the signal.
|
|
173
|
+
*
|
|
174
|
+
* Use when you need to ensure a signal exists and is subscribed to.
|
|
175
|
+
*
|
|
176
|
+
* @internal
|
|
177
|
+
* @param signals Map of signals
|
|
178
|
+
* @param obj Object we're creating the signal on
|
|
179
|
+
* @param key Key to create the signal for
|
|
180
|
+
* @return the signal
|
|
181
|
+
*/
|
|
182
|
+
export declare function entangleSignal<T extends object>(signals: Map<string, Signal>, obj: T, key: string): Signal;
|
|
183
|
+
export declare function getSignal<T extends object>(obj: T, key: string, initialState: boolean): Signal;
|
|
184
|
+
export declare function peekSignal<T extends object>(obj: T, key: string): Signal | undefined;
|
|
185
|
+
export {};
|
|
186
|
+
//# sourceMappingURL=-private.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"-private.d.ts","sourceRoot":"","sources":["../src/-private.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAMzD;;;;;;;;;;;;;GAaG;AACH,KAAK,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAChD,KAAK,GAAG,GAAG;IAAE,GAAG,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAmCrC;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAYjD;AA6GD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAMxD;AACD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAMvD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAKtE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAKrE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,UAAU,CAAC,CAAC,CAAC,CAOjG;AAED,eAAO,MAAM,OAAO,eAAoB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U,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKpF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="ember-source/types" />
|
|
2
|
+
/// <reference types="ember-source/types" />
|
|
3
|
+
import { createCache, getValue } from '@glimmer/tracking/primitives/cache';
|
|
4
|
+
export { transact, memoTransact, untracked } from './-private';
|
|
5
|
+
export { dependentKeyCompat as compat } from '@ember/object/compat';
|
|
6
|
+
export declare function cached<T extends object, K extends keyof T & string>(target: T, key: K, descriptor: PropertyDescriptor): void;
|
|
7
|
+
export { createCache, getValue };
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI/D,OAAO,EAAE,kBAAkB,IAAI,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEpE,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,EACjE,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,CAAC,EACN,UAAU,EAAE,kBAAkB,QA6B/B;AAED,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC"}
|