@ember-data/tracking 5.5.0-alpha.2 → 5.5.0-alpha.20
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/LICENSE.md +19 -7
- package/README.md +35 -13
- package/addon-main.cjs +5 -0
- package/dist/-private.js +415 -0
- package/dist/-private.js.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/logos/NCC-1701-a-blue.svg +4 -0
- package/logos/NCC-1701-a-gold.svg +4 -0
- package/logos/NCC-1701-a-gold_100.svg +1 -0
- package/logos/NCC-1701-a-gold_base-64.txt +1 -0
- package/logos/NCC-1701-a.svg +4 -0
- package/logos/README.md +4 -0
- package/logos/docs-badge.svg +2 -0
- package/logos/ember-data-logo-dark.svg +12 -0
- package/logos/ember-data-logo-light.svg +12 -0
- package/logos/github-header.svg +444 -0
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +4 -0
- package/logos/warp-drive-logo-gold.svg +4 -0
- package/package.json +52 -35
- package/unstable-preview-types/-private.d.ts +196 -0
- package/unstable-preview-types/-private.d.ts.map +1 -0
- package/unstable-preview-types/index.d.ts +8 -0
- package/unstable-preview-types/index.d.ts.map +1 -0
- package/addon/-private.js +0 -199
- package/addon/-private.js.map +0 -1
- package/addon/index.js +0 -1
- package/addon/index.js.map +0 -1
- package/addon-main.js +0 -93
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 324 32">
|
|
2
|
+
<path fill="#110819"
|
|
3
|
+
d="M321.58 29.54a41.7 41.7 0 0 1-7.26 1.72c-2.4.36-4.87.53-7.4.53-3.21 0-6.09-.34-8.6-1.03a18.5 18.5 0 0 1-6.34-3.03 13.07 13.07 0 0 1-3.94-4.83c-.9-1.9-1.35-4.06-1.35-6.47a14.32 14.32 0 0 1 5.22-11.19 18.14 18.14 0 0 1 6.06-3.3c2.36-.81 5-1.21 7.9-1.21 2.68 0 5.13.36 7.35 1.1 2.24.71 4.15 1.78 5.74 3.2a14.28 14.28 0 0 1 3.72 5.24 18.12 18.12 0 0 1 1.33 7.17v1.98h-29.1a7.5 7.5 0 0 0 1.28 2.56c.6.77 1.4 1.43 2.42 1.97 1.02.55 2.27.97 3.74 1.27 1.5.3 3.27.45 5.33.45a35.35 35.35 0 0 0 8.23-.96c1.22-.3 2.31-.64 3.29-1 .99-.35 1.78-.7 2.38-1.07v6.9Zm-5.5-15.96a6.73 6.73 0 0 0-.66-2.26 5.82 5.82 0 0 0-1.72-2.13 9.46 9.46 0 0 0-3.1-1.54 15.6 15.6 0 0 0-4.77-.63c-1.79 0-3.33.23-4.64.67-1.3.44-2.4 1-3.29 1.65a8.37 8.37 0 0 0-2.04 2.13c-.48.76-.8 1.46-.94 2.1h21.16ZM271.84 31h-9.28L247.63 1.48h8.9l10.74 22.22 10.72-22.22h8.9L271.83 31ZM234.8 31V1.48h7.97V31h-7.97ZM229.73 8.16l-.94-.28c-.4-.13-.88-.25-1.42-.36a17.88 17.88 0 0 0-3.8-.45c-1.44 0-2.78.18-4.02.53-1.23.35-2.39.81-3.46 1.4a19.48 19.48 0 0 0-3 1.98c-.92.73-1.77 1.48-2.54 2.25V31h-7.97V1.48h7.97v4.8c.96-.72 1.94-1.41 2.94-2.07a25.36 25.36 0 0 1 3.16-1.78 18.9 18.9 0 0 1 3.48-1.23 15.39 15.39 0 0 1 5.44-.39 25 25 0 0 1 4.16.67v6.68ZM197.05 16.22c0 1.89-.2 3.57-.62 5.05a12.7 12.7 0 0 1-1.76 3.82 11.07 11.07 0 0 1-2.7 2.77 13.77 13.77 0 0 1-3.51 1.83c-1.29.46-2.68.8-4.17 1-1.49.21-3.04.31-4.66.31H160.9V1.48h18.69c1.62 0 3.17.1 4.66.32 1.49.2 2.88.53 4.17 1 1.3.45 2.48 1.06 3.54 1.82 1.06.74 1.96 1.67 2.7 2.77a12.7 12.7 0 0 1 1.77 3.82c.42 1.46.62 3.13.62 5Zm-8.03 0c0-1.42-.19-2.65-.56-3.7a5.64 5.64 0 0 0-1.76-2.57 7.66 7.66 0 0 0-3.16-1.53c-1.3-.34-2.9-.52-4.77-.52h-9.9v16.68h9.9c1.88 0 3.47-.17 4.77-.5a7.86 7.86 0 0 0 3.16-1.54c.81-.7 1.4-1.58 1.76-2.63.37-1.04.56-2.27.56-3.7ZM153.98 10.55c0 1.47-.25 2.78-.73 3.9a6.82 6.82 0 0 1-2.26 2.86 10.95 10.95 0 0 1-4 1.77 25.6 25.6 0 0 1-5.86.58h-13.26V31h-2.68V1.48h15.94c2.3 0 4.25.2 5.87.6 1.63.39 2.96.96 4 1.72a6.67 6.67 0 0 1 2.25 2.84c.48 1.13.73 2.43.73 3.9Zm-2.77 0c0-1.4-.24-2.54-.71-3.4a4.53 4.53 0 0 0-2.15-1.97c-.96-.48-2.19-.8-3.68-.95a50.43 50.43 0 0 0-5.26-.24h-11.54v13.15h11.54l2.51.02c.9 0 1.8-.04 2.67-.12.87-.1 1.7-.27 2.5-.5.8-.24 1.5-.6 2.1-1.1a5.05 5.05 0 0 0 1.46-1.9 7 7 0 0 0 .56-3ZM119.76 3.76c-.41-.13-1-.27-1.74-.41-.73-.16-1.67-.24-2.83-.24-1.6 0-3.12.2-4.54.6a17.94 17.94 0 0 0-7.28 3.96 23.73 23.73 0 0 0-2.8 2.83V31H97.9V1.48h2.69V7.5c.96-1 2-1.9 3.11-2.73a21.54 21.54 0 0 1 7.48-3.53 17.47 17.47 0 0 1 5.6-.47c.4.02.77.04 1.1.09a16.6 16.6 0 0 1 1.9.26v2.64ZM85.52 31v-3.27c-1.03.56-2.2 1.08-3.53 1.55a40.4 40.4 0 0 1-13.13 2.3c-1.91 0-3.64-.17-5.17-.52a12.2 12.2 0 0 1-3.87-1.52A7.38 7.38 0 0 1 57.37 27a7.06 7.06 0 0 1-.86-3.52c0-1.32.33-2.48 1-3.48a8.81 8.81 0 0 1 2.85-2.64c1.23-.76 2.71-1.4 4.45-1.91 1.74-.53 3.7-.98 5.84-1.34 2.15-.37 4.47-.67 6.96-.9 2.5-.24 5.14-.44 7.9-.6v-2.26c0-.91-.16-1.72-.5-2.42a5.54 5.54 0 0 0-1.45-1.83 7.97 7.97 0 0 0-2.17-1.31c-.83-.36-1.73-.65-2.7-.86a33.97 33.97 0 0 0-13.54.21c-1.03.25-2.02.53-2.96.86-.95.33-1.9.68-2.86 1.06V2.92c1.99-.53 4.1-.99 6.36-1.38 2.26-.4 4.66-.6 7.2-.6 2.14 0 4.15.19 6.01.56 1.86.36 3.48.94 4.86 1.74A9.16 9.16 0 0 1 87 6.36a8.55 8.55 0 0 1 1.18 4.62V31h-2.66Zm0-16c-4.69.25-8.69.62-12.01 1.09-3.31.47-6.02 1.05-8.12 1.74-2.1.69-3.66 1.49-4.64 2.4a4.18 4.18 0 0 0-1.46 3.12c0 .95.23 1.78.7 2.52a5.86 5.86 0 0 0 2.09 1.84c.9.49 2 .86 3.29 1.12 1.28.24 2.73.37 4.34.37a29.36 29.36 0 0 0 5.95-.6 36.6 36.6 0 0 0 5.71-1.57c.86-.32 1.64-.66 2.34-1.01a11.3 11.3 0 0 0 1.8-1.1v-9.93ZM28.65 1.48l10.53 27.37L50.09 1.48h2.99L41.2 31h-4L26.84 4.34 16.51 31h-4L.63 1.48h2.99l10.91 27.37 10.5-27.37h3.62Z" />
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 324 32">
|
|
2
|
+
<path fill="#FFC474"
|
|
3
|
+
d="M321.58 29.54a41.7 41.7 0 0 1-7.26 1.72c-2.4.36-4.87.53-7.4.53-3.21 0-6.09-.34-8.6-1.03a18.5 18.5 0 0 1-6.34-3.03 13.07 13.07 0 0 1-3.94-4.83c-.9-1.9-1.35-4.06-1.35-6.47a14.32 14.32 0 0 1 5.22-11.19 18.14 18.14 0 0 1 6.06-3.3c2.36-.81 5-1.21 7.9-1.21 2.68 0 5.13.36 7.35 1.1 2.24.71 4.15 1.78 5.74 3.2a14.28 14.28 0 0 1 3.72 5.24 18.12 18.12 0 0 1 1.33 7.17v1.98h-29.1a7.5 7.5 0 0 0 1.28 2.56c.6.77 1.4 1.43 2.42 1.97 1.02.55 2.27.97 3.74 1.27 1.5.3 3.27.45 5.33.45a35.35 35.35 0 0 0 8.23-.96c1.22-.3 2.31-.64 3.29-1 .99-.35 1.78-.7 2.38-1.07v6.9Zm-5.5-15.96a6.73 6.73 0 0 0-.66-2.26 5.82 5.82 0 0 0-1.72-2.13 9.46 9.46 0 0 0-3.1-1.54 15.6 15.6 0 0 0-4.77-.63c-1.79 0-3.33.23-4.64.67-1.3.44-2.4 1-3.29 1.65a8.37 8.37 0 0 0-2.04 2.13c-.48.76-.8 1.46-.94 2.1h21.16ZM271.84 31h-9.28L247.63 1.48h8.9l10.74 22.22 10.72-22.22h8.9L271.83 31ZM234.8 31V1.48h7.97V31h-7.97ZM229.73 8.16l-.94-.28c-.4-.13-.88-.25-1.42-.36a17.88 17.88 0 0 0-3.8-.45c-1.44 0-2.78.18-4.02.53-1.23.35-2.39.81-3.46 1.4a19.48 19.48 0 0 0-3 1.98c-.92.73-1.77 1.48-2.54 2.25V31h-7.97V1.48h7.97v4.8c.96-.72 1.94-1.41 2.94-2.07a25.36 25.36 0 0 1 3.16-1.78 18.9 18.9 0 0 1 3.48-1.23 15.39 15.39 0 0 1 5.44-.39 25 25 0 0 1 4.16.67v6.68ZM197.05 16.22c0 1.89-.2 3.57-.62 5.05a12.7 12.7 0 0 1-1.76 3.82 11.07 11.07 0 0 1-2.7 2.77 13.77 13.77 0 0 1-3.51 1.83c-1.29.46-2.68.8-4.17 1-1.49.21-3.04.31-4.66.31H160.9V1.48h18.69c1.62 0 3.17.1 4.66.32 1.49.2 2.88.53 4.17 1 1.3.45 2.48 1.06 3.54 1.82 1.06.74 1.96 1.67 2.7 2.77a12.7 12.7 0 0 1 1.77 3.82c.42 1.46.62 3.13.62 5Zm-8.03 0c0-1.42-.19-2.65-.56-3.7a5.64 5.64 0 0 0-1.76-2.57 7.66 7.66 0 0 0-3.16-1.53c-1.3-.34-2.9-.52-4.77-.52h-9.9v16.68h9.9c1.88 0 3.47-.17 4.77-.5a7.86 7.86 0 0 0 3.16-1.54c.81-.7 1.4-1.58 1.76-2.63.37-1.04.56-2.27.56-3.7ZM153.98 10.55c0 1.47-.25 2.78-.73 3.9a6.82 6.82 0 0 1-2.26 2.86 10.95 10.95 0 0 1-4 1.77 25.6 25.6 0 0 1-5.86.58h-13.26V31h-2.68V1.48h15.94c2.3 0 4.25.2 5.87.6 1.63.39 2.96.96 4 1.72a6.67 6.67 0 0 1 2.25 2.84c.48 1.13.73 2.43.73 3.9Zm-2.77 0c0-1.4-.24-2.54-.71-3.4a4.53 4.53 0 0 0-2.15-1.97c-.96-.48-2.19-.8-3.68-.95a50.43 50.43 0 0 0-5.26-.24h-11.54v13.15h11.54l2.51.02c.9 0 1.8-.04 2.67-.12.87-.1 1.7-.27 2.5-.5.8-.24 1.5-.6 2.1-1.1a5.05 5.05 0 0 0 1.46-1.9 7 7 0 0 0 .56-3ZM119.76 3.76c-.41-.13-1-.27-1.74-.41-.73-.16-1.67-.24-2.83-.24-1.6 0-3.12.2-4.54.6a17.94 17.94 0 0 0-7.28 3.96 23.73 23.73 0 0 0-2.8 2.83V31H97.9V1.48h2.69V7.5c.96-1 2-1.9 3.11-2.73a21.54 21.54 0 0 1 7.48-3.53 17.47 17.47 0 0 1 5.6-.47c.4.02.77.04 1.1.09a16.6 16.6 0 0 1 1.9.26v2.64ZM85.52 31v-3.27c-1.03.56-2.2 1.08-3.53 1.55a40.4 40.4 0 0 1-13.13 2.3c-1.91 0-3.64-.17-5.17-.52a12.2 12.2 0 0 1-3.87-1.52A7.38 7.38 0 0 1 57.37 27a7.06 7.06 0 0 1-.86-3.52c0-1.32.33-2.48 1-3.48a8.81 8.81 0 0 1 2.85-2.64c1.23-.76 2.71-1.4 4.45-1.91 1.74-.53 3.7-.98 5.84-1.34 2.15-.37 4.47-.67 6.96-.9 2.5-.24 5.14-.44 7.9-.6v-2.26c0-.91-.16-1.72-.5-2.42a5.54 5.54 0 0 0-1.45-1.83 7.97 7.97 0 0 0-2.17-1.31c-.83-.36-1.73-.65-2.7-.86a33.97 33.97 0 0 0-13.54.21c-1.03.25-2.02.53-2.96.86-.95.33-1.9.68-2.86 1.06V2.92c1.99-.53 4.1-.99 6.36-1.38 2.26-.4 4.66-.6 7.2-.6 2.14 0 4.15.19 6.01.56 1.86.36 3.48.94 4.86 1.74A9.16 9.16 0 0 1 87 6.36a8.55 8.55 0 0 1 1.18 4.62V31h-2.66Zm0-16c-4.69.25-8.69.62-12.01 1.09-3.31.47-6.02 1.05-8.12 1.74-2.1.69-3.66 1.49-4.64 2.4a4.18 4.18 0 0 0-1.46 3.12c0 .95.23 1.78.7 2.52a5.86 5.86 0 0 0 2.09 1.84c.9.49 2 .86 3.29 1.12 1.28.24 2.73.37 4.34.37a29.36 29.36 0 0 0 5.95-.6 36.6 36.6 0 0 0 5.71-1.57c.86-.32 1.64-.66 2.34-1.01a11.3 11.3 0 0 0 1.8-1.1v-9.93ZM28.65 1.48l10.53 27.37L50.09 1.48h2.99L41.2 31h-4L26.84 4.34 16.51 31h-4L.63 1.48h2.99l10.91 27.37 10.5-27.37h3.62Z" />
|
|
4
|
+
</svg>
|
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.5.0-alpha.
|
|
4
|
+
"version": "5.5.0-alpha.20",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"homepage": "https://github.com/emberjs/data",
|
|
14
14
|
"bugs": "https://github.com/emberjs/data/issues",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": "
|
|
16
|
+
"node": ">= 18.20.8"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"ember-addon"
|
|
@@ -21,53 +21,70 @@
|
|
|
21
21
|
"volta": {
|
|
22
22
|
"extends": "../../package.json"
|
|
23
23
|
},
|
|
24
|
-
"dependenciesMeta": {
|
|
25
|
-
"@ember-data/private-build-infra": {
|
|
26
|
-
"injected": true
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
24
|
"dependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
|
|
25
|
+
"@embroider/macros": "^1.16.12",
|
|
26
|
+
"@warp-drive/build-config": "5.5.0-alpha.20"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"ember-source": "3.28.12 || ^4.0.4 || ^5.0.0 || ^6.0.0",
|
|
30
|
+
"@warp-drive/core-types": "5.5.0-alpha.20"
|
|
33
31
|
},
|
|
34
32
|
"files": [
|
|
35
|
-
"
|
|
36
|
-
"addon",
|
|
33
|
+
"unstable-preview-types",
|
|
34
|
+
"addon-main.cjs",
|
|
35
|
+
"dist",
|
|
37
36
|
"README.md",
|
|
38
37
|
"LICENSE.md",
|
|
39
|
-
"
|
|
40
|
-
"ember-data-logo-light.svg"
|
|
38
|
+
"logos"
|
|
41
39
|
],
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./*": {
|
|
45
|
+
"default": "./dist/*.js"
|
|
46
|
+
},
|
|
47
|
+
"./unstable-preview-types": {
|
|
48
|
+
"types": "./unstable-preview-types/index.d.ts"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
42
51
|
"ember-addon": {
|
|
43
|
-
"main": "addon-main.
|
|
52
|
+
"main": "addon-main.cjs",
|
|
44
53
|
"type": "addon",
|
|
45
|
-
"version":
|
|
54
|
+
"version": 2,
|
|
55
|
+
"externals": [
|
|
56
|
+
"@ember/-internals",
|
|
57
|
+
"@ember/-internals/metal",
|
|
58
|
+
"@glimmer/validator"
|
|
59
|
+
]
|
|
46
60
|
},
|
|
47
61
|
"devDependencies": {
|
|
48
|
-
"@babel/
|
|
49
|
-
"@babel/
|
|
50
|
-
"@babel/
|
|
51
|
-
"@babel/
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"@rollup/plugin-babel": "^6.0.3",
|
|
60
|
-
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
61
|
-
"rollup": "^3.29.2",
|
|
62
|
-
"tslib": "^2.6.2",
|
|
63
|
-
"typescript": "^5.2.2",
|
|
64
|
-
"walk-sync": "^3.0.0"
|
|
62
|
+
"@babel/core": "^7.26.10",
|
|
63
|
+
"@babel/plugin-transform-typescript": "^7.27.0",
|
|
64
|
+
"@babel/preset-env": "^7.26.9",
|
|
65
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
66
|
+
"@glimmer/component": "^2.0.0",
|
|
67
|
+
"@glimmer/validator": "^0.94.8",
|
|
68
|
+
"@warp-drive/core-types": "5.5.0-alpha.20",
|
|
69
|
+
"@warp-drive/internal-config": "5.5.0-alpha.20",
|
|
70
|
+
"ember-source": "~6.3.0",
|
|
71
|
+
"typescript": "^5.8.3",
|
|
72
|
+
"vite": "^5.4.15"
|
|
65
73
|
},
|
|
66
74
|
"ember": {
|
|
67
75
|
"edition": "octane"
|
|
68
76
|
},
|
|
77
|
+
"typesVersions": {
|
|
78
|
+
"*": {
|
|
79
|
+
"unstable-preview-types": [
|
|
80
|
+
"./unstable-preview-types"
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
},
|
|
69
84
|
"scripts": {
|
|
70
|
-
"
|
|
71
|
-
"
|
|
85
|
+
"lint": "eslint . --quiet --cache --cache-strategy=content",
|
|
86
|
+
"build:pkg": "vite build;",
|
|
87
|
+
"sync": "echo \"syncing\"",
|
|
88
|
+
"start": "vite"
|
|
72
89
|
}
|
|
73
90
|
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
declare module '@ember-data/tracking/-private' {
|
|
2
|
+
import { tagForProperty } from '@ember/-internals/metal';
|
|
3
|
+
import { dependentKeyCompat as compat } from '@ember/object/compat';
|
|
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 function subscribe(obj: Tag | Signal): void;
|
|
34
|
+
export function addToTransaction(obj: Tag | Signal): void;
|
|
35
|
+
export 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 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 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 function memoTransact<T extends OpaqueFn>(method: T): (...args: unknown[]) => ReturnType<T>;
|
|
83
|
+
export const Signals: "___(unique) Symbol(Signals)";
|
|
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 function defineSignal<T extends object>(obj: T, key: string, v?: unknown): void;
|
|
112
|
+
export function defineSubscription<T extends object>(obj: T, key: string, desc: PropertyDescriptor): void;
|
|
113
|
+
export interface Signal {
|
|
114
|
+
/**
|
|
115
|
+
* Key on the associated object
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
key: string;
|
|
119
|
+
_debug_base?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Whether this signal is part of an active transaction.
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
t: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Whether to "bust" the lastValue cache
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
shouldReset: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* The reason this signal is dirty
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
reason: string | null;
|
|
136
|
+
/**
|
|
137
|
+
* The framework specific "signal" e.g. glimmer "tracked"
|
|
138
|
+
* or starbeam "cell" to consume/invalidate when appropriate.
|
|
139
|
+
*
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
tag: ReturnType<typeof tagForProperty>;
|
|
143
|
+
/**
|
|
144
|
+
* In classic ember, arrays must entangle a `[]` symbol
|
|
145
|
+
* in addition to any other tag in order for array chains to work.
|
|
146
|
+
*
|
|
147
|
+
* Note, this symbol MUST be the one that ember itself generates
|
|
148
|
+
*
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
'[]': ReturnType<typeof tagForProperty> | null;
|
|
152
|
+
/**
|
|
153
|
+
* In classic ember, arrays must entangle a `@length` symbol
|
|
154
|
+
* in addition to any other tag in order for array chains to work.
|
|
155
|
+
*
|
|
156
|
+
* Note, this symbol MUST be the one that ember itself generates
|
|
157
|
+
*
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
'@length': ReturnType<typeof tagForProperty> | null;
|
|
161
|
+
/**
|
|
162
|
+
* The lastValue computed for this signal when
|
|
163
|
+
* a signal is also used for storage.
|
|
164
|
+
* @internal
|
|
165
|
+
*/
|
|
166
|
+
lastValue: unknown;
|
|
167
|
+
}
|
|
168
|
+
export function createArrayTags<T extends object>(obj: T, signal: Signal): void;
|
|
169
|
+
/**
|
|
170
|
+
* Create a signal for the key/object pairing.
|
|
171
|
+
*
|
|
172
|
+
* @internal
|
|
173
|
+
* @param obj Object we're creating the signal on
|
|
174
|
+
* @param key Key to create the signal for
|
|
175
|
+
* @return the signal
|
|
176
|
+
*/
|
|
177
|
+
export function createSignal<T extends object>(obj: T, key: string): Signal;
|
|
178
|
+
/**
|
|
179
|
+
* Create a signal for the key/object pairing and subscribes to the signal.
|
|
180
|
+
*
|
|
181
|
+
* Use when you need to ensure a signal exists and is subscribed to.
|
|
182
|
+
*
|
|
183
|
+
* @internal
|
|
184
|
+
* @param signals Map of signals
|
|
185
|
+
* @param obj Object we're creating the signal on
|
|
186
|
+
* @param key Key to create the signal for
|
|
187
|
+
* @return the signal
|
|
188
|
+
*/
|
|
189
|
+
export function entangleSignal<T extends object>(signals: Map<string, Signal>, obj: T, key: string): Signal;
|
|
190
|
+
export function getSignal<T extends object>(obj: T, key: string, initialState: boolean): Signal;
|
|
191
|
+
export function peekSignal<T extends object>(obj: T, key: string): Signal | undefined;
|
|
192
|
+
export function subscribed<T extends object, K extends keyof T & string>(_target: T, key: K, desc: PropertyDescriptor): PropertyDescriptor;
|
|
193
|
+
export { compat };
|
|
194
|
+
export function notifySignal<T extends object, K extends keyof T & string>(obj: T, key: K): void;
|
|
195
|
+
}
|
|
196
|
+
//# 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;AAGzD,OAAO,EAAE,kBAAkB,IAAI,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAOpE;;;;;;;;;;;;;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;AAoCrC;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAejD;AA8GD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAQxD;AACD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAQvD;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,C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,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CA6B1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ1G;AAMD,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,MAAM,CAe9F;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKpF;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,kBAAkB,sBAwBpH;AACD,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,QAMxF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference path="./-private.d.ts" />
|
|
2
|
+
declare module '@ember-data/tracking' {
|
|
3
|
+
import { createCache, getValue } from '@glimmer/tracking/primitives/cache';
|
|
4
|
+
export { transact, memoTransact, untracked, compat, notifySignal } from '@ember-data/tracking/-private';
|
|
5
|
+
export function cached<T extends object, K extends keyof T & string>(target: T, key: K, descriptor: PropertyDescriptor): void;
|
|
6
|
+
export { createCache, getValue };
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAI3E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAErF,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"}
|
package/addon/-private.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { macroCondition, getOwnConfig } from '@embroider/macros';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This package provides primitives that allow powerful low-level
|
|
5
|
-
* adjustments to change tracking notification behaviors.
|
|
6
|
-
*
|
|
7
|
-
* Typically you want to use these primitives when you want to divorce
|
|
8
|
-
* property accesses on EmberData provided objects from the current
|
|
9
|
-
* tracking context. Typically this sort of thing occurs when serializing
|
|
10
|
-
* tracked data to send in a request: the data itself is often ancillary
|
|
11
|
-
* to the thing which triggered the request in the first place and you
|
|
12
|
-
* would not want to re-trigger the request for any update to the data.
|
|
13
|
-
*
|
|
14
|
-
* @module @ember-data/tracking
|
|
15
|
-
* @main @ember-data/tracking
|
|
16
|
-
*/
|
|
17
|
-
let TRANSACTION = null;
|
|
18
|
-
function createTransaction() {
|
|
19
|
-
let transaction = {
|
|
20
|
-
cbs: new Set(),
|
|
21
|
-
props: new Set(),
|
|
22
|
-
sub: new Set(),
|
|
23
|
-
parent: null
|
|
24
|
-
};
|
|
25
|
-
if (TRANSACTION) {
|
|
26
|
-
transaction.parent = TRANSACTION;
|
|
27
|
-
}
|
|
28
|
-
TRANSACTION = transaction;
|
|
29
|
-
}
|
|
30
|
-
function subscribe(obj) {
|
|
31
|
-
if (TRANSACTION) {
|
|
32
|
-
TRANSACTION.sub.add(obj);
|
|
33
|
-
} else {
|
|
34
|
-
obj.ref;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function updateRef(obj) {
|
|
38
|
-
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
39
|
-
try {
|
|
40
|
-
obj.ref = null;
|
|
41
|
-
} catch (e) {
|
|
42
|
-
if (e instanceof Error) {
|
|
43
|
-
if (e.message.includes('You attempted to update `ref` on `Tag`')) {
|
|
44
|
-
e.message = e.message.replace('You attempted to update `ref` on `Tag`',
|
|
45
|
-
// @ts-expect-error
|
|
46
|
-
`You attempted to update <${obj._debug_base}>.${obj._debug_prop}` // eslint-disable-line
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
e.stack = e.stack?.replace('You attempted to update `ref` on `Tag`',
|
|
50
|
-
// @ts-expect-error
|
|
51
|
-
`You attempted to update <${obj._debug_base}>.${obj._debug_prop}` // eslint-disable-line
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const lines = e.stack?.split(`\n`);
|
|
55
|
-
const finalLines = [];
|
|
56
|
-
let lastFile = null;
|
|
57
|
-
lines?.forEach(line => {
|
|
58
|
-
if (line.trim().startsWith('at ')) {
|
|
59
|
-
// get the last string in the line which contains the code source location
|
|
60
|
-
const location = line.split(' ').at(-1);
|
|
61
|
-
// remove the line and char offset info
|
|
62
|
-
|
|
63
|
-
if (location.includes(':')) {
|
|
64
|
-
const parts = location.split(':');
|
|
65
|
-
parts.pop();
|
|
66
|
-
parts.pop();
|
|
67
|
-
const file = parts.join(':');
|
|
68
|
-
if (file !== lastFile) {
|
|
69
|
-
lastFile = file;
|
|
70
|
-
finalLines.push('');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
finalLines.push(line);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
const splitstr = '`ref` was first used:';
|
|
77
|
-
const parts = e.message.split(splitstr);
|
|
78
|
-
parts.splice(1, 0, `Original Stack\n=============\n${finalLines.join(`\n`)}\n\n${splitstr}`);
|
|
79
|
-
e.message = parts.join('');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
throw e;
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
obj.ref = null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function flushTransaction() {
|
|
89
|
-
let transaction = TRANSACTION;
|
|
90
|
-
TRANSACTION = transaction.parent;
|
|
91
|
-
transaction.cbs.forEach(cb => {
|
|
92
|
-
cb();
|
|
93
|
-
});
|
|
94
|
-
transaction.props.forEach(obj => {
|
|
95
|
-
// mark this mutation as part of a transaction
|
|
96
|
-
obj.t = true;
|
|
97
|
-
updateRef(obj);
|
|
98
|
-
});
|
|
99
|
-
transaction.sub.forEach(obj => {
|
|
100
|
-
obj.ref;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
async function untrack() {
|
|
104
|
-
let transaction = TRANSACTION;
|
|
105
|
-
TRANSACTION = transaction.parent;
|
|
106
|
-
|
|
107
|
-
// defer writes
|
|
108
|
-
await Promise.resolve();
|
|
109
|
-
transaction.cbs.forEach(cb => {
|
|
110
|
-
cb();
|
|
111
|
-
});
|
|
112
|
-
transaction.props.forEach(obj => {
|
|
113
|
-
// mark this mutation as part of a transaction
|
|
114
|
-
obj.t = true;
|
|
115
|
-
updateRef(obj);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function addToTransaction(obj) {
|
|
119
|
-
if (TRANSACTION) {
|
|
120
|
-
TRANSACTION.props.add(obj);
|
|
121
|
-
} else {
|
|
122
|
-
updateRef(obj);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function addTransactionCB(method) {
|
|
126
|
-
if (TRANSACTION) {
|
|
127
|
-
TRANSACTION.cbs.add(method);
|
|
128
|
-
} else {
|
|
129
|
-
method();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Run `method` without subscribing to any tracked properties
|
|
135
|
-
* controlled by EmberData.
|
|
136
|
-
*
|
|
137
|
-
* This should rarely be used except by libraries that really
|
|
138
|
-
* know what they are doing. It is most useful for wrapping
|
|
139
|
-
* certain kinds of fetch/query logic from within a `Resource`
|
|
140
|
-
* `hook` or other similar pattern.
|
|
141
|
-
*
|
|
142
|
-
* @function untracked
|
|
143
|
-
* @public
|
|
144
|
-
* @static
|
|
145
|
-
* @for @ember-data/tracking
|
|
146
|
-
* @param method
|
|
147
|
-
* @returns result of invoking method
|
|
148
|
-
*/
|
|
149
|
-
function untracked(method) {
|
|
150
|
-
createTransaction();
|
|
151
|
-
const ret = method();
|
|
152
|
-
void untrack();
|
|
153
|
-
return ret;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Run the method, subscribing to any tracked properties
|
|
158
|
-
* managed by EmberData that were accessed or written during
|
|
159
|
-
* the method's execution as per-normal but while allowing
|
|
160
|
-
* interleaving of reads and writes.
|
|
161
|
-
*
|
|
162
|
-
* This is useful when for instance you want to perform
|
|
163
|
-
* a mutation based on existing state that must be read first.
|
|
164
|
-
*
|
|
165
|
-
* @function transact
|
|
166
|
-
* @public
|
|
167
|
-
* @static
|
|
168
|
-
* @for @ember-data/tracking
|
|
169
|
-
* @param method
|
|
170
|
-
* @returns result of invoking method
|
|
171
|
-
*/
|
|
172
|
-
function transact(method) {
|
|
173
|
-
createTransaction();
|
|
174
|
-
const ret = method();
|
|
175
|
-
flushTransaction();
|
|
176
|
-
return ret;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* A helpful utility for creating a new function that
|
|
181
|
-
* always runs in a transaction. E.G. this "memoizes"
|
|
182
|
-
* calling `transact(fn)`, currying args as necessary.
|
|
183
|
-
*
|
|
184
|
-
* @method memoTransact
|
|
185
|
-
* @public
|
|
186
|
-
* @static
|
|
187
|
-
* @for @ember-data/tracking
|
|
188
|
-
* @param method
|
|
189
|
-
* @returns a function that will invoke method in a transaction with any provided args and return its result
|
|
190
|
-
*/
|
|
191
|
-
function memoTransact(method) {
|
|
192
|
-
return function (...args) {
|
|
193
|
-
createTransaction();
|
|
194
|
-
const ret = method(...args);
|
|
195
|
-
flushTransaction();
|
|
196
|
-
return ret;
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
export { addToTransaction, addTransactionCB, memoTransact, subscribe, transact, untracked };
|
package/addon/-private.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"-private.js","sources":["../src/-private.ts"],"sourcesContent":["import { DEBUG } from '@ember-data/env';\n\n/**\n * This package provides primitives that allow powerful low-level\n * adjustments to change tracking notification behaviors.\n *\n * Typically you want to use these primitives when you want to divorce\n * property accesses on EmberData provided objects from the current\n * tracking context. Typically this sort of thing occurs when serializing\n * tracked data to send in a request: the data itself is often ancillary\n * to the thing which triggered the request in the first place and you\n * would not want to re-trigger the request for any update to the data.\n *\n * @module @ember-data/tracking\n * @main @ember-data/tracking\n */\ntype OpaqueFn = (...args: unknown[]) => unknown;\ntype Tag = { ref: null; t: boolean };\ntype Transaction = {\n cbs: Set<OpaqueFn>;\n props: Set<Tag>;\n sub: Set<Tag>;\n parent: Transaction | null;\n};\nlet TRANSACTION: Transaction | null = null;\n\nfunction createTransaction() {\n let transaction: Transaction = {\n cbs: new Set(),\n props: new Set(),\n sub: new Set(),\n parent: null,\n };\n if (TRANSACTION) {\n transaction.parent = TRANSACTION;\n }\n TRANSACTION = transaction;\n}\n\nexport function subscribe(obj: Tag): void {\n if (TRANSACTION) {\n TRANSACTION.sub.add(obj);\n } else {\n obj.ref;\n }\n}\n\nfunction updateRef(obj: Tag): void {\n if (DEBUG) {\n try {\n obj.ref = null;\n } catch (e: unknown) {\n if (e instanceof Error) {\n if (e.message.includes('You attempted to update `ref` on `Tag`')) {\n e.message = e.message.replace(\n 'You attempted to update `ref` on `Tag`',\n // @ts-expect-error\n `You attempted to update <${obj._debug_base}>.${obj._debug_prop}` // eslint-disable-line\n );\n e.stack = e.stack?.replace(\n 'You attempted to update `ref` on `Tag`',\n // @ts-expect-error\n `You attempted to update <${obj._debug_base}>.${obj._debug_prop}` // eslint-disable-line\n );\n\n const lines = e.stack?.split(`\\n`);\n const finalLines: string[] = [];\n let lastFile: string | null = null;\n\n lines?.forEach((line) => {\n if (line.trim().startsWith('at ')) {\n // get the last string in the line which contains the code source location\n const location = line.split(' ').at(-1)!;\n // remove the line and char offset info\n\n if (location.includes(':')) {\n const parts = location.split(':');\n parts.pop();\n parts.pop();\n const file = parts.join(':');\n if (file !== lastFile) {\n lastFile = file;\n finalLines.push('');\n }\n }\n finalLines.push(line);\n }\n });\n\n const splitstr = '`ref` was first used:';\n const parts = e.message.split(splitstr);\n parts.splice(1, 0, `Original Stack\\n=============\\n${finalLines.join(`\\n`)}\\n\\n${splitstr}`);\n\n e.message = parts.join('');\n }\n }\n throw e;\n }\n } else {\n obj.ref = null;\n }\n}\n\nfunction flushTransaction() {\n let transaction = TRANSACTION!;\n TRANSACTION = transaction.parent;\n transaction.cbs.forEach((cb) => {\n cb();\n });\n transaction.props.forEach((obj: Tag) => {\n // mark this mutation as part of a transaction\n obj.t = true;\n updateRef(obj);\n });\n transaction.sub.forEach((obj: Tag) => {\n obj.ref;\n });\n}\nasync function untrack() {\n let transaction = TRANSACTION!;\n TRANSACTION = transaction.parent;\n\n // defer writes\n await Promise.resolve();\n transaction.cbs.forEach((cb) => {\n cb();\n });\n transaction.props.forEach((obj: Tag) => {\n // mark this mutation as part of a transaction\n obj.t = true;\n updateRef(obj);\n });\n}\n\nexport function addToTransaction(obj: Tag): void {\n if (TRANSACTION) {\n TRANSACTION.props.add(obj);\n } else {\n updateRef(obj);\n }\n}\nexport function addTransactionCB(method: OpaqueFn): void {\n if (TRANSACTION) {\n TRANSACTION.cbs.add(method);\n } else {\n method();\n }\n}\n\n/**\n * Run `method` without subscribing to any tracked properties\n * controlled by EmberData.\n *\n * This should rarely be used except by libraries that really\n * know what they are doing. It is most useful for wrapping\n * certain kinds of fetch/query logic from within a `Resource`\n * `hook` or other similar pattern.\n *\n * @function untracked\n * @public\n * @static\n * @for @ember-data/tracking\n * @param method\n * @returns result of invoking method\n */\nexport function untracked<T extends OpaqueFn>(method: T): ReturnType<T> {\n createTransaction();\n const ret = method();\n void untrack();\n return ret as ReturnType<T>;\n}\n\n/**\n * Run the method, subscribing to any tracked properties\n * managed by EmberData that were accessed or written during\n * the method's execution as per-normal but while allowing\n * interleaving of reads and writes.\n *\n * This is useful when for instance you want to perform\n * a mutation based on existing state that must be read first.\n *\n * @function transact\n * @public\n * @static\n * @for @ember-data/tracking\n * @param method\n * @returns result of invoking method\n */\nexport function transact<T extends OpaqueFn>(method: T): ReturnType<T> {\n createTransaction();\n const ret = method();\n flushTransaction();\n return ret as ReturnType<T>;\n}\n\n/**\n * A helpful utility for creating a new function that\n * always runs in a transaction. E.G. this \"memoizes\"\n * calling `transact(fn)`, currying args as necessary.\n *\n * @method memoTransact\n * @public\n * @static\n * @for @ember-data/tracking\n * @param method\n * @returns a function that will invoke method in a transaction with any provided args and return its result\n */\nexport function memoTransact<T extends OpaqueFn>(method: T): (...args: unknown[]) => ReturnType<T> {\n return function (...args: unknown[]) {\n createTransaction();\n const ret = method(...args);\n flushTransaction();\n return ret as ReturnType<T>;\n };\n}\n"],"names":["TRANSACTION","createTransaction","transaction","cbs","Set","props","sub","parent","subscribe","obj","add","ref","updateRef","macroCondition","getOwnConfig","env","DEBUG","e","Error","message","includes","replace","_debug_base","_debug_prop","stack","lines","split","finalLines","lastFile","forEach","line","trim","startsWith","location","at","parts","pop","file","join","push","splitstr","splice","flushTransaction","cb","t","untrack","Promise","resolve","addToTransaction","addTransactionCB","method","untracked","ret","transact","memoTransact","args"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AASA,IAAIA,WAA+B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AyC;EACjG,OAAO,UAAU,GAAGK,IAAe,EAAE;AACnCtD,IAAAA,iBAAiB,EAAE,CAAA;AACnB,IAAA,MAAMmD,GAAG,GAAGF,MAAM,CAAC,GAAGK,IAAI,CAAC,CAAA;AAC3Bb,IAAAA,gBAAgB,EAAE,CAAA;AAClB,IAAA,OAAOU,GAAG,CAAA;GACX,CAAA;AACH;;;;"}
|
package/addon/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { memoTransact, transact, untracked } from "./-private";
|
package/addon/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|