@ember-data/tracking 5.3.0-alpha.1 → 5.3.0-alpha.11

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/addon/-private.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { macroCondition, getOwnConfig } from '@embroider/macros';
2
+
1
3
  /**
2
4
  * This package provides primitives that allow powerful low-level
3
5
  * adjustments to change tracking notification behaviors.
@@ -12,7 +14,6 @@
12
14
  * @module @ember-data/tracking
13
15
  * @main @ember-data/tracking
14
16
  */
15
-
16
17
  let TRANSACTION = null;
17
18
  function createTransaction() {
18
19
  let transaction = {
@@ -33,6 +34,57 @@ function subscribe(obj) {
33
34
  obj.ref;
34
35
  }
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
+ }
36
88
  function flushTransaction() {
37
89
  let transaction = TRANSACTION;
38
90
  TRANSACTION = transaction.parent;
@@ -42,7 +94,7 @@ function flushTransaction() {
42
94
  transaction.props.forEach(obj => {
43
95
  // mark this mutation as part of a transaction
44
96
  obj.t = true;
45
- obj.ref = null;
97
+ updateRef(obj);
46
98
  });
47
99
  transaction.sub.forEach(obj => {
48
100
  obj.ref;
@@ -60,14 +112,14 @@ async function untrack() {
60
112
  transaction.props.forEach(obj => {
61
113
  // mark this mutation as part of a transaction
62
114
  obj.t = true;
63
- obj.ref = null;
115
+ updateRef(obj);
64
116
  });
65
117
  }
66
118
  function addToTransaction(obj) {
67
119
  if (TRANSACTION) {
68
120
  TRANSACTION.props.add(obj);
69
121
  } else {
70
- obj.ref = null;
122
+ updateRef(obj);
71
123
  }
72
124
  }
73
125
  function addTransactionCB(method) {
@@ -1 +1 @@
1
- {"version":3,"file":"-private.js","sources":["../src/-private.ts"],"sourcesContent":["/**\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 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 obj.ref = null;\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 obj.ref = null;\n });\n}\n\nexport function addToTransaction(obj: Tag): void {\n if (TRANSACTION) {\n TRANSACTION.props.add(obj);\n } else {\n obj.ref = null;\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","flushTransaction","forEach","cb","t","untrack","Promise","resolve","addToTransaction","addTransactionCB","method","untracked","ret","transact","memoTransact","args"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,IAAIA,WAA+B,GAAG,IAAI,CAAA;AAE1C,SAASC,iBAAiBA,GAAG;AAC3B,EAAA,IAAIC,WAAwB,GAAG;AAC7BC,IAAAA,GAAG,EAAE,IAAIC,GAAG,EAAE;AACdC,IAAAA,KAAK,EAAE,IAAID,GAAG,EAAE;AAChBE,IAAAA,GAAG,EAAE,IAAIF,GAAG,EAAE;AACdG,IAAAA,MAAM,EAAE,IAAA;GACT,CAAA;AACD,EAAA,IAAIP,WAAW,EAAE;IACfE,WAAW,CAACK,MAAM,GAAGP,WAAW,CAAA;AAClC,GAAA;AACAA,EAAAA,WAAW,GAAGE,WAAW,CAAA;AAC3B,CAAA;AAEO,SAASM,SAASA,CAACC,GAAQ,EAAQ;AACxC,EAAA,IAAIT,WAAW,EAAE;AACfA,IAAAA,WAAW,CAACM,GAAG,CAACI,GAAG,CAACD,GAAG,CAAC,CAAA;AAC1B,GAAC,MAAM;AACLA,IAAAA,GAAG,CAACE,GAAG,CAAA;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ACE,GAAG,GAAG,IAAI,CAAA;AAChB,GAAA;AACF,CAAA;AACO,SAASS,gBAAgBA,CAACC,MAAgB,EAAQ;AACvD,EAAA,IAAIrB,WAAW,EAAE;AACfA,IAAAA,WAAW,CAACG,GAAG,CAACO,GAAG,CAACW,MAAM,CAAC,CAAA;AAC7B,GAAC,MAAM;AACLA,IAAAA,MAAM,EAAE,CAAA;AACV,GAAA;AACF,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAAqBD,MAAS,EAAiB;AACtEpB,EAAAA,iBAAiB,EAAE,CAAA;AACnB,EAAA,MAAMsB,GAAG,GAAGF,MAAM,EAAE,CAAA;EACpB,KAAKL,OAAO,EAAE,CAAA;AACd,EAAA,OAAOO,GAAG,CAAA;AACZ,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAAqBH,MAAS,EAAiB;AACrEpB,EAAAA,iBAAiB,EAAE,CAAA;AACnB,EAAA,MAAMsB,GAAG,GAAGF,MAAM,EAAE,CAAA;AACpBT,EAAAA,gBAAgB,EAAE,CAAA;AAClB,EAAA,OAAOW,GAAG,CAAA;AACZ,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAAqBJ,MAAS,EAAyC;EACjG,OAAO,UAAU,GAAGK,IAAe,EAAE;AACnCzB,IAAAA,iBAAiB,EAAE,CAAA;AACnB,IAAA,MAAMsB,GAAG,GAAGF,MAAM,CAAC,GAAGK,IAAI,CAAC,CAAA;AAC3Bd,IAAAA,gBAAgB,EAAE,CAAA;AAClB,IAAA,OAAOW,GAAG,CAAA;GACX,CAAA;AACH;;;;"}
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,GAAG,IAAI,CAAA;AAE1C,SAASC,iBAAiBA,GAAG;AAC3B,EAAA,IAAIC,WAAwB,GAAG;AAC7BC,IAAAA,GAAG,EAAE,IAAIC,GAAG,EAAE;AACdC,IAAAA,KAAK,EAAE,IAAID,GAAG,EAAE;AAChBE,IAAAA,GAAG,EAAE,IAAIF,GAAG,EAAE;AACdG,IAAAA,MAAM,EAAE,IAAA;GACT,CAAA;AACD,EAAA,IAAIP,WAAW,EAAE;IACfE,WAAW,CAACK,MAAM,GAAGP,WAAW,CAAA;AAClC,GAAA;AACAA,EAAAA,WAAW,GAAGE,WAAW,CAAA;AAC3B,CAAA;AAEO,SAASM,SAASA,CAACC,GAA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EAAE;AACfA,IAAAA,WAAW,CAACG,GAAG,CAACO,GAAG,CAACwC,MAAM,CAAC,CAAA;AAC7B,GAAC,MAAM;AACLA,IAAAA,MAAM,EAAE,CAAA;AACV,GAAA;AACF,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAAqBD,MAAS,EAAiB;AACtEjD,EAAAA,iBAAiB,EAAE,CAAA;AACnB,EAAA,MAAMmD,GAAG,GAAGF,MAAM,EAAE,CAAA;EACpB,KAAKL,OAAO,EAAE,CAAA;AACd,EAAA,OAAOO,GAAG,CAAA;AACZ,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAAqBH,MAAS,EAAiB;AACrEjD,EAAAA,iBAAiB,EAAE,CAAA;AACnB,EAAA,MAAMmD,GAAG,GAAGF,MAAM,EAAE,CAAA;AACpBR,EAAAA,gBAAgB,EAAE,CAAA;AAClB,EAAA,OAAOU,GAAG,CAAA;AACZ,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAAqBJ,MAAS,EAAyC;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-main.js CHANGED
@@ -1,5 +1,79 @@
1
+ const requireModule = require('@ember-data/private-build-infra/src/utilities/require-module');
2
+ const getEnv = require('@ember-data/private-build-infra/src/utilities/get-env');
3
+ const detectModule = require('@ember-data/private-build-infra/src/utilities/detect-module');
4
+
5
+ const pkg = require('./package.json');
6
+
1
7
  module.exports = {
2
- name: require('./package.json').name,
8
+ name: pkg.name,
9
+
10
+ options: {
11
+ '@embroider/macros': {
12
+ setOwnConfig: {},
13
+ },
14
+ },
15
+
16
+ _emberDataConfig: null,
17
+ configureEmberData() {
18
+ if (this._emberDataConfig) {
19
+ return this._emberDataConfig;
20
+ }
21
+ const app = this._findHost();
22
+ const isProd = /production/.test(process.env.EMBER_ENV);
23
+ const hostOptions = app.options?.emberData || {};
24
+ const debugOptions = Object.assign(
25
+ {
26
+ LOG_PAYLOADS: false,
27
+ LOG_OPERATIONS: false,
28
+ LOG_MUTATIONS: false,
29
+ LOG_NOTIFICATIONS: false,
30
+ LOG_REQUESTS: false,
31
+ LOG_REQUEST_STATUS: false,
32
+ LOG_IDENTIFIERS: false,
33
+ LOG_GRAPH: false,
34
+ LOG_INSTANCE_CACHE: false,
35
+ },
36
+ hostOptions.debug || {}
37
+ );
38
+
39
+ const HAS_DEBUG_PACKAGE = detectModule(require, '@ember-data/debug', __dirname, pkg);
40
+ const HAS_META_PACKAGE = detectModule(require, 'ember-data', __dirname, pkg);
41
+
42
+ const includeDataAdapterInProduction =
43
+ typeof hostOptions.includeDataAdapterInProduction === 'boolean'
44
+ ? hostOptions.includeDataAdapterInProduction
45
+ : HAS_META_PACKAGE;
46
+
47
+ const includeDataAdapter = HAS_DEBUG_PACKAGE ? (isProd ? includeDataAdapterInProduction : true) : false;
48
+ const DEPRECATIONS = require('@ember-data/private-build-infra/src/deprecations')(hostOptions.compatWith || null);
49
+ const FEATURES = require('@ember-data/private-build-infra/src/features')(isProd);
50
+
51
+ const ALL_PACKAGES = requireModule('@ember-data/private-build-infra/virtual-packages/packages.js');
52
+ const MACRO_PACKAGE_FLAGS = Object.assign({}, ALL_PACKAGES.default);
53
+ delete MACRO_PACKAGE_FLAGS['HAS_DEBUG_PACKAGE'];
54
+
55
+ Object.keys(MACRO_PACKAGE_FLAGS).forEach((key) => {
56
+ MACRO_PACKAGE_FLAGS[key] = detectModule(require, MACRO_PACKAGE_FLAGS[key], __dirname, pkg);
57
+ });
58
+
59
+ // copy configs forward
60
+ const ownConfig = this.options['@embroider/macros'].setOwnConfig;
61
+ ownConfig.compatWith = hostOptions.compatWith || null;
62
+ ownConfig.debug = debugOptions;
63
+ ownConfig.deprecations = Object.assign(DEPRECATIONS, ownConfig.deprecations || {}, hostOptions.deprecations || {});
64
+ ownConfig.features = Object.assign({}, FEATURES, ownConfig.features || {}, hostOptions.features || {});
65
+ ownConfig.includeDataAdapter = includeDataAdapter;
66
+ ownConfig.packages = MACRO_PACKAGE_FLAGS;
67
+ ownConfig.env = getEnv(ownConfig);
68
+
69
+ this._emberDataConfig = ownConfig;
70
+ return ownConfig;
71
+ },
72
+
73
+ included() {
74
+ this.configureEmberData();
75
+ return this._super.included.call(this, ...arguments);
76
+ },
3
77
 
4
78
  treeForVendor() {
5
79
  return;
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.3.0-alpha.1",
4
+ "version": "5.3.0-alpha.11",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
@@ -21,7 +21,14 @@
21
21
  "volta": {
22
22
  "extends": "../../package.json"
23
23
  },
24
+ "dependenciesMeta": {
25
+ "@ember-data/private-build-infra": {
26
+ "injected": true
27
+ }
28
+ },
24
29
  "dependencies": {
30
+ "@ember-data/private-build-infra": "5.3.0-alpha.11",
31
+ "@embroider/macros": "^1.13.0",
25
32
  "ember-cli-babel": "^7.26.11"
26
33
  },
27
34
  "files": [
@@ -38,21 +45,22 @@
38
45
  "version": 1
39
46
  },
40
47
  "devDependencies": {
41
- "@babel/core": "^7.22.5",
42
- "@babel/cli": "^7.22.5",
43
- "@babel/plugin-proposal-class-properties": "^7.18.6",
44
- "@babel/plugin-proposal-decorators": "^7.22.5",
45
- "@babel/plugin-transform-runtime": "^7.22.5",
46
- "@babel/plugin-transform-typescript": "^7.22.5",
47
- "@babel/preset-env": "^7.22.5",
48
+ "@babel/cli": "^7.22.9",
49
+ "@babel/core": "^7.22.9",
50
+ "@babel/plugin-proposal-decorators": "^7.22.7",
51
+ "@babel/plugin-transform-class-properties": "^7.22.5",
52
+ "@babel/plugin-transform-private-methods": "^7.22.5",
53
+ "@babel/plugin-transform-runtime": "^7.22.9",
54
+ "@babel/plugin-transform-typescript": "^7.22.9",
55
+ "@babel/preset-env": "^7.22.9",
48
56
  "@babel/preset-typescript": "^7.22.5",
49
- "@babel/runtime": "^7.22.5",
50
- "@embroider/addon-dev": "^3.0.0",
57
+ "@babel/runtime": "^7.22.6",
58
+ "@embroider/addon-dev": "^3.2.0",
51
59
  "@rollup/plugin-babel": "^6.0.3",
52
60
  "@rollup/plugin-node-resolve": "^15.1.0",
53
- "rollup": "^3.25.3",
54
- "tslib": "^2.5.3",
55
- "typescript": "^5.1.3",
61
+ "rollup": "^3.27.0",
62
+ "tslib": "^2.6.1",
63
+ "typescript": "^5.1.6",
56
64
  "walk-sync": "^3.0.0"
57
65
  },
58
66
  "ember": {