@warp-drive-mirror/build-config 4.13.0-alpha.3 → 4.13.0-alpha.5
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 -5
- package/README.md +2 -2
- package/dist/babel-macros.js +2 -1
- package/dist/babel-macros.js.map +1 -1
- package/dist/babel-plugin-transform-asserts.cjs +3 -3
- package/dist/babel-plugin-transform-asserts.cjs.map +1 -1
- package/dist/babel-plugin-transform-deprecations.cjs +3 -3
- package/dist/babel-plugin-transform-deprecations.cjs.map +1 -1
- package/dist/babel-plugin-transform-features.cjs +2 -2
- package/dist/babel-plugin-transform-features.cjs.map +1 -1
- package/dist/babel-plugin-transform-logging.cjs +46 -3
- package/dist/babel-plugin-transform-logging.cjs.map +1 -1
- package/dist/cjs-set-config.cjs +35 -3
- package/dist/cjs-set-config.cjs.map +1 -1
- package/dist/{debugging-BzogyWJo.js → debugging-Bvt2walA.js} +20 -2
- package/dist/{debugging-BzogyWJo.js.map → debugging-Bvt2walA.js.map} +1 -1
- package/dist/debugging.js +1 -1
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime.js +21 -0
- package/dist/runtime.js.map +1 -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/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 +26 -18
- package/unstable-preview-types/-private/utils/get-env.d.ts.map +1 -1
- package/unstable-preview-types/-private/utils/logging.d.ts +14 -0
- package/unstable-preview-types/-private/utils/logging.d.ts.map +1 -0
- package/unstable-preview-types/babel-macros.d.ts +3 -24
- package/unstable-preview-types/babel-macros.d.ts.map +1 -1
- package/unstable-preview-types/debugging.d.ts +16 -0
- package/unstable-preview-types/debugging.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +10 -5
- package/unstable-preview-types/index.d.ts.map +1 -1
- package/unstable-preview-types/runtime.d.ts +18 -0
- package/unstable-preview-types/runtime.d.ts.map +1 -0
- /package/{NCC-1701-a-blue.svg → logos/NCC-1701-a-blue.svg} +0 -0
- /package/{NCC-1701-a.svg → logos/NCC-1701-a.svg} +0 -0
package/LICENSE.md
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (
|
|
3
|
+
Copyright (c) 2017-2025 Ember.js and contributors
|
|
4
|
+
Copyright (c) 2011-2017 Tilde, Inc. and contributors
|
|
5
|
+
Copyright (c) 2011 LivingSocial Inc.
|
|
4
6
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
6
13
|
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
8
16
|
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<img
|
|
3
3
|
class="project-logo"
|
|
4
|
-
src="./NCC-1701-a-blue.svg#gh-light-mode-only"
|
|
4
|
+
src="./logos/NCC-1701-a-blue.svg#gh-light-mode-only"
|
|
5
5
|
alt="WarpDrive"
|
|
6
6
|
width="120px"
|
|
7
7
|
title="WarpDrive" />
|
|
8
8
|
<img
|
|
9
9
|
class="project-logo"
|
|
10
|
-
src="./NCC-1701-a.svg#gh-dark-mode-only"
|
|
10
|
+
src="./logos/NCC-1701-a.svg#gh-dark-mode-only"
|
|
11
11
|
alt="WarpDrive"
|
|
12
12
|
width="120px"
|
|
13
13
|
title="WarpDrive" />
|
package/dist/babel-macros.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as LOGGING } from './debugging-
|
|
1
|
+
import { L as LOGGING } from './debugging-Bvt2walA.js';
|
|
2
2
|
import { C as CURRENT_FEATURES } from './canary-features-BzGSGY5j.js';
|
|
3
3
|
import { C as CURRENT_DEPRECATIONS } from './deprecations-BjnhZL6k.js';
|
|
4
4
|
|
|
@@ -29,6 +29,7 @@ function macros() {
|
|
|
29
29
|
}, '@warp-drive-mirror/build-config/deprecation-stripping'], [TransformDebugLogging, {
|
|
30
30
|
source: '@warp-drive-mirror/build-config/debugging',
|
|
31
31
|
configKey: 'debug',
|
|
32
|
+
runtimeKey: 'activeLogging',
|
|
32
33
|
flags: config.debug
|
|
33
34
|
}, '@warp-drive-mirror/build-config/debugging-stripping'], [TransformDebugLogging, {
|
|
34
35
|
source: '@warp-drive-mirror/build-config/env',
|
package/dist/babel-macros.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-macros.js","sources":["../src/babel-macros.ts"],"sourcesContent":["import * as LOGGING from './debugging.ts';\nimport * as CURRENT_FEATURES from './canary-features.ts';\nimport * as CURRENT_DEPRECATIONS from './deprecations.ts';\n\ntype FEATURE = keyof typeof CURRENT_FEATURES;\nconst features = Object.keys(CURRENT_FEATURES) as FEATURE[];\nconst FEATURES = Object.assign({}, CURRENT_FEATURES) as Record<FEATURE, boolean>;\nfeatures.forEach((feature) => {\n let featureValue = FEATURES[feature];\n if (featureValue === null) {\n FEATURES[feature] = false;\n }\n});\n\nconst config = {\n features: FEATURES,\n deprecations: Object.assign({}, CURRENT_DEPRECATIONS),\n debug: Object.assign({}, LOGGING),\n};\n\nexport function macros() {\n const TransformAsserts = import.meta.resolve('./babel-plugin-transform-asserts.cjs').slice(7);\n const TransformDeprecations = import.meta.resolve('./babel-plugin-transform-deprecations.cjs').slice(7);\n const TransformDebugLogging = import.meta.resolve('./babel-plugin-transform-logging.cjs').slice(7);\n const TransformFeatures = import.meta.resolve('./babel-plugin-transform-features.cjs').slice(7);\n\n let plugins = [\n [TransformAsserts, {}, '@warp-drive-mirror/build-config/asserts-stripping'],\n [\n TransformFeatures,\n {\n source: '@warp-drive-mirror/build-config/canary-features',\n flags: config.features,\n },\n '@warp-drive-mirror/build-config/canary-features-stripping',\n ],\n [\n TransformDeprecations,\n {\n source: '@warp-drive-mirror/build-config/deprecations',\n flags: config.deprecations,\n },\n '@warp-drive-mirror/build-config/deprecation-stripping',\n ],\n [\n TransformDebugLogging,\n {\n source: '@warp-drive-mirror/build-config/debugging',\n configKey: 'debug',\n flags: config.debug,\n },\n '@warp-drive-mirror/build-config/debugging-stripping',\n ],\n [\n TransformDebugLogging,\n {\n source: '@warp-drive-mirror/build-config/env',\n configKey: 'env',\n flags: {\n TESTING: true,\n PRODUCTION: true,\n DEBUG: true,\n IS_RECORDING: true,\n IS_CI: true,\n SHOULD_RECORD: true,\n },\n },\n '@warp-drive-mirror/build-config/env',\n ],\n ];\n\n return plugins;\n}\n"],"names":["features","Object","keys","CURRENT_FEATURES","FEATURES","assign","forEach","feature","featureValue","config","deprecations","CURRENT_DEPRECATIONS","debug","LOGGING","macros","TransformAsserts","import","meta","resolve","slice","TransformDeprecations","TransformDebugLogging","TransformFeatures","plugins","source","flags","configKey","TESTING","PRODUCTION","DEBUG","IS_RECORDING","IS_CI","SHOULD_RECORD"],"mappings":";;;;AAKA,MAAMA,QAAQ,GAAGC,MAAM,CAACC,IAAI,CAACC,gBAAgB,CAAc;AAC3D,MAAMC,QAAQ,GAAGH,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEF,gBAAgB,CAA6B;AAChFH,QAAQ,CAACM,OAAO,CAAEC,OAAO,IAAK;AAC5B,EAAA,IAAIC,YAAY,GAAGJ,QAAQ,CAACG,OAAO,CAAC;EACpC,IAAIC,YAAY,KAAK,IAAI,EAAE;AACzBJ,IAAAA,QAAQ,CAACG,OAAO,CAAC,GAAG,KAAK;AAC3B;AACF,CAAC,CAAC;AAEF,MAAME,MAAM,GAAG;AACbT,EAAAA,QAAQ,EAAEI,QAAQ;EAClBM,YAAY,EAAET,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEM,oBAAoB,CAAC;EACrDC,KAAK,EAAEX,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEQ,OAAO;AAClC,CAAC;
|
|
1
|
+
{"version":3,"file":"babel-macros.js","sources":["../src/babel-macros.ts"],"sourcesContent":["import * as LOGGING from './debugging.ts';\nimport * as CURRENT_FEATURES from './canary-features.ts';\nimport * as CURRENT_DEPRECATIONS from './deprecations.ts';\n\ntype FEATURE = keyof typeof CURRENT_FEATURES;\nconst features = Object.keys(CURRENT_FEATURES) as FEATURE[];\nconst FEATURES = Object.assign({}, CURRENT_FEATURES) as Record<FEATURE, boolean>;\nfeatures.forEach((feature) => {\n let featureValue = FEATURES[feature];\n if (featureValue === null) {\n FEATURES[feature] = false;\n }\n});\n\nconst config = {\n features: FEATURES,\n deprecations: Object.assign({}, CURRENT_DEPRECATIONS),\n debug: Object.assign({}, LOGGING),\n};\n\ntype BabelPlugin = [string, Record<string, unknown>, string];\n\nexport function macros(): BabelPlugin[] {\n const TransformAsserts = import.meta.resolve('./babel-plugin-transform-asserts.cjs').slice(7);\n const TransformDeprecations = import.meta.resolve('./babel-plugin-transform-deprecations.cjs').slice(7);\n const TransformDebugLogging = import.meta.resolve('./babel-plugin-transform-logging.cjs').slice(7);\n const TransformFeatures = import.meta.resolve('./babel-plugin-transform-features.cjs').slice(7);\n\n let plugins = [\n [TransformAsserts, {}, '@warp-drive-mirror/build-config/asserts-stripping'],\n [\n TransformFeatures,\n {\n source: '@warp-drive-mirror/build-config/canary-features',\n flags: config.features,\n },\n '@warp-drive-mirror/build-config/canary-features-stripping',\n ],\n [\n TransformDeprecations,\n {\n source: '@warp-drive-mirror/build-config/deprecations',\n flags: config.deprecations,\n },\n '@warp-drive-mirror/build-config/deprecation-stripping',\n ],\n [\n TransformDebugLogging,\n {\n source: '@warp-drive-mirror/build-config/debugging',\n configKey: 'debug',\n runtimeKey: 'activeLogging',\n flags: config.debug,\n },\n '@warp-drive-mirror/build-config/debugging-stripping',\n ],\n [\n TransformDebugLogging,\n {\n source: '@warp-drive-mirror/build-config/env',\n configKey: 'env',\n flags: {\n TESTING: true,\n PRODUCTION: true,\n DEBUG: true,\n IS_RECORDING: true,\n IS_CI: true,\n SHOULD_RECORD: true,\n },\n },\n '@warp-drive-mirror/build-config/env',\n ],\n ] satisfies BabelPlugin[];\n\n return plugins;\n}\n"],"names":["features","Object","keys","CURRENT_FEATURES","FEATURES","assign","forEach","feature","featureValue","config","deprecations","CURRENT_DEPRECATIONS","debug","LOGGING","macros","TransformAsserts","import","meta","resolve","slice","TransformDeprecations","TransformDebugLogging","TransformFeatures","plugins","source","flags","configKey","runtimeKey","TESTING","PRODUCTION","DEBUG","IS_RECORDING","IS_CI","SHOULD_RECORD"],"mappings":";;;;AAKA,MAAMA,QAAQ,GAAGC,MAAM,CAACC,IAAI,CAACC,gBAAgB,CAAc;AAC3D,MAAMC,QAAQ,GAAGH,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEF,gBAAgB,CAA6B;AAChFH,QAAQ,CAACM,OAAO,CAAEC,OAAO,IAAK;AAC5B,EAAA,IAAIC,YAAY,GAAGJ,QAAQ,CAACG,OAAO,CAAC;EACpC,IAAIC,YAAY,KAAK,IAAI,EAAE;AACzBJ,IAAAA,QAAQ,CAACG,OAAO,CAAC,GAAG,KAAK;AAC3B;AACF,CAAC,CAAC;AAEF,MAAME,MAAM,GAAG;AACbT,EAAAA,QAAQ,EAAEI,QAAQ;EAClBM,YAAY,EAAET,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEM,oBAAoB,CAAC;EACrDC,KAAK,EAAEX,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEQ,OAAO;AAClC,CAAC;AAIM,SAASC,MAAMA,GAAkB;AACtC,EAAA,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,IAAI,CAACC,OAAO,CAAC,sCAAsC,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC;AAC7F,EAAA,MAAMC,qBAAqB,GAAGJ,MAAM,CAACC,IAAI,CAACC,OAAO,CAAC,2CAA2C,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC;AACvG,EAAA,MAAME,qBAAqB,GAAGL,MAAM,CAACC,IAAI,CAACC,OAAO,CAAC,sCAAsC,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC;AAClG,EAAA,MAAMG,iBAAiB,GAAGN,MAAM,CAACC,IAAI,CAACC,OAAO,CAAC,uCAAuC,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC;AAE/F,EAAA,IAAII,OAAO,GAAG,CACZ,CAACR,gBAAgB,EAAE,EAAE,EAAE,4CAA4C,CAAC,EACpE,CACEO,iBAAiB,EACjB;AACEE,IAAAA,MAAM,EAAE,0CAA0C;IAClDC,KAAK,EAAEhB,MAAM,CAACT;AAChB,GAAC,EACD,oDAAoD,CACrD,EACD,CACEoB,qBAAqB,EACrB;AACEI,IAAAA,MAAM,EAAE,uCAAuC;IAC/CC,KAAK,EAAEhB,MAAM,CAACC;AAChB,GAAC,EACD,gDAAgD,CACjD,EACD,CACEW,qBAAqB,EACrB;AACEG,IAAAA,MAAM,EAAE,oCAAoC;AAC5CE,IAAAA,SAAS,EAAE,OAAO;AAClBC,IAAAA,UAAU,EAAE,eAAe;IAC3BF,KAAK,EAAEhB,MAAM,CAACG;AAChB,GAAC,EACD,8CAA8C,CAC/C,EACD,CACES,qBAAqB,EACrB;AACEG,IAAAA,MAAM,EAAE,8BAA8B;AACtCE,IAAAA,SAAS,EAAE,KAAK;AAChBD,IAAAA,KAAK,EAAE;AACLG,MAAAA,OAAO,EAAE,IAAI;AACbC,MAAAA,UAAU,EAAE,IAAI;AAChBC,MAAAA,KAAK,EAAE,IAAI;AACXC,MAAAA,YAAY,EAAE,IAAI;AAClBC,MAAAA,KAAK,EAAE,IAAI;AACXC,MAAAA,aAAa,EAAE;AACjB;GACD,EACD,8BAA8B,CAC/B,CACsB;AAEzB,EAAA,OAAOV,OAAO;AAChB;;;;"}
|
|
@@ -15,12 +15,12 @@ assert('foo', true);
|
|
|
15
15
|
(macroCondition(isDevelopingApp()) ? function assert(test) { if (!test) { throw new Error('foo'); } }(true) : {});
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
// => _macros.getGlobalConfig().
|
|
18
|
+
// => _macros.getGlobalConfig().WarpDriveMirror.env.DEBUG
|
|
19
19
|
function buildMacroConstDEBUG(types, binding, state) {
|
|
20
|
-
return types.memberExpression(types.memberExpression(types.memberExpression(types.callExpression(state.importer.import(binding, '@embroider/macros', 'getGlobalConfig'), []), types.identifier('
|
|
20
|
+
return types.memberExpression(types.memberExpression(types.memberExpression(types.callExpression(state.importer.import(binding, '@embroider/macros', 'getGlobalConfig'), []), types.identifier('WarpDriveMirror')), types.identifier('env')), types.identifier('DEBUG'));
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
// => _macros.macroCondition(_macros.getGlobalConfig().
|
|
23
|
+
// => _macros.macroCondition(_macros.getGlobalConfig().WarpDriveMirror.env.DEBUG)
|
|
24
24
|
function buildMacroConditionDEBUG(types, binding, state) {
|
|
25
25
|
return types.callExpression(state.importer.import(binding, '@embroider/macros', 'macroCondition'), [buildMacroConstDEBUG(types, binding, state)]);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-transform-asserts.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-asserts.js"],"sourcesContent":["const { ImportUtil } = require('babel-import-util');\n\nconst Utils = new Set(['assert']);\n\n/*\n// Before\nimport { assert } from '@warp-drive-mirror/build-config/macros';\n\nassert('foo', true);\n\n// After\n(macroCondition(isDevelopingApp()) ? function assert(test) { if (!test) { throw new Error('foo'); } }(true) : {});\n*/\n\n// => _macros.getGlobalConfig().
|
|
1
|
+
{"version":3,"file":"babel-plugin-transform-asserts.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-asserts.js"],"sourcesContent":["const { ImportUtil } = require('babel-import-util');\n\nconst Utils = new Set(['assert']);\n\n/*\n// Before\nimport { assert } from '@warp-drive-mirror/build-config/macros';\n\nassert('foo', true);\n\n// After\n(macroCondition(isDevelopingApp()) ? function assert(test) { if (!test) { throw new Error('foo'); } }(true) : {});\n*/\n\n// => _macros.getGlobalConfig().WarpDriveMirror.env.DEBUG\nfunction buildMacroConstDEBUG(types, binding, state) {\n return types.memberExpression(\n types.memberExpression(\n types.memberExpression(\n types.callExpression(state.importer.import(binding, '@embroider/macros', 'getGlobalConfig'), []),\n types.identifier('WarpDriveMirror')\n ),\n types.identifier('env')\n ),\n types.identifier('DEBUG')\n );\n}\n\n// => _macros.macroCondition(_macros.getGlobalConfig().WarpDriveMirror.env.DEBUG)\nfunction buildMacroConditionDEBUG(types, binding, state) {\n return types.callExpression(state.importer.import(binding, '@embroider/macros', 'macroCondition'), [\n buildMacroConstDEBUG(types, binding, state),\n ]);\n}\n\n// (test) => { if (!test) { throw new Error(someMessage); } }(someCond)\nfunction buildAssert(types, originalCallExpression) {\n const desc = originalCallExpression.arguments[0];\n const test = originalCallExpression.arguments[1] ?? types.booleanLiteral(false);\n // prettier-ignore\n return types.callExpression(\n types.arrowFunctionExpression([types.identifier('test')], // (test) =>\n types.blockStatement([ // {\n types.ifStatement( // if\n types.unaryExpression('!', types.identifier('test')), // (!test)\n types.blockStatement([ // {\n types.throwStatement( // throw\n types.newExpression(types.identifier('Error'), [desc]) // new Error(desc)\n )]) // }\n )]) // }\n ),\n [test] // (someCond)\n );\n}\n\n// => ( <debug-macro> ? <assert-exp> : {});\nfunction buildAssertTernary(types, binding, state, originalCallExpression) {\n return types.expressionStatement(\n types.conditionalExpression(\n buildMacroConditionDEBUG(types, binding, state),\n buildAssert(types, originalCallExpression),\n types.objectExpression([])\n )\n );\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === '@warp-drive-mirror/build-config/macros') {\n const specifiers = path.get('specifiers');\n\n specifiers.forEach((specifier) => {\n const name = specifier.node.imported.name;\n if (!Utils.has(name)) {\n throw new Error(`Unexpected import '${name}' imported from '@warp-drive-mirror/build-config/macros'`);\n }\n\n const localBindingName = specifier.node.local.name;\n const binding = specifier.scope.getBinding(localBindingName);\n\n binding.referencePaths.forEach((p) => {\n const originalCallExpression = p.parentPath.node;\n\n if (!t.isCallExpression(originalCallExpression)) {\n throw new Error('Expected a call expression');\n }\n\n const assertTernary = buildAssertTernary(t, binding, state, originalCallExpression);\n p.parentPath.replaceWith(assertTernary);\n });\n specifier.scope.removeOwnBinding(localBindingName);\n specifier.remove();\n });\n\n if (path.get('specifiers').length === 0) {\n path.remove();\n }\n }\n },\n\n Program(path, state) {\n state.importer = new ImportUtil(t, path);\n },\n },\n };\n}\n"],"names":["ImportUtil","require","Utils","Set","buildMacroConstDEBUG","types","binding","state","memberExpression","callExpression","importer","import","identifier","buildMacroConditionDEBUG","buildAssert","originalCallExpression","desc","arguments","test","booleanLiteral","arrowFunctionExpression","blockStatement","ifStatement","unaryExpression","throwStatement","newExpression","buildAssertTernary","expressionStatement","conditionalExpression","objectExpression","babel","t","name","visitor","ImportDeclaration","path","importPath","node","source","value","specifiers","get","forEach","specifier","imported","has","Error","localBindingName","local","scope","getBinding","referencePaths","p","parentPath","isCallExpression","assertTernary","replaceWith","removeOwnBinding","remove","length","Program"],"mappings":";;AAAA,MAAM;AAAEA,EAAAA;AAAW,CAAC,GAAGC,OAAO,CAAC,mBAAmB,CAAC;AAEnD,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;;AAEjC;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,SAASC,oBAAoBA,CAACC,KAAK,EAAEC,OAAO,EAAEC,KAAK,EAAE;EACnD,OAAOF,KAAK,CAACG,gBAAgB,CAC3BH,KAAK,CAACG,gBAAgB,CACpBH,KAAK,CAACG,gBAAgB,CACpBH,KAAK,CAACI,cAAc,CAACF,KAAK,CAACG,QAAQ,CAACC,MAAM,CAACL,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAChGD,KAAK,CAACO,UAAU,CAAC,WAAW,CAC9B,CAAC,EACDP,KAAK,CAACO,UAAU,CAAC,KAAK,CACxB,CAAC,EACDP,KAAK,CAACO,UAAU,CAAC,OAAO,CAC1B,CAAC;AACH;;AAEA;AACA,SAASC,wBAAwBA,CAACR,KAAK,EAAEC,OAAO,EAAEC,KAAK,EAAE;EACvD,OAAOF,KAAK,CAACI,cAAc,CAACF,KAAK,CAACG,QA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7B,kBAAkB,CAACK,CAAC,EAAEzB,OAAO,EAAEC,KAAK,EAAEQ,sBAAsB,CAAC;AACnFqC,cAAAA,CAAC,CAACC,UAAU,CAACG,WAAW,CAACD,aAAa,CAAC;AACzC,aAAC,CAAC;AACFZ,YAAAA,SAAS,CAACM,KAAK,CAACQ,gBAAgB,CAACV,gBAAgB,CAAC;YAClDJ,SAAS,CAACe,MAAM,EAAE;AACpB,WAAC,CAAC;UAEF,IAAIvB,IAAI,CAACM,GAAG,CAAC,YAAY,CAAC,CAACkB,MAAM,KAAK,CAAC,EAAE;YACvCxB,IAAI,CAACuB,MAAM,EAAE;AACf;AACF;OACD;AAEDE,MAAAA,OAAOA,CAACzB,IAAI,EAAE5B,KAAK,EAAE;QACnBA,KAAK,CAACG,QAAQ,GAAG,IAAIV,UAAU,CAAC+B,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
|
|
@@ -41,16 +41,16 @@ function babelPluginTransformDeprecations (babel) {
|
|
|
41
41
|
shouldInlineConfigValue = true;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('
|
|
44
|
+
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('WarpDriveMirror')), t.identifier('deprecations')), t.identifier(name));
|
|
45
45
|
const configExp = negateStatement ? t.unaryExpression('!', getConfig) : getConfig;
|
|
46
46
|
const replaceExp = shouldInlineConfigValue ?
|
|
47
47
|
// if (DEPRECATE_FOO)
|
|
48
48
|
// =>
|
|
49
|
-
// if (getGlobalConfig('
|
|
49
|
+
// if (getGlobalConfig('WarpDriveMirror').deprecations.FOO)
|
|
50
50
|
configExp :
|
|
51
51
|
// if (DEPRECATE_FOO)
|
|
52
52
|
// =>
|
|
53
|
-
// if (macroCondition(getGlobalConfig('
|
|
53
|
+
// if (macroCondition(getGlobalConfig('WarpDriveMirror').deprecations.FOO))
|
|
54
54
|
t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [configExp]);
|
|
55
55
|
node.replaceWith(replaceExp);
|
|
56
56
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-transform-deprecations.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-deprecations.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'deprecation-flags',\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p, other) => {\n let negateStatement = false;\n let node = p;\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n const comments =\n node.node.leadingComments ??\n (node.parent.type === 'ConditionalExpression' && node.parent.leadingComments) ??\n [];\n let shouldInlineConfigValue = false;\n if (comments?.length) {\n const lastComment = comments.at(-1);\n if (lastComment.value.trim() === 'inline-macro-config') {\n shouldInlineConfigValue = true;\n }\n }\n\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('
|
|
1
|
+
{"version":3,"file":"babel-plugin-transform-deprecations.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-deprecations.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'deprecation-flags',\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p, other) => {\n let negateStatement = false;\n let node = p;\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n const comments =\n node.node.leadingComments ??\n (node.parent.type === 'ConditionalExpression' && node.parent.leadingComments) ??\n [];\n let shouldInlineConfigValue = false;\n if (comments?.length) {\n const lastComment = comments.at(-1);\n if (lastComment.value.trim() === 'inline-macro-config') {\n shouldInlineConfigValue = true;\n }\n }\n\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('WarpDriveMirror')\n ),\n t.identifier('deprecations')\n ),\n t.identifier(name)\n );\n\n const configExp = negateStatement ? t.unaryExpression('!', getConfig) : getConfig;\n const replaceExp = shouldInlineConfigValue\n ? // if (DEPRECATE_FOO)\n // =>\n // if (getGlobalConfig('WarpDriveMirror').deprecations.FOO)\n configExp\n : // if (DEPRECATE_FOO)\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').deprecations.FOO))\n t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [configExp]);\n node.replaceWith(replaceExp);\n });\n specifier.scope.removeOwnBinding(localBindingName);\n specifier.remove();\n });\n if (path.get('specifiers').length === 0) {\n path.remove();\n }\n }\n },\n\n Program(path, state) {\n state.importer = new ImportUtil(t, path);\n },\n },\n };\n}\n"],"names":["parentIsUnary","node","parent","type","operator","babel","types","t","name","visitor","ImportDeclaration","path","state","importPath","source","value","opts","specifiers","get","forEach","specifier","imported","flags","Error","localBindingName","local","binding","scope","getBinding","referencePaths","p","other","negateStatement","parentPath","comments","leadingComments","shouldInlineConfigValue","length","lastComment","at","trim","getConfig","memberExpression","callExpression","importer","import","identifier","configExp","unaryExpression","replaceExp","replaceWith","removeOwnBinding","remove","Program","ImportUtil"],"mappings":";;;;AAEA,SAASA,aAAaA,CAACC,IAAI,EAAE;AAC3B,EAAA,IAAIA,IAAI,CAACC,MAAM,CAACC,IAAI,KAAK,iBAAiB,IAAIF,IAAI,CAACC,MAAM,CAACE,QAAQ,KAAK,GAAG,EAAE;AAC1E,IAAA,OAAO,IAAI;AACb;AACA,EAAA,OAAO,KAAK;AACd;AAEe,yCAAA,EAAUC,KAAK,EAAE;EAC9B,MAAM;AAAEC,IAAAA,KAAK,EAAEC;AAAE,GAAC,GAAGF,KAAK;EAE1B,OAAO;AACLG,IAAAA,IAAI,EAAE,mBAAmB;AACzBC,IAAAA,OAAO,EAAE;AACPC,MAAAA,iBAAiBA,CAACC,IAAI,EAAEC,KAAK,EAAE;QAC7B,MAAMC,UAAU,GAAGF,IAAI,CAACV,IAAI,CAACa,MAAM,CAACC,KAAK;AAEzC,QAAA,IAAIF,UAAU,KAAKD,KAAK,CAACI,IAAI,CAACF,MAAM,EAAE;AACpC,UAAA,MAAMG,UAAU,GAAGN,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC;AACzCD,UAAAA,UAAU,CAACE,OAAO,CAAEC,SAAS,IAAK;YAChC,IAAIZ,IAAI,GAAGY,SAAS,CAACnB,IAAI,CAACoB,QAAQ,CAACb,IAAI;YACvC,IAAI,EAAEA,IAAI,IAAII,KAAK,CAACI,IAAI,CAACM,KAAK,CAAC,EAAE;AAC/B,cAAA,MAAM,IAAIC,KAAK,CAAC,CAAA,gBAAA,EAAmBf,IAAI,CAAA,eAAA,EAAkBI,KAAK,CAACI,IAAI,CAACF,MAAM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AC,EACDvC,CAAC,CAACuC,UAAU,CAACtC,IAAI,CACnB,CAAC;AAED,cAAA,MAAMuC,SAAS,GAAGf,eAAe,GAAGzB,CAAC,CAACyC,eAAe,CAAC,GAAG,EAAEP,SAAS,CAAC,GAAGA,SAAS;cACjF,MAAMQ,UAAU,GAAGb,uBAAuB;AACtC;AACA;AACA;cACAW,SAAS;AACT;AACA;AACA;AACAxC,cAAAA,CAAC,CAACoC,cAAc,CAAC/B,KAAK,CAACgC,QAAQ,CAACC,MAAM,CAACf,CAAC,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,EAAE,CAACiB,SAAS,CAAC,CAAC;AAClG9C,cAAAA,IAAI,CAACiD,WAAW,CAACD,UAAU,CAAC;AAC9B,aAAC,CAAC;AACF7B,YAAAA,SAAS,CAACO,KAAK,CAACwB,gBAAgB,CAAC3B,gBAAgB,CAAC;YAClDJ,SAAS,CAACgC,MAAM,EAAE;AACpB,WAAC,CAAC;UACF,IAAIzC,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC,CAACmB,MAAM,KAAK,CAAC,EAAE;YACvC1B,IAAI,CAACyC,MAAM,EAAE;AACf;AACF;OACD;AAEDC,MAAAA,OAAOA,CAAC1C,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAACgC,QAAQ,GAAG,IAAIU,0BAAU,CAAC/C,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
|
|
@@ -43,11 +43,11 @@ function babelPluginTransformFeatures (babel) {
|
|
|
43
43
|
negateStatement = true;
|
|
44
44
|
node = p.parentPath;
|
|
45
45
|
}
|
|
46
|
-
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('
|
|
46
|
+
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('WarpDriveMirror')), t.identifier('features')), t.identifier(name));
|
|
47
47
|
node.replaceWith(
|
|
48
48
|
// if (LOG_FOO)
|
|
49
49
|
// =>
|
|
50
|
-
// if (macroCondition(getGlobalConfig('
|
|
50
|
+
// if (macroCondition(getGlobalConfig('WarpDriveMirror').debug.LOG_FOO))
|
|
51
51
|
t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [negateStatement ? t.unaryExpression('!', getConfig) : getConfig]));
|
|
52
52
|
});
|
|
53
53
|
specifier.scope.removeOwnBinding(localBindingName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-transform-features.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-features.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\nimport fs from 'fs';\n\nconst pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));\nconst version = pkg.version;\n\nconst isCanary = version.includes('alpha');\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p) => {\n let negateStatement = false;\n let node = p;\n if (!isCanary) {\n p.replaceWith(t.boolean(state.opts.flags[name]));\n return;\n }\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('
|
|
1
|
+
{"version":3,"file":"babel-plugin-transform-features.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-features.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\nimport fs from 'fs';\n\nconst pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));\nconst version = pkg.version;\n\nconst isCanary = version.includes('alpha');\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p) => {\n let negateStatement = false;\n let node = p;\n if (!isCanary) {\n p.replaceWith(t.boolean(state.opts.flags[name]));\n return;\n }\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('WarpDriveMirror')\n ),\n t.identifier('features')\n ),\n t.identifier(name)\n );\n node.replaceWith(\n // if (LOG_FOO)\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').debug.LOG_FOO))\n t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [\n negateStatement ? t.unaryExpression('!', getConfig) : getConfig,\n ])\n );\n });\n specifier.scope.removeOwnBinding(localBindingName);\n specifier.remove();\n });\n if (path.get('specifiers').length === 0) {\n path.remove();\n }\n }\n },\n\n Program(path, state) {\n state.importer = new ImportUtil(t, path);\n },\n },\n };\n}\n"],"names":["pkg","JSON","parse","fs","readFileSync","version","isCanary","includes","parentIsUnary","node","parent","type","operator","babel","types","t","name","visitor","ImportDeclaration","path","state","importPath","source","value","opts","specifiers","get","forEach","specifier","imported","flags","Error","localBindingName","local","binding","scope","getBinding","referencePaths","p","negateStatement","replaceWith","boolean","parentPath","getConfig","memberExpression","callExpression","importer","import","identifier","unaryExpression","removeOwnBinding","remove","length","Program","ImportUtil"],"mappings":";;;;;;AAGA,MAAMA,GAAG,GAAGC,IAAI,CAACC,KAAK,CAACC,EAAE,CAACC,YAAY,CAAC,IAAA,GAAA,CAAA,iBAAA,EAAA,qRAAA,CAA2C,EAAE,OAAO,CAAC,CAAC;AAC7F,MAAMC,OAAO,GAAGL,GAAG,CAACK,OAAO;AAE3B,MAAMC,QAAQ,GAAGD,OAAO,CAACE,QAAQ,CAAC,OAAO,CAAC;AAE1C,SAASC,aAAaA,CAACC,IAAI,EAAE;AAC3B,EAAA,IAAIA,IAAI,CAACC,MAAM,CAACC,IAAI,KAAK,iBAAiB,IAAIF,IAAI,CAACC,MAAM,CAACE,QAAQ,KAAK,GAAG,EAAE;AAC1E,IAAA,OAAO,IAAI;AACb;AACA,EAAA,OAAO,KAAK;AACd;AAEe,qCAAA,EAAUC,KAAK,EAAE;EAC9B,MAAM;AAAEC,IAAAA,KAAK,EAAEC;AAAE,GAAC,GAAGF,KAAK;EAE1B,OAAO;AACLG,IAAAA,IAAI,EAAE,eAAe;AAAE;AACvBC,IAAAA,OAAO,EAAE;AACPC,MAAAA,iBAAiBA,CAACC,IAAI,EAAEC,KAAK,EAAE;QAC7B,MAAMC,UAAU,GAAGF,IAAI,CAACV,IAAI,CAACa,MAAM,CAACC,KAAK;AAEzC,QAAA,IAAIF,UAAU,KAAKD,KAAK,CAACI,IAAI,CAACF,MAAM,EAAE;AACpC,UAAA,MAAMG,UAAU,GAAGN,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC;AACzCD,UAAAA,UAAU,CAACE,OAAO,CAAEC,SAAS,IAAK;YAChC,IAAIZ,IAAI,GAAGY,SAAS,CAAC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,IAAI,CACnB,CAAC;AACDP,cAAAA,IAAI,CAAC+B,WAAW;AACd;AACA;AACA;AACAzB,cAAAA,CAAC,CAAC8B,cAAc,CAACzB,KAAK,CAAC0B,QAAQ,CAACC,MAAM,CAACT,CAAC,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,EAAE,CAChFC,eAAe,GAAGxB,CAAC,CAACkC,eAAe,CAAC,GAAG,EAAEN,SAAS,CAAC,GAAGA,SAAS,CAChE,CACH,CAAC;AACH,aAAC,CAAC;AACFf,YAAAA,SAAS,CAACO,KAAK,CAACe,gBAAgB,CAAClB,gBAAgB,CAAC;YAClDJ,SAAS,CAACuB,MAAM,EAAE;AACpB,WAAC,CAAC;UACF,IAAIhC,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC,CAAC0B,MAAM,KAAK,CAAC,EAAE;YACvCjC,IAAI,CAACgC,MAAM,EAAE;AACf;AACF;OACD;AAEDE,MAAAA,OAAOA,CAAClC,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAAC0B,QAAQ,GAAG,IAAIQ,0BAAU,CAACvC,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
|
|
@@ -27,6 +27,8 @@ function babelPluginTransformLogging (babel) {
|
|
|
27
27
|
}
|
|
28
28
|
let localBindingName = specifier.node.local.name;
|
|
29
29
|
let binding = specifier.scope.getBinding(localBindingName);
|
|
30
|
+
const enableRuntimeActivation = Boolean(state.opts.runtimeKey);
|
|
31
|
+
const strippableKey = enableRuntimeActivation ? state.opts.runtimeKey : state.opts.configKey;
|
|
30
32
|
binding.referencePaths.forEach(p => {
|
|
31
33
|
let negateStatement = false;
|
|
32
34
|
let node = p;
|
|
@@ -34,12 +36,53 @@ function babelPluginTransformLogging (babel) {
|
|
|
34
36
|
negateStatement = true;
|
|
35
37
|
node = p.parentPath;
|
|
36
38
|
}
|
|
37
|
-
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('
|
|
39
|
+
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('WarpDriveMirror')), t.identifier(strippableKey)), t.identifier(name));
|
|
38
40
|
node.replaceWith(
|
|
39
|
-
// if (LOG_FOO)
|
|
41
|
+
// if (LOG_FOO) {
|
|
42
|
+
// // ...
|
|
43
|
+
// }
|
|
40
44
|
// =>
|
|
41
|
-
// if (macroCondition(getGlobalConfig('
|
|
45
|
+
// if (macroCondition(getGlobalConfig('WarpDriveMirror').debug.LOG_FOO)) {
|
|
46
|
+
// // ...
|
|
47
|
+
// }
|
|
42
48
|
t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [negateStatement ? t.unaryExpression('!', getConfig) : getConfig]));
|
|
49
|
+
if (enableRuntimeActivation) {
|
|
50
|
+
// we do not yet support arbitrary runtime activation locations,
|
|
51
|
+
// the only supported locations are `if (LOG)` style statements, no
|
|
52
|
+
// ternaries or other more complex expressions
|
|
53
|
+
const parentIfStatement = node.parentPath.type === 'IfStatement' ? node.parentPath : null;
|
|
54
|
+
if (!parentIfStatement) {
|
|
55
|
+
throw new Error(`Runtime activation of logging flags is only supported in if statements, but found node '${node.parentPath.type}'`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// if (LOG_FOO) {
|
|
59
|
+
// // ...
|
|
60
|
+
// }
|
|
61
|
+
// =>
|
|
62
|
+
// if (macroCondition(getGlobalConfig('WarpDriveMirror').activeLogging.LOG_FOO)) {
|
|
63
|
+
// if (getGlobalConfig('WarpDriveMirror').debug.LOG_FOO || globalThis.getWarpDriveRuntimeConfig().debug.LOG_FOO) {
|
|
64
|
+
// // ...
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
//
|
|
68
|
+
// the outer-if is generated by the node-replace above. The inner if is generated here.
|
|
69
|
+
const originalBody = parentIfStatement.node.consequent;
|
|
70
|
+
|
|
71
|
+
// getGlobalConfig('WarpDriveMirror').debug.LOG_FOO
|
|
72
|
+
const getActualConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('WarpDriveMirror')), t.identifier(state.opts.configKey)), t.identifier(name));
|
|
73
|
+
|
|
74
|
+
// globalThis.getWarpDriveRuntimeConfig().debug.LOG_FOO
|
|
75
|
+
const getRuntimeConfig = t.memberExpression(t.memberExpression(t.callExpression(t.memberExpression(t.identifier('globalThis'), t.identifier('getWarpDriveRuntimeConfig')), []), t.identifier(state.opts.configKey)), t.identifier(name));
|
|
76
|
+
|
|
77
|
+
// <getActualConfig> || <getRuntimeConfig>
|
|
78
|
+
const ifExp = t.logicalExpression('||', getActualConfig, getRuntimeConfig);
|
|
79
|
+
|
|
80
|
+
// if (<negateStatement>(<getActualConfig> || <getRuntimeConfig>)) <originalBody>
|
|
81
|
+
const innerIfStatement = t.ifStatement(negateStatement ? t.unaryExpression('!', ifExp) : ifExp, originalBody);
|
|
82
|
+
|
|
83
|
+
// replace the original body with the new if statement
|
|
84
|
+
parentIfStatement.node.consequent = t.blockStatement([innerIfStatement]);
|
|
85
|
+
}
|
|
43
86
|
});
|
|
44
87
|
specifier.scope.removeOwnBinding(localBindingName);
|
|
45
88
|
specifier.remove();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-transform-logging.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-logging.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p) => {\n let negateStatement = false;\n let node = p;\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('WarpDrive')\n ),\n t.identifier(state.opts.configKey)\n ),\n t.identifier(name)\n );\n node.replaceWith(\n // if (LOG_FOO)\n // =>\n // if (macroCondition(getGlobalConfig('WarpDrive').debug.LOG_FOO))\n t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [\n negateStatement ? t.unaryExpression('!', getConfig) : getConfig,\n ])\n );\n });\n specifier.scope.removeOwnBinding(localBindingName);\n specifier.remove();\n });\n if (path.get('specifiers').length === 0) {\n path.remove();\n }\n }\n },\n\n Program(path, state) {\n state.importer = new ImportUtil(t, path);\n },\n },\n };\n}\n"],"names":["parentIsUnary","node","parent","type","operator","babel","types","t","name","visitor","ImportDeclaration","path","state","importPath","source","value","opts","specifiers","get","forEach","specifier","imported","flags","Error","localBindingName","local","binding","scope","getBinding","referencePaths","p","negateStatement","parentPath","getConfig","memberExpression","callExpression","importer","import","identifier","configKey","replaceWith","unaryExpression","removeOwnBinding","remove","length","Program","ImportUtil"],"mappings":";;;;AAEA,SAASA,aAAaA,CAACC,IAAI,EAAE;AAC3B,EAAA,IAAIA,IAAI,CAACC,MAAM,CAACC,IAAI,KAAK,iBAAiB,IAAIF,IAAI,CAACC,MAAM,CAACE,QAAQ,KAAK,GAAG,EAAE;AAC1E,IAAA,OAAO,IAAI;AACb;AACA,EAAA,OAAO,KAAK;AACd;AAEe,oCAAA,EAAUC,KAAK,EAAE;EAC9B,MAAM;AAAEC,IAAAA,KAAK,EAAEC;AAAE,GAAC,GAAGF,KAA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AC,CAAC4B,cAAc,CAACvB,KAAK,CAACwB,QAAQ,CAACC,MAAM,CAACP,CAAC,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,EACtFvB,CAAC,CAAC+B,UAAU,CAAC,WAAW,CAC1B,CAAC,EACD/B,CAAC,CAAC+B,UAAU,CAAC1B,KAAK,CAACI,IAAI,CAACuB,SAAS,CACnC,CAAC,EACDhC,CAAC,CAAC+B,UAAU,CAAC9B,IAAI,CACnB,CAAC;AACDP,cAAAA,IAAI,CAACuC,WAAW;AACd;AACA;AACA;AACAjC,cAAAA,CAAC,CAAC4B,cAAc,CAACvB,KAAK,CAACwB,QAAQ,CAACC,MAAM,CAACP,CAAC,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,EAAE,CAChFC,eAAe,GAAGxB,CAAC,CAACkC,eAAe,CAAC,GAAG,EAAER,SAAS,CAAC,GAAGA,SAAS,CAChE,CACH,CAAC;AACH,aAAC,CAAC;AACFb,YAAAA,SAAS,CAACO,KAAK,CAACe,gBAAgB,CAAClB,gBAAgB,CAAC;YAClDJ,SAAS,CAACuB,MAAM,EAAE;AACpB,WAAC,CAAC;UACF,IAAIhC,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC,CAAC0B,MAAM,KAAK,CAAC,EAAE;YACvCjC,IAAI,CAACgC,MAAM,EAAE;AACf;AACF;OACD;AAEDE,MAAAA,OAAOA,CAAClC,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAACwB,QAAQ,GAAG,IAAIU,0BAAU,CAACvC,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"babel-plugin-transform-logging.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-logging.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n const enableRuntimeActivation = Boolean(state.opts.runtimeKey);\n const strippableKey = enableRuntimeActivation ? state.opts.runtimeKey : state.opts.configKey;\n\n binding.referencePaths.forEach((p) => {\n let negateStatement = false;\n let node = p;\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('WarpDriveMirror')\n ),\n t.identifier(strippableKey)\n ),\n t.identifier(name)\n );\n\n node.replaceWith(\n // if (LOG_FOO) {\n // // ...\n // }\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').debug.LOG_FOO)) {\n // // ...\n // }\n t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [\n negateStatement ? t.unaryExpression('!', getConfig) : getConfig,\n ])\n );\n\n if (enableRuntimeActivation) {\n // we do not yet support arbitrary runtime activation locations,\n // the only supported locations are `if (LOG)` style statements, no\n // ternaries or other more complex expressions\n const parentIfStatement = node.parentPath.type === 'IfStatement' ? node.parentPath : null;\n if (!parentIfStatement) {\n throw new Error(\n `Runtime activation of logging flags is only supported in if statements, but found node '${node.parentPath.type}'`\n );\n }\n\n // if (LOG_FOO) {\n // // ...\n // }\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').activeLogging.LOG_FOO)) {\n // if (getGlobalConfig('WarpDriveMirror').debug.LOG_FOO || globalThis.getWarpDriveRuntimeConfig().debug.LOG_FOO) {\n // // ...\n // }\n // }\n //\n // the outer-if is generated by the node-replace above. The inner if is generated here.\n const originalBody = parentIfStatement.node.consequent;\n\n // getGlobalConfig('WarpDriveMirror').debug.LOG_FOO\n const getActualConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('WarpDriveMirror')\n ),\n t.identifier(state.opts.configKey)\n ),\n t.identifier(name)\n );\n\n // globalThis.getWarpDriveRuntimeConfig().debug.LOG_FOO\n const getRuntimeConfig = t.memberExpression(\n t.memberExpression(\n t.callExpression(\n t.memberExpression(t.identifier('globalThis'), t.identifier('getWarpDriveRuntimeConfig')),\n []\n ),\n t.identifier(state.opts.configKey)\n ),\n t.identifier(name)\n );\n\n // <getActualConfig> || <getRuntimeConfig>\n const ifExp = t.logicalExpression('||', getActualConfig, getRuntimeConfig);\n\n // if (<negateStatement>(<getActualConfig> || <getRuntimeConfig>)) <originalBody>\n const innerIfStatement = t.ifStatement(\n negateStatement ? t.unaryExpression('!', ifExp) : ifExp,\n originalBody\n );\n\n // replace the original body with the new if statement\n parentIfStatement.node.consequent = t.blockStatement([innerIfStatement]);\n } else {\n }\n });\n specifier.scope.removeOwnBinding(localBindingName);\n specifier.remove();\n });\n if (path.get('specifiers').length === 0) {\n path.remove();\n }\n }\n },\n\n Program(path, state) {\n state.importer = new ImportUtil(t, path);\n },\n },\n };\n}\n"],"names":["parentIsUnary","node","parent","type","operator","babel","types","t","name","visitor","ImportDeclaration","path","state","importPath","source","value","opts","specifiers","get","forEach","specifier","imported","flags","Error","localBindingName","local","binding","scope","getBinding","enableRuntimeActivation","Boolean","runtimeKey","strippableKey","configKey","referencePaths","p","negateStatement","parentPath","getConfig","memberExpression","callExpression","importer","import","identifier","replaceWith","unaryExpression","parentIfStatement","originalBody","consequent","getActualConfig","getRuntimeConfig","ifExp","logicalExpression","innerIfStatement","ifStatement","blockStatement","removeOwnBinding","remove","length","Program","ImportUtil"],"mappings":";;;;AAE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1E;gBACA,MAAMG,gBAAgB,GAAG9C,CAAC,CAAC+C,WAAW,CACpClB,eAAe,GAAG7B,CAAC,CAACsC,eAAe,CAAC,GAAG,EAAEM,KAAK,CAAC,GAAGA,KAAK,EACvDJ,YACF,CAAC;;AAED;AACAD,gBAAAA,iBAAiB,CAAC7C,IAAI,CAAC+C,UAAU,GAAGzC,CAAC,CAACgD,cAAc,CAAC,CAACF,gBAAgB,CAAC,CAAC;AAC1E;AAEF,aAAC,CAAC;AACFjC,YAAAA,SAAS,CAACO,KAAK,CAAC6B,gBAAgB,CAAChC,gBAAgB,CAAC;YAClDJ,SAAS,CAACqC,MAAM,EAAE;AACpB,WAAC,CAAC;UACF,IAAI9C,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC,CAACwC,MAAM,KAAK,CAAC,EAAE;YACvC/C,IAAI,CAAC8C,MAAM,EAAE;AACf;AACF;OACD;AAEDE,MAAAA,OAAOA,CAAChD,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAAC6B,QAAQ,GAAG,IAAImB,0BAAU,CAACrD,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
|
package/dist/cjs-set-config.cjs
CHANGED
|
@@ -1109,7 +1109,7 @@ const CURRENT_DEPRECATIONS = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defi
|
|
|
1109
1109
|
function deprecationIsResolved(deprecatedSince, compatVersion) {
|
|
1110
1110
|
return semver.lte(semver.minVersion(deprecatedSince), semver.minVersion(compatVersion));
|
|
1111
1111
|
}
|
|
1112
|
-
const NextMajorVersion = '
|
|
1112
|
+
const NextMajorVersion = '6.';
|
|
1113
1113
|
function deprecationIsNextMajorCycle(deprecatedSince) {
|
|
1114
1114
|
return deprecatedSince.startsWith(NextMajorVersion);
|
|
1115
1115
|
}
|
|
@@ -1403,12 +1403,30 @@ const LOG_GRAPH = false;
|
|
|
1403
1403
|
* @public
|
|
1404
1404
|
*/
|
|
1405
1405
|
const LOG_INSTANCE_CACHE = false;
|
|
1406
|
+
/**
|
|
1407
|
+
* Log key count metrics, useful for performance
|
|
1408
|
+
* debugging.
|
|
1409
|
+
*
|
|
1410
|
+
* @property {boolean} LOG_METRIC_COUNTS
|
|
1411
|
+
* @public
|
|
1412
|
+
*/
|
|
1413
|
+
const LOG_METRIC_COUNTS = false;
|
|
1414
|
+
/**
|
|
1415
|
+
* Helps when debugging causes of a change notification
|
|
1416
|
+
* when processing an update to a hasMany relationship.
|
|
1417
|
+
*
|
|
1418
|
+
* @property {boolean} DEBUG_RELATIONSHIP_NOTIFICATIONS
|
|
1419
|
+
* @public
|
|
1420
|
+
*/
|
|
1421
|
+
const DEBUG_RELATIONSHIP_NOTIFICATIONS = false;
|
|
1406
1422
|
|
|
1407
1423
|
const LOGGING = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
1408
1424
|
__proto__: null,
|
|
1425
|
+
DEBUG_RELATIONSHIP_NOTIFICATIONS,
|
|
1409
1426
|
LOG_GRAPH,
|
|
1410
1427
|
LOG_IDENTIFIERS,
|
|
1411
1428
|
LOG_INSTANCE_CACHE,
|
|
1429
|
+
LOG_METRIC_COUNTS,
|
|
1412
1430
|
LOG_MUTATIONS,
|
|
1413
1431
|
LOG_NOTIFICATIONS,
|
|
1414
1432
|
LOG_OPERATIONS,
|
|
@@ -1417,6 +1435,19 @@ const LOGGING = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
1417
1435
|
LOG_REQUEST_STATUS
|
|
1418
1436
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1419
1437
|
|
|
1438
|
+
function createLoggingConfig(env, debug) {
|
|
1439
|
+
const config = {};
|
|
1440
|
+
const keys = Object.keys(LOGGING);
|
|
1441
|
+
for (const key of keys) {
|
|
1442
|
+
if (env.DEBUG || env.TESTING) {
|
|
1443
|
+
config[key] = true;
|
|
1444
|
+
} else {
|
|
1445
|
+
config[key] = debug[key] || false;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
return config;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1420
1451
|
const _MacrosConfig = EmbroiderMacros.MacrosConfig;
|
|
1421
1452
|
function recastMacrosConfig(macros) {
|
|
1422
1453
|
if (!('globalConfig' in macros)) {
|
|
@@ -1428,7 +1459,7 @@ function setConfig(context, appRoot, config) {
|
|
|
1428
1459
|
const macros = recastMacrosConfig(_MacrosConfig.for(context, appRoot));
|
|
1429
1460
|
const isLegacySupport = config.___legacy_support;
|
|
1430
1461
|
const hasDeprecatedConfig = isLegacySupport && Object.keys(config).length > 1;
|
|
1431
|
-
const hasInitiatedConfig = macros.globalConfig['
|
|
1462
|
+
const hasInitiatedConfig = macros.globalConfig['WarpDriveMirror'];
|
|
1432
1463
|
|
|
1433
1464
|
// setConfig called by user prior to legacy support called
|
|
1434
1465
|
if (isLegacySupport && hasInitiatedConfig) {
|
|
@@ -1465,9 +1496,10 @@ function setConfig(context, appRoot, config) {
|
|
|
1465
1496
|
compatWith: config.compatWith ?? null,
|
|
1466
1497
|
deprecations: DEPRECATIONS,
|
|
1467
1498
|
features: FEATURES,
|
|
1499
|
+
activeLogging: createLoggingConfig(env, debugOptions),
|
|
1468
1500
|
env
|
|
1469
1501
|
};
|
|
1470
|
-
macros.setGlobalConfig(undefined, '
|
|
1502
|
+
macros.setGlobalConfig(undefined, 'WarpDriveMirror', finalizedConfig);
|
|
1471
1503
|
}
|
|
1472
1504
|
|
|
1473
1505
|
exports.setConfig = setConfig;
|