@embroider/macros 1.0.0 → 1.3.0

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/README.md CHANGED
@@ -121,6 +121,10 @@ let foo = importSync('foo');
121
121
  let foo = require('foo');
122
122
  ```
123
123
 
124
+ #### hint
125
+
126
+ When using `importSync` on non ember-addon packages both the package being imported from *and* `ember-auto-import` *must* be in the `dependencies` of your addons `package.json`.
127
+
124
128
  ### dependencySatisfies
125
129
 
126
130
  Tests whether a given dependency is present and satisfies the given semver range. Both arguments must be strings and the second argument will be passed into [semver's satisfies](https://github.com/npm/node-semver#usage) method.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/macros",
3
- "version": "1.0.0",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
5
  "description": "Standardized build-time macros for ember apps.",
6
6
  "keywords": [
@@ -24,7 +24,7 @@
24
24
  "test": "jest"
25
25
  },
26
26
  "dependencies": {
27
- "@embroider/shared-internals": "1.0.0",
27
+ "@embroider/shared-internals": "1.3.0",
28
28
  "assert-never": "^1.2.1",
29
29
  "babel-import-util": "^1.1.0",
30
30
  "ember-cli-babel": "^7.26.6",
@@ -36,7 +36,7 @@
36
36
  "devDependencies": {
37
37
  "@babel/core": "^7.14.5",
38
38
  "@babel/traverse": "^7.14.5",
39
- "@embroider/core": "1.0.0",
39
+ "@embroider/core": "1.3.0",
40
40
  "@embroider/test-support": "0.36.0",
41
41
  "@types/babel__core": "^7.1.14",
42
42
  "@types/babel__generator": "^7.6.2",
@@ -21,10 +21,10 @@ function maybeAttrs(elementNode, node, builders) {
21
21
  }
22
22
  if (result.value) {
23
23
  for (let bareAttr of bareAttrs) {
24
- elementNode.attributes.push(builders.attr(bareAttr.original, builders.text('')));
24
+ elementNode.attributes.push(builders.attr(bareAttr.original, builders.text(''), bareAttr.loc));
25
25
  }
26
26
  for (let attr of node.hash.pairs) {
27
- elementNode.attributes.push(builders.attr(attr.key, builders.mustache(attr.value)));
27
+ elementNode.attributes.push(builders.attr(attr.key, builders.mustache(attr.value), attr.loc));
28
28
  }
29
29
  }
30
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"macro-maybe-attrs.js","sourceRoot":"","sources":["macro-maybe-attrs.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AAElC,SAAgB,UAAU,CAAC,WAAgB,EAAE,IAAS,EAAE,QAAa;IACnE,IAAI,CAAC,SAAS,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAE5C,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IAED,IAAI,MAAM,GAAG,IAAA,kBAAQ,EAAC,SAAS,CAAC,CAAC;IACjC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;KACpF;IAED,KAAK,IAAI,QAAQ,IAAI,SAAS,EAAE;QAC9B,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,CAAC,IAAI,qCAAqC,CAAC,CAAC;SAChG;KACF;IAED,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,KAAK,IAAI,QAAQ,IAAI,SAAS,EAAE;YAC9B,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAClF;QAED,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YAChC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACrF;KACF;AACH,CAAC;AA3BD,gCA2BC","sourcesContent":["import evaluate from './evaluate';\n\nexport function maybeAttrs(elementNode: any, node: any, builders: any) {\n let [predicate, ...bareAttrs] = node.params;\n\n if (!predicate) {\n throw new Error(`macroMaybeAttrs requires at least one argument`);\n }\n\n let result = evaluate(predicate);\n if (!result.confident) {\n throw new Error(`first argument to macroMaybeAttrs must be statically analyzable`);\n }\n\n for (let bareAttr of bareAttrs) {\n if (bareAttr.type !== 'PathExpression') {\n throw new Error(`macroMaybeAttrs found a ${bareAttr.type} where it expected a PathExpression`);\n }\n }\n\n if (result.value) {\n for (let bareAttr of bareAttrs) {\n elementNode.attributes.push(builders.attr(bareAttr.original, builders.text('')));\n }\n\n for (let attr of node.hash.pairs) {\n elementNode.attributes.push(builders.attr(attr.key, builders.mustache(attr.value)));\n }\n }\n}\n"]}
1
+ {"version":3,"file":"macro-maybe-attrs.js","sourceRoot":"","sources":["macro-maybe-attrs.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AAElC,SAAgB,UAAU,CAAC,WAAgB,EAAE,IAAS,EAAE,QAAa;IACnE,IAAI,CAAC,SAAS,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAE5C,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IAED,IAAI,MAAM,GAAG,IAAA,kBAAQ,EAAC,SAAS,CAAC,CAAC;IACjC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;KACpF;IAED,KAAK,IAAI,QAAQ,IAAI,SAAS,EAAE;QAC9B,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,CAAC,IAAI,qCAAqC,CAAC,CAAC;SAChG;KACF;IAED,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,KAAK,IAAI,QAAQ,IAAI,SAAS,EAAE;YAC9B,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;SAChG;QAED,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YAChC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;SAC/F;KACF;AACH,CAAC;AA3BD,gCA2BC","sourcesContent":["import evaluate from './evaluate';\n\nexport function maybeAttrs(elementNode: any, node: any, builders: any) {\n let [predicate, ...bareAttrs] = node.params;\n\n if (!predicate) {\n throw new Error(`macroMaybeAttrs requires at least one argument`);\n }\n\n let result = evaluate(predicate);\n if (!result.confident) {\n throw new Error(`first argument to macroMaybeAttrs must be statically analyzable`);\n }\n\n for (let bareAttr of bareAttrs) {\n if (bareAttr.type !== 'PathExpression') {\n throw new Error(`macroMaybeAttrs found a ${bareAttr.type} where it expected a PathExpression`);\n }\n }\n\n if (result.value) {\n for (let bareAttr of bareAttrs) {\n elementNode.attributes.push(builders.attr(bareAttr.original, builders.text(''), bareAttr.loc));\n }\n\n for (let attr of node.hash.pairs) {\n elementNode.attributes.push(builders.attr(attr.key, builders.mustache(attr.value), attr.loc));\n }\n }\n}\n"]}
@@ -16,15 +16,30 @@ const partition_1 = __importDefault(require("lodash/partition"));
16
16
  // MacrosConfig, it will have its own instance with its own code, but will still
17
17
  // share the GlobalSharedState beneath.
18
18
  let localSharedState = new WeakMap();
19
+ function gatherAddonCacheKeyWorker(item, memo) {
20
+ item.addons.forEach((addon) => {
21
+ let key = `${addon.pkg.name}@${addon.pkg.version}`;
22
+ memo.add(key);
23
+ gatherAddonCacheKeyWorker(addon, memo);
24
+ });
25
+ }
26
+ let addonCacheKey = new WeakMap();
19
27
  // creates a string representing all addons and their versions
20
28
  // (foo@1.0.0|bar@2.0.0) to use as a cachekey
21
- function gatherAddonCacheKey(item, memo = new Set()) {
22
- item.addons.forEach((addon) => {
29
+ function gatherAddonCacheKey(project) {
30
+ let cacheKey = addonCacheKey.get(project);
31
+ if (cacheKey) {
32
+ return cacheKey;
33
+ }
34
+ let memo = new Set();
35
+ project.addons.forEach((addon) => {
23
36
  let key = `${addon.pkg.name}@${addon.pkg.version}`;
24
37
  memo.add(key);
25
- gatherAddonCacheKey(addon, memo);
38
+ gatherAddonCacheKeyWorker(addon, memo);
26
39
  });
27
- return [...memo].join('|');
40
+ cacheKey = [...memo].join('|');
41
+ addonCacheKey.set(project, cacheKey);
42
+ return cacheKey;
28
43
  }
29
44
  class MacrosConfig {
30
45
  constructor(appRoot) {
@@ -144,6 +159,9 @@ class MacrosConfig {
144
159
  if (!this._configWritable) {
145
160
  throw new Error(`[Embroider:MacrosConfig] attempted to set config after configs have been finalized from: '${fromPath}'`);
146
161
  }
162
+ if (!isSerializable(config)) {
163
+ throw new Error(`[Embroider:MacrosConfig] the given config from '${fromPath}' for packageName '${packageName}' is not JSON serializable.`);
164
+ }
147
165
  let targetPackage = this.resolvePackage(fromPath, packageName);
148
166
  let peers = (0, shared_internals_1.getOrCreate)(this.configs, targetPackage.root, () => []);
149
167
  peers.push(config);
@@ -337,4 +355,32 @@ function defaultMergerFor(pkgRoot) {
337
355
  return Object.assign({}, ...ownConfigs, ...otherConfigs);
338
356
  };
339
357
  }
358
+ function isSerializable(obj) {
359
+ if (isScalar(obj)) {
360
+ return true;
361
+ }
362
+ if (Array.isArray(obj)) {
363
+ return !obj.some((arrayItem) => !isSerializable(arrayItem));
364
+ }
365
+ if (isPlainObject(obj)) {
366
+ for (let property in obj) {
367
+ let value = obj[property];
368
+ if (!isSerializable(value)) {
369
+ return false;
370
+ }
371
+ }
372
+ return true;
373
+ }
374
+ return false;
375
+ }
376
+ function isScalar(val) {
377
+ return (typeof val === 'undefined' ||
378
+ typeof val === 'string' ||
379
+ typeof val === 'boolean' ||
380
+ typeof val === 'number' ||
381
+ val === null);
382
+ }
383
+ function isPlainObject(obj) {
384
+ return typeof obj === 'object' && obj.constructor === Object && obj.toString() === '[object Object]';
385
+ }
340
386
  //# sourceMappingURL=macros-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"macros-config.js","sourceRoot":"","sources":["macros-config.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,+BAA4B;AAC5B,oDAA4B;AAC5B,sDAA6B;AAE7B,kEAAwE;AACxE,2DAAwG;AAExG,iEAAyC;AA0BzC,wEAAwE;AACxE,6EAA6E;AAC7E,8EAA8E;AAC9E,gFAAgF;AAChF,uCAAuC;AACvC,IAAI,gBAAgB,GAA+B,IAAI,OAAO,EAAE,CAAC;AAEjE,8DAA8D;AAC9D,6CAA6C;AAC7C,SAAS,mBAAmB,CAAC,IAAS,EAAE,IAAI,GAAG,IAAI,GAAG,EAAE;IACtD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;QACjC,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACnD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,MAAqB,YAAY;IA8E/B,YAA4B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QA1CnC,SAAI,GAAgC,cAAc,CAAC;QACnD,iBAAY,GAA+B,EAAE,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,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,IAAA,mBAAS,EAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAW,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;QACvG,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,UAAU,EAAE,GAAG,YAAY,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import fs from 'fs';\nimport { join } from 'path';\nimport crypto from 'crypto';\nimport findUp from 'find-up';\nimport type { PluginItem } from '@babel/core';\nimport { PackageCache, getOrCreate } from '@embroider/shared-internals';\nimport { FirstTransformParams, makeFirstTransform, makeSecondTransform } from './glimmer/ast-transform';\nimport State from './babel/state';\nimport partition from 'lodash/partition';\n\nexport type SourceOfConfig = (config: object) => {\n readonly name: string;\n readonly root: string;\n readonly version: string;\n};\n\nexport type Merger = (\n configs: object[],\n params: {\n sourceOfConfig: SourceOfConfig;\n }\n) => object;\n\n// Do not change this type signature without pondering deeply the mysteries of\n// being compatible with unwritten future versions of this library.\ntype GlobalSharedState = WeakMap<\n any,\n {\n configs: Map<string, object[]>;\n configSources: WeakMap<object, string>;\n mergers: Map<string, { merger: Merger; fromPath: string }>;\n }\n>;\n\n// this is a module-scoped cache. If multiple callers ask _this copy_ of\n// @embroider/macros for a shared MacrosConfig, they'll all get the same one.\n// And if somebody asks a *different* copy of @embroider/macros for the shared\n// MacrosConfig, it will have its own instance with its own code, but will still\n// share the GlobalSharedState beneath.\nlet localSharedState: WeakMap<any, MacrosConfig> = new WeakMap();\n\n// creates a string representing all addons and their versions\n// (foo@1.0.0|bar@2.0.0) to use as a cachekey\nfunction gatherAddonCacheKey(item: any, memo = new Set()) {\n item.addons.forEach((addon: any) => {\n let key = `${addon.pkg.name}@${addon.pkg.version}`;\n memo.add(key);\n gatherAddonCacheKey(addon, memo);\n });\n\n return [...memo].join('|');\n}\n\nexport default class MacrosConfig {\n static for(key: any, appRoot: string): MacrosConfig {\n let found = localSharedState.get(key);\n if (found) {\n return found;\n }\n\n let g = global as any as { __embroider_macros_global__: GlobalSharedState | undefined };\n if (!g.__embroider_macros_global__) {\n g.__embroider_macros_global__ = new WeakMap();\n }\n\n let shared = g.__embroider_macros_global__.get(key);\n if (shared) {\n // if an earlier version of @embroider/macros created the shared state, it\n // would have configSources.\n if (!shared.configSources) {\n shared.configSources = new WeakMap();\n }\n } else {\n shared = {\n configs: new Map(),\n configSources: new WeakMap(),\n mergers: new Map(),\n };\n g.__embroider_macros_global__.set(key, shared);\n }\n\n let config = new MacrosConfig(appRoot);\n config.configs = shared.configs;\n config.configSources = shared.configSources;\n config.mergers = shared.mergers;\n localSharedState.set(key, config);\n return config;\n }\n\n private mode: 'compile-time' | 'run-time' = 'compile-time';\n private globalConfig: { [key: string]: unknown } = {};\n\n private isDevelopingPackageRoots: Set<string> = new Set();\n\n enableRuntimeMode() {\n if (this.mode !== 'run-time') {\n if (!this._configWritable) {\n throw new Error(`[Embroider:MacrosConfig] attempted to enableRuntimeMode after configs have been finalized`);\n }\n this.mode = 'run-time';\n }\n }\n\n enablePackageDevelopment(packageRoot: string) {\n if (!this.isDevelopingPackageRoots.has(packageRoot)) {\n if (!this._configWritable) {\n throw new Error(\n `[Embroider:MacrosConfig] attempted to enablePackageDevelopment after configs have been finalized`\n );\n }\n this.isDevelopingPackageRoots.add(packageRoot);\n }\n }\n\n private _importSyncImplementation: 'cjs' | 'eager' = 'cjs';\n\n get importSyncImplementation() {\n return this._importSyncImplementation;\n }\n\n set importSyncImplementation(value: 'cjs' | 'eager') {\n if (!this._configWritable) {\n throw new Error(\n `[Embroider:MacrosConfig] attempted to set importSyncImplementation after configs have been finalized`\n );\n }\n this._importSyncImplementation = value;\n }\n\n private packageCache: PackageCache;\n\n private constructor(private appRoot: string) {\n // this uses globalConfig because these things truly are global. Even if a\n // package doesn't have a dep or peerDep on @embroider/macros, it's legit\n // for them to want to know the answer to these questions, and there is only\n // one answer throughout the whole dependency graph.\n this.globalConfig['@embroider/macros'] = {\n // this powers the `isTesting` macro. It always starts out false here,\n // because:\n // - if this is a production build, we will evaluate all macros at build\n // time and isTesting will stay false, so test-only code will not be\n // included.\n // - if this is a dev build, we evaluate macros at runtime, which allows\n // both \"I'm running my app in development\" and \"I'm running my test\n // suite\" to coexist within a single build. When you run the test\n // suite, early in the runtime boot process we can flip isTesting to\n // true to distinguish the two.\n isTesting: false,\n };\n this.packageCache = PackageCache.shared('embroider-stage3', appRoot);\n }\n\n private _configWritable = true;\n private configs: Map<string, object[]> = new Map();\n private configSources: WeakMap<object, string> = new WeakMap();\n private mergers: Map<string, { merger: Merger; fromPath: string }> = new Map();\n\n // Registers a new source of configuration to be given to the named package.\n // Your config type must be json-serializable. You must always set fromPath to\n // `__filename`.\n setConfig(fromPath: string, packageName: string, config: object) {\n return this.internalSetConfig(fromPath, packageName, config);\n }\n\n // Registers a new source of configuration to be given to your own package.\n // Your config type must be json-serializable. You must always set fromPath to\n // `__filename`.\n setOwnConfig(fromPath: string, config: object) {\n return this.internalSetConfig(fromPath, undefined, config);\n }\n\n // Registers a new source of configuration to be shared globally within the\n // app. USE GLOBALS SPARINGLY! Prefer setConfig or setOwnConfig instead,\n // unless your state is truly, necessarily global.\n //\n // Include a relevant package name in your key to help avoid collisions.\n //\n // Your value must be json-serializable. You must always set fromPath to\n // `__filename`.\n setGlobalConfig(fromPath: string, key: string, value: object) {\n if (!this._configWritable) {\n throw new Error(\n `[Embroider:MacrosConfig] attempted to set global config after configs have been finalized from: '${fromPath}'`\n );\n }\n this.globalConfig[key] = value;\n }\n\n private internalSetConfig(fromPath: string, packageName: string | undefined, config: object) {\n if (!this._configWritable) {\n throw new Error(\n `[Embroider:MacrosConfig] attempted to set config after configs have been finalized from: '${fromPath}'`\n );\n }\n\n let targetPackage = this.resolvePackage(fromPath, packageName);\n let peers = getOrCreate(this.configs, targetPackage.root, () => []);\n peers.push(config);\n this.configSources.set(config, fromPath);\n }\n\n // Allows you to set the merging strategy used for your package's config. The\n // merging strategy applies when multiple other packages all try to send\n // configuration to you.\n useMerger(fromPath: string, merger: Merger) {\n if (this._configWritable) {\n throw new Error(`[Embroider:MacrosConfig] attempted to call useMerger after configs have been finalized`);\n }\n\n let targetPackage = this.resolvePackage(fromPath, undefined);\n let other = this.mergers.get(targetPackage.root);\n if (other) {\n throw new Error(\n `[Embroider:MacrosConfig] conflicting mergers registered for package ${targetPackage.name} at ${targetPackage.root}. See ${other.fromPath} and ${fromPath}.`\n );\n }\n this.mergers.set(targetPackage.root, { merger, fromPath });\n }\n\n private cachedUserConfigs: { [packageRoot: string]: object } | undefined;\n\n private get userConfigs() {\n if (this._configWritable) {\n throw new Error('[Embroider:MacrosConfig] cannot read userConfigs until MacrosConfig has been finalized.');\n }\n\n if (!this.cachedUserConfigs) {\n let userConfigs: { [packageRoot: string]: object } = {};\n let sourceOfConfig = this.makeConfigSourcer(this.configSources);\n for (let [pkgRoot, configs] of this.configs) {\n let combined: object;\n if (configs.length > 1) {\n combined = this.mergerFor(pkgRoot)(configs, { sourceOfConfig });\n } else {\n combined = configs[0];\n }\n userConfigs[pkgRoot] = combined;\n }\n for (let [oldPath, newPath] of this.moves) {\n userConfigs[newPath] = userConfigs[oldPath];\n }\n this.cachedUserConfigs = userConfigs;\n }\n\n return this.cachedUserConfigs;\n }\n\n private makeConfigSourcer(configSources: WeakMap<object, string>): SourceOfConfig {\n return config => {\n let fromPath = configSources.get(config);\n if (!fromPath) {\n throw new Error(\n `unknown object passed to sourceOfConfig(). You can only pass back the configs you were given.`\n );\n }\n let maybePkg = this.packageCache.ownerOfFile(fromPath);\n if (!maybePkg) {\n throw new Error(\n `bug: unexpected error, we always check that fromPath is owned during internalSetConfig so this should never happen`\n );\n }\n let pkg = maybePkg;\n return {\n get name() {\n return pkg.name;\n },\n get version() {\n return pkg.version;\n },\n get root() {\n return pkg.root;\n },\n };\n };\n }\n\n // to be called from within your build system. Returns the thing you should\n // push into your babel plugins list.\n //\n // owningPackageRoot is needed when the files you will process (1) all belongs\n // to one package, (2) will not be located in globally correct paths such that\n // normal node_modules resolution can find their dependencies. In other words,\n // owningPackageRoot is needed when you use this inside classic ember-cli, and\n // it's not appropriate inside embroider.\n babelPluginConfig(appOrAddonInstance?: any): PluginItem[] {\n let self = this;\n let owningPackageRoot = appOrAddonInstance ? appOrAddonInstance.root || appOrAddonInstance.project.root : null;\n let opts: State['opts'] = {\n // this is deliberately lazy because we want to allow everyone to finish\n // setting config before we generate the userConfigs\n get userConfigs() {\n return self.userConfigs;\n },\n get globalConfig() {\n return self.globalConfig;\n },\n owningPackageRoot,\n\n isDevelopingPackageRoots: [...this.isDevelopingPackageRoots].map(root => this.moves.get(root) || root),\n appPackageRoot: this.moves.get(this.appRoot) ?? this.appRoot,\n\n // This is used as a signature so we can detect ourself among the plugins\n // emitted from v1 addons.\n embroiderMacrosConfigMarker: true,\n\n get mode() {\n return self.mode;\n },\n\n importSyncImplementation: this.importSyncImplementation,\n };\n\n let lockFilePath = findUp.sync(['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml'], { cwd: opts.appPackageRoot });\n\n if (!lockFilePath) {\n lockFilePath = findUp.sync('package.json', { cwd: opts.appPackageRoot });\n }\n\n let lockFileBuffer = lockFilePath ? fs.readFileSync(lockFilePath) : 'no-cache-key';\n\n // @embroider/macros provides a macro called dependencySatisfies which checks if a given\n // package name satisfies a given semver version range. Due to the way babel caches this can\n // cause a problem where the macro plugin does not run (because it has been cached) but the version\n // of the dependency being checked for changes (due to installing a different version). This will lead to\n // the old evaluated state being used which might be invalid. This cache busting plugin keeps track of a\n // hash representing the lock file of the app and if it ever changes forces babel to rerun its plugins.\n // more information in issue #906\n let hash = crypto.createHash('sha256');\n hash = hash.update(lockFileBuffer);\n if (appOrAddonInstance) {\n // ensure that the actual running addon names and versions are accounted\n // for in the cache key; this ensures that we still invalidate the cache\n // when linking another project (e.g. ember-source) which would normally\n // not cause the lockfile to change;\n hash = hash.update(gatherAddonCacheKey(appOrAddonInstance.project));\n }\n let cacheKey = hash.digest('hex');\n\n return [\n [join(__dirname, 'babel', 'macros-babel-plugin.js'), opts],\n [\n require.resolve('@embroider/shared-internals/src/babel-plugin-cache-busting.js'),\n { version: cacheKey },\n `@embroider/macros cache buster: ${owningPackageRoot}`,\n ],\n ];\n }\n\n static astPlugins(owningPackageRoot?: string): {\n plugins: Function[];\n setConfig: (config: MacrosConfig) => void;\n lazyParams: FirstTransformParams;\n } {\n let configs: MacrosConfig | undefined;\n\n let lazyParams = {\n // this is deliberately lazy because we want to allow everyone to finish\n // setting config before we generate the userConfigs\n get configs() {\n if (!configs) {\n throw new Error(`Bug: @embroider/macros ast-transforms were not plugged into a MacrosConfig`);\n }\n return configs.userConfigs;\n },\n packageRoot: owningPackageRoot,\n get appRoot() {\n if (!configs) {\n throw new Error(`Bug: @embroider/macros ast-transforms were not plugged into a MacrosConfig`);\n }\n return configs.appRoot;\n },\n };\n\n let plugins = [makeFirstTransform(lazyParams), makeSecondTransform()].reverse();\n function setConfig(c: MacrosConfig) {\n configs = c;\n }\n return { plugins, setConfig, lazyParams };\n }\n\n private mergerFor(pkgRoot: string) {\n let entry = this.mergers.get(pkgRoot);\n if (entry) {\n return entry.merger;\n }\n return defaultMergerFor(pkgRoot);\n }\n\n // this exists because @embroider/compat rewrites and moves v1 addons, and\n // their macro configs need to follow them to their new homes.\n packageMoved(oldPath: string, newPath: string) {\n if (!this._configWritable) {\n throw new Error(`[Embroider:MacrosConfig] attempted to call packageMoved after configs have been finalized`);\n }\n\n this.moves.set(oldPath, newPath);\n }\n\n private moves: Map<string, string> = new Map();\n\n private resolvePackage(fromPath: string, packageName?: string | undefined) {\n let us = this.packageCache.ownerOfFile(fromPath);\n if (!us) {\n throw new Error(`[Embroider:MacrosConfig] unable to determine which npm package owns the file ${fromPath}`);\n }\n if (packageName) {\n return this.packageCache.resolve(packageName, us);\n } else {\n return us;\n }\n }\n\n finalize() {\n this._configWritable = false;\n }\n}\n\nfunction defaultMergerFor(pkgRoot: string) {\n return function defaultMerger(configs: object[], { sourceOfConfig }: { sourceOfConfig: SourceOfConfig }): object {\n let [ownConfigs, otherConfigs] = partition(configs, c => sourceOfConfig(c as object).root === pkgRoot);\n return Object.assign({}, ...ownConfigs, ...otherConfigs);\n };\n}\n"]}
1
+ {"version":3,"file":"macros-config.js","sourceRoot":"","sources":["macros-config.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,+BAA4B;AAC5B,oDAA4B;AAC5B,sDAA6B;AAE7B,kEAAwE;AACxE,2DAAwG;AAExG,iEAAyC;AA0BzC,wEAAwE;AACxE,6EAA6E;AAC7E,8EAA8E;AAC9E,gFAAgF;AAChF,uCAAuC;AACvC,IAAI,gBAAgB,GAA+B,IAAI,OAAO,EAAE,CAAC;AAEjE,SAAS,yBAAyB,CAAC,IAAS,EAAE,IAAiB;IAC7D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;QACjC,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACnD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,yBAAyB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,aAAa,GAAyB,IAAI,OAAO,EAAE,CAAC;AACxD,8DAA8D;AAC9D,6CAA6C;AAC7C,SAAS,mBAAmB,CAAC,OAAY;IACvC,IAAI,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,QAAQ,EAAE;QACZ,OAAO,QAAQ,CAAC;KACjB;IAED,IAAI,IAAI,GAAgB,IAAI,GAAG,EAAE,CAAC;IAClC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;QACpC,IAAI,GAAG,GAAG,GAAG,KAAK,C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ACtB,KAAK,IAAI,QAAQ,IAAI,GAAG,EAAE;YACxB,IAAI,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAQ,CAAC;YACjC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;gBAC1B,OAAO,KAAK,CAAC;aACd;SACF;QAED,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,QAAQ,CAAC,GAAQ;IACxB,OAAO,CACL,OAAO,GAAG,KAAK,WAAW;QAC1B,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,SAAS;QACxB,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI,CACb,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,GAAQ;IAC7B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,WAAW,KAAK,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,KAAK,iBAAiB,CAAC;AACvG,CAAC","sourcesContent":["import fs from 'fs';\nimport { join } from 'path';\nimport crypto from 'crypto';\nimport findUp from 'find-up';\nimport type { PluginItem } from '@babel/core';\nimport { PackageCache, getOrCreate } from '@embroider/shared-internals';\nimport { FirstTransformParams, makeFirstTransform, makeSecondTransform } from './glimmer/ast-transform';\nimport State from './babel/state';\nimport partition from 'lodash/partition';\n\nexport type SourceOfConfig = (config: object) => {\n readonly name: string;\n readonly root: string;\n readonly version: string;\n};\n\nexport type Merger = (\n configs: object[],\n params: {\n sourceOfConfig: SourceOfConfig;\n }\n) => object;\n\n// Do not change this type signature without pondering deeply the mysteries of\n// being compatible with unwritten future versions of this library.\ntype GlobalSharedState = WeakMap<\n any,\n {\n configs: Map<string, object[]>;\n configSources: WeakMap<object, string>;\n mergers: Map<string, { merger: Merger; fromPath: string }>;\n }\n>;\n\n// this is a module-scoped cache. If multiple callers ask _this copy_ of\n// @embroider/macros for a shared MacrosConfig, they'll all get the same one.\n// And if somebody asks a *different* copy of @embroider/macros for the shared\n// MacrosConfig, it will have its own instance with its own code, but will still\n// share the GlobalSharedState beneath.\nlet localSharedState: WeakMap<any, MacrosConfig> = new WeakMap();\n\nfunction gatherAddonCacheKeyWorker(item: any, memo: Set<string>) {\n item.addons.forEach((addon: any) => {\n let key = `${addon.pkg.name}@${addon.pkg.version}`;\n memo.add(key);\n gatherAddonCacheKeyWorker(addon, memo);\n });\n}\n\nlet addonCacheKey: WeakMap<any, string> = new WeakMap();\n// creates a string representing all addons and their versions\n// (foo@1.0.0|bar@2.0.0) to use as a cachekey\nfunction gatherAddonCacheKey(project: any): string {\n let cacheKey = addonCacheKey.get(project);\n if (cacheKey) {\n return cacheKey;\n }\n\n let memo: Set<string> = new Set();\n project.addons.forEach((addon: any) => {\n let key = `${addon.pkg.name}@${addon.pkg.version}`;\n memo.add(key);\n gatherAddonCacheKeyWorker(addon, memo);\n });\n\n cacheKey = [...memo].join('|');\n addonCacheKey.set(project, cacheKey);\n\n return cacheKey;\n}\n\nexport default class MacrosConfig {\n static for(key: any, appRoot: string): MacrosConfig {\n let found = localSharedState.get(key);\n if (found) {\n return found;\n }\n\n let g = global as any as { __embroider_macros_global__: GlobalSharedState | undefined };\n if (!g.__embroider_macros_global__) {\n g.__embroider_macros_global__ = new WeakMap();\n }\n\n let shared = g.__embroider_macros_global__.get(key);\n if (shared) {\n // if an earlier version of @embroider/macros created the shared state, it\n // would have configSources.\n if (!shared.configSources) {\n shared.configSources = new WeakMap();\n }\n } else {\n shared = {\n configs: new Map(),\n configSources: new WeakMap(),\n mergers: new Map(),\n };\n g.__embroider_macros_global__.set(key, shared);\n }\n\n let config = new MacrosConfig(appRoot);\n config.configs = shared.configs;\n config.configSources = shared.configSources;\n config.mergers = shared.mergers;\n localSharedState.set(key, config);\n return config;\n }\n\n private mode: 'compile-time' | 'run-time' = 'compile-time';\n private globalConfig: { [key: string]: unknown } = {};\n\n private isDevelopingPackageRoots: Set<string> = new Set();\n\n enableRuntimeMode() {\n if (this.mode !== 'run-time') {\n if (!this._configWritable) {\n throw new Error(`[Embroider:MacrosConfig] attempted to enableRuntimeMode after configs have been finalized`);\n }\n this.mode = 'run-time';\n }\n }\n\n enablePackageDevelopment(packageRoot: string) {\n if (!this.isDevelopingPackageRoots.has(packageRoot)) {\n if (!this._configWritable) {\n throw new Error(\n `[Embroider:MacrosConfig] attempted to enablePackageDevelopment after configs have been finalized`\n );\n }\n this.isDevelopingPackageRoots.add(packageRoot);\n }\n }\n\n private _importSyncImplementation: 'cjs' | 'eager' = 'cjs';\n\n get importSyncImplementation() {\n return this._importSyncImplementation;\n }\n\n set importSyncImplementation(value: 'cjs' | 'eager') {\n if (!this._configWritable) {\n throw new Error(\n `[Embroider:MacrosConfig] attempted to set importSyncImplementation after configs have been finalized`\n );\n }\n this._importSyncImplementation = value;\n }\n\n private packageCache: PackageCache;\n\n private constructor(private appRoot: string) {\n // this uses globalConfig because these things truly are global. Even if a\n // package doesn't have a dep or peerDep on @embroider/macros, it's legit\n // for them to want to know the answer to these questions, and there is only\n // one answer throughout the whole dependency graph.\n this.globalConfig['@embroider/macros'] = {\n // this powers the `isTesting` macro. It always starts out false here,\n // because:\n // - if this is a production build, we will evaluate all macros at build\n // time and isTesting will stay false, so test-only code will not be\n // included.\n // - if this is a dev build, we evaluate macros at runtime, which allows\n // both \"I'm running my app in development\" and \"I'm running my test\n // suite\" to coexist within a single build. When you run the test\n // suite, early in the runtime boot process we can flip isTesting to\n // true to distinguish the two.\n isTesting: false,\n };\n this.packageCache = PackageCache.shared('embroider-stage3', appRoot);\n }\n\n private _configWritable = true;\n private configs: Map<string, object[]> = new Map();\n private configSources: WeakMap<object, string> = new WeakMap();\n private mergers: Map<string, { merger: Merger; fromPath: string }> = new Map();\n\n // Registers a new source of configuration to be given to the named package.\n // Your config type must be json-serializable. You must always set fromPath to\n // `__filename`.\n setConfig(fromPath: string, packageName: string, config: object) {\n return this.internalSetConfig(fromPath, packageName, config);\n }\n\n // Registers a new source of configuration to be given to your own package.\n // Your config type must be json-serializable. You must always set fromPath to\n // `__filename`.\n setOwnConfig(fromPath: string, config: object) {\n return this.internalSetConfig(fromPath, undefined, config);\n }\n\n // Registers a new source of configuration to be shared globally within the\n // app. USE GLOBALS SPARINGLY! Prefer setConfig or setOwnConfig instead,\n // unless your state is truly, necessarily global.\n //\n // Include a relevant package name in your key to help avoid collisions.\n //\n // Your value must be json-serializable. You must always set fromPath to\n // `__filename`.\n setGlobalConfig(fromPath: string, key: string, value: object) {\n if (!this._configWritable) {\n throw new Error(\n `[Embroider:MacrosConfig] attempted to set global config after configs have been finalized from: '${fromPath}'`\n );\n }\n this.globalConfig[key] = value;\n }\n\n private internalSetConfig(fromPath: string, packageName: string | undefined, config: object) {\n if (!this._configWritable) {\n throw new Error(\n `[Embroider:MacrosConfig] attempted to set config after configs have been finalized from: '${fromPath}'`\n );\n }\n\n if (!isSerializable(config)) {\n throw new Error(\n `[Embroider:MacrosConfig] the given config from '${fromPath}' for packageName '${packageName}' is not JSON serializable.`\n );\n }\n\n let targetPackage = this.resolvePackage(fromPath, packageName);\n let peers = getOrCreate(this.configs, targetPackage.root, () => []);\n peers.push(config);\n this.configSources.set(config, fromPath);\n }\n\n // Allows you to set the merging strategy used for your package's config. The\n // merging strategy applies when multiple other packages all try to send\n // configuration to you.\n useMerger(fromPath: string, merger: Merger) {\n if (this._configWritable) {\n throw new Error(`[Embroider:MacrosConfig] attempted to call useMerger after configs have been finalized`);\n }\n\n let targetPackage = this.resolvePackage(fromPath, undefined);\n let other = this.mergers.get(targetPackage.root);\n if (other) {\n throw new Error(\n `[Embroider:MacrosConfig] conflicting mergers registered for package ${targetPackage.name} at ${targetPackage.root}. See ${other.fromPath} and ${fromPath}.`\n );\n }\n this.mergers.set(targetPackage.root, { merger, fromPath });\n }\n\n private cachedUserConfigs: { [packageRoot: string]: object } | undefined;\n\n private get userConfigs() {\n if (this._configWritable) {\n throw new Error('[Embroider:MacrosConfig] cannot read userConfigs until MacrosConfig has been finalized.');\n }\n\n if (!this.cachedUserConfigs) {\n let userConfigs: { [packageRoot: string]: object } = {};\n let sourceOfConfig = this.makeConfigSourcer(this.configSources);\n for (let [pkgRoot, configs] of this.configs) {\n let combined: object;\n if (configs.length > 1) {\n combined = this.mergerFor(pkgRoot)(configs, { sourceOfConfig });\n } else {\n combined = configs[0];\n }\n userConfigs[pkgRoot] = combined;\n }\n for (let [oldPath, newPath] of this.moves) {\n userConfigs[newPath] = userConfigs[oldPath];\n }\n this.cachedUserConfigs = userConfigs;\n }\n\n return this.cachedUserConfigs;\n }\n\n private makeConfigSourcer(configSources: WeakMap<object, string>): SourceOfConfig {\n return config => {\n let fromPath = configSources.get(config);\n if (!fromPath) {\n throw new Error(\n `unknown object passed to sourceOfConfig(). You can only pass back the configs you were given.`\n );\n }\n let maybePkg = this.packageCache.ownerOfFile(fromPath);\n if (!maybePkg) {\n throw new Error(\n `bug: unexpected error, we always check that fromPath is owned during internalSetConfig so this should never happen`\n );\n }\n let pkg = maybePkg;\n return {\n get name() {\n return pkg.name;\n },\n get version() {\n return pkg.version;\n },\n get root() {\n return pkg.root;\n },\n };\n };\n }\n\n // to be called from within your build system. Returns the thing you should\n // push into your babel plugins list.\n //\n // owningPackageRoot is needed when the files you will process (1) all belongs\n // to one package, (2) will not be located in globally correct paths such that\n // normal node_modules resolution can find their dependencies. In other words,\n // owningPackageRoot is needed when you use this inside classic ember-cli, and\n // it's not appropriate inside embroider.\n babelPluginConfig(appOrAddonInstance?: any): PluginItem[] {\n let self = this;\n let owningPackageRoot = appOrAddonInstance ? appOrAddonInstance.root || appOrAddonInstance.project.root : null;\n let opts: State['opts'] = {\n // this is deliberately lazy because we want to allow everyone to finish\n // setting config before we generate the userConfigs\n get userConfigs() {\n return self.userConfigs;\n },\n get globalConfig() {\n return self.globalConfig;\n },\n owningPackageRoot,\n\n isDevelopingPackageRoots: [...this.isDevelopingPackageRoots].map(root => this.moves.get(root) || root),\n appPackageRoot: this.moves.get(this.appRoot) ?? this.appRoot,\n\n // This is used as a signature so we can detect ourself among the plugins\n // emitted from v1 addons.\n embroiderMacrosConfigMarker: true,\n\n get mode() {\n return self.mode;\n },\n\n importSyncImplementation: this.importSyncImplementation,\n };\n\n let lockFilePath = findUp.sync(['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml'], { cwd: opts.appPackageRoot });\n\n if (!lockFilePath) {\n lockFilePath = findUp.sync('package.json', { cwd: opts.appPackageRoot });\n }\n\n let lockFileBuffer = lockFilePath ? fs.readFileSync(lockFilePath) : 'no-cache-key';\n\n // @embroider/macros provides a macro called dependencySatisfies which checks if a given\n // package name satisfies a given semver version range. Due to the way babel caches this can\n // cause a problem where the macro plugin does not run (because it has been cached) but the version\n // of the dependency being checked for changes (due to installing a different version). This will lead to\n // the old evaluated state being used which might be invalid. This cache busting plugin keeps track of a\n // hash representing the lock file of the app and if it ever changes forces babel to rerun its plugins.\n // more information in issue #906\n let hash = crypto.createHash('sha256');\n hash = hash.update(lockFileBuffer);\n if (appOrAddonInstance) {\n // ensure that the actual running addon names and versions are accounted\n // for in the cache key; this ensures that we still invalidate the cache\n // when linking another project (e.g. ember-source) which would normally\n // not cause the lockfile to change;\n hash = hash.update(gatherAddonCacheKey(appOrAddonInstance.project));\n }\n let cacheKey = hash.digest('hex');\n\n return [\n [join(__dirname, 'babel', 'macros-babel-plugin.js'), opts],\n [\n require.resolve('@embroider/shared-internals/src/babel-plugin-cache-busting.js'),\n { version: cacheKey },\n `@embroider/macros cache buster: ${owningPackageRoot}`,\n ],\n ];\n }\n\n static astPlugins(owningPackageRoot?: string): {\n plugins: Function[];\n setConfig: (config: MacrosConfig) => void;\n lazyParams: FirstTransformParams;\n } {\n let configs: MacrosConfig | undefined;\n\n let lazyParams = {\n // this is deliberately lazy because we want to allow everyone to finish\n // setting config before we generate the userConfigs\n get configs() {\n if (!configs) {\n throw new Error(`Bug: @embroider/macros ast-transforms were not plugged into a MacrosConfig`);\n }\n return configs.userConfigs;\n },\n packageRoot: owningPackageRoot,\n get appRoot() {\n if (!configs) {\n throw new Error(`Bug: @embroider/macros ast-transforms were not plugged into a MacrosConfig`);\n }\n return configs.appRoot;\n },\n };\n\n let plugins = [makeFirstTransform(lazyParams), makeSecondTransform()].reverse();\n function setConfig(c: MacrosConfig) {\n configs = c;\n }\n return { plugins, setConfig, lazyParams };\n }\n\n private mergerFor(pkgRoot: string) {\n let entry = this.mergers.get(pkgRoot);\n if (entry) {\n return entry.merger;\n }\n return defaultMergerFor(pkgRoot);\n }\n\n // this exists because @embroider/compat rewrites and moves v1 addons, and\n // their macro configs need to follow them to their new homes.\n packageMoved(oldPath: string, newPath: string) {\n if (!this._configWritable) {\n throw new Error(`[Embroider:MacrosConfig] attempted to call packageMoved after configs have been finalized`);\n }\n\n this.moves.set(oldPath, newPath);\n }\n\n private moves: Map<string, string> = new Map();\n\n private resolvePackage(fromPath: string, packageName?: string | undefined) {\n let us = this.packageCache.ownerOfFile(fromPath);\n if (!us) {\n throw new Error(`[Embroider:MacrosConfig] unable to determine which npm package owns the file ${fromPath}`);\n }\n if (packageName) {\n return this.packageCache.resolve(packageName, us);\n } else {\n return us;\n }\n }\n\n finalize() {\n this._configWritable = false;\n }\n}\n\nfunction defaultMergerFor(pkgRoot: string) {\n return function defaultMerger(configs: object[], { sourceOfConfig }: { sourceOfConfig: SourceOfConfig }): object {\n let [ownConfigs, otherConfigs] = partition(configs, c => sourceOfConfig(c as object).root === pkgRoot);\n return Object.assign({}, ...ownConfigs, ...otherConfigs);\n };\n}\n\nfunction isSerializable(obj: object): boolean {\n if (isScalar(obj)) {\n return true;\n }\n\n if (Array.isArray(obj)) {\n return !obj.some((arrayItem: any) => !isSerializable(arrayItem));\n }\n\n if (isPlainObject(obj)) {\n for (let property in obj) {\n let value = obj[property] as any;\n if (!isSerializable(value)) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n}\n\nfunction isScalar(val: any): boolean {\n return (\n typeof val === 'undefined' ||\n typeof val === 'string' ||\n typeof val === 'boolean' ||\n typeof val === 'number' ||\n val === null\n );\n}\n\nfunction isPlainObject(obj: any): obj is Record<string, any> {\n return typeof obj === 'object' && obj.constructor === Object && obj.toString() === '[object Object]';\n}\n"]}