@embroider/macros 1.12.4-unstable.ed7b6fe → 1.13.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Edward Faulkner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/macros",
3
- "version": "1.12.4-unstable.ed7b6fe",
3
+ "version": "1.13.0",
4
4
  "private": false,
5
5
  "description": "Standardized build-time macros for ember apps.",
6
6
  "keywords": [
@@ -19,25 +19,20 @@
19
19
  "src/**/*.d.ts",
20
20
  "src/**/*.js.map"
21
21
  ],
22
- "scripts": {
23
- "test": "jest"
24
- },
25
22
  "dependencies": {
26
- "@embroider/shared-internals": "2.2.4-unstable.ed7b6fe",
27
23
  "assert-never": "^1.2.1",
28
24
  "babel-import-util": "^2.0.0",
29
25
  "ember-cli-babel": "^7.26.6",
30
26
  "find-up": "^5.0.0",
31
27
  "lodash": "^4.17.21",
32
28
  "resolve": "^1.20.0",
33
- "semver": "^7.3.2"
29
+ "semver": "^7.3.2",
30
+ "@embroider/shared-internals": "2.3.0"
34
31
  },
35
32
  "devDependencies": {
36
33
  "@babel/core": "^7.14.5",
37
34
  "@babel/plugin-transform-modules-amd": "^7.19.6",
38
35
  "@babel/traverse": "^7.14.5",
39
- "@embroider/core": "3.1.4-unstable.ed7b6fe",
40
- "@embroider/test-support": "workspace:*",
41
36
  "@glint/template": "^1.0.0",
42
37
  "@types/babel__core": "^7.1.14",
43
38
  "@types/babel__generator": "^7.6.2",
@@ -50,7 +45,9 @@
50
45
  "babel-plugin-ember-template-compilation": "^2.1.1",
51
46
  "code-equality-assertions": "^0.9.0",
52
47
  "scenario-tester": "^2.1.2",
53
- "typescript": "^5.1.6"
48
+ "typescript": "^5.1.6",
49
+ "@embroider/test-support": "0.36.0",
50
+ "@embroider/core": "3.2.0"
54
51
  },
55
52
  "peerDependencies": {
56
53
  "@glint/template": "^1.0.0"
@@ -68,5 +65,8 @@
68
65
  },
69
66
  "volta": {
70
67
  "extends": "../../package.json"
68
+ },
69
+ "scripts": {
70
+ "test": "jest"
71
71
  }
72
- }
72
+ }
@@ -16,7 +16,7 @@ function initState(t, path, state) {
16
16
  state.removed = new Set();
17
17
  state.calledIdentifiers = new Set();
18
18
  state.packageCache = shared_internals_1.RewrittenPackageCache.shared('embroider', state.opts.appPackageRoot);
19
- state.sourceFile = state.opts.owningPackageRoot || path.hub.file.opts.filename;
19
+ state.sourceFile = state.opts.owningPackageRoot || (0, shared_internals_1.cleanUrl)(path.hub.file.opts.filename);
20
20
  state.pathToOurAddon = pathToAddon;
21
21
  state.owningPackage = owningPackage;
22
22
  state.originalOwningPackage = originalOwningPackage;
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["state.ts"],"names":[],"mappings":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AAM;QACL,sEAAsE;QACtE,aAAa;QACb,EAAE;QACF,qEAAqE;QACrE,yEAAyE;QACzE,4EAA4E;QAC5E,0EAA0E;QAC1E,eAAe;QACf,OAAO,qBAAqB,UAAU,EAAE,CAAC;KAC1C;AACH,CAAC;AAED,SAAS,aAAa;IACpB,IAAI,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzD,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,uDAAuD,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;KAC3F;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,qBAAqB;IAC5B,IAAI,GAAG,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IAC/B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;AAChD,CAAC;AAED,SAAS,SAAS,CAAc,IAAU;IACxC,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,OAAO,IAAA,uBAAa,EAAC,IAAI,EAAE,UAAU,KAAU;QAC7C,IAAI,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACtC,IAAI,MAAM,GAAG,IAAA,mBAAe,EAAC,KAAK,CAAC,CAAC;YACpC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,MAAM,CAAC;SACf;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { NodePath, Node } from '@babel/traverse';\nimport cloneDeepWith from 'lodash/cloneDeepWith';\nimport lodashCloneDeep from 'lodash/cloneDeep';\nimport { join, dirname, resolve } from 'path';\nimport { explicitRelative, Package, RewrittenPackageCache } from '@embroider/shared-internals';\nimport { ImportUtil } from 'babel-import-util';\nimport type * as Babel from '@babel/core';\n\nexport default interface State {\n importUtil: ImportUtil;\n generatedRequires: Set<Node>;\n removed: Set<Node>;\n calledIdentifiers: Set<Node>;\n jobs: (() => void)[];\n packageCache: RewrittenPackageCache;\n sourceFile: string;\n pathToOurAddon(moduleName: string): string;\n owningPackage(): Package;\n originalOwningPackage(): Package;\n cloneDeep(node: Node): Node;\n\n opts: {\n userConfigs: {\n [pkgRoot: string]: unknown;\n };\n globalConfig: {\n [key: string]: unknown;\n };\n // we set this when we're running inside classic ember-cli, because in that\n // case we don't have finer-grained info available about where the files\n // we're processing are globally located. When running in embroider, we\n // don't set this, because each file is visible at its full\n // globally-relevant path.\n owningPackageRoot: string | undefined;\n\n // list of packages that are under active development, represented by the\n // path to their package root directory\n isDevelopingPackageRoots: string[];\n\n // the package root directory of the app. Needed so that we can get\n // consistent answers to `isDevelopingApp` and `isDeveopingThisPackage`, as\n // well as consistent handling of Package devDependencies vs dependencies.\n appPackageRoot: string;\n\n embroiderMacrosConfigMarker: true;\n\n mode: 'compile-time' | 'run-time';\n\n importSyncImplementation: 'cjs' | 'eager';\n };\n}\n\nexport function initState(t: typeof Babel.types, path: NodePath<Babel.types.Program>, state: State) {\n state.importUtil = new ImportUtil(t, path);\n state.generatedRequires = new Set();\n state.jobs = [];\n state.removed = new Set();\n state.calledIdentifiers = new Set();\n state.packageCache = RewrittenPackageCache.shared('embroider', state.opts.appPackageRoot);\n state.sourceFile = state.opts.owningPackageRoot || (path.hub as any).file.opts.filename;\n state.pathToOurAddon = pathToAddon;\n state.owningPackage = owningPackage;\n state.originalOwningPackage = originalOwningPackage;\n state.cloneDeep = cloneDeep;\n}\n\nconst runtimeAddonPath = resolve(join(__dirname, '..', 'addon'));\n\nfunction pathToAddon(this: State, moduleName: string): string {\n if (!this.opts.owningPackageRoot) {\n // running inside embroider, so make a relative path to the module\n return explicitRelative(dirname(this.sourceFile), join(runtimeAddonPath, moduleName));\n } else {\n // running inside a classic build, so use a classic-compatible runtime\n // specifier.\n //\n // CAUTION: the module we're pointing at here gets merged between all\n // present versions of @embroider/macros, and one will win. So if you are\n // introducing incompatible changes to its API, you need to change this name\n // (by tacking on a version number, etc) and rename the corresponding file\n // in ../addon.\n return `@embroider/macros/${moduleName}`;\n }\n}\n\nfunction owningPackage(this: State): Package {\n let pkg = this.packageCache.ownerOfFile(this.sourceFile);\n if (!pkg) {\n throw new Error(`unable to determine which npm package owns the file ${this.sourceFile}`);\n }\n return pkg;\n}\n\nfunction originalOwningPackage(this: State): Package {\n let pkg = this.owningPackage();\n return this.packageCache.original(pkg) || pkg;\n}\n\nfunction cloneDeep(this: State, node: Node): Node {\n let state = this;\n return cloneDeepWith(node, function (value: any) {\n if (state.generatedRequires.has(value)) {\n let cloned = lodashCloneDeep(value);\n state.generatedRequires.add(cloned);\n return cloned;\n }\n });\n}\n"]}
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["state.ts"],"names":[],"mappings":";;;;;;AACA,yEAAiD;AACjD,iEAA+C;AAC/C,+BAA8C;AAC9C,kEAAyG;AACzG,yDAA+C;AA+C/C,SAAgB,SAAS,CAAC,CAAqB,EAAE,IAAmC,EAAE,KAAY;IAChG,KAAK,CAAC,UAAU,GAAG,IAAI,8BAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC3C,KAAK,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;IACpC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;IAChB,KAAK,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1B,KAAK,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;IACpC,KAAK,CAAC,YAAY,GAAG,wCAAqB,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC1F,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,iBAAiB,IAAI,IAAA,2BAAQ,EAAE,IAAI,CAAC,GAAW,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClG,KAAK,CAAC,cA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AAU,KAAU;QAC7C,IAAI,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACtC,IAAI,MAAM,GAAG,IAAA,mBAAe,EAAC,KAAK,CAAC,CAAC;YACpC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,MAAM,CAAC;SACf;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { NodePath, Node } from '@babel/traverse';\nimport cloneDeepWith from 'lodash/cloneDeepWith';\nimport lodashCloneDeep from 'lodash/cloneDeep';\nimport { join, dirname, resolve } from 'path';\nimport { cleanUrl, explicitRelative, Package, RewrittenPackageCache } from '@embroider/shared-internals';\nimport { ImportUtil } from 'babel-import-util';\nimport type * as Babel from '@babel/core';\n\nexport default interface State {\n importUtil: ImportUtil;\n generatedRequires: Set<Node>;\n removed: Set<Node>;\n calledIdentifiers: Set<Node>;\n jobs: (() => void)[];\n packageCache: RewrittenPackageCache;\n sourceFile: string;\n pathToOurAddon(moduleName: string): string;\n owningPackage(): Package;\n originalOwningPackage(): Package;\n cloneDeep(node: Node): Node;\n\n opts: {\n userConfigs: {\n [pkgRoot: string]: unknown;\n };\n globalConfig: {\n [key: string]: unknown;\n };\n // we set this when we're running inside classic ember-cli, because in that\n // case we don't have finer-grained info available about where the files\n // we're processing are globally located. When running in embroider, we\n // don't set this, because each file is visible at its full\n // globally-relevant path.\n owningPackageRoot: string | undefined;\n\n // list of packages that are under active development, represented by the\n // path to their package root directory\n isDevelopingPackageRoots: string[];\n\n // the package root directory of the app. Needed so that we can get\n // consistent answers to `isDevelopingApp` and `isDeveopingThisPackage`, as\n // well as consistent handling of Package devDependencies vs dependencies.\n appPackageRoot: string;\n\n embroiderMacrosConfigMarker: true;\n\n mode: 'compile-time' | 'run-time';\n\n importSyncImplementation: 'cjs' | 'eager';\n };\n}\n\nexport function initState(t: typeof Babel.types, path: NodePath<Babel.types.Program>, state: State) {\n state.importUtil = new ImportUtil(t, path);\n state.generatedRequires = new Set();\n state.jobs = [];\n state.removed = new Set();\n state.calledIdentifiers = new Set();\n state.packageCache = RewrittenPackageCache.shared('embroider', state.opts.appPackageRoot);\n state.sourceFile = state.opts.owningPackageRoot || cleanUrl((path.hub as any).file.opts.filename);\n state.pathToOurAddon = pathToAddon;\n state.owningPackage = owningPackage;\n state.originalOwningPackage = originalOwningPackage;\n state.cloneDeep = cloneDeep;\n}\n\nconst runtimeAddonPath = resolve(join(__dirname, '..', 'addon'));\n\nfunction pathToAddon(this: State, moduleName: string): string {\n if (!this.opts.owningPackageRoot) {\n // running inside embroider, so make a relative path to the module\n return explicitRelative(dirname(this.sourceFile), join(runtimeAddonPath, moduleName));\n } else {\n // running inside a classic build, so use a classic-compatible runtime\n // specifier.\n //\n // CAUTION: the module we're pointing at here gets merged between all\n // present versions of @embroider/macros, and one will win. So if you are\n // introducing incompatible changes to its API, you need to change this name\n // (by tacking on a version number, etc) and rename the corresponding file\n // in ../addon.\n return `@embroider/macros/${moduleName}`;\n }\n}\n\nfunction owningPackage(this: State): Package {\n let pkg = this.packageCache.ownerOfFile(this.sourceFile);\n if (!pkg) {\n throw new Error(`unable to determine which npm package owns the file ${this.sourceFile}`);\n }\n return pkg;\n}\n\nfunction originalOwningPackage(this: State): Package {\n let pkg = this.owningPackage();\n return this.packageCache.original(pkg) || pkg;\n}\n\nfunction cloneDeep(this: State, node: Node): Node {\n let state = this;\n return cloneDeepWith(node, function (value: any) {\n if (state.generatedRequires.has(value)) {\n let cloned = lodashCloneDeep(value);\n state.generatedRequires.add(cloned);\n return cloned;\n }\n });\n}\n"]}