New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@embroider/shared-internals

Package Overview
Dependencies
Maintainers
9
Versions
457
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@embroider/shared-internals - npm Package Compare versions

Comparing version 2.8.2-unstable.f779011 to 2.9.0

src/babel-filter.d.ts

8

package.json
{
"name": "@embroider/shared-internals",
"version": "2.8.2-unstable.f779011",
"version": "2.9.0",
"private": false,

@@ -16,3 +16,4 @@ "description": "Utilities shared among the other embroider packages",

},
"./src/*": "./src/*.js"
"./src/babel-plugin-cache-busting.js": "./src/babel-plugin-cache-busting.js",
"./src/template-colocation-plugin": "./src/template-colocation-plugin.js"
},

@@ -37,3 +38,2 @@ "license": "MIT",

"pkg-entry-points": "^1.1.0",
"resolve.exports": "^2.0.2",
"resolve-package-path": "^4.0.1",

@@ -57,3 +57,3 @@ "semver": "^7.3.5",

"tmp": "^0.1.0",
"typescript": "^5.4.5",
"typescript": "^5.1.6",
"@embroider/test-support": "0.36.0"

@@ -60,0 +60,0 @@ },

@@ -1,5 +0,3 @@

import type PackageCache from './package-cache';
export declare function syntheticJStoHBS(source: string): string | null;
export declare function needsSyntheticComponentJS(requestedSpecifier: string, foundFile: string): string | null;
export declare function isInComponents(url: string, packageCache: Pick<PackageCache, 'ownerOfFile'>): boolean;
export declare function templateOnlyComponentSource(): string;

@@ -5,3 +5,2 @@ "use strict";

exports.needsSyntheticComponentJS = needsSyntheticComponentJS;
exports.isInComponents = isInComponents;
exports.templateOnlyComponentSource = templateOnlyComponentSource;

@@ -11,3 +10,2 @@ const fs_extra_1 = require("fs-extra");

const path_1 = require("path");
const resolve_exports_1 = require("resolve.exports");
function syntheticJStoHBS(source) {

@@ -18,3 +16,3 @@ // explicit js is the only case we care about here. Synthetic template JS is

if ((0, paths_1.cleanUrl)(source).endsWith('.js')) {
return source.replace(/.js(\?.*)?$/, '.hbs$1');
return source.replace(/\.js(\?.*)?$/, '.hbs$1');
}

@@ -39,16 +37,2 @@ return null;

}
function isInComponents(url, packageCache) {
var _a;
const id = (0, paths_1.cleanUrl)(url);
const pkg = packageCache.ownerOfFile(id);
if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isApp())) {
return false;
}
let tryResolve = (0, resolve_exports_1.resolve)(pkg.packageJSON, './components', {
browser: true,
conditions: ['default', 'imports'],
});
let componentsDir = (_a = tryResolve === null || tryResolve === void 0 ? void 0 : tryResolve[0]) !== null && _a !== void 0 ? _a : './components';
return (0, paths_1.explicitRelative)(pkg.root, id).split(path_1.sep).join('/').startsWith(componentsDir);
}
function templateOnlyComponentSource() {

@@ -55,0 +39,0 @@ return `import templateOnly from '@ember/component/template-only';\nexport default templateOnly();\n`;

@@ -45,3 +45,3 @@ "use strict";

let ancestorsDep = ancestor.dependencies.find(d => d.name === dep.name);
if (ancestorsDep !== dep && dep.isEmberAddon()) {
if (ancestorsDep !== dep && dep.isEmberPackage()) {
violations.push({ pkg, dep, ancestors, ancestor, ancestorsDep });

@@ -48,0 +48,0 @@ }

@@ -57,4 +57,2 @@ "use strict";

exports.emberVirtualPackages.add('@glimmer/manager');
// ember-data pre 4.12 failed to declare this as a peer dependency of @ember-data/debug
exports.emberVirtualPeerDeps.add('@ember-data/store');
// These are the known names that people use to import template precomiplation

@@ -61,0 +59,0 @@ // macros from.

@@ -1,8 +0,9 @@

export { AddonMeta, PackageInfo } from './metadata';
export { explicitRelative, extensionsPattern, unrelativize, cleanUrl, getUrlQueryParams, correspondingTemplate, } from './paths';
export { AppMeta, AddonMeta, PackageInfo } from './metadata';
export { explicitRelative, extensionsPattern, unrelativize, cleanUrl, correspondingTemplate } from './paths';
export { getOrCreate } from './get-or-create';
export { default as Package, V2AddonPackage as AddonPackage } from './package';
export { default as PackageCache, type PackageCachePublicAPI } from './package-cache';
export { default as Package, V2AddonPackage as AddonPackage, V2AppPackage as AppPackage, V2Package } from './package';
export { default as PackageCache } from './package-cache';
export type { RewrittenPackageIndex } from './rewritten-package-cache';
export { RewrittenPackageCache } from './rewritten-package-cache';
export { default as babelFilter } from './babel-filter';
export { default as packageName } from './package-name';

@@ -9,0 +10,0 @@ export { default as tmpdir } from './tmpdir';

@@ -20,3 +20,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getWatchedDirectories = exports.locateEmbroiderWorkingDir = exports.cacheBustingPluginVersion = exports.cacheBustingPluginPath = exports.cacheBustingPlugin = exports.templateColocationPluginPath = exports.templateColocationPlugin = exports.hbsToJS = exports.tmpdir = exports.packageName = exports.RewrittenPackageCache = exports.PackageCache = exports.Package = exports.getOrCreate = exports.correspondingTemplate = exports.getUrlQueryParams = exports.cleanUrl = exports.unrelativize = exports.extensionsPattern = exports.explicitRelative = void 0;
exports.getWatchedDirectories = exports.locateEmbroiderWorkingDir = exports.cacheBustingPluginVersion = exports.cacheBustingPluginPath = exports.cacheBustingPlugin = exports.templateColocationPluginPath = exports.templateColocationPlugin = exports.hbsToJS = exports.tmpdir = exports.packageName = exports.babelFilter = exports.RewrittenPackageCache = exports.PackageCache = exports.Package = exports.getOrCreate = exports.correspondingTemplate = exports.cleanUrl = exports.unrelativize = exports.extensionsPattern = exports.explicitRelative = void 0;
var paths_1 = require("./paths");

@@ -27,3 +27,2 @@ Object.defineProperty(exports, "explicitRelative", { enumerable: true, get: function () { return paths_1.explicitRelative; } });

Object.defineProperty(exports, "cleanUrl", { enumerable: true, get: function () { return paths_1.cleanUrl; } });
Object.defineProperty(exports, "getUrlQueryParams", { enumerable: true, get: function () { return paths_1.getUrlQueryParams; } });
Object.defineProperty(exports, "correspondingTemplate", { enumerable: true, get: function () { return paths_1.correspondingTemplate; } });

@@ -38,2 +37,4 @@ var get_or_create_1 = require("./get-or-create");

Object.defineProperty(exports, "RewrittenPackageCache", { enumerable: true, get: function () { return rewritten_package_cache_1.RewrittenPackageCache; } });
var babel_filter_1 = require("./babel-filter");
Object.defineProperty(exports, "babelFilter", { enumerable: true, get: function () { return __importDefault(babel_filter_1).default; } });
var package_name_1 = require("./package-name");

@@ -40,0 +41,0 @@ Object.defineProperty(exports, "packageName", { enumerable: true, get: function () { return __importDefault(package_name_1).default; } });

type Filename = string;
type AppRelativeURL = string;
export interface AppMeta {
type: 'app';
main?: string;
'auto-upgraded'?: true;
assets: Filename[];
babel: {
filename: string;
isParallelSafe: boolean;
majorVersion: 7;
fileFilter: string;
};
'root-url': string;
version: 2;
}
export interface AddonMeta {
type: 'addon';
main?: string;

@@ -14,2 +29,3 @@ 'order-index'?: number;

};
externals?: string[];
'implicit-modules'?: string[];

@@ -42,5 +58,6 @@ 'implicit-scripts'?: Filename[];

dependencies?: Record<string, string>;
'ember-addon': AddonMeta | {
'ember-addon': AddonMeta | AppMeta | {
main?: string;
version?: 1;
type?: 'addon' | 'app';
paths?: string[];

@@ -47,0 +64,0 @@ before?: string | string[];

@@ -12,6 +12,1 @@ import Package from './package';

}
type PublicAPI<T> = {
[K in keyof T]: T[K];
};
export type PackageCachePublicAPI = PublicAPI<PackageCache>;
export {};

@@ -1,2 +0,2 @@

import type { AddonMeta, PackageInfo } from './metadata';
import type { AddonMeta, AppMeta, PackageInfo } from './metadata';
import type PackageCache from './package-cache';

@@ -6,5 +6,5 @@ export default class Package {

protected packageCache: PackageCache;
private _isApp;
private isApp;
private dependencyKeys;
constructor(root: string, packageCache: PackageCache, _isApp: boolean);
constructor(root: string, packageCache: PackageCache, isApp: boolean);
get name(): string;

@@ -14,9 +14,8 @@ get version(): string;

get packageJSON(): PackageInfo;
get meta(): AddonMeta | undefined;
isEmberAddon(): boolean;
get meta(): AddonMeta | AppMeta | undefined;
isEmberPackage(): boolean;
isEngine(): boolean;
isLazyEngine(): boolean;
isV2Ember(): boolean;
isApp(): boolean;
needsLooseResolving(): boolean;
isV2Ember(): this is V2Package;
isV2App(): this is V2AppPackage;
isV2Addon(): this is V2AddonPackage;

@@ -34,4 +33,10 @@ findDescendants(filter?: (pkg: Package) => boolean): Package[];

}
export interface V2Package extends Package {
meta: AddonMeta | AppMeta;
}
export interface V2AddonPackage extends Package {
meta: AddonMeta;
}
export interface V2AppPackage extends Package {
meta: AppMeta;
}

@@ -17,36 +17,8 @@ "use strict";

const flatMap_1 = __importDefault(require("lodash/flatMap"));
// This is controllable via env var because there are many different contexts
// (babel/rollup/vite/webpack/handlebars plugins) that can all depend on
// `@embroider/shared-internals` to help understand the structure of packages,
// and we want one clear way to signal to all of those whether this feature is
// configured.
//
// The initial motivating use case for this is that new-enough ember-source can
// function as a v2 addon despite not declaring itself to be a v2 addon, because
// that would be potentially-breaking for people who still consume it via AMD
// and/or depend on the specific timng of the classic vendor.js file. We don't
// want to break people but we also want people on the bleeding edge to be able
// to take advantage of the capability.
const forcedV2Packages = (() => {
let cached;
return () => {
if (!cached) {
if (typeof process !== undefined &&
typeof process.env !== undefined &&
process.env.EMBROIDER_FORCED_V2_PACKAGES) {
cached = process.env.EMBROIDER_FORCED_V2_PACKAGES.split(',');
}
else {
cached = [];
}
}
return cached;
};
})();
class Package {
constructor(root, packageCache, _isApp) {
constructor(root, packageCache, isApp) {
this.root = root;
this.packageCache = packageCache;
this._isApp = _isApp;
this.dependencyKeys = _isApp
this.isApp = isApp;
this.dependencyKeys = isApp
? ['dependencies', 'devDependencies', 'peerDependencies']

@@ -74,8 +46,2 @@ : ['dependencies', 'peerDependencies'];

}
if (forcedV2Packages().includes(json.name)) {
let defaults = {
version: 2,
};
json['ember-addon'] = Object.assign(defaults, json['ember-addon']);
}
return json;

@@ -85,2 +51,5 @@ }

let m = this.packageJSON['ember-addon'];
if (this.isV2App()) {
return m;
}
if (this.isV2Addon()) {

@@ -90,3 +59,3 @@ return m;

}
isEmberAddon() {
isEmberPackage() {
let keywords = this.packageJSON.keywords;

@@ -96,3 +65,3 @@ return Boolean(keywords && keywords.includes('ember-addon'));

isEngine() {
if (this.isApp()) {
if (this.isApp) {
// an app is implicitly an engine

@@ -108,14 +77,9 @@ return true;

isV2Ember() {
return this.isApp() || this.isV2Addon();
return this.isEmberPackage() && (0, get_1.default)(this.packageJSON, 'ember-addon.version') === 2;
}
isApp() {
return this._isApp;
isV2App() {
return this.isV2Ember() && this.packageJSON['ember-addon'].type === 'app';
}
needsLooseResolving() {
var _a;
return this.isApp() || ((_a = (this.isV2Addon() && this.meta['auto-upgraded'])) !== null && _a !== void 0 ? _a : false);
}
isV2Addon() {
var _a;
return this.isEmberAddon() && ((_a = this.packageJSON['ember-addon']) === null || _a === void 0 ? void 0 : _a.version) === 2;
return this.isV2Ember() && this.packageJSON['ember-addon'].type === 'addon';
}

@@ -122,0 +86,0 @@ findDescendants(filter) {

@@ -6,3 +6,2 @@ import type Package from './package';

export declare function cleanUrl(url: string): string;
export declare function getUrlQueryParams(url: string): string;
export declare function correspondingTemplate(filename: string): string;

@@ -7,3 +7,2 @@ "use strict";

exports.cleanUrl = cleanUrl;
exports.getUrlQueryParams = getUrlQueryParams;
exports.correspondingTemplate = correspondingTemplate;

@@ -51,13 +50,5 @@ const path_1 = require("path");

// cache-busting query params from leaking where they shouldn't.
// includeHashSign true means #my-specifier is considered part of the pathname
function cleanUrl(url) {
const regexp = postfixRE;
return url.replace(regexp, '');
return url.replace(postfixRE, '');
}
// includeHashSign true means #my-specifier is considered part of the pathname
function getUrlQueryParams(url) {
var _a, _b;
const regexp = postfixRE;
return (_b = (_a = url.match(regexp)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '';
}
// given a filename, returns it with the hbs extension

@@ -64,0 +55,0 @@ // for instance, passing filename.js returns filename.hbs

@@ -1,2 +0,2 @@

import PackageCache, { type PackageCachePublicAPI } from './package-cache';
import PackageCache from './package-cache';
import Package from './package';

@@ -7,3 +7,6 @@ export interface RewrittenPackageIndex {

}
export declare class RewrittenPackageCache implements PackageCachePublicAPI {
type PublicAPI<T> = {
[K in keyof T]: T[K];
};
export declare class RewrittenPackageCache implements PublicAPI<PackageCache> {
private plainCache;

@@ -24,1 +27,2 @@ constructor(plainCache: PackageCache);

}
export {};

@@ -172,4 +172,4 @@ "use strict";

}
isEmberAddon() {
return this.plainPkg.isEmberAddon();
isEmberPackage() {
return this.plainPkg.isEmberPackage();
}

@@ -185,4 +185,4 @@ isEngine() {

}
isApp() {
return this.plainPkg.isApp();
isV2App() {
return this.plainPkg.isV2App();
}

@@ -192,5 +192,2 @@ isV2Addon() {

}
needsLooseResolving() {
return this.plainPkg.needsLooseResolving();
}
// it's important that we're calling this.dependencies here at this level, not

@@ -197,0 +194,0 @@ // plainPkg.dependencies, which wouldn't be correct

@@ -31,3 +31,3 @@ "use strict";

let owningPackage = _1.PackageCache.shared('embroider', state.opts.appRoot).ownerOfFile(filename);
if (!owningPackage || !owningPackage.needsLooseResolving()) {
if (!owningPackage || !owningPackage.isV2Ember() || !owningPackage.meta['auto-upgraded']) {
debug('not handling colocation for %s', filename);

@@ -34,0 +34,0 @@ return;

@@ -14,3 +14,7 @@ "use strict";

}
if ((0, fs_1.existsSync)((0, path_1.resolve)(appRoot, 'package.json'))) {
if (process.env.EMBROIDER_WORKING_DIRECTORY) {
let path = (0, path_1.resolve)(appRoot, process.env.EMBROIDER_WORKING_DIRECTORY);
return path;
}
else if ((0, fs_1.existsSync)((0, path_1.resolve)(appRoot, 'package.json'))) {
// the normal case

@@ -17,0 +21,0 @@ let path = (0, path_1.resolve)(appRoot, 'node_modules', '.embroider');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc