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

@fastkit/color-scheme

Package Overview
Dependencies
Maintainers
1
Versions
213
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastkit/color-scheme - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

165

dist/tool/index.js

@@ -8,6 +8,6 @@ 'use strict';

var eta = require('eta');
var esbuild = require('esbuild');
var nodeUtil = require('@fastkit/node-util');
var chokidar = require('chokidar');
var tinyLogger = require('@fastkit/tiny-logger');
var color = require('@fastkit/color');
var chokidar = require('chokidar');

@@ -18,8 +18,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }

var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
var esbuild__default = /*#__PURE__*/_interopDefaultLegacy(esbuild);
var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar);
const name$1 = 'color-scheme';
new tinyLogger.TinyLogger(name$1);
const ColorSchemeError = tinyLogger.createTinyError(name$1);
const name = 'color-scheme';
new tinyLogger.TinyLogger(name);
const ColorSchemeError = tinyLogger.createTinyError(name);

@@ -568,155 +567,5 @@ function createBucket(modelName, values, ctx, _getter, _toJSON) {

async function resolveEntryPoint(rawEntryPoint, extensions = ['ts', 'js']) {
const { ext, base } = path__default.parse(rawEntryPoint);
if (ext) {
return base;
}
if (await pathExists(rawEntryPoint, 'dir')) {
for (const _ext of extensions) {
const indexPath = path__default.join(rawEntryPoint, `index.${_ext}`);
if (await pathExists(indexPath, 'file')) {
return indexPath;
}
}
}
for (const _ext of extensions) {
const targetPath = `${rawEntryPoint}.${_ext}`;
if (await pathExists(targetPath, 'file')) {
return targetPath;
}
}
return rawEntryPoint;
}
async function findPackageDir(from = process.cwd()) {
let result;
if (await pathExists(from, 'file')) {
from = path__default.dirname(from);
}
while (true) {
const target = path__default.join(from, 'package.json');
try {
const pkg = require(target);
if (pkg) {
result = from;
break;
}
}
catch (err) {
if (!err.message.startsWith('Cannot find module')) {
throw err;
}
}
const next = path__default.dirname(from);
if (next === from) {
break;
}
from = next;
}
return result;
}
async function pathExists(filepath, type) {
try {
const stat = await fs__default.stat(filepath);
if (type === 'file')
return stat.isFile();
if (type === 'dir')
return stat.isDirectory();
return true;
}
catch (err) {
if (err.code === 'ENOENT')
return false;
throw err;
}
}
const name = 'node-util';
new tinyLogger.TinyLogger(name);
const NodeUtilError = tinyLogger.createTinyError(name);
const nativeNodeModulesPlugin = {
name: 'native-node-modules',
setup(build) {
// If a ".node" file is imported within a module in the "file" namespace, resolve
// it to an absolute path and put it into the "node-file" virtual namespace.
build.onResolve({ filter: /\.node$/, namespace: 'file' }, (args) => ({
path: require.resolve(args.path, { paths: [args.resolveDir] }),
namespace: 'node-file',
}));
// Files in the "node-file" virtual namespace call "require()" on the
// path from esbuild of the ".node" file in the output directory.
build.onLoad({ filter: /.*/, namespace: 'node-file' }, (args) => ({
contents: `
import path from ${JSON.stringify(args.path)}
try { module.exports = require(path) }
catch {}
`,
}));
// If a ".node" file is imported within a module in the "node-file" namespace, put
// it in the "file" namespace where esbuild's default loading behavior will handle
// it. It is already an absolute path since we resolved it to one above.
build.onResolve({ filter: /\.node$/, namespace: 'node-file' }, (args) => ({
path: args.path,
namespace: 'file',
}));
// Tell esbuild's default loading behavior to use the "file" loader for
// these ".node" files.
const opts = build.initialOptions;
opts.loader = opts.loader || {};
opts.loader['.node'] = 'file';
},
};
async function esbuildRequire(rawEntryPoint, filename) {
const entryPoint = await resolveEntryPoint(rawEntryPoint);
if (!filename) {
const { name, ext } = path__default.parse(entryPoint);
filename = name + (ext || '.js');
}
else {
filename = path__default.parse(filename).base;
}
const pkgDir = await findPackageDir();
if (!pkgDir)
throw new NodeUtilError('missing package.');
const tsconfig = path__default.join(pkgDir, 'tsconfig.json');
const cacheName = entryPoint.replace(/\//g, '_');
const cacheDir = path__default.join(pkgDir, 'node_modules/.esbuild-require', cacheName);
const outfile = path__default.join(cacheDir, 'index.js');
const buildResult = await esbuild__default.build({
// outfile
entryPoints: [entryPoint],
bundle: true,
tsconfig,
platform: 'node',
// write: false,
metafile: true,
logLevel: 'info',
// external: ['module'],
plugins: [nativeNodeModulesPlugin],
outfile,
});
const { metafile } = buildResult;
let m = undefined;
try {
m = require(outfile);
}
catch (err) {
throw err;
}
delete require.cache[outfile];
const dependencies = [];
const inputs = metafile && metafile.inputs;
if (inputs) {
dependencies.push(...Object.keys(inputs));
}
return {
entryPoint,
exports: m,
dependencies,
};
}
const TEMPLATES_DIR = path__default.resolve(__dirname, 'assets/templates');
async function loadColorScheme(rawEntryPoint, dest) {
const { entryPoint, exports: exportsResult, dependencies, } = await esbuildRequire(rawEntryPoint);
const { entryPoint, exports: exportsResult, dependencies, } = await nodeUtil.esbuildRequire(rawEntryPoint);
const { name: entryName } = path__default.parse(entryPoint);

@@ -814,3 +663,3 @@ // const cachePathPrefix = entryDir.replace(/\//g, '_') + '_';

if (!_dest) {
const pkgDir = await color.findPackageDir();
const pkgDir = await nodeUtil.findPackageDir();
if (!pkgDir)

@@ -817,0 +666,0 @@ throw new ColorSchemeError('missing package.json');

12

package.json
{
"name": "@fastkit/color-scheme",
"version": "0.1.7",
"version": "0.1.8",
"description": "@fastkit/color-scheme",

@@ -30,8 +30,8 @@ "buildOptions": {

"dependencies": {
"@fastkit/node-util": "0.1.7",
"@fastkit/color": "0.1.7",
"@fastkit/tiny-logger": "0.1.7",
"fs-extra": "^9.1.0",
"eta": "^1.12.1"
"@fastkit/node-util": "0.1.8",
"@fastkit/color": "0.1.8",
"@fastkit/tiny-logger": "0.1.8",
"fs-extra": "^0.1.0",
"eta": "^0.1.0"
}
}

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