mirror of
https://github.com/SamEyeBam/animate.git
synced 2025-09-28 23:15:25 +00:00
larry babby and threejs for glsl
This commit is contained in:
106
webGl/my-threejs-test/node_modules/@parcel/transformer-image/lib/ImageTransformer.js
generated
vendored
Normal file
106
webGl/my-threejs-test/node_modules/@parcel/transformer-image/lib/ImageTransformer.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _validateConfig = require("./validateConfig");
|
||||
function _plugin() {
|
||||
const data = require("@parcel/plugin");
|
||||
_plugin = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _nullthrows() {
|
||||
const data = _interopRequireDefault(require("nullthrows"));
|
||||
_nullthrows = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _workers() {
|
||||
const data = _interopRequireDefault(require("@parcel/workers"));
|
||||
_workers = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _loadSharp = _interopRequireDefault(require("./loadSharp"));
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
// from https://github.com/lovell/sharp/blob/df7b8ba73808fc494be413e88cfb621b6279218c/lib/output.js#L6-L17
|
||||
const FORMATS = new Map([['jpeg', 'jpeg'], ['jpg', 'jpeg'], ['png', 'png'], ['webp', 'webp'], ['gif', 'gif'], ['tiff', 'tiff'], ['avif', 'avif'], ['heic', 'heif'], ['heif', 'heif']]);
|
||||
let isSharpLoadedOnMainThread = false;
|
||||
var _default = exports.default = new (_plugin().Transformer)({
|
||||
async loadConfig({
|
||||
config
|
||||
}) {
|
||||
let configFile = await config.getConfig(['sharp.config.json'],
|
||||
// '.sharprc', '.sharprc.json'
|
||||
{
|
||||
packageKey: 'sharp'
|
||||
});
|
||||
if (configFile !== null && configFile !== void 0 && configFile.contents) {
|
||||
(0, _validateConfig.validateConfig)(configFile.contents, configFile.filePath);
|
||||
return configFile.contents;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
async transform({
|
||||
config,
|
||||
asset,
|
||||
options
|
||||
}) {
|
||||
var _asset$query$get;
|
||||
asset.bundleBehavior = 'isolated';
|
||||
const originalFormat = FORMATS.get(asset.type);
|
||||
if (!originalFormat) {
|
||||
throw new Error(`The image transformer does not support ${asset.type} images.`);
|
||||
}
|
||||
const width = asset.query.has('width') ? parseInt(asset.query.get('width'), 10) : null;
|
||||
const height = asset.query.has('height') ? parseInt(asset.query.get('height'), 10) : null;
|
||||
const quality = asset.query.has('quality') ? parseInt(asset.query.get('quality'), 10) : config.quality;
|
||||
let targetFormat = (_asset$query$get = asset.query.get('as')) === null || _asset$query$get === void 0 ? void 0 : _asset$query$get.toLowerCase().trim();
|
||||
if (targetFormat && !FORMATS.has(targetFormat)) {
|
||||
throw new Error(`The image transformer does not support ${targetFormat} images.`);
|
||||
}
|
||||
const format = (0, _nullthrows().default)(FORMATS.get(targetFormat || originalFormat));
|
||||
const outputOptions = config[format];
|
||||
if (width || height || quality || targetFormat || outputOptions) {
|
||||
// Sharp must be required from the main thread as well to prevent errors when workers exit
|
||||
// See https://sharp.pixelplumbing.com/install#worker-threads and https://github.com/lovell/sharp/issues/2263
|
||||
if (_workers().default.isWorker() && !isSharpLoadedOnMainThread) {
|
||||
let api = _workers().default.getWorkerApi();
|
||||
await api.callMaster({
|
||||
location: __dirname + '/loadSharp.js',
|
||||
args: [options.packageManager, asset.filePath, options.shouldAutoInstall]
|
||||
});
|
||||
isSharpLoadedOnMainThread = true;
|
||||
}
|
||||
let inputBuffer = await asset.getBuffer();
|
||||
let sharp = await (0, _loadSharp.default)(options.packageManager, asset.filePath, options.shouldAutoInstall, true);
|
||||
let imagePipeline = sharp(inputBuffer, {
|
||||
animated: true
|
||||
});
|
||||
imagePipeline.withMetadata();
|
||||
if (width || height) {
|
||||
imagePipeline.resize(width, height);
|
||||
}
|
||||
imagePipeline.rotate();
|
||||
const normalizedOutputOptions = outputOptions || {};
|
||||
if (format === 'jpeg') {
|
||||
var _normalizedOutputOpti;
|
||||
normalizedOutputOptions.mozjpeg = (_normalizedOutputOpti = normalizedOutputOptions.mozjpeg) !== null && _normalizedOutputOpti !== void 0 ? _normalizedOutputOpti : true;
|
||||
}
|
||||
imagePipeline[format]({
|
||||
quality,
|
||||
...normalizedOutputOptions
|
||||
});
|
||||
asset.type = format;
|
||||
let buffer = await imagePipeline.toBuffer();
|
||||
asset.setBuffer(buffer);
|
||||
}
|
||||
return [asset];
|
||||
}
|
||||
});
|
15
webGl/my-threejs-test/node_modules/@parcel/transformer-image/lib/loadSharp.js
generated
vendored
Normal file
15
webGl/my-threejs-test/node_modules/@parcel/transformer-image/lib/loadSharp.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
const SHARP_RANGE = '^0.31.1';
|
||||
|
||||
// This is used to load sharp on the main thread, which prevents errors when worker threads exit
|
||||
// See https://sharp.pixelplumbing.com/install#worker-threads and https://github.com/lovell/sharp/issues/2263
|
||||
module.exports = async (packageManager, filePath, shouldAutoInstall, shouldReturn) => {
|
||||
let sharp = await packageManager.require('sharp', filePath, {
|
||||
range: SHARP_RANGE,
|
||||
shouldAutoInstall: shouldAutoInstall
|
||||
});
|
||||
if (shouldReturn) {
|
||||
return sharp;
|
||||
}
|
||||
};
|
265
webGl/my-threejs-test/node_modules/@parcel/transformer-image/lib/validateConfig.js
generated
vendored
Normal file
265
webGl/my-threejs-test/node_modules/@parcel/transformer-image/lib/validateConfig.js
generated
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.validateConfig = validateConfig;
|
||||
function _utils() {
|
||||
const data = require("@parcel/utils");
|
||||
_utils = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
// https://sharp.pixelplumbing.com/api-output#jpeg
|
||||
const JPEG_OUTPUT_SCHEMA = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
quality: {
|
||||
type: 'number'
|
||||
},
|
||||
progressive: {
|
||||
type: 'boolean'
|
||||
},
|
||||
chromaSubsampling: {
|
||||
type: 'string'
|
||||
},
|
||||
optimiseCoding: {
|
||||
type: 'boolean'
|
||||
},
|
||||
optimizeCoding: {
|
||||
type: 'boolean'
|
||||
},
|
||||
mozjpeg: {
|
||||
type: 'boolean'
|
||||
},
|
||||
trellisQuantisation: {
|
||||
type: 'boolean'
|
||||
},
|
||||
overshootDeringing: {
|
||||
type: 'boolean'
|
||||
},
|
||||
optimiseScans: {
|
||||
type: 'boolean'
|
||||
},
|
||||
optimizeScans: {
|
||||
type: 'boolean'
|
||||
},
|
||||
quantisationTable: {
|
||||
type: 'number'
|
||||
},
|
||||
quantizationTable: {
|
||||
type: 'number'
|
||||
},
|
||||
force: {
|
||||
type: 'boolean'
|
||||
}
|
||||
},
|
||||
additionalProperties: true
|
||||
};
|
||||
|
||||
// https://sharp.pixelplumbing.com/api-output#png
|
||||
const PNG_OUTPUT_SCHEMA = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
quality: {
|
||||
type: 'number'
|
||||
},
|
||||
progressive: {
|
||||
type: 'boolean'
|
||||
},
|
||||
compressionLevel: {
|
||||
type: 'number'
|
||||
},
|
||||
adaptiveFiltering: {
|
||||
type: 'boolean'
|
||||
},
|
||||
palette: {
|
||||
type: 'boolean'
|
||||
},
|
||||
colours: {
|
||||
type: 'number'
|
||||
},
|
||||
colors: {
|
||||
type: 'number'
|
||||
},
|
||||
dither: {
|
||||
type: 'number'
|
||||
},
|
||||
force: {
|
||||
type: 'boolean'
|
||||
}
|
||||
},
|
||||
additionalProperties: true
|
||||
};
|
||||
|
||||
// https://sharp.pixelplumbing.com/api-output#webp
|
||||
const WEBP_OUTPUT_SCHEMA = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
quality: {
|
||||
type: 'number'
|
||||
},
|
||||
alphaQuality: {
|
||||
type: 'number'
|
||||
},
|
||||
lossless: {
|
||||
type: 'boolean'
|
||||
},
|
||||
nearLossless: {
|
||||
type: 'boolean'
|
||||
},
|
||||
smartSubsample: {
|
||||
type: 'boolean'
|
||||
},
|
||||
reductionEffort: {
|
||||
type: 'number'
|
||||
},
|
||||
pageHeight: {
|
||||
type: 'number'
|
||||
},
|
||||
loop: {
|
||||
type: 'number'
|
||||
},
|
||||
delay: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'number'
|
||||
}
|
||||
},
|
||||
force: {
|
||||
type: 'boolean'
|
||||
}
|
||||
},
|
||||
additionalProperties: true
|
||||
};
|
||||
|
||||
// https://sharp.pixelplumbing.com/api-output#gif
|
||||
const GIF_OUTPUT_SCHEMA = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
pageHeight: {
|
||||
type: 'number'
|
||||
},
|
||||
loop: {
|
||||
type: 'number'
|
||||
},
|
||||
delay: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'number'
|
||||
}
|
||||
},
|
||||
force: {
|
||||
type: 'boolean'
|
||||
}
|
||||
},
|
||||
additionalProperties: true
|
||||
};
|
||||
|
||||
// https://sharp.pixelplumbing.com/api-output#tiff
|
||||
const TIFF_OUTPUT_SCHEMA = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
quality: {
|
||||
type: 'number'
|
||||
},
|
||||
force: {
|
||||
type: 'boolean'
|
||||
},
|
||||
compression: {
|
||||
type: 'string'
|
||||
},
|
||||
predictor: {
|
||||
type: 'string'
|
||||
},
|
||||
pyramid: {
|
||||
type: 'boolean'
|
||||
},
|
||||
tile: {
|
||||
type: 'boolean'
|
||||
},
|
||||
tileWidth: {
|
||||
type: 'number'
|
||||
},
|
||||
tileHeight: {
|
||||
type: 'number'
|
||||
},
|
||||
xres: {
|
||||
type: 'number'
|
||||
},
|
||||
yres: {
|
||||
type: 'number'
|
||||
},
|
||||
bitdepth: {
|
||||
type: 'number'
|
||||
}
|
||||
},
|
||||
additionalProperties: true
|
||||
};
|
||||
|
||||
// https://sharp.pixelplumbing.com/api-output#avif
|
||||
const AVIF_OUTPUT_SCHEMA = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
quality: {
|
||||
type: 'number'
|
||||
},
|
||||
lossless: {
|
||||
type: 'boolean'
|
||||
},
|
||||
speed: {
|
||||
type: 'number'
|
||||
},
|
||||
chromaSubsampling: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
additionalProperties: true
|
||||
};
|
||||
|
||||
// https://sharp.pixelplumbing.com/api-output#heif
|
||||
const HEIF_OUTPUT_SCHEMA = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
quality: {
|
||||
type: 'number'
|
||||
},
|
||||
compression: {
|
||||
type: 'string'
|
||||
},
|
||||
lossless: {
|
||||
type: 'boolean'
|
||||
},
|
||||
speed: {
|
||||
type: 'number'
|
||||
},
|
||||
chromaSubsampling: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
additionalProperties: true
|
||||
};
|
||||
const CONFIG_SCHEMA = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
// Fallback quality
|
||||
quality: {
|
||||
type: 'number'
|
||||
},
|
||||
jpeg: JPEG_OUTPUT_SCHEMA,
|
||||
png: PNG_OUTPUT_SCHEMA,
|
||||
webp: WEBP_OUTPUT_SCHEMA,
|
||||
gif: GIF_OUTPUT_SCHEMA,
|
||||
tiff: TIFF_OUTPUT_SCHEMA,
|
||||
avif: AVIF_OUTPUT_SCHEMA,
|
||||
heif: HEIF_OUTPUT_SCHEMA
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
function validateConfig(data, filePath) {
|
||||
_utils().validateSchema.diagnostic(CONFIG_SCHEMA, {
|
||||
data,
|
||||
filePath
|
||||
}, '@parcel/transformer-image', 'Invalid sharp config');
|
||||
}
|
Reference in New Issue
Block a user