larry babby and threejs for glsl

This commit is contained in:
Sam
2024-06-24 21:24:00 +12:00
parent 87d5dc634d
commit 907ebae4c0
6474 changed files with 1279596 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017-present Devon Govett
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,164 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _plugin() {
const data = require("@parcel/plugin");
_plugin = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _posthtml() {
const data = _interopRequireDefault(require("posthtml"));
_posthtml = function () {
return data;
};
return data;
}
function _posthtmlParser() {
const data = require("posthtml-parser");
_posthtmlParser = function () {
return data;
};
return data;
}
function _posthtmlRender() {
const data = require("posthtml-render");
_posthtmlRender = function () {
return data;
};
return data;
}
function _nullthrows() {
const data = _interopRequireDefault(require("nullthrows"));
_nullthrows = function () {
return data;
};
return data;
}
function _semver() {
const data = _interopRequireDefault(require("semver"));
_semver = function () {
return data;
};
return data;
}
var _loadPlugins = _interopRequireDefault(require("./loadPlugins"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = exports.default = new (_plugin().Transformer)({
async loadConfig({
config,
options,
logger
}) {
if (!config.isSource) {
return;
}
let configFile = await config.getConfig(['.posthtmlrc', '.posthtmlrc.js', '.posthtmlrc.cjs', '.posthtmlrc.mjs', 'posthtml.config.js', 'posthtml.config.cjs', 'posthtml.config.mjs'], {
packageKey: 'posthtml'
});
if (configFile) {
let isJavascript = _path().default.extname(configFile.filePath).endsWith('js');
if (isJavascript) {
// We have to invalidate on startup in case the config is non-deterministic,
// e.g. using unknown environment variables, reading from the filesystem, etc.
logger.warn({
message: 'WARNING: Using a JavaScript PostHTML config file means losing out on caching features of Parcel. Use a .posthtmlrc (JSON) file whenever possible.'
});
}
// Load plugins. This must be done before adding dev dependencies so we auto install.
let plugins = await (0, _loadPlugins.default)(configFile.contents.plugins, config.searchPath, options);
// Now add dev dependencies so we invalidate when they change.
let pluginArray = Array.isArray(configFile.contents.plugins) ? configFile.contents.plugins : Object.keys(configFile.contents.plugins);
for (let p of pluginArray) {
if (typeof p === 'string') {
config.addDevDependency({
specifier: p,
resolveFrom: configFile.filePath
});
}
}
configFile.contents.plugins = plugins;
// tells posthtml that we have already called parse
configFile.contents.skipParse = true;
delete configFile.contents.render;
return configFile.contents;
}
},
canReuseAST({
ast
}) {
return ast.type === 'posthtml' && _semver().default.satisfies(ast.version, '^0.4.0');
},
async parse({
asset,
config
}) {
// if we don't have a config it is posthtml is not configure, don't parse
if (!config) {
return;
}
return {
type: 'posthtml',
version: '0.4.1',
program: (0, _posthtmlParser().parser)(await asset.getCode(), {
lowerCaseAttributeNames: true,
sourceLocations: true,
xmlMode: asset.type === 'xhtml'
})
};
},
async transform({
asset,
config
}) {
if (!config) {
return [asset];
}
let ast = (0, _nullthrows().default)(await asset.getAST());
let res = await (0, _posthtml().default)(config.plugins).process(ast.program, {
...config,
plugins: config.plugins
});
if (res.messages) {
for (let {
type,
file: filePath
} of res.messages) {
if (type === 'dependency') {
asset.invalidateOnFileChange(filePath);
}
}
}
asset.setAST({
type: 'posthtml',
version: '0.4.1',
program: JSON.parse(JSON.stringify(res.tree)) // posthtml adds functions to the AST that are not serializable
});
return [asset];
},
generate({
ast,
asset
}) {
return {
content: (0, _posthtmlRender().render)(ast.program, {
closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined
})
};
}
});

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = loadExternalPlugins;
async function loadExternalPlugins(plugins, relative, options) {
if (Array.isArray(plugins)) {
return Promise.all(plugins.map(p => loadPlugin(p, relative, null, options.packageManager, options.shouldAutoInstall)).filter(Boolean));
} else if (typeof plugins === 'object') {
let mapPlugins = await Promise.all(Object.keys(plugins).map(p => loadPlugin(p, relative, plugins[p], options.packageManager, options.shouldAutoInstall)));
return mapPlugins.filter(Boolean);
} else {
return [];
}
}
async function loadPlugin(pluginArg, relative, options = {}, packageManager, shouldAutoInstall) {
if (typeof pluginArg !== 'string') {
return pluginArg;
}
let plugin = await packageManager.require(pluginArg, relative, {
shouldAutoInstall
});
plugin = plugin.default || plugin;
return plugin(options);
}

View File

@@ -0,0 +1,32 @@
{
"name": "@parcel/transformer-posthtml",
"version": "2.12.0",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
},
"repository": {
"type": "git",
"url": "https://github.com/parcel-bundler/parcel.git"
},
"main": "lib/PostHTMLTransformer.js",
"source": "src/PostHTMLTransformer.js",
"engines": {
"node": ">= 12.0.0",
"parcel": "^2.12.0"
},
"dependencies": {
"@parcel/plugin": "2.12.0",
"@parcel/utils": "2.12.0",
"nullthrows": "^1.1.1",
"posthtml": "^0.16.5",
"posthtml-parser": "^0.10.1",
"posthtml-render": "^3.0.0",
"semver": "^7.5.2"
},
"gitHead": "2059029ee91e5f03a273b0954d3e629d7375f986"
}

View File

@@ -0,0 +1,131 @@
// @flow
import {Transformer} from '@parcel/plugin';
import path from 'path';
import posthtml from 'posthtml';
import {parser as parse} from 'posthtml-parser';
import {render} from 'posthtml-render';
import nullthrows from 'nullthrows';
import semver from 'semver';
import loadPlugins from './loadPlugins';
export default (new Transformer({
async loadConfig({config, options, logger}) {
if (!config.isSource) {
return;
}
let configFile = await config.getConfig(
[
'.posthtmlrc',
'.posthtmlrc.js',
'.posthtmlrc.cjs',
'.posthtmlrc.mjs',
'posthtml.config.js',
'posthtml.config.cjs',
'posthtml.config.mjs',
],
{
packageKey: 'posthtml',
},
);
if (configFile) {
let isJavascript = path.extname(configFile.filePath).endsWith('js');
if (isJavascript) {
// We have to invalidate on startup in case the config is non-deterministic,
// e.g. using unknown environment variables, reading from the filesystem, etc.
logger.warn({
message:
'WARNING: Using a JavaScript PostHTML config file means losing out on caching features of Parcel. Use a .posthtmlrc (JSON) file whenever possible.',
});
}
// Load plugins. This must be done before adding dev dependencies so we auto install.
let plugins = await loadPlugins(
configFile.contents.plugins,
config.searchPath,
options,
);
// Now add dev dependencies so we invalidate when they change.
let pluginArray = Array.isArray(configFile.contents.plugins)
? configFile.contents.plugins
: Object.keys(configFile.contents.plugins);
for (let p of pluginArray) {
if (typeof p === 'string') {
config.addDevDependency({
specifier: p,
resolveFrom: configFile.filePath,
});
}
}
configFile.contents.plugins = plugins;
// tells posthtml that we have already called parse
configFile.contents.skipParse = true;
delete configFile.contents.render;
return configFile.contents;
}
},
canReuseAST({ast}) {
return ast.type === 'posthtml' && semver.satisfies(ast.version, '^0.4.0');
},
async parse({asset, config}) {
// if we don't have a config it is posthtml is not configure, don't parse
if (!config) {
return;
}
return {
type: 'posthtml',
version: '0.4.1',
program: parse(await asset.getCode(), {
lowerCaseAttributeNames: true,
sourceLocations: true,
xmlMode: asset.type === 'xhtml',
}),
};
},
async transform({asset, config}) {
if (!config) {
return [asset];
}
let ast = nullthrows(await asset.getAST());
let res = await posthtml(config.plugins).process(ast.program, {
...config,
plugins: config.plugins,
});
if (res.messages) {
for (let {type, file: filePath} of res.messages) {
if (type === 'dependency') {
asset.invalidateOnFileChange(filePath);
}
}
}
asset.setAST({
type: 'posthtml',
version: '0.4.1',
program: JSON.parse(JSON.stringify(res.tree)), // posthtml adds functions to the AST that are not serializable
});
return [asset];
},
generate({ast, asset}) {
return {
content: render(ast.program, {
closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined,
}),
};
},
}): Transformer);

View File

@@ -0,0 +1,62 @@
// @flow
import type {FilePath, PluginOptions} from '@parcel/types';
import type {PackageManager} from '@parcel/package-manager';
export default async function loadExternalPlugins(
plugins: Array<string> | {+[pluginName: string]: mixed, ...},
relative: FilePath,
options: PluginOptions,
): Promise<Array<mixed>> {
if (Array.isArray(plugins)) {
return Promise.all(
plugins
.map(p =>
loadPlugin(
p,
relative,
null,
options.packageManager,
options.shouldAutoInstall,
),
)
.filter(Boolean),
);
} else if (typeof plugins === 'object') {
let _plugins = plugins;
let mapPlugins = await Promise.all(
Object.keys(plugins).map(p =>
loadPlugin(
p,
relative,
_plugins[p],
options.packageManager,
options.shouldAutoInstall,
),
),
);
return mapPlugins.filter(Boolean);
} else {
return [];
}
}
async function loadPlugin(
pluginArg: string | Function,
relative: FilePath,
options: mixed = {},
packageManager: PackageManager,
shouldAutoInstall: boolean,
): mixed {
if (typeof pluginArg !== 'string') {
return pluginArg;
}
let plugin = await packageManager.require(pluginArg, relative, {
shouldAutoInstall,
});
plugin = plugin.default || plugin;
return plugin(options);
}