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,56 @@
/* global WebAssembly, crypto */
const {Environment, napi} = require('napi-wasm');
let env;
module.exports.init = async function init(input) {
if (env) return;
input = input ?? new URL('parcel_node_bindings.wasm', import.meta.url);
const {instance} = await WebAssembly.instantiateStreaming(fetch(input), {
env: {
...napi,
__getrandom_custom: (ptr, len) => {
let buf = env.memory.subarray(ptr, ptr + len);
crypto.getRandomValues(buf);
},
log: (ptr, len) => {
// eslint-disable-next-line no-console
console.log(env.getString(ptr, len));
},
},
});
// input =
// input ?? require('path').join(__dirname, 'parcel_node_bindings.wasm');
// const {instance} = await WebAssembly.instantiate(
// require('fs').readFileSync(input),
// {
// env: napi,
// },
// );
for (let key in instance.exports) {
if (key.startsWith('__napi_register__')) {
instance.exports[key]();
}
}
env = new Environment(instance);
for (let key in env.exports) {
if (key !== 'transform') {
module.exports[key] = env.exports[key];
}
}
module.exports.transform = function (config) {
let result = env.exports.transform(config);
return {
...result,
// Hydrate Uint8Array into Buffer
code: Buffer.from(result.code),
};
};
env.exports.initPanicHook();
};

View File

@@ -0,0 +1,79 @@
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export interface JsMacroError {
kind: number
message: string
}
export function findAncestorFile(filenames: Array<string>, from: string, root: string): string | null
export function findFirstFile(names: Array<string>): string | null
export function findNodeModule(module: string, from: string): string | null
export function hashString(s: string): string
export function hashBuffer(buf: Buffer): string
export function optimizeImage(kind: string, buf: Buffer): Buffer
export interface JsFileSystemOptions {
canonicalize: (...args: any[]) => any
read: (...args: any[]) => any
isFile: (...args: any[]) => any
isDir: (...args: any[]) => any
includeNodeModules?: NapiSideEffectsVariants
}
export interface FileSystem {
fs?: JsFileSystemOptions
includeNodeModules?: NapiSideEffectsVariants
conditions?: number
moduleDirResolver?: (...args: any[]) => any
mode: number
entries?: number
extensions?: Array<string>
packageExports: boolean
typescript?: boolean
}
export interface ResolveOptions {
filename: string
specifierType: string
parent: string
packageConditions?: Array<string>
}
export interface FilePathCreateInvalidation {
filePath: string
}
export interface FileNameCreateInvalidation {
fileName: string
aboveFilePath: string
}
export interface GlobCreateInvalidation {
glob: string
}
export interface ResolveResult {
resolution: unknown
invalidateOnFileChange: Array<string>
invalidateOnFileCreate: Array<FilePathCreateInvalidation | FileNameCreateInvalidation | GlobCreateInvalidation>
query?: string
sideEffects: boolean
error: unknown
moduleType: number
}
export interface JsInvalidations {
invalidateOnFileChange: Array<string>
invalidateOnFileCreate: Array<FilePathCreateInvalidation | FileNameCreateInvalidation | GlobCreateInvalidation>
invalidateOnStartup: boolean
}
export function transform(opts: object): unknown
export function transformAsync(opts: object): object
export class Hash {
constructor()
writeString(s: string): void
writeBuffer(buf: Buffer): void
finish(): string
}
export class Resolver {
constructor(projectRoot: string, options: FileSystem)
resolve(options: ResolveOptions): ResolveResult
resolveAsync(): object
resolveAsync(options: ResolveOptions): object
getInvalidations(path: string): JsInvalidations
getInvalidations(path: string): JsInvalidations
}

View File

@@ -0,0 +1,309 @@
/* tslint:disable */
/* eslint-disable */
/* prettier-ignore */
/* auto-generated by NAPI-RS */
const { existsSync, readFileSync } = require('fs')
const { join } = require('path')
const { platform, arch } = process
let nativeBinding = null
let localFileExisted = false
let loadError = null
function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== 'function') {
try {
const lddPath = require('child_process').execSync('which ldd').toString().trim()
return readFileSync(lddPath, 'utf8').includes('musl')
} catch (e) {
return true
}
} else {
const { glibcVersionRuntime } = process.report.getReport().header
return !glibcVersionRuntime
}
}
switch (platform) {
case 'android':
switch (arch) {
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'parcel-node-bindings.android-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.android-arm64.node')
} else {
nativeBinding = require('@parcel/rust-android-arm64')
}
} catch (e) {
loadError = e
}
break
case 'arm':
localFileExisted = existsSync(join(__dirname, 'parcel-node-bindings.android-arm-eabi.node'))
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.android-arm-eabi.node')
} else {
nativeBinding = require('@parcel/rust-android-arm-eabi')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Android ${arch}`)
}
break
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.win32-x64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.win32-x64-msvc.node')
} else {
nativeBinding = require('@parcel/rust-win32-x64-msvc')
}
} catch (e) {
loadError = e
}
break
case 'ia32':
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.win32-ia32-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.win32-ia32-msvc.node')
} else {
nativeBinding = require('@parcel/rust-win32-ia32-msvc')
}
} catch (e) {
loadError = e
}
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.win32-arm64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.win32-arm64-msvc.node')
} else {
nativeBinding = require('@parcel/rust-win32-arm64-msvc')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Windows: ${arch}`)
}
break
case 'darwin':
localFileExisted = existsSync(join(__dirname, 'parcel-node-bindings.darwin-universal.node'))
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.darwin-universal.node')
} else {
nativeBinding = require('@parcel/rust-darwin-universal')
}
break
} catch {}
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'parcel-node-bindings.darwin-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.darwin-x64.node')
} else {
nativeBinding = require('@parcel/rust-darwin-x64')
}
} catch (e) {
loadError = e
}
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.darwin-arm64.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.darwin-arm64.node')
} else {
nativeBinding = require('@parcel/rust-darwin-arm64')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on macOS: ${arch}`)
}
break
case 'freebsd':
if (arch !== 'x64') {
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
}
localFileExisted = existsSync(join(__dirname, 'parcel-node-bindings.freebsd-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.freebsd-x64.node')
} else {
nativeBinding = require('@parcel/rust-freebsd-x64')
}
} catch (e) {
loadError = e
}
break
case 'linux':
switch (arch) {
case 'x64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.linux-x64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.linux-x64-musl.node')
} else {
nativeBinding = require('@parcel/rust-linux-x64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.linux-x64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.linux-x64-gnu.node')
} else {
nativeBinding = require('@parcel/rust-linux-x64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 'arm64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.linux-arm64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.linux-arm64-musl.node')
} else {
nativeBinding = require('@parcel/rust-linux-arm64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.linux-arm64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.linux-arm64-gnu.node')
} else {
nativeBinding = require('@parcel/rust-linux-arm64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 'arm':
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@parcel/rust-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e
}
break
case 'riscv64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.linux-riscv64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.linux-riscv64-musl.node')
} else {
nativeBinding = require('@parcel/rust-linux-riscv64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.linux-riscv64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.linux-riscv64-gnu.node')
} else {
nativeBinding = require('@parcel/rust-linux-riscv64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 's390x':
localFileExisted = existsSync(
join(__dirname, 'parcel-node-bindings.linux-s390x-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parcel-node-bindings.linux-s390x-gnu.node')
} else {
nativeBinding = require('@parcel/rust-linux-s390x-gnu')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Linux: ${arch}`)
}
break
default:
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
}
if (!nativeBinding) {
if (loadError) {
throw loadError
}
throw new Error(`Failed to load native binding`)
}
const { findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, Resolver, transform, transformAsync } = nativeBinding
module.exports.findAncestorFile = findAncestorFile
module.exports.findFirstFile = findFirstFile
module.exports.findNodeModule = findNodeModule
module.exports.hashString = hashString
module.exports.hashBuffer = hashBuffer
module.exports.Hash = Hash
module.exports.optimizeImage = optimizeImage
module.exports.Resolver = Resolver
module.exports.transform = transform
module.exports.transformAsync = transformAsync

View File

@@ -0,0 +1,77 @@
// @flow
import type {FileCreateInvalidation} from '@parcel/types';
declare export var init: void | (() => void);
declare export function findAncestorFile(filenames: Array<string>, from: string, root: string): string | null
declare export function findFirstFile(names: Array<string>): string | null
declare export function findNodeModule(module: string, from: string): string | null
declare export function hashString(s: string): string
declare export function hashBuffer(buf: Buffer): string
declare export function optimizeImage(kind: string, buf: Buffer): Buffer
export interface JsFileSystemOptions {
canonicalize: string => string;
read: string => Buffer;
isFile: string => boolean;
isDir: string => boolean;
includeNodeModules?: boolean | Array<string> | {|[string]: boolean|};
}
export interface FileSystem {
fs?: JsFileSystemOptions,
includeNodeModules?: boolean | Array<string> | {|[string]: boolean|};
conditions?: number,
moduleDirResolver?: (...args: any[]) => any,
mode: number,
entries?: number,
extensions?: Array<string>,
packageExports: boolean
}
export interface ResolveOptions {
filename: string;
specifierType: string;
parent: string;
packageConditions?: Array<string>;
}
export type Resolution =
| {|type: 'Path', value: string|}
| {|type: 'Builtin', value: string|}
| {|type: 'External'|}
| {|type: 'Empty'|}
| {|type: 'Global', value: string|};
export interface ResolveResult {
resolution: Resolution;
invalidateOnFileChange: Array<string>;
invalidateOnFileCreate: Array<FileCreateInvalidation>;
query?: string;
sideEffects: boolean;
error: mixed;
moduleType: number;
}
export interface JsInvalidations {
invalidateOnFileChange: Array<string>;
invalidateOnFileCreate: Array<FileCreateInvalidation>;
invalidateOnStartup: boolean;
}
declare export function transform(opts: any): any;
declare export function transformAsync(opts: any): Promise<any>;
declare export class Hash {
writeString(s: string): void;
writeBuffer(b: Buffer): void;
finish(): string;
}
export interface ResolverOptions {
fs?: JsFileSystemOptions;
includeNodeModules?: boolean | Array<string> | {|[string]: boolean|};
conditions?: number;
moduleDirResolver?: (...args: any[]) => any;
mode: number;
entries?: number;
extensions?: Array<string>;
}
declare export class Resolver {
constructor(projectRoot: string, options: ResolverOptions): Resolver;
resolve(options: ResolveOptions): ResolveResult;
resolveAsync(options: ResolveOptions): Promise<ResolveResult>;
getInvalidations(path: string): JsInvalidations;
}

View File

@@ -0,0 +1,43 @@
{
"name": "@parcel/rust",
"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": "index.js",
"browser": "browser.js",
"napi": {
"name": "parcel-node-bindings"
},
"engines": {
"node": ">= 12.0.0"
},
"files": [
"browser.js",
"index.d.ts",
"index.js",
"index.js.flow",
"*.node",
"*.wasm"
],
"devDependencies": {
"@napi-rs/cli": "^2.15.2",
"napi-wasm": "^1.0.1"
},
"scripts": {
"build": "napi build --platform --cargo-cwd ../../../crates/node-bindings",
"build-release": "napi build --platform --release --cargo-cwd ../../../crates/node-bindings",
"wasm:build": "cargo build -p parcel-node-bindings --target wasm32-unknown-unknown && cp ../../../target/wasm32-unknown-unknown/debug/parcel_node_bindings.wasm .",
"wasm:build-release": "CARGO_PROFILE_RELEASE_LTO=true cargo build -p parcel-node-bindings --target wasm32-unknown-unknown --release && wasm-opt --strip-debug -O ../../../target/wasm32-unknown-unknown/release/parcel_node_bindings.wasm -o parcel_node_bindings.wasm"
},
"gitHead": "2059029ee91e5f03a273b0954d3e629d7375f986"
}