mirror of
https://github.com/SamEyeBam/animate.git
synced 2025-09-27 22:45:25 +00:00
larry babby and threejs for glsl
This commit is contained in:
51
webGl/my-threejs-test/node_modules/@parcel/packager-wasm/lib/WasmPackager.js
generated
vendored
Normal file
51
webGl/my-threejs-test/node_modules/@parcel/packager-wasm/lib/WasmPackager.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _assert() {
|
||||
const data = _interopRequireDefault(require("assert"));
|
||||
_assert = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _plugin() {
|
||||
const data = require("@parcel/plugin");
|
||||
_plugin = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var wasmmap = _interopRequireWildcard(require("./wasm-sourcemap"));
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
var _default = exports.default = new (_plugin().Packager)({
|
||||
async package({
|
||||
bundle,
|
||||
getSourceMapReference
|
||||
}) {
|
||||
let assets = [];
|
||||
bundle.traverseAssets(asset => {
|
||||
assets.push(asset);
|
||||
});
|
||||
_assert().default.equal(assets.length, 1, 'Wasm bundles must only contain one asset');
|
||||
let [contents, map] = await Promise.all([assets[0].getBuffer(), assets[0].getMap()]);
|
||||
let sourcemapReference = await getSourceMapReference(map);
|
||||
if (sourcemapReference != null) {
|
||||
return {
|
||||
contents: Buffer.from(wasmmap.SetSourceMapURL(contents, sourcemapReference, sourcemapReference.includes('HASH_REF_') ?
|
||||
// HASH_REF_\w{16} -> \w{8}
|
||||
sourcemapReference.length - (9 + 16 - 8) : undefined)),
|
||||
map
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
contents,
|
||||
map
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
166
webGl/my-threejs-test/node_modules/@parcel/packager-wasm/lib/wasm-sourcemap.js
generated
vendored
Normal file
166
webGl/my-threejs-test/node_modules/@parcel/packager-wasm/lib/wasm-sourcemap.js
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
"use strict";
|
||||
|
||||
/* eslint-disable */
|
||||
// Modified version of https://github.com/oasislabs/wasm-sourcemap/blob/77242f93ebd010cf69515d988b984244a119dd9d/index.js
|
||||
|
||||
// Modifications Copyright 2019 Oasis Labs
|
||||
// Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
// provided that the following conditions are met:
|
||||
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
// and the following disclaimer.
|
||||
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
// conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
|
||||
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
const url = require('url');
|
||||
const section = 'sourceMappingURL';
|
||||
|
||||
// read a variable uint encoding from the buffer stream.
|
||||
// return the int, and the next position in the stream.
|
||||
function read_uint(buf, pos) {
|
||||
let n = 0;
|
||||
let shift = 0;
|
||||
let b = buf[pos];
|
||||
let outpos = pos + 1;
|
||||
while (b >= 128) {
|
||||
n = n | b - 128 << shift;
|
||||
b = buf[outpos];
|
||||
outpos++;
|
||||
shift += 7;
|
||||
}
|
||||
return [n + (b << shift), outpos];
|
||||
}
|
||||
|
||||
// Write a buffer with a variable uint encoding of a number.
|
||||
function encode_uint(n) {
|
||||
let result = [];
|
||||
while (n > 127) {
|
||||
result.push(128 | n & 127);
|
||||
n = n >> 7;
|
||||
}
|
||||
result.push(n);
|
||||
return new Uint8Array(result);
|
||||
}
|
||||
function ab2str(buf) {
|
||||
let str = '';
|
||||
let bytes = new Uint8Array(buf);
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
str += String.fromCharCode(bytes[i]);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function str2ab(str) {
|
||||
let bytes = new Uint8Array(str.length);
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
bytes[i] = str[i].charCodeAt(0);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an array buffer representing a WASM 0-id
|
||||
* sections containing a given name and value pair.
|
||||
* @param {String} name
|
||||
* @param {String} value
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
function WriteSection(name, value, valLenOverride) {
|
||||
const nameBuf = str2ab(name);
|
||||
const valBuf = str2ab(value);
|
||||
const nameLen = encode_uint(nameBuf.length);
|
||||
const valLen = encode_uint(valLenOverride !== null && valLenOverride !== void 0 ? valLenOverride : valBuf.length);
|
||||
const sectionLenDeclared = nameLen.length + nameBuf.length + valLen.length + (valLenOverride !== null && valLenOverride !== void 0 ? valLenOverride : valBuf.length);
|
||||
const sectionLenActual = nameLen.length + nameBuf.length + valLen.length + valBuf.length;
|
||||
const headerLen = encode_uint(sectionLenDeclared);
|
||||
let bytes = new Uint8Array(sectionLenActual + headerLen.length + 1);
|
||||
let pos = 1;
|
||||
bytes.set(headerLen, pos);
|
||||
pos += headerLen.length;
|
||||
bytes.set(nameLen, pos);
|
||||
pos += nameLen.length;
|
||||
bytes.set(nameBuf, pos);
|
||||
pos += nameBuf.length;
|
||||
bytes.set(valLen, pos);
|
||||
pos += valLen.length;
|
||||
bytes.set(valBuf, pos);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the module sections of a WASM buffer to find
|
||||
* a section with a given identifier.
|
||||
* @param {Buffer} buf
|
||||
* @param {String} id
|
||||
* @returns {Array.<Number>} An array with the index of
|
||||
* the section, the length of the section, and the index
|
||||
* of the beginning of the body of the section.
|
||||
*/
|
||||
function FindSection(buf, id) {
|
||||
let pos = 8;
|
||||
while (pos < buf.byteLength) {
|
||||
const sec_start = pos;
|
||||
const [sec_id, pos2] = read_uint(buf, pos);
|
||||
const [sec_size, body_pos] = read_uint(buf, pos2);
|
||||
pos = body_pos + sec_size;
|
||||
if (sec_id == 0) {
|
||||
const [name_len, name_pos] = read_uint(buf, body_pos);
|
||||
const name = buf.slice(name_pos, name_pos + name_len);
|
||||
const nameString = ab2str(name);
|
||||
if (nameString == id) {
|
||||
return [sec_start, sec_size + 1 + (body_pos - pos2), name_pos + name_len];
|
||||
}
|
||||
}
|
||||
}
|
||||
return [-1, null, null];
|
||||
}
|
||||
module.exports = {
|
||||
/**
|
||||
* GetSourceMapURL extracts the source map from a WASM buffer.
|
||||
* @param {Buffer} buf The WASM buffer
|
||||
* @returns {String|null} The linked sourcemap URL if present.
|
||||
*/
|
||||
GetSourceMapURL: function (buf) {
|
||||
buf = new Uint8Array(buf);
|
||||
const [sec_start, _, uri_start] = FindSection(buf, section);
|
||||
if (sec_start == -1) {
|
||||
return null;
|
||||
}
|
||||
const [uri_len, uri_pos] = read_uint(buf, uri_start);
|
||||
return ab2str(buf.slice(uri_pos, uri_pos + uri_len));
|
||||
},
|
||||
RemoveSourceMapURL: function (buf) {
|
||||
buf = new Uint8Array(buf);
|
||||
const [sec_start, sec_size, _] = FindSection(buf, section);
|
||||
if (sec_start == -1) {
|
||||
return buf;
|
||||
}
|
||||
let strippedBuf = new Uint8Array(buf.length - sec_size);
|
||||
strippedBuf.set(buf.slice(0, sec_start));
|
||||
strippedBuf.set(buf.slice(sec_start + sec_size), sec_start);
|
||||
return strippedBuf;
|
||||
},
|
||||
SetSourceMapURL: function (buf, url, urlLenOverride) {
|
||||
const stripped = module.exports.RemoveSourceMapURL(buf);
|
||||
const newSection = WriteSection(section, url, urlLenOverride);
|
||||
const outBuf = new Uint8Array(stripped.length + newSection.length);
|
||||
outBuf.set(stripped);
|
||||
outBuf.set(newSection, stripped.length);
|
||||
return outBuf;
|
||||
},
|
||||
SetSourceMapURLRelativeTo: function (buf, relativeURL) {
|
||||
const originalURL = module.exports.GetSourceMapURL(buf);
|
||||
const newURL = url.resolve(relativeURL, originalURL);
|
||||
return module.exports.SetSourceMapURL(buf, newURL);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user