Grabbed dndbeyond's source code
``` ~/go/bin/sourcemapper -output ddb -jsurl https://media.dndbeyond.com/character-app/static/js/main.90aa78c5.js ```
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.assert = void 0;
|
||||
/** https://docs.tsafe.dev/assert */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function assert(condition, msg) {
|
||||
if (!condition) {
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
exports.assert = assert;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.capitalize = void 0;
|
||||
/** @see <https://docs.tsafe.dev/capitalize> */
|
||||
function capitalize(str) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (str.charAt(0).toUpperCase() + str.slice(1));
|
||||
}
|
||||
exports.capitalize = capitalize;
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.classnames = void 0;
|
||||
const assert_1 = require("./assert");
|
||||
const typeGuard_1 = require("./typeGuard");
|
||||
/** Copy pasted from
|
||||
* https://github.com/emotion-js/emotion/blob/23f43ab9f24d44219b0b007a00f4ac681fe8712e/packages/react/src/class-names.js#L17-L63
|
||||
**/
|
||||
const classnames = (args) => {
|
||||
const len = args.length;
|
||||
let i = 0;
|
||||
let cls = "";
|
||||
for (; i < len; i++) {
|
||||
const arg = args[i];
|
||||
if (arg == null)
|
||||
continue;
|
||||
let toAdd;
|
||||
switch (typeof arg) {
|
||||
case "boolean":
|
||||
break;
|
||||
case "object": {
|
||||
if (Array.isArray(arg)) {
|
||||
toAdd = (0, exports.classnames)(arg);
|
||||
}
|
||||
else {
|
||||
(0, assert_1.assert)(!(0, typeGuard_1.typeGuard)(arg, false));
|
||||
if (process.env.NODE_ENV !== "production" &&
|
||||
arg.styles !== undefined &&
|
||||
arg.name !== undefined) {
|
||||
console.error("You have passed styles created with `css` from `@emotion/react` package to the `cx`.\n" +
|
||||
"`cx` is meant to compose class names (strings) so you should convert those styles to a class name by passing them to the `css` received from <ClassNames/> component.");
|
||||
}
|
||||
toAdd = "";
|
||||
for (const k in arg) {
|
||||
if (arg[k] && k) {
|
||||
toAdd && (toAdd += " ");
|
||||
toAdd += k;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
toAdd = arg;
|
||||
}
|
||||
}
|
||||
if (toAdd) {
|
||||
cls && (cls += " ");
|
||||
cls += toAdd;
|
||||
}
|
||||
}
|
||||
return cls;
|
||||
};
|
||||
exports.classnames = classnames;
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getDependencyArrayRef = void 0;
|
||||
/**
|
||||
* useEffect(
|
||||
* ()=> { ... },
|
||||
* [ { "foo": "bar" } ]
|
||||
* )
|
||||
* => The callback will be invoked every render.
|
||||
* because { "foo": "bar" } is a new instance every render.
|
||||
*
|
||||
* useEffect(
|
||||
* ()=> { ... },
|
||||
* [ getDependencyArrayRef({ "foo": "bar" }) ]
|
||||
* );
|
||||
* => The callback will only be invoked once.
|
||||
*
|
||||
* The optimization will be enabled only if obj is
|
||||
* of the form Record<string, string | number | undefined | null>
|
||||
* overwise the object is returned (the function is the identity function).
|
||||
*/
|
||||
function getDependencyArrayRef(obj) {
|
||||
if (!(obj instanceof Object) || typeof obj === "function") {
|
||||
return obj;
|
||||
}
|
||||
const arr = [];
|
||||
for (const key in obj) {
|
||||
const value = obj[key];
|
||||
const typeofValue = typeof value;
|
||||
if (!(typeofValue === "string" ||
|
||||
(typeofValue === "number" && !isNaN(value)) ||
|
||||
typeofValue === "boolean" ||
|
||||
value === undefined ||
|
||||
value === null)) {
|
||||
return obj;
|
||||
}
|
||||
arr.push(`${key}:${typeofValue}_${value}`);
|
||||
}
|
||||
return "xSqLiJdLMd9s" + arr.join("|");
|
||||
}
|
||||
exports.getDependencyArrayRef = getDependencyArrayRef;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.objectKeys = void 0;
|
||||
/** Object.keys() with types */
|
||||
function objectKeys(o) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return Object.keys(o);
|
||||
}
|
||||
exports.objectKeys = objectKeys;
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.objectFromEntries = void 0;
|
||||
exports.objectFromEntries = !Object
|
||||
.fromEntries
|
||||
? (entries) => {
|
||||
if (!entries || !entries[Symbol.iterator]) {
|
||||
throw new Error("Object.fromEntries() requires a single iterable argument");
|
||||
}
|
||||
const o = {};
|
||||
Object.keys(entries).forEach(key => {
|
||||
const [k, v] = entries[key];
|
||||
o[k] = v;
|
||||
});
|
||||
return o;
|
||||
}
|
||||
: Object.fromEntries;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.typeGuard = void 0;
|
||||
/** https://docs.tsafe.dev/typeguard */
|
||||
function typeGuard(_value, isMatched) {
|
||||
return isMatched;
|
||||
}
|
||||
exports.typeGuard = typeGuard;
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.useGuaranteedMemo = void 0;
|
||||
const react_1 = require("react");
|
||||
/** Like react's useMemo but with guarantee that the fn
|
||||
* won't be invoked again if deps hasn't change */
|
||||
function useGuaranteedMemo(fn, deps) {
|
||||
const ref = (0, react_1.useRef)();
|
||||
if (!ref.current ||
|
||||
deps.length !== ref.current.prevDeps.length ||
|
||||
ref.current.prevDeps.map((v, i) => v === deps[i]).indexOf(false) >= 0) {
|
||||
ref.current = {
|
||||
"v": fn(),
|
||||
"prevDeps": [...deps],
|
||||
};
|
||||
}
|
||||
return ref.current.v;
|
||||
}
|
||||
exports.useGuaranteedMemo = useGuaranteedMemo;
|
||||
Reference in New Issue
Block a user