mirror of
https://github.com/mivodev/mivodev.github.io.git
synced 2026-01-26 21:41:53 +07:00
Fix dependencies: Add flag-icons, tailwind directives, and postcss config
This commit is contained in:
2
node_modules/superjson/dist/accessDeep.d.ts
generated
vendored
Normal file
2
node_modules/superjson/dist/accessDeep.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare const getDeep: (object: object, path: (string | number)[]) => object;
|
||||
export declare const setDeep: (object: any, path: (string | number)[], mapper: (v: any) => any) => any;
|
||||
123
node_modules/superjson/dist/accessDeep.js
generated
vendored
Normal file
123
node_modules/superjson/dist/accessDeep.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
import { isMap, isArray, isPlainObject, isSet } from './is.js';
|
||||
import { includes } from './util.js';
|
||||
const getNthKey = (value, n) => {
|
||||
if (n > value.size)
|
||||
throw new Error('index out of bounds');
|
||||
const keys = value.keys();
|
||||
while (n > 0) {
|
||||
keys.next();
|
||||
n--;
|
||||
}
|
||||
return keys.next().value;
|
||||
};
|
||||
function validatePath(path) {
|
||||
if (includes(path, '__proto__')) {
|
||||
throw new Error('__proto__ is not allowed as a property');
|
||||
}
|
||||
if (includes(path, 'prototype')) {
|
||||
throw new Error('prototype is not allowed as a property');
|
||||
}
|
||||
if (includes(path, 'constructor')) {
|
||||
throw new Error('constructor is not allowed as a property');
|
||||
}
|
||||
}
|
||||
export const getDeep = (object, path) => {
|
||||
validatePath(path);
|
||||
for (let i = 0; i < path.length; i++) {
|
||||
const key = path[i];
|
||||
if (isSet(object)) {
|
||||
object = getNthKey(object, +key);
|
||||
}
|
||||
else if (isMap(object)) {
|
||||
const row = +key;
|
||||
const type = +path[++i] === 0 ? 'key' : 'value';
|
||||
const keyOfRow = getNthKey(object, row);
|
||||
switch (type) {
|
||||
case 'key':
|
||||
object = keyOfRow;
|
||||
break;
|
||||
case 'value':
|
||||
object = object.get(keyOfRow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
object = object[key];
|
||||
}
|
||||
}
|
||||
return object;
|
||||
};
|
||||
export const setDeep = (object, path, mapper) => {
|
||||
validatePath(path);
|
||||
if (path.length === 0) {
|
||||
return mapper(object);
|
||||
}
|
||||
let parent = object;
|
||||
for (let i = 0; i < path.length - 1; i++) {
|
||||
const key = path[i];
|
||||
if (isArray(parent)) {
|
||||
const index = +key;
|
||||
parent = parent[index];
|
||||
}
|
||||
else if (isPlainObject(parent)) {
|
||||
parent = parent[key];
|
||||
}
|
||||
else if (isSet(parent)) {
|
||||
const row = +key;
|
||||
parent = getNthKey(parent, row);
|
||||
}
|
||||
else if (isMap(parent)) {
|
||||
const isEnd = i === path.length - 2;
|
||||
if (isEnd) {
|
||||
break;
|
||||
}
|
||||
const row = +key;
|
||||
const type = +path[++i] === 0 ? 'key' : 'value';
|
||||
const keyOfRow = getNthKey(parent, row);
|
||||
switch (type) {
|
||||
case 'key':
|
||||
parent = keyOfRow;
|
||||
break;
|
||||
case 'value':
|
||||
parent = parent.get(keyOfRow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const lastKey = path[path.length - 1];
|
||||
if (isArray(parent)) {
|
||||
parent[+lastKey] = mapper(parent[+lastKey]);
|
||||
}
|
||||
else if (isPlainObject(parent)) {
|
||||
parent[lastKey] = mapper(parent[lastKey]);
|
||||
}
|
||||
if (isSet(parent)) {
|
||||
const oldValue = getNthKey(parent, +lastKey);
|
||||
const newValue = mapper(oldValue);
|
||||
if (oldValue !== newValue) {
|
||||
parent.delete(oldValue);
|
||||
parent.add(newValue);
|
||||
}
|
||||
}
|
||||
if (isMap(parent)) {
|
||||
const row = +path[path.length - 2];
|
||||
const keyToRow = getNthKey(parent, row);
|
||||
const type = +lastKey === 0 ? 'key' : 'value';
|
||||
switch (type) {
|
||||
case 'key': {
|
||||
const newKey = mapper(keyToRow);
|
||||
parent.set(newKey, parent.get(keyToRow));
|
||||
if (newKey !== keyToRow) {
|
||||
parent.delete(keyToRow);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'value': {
|
||||
parent.set(keyToRow, mapper(parent.get(keyToRow)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return object;
|
||||
};
|
||||
//# sourceMappingURL=accessDeep.js.map
|
||||
1
node_modules/superjson/dist/accessDeep.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/accessDeep.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"accessDeep.js","sourceRoot":"","sources":["../src/accessDeep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,SAAS,GAAG,CAAC,KAA+B,EAAE,CAAS,EAAO,EAAE;IACpE,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC1B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,CAAC,EAAE,CAAC;IACN,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;AAC3B,CAAC,CAAC;AAEF,SAAS,YAAY,CAAC,IAAyB;IAC7C,IAAI,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CA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AG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAEzC,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;oBACxB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAC1B,CAAC;gBACD,MAAM;YACR,CAAC;YAED,KAAK,OAAO,CAAC,CAAC,CAAC;gBACb,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACnD,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
||||
12
node_modules/superjson/dist/class-registry.d.ts
generated
vendored
Normal file
12
node_modules/superjson/dist/class-registry.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Registry } from './registry.js';
|
||||
import { Class } from './types.js';
|
||||
export interface RegisterOptions {
|
||||
identifier?: string;
|
||||
allowProps?: string[];
|
||||
}
|
||||
export declare class ClassRegistry extends Registry<Class> {
|
||||
constructor();
|
||||
private classToAllowedProps;
|
||||
register(value: Class, options?: string | RegisterOptions): void;
|
||||
getAllowedProps(value: Class): string[] | undefined;
|
||||
}
|
||||
22
node_modules/superjson/dist/class-registry.js
generated
vendored
Normal file
22
node_modules/superjson/dist/class-registry.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Registry } from './registry.js';
|
||||
export class ClassRegistry extends Registry {
|
||||
constructor() {
|
||||
super(c => c.name);
|
||||
this.classToAllowedProps = new Map();
|
||||
}
|
||||
register(value, options) {
|
||||
if (typeof options === 'object') {
|
||||
if (options.allowProps) {
|
||||
this.classToAllowedProps.set(value, options.allowProps);
|
||||
}
|
||||
super.register(value, options.identifier);
|
||||
}
|
||||
else {
|
||||
super.register(value, options);
|
||||
}
|
||||
}
|
||||
getAllowedProps(value) {
|
||||
return this.classToAllowedProps.get(value);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=class-registry.js.map
|
||||
1
node_modules/superjson/dist/class-registry.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/class-registry.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"class-registry.js","sourceRoot":"","sources":["../src/class-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQzC,MAAM,OAAO,aAAc,SAAQ,QAAe;IAChD;QACE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAGb,wBAAmB,GAAG,IAAI,GAAG,EAAmB,CAAC;IAFzD,CAAC;IAID,QAAQ,CAAC,KAAY,EAAE,OAAkC;QACvD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;YAC1D,CAAC;YAED,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,eAAe,CAAC,KAAY;QAC1B,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
||||
13
node_modules/superjson/dist/custom-transformer-registry.d.ts
generated
vendored
Normal file
13
node_modules/superjson/dist/custom-transformer-registry.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { JSONValue } from './types.js';
|
||||
export interface CustomTransfomer<I, O extends JSONValue> {
|
||||
name: string;
|
||||
isApplicable: (v: any) => v is I;
|
||||
serialize: (v: I) => O;
|
||||
deserialize: (v: O) => I;
|
||||
}
|
||||
export declare class CustomTransformerRegistry {
|
||||
private transfomers;
|
||||
register<I, O extends JSONValue>(transformer: CustomTransfomer<I, O>): void;
|
||||
findApplicable<T>(v: T): CustomTransfomer<T, JSONValue> | undefined;
|
||||
findByName(name: string): CustomTransfomer<any, any>;
|
||||
}
|
||||
16
node_modules/superjson/dist/custom-transformer-registry.js
generated
vendored
Normal file
16
node_modules/superjson/dist/custom-transformer-registry.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { find } from './util.js';
|
||||
export class CustomTransformerRegistry {
|
||||
constructor() {
|
||||
this.transfomers = {};
|
||||
}
|
||||
register(transformer) {
|
||||
this.transfomers[transformer.name] = transformer;
|
||||
}
|
||||
findApplicable(v) {
|
||||
return find(this.transfomers, transformer => transformer.isApplicable(v));
|
||||
}
|
||||
findByName(name) {
|
||||
return this.transfomers[name];
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=custom-transformer-registry.js.map
|
||||
1
node_modules/superjson/dist/custom-transformer-registry.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/custom-transformer-registry.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"custom-transformer-registry.js","sourceRoot":"","sources":["../src/custom-transformer-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AASjC,MAAM,OAAO,yBAAyB;IAAtC;QACU,gBAAW,GAA+C,EAAE,CAAC;IAevE,CAAC;IAbC,QAAQ,CAAyB,WAAmC;QAClE,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IACnD,CAAC;IAED,cAAc,CAAI,CAAI;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,CAC1C,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CACkB,CAAC;IAClD,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF"}
|
||||
8
node_modules/superjson/dist/double-indexed-kv.d.ts
generated
vendored
Normal file
8
node_modules/superjson/dist/double-indexed-kv.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export declare class DoubleIndexedKV<K, V> {
|
||||
keyToValue: Map<K, V>;
|
||||
valueToKey: Map<V, K>;
|
||||
set(key: K, value: V): void;
|
||||
getByKey(key: K): V | undefined;
|
||||
getByValue(value: V): K | undefined;
|
||||
clear(): void;
|
||||
}
|
||||
21
node_modules/superjson/dist/double-indexed-kv.js
generated
vendored
Normal file
21
node_modules/superjson/dist/double-indexed-kv.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export class DoubleIndexedKV {
|
||||
constructor() {
|
||||
this.keyToValue = new Map();
|
||||
this.valueToKey = new Map();
|
||||
}
|
||||
set(key, value) {
|
||||
this.keyToValue.set(key, value);
|
||||
this.valueToKey.set(value, key);
|
||||
}
|
||||
getByKey(key) {
|
||||
return this.keyToValue.get(key);
|
||||
}
|
||||
getByValue(value) {
|
||||
return this.valueToKey.get(value);
|
||||
}
|
||||
clear() {
|
||||
this.keyToValue.clear();
|
||||
this.valueToKey.clear();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=double-indexed-kv.js.map
|
||||
1
node_modules/superjson/dist/double-indexed-kv.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/double-indexed-kv.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"double-indexed-kv.js","sourceRoot":"","sources":["../src/double-indexed-kv.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IAA5B;QACE,eAAU,GAAG,IAAI,GAAG,EAAQ,CAAC;QAC7B,eAAU,GAAG,IAAI,GAAG,EAAQ,CAAC;IAmB/B,CAAC;IAjBC,GAAG,CAAC,GAAM,EAAE,KAAQ;QAClB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,QAAQ,CAAC,GAAM;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,UAAU,CAAC,KAAQ;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
||||
52
node_modules/superjson/dist/index.d.ts
generated
vendored
Normal file
52
node_modules/superjson/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Class, JSONValue, SuperJSONResult, SuperJSONValue } from './types.js';
|
||||
import { ClassRegistry, RegisterOptions } from './class-registry.js';
|
||||
import { Registry } from './registry.js';
|
||||
import { CustomTransfomer, CustomTransformerRegistry } from './custom-transformer-registry.js';
|
||||
export default class SuperJSON {
|
||||
/**
|
||||
* If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
|
||||
*/
|
||||
private readonly dedupe;
|
||||
/**
|
||||
* @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
|
||||
*/
|
||||
constructor({ dedupe, }?: {
|
||||
dedupe?: boolean;
|
||||
});
|
||||
serialize(object: SuperJSONValue): SuperJSONResult;
|
||||
deserialize<T = unknown>(payload: SuperJSONResult, options?: {
|
||||
inPlace?: boolean;
|
||||
}): T;
|
||||
stringify(object: SuperJSONValue): string;
|
||||
parse<T = unknown>(string: string): T;
|
||||
readonly classRegistry: ClassRegistry;
|
||||
registerClass(v: Class, options?: RegisterOptions | string): void;
|
||||
readonly symbolRegistry: Registry<Symbol>;
|
||||
registerSymbol(v: Symbol, identifier?: string): void;
|
||||
readonly customTransformerRegistry: CustomTransformerRegistry;
|
||||
registerCustom<I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, 'name'>, name: string): void;
|
||||
readonly allowedErrorProps: string[];
|
||||
allowErrorProps(...props: string[]): void;
|
||||
private static defaultInstance;
|
||||
static serialize: (object: SuperJSONValue) => SuperJSONResult;
|
||||
static deserialize: <T = unknown>(payload: SuperJSONResult, options?: {
|
||||
inPlace?: boolean;
|
||||
}) => T;
|
||||
static stringify: (object: SuperJSONValue) => string;
|
||||
static parse: <T = unknown>(string: string) => T;
|
||||
static registerClass: (v: Class, options?: RegisterOptions | string) => void;
|
||||
static registerSymbol: (v: Symbol, identifier?: string) => void;
|
||||
static registerCustom: <I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, "name">, name: string) => void;
|
||||
static allowErrorProps: (...props: string[]) => void;
|
||||
}
|
||||
export { SuperJSON, SuperJSONResult, SuperJSONValue };
|
||||
export declare const serialize: (object: SuperJSONValue) => SuperJSONResult;
|
||||
export declare const deserialize: <T = unknown>(payload: SuperJSONResult, options?: {
|
||||
inPlace?: boolean;
|
||||
}) => T;
|
||||
export declare const stringify: (object: SuperJSONValue) => string;
|
||||
export declare const parse: <T = unknown>(string: string) => T;
|
||||
export declare const registerClass: (v: Class, options?: RegisterOptions | string) => void;
|
||||
export declare const registerCustom: <I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, "name">, name: string) => void;
|
||||
export declare const registerSymbol: (v: Symbol, identifier?: string) => void;
|
||||
export declare const allowErrorProps: (...props: string[]) => void;
|
||||
92
node_modules/superjson/dist/index.js
generated
vendored
Normal file
92
node_modules/superjson/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
import { ClassRegistry } from './class-registry.js';
|
||||
import { Registry } from './registry.js';
|
||||
import { CustomTransformerRegistry, } from './custom-transformer-registry.js';
|
||||
import { applyReferentialEqualityAnnotations, applyValueAnnotations, generateReferentialEqualityAnnotations, walker, } from './plainer.js';
|
||||
import { copy } from 'copy-anything';
|
||||
class SuperJSON {
|
||||
/**
|
||||
* @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
|
||||
*/
|
||||
constructor({ dedupe = false, } = {}) {
|
||||
this.classRegistry = new ClassRegistry();
|
||||
this.symbolRegistry = new Registry(s => s.description ?? '');
|
||||
this.customTransformerRegistry = new CustomTransformerRegistry();
|
||||
this.allowedErrorProps = [];
|
||||
this.dedupe = dedupe;
|
||||
}
|
||||
serialize(object) {
|
||||
const identities = new Map();
|
||||
const output = walker(object, identities, this, this.dedupe);
|
||||
const res = {
|
||||
json: output.transformedValue,
|
||||
};
|
||||
if (output.annotations) {
|
||||
res.meta = {
|
||||
...res.meta,
|
||||
values: output.annotations,
|
||||
};
|
||||
}
|
||||
const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
|
||||
if (equalityAnnotations) {
|
||||
res.meta = {
|
||||
...res.meta,
|
||||
referentialEqualities: equalityAnnotations,
|
||||
};
|
||||
}
|
||||
if (res.meta)
|
||||
res.meta.v = 1;
|
||||
return res;
|
||||
}
|
||||
deserialize(payload, options) {
|
||||
const { json, meta } = payload;
|
||||
let result = options?.inPlace ? json : copy(json);
|
||||
if (meta?.values) {
|
||||
result = applyValueAnnotations(result, meta.values, meta.v ?? 0, this);
|
||||
}
|
||||
if (meta?.referentialEqualities) {
|
||||
result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities, meta.v ?? 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
stringify(object) {
|
||||
return JSON.stringify(this.serialize(object));
|
||||
}
|
||||
parse(string) {
|
||||
return this.deserialize(JSON.parse(string), { inPlace: true });
|
||||
}
|
||||
registerClass(v, options) {
|
||||
this.classRegistry.register(v, options);
|
||||
}
|
||||
registerSymbol(v, identifier) {
|
||||
this.symbolRegistry.register(v, identifier);
|
||||
}
|
||||
registerCustom(transformer, name) {
|
||||
this.customTransformerRegistry.register({
|
||||
name,
|
||||
...transformer,
|
||||
});
|
||||
}
|
||||
allowErrorProps(...props) {
|
||||
this.allowedErrorProps.push(...props);
|
||||
}
|
||||
}
|
||||
SuperJSON.defaultInstance = new SuperJSON();
|
||||
SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
|
||||
SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
|
||||
SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
|
||||
SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
|
||||
SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
|
||||
SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
|
||||
SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
|
||||
SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
|
||||
export default SuperJSON;
|
||||
export { SuperJSON };
|
||||
export const serialize = SuperJSON.serialize;
|
||||
export const deserialize = SuperJSON.deserialize;
|
||||
export const stringify = SuperJSON.stringify;
|
||||
export const parse = SuperJSON.parse;
|
||||
export const registerClass = SuperJSON.registerClass;
|
||||
export const registerCustom = SuperJSON.registerCustom;
|
||||
export const registerSymbol = SuperJSON.registerSymbol;
|
||||
export const allowErrorProps = SuperJSON.allowErrorProps;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/superjson/dist/index.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAmB,MAAM,qBAAqB,CAAC;AACr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AC;AAEtD,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;AAC7C,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;AAEjD,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;AAC7C,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;AAErC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;AACrD,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,cAAc,CAAC;AACvD,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,cAAc,CAAC;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC"}
|
||||
24
node_modules/superjson/dist/is.d.ts
generated
vendored
Normal file
24
node_modules/superjson/dist/is.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
export declare const isUndefined: (payload: any) => payload is undefined;
|
||||
export declare const isNull: (payload: any) => payload is null;
|
||||
export declare const isPlainObject: (payload: any) => payload is {
|
||||
[key: string]: any;
|
||||
};
|
||||
export declare const isEmptyObject: (payload: any) => payload is {};
|
||||
export declare const isArray: (payload: any) => payload is any[];
|
||||
export declare const isString: (payload: any) => payload is string;
|
||||
export declare const isNumber: (payload: any) => payload is number;
|
||||
export declare const isBoolean: (payload: any) => payload is boolean;
|
||||
export declare const isRegExp: (payload: any) => payload is RegExp;
|
||||
export declare const isMap: (payload: any) => payload is Map<any, any>;
|
||||
export declare const isSet: (payload: any) => payload is Set<any>;
|
||||
export declare const isSymbol: (payload: any) => payload is symbol;
|
||||
export declare const isDate: (payload: any) => payload is Date;
|
||||
export declare const isError: (payload: any) => payload is Error;
|
||||
export declare const isNaNValue: (payload: any) => payload is typeof NaN;
|
||||
export declare const isPrimitive: (payload: any) => payload is boolean | null | undefined | number | string | symbol;
|
||||
export declare const isBigint: (payload: any) => payload is bigint;
|
||||
export declare const isInfinite: (payload: any) => payload is number;
|
||||
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
|
||||
export type TypedArray = InstanceType<TypedArrayConstructor>;
|
||||
export declare const isTypedArray: (payload: any) => payload is TypedArray;
|
||||
export declare const isURL: (payload: any) => payload is URL;
|
||||
35
node_modules/superjson/dist/is.js
generated
vendored
Normal file
35
node_modules/superjson/dist/is.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
const getType = (payload) => Object.prototype.toString.call(payload).slice(8, -1);
|
||||
export const isUndefined = (payload) => typeof payload === 'undefined';
|
||||
export const isNull = (payload) => payload === null;
|
||||
export const isPlainObject = (payload) => {
|
||||
if (typeof payload !== 'object' || payload === null)
|
||||
return false;
|
||||
if (payload === Object.prototype)
|
||||
return false;
|
||||
if (Object.getPrototypeOf(payload) === null)
|
||||
return true;
|
||||
return Object.getPrototypeOf(payload) === Object.prototype;
|
||||
};
|
||||
export const isEmptyObject = (payload) => isPlainObject(payload) && Object.keys(payload).length === 0;
|
||||
export const isArray = (payload) => Array.isArray(payload);
|
||||
export const isString = (payload) => typeof payload === 'string';
|
||||
export const isNumber = (payload) => typeof payload === 'number' && !isNaN(payload);
|
||||
export const isBoolean = (payload) => typeof payload === 'boolean';
|
||||
export const isRegExp = (payload) => payload instanceof RegExp;
|
||||
export const isMap = (payload) => payload instanceof Map;
|
||||
export const isSet = (payload) => payload instanceof Set;
|
||||
export const isSymbol = (payload) => getType(payload) === 'Symbol';
|
||||
export const isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
|
||||
export const isError = (payload) => payload instanceof Error;
|
||||
export const isNaNValue = (payload) => typeof payload === 'number' && isNaN(payload);
|
||||
export const isPrimitive = (payload) => isBoolean(payload) ||
|
||||
isNull(payload) ||
|
||||
isUndefined(payload) ||
|
||||
isNumber(payload) ||
|
||||
isString(payload) ||
|
||||
isSymbol(payload);
|
||||
export const isBigint = (payload) => typeof payload === 'bigint';
|
||||
export const isInfinite = (payload) => payload === Infinity || payload === -Infinity;
|
||||
export const isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
|
||||
export const isURL = (payload) => payload instanceof URL;
|
||||
//# sourceMappingURL=is.js.map
|
||||
1
node_modules/superjson/dist/is.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/is.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is.js","sourceRoot":"","sources":["../src/is.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,CAAC,OAAY,EAAU,EAAE,CACvC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAY,EAAwB,EAAE,CAChE,OAAO,OAAO,KAAK,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAY,EAAmB,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC;AAE1E,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAAY,EACuB,EAAE;IACrC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClE,IAAI,OAAO,KAAK,MAAM,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC/C,IAAI,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEzD,OAAO,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAY,EAAiB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G,CAAC,OAAY,EAAyB,EAAE,CAChE,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAY,EACsD,EAAE,CACpE,SAAS,CAAC,OAAO,CAAC;IAClB,MAAM,CAAC,OAAO,CAAC;IACf,WAAW,CAAC,OAAO,CAAC;IACpB,QAAQ,CAAC,OAAO,CAAC;IACjB,QAAQ,CAAC,OAAO,CAAC;IACjB,QAAQ,CAAC,OAAO,CAAC,CAAC;AAEpB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAY,EAAqB,EAAE,CAC1D,OAAO,OAAO,KAAK,QAAQ,CAAC;AAE9B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAY,EAAqB,EAAE,CAC5D,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,QAAQ,CAAC;AAehD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAY,EAAyB,EAAE,CAClE,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,YAAY,QAAQ,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAY,EAAkB,EAAE,CAAC,OAAO,YAAY,GAAG,CAAC"}
|
||||
6
node_modules/superjson/dist/pathstringifier.d.ts
generated
vendored
Normal file
6
node_modules/superjson/dist/pathstringifier.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export type StringifiedPath = string;
|
||||
type Path = string[];
|
||||
export declare const escapeKey: (key: string) => string;
|
||||
export declare const stringifyPath: (path: Path) => StringifiedPath;
|
||||
export declare const parsePath: (string: StringifiedPath, legacyPaths: boolean) => string[];
|
||||
export {};
|
||||
40
node_modules/superjson/dist/pathstringifier.js
generated
vendored
Normal file
40
node_modules/superjson/dist/pathstringifier.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
export const escapeKey = (key) => key.replace(/\\/g, '\\\\').replace(/\./g, '\\.');
|
||||
export const stringifyPath = (path) => path
|
||||
.map(String)
|
||||
.map(escapeKey)
|
||||
.join('.');
|
||||
export const parsePath = (string, legacyPaths) => {
|
||||
const result = [];
|
||||
let segment = '';
|
||||
for (let i = 0; i < string.length; i++) {
|
||||
let char = string.charAt(i);
|
||||
if (!legacyPaths && char === '\\') {
|
||||
const escaped = string.charAt(i + 1);
|
||||
if (escaped === '\\') {
|
||||
segment += '\\';
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
else if (escaped !== '.') {
|
||||
throw Error('invalid path');
|
||||
}
|
||||
}
|
||||
const isEscapedDot = char === '\\' && string.charAt(i + 1) === '.';
|
||||
if (isEscapedDot) {
|
||||
segment += '.';
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
const isEndOfSegment = char === '.';
|
||||
if (isEndOfSegment) {
|
||||
result.push(segment);
|
||||
segment = '';
|
||||
continue;
|
||||
}
|
||||
segment += char;
|
||||
}
|
||||
const lastSegment = segment;
|
||||
result.push(lastSegment);
|
||||
return result;
|
||||
};
|
||||
//# sourceMappingURL=pathstringifier.js.map
|
||||
1
node_modules/superjson/dist/pathstringifier.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/pathstringifier.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pathstringifier.js","sourceRoot":"","sources":["../src/pathstringifier.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CACvC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAU,EAAmB,EAAE,CAC3D,IAAI;KACD,GAAG,CAAC,MAAM,CAAC;KACX,GAAG,CAAC,SAAS,CAAC;KACd,IAAI,CAAC,GAAG,CAAC,CAAC;AAEf,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AChB,CAAC,CAAC"}
|
||||
16
node_modules/superjson/dist/plainer.d.ts
generated
vendored
Normal file
16
node_modules/superjson/dist/plainer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TypeAnnotation } from './transformer.js';
|
||||
import SuperJSON from './index.js';
|
||||
type Tree<T> = InnerNode<T> | Leaf<T>;
|
||||
type Leaf<T> = [T];
|
||||
type InnerNode<T> = [T, Record<string, Tree<T>>];
|
||||
export type MinimisedTree<T> = Tree<T> | Record<string, Tree<T>> | undefined;
|
||||
export declare function applyValueAnnotations(plain: any, annotations: MinimisedTree<TypeAnnotation>, version: number, superJson: SuperJSON): any;
|
||||
export declare function applyReferentialEqualityAnnotations(plain: any, annotations: ReferentialEqualityAnnotations, version: number): any;
|
||||
interface Result {
|
||||
transformedValue: any;
|
||||
annotations?: MinimisedTree<TypeAnnotation>;
|
||||
}
|
||||
export type ReferentialEqualityAnnotations = Record<string, string[]> | [string[]] | [string[], Record<string, string[]>];
|
||||
export declare function generateReferentialEqualityAnnotations(identitites: Map<any, any[][]>, dedupe: boolean): ReferentialEqualityAnnotations | undefined;
|
||||
export declare const walker: (object: any, identities: Map<any, any[][]>, superJson: SuperJSON, dedupe: boolean, path?: any[], objectsInThisPath?: any[], seenObjects?: Map<unknown, Result>) => Result;
|
||||
export {};
|
||||
185
node_modules/superjson/dist/plainer.js
generated
vendored
Normal file
185
node_modules/superjson/dist/plainer.js
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
import { isArray, isEmptyObject, isError, isMap, isPlainObject, isPrimitive, isSet, } from './is.js';
|
||||
import { escapeKey, stringifyPath } from './pathstringifier.js';
|
||||
import { isInstanceOfRegisteredClass, transformValue, untransformValue, } from './transformer.js';
|
||||
import { includes, forEach } from './util.js';
|
||||
import { parsePath } from './pathstringifier.js';
|
||||
import { getDeep, setDeep } from './accessDeep.js';
|
||||
const enableLegacyPaths = (version) => version < 1;
|
||||
function traverse(tree, walker, version, origin = []) {
|
||||
if (!tree) {
|
||||
return;
|
||||
}
|
||||
const legacyPaths = enableLegacyPaths(version);
|
||||
if (!isArray(tree)) {
|
||||
forEach(tree, (subtree, key) => traverse(subtree, walker, version, [
|
||||
...origin,
|
||||
...parsePath(key, legacyPaths),
|
||||
]));
|
||||
return;
|
||||
}
|
||||
const [nodeValue, children] = tree;
|
||||
if (children) {
|
||||
forEach(children, (child, key) => {
|
||||
traverse(child, walker, version, [
|
||||
...origin,
|
||||
...parsePath(key, legacyPaths),
|
||||
]);
|
||||
});
|
||||
}
|
||||
walker(nodeValue, origin);
|
||||
}
|
||||
export function applyValueAnnotations(plain, annotations, version, superJson) {
|
||||
traverse(annotations, (type, path) => {
|
||||
plain = setDeep(plain, path, v => untransformValue(v, type, superJson));
|
||||
}, version);
|
||||
return plain;
|
||||
}
|
||||
export function applyReferentialEqualityAnnotations(plain, annotations, version) {
|
||||
const legacyPaths = enableLegacyPaths(version);
|
||||
function apply(identicalPaths, path) {
|
||||
const object = getDeep(plain, parsePath(path, legacyPaths));
|
||||
identicalPaths
|
||||
.map(path => parsePath(path, legacyPaths))
|
||||
.forEach(identicalObjectPath => {
|
||||
plain = setDeep(plain, identicalObjectPath, () => object);
|
||||
});
|
||||
}
|
||||
if (isArray(annotations)) {
|
||||
const [root, other] = annotations;
|
||||
root.forEach(identicalPath => {
|
||||
plain = setDeep(plain, parsePath(identicalPath, legacyPaths), () => plain);
|
||||
});
|
||||
if (other) {
|
||||
forEach(other, apply);
|
||||
}
|
||||
}
|
||||
else {
|
||||
forEach(annotations, apply);
|
||||
}
|
||||
return plain;
|
||||
}
|
||||
const isDeep = (object, superJson) => isPlainObject(object) ||
|
||||
isArray(object) ||
|
||||
isMap(object) ||
|
||||
isSet(object) ||
|
||||
isError(object) ||
|
||||
isInstanceOfRegisteredClass(object, superJson);
|
||||
function addIdentity(object, path, identities) {
|
||||
const existingSet = identities.get(object);
|
||||
if (existingSet) {
|
||||
existingSet.push(path);
|
||||
}
|
||||
else {
|
||||
identities.set(object, [path]);
|
||||
}
|
||||
}
|
||||
export function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
||||
const result = {};
|
||||
let rootEqualityPaths = undefined;
|
||||
identitites.forEach(paths => {
|
||||
if (paths.length <= 1) {
|
||||
return;
|
||||
}
|
||||
// if we're not deduping, all of these objects continue existing.
|
||||
// putting the shortest path first makes it easier to parse for humans
|
||||
// if we're deduping though, only the first entry will still exist, so we can't do this optimisation.
|
||||
if (!dedupe) {
|
||||
paths = paths
|
||||
.map(path => path.map(String))
|
||||
.sort((a, b) => a.length - b.length);
|
||||
}
|
||||
const [representativePath, ...identicalPaths] = paths;
|
||||
if (representativePath.length === 0) {
|
||||
rootEqualityPaths = identicalPaths.map(stringifyPath);
|
||||
}
|
||||
else {
|
||||
result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
|
||||
}
|
||||
});
|
||||
if (rootEqualityPaths) {
|
||||
if (isEmptyObject(result)) {
|
||||
return [rootEqualityPaths];
|
||||
}
|
||||
else {
|
||||
return [rootEqualityPaths, result];
|
||||
}
|
||||
}
|
||||
else {
|
||||
return isEmptyObject(result) ? undefined : result;
|
||||
}
|
||||
}
|
||||
export const walker = (object, identities, superJson, dedupe, path = [], objectsInThisPath = [], seenObjects = new Map()) => {
|
||||
const primitive = isPrimitive(object);
|
||||
if (!primitive) {
|
||||
addIdentity(object, path, identities);
|
||||
const seen = seenObjects.get(object);
|
||||
if (seen) {
|
||||
// short-circuit result if we've seen this object before
|
||||
return dedupe
|
||||
? {
|
||||
transformedValue: null,
|
||||
}
|
||||
: seen;
|
||||
}
|
||||
}
|
||||
if (!isDeep(object, superJson)) {
|
||||
const transformed = transformValue(object, superJson);
|
||||
const result = transformed
|
||||
? {
|
||||
transformedValue: transformed.value,
|
||||
annotations: [transformed.type],
|
||||
}
|
||||
: {
|
||||
transformedValue: object,
|
||||
};
|
||||
if (!primitive) {
|
||||
seenObjects.set(object, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (includes(objectsInThisPath, object)) {
|
||||
// prevent circular references
|
||||
return {
|
||||
transformedValue: null,
|
||||
};
|
||||
}
|
||||
const transformationResult = transformValue(object, superJson);
|
||||
const transformed = transformationResult?.value ?? object;
|
||||
const transformedValue = isArray(transformed) ? [] : {};
|
||||
const innerAnnotations = {};
|
||||
forEach(transformed, (value, index) => {
|
||||
if (index === '__proto__' ||
|
||||
index === 'constructor' ||
|
||||
index === 'prototype') {
|
||||
throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
|
||||
}
|
||||
const recursiveResult = walker(value, identities, superJson, dedupe, [...path, index], [...objectsInThisPath, object], seenObjects);
|
||||
transformedValue[index] = recursiveResult.transformedValue;
|
||||
if (isArray(recursiveResult.annotations)) {
|
||||
innerAnnotations[escapeKey(index)] = recursiveResult.annotations;
|
||||
}
|
||||
else if (isPlainObject(recursiveResult.annotations)) {
|
||||
forEach(recursiveResult.annotations, (tree, key) => {
|
||||
innerAnnotations[escapeKey(index) + '.' + key] = tree;
|
||||
});
|
||||
}
|
||||
});
|
||||
const result = isEmptyObject(innerAnnotations)
|
||||
? {
|
||||
transformedValue,
|
||||
annotations: !!transformationResult
|
||||
? [transformationResult.type]
|
||||
: undefined,
|
||||
}
|
||||
: {
|
||||
transformedValue,
|
||||
annotations: !!transformationResult
|
||||
? [transformationResult.type, innerAnnotations]
|
||||
: innerAnnotations,
|
||||
};
|
||||
if (!primitive) {
|
||||
seenObjects.set(object, result);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
//# sourceMappingURL=plainer.js.map
|
||||
1
node_modules/superjson/dist/plainer.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/plainer.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/superjson/dist/registry.d.ts
generated
vendored
Normal file
9
node_modules/superjson/dist/registry.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export declare class Registry<T> {
|
||||
private readonly generateIdentifier;
|
||||
private kv;
|
||||
constructor(generateIdentifier: (v: T) => string);
|
||||
register(value: T, identifier?: string): void;
|
||||
clear(): void;
|
||||
getIdentifier(value: T): string | undefined;
|
||||
getValue(identifier: string): T | undefined;
|
||||
}
|
||||
26
node_modules/superjson/dist/registry.js
generated
vendored
Normal file
26
node_modules/superjson/dist/registry.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { DoubleIndexedKV } from './double-indexed-kv.js';
|
||||
export class Registry {
|
||||
constructor(generateIdentifier) {
|
||||
this.generateIdentifier = generateIdentifier;
|
||||
this.kv = new DoubleIndexedKV();
|
||||
}
|
||||
register(value, identifier) {
|
||||
if (this.kv.getByValue(value)) {
|
||||
return;
|
||||
}
|
||||
if (!identifier) {
|
||||
identifier = this.generateIdentifier(value);
|
||||
}
|
||||
this.kv.set(identifier, value);
|
||||
}
|
||||
clear() {
|
||||
this.kv.clear();
|
||||
}
|
||||
getIdentifier(value) {
|
||||
return this.kv.getByValue(value);
|
||||
}
|
||||
getValue(identifier) {
|
||||
return this.kv.getByKey(identifier);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=registry.js.map
|
||||
1
node_modules/superjson/dist/registry.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/registry.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,OAAO,QAAQ;IAGnB,YAA6B,kBAAoC;QAApC,uBAAkB,GAAlB,kBAAkB,CAAkB;QAFzD,OAAE,GAAG,IAAI,eAAe,EAAa,CAAC;IAEsB,CAAC;IAErE,QAAQ,CAAC,KAAQ,EAAE,UAAmB;QACpC,IAAI,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IAED,aAAa,CAAC,KAAQ;QACpB,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ,CAAC,UAAkB;QACzB,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;CACF"}
|
||||
17
node_modules/superjson/dist/transformer.d.ts
generated
vendored
Normal file
17
node_modules/superjson/dist/transformer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import SuperJSON from './index.js';
|
||||
export type PrimitiveTypeAnnotation = 'number' | 'undefined' | 'bigint';
|
||||
type LeafTypeAnnotation = PrimitiveTypeAnnotation | 'regexp' | 'Date' | 'URL';
|
||||
type TypedArrayAnnotation = ['typed-array', string];
|
||||
type ClassTypeAnnotation = ['class', string];
|
||||
type SymbolTypeAnnotation = ['symbol', string];
|
||||
type CustomTypeAnnotation = ['custom', string];
|
||||
type SimpleTypeAnnotation = LeafTypeAnnotation | 'map' | 'set' | 'Error';
|
||||
type CompositeTypeAnnotation = TypedArrayAnnotation | ClassTypeAnnotation | SymbolTypeAnnotation | CustomTypeAnnotation;
|
||||
export type TypeAnnotation = SimpleTypeAnnotation | CompositeTypeAnnotation;
|
||||
export declare function isInstanceOfRegisteredClass(potentialClass: any, superJson: SuperJSON): potentialClass is any;
|
||||
export declare const transformValue: (value: any, superJson: SuperJSON) => {
|
||||
value: any;
|
||||
type: TypeAnnotation;
|
||||
} | undefined;
|
||||
export declare const untransformValue: (json: any, type: TypeAnnotation, superJson: SuperJSON) => any;
|
||||
export {};
|
||||
200
node_modules/superjson/dist/transformer.js
generated
vendored
Normal file
200
node_modules/superjson/dist/transformer.js
generated
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
import { isBigint, isDate, isInfinite, isMap, isNaNValue, isRegExp, isSet, isUndefined, isSymbol, isArray, isError, isTypedArray, isURL, } from './is.js';
|
||||
import { findArr } from './util.js';
|
||||
function simpleTransformation(isApplicable, annotation, transform, untransform) {
|
||||
return {
|
||||
isApplicable,
|
||||
annotation,
|
||||
transform,
|
||||
untransform,
|
||||
};
|
||||
}
|
||||
const simpleRules = [
|
||||
simpleTransformation(isUndefined, 'undefined', () => null, () => undefined),
|
||||
simpleTransformation(isBigint, 'bigint', v => v.toString(), v => {
|
||||
if (typeof BigInt !== 'undefined') {
|
||||
return BigInt(v);
|
||||
}
|
||||
console.error('Please add a BigInt polyfill.');
|
||||
return v;
|
||||
}),
|
||||
simpleTransformation(isDate, 'Date', v => v.toISOString(), v => new Date(v)),
|
||||
simpleTransformation(isError, 'Error', (v, superJson) => {
|
||||
const baseError = {
|
||||
name: v.name,
|
||||
message: v.message,
|
||||
};
|
||||
if ('cause' in v) {
|
||||
baseError.cause = v.cause;
|
||||
}
|
||||
superJson.allowedErrorProps.forEach(prop => {
|
||||
baseError[prop] = v[prop];
|
||||
});
|
||||
return baseError;
|
||||
}, (v, superJson) => {
|
||||
const e = new Error(v.message, { cause: v.cause });
|
||||
e.name = v.name;
|
||||
e.stack = v.stack;
|
||||
superJson.allowedErrorProps.forEach(prop => {
|
||||
e[prop] = v[prop];
|
||||
});
|
||||
return e;
|
||||
}),
|
||||
simpleTransformation(isRegExp, 'regexp', v => '' + v, regex => {
|
||||
const body = regex.slice(1, regex.lastIndexOf('/'));
|
||||
const flags = regex.slice(regex.lastIndexOf('/') + 1);
|
||||
return new RegExp(body, flags);
|
||||
}),
|
||||
simpleTransformation(isSet, 'set',
|
||||
// (sets only exist in es6+)
|
||||
// eslint-disable-next-line es5/no-es6-methods
|
||||
v => [...v.values()], v => new Set(v)),
|
||||
simpleTransformation(isMap, 'map', v => [...v.entries()], v => new Map(v)),
|
||||
simpleTransformation((v) => isNaNValue(v) || isInfinite(v), 'number', v => {
|
||||
if (isNaNValue(v)) {
|
||||
return 'NaN';
|
||||
}
|
||||
if (v > 0) {
|
||||
return 'Infinity';
|
||||
}
|
||||
else {
|
||||
return '-Infinity';
|
||||
}
|
||||
}, Number),
|
||||
simpleTransformation((v) => v === 0 && 1 / v === -Infinity, 'number', () => {
|
||||
return '-0';
|
||||
}, Number),
|
||||
simpleTransformation(isURL, 'URL', v => v.toString(), v => new URL(v)),
|
||||
];
|
||||
function compositeTransformation(isApplicable, annotation, transform, untransform) {
|
||||
return {
|
||||
isApplicable,
|
||||
annotation,
|
||||
transform,
|
||||
untransform,
|
||||
};
|
||||
}
|
||||
const symbolRule = compositeTransformation((s, superJson) => {
|
||||
if (isSymbol(s)) {
|
||||
const isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
|
||||
return isRegistered;
|
||||
}
|
||||
return false;
|
||||
}, (s, superJson) => {
|
||||
const identifier = superJson.symbolRegistry.getIdentifier(s);
|
||||
return ['symbol', identifier];
|
||||
}, v => v.description, (_, a, superJson) => {
|
||||
const value = superJson.symbolRegistry.getValue(a[1]);
|
||||
if (!value) {
|
||||
throw new Error('Trying to deserialize unknown symbol');
|
||||
}
|
||||
return value;
|
||||
});
|
||||
const constructorToName = [
|
||||
Int8Array,
|
||||
Uint8Array,
|
||||
Int16Array,
|
||||
Uint16Array,
|
||||
Int32Array,
|
||||
Uint32Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
Uint8ClampedArray,
|
||||
].reduce((obj, ctor) => {
|
||||
obj[ctor.name] = ctor;
|
||||
return obj;
|
||||
}, {});
|
||||
const typedArrayRule = compositeTransformation(isTypedArray, v => ['typed-array', v.constructor.name], v => [...v], (v, a) => {
|
||||
const ctor = constructorToName[a[1]];
|
||||
if (!ctor) {
|
||||
throw new Error('Trying to deserialize unknown typed array');
|
||||
}
|
||||
return new ctor(v);
|
||||
});
|
||||
export function isInstanceOfRegisteredClass(potentialClass, superJson) {
|
||||
if (potentialClass?.constructor) {
|
||||
const isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
|
||||
return isRegistered;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
|
||||
const identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
|
||||
return ['class', identifier];
|
||||
}, (clazz, superJson) => {
|
||||
const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
|
||||
if (!allowedProps) {
|
||||
return { ...clazz };
|
||||
}
|
||||
const result = {};
|
||||
allowedProps.forEach(prop => {
|
||||
result[prop] = clazz[prop];
|
||||
});
|
||||
return result;
|
||||
}, (v, a, superJson) => {
|
||||
const clazz = superJson.classRegistry.getValue(a[1]);
|
||||
if (!clazz) {
|
||||
throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
|
||||
}
|
||||
return Object.assign(Object.create(clazz.prototype), v);
|
||||
});
|
||||
const customRule = compositeTransformation((value, superJson) => {
|
||||
return !!superJson.customTransformerRegistry.findApplicable(value);
|
||||
}, (value, superJson) => {
|
||||
const transformer = superJson.customTransformerRegistry.findApplicable(value);
|
||||
return ['custom', transformer.name];
|
||||
}, (value, superJson) => {
|
||||
const transformer = superJson.customTransformerRegistry.findApplicable(value);
|
||||
return transformer.serialize(value);
|
||||
}, (v, a, superJson) => {
|
||||
const transformer = superJson.customTransformerRegistry.findByName(a[1]);
|
||||
if (!transformer) {
|
||||
throw new Error('Trying to deserialize unknown custom value');
|
||||
}
|
||||
return transformer.deserialize(v);
|
||||
});
|
||||
const compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
|
||||
export const transformValue = (value, superJson) => {
|
||||
const applicableCompositeRule = findArr(compositeRules, rule => rule.isApplicable(value, superJson));
|
||||
if (applicableCompositeRule) {
|
||||
return {
|
||||
value: applicableCompositeRule.transform(value, superJson),
|
||||
type: applicableCompositeRule.annotation(value, superJson),
|
||||
};
|
||||
}
|
||||
const applicableSimpleRule = findArr(simpleRules, rule => rule.isApplicable(value, superJson));
|
||||
if (applicableSimpleRule) {
|
||||
return {
|
||||
value: applicableSimpleRule.transform(value, superJson),
|
||||
type: applicableSimpleRule.annotation,
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
const simpleRulesByAnnotation = {};
|
||||
simpleRules.forEach(rule => {
|
||||
simpleRulesByAnnotation[rule.annotation] = rule;
|
||||
});
|
||||
export const untransformValue = (json, type, superJson) => {
|
||||
if (isArray(type)) {
|
||||
switch (type[0]) {
|
||||
case 'symbol':
|
||||
return symbolRule.untransform(json, type, superJson);
|
||||
case 'class':
|
||||
return classRule.untransform(json, type, superJson);
|
||||
case 'custom':
|
||||
return customRule.untransform(json, type, superJson);
|
||||
case 'typed-array':
|
||||
return typedArrayRule.untransform(json, type, superJson);
|
||||
default:
|
||||
throw new Error('Unknown transformation: ' + type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const transformation = simpleRulesByAnnotation[type];
|
||||
if (!transformation) {
|
||||
throw new Error('Unknown transformation: ' + type);
|
||||
}
|
||||
return transformation.untransform(json, superJson);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=transformer.js.map
|
||||
1
node_modules/superjson/dist/transformer.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/transformer.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
29
node_modules/superjson/dist/types.d.ts
generated
vendored
Normal file
29
node_modules/superjson/dist/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { TypeAnnotation } from './transformer.js';
|
||||
import { MinimisedTree, ReferentialEqualityAnnotations } from './plainer.js';
|
||||
export type Class = {
|
||||
new (...args: any[]): any;
|
||||
};
|
||||
export type PrimitiveJSONValue = string | number | boolean | undefined | null;
|
||||
export type JSONValue = PrimitiveJSONValue | JSONArray | JSONObject;
|
||||
export interface JSONArray extends Array<JSONValue> {
|
||||
}
|
||||
export interface JSONObject {
|
||||
[key: string]: JSONValue;
|
||||
}
|
||||
type ClassInstance = any;
|
||||
export type SerializableJSONValue = Symbol | Set<SuperJSONValue> | Map<SuperJSONValue, SuperJSONValue> | undefined | bigint | Date | ClassInstance | RegExp;
|
||||
export type SuperJSONValue = JSONValue | SerializableJSONValue | SuperJSONArray | SuperJSONObject;
|
||||
export interface SuperJSONArray extends Array<SuperJSONValue> {
|
||||
}
|
||||
export interface SuperJSONObject {
|
||||
[key: string]: SuperJSONValue;
|
||||
}
|
||||
export interface SuperJSONResult {
|
||||
json: JSONValue;
|
||||
meta?: {
|
||||
values?: MinimisedTree<TypeAnnotation>;
|
||||
referentialEqualities?: ReferentialEqualityAnnotations;
|
||||
v?: number;
|
||||
};
|
||||
}
|
||||
export {};
|
||||
2
node_modules/superjson/dist/types.js
generated
vendored
Normal file
2
node_modules/superjson/dist/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=types.js.map
|
||||
1
node_modules/superjson/dist/types.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
||||
4
node_modules/superjson/dist/util.d.ts
generated
vendored
Normal file
4
node_modules/superjson/dist/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare function find<T>(record: Record<string, T>, predicate: (v: T) => boolean): T | undefined;
|
||||
export declare function forEach<T>(record: Record<string, T>, run: (v: T, key: string) => void): void;
|
||||
export declare function includes<T>(arr: T[], value: T): boolean;
|
||||
export declare function findArr<T>(record: T[], predicate: (v: T) => boolean): T | undefined;
|
||||
45
node_modules/superjson/dist/util.js
generated
vendored
Normal file
45
node_modules/superjson/dist/util.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
function valuesOfObj(record) {
|
||||
if ('values' in Object) {
|
||||
// eslint-disable-next-line es5/no-es6-methods
|
||||
return Object.values(record);
|
||||
}
|
||||
const values = [];
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const key in record) {
|
||||
if (record.hasOwnProperty(key)) {
|
||||
values.push(record[key]);
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
export function find(record, predicate) {
|
||||
const values = valuesOfObj(record);
|
||||
if ('find' in values) {
|
||||
// eslint-disable-next-line es5/no-es6-methods
|
||||
return values.find(predicate);
|
||||
}
|
||||
const valuesNotNever = values;
|
||||
for (let i = 0; i < valuesNotNever.length; i++) {
|
||||
const value = valuesNotNever[i];
|
||||
if (predicate(value)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
export function forEach(record, run) {
|
||||
Object.entries(record).forEach(([key, value]) => run(value, key));
|
||||
}
|
||||
export function includes(arr, value) {
|
||||
return arr.indexOf(value) !== -1;
|
||||
}
|
||||
export function findArr(record, predicate) {
|
||||
for (let i = 0; i < record.length; i++) {
|
||||
const value = record[i];
|
||||
if (predicate(value)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
//# sourceMappingURL=util.js.map
|
||||
1
node_modules/superjson/dist/util.js.map
generated
vendored
Normal file
1
node_modules/superjson/dist/util.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,SAAS,WAAW,CAAI,MAAyB;IAC/C,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;QACvB,8CAA8C;QAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,gDAAgD;IAChD,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,cAAc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