- Move components/ to src/ and compile to dist/ with tsc - Add root barrel export plus deep-import subpath exports and base.css export - Post-compile step: copy base.css, add .js import extensions, mark client modules - Add publish.sh and .npmrc for the Gitea npm registry - Fix type errors, guard TinyMCE env access, drop ace-builds type dependency - Rename clashing props type names, remove Next.js scaffolding and unused deps Co-Authored-By: Claude Opus 5.5 <[email protected]>
39 lines
861 B
TypeScript
39 lines
861 B
TypeScript
/**
|
|
* # EJSON parse string
|
|
*/
|
|
function parse(
|
|
string: string | null | number,
|
|
reviver?: (this: any, key: string, value: any) => any,
|
|
): { [s: string]: any } | { [s: string]: any }[] | undefined {
|
|
if (!string) return undefined;
|
|
if (typeof string == "object") return string;
|
|
if (typeof string !== "string") return undefined;
|
|
try {
|
|
return JSON.parse(string, reviver);
|
|
} catch (error) {
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* # EJSON stringify object
|
|
*/
|
|
function stringify(
|
|
value: any,
|
|
replacer?: ((this: any, key: string, value: any) => any) | null,
|
|
space?: string | number,
|
|
): string | undefined {
|
|
try {
|
|
return JSON.stringify(value, replacer || undefined, space);
|
|
} catch (error) {
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
const TWUIEJSON = {
|
|
parse,
|
|
stringify,
|
|
};
|
|
|
|
export default TWUIEJSON;
|