- Consolidated duplicate UndoManagers to single instance - Fixed connection promise to only resolve on 'connected' status - Fixed WebSocketProvider import (WebsocketProvider) - Added proper doc.destroy() cleanup - Renamed isPresenceInitialized property to avoid conflict Co-Authored-By: Paperclip <noreply@paperclip.ing>
38 lines
831 B
TypeScript
38 lines
831 B
TypeScript
import type { SerovalNode } from 'seroval';
|
|
import { createPlugin } from 'seroval';
|
|
|
|
const URLPlugin = /* @__PURE__ */ createPlugin<URL, { value: SerovalNode }>({
|
|
tag: 'seroval-plugins/web/URL',
|
|
test(value) {
|
|
if (typeof URL === 'undefined') {
|
|
return false;
|
|
}
|
|
return value instanceof URL;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
return {
|
|
value: ctx.parse(value.href),
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
value: await ctx.parse(value.href),
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
value: ctx.parse(value.href),
|
|
};
|
|
},
|
|
},
|
|
serialize(node, ctx) {
|
|
return 'new URL(' + ctx.serialize(node.value) + ')';
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new URL(ctx.deserialize(node.value) as string);
|
|
},
|
|
});
|
|
|
|
export default URLPlugin;
|