New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

astro-portabletext

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-portabletext - npm Package Compare versions

Comparing version 0.7.0-next.1 to 0.7.0-next.2

21

lib/context.d.ts
import type { TypedObject } from "@portabletext/types";
import type { Component } from "./internal";
import type { MissingComponentHandler } from "./types";
declare const _default: {
provideDefaultComponent: (node: TypedObject) => Component<import("./types").Props<import("@portabletext/types").ArbitraryTypedObject>>;
provideUnknownComponent: (node: TypedObject) => Component<import("./types").Props<import("@portabletext/types").ArbitraryTypedObject>>;
provideMissingComponentHandler: MissingComponentHandler;
provideWarningMessage: (node: TypedObject) => string;
};
export default _default;
export declare const key: unique symbol;
export declare function useContext(node: TypedObject): {
getDefaultComponent: () => Component<import("./types").Props<import("@portabletext/types").ArbitraryTypedObject>>;
getUnknownComponent: () => Component<import("./types").Props<import("@portabletext/types").ArbitraryTypedObject>>;
export interface Context {
getDefaultComponent: () => Component;
getUnknownComponent: () => Component;
getWarningMessage: () => string;
notifyMissingComponentHandler: (message?: string) => void;
/** @deprecated Use `getDefaultComponent` */
next: () => Component<import("./types").Props<import("@portabletext/types").ArbitraryTypedObject>>;
next: () => Component;
/** @deprecated Use `notifyMissingComponentHandler` */
onMissingComponent: (message?: string) => void;
};
}
export declare const key: unique symbol;
export declare function useContext(node: TypedObject): Context;

@@ -1,53 +0,8 @@

const context = {
provideDefaultComponent: (
// eslint-disable-next-line @typescript-eslint/no-unused-vars
node) => {
throw new Error(`context.provideDefaultComponent() handler has not been set`);
},
provideUnknownComponent: function (
// eslint-disable-next-line @typescript-eslint/no-unused-vars
node) {
throw new Error(`context.provideUnknownComponent() handler has not been set`);
},
provideMissingComponentHandler: (
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function (message, ctx) {
throw new Error(`context.provideMissingComponentHandler() handler has not been set`);
}),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
provideWarningMessage: function (node) {
throw new Error(`context.provideWarningMessage() handler has not been set`);
},
};
export default {
set provideDefaultComponent(fn) {
context.provideDefaultComponent = fn;
},
set provideUnknownComponent(fn) {
context.provideUnknownComponent = fn;
},
set provideMissingComponentHandler(fn) {
context.provideMissingComponentHandler = fn;
},
set provideWarningMessage(fn) {
context.provideWarningMessage = fn;
},
};
export const key = Symbol("astro-portabletext:context");
export const key = Symbol("astro-portabletext");
export function useContext(node) {
const notifyMissingComponentHandler = (message) => {
context.provideMissingComponentHandler(message ?? context.provideWarningMessage(node),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
node[key]);
};
return {
getDefaultComponent: () => context.provideDefaultComponent(node),
getUnknownComponent: () => context.provideUnknownComponent(node),
getWarningMessage: () => context.provideWarningMessage(node),
notifyMissingComponentHandler: notifyMissingComponentHandler,
/** @deprecated Use `getDefaultComponent` */
next: () => context.provideDefaultComponent(node),
/** @deprecated Use `notifyMissingComponentHandler` */
onMissingComponent: notifyMissingComponentHandler,
};
if (!(key in globalThis)) {
throw new Error(`PortableText "context" has not been initialised`);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return globalThis[key](node);
}
{
"name": "astro-portabletext",
"version": "0.7.0-next.1",
"version": "0.7.0-next.2",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Render Portable Text with Astro",

@@ -7,5 +7,7 @@ <div>

![license](https://img.shields.io/npm/l/astro-portabletext?style=flat-square)
[![npm](https://img.shields.io/npm/v/astro-portabletext?style=flat-square)](https://www.npmjs.com/package/astro-portabletext)
[![prerelease](https://img.shields.io/npm/v/astro-portabletext/next?style=flat-square&colour-blue)](https://www.npmjs.com/package/astro-portabletext)
![license](https://img.shields.io/npm/l/astro-portabletext?style=flat-square)
Render [Portable Text](https://portabletext.org/) with [Astro](https://astro.build/).

@@ -12,0 +14,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc