Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@frontify/app-bridge-theme

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frontify/app-bridge-theme - npm Package Compare versions

Comparing version 0.0.0-alpha.10 to 0.0.0-alpha.11

411

dist/index.d.ts

@@ -18,2 +18,25 @@ import { Simplify } from 'type-fest';

declare interface AppBridgeTheme_2 {
dispatch<CommandName extends keyof CommandRegistry_2>(
dispatchHandler: DispatchHandlerParameter_2<CommandName, CommandRegistry_2>,
): Promise<void>;
context(): ContextReturn_2<Context_2, void>;
context<Key extends keyof Context_2>(key: Key): ContextReturn_2<Context_2, Key>;
context(key?: keyof Context_2 | void): unknown;
subscribe<EventName extends keyof AppBridgeThemeEvent_2>(
eventName: EventNameParameter_2<EventName, AppBridgeThemeEvent_2>,
callback: EventCallbackParameter_2<EventName, AppBridgeThemeEvent_2>,
): EventUnsubscribeFunction_2;
/**
* @deprecated
* Search in the current Guideline for a given query.
* @param query - The query to search for.
* @param order - The order in which the results should be returned. Defaults to 'relevance'.
*/
searchInGuideline(query: string, order?: 'relevance' | 'newest' | 'oldest'): Promise<GuidelineSearchResult_2[]>;
}
export declare type AppBridgeThemeEvent = EventNameValidator<Pick<EventRegistry, 'assetsChosen'> & ContextAsEventName<Context & {

@@ -23,2 +46,11 @@ '*': Context;

declare type AppBridgeThemeEvent_2 = EventNameValidator_2<
Pick<EventRegistry_2, 'assetsChosen'> &
ContextAsEventName_2<
Context_2 & {
'*': Context_2;
}
>
>;
export declare type Asset = {

@@ -49,2 +81,27 @@ id: number;

declare type Asset_2 = {
id: number;
creatorName: string;
extension: string;
externalUrl: Nullable<string>;
fileName: string;
title: string;
status: string;
objectType: string;
height: Nullable<number>;
width: Nullable<number>;
genericUrl: string;
previewUrl: string;
originUrl: string;
projectId: number;
fileSize: number;
fileSizeHumanReadable: string;
fileId: string;
token: string;
projectType: Nullable<string>;
revisionId: Nullable<number>;
backgroundColor: Nullable<string>;
isDownloadProtected: boolean;
};
export declare interface BrandPortalLink {

@@ -56,2 +113,10 @@ isEnabled(): boolean;

declare interface BrandPortalLink_2 {
isEnabled(): boolean;
title(language?: string): string;
url(language?: string): string;
}
export declare const closeSearchDialog: () => DispatchHandlerParameter_2<"closeSearchDialog", CommandRegistry>;
declare type CommandNamePattern = {

@@ -61,4 +126,10 @@ [commandName: `${CommandVerb}${string}`]: unknown;

declare type CommandNamePattern_2 = { [commandName: `${CommandVerb_2}${string}`]: unknown };
declare type CommandNameValidator<CommandNameObject> = Simplify<ObjectNameValidator<CommandNameObject, CommandNamePattern, 'Command'>>;
declare type CommandNameValidator_2<CommandNameObject> = Simplify<
ObjectNameValidator_2<CommandNameObject, CommandNamePattern_2, 'Command'>
>;
export declare type CommandRegistry = CommandNameValidator<{

@@ -69,6 +140,17 @@ openSearchDialog: void;

navigateToDocumentSection: number | string;
hydrateContextDocumentNavigation: number;
}>;
declare type CommandVerb = 'open' | 'close' | 'navigate' | 'download';
declare type CommandRegistry_2 = CommandNameValidator_2<{
openSearchDialog: void;
closeSearchDialog: void;
navigate: string;
navigateToDocumentSection: number | string;
hydrateContextDocumentNavigation: number;
}>;
declare type CommandVerb = 'open' | 'close' | 'navigate' | 'hydrateContext';
declare type CommandVerb_2 = 'open' | 'close' | 'navigate' | 'hydrateContext';
export declare type Context = {

@@ -80,2 +162,3 @@ brandId: number;

portalNavigation: PortalNavigationItem[] | null;
documentNavigation: Record<number, DocumentChildNavigationItem[] | undefined>;
portalToken: string | null;

@@ -96,2 +179,24 @@ currentLanguage: string;

declare type Context_2 = {
brandId: number;
brandPortalLink: BrandPortalLink_2 | null;
projectId: number;
portalId: number;
portalNavigation: PortalNavigationItem_2[] | null;
documentNavigation: Record<number, DocumentChildNavigationItem_2[] | undefined>;
portalToken: string | null;
currentLanguage: string;
defaultLanguage: string;
isEditing: boolean;
isPublicLink: boolean;
isAuthenticated: boolean;
isSearchDialogOpen: boolean;
languages: Language_2[];
template: TemplateContext_2 | null;
settings: {
templateSettings: Record<string, unknown>;
templateAssets: Record<string, Asset_2[]>;
};
};
declare type ContextAsEventName<Context> = {

@@ -104,2 +209,9 @@ [ContextKey in keyof Context as ContextKey extends string ? `Context.${ContextKey}` : never]: [

declare type ContextAsEventName_2<Context> = {
[ContextKey in keyof Context as ContextKey extends string ? `Context.${ContextKey}` : never]: [
Context[ContextKey],
Context[ContextKey],
];
};
export declare type ContextReturn<Context, Key> = Key extends keyof Context ? {

@@ -125,5 +237,33 @@ /**

declare type ContextReturn_2<Context, Key> = Key extends keyof Context
? {
/**
* Gets the current value of the context object at the given key.
*/
get(): Readonly<Context[Key]>;
/**
* Subscribes to changes in the context object at the given key.
*/
subscribe(
callbackFunction: (nextContext: Context[Key], previousContext: Context[Key]) => void,
): EventUnsubscribeFunction_2;
}
: {
/**
* Gets the current value of the context object.
*/
get(): Readonly<Context>;
/**
* Subscribes to changes in the context object.
*/
subscribe(
callbackFunction: (nextContext: Context, previousContext: Context) => void,
): EventUnsubscribeFunction_2;
};
export declare interface CoverPage extends CoverPageBase {
}
declare interface CoverPage_2 extends CoverPageBase_2 {}
declare interface CoverPageBase {

@@ -138,5 +278,16 @@ id(): number;

declare interface CoverPageBase_2 {
id(): number;
title(language?: string): string;
isPublished(): boolean;
isHiddenInNavigation(): boolean;
url(language?: string): string;
type: 'cover-page';
}
export declare interface CoverPageNavigationItem extends CoverPageBase {
}
declare interface CoverPageNavigationItem_2 extends CoverPageBase_2 {}
declare type DispatchHandler<CommandName extends keyof CommandRegistry, TCommand extends CommandRegistry> = TCommand[CommandName] extends void ? {

@@ -149,4 +300,16 @@ name: CommandName;

declare type DispatchHandler_2<
CommandName extends keyof CommandRegistry_2,
TCommand extends CommandRegistry_2,
> = TCommand[CommandName] extends void ? { name: CommandName } : { name: CommandName; payload: TCommand[CommandName] };
export declare type DispatchHandlerParameter<CommandName, TCommand extends CommandRegistry> = CommandName extends keyof CommandRegistry ? DispatchHandler<CommandName, TCommand> : WrongNamePattern<CommandName, 'Command'>;
declare type DispatchHandlerParameter_2<
CommandName,
TCommand extends CommandRegistry_2,
> = CommandName extends keyof CommandRegistry_2
? DispatchHandler_2<CommandName, TCommand>
: WrongNamePattern_2<CommandName, 'Command'>;
declare interface Document_2 extends DocumentBase {

@@ -157,2 +320,6 @@ documentGroupId(): Nullable<number>;

declare interface Document_3 extends DocumentBase_2 {
documentGroupId(): Nullable<number>;
}
declare interface DocumentBase {

@@ -166,4 +333,17 @@ id(): number;

declare interface DocumentBase_2 {
id(): number;
title(language?: string): string;
slug(language?: string): string;
url(language?: string): string;
type: 'document';
}
export declare type DocumentChildNavigationItem = PageCategoryNavigationItem | DocumentPageNavigationItem | DocumentPageLinkNavigationItem;
declare type DocumentChildNavigationItem_2 =
| PageCategoryNavigationItem_2
| DocumentPageNavigationItem_2
| DocumentPageLinkNavigationItem_2;
export declare interface DocumentGroupNavigationItem {

@@ -176,2 +356,9 @@ id(): number;

declare interface DocumentGroupNavigationItem_2 {
id(): number;
title(language?: string): string;
children(): (DocumentNavigationItem_2 | DocumentLibraryNavigationItem_2 | DocumentLinkNavigationItem_2)[];
type: 'document-group';
}
export declare interface DocumentLibrary extends DocumentLibraryBase {

@@ -181,2 +368,6 @@ documentGroupId(): Nullable<number>;

declare interface DocumentLibrary_2 extends DocumentLibraryBase_2 {
documentGroupId(): Nullable<number>;
}
declare interface DocumentLibraryBase {

@@ -190,2 +381,10 @@ id(): number;

declare interface DocumentLibraryBase_2 {
id(): number;
title(language?: string): string;
slug(language?: string): string;
url(language?: string): string;
type: 'document-library';
}
export declare interface DocumentLibraryNavigationItem extends DocumentLibraryBase {

@@ -195,2 +394,6 @@ parentId(): Nullable<number>;

declare interface DocumentLibraryNavigationItem_2 extends DocumentLibraryBase_2 {
parentId(): Nullable<number>;
}
export declare interface DocumentLinkNavigationItem {

@@ -208,2 +411,14 @@ id(): number;

declare interface DocumentLinkNavigationItem_2 {
id(): number;
title(language?: string): string;
url(): string;
displayMode(): LinkSettingsDisplay_2;
iconPosition(): LinkSettingsIconPosition_2;
customIconUrl(): Nullable<string>;
shouldOpenInNewTab(): boolean;
parentId(): Nullable<number>;
type: 'document-link';
}
export declare interface DocumentNavigationItem extends DocumentBase {

@@ -213,2 +428,6 @@ parentId(): Nullable<number>;

declare interface DocumentNavigationItem_2 extends DocumentBase_2 {
parentId(): Nullable<number>;
}
export declare interface DocumentPage extends DocumentPageBase {

@@ -219,2 +438,7 @@ categoryId(): Nullable<number>;

declare interface DocumentPage_2 extends DocumentPageBase_2 {
categoryId(): Nullable<number>;
documentId(): number;
}
declare interface DocumentPageBase {

@@ -228,2 +452,10 @@ id(): number;

declare interface DocumentPageBase_2 {
id(): number;
title(language?: string): string;
slug(language?: string): string;
url(language?: string): string;
type: 'document-page';
}
export declare interface DocumentPageHeadingNavigationItem {

@@ -236,2 +468,9 @@ id(): number;

declare interface DocumentPageHeadingNavigationItem_2 {
id(): number;
title(language?: string): string;
slug(language?: string): string;
type: 'document-page-heading';
}
export declare interface DocumentPageLinkNavigationItem {

@@ -244,2 +483,9 @@ id(): number;

declare interface DocumentPageLinkNavigationItem_2 {
id(): number;
title(language?: string): string;
url(): string;
type: 'document-page-link';
}
export declare interface DocumentPageNavigationItem extends DocumentPageBase {

@@ -249,6 +495,22 @@ headings(): DocumentPageHeadingNavigationItem[];

declare interface DocumentPageNavigationItem_2 extends DocumentPageBase_2 {
headings(): DocumentPageHeadingNavigationItem_2[];
}
export declare type EventCallbackParameter<EventName, AppBridgeThemeEvent> = EventName extends keyof AppBridgeThemeEvent ? AppBridgeThemeEvent[EventName] extends any[] ? (...eventReturn: AppBridgeThemeEvent[EventName]) => void : (eventReturn: AppBridgeThemeEvent[EventName]) => void : () => void;
declare type EventCallbackParameter_2<EventName, AppBridgeThemeEvent> = EventName extends keyof AppBridgeThemeEvent
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
AppBridgeThemeEvent[EventName] extends any[]
? (...eventReturn: AppBridgeThemeEvent[EventName]) => void
: (eventReturn: AppBridgeThemeEvent[EventName]) => void
: () => void;
export declare type EventNameParameter<EventName, EventNameParameter extends EventNamePattern> = EventName extends keyof EventNameParameter ? EventName : WrongNamePattern<EventName, 'Event'>;
declare type EventNameParameter_2<
EventName,
EventNameParameter extends EventNamePattern_2,
> = EventName extends keyof EventNameParameter ? EventName : WrongNamePattern_2<EventName, 'Event'>;
export declare type EventNamePattern = {

@@ -258,4 +520,12 @@ [eventName: `Context.${string}` | `${string}${Capitalize<EventVerb>}`]: unknown;

declare type EventNamePattern_2 = {
[eventName: `Context.${string}` | `${string}${Capitalize<EventVerb_2>}`]: unknown;
};
export declare type EventNameValidator<EventNameObject> = Simplify<ObjectNameValidator<EventNameObject, EventNamePattern, 'Event'>>;
declare type EventNameValidator_2<EventNameObject> = Simplify<
ObjectNameValidator_2<EventNameObject, EventNamePattern_2, 'Event'>
>;
export declare type EventRegistry = EventNameValidator<{

@@ -267,6 +537,14 @@ assetsChosen: {

declare type EventRegistry_2 = EventNameValidator_2<{
assetsChosen: { assets: Asset_2[] };
}>;
export declare type EventUnsubscribeFunction = () => void;
declare type EventUnsubscribeFunction_2 = () => void;
declare type EventVerb = 'chosen';
declare type EventVerb_2 = 'chosen';
export declare type GuidelineSearchResult = {

@@ -294,11 +572,44 @@ highlights: string[];

declare type GuidelineSearchResult_2 = {
highlights: string[];
type: GuidelineSearchResultType_2;
objectId: number;
pageId: number;
pageSlug: string;
pageTitle: string;
pageCategorySlug: string | null;
blockId: number;
documentId: number;
documentSlug: string;
documentTitle: string;
portalId: number;
portalToken: string | null;
sectionId: string | null;
sectionSlug: string | null;
sectionTitle: string | null;
colorHex?: string;
projectColorId?: string;
guidelineTitle: string;
};
declare type GuidelineSearchResultType = (typeof GuidelineSearchResultTypeMap)[keyof typeof GuidelineSearchResultTypeMap];
declare type GuidelineSearchResultType_2 = (typeof GuidelineSearchResultTypeMap_2)[keyof typeof GuidelineSearchResultTypeMap_2];
export declare const GuidelineSearchResultTypeMap: {
readonly block: "BLOCK";
readonly section: "SECTION";
readonly page: "PAGE";
readonly color: "COLOR";
block: string;
section: string;
page: string;
color: string;
};
declare const GuidelineSearchResultTypeMap_2 = {
block: 'BLOCK',
section: 'SECTION',
page: 'PAGE',
color: 'COLOR',
};
export declare const hydrateContextDocumentNavigation: (documentId: CommandRegistry["hydrateContextDocumentNavigation"]) => DispatchHandlerParameter_2<"hydrateContextDocumentNavigation", CommandRegistry>;
export declare type Language = {

@@ -323,2 +634,24 @@ /**

declare type Language_2 = {
/**
* The language code in ISO 639-1 format.
*/
isoCode: string;
/**
* The name of the language.
*/
name: string;
/**
* Indicates whether the language is the default language.
*/
isDefault: boolean;
/**
* Indicates whether the language is in draft state.
*/
isDraft: boolean;
};
export declare enum LinkSettingsDisplay {

@@ -330,2 +663,8 @@ TextAndIcon = "ICON_TEXT",

declare enum LinkSettingsDisplay_2 {
TextAndIcon = 'ICON_TEXT',
IconOnly = 'ICON',
TextOnly = 'TEXT',
}
export declare enum LinkSettingsIconPosition {

@@ -336,6 +675,30 @@ Right = "RIGHT",

declare enum LinkSettingsIconPosition_2 {
Right = 'RIGHT',
Left = 'LEFT',
}
declare type NameContextList = 'Command' | 'Event';
declare type NameContextList_2 = 'Command' | 'Event';
export declare const navigate: (path: CommandRegistry["navigate"]) => DispatchHandlerParameter_2<"navigate", CommandRegistry>;
export declare const navigateToDocumentSection: (sectionId: CommandRegistry["navigateToDocumentSection"]) => DispatchHandlerParameter_2<"navigateToDocumentSection", CommandRegistry>;
export declare type ObjectNameValidator<NameObject, PatternObject, NameContext extends NameContextList> = keyof NameObject extends keyof PatternObject ? NameObject : WrongNamePattern<`${Exclude<Extract<keyof NameObject, string>, Extract<keyof PatternObject, string>>}`, NameContext>;
declare type ObjectNameValidator_2<
NameObject,
PatternObject,
NameContext extends NameContextList_2,
> = keyof NameObject extends keyof PatternObject
? NameObject
: WrongNamePattern_2<
`${Exclude<Extract<keyof NameObject, string>, Extract<keyof PatternObject, string>>}`,
NameContext
>;
export declare const openSearchDialog: () => DispatchHandlerParameter_2<"openSearchDialog", CommandRegistry>;
export declare interface PageCategoryNavigationItem {

@@ -349,4 +712,19 @@ id(): number;

declare interface PageCategoryNavigationItem_2 {
id(): number;
title(language?: string): string;
slug(language?: string): string;
children(): (DocumentPageNavigationItem_2 | DocumentPageLinkNavigationItem_2)[];
type: 'page-category';
}
export declare type PortalNavigationItem = CoverPageNavigationItem | DocumentGroupNavigationItem | DocumentNavigationItem | DocumentLibraryNavigationItem | DocumentLinkNavigationItem;
declare type PortalNavigationItem_2 =
| CoverPageNavigationItem_2
| DocumentGroupNavigationItem_2
| DocumentNavigationItem_2
| DocumentLibraryNavigationItem_2
| DocumentLinkNavigationItem_2;
export declare type SubscribeMap<Event> = {

@@ -371,6 +749,29 @@ [EventName in keyof Event as EventName]: Map<EventCallbackParameter<keyof Event, Event>, boolean>;

declare type TemplateContext_2 = { templateId: string; type: ThemeTemplate_2 } & (
| { type: 'documentPage'; document: Document_3; documentPage: DocumentPage_2 }
| { type: 'library'; document: DocumentLibrary_2 }
| { type: 'cover'; coverPage: CoverPage_2 }
);
export declare type ThemeTemplate = 'documentPage' | 'cover' | 'library';
declare type ThemeTemplate_2 = 'documentPage' | 'cover' | 'library';
export declare const useDocumentNavigation: (appBridge: AppBridgeTheme_2, document: DocumentNavigationItem) => DocumentChildNavigationItem[];
export declare const useIsEditing: (appBridge: AppBridgeTheme) => boolean;
export declare const useLanguage: (appBridge: AppBridgeTheme) => UseLanguageReturn;
declare type UseLanguageReturn = {
currentLanguage: string;
defaultLanguage: string;
};
export declare type WrongNamePattern<ApiMethodName, NameContext extends NameContextList> = ApiMethodName extends string ? `The following ${NameContext} do not match the naming pattern: ${ApiMethodName}` : never;
declare type WrongNamePattern_2<ApiMethodName, NameContext extends NameContextList_2> = ApiMethodName extends string
? `The following ${NameContext} do not match the naming pattern: ${ApiMethodName}`
: never;
export { }

@@ -1,3 +0,35 @@

var T = /* @__PURE__ */ ((e) => (e.TextAndIcon = "ICON_TEXT", e.IconOnly = "ICON", e.TextOnly = "TEXT", e))(T || {}), r = /* @__PURE__ */ ((e) => (e.Right = "RIGHT", e.Left = "LEFT", e))(r || {});
const O = {
import { useSyncExternalStore as n, useEffect as o } from "react";
const s = (t) => n(t.context("isEditing").subscribe, t.context("isEditing").get), i = (t) => {
const e = n(
t.context("currentLanguage").subscribe,
t.context("currentLanguage").get
), a = n(
t.context("defaultLanguage").subscribe,
t.context("defaultLanguage").get
);
return { currentLanguage: e, defaultLanguage: a };
}, c = (t) => ({
name: "hydrateContextDocumentNavigation",
payload: t
}), l = (t, e) => {
const a = n(
t.context("documentNavigation").subscribe,
t.context("documentNavigation").get
);
return o(() => {
t.dispatch(c(e.id()));
}, [t, e]), a[e.id()] ?? [];
}, x = () => ({
name: "openSearchDialog"
}), m = () => ({
name: "closeSearchDialog"
}), v = (t) => ({
name: "navigate",
payload: t
}), T = (t) => ({
name: "navigateToDocumentSection",
payload: t
});
var u = /* @__PURE__ */ ((t) => (t.TextAndIcon = "ICON_TEXT", t.IconOnly = "ICON", t.TextOnly = "TEXT", t))(u || {}), r = /* @__PURE__ */ ((t) => (t.Right = "RIGHT", t.Left = "LEFT", t))(r || {});
const d = {
block: "BLOCK",

@@ -9,6 +41,14 @@ section: "SECTION",

export {
O as GuidelineSearchResultTypeMap,
T as LinkSettingsDisplay,
r as LinkSettingsIconPosition
d as GuidelineSearchResultTypeMap,
u as LinkSettingsDisplay,
r as LinkSettingsIconPosition,
m as closeSearchDialog,
c as hydrateContextDocumentNavigation,
v as navigate,
T as navigateToDocumentSection,
x as openSearchDialog,
l as useDocumentNavigation,
s as useIsEditing,
i as useLanguage
};
//# sourceMappingURL=index.js.map
{
"name": "@frontify/app-bridge-theme",
"type": "module",
"version": "0.0.0-alpha.10",
"version": "0.0.0-alpha.11",
"description": "Package to establish communication between Frontify and themes",

@@ -35,8 +35,13 @@ "author": "Frontify Developers <developers@frontify.com>",

"@frontify/eslint-config-react": "^0.17.6",
"@testing-library/react": "^14.3.0",
"@types/react": "^18.2.75",
"@types/react-dom": "^18.2.24",
"@vitest/coverage-v8": "^1.4.0",
"@vitest/ui": "^1.4.0",
"eslint": "^8.57.0",
"eslint-plugin-notice": "^0.9.10",
"happy-dom": "^13.10.1",
"prettier": "^3.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ts-json-as-const": "^1.0.7",

@@ -46,3 +51,4 @@ "type-fest": "^4.15.0",

"vite": "^5.2.10",
"vite-plugin-dts": "^3.8.1"
"vite-plugin-dts": "^3.8.1",
"vitest": "^1.4.0"
},

@@ -54,4 +60,8 @@ "scripts": {

"lint:fix": "eslint --fix .",
"test": "vitest run",
"test:ui": "vitest --ui",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"typecheck": "tsc --noEmit"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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