@shopify/app-bridge
Advanced tools
Comparing version 3.3.2 to 3.4.0-alpha.0
@@ -68,2 +68,23 @@ import { ClientApplication } from '../../../client'; | ||
export declare type RedirectAction = AdminPathAction | RemoteAction | AppAction | AdminSectionAction | MetaAction; | ||
export interface Location { | ||
pathname: string; | ||
search?: string | URLSearchParams; | ||
hash?: string; | ||
} | ||
export interface AppOptions { | ||
replace?: boolean; | ||
target?: 'self'; | ||
} | ||
export interface HostOptions { | ||
target: 'host' | 'new'; | ||
} | ||
export declare type Options = AppOptions | HostOptions; | ||
export declare type To = Location | URL | string; | ||
export interface SectionStringName extends Omit<Section, 'name'> { | ||
name: keyof typeof ResourceType; | ||
} | ||
export interface Navigate<T = To> { | ||
(to: T, options?: AppOptions): void; | ||
(to: T | SectionStringName, options?: HostOptions): void; | ||
} | ||
export declare function isResourcePayload(resource: ResourceInfo | object): resource is ResourceInfo; | ||
@@ -80,2 +101,5 @@ export declare function isCreateResourcePayload(resource: CreateResource | object): resource is CreateResource; | ||
export declare function toDestination(action: Action, payload: any, id?: string): AdminPathAction | AdminSectionAction | AppAction | RemoteAction; | ||
export declare function getPathWithSearchAndHash({ pathname, search, hash }: Location): string; | ||
export declare function normalizeUrl(to: To): string; | ||
export declare function getRelativePath(to: To): string; | ||
export declare function isAppPayload(payload: any): payload is AppPayload; | ||
@@ -85,2 +109,3 @@ export declare function isAdminPathPayload(payload: any): payload is AdminPathPayload; | ||
export declare function isRemotePayload(payload: any): payload is RemotePayload; | ||
export declare function isAdminSection(to: any): to is SectionStringName; | ||
export declare class Redirect extends ActionSet implements ComplexDispatch<Section | string> { | ||
@@ -87,0 +112,0 @@ constructor(app: ClientApplication); |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.create = exports.Redirect = exports.isRemotePayload = exports.isAdminSectionPayload = exports.isAdminPathPayload = exports.isAppPayload = exports.toDestination = exports.toApp = exports.toRemote = exports.toAdminSection = exports.toAdminPath = exports.isProductVariantCreateResourcePayload = exports.isProductVariantResourcePayload = exports.isCreateResourcePayload = exports.isResourcePayload = exports.ResourceType = exports.Action = void 0; | ||
exports.create = exports.Redirect = exports.isAdminSection = exports.isRemotePayload = exports.isAdminSectionPayload = exports.isAdminPathPayload = exports.isAppPayload = exports.getRelativePath = exports.normalizeUrl = exports.getPathWithSearchAndHash = exports.toDestination = exports.toApp = exports.toRemote = exports.toAdminSection = exports.toAdminPath = exports.isProductVariantCreateResourcePayload = exports.isProductVariantResourcePayload = exports.isCreateResourcePayload = exports.isResourcePayload = exports.ResourceType = exports.Action = void 0; | ||
var helper_1 = require("../../helper"); | ||
@@ -127,2 +127,28 @@ var ActionSet_1 = require("../../ActionSet"); | ||
exports.toDestination = toDestination; | ||
function getPathWithSearchAndHash(_a) { | ||
var pathname = _a.pathname, search = _a.search, hash = _a.hash; | ||
return "" + pathname + (search || '') + (hash || ''); | ||
} | ||
exports.getPathWithSearchAndHash = getPathWithSearchAndHash; | ||
function normalizeUrl(to) { | ||
if (to instanceof URL) { | ||
return to.toString(); | ||
} | ||
if (typeof to === 'string') { | ||
return to; | ||
} | ||
return getRelativePath(to); | ||
} | ||
exports.normalizeUrl = normalizeUrl; | ||
function getRelativePath(to) { | ||
if (typeof to === 'string') { | ||
if (to.startsWith('/')) { | ||
return to; | ||
} | ||
return getPathWithSearchAndHash(new URL(to)); | ||
} | ||
var search = to.search instanceof URLSearchParams ? to.search.toString() : to.search; | ||
return getPathWithSearchAndHash(__assign(__assign({}, to), { search: search })); | ||
} | ||
exports.getRelativePath = getRelativePath; | ||
function isAppPayload(payload) { | ||
@@ -146,2 +172,6 @@ return typeof payload === 'object' && Object.prototype.hasOwnProperty.call(payload, 'path'); | ||
exports.isRemotePayload = isRemotePayload; | ||
function isAdminSection(to) { | ||
return typeof to === 'object' && typeof (to === null || to === void 0 ? void 0 : to.name) === 'string'; | ||
} | ||
exports.isAdminSection = isAdminSection; | ||
var Redirect = /** @class */ (function (_super) { | ||
@@ -148,0 +178,0 @@ __extends(Redirect, _super); |
{ | ||
"name": "@shopify/app-bridge", | ||
"version": "3.3.2", | ||
"version": "3.4.0-alpha.0", | ||
"types": "index.d.ts", | ||
@@ -57,3 +57,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "769632a38875aa5856a26e3a341b006b1e545f2d" | ||
"gitHead": "579510f6c1db20300d86489e933241d5c2426017" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
978946
20115
1