@shopify/app-bridge-react 3.7.11-snapshot-20240220213625 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +7 -0
- package/README.md +98 -128
- package/dist/index.cjs +28 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +700 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -42
- package/components/ClientRouter/ClientRouter.d.ts +0 -23
- package/components/ClientRouter/ClientRouter.js +0 -52
- package/components/ClientRouter/hook.d.ts +0 -10
- package/components/ClientRouter/hook.js +0 -20
- package/components/ClientRouter/index.d.ts +0 -3
- package/components/ClientRouter/index.js +0 -10
- package/components/ClientRouter/router.d.ts +0 -5
- package/components/ClientRouter/router.js +0 -11
- package/components/ContextualSaveBar/ContextualSaveBar.d.ts +0 -9
- package/components/ContextualSaveBar/ContextualSaveBar.js +0 -24
- package/components/ContextualSaveBar/index.d.ts +0 -3
- package/components/ContextualSaveBar/index.js +0 -7
- package/components/Loading/Loading.d.ts +0 -19
- package/components/Loading/Loading.js +0 -55
- package/components/Loading/index.d.ts +0 -2
- package/components/Loading/index.js +0 -7
- package/components/Modal/Modal.d.ts +0 -32
- package/components/Modal/Modal.js +0 -140
- package/components/Modal/ModalContent/ModalContent.d.ts +0 -24
- package/components/Modal/ModalContent/ModalContent.js +0 -61
- package/components/Modal/ModalContent/index.d.ts +0 -2
- package/components/Modal/ModalContent/index.js +0 -7
- package/components/Modal/index.d.ts +0 -4
- package/components/Modal/index.js +0 -10
- package/components/NavigationMenu/NavigationMenu.d.ts +0 -18
- package/components/NavigationMenu/NavigationMenu.js +0 -44
- package/components/NavigationMenu/index.d.ts +0 -3
- package/components/NavigationMenu/index.js +0 -7
- package/components/Provider/Provider.d.ts +0 -87
- package/components/Provider/Provider.js +0 -81
- package/components/Provider/index.d.ts +0 -3
- package/components/Provider/index.js +0 -7
- package/components/ResourcePicker/ResourcePicker.d.ts +0 -36
- package/components/ResourcePicker/ResourcePicker.js +0 -120
- package/components/ResourcePicker/index.d.ts +0 -3
- package/components/ResourcePicker/index.js +0 -7
- package/components/RoutePropagator/RoutePropagator.d.ts +0 -22
- package/components/RoutePropagator/RoutePropagator.js +0 -54
- package/components/RoutePropagator/globals.d.ts +0 -3
- package/components/RoutePropagator/globals.js +0 -15
- package/components/RoutePropagator/hook.d.ts +0 -10
- package/components/RoutePropagator/hook.js +0 -20
- package/components/RoutePropagator/index.d.ts +0 -3
- package/components/RoutePropagator/index.js +0 -10
- package/components/RoutePropagator/route-propagator.d.ts +0 -7
- package/components/RoutePropagator/route-propagator.js +0 -91
- package/components/TitleBar/TitleBar.d.ts +0 -27
- package/components/TitleBar/TitleBar.js +0 -107
- package/components/TitleBar/index.d.ts +0 -3
- package/components/TitleBar/index.js +0 -7
- package/components/Toast/Toast.d.ts +0 -38
- package/components/Toast/Toast.js +0 -67
- package/components/Toast/index.d.ts +0 -3
- package/components/Toast/index.js +0 -7
- package/components/index.d.ts +0 -11
- package/components/index.js +0 -37
- package/components/unstable_Picker/index.d.ts +0 -3
- package/components/unstable_Picker/index.js +0 -7
- package/components/unstable_Picker/unstable_Picker.d.ts +0 -13
- package/components/unstable_Picker/unstable_Picker.js +0 -85
- package/context.d.ts +0 -14
- package/context.js +0 -10
- package/hooks/index.d.ts +0 -10
- package/hooks/index.js +0 -21
- package/hooks/useAppBridgeState/index.d.ts +0 -1
- package/hooks/useAppBridgeState/index.js +0 -13
- package/hooks/useAppBridgeState/useAppBridgeState.d.ts +0 -10
- package/hooks/useAppBridgeState/useAppBridgeState.js +0 -89
- package/hooks/useAuthenticatedFetch/index.d.ts +0 -1
- package/hooks/useAuthenticatedFetch/index.js +0 -13
- package/hooks/useAuthenticatedFetch/useAuthenticatedFetch.d.ts +0 -11
- package/hooks/useAuthenticatedFetch/useAuthenticatedFetch.js +0 -22
- package/hooks/useContextualSaveBar/index.d.ts +0 -1
- package/hooks/useContextualSaveBar/index.js +0 -5
- package/hooks/useContextualSaveBar/useContextualSaveBar.d.ts +0 -10
- package/hooks/useContextualSaveBar/useContextualSaveBar.js +0 -85
- package/hooks/useFeatureRequest/index.d.ts +0 -1
- package/hooks/useFeatureRequest/index.js +0 -13
- package/hooks/useFeatureRequest/useFeatureRequest.d.ts +0 -13
- package/hooks/useFeatureRequest/useFeatureRequest.js +0 -49
- package/hooks/useFeaturesAvailable/index.d.ts +0 -2
- package/hooks/useFeaturesAvailable/index.js +0 -5
- package/hooks/useFeaturesAvailable/useFeaturesAvailable.d.ts +0 -12
- package/hooks/useFeaturesAvailable/useFeaturesAvailable.js +0 -101
- package/hooks/useLocale/index.d.ts +0 -1
- package/hooks/useLocale/index.js +0 -5
- package/hooks/useLocale/useLocale.d.ts +0 -1
- package/hooks/useLocale/useLocale.js +0 -8
- package/hooks/useNavigate/index.d.ts +0 -1
- package/hooks/useNavigate/index.js +0 -5
- package/hooks/useNavigate/useNavigate.d.ts +0 -3
- package/hooks/useNavigate/useNavigate.js +0 -63
- package/hooks/useNavigationHistory/index.d.ts +0 -1
- package/hooks/useNavigationHistory/index.js +0 -5
- package/hooks/useNavigationHistory/useNavigationHistory.d.ts +0 -16
- package/hooks/useNavigationHistory/useNavigationHistory.js +0 -28
- package/hooks/useOnceEffect/index.d.ts +0 -1
- package/hooks/useOnceEffect/index.js +0 -13
- package/hooks/useOnceEffect/useOnceEffect.d.ts +0 -5
- package/hooks/useOnceEffect/useOnceEffect.js +0 -11
- package/hooks/useToast/index.d.ts +0 -1
- package/hooks/useToast/index.js +0 -5
- package/hooks/useToast/useToast.d.ts +0 -20
- package/hooks/useToast/useToast.js +0 -46
- package/index.d.ts +0 -4
- package/index.js +0 -19
- package/types.d.ts +0 -35
- package/types.js +0 -5
- package/umd/index.js +0 -10
- package/useAppBridge.d.ts +0 -1
- package/useAppBridge.js +0 -13
- package/utilities/transformers.d.ts +0 -20
- package/utilities/transformers.js +0 -105
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
var react_1 = require("react");
|
|
15
|
-
var Picker_1 = require("@shopify/app-bridge/actions/Picker");
|
|
16
|
-
var useAppBridge_1 = require("../../useAppBridge");
|
|
17
|
-
function Picker(_a) {
|
|
18
|
-
var open = _a.open, onCancel = _a.onCancel, onSelect = _a.onSelect, onSearch = _a.onSearch, onLoadMore = _a.onLoadMore, options = __rest(_a, ["open", "onCancel", "onSelect", "onSearch", "onLoadMore"]);
|
|
19
|
-
var app = useAppBridge_1.useAppBridge();
|
|
20
|
-
var isUnmountedRef = react_1.useRef(false);
|
|
21
|
-
react_1.useEffect(function () { return function () {
|
|
22
|
-
isUnmountedRef.current = true;
|
|
23
|
-
}; }, []);
|
|
24
|
-
var openRef = react_1.useRef(false);
|
|
25
|
-
var optionsRef = react_1.useRef(options);
|
|
26
|
-
var picker = react_1.useMemo(function () { return Picker_1.create(app, optionsRef.current); }, [app]);
|
|
27
|
-
react_1.useEffect(function () {
|
|
28
|
-
openRef.current = false;
|
|
29
|
-
return function () {
|
|
30
|
-
if (openRef.current && isUnmountedRef.current) {
|
|
31
|
-
picker.dispatch(Picker_1.Action.CANCEL);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}, [picker]);
|
|
35
|
-
react_1.useEffect(function () {
|
|
36
|
-
if (open === openRef.current)
|
|
37
|
-
return;
|
|
38
|
-
openRef.current = open;
|
|
39
|
-
if (open) {
|
|
40
|
-
picker.dispatch(Picker_1.Action.OPEN);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
picker.dispatch(Picker_1.Action.CANCEL);
|
|
44
|
-
}
|
|
45
|
-
}, [picker, open]);
|
|
46
|
-
react_1.useEffect(function () {
|
|
47
|
-
if (!onSelect)
|
|
48
|
-
return;
|
|
49
|
-
return picker.subscribe(Picker_1.Action.SELECT, function () {
|
|
50
|
-
var args = [];
|
|
51
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
52
|
-
args[_i] = arguments[_i];
|
|
53
|
-
}
|
|
54
|
-
openRef.current = false;
|
|
55
|
-
return onSelect.apply(void 0, args);
|
|
56
|
-
});
|
|
57
|
-
}, [picker, onSelect]);
|
|
58
|
-
react_1.useEffect(function () {
|
|
59
|
-
if (!onCancel)
|
|
60
|
-
return;
|
|
61
|
-
return picker.subscribe(Picker_1.Action.CANCEL, function () {
|
|
62
|
-
openRef.current = false;
|
|
63
|
-
return onCancel();
|
|
64
|
-
});
|
|
65
|
-
}, [picker, onCancel]);
|
|
66
|
-
react_1.useEffect(function () {
|
|
67
|
-
if (!onSearch)
|
|
68
|
-
return;
|
|
69
|
-
return picker.subscribe(Picker_1.Action.SEARCH, onSearch);
|
|
70
|
-
}, [picker, onSearch]);
|
|
71
|
-
react_1.useEffect(function () {
|
|
72
|
-
if (!onLoadMore)
|
|
73
|
-
return;
|
|
74
|
-
return picker.subscribe(Picker_1.Action.LOAD_MORE, onLoadMore);
|
|
75
|
-
}, [picker, onLoadMore]);
|
|
76
|
-
react_1.useEffect(function () {
|
|
77
|
-
var shouldUpdate = JSON.stringify(options) !== JSON.stringify(optionsRef.current);
|
|
78
|
-
if (!shouldUpdate)
|
|
79
|
-
return;
|
|
80
|
-
optionsRef.current = options;
|
|
81
|
-
picker.set(options, openRef.current);
|
|
82
|
-
}, [picker, options]);
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
exports.default = Picker;
|
package/context.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { ClientApplication } from '@shopify/app-bridge/client';
|
|
3
|
-
/**
|
|
4
|
-
* App Bridge context consumer type.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export declare type IAppBridgeContext = ClientApplication | null;
|
|
9
|
-
/**
|
|
10
|
-
* App Bridge context.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare const AppBridgeContext: import("react").Context<IAppBridgeContext>;
|
package/context.js
DELETED
package/hooks/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { useAppBridgeState } from './useAppBridgeState';
|
|
2
|
-
export { useAuthenticatedFetch } from './useAuthenticatedFetch';
|
|
3
|
-
export { useContextualSaveBar } from './useContextualSaveBar';
|
|
4
|
-
export { useFeaturesAvailable } from './useFeaturesAvailable';
|
|
5
|
-
export type { FeaturesAvailable } from './useFeaturesAvailable';
|
|
6
|
-
export { useFeatureRequest } from './useFeatureRequest';
|
|
7
|
-
export { useLocale } from './useLocale';
|
|
8
|
-
export { useNavigate } from './useNavigate';
|
|
9
|
-
export { useNavigationHistory } from './useNavigationHistory';
|
|
10
|
-
export { useToast } from './useToast';
|
package/hooks/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useToast = exports.useNavigationHistory = exports.useNavigate = exports.useLocale = exports.useFeatureRequest = exports.useFeaturesAvailable = exports.useContextualSaveBar = exports.useAuthenticatedFetch = exports.useAppBridgeState = void 0;
|
|
4
|
-
var useAppBridgeState_1 = require("./useAppBridgeState");
|
|
5
|
-
Object.defineProperty(exports, "useAppBridgeState", { enumerable: true, get: function () { return useAppBridgeState_1.useAppBridgeState; } });
|
|
6
|
-
var useAuthenticatedFetch_1 = require("./useAuthenticatedFetch");
|
|
7
|
-
Object.defineProperty(exports, "useAuthenticatedFetch", { enumerable: true, get: function () { return useAuthenticatedFetch_1.useAuthenticatedFetch; } });
|
|
8
|
-
var useContextualSaveBar_1 = require("./useContextualSaveBar");
|
|
9
|
-
Object.defineProperty(exports, "useContextualSaveBar", { enumerable: true, get: function () { return useContextualSaveBar_1.useContextualSaveBar; } });
|
|
10
|
-
var useFeaturesAvailable_1 = require("./useFeaturesAvailable");
|
|
11
|
-
Object.defineProperty(exports, "useFeaturesAvailable", { enumerable: true, get: function () { return useFeaturesAvailable_1.useFeaturesAvailable; } });
|
|
12
|
-
var useFeatureRequest_1 = require("./useFeatureRequest");
|
|
13
|
-
Object.defineProperty(exports, "useFeatureRequest", { enumerable: true, get: function () { return useFeatureRequest_1.useFeatureRequest; } });
|
|
14
|
-
var useLocale_1 = require("./useLocale");
|
|
15
|
-
Object.defineProperty(exports, "useLocale", { enumerable: true, get: function () { return useLocale_1.useLocale; } });
|
|
16
|
-
var useNavigate_1 = require("./useNavigate");
|
|
17
|
-
Object.defineProperty(exports, "useNavigate", { enumerable: true, get: function () { return useNavigate_1.useNavigate; } });
|
|
18
|
-
var useNavigationHistory_1 = require("./useNavigationHistory");
|
|
19
|
-
Object.defineProperty(exports, "useNavigationHistory", { enumerable: true, get: function () { return useNavigationHistory_1.useNavigationHistory; } });
|
|
20
|
-
var useToast_1 = require("./useToast");
|
|
21
|
-
Object.defineProperty(exports, "useToast", { enumerable: true, get: function () { return useToast_1.useToast; } });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useAppBridgeState';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./useAppBridgeState"), exports);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AppBridgeState, Path, PathValue, StateWithoutFeatures } from '@shopify/app-bridge';
|
|
2
|
-
declare type Query = keyof AppBridgeState | Path<StateWithoutFeatures<AppBridgeState>>;
|
|
3
|
-
declare type State<K extends Query> = K extends keyof AppBridgeState ? AppBridgeState[K] : K extends Path<StateWithoutFeatures<AppBridgeState>> ? PathValue<StateWithoutFeatures<AppBridgeState>, K> : K extends never ? AppBridgeState : never;
|
|
4
|
-
interface UseAppBridgeState {
|
|
5
|
-
(): AppBridgeState | undefined;
|
|
6
|
-
<K extends Query>(query: K): State<K> | undefined;
|
|
7
|
-
<PartialState>(query: keyof AppBridgeState): PartialState | undefined;
|
|
8
|
-
}
|
|
9
|
-
export declare const useAppBridgeState: UseAppBridgeState;
|
|
10
|
-
export {};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.useAppBridgeState = void 0;
|
|
40
|
-
var react_1 = require("react");
|
|
41
|
-
var useAppBridge_1 = require("../../useAppBridge");
|
|
42
|
-
var useAppBridgeState = function (query) {
|
|
43
|
-
var app = useAppBridge_1.useAppBridge();
|
|
44
|
-
var _a = react_1.useState(), state = _a[0], setState = _a[1];
|
|
45
|
-
var isUnmounted = react_1.useRef(false);
|
|
46
|
-
var refresh = react_1.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var newState, _a;
|
|
48
|
-
return __generator(this, function (_b) {
|
|
49
|
-
switch (_b.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
if (!query) return [3 /*break*/, 2];
|
|
52
|
-
return [4 /*yield*/, app.getState(query)];
|
|
53
|
-
case 1:
|
|
54
|
-
_a = _b.sent();
|
|
55
|
-
return [3 /*break*/, 4];
|
|
56
|
-
case 2: return [4 /*yield*/, app.getState()];
|
|
57
|
-
case 3:
|
|
58
|
-
_a = _b.sent();
|
|
59
|
-
_b.label = 4;
|
|
60
|
-
case 4:
|
|
61
|
-
newState = _a;
|
|
62
|
-
if (isUnmounted.current) {
|
|
63
|
-
return [2 /*return*/];
|
|
64
|
-
}
|
|
65
|
-
setState(function (currentState) {
|
|
66
|
-
if (JSON.stringify(newState) === JSON.stringify(currentState)) {
|
|
67
|
-
return currentState;
|
|
68
|
-
}
|
|
69
|
-
return newState;
|
|
70
|
-
});
|
|
71
|
-
return [2 /*return*/];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}); }, [app, query]);
|
|
75
|
-
react_1.useEffect(function () {
|
|
76
|
-
refresh();
|
|
77
|
-
// Automatically check to see if the state has changed every time an action has been dispatched
|
|
78
|
-
return app.subscribe(function () {
|
|
79
|
-
refresh();
|
|
80
|
-
});
|
|
81
|
-
}, [app, refresh]);
|
|
82
|
-
react_1.useEffect(function () {
|
|
83
|
-
return function () {
|
|
84
|
-
isUnmounted.current = true;
|
|
85
|
-
};
|
|
86
|
-
}, [app]);
|
|
87
|
-
return state;
|
|
88
|
-
};
|
|
89
|
-
exports.useAppBridgeState = useAppBridgeState;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useAuthenticatedFetch';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./useAuthenticatedFetch"), exports);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AuthenticatedFetchOptions } from '@shopify/app-bridge/utilities';
|
|
2
|
-
/**
|
|
3
|
-
* useAuthenticatedFetch hook
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
* @remarks
|
|
7
|
-
* React hook that wraps the Shopify App Bridge authenticatedFetch method.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Options for the hook
|
|
10
|
-
*/
|
|
11
|
-
export declare function useAuthenticatedFetch(options?: AuthenticatedFetchOptions | undefined): typeof fetch;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useAuthenticatedFetch = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var utilities_1 = require("@shopify/app-bridge/utilities");
|
|
6
|
-
var useAppBridge_1 = require("../../useAppBridge");
|
|
7
|
-
/**
|
|
8
|
-
* useAuthenticatedFetch hook
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
* @remarks
|
|
12
|
-
* React hook that wraps the Shopify App Bridge authenticatedFetch method.
|
|
13
|
-
*
|
|
14
|
-
* @param options - Options for the hook
|
|
15
|
-
*/
|
|
16
|
-
function useAuthenticatedFetch(options) {
|
|
17
|
-
if (options === void 0) { options = undefined; }
|
|
18
|
-
var app = useAppBridge_1.useAppBridge();
|
|
19
|
-
var fetchFunction = react_1.useMemo(function () { return utilities_1.authenticatedFetch(app, options); }, [app, options]);
|
|
20
|
-
return fetchFunction;
|
|
21
|
-
}
|
|
22
|
-
exports.useAuthenticatedFetch = useAuthenticatedFetch;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useContextualSaveBar } from './useContextualSaveBar';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useContextualSaveBar = void 0;
|
|
4
|
-
var useContextualSaveBar_1 = require("./useContextualSaveBar");
|
|
5
|
-
Object.defineProperty(exports, "useContextualSaveBar", { enumerable: true, get: function () { return useContextualSaveBar_1.useContextualSaveBar; } });
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ContextualSaveBarApi } from '@shopify/app-bridge/actions/ContextualSaveBar';
|
|
2
|
-
/**
|
|
3
|
-
* useContextualSaveBar hook
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* React hook which wraps the Shopify App Bridge ContextualSaveBar action.
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export declare function useContextualSaveBar(): ContextualSaveBarApi;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.useContextualSaveBar = void 0;
|
|
15
|
-
var react_1 = require("react");
|
|
16
|
-
var ContextualSaveBar_1 = require("@shopify/app-bridge/actions/ContextualSaveBar");
|
|
17
|
-
var useAppBridge_1 = require("../../useAppBridge");
|
|
18
|
-
/**
|
|
19
|
-
* useContextualSaveBar hook
|
|
20
|
-
*
|
|
21
|
-
* @remarks
|
|
22
|
-
* React hook which wraps the Shopify App Bridge ContextualSaveBar action.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
function useContextualSaveBar() {
|
|
27
|
-
var app = useAppBridge_1.useAppBridge();
|
|
28
|
-
var visibleRef = react_1.useRef(false);
|
|
29
|
-
var _a = react_1.useState(), onSaveAction = _a[0], setOnSaveAction = _a[1];
|
|
30
|
-
var _b = react_1.useState(), onDiscardAction = _b[0], setOnDiscardAction = _b[1];
|
|
31
|
-
var contextualSaveBar = react_1.useMemo(function () {
|
|
32
|
-
return ContextualSaveBar_1.create(app);
|
|
33
|
-
}, [app]);
|
|
34
|
-
var show = react_1.useCallback(function (options) {
|
|
35
|
-
// Update options first
|
|
36
|
-
if (options) {
|
|
37
|
-
contextualSaveBar.set(options, false);
|
|
38
|
-
}
|
|
39
|
-
// Updated options will be sent with the "SHOW" action
|
|
40
|
-
contextualSaveBar.dispatch(ContextualSaveBar_1.Action.SHOW);
|
|
41
|
-
visibleRef.current = true;
|
|
42
|
-
}, [contextualSaveBar]);
|
|
43
|
-
var hide = react_1.useCallback(function () {
|
|
44
|
-
contextualSaveBar.dispatch(ContextualSaveBar_1.Action.HIDE);
|
|
45
|
-
visibleRef.current = false;
|
|
46
|
-
}, [contextualSaveBar]);
|
|
47
|
-
var saveAction = react_1.useMemo(function () { return ({
|
|
48
|
-
setOptions: function (_a) {
|
|
49
|
-
var onAction = _a.onAction, saveAction = __rest(_a, ["onAction"]);
|
|
50
|
-
var shouldUpdate = JSON.stringify(contextualSaveBar.options.saveAction) !== JSON.stringify(saveAction) &&
|
|
51
|
-
visibleRef.current;
|
|
52
|
-
setOnSaveAction(function () { return onAction; });
|
|
53
|
-
contextualSaveBar.set({ saveAction: saveAction }, shouldUpdate);
|
|
54
|
-
},
|
|
55
|
-
}); }, [contextualSaveBar]);
|
|
56
|
-
var discardAction = react_1.useMemo(function () { return ({
|
|
57
|
-
setOptions: function (_a) {
|
|
58
|
-
var onAction = _a.onAction, discardAction = __rest(_a, ["onAction"]);
|
|
59
|
-
var shouldUpdate = JSON.stringify(contextualSaveBar.options.discardAction) !==
|
|
60
|
-
JSON.stringify(discardAction) && visibleRef.current;
|
|
61
|
-
setOnDiscardAction(function () { return onAction; });
|
|
62
|
-
contextualSaveBar.set({ discardAction: discardAction }, shouldUpdate);
|
|
63
|
-
},
|
|
64
|
-
}); }, [contextualSaveBar]);
|
|
65
|
-
// Hide contextual save bar on unmount
|
|
66
|
-
react_1.useEffect(function () {
|
|
67
|
-
return function () {
|
|
68
|
-
if (visibleRef.current) {
|
|
69
|
-
hide();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}, []);
|
|
73
|
-
react_1.useEffect(function () {
|
|
74
|
-
return contextualSaveBar.subscribe(ContextualSaveBar_1.Action.DISCARD, function () {
|
|
75
|
-
onDiscardAction === null || onDiscardAction === void 0 ? void 0 : onDiscardAction();
|
|
76
|
-
});
|
|
77
|
-
}, [contextualSaveBar, onDiscardAction]);
|
|
78
|
-
react_1.useEffect(function () {
|
|
79
|
-
return contextualSaveBar.subscribe(ContextualSaveBar_1.Action.SAVE, function () {
|
|
80
|
-
onSaveAction === null || onSaveAction === void 0 ? void 0 : onSaveAction();
|
|
81
|
-
});
|
|
82
|
-
}, [contextualSaveBar, onSaveAction]);
|
|
83
|
-
return { show: show, hide: hide, saveAction: saveAction, discardAction: discardAction };
|
|
84
|
-
}
|
|
85
|
-
exports.useContextualSaveBar = useContextualSaveBar;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useFeatureRequest';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./useFeatureRequest"), exports);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { FeaturePermission, FeaturesAction } from '@shopify/app-bridge';
|
|
2
|
-
import { Group } from '@shopify/app-bridge/actions';
|
|
3
|
-
/**
|
|
4
|
-
* useFeatureRequest hook
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
* @remarks
|
|
8
|
-
* React hook performs a feature request and then returns
|
|
9
|
-
* the requested feature when permissions has been updated
|
|
10
|
-
* @param {Group} group - The requested group enum
|
|
11
|
-
* @param {string} action - The requested action. This param is optional
|
|
12
|
-
*/
|
|
13
|
-
export declare function useFeatureRequest(group: Group, action?: string): FeaturesAction | FeaturePermission | undefined;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useFeatureRequest = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var Features_1 = require("@shopify/app-bridge/actions/Features");
|
|
6
|
-
var useAppBridge_1 = require("../../useAppBridge");
|
|
7
|
-
var useFeaturesAvailable_1 = require("../useFeaturesAvailable");
|
|
8
|
-
/**
|
|
9
|
-
* useFeatureRequest hook
|
|
10
|
-
*
|
|
11
|
-
* @public
|
|
12
|
-
* @remarks
|
|
13
|
-
* React hook performs a feature request and then returns
|
|
14
|
-
* the requested feature when permissions has been updated
|
|
15
|
-
* @param {Group} group - The requested group enum
|
|
16
|
-
* @param {string} action - The requested action. This param is optional
|
|
17
|
-
*/
|
|
18
|
-
function useFeatureRequest(group, action) {
|
|
19
|
-
var app = useAppBridge_1.useAppBridge();
|
|
20
|
-
var featuresAvailable = useFeaturesAvailable_1.useFeaturesAvailable();
|
|
21
|
-
var _a = react_1.useState(), feature = _a[0], setFeature = _a[1];
|
|
22
|
-
var handleFeatureUpdate = react_1.useCallback(function (featuresAvailable) {
|
|
23
|
-
var updatedFeatures = featuresAvailable === null || featuresAvailable === void 0 ? void 0 : featuresAvailable[group];
|
|
24
|
-
if (action && (updatedFeatures === null || updatedFeatures === void 0 ? void 0 : updatedFeatures[action])) {
|
|
25
|
-
var actionPermission_1 = updatedFeatures === null || updatedFeatures === void 0 ? void 0 : updatedFeatures[action];
|
|
26
|
-
setFeature(function (currentState) {
|
|
27
|
-
if (JSON.stringify(actionPermission_1) !== JSON.stringify(currentState)) {
|
|
28
|
-
return actionPermission_1;
|
|
29
|
-
}
|
|
30
|
-
return currentState;
|
|
31
|
-
});
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
setFeature(function (currentState) {
|
|
35
|
-
if (JSON.stringify(updatedFeatures) !== JSON.stringify(currentState)) {
|
|
36
|
-
return updatedFeatures;
|
|
37
|
-
}
|
|
38
|
-
return currentState;
|
|
39
|
-
});
|
|
40
|
-
}, [group, action]);
|
|
41
|
-
react_1.useEffect(function () {
|
|
42
|
-
Features_1.create(app).dispatch(Features_1.Action.REQUEST, { feature: group, action: action });
|
|
43
|
-
}, [app, group, action]);
|
|
44
|
-
react_1.useEffect(function () {
|
|
45
|
-
handleFeatureUpdate(featuresAvailable);
|
|
46
|
-
}, [featuresAvailable, handleFeatureUpdate]);
|
|
47
|
-
return feature;
|
|
48
|
-
}
|
|
49
|
-
exports.useFeatureRequest = useFeatureRequest;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useFeaturesAvailable = void 0;
|
|
4
|
-
var useFeaturesAvailable_1 = require("./useFeaturesAvailable");
|
|
5
|
-
Object.defineProperty(exports, "useFeaturesAvailable", { enumerable: true, get: function () { return useFeaturesAvailable_1.useFeaturesAvailable; } });
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Group } from '@shopify/app-bridge/actions/types';
|
|
2
|
-
import { AppBridgeState } from '@shopify/app-bridge/client';
|
|
3
|
-
export declare type FeaturesAvailable = AppBridgeState['features'];
|
|
4
|
-
/**
|
|
5
|
-
* useFeaturesAvailable hook
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* React hook that wraps the Shopify App Bridge getFeaturesAvailable method.
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export declare function useFeaturesAvailable(...query: Group[]): import("@shopify/app-bridge/client").FeaturesAvailable<Group> | undefined;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.useFeaturesAvailable = void 0;
|
|
40
|
-
var react_1 = require("react");
|
|
41
|
-
var types_1 = require("@shopify/app-bridge/actions/Features/types");
|
|
42
|
-
var useAppBridge_1 = require("../../useAppBridge");
|
|
43
|
-
/**
|
|
44
|
-
* useFeaturesAvailable hook
|
|
45
|
-
*
|
|
46
|
-
* @remarks
|
|
47
|
-
* React hook that wraps the Shopify App Bridge getFeaturesAvailable method.
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
function useFeaturesAvailable() {
|
|
52
|
-
var _this = this;
|
|
53
|
-
var query = [];
|
|
54
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
55
|
-
query[_i] = arguments[_i];
|
|
56
|
-
}
|
|
57
|
-
var app = useAppBridge_1.useAppBridge();
|
|
58
|
-
var _a = react_1.useState(), state = _a[0], setState = _a[1];
|
|
59
|
-
var queryRef = react_1.useRef([]);
|
|
60
|
-
var refresh = react_1.useCallback(function () {
|
|
61
|
-
var isUnmounted = false;
|
|
62
|
-
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
63
|
-
var features;
|
|
64
|
-
return __generator(this, function (_a) {
|
|
65
|
-
switch (_a.label) {
|
|
66
|
-
case 0: return [4 /*yield*/, app.featuresAvailable.apply(app, queryRef.current)];
|
|
67
|
-
case 1:
|
|
68
|
-
features = _a.sent();
|
|
69
|
-
if (!isUnmounted) {
|
|
70
|
-
setState(function (currentFeatures) {
|
|
71
|
-
if (JSON.stringify(currentFeatures) === JSON.stringify(features)) {
|
|
72
|
-
return currentFeatures;
|
|
73
|
-
}
|
|
74
|
-
return features;
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return [2 /*return*/];
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}); })();
|
|
81
|
-
return function () {
|
|
82
|
-
isUnmounted = true;
|
|
83
|
-
};
|
|
84
|
-
}, [app]);
|
|
85
|
-
react_1.useEffect(function () {
|
|
86
|
-
queryRef.current = query;
|
|
87
|
-
return refresh();
|
|
88
|
-
}, [JSON.stringify(query)]);
|
|
89
|
-
react_1.useEffect(function () {
|
|
90
|
-
var onRefreshCleanup;
|
|
91
|
-
var unsubscribe = app.subscribe(types_1.Action.UPDATE, function () {
|
|
92
|
-
onRefreshCleanup = refresh();
|
|
93
|
-
});
|
|
94
|
-
return function () {
|
|
95
|
-
unsubscribe();
|
|
96
|
-
onRefreshCleanup === null || onRefreshCleanup === void 0 ? void 0 : onRefreshCleanup();
|
|
97
|
-
};
|
|
98
|
-
}, [app, refresh]);
|
|
99
|
-
return state;
|
|
100
|
-
}
|
|
101
|
-
exports.useFeaturesAvailable = useFeaturesAvailable;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useLocale } from './useLocale';
|
package/hooks/useLocale/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useLocale = void 0;
|
|
4
|
-
var useLocale_1 = require("./useLocale");
|
|
5
|
-
Object.defineProperty(exports, "useLocale", { enumerable: true, get: function () { return useLocale_1.useLocale; } });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useLocale(): string | undefined;
|