@shopify/app-bridge-types 0.2.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#760](https://github.com/Shopify/extensibility/pull/760) [`4f7742e4aacb581a380c76742689dca617c86b6d`](https://github.com/Shopify/extensibility/commit/4f7742e4aacb581a380c76742689dca617c86b6d) Thanks [@Fionoble](https://github.com/Fionoble)! - Add new s-app-\* types
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#669](https://github.com/Shopify/extensibility/pull/669) [`ad18a376e0e7a4e3921fa8f394d424644eb1f7bc`](https://github.com/Shopify/extensibility/commit/ad18a376e0e7a4e3921fa8f394d424644eb1f7bc) Thanks [@SammyJoeOsborne](https://github.com/SammyJoeOsborne)! - Updating ReviewRequestDeclinedResponse type with new codes: already-open, open-in-progress, and cancelled
14
+
3
15
  ## 0.2.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -13,3 +13,26 @@ You can install Shopify App Bridge Types by using [Yarn](https://yarnpkg.com):
13
13
  ```sh
14
14
  yarn add --dev @shopify/app-bridge-types
15
15
  ```
16
+
17
+ ## Development
18
+
19
+ ### How Types are Generated
20
+
21
+ The types in this package are automatically generated from the `sandboxes/app-bridge-next` source code:
22
+
23
+ 1. Types are defined in `sandboxes/app-bridge-next/src/features/`
24
+ 2. During build, they're compiled to `sandboxes/app-bridge-next/dist/app-bridge.d.ts`
25
+ 3. The build script (`scripts/build.mjs`) processes and copies these types to the `dist` folder
26
+ 4. The processed types are then published to npm
27
+
28
+ ### Releasing a New Version
29
+
30
+ To release a new version of the types package:
31
+
32
+ 1. Make your changes to the type definitions in `sandboxes/app-bridge-next/src/features/`
33
+ 2. Run `pnpm changeset` from the root of the repository
34
+ 3. Select `@shopify/app-bridge-types` to bump its version
35
+ 4. Commit your changes
36
+ 5. CI will automatically handle building and publishing the updated package
37
+
38
+ The automation ensures that the types stay in sync with the app-bridge-next implementation.
package/dist/index.d.ts CHANGED
@@ -4,11 +4,15 @@ import type {
4
4
  AppBridgeElements,
5
5
  AppBridgeAttributes,
6
6
  UIModalElement as BaseUIModalElement,
7
+ SAppWindowElement as BaseSAppWindowElement,
7
8
  UINavMenuElement as BaseUINavMenuElement,
9
+ SAppNavElement as BaseSAppNavElement,
8
10
  UITitleBarElement as BaseUITitleBarElement,
9
11
  UISaveBarElement as BaseUISaveBarElement,
10
12
  UIModalAttributes,
13
+ SAppWindowAttributes,
11
14
  UINavMenuAttributes,
15
+ SAppNavAttributes,
12
16
  UITitleBarAttributes,
13
17
  UISaveBarAttributes,
14
18
  ToastOptions,
@@ -20,7 +24,9 @@ import type {
20
24
  export {
21
25
  ShopifyGlobal,
22
26
  UIModalAttributes,
27
+ SAppWindowAttributes,
23
28
  UINavMenuAttributes,
29
+ SAppNavAttributes,
24
30
  UITitleBarAttributes,
25
31
  UISaveBarAttributes,
26
32
  ToastOptions,
@@ -37,7 +43,9 @@ declare global {
37
43
  interface HTMLAnchorElement extends AugmentedElement<'a'> {}
38
44
 
39
45
  interface UIModalElement extends BaseUIModalElement {}
46
+ interface SAppWindowElement extends BaseSAppWindowElement {}
40
47
  interface UINavMenuElement extends BaseUINavMenuElement {}
48
+ interface SAppNavElement extends BaseSAppNavElement {}
41
49
  interface UITitleBarElement extends BaseUITitleBarElement {}
42
50
  interface UISaveBarElement extends BaseUISaveBarElement {}
43
51
 
package/dist/shopify.ts CHANGED
@@ -136,7 +136,9 @@ interface AppBridgeConfig {
136
136
 
137
137
  export interface AppBridgeElements {
138
138
  'ui-modal': UIModalAttributes;
139
+ 's-app-window': SAppWindowAttributes;
139
140
  'ui-nav-menu': UINavMenuAttributes;
141
+ 's-app-nav': SAppNavAttributes;
140
142
  'ui-save-bar': UISaveBarAttributes;
141
143
  'ui-title-bar': UITitleBarAttributes;
142
144
  }
@@ -364,7 +366,7 @@ interface ExtensionActivation {
364
366
  }
365
367
 
366
368
  /**
367
- * Contains the status information for the App's extension.
369
+ * Contains the status information for the app's extension.
368
370
  * This includes the extension's handle, and activation targets.
369
371
  */
370
372
  interface ExtensionInfo {
@@ -918,7 +920,7 @@ type ResourceTypes = {
918
920
  collection: Collection;
919
921
  };
920
922
 
921
- type ReviewRequestDeclinedCode = 'mobile-app' | 'already-reviewed' | 'annual-limit-reached' | 'cooldown-period' | 'merchant-ineligible' | 'recently-installed';
923
+ type ReviewRequestDeclinedCode = 'mobile-app' | 'already-reviewed' | 'annual-limit-reached' | 'cooldown-period' | 'merchant-ineligible' | 'recently-installed' | 'already-open' | 'open-in-progress' | 'cancelled';
922
924
 
923
925
  interface ReviewRequestDeclinedResponse {
924
926
  success: false;
@@ -943,6 +945,66 @@ interface RuleSet {
943
945
  rules: CollectionRule[];
944
946
  }
945
947
 
948
+ export interface SAppNavAttributes {
949
+ children?: any;
950
+ }
951
+
952
+ interface SAppNavElement_2 extends HTMLElement {
953
+ }
954
+ export type { SAppNavElement_2 as SAppNavElement }
955
+
956
+ export interface SAppWindowAttributes {
957
+ /**
958
+ * A unique identifier for the S-App-Window
959
+ */
960
+ id?: string;
961
+ /**
962
+ * The URL of the content to display within the S-App-Window.
963
+ * S-App-Window only supports src-based content (required).
964
+ */
965
+ src: string;
966
+ }
967
+
968
+ interface _SAppWindowElement {
969
+ /**
970
+ * Always returns undefined for s-app-window (src-only)
971
+ */
972
+ readonly content: undefined;
973
+ /**
974
+ * A getter/setter for the s-app-window src URL
975
+ */
976
+ src?: string;
977
+ /**
978
+ * A getter for the Window object of the s-app-window iframe.
979
+ * Only accessible when the s-app-window is open.
980
+ */
981
+ readonly contentWindow?: Window | null;
982
+ /**
983
+ * Shows the s-app-window element
984
+ */
985
+ show?(): Promise<void>;
986
+ /**
987
+ * Hides the s-app-window element
988
+ */
989
+ hide?(): Promise<void>;
990
+ /**
991
+ * Toggles the s-app-window element between showing and hidden states
992
+ */
993
+ toggle?(): Promise<void>;
994
+ /**
995
+ * Add 'show' | 'hide' event listeners.
996
+ */
997
+ addEventListener?(type: 'show' | 'hide', listener: EventListenerOrEventListenerObject): void;
998
+ /**
999
+ * Remove 'show' | 'hide' event listeners.
1000
+ */
1001
+ removeEventListener?(type: 'show' | 'hide', listener: EventListenerOrEventListenerObject): void;
1002
+ }
1003
+
1004
+ interface SAppWindowElement_2 extends Omit<HTMLElement, 'addEventListener' | 'removeEventListener'>, Required<Omit<_SAppWindowElement, 'src' | 'contentWindow'>>, Pick<_SAppWindowElement, 'src' | 'contentWindow'> {
1005
+ }
1006
+ export type { SAppWindowElement_2 as SAppWindowElement }
1007
+
946
1008
  interface SaveBarApi extends Required<_SaveBarApi> {
947
1009
  }
948
1010
 
@@ -963,9 +1025,9 @@ interface _SaveBarApi {
963
1025
  */
964
1026
  toggle?(id: string): Promise<void>;
965
1027
  /**
966
- * Show leave confirmation dialog if necessary. This promise is resolved when there is no visible save bar or user confirms to leave.
1028
+ * Checks if saveBar is shown. This promise resolves if the save bar is not shown. Uses this method before navigating away from the page only when you have a custom routing that is not anchor tag.
967
1029
  */
968
- leaveConfirmation(): Promise<void>;
1030
+ leaveConfirmation?(): Promise<void>;
969
1031
  }
970
1032
 
971
1033
  interface ScannerApi {
@@ -1146,7 +1208,7 @@ interface _UIModalElement {
1146
1208
  /**
1147
1209
  * A getter/setter that is used to set modal variant.
1148
1210
  */
1149
- variant?: Variant;
1211
+ variant?: 'small' | 'base' | 'large' | 'max';
1150
1212
  /**
1151
1213
  * A getter/setter that is used to get the DOM content of the modal
1152
1214
  * element and update the content after the modal has been opened.
@@ -1164,15 +1226,15 @@ interface _UIModalElement {
1164
1226
  */
1165
1227
  readonly contentWindow?: Window | null;
1166
1228
  /**
1167
- * Shows the save bar element
1229
+ * Shows the modal element
1168
1230
  */
1169
1231
  show?(): Promise<void>;
1170
1232
  /**
1171
- * Hides the save bar element
1233
+ * Hides the modal element
1172
1234
  */
1173
1235
  hide?(): Promise<void>;
1174
1236
  /**
1175
- * Toggles the save bar element between the showing and hidden states
1237
+ * Toggles the modal element between the showing and hidden states
1176
1238
  */
1177
1239
  toggle?(): Promise<void>;
1178
1240
  /**
@@ -1193,33 +1255,14 @@ interface UIModalElement_2 extends Omit<HTMLElement, 'addEventListener' | 'remov
1193
1255
  }
1194
1256
  export type { UIModalElement_2 as UIModalElement }
1195
1257
 
1196
- export interface UINavMenuAttributes extends _UINavMenuAttributes {
1258
+ export interface UINavMenuAttributes {
1197
1259
  children?: any;
1198
1260
  }
1199
1261
 
1200
- interface _UINavMenuAttributes {
1201
- children?: [UINavMenuFirstChild, ...UINavMenuChildren[]];
1202
- }
1203
-
1204
- interface UINavMenuChildren {
1205
- a?: {
1206
- href: string;
1207
- children: string;
1208
- };
1209
- }
1210
-
1211
1262
  interface UINavMenuElement_2 extends HTMLElement {
1212
1263
  }
1213
1264
  export type { UINavMenuElement_2 as UINavMenuElement }
1214
1265
 
1215
- interface UINavMenuFirstChild {
1216
- a: {
1217
- rel: 'home';
1218
- href: string;
1219
- children?: string;
1220
- };
1221
- }
1222
-
1223
1266
  export interface UISaveBarAttributes extends _UISaveBarAttributes {
1224
1267
  children?: any;
1225
1268
  }
@@ -1311,6 +1354,9 @@ interface _UITitleBarAttributes {
1311
1354
  }
1312
1355
 
1313
1356
  interface UITitleBarChildren {
1357
+ /**
1358
+ * Note that anchor tag elements are not supported in Remix. You can use Remix's `<Link>` component instead.
1359
+ */
1314
1360
  a?: BaseElementAttributes & {
1315
1361
  variant?: 'breadcrumb' | 'primary';
1316
1362
  };
@@ -1349,8 +1395,6 @@ type UserApi = () => Promise<User>;
1349
1395
  */
1350
1396
  type UserResult = 'granted-all' | 'declined-all';
1351
1397
 
1352
- type Variant = 'small' | 'base' | 'large' | 'max';
1353
-
1354
1398
  interface WebVitalsApi {
1355
1399
  onReport?: (callback: WebVitalsCallback | null) => Promise<void>;
1356
1400
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/app-bridge-types",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Companion types library for the Shopify App Bridge script",
5
5
  "private": false,
6
6
  "publishConfig": {