@thor-commerce/app-bridge-react 0.7.3 → 0.9.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/README.md +48 -0
- package/dist/browser.cjs +1034 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +16 -0
- package/dist/browser.d.ts +16 -0
- package/dist/browser.js +37 -0
- package/dist/browser.js.map +1 -0
- package/dist/{chunk-FGZGTJQS.js → chunk-GEBMO3KT.js} +359 -241
- package/dist/chunk-GEBMO3KT.js.map +1 -0
- package/dist/chunk-ORDG3T77.js +82 -0
- package/dist/chunk-ORDG3T77.js.map +1 -0
- package/dist/index.cjs +429 -228
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -128
- package/dist/index.d.ts +4 -128
- package/dist/index.js +14 -4
- package/dist/next.cjs +415 -227
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.cts +1 -0
- package/dist/next.d.ts +1 -0
- package/dist/next.js +4 -2
- package/dist/next.js.map +1 -1
- package/dist/react-router.cjs +415 -227
- package/dist/react-router.cjs.map +1 -1
- package/dist/react-router.d.cts +1 -0
- package/dist/react-router.d.ts +1 -0
- package/dist/react-router.js +4 -2
- package/dist/react-router.js.map +1 -1
- package/dist/runtime-BsE3hxuZ.d.cts +163 -0
- package/dist/runtime-BsE3hxuZ.d.ts +163 -0
- package/dist/thor-app-bridge.js +2 -0
- package/dist/thor-app-bridge.js.map +1 -0
- package/package.json +9 -1
- package/dist/chunk-FGZGTJQS.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,6 +10,53 @@ Repository link: [thor-email-app](https://github.com/thor-commerce/thor-email-ap
|
|
|
10
10
|
npm install @thor-commerce/app-bridge-react
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
## CDN Runtime
|
|
14
|
+
|
|
15
|
+
The package now also builds a standalone browser runtime that can be hosted on a CDN.
|
|
16
|
+
|
|
17
|
+
Build it with:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The CDN-friendly artifact is:
|
|
24
|
+
|
|
25
|
+
```txt
|
|
26
|
+
dist/thor-app-bridge.js
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
You can load it before your app bundle:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<script
|
|
33
|
+
src="https://cdn.example.com/thor-app-bridge/thor-app-bridge.js"
|
|
34
|
+
data-client-id="your-client-id"
|
|
35
|
+
data-target-origin="https://dashboard.thorcommerce.com"
|
|
36
|
+
></script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For Shopify-like markup, the script also accepts `data-api-key`, but the value must still be the public Thor `clientId`, not the `clientSecret`.
|
|
40
|
+
|
|
41
|
+
That script:
|
|
42
|
+
|
|
43
|
+
- bootstraps a singleton runtime before React mounts
|
|
44
|
+
- patches same-origin `fetch` to attach Thor session tokens
|
|
45
|
+
- intercepts in-app navigation and reports sanitized paths back to the dashboard
|
|
46
|
+
- keeps embedded launch params on the iframe document URL
|
|
47
|
+
|
|
48
|
+
If you do not want auto-init, omit the data attributes and initialize it manually:
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<script src="https://cdn.example.com/thor-app-bridge/thor-app-bridge.js"></script>
|
|
52
|
+
<script>
|
|
53
|
+
window.ThorAppBridge.init({
|
|
54
|
+
clientId: "your-client-id",
|
|
55
|
+
targetOrigin: "https://dashboard.thorcommerce.com",
|
|
56
|
+
});
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
13
60
|
## Core Usage
|
|
14
61
|
|
|
15
62
|
```ts
|
|
@@ -65,6 +112,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|
|
65
112
|
`ReactRouterAppBridgeProvider` and `NextAppBridgeProvider` automatically:
|
|
66
113
|
|
|
67
114
|
- create the bridge on the client
|
|
115
|
+
- attach to the singleton runtime when the browser script already initialized it
|
|
68
116
|
- send `app:ready`
|
|
69
117
|
- emit `navigation:update` when the route changes
|
|
70
118
|
- listen for `navigation:go` and push the app to the requested route
|