@userflow-tech/react-native 0.1.0 → 0.1.1

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.
Files changed (142) hide show
  1. package/README.md +24 -14
  2. package/app.plugin.js +3 -0
  3. package/babel-plugin/index.d.ts +43 -0
  4. package/babel-plugin/index.d.ts.map +1 -0
  5. package/babel-plugin/index.js +854 -0
  6. package/babel-plugin/index.js.map +1 -0
  7. package/docs/deep-linking.md +2 -2
  8. package/docs/troubleshooting.md +2 -2
  9. package/expo-plugin/withUserflow.d.ts +17 -0
  10. package/expo-plugin/withUserflow.d.ts.map +1 -0
  11. package/expo-plugin/withUserflow.js +99 -0
  12. package/expo-plugin/withUserflow.js.map +1 -0
  13. package/lib/commonjs/anchors/AutoAnchorRegistry.js +1 -1
  14. package/lib/commonjs/anchors/autoAnchor.js +1 -1
  15. package/lib/commonjs/anchors/hintsCodec.js +1 -1
  16. package/lib/commonjs/pairing/diagnostics.js +2 -2
  17. package/lib/commonjs/pairing/diagnostics.js.map +1 -1
  18. package/lib/commonjs/version.js +1 -1
  19. package/lib/module/anchors/AutoAnchorRegistry.js +1 -1
  20. package/lib/module/anchors/autoAnchor.js +1 -1
  21. package/lib/module/anchors/hintsCodec.js +1 -1
  22. package/lib/module/pairing/diagnostics.js +2 -2
  23. package/lib/module/pairing/diagnostics.js.map +1 -1
  24. package/lib/module/version.js +1 -1
  25. package/lib/typescript/commonjs/src/anchors/AutoAnchorRegistry.d.ts +1 -1
  26. package/lib/typescript/commonjs/src/anchors/AutoAnchorRegistry.d.ts.map +1 -1
  27. package/lib/typescript/commonjs/src/anchors/autoAnchor.d.ts +1 -1
  28. package/lib/typescript/commonjs/src/anchors/hintsCodec.d.ts +1 -1
  29. package/lib/typescript/commonjs/src/version.d.ts +1 -1
  30. package/lib/typescript/module/src/anchors/AutoAnchorRegistry.d.ts +1 -1
  31. package/lib/typescript/module/src/anchors/AutoAnchorRegistry.d.ts.map +1 -1
  32. package/lib/typescript/module/src/anchors/autoAnchor.d.ts +1 -1
  33. package/lib/typescript/module/src/anchors/hintsCodec.d.ts +1 -1
  34. package/lib/typescript/module/src/version.d.ts +1 -1
  35. package/package.json +15 -7
  36. package/src/anchors/AutoAnchorRegistry.ts +1 -1
  37. package/src/anchors/autoAnchor.ts +1 -1
  38. package/src/anchors/hintsCodec.ts +1 -1
  39. package/src/pairing/diagnostics.ts +2 -2
  40. package/src/version.ts +1 -1
  41. package/vendor/core/LICENSE +76 -0
  42. package/vendor/core/README.md +9 -0
  43. package/vendor/core/dist/attributes.d.ts +16 -0
  44. package/vendor/core/dist/attributes.d.ts.map +1 -0
  45. package/vendor/core/dist/attributes.js +55 -0
  46. package/vendor/core/dist/attributes.js.map +1 -0
  47. package/vendor/core/dist/constants.d.ts +21 -0
  48. package/vendor/core/dist/constants.d.ts.map +1 -0
  49. package/vendor/core/dist/constants.js +21 -0
  50. package/vendor/core/dist/constants.js.map +1 -0
  51. package/vendor/core/dist/engine/ClientConditionEngine.d.ts +68 -0
  52. package/vendor/core/dist/engine/ClientConditionEngine.d.ts.map +1 -0
  53. package/vendor/core/dist/engine/ClientConditionEngine.js +197 -0
  54. package/vendor/core/dist/engine/ClientConditionEngine.js.map +1 -0
  55. package/vendor/core/dist/engine/FlowSessionEngine.d.ts +92 -0
  56. package/vendor/core/dist/engine/FlowSessionEngine.d.ts.map +1 -0
  57. package/vendor/core/dist/engine/FlowSessionEngine.js +310 -0
  58. package/vendor/core/dist/engine/FlowSessionEngine.js.map +1 -0
  59. package/vendor/core/dist/engine/PairingEngine.d.ts +92 -0
  60. package/vendor/core/dist/engine/PairingEngine.d.ts.map +1 -0
  61. package/vendor/core/dist/engine/PairingEngine.js +302 -0
  62. package/vendor/core/dist/engine/PairingEngine.js.map +1 -0
  63. package/vendor/core/dist/engine/UserflowCore.d.ts +126 -0
  64. package/vendor/core/dist/engine/UserflowCore.d.ts.map +1 -0
  65. package/vendor/core/dist/engine/UserflowCore.js +266 -0
  66. package/vendor/core/dist/engine/UserflowCore.js.map +1 -0
  67. package/vendor/core/dist/engine/handleActions.d.ts +19 -0
  68. package/vendor/core/dist/engine/handleActions.d.ts.map +1 -0
  69. package/vendor/core/dist/engine/handleActions.js +71 -0
  70. package/vendor/core/dist/engine/handleActions.js.map +1 -0
  71. package/vendor/core/dist/engine/interpolateSessionData.d.ts +7 -0
  72. package/vendor/core/dist/engine/interpolateSessionData.d.ts.map +1 -0
  73. package/vendor/core/dist/engine/interpolateSessionData.js +29 -0
  74. package/vendor/core/dist/engine/interpolateSessionData.js.map +1 -0
  75. package/vendor/core/dist/errors.d.ts +9 -0
  76. package/vendor/core/dist/errors.d.ts.map +1 -0
  77. package/vendor/core/dist/errors.js +15 -0
  78. package/vendor/core/dist/errors.js.map +1 -0
  79. package/vendor/core/dist/eventAttributes.d.ts +7 -0
  80. package/vendor/core/dist/eventAttributes.d.ts.map +1 -0
  81. package/vendor/core/dist/eventAttributes.js +31 -0
  82. package/vendor/core/dist/eventAttributes.js.map +1 -0
  83. package/vendor/core/dist/index.d.ts +30 -0
  84. package/vendor/core/dist/index.d.ts.map +1 -0
  85. package/vendor/core/dist/index.js +21 -0
  86. package/vendor/core/dist/index.js.map +1 -0
  87. package/vendor/core/dist/transport/backoff.d.ts +11 -0
  88. package/vendor/core/dist/transport/backoff.d.ts.map +1 -0
  89. package/vendor/core/dist/transport/backoff.js +17 -0
  90. package/vendor/core/dist/transport/backoff.js.map +1 -0
  91. package/vendor/core/dist/transport/pairing.d.ts +121 -0
  92. package/vendor/core/dist/transport/pairing.d.ts.map +1 -0
  93. package/vendor/core/dist/transport/pairing.js +551 -0
  94. package/vendor/core/dist/transport/pairing.js.map +1 -0
  95. package/vendor/core/dist/transport/phoenix.d.ts +223 -0
  96. package/vendor/core/dist/transport/phoenix.d.ts.map +1 -0
  97. package/vendor/core/dist/transport/phoenix.js +757 -0
  98. package/vendor/core/dist/transport/phoenix.js.map +1 -0
  99. package/vendor/core/dist/transport/rateLimiter.d.ts +17 -0
  100. package/vendor/core/dist/transport/rateLimiter.d.ts.map +1 -0
  101. package/vendor/core/dist/transport/rateLimiter.js +30 -0
  102. package/vendor/core/dist/transport/rateLimiter.js.map +1 -0
  103. package/vendor/core/dist/transport/scheduler.d.ts +12 -0
  104. package/vendor/core/dist/transport/scheduler.d.ts.map +1 -0
  105. package/vendor/core/dist/transport/scheduler.js +11 -0
  106. package/vendor/core/dist/transport/scheduler.js.map +1 -0
  107. package/vendor/core/dist/types.d.ts +35 -0
  108. package/vendor/core/dist/types.d.ts.map +1 -0
  109. package/vendor/core/dist/types.js +2 -0
  110. package/vendor/core/dist/types.js.map +1 -0
  111. package/vendor/core/dist/version.d.ts +3 -0
  112. package/vendor/core/dist/version.d.ts.map +1 -0
  113. package/vendor/core/dist/version.js +3 -0
  114. package/vendor/core/dist/version.js.map +1 -0
  115. package/vendor/core/package.json +20 -0
  116. package/vendor/protocol/LICENSE +76 -0
  117. package/vendor/protocol/README.md +8 -0
  118. package/vendor/protocol/dist/autoData.d.ts +232 -0
  119. package/vendor/protocol/dist/autoData.d.ts.map +1 -0
  120. package/vendor/protocol/dist/autoData.js +78 -0
  121. package/vendor/protocol/dist/autoData.js.map +1 -0
  122. package/vendor/protocol/dist/events.d.ts +16 -0
  123. package/vendor/protocol/dist/events.d.ts.map +1 -0
  124. package/vendor/protocol/dist/events.js +8 -0
  125. package/vendor/protocol/dist/events.js.map +1 -0
  126. package/vendor/protocol/dist/flows.d.ts +298 -0
  127. package/vendor/protocol/dist/flows.d.ts.map +1 -0
  128. package/vendor/protocol/dist/flows.js +154 -0
  129. package/vendor/protocol/dist/flows.js.map +1 -0
  130. package/vendor/protocol/dist/index.d.ts +24 -0
  131. package/vendor/protocol/dist/index.d.ts.map +1 -0
  132. package/vendor/protocol/dist/index.js +16 -0
  133. package/vendor/protocol/dist/index.js.map +1 -0
  134. package/vendor/protocol/dist/messages.d.ts +166 -0
  135. package/vendor/protocol/dist/messages.d.ts.map +1 -0
  136. package/vendor/protocol/dist/messages.js +57 -0
  137. package/vendor/protocol/dist/messages.js.map +1 -0
  138. package/vendor/protocol/dist/pairing.d.ts +56 -0
  139. package/vendor/protocol/dist/pairing.d.ts.map +1 -0
  140. package/vendor/protocol/dist/pairing.js +146 -0
  141. package/vendor/protocol/dist/pairing.js.map +1 -0
  142. package/vendor/protocol/package.json +17 -0
package/README.md CHANGED
@@ -9,10 +9,10 @@ release for every content change.
9
9
 
10
10
  ## Requirements
11
11
 
12
- | Peer dependency | Required? | Why |
12
+ | Peer / dependency | Required? | Why |
13
13
  | ------------------------------------------- | --------- | ------------------------------------------------------------- |
14
14
  | `react`, `react-native` | Yes | Host runtime. |
15
- | `@react-native-async-storage/async-storage` | Yes | Persists the anonymous user id across launches. |
15
+ | `@react-native-async-storage/async-storage` | Yes (dep) | Persists the anonymous user id. Installed with this package. |
16
16
  | `react-native-safe-area-context` | Optional | Correct insets for modal/tooltip surfaces. |
17
17
  | `@react-navigation/native` | Optional | Screen tracking + NAVIGATE routing (React Navigation). |
18
18
  | `expo-router` | Optional | Screen tracking + NAVIGATE routing (Expo Router). |
@@ -29,15 +29,28 @@ compatible with Expo Go.
29
29
 
30
30
  ## Install
31
31
 
32
+ Packages publish to the private `@userflow-tech` npm org. Create a **granular
33
+ access token** on npm (Read-only, limited to `@userflow-tech`) and put it in
34
+ the host app’s `.npmrc` via an env var — do not commit the token:
35
+
36
+ ```ini
37
+ @userflow-tech:registry=https://registry.npmjs.org/
38
+ //registry.npmjs.org/:_authToken=${NPM_TOKEN}
39
+ ```
40
+
32
41
  ```bash
33
- # Expo (dev build) — include the config plugin for Builder deep-link schemes
34
- npx expo install @userflow-tech/react-native @userflow-tech/expo @react-native-async-storage/async-storage
42
+ # Expo (dev build)
43
+ npx expo install @userflow-tech/react-native
35
44
 
36
45
  # Bare React Native
37
- npm install @userflow-tech/react-native @react-native-async-storage/async-storage
46
+ npm install @userflow-tech/react-native
38
47
  cd ios && pod install
39
48
  ```
40
49
 
50
+ `@react-native-async-storage/async-storage` is a dependency of this package and
51
+ is installed automatically. If autolinking misses it, run
52
+ `npx expo install @react-native-async-storage/async-storage`.
53
+
41
54
  Optional peers as needed:
42
55
 
43
56
  ```bash
@@ -45,11 +58,8 @@ npx expo install react-native-safe-area-context @react-native-community/netinfo
45
58
  # and either expo-router or @react-navigation/native, depending on your router
46
59
  ```
47
60
 
48
- For local tarball installs from this monorepo (before the private registry is
49
- set up), pack with `pnpm pack:all` at the repo root and install **all four**
50
- tarballs together — a single `@userflow-tech/react-native` tarball alone will fail
51
- because `@userflow-tech/core@0.1.0` is not on the public registry, and Expo hosts
52
- need `@userflow-tech/expo` for scheme registration. Steps:
61
+ For local tarball installs from this monorepo, pack with `pnpm pack:all` at the
62
+ repo root and install the single `@userflow-tech/react-native` tarball. Steps:
53
63
  `docs/local-testing.md` in the monorepo.
54
64
 
55
65
  ## Quick start
@@ -196,9 +206,9 @@ Full contract, prop priority, missing-target behavior, and duplicate-id rules:
196
206
  To preview draft flows from the Userflow builder onto a device (QR / deep link):
197
207
 
198
208
  1. Register the environment's **`scheme_id`** (e.g. `userflow-257587` — **not**
199
- the env UUID) with the `@userflow-tech/expo` config plugin, then **rebuild
200
- native** (`npx expo prebuild` / a new development client). Metro reload is
201
- not enough.
209
+ the env UUID) with the `@userflow-tech/react-native` config plugin, then
210
+ **rebuild native** (`npx expo prebuild` / a new development client). Metro
211
+ reload is not enough.
202
212
  2. Call `Userflow.init` (optionally with `pairingEndpoint` / `serverEndpoint`
203
213
  for staging or local stacks) and wrap the tree in `UserflowProvider`.
204
214
  3. Open the builder Preview dialog → **Pair a device** → scan/open the QR. The
@@ -208,7 +218,7 @@ To preview draft flows from the Userflow builder onto a device (QR / deep link):
208
218
  ```json
209
219
  {
210
220
  "expo": {
211
- "plugins": [["@userflow-tech/expo", { "schemeId": "userflow-257587" }]]
221
+ "plugins": [["@userflow-tech/react-native", { "schemeId": "userflow-257587" }]]
212
222
  }
213
223
  }
214
224
  ```
package/app.plugin.js ADDED
@@ -0,0 +1,3 @@
1
+ // Expo loads this file as the config plugin entry.
2
+ // Hosts register: plugins: [['@userflow-tech/react-native', { schemeId: 'userflow-…' }]]
3
+ module.exports = require('./expo-plugin/withUserflow.js');
@@ -0,0 +1,43 @@
1
+ import type { PluginObj, PluginPass, types as BabelTypes } from '@babel/core';
2
+ export interface UserflowBabelPluginOptions {
3
+ rootDir?: string;
4
+ allowlist?: string[];
5
+ injectUfidProp?: boolean;
6
+ exclude?: string[];
7
+ /**
8
+ * When true (the default), only stamp `nativeID` (and `collapsable={false}`
9
+ * when needed). Skips the SDK import, `__ufRef` helper, ref wrapping, hints,
10
+ * and scope capture. Use this against the current official SDK, which
11
+ * resolves anchors via fiber `nativeID` matching and does not yet export
12
+ * `__userflowAutoAnchor`.
13
+ *
14
+ * Set to `false` only when the host SDK provides `__userflowAutoAnchor`
15
+ * (full auto-register mode). Enabling full mode without that export will
16
+ * inject a broken import into every stamped module.
17
+ */
18
+ stampOnly?: boolean;
19
+ }
20
+ interface PluginState extends PluginPass {
21
+ ufStamped?: boolean;
22
+ ufCallSiteCounters?: Map<string, Map<string, number>>;
23
+ /**
24
+ * Parent-scoped ordinals precomputed against the pristine JSX tree, keyed by
25
+ * opening-element node. Populated in `Program.enter` before `@babel/preset-react`
26
+ * rewrites `<El>` into `_jsx(El, …)` — otherwise earlier same-type siblings are
27
+ * already gone by the time we visit a later one and every element mis-reads as
28
+ * `#0`, colliding their `uf_<hash>` ids.
29
+ */
30
+ ufOrdinals?: WeakMap<BabelTypes.Node, {
31
+ ordinal: number;
32
+ siblingIndex: number;
33
+ }>;
34
+ }
35
+ export default function userflowAutoStamp(api: {
36
+ types: typeof BabelTypes;
37
+ template: {
38
+ statement: (tpl: string) => (replacements?: Record<string, unknown>) => BabelTypes.Statement;
39
+ };
40
+ env?: (name?: string) => boolean;
41
+ }): PluginObj<PluginState>;
42
+ export {};
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAY,SAAS,EAAE,UAAU,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAyiBxF,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,WAAY,SAAQ,UAAU;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClF;AA8GD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,GAAG,EAAE;IAC7C,KAAK,EAAE,OAAO,UAAU,CAAC;IACzB,QAAQ,EAAE;QACR,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,UAAU,CAAC,SAAS,CAAC;KAC9F,CAAC;IACF,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CAClC,GAAG,SAAS,CAAC,WAAW,CAAC,CA+TzB"}