@ionic/portals-react-native 0.7.1 → 0.8.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.
@@ -0,0 +1,159 @@
1
+ import React from 'react';
2
+ import { type EmitterSubscription, type ViewProps } from 'react-native';
3
+ export declare const PortalView: (props: PortalProps) => React.JSX.Element;
4
+ /**
5
+ * The data that is received from a subscription event.
6
+ */
7
+ export interface Message {
8
+ /** The unique subscription reference received from {@link subscribe}*/
9
+ subscriptionRef: number;
10
+ data: any;
11
+ /** The topic the message was sent from */
12
+ topic: string;
13
+ }
14
+ /**
15
+ * Subscribes to messages for a topic
16
+ *
17
+ * @param topic The topic to subscribe to
18
+ * @param onMessageReceived The callback to invoke when a message is received
19
+ * @returns A Promise<number> containing the unique subscription reference. This will need to be stored for calling {@link unsubscribe}.
20
+ */
21
+ export declare const subscribe: (topic: string, onMessageReceived: (message: Message) => void) => EmitterSubscription;
22
+ /**
23
+ * Publishes a message to the provided topic
24
+ *
25
+ * @param topic The topic to publish the message to
26
+ * @param data The data to publish to subscribers
27
+ */
28
+ export declare const publish: (topic: string, data: any) => void;
29
+ export type WebVitals = {
30
+ firstContentfulPaint?: (duration: number) => void;
31
+ firstInputDelay?: (duration: number) => void;
32
+ timeToFirstByte?: (duration: number) => void;
33
+ };
34
+ /**
35
+ * Validates that a valid registration key has been procured from http://ionic.io/register-portals
36
+ * @param key The registration key
37
+ * @returns Promise<void>
38
+ */
39
+ export declare const register: (key: string) => Promise<void>;
40
+ /**
41
+ * The configuration of a web application to be embedded in a React Native application.
42
+ */
43
+ export interface Portal {
44
+ /** The name of the Portal to be referenced. Must be **unique** */
45
+ name: string;
46
+ /** Any Capacitor plugins to be made available to the Portal */
47
+ plugins?: CapacitorPlugin[];
48
+ /**
49
+ * The root directory of the web application relative to Bundle.main on iOS
50
+ * and src/main/assets on Android. If omitted, `name` is used.
51
+ */
52
+ startDir?: string;
53
+ /** The name of the initial file to load. If omitted, 'index.html' is used. */
54
+ index?: string;
55
+ /** Any data needed at initial render when a portal is loaded. */
56
+ initialContext?: {
57
+ [key: string]: any;
58
+ };
59
+ assetMaps?: AssetMap[];
60
+ liveUpdate?: LiveUpdateConfig;
61
+ }
62
+ export interface CapacitorPlugin {
63
+ /** The classpath of the plugin to be used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */
64
+ androidClassPath: string;
65
+ /** The class name of the plugin to be used in iOS.
66
+ * This must be the name as it is exposed to the Objective-C runtime.
67
+ * For example, The CameraPlugin swift class is exposed to Objective-C as CAPCameraPlugin.
68
+ */
69
+ iosClassName: string;
70
+ }
71
+ export interface AssetMap {
72
+ /** The name to index the asset map by */
73
+ name: string;
74
+ /** Any path to match via the web. If omitted, {@link AssetMap#name} will be used. */
75
+ virtualPath?: string;
76
+ /** The root directory of the assets relative to Bundle.main on iOS
77
+ * and src/main/assets on Android. If omitted, the root of Bundle.main
78
+ * and src/main/assets will be used.
79
+ */
80
+ startDir?: string;
81
+ }
82
+ /**
83
+ * Props needed for rendering a {@link Portal}
84
+ */
85
+ export type PortalProps = {
86
+ portal: Portal;
87
+ webVitals?: WebVitals;
88
+ } & ViewProps;
89
+ export interface LiveUpdate {
90
+ /** The AppFlow application ID */
91
+ appId: string;
92
+ /** The AppFlow distribution channel */
93
+ channel: string;
94
+ }
95
+ /** Data needed to register a live update to be managed */
96
+ export type LiveUpdateConfig = LiveUpdate & {
97
+ syncOnAdd: boolean;
98
+ };
99
+ export interface LiveUpdateError {
100
+ /** The AppFlow application ID relating to the failure */
101
+ appId: string;
102
+ /** The step in the sync process the LiveUpdate failed on. (e.g. CHECK, UNPACK)*/
103
+ failStep: string;
104
+ /** A human readable error message */
105
+ message: string;
106
+ }
107
+ export interface Snapshot {
108
+ /** The snapshot id as found in AppFlow */
109
+ id: string;
110
+ /** The AppFlow build id that produced the snapshot */
111
+ buildId: string;
112
+ }
113
+ export interface SyncResult {
114
+ /** The {@link LiveUpdate} associated with the result */
115
+ liveUpdate: LiveUpdate;
116
+ /** The {@link Snapshot} that was sync'd */
117
+ snapshot: Snapshot | null;
118
+ /** Whether the snapshot was downloaded or already on disk */
119
+ source: 'download' | 'cache';
120
+ /** If the active application path was changed. A `false` value would indicate
121
+ * the application already has the latest code for the associated {@link LiveUpdate}
122
+ * configuration.
123
+ */
124
+ activeApplicationPathChanged: boolean;
125
+ }
126
+ /** Used for communicating sync results of multiple live updates */
127
+ export interface SyncResults {
128
+ results: SyncResult[];
129
+ errors: LiveUpdateError[];
130
+ }
131
+ /**
132
+ * Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.
133
+ * This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.
134
+ *
135
+ * @param pathToKey The *relative* path to the public key for verification.
136
+ * This path should be the same relatibe to the main application bundle on iOS and the assets directory on Android.
137
+ * @returns Promise<void>
138
+ */
139
+ export declare const enableSecureLiveUpdates: (pathToKey: string) => Promise<void>;
140
+ /**
141
+ * Syncs a single live update.
142
+ *
143
+ * @param appId The AppFlow application ID to sync.
144
+ * @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.
145
+ */
146
+ export declare const syncOne: (appId: string) => Promise<SyncResult>;
147
+ /**
148
+ * Syncs many live updates.
149
+ *
150
+ * @param appIds The AppFlow application IDs to sync.
151
+ * @returns Promise<SyncResults>
152
+ */
153
+ export declare const syncSome: (appIds: string[]) => Promise<SyncResults>;
154
+ /**
155
+ * Syncs all registered LiveUpdates
156
+ * @returns Promise<SyncResults>
157
+ */
158
+ export declare const syncAll: () => Promise<SyncResults>;
159
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,mBAAmB,EAIxB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAMtB,eAAO,MAAM,UAAU,UAAW,WAAW,sB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IAAI,CAEd,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,UAAiB,MAAM,KAAG,QAAQ,UAAU,CAE/D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,WAAkB,MAAM,EAAE,KAAG,QAAQ,WAAW,CAEpE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,OAAO,QAAa,QAAQ,WAAW,CAEnD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ionic/portals-react-native",
3
- "version": "0.7.1",
3
+ "version": "0.8.1",
4
4
  "description": "Portals for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -57,19 +57,24 @@
57
57
  "devDependencies": {
58
58
  "@commitlint/config-conventional": "^17.0.2",
59
59
  "@evilmartians/lefthook": "^1.5.0",
60
- "@react-native/eslint-config": "^0.73.1",
60
+ "@react-native/babel-preset": "0.75.4",
61
+ "@react-native/eslint-config": "0.75.4",
62
+ "@react-native/metro-config": "0.75.4",
63
+ "@react-native/typescript-config": "0.75.4",
61
64
  "@release-it/conventional-changelog": "^5.0.0",
62
65
  "@types/jest": "^29.5.5",
63
66
  "@types/react": "^18.2.44",
67
+ "@typescript-eslint/eslint-plugin": "latest",
64
68
  "commitlint": "^17.0.2",
65
69
  "del-cli": "^5.1.0",
66
70
  "eslint": "^8.51.0",
67
71
  "eslint-config-prettier": "^9.0.0",
68
- "eslint-plugin-prettier": "^5.0.1",
72
+ "eslint-plugin-jest": "^28.11.0",
73
+ "eslint-plugin-prettier": "^5.2.3",
69
74
  "jest": "^29.7.0",
70
75
  "prettier": "^3.0.3",
71
- "react": "18.2.0",
72
- "react-native": "0.74.2",
76
+ "react": "18.3.1",
77
+ "react-native": "0.75.4",
73
78
  "react-native-builder-bob": "^0.23.2",
74
79
  "release-it": "^15.0.0",
75
80
  "turbo": "^1.10.7",
@@ -77,7 +82,8 @@
77
82
  "typescript": "^5.2.2"
78
83
  },
79
84
  "resolutions": {
80
- "@types/react": "^18.2.44"
85
+ "@types/react": "^18.2.44",
86
+ "typescript": "5.2.2"
81
87
  },
82
88
  "peerDependencies": {
83
89
  "react": "*",
@@ -107,6 +113,9 @@
107
113
  "@react-native",
108
114
  "prettier"
109
115
  ],
116
+ "plugins": [
117
+ "prettier"
118
+ ],
110
119
  "rules": {
111
120
  "prettier/prettier": [
112
121
  "error",
@@ -115,7 +124,8 @@
115
124
  "singleQuote": true,
116
125
  "tabWidth": 2,
117
126
  "trailingComma": "es5",
118
- "useTabs": false
127
+ "useTabs": false,
128
+ "endOfLine": "auto"
119
129
  }
120
130
  ]
121
131
  }
@@ -151,4 +161,4 @@
151
161
  ]
152
162
  ]
153
163
  }
154
- }
164
+ }
package/ios/Podfile DELETED
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../node_modules/react-native/scripts/react_native_pods'
4
- require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
5
-
6
- platform :ios, '14.0'
7
-
8
- target 'ReactNativePortals' do
9
- # Comment the next line if you don't want to use dynamic frameworks
10
- config = use_native_modules!
11
- use_react_native!(path: config[:reactNativePath])
12
- # Pods for ReactNativePortals
13
- pod 'IonicPortals', '~> 0.11.0'
14
- pod 'IonicLiveUpdates', '~> 0.5.2'
15
- end
16
-
17
- dynamic_frameworks = ['Capacitor', 'CapacitorCordova']
18
-
19
- pre_install do |installer|
20
- installer.pod_targets.each do |pod|
21
- if dynamic_frameworks.include?(pod.name)
22
- def pod.static_framework?
23
- false
24
- end
25
- def pod.build_type
26
- Pod::BuildType.dynamic_framework
27
- end
28
- end
29
- end
30
- end
31
-
32
- post_install do |installer|
33
- installer.pods_project.targets.each do |target|
34
- target.build_configurations.each do |config|
35
- config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)',
36
- '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
37
- end
38
- end
39
- end