react-native-webview-stream-chunks 0.1.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 ADDED
@@ -0,0 +1,109 @@
1
+ # react-native-webview-stream-chunks
2
+
3
+ Stream large payloads into a React Native WebView by chunking, inject them as `<script>` tags, and optionally re-execute scripts — through a high-level sender API.
4
+
5
+ ## Features
6
+
7
+ - High-level sender (`WebViewStreamSender`) instead of manual low-level events.
8
+ - Per-injection script options on `finalizePayload(options)`.
9
+ - Supports injecting multiple different script tags in one session.
10
+ - Optional script re-execution (`all` via default selector, or specific selector).
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install react-native-webview-stream-chunks
16
+ # or
17
+ pnpm add react-native-webview-stream-chunks
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### 1) Generate the preload script (receiver side)
23
+
24
+ ```ts
25
+ import { getWebViewStreamChunksPreloadScript } from 'react-native-webview-stream-chunks';
26
+
27
+ const preloadScript = getWebViewStreamChunksPreloadScript({
28
+ receiverReadyCallbackPath: 'myApp.onReady', // Optional
29
+ });
30
+ ```
31
+
32
+ Inject `preloadScript` into your WebView (for example with `injectedJavaScript`).
33
+
34
+ ### 2) Send data from React Native (sender side)
35
+
36
+ ```ts
37
+ import { WebViewStreamSender } from 'react-native-webview-stream-chunks';
38
+
39
+ const sender = new WebViewStreamSender((type, data) => {
40
+ const message = JSON.stringify({ type, data });
41
+ webViewRef.current?.injectJavaScript(`window.onStreamChunksToWebView(${message});`);
42
+ });
43
+
44
+ sender.checkReceiverReady();
45
+ sender.setContent(skeletonHtml);
46
+
47
+ for (const chunk of chunks) {
48
+ sender.appendChunk(chunk);
49
+ }
50
+
51
+ sender.finalizePayload({
52
+ scriptType: 'application/json',
53
+ scriptClassName: 'my-payload-store',
54
+ scriptTagName: 'main-store',
55
+ anchorSelector: '#styleArea',
56
+ });
57
+
58
+ sender.reexecuteScripts();
59
+ // sender.reexecuteScripts('script[data-boot]');
60
+ ```
61
+
62
+ ### 3) Inject multiple script tags
63
+
64
+ ```ts
65
+ // First payload
66
+ for (const chunk of firstChunks) sender.appendChunk(chunk);
67
+ sender.finalizePayload({
68
+ scriptType: 'application/json',
69
+ scriptClassName: 'store-a',
70
+ scriptTagName: 'users',
71
+ anchorSelector: '#styleArea',
72
+ });
73
+
74
+ // Second payload
75
+ for (const chunk of secondChunks) sender.appendChunk(chunk);
76
+ sender.finalizePayload({
77
+ scriptType: 'text/javascript',
78
+ scriptClassName: 'boot-script',
79
+ scriptTagName: 'runtime',
80
+ anchorSelector: '#styleArea',
81
+ });
82
+ ```
83
+
84
+ ## API
85
+
86
+ ### `WebViewStreamSender`
87
+
88
+ | Method | Description |
89
+ | ----------------------------- | ----------------------------------------------------------------------- |
90
+ | `checkReceiverReady()` | Ping receiver and trigger its configured ready callback path. |
91
+ | `setContent(html)` | Replace `document.body.innerHTML` and reset buffered chunks. |
92
+ | `appendChunk(chunk)` | Append one payload chunk to the receiver buffer. |
93
+ | `finalizePayload(options?)` | Join buffered chunks and inject one `<script>` with per-call options. |
94
+ | `reexecuteScripts(selector?)` | Re-execute matching script tags by clone-replace. Defaults to `script`. |
95
+
96
+ ### `finalizePayload(options)`
97
+
98
+ | Option | Default | Description |
99
+ | ----------------- | ------------------------ | ------------------------------------------------------------------------------- |
100
+ | `scriptType` | `application/json` | `type` attribute of injected `<script>`. |
101
+ | `scriptClassName` | `webview-stream-payload` | Class used for this payload script (also used to exclude it from re-execution). |
102
+ | `scriptTagName` | `default-payload` | Extra class/name tag for easier identification. |
103
+ | `anchorSelector` | `#styleArea` | Inject payload script after this element. |
104
+
105
+ ### Preload options
106
+
107
+ | Option | Default | Description |
108
+ | --------------------------- | ------- | ------------------------------------------------------------------ |
109
+ | `receiverReadyCallbackPath` | `''` | (Optional) Dot-path on `window` invoked by `checkReceiverReady()`. |
@@ -0,0 +1,7 @@
1
+ export { WebViewStreamSender } from './sender';
2
+ export type { WebViewStreamTransport } from './sender';
3
+ export { createWebViewStreamChunksPreloadScript, getWebViewStreamChunksPreloadScript } from './streamChunksPreloadScript';
4
+ export type { PayloadScriptInjectionOptions, WebViewStreamPreloadScriptOptions } from './streamChunksPreloadScript';
5
+ export { WebViewStreamEventTypes } from './streamChunksPreloadScript';
6
+ export type { WebViewStreamEventType, WebViewStreamReceiverEvent } from './streamChunksPreloadScript';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,YAAY,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGvD,OAAO,EAAE,sCAAsC,EAAE,mCAAmC,EAAE,MAAM,6BAA6B,CAAC;AAC1H,YAAY,EAAE,6BAA6B,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAGpH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,YAAY,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ // High-level API (preferred)
2
+ export { WebViewStreamSender } from './sender';
3
+ // Preload script generators
4
+ export { createWebViewStreamChunksPreloadScript, getWebViewStreamChunksPreloadScript } from './streamChunksPreloadScript';
5
+ // Low-level event protocol (advanced usage)
6
+ export { WebViewStreamEventTypes } from './streamChunksPreloadScript';
@@ -0,0 +1,64 @@
1
+ import { type PayloadScriptInjectionOptions, type WebViewStreamEventType } from './streamChunksPreloadScript';
2
+ /**
3
+ * Transport function that delivers a message to the WebView.
4
+ * The user is responsible for implementing the actual delivery mechanism
5
+ * (e.g. `webViewRef.current.injectJavaScript()`).
6
+ */
7
+ export type WebViewStreamTransport = (eventType: WebViewStreamEventType, data?: string) => void;
8
+ /**
9
+ * High-level API for streaming content into a WebView.
10
+ *
11
+ * Wraps the low-level event protocol so callers never need to deal with
12
+ * event type constants, message serialisation, or sequencing concerns.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const sender = new WebViewStreamSender((type, data) => {
17
+ * webViewRef.current.injectJavaScript(
18
+ * `window.onStreamChunksToWebView(${JSON.stringify({ type, data })});`
19
+ * );
20
+ * });
21
+ *
22
+ * sender.checkReceiverReady();
23
+ * sender.setContent(html);
24
+ * sender.appendChunk(chunk);
25
+ * sender.finalizePayload();
26
+ * sender.reexecuteScripts();
27
+ * ```
28
+ */
29
+ export declare class WebViewStreamSender {
30
+ private readonly transport;
31
+ constructor(transport: WebViewStreamTransport);
32
+ /**
33
+ * Ask the receiver whether it is ready. The receiver will invoke its
34
+ * configured `receiverReadyCallbackPath` when it handles this event.
35
+ */
36
+ checkReceiverReady(): void;
37
+ /**
38
+ * Replace the WebView's `document.body.innerHTML` with the provided HTML.
39
+ * This also resets any previously buffered chunks.
40
+ */
41
+ setContent(html: string): void;
42
+ /**
43
+ * Buffer a chunk in the receiver. Call this as many times as needed.
44
+ */
45
+ appendChunk(chunk: string): void;
46
+ /**
47
+ * Join all buffered chunks and inject them as a single `<script>` tag
48
+ * into the DOM.
49
+ *
50
+ * This does NOT re-execute existing scripts — call `reexecuteScripts()`
51
+ * separately when needed.
52
+ */
53
+ finalizePayload(options?: PayloadScriptInjectionOptions): void;
54
+ /**
55
+ * Re-execute `<script>` tags in the DOM by replacing them with clones.
56
+ *
57
+ * @param selector - optional CSS selector to limit which scripts are
58
+ * re-executed. Defaults to `'script'` (all scripts).
59
+ * The payload `<script>` injected by `finalizePayload()` is always
60
+ * excluded automatically.
61
+ */
62
+ reexecuteScripts(selector?: string): void;
63
+ }
64
+ //# sourceMappingURL=sender.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sender.d.ts","sourceRoot":"","sources":["../src/sender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,6BAA6B,EAAE,KAAK,sBAAsB,EAA2B,MAAM,6BAA6B,CAAC;AAEvI;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,SAAS,EAAE,sBAAsB,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;gBAEvC,SAAS,EAAE,sBAAsB;IAI7C;;;OAGG;IACH,kBAAkB,IAAI,IAAI;IAI1B;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIhC;;;;;;OAMG;IACH,eAAe,CAAC,OAAO,CAAC,EAAE,6BAA6B,GAAG,IAAI;IAI9D;;;;;;;OAOG;IACH,gBAAgB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;CAG1C"}
package/dist/sender.js ADDED
@@ -0,0 +1,68 @@
1
+ import { WebViewStreamEventTypes } from './streamChunksPreloadScript';
2
+ /**
3
+ * High-level API for streaming content into a WebView.
4
+ *
5
+ * Wraps the low-level event protocol so callers never need to deal with
6
+ * event type constants, message serialisation, or sequencing concerns.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const sender = new WebViewStreamSender((type, data) => {
11
+ * webViewRef.current.injectJavaScript(
12
+ * `window.onStreamChunksToWebView(${JSON.stringify({ type, data })});`
13
+ * );
14
+ * });
15
+ *
16
+ * sender.checkReceiverReady();
17
+ * sender.setContent(html);
18
+ * sender.appendChunk(chunk);
19
+ * sender.finalizePayload();
20
+ * sender.reexecuteScripts();
21
+ * ```
22
+ */
23
+ export class WebViewStreamSender {
24
+ constructor(transport) {
25
+ this.transport = transport;
26
+ }
27
+ /**
28
+ * Ask the receiver whether it is ready. The receiver will invoke its
29
+ * configured `receiverReadyCallbackPath` when it handles this event.
30
+ */
31
+ checkReceiverReady() {
32
+ this.transport(WebViewStreamEventTypes.CHECK_RECEIVER_READY);
33
+ }
34
+ /**
35
+ * Replace the WebView's `document.body.innerHTML` with the provided HTML.
36
+ * This also resets any previously buffered chunks.
37
+ */
38
+ setContent(html) {
39
+ this.transport(WebViewStreamEventTypes.SET_CONTENT, html);
40
+ }
41
+ /**
42
+ * Buffer a chunk in the receiver. Call this as many times as needed.
43
+ */
44
+ appendChunk(chunk) {
45
+ this.transport(WebViewStreamEventTypes.APPEND_CHUNK, chunk);
46
+ }
47
+ /**
48
+ * Join all buffered chunks and inject them as a single `<script>` tag
49
+ * into the DOM.
50
+ *
51
+ * This does NOT re-execute existing scripts — call `reexecuteScripts()`
52
+ * separately when needed.
53
+ */
54
+ finalizePayload(options) {
55
+ this.transport(WebViewStreamEventTypes.FINALIZE_PAYLOAD, options ? JSON.stringify(options) : undefined);
56
+ }
57
+ /**
58
+ * Re-execute `<script>` tags in the DOM by replacing them with clones.
59
+ *
60
+ * @param selector - optional CSS selector to limit which scripts are
61
+ * re-executed. Defaults to `'script'` (all scripts).
62
+ * The payload `<script>` injected by `finalizePayload()` is always
63
+ * excluded automatically.
64
+ */
65
+ reexecuteScripts(selector) {
66
+ this.transport(WebViewStreamEventTypes.REEXECUTE_SCRIPTS, selector);
67
+ }
68
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Internal event types for the sender–receiver protocol.
3
+ * Prefer the high-level `WebViewStreamSender` API over using these directly.
4
+ */
5
+ export declare const WebViewStreamEventTypes: {
6
+ readonly CHECK_RECEIVER_READY: "CHECK_RECEIVER_READY";
7
+ readonly SET_CONTENT: "SET_CONTENT";
8
+ readonly APPEND_CHUNK: "APPEND_CHUNK";
9
+ readonly FINALIZE_PAYLOAD: "FINALIZE_PAYLOAD";
10
+ readonly REEXECUTE_SCRIPTS: "REEXECUTE_SCRIPTS";
11
+ };
12
+ export type WebViewStreamEventType = (typeof WebViewStreamEventTypes)[keyof typeof WebViewStreamEventTypes];
13
+ export type WebViewStreamReceiverEvent = {
14
+ type: WebViewStreamEventType;
15
+ data?: string;
16
+ };
17
+ export interface WebViewStreamPreloadScriptOptions {
18
+ /** Dot-separated path on `window` to call when CHECK_RECEIVER_READY fires, e.g. `'myService.onReady'` */
19
+ receiverReadyCallbackPath?: string;
20
+ }
21
+ export interface PayloadScriptInjectionOptions {
22
+ scriptType?: string;
23
+ scriptClassName?: string;
24
+ scriptTagName?: string;
25
+ anchorSelector?: string;
26
+ }
27
+ export declare const createWebViewStreamChunksPreloadScript: (options?: WebViewStreamPreloadScriptOptions) => string;
28
+ export declare const getWebViewStreamChunksPreloadScript: (options?: WebViewStreamPreloadScriptOptions) => string;
29
+ //# sourceMappingURL=streamChunksPreloadScript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streamChunksPreloadScript.d.ts","sourceRoot":"","sources":["../src/streamChunksPreloadScript.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;CAM1B,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAE5G,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,iCAAiC;IAChD,yGAAyG;IACzG,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,6BAA6B;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAoMD,eAAO,MAAM,sCAAsC,GAAI,UAAS,iCAAsC,WAGrG,CAAC;AAEF,eAAO,MAAM,mCAAmC,GAAI,UAAU,iCAAiC,WAE9F,CAAC"}
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Internal event types for the sender–receiver protocol.
3
+ * Prefer the high-level `WebViewStreamSender` API over using these directly.
4
+ */
5
+ export const WebViewStreamEventTypes = {
6
+ CHECK_RECEIVER_READY: 'CHECK_RECEIVER_READY',
7
+ SET_CONTENT: 'SET_CONTENT',
8
+ APPEND_CHUNK: 'APPEND_CHUNK',
9
+ FINALIZE_PAYLOAD: 'FINALIZE_PAYLOAD',
10
+ REEXECUTE_SCRIPTS: 'REEXECUTE_SCRIPTS',
11
+ };
12
+ // ---------------------------------------------------------------------------
13
+ // Receiver IIFE — serialised via `.toString()` and injected into the WebView.
14
+ // ---------------------------------------------------------------------------
15
+ function webViewStreamReceiverIIFE(options, eventTypes) {
16
+ let payloadChunks = [];
17
+ let contentMutationObserved = false;
18
+ const injectedPayloadScriptClasses = new Set();
19
+ function resetState() {
20
+ payloadChunks = [];
21
+ contentMutationObserved = false;
22
+ }
23
+ const targetWindow = window;
24
+ // -- receiver-ready callback resolver -------------------------------------
25
+ function runReceiverReadyCallback() {
26
+ if (!options.receiverReadyCallbackPath.trim())
27
+ return;
28
+ const segments = options.receiverReadyCallbackPath.split('.').filter(Boolean);
29
+ let current = targetWindow;
30
+ for (const segment of segments) {
31
+ if (current === null || current === undefined || typeof current !== 'object') {
32
+ current = undefined;
33
+ break;
34
+ }
35
+ current = current[segment];
36
+ }
37
+ if (typeof current === 'function') {
38
+ current();
39
+ }
40
+ }
41
+ // -- event dispatcher -----------------------------------------------------
42
+ targetWindow.onStreamChunksToWebView = function (event) {
43
+ switch (event.type) {
44
+ case eventTypes.SET_CONTENT: {
45
+ resetState();
46
+ replaceBodyContent(event.data ?? '');
47
+ break;
48
+ }
49
+ case eventTypes.APPEND_CHUNK: {
50
+ if (event.data)
51
+ payloadChunks.push(event.data);
52
+ break;
53
+ }
54
+ case eventTypes.FINALIZE_PAYLOAD: {
55
+ const waitAndInject = () => {
56
+ if (contentMutationObserved) {
57
+ injectPayloadScript(event.data);
58
+ }
59
+ else {
60
+ setTimeout(waitAndInject, 100);
61
+ }
62
+ };
63
+ waitAndInject();
64
+ break;
65
+ }
66
+ case eventTypes.REEXECUTE_SCRIPTS: {
67
+ const waitAndExec = () => {
68
+ if (contentMutationObserved) {
69
+ reexecuteScripts(event.data);
70
+ }
71
+ else {
72
+ setTimeout(waitAndExec, 100);
73
+ }
74
+ };
75
+ waitAndExec();
76
+ break;
77
+ }
78
+ case eventTypes.CHECK_RECEIVER_READY: {
79
+ runReceiverReadyCallback();
80
+ break;
81
+ }
82
+ }
83
+ };
84
+ // -- DOM helpers ----------------------------------------------------------
85
+ function replaceBodyContent(newInnerHTML) {
86
+ const observer = new MutationObserver((mutationsList, currentObserver) => {
87
+ for (const mutation of mutationsList) {
88
+ if (mutation.type === 'childList') {
89
+ currentObserver.disconnect();
90
+ contentMutationObserved = true;
91
+ return;
92
+ }
93
+ }
94
+ });
95
+ observer.observe(document.body, { childList: true });
96
+ document.body.innerHTML = newInnerHTML;
97
+ }
98
+ const defaultInjectionOptions = {
99
+ scriptType: 'application/json',
100
+ scriptClassName: 'webview-stream-payload',
101
+ scriptTagName: 'default-payload',
102
+ anchorSelector: '#styleArea',
103
+ };
104
+ function resolveInjectionOptions(rawData) {
105
+ if (!rawData) {
106
+ return defaultInjectionOptions;
107
+ }
108
+ try {
109
+ const parsed = JSON.parse(rawData);
110
+ return {
111
+ scriptType: parsed.scriptType ?? defaultInjectionOptions.scriptType,
112
+ scriptClassName: parsed.scriptClassName ?? defaultInjectionOptions.scriptClassName,
113
+ scriptTagName: parsed.scriptTagName ?? defaultInjectionOptions.scriptTagName,
114
+ anchorSelector: parsed.anchorSelector ?? defaultInjectionOptions.anchorSelector,
115
+ };
116
+ }
117
+ catch {
118
+ return defaultInjectionOptions;
119
+ }
120
+ }
121
+ function injectPayloadScript(rawData) {
122
+ try {
123
+ const injectionOptions = resolveInjectionOptions(rawData);
124
+ const fullPayload = payloadChunks.join('');
125
+ const scriptElement = document.createElement('script');
126
+ scriptElement.type = injectionOptions.scriptType;
127
+ scriptElement.classList.add(injectionOptions.scriptClassName, injectionOptions.scriptTagName);
128
+ scriptElement.textContent = fullPayload;
129
+ const anchor = document.querySelector(injectionOptions.anchorSelector);
130
+ anchor?.insertAdjacentElement('afterend', scriptElement);
131
+ injectedPayloadScriptClasses.add(injectionOptions.scriptClassName);
132
+ }
133
+ catch (error) {
134
+ console.error('[webview-stream] injectPayloadScript error', error);
135
+ }
136
+ payloadChunks = [];
137
+ }
138
+ function reexecuteScripts(selector) {
139
+ try {
140
+ const query = selector?.trim() || 'script';
141
+ const elements = Array.from(document.querySelectorAll(query));
142
+ for (const element of elements) {
143
+ if (!(element instanceof HTMLScriptElement))
144
+ continue;
145
+ let isInjectedPayloadScript = false;
146
+ for (const payloadClassName of injectedPayloadScriptClasses) {
147
+ if (element.classList.contains(payloadClassName)) {
148
+ isInjectedPayloadScript = true;
149
+ break;
150
+ }
151
+ }
152
+ if (isInjectedPayloadScript)
153
+ continue;
154
+ const replacement = document.createElement('script');
155
+ for (const { name, value } of Array.from(element.attributes)) {
156
+ replacement.setAttribute(name, value);
157
+ }
158
+ if (element.src) {
159
+ replacement.src = element.src;
160
+ }
161
+ else {
162
+ replacement.textContent = element.textContent;
163
+ }
164
+ if (element.parentNode !== null) {
165
+ try {
166
+ element.parentNode.replaceChild(replacement, element);
167
+ }
168
+ catch (error) {
169
+ console.error('[webview-stream] Failed to re-execute script tag', replacement, element, error);
170
+ }
171
+ }
172
+ }
173
+ }
174
+ catch (error) {
175
+ console.error('[webview-stream] reexecuteScripts error', error);
176
+ }
177
+ }
178
+ }
179
+ // ---------------------------------------------------------------------------
180
+ // Preload script generators
181
+ // ---------------------------------------------------------------------------
182
+ const defaultOptions = {
183
+ receiverReadyCallbackPath: '',
184
+ };
185
+ export const createWebViewStreamChunksPreloadScript = (options = {}) => {
186
+ const resolved = { ...defaultOptions, ...options };
187
+ return `(${webViewStreamReceiverIIFE.toString()})(${JSON.stringify(resolved)}, ${JSON.stringify(WebViewStreamEventTypes)});`;
188
+ };
189
+ export const getWebViewStreamChunksPreloadScript = (options) => {
190
+ return createWebViewStreamChunksPreloadScript(options);
191
+ };
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "react-native-webview-stream-chunks",
3
+ "version": "0.1.0",
4
+ "description": "Reusable preload script and event types for streaming large HTML/chunks into WebView",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "lint": "eslint ./src --ext ts",
19
+ "lint:fix": "eslint ./src --ext ts --fix",
20
+ "build": "tsc -p tsconfig.json",
21
+ "check": "tsc --noEmit -p tsconfig.json",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "webview",
26
+ "preload",
27
+ "stream",
28
+ "tiddlywiki"
29
+ ],
30
+ "license": "MIT",
31
+ "devDependencies": {
32
+ "eslint": "^9.39.0",
33
+ "eslint-config-tidgi": "^2.2.0",
34
+ "typescript": "^5.9.3"
35
+ }
36
+ }