Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/actions/publish-npm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ runs:
shell: bash
run: test -f harmony/pushy.har

# npm publish rebuilds them in prepack; build them here too so the
# file-list check below sees lib/typescript.
- name: Build type declarations
shell: bash
run: bun build:types

- name: Verify publish file list
shell: bash
run: node scripts/check-packlist.js --release
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@ jobs:
- name: Run lint
run: bun lint

# check-packlist.js requires the emitted declarations that
# package.json `types` points at.
- name: Build type declarations
run: bun build:types

- name: Verify publish file list
run: node scripts/check-packlist.js
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ local.properties
node_modules/
npm-debug.log

# Type declarations emitted by `bun build:types` (published, not committed)
lib/

Example/**/.update
Example/**/.pushy
Example/**/.e2e-artifacts
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"version": "10.62.0",
"description": "Hot update (OTA) for React Native with Hermes-optimized diff patches, crash rollback and staged rollout. A CodePush alternative for iOS, Android and HarmonyOS.",
"main": "src/index",
"types": "src/index.ts",
"types": "lib/typescript/index.d.ts",
"files": [
"src",
"!src/__tests__",
"lib/typescript",
"android/src",
"!android/src/test",
"android/lib",
Expand Down Expand Up @@ -45,8 +46,9 @@
"LICENSE"
],
"scripts": {
"prepack": "bun submodule && bun lint",
"prepack": "bun submodule && bun lint && bun build:types",
"lint": "biome check src && tsc --noEmit && node scripts/check-harmony-types.js && node scripts/check-native-spec-parity.js && bun scripts/generate-contract.ts --check && node scripts/check-readme-options.js",
"build:types": "rm -rf lib/typescript && tsc -p tsconfig.build.json",
"contract": "bun scripts/generate-contract.ts",
"lint:harmony": "node scripts/check-harmony-types.js",
"submodule": "git submodule update --init --recursive",
Expand Down
6 changes: 5 additions & 1 deletion scripts/check-packlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// must and must not be there. Run in lint CI and right before `npm publish`
// (with --release, which additionally requires the Harmony HAR).
const { execFileSync } = require('child_process');
const { files: filesField } = require('../package.json');
const { files: filesField, types } = require('../package.json');

const release = process.argv.includes('--release');
// Also compile the packed native sources (needs the submodules and a C
Expand Down Expand Up @@ -56,6 +56,10 @@ const required = [
'package.json',
'src/index.ts',
'src/NativePushy.ts',
// The declarations apps type-check against (bun build:types emits them).
// --compile runs in test.yml's C++ job, which has no JS toolchain to
// build them; the lint workflow and the publish action check them.
...(compile ? [] : [types]),
'android/build.gradle',
'android/src/main/java/cn/reactnative/modules/update/UpdateContext.java',
'ios/RCTPushy/RCTPushy.mm',
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('Pushy server config', () => {
async () => {}
);

(client as any).emitError(new Error('offline'), 'errorChecking');
(client as any).reporter.emitError(new Error('offline'), 'errorChecking');
client.reportInvalidUpdateOnce('noArtifact', 'h2');

expect(report).toHaveBeenCalledWith(
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/provider.render.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('UpdateProvider rendering', () => {
// Real client contract under the default throwError:false — the error is
// emitted to onError listeners and checkUpdate resolves undefined.
client.checkUpdate.mockImplementation(async () => {
client.emitError(checkError, 'errorChecking');
(client as any).reporter.emitError(checkError, 'errorChecking');
return undefined;
});

Expand Down Expand Up @@ -244,7 +244,7 @@ describe('UpdateProvider rendering', () => {
});
const checkError = new Error('offline');
client.checkUpdate.mockImplementation(async () => {
client.emitError(checkError, 'errorChecking');
(client as any).reporter.emitError(checkError, 'errorChecking');
return undefined;
});

Expand All @@ -265,7 +265,7 @@ describe('UpdateProvider rendering', () => {
dismissErrorAfter: 20,
});
client.checkUpdate.mockImplementation(async () => {
client.emitError(new Error('offline'), 'errorChecking');
(client as any).reporter.emitError(new Error('offline'), 'errorChecking');
return undefined;
});

Expand Down
2 changes: 0 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ export class Pushy {
throwIfEnabled = (e: Error) => this.reporter.throwIfEnabled(e);
onError: Reporter['onError'] = (listener) => this.reporter.onError(listener);
wasEmitted = (e: unknown): boolean => this.reporter.wasEmitted(e);
private emitError: Reporter['emitError'] = (...args) =>
this.reporter.emitError(...args);
notifyAfterCheckUpdate: Reporter['notifyAfterCheckUpdate'] = (state) =>
this.reporter.notifyAfterCheckUpdate(state);

Expand Down
14 changes: 11 additions & 3 deletions src/clientDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,17 @@ export class Downloader {
};
// @ts-expect-error harmony not in existing platforms
const isHarmony = Platform.OS === 'harmony';
const progressSubscription = (
isHarmony ? DeviceEventEmitter : pushyNativeEventEmitter
).addListener('RCTPushyDownloadProgress', onNativeProgress);
// Two separate calls: on RN 0.88 the two emitters' addListener signatures
// no longer unify, so calling it on the union type does not compile.
const progressSubscription = isHarmony
? DeviceEventEmitter.addListener(
'RCTPushyDownloadProgress',
onNativeProgress
)
: pushyNativeEventEmitter.addListener(
'RCTPushyDownloadProgress',
onNativeProgress
);
const maxRetries = Math.max(
0,
Math.floor(this.host.options.maxRetries ?? 3)
Expand Down
16 changes: 16 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Emits the published type declarations (lib/typescript), which
// package.json `types` points at: apps then type-check against .d.ts files
// their skipLibCheck covers, instead of compiling this package's sources
// under their own tsconfig and React Native version.
"extends": "./tsconfig.json",
"include": ["src"],
"exclude": ["src/__tests__"],
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
"rootDir": "src",
"outDir": "lib/typescript"
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@react-native/typescript-config",
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["**/node_modules", "**/Pods", "**/harmony", "**/Example"],
"exclude": ["lib", "**/node_modules", "**/Pods", "**/harmony", "**/Example"],
"compilerOptions": {
// The RN base config lists "jest"; this package tests with bun:test and
// no longer installs @types/jest, so a clean install would fail tsc.
Expand Down
Loading