Skip to content

Commit

Permalink
feat: update [email protected] (#26)
Browse files Browse the repository at this point in the history
* feat: update [email protected]

* feat: gz

* chore: remove files

* chore: bump beta

* fix: v8

* fix: re-upload so files

* refactor: remove x86 options

* feat: add script

* chore: update npmignore

* chore: ignore package-loack.json

* refactor: npm scripts

* chore: rollback version

* fix: test script

* fix: add npm ci
  • Loading branch information
okhiroyuki authored Oct 18, 2023
1 parent 24db976 commit f5897de
Show file tree
Hide file tree
Showing 923 changed files with 174,310 additions and 84,285 deletions.
39 changes: 20 additions & 19 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.node-version'
- name: set up JDK 11
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "11"
- name: Installing Cordova!
run: |
sudo npm i cordova -g
- name: npm install, build, and test
run: |
npm run test:android --if-present
env:
CI: true
- name: Clone repo
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
- name: set up JDK 11
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "11"
- name: Installing Cordova!
run: |
sudo npm i cordova -g
- name: npm install, build, and test
run: |
npm ci
npm run test:build --if-present
env:
CI: true
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.eslintignore
.eslintrc.yml
.jshinrc
.node-version
.editorconfig

# Git
.git
Expand All @@ -14,3 +16,5 @@
# test
tests/
testapp/

zipLibNode.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
'use strict';
"use strict";

const EventEmitter = require('events');
const NativeBridge = process._linkedBinding('cordova_bridge');
const EventEmitter = require("events");
const NativeBridge = process._linkedBinding("cordova_bridge");

/**
* Built-in events channel to exchange events between the Cordova app
* and the Node.js app. It allows to emit user defined event types with
* optional arguments.
*/
const EVENT_CHANNEL = '_EVENTS_';
const EVENT_CHANNEL = "_EVENTS_";

/**
* Built-in, one-way event channel reserved for sending events from
* the Cordova plug-in native layer to the Node.js app.
*/
const SYSTEM_CHANNEL = '_SYSTEM_';
const SYSTEM_CHANNEL = "_SYSTEM_";

/**
* This class is defined in www/nodejs-apis.js as well.
* Any change made here should be ported to www/nodejs-apis.js too.
* The MessageCodec class provides two static methods to serialize/deserialize
* the data sent through the events channel.
*/
*/
class MessageCodec {
// This is a 'private' constructor, should only be used by this class
// static methods.
constructor(_event, ..._payload) {
this.event = _event;
this.payload = JSON.stringify(_payload);
};
}

// Serialize the message payload and the message.
static serialize(event, ...payload) {
const envelope = new MessageCodec(event, ...payload);
// Return the serialized message, that can be sent through a channel.
return JSON.stringify(envelope);
};
}

// Deserialize the message and the message payload.
static deserialize(message) {
var envelope = JSON.parse(message);
if (typeof envelope.payload !== 'undefined') {
if (typeof envelope.payload !== "undefined") {
envelope.payload = JSON.parse(envelope.payload);
}
return envelope;
};
};
}
}

/**
* Channel super class.
Expand All @@ -60,15 +60,15 @@ class ChannelSuper extends EventEmitter {
// the event to Node.
this.emitLocal = this.emit;
delete this.emit;
};
}

emitWrapper(type, ...msg) {
const _this = this;
setImmediate( () => {
setImmediate(() => {
_this.emitLocal(type, ...msg);
});
};
};
});
}
}

/**
* Events channel class that supports user defined event types with
Expand All @@ -80,19 +80,19 @@ class ChannelSuper extends EventEmitter {
class EventChannel extends ChannelSuper {
post(event, ...msg) {
NativeBridge.sendMessage(this.name, MessageCodec.serialize(event, ...msg));
};
}

// Posts a 'message' event, to be backward compatible with old code.
send(...msg) {
this.post('message', ...msg);
};
this.post("message", ...msg);
}

processData(data) {
// The data contains the serialized message envelope.
var envelope = MessageCodec.deserialize(data);
this.emitWrapper(envelope.event, ...(envelope.payload));
};
};
this.emitWrapper(envelope.event, ...envelope.payload);
}
}

/**
* System event Lock class
Expand All @@ -114,12 +114,11 @@ class SystemEventLock {
}
// Check if the lock can be released and release it.
_checkRelease() {
if(this._locksAcquired<=0) {
this._hasReleased=true;
if (this._locksAcquired <= 0) {
this._hasReleased = true;
this._callback();
}
}

}

/**
Expand All @@ -131,49 +130,49 @@ class SystemChannel extends ChannelSuper {
super(name);
// datadir should not change during runtime, so we cache it.
this._cacheDataDir = null;
};
}

emitWrapper(type) {
// Overload the emitWrapper to handle the pause event locks.
const _this = this;
if (type.startsWith('pause')) {
setImmediate( () => {
let releaseMessage = 'release-pause-event';
let eventArguments = type.split('|');
if (type.startsWith("pause")) {
setImmediate(() => {
let releaseMessage = "release-pause-event";
let eventArguments = type.split("|");
if (eventArguments.length >= 2) {
// The expected format for the release message is "release-pause-event|{eventId}"
// eventId comes from the pause event, with the format "pause|{eventId}"
releaseMessage = releaseMessage + '|' + eventArguments[1];
releaseMessage = releaseMessage + "|" + eventArguments[1];
}
// Create a lock to signal the native side after the app event has been handled.
let eventLock = new SystemEventLock(
() => {
NativeBridge.sendMessage(_this.name, releaseMessage);
}
, _this.listenerCount("pause") // A lock for each current event listener. All listeners need to call release().
},
_this.listenerCount("pause") // A lock for each current event listener. All listeners need to call release().
);
_this.emitLocal("pause", eventLock);
});
} else {
setImmediate( () => {
setImmediate(() => {
_this.emitLocal(type);
});
}
};
}

processData(data) {
// The data is the event.
this.emitWrapper(data);
};
}

// Get a writable data directory for persistent file storage.
datadir() {
if (this._cacheDataDir===null) {
this._cacheDataDir=NativeBridge.getDataDir();
if (this._cacheDataDir === null) {
this._cacheDataDir = NativeBridge.getDataDir();
}
return this._cacheDataDir;
};
};
}
}

/**
* Manage the registered channels to emit events/messages received by the
Expand All @@ -189,9 +188,9 @@ function bridgeListener(channelName, data) {
if (channels.hasOwnProperty(channelName)) {
channels[channelName].processData(data);
} else {
console.error('ERROR: Channel not found:', channelName);
console.error("ERROR: Channel not found:", channelName);
}
};
}

/*
* The bridge's native code processes each channel's messages in a dedicated
Expand All @@ -201,7 +200,7 @@ function bridgeListener(channelName, data) {
function registerChannel(channel) {
channels[channel.name] = channel;
NativeBridge.registerChannel(channel.name, bridgeListener);
};
}

/**
* Module exports.
Expand All @@ -217,5 +216,5 @@ registerChannel(eventChannel);

module.exports = exports = {
app: systemChannel,
channel: eventChannel
channel: eventChannel,
};
Binary file modified libs/android/libnode/bin/arm64-v8a/libnode.so.gz
Binary file not shown.
Binary file modified libs/android/libnode/bin/armeabi-v7a/libnode.so.gz
Binary file not shown.
Binary file modified libs/android/libnode/bin/x86_64/libnode.so.gz
Binary file not shown.
Loading

0 comments on commit f5897de

Please sign in to comment.