Skip to content

Commit

Permalink
Merge pull request #8 from PureMVC/develop
Browse files Browse the repository at this point in the history
CI/CD
  • Loading branch information
cliffhall authored Sep 13, 2024
2 parents 8e4546f + 6277023 commit a1143a2
Show file tree
Hide file tree
Showing 53 changed files with 798 additions and 5,554 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [19.x, 20.x, 21.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install
- run: npm run build
- run: npm test
- run: sudo apt-get install xvfb
- run: xvfb-run --auto-servernum npm run test:chrome
- run: xvfb-run --auto-servernum npm run test:firefox
- uses: actions/checkout@v3
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: "20.x"
cache: "npm"
- run: npm install
- run: npm run build
- run: npm test
- run: sudo apt-get install xvfb
- run: xvfb-run --auto-servernum npm run test:chrome
- run: xvfb-run --auto-servernum npm run test:firefox

- name: Publish to npm
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ PureMVC is a lightweight framework for creating applications based upon the clas
* [API Docs](https://puremvc.org/pages/docs/JS/es/)
* [Legacy Implementation](https://github.com/PureMVC/puremvc-js-multicore-framework/tree/1.0.1)

## Installation
```shell
npm i @puremvc/puremvc-js-multicore-framework
```

## Demos
* [Frontend Demo: EmployeeAdmin](https://github.com/PureMVC/puremvc-js-demo-employeeadmin)
* [Backend Demo: Employee Admin NodeJS Microservice](https://github.com/PureMVC/puremvc-js-demo-microservice-employeeadmin)
Expand All @@ -19,7 +24,7 @@ PureMVC is a lightweight framework for creating applications based upon the clas
* [React Native](https://en.wikipedia.org/wiki/React_Native)

## Status
Production - [Version 2.0.7](https://github.com/PureMVC/puremvc-js-multicore-framework/blob/master/VERSION)
Production - [Version 2.0.8](https://github.com/PureMVC/puremvc-js-multicore-framework/blob/master/VERSION)

#### Documentation
- https://jsdoc.app/about-commandline.html
Expand Down
5 changes: 3 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
PureMVC MultiCore Framework for JavaScript
--------------------------------------------------------------------------
Release Date: 8/14/24
Release Date: 9/4/24
Platform: JavaScript
Version: 2
Revision: 0
Minor: 7
Minor: 8
Authors: Saad Shams <[email protected]>
: David Foley <[email protected]>
: Cliff Hall <[email protected]>
Expand All @@ -17,3 +17,4 @@ Release Date: 8/14/24
2.0.5 - NPM package borked for cjs
2.0.6 - NPM package bundling the ESM/CommonJS support
2.0.7 - Finally? NPM bundling
2.0.8 - CI/CD Pipeline
43 changes: 21 additions & 22 deletions bin/cjs/puremvc.cjs → bin/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class Observer {
* <P>The notification method on the interested object should take
* one parameter of type `Notification`</P>
*
* @param {function(Notification):void} notifyMethod
* @param {Object} notifyContext
* @param {function(Notification):void | null} [notify = null]
* @param {Object | null} [context = null]
*/
constructor(notifyMethod, notifyContext) {
this._notifyMethod = notifyMethod;
this._notifyContext = notifyContext;
constructor(notify = null, context = null) {
this._notifyMethod = notify;
this._notifyContext = context;
}

/**
Expand Down Expand Up @@ -420,10 +420,10 @@ class Controller {
* passing the unique key for this instance
* `Controller.getInstance( multitonKey )`</P>
*
* @throws {Error} Error if instance for this Multiton key has already been constructed
*
* @constructor
* @param {string} key
*
* @throws {Error} Error if instance for this Multiton key has already been constructed
*/
constructor(key) {
if (Controller.instanceMap[key] != null) throw new Error(Controller.MULTITON_MSG);
Expand Down Expand Up @@ -592,7 +592,6 @@ class Controller {
*
* @class Model
*/

class Model {

/**
Expand Down Expand Up @@ -722,7 +721,6 @@ class Model {
*/

/**
*
* A base `Notification` implementation.
*
* <P>PureMVC does not rely upon underlying event models such
Expand Down Expand Up @@ -780,7 +778,7 @@ class Notification {
/**
* Get the body of the `Notification` instance.
*
* @returns {Object}
* @returns {Object | null}
*/
get body() {
return this._body;
Expand Down Expand Up @@ -858,6 +856,7 @@ class Facade {
*
* @constructor
* @param {string} key
*
* @throws {Error} Error if instance for this Multiton key has already been constructed
*/
constructor(key) {
Expand Down Expand Up @@ -1022,7 +1021,7 @@ class Facade {
}

/**
* Check if a Proxy is registered
* Check if a `Proxy` is registered
*
* @param {string} proxyName
* @returns {boolean} whether a Proxy is currently registered with the given `proxyName`.
Expand Down Expand Up @@ -1061,7 +1060,7 @@ class Facade {
}

/**
* Check if a Mediator is registered or not
* Check if a `Mediator` is registered or not
*
* @param {string} mediatorName
* @returns {boolean} whether a Mediator is registered with the given `mediatorName`.
Expand Down Expand Up @@ -1101,7 +1100,7 @@ class Facade {
* compatibility, and to allow you to send custom
* notification classes using the facade.</P>
*
* <P>Usually you should just call sendNotification
* <P>Usually you should just call `sendNotification`
* and pass the parameters, never having to
* construct the notification yourself.</P>
*
Expand Down Expand Up @@ -1440,10 +1439,10 @@ class Mediator extends Notifier {
* Constructor.
*
* @constructor
* @param {string} mediatorName
* @param {Object} [viewComponent] viewComponent
* @param {string | null} [mediatorName=null]
* @param {Object | null} [viewComponent=null]
*/
constructor(mediatorName, viewComponent = null) {
constructor(mediatorName = null, viewComponent = null) {
super();
this._mediatorName = mediatorName || Mediator.NAME;
this._viewComponent = viewComponent;
Expand Down Expand Up @@ -1504,7 +1503,7 @@ class Mediator extends Notifier {
* be defined in the subclass that casts the view
* object to a type, like this:</P>
*
* @returns {Object}
* @returns {Object | null}
*/
get viewComponent() {
return this._viewComponent;
Expand Down Expand Up @@ -1566,16 +1565,16 @@ class Proxy extends Notifier {
* Constructor
*
* @constructor
* @param {string} proxyName
* @param {Object} [data]
* @param {string | null} [proxyName=null]
* @param {Object | null} [data=null]
*/
constructor(proxyName, data = null) {
constructor(proxyName = null, data = null) {
super();
/** @protected
* @type {string} */
this._proxyName = proxyName || Proxy.NAME;
/** @protected
* @type {Object} */
* @type {Object | null} */
this._data = data;
}

Expand All @@ -1601,7 +1600,7 @@ class Proxy extends Notifier {
/**
* Get the data object
*
* @returns {Object}
* @returns {Object | null}
*/
get data () {
return this._data;
Expand Down
2 changes: 2 additions & 0 deletions bin/cjs/index.min.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"use strict";class t{constructor(t=null,e=null){this._notifyMethod=t,this._notifyContext=e}notifyObserver(t){this._notifyMethod.call(this._notifyContext,t)}compareNotifyContext(t){return this._notifyContext===t}get notifyMethod(){return this._notifyMethod}set notifyMethod(t){this._notifyMethod=t}get notifyContext(){return this._notifyContext}set notifyContext(t){this._notifyContext=t}}class e{constructor(t){if(null!=e.instanceMap.get(t))throw new Error(e.MULTITON_MSG);this.multitonKey=t,e.instanceMap.set(this.multitonKey,this),this.mediatorMap=new Map,this.observerMap=new Map,this.initializeView()}initializeView(){}static getInstance(t,i){return null==e.instanceMap&&(e.instanceMap=new Map),null==e.instanceMap.get(t)&&e.instanceMap.set(t,i(t)),e.instanceMap.get(t)}registerObserver(t,e){if(null!=this.observerMap.get(t)){this.observerMap.get(t).push(e)}else this.observerMap.set(t,new Array(e))}notifyObservers(t){if(this.observerMap.has(t.name)){let e=this.observerMap.get(t.name).slice();for(let i=0;i<e.length;i++)e[i].notifyObserver(t)}}removeObserver(t,e){let i=this.observerMap.get(t);for(let t=0;t<i.length;t++)if(!0===i[t].compareNotifyContext(e)){i.splice(t,1);break}0===i.length&&this.observerMap.delete(t)}registerMediator(e){if(!1!==this.mediatorMap.has(e.mediatorName))return;e.initializeNotifier(this.multitonKey),this.mediatorMap.set(e.mediatorName,e);let i=e.listNotificationInterests();if(i.length>0){let n=new t(e.handleNotification.bind(e),e);for(let t=0;t<i.length;t++)this.registerObserver(i[t],n)}e.onRegister()}retrieveMediator(t){return this.mediatorMap.get(t)||null}removeMediator(t){let e=this.mediatorMap.get(t);if(e){let i=e.listNotificationInterests();for(let t=0;t<i.length;t++)this.removeObserver(i[t],e);this.mediatorMap.delete(t),e.onRemove()}return e}hasMediator(t){return this.mediatorMap.has(t)}static removeView(t){this.instanceMap.delete(t)}static get MULTITON_MSG(){return"View instance for this Multiton key already constructed!"}}class i{constructor(t){if(null!=i.instanceMap[t])throw new Error(i.MULTITON_MSG);this.multitonKey=t,i.instanceMap.set(this.multitonKey,this),this.commandMap=new Map,this.initializeController()}initializeController(){this.view=e.getInstance(this.multitonKey,(t=>new e(t)))}static getInstance(t,e){return null==i.instanceMap&&(i.instanceMap=new Map),null==i.instanceMap.get(t)&&i.instanceMap.set(t,e(t)),i.instanceMap.get(t)}executeCommand(t){let e=this.commandMap.get(t.name);if(null==e)return;let i=e();i.initializeNotifier(this.multitonKey),i.execute(t)}registerCommand(e,i){null==this.commandMap.get(e)&&this.view.registerObserver(e,new t(this.executeCommand,this)),this.commandMap.set(e,i)}hasCommand(t){return this.commandMap.has(t)}removeCommand(t){this.hasCommand(t)&&(this.view.removeObserver(t,this),this.commandMap.delete(t))}static removeController(t){i.instanceMap.delete(t)}static get MULTITON_MSG(){return"Controller instance for this Multiton key already constructed!"}}class n{constructor(t){if(null!=n.instanceMap.get(t))throw new Error(n.MULTITON_MSG);this.multitonKey=t,n.instanceMap.set(this.multitonKey,this),this.proxyMap=new Map,this.initializeModel()}initializeModel(){}static getInstance(t,e){return null==n.instanceMap&&(n.instanceMap=new Map),null==n.instanceMap.get(t)&&n.instanceMap.set(t,e(t)),n.instanceMap.get(t)}registerProxy(t){t.initializeNotifier(this.multitonKey),this.proxyMap.set(t.proxyName,t),t.onRegister()}retrieveProxy(t){return this.proxyMap.get(t)||null}hasProxy(t){return this.proxyMap.has(t)}removeProxy(t){let e=this.proxyMap.get(t);return null!=e&&(this.proxyMap.delete(t),e.onRemove()),e}static removeModel(t){n.instanceMap.delete(t)}static get MULTITON_MSG(){return"Model instance for this Multiton key already constructed!"}}class r{constructor(t,e=null,i=""){this._name=t,this._body=e,this._type=i}get name(){return this._name}get body(){return this._body}set body(t){this._body=t}get type(){return this._type}set type(t){this._type=t}toString(){let t="Notification Name: "+this.name;return t+="\nBody:"+(null==this.body?"null":this.body.toString()),t+="\nType:"+(null==this.type?"null":this.type),t}}class s{constructor(t){if(null!=s.instanceMap[t])throw new Error(s.MULTITON_MSG);this.initializeNotifier(t),s.instanceMap.set(this.multitonKey,this),this.initializeFacade()}initializeFacade(){this.initializeModel(),this.initializeController(),this.initializeView()}static getInstance(t,e){return null==s.instanceMap&&(s.instanceMap=new Map),null==s.instanceMap.get(t)&&s.instanceMap.set(t,e(t)),s.instanceMap.get(t)}initializeModel(){null==this.model&&(this.model=n.getInstance(this.multitonKey,(t=>new n(t))))}initializeController(){null==this.controller&&(this.controller=i.getInstance(this.multitonKey,(t=>new i(t))))}initializeView(){null==this.view&&(this.view=e.getInstance(this.multitonKey,(t=>new e(t))))}registerCommand(t,e){this.controller.registerCommand(t,e)}hasCommand(t){return this.controller.hasCommand(t)}removeCommand(t){this.controller.removeCommand(t)}registerProxy(t){this.model.registerProxy(t)}removeProxy(t){return this.model.removeProxy(t)}hasProxy(t){return this.model.hasProxy(t)}retrieveProxy(t){return this.model.retrieveProxy(t)}registerMediator(t){this.view.registerMediator(t)}removeMediator(t){return this.view.removeMediator(t)}hasMediator(t){return this.view.hasMediator(t)}retrieveMediator(t){return this.view.retrieveMediator(t)}sendNotification(t,e=null,i=""){this.notifyObservers(new r(t,e,i))}notifyObservers(t){this.view.notifyObservers(t)}initializeNotifier(t){this.multitonKey=t}static hasCore(t){return this.instanceMap.has(t)}static removeCore(t){null!=s.instanceMap.get(t)&&(n.removeModel(t),e.removeView(t),i.removeController(t),this.instanceMap.delete(t))}static get MULTITON_MSG(){return"Facade instance for this Multiton key already constructed!"}}class o{constructor(){}sendNotification(t,e=null,i=""){null!=this.facade&&this.facade.sendNotification(t,e,i)}initializeNotifier(t){this.multitonKey=t}get facade(){if(null==this.multitonKey)throw new Error(o.MULTITON_MSG);return s.getInstance(this.multitonKey,(t=>new s(t)))}static get MULTITON_MSG(){return"multitonKey for this Notifier not yet initialized!"}}class a extends o{constructor(){super()}execute(t){}}class l extends o{constructor(t=null,e=null){super(),this._mediatorName=t||l.NAME,this._viewComponent=e}onRegister(){}onRemove(){}listNotificationInterests(){return[]}handleNotification(t){}get mediatorName(){return this._mediatorName}get viewComponent(){return this._viewComponent}set viewComponent(t){this._viewComponent=t}static get NAME(){return"Mediator"}}class h extends o{constructor(t=null,e=null){super(),this._proxyName=t||h.NAME,this._data=e}onRegister(){}onRemove(){}get proxyName(){return this._proxyName}get data(){return this._data}set data(t){this._data=t}static get NAME(){return"Proxy"}}exports.Controller=i,exports.Facade=s,exports.MacroCommand=class extends a{constructor(){super(),this.subCommands=[],this.initializeMacroCommand()}initializeMacroCommand(){}addSubCommand(t){this.subCommands.push(t)}execute(t){for(;this.subCommands.length>0;){let e=this.subCommands.shift()();e.initializeNotifier(this.multitonKey),e.execute(t)}}},exports.Mediator=l,exports.Model=n,exports.Notification=r,exports.Notifier=o,exports.Observer=t,exports.Proxy=h,exports.SimpleCommand=a,exports.View=e;
//# sourceMappingURL=index.min.cjs.map
1 change: 1 addition & 0 deletions bin/cjs/index.min.cjs.map

Large diffs are not rendered by default.

Loading

0 comments on commit a1143a2

Please sign in to comment.