spyne 0.20.0 → 0.20.2
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/.eslintignore +2 -0
- package/.husky/pre-commit +1 -0
- package/.travis.yml +6 -6
- package/README.md +3 -1
- package/karma.conf.js +3 -6
- package/lib/spyne.esm.js +4 -4
- package/lib/spyne.esm.js.map +1 -1
- package/lib/spyne.js +248 -248
- package/lib/spyne.umd.js +3 -9565
- package/lib/spyne.umd.js.LICENSE.txt +16 -0
- package/package.json +8 -5
- package/src/spyne/spyne-app.js +3 -2
- package/src/spyne/spyne-plugins.js +45 -6
- package/src/spyne/utils/spyne-app-properties.js +11 -0
- package/src/tests/package-json.spec.test.js +3 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Spyne 0.20.1
|
|
3
|
+
* https://spynejs.org
|
|
4
|
+
*
|
|
5
|
+
* @license Copyright 2017-2021, Frank Batista, Relevant Context, LLC. All rights reserved.
|
|
6
|
+
* Spyne is licensed under the GNU Lesser General Public License v3.0
|
|
7
|
+
*
|
|
8
|
+
* @author: Frank Batista,
|
|
9
|
+
* @email: frbatista.nyc@gmail.com
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/*!
|
|
13
|
+
* spynejs 0.20.1
|
|
14
|
+
* https://spynejs.org
|
|
15
|
+
* (c) 2017-present Frank Batista
|
|
16
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spyne",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"description": "Reactive Real-DOM Framework for Advanced Javascript applications",
|
|
5
5
|
"sideEffects": true,
|
|
6
|
-
"main": "./lib/spyne.
|
|
6
|
+
"main": "./lib/spyne.esm.js",
|
|
7
7
|
"module": "./lib/spyne.esm.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./lib/spyne.esm.js",
|
|
11
|
-
"require": "./lib/spyne.
|
|
11
|
+
"require": "./lib/spyne.esm.js"
|
|
12
12
|
},
|
|
13
13
|
"./lib/*": "./lib/*.js"
|
|
14
14
|
},
|
|
@@ -19,13 +19,15 @@
|
|
|
19
19
|
"report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
|
20
20
|
"commit": "git-cz",
|
|
21
21
|
"start": "webpack-dev-server --hot",
|
|
22
|
+
"prepare": "husky",
|
|
22
23
|
"build": "webpack --config webpack.config.js --mode production",
|
|
23
24
|
"build:esm": "rollup --config rollup.config.js",
|
|
24
25
|
"dev": "webpack --config webpack.config.js --mode development",
|
|
25
26
|
"stats": "webpack --profile --json --optimize-minimize --mode production --env build > stats.json",
|
|
26
27
|
"docs": "jsdoc --readme README.md -d docs -c docs/jsdoc.config.json -r",
|
|
27
28
|
"esdocs": "esdoc -d esdocs -c esdocs/esdoc.config.json -r",
|
|
28
|
-
"test": "karma start
|
|
29
|
+
"test": "karma start karma.conf.js",
|
|
30
|
+
"test:single": "karma start karma.conf.js --single-run",
|
|
29
31
|
"watch:test": "npm test -- --auto-watch --no-single-run",
|
|
30
32
|
"test:mocha": "mocha tests",
|
|
31
33
|
"lint": "eslint 'src/spyne/**' --fix"
|
|
@@ -43,7 +45,7 @@
|
|
|
43
45
|
"Single-Page-Application Framework"
|
|
44
46
|
],
|
|
45
47
|
"author": "Frank Batista",
|
|
46
|
-
"license": "
|
|
48
|
+
"license": "LGPL",
|
|
47
49
|
"devDependencies": {
|
|
48
50
|
"@rollup/plugin-commonjs": "^28.0.2",
|
|
49
51
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -59,6 +61,7 @@
|
|
|
59
61
|
"eslint-plugin-node": "^11.1.0",
|
|
60
62
|
"eslint-webpack-plugin": "^4.2.0",
|
|
61
63
|
"file-loader": "^6.2.0",
|
|
64
|
+
"husky": "^9.1.7",
|
|
62
65
|
"karma": "^6.4.4",
|
|
63
66
|
"karma-chai": "^0.1.0",
|
|
64
67
|
"karma-chrome-launcher": "^3.2.0",
|
package/src/spyne/spyne-app.js
CHANGED
|
@@ -5,7 +5,7 @@ import { SpyneAppProperties } from './utils/spyne-app-properties'
|
|
|
5
5
|
import { sanitizeHTMLConfigure } from './utils/sanitize-html'
|
|
6
6
|
|
|
7
7
|
const _channels = new ChannelsMap()
|
|
8
|
-
const version = '0.20.
|
|
8
|
+
const version = '0.20.2'
|
|
9
9
|
|
|
10
10
|
class SpyneApplication {
|
|
11
11
|
/**
|
|
@@ -42,7 +42,7 @@ class SpyneApplication {
|
|
|
42
42
|
init(config = {}, testMode = false) {
|
|
43
43
|
// this.channels = new ChannelsMap();
|
|
44
44
|
/*!
|
|
45
|
-
* Spyne 0.20.
|
|
45
|
+
* Spyne 0.20.2
|
|
46
46
|
* https://spynejs.org
|
|
47
47
|
*
|
|
48
48
|
* @license Copyright 2017-2021, Frank Batista, Relevant Context, LLC. All rights reserved.
|
|
@@ -121,6 +121,7 @@ class SpyneApplication {
|
|
|
121
121
|
this.pluginsFn = SpyneAppProperties.getPluginsMethodObj(config['pluginMethods']);
|
|
122
122
|
this.getChannelActions = (str) => _channels.getChannelActions(str);
|
|
123
123
|
this.registerChannel = (val) => _channels.registerStream(val);
|
|
124
|
+
this.registerPlugin = (pluginInstance) => SpyneAppProperties.registerPlugin(pluginInstance);
|
|
124
125
|
this.registerDataChannel = (obs$) => _channels.registerStream(obs$);
|
|
125
126
|
this.listChannels = () => Array.from(_channels.map.keys());
|
|
126
127
|
let nullHolder = new ViewStream({ id:'spyne-null-views' });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DomElement } from './views/dom-element'
|
|
2
2
|
import { SpyneAppProperties } from './utils/spyne-app-properties'
|
|
3
3
|
import { is, clone, pathSatisfies } from 'ramda'
|
|
4
|
+
let _spyneAppProps = SpyneAppProperties
|
|
4
5
|
export class SpynePlugin {
|
|
5
6
|
constructor(props = {}) {
|
|
6
7
|
let { name, config, parentEl } = props
|
|
@@ -14,27 +15,65 @@ export class SpynePlugin {
|
|
|
14
15
|
this.props.name = name
|
|
15
16
|
config = SpynePlugin.mergeDefaultConfig(config, this.defaultConfig())
|
|
16
17
|
this.props.parentEl = parentEl || SpynePlugin.createParentEl()
|
|
17
|
-
SpynePlugin.getSpyneApp(name, config)
|
|
18
|
-
|
|
18
|
+
// SpynePlugin.getSpyneApp(name, config)
|
|
19
|
+
this.props.config = config
|
|
19
20
|
if (this.props.traits !== undefined) {
|
|
20
21
|
this.addTraits(this.props.traits)
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
// this.onBeforeRegistered()
|
|
25
|
+
// this.onRegistered()
|
|
26
|
+
// this.onRender()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Now this method will be called when the app decides to register the plugin.
|
|
31
|
+
* This way, the plugin no longer has to import or rely on its own version
|
|
32
|
+
* of SpyneAppProperties. Instead, it is *passed* the authoritative instance.
|
|
33
|
+
*/
|
|
34
|
+
register(spyneAppProps) {
|
|
35
|
+
// 1. Save a reference to the real SpyneAppProperties
|
|
36
|
+
_spyneAppProps = spyneAppProps
|
|
37
|
+
this.props.pluginName = this.props.name
|
|
38
|
+
|
|
39
|
+
// this.props.config = _spyneAppProps.getPluginConfigByPluginName(this.props.pluginName)
|
|
40
|
+
|
|
41
|
+
if (_spyneAppProps.initialized === false) {
|
|
42
|
+
console.warn(
|
|
43
|
+
`Spyne Warning: SpyneApp has not been initialized yet! Cannot register plugin "${this.name}".`
|
|
44
|
+
)
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
23
48
|
this.onBeforeRegistered()
|
|
49
|
+
|
|
50
|
+
// 2. Add plugin config in the real SpyneAppProperties
|
|
51
|
+
this.props.config = clone(this.props.config)
|
|
52
|
+
_spyneAppProps.addPluginConfig(this.name, this.props.config)
|
|
53
|
+
|
|
54
|
+
// If you have plugin-level logic that depends on the real spyneApp,
|
|
55
|
+
// you can add it here, e.g.:
|
|
56
|
+
// spyneAppProps.addPluginMethods(this.props.config.pluginMethods)
|
|
57
|
+
|
|
58
|
+
// 3. If you have other plugin lifecycle methods
|
|
24
59
|
this.onRegistered()
|
|
25
60
|
this.onRender()
|
|
26
61
|
}
|
|
27
62
|
|
|
63
|
+
get SpyneAppProperties() {
|
|
64
|
+
return _spyneAppProps
|
|
65
|
+
}
|
|
66
|
+
|
|
28
67
|
static mergeDefaultConfig(config = {}, defaultConfig = this.defaultConfig()) {
|
|
29
68
|
return Object.assign(defaultConfig, config)
|
|
30
69
|
}
|
|
31
70
|
|
|
32
71
|
static getSpyneApp(name, config) {
|
|
33
|
-
if (
|
|
72
|
+
if (_spyneAppProps.initialized === false) {
|
|
34
73
|
console.warn(`Spyne Warning: Unable to install plugin, ${name}! SpyneApp has not been initialized!`)
|
|
35
74
|
// SpyneApp.init()
|
|
36
75
|
} else {
|
|
37
|
-
|
|
76
|
+
_spyneAppProps.addPluginConfig(name, config)
|
|
38
77
|
}
|
|
39
78
|
}
|
|
40
79
|
|
|
@@ -82,8 +121,8 @@ export class SpynePlugin {
|
|
|
82
121
|
}
|
|
83
122
|
|
|
84
123
|
onBeforeRegistered() {
|
|
85
|
-
this.props.pluginName = this.props.name
|
|
86
|
-
this.props.config =
|
|
124
|
+
// this.props.pluginName = this.props.name
|
|
125
|
+
// this.props.config = _spyneAppProps.getPluginConfigByPluginName(this.props.pluginName)
|
|
87
126
|
}
|
|
88
127
|
|
|
89
128
|
defaultConfig() {
|
|
@@ -61,6 +61,7 @@ class SpyneAppPropertiesClass {
|
|
|
61
61
|
this.getChannelActions = _channels.getChannelActions.bind(_channels)
|
|
62
62
|
this.listRegisteredChannels = _channels.listRegisteredChannels.bind(_channels)
|
|
63
63
|
_initialized = true
|
|
64
|
+
this._initialized = _initialized
|
|
64
65
|
this.setChannelsMap()
|
|
65
66
|
if (config?.baseHref) {
|
|
66
67
|
this.setHeadBaseHref(config.baseHref)
|
|
@@ -178,6 +179,16 @@ class SpyneAppPropertiesClass {
|
|
|
178
179
|
// console.log("REGISTERD PROXY REVIVER",_proxiesMap, _proxiesMap.get(name));
|
|
179
180
|
}
|
|
180
181
|
|
|
182
|
+
// This is the new method you add
|
|
183
|
+
registerPlugin(pluginInstance) {
|
|
184
|
+
if (!this._initialized) {
|
|
185
|
+
console.warn('SpyneApp is not initialized yet. Plugin will not be fully registered.')
|
|
186
|
+
}
|
|
187
|
+
// console.log("INSTANCE ",this, pluginInstance)
|
|
188
|
+
|
|
189
|
+
pluginInstance.register(this)
|
|
190
|
+
}
|
|
191
|
+
|
|
181
192
|
getProxyReviver(proxyName) {
|
|
182
193
|
return _proxiesMap.get(proxyName)
|
|
183
194
|
}
|
|
@@ -4,6 +4,9 @@ import pkg from '../../package.json' // Import package.json
|
|
|
4
4
|
describe('package.json export import statement', () => {
|
|
5
5
|
it('should be set to "./lib/spyne.esm.js"', () => {
|
|
6
6
|
const exports = pkg.exports['.']
|
|
7
|
+
expect(pkg.main).to.equal('./lib/spyne.esm.js')
|
|
8
|
+
expect(pkg.module).to.equal('./lib/spyne.esm.js')
|
|
7
9
|
expect(exports.import).to.equal('./lib/spyne.esm.js')
|
|
10
|
+
expect(exports.require).to.equal('./lib/spyne.esm.js')
|
|
8
11
|
})
|
|
9
12
|
})
|