spyne 0.20.1 → 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.
@@ -0,0 +1 @@
1
+ npm run test:single
package/README.md CHANGED
@@ -3,7 +3,9 @@ Spyne is a full-featured, Javascript framework that reactively renders to the Re
3
3
 
4
4
  [![NPM version](https://img.shields.io/npm/v/spyne.svg?longCache=true&style=flat-square)](https://www.npmjs.com/package/spyne)
5
5
  [![GitHub license](https://img.shields.io/github/license/spynejs/spyne.svg?longCache=true&style=flat-square)](https://github.com/spynejs/spyne/blob/master/LICENSE)
6
- [![Build Status](https://travis-ci.com/spynejs/spyne.svg?branch=master)](https://travis-ci.com/spynejs/spyne)
6
+ [![Build Status](https://app.travis-ci.com/spynejs/spyne.svg?token=tUNpKxHHHcwypyVzqWmD&branch=main&style=flat-square)](https://travis-ci.com/spynejs/spyne)
7
+
8
+
7
9
 
8
10
  ### Spyne.js’ key features includes:
9
11
 
package/karma.conf.js CHANGED
@@ -12,7 +12,7 @@ const karmaWebpackConfig = {
12
12
  mode: 'none',
13
13
 
14
14
  // Karma manages watching/rebuilding on its own, so we typically disable watch from Webpack
15
- watch: false,
15
+ watch: true,
16
16
 
17
17
  // Remove the library entry/output so that Karma can inline test files
18
18
  entry: undefined,
@@ -101,9 +101,6 @@ module.exports = function (config) {
101
101
  // autoWatch: if true, re-run tests on file changes
102
102
  autoWatch: true,
103
103
 
104
- // For file-watching inside containers or certain OS environments
105
- usePolling: true,
106
-
107
104
  customLaunchers: {
108
105
  ChromeHeadlessNoSandbox: {
109
106
  base: 'ChromeHeadless',
@@ -115,7 +112,7 @@ module.exports = function (config) {
115
112
  browsers: ['Chrome'],
116
113
 
117
114
  // If true, Karma runs tests once and exits
118
- singleRun: true,
115
+ singleRun: false,
119
116
 
120
117
  // Concurrency level
121
118
  concurrency: Infinity
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "spyne",
3
- "version": "0.20.1",
3
+ "version": "0.20.2",
4
4
  "description": "Reactive Real-DOM Framework for Advanced Javascript applications",
5
5
  "sideEffects": true,
6
- "main": "./lib/spyne.umd.js",
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.umd.js"
11
+ "require": "./lib/spyne.esm.js"
12
12
  },
13
13
  "./lib/*": "./lib/*.js"
14
14
  },
@@ -19,6 +19,7 @@
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",
@@ -60,6 +61,7 @@
60
61
  "eslint-plugin-node": "^11.1.0",
61
62
  "eslint-webpack-plugin": "^4.2.0",
62
63
  "file-loader": "^6.2.0",
64
+ "husky": "^9.1.7",
63
65
  "karma": "^6.4.4",
64
66
  "karma-chai": "^0.1.0",
65
67
  "karma-chrome-launcher": "^3.2.0",
@@ -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.1'
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.1
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 (SpyneAppProperties.initialized === false) {
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
- SpyneAppProperties.addPluginConfig(name, config)
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 = SpyneAppProperties.getPluginConfigByPluginName(this.props.pluginName)
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
  })