Skip to content

Commit 7fce6eb

Browse files
committed
rename project to "vue-extensions"
1 parent cfd532b commit 7fce6eb

File tree

4 files changed

+59
-48
lines changed

4 files changed

+59
-48
lines changed

README.md

+30-20
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,66 @@
1-
# vue-extensionpoints
1+
# vue-extensions
22

3-
This library is a Vue plugin providing a custom element which acts as extension point, with a named "hook". Plugins of your application then can provide components for this extension point which are automatically found and rendered replacing the extension.
3+
This library is a Vue plugin providing a custom element which acts as extension point, with a named "hook". Plugins of your application then can provide "extension" components for this extensionpoint which are automatically found and rendered replacing the extensionpoint.
44

55
This is intended wherever you need to have a "list" of different looking components at one place each provided by a plugin.
66

7-
If you just need a list of the same component, just with different data, don't use `vue-extensionpoints` just use a `v-for` directive.
7+
If you just need a list of the same component, just with different data, don't use `vue-extensions` just use a `v-for` directive.
88

99
## Install
1010

11-
The easiest way to install this library in your project is to use the corresponding Vue CLI plugin [extensionpoints](https://github.com/nerdocs/vue-cli-plugin-extensionpoints). It will do all magic for you:
11+
The easiest way to install this library in your project is to use the corresponding Vue CLI plugin [extensions](https://github.com/nerdocs/vue-cli-plugin-extensions). It will do all magic for you:
1212
```bash
13-
# vue add extensionpoints
13+
# vue add extensions
1414
```
1515

1616
#### Manual install
1717

1818
You can do everything manually too, if you want:
1919
```bash
20-
npm install vue-extensionpoints
20+
npm install vue-extensions
2121
```
2222
and add the following code:
2323

24-
Create a file, e.g. named `plugins.js` (or `plugins/index.js`) which exports all of your plugins (you can e.g. automate the creation of this file in a script):
24+
Create a file, e.g. named `extensions.js`, which exports all of your extensions as default (you can e.g. automate the creation of this file in a script):
2525
```javascript
26-
import FooPlugin from '@/plugins/fooplugin'
27-
import BarPlugin from 'my/path/to/some/plugins/barplugin.js'
26+
import FooPlugin from '@/extensions/fooplugin'
27+
import BarPlugin from 'my/path/to/some/extensions/barextension.js'
2828

2929
export default {
30-
FooPlugin, BarPlugin
30+
FooExtension,
31+
BarExtension
3132
}
3233
```
3334

34-
Now import that file into `main.js` and pass it to `vue-extensions`:
35+
Now import that file into `main.js` and pass it as "extensions" option to `vue-extensions`:
3536

3637
```javascript
3738

38-
import Extensionpoints from 'vue-extensionpoints'
39-
import plugins from '@/plugins'
39+
import Extensionpoints from 'vue-extensions'
40+
import AppExtensions from '@/extensions' // you can freely rename that
4041

41-
Vue.add(Extensionpoints, {plugins})
42+
Vue.add(Extensionpoints, {extensions: AppExtensions})
4243

4344
new Vue({
4445
//...
4546
})
4647
```
4748

48-
## Plugins
49+
Note that you have to enable Vue's runtime compiler if you want to render single file template components as extensions!
4950

50-
Easily said: Plugins are Javascript modules that export a `hooks` object, which is a named index to Vue components:
51+
```Javascript
52+
// vue.config.js
53+
module.exports = {
54+
runtimeCompiler: true
55+
}
56+
```
57+
58+
## Extensions
59+
60+
Easily said: Extensions are Javascript modules that export a `hooks` object, which is a named index pointing to Vue components:
5161

5262
```javascript
53-
// plugins/FooPlugin/index.js
63+
// extensions/FooExtension/index.js
5464
import AComponent from './components/acomponent.vue'
5565
import {FooElement, BazElement} from './components/othercomponents.vue'
5666

@@ -72,7 +82,7 @@ You have an `<extensionpoint>` tag in your project available now:
7282
</template>
7383
```
7484

75-
The *vue-extensions* plugin renders the hooked elements replacing the <extensionpoint> element, one after another. It's up to you what the plugin is rendering: One plugin can render a simple `<div>` element with an image, the next plugin (same hook!) can render a complicated component with variables, sub-components etc. The `extensionpoint` renders them one after another. You only have to make sure that your components do what they promise: in the sample case above, `FooListElement` should render a \<li\> element - because it will be rendered within an \<ul\> element. But there are no constraints, you are free to choose.
85+
The *vue-extensions* plugin renders the hooked elements replacing the <extensionpoint> element, one after another. It's up to you what the extensions are rendering: One extension can render a simple `<div>` element with an image, the next extension (same hook!) can render a complicated component with variables, sub-components etc. The `<extensionpoint>` renders them one after another. You only have to make sure that your components do what they promise: in the sample case above, `FooListElement` should render a \<li\> element - because it will be rendered within an \<ul\> element. But there are no constraints, you are free to choose.
7686

7787

7888
## Development
@@ -81,15 +91,15 @@ You have an idea, improvement, found a bug? Don't hesitate to contact me. PRs an
8191

8292
## License
8393

84-
`vue-extensionpoints` is licensed under the [MIT](https://opensource.org/licenses/mit-license.php) license
94+
`vue-extensions` is licensed under the [MIT](https://opensource.org/licenses/mit-license.php) license
8595

8696
#### Compiles and minifies library for production
8797
```
8898
npm run build-lib
8999
```
90100

91101
#### Runs your tests
92-
Currently there are no tests, because of three important causes:
102+
Currently there are no tests (yet), because of three important causes:
93103

94104
* I'm lazy
95105
* tests are not necessary here

index.js

+22-21
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,35 @@ export default {
55
/**
66
* Vue's plugin install hook.
77
*
8-
* Collects all available plugins and maintains a list of hooks, pointing to them.
8+
* Collects all available extensions and maintains a list of hooks, pointing to them.
99
* @param {Object} Vue The main Vue instance
1010
* @param {Object} options An named index of objects:
11-
* "plugins": a named index of modules that export a plugin:
12-
* name: the name of the plugin
13-
* hooks: named index of hooks, each pointing to a list of Vue components
14-
* implementing that hook. They will be rendered at each extensionpoint
15-
* that has the same hook name.
11+
* "extensions": a named index of modules that export a extension:
12+
* name: the name of the extensions
13+
* hooks: named index, each one pointing to a list of Vue
14+
* components implementing that hook. They will be
15+
* rendered at each extensionpoint that has the same hook
16+
* name.
1617
*/
1718
install: (Vue, options) => {
1819

19-
for (let pluginName in options.plugins) {
20-
let plugin = options.plugins[pluginName]
21-
if(plugin.initialize){
22-
plugin.initialize()
20+
for (let extensionName in options.extensions) {
21+
let extension = options.extensions[extensionName]
22+
if(extension.initialize){
23+
extension.initialize()
2324
}
24-
for (let hook in plugin.hooks) {
25+
for (let hook in extension.hooks) {
2526
if (hook_registry[hook] === undefined) {
26-
hook_registry[hook] = Array.isArray(plugin.hooks[hook])?
27-
plugin.hooks[hook] : [plugin.hooks[hook]]
27+
hook_registry[hook] = Array.isArray(extension.hooks[hook])?
28+
extension.hooks[hook] : [extension.hooks[hook]]
2829
}
29-
// console.debug(plugin.name + ": registering a component for hook '" + hook + "'")
30+
// console.debug(extension.name + ": registering a component for hook '" + hook + "'")
3031

31-
// add plugin's component(s) to registry
32-
if (Array.isArray(plugin.hooks[hook])) {
33-
hook_registry[hook].concat(plugin.hooks[hook])
32+
// add extension's component(s) to registry
33+
if (Array.isArray(extension.hooks[hook])) {
34+
hook_registry[hook].concat(extension.hooks[hook])
3435
} else {
35-
hook_registry[hook].push(plugin.hooks[hook])
36+
hook_registry[hook].push(extension.hooks[hook])
3637
}
3738

3839
}
@@ -44,13 +45,13 @@ export default {
4445
hook: String
4546
},
4647
computed: {
47-
plugins () {
48+
extensions () {
4849
return hook_registry[this.hook]
4950
}
5051
},
5152
template: `
52-
<div class="extensionpoint-container">
53-
<component :is="plugin_component" v-for="plugin_component in plugins" :key="plugin_component.id"/>
53+
<div class="extension-container">
54+
<component :is="extension_component" v-for="extension_component in extensions" :key="extension_component.id"/>
5455
</div>
5556
`
5657
})

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
2-
"name": "vue-extensionpoints",
3-
"version": "0.1.5",
2+
"name": "vue-extensions",
3+
"version": "0.2.0",
44
"license": "MIT",
55
"author": "Christian González <[email protected]>",
66
"scripts": {
77
"serve": "vue-cli-service serve",
8-
"build": "vue-cli-service build --target lib --name vue-extensionpoints index.js",
8+
"build": "vue-cli-service build --target lib --name vue-extensions index.js",
99
"lint": "vue-cli-service lint",
1010
"prepublish": "npm run lint && npm run build"
1111
},
1212
"repository": {
1313
"type": "git",
14-
"url": "git://github.com/nerdocs/vue-extensionpoints"
14+
"url": "git://github.com/nerdocs/vue-extensions"
1515
},
1616
"bugs": {
17-
"url": "https://github.com/nerdocs/vue-extensionpoints/issues"
17+
"url": "https://github.com/nerdocs/vue-extensions/issues"
1818
},
19-
"main": "./dist/vue-extensionpoints.common.js",
19+
"main": "./dist/vue-extensions.common.js",
2020
"dependencies": {
2121
"core-js": "^3.4.3",
2222
"vue": "^2.6.10"

0 commit comments

Comments
 (0)