@ornery/web-components 1.1.8 → 4.0.0
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/.github/workflows/publish.yml +25 -0
- package/esbuild.js +2 -0
- package/html.d.ts +7 -0
- package/index.js +7 -17
- package/jestLoader.js +5 -3
- package/loader.js +1 -2
- package/package.json +26 -18
- package/rollup.js +2 -0
- package/rspack.js +2 -0
- package/src/bind-events.js +2 -2
- package/src/context-binding.js +1 -1
- package/src/data-manager.js +51 -52
- package/src/event-map.js +1 -1
- package/src/i18n.js +87 -187
- package/src/index.js +5 -7
- package/src/loaders/attrs-parser.js +2 -2
- package/src/loaders/html-loader.js +107 -131
- package/src/plugin.js +14 -0
- package/src/setup-connect.js +1 -1
- package/src/utils.js +46 -36
- package/templates.js +2 -7
- package/tests/fixtures/list.html +10 -0
- package/tests/fixtures/list.scss +12 -0
- package/tests/loader.smoke.test.mjs +127 -0
- package/vite.js +2 -0
- package/webpack.js +2 -0
- package/src/loaders/rules.js +0 -17
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: '20'
|
|
19
|
+
registry-url: 'https://registry.npmjs.org'
|
|
20
|
+
|
|
21
|
+
- run: npm install
|
|
22
|
+
|
|
23
|
+
- run: npm publish --access public
|
|
24
|
+
env:
|
|
25
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/esbuild.js
ADDED
package/html.d.ts
ADDED
package/index.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
ContextBinding,
|
|
11
|
-
DataManager,
|
|
12
|
-
EventMap,
|
|
13
|
-
bindEvents,
|
|
14
|
-
setupConnect,
|
|
15
|
-
...i18n,
|
|
16
|
-
...utils,
|
|
17
|
-
};
|
|
1
|
+
export { default as ContextBinding } from './src/context-binding.js';
|
|
2
|
+
export { default as DataManager } from './src/data-manager.js';
|
|
3
|
+
export { default as EventMap } from './src/event-map.js';
|
|
4
|
+
export { I18n } from './src/i18n.js';
|
|
5
|
+
export { default as bindEvents } from './src/bind-events.js';
|
|
6
|
+
export { default as setupConnect } from './src/setup-connect.js';
|
|
7
|
+
export * from './src/utils.js';
|
package/jestLoader.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { transformHTML } from './src/loaders/html-loader.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export default {
|
|
4
|
+
processAsync: async (src, filename) => ({
|
|
5
|
+
code: await transformHTML(src, filename),
|
|
6
|
+
}),
|
|
5
7
|
};
|
package/loader.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports = HtmlLoader;
|
|
1
|
+
export { default } from './webpack.js';
|
package/package.json
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ornery/web-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "WebComponents html loader and optional runtime mixins to enable creation of custom HTML elements using es6 template literal syntax in *.html files.",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./templates": "./templates.js",
|
|
10
|
+
"./loader": "./loader.js",
|
|
11
|
+
"./vite": "./vite.js",
|
|
12
|
+
"./webpack": "./webpack.js",
|
|
13
|
+
"./rollup": "./rollup.js",
|
|
14
|
+
"./esbuild": "./esbuild.js",
|
|
15
|
+
"./rspack": "./rspack.js",
|
|
16
|
+
"./html.d.ts": "./html.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"types": "./html.d.ts",
|
|
6
19
|
"scripts": {
|
|
7
|
-
"docs": "jsdoc2md src/loaders/*.js src/*.js > README.md"
|
|
20
|
+
"docs": "jsdoc2md src/loaders/*.js src/*.js > README.md",
|
|
21
|
+
"test": "node --test tests/*.test.mjs"
|
|
8
22
|
},
|
|
9
23
|
"author": "timothyswt@gmail.com",
|
|
10
24
|
"license": "MIT",
|
|
11
25
|
"dependencies": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"loader-utils": "^1.1.0",
|
|
17
|
-
"node-sass": "^6.0.0",
|
|
18
|
-
"sass": "^1.34.0"
|
|
26
|
+
"fastparse": "^1.1.2",
|
|
27
|
+
"html-minifier-terser": "^7.2.0",
|
|
28
|
+
"sass": "^1.86.0",
|
|
29
|
+
"unplugin": "^3.0.0"
|
|
19
30
|
},
|
|
20
31
|
"devDependencies": {
|
|
21
|
-
"eslint": "^
|
|
22
|
-
"eslint-config-
|
|
23
|
-
"eslint-
|
|
24
|
-
"
|
|
25
|
-
"jsdoc": "^
|
|
26
|
-
"
|
|
27
|
-
},
|
|
28
|
-
"peerDependencies": {
|
|
29
|
-
"node-sass": "^4.13.1"
|
|
32
|
+
"eslint": "^9.0.0",
|
|
33
|
+
"eslint-config-google": "^0.14.0",
|
|
34
|
+
"eslint-plugin-jsdoc": "^50.0.0",
|
|
35
|
+
"jsdoc": "^4.0.0",
|
|
36
|
+
"jsdoc-to-markdown": "^9.0.0",
|
|
37
|
+
"jsdom": "^29.1.1"
|
|
30
38
|
}
|
|
31
39
|
}
|
package/rollup.js
ADDED
package/rspack.js
ADDED
package/src/bind-events.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import {template} from './utils.js';
|
|
2
2
|
/**
|
|
3
3
|
* @param {HTMLElement} root The root element to find all elements from.
|
|
4
4
|
* @param {Object} context the context object for finding functions to bind against. default is the root element
|
|
@@ -96,4 +96,4 @@ const bindEvents = (root, context = root) => {
|
|
|
96
96
|
return root;
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
export default bindEvents;
|
package/src/context-binding.js
CHANGED
package/src/data-manager.js
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import EventMap from './event-map.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
/**
|
|
3
|
+
/**
|
|
5
4
|
* @class DataStore
|
|
6
5
|
* @description Configuration values can be set and propagated to consuming
|
|
7
6
|
* components via this static class or through
|
|
8
7
|
* the corresponding wc-config element
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
class DataManager {
|
|
10
|
+
constructor() {
|
|
11
|
+
this._state = new EventMap();
|
|
12
|
+
}
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
/**
|
|
16
15
|
* @memberOf DataStore
|
|
17
16
|
* @param {String} key
|
|
18
17
|
* @return {Object} the current value of the requested property name.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
get(key) {
|
|
20
|
+
return key ? this._state.get(key) : this._state.getAll();
|
|
21
|
+
}
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
/**
|
|
25
24
|
* @memberOf DataStore
|
|
26
25
|
* @return {Object} the current state object.
|
|
27
26
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
getState() {
|
|
28
|
+
return this._state.getAll();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
32
31
|
* @memberOf DataStore
|
|
33
32
|
* @param {String|Object} key the name of the value to set.
|
|
34
33
|
* It can also be called with an {} query to set multiple values at once.
|
|
@@ -36,59 +35,59 @@ module.exports = (() => {
|
|
|
36
35
|
* @return {{state}|*}
|
|
37
36
|
* @description wraps this.set
|
|
38
37
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
return this._state.replace({...this._state.getAll(), ...query});
|
|
38
|
+
set(key, value) {
|
|
39
|
+
let query = key;
|
|
40
|
+
if (value) {
|
|
41
|
+
// we have a single value
|
|
42
|
+
query = {[key]: value};
|
|
46
43
|
}
|
|
44
|
+
return this._state.replace({...this._state.getAll(), ...query});
|
|
45
|
+
}
|
|
47
46
|
|
|
48
|
-
|
|
47
|
+
/**
|
|
49
48
|
* @memberOf DataStore
|
|
50
49
|
* @param {Object} newState the new state object.
|
|
51
50
|
* @return {{state}|*}
|
|
52
51
|
* @description wraps this.set
|
|
53
52
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
setState(newState) {
|
|
54
|
+
return this.set(newState);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
58
57
|
* @memberOf DataStore
|
|
59
58
|
* @param {Function} callback is the function to execute when any property changes.
|
|
60
59
|
* @return {{destroy}|*}
|
|
61
60
|
* @description call destroy() on the returned object to remove the event listener.
|
|
62
61
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
subscribe(callback) {
|
|
63
|
+
return callback && this._state.on('set', callback);
|
|
64
|
+
}
|
|
66
65
|
|
|
67
|
-
|
|
66
|
+
/**
|
|
68
67
|
* @memberOf DataStore
|
|
69
68
|
* @param {Array} keys the property names to be notified when they mutate
|
|
70
69
|
* @param {Function} callback the callback to be executed when any of the value for any of those keys have changed.
|
|
71
70
|
* @return {{destroy}|*}
|
|
72
71
|
* @description call destroy() on the returned object to remove the event listener.
|
|
73
72
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
89
|
-
updates && callback(updates, newState, oldState);
|
|
73
|
+
subscribeTo(keys, callback) {
|
|
74
|
+
keys = typeof (keys) === 'string' ? [keys] : keys;
|
|
75
|
+
return this.subscribe((event, newState, oldState) => {
|
|
76
|
+
let updates;
|
|
77
|
+
keys.forEach((property) => {
|
|
78
|
+
if (newState[property] !== oldState[property]) {
|
|
79
|
+
updates = {
|
|
80
|
+
...updates,
|
|
81
|
+
[property]: {
|
|
82
|
+
oldValue: oldState[property],
|
|
83
|
+
newValue: newState[property],
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
90
87
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
88
|
+
updates && callback(updates, newState, oldState);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default DataManager;
|
package/src/event-map.js
CHANGED