@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.
@@ -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
@@ -0,0 +1,2 @@
1
+ import { unplugin } from './src/plugin.js';
2
+ export default unplugin.esbuild;
package/html.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ declare module '*.html' {
2
+ type ConnectableNodeList = Node[] & {
3
+ connect(root?: Element | DocumentFragment): Element | DocumentFragment | undefined;
4
+ };
5
+ const template: (props?: Record<string, unknown>) => ConnectableNodeList;
6
+ export default template;
7
+ }
package/index.js CHANGED
@@ -1,17 +1,7 @@
1
- const ContextBinding = require('./src/context-binding');
2
- const DataManager = require('./src/data-manager');
3
- const EventMap = require('./src/event-map');
4
- const i18n = require('./src/i18n');
5
- const utils = require('./src/utils');
6
- const bindEvents = require('./src/bind-events');
7
- const setupConnect = require('./src/setup-connect');
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
- const HtmlLoader = require('./src/loaders/html-loader');
1
+ import { transformHTML } from './src/loaders/html-loader.js';
2
2
 
3
- module.exports = {
4
- process: (src) => HtmlLoader(src),
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
- const HtmlLoader = require('./src/loaders/html-loader');
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": "1.1.8",
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
- "es6-templates": "^0.2.3",
13
- "fastparse": "^1.1.1",
14
- "html-minifier": "^3.5.8",
15
- "html-webpack-plugin": "^3.2.0",
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": "^6.8.0",
22
- "eslint-config-babel": "^9.0.0",
23
- "eslint-config-google": "^0.13.0",
24
- "eslint-plugin-jsdoc": "^15.8.0",
25
- "jsdoc": "^3.6.3",
26
- "jsdoc-to-markdown": "^5.0.0"
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
@@ -0,0 +1,2 @@
1
+ import { unplugin } from './src/plugin.js';
2
+ export default unplugin.rollup;
package/rspack.js ADDED
@@ -0,0 +1,2 @@
1
+ import { unplugin } from './src/plugin.js';
2
+ export default unplugin.rspack;
@@ -1,4 +1,4 @@
1
- const {template} = require('./utils');
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
- module.exports = bindEvents;
99
+ export default bindEvents;
@@ -1,5 +1,5 @@
1
1
 
2
- module.exports = (superclass) =>
2
+ export default (superclass) =>
3
3
  /**
4
4
  * @class ContextBinding
5
5
  * @param {class} superclass inheriting class
@@ -1,34 +1,33 @@
1
- const EventMap = require('./event-map');
1
+ import EventMap from './event-map.js';
2
2
 
3
- module.exports = (() => {
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
- const DataStore = new class {
11
- constructor() {
12
- this._state = new EventMap();
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
- get(key) {
21
- return key ? this._state.get(key) : this._state.getAll();
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
- getState() {
29
- return this._state.getAll();
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
- set(key, value) {
40
- let query = key;
41
- if (value) {
42
- // we have a single value
43
- query = {[key]: value};
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
- setState(newState) {
55
- return this.set(newState);
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
- subscribe(callback) {
64
- return callback && this._state.on('set', callback);
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
- subscribeTo(keys, callback) {
75
- keys = typeof (keys) === 'string' ? [keys] : keys;
76
- return this.subscribe((event, newState, oldState) => {
77
- let updates;
78
- keys.forEach((property) => {
79
- if (newState[property] !== oldState[property]) {
80
- updates = {
81
- ...updates,
82
- [property]: {
83
- oldValue: oldState[property],
84
- newValue: newState[property],
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
- return DataStore;
94
- })();
88
+ updates && callback(updates, newState, oldState);
89
+ });
90
+ }
91
+ }
92
+
93
+ export default DataManager;
package/src/event-map.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @class EventMap
3
3
  * @description provides an event bus for when properties of the underlying Map change.
4
4
  */
5
- module.exports = class EventMap {
5
+ export default class EventMap {
6
6
  constructor() {
7
7
  this._map = new Map();
8
8
  this._subscribers = {