@webqit/oohtml 1.9.22 → 1.10.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/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "wicg-proposal"
15
15
  ],
16
16
  "homepage": "https://webqit.io/tooling/oohtml",
17
- "version": "1.9.22",
17
+ "version": "1.10.0-0",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -32,7 +32,7 @@
32
32
  "scripts": {
33
33
  "test": "mocha --extension .test.js --exit",
34
34
  "test:coverage": "c8 --reporter=text-lcov npm run test | coveralls",
35
- "build": "webpack --config ./webpack.config.cjs",
35
+ "build": "esbuild main=src/browser-entry.js html-modules=src/html-modules/browser-entry.js html-imports=src/html-imports/browser-entry.js state-api=src/state-api/browser-entry.js namespaced-html=src/namespaced-html/browser-entry.js subscript=src/subscript/browser-entry.js --bundle --minify --sourcemap --outdir=dist",
36
36
  "preversion": "npm run test && npm run build && git add -A dist",
37
37
  "postversion": "npm publish",
38
38
  "postpublish": "git push && git push --tags"
@@ -40,18 +40,16 @@
40
40
  "dependencies": {
41
41
  "@webqit/browser-pie": "^0.0.17",
42
42
  "@webqit/observer": "^1.7.5",
43
- "@webqit/subscript": "^2.1.6",
43
+ "@webqit/subscript": "^2.1.27",
44
44
  "@webqit/util": "^0.8.7",
45
45
  "acorn": "^8.7.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "chai": "^4.3.4",
49
- "compression-webpack-plugin": "^9.2.0",
50
49
  "coveralls": "^3.1.1",
50
+ "esbuild": "^0.14.43",
51
51
  "mocha": "^9.0.2",
52
- "mocha-lcov-reporter": "^1.3.0",
53
- "webpack": "^5.69.0",
54
- "webpack-cli": "^4.9.2"
52
+ "mocha-lcov-reporter": "^1.3.0"
55
53
  },
56
54
  "author": "Oxford Harrison <oxharris.dev@gmail.com>",
57
55
  "maintainers": [
@@ -109,7 +109,7 @@ export default function init( _config = {} ) {
109
109
  });
110
110
  };
111
111
 
112
- const discoverContents = (contents, node, path, mutationType = null, fireEvents = true) => {
112
+ const discoverContents = (node, contentNode, path, mutationType = null, fireEvents = true) => {
113
113
 
114
114
  // -----------------------
115
115
  // Templates and exports
@@ -123,8 +123,8 @@ export default function init( _config = {} ) {
123
123
  var _path = (path ? path + '/' : '') + templateName;
124
124
  if (mutationType === 'removed') {
125
125
  _internals(node, 'oohtml', 'templates').delete(templateName)
126
- if (_internals(node, 'oohtml').get('parentTemplate') === node) {
127
- _internals(node, 'oohtml').delete('parentTemplate');
126
+ if (_internals(el, 'oohtml').get('parentTemplate') === node) {
127
+ _internals(el, 'oohtml').delete('parentTemplate');
128
128
  }
129
129
  if (eventsObject) {
130
130
  eventsObject.removedTemplates[templateName] = el;
@@ -137,7 +137,7 @@ export default function init( _config = {} ) {
137
137
  }
138
138
  }
139
139
  // Recurse
140
- discoverContents(el.content, el, _path, mutationType, fireEvents);
140
+ discoverContents(el, el.content, _path, mutationType, fireEvents);
141
141
  } else {
142
142
  const manageExportItem = exportItem => {
143
143
  var exportId = exportItem.getAttribute(_meta.get('attr.exportgroup')) || 'default';
@@ -183,7 +183,7 @@ export default function init( _config = {} ) {
183
183
  // Run...
184
184
  node.modulemutationsType = mutationType;
185
185
  const eventsObject = { addedTemplates: Object.create(null), removedTemplates: Object.create(null), addedExports: Object.create(null), removedExports: Object.create(null), };
186
- _arrFrom(contents.children).forEach(el => manageComponent(el, eventsObject, mutationType, fireEvents));
186
+ _arrFrom(contentNode.children).forEach(el => manageComponent(el, eventsObject, mutationType, fireEvents));
187
187
  if (fireEvents) {
188
188
  fireDocumentTemplateEvent('templatemutation', eventsObject, path);
189
189
  }
@@ -192,14 +192,28 @@ export default function init( _config = {} ) {
192
192
  // Handle content loading
193
193
  if (mutationType === 'added' && !_internals(node, 'oohtml').get('onLiveMode')) {
194
194
  _internals(node, 'oohtml').set('onLiveMode', true);
195
- if (node.getAttribute('src') && !node.content.children.length) {
196
- loadingTemplates.push(loadTemplateContent(node, path));
195
+ const honourSrc = () => {
196
+ if (node.content.children.length) return;
197
+ _internals(node, 'oohtml').delete('onAccess');
198
+ return loadTemplateContent(node, path);
199
+ };
200
+ if (node.getAttribute('src')) {
201
+ if (node.getAttribute('loading') === 'lazy') {
202
+ _internals(node, 'oohtml').set('onAccess', honourSrc);
203
+ } else {
204
+ loadingTemplates.push(honourSrc());
205
+ }
197
206
  }
198
207
  mutations.onAttrChange(node, mr => {
199
- if (mr[0].target.getAttribute(mr[0].attributeName) !== mr[0].oldValue) {
200
- loadTemplateContent(node, path);
208
+ if (mr[0].target.getAttribute(mr[0].attributeName) === mr[0].oldValue) return;
209
+ if (node.getAttribute('loading') === 'lazy') {
210
+ _internals(node, 'oohtml').set('onAccess', honourSrc);
211
+ } else if (mr[0].attributeName === 'loading') {
212
+ _internals(node, 'oohtml').delete('onAccess');
213
+ } else {
214
+ honourSrc();
201
215
  }
202
- }, ['src']);
216
+ }, ['src', 'loading']);
203
217
 
204
218
  // -----------------------
205
219
  // Watch mutations
@@ -211,7 +225,7 @@ export default function init( _config = {} ) {
211
225
  });
212
226
  fireDocumentTemplateEvent('templatemutation', eventsObject, path);
213
227
  });
214
- mo.observe(contents, {childList: true});
228
+ mo.observe(contentNode, {childList: true});
215
229
  }
216
230
 
217
231
  };
@@ -239,6 +253,9 @@ export default function init( _config = {} ) {
239
253
  }
240
254
  Object.defineProperty(TemplateElementClass.prototype, _meta.get('api.templates'), {
241
255
  get: function() {
256
+ if (_internals(this, 'oohtml').has('onAccess')) {
257
+ _internals(this, 'oohtml').get('onAccess')();
258
+ }
242
259
  return mapToObject(_internals(this, 'oohtml', 'templates'));
243
260
  }
244
261
  });
@@ -247,6 +264,9 @@ export default function init( _config = {} ) {
247
264
  }
248
265
  Object.defineProperty(TemplateElementClass.prototype, _meta.get('api.exports'), {
249
266
  get: function() {
267
+ if (_internals(this, 'oohtml').has('onAccess')) {
268
+ _internals(this, 'oohtml').get('onAccess')();
269
+ }
250
270
  return mapToObject(_internals(this, 'oohtml', 'exports'));
251
271
  }
252
272
  });
@@ -293,25 +313,24 @@ export default function init( _config = {} ) {
293
313
  var name = el.getAttribute(_meta.get('attr.moduleid'));
294
314
  if (!el.closest(_meta.get('element.import')) && validateModuleName(name)) {
295
315
  _internals(document, 'oohtml', 'templates').set(name, el);
296
- discoverContents(el.content, el, name, 'added', false);
316
+ discoverContents(el, el.content, name, 'added', false);
297
317
  }
298
318
  });
299
319
  mutations.onPresenceChange(templateSelector, async (els, presence) => {
300
320
  const eventsObject = { addedTemplates: Object.create(null), removedTemplates: Object.create(null), addedExports: Object.create(null), removedExports: Object.create(null), };
301
321
  els.forEach(el => {
302
322
  var name = el.getAttribute(_meta.get('attr.moduleid'));
303
- if (!el.closest(_meta.get('element.import')) && validateModuleName(name)) {
304
- if (presence) {
305
- _internals(document, 'oohtml', 'templates').set(name, el);
306
- discoverContents(el.content, el, name, 'added');
307
- eventsObject.addedTemplates[name] = el;
308
- } else {
309
- if (_internals(document, 'oohtml', 'templates').get(name) === el) {
310
- _internals(document, 'oohtml', 'templates').delete(name);
311
- }
312
- discoverContents(el.content, el, name, 'removed');
313
- eventsObject.removedTemplates[name] = el;
323
+ if (el.closest(_meta.get('element.import')) || !validateModuleName(name)) return;
324
+ if (presence) {
325
+ _internals(document, 'oohtml', 'templates').set(name, el);
326
+ discoverContents(el, el.content, name, 'added');
327
+ eventsObject.addedTemplates[name] = el;
328
+ } else {
329
+ if (_internals(document, 'oohtml', 'templates').get(name) === el) {
330
+ _internals(document, 'oohtml', 'templates').delete(name);
314
331
  }
332
+ discoverContents(el, el.content, name, 'removed');
333
+ eventsObject.removedTemplates[name] = el;
315
334
  }
316
335
  });
317
336
  fireDocumentTemplateEvent('templatemutation', eventsObject, '');
package/src/index.js CHANGED
@@ -19,8 +19,8 @@ export default function init(configs = {}) {
19
19
  if (WebQit.OOHTML) {
20
20
  return;
21
21
  }
22
- WebQit.OOHTML = {};
23
22
  // --------------
23
+ WebQit.OOHTML = {};
24
24
  WebQit.Observer = Observer;
25
25
  // --------------
26
26
  HTMLModules.call(this, (configs.HTMLModules || {}));
Binary file
Binary file
Binary file
Binary file
package/dist/main.js.gz DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,24 +0,0 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- const path = require('path');
6
- const CompressionPlugin = require("compression-webpack-plugin");
7
-
8
- module.exports = {
9
- plugins: [ new CompressionPlugin() ],
10
- mode: process.argv.includes('--dev') ? 'development' : 'production',
11
- entry: {
12
- main: './src/browser-entry.js',
13
- 'html-modules': './src/html-modules/browser-entry.js',
14
- 'html-imports': './src/html-imports/browser-entry.js',
15
- 'state-api': './src/state-api/browser-entry.js',
16
- 'namespaced-html': './src/namespaced-html/browser-entry.js',
17
- 'subscript': './src/subscript/browser-entry.js',
18
- },
19
- output: {
20
- filename: '[name].js',
21
- path: path.resolve(__dirname, 'dist'),
22
- },
23
- devtool: 'source-map',
24
- };