amphora-html 6.0.0-3 → 6.0.0-6

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.
Files changed (43) hide show
  1. package/.envrc +1 -1
  2. package/lib/media.js +6 -22
  3. package/package.json +1 -1
  4. package/.vscode/.history/amphora-html/lib/media.test_20210527151433.js +0 -797
  5. package/.vscode/.history/amphora-html/lib/media.test_20210607095503.js +0 -815
  6. package/.vscode/.history/amphora-html/lib/media.test_20210607095544.js +0 -815
  7. package/.vscode/.history/amphora-html/lib/media.test_20210607100025.js +0 -817
  8. package/.vscode/.history/amphora-html/lib/media.test_20210607100402.js +0 -817
  9. package/.vscode/.history/amphora-html/lib/media.test_20210607100635.js +0 -829
  10. package/.vscode/.history/amphora-html/lib/media.test_20210607105251.js +0 -852
  11. package/.vscode/.history/amphora-html/lib/media.test_20210607120734.js +0 -839
  12. package/.vscode/.history/amphora-html/lib/media.test_20210607121735.js +0 -873
  13. package/.vscode/.history/amphora-html/lib/media.test_20210608203514.js +0 -908
  14. package/.vscode/.history/amphora-html/lib/media_20210511135806.js +0 -434
  15. package/.vscode/.history/amphora-html/lib/media_20210512105948.js +0 -434
  16. package/.vscode/.history/amphora-html/lib/media_20210512110245.js +0 -434
  17. package/.vscode/.history/amphora-html/lib/media_20210512114913.js +0 -434
  18. package/.vscode/.history/amphora-html/lib/media_20210512114917.js +0 -434
  19. package/.vscode/.history/amphora-html/lib/media_20210512122725.js +0 -429
  20. package/.vscode/.history/amphora-html/lib/media_20210512123057.js +0 -429
  21. package/.vscode/.history/amphora-html/lib/media_20210512123102.js +0 -429
  22. package/.vscode/.history/amphora-html/lib/media_20210512123201.js +0 -429
  23. package/.vscode/.history/amphora-html/lib/media_20210512152244.js +0 -429
  24. package/.vscode/.history/amphora-html/lib/media_20210512152536.js +0 -433
  25. package/.vscode/.history/amphora-html/lib/media_20210512152541.js +0 -433
  26. package/.vscode/.history/amphora-html/lib/media_20210512152717.js +0 -433
  27. package/.vscode/.history/amphora-html/lib/media_20210512152931.js +0 -419
  28. package/.vscode/.history/amphora-html/lib/media_20210512152949.js +0 -420
  29. package/.vscode/.history/amphora-html/lib/media_20210512152958.js +0 -418
  30. package/.vscode/.history/amphora-html/lib/media_20210512155619.js +0 -418
  31. package/.vscode/.history/amphora-html/lib/media_20210512164028.js +0 -418
  32. package/.vscode/.history/amphora-html/lib/media_20210512170157.js +0 -418
  33. package/.vscode/.history/amphora-html/lib/media_20210512171030.js +0 -418
  34. package/.vscode/.history/amphora-html/lib/media_20210607085451.js +0 -454
  35. package/.vscode/.history/amphora-html/lib/media_20210607085550.js +0 -454
  36. package/.vscode/.history/amphora-html/lib/media_20210607095350.js +0 -454
  37. package/.vscode/.history/amphora-html/lib/media_20210607121609.js +0 -455
  38. package/.vscode/.history/amphora-html/lib/media_20210607121656.js +0 -455
  39. package/.vscode/.history/amphora-html/lib/media_20210607121742.js +0 -455
  40. package/.vscode/.history/amphora-html/lib/media_20210608203406.js +0 -454
  41. package/.vscode/.history/amphora-html/package_20210607131602.json +0 -62
  42. package/.vscode/.history/amphora-html/package_20210607131617.json +0 -62
  43. package/.vscode/.history/amphora-html/package_20210608210629.json +0 -62
package/.envrc CHANGED
@@ -1,2 +1,2 @@
1
- use node 12
1
+ use node 14
2
2
  layout node
package/lib/media.js CHANGED
@@ -332,15 +332,10 @@ function getManifestAssets(state) {
332
332
  return [];
333
333
  }
334
334
 
335
- const runtime = _.get(manifest, 'runtime.js', '');
335
+ const entrypoints = _.get(manifest, 'entrypoints', []);
336
+ const scriptFiles = _.flatMap(entrypoints, entrypoint => _.get(entrypoint, 'assets.js', []));
336
337
 
337
- const scriptFiles = [...state._components, '__clay_globals', '__clay_client_init'].reduce((components, component) => {
338
- const assets = _.get(manifest, ['entrypoints', component, 'assets', 'js'], []);
339
-
340
- return components.concat(assets);
341
- }, []);
342
-
343
- return _.union(runtime, scriptFiles).map(script => url.resolve(assetHost, script));
338
+ return scriptFiles.map(script => url.resolve(assetHost, script));
344
339
  }
345
340
 
346
341
  /**
@@ -413,28 +408,17 @@ function injectScriptsAndStyles(state) {
413
408
 
414
409
  if (!locals.edit) {
415
410
  mediaMap.styles = combineFileContents(mediaMap.styles, 'public/css', '/css/', STYLE_TAG);
416
- mediaMap.scripts = combineFileContents(mediaMap.scripts, 'public/js', '/js/', SCRIPT_TAG);
417
-
418
- // TODO: Ideally, we'd load these scripts asynchronously or after the DOM
419
- // is ready, setting the `async` attribute, the `defer` attribute, or
420
- // both. Because the order in which they're parsed and executed currently
421
- // matters, we can't do that safely.
422
- mediaMap.manifestAssets = injectTags(mediaMap.manifestAssets, locals.site, SCRIPT_TAG);
411
+ mediaMap.scripts = !!mediaMap.manifestAssets && mediaMap.manifestAssets.length > 0
412
+ ? injectTags(mediaMap.manifestAssets, locals.site, DEFER_SCRIPT_TAG)
413
+ : combineFileContents(mediaMap.scripts, 'public/js', '/js/', SCRIPT_TAG);
423
414
  } else {
424
415
  mediaMap.styles = module.exports.editStylesTags ? injectTags(mediaMap.styles, locals.site, STYLE_TAG) : combineFileContents(mediaMap.styles, 'public/css', '/css/', STYLE_TAG);
425
416
  mediaMap.scripts = module.exports.editScriptsTags ? injectTags(mediaMap.scripts, locals.site, SCRIPT_TAG) : combineFileContents(mediaMap.scripts, 'public/js', '/js/', SCRIPT_TAG);
426
-
427
- // FIXME: Some of the logic which excludes client-side scripts from edit
428
- // mode sits with nymag/sites, in the `resolve-media` module, and some
429
- // lives here. Since we're currently not using Webpack for Kiln and model
430
- // assets, this feels like the best place to null out client scripts.
431
- mediaMap.manifestAssets = null;
432
417
  }
433
418
 
434
419
  return bluebird.props(mediaMap)
435
420
  .then(combinedFiles => {
436
421
  html = combinedFiles.styles ? appendMediaToTop(combinedFiles.styles, html) : html; // If there are styles, append them
437
- html = combinedFiles.manifestAssets ? appendMediaToBottom(combinedFiles.manifestAssets, html) : html; // If there are assets registered with the manifest, append them
438
422
  html = combinedFiles.scripts ? appendMediaToBottom(combinedFiles.scripts, html) : html; // If there are scripts, append them
439
423
  return html; // Return the compiled HTML
440
424
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amphora-html",
3
- "version": "6.0.0-3",
3
+ "version": "6.0.0-6",
4
4
  "description": "An HTML renderer for component data",
5
5
  "main": "index.js",
6
6
  "scripts": {