@lwrjs/shared-utils 0.11.0-alpha.12 → 0.11.0-alpha.13
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/build/cjs/html-meta.cjs
CHANGED
|
@@ -64,8 +64,12 @@ var isSelfUrlRegex = /^\s*(data:|#)/i;
|
|
|
64
64
|
function hasHydrationDirective(attrs = {}) {
|
|
65
65
|
return Object.keys(attrs).some((attr) => attr === HYDRATE_DIRECTIVE);
|
|
66
66
|
}
|
|
67
|
-
async function extractMetadataFromHtml(htmlSource, viewMetadata) {
|
|
67
|
+
async function extractMetadataFromHtml(htmlSource, viewMetadata, appConfig) {
|
|
68
68
|
const {customElements, assetReferences, serverData} = viewMetadata;
|
|
69
|
+
const {
|
|
70
|
+
bundleConfig: {external = {}}
|
|
71
|
+
} = appConfig;
|
|
72
|
+
const externals = Object.keys(external);
|
|
69
73
|
return new Promise((resolve, reject) => {
|
|
70
74
|
const openElements = new Set();
|
|
71
75
|
const parser = new import_parse5_sax_parser.default({sourceCodeLocationInfo: true});
|
|
@@ -76,7 +80,7 @@ async function extractMetadataFromHtml(htmlSource, viewMetadata) {
|
|
|
76
80
|
attrs,
|
|
77
81
|
sourceCodeLocation
|
|
78
82
|
}) => {
|
|
79
|
-
if (tagName.includes("-") && !openElements.has(tagName)) {
|
|
83
|
+
if (tagName.includes("-") && !openElements.has(tagName) && !externals.includes((0, import_identity.kebabCaseToModuleSpecifier)(tagName))) {
|
|
80
84
|
const {startOffset, endOffset} = sourceCodeLocation;
|
|
81
85
|
const props = attrs.length ? attrs.reduce((obj, {name, value}) => {
|
|
82
86
|
obj[(0, import_identity.getPropFromAttrName)(name)] = value === "" ? "true" : value;
|
package/build/es/html-meta.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { RenderedViewMetadata } from '@lwrjs/types';
|
|
1
|
+
import type { NormalizedLwrGlobalConfig, RenderedViewMetadata } from '@lwrjs/types';
|
|
2
2
|
export declare function isRelative(url: string): boolean;
|
|
3
3
|
export declare function isSelfUrl(url: string): boolean;
|
|
4
4
|
/**
|
|
5
5
|
* Pull the custom elements and img tags out of an HTML string, to use as metadata
|
|
6
6
|
* @param htmlSource - An HTML string to parse
|
|
7
7
|
*/
|
|
8
|
-
export declare function extractMetadataFromHtml(htmlSource: string, viewMetadata: RenderedViewMetadata): Promise<RenderedViewMetadata>;
|
|
8
|
+
export declare function extractMetadataFromHtml(htmlSource: string, viewMetadata: RenderedViewMetadata, appConfig: NormalizedLwrGlobalConfig): Promise<RenderedViewMetadata>;
|
|
9
9
|
export declare const HYDRATE_DIRECTIVE = "lwr:hydrate";
|
|
10
10
|
export declare const HYDRATE_LOAD_VALUE = "load";
|
|
11
11
|
export declare const HYDRATE_CLIENT_VALUE = "client-only";
|
package/build/es/html-meta.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getPropFromAttrName } from './identity.js';
|
|
1
|
+
import { getPropFromAttrName, kebabCaseToModuleSpecifier } from './identity.js';
|
|
2
2
|
import SAXParser from 'parse5-sax-parser';
|
|
3
3
|
import { Readable } from 'stream';
|
|
4
4
|
function parseAssetLocation(htmlSource, tagName, attrLocation) {
|
|
@@ -36,8 +36,10 @@ function hasHydrationDirective(attrs = {}) {
|
|
|
36
36
|
* Pull the custom elements and img tags out of an HTML string, to use as metadata
|
|
37
37
|
* @param htmlSource - An HTML string to parse
|
|
38
38
|
*/
|
|
39
|
-
export async function extractMetadataFromHtml(htmlSource, viewMetadata) {
|
|
39
|
+
export async function extractMetadataFromHtml(htmlSource, viewMetadata, appConfig) {
|
|
40
40
|
const { customElements, assetReferences, serverData } = viewMetadata;
|
|
41
|
+
const { bundleConfig: { external = {} }, } = appConfig;
|
|
42
|
+
const externals = Object.keys(external);
|
|
41
43
|
return new Promise((resolve, reject) => {
|
|
42
44
|
const openElements = new Set();
|
|
43
45
|
const parser = new SAXParser({ sourceCodeLocationInfo: true }); // TODO: Would we need this in the future?
|
|
@@ -46,7 +48,9 @@ export async function extractMetadataFromHtml(htmlSource, viewMetadata) {
|
|
|
46
48
|
parser.on('startTag', ({ tagName, attrs, // attributes are passed into SSR
|
|
47
49
|
sourceCodeLocation, }) => {
|
|
48
50
|
// custom elements
|
|
49
|
-
if (tagName.includes('-') &&
|
|
51
|
+
if (tagName.includes('-') &&
|
|
52
|
+
!openElements.has(tagName) &&
|
|
53
|
+
!externals.includes(kebabCaseToModuleSpecifier(tagName))) {
|
|
50
54
|
const { startOffset, endOffset } = sourceCodeLocation;
|
|
51
55
|
// transform attributes [{ name: 'some-attr', value: 'the value' }] into properties { someAttr: 'the value' }
|
|
52
56
|
// leave props as undefined if there are no attributes
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.11.0-alpha.
|
|
7
|
+
"version": "0.11.0-alpha.13",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"build/**/*.d.ts"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@lwrjs/diagnostics": "0.11.0-alpha.
|
|
40
|
+
"@lwrjs/diagnostics": "0.11.0-alpha.13",
|
|
41
41
|
"es-module-lexer": "^1.3.0",
|
|
42
42
|
"fast-json-stable-stringify": "^2.1.0",
|
|
43
43
|
"magic-string": "^0.30.0",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"slugify": "^1.4.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@lwrjs/types": "0.11.0-alpha.
|
|
53
|
+
"@lwrjs/types": "0.11.0-alpha.13",
|
|
54
54
|
"@types/mime-types": "2.1.1",
|
|
55
55
|
"@types/path-to-regexp": "^1.7.0"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=16.0.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "101ac765e89de3b378b4c049cdeb0cfc635ae22a"
|
|
61
61
|
}
|