@peculiar/certificates-viewer 2.0.1 → 2.0.2-alpha.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/README.md +3 -3
- package/dist/cjs/_commonjsHelpers-cb1f949a.js +23 -0
- package/dist/cjs/{download-cd98aa01.js → certification_request-96951e7b.js} +2880 -3313
- package/dist/cjs/{dom-760f300f.js → dom-f57e260e.js} +4 -1
- package/dist/cjs/download-5e7d5455.js +438 -0
- package/dist/cjs/{index-2973f90a.js → index-064e95c7.js} +287 -634
- package/dist/cjs/index.cjs.js +12 -0
- package/dist/cjs/{l10n-e971a5ac.js → l10n-2e7def18.js} +72 -90
- package/dist/cjs/loader.cjs.js +12 -3
- package/dist/cjs/peculiar-attribute-certificate-viewer_9.cjs.entry.js +1426 -1391
- package/dist/cjs/peculiar-certificate-summary_3.cjs.entry.js +66 -62
- package/dist/cjs/peculiar-certificates-viewer.cjs.entry.js +222 -217
- package/dist/cjs/peculiar.cjs.js +70 -3
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/attribute-certificate-viewer/attribute-certificate-viewer.js +220 -205
- package/dist/collection/components/attribute-certificate-viewer/holder.js +27 -24
- package/dist/collection/components/attribute-certificate-viewer/issuer.js +11 -8
- package/dist/collection/components/button/button.css +2 -7
- package/dist/collection/components/button/button.js +125 -122
- package/dist/collection/components/button-split/button-split.js +103 -100
- package/dist/collection/components/certificate-decoder/certificate-decoder.css +1 -3
- package/dist/collection/components/certificate-decoder/certificate-decoder.js +158 -155
- package/dist/collection/components/certificate-summary/certificate-summary.js +75 -72
- package/dist/collection/components/certificate-viewer/attributes/activity_description_attribute.js +11 -8
- package/dist/collection/components/certificate-viewer/attributes/as_string_attribute.js +6 -3
- package/dist/collection/components/certificate-viewer/attributes/basic_attribute.js +11 -8
- package/dist/collection/components/certificate-viewer/attributes/challenge_password_attribute.js +6 -3
- package/dist/collection/components/certificate-viewer/attributes/index.js +45 -42
- package/dist/collection/components/certificate-viewer/attributes/insurance_value_attribute.js +7 -4
- package/dist/collection/components/certificate-viewer/attributes/name_attribute.js +6 -3
- package/dist/collection/components/certificate-viewer/attributes/name_part.js +8 -5
- package/dist/collection/components/certificate-viewer/attributes/type_relationship_attribute.js +5 -2
- package/dist/collection/components/certificate-viewer/attributes/unstructured_name_attribute.js +6 -3
- package/dist/collection/components/certificate-viewer/attributes/valuation_ranking_attribute.js +18 -15
- package/dist/collection/components/certificate-viewer/attributes/web_gdpr_attribute.js +13 -10
- package/dist/collection/components/certificate-viewer/basic_information.js +13 -10
- package/dist/collection/components/certificate-viewer/certificate-viewer.js +255 -240
- package/dist/collection/components/certificate-viewer/extensions/archive_rev_info_extension.js +6 -3
- package/dist/collection/components/certificate-viewer/extensions/as_string_extension.js +6 -3
- package/dist/collection/components/certificate-viewer/extensions/attribute_value.js +4 -1
- package/dist/collection/components/certificate-viewer/extensions/authority_key_identifier_extension.js +18 -15
- package/dist/collection/components/certificate-viewer/extensions/basic_constraints_extension.js +7 -4
- package/dist/collection/components/certificate-viewer/extensions/basic_extension.js +12 -9
- package/dist/collection/components/certificate-viewer/extensions/biometric_syntax_extension.js +12 -9
- package/dist/collection/components/certificate-viewer/extensions/ca_version_extension.js +8 -5
- package/dist/collection/components/certificate-viewer/extensions/certificate_policies_extension.js +28 -25
- package/dist/collection/components/certificate-viewer/extensions/certificate_template_extension.js +8 -5
- package/dist/collection/components/certificate-viewer/extensions/certificate_transparency_extension.js +13 -10
- package/dist/collection/components/certificate-viewer/extensions/crl_distribution_points_extension.js +11 -8
- package/dist/collection/components/certificate-viewer/extensions/crl_reason_extension.js +6 -3
- package/dist/collection/components/certificate-viewer/extensions/enroll_cert_type_extension.js +6 -3
- package/dist/collection/components/certificate-viewer/extensions/entrust_version_info_extension.js +7 -4
- package/dist/collection/components/certificate-viewer/extensions/extended_key_usage_extension.js +5 -2
- package/dist/collection/components/certificate-viewer/extensions/general_name_part.js +55 -52
- package/dist/collection/components/certificate-viewer/extensions/index.js +112 -109
- package/dist/collection/components/certificate-viewer/extensions/info_access_syntax_extension.js +9 -6
- package/dist/collection/components/certificate-viewer/extensions/key_usage_extension.js +6 -3
- package/dist/collection/components/certificate-viewer/extensions/lei_extension.js +6 -3
- package/dist/collection/components/certificate-viewer/extensions/lei_role_extennsion.js +6 -3
- package/dist/collection/components/certificate-viewer/extensions/logotype_extension.js +49 -46
- package/dist/collection/components/certificate-viewer/extensions/name_constraints_extension.js +8 -5
- package/dist/collection/components/certificate-viewer/extensions/netscape_cert_type_extension.js +6 -3
- package/dist/collection/components/certificate-viewer/extensions/netscape_comment_extension.js +6 -3
- package/dist/collection/components/certificate-viewer/extensions/policy_constraints_extension.js +7 -4
- package/dist/collection/components/certificate-viewer/extensions/policy_mappings_extension.js +9 -6
- package/dist/collection/components/certificate-viewer/extensions/private_key_usage_period_extension.js +7 -4
- package/dist/collection/components/certificate-viewer/extensions/qc_statements_extension.js +9 -6
- package/dist/collection/components/certificate-viewer/extensions/subject_alternative_name_extension.js +5 -2
- package/dist/collection/components/certificate-viewer/extensions/subject_directory_attributes_extension.js +9 -6
- package/dist/collection/components/certificate-viewer/extensions/subject_key_identifier_extension.js +18 -15
- package/dist/collection/components/certificate-viewer/extensions/timestamp_extension.js +8 -5
- package/dist/collection/components/certificate-viewer/extensions/tn_auth_list_extension.js +10 -7
- package/dist/collection/components/certificate-viewer/get_string_by_oid.js +8 -5
- package/dist/collection/components/certificate-viewer/issuer_name.js +9 -6
- package/dist/collection/components/certificate-viewer/miscellaneous.js +29 -26
- package/dist/collection/components/certificate-viewer/public_key.js +31 -28
- package/dist/collection/components/certificate-viewer/row.js +35 -32
- package/dist/collection/components/certificate-viewer/signature.js +12 -9
- package/dist/collection/components/certificate-viewer/subject_name.js +8 -5
- package/dist/collection/components/certificate-viewer/thumbprints.js +15 -12
- package/dist/collection/components/certificates-viewer/certificates-viewer.css +1 -19
- package/dist/collection/components/certificates-viewer/certificates-viewer.js +384 -381
- package/dist/collection/components/circular-progress/circular-progress.css +2 -24
- package/dist/collection/components/circular-progress/circular-progress.js +73 -70
- package/dist/collection/components/csr-viewer/csr-viewer.js +197 -188
- package/dist/collection/components/highlight-words/highlight-words.js +56 -53
- package/dist/collection/components/link/link.css +1 -3
- package/dist/collection/components/link/link.js +60 -57
- package/dist/collection/components/text-hider/text-hider.js +75 -72
- package/dist/collection/components/typography/typography.css +1 -3
- package/dist/collection/components/typography/typography.js +126 -123
- package/dist/collection/constants/logs.js +79 -76
- package/dist/collection/constants/oids.js +2301 -2298
- package/dist/collection/crypto/asn_data.js +33 -32
- package/dist/collection/crypto/attribute.js +52 -49
- package/dist/collection/crypto/csr.js +64 -61
- package/dist/collection/crypto/extension.js +126 -123
- package/dist/collection/crypto/index.js +3 -0
- package/dist/collection/crypto/name.js +33 -32
- package/dist/collection/crypto/provider.js +28 -25
- package/dist/collection/crypto/utils.js +24 -21
- package/dist/collection/crypto/x509_attribute_certificate.js +61 -58
- package/dist/collection/crypto/x509_certificate.js +107 -104
- package/dist/collection/index.js +5 -1
- package/dist/collection/utils/date_formatter.js +19 -16
- package/dist/collection/utils/download.js +18 -15
- package/dist/collection/utils/download_from_buffer.js +30 -25
- package/dist/collection/utils/history.js +5 -2
- package/dist/collection/utils/index.js +3 -0
- package/dist/collection/utils/is_link.js +4 -1
- package/dist/collection/utils/l10n.js +28 -25
- package/dist/collection/utils/parse_hash.js +16 -13
- package/dist/collection/utils/query_stringify.js +12 -9
- package/dist/collection/utils/read_file.js +43 -40
- package/dist/collection/utils/third_party_links.js +3 -0
- package/dist/collection/utils/validator.js +15 -12
- package/dist/esm/_commonjsHelpers-bfbd2ad8.js +20 -0
- package/dist/esm/{download-1ff0a3be.js → certification_request-48e8b956.js} +2898 -3328
- package/dist/esm/{dom-91ed8d21.js → dom-f1b08a97.js} +4 -1
- package/dist/esm/download-cf68ac2c.js +434 -0
- package/dist/esm/{index-5ef692cc.js → index-bbd484d9.js} +278 -624
- package/dist/esm/index.js +5 -0
- package/dist/esm/{l10n-c8cf6930.js → l10n-ead9928b.js} +71 -86
- package/dist/esm/{loader.mjs → loader.js} +11 -2
- package/dist/esm/peculiar-attribute-certificate-viewer_9.entry.js +1425 -1390
- package/dist/esm/peculiar-certificate-summary_3.entry.js +66 -62
- package/dist/esm/peculiar-certificates-viewer.entry.js +222 -217
- package/dist/esm/peculiar.js +73 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/polyfills/index.js +2 -2
- package/dist/esm-es5/_commonjsHelpers-bfbd2ad8.js +4 -0
- package/dist/esm-es5/certification_request-48e8b956.js +89 -0
- package/dist/esm-es5/dom-f1b08a97.js +24 -0
- package/dist/esm-es5/download-cf68ac2c.js +18 -0
- package/dist/esm-es5/index-bbd484d9.js +5 -0
- package/dist/esm-es5/index.js +4 -0
- package/dist/esm-es5/l10n-ead9928b.js +39 -0
- package/dist/esm-es5/loader.js +4 -0
- package/dist/esm-es5/peculiar-attribute-certificate-viewer_9.entry.js +198 -1907
- package/dist/esm-es5/peculiar-certificate-summary_3.entry.js +4 -83
- package/dist/esm-es5/peculiar-certificates-viewer.entry.js +4 -290
- package/dist/esm-es5/peculiar.js +4 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -1
- package/dist/peculiar/index.esm.js +4 -0
- package/dist/peculiar/p-047b12d9.system.js +89 -0
- package/dist/peculiar/p-13e9d17d.system.entry.js +460 -0
- package/dist/peculiar/p-29cdd256.system.js +18 -0
- package/dist/peculiar/{p-75076c56.system.js → p-3929074b.system.js} +18 -15
- package/dist/peculiar/p-452d69af.entry.js +113 -0
- package/dist/peculiar/p-4f52a24f.system.js +39 -0
- package/dist/peculiar/p-5f7fbf05.system.entry.js +4 -0
- package/dist/peculiar/p-82033e2e.system.entry.js +4 -0
- package/dist/peculiar/p-886e9c53.js +87 -0
- package/dist/peculiar/p-88fbaf05.system.js +4 -0
- package/dist/peculiar/p-8df391dc.system.js +4 -0
- package/dist/peculiar/p-9837be14.system.js +5 -0
- package/dist/peculiar/p-9ae6b1f8.entry.js +4 -0
- package/dist/peculiar/{p-3d1015c2.js → p-9f4ee110.js} +5 -2
- package/dist/peculiar/p-c774ec0b.js +18 -0
- package/dist/peculiar/p-d09b762f.js +33 -0
- package/dist/peculiar/p-d0b55fbb.js +4 -0
- package/dist/peculiar/p-e5f99586.entry.js +4 -0
- package/dist/peculiar/p-ee0e2707.system.js +4 -0
- package/dist/peculiar/p-f7683ba5.js +5 -0
- package/dist/peculiar/peculiar.esm.js +4 -1
- package/dist/peculiar/peculiar.js +1 -3
- package/dist/types/components/attribute-certificate-viewer/attribute-certificate-viewer.d.ts +56 -56
- package/dist/types/components/attribute-certificate-viewer/holder.d.ts +1 -1
- package/dist/types/components/attribute-certificate-viewer/issuer.d.ts +1 -1
- package/dist/types/components/button/button.d.ts +17 -17
- package/dist/types/components/button-split/button-split.d.ts +10 -10
- package/dist/types/components/certificate-decoder/certificate-decoder.d.ts +16 -16
- package/dist/types/components/certificate-summary/certificate-summary.d.ts +4 -4
- package/dist/types/components/certificate-viewer/attributes/activity_description_attribute.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/as_string_attribute.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/basic_attribute.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/challenge_password_attribute.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/index.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/insurance_value_attribute.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/name_attribute.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/name_part.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/type_relationship_attribute.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/unstructured_name_attribute.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/valuation_ranking_attribute.d.ts +1 -1
- package/dist/types/components/certificate-viewer/attributes/web_gdpr_attribute.d.ts +1 -1
- package/dist/types/components/certificate-viewer/basic_information.d.ts +6 -6
- package/dist/types/components/certificate-viewer/certificate-viewer.d.ts +66 -66
- package/dist/types/components/certificate-viewer/extensions/archive_rev_info_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/as_string_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/authority_key_identifier_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/basic_constraints_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/basic_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/biometric_syntax_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/ca_version_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/certificate_policies_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/certificate_template_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/certificate_transparency_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/crl_distribution_points_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/crl_reason_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/enroll_cert_type_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/entrust_version_info_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/extended_key_usage_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/general_name_part.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/index.d.ts +2 -2
- package/dist/types/components/certificate-viewer/extensions/info_access_syntax_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/key_usage_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/lei_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/lei_role_extennsion.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/logotype_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/name_constraints_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/netscape_cert_type_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/netscape_comment_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/policy_constraints_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/policy_mappings_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/private_key_usage_period_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/qc_statements_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/subject_alternative_name_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/subject_directory_attributes_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/subject_key_identifier_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/timestamp_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/extensions/tn_auth_list_extension.d.ts +1 -1
- package/dist/types/components/certificate-viewer/issuer_name.d.ts +2 -2
- package/dist/types/components/certificate-viewer/miscellaneous.d.ts +1 -1
- package/dist/types/components/certificate-viewer/public_key.d.ts +1 -1
- package/dist/types/components/certificate-viewer/row.d.ts +7 -7
- package/dist/types/components/certificate-viewer/signature.d.ts +1 -1
- package/dist/types/components/certificate-viewer/subject_name.d.ts +1 -1
- package/dist/types/components/certificate-viewer/thumbprints.d.ts +1 -1
- package/dist/types/components/certificate-viewer/types.d.ts +26 -0
- package/dist/types/components/certificates-viewer/certificates-viewer.d.ts +64 -64
- package/dist/types/components/circular-progress/circular-progress.d.ts +10 -10
- package/dist/types/components/csr-viewer/csr-viewer.d.ts +45 -45
- package/dist/types/components/highlight-words/highlight-words.d.ts +8 -8
- package/dist/types/components/link/link.d.ts +6 -6
- package/dist/types/components/text-hider/text-hider.d.ts +4 -4
- package/dist/types/components/typography/typography.d.ts +18 -18
- package/dist/types/components.d.ts +11 -3
- package/dist/types/constants/logs.d.ts +76 -76
- package/dist/types/constants/oids.d.ts +2293 -2293
- package/dist/types/crypto/asn_data.d.ts +6 -6
- package/dist/types/crypto/attribute.d.ts +3 -3
- package/dist/types/crypto/csr.d.ts +19 -19
- package/dist/types/crypto/extension.d.ts +3 -3
- package/dist/types/crypto/name.d.ts +7 -7
- package/dist/types/crypto/provider.d.ts +15 -15
- package/dist/types/crypto/x509_attribute_certificate.d.ts +22 -22
- package/dist/types/crypto/x509_certificate.d.ts +28 -28
- package/dist/types/index.d.ts +2 -1
- package/dist/types/interface.d.ts +3 -0
- package/dist/types/stencil-public-runtime.d.ts +230 -217
- package/dist/types/utils/download.d.ts +8 -8
- package/dist/types/utils/download_from_buffer.d.ts +3 -3
- package/dist/types/utils/l10n.d.ts +43 -43
- package/dist/types/utils/read_file.d.ts +7 -7
- package/loader/cdn.js +3 -1
- package/loader/index.cjs.js +3 -1
- package/loader/index.d.ts +0 -1
- package/loader/index.es2017.js +5 -0
- package/loader/{index.mjs → index.js} +4 -2
- package/loader/package.json +4 -5
- package/package.json +15 -16
- package/dist/cjs/css-shim-1b988199.js +0 -6
- package/dist/cjs/patch-15ea31af.js +0 -112
- package/dist/cjs/shadow-css-376763e9.js +0 -385
- package/dist/esm/css-shim-5ce2b5c4.js +0 -4
- package/dist/esm/index.mjs +0 -1
- package/dist/esm/patch-f8a17185.js +0 -109
- package/dist/esm/peculiar.mjs +0 -6
- package/dist/esm/shadow-css-95922619.js +0 -383
- package/dist/esm-es5/css-shim-5ce2b5c4.js +0 -122
- package/dist/esm-es5/dom-91ed8d21.js +0 -468
- package/dist/esm-es5/download-1ff0a3be.js +0 -12692
- package/dist/esm-es5/index-5ef692cc.js +0 -1839
- package/dist/esm-es5/index.mjs +0 -0
- package/dist/esm-es5/l10n-c8cf6930.js +0 -758
- package/dist/esm-es5/loader.mjs +0 -10
- package/dist/esm-es5/patch-f8a17185.js +0 -106
- package/dist/esm-es5/peculiar.mjs +0 -5
- package/dist/esm-es5/shadow-css-95922619.js +0 -408
- package/dist/index.mjs +0 -1
- package/dist/peculiar/p-0ad0b6e8.js +0 -1
- package/dist/peculiar/p-198d9121.js +0 -1
- package/dist/peculiar/p-294c4ef9.entry.js +0 -1
- package/dist/peculiar/p-3d339152.system.entry.js +0 -1
- package/dist/peculiar/p-4b7cd42f.js +0 -12
- package/dist/peculiar/p-50ea2036.system.js +0 -1
- package/dist/peculiar/p-557d912f.system.js +0 -1
- package/dist/peculiar/p-84e8326d.entry.js +0 -110
- package/dist/peculiar/p-94f96303.system.js +0 -100
- package/dist/peculiar/p-983b5210.system.entry.js +0 -1
- package/dist/peculiar/p-9f815f76.system.js +0 -1
- package/dist/peculiar/p-aa0a9b36.system.js +0 -1
- package/dist/peculiar/p-bd1f9066.system.js +0 -36
- package/dist/peculiar/p-bd949790.js +0 -1
- package/dist/peculiar/p-cf1841f8.js +0 -30
- package/dist/peculiar/p-dbdd61e7.entry.js +0 -1
- package/dist/peculiar/p-dc6b70b2.js +0 -100
- package/dist/peculiar/p-fb53799e.system.js +0 -1
- package/dist/peculiar/p-fc92385a.system.entry.js +0 -457
- package/dist/peculiar/p-fdad110e.system.js +0 -13
- package/dist/peculiar.js +0 -30
- package/loader/index.es2017.mjs +0 -3
- package/loader/node-main.js +0 -3
|
@@ -1,41 +1,37 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
|
|
3
|
+
*/
|
|
1
4
|
const NAMESPACE = 'peculiar';
|
|
2
5
|
|
|
3
6
|
let scopeId;
|
|
4
|
-
let contentRef;
|
|
5
7
|
let hostTagName;
|
|
6
|
-
let useNativeShadowDom = false;
|
|
7
|
-
let checkSlotFallbackVisibility = false;
|
|
8
|
-
let checkSlotRelocate = false;
|
|
9
8
|
let isSvgMode = false;
|
|
10
|
-
let queueCongestion = 0;
|
|
11
9
|
let queuePending = false;
|
|
12
10
|
const win = typeof window !== 'undefined' ? window : {};
|
|
13
|
-
const CSS = win.CSS ;
|
|
14
11
|
const doc = win.document || { head: {} };
|
|
15
12
|
const plt = {
|
|
16
13
|
$flags$: 0,
|
|
17
14
|
$resourcesUrl$: '',
|
|
18
|
-
jmp: h => h(),
|
|
19
|
-
raf: h => requestAnimationFrame(h),
|
|
15
|
+
jmp: (h) => h(),
|
|
16
|
+
raf: (h) => requestAnimationFrame(h),
|
|
20
17
|
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
21
18
|
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
22
19
|
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
23
20
|
};
|
|
24
|
-
const supportsShadow = /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)() ;
|
|
25
21
|
const promiseResolve = (v) => Promise.resolve(v);
|
|
26
|
-
const supportsConstructibleStylesheets =
|
|
22
|
+
const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
27
23
|
try {
|
|
28
24
|
new CSSStyleSheet();
|
|
29
|
-
return
|
|
25
|
+
return typeof new CSSStyleSheet().replace === 'function';
|
|
30
26
|
}
|
|
31
27
|
catch (e) { }
|
|
32
28
|
return false;
|
|
33
29
|
})()
|
|
34
30
|
;
|
|
35
31
|
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
36
|
-
if (
|
|
32
|
+
if (listeners) {
|
|
37
33
|
listeners.map(([flags, name, method]) => {
|
|
38
|
-
const target =
|
|
34
|
+
const target = elm;
|
|
39
35
|
const handler = hostListenerProxy(hostRef, method);
|
|
40
36
|
const opts = hostListenerOpts(flags);
|
|
41
37
|
plt.ael(target, name, handler, opts);
|
|
@@ -44,18 +40,23 @@ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =
|
|
|
44
40
|
}
|
|
45
41
|
};
|
|
46
42
|
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
try {
|
|
44
|
+
{
|
|
45
|
+
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
46
|
+
// instance is ready, let's call it's member method for this event
|
|
47
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
51
|
+
}
|
|
54
52
|
}
|
|
55
53
|
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
consoleError(e);
|
|
56
|
+
}
|
|
56
57
|
};
|
|
57
58
|
// prettier-ignore
|
|
58
|
-
const hostListenerOpts = (flags) =>
|
|
59
|
+
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
59
60
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
60
61
|
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
61
62
|
const createTime = (fnName, tagName = '') => {
|
|
@@ -86,7 +87,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
|
|
|
86
87
|
};
|
|
87
88
|
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
88
89
|
let scopeId = getScopeId(cmpMeta);
|
|
89
|
-
|
|
90
|
+
const style = styles.get(scopeId);
|
|
90
91
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
91
92
|
// so the fallback is to always use the document for the root node in those cases
|
|
92
93
|
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
@@ -100,18 +101,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
100
101
|
}
|
|
101
102
|
if (!appliedStyles.has(scopeId)) {
|
|
102
103
|
{
|
|
103
|
-
|
|
104
|
-
styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
|
|
105
|
-
const newScopeId = styleElm['s-sc'];
|
|
106
|
-
if (newScopeId) {
|
|
107
|
-
scopeId = newScopeId;
|
|
108
|
-
// we don't want to add this styleID to the appliedStyles Set
|
|
109
|
-
// since the cssVarShim might need to apply several different
|
|
110
|
-
// stylesheets for the same component
|
|
111
|
-
appliedStyles = null;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
104
|
+
{
|
|
115
105
|
styleElm = doc.createElement('style');
|
|
116
106
|
styleElm.innerHTML = style;
|
|
117
107
|
}
|
|
@@ -122,7 +112,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
122
112
|
}
|
|
123
113
|
}
|
|
124
114
|
}
|
|
125
|
-
else if (
|
|
115
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
126
116
|
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
127
117
|
}
|
|
128
118
|
}
|
|
@@ -133,8 +123,8 @@ const attachStyles = (hostRef) => {
|
|
|
133
123
|
const elm = hostRef.$hostElement$;
|
|
134
124
|
const flags = cmpMeta.$flags$;
|
|
135
125
|
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
136
|
-
const scopeId = addStyle(
|
|
137
|
-
if (
|
|
126
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
127
|
+
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
138
128
|
// only required when we're NOT using native shadow dom (slot)
|
|
139
129
|
// or this browser doesn't support native shadow dom
|
|
140
130
|
// and this host element was NOT created with SSR
|
|
@@ -147,7 +137,7 @@ const attachStyles = (hostRef) => {
|
|
|
147
137
|
}
|
|
148
138
|
endAttachStyles();
|
|
149
139
|
};
|
|
150
|
-
const getScopeId = (cmp, mode) => 'sc-' + (
|
|
140
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
151
141
|
/**
|
|
152
142
|
* Default style mode id
|
|
153
143
|
*/
|
|
@@ -162,24 +152,11 @@ const EMPTY_OBJ = {};
|
|
|
162
152
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
163
153
|
const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
164
154
|
const isDef = (v) => v != null;
|
|
165
|
-
const noop = () => {
|
|
166
|
-
/* noop*/
|
|
167
|
-
};
|
|
168
155
|
const isComplexType = (o) => {
|
|
169
156
|
// https://jsperf.com/typeof-fn-object/5
|
|
170
157
|
o = typeof o;
|
|
171
158
|
return o === 'object' || o === 'function';
|
|
172
159
|
};
|
|
173
|
-
const IS_DENO_ENV = typeof Deno !== 'undefined';
|
|
174
|
-
const IS_NODE_ENV = !IS_DENO_ENV &&
|
|
175
|
-
typeof global !== 'undefined' &&
|
|
176
|
-
typeof require === 'function' &&
|
|
177
|
-
!!global.process &&
|
|
178
|
-
typeof __filename === 'string' &&
|
|
179
|
-
(!global.origin || typeof global.origin !== 'string');
|
|
180
|
-
const IS_DENO_WINDOWS_ENV = IS_DENO_ENV && Deno.build.os === 'windows';
|
|
181
|
-
const getCurrentDirectory = IS_NODE_ENV ? process.cwd : IS_DENO_ENV ? Deno.cwd : () => '/';
|
|
182
|
-
const exit = IS_NODE_ENV ? process.exit : IS_DENO_ENV ? Deno.exit : noop;
|
|
183
160
|
/**
|
|
184
161
|
* Production h() function based on Preact by
|
|
185
162
|
* Jason Miller (@developit)
|
|
@@ -194,10 +171,9 @@ const exit = IS_NODE_ENV ? process.exit : IS_DENO_ENV ? Deno.exit : noop;
|
|
|
194
171
|
const h = (nodeName, vnodeData, ...children) => {
|
|
195
172
|
let child = null;
|
|
196
173
|
let key = null;
|
|
197
|
-
let slotName = null;
|
|
198
174
|
let simple = false;
|
|
199
175
|
let lastSimple = false;
|
|
200
|
-
|
|
176
|
+
const vNodeChildren = [];
|
|
201
177
|
const walk = (c) => {
|
|
202
178
|
for (let i = 0; i < c.length; i++) {
|
|
203
179
|
child = c[i];
|
|
@@ -223,12 +199,9 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
223
199
|
walk(children);
|
|
224
200
|
if (vnodeData) {
|
|
225
201
|
// normalize class / classname attributes
|
|
226
|
-
if (
|
|
202
|
+
if (vnodeData.key) {
|
|
227
203
|
key = vnodeData.key;
|
|
228
204
|
}
|
|
229
|
-
if ( vnodeData.name) {
|
|
230
|
-
slotName = vnodeData.name;
|
|
231
|
-
}
|
|
232
205
|
{
|
|
233
206
|
const classData = vnodeData.className || vnodeData.class;
|
|
234
207
|
if (classData) {
|
|
@@ -236,12 +209,12 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
236
209
|
typeof classData !== 'object'
|
|
237
210
|
? classData
|
|
238
211
|
: Object.keys(classData)
|
|
239
|
-
.filter(k => classData[k])
|
|
212
|
+
.filter((k) => classData[k])
|
|
240
213
|
.join(' ');
|
|
241
214
|
}
|
|
242
215
|
}
|
|
243
216
|
}
|
|
244
|
-
if (
|
|
217
|
+
if (typeof nodeName === 'function') {
|
|
245
218
|
// nodeName is a functional component
|
|
246
219
|
return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
247
220
|
}
|
|
@@ -253,9 +226,6 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
253
226
|
{
|
|
254
227
|
vnode.$key$ = key;
|
|
255
228
|
}
|
|
256
|
-
{
|
|
257
|
-
vnode.$name$ = slotName;
|
|
258
|
-
}
|
|
259
229
|
return vnode;
|
|
260
230
|
};
|
|
261
231
|
const newVNode = (tag, text) => {
|
|
@@ -272,19 +242,13 @@ const newVNode = (tag, text) => {
|
|
|
272
242
|
{
|
|
273
243
|
vnode.$key$ = null;
|
|
274
244
|
}
|
|
275
|
-
{
|
|
276
|
-
vnode.$name$ = null;
|
|
277
|
-
}
|
|
278
245
|
return vnode;
|
|
279
246
|
};
|
|
280
247
|
const Host = {};
|
|
281
248
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
282
249
|
const vdomFnUtils = {
|
|
283
250
|
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
284
|
-
map: (children, cb) => children
|
|
285
|
-
.map(convertToPublic)
|
|
286
|
-
.map(cb)
|
|
287
|
-
.map(convertToPrivate),
|
|
251
|
+
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
288
252
|
};
|
|
289
253
|
const convertToPublic = (node) => ({
|
|
290
254
|
vattrs: node.$attrs$,
|
|
@@ -303,7 +267,7 @@ const convertToPrivate = (node) => {
|
|
|
303
267
|
if (node.vname) {
|
|
304
268
|
vnodeData.name = node.vname;
|
|
305
269
|
}
|
|
306
|
-
return h(node.vtag, vnodeData, ...node.vchildren || []);
|
|
270
|
+
return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
|
307
271
|
}
|
|
308
272
|
const vnode = newVNode(node.vtag, node.vtext);
|
|
309
273
|
vnode.$attrs$ = node.vattrs;
|
|
@@ -324,19 +288,19 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
324
288
|
if (oldValue !== newValue) {
|
|
325
289
|
let isProp = isMemberInElement(elm, memberName);
|
|
326
290
|
let ln = memberName.toLowerCase();
|
|
327
|
-
if (
|
|
291
|
+
if (memberName === 'class') {
|
|
328
292
|
const classList = elm.classList;
|
|
329
293
|
const oldClasses = parseClassList(oldValue);
|
|
330
294
|
const newClasses = parseClassList(newValue);
|
|
331
|
-
classList.remove(...oldClasses.filter(c => c && !newClasses.includes(c)));
|
|
332
|
-
classList.add(...newClasses.filter(c => c && !oldClasses.includes(c)));
|
|
295
|
+
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
296
|
+
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
333
297
|
}
|
|
334
|
-
else if (
|
|
298
|
+
else if (memberName === 'style') {
|
|
335
299
|
// update style attribute, css properties and values
|
|
336
300
|
{
|
|
337
301
|
for (const prop in oldValue) {
|
|
338
302
|
if (!newValue || newValue[prop] == null) {
|
|
339
|
-
if (
|
|
303
|
+
if (prop.includes('-')) {
|
|
340
304
|
elm.style.removeProperty(prop);
|
|
341
305
|
}
|
|
342
306
|
else {
|
|
@@ -347,7 +311,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
347
311
|
}
|
|
348
312
|
for (const prop in newValue) {
|
|
349
313
|
if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
|
350
|
-
if (
|
|
314
|
+
if (prop.includes('-')) {
|
|
351
315
|
elm.style.setProperty(prop, newValue[prop]);
|
|
352
316
|
}
|
|
353
317
|
else {
|
|
@@ -356,15 +320,17 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
356
320
|
}
|
|
357
321
|
}
|
|
358
322
|
}
|
|
359
|
-
else if (
|
|
323
|
+
else if (memberName === 'key')
|
|
360
324
|
;
|
|
361
|
-
else if (
|
|
325
|
+
else if (memberName === 'ref') {
|
|
362
326
|
// minifier will clean this up
|
|
363
327
|
if (newValue) {
|
|
364
328
|
newValue(elm);
|
|
365
329
|
}
|
|
366
330
|
}
|
|
367
|
-
else if (
|
|
331
|
+
else if ((!isProp ) &&
|
|
332
|
+
memberName[0] === 'o' &&
|
|
333
|
+
memberName[1] === 'n') {
|
|
368
334
|
// Event Handlers
|
|
369
335
|
// so if the member name starts with "on" and the 3rd characters is
|
|
370
336
|
// a capital letter, and it's not already a member on the element,
|
|
@@ -407,11 +373,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
407
373
|
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
|
408
374
|
try {
|
|
409
375
|
if (!elm.tagName.includes('-')) {
|
|
410
|
-
|
|
376
|
+
const n = newValue == null ? '' : newValue;
|
|
411
377
|
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
|
|
412
378
|
if (memberName === 'list') {
|
|
413
379
|
isProp = false;
|
|
414
|
-
// tslint:disable-next-line: triple-equals
|
|
415
380
|
}
|
|
416
381
|
else if (oldValue == null || elm[memberName] != n) {
|
|
417
382
|
elm[memberName] = n;
|
|
@@ -439,7 +404,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
439
404
|
}
|
|
440
405
|
if (newValue == null || newValue === false) {
|
|
441
406
|
if (newValue !== false || elm.getAttribute(memberName) === '') {
|
|
442
|
-
if (
|
|
407
|
+
if (xlink) {
|
|
443
408
|
elm.removeAttributeNS(XLINK_NS, memberName);
|
|
444
409
|
}
|
|
445
410
|
else {
|
|
@@ -449,7 +414,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
449
414
|
}
|
|
450
415
|
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
451
416
|
newValue = newValue === true ? '' : newValue;
|
|
452
|
-
if (
|
|
417
|
+
if (xlink) {
|
|
453
418
|
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
454
419
|
}
|
|
455
420
|
else {
|
|
@@ -465,7 +430,9 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
465
430
|
// if the element passed in is a shadow root, which is a document fragment
|
|
466
431
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
467
432
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
468
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
433
|
+
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
434
|
+
? newVnode.$elm$.host
|
|
435
|
+
: newVnode.$elm$;
|
|
469
436
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
470
437
|
const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
|
|
471
438
|
{
|
|
@@ -483,49 +450,29 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
483
450
|
};
|
|
484
451
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
485
452
|
// tslint:disable-next-line: prefer-const
|
|
486
|
-
|
|
453
|
+
const newVNode = newParentVNode.$children$[childIndex];
|
|
487
454
|
let i = 0;
|
|
488
455
|
let elm;
|
|
489
456
|
let childNode;
|
|
490
|
-
|
|
491
|
-
if ( !useNativeShadowDom) {
|
|
492
|
-
// remember for later we need to check to relocate nodes
|
|
493
|
-
checkSlotRelocate = true;
|
|
494
|
-
if (newVNode.$tag$ === 'slot') {
|
|
495
|
-
if (scopeId) {
|
|
496
|
-
// scoped css needs to add its scoped id to the parent element
|
|
497
|
-
parentElm.classList.add(scopeId + '-s');
|
|
498
|
-
}
|
|
499
|
-
newVNode.$flags$ |= newVNode.$children$
|
|
500
|
-
? // slot element has fallback content
|
|
501
|
-
2 /* isSlotFallback */
|
|
502
|
-
: // slot element does not have fallback content
|
|
503
|
-
1 /* isSlotReference */;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
if ( newVNode.$text$ !== null) {
|
|
457
|
+
if (newVNode.$text$ !== null) {
|
|
507
458
|
// create text node
|
|
508
459
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
509
460
|
}
|
|
510
|
-
else if ( newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
511
|
-
// create a slot reference node
|
|
512
|
-
elm = newVNode.$elm$ = doc.createTextNode('');
|
|
513
|
-
}
|
|
514
461
|
else {
|
|
515
|
-
if (
|
|
462
|
+
if (!isSvgMode) {
|
|
516
463
|
isSvgMode = newVNode.$tag$ === 'svg';
|
|
517
464
|
}
|
|
518
465
|
// create element
|
|
519
|
-
elm = newVNode.$elm$ = (
|
|
466
|
+
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
|
|
520
467
|
);
|
|
521
|
-
if (
|
|
468
|
+
if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
|
|
522
469
|
isSvgMode = false;
|
|
523
470
|
}
|
|
524
471
|
// add css classes, attrs, props, listeners, etc.
|
|
525
472
|
{
|
|
526
473
|
updateElement(null, newVNode, isSvgMode);
|
|
527
474
|
}
|
|
528
|
-
if (
|
|
475
|
+
if (isDef(scopeId) && elm['s-si'] !== scopeId) {
|
|
529
476
|
// if there is a scopeId and this is the initial render
|
|
530
477
|
// then let's add the scopeId as a css class
|
|
531
478
|
elm.classList.add((elm['s-si'] = scopeId));
|
|
@@ -533,7 +480,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
533
480
|
if (newVNode.$children$) {
|
|
534
481
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
535
482
|
// create the node
|
|
536
|
-
childNode = createElm(oldParentVNode, newVNode, i
|
|
483
|
+
childNode = createElm(oldParentVNode, newVNode, i);
|
|
537
484
|
// return node could have been null
|
|
538
485
|
if (childNode) {
|
|
539
486
|
// append our new node
|
|
@@ -552,62 +499,20 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
552
499
|
}
|
|
553
500
|
}
|
|
554
501
|
}
|
|
555
|
-
{
|
|
556
|
-
elm['s-hn'] = hostTagName;
|
|
557
|
-
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
558
|
-
// remember the content reference comment
|
|
559
|
-
elm['s-sr'] = true;
|
|
560
|
-
// remember the content reference comment
|
|
561
|
-
elm['s-cr'] = contentRef;
|
|
562
|
-
// remember the slot name, or empty string for default slot
|
|
563
|
-
elm['s-sn'] = newVNode.$name$ || '';
|
|
564
|
-
// check if we've got an old vnode for this slot
|
|
565
|
-
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
566
|
-
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
567
|
-
// we've got an old slot vnode and the wrapper is being replaced
|
|
568
|
-
// so let's move the old slot content back to it's original location
|
|
569
|
-
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
502
|
return elm;
|
|
574
503
|
};
|
|
575
|
-
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
576
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
577
|
-
const oldSlotChildNodes = parentElm.childNodes;
|
|
578
|
-
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
579
|
-
const childNode = oldSlotChildNodes[i];
|
|
580
|
-
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
|
581
|
-
// // this child node in the old element is from another component
|
|
582
|
-
// // remove this node from the old slot's parent
|
|
583
|
-
// childNode.remove();
|
|
584
|
-
// and relocate it back to it's original location
|
|
585
|
-
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
586
|
-
// remove the old original location comment entirely
|
|
587
|
-
// later on the patch function will know what to do
|
|
588
|
-
// and move this to the correct spot in need be
|
|
589
|
-
childNode['s-ol'].remove();
|
|
590
|
-
childNode['s-ol'] = undefined;
|
|
591
|
-
checkSlotRelocate = true;
|
|
592
|
-
}
|
|
593
|
-
if (recursive) {
|
|
594
|
-
putBackInOriginalLocation(childNode, recursive);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
598
|
-
};
|
|
599
504
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
600
|
-
let containerElm = (
|
|
505
|
+
let containerElm = (parentElm);
|
|
601
506
|
let childNode;
|
|
602
|
-
if (
|
|
507
|
+
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
603
508
|
containerElm = containerElm.shadowRoot;
|
|
604
509
|
}
|
|
605
510
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
606
511
|
if (vnodes[startIdx]) {
|
|
607
|
-
childNode = createElm(null, parentVNode, startIdx
|
|
512
|
+
childNode = createElm(null, parentVNode, startIdx);
|
|
608
513
|
if (childNode) {
|
|
609
514
|
vnodes[startIdx].$elm$ = childNode;
|
|
610
|
-
containerElm.insertBefore(childNode,
|
|
515
|
+
containerElm.insertBefore(childNode, before);
|
|
611
516
|
}
|
|
612
517
|
}
|
|
613
518
|
}
|
|
@@ -617,20 +522,6 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
617
522
|
if ((vnode = vnodes[startIdx])) {
|
|
618
523
|
elm = vnode.$elm$;
|
|
619
524
|
callNodeRefs(vnode);
|
|
620
|
-
{
|
|
621
|
-
// we're removing this element
|
|
622
|
-
// so it's possible we need to show slot fallback content now
|
|
623
|
-
checkSlotFallbackVisibility = true;
|
|
624
|
-
if (elm['s-ol']) {
|
|
625
|
-
// remove the original location comment
|
|
626
|
-
elm['s-ol'].remove();
|
|
627
|
-
}
|
|
628
|
-
else {
|
|
629
|
-
// it's possible that child nodes of the node
|
|
630
|
-
// that's being removed are slot nodes
|
|
631
|
-
putBackInOriginalLocation(elm, true);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
525
|
// remove the vnode's element from the dom
|
|
635
526
|
elm.remove();
|
|
636
527
|
}
|
|
@@ -674,20 +565,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
674
565
|
newEndVnode = newCh[--newEndIdx];
|
|
675
566
|
}
|
|
676
567
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
677
|
-
// Vnode moved right
|
|
678
|
-
if ( (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
679
|
-
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
680
|
-
}
|
|
681
568
|
patch(oldStartVnode, newEndVnode);
|
|
682
569
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
683
570
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
684
571
|
newEndVnode = newCh[--newEndIdx];
|
|
685
572
|
}
|
|
686
573
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
687
|
-
// Vnode moved left
|
|
688
|
-
if ( (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
689
|
-
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
690
|
-
}
|
|
691
574
|
patch(oldEndVnode, newStartVnode);
|
|
692
575
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
693
576
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
@@ -704,10 +587,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
704
587
|
}
|
|
705
588
|
}
|
|
706
589
|
}
|
|
707
|
-
if (
|
|
590
|
+
if (idxInOld >= 0) {
|
|
708
591
|
elmToMove = oldCh[idxInOld];
|
|
709
592
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
710
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld
|
|
593
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
|
|
711
594
|
}
|
|
712
595
|
else {
|
|
713
596
|
patch(elmToMove, newStartVnode);
|
|
@@ -718,12 +601,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
718
601
|
}
|
|
719
602
|
else {
|
|
720
603
|
// new element
|
|
721
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx
|
|
604
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
722
605
|
newStartVnode = newCh[++newStartIdx];
|
|
723
606
|
}
|
|
724
607
|
if (node) {
|
|
725
608
|
{
|
|
726
|
-
|
|
609
|
+
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
727
610
|
}
|
|
728
611
|
}
|
|
729
612
|
}
|
|
@@ -731,7 +614,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
731
614
|
if (oldStartIdx > oldEndIdx) {
|
|
732
615
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
733
616
|
}
|
|
734
|
-
else if (
|
|
617
|
+
else if (newStartIdx > newEndIdx) {
|
|
735
618
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
736
619
|
}
|
|
737
620
|
};
|
|
@@ -739,31 +622,19 @@ const isSameVnode = (vnode1, vnode2) => {
|
|
|
739
622
|
// compare if two vnode to see if they're "technically" the same
|
|
740
623
|
// need to have the same element tag, and same key to be the same
|
|
741
624
|
if (vnode1.$tag$ === vnode2.$tag$) {
|
|
742
|
-
if ( vnode1.$tag$ === 'slot') {
|
|
743
|
-
return vnode1.$name$ === vnode2.$name$;
|
|
744
|
-
}
|
|
745
625
|
{
|
|
746
626
|
return vnode1.$key$ === vnode2.$key$;
|
|
747
627
|
}
|
|
748
628
|
}
|
|
749
629
|
return false;
|
|
750
630
|
};
|
|
751
|
-
const referenceNode = (node) => {
|
|
752
|
-
// this node was relocated to a new location in the dom
|
|
753
|
-
// because of some other component's slot
|
|
754
|
-
// but we still have an html comment in place of where
|
|
755
|
-
// it's original location was according to it's original vdom
|
|
756
|
-
return (node && node['s-ol']) || node;
|
|
757
|
-
};
|
|
758
|
-
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
759
631
|
const patch = (oldVNode, newVNode) => {
|
|
760
632
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
761
633
|
const oldChildren = oldVNode.$children$;
|
|
762
634
|
const newChildren = newVNode.$children$;
|
|
763
635
|
const tag = newVNode.$tag$;
|
|
764
636
|
const text = newVNode.$text$;
|
|
765
|
-
|
|
766
|
-
if ( text === null) {
|
|
637
|
+
if (text === null) {
|
|
767
638
|
{
|
|
768
639
|
// test if we're rendering an svg element, or still rendering nodes inside of one
|
|
769
640
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
@@ -771,7 +642,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
771
642
|
}
|
|
772
643
|
// element node
|
|
773
644
|
{
|
|
774
|
-
if (
|
|
645
|
+
if (tag === 'slot')
|
|
775
646
|
;
|
|
776
647
|
else {
|
|
777
648
|
// either this is the first render of an element OR it's an update
|
|
@@ -780,170 +651,33 @@ const patch = (oldVNode, newVNode) => {
|
|
|
780
651
|
updateElement(oldVNode, newVNode, isSvgMode);
|
|
781
652
|
}
|
|
782
653
|
}
|
|
783
|
-
if (
|
|
654
|
+
if (oldChildren !== null && newChildren !== null) {
|
|
784
655
|
// looks like there's child vnodes for both the old and new vnodes
|
|
785
656
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
786
657
|
}
|
|
787
658
|
else if (newChildren !== null) {
|
|
788
659
|
// no old child vnodes, but there are new child vnodes to add
|
|
789
|
-
if (
|
|
660
|
+
if (oldVNode.$text$ !== null) {
|
|
790
661
|
// the old vnode was text, so be sure to clear it out
|
|
791
662
|
elm.textContent = '';
|
|
792
663
|
}
|
|
793
664
|
// add the new vnode children
|
|
794
665
|
addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
|
|
795
666
|
}
|
|
796
|
-
else if (
|
|
667
|
+
else if (oldChildren !== null) {
|
|
797
668
|
// no new child vnodes, but there are old child vnodes to remove
|
|
798
669
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
799
670
|
}
|
|
800
|
-
if (
|
|
671
|
+
if (isSvgMode && tag === 'svg') {
|
|
801
672
|
isSvgMode = false;
|
|
802
673
|
}
|
|
803
674
|
}
|
|
804
|
-
else if (
|
|
805
|
-
// this element has slotted content
|
|
806
|
-
defaultHolder.parentNode.textContent = text;
|
|
807
|
-
}
|
|
808
|
-
else if ( oldVNode.$text$ !== text) {
|
|
675
|
+
else if (oldVNode.$text$ !== text) {
|
|
809
676
|
// update the text content for the text only vnode
|
|
810
677
|
// and also only if the text is different than before
|
|
811
678
|
elm.data = text;
|
|
812
679
|
}
|
|
813
680
|
};
|
|
814
|
-
const updateFallbackSlotVisibility = (elm) => {
|
|
815
|
-
// tslint:disable-next-line: prefer-const
|
|
816
|
-
let childNodes = elm.childNodes;
|
|
817
|
-
let childNode;
|
|
818
|
-
let i;
|
|
819
|
-
let ilen;
|
|
820
|
-
let j;
|
|
821
|
-
let slotNameAttr;
|
|
822
|
-
let nodeType;
|
|
823
|
-
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
824
|
-
childNode = childNodes[i];
|
|
825
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
826
|
-
if (childNode['s-sr']) {
|
|
827
|
-
// this is a slot fallback node
|
|
828
|
-
// get the slot name for this slot reference node
|
|
829
|
-
slotNameAttr = childNode['s-sn'];
|
|
830
|
-
// by default always show a fallback slot node
|
|
831
|
-
// then hide it if there are other slots in the light dom
|
|
832
|
-
childNode.hidden = false;
|
|
833
|
-
for (j = 0; j < ilen; j++) {
|
|
834
|
-
if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
|
|
835
|
-
// this sibling node is from a different component
|
|
836
|
-
nodeType = childNodes[j].nodeType;
|
|
837
|
-
if (slotNameAttr !== '') {
|
|
838
|
-
// this is a named fallback slot node
|
|
839
|
-
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
840
|
-
childNode.hidden = true;
|
|
841
|
-
break;
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
else {
|
|
845
|
-
// this is a default fallback slot node
|
|
846
|
-
// any element or text node (with content)
|
|
847
|
-
// should hide the default fallback slot node
|
|
848
|
-
if (nodeType === 1 /* ElementNode */ || (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
849
|
-
childNode.hidden = true;
|
|
850
|
-
break;
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
// keep drilling down
|
|
857
|
-
updateFallbackSlotVisibility(childNode);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
const relocateNodes = [];
|
|
862
|
-
const relocateSlotContent = (elm) => {
|
|
863
|
-
// tslint:disable-next-line: prefer-const
|
|
864
|
-
let childNode;
|
|
865
|
-
let node;
|
|
866
|
-
let hostContentNodes;
|
|
867
|
-
let slotNameAttr;
|
|
868
|
-
let relocateNodeData;
|
|
869
|
-
let j;
|
|
870
|
-
let i = 0;
|
|
871
|
-
let childNodes = elm.childNodes;
|
|
872
|
-
let ilen = childNodes.length;
|
|
873
|
-
for (; i < ilen; i++) {
|
|
874
|
-
childNode = childNodes[i];
|
|
875
|
-
if (childNode['s-sr'] && (node = childNode['s-cr'])) {
|
|
876
|
-
// first got the content reference comment node
|
|
877
|
-
// then we got it's parent, which is where all the host content is in now
|
|
878
|
-
hostContentNodes = node.parentNode.childNodes;
|
|
879
|
-
slotNameAttr = childNode['s-sn'];
|
|
880
|
-
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
881
|
-
node = hostContentNodes[j];
|
|
882
|
-
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
883
|
-
// let's do some relocating to its new home
|
|
884
|
-
// but never relocate a content reference node
|
|
885
|
-
// that is suppose to always represent the original content location
|
|
886
|
-
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
887
|
-
// it's possible we've already decided to relocate this node
|
|
888
|
-
relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
|
|
889
|
-
// made some changes to slots
|
|
890
|
-
// let's make sure we also double check
|
|
891
|
-
// fallbacks are correctly hidden or shown
|
|
892
|
-
checkSlotFallbackVisibility = true;
|
|
893
|
-
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
894
|
-
if (relocateNodeData) {
|
|
895
|
-
// previously we never found a slot home for this node
|
|
896
|
-
// but turns out we did, so let's remember it now
|
|
897
|
-
relocateNodeData.$slotRefNode$ = childNode;
|
|
898
|
-
}
|
|
899
|
-
else {
|
|
900
|
-
// add to our list of nodes to relocate
|
|
901
|
-
relocateNodes.push({
|
|
902
|
-
$slotRefNode$: childNode,
|
|
903
|
-
$nodeToRelocate$: node,
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
|
-
if (node['s-sr']) {
|
|
907
|
-
relocateNodes.map(relocateNode => {
|
|
908
|
-
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
909
|
-
relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
|
|
910
|
-
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
911
|
-
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
else if (!relocateNodes.some(r => r.$nodeToRelocate$ === node)) {
|
|
918
|
-
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
919
|
-
// if we never find a home for this element then we'll need to hide it
|
|
920
|
-
relocateNodes.push({
|
|
921
|
-
$nodeToRelocate$: node,
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
928
|
-
relocateSlotContent(childNode);
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
};
|
|
932
|
-
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
933
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
934
|
-
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
935
|
-
return true;
|
|
936
|
-
}
|
|
937
|
-
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
938
|
-
return true;
|
|
939
|
-
}
|
|
940
|
-
return false;
|
|
941
|
-
}
|
|
942
|
-
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
943
|
-
return true;
|
|
944
|
-
}
|
|
945
|
-
return slotNameAttr === '';
|
|
946
|
-
};
|
|
947
681
|
const callNodeRefs = (vNode) => {
|
|
948
682
|
{
|
|
949
683
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
@@ -956,101 +690,21 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
956
690
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
957
691
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
958
692
|
hostTagName = hostElm.tagName;
|
|
959
|
-
if (
|
|
693
|
+
if (cmpMeta.$attrsToReflect$) {
|
|
960
694
|
rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
|
961
695
|
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
962
696
|
}
|
|
963
697
|
rootVnode.$tag$ = null;
|
|
964
698
|
rootVnode.$flags$ |= 4 /* isHost */;
|
|
965
699
|
hostRef.$vnode$ = rootVnode;
|
|
966
|
-
rootVnode.$elm$ = oldVNode.$elm$ = (
|
|
700
|
+
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
967
701
|
{
|
|
968
702
|
scopeId = hostElm['s-sc'];
|
|
969
703
|
}
|
|
970
|
-
{
|
|
971
|
-
contentRef = hostElm['s-cr'];
|
|
972
|
-
useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
973
|
-
// always reset
|
|
974
|
-
checkSlotFallbackVisibility = false;
|
|
975
|
-
}
|
|
976
704
|
// synchronous patch
|
|
977
705
|
patch(oldVNode, rootVnode);
|
|
978
|
-
{
|
|
979
|
-
// while we're moving nodes around existing nodes, temporarily disable
|
|
980
|
-
// the disconnectCallback from working
|
|
981
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
982
|
-
if (checkSlotRelocate) {
|
|
983
|
-
relocateSlotContent(rootVnode.$elm$);
|
|
984
|
-
let relocateData;
|
|
985
|
-
let nodeToRelocate;
|
|
986
|
-
let orgLocationNode;
|
|
987
|
-
let parentNodeRef;
|
|
988
|
-
let insertBeforeNode;
|
|
989
|
-
let refNode;
|
|
990
|
-
let i = 0;
|
|
991
|
-
for (; i < relocateNodes.length; i++) {
|
|
992
|
-
relocateData = relocateNodes[i];
|
|
993
|
-
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
994
|
-
if (!nodeToRelocate['s-ol']) {
|
|
995
|
-
// add a reference node marking this node's original location
|
|
996
|
-
// keep a reference to this node for later lookups
|
|
997
|
-
orgLocationNode = doc.createTextNode('');
|
|
998
|
-
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
999
|
-
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
for (i = 0; i < relocateNodes.length; i++) {
|
|
1003
|
-
relocateData = relocateNodes[i];
|
|
1004
|
-
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1005
|
-
if (relocateData.$slotRefNode$) {
|
|
1006
|
-
// by default we're just going to insert it directly
|
|
1007
|
-
// after the slot reference node
|
|
1008
|
-
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
1009
|
-
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
1010
|
-
orgLocationNode = nodeToRelocate['s-ol'];
|
|
1011
|
-
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
1012
|
-
refNode = orgLocationNode['s-nr'];
|
|
1013
|
-
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
1014
|
-
refNode = refNode.nextSibling;
|
|
1015
|
-
if (!refNode || !refNode['s-nr']) {
|
|
1016
|
-
insertBeforeNode = refNode;
|
|
1017
|
-
break;
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) || nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
1022
|
-
// we've checked that it's worth while to relocate
|
|
1023
|
-
// since that the node to relocate
|
|
1024
|
-
// has a different next sibling or parent relocated
|
|
1025
|
-
if (nodeToRelocate !== insertBeforeNode) {
|
|
1026
|
-
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
1027
|
-
// probably a component in the index.html that doesn't have it's hostname set
|
|
1028
|
-
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
1029
|
-
}
|
|
1030
|
-
// add it back to the dom but in its new home
|
|
1031
|
-
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
else {
|
|
1036
|
-
// this node doesn't have a slot home to go to, so let's hide it
|
|
1037
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1038
|
-
nodeToRelocate.hidden = true;
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
if (checkSlotFallbackVisibility) {
|
|
1044
|
-
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
1045
|
-
}
|
|
1046
|
-
// done moving nodes around
|
|
1047
|
-
// allow the disconnect callback to work again
|
|
1048
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
1049
|
-
// always reset
|
|
1050
|
-
relocateNodes.length = 0;
|
|
1051
|
-
}
|
|
1052
706
|
};
|
|
1053
|
-
const getElement = (ref) => (
|
|
707
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
1054
708
|
const createEvent = (ref, name, flags) => {
|
|
1055
709
|
const elm = getElement(ref);
|
|
1056
710
|
return {
|
|
@@ -1064,34 +718,41 @@ const createEvent = (ref, name, flags) => {
|
|
|
1064
718
|
},
|
|
1065
719
|
};
|
|
1066
720
|
};
|
|
721
|
+
/**
|
|
722
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
723
|
+
* @param elm the target of the Event
|
|
724
|
+
* @param name the name to give the custom Event
|
|
725
|
+
* @param opts options for configuring a custom Event
|
|
726
|
+
* @returns the custom Event
|
|
727
|
+
*/
|
|
1067
728
|
const emitEvent = (elm, name, opts) => {
|
|
1068
729
|
const ev = plt.ce(name, opts);
|
|
1069
730
|
elm.dispatchEvent(ev);
|
|
1070
731
|
return ev;
|
|
1071
732
|
};
|
|
1072
733
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
1073
|
-
if (
|
|
1074
|
-
ancestorComponent['s-p'].push(new Promise(r => (hostRef.$onRenderResolve$ = r)));
|
|
734
|
+
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
735
|
+
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
1075
736
|
}
|
|
1076
737
|
};
|
|
1077
738
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
1078
739
|
{
|
|
1079
740
|
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1080
741
|
}
|
|
1081
|
-
if (
|
|
742
|
+
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
1082
743
|
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1083
744
|
return;
|
|
1084
745
|
}
|
|
1085
746
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
1086
|
-
// there is no
|
|
747
|
+
// there is no ancestor component or the ancestor component
|
|
1087
748
|
// has already fired off its lifecycle update then
|
|
1088
749
|
// fire off the initial update
|
|
1089
750
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
1090
|
-
return
|
|
751
|
+
return writeTask(dispatch) ;
|
|
1091
752
|
};
|
|
1092
753
|
const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
1093
754
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
1094
|
-
const instance =
|
|
755
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1095
756
|
let promise;
|
|
1096
757
|
if (isInitialLoad) {
|
|
1097
758
|
{
|
|
@@ -1108,32 +769,24 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1108
769
|
endSchedule();
|
|
1109
770
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
1110
771
|
};
|
|
1111
|
-
const updateComponent = (hostRef, instance, isInitialLoad) => {
|
|
772
|
+
const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
1112
773
|
// updateComponent
|
|
1113
774
|
const elm = hostRef.$hostElement$;
|
|
1114
775
|
const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
|
1115
776
|
const rc = elm['s-rc'];
|
|
1116
|
-
if (
|
|
777
|
+
if (isInitialLoad) {
|
|
1117
778
|
// DOM WRITE!
|
|
1118
779
|
attachStyles(hostRef);
|
|
1119
780
|
}
|
|
1120
781
|
const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
|
|
1121
782
|
{
|
|
1122
|
-
|
|
1123
|
-
// looks like we've got child nodes to render into this host element
|
|
1124
|
-
// or we need to update the css class/attrs on the host element
|
|
1125
|
-
// DOM WRITE!
|
|
1126
|
-
renderVdom(hostRef, callRender(hostRef, instance));
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
if ( plt.$cssShim$) {
|
|
1130
|
-
plt.$cssShim$.updateHost(elm);
|
|
783
|
+
callRender(hostRef, instance);
|
|
1131
784
|
}
|
|
1132
|
-
if (
|
|
785
|
+
if (rc) {
|
|
1133
786
|
// ok, so turns out there are some child host elements
|
|
1134
787
|
// waiting on this parent element to load
|
|
1135
788
|
// let's fire off all update callbacks waiting
|
|
1136
|
-
rc.map(cb => cb());
|
|
789
|
+
rc.map((cb) => cb());
|
|
1137
790
|
elm['s-rc'] = undefined;
|
|
1138
791
|
}
|
|
1139
792
|
endRender();
|
|
@@ -1151,26 +804,36 @@ const updateComponent = (hostRef, instance, isInitialLoad) => {
|
|
|
1151
804
|
}
|
|
1152
805
|
}
|
|
1153
806
|
};
|
|
1154
|
-
const callRender = (hostRef, instance) => {
|
|
807
|
+
const callRender = (hostRef, instance, elm) => {
|
|
1155
808
|
try {
|
|
1156
|
-
instance =
|
|
809
|
+
instance = instance.render() ;
|
|
1157
810
|
{
|
|
1158
811
|
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1159
812
|
}
|
|
1160
813
|
{
|
|
1161
814
|
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1162
815
|
}
|
|
816
|
+
{
|
|
817
|
+
{
|
|
818
|
+
// looks like we've got child nodes to render into this host element
|
|
819
|
+
// or we need to update the css class/attrs on the host element
|
|
820
|
+
// DOM WRITE!
|
|
821
|
+
{
|
|
822
|
+
renderVdom(hostRef, instance);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
1163
826
|
}
|
|
1164
827
|
catch (e) {
|
|
1165
|
-
consoleError(e);
|
|
828
|
+
consoleError(e, hostRef.$hostElement$);
|
|
1166
829
|
}
|
|
1167
|
-
return
|
|
830
|
+
return null;
|
|
1168
831
|
};
|
|
1169
832
|
const postUpdateComponent = (hostRef) => {
|
|
1170
833
|
const tagName = hostRef.$cmpMeta$.$tagName$;
|
|
1171
834
|
const elm = hostRef.$hostElement$;
|
|
1172
835
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
1173
|
-
const instance =
|
|
836
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1174
837
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1175
838
|
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
1176
839
|
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
@@ -1211,26 +874,12 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1211
874
|
// ( •_•)>⌐■-■
|
|
1212
875
|
// (⌐■_■)
|
|
1213
876
|
};
|
|
1214
|
-
const forceUpdate = (ref) => {
|
|
1215
|
-
{
|
|
1216
|
-
const hostRef = getHostRef(ref);
|
|
1217
|
-
const isConnected = hostRef.$hostElement$.isConnected;
|
|
1218
|
-
if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1219
|
-
scheduleUpdate(hostRef, false);
|
|
1220
|
-
}
|
|
1221
|
-
// Returns "true" when the forced update was successfully scheduled
|
|
1222
|
-
return isConnected;
|
|
1223
|
-
}
|
|
1224
|
-
};
|
|
1225
877
|
const appDidLoad = (who) => {
|
|
1226
878
|
// on appload
|
|
1227
879
|
// we have finish the first big initial render
|
|
1228
880
|
{
|
|
1229
881
|
addHydratedFlag(doc.documentElement);
|
|
1230
882
|
}
|
|
1231
|
-
{
|
|
1232
|
-
plt.$flags$ |= 2 /* appLoaded */;
|
|
1233
|
-
}
|
|
1234
883
|
nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
|
1235
884
|
};
|
|
1236
885
|
const safeCall = (instance, method, arg) => {
|
|
@@ -1247,20 +896,44 @@ const safeCall = (instance, method, arg) => {
|
|
|
1247
896
|
const then = (promise, thenFn) => {
|
|
1248
897
|
return promise && promise.then ? promise.then(thenFn) : thenFn();
|
|
1249
898
|
};
|
|
1250
|
-
const addHydratedFlag = (elm) =>
|
|
899
|
+
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
900
|
+
;
|
|
901
|
+
/**
|
|
902
|
+
* Parse a new property value for a given property type.
|
|
903
|
+
*
|
|
904
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
905
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
906
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
907
|
+
* 2. the type stored from `propType`.
|
|
908
|
+
*
|
|
909
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
910
|
+
*
|
|
911
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
912
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
913
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
914
|
+
* ```tsx
|
|
915
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
916
|
+
* ```
|
|
917
|
+
*
|
|
918
|
+
* HTML prop values on the other hand, will always a string
|
|
919
|
+
*
|
|
920
|
+
* @param propValue the new value to coerce to some type
|
|
921
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
922
|
+
* @returns the parsed/coerced value
|
|
923
|
+
*/
|
|
1251
924
|
const parsePropertyValue = (propValue, propType) => {
|
|
1252
925
|
// ensure this value is of the correct prop type
|
|
1253
926
|
if (propValue != null && !isComplexType(propValue)) {
|
|
1254
|
-
if (
|
|
927
|
+
if (propType & 4 /* Boolean */) {
|
|
1255
928
|
// per the HTML spec, any string value means it is a boolean true value
|
|
1256
929
|
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1257
930
|
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1258
931
|
}
|
|
1259
|
-
if (
|
|
932
|
+
if (propType & 2 /* Number */) {
|
|
1260
933
|
// force it to be a number
|
|
1261
934
|
return parseFloat(propValue);
|
|
1262
935
|
}
|
|
1263
|
-
if (
|
|
936
|
+
if (propType & 1 /* String */) {
|
|
1264
937
|
// could have been passed as a number or boolean
|
|
1265
938
|
// but we still want it as a string
|
|
1266
939
|
return String(propValue);
|
|
@@ -1276,32 +949,36 @@ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propNam
|
|
|
1276
949
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
1277
950
|
// check our new property value against our internal value
|
|
1278
951
|
const hostRef = getHostRef(ref);
|
|
952
|
+
const elm = hostRef.$hostElement$ ;
|
|
1279
953
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
1280
954
|
const flags = hostRef.$flags$;
|
|
1281
|
-
const instance =
|
|
955
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1282
956
|
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
1283
|
-
|
|
957
|
+
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
958
|
+
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
959
|
+
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
960
|
+
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1284
961
|
// gadzooks! the property's value has changed!!
|
|
1285
962
|
// set our new value!
|
|
1286
963
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1287
|
-
if (
|
|
964
|
+
if (instance) {
|
|
1288
965
|
// get an array of method names of watch functions to call
|
|
1289
|
-
if (
|
|
966
|
+
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1290
967
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1291
968
|
if (watchMethods) {
|
|
1292
969
|
// this instance is watching for when this property changed
|
|
1293
|
-
watchMethods.map(watchMethodName => {
|
|
970
|
+
watchMethods.map((watchMethodName) => {
|
|
1294
971
|
try {
|
|
1295
972
|
// fire off each of the watch methods that are watching this property
|
|
1296
973
|
instance[watchMethodName](newVal, oldVal, propName);
|
|
1297
974
|
}
|
|
1298
975
|
catch (e) {
|
|
1299
|
-
consoleError(e);
|
|
976
|
+
consoleError(e, elm);
|
|
1300
977
|
}
|
|
1301
978
|
});
|
|
1302
979
|
}
|
|
1303
980
|
}
|
|
1304
|
-
if (
|
|
981
|
+
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1305
982
|
// looks like this value actually changed, so we've got work to do!
|
|
1306
983
|
// but only if we've already rendered, otherwise just chill out
|
|
1307
984
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1312,15 +989,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1312
989
|
}
|
|
1313
990
|
};
|
|
1314
991
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1315
|
-
if (
|
|
1316
|
-
if (
|
|
992
|
+
if (cmpMeta.$members$) {
|
|
993
|
+
if (Cstr.watchers) {
|
|
1317
994
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1318
995
|
}
|
|
1319
996
|
// It's better to have a const than two Object.entries()
|
|
1320
997
|
const members = Object.entries(cmpMeta.$members$);
|
|
1321
998
|
const prototype = Cstr.prototype;
|
|
1322
999
|
members.map(([memberName, [memberFlags]]) => {
|
|
1323
|
-
if (
|
|
1000
|
+
if ((memberFlags & 31 /* Prop */ ||
|
|
1001
|
+
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1324
1002
|
// proxyComponent - prop
|
|
1325
1003
|
Object.defineProperty(prototype, memberName, {
|
|
1326
1004
|
get() {
|
|
@@ -1336,11 +1014,56 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1336
1014
|
});
|
|
1337
1015
|
}
|
|
1338
1016
|
});
|
|
1339
|
-
if (
|
|
1017
|
+
if ((flags & 1 /* isElementConstructor */)) {
|
|
1340
1018
|
const attrNameToPropName = new Map();
|
|
1341
1019
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1342
1020
|
plt.jmp(() => {
|
|
1343
1021
|
const propName = attrNameToPropName.get(attrName);
|
|
1022
|
+
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
1023
|
+
// in the case where an attribute was set inline.
|
|
1024
|
+
// ```html
|
|
1025
|
+
// <my-component some-attribute="some-value"></my-component>
|
|
1026
|
+
// ```
|
|
1027
|
+
//
|
|
1028
|
+
// There is an edge case where a developer sets the attribute inline on a custom element and then
|
|
1029
|
+
// programmatically changes it before it has been upgraded as shown below:
|
|
1030
|
+
//
|
|
1031
|
+
// ```html
|
|
1032
|
+
// <!-- this component has _not_ been upgraded yet -->
|
|
1033
|
+
// <my-component id="test" some-attribute="some-value"></my-component>
|
|
1034
|
+
// <script>
|
|
1035
|
+
// // grab non-upgraded component
|
|
1036
|
+
// el = document.querySelector("#test");
|
|
1037
|
+
// el.someAttribute = "another-value";
|
|
1038
|
+
// // upgrade component
|
|
1039
|
+
// customElements.define('my-component', MyComponent);
|
|
1040
|
+
// </script>
|
|
1041
|
+
// ```
|
|
1042
|
+
// In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
|
|
1043
|
+
// will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
|
|
1044
|
+
// to the value that was set inline i.e. "some-value" from above example. When
|
|
1045
|
+
// the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
|
|
1046
|
+
//
|
|
1047
|
+
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
|
|
1048
|
+
// by connectedCallback as this attributeChangedCallback will not fire.
|
|
1049
|
+
//
|
|
1050
|
+
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1051
|
+
//
|
|
1052
|
+
// TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
|
|
1053
|
+
// properties here given that this goes against best practices outlined here
|
|
1054
|
+
// https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
|
|
1055
|
+
if (this.hasOwnProperty(propName)) {
|
|
1056
|
+
newValue = this[propName];
|
|
1057
|
+
delete this[propName];
|
|
1058
|
+
}
|
|
1059
|
+
else if (prototype.hasOwnProperty(propName) &&
|
|
1060
|
+
typeof this[propName] === 'number' &&
|
|
1061
|
+
this[propName] == newValue) {
|
|
1062
|
+
// if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
|
|
1063
|
+
// APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
|
|
1064
|
+
// `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1344
1067
|
this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
|
1345
1068
|
});
|
|
1346
1069
|
};
|
|
@@ -1351,7 +1074,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1351
1074
|
.map(([propName, m]) => {
|
|
1352
1075
|
const attrName = m[1] || propName;
|
|
1353
1076
|
attrNameToPropName.set(attrName, propName);
|
|
1354
|
-
if (
|
|
1077
|
+
if (m[0] & 512 /* ReflectAttr */) {
|
|
1355
1078
|
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1356
1079
|
}
|
|
1357
1080
|
return attrName;
|
|
@@ -1362,7 +1085,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1362
1085
|
};
|
|
1363
1086
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1364
1087
|
// initializeComponent
|
|
1365
|
-
if (
|
|
1088
|
+
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1366
1089
|
{
|
|
1367
1090
|
// we haven't initialized this element yet
|
|
1368
1091
|
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
@@ -1376,8 +1099,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1376
1099
|
Cstr = await Cstr;
|
|
1377
1100
|
endLoad();
|
|
1378
1101
|
}
|
|
1379
|
-
if (
|
|
1380
|
-
// we'
|
|
1102
|
+
if (!Cstr.isProxied) {
|
|
1103
|
+
// we've never proxied this Constructor before
|
|
1381
1104
|
// let's add the getters/setters to its prototype before
|
|
1382
1105
|
// the first time we create an instance of the implementation
|
|
1383
1106
|
{
|
|
@@ -1411,15 +1134,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1411
1134
|
}
|
|
1412
1135
|
endNewInstance();
|
|
1413
1136
|
}
|
|
1414
|
-
if (
|
|
1137
|
+
if (Cstr.style) {
|
|
1415
1138
|
// this component has styles but we haven't registered them yet
|
|
1416
1139
|
let style = Cstr.style;
|
|
1417
1140
|
const scopeId = getScopeId(cmpMeta);
|
|
1418
1141
|
if (!styles.has(scopeId)) {
|
|
1419
1142
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1420
|
-
if ( cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
|
|
1421
|
-
style = await import('./shadow-css-95922619.js').then(m => m.scopeCss(style, scopeId, false));
|
|
1422
|
-
}
|
|
1423
1143
|
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1424
1144
|
endRegisterStyles();
|
|
1425
1145
|
}
|
|
@@ -1428,8 +1148,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1428
1148
|
// we've successfully created a lazy instance
|
|
1429
1149
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1430
1150
|
const schedule = () => scheduleUpdate(hostRef, true);
|
|
1431
|
-
if (
|
|
1432
|
-
// this is the
|
|
1151
|
+
if (ancestorComponent && ancestorComponent['s-rc']) {
|
|
1152
|
+
// this is the initial load and this component it has an ancestor component
|
|
1433
1153
|
// but the ancestor component has NOT fired its will update lifecycle yet
|
|
1434
1154
|
// so let's just cool our jets and wait for the ancestor to continue first
|
|
1435
1155
|
// this will get fired off when the ancestor component
|
|
@@ -1449,15 +1169,6 @@ const connectedCallback = (elm) => {
|
|
|
1449
1169
|
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1450
1170
|
// first time this component has connected
|
|
1451
1171
|
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1452
|
-
{
|
|
1453
|
-
// initUpdate
|
|
1454
|
-
// if the slot polyfill is required we'll need to put some nodes
|
|
1455
|
-
// in here to act as original content anchors as we move nodes around
|
|
1456
|
-
// host element has been connected to the DOM
|
|
1457
|
-
if ( ( cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1458
|
-
setContentReference(elm);
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
1172
|
{
|
|
1462
1173
|
// find the first ancestor component (if there is one) and register
|
|
1463
1174
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1465,8 +1176,7 @@ const connectedCallback = (elm) => {
|
|
|
1465
1176
|
while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
|
1466
1177
|
// climb up the ancestors looking for the first
|
|
1467
1178
|
// component that hasn't finished its lifecycle update yet
|
|
1468
|
-
if (
|
|
1469
|
-
ancestorComponent['s-p']) {
|
|
1179
|
+
if (ancestorComponent['s-p']) {
|
|
1470
1180
|
// we found this components first ancestor component
|
|
1471
1181
|
// keep a reference to this component's ancestor component
|
|
1472
1182
|
attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
|
|
@@ -1476,7 +1186,7 @@ const connectedCallback = (elm) => {
|
|
|
1476
1186
|
}
|
|
1477
1187
|
// Lazy properties
|
|
1478
1188
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1479
|
-
if (
|
|
1189
|
+
if (cmpMeta.$members$) {
|
|
1480
1190
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1481
1191
|
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1482
1192
|
const value = elm[memberName];
|
|
@@ -1502,30 +1212,15 @@ const connectedCallback = (elm) => {
|
|
|
1502
1212
|
endConnected();
|
|
1503
1213
|
}
|
|
1504
1214
|
};
|
|
1505
|
-
const setContentReference = (elm) => {
|
|
1506
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
1507
|
-
// or this browser doesn't support native shadow dom
|
|
1508
|
-
// and this host element was NOT created with SSR
|
|
1509
|
-
// let's pick out the inner content for slot projection
|
|
1510
|
-
// create a node to represent where the original
|
|
1511
|
-
// content was first placed, which is useful later on
|
|
1512
|
-
const contentRefElm = (elm['s-cr'] = doc.createComment( ''));
|
|
1513
|
-
contentRefElm['s-cn'] = true;
|
|
1514
|
-
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1515
|
-
};
|
|
1516
1215
|
const disconnectedCallback = (elm) => {
|
|
1517
1216
|
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1518
1217
|
const hostRef = getHostRef(elm);
|
|
1519
1218
|
{
|
|
1520
1219
|
if (hostRef.$rmListeners$) {
|
|
1521
|
-
hostRef.$rmListeners$.map(rmListener => rmListener());
|
|
1220
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
1522
1221
|
hostRef.$rmListeners$ = undefined;
|
|
1523
1222
|
}
|
|
1524
1223
|
}
|
|
1525
|
-
// clear CSS var-shim tracking
|
|
1526
|
-
if ( plt.$cssShim$) {
|
|
1527
|
-
plt.$cssShim$.removeHost(elm);
|
|
1528
|
-
}
|
|
1529
1224
|
}
|
|
1530
1225
|
};
|
|
1531
1226
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
@@ -1541,85 +1236,73 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1541
1236
|
let isBootstrapping = true;
|
|
1542
1237
|
Object.assign(plt, options);
|
|
1543
1238
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1544
|
-
{
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
self = this;
|
|
1578
|
-
registerHost(self, cmpMeta);
|
|
1579
|
-
if ( cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1580
|
-
// this component is using shadow dom
|
|
1581
|
-
// and this browser supports shadow dom
|
|
1582
|
-
// add the read-only property "shadowRoot" to the host element
|
|
1583
|
-
// adding the shadow root build conditionals to minimize runtime
|
|
1584
|
-
if (supportsShadow) {
|
|
1239
|
+
lazyBundles.map((lazyBundle) => {
|
|
1240
|
+
lazyBundle[1].map((compactMeta) => {
|
|
1241
|
+
const cmpMeta = {
|
|
1242
|
+
$flags$: compactMeta[0],
|
|
1243
|
+
$tagName$: compactMeta[1],
|
|
1244
|
+
$members$: compactMeta[2],
|
|
1245
|
+
$listeners$: compactMeta[3],
|
|
1246
|
+
};
|
|
1247
|
+
{
|
|
1248
|
+
cmpMeta.$members$ = compactMeta[2];
|
|
1249
|
+
}
|
|
1250
|
+
{
|
|
1251
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
1252
|
+
}
|
|
1253
|
+
{
|
|
1254
|
+
cmpMeta.$attrsToReflect$ = [];
|
|
1255
|
+
}
|
|
1256
|
+
{
|
|
1257
|
+
cmpMeta.$watchers$ = {};
|
|
1258
|
+
}
|
|
1259
|
+
const tagName = cmpMeta.$tagName$;
|
|
1260
|
+
const HostElement = class extends HTMLElement {
|
|
1261
|
+
// StencilLazyHost
|
|
1262
|
+
constructor(self) {
|
|
1263
|
+
// @ts-ignore
|
|
1264
|
+
super(self);
|
|
1265
|
+
self = this;
|
|
1266
|
+
registerHost(self, cmpMeta);
|
|
1267
|
+
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1268
|
+
// this component is using shadow dom
|
|
1269
|
+
// and this browser supports shadow dom
|
|
1270
|
+
// add the read-only property "shadowRoot" to the host element
|
|
1271
|
+
// adding the shadow root build conditionals to minimize runtime
|
|
1585
1272
|
{
|
|
1586
|
-
|
|
1273
|
+
{
|
|
1274
|
+
self.attachShadow({ mode: 'open' });
|
|
1275
|
+
}
|
|
1587
1276
|
}
|
|
1588
1277
|
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1278
|
+
}
|
|
1279
|
+
connectedCallback() {
|
|
1280
|
+
if (appLoadFallback) {
|
|
1281
|
+
clearTimeout(appLoadFallback);
|
|
1282
|
+
appLoadFallback = null;
|
|
1283
|
+
}
|
|
1284
|
+
if (isBootstrapping) {
|
|
1285
|
+
// connectedCallback will be processed once all components have been registered
|
|
1286
|
+
deferredConnectedCallbacks.push(this);
|
|
1287
|
+
}
|
|
1288
|
+
else {
|
|
1289
|
+
plt.jmp(() => connectedCallback(this));
|
|
1591
1290
|
}
|
|
1592
1291
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
if (appLoadFallback) {
|
|
1596
|
-
clearTimeout(appLoadFallback);
|
|
1597
|
-
appLoadFallback = null;
|
|
1292
|
+
disconnectedCallback() {
|
|
1293
|
+
plt.jmp(() => disconnectedCallback(this));
|
|
1598
1294
|
}
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
deferredConnectedCallbacks.push(this);
|
|
1295
|
+
componentOnReady() {
|
|
1296
|
+
return getHostRef(this).$onReadyPromise$;
|
|
1602
1297
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
plt.jmp(() => disconnectedCallback(this));
|
|
1609
|
-
}
|
|
1610
|
-
forceUpdate() {
|
|
1611
|
-
forceUpdate(this);
|
|
1612
|
-
}
|
|
1613
|
-
componentOnReady() {
|
|
1614
|
-
return getHostRef(this).$onReadyPromise$;
|
|
1298
|
+
};
|
|
1299
|
+
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1300
|
+
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1301
|
+
cmpTags.push(tagName);
|
|
1302
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1615
1303
|
}
|
|
1616
|
-
};
|
|
1617
|
-
|
|
1618
|
-
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1619
|
-
cmpTags.push(tagName);
|
|
1620
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1621
|
-
}
|
|
1622
|
-
}));
|
|
1304
|
+
});
|
|
1305
|
+
});
|
|
1623
1306
|
{
|
|
1624
1307
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1625
1308
|
visibilityStyle.setAttribute('data-styles', '');
|
|
@@ -1628,7 +1311,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1628
1311
|
// Process deferred connectedCallbacks now all components have been registered
|
|
1629
1312
|
isBootstrapping = false;
|
|
1630
1313
|
if (deferredConnectedCallbacks.length) {
|
|
1631
|
-
deferredConnectedCallbacks.map(host => host.connectedCallback());
|
|
1314
|
+
deferredConnectedCallbacks.map((host) => host.connectedCallback());
|
|
1632
1315
|
}
|
|
1633
1316
|
else {
|
|
1634
1317
|
{
|
|
@@ -1649,7 +1332,7 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
1649
1332
|
$instanceValues$: new Map(),
|
|
1650
1333
|
};
|
|
1651
1334
|
{
|
|
1652
|
-
hostRef.$onReadyPromise$ = new Promise(r => (hostRef.$onReadyResolve$ = r));
|
|
1335
|
+
hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
|
|
1653
1336
|
elm['s-p'] = [];
|
|
1654
1337
|
elm['s-rc'] = [];
|
|
1655
1338
|
}
|
|
@@ -1657,21 +1340,23 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
1657
1340
|
return hostRefs.set(elm, hostRef);
|
|
1658
1341
|
};
|
|
1659
1342
|
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
1660
|
-
const consoleError = (e) => console.error(e);
|
|
1343
|
+
const consoleError = (e, el) => (0, console.error)(e, el);
|
|
1661
1344
|
const cmpModules = /*@__PURE__*/ new Map();
|
|
1662
1345
|
const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
1663
1346
|
// loadModuleImport
|
|
1664
1347
|
const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
|
|
1665
1348
|
const bundleId = cmpMeta.$lazyBundleId$;
|
|
1666
|
-
const module =
|
|
1349
|
+
const module = cmpModules.get(bundleId) ;
|
|
1667
1350
|
if (module) {
|
|
1668
1351
|
return module[exportName];
|
|
1669
1352
|
}
|
|
1353
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
|
1670
1354
|
return import(
|
|
1355
|
+
/* @vite-ignore */
|
|
1671
1356
|
/* webpackInclude: /\.entry\.js$/ */
|
|
1672
1357
|
/* webpackExclude: /\.system\.entry\.js$/ */
|
|
1673
1358
|
/* webpackMode: "lazy" */
|
|
1674
|
-
`./${bundleId}.entry.js${
|
|
1359
|
+
`./${bundleId}.entry.js${''}`).then((importedModule) => {
|
|
1675
1360
|
{
|
|
1676
1361
|
cmpModules.set(bundleId, importedModule);
|
|
1677
1362
|
}
|
|
@@ -1681,7 +1366,6 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1681
1366
|
const styles = new Map();
|
|
1682
1367
|
const queueDomReads = [];
|
|
1683
1368
|
const queueDomWrites = [];
|
|
1684
|
-
const queueDomWritesLow = [];
|
|
1685
1369
|
const queueTask = (queue, write) => (cb) => {
|
|
1686
1370
|
queue.push(cb);
|
|
1687
1371
|
if (!queuePending) {
|
|
@@ -1705,52 +1389,22 @@ const consume = (queue) => {
|
|
|
1705
1389
|
}
|
|
1706
1390
|
queue.length = 0;
|
|
1707
1391
|
};
|
|
1708
|
-
const consumeTimeout = (queue, timeout) => {
|
|
1709
|
-
let i = 0;
|
|
1710
|
-
let ts = 0;
|
|
1711
|
-
while (i < queue.length && (ts = performance.now()) < timeout) {
|
|
1712
|
-
try {
|
|
1713
|
-
queue[i++](ts);
|
|
1714
|
-
}
|
|
1715
|
-
catch (e) {
|
|
1716
|
-
consoleError(e);
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
if (i === queue.length) {
|
|
1720
|
-
queue.length = 0;
|
|
1721
|
-
}
|
|
1722
|
-
else if (i !== 0) {
|
|
1723
|
-
queue.splice(0, i);
|
|
1724
|
-
}
|
|
1725
|
-
};
|
|
1726
1392
|
const flush = () => {
|
|
1727
|
-
{
|
|
1728
|
-
queueCongestion++;
|
|
1729
|
-
}
|
|
1730
1393
|
// always force a bunch of medium callbacks to run, but still have
|
|
1731
1394
|
// a throttle on how many can run in a certain time
|
|
1732
1395
|
// DOM READS!!!
|
|
1733
1396
|
consume(queueDomReads);
|
|
1734
1397
|
// DOM WRITES!!!
|
|
1735
1398
|
{
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
consumeTimeout(queueDomWritesLow, timeout);
|
|
1739
|
-
if (queueDomWrites.length > 0) {
|
|
1740
|
-
queueDomWritesLow.push(...queueDomWrites);
|
|
1741
|
-
queueDomWrites.length = 0;
|
|
1742
|
-
}
|
|
1743
|
-
if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
|
|
1399
|
+
consume(queueDomWrites);
|
|
1400
|
+
if ((queuePending = queueDomReads.length > 0)) {
|
|
1744
1401
|
// still more to do yet, but we've run out of time
|
|
1745
1402
|
// let's let this thing cool off and try again in the next tick
|
|
1746
1403
|
plt.raf(flush);
|
|
1747
1404
|
}
|
|
1748
|
-
else {
|
|
1749
|
-
queueCongestion = 0;
|
|
1750
|
-
}
|
|
1751
1405
|
}
|
|
1752
1406
|
};
|
|
1753
1407
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1754
1408
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1755
1409
|
|
|
1756
|
-
export {
|
|
1410
|
+
export { Host as H, NAMESPACE as N, bootstrapLazy as b, createEvent as c, doc as d, getElement as g, h, promiseResolve as p, registerInstance as r, win as w };
|