@jsenv/core 27.0.0-alpha.9 → 27.0.0-alpha.92
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/dist/babel_helpers/AsyncGenerator/AsyncGenerator.js +95 -0
- package/dist/babel_helpers/AwaitValue/AwaitValue.js +3 -0
- package/dist/babel_helpers/applyDecoratorDescriptor/applyDecoratorDescriptor.js +29 -0
- package/dist/babel_helpers/applyDecs/applyDecs.js +756 -0
- package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +9 -0
- package/dist/babel_helpers/arrayWithHoles/arrayWithHoles.js +4 -0
- package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +5 -0
- package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +8 -0
- package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +52 -0
- package/dist/babel_helpers/asyncIterator/asyncIterator.js +78 -0
- package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +39 -0
- package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +4 -0
- package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +24 -0
- package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +7 -0
- package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +14 -0
- package/dist/babel_helpers/classCallCheck/classCallCheck.js +5 -0
- package/dist/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -0
- package/dist/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -0
- package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +8 -0
- package/dist/babel_helpers/classNameTDZError/classNameTDZError.js +4 -0
- package/dist/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +6 -0
- package/dist/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +6 -0
- package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +7 -0
- package/dist/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -0
- package/dist/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +7 -0
- package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +7 -0
- package/dist/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +3 -0
- package/dist/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +8 -0
- package/dist/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +9 -0
- package/dist/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +5 -0
- package/dist/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -0
- package/dist/babel_helpers/construct/construct.js +15 -0
- package/dist/babel_helpers/createClass/createClass.js +18 -0
- package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +63 -0
- package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +22 -0
- package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +50 -0
- package/dist/babel_helpers/createSuper/createSuper.js +22 -0
- package/dist/babel_helpers/decorate/decorate.js +622 -0
- package/dist/babel_helpers/defaults/defaults.js +14 -0
- package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +26 -0
- package/dist/babel_helpers/defineProperty/defineProperty.js +19 -0
- package/dist/babel_helpers/extends/extends.js +16 -0
- package/dist/babel_helpers/get/get.js +21 -0
- package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +2 -0
- package/dist/babel_helpers/identity/identity.js +3 -0
- package/dist/babel_helpers/inherits/inherits.js +21 -0
- package/dist/babel_helpers/inheritsLoose/inheritsLoose.js +6 -0
- package/dist/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +10 -0
- package/dist/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +3 -0
- package/dist/babel_helpers/instanceof/instanceof.js +7 -0
- package/dist/babel_helpers/interopRequireDefault/interopRequireDefault.js +5 -0
- package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +49 -0
- package/dist/babel_helpers/isNativeFunction/isNativeFunction.js +4 -0
- package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -0
- package/dist/babel_helpers/iterableToArray/iterableToArray.js +3 -0
- package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +38 -0
- package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +13 -0
- package/dist/babel_helpers/jsx/jsx.js +49 -0
- package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +10 -0
- package/dist/babel_helpers/newArrowCheck/newArrowCheck.js +5 -0
- package/dist/babel_helpers/nonIterableRest/nonIterableRest.js +3 -0
- package/dist/babel_helpers/nonIterableSpread/nonIterableSpread.js +3 -0
- package/dist/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -0
- package/dist/babel_helpers/objectSpread/objectSpread.js +22 -0
- package/dist/babel_helpers/objectSpread2/objectSpread2.js +41 -0
- package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +20 -0
- package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +15 -0
- package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +10 -0
- package/dist/babel_helpers/readOnlyError/readOnlyError.js +4 -0
- package/dist/babel_helpers/set/set.js +51 -0
- package/dist/babel_helpers/setPrototypeOf/setPrototypeOf.js +5 -0
- package/dist/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -0
- package/dist/babel_helpers/slicedToArray/slicedToArray.js +5 -0
- package/dist/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +7 -0
- package/dist/babel_helpers/superPropBase/superPropBase.js +10 -0
- package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +11 -0
- package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +8 -0
- package/dist/babel_helpers/tdz/tdz.js +4 -0
- package/dist/babel_helpers/temporalRef/temporalRef.js +5 -0
- package/dist/babel_helpers/temporalUndefined/temporalUndefined.js +3 -0
- package/dist/babel_helpers/toArray/toArray.js +5 -0
- package/dist/babel_helpers/toConsumableArray/toConsumableArray.js +5 -0
- package/dist/babel_helpers/toPrimitive/toPrimitive.js +14 -0
- package/dist/babel_helpers/toPropertyKey/toPropertyKey.js +5 -0
- package/dist/babel_helpers/typeof/typeof.js +7 -0
- package/dist/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +10 -0
- package/dist/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +7 -0
- package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +35 -0
- package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +67 -0
- package/dist/babel_helpers/writeOnlyError/writeOnlyError.js +4 -0
- package/dist/html/explorer.html +557 -0
- package/dist/js/controllable_file.mjs +227 -0
- package/dist/js/event_source_client.js +528 -0
- package/dist/js/global_this.js +32 -0
- package/dist/js/html_supervisor_installer.js +522 -0
- package/dist/js/html_supervisor_setup.js +82 -0
- package/dist/js/import_meta_hot.js +84 -0
- package/dist/js/inline_content.js +8 -0
- package/dist/js/new_stylesheet.js +409 -0
- package/dist/js/regenerator_runtime.js +721 -0
- package/dist/js/s.js +429 -0
- package/dist/js/uneval.js +804 -0
- package/dist/main.js +25163 -0
- package/dist/other/jsenv.png +0 -0
- package/dist/s.js +626 -0
- package/dist/s.js.map +205 -0
- package/package.json +61 -57
- package/readme.md +6 -14
- package/src/build/build.js +1040 -551
- package/src/build/build_urls_generator.js +65 -25
- package/src/build/graph_utils.js +31 -0
- package/src/build/inject_global_version_mappings.js +93 -0
- package/src/build/inject_service_worker_urls.js +79 -0
- package/src/build/resync_ressource_hints.js +114 -0
- package/src/build/start_build_server.js +217 -0
- package/src/build/version_generator.js +60 -0
- package/src/dev/plugins/explorer/client/explorer.html +1 -1
- package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +9 -14
- package/src/dev/plugins/toolbar/client/util/fetching.js +1 -1
- package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +6 -4
- package/src/dev/start_dev_server.js +173 -38
- package/src/execute/execute.js +35 -8
- package/src/execute/run.js +21 -57
- package/src/execute/runtimes/browsers/from_playwright.js +224 -153
- package/src/execute/runtimes/node/child_exec_options.js +1 -1
- package/src/execute/runtimes/node/controllable_file.mjs +26 -10
- package/src/execute/runtimes/node/kill_process_tree.js +2 -4
- package/src/execute/runtimes/node/node_execution_performance.js +67 -0
- package/src/execute/runtimes/node/node_process.js +288 -39
- package/src/helpers/command/command.js +73 -0
- package/src/{dev/plugins/autoreload/client/event_source_connection.js → helpers/event_source/event_source.js} +2 -0
- package/src/helpers/event_source/sse_service.js +53 -0
- package/src/helpers/worker_reload.js +57 -0
- package/src/main.js +27 -0
- package/src/omega/{runtime_support/features_compatibility.js → compat/features_compats.js} +30 -7
- package/src/omega/{runtime_support/runtime_support.js → compat/runtime_compat.js} +16 -17
- package/src/omega/errors.js +63 -67
- package/src/omega/fetched_content_compliance.js +24 -0
- package/src/omega/file_url_converter.js +9 -51
- package/src/omega/kitchen.js +607 -466
- package/src/omega/omega_server.js +2 -3
- package/src/omega/server/file_service.js +88 -41
- package/src/omega/server/user_agent.js +5 -5
- package/src/omega/url_graph/{url_graph_sort.js → sort_by_dependencies.js} +3 -5
- package/src/omega/url_graph/url_graph_load.js +31 -23
- package/src/omega/url_graph/url_graph_report.js +94 -51
- package/src/omega/url_graph/url_info_transformations.js +54 -24
- package/src/omega/url_graph.js +88 -19
- package/src/omega/url_specifier_encoding.js +59 -0
- package/src/omega/web_workers.js +42 -0
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/autoreload_preference.js +0 -0
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/event_source_client.js +19 -12
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/reload.js +6 -3
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/url_helpers.js +0 -0
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +41 -0
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js +204 -0
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +25 -0
- package/src/plugins/autoreload/jsenv_plugin_hmr.js +35 -0
- package/src/plugins/bundling/css/bundle_css.js +140 -0
- package/src/plugins/bundling/js_classic_workers/bundle_js_classic_workers.js +13 -0
- package/src/plugins/bundling/js_module/bundle_js_module.js +362 -0
- package/src/plugins/bundling/jsenv_plugin_bundling.js +54 -0
- package/src/plugins/cache_control/jsenv_plugin_cache_control.js +34 -0
- package/src/{omega/core_plugins → plugins}/commonjs_globals/jsenv_plugin_commonjs_globals.js +56 -43
- package/src/plugins/file_urls/jsenv_plugin_file_urls.js +190 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_document.js +0 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_notification.js +0 -0
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +254 -0
- package/src/plugins/html_supervisor/client/html_supervisor_setup.js +82 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/perf_browser.js +0 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/uneval_exception.js +0 -0
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +239 -0
- package/src/plugins/http_urls/jsenv_plugin_http_urls.js +16 -0
- package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/babel_plugin_metadata_import_meta_hot.js +4 -5
- package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/client/import_meta_hot.js +3 -1
- package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/html_hot_dependencies.js +15 -18
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +100 -0
- package/src/{omega/core_plugins → plugins}/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +35 -10
- package/src/plugins/import_meta_url/client/import_meta_url_browser.js +52 -0
- package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +9 -0
- package/src/{omega/core_plugins → plugins}/importmap/jsenv_plugin_importmap.js +56 -54
- package/src/plugins/inject_globals/inject_globals.js +57 -0
- package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +24 -0
- package/src/{omega/core_plugins → plugins}/inline/client/inline_content.js +0 -0
- package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_data_urls.js +22 -21
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +159 -0
- package/src/plugins/inline/jsenv_plugin_inline.js +36 -0
- package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_inline_query_param.js +8 -11
- package/src/plugins/inline/jsenv_plugin_js_inline_content.js +294 -0
- package/src/plugins/leading_slash/jsenv_plugin_leading_slash.js +13 -0
- package/src/plugins/minification/css/minify_css.js +9 -0
- package/src/plugins/minification/html/minify_html.js +13 -0
- package/src/{build/plugins/minify_js/jsenv_plugin_minify_js.js → plugins/minification/js/minify_js.js} +6 -22
- package/src/plugins/minification/jsenv_plugin_minification.js +78 -0
- package/src/plugins/minification/json/minify_json.js +8 -0
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +162 -0
- package/src/plugins/node_runtime/jsenv_plugin_node_runtime.js +12 -0
- package/src/{omega → plugins}/plugin_controller.js +57 -12
- package/src/plugins/plugins.js +91 -0
- package/src/plugins/transpilation/as_js_classic/client/s.js +429 -0
- package/src/plugins/transpilation/as_js_classic/helpers/babel_plugin_transform_import_meta_url.js +47 -0
- package/src/plugins/transpilation/as_js_classic/helpers/systemjs_old.js +43 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +209 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +282 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_workers.js +55 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +2 -3
- package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/client/global_this.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js +3 -4
- package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugin_structure.js +14 -17
- package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugins_compatibility.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/jsenv_plugin_babel.js +40 -33
- package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +32 -9
- package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/client/new_stylesheet.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +2 -3
- package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/client/regenerator_runtime.js +0 -0
- package/src/plugins/transpilation/babel/require_babel_plugin.js +8 -0
- package/src/plugins/transpilation/css_parcel/jsenv_plugin_css_parcel.js +18 -0
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +184 -0
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +80 -0
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +46 -0
- package/src/plugins/url_analysis/css/css_urls.js +48 -0
- package/src/plugins/url_analysis/html/html_urls.js +257 -0
- package/src/plugins/url_analysis/js/js_urls.js +69 -0
- package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +110 -0
- package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +20 -0
- package/src/{omega/core_plugins → plugins}/url_resolution/jsenv_plugin_url_resolution.js +9 -5
- package/src/plugins/url_version/jsenv_plugin_url_version.js +28 -0
- package/src/require_from_jsenv.js +3 -0
- package/src/test/coverage/babel_plugin_instrument.js +82 -0
- package/src/test/coverage/coverage_reporter_html_directory.js +36 -0
- package/src/test/coverage/coverage_reporter_json_file.js +22 -0
- package/src/test/coverage/coverage_reporter_text_log.js +19 -0
- package/src/test/coverage/empty_coverage_factory.js +52 -0
- package/src/test/coverage/file_by_file_coverage.js +25 -0
- package/src/test/coverage/istanbul_coverage_composition.js +28 -0
- package/src/test/coverage/istanbul_coverage_map_from_coverage.js +16 -0
- package/src/test/coverage/list_files_not_covered.js +15 -0
- package/src/test/coverage/missing_coverage.js +41 -0
- package/src/test/coverage/report_to_coverage.js +196 -0
- package/src/test/coverage/v8_and_istanbul.js +37 -0
- package/src/test/coverage/v8_coverage_composition.js +24 -0
- package/src/test/coverage/v8_coverage_from_directory.js +87 -0
- package/src/test/coverage/v8_coverage_to_istanbul.js +99 -0
- package/src/test/execute_plan.js +87 -46
- package/src/test/execute_test_plan.js +40 -28
- package/src/test/execution_steps.js +2 -5
- package/src/test/logs_file_execution.js +56 -49
- package/main.js +0 -19
- package/src/build/inject_version_mappings.js +0 -62
- package/src/build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js +0 -227
- package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +0 -30
- package/src/dev/plugins/autoreload/jsenv_plugin_autoreload.js +0 -374
- package/src/dev/plugins/autoreload/sse_service.js +0 -149
- package/src/execute/runtimes/node/controlled_process.js +0 -316
- package/src/omega/core_plugins/babel/new_stylesheet/client/.eslintrc.cjs +0 -24
- package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +0 -67
- package/src/omega/core_plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +0 -58
- package/src/omega/core_plugins/html_supervisor/client/html_supervisor_installer.js +0 -168
- package/src/omega/core_plugins/html_supervisor/client/html_supervisor_setup.js +0 -77
- package/src/omega/core_plugins/html_supervisor/jsenv_plugin_html_supervisor.js +0 -233
- package/src/omega/core_plugins/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +0 -98
- package/src/omega/core_plugins/import_assertions/helpers/json_module.js +0 -12
- package/src/omega/core_plugins/import_assertions/helpers/text_module.js +0 -6
- package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +0 -211
- package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +0 -13
- package/src/omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js +0 -142
- package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +0 -207
- package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +0 -12
- package/src/omega/core_plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +0 -77
- package/src/omega/core_plugins/url_version/jsenv_plugin_url_version.js +0 -50
- package/src/omega/core_plugins.js +0 -39
- package/src/omega/runtime_support/default_runtime_support.js +0 -13
- package/src/omega/url_mentions/css_url_mentions.js +0 -63
- package/src/omega/url_mentions/html_url_mentions.js +0 -185
- package/src/omega/url_mentions/js_module_url_mentions.js +0 -91
- package/src/omega/url_mentions/parse_url_mentions.js +0 -37
- package/src/omega/url_mentions/worker_classic_url_mentions.js +0 -37
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
/* @minVersion 7.16.6 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Enums are used in this file, but not assigned to vars to avoid non-hoistable values
|
|
5
|
+
|
|
6
|
+
CONSTRUCTOR = 0;
|
|
7
|
+
PUBLIC = 1;
|
|
8
|
+
PRIVATE = 2;
|
|
9
|
+
|
|
10
|
+
FIELD = 0;
|
|
11
|
+
ACCESSOR = 1;
|
|
12
|
+
METHOD = 2;
|
|
13
|
+
GETTER = 3;
|
|
14
|
+
SETTER = 4;
|
|
15
|
+
|
|
16
|
+
STATIC = 5;
|
|
17
|
+
*/
|
|
18
|
+
function createMetadataMethodsForProperty(metadataMap, kind, property) {
|
|
19
|
+
return {
|
|
20
|
+
getMetadata(key) {
|
|
21
|
+
if (typeof key !== "symbol") {
|
|
22
|
+
throw new TypeError("Metadata keys must be symbols, received: " + key);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var metadataForKey = metadataMap[key];
|
|
26
|
+
if (metadataForKey === void 0) return void 0;
|
|
27
|
+
|
|
28
|
+
if (kind === 1
|
|
29
|
+
/* PUBLIC */
|
|
30
|
+
) {
|
|
31
|
+
var pub = metadataForKey.public;
|
|
32
|
+
|
|
33
|
+
if (pub !== void 0) {
|
|
34
|
+
return pub[property];
|
|
35
|
+
}
|
|
36
|
+
} else if (kind === 2
|
|
37
|
+
/* PRIVATE */
|
|
38
|
+
) {
|
|
39
|
+
var priv = metadataForKey.private;
|
|
40
|
+
|
|
41
|
+
if (priv !== void 0) {
|
|
42
|
+
return priv.get(property);
|
|
43
|
+
}
|
|
44
|
+
} else if (Object.hasOwnProperty.call(metadataForKey, "constructor")) {
|
|
45
|
+
return metadataForKey.constructor;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
setMetadata(key, value) {
|
|
50
|
+
if (typeof key !== "symbol") {
|
|
51
|
+
throw new TypeError("Metadata keys must be symbols, received: " + key);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var metadataForKey = metadataMap[key];
|
|
55
|
+
|
|
56
|
+
if (metadataForKey === void 0) {
|
|
57
|
+
metadataForKey = metadataMap[key] = {};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (kind === 1
|
|
61
|
+
/* PUBLIC */
|
|
62
|
+
) {
|
|
63
|
+
var pub = metadataForKey.public;
|
|
64
|
+
|
|
65
|
+
if (pub === void 0) {
|
|
66
|
+
pub = metadataForKey.public = {};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
pub[property] = value;
|
|
70
|
+
} else if (kind === 2
|
|
71
|
+
/* PRIVATE */
|
|
72
|
+
) {
|
|
73
|
+
var priv = metadataForKey.priv;
|
|
74
|
+
|
|
75
|
+
if (priv === void 0) {
|
|
76
|
+
priv = metadataForKey.private = new Map();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
priv.set(property, value);
|
|
80
|
+
} else {
|
|
81
|
+
metadataForKey.constructor = value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function convertMetadataMapToFinal(obj, metadataMap) {
|
|
89
|
+
var parentMetadataMap = obj[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
90
|
+
var metadataKeys = Object.getOwnPropertySymbols(metadataMap);
|
|
91
|
+
if (metadataKeys.length === 0) return;
|
|
92
|
+
|
|
93
|
+
for (var i = 0; i < metadataKeys.length; i++) {
|
|
94
|
+
var key = metadataKeys[i];
|
|
95
|
+
var metaForKey = metadataMap[key];
|
|
96
|
+
var parentMetaForKey = parentMetadataMap ? parentMetadataMap[key] : null;
|
|
97
|
+
var pub = metaForKey.public;
|
|
98
|
+
var parentPub = parentMetaForKey ? parentMetaForKey.public : null;
|
|
99
|
+
|
|
100
|
+
if (pub && parentPub) {
|
|
101
|
+
Object.setPrototypeOf(pub, parentPub);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var priv = metaForKey.private;
|
|
105
|
+
|
|
106
|
+
if (priv) {
|
|
107
|
+
var privArr = Array.from(priv.values());
|
|
108
|
+
var parentPriv = parentMetaForKey ? parentMetaForKey.private : null;
|
|
109
|
+
|
|
110
|
+
if (parentPriv) {
|
|
111
|
+
privArr = privArr.concat(parentPriv);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
metaForKey.private = privArr;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (parentMetaForKey) {
|
|
118
|
+
Object.setPrototypeOf(metaForKey, parentMetaForKey);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (parentMetadataMap) {
|
|
123
|
+
Object.setPrototypeOf(metadataMap, parentMetadataMap);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
obj[Symbol.metadata || Symbol.for("Symbol.metadata")] = metadataMap;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function createAddInitializerMethod(initializers) {
|
|
130
|
+
return function addInitializer(initializer) {
|
|
131
|
+
assertValidInitializer(initializer);
|
|
132
|
+
initializers.push(initializer);
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function memberDecCtx(base, name, desc, metadataMap, initializers, kind, isStatic, isPrivate) {
|
|
137
|
+
var kindStr;
|
|
138
|
+
|
|
139
|
+
switch (kind) {
|
|
140
|
+
case 1
|
|
141
|
+
/* ACCESSOR */
|
|
142
|
+
:
|
|
143
|
+
kindStr = "accessor";
|
|
144
|
+
break;
|
|
145
|
+
|
|
146
|
+
case 2
|
|
147
|
+
/* METHOD */
|
|
148
|
+
:
|
|
149
|
+
kindStr = "method";
|
|
150
|
+
break;
|
|
151
|
+
|
|
152
|
+
case 3
|
|
153
|
+
/* GETTER */
|
|
154
|
+
:
|
|
155
|
+
kindStr = "getter";
|
|
156
|
+
break;
|
|
157
|
+
|
|
158
|
+
case 4
|
|
159
|
+
/* SETTER */
|
|
160
|
+
:
|
|
161
|
+
kindStr = "setter";
|
|
162
|
+
break;
|
|
163
|
+
|
|
164
|
+
default:
|
|
165
|
+
kindStr = "field";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
var ctx = {
|
|
169
|
+
kind: kindStr,
|
|
170
|
+
name: isPrivate ? "#" + name : name,
|
|
171
|
+
isStatic: isStatic,
|
|
172
|
+
isPrivate: isPrivate
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
if (kind !== 0
|
|
176
|
+
/* FIELD */
|
|
177
|
+
) {
|
|
178
|
+
ctx.addInitializer = createAddInitializerMethod(initializers);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var metadataKind, metadataName;
|
|
182
|
+
|
|
183
|
+
if (isPrivate) {
|
|
184
|
+
metadataKind = 2
|
|
185
|
+
/* PRIVATE */
|
|
186
|
+
;
|
|
187
|
+
metadataName = Symbol(name);
|
|
188
|
+
var access = {};
|
|
189
|
+
|
|
190
|
+
if (kind === 0
|
|
191
|
+
/* FIELD */
|
|
192
|
+
) {
|
|
193
|
+
access.get = desc.get;
|
|
194
|
+
access.set = desc.set;
|
|
195
|
+
} else if (kind === 2
|
|
196
|
+
/* METHOD */
|
|
197
|
+
) {
|
|
198
|
+
access.get = function () {
|
|
199
|
+
return desc.value;
|
|
200
|
+
};
|
|
201
|
+
} else {
|
|
202
|
+
// replace with values that will go through the final getter and setter
|
|
203
|
+
if (kind === 1
|
|
204
|
+
/* ACCESSOR */
|
|
205
|
+
|| kind === 3
|
|
206
|
+
/* GETTER */
|
|
207
|
+
) {
|
|
208
|
+
access.get = function () {
|
|
209
|
+
return desc.get.call(this);
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (kind === 1
|
|
214
|
+
/* ACCESSOR */
|
|
215
|
+
|| kind === 4
|
|
216
|
+
/* SETTER */
|
|
217
|
+
) {
|
|
218
|
+
access.set = function (v) {
|
|
219
|
+
desc.set.call(this, v);
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
ctx.access = access;
|
|
225
|
+
} else {
|
|
226
|
+
metadataKind = 1
|
|
227
|
+
/* PUBLIC */
|
|
228
|
+
;
|
|
229
|
+
metadataName = name;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return Object.assign(ctx, createMetadataMethodsForProperty(metadataMap, metadataKind, metadataName));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function assertValidInitializer(initializer) {
|
|
236
|
+
if (typeof initializer !== "function") {
|
|
237
|
+
throw new Error("initializers must be functions");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function assertValidReturnValue(kind, value) {
|
|
242
|
+
var type = typeof value;
|
|
243
|
+
|
|
244
|
+
if (kind === 1
|
|
245
|
+
/* ACCESSOR */
|
|
246
|
+
) {
|
|
247
|
+
if (type !== "object" || value === null) {
|
|
248
|
+
throw new Error("accessor decorators must return an object with get, set, or initializer properties or void 0");
|
|
249
|
+
}
|
|
250
|
+
} else if (type !== "function") {
|
|
251
|
+
if (kind === 0
|
|
252
|
+
/* FIELD */
|
|
253
|
+
) {
|
|
254
|
+
throw new Error("field decorators must return a initializer function or void 0");
|
|
255
|
+
} else {
|
|
256
|
+
throw new Error("method decorators must return a function or void 0");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, metadataMap, initializers) {
|
|
262
|
+
var decs = decInfo[0];
|
|
263
|
+
var desc, initializer, value;
|
|
264
|
+
|
|
265
|
+
if (isPrivate) {
|
|
266
|
+
if (kind === 0
|
|
267
|
+
/* FIELD */
|
|
268
|
+
|| kind === 1
|
|
269
|
+
/* ACCESSOR */
|
|
270
|
+
) {
|
|
271
|
+
desc = {
|
|
272
|
+
get: decInfo[3],
|
|
273
|
+
set: decInfo[4]
|
|
274
|
+
};
|
|
275
|
+
} else if (kind === 3
|
|
276
|
+
/* GETTER */
|
|
277
|
+
) {
|
|
278
|
+
desc = {
|
|
279
|
+
get: decInfo[3]
|
|
280
|
+
};
|
|
281
|
+
} else if (kind === 4
|
|
282
|
+
/* SETTER */
|
|
283
|
+
) {
|
|
284
|
+
desc = {
|
|
285
|
+
set: decInfo[3]
|
|
286
|
+
};
|
|
287
|
+
} else {
|
|
288
|
+
desc = {
|
|
289
|
+
value: decInfo[3]
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
} else if (kind !== 0
|
|
293
|
+
/* FIELD */
|
|
294
|
+
) {
|
|
295
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (kind === 1
|
|
299
|
+
/* ACCESSOR */
|
|
300
|
+
) {
|
|
301
|
+
value = {
|
|
302
|
+
get: desc.get,
|
|
303
|
+
set: desc.set
|
|
304
|
+
};
|
|
305
|
+
} else if (kind === 2
|
|
306
|
+
/* METHOD */
|
|
307
|
+
) {
|
|
308
|
+
value = desc.value;
|
|
309
|
+
} else if (kind === 3
|
|
310
|
+
/* GETTER */
|
|
311
|
+
) {
|
|
312
|
+
value = desc.get;
|
|
313
|
+
} else if (kind === 4
|
|
314
|
+
/* SETTER */
|
|
315
|
+
) {
|
|
316
|
+
value = desc.set;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
var ctx = memberDecCtx(base, name, desc, metadataMap, initializers, kind, isStatic, isPrivate);
|
|
320
|
+
var newValue, get, set;
|
|
321
|
+
|
|
322
|
+
if (typeof decs === "function") {
|
|
323
|
+
newValue = decs(value, ctx);
|
|
324
|
+
|
|
325
|
+
if (newValue !== void 0) {
|
|
326
|
+
assertValidReturnValue(kind, newValue);
|
|
327
|
+
|
|
328
|
+
if (kind === 0
|
|
329
|
+
/* FIELD */
|
|
330
|
+
) {
|
|
331
|
+
initializer = newValue;
|
|
332
|
+
} else if (kind === 1
|
|
333
|
+
/* ACCESSOR */
|
|
334
|
+
) {
|
|
335
|
+
initializer = newValue.initializer;
|
|
336
|
+
get = newValue.get || value.get;
|
|
337
|
+
set = newValue.set || value.set;
|
|
338
|
+
value = {
|
|
339
|
+
get: get,
|
|
340
|
+
set: set
|
|
341
|
+
};
|
|
342
|
+
} else {
|
|
343
|
+
value = newValue;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
for (var i = 0; i < decs.length; i++) {
|
|
348
|
+
var dec = decs[i];
|
|
349
|
+
newValue = dec(value, ctx);
|
|
350
|
+
|
|
351
|
+
if (newValue !== void 0) {
|
|
352
|
+
assertValidReturnValue(kind, newValue);
|
|
353
|
+
var newInit;
|
|
354
|
+
|
|
355
|
+
if (kind === 0
|
|
356
|
+
/* FIELD */
|
|
357
|
+
) {
|
|
358
|
+
newInit = newValue;
|
|
359
|
+
} else if (kind === 1
|
|
360
|
+
/* ACCESSOR */
|
|
361
|
+
) {
|
|
362
|
+
newInit = newValue.initializer;
|
|
363
|
+
get = newValue.get || value.get;
|
|
364
|
+
set = newValue.set || value.set;
|
|
365
|
+
value = {
|
|
366
|
+
get: get,
|
|
367
|
+
set: set
|
|
368
|
+
};
|
|
369
|
+
} else {
|
|
370
|
+
value = newValue;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (newInit !== void 0) {
|
|
374
|
+
if (initializer === void 0) {
|
|
375
|
+
initializer = newInit;
|
|
376
|
+
} else if (typeof initializer === "function") {
|
|
377
|
+
initializer = [initializer, newInit];
|
|
378
|
+
} else {
|
|
379
|
+
initializer.push(newInit);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (kind === 0
|
|
387
|
+
/* FIELD */
|
|
388
|
+
|| kind === 1
|
|
389
|
+
/* ACCESSOR */
|
|
390
|
+
) {
|
|
391
|
+
if (initializer === void 0) {
|
|
392
|
+
// If the initializer was void 0, sub in a dummy initializer
|
|
393
|
+
initializer = function (instance, init) {
|
|
394
|
+
return init;
|
|
395
|
+
};
|
|
396
|
+
} else if (typeof initializer !== "function") {
|
|
397
|
+
var ownInitializers = initializer;
|
|
398
|
+
|
|
399
|
+
initializer = function (instance, init) {
|
|
400
|
+
var value = init;
|
|
401
|
+
|
|
402
|
+
for (var i = 0; i < ownInitializers.length; i++) {
|
|
403
|
+
value = ownInitializers[i].call(instance, value);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return value;
|
|
407
|
+
};
|
|
408
|
+
} else {
|
|
409
|
+
var originalInitializer = initializer;
|
|
410
|
+
|
|
411
|
+
initializer = function (instance, init) {
|
|
412
|
+
return originalInitializer.call(instance, init);
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
ret.push(initializer);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (kind !== 0
|
|
420
|
+
/* FIELD */
|
|
421
|
+
) {
|
|
422
|
+
if (kind === 1
|
|
423
|
+
/* ACCESSOR */
|
|
424
|
+
) {
|
|
425
|
+
desc.get = value.get;
|
|
426
|
+
desc.set = value.set;
|
|
427
|
+
} else if (kind === 2
|
|
428
|
+
/* METHOD */
|
|
429
|
+
) {
|
|
430
|
+
desc.value = value;
|
|
431
|
+
} else if (kind === 3
|
|
432
|
+
/* GETTER */
|
|
433
|
+
) {
|
|
434
|
+
desc.get = value;
|
|
435
|
+
} else if (kind === 4
|
|
436
|
+
/* SETTER */
|
|
437
|
+
) {
|
|
438
|
+
desc.set = value;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (isPrivate) {
|
|
442
|
+
if (kind === 1
|
|
443
|
+
/* ACCESSOR */
|
|
444
|
+
) {
|
|
445
|
+
ret.push(function (instance, args) {
|
|
446
|
+
return value.get.call(instance, args);
|
|
447
|
+
});
|
|
448
|
+
ret.push(function (instance, args) {
|
|
449
|
+
return value.set.call(instance, args);
|
|
450
|
+
});
|
|
451
|
+
} else if (kind === 2
|
|
452
|
+
/* METHOD */
|
|
453
|
+
) {
|
|
454
|
+
ret.push(value);
|
|
455
|
+
} else {
|
|
456
|
+
ret.push(function (instance, args) {
|
|
457
|
+
return value.call(instance, args);
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
} else {
|
|
461
|
+
Object.defineProperty(base, name, desc);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function applyMemberDecs(ret, Class, protoMetadataMap, staticMetadataMap, decInfos) {
|
|
467
|
+
var protoInitializers;
|
|
468
|
+
var staticInitializers;
|
|
469
|
+
var existingProtoNonFields = new Map();
|
|
470
|
+
var existingStaticNonFields = new Map();
|
|
471
|
+
|
|
472
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
473
|
+
var decInfo = decInfos[i]; // skip computed property names
|
|
474
|
+
|
|
475
|
+
if (!Array.isArray(decInfo)) continue;
|
|
476
|
+
var kind = decInfo[1];
|
|
477
|
+
var name = decInfo[2];
|
|
478
|
+
var isPrivate = decInfo.length > 3;
|
|
479
|
+
var isStatic = kind >= 5;
|
|
480
|
+
/* STATIC */
|
|
481
|
+
|
|
482
|
+
var base;
|
|
483
|
+
var metadataMap;
|
|
484
|
+
var initializers;
|
|
485
|
+
|
|
486
|
+
if (isStatic) {
|
|
487
|
+
base = Class;
|
|
488
|
+
metadataMap = staticMetadataMap;
|
|
489
|
+
kind = kind - 5
|
|
490
|
+
/* STATIC */
|
|
491
|
+
;
|
|
492
|
+
|
|
493
|
+
if (!staticInitializers) {
|
|
494
|
+
staticInitializers = [];
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
initializers = staticInitializers;
|
|
498
|
+
} else {
|
|
499
|
+
base = Class.prototype;
|
|
500
|
+
metadataMap = protoMetadataMap;
|
|
501
|
+
|
|
502
|
+
if (!protoInitializers) {
|
|
503
|
+
protoInitializers = [];
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
initializers = protoInitializers;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if (kind !== 0
|
|
510
|
+
/* FIELD */
|
|
511
|
+
&& !isPrivate) {
|
|
512
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
513
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
514
|
+
|
|
515
|
+
if (existingKind === true || existingKind === 3
|
|
516
|
+
/* GETTER */
|
|
517
|
+
&& kind !== 4
|
|
518
|
+
/* SETTER */
|
|
519
|
+
|| existingKind === 4
|
|
520
|
+
/* SETTER */
|
|
521
|
+
&& kind !== 3
|
|
522
|
+
/* GETTER */
|
|
523
|
+
) {
|
|
524
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
525
|
+
} else if (!existingKind && kind > 2
|
|
526
|
+
/* METHOD */
|
|
527
|
+
) {
|
|
528
|
+
existingNonFields.set(name, kind);
|
|
529
|
+
} else {
|
|
530
|
+
existingNonFields.set(name, true);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, metadataMap, initializers);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if (protoInitializers) {
|
|
538
|
+
pushInitializers(ret, protoInitializers);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if (staticInitializers) {
|
|
542
|
+
pushInitializers(ret, staticInitializers);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function pushInitializers(ret, initializers) {
|
|
547
|
+
if (initializers.length > 0) {
|
|
548
|
+
// Slice the array, which means that `addInitializer` can no longer add
|
|
549
|
+
// additional initializers to the array
|
|
550
|
+
initializers = initializers.slice();
|
|
551
|
+
ret.push(function (instance) {
|
|
552
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
553
|
+
initializers[i].call(instance, instance);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
return instance;
|
|
557
|
+
});
|
|
558
|
+
} else {
|
|
559
|
+
ret.push(function (instance) {
|
|
560
|
+
return instance;
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function applyClassDecs(ret, targetClass, metadataMap, classDecs) {
|
|
566
|
+
var initializers = [];
|
|
567
|
+
var newClass = targetClass;
|
|
568
|
+
var name = targetClass.name;
|
|
569
|
+
var ctx = Object.assign({
|
|
570
|
+
kind: "class",
|
|
571
|
+
name: name,
|
|
572
|
+
addInitializer: createAddInitializerMethod(initializers)
|
|
573
|
+
}, createMetadataMethodsForProperty(metadataMap, 0
|
|
574
|
+
/* CONSTRUCTOR */
|
|
575
|
+
, name));
|
|
576
|
+
|
|
577
|
+
for (var i = 0; i < classDecs.length; i++) {
|
|
578
|
+
newClass = classDecs[i](newClass, ctx) || newClass;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
ret.push(newClass);
|
|
582
|
+
|
|
583
|
+
if (initializers.length > 0) {
|
|
584
|
+
ret.push(function () {
|
|
585
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
586
|
+
initializers[i].call(newClass, newClass);
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
} else {
|
|
590
|
+
ret.push(function () {});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
Basic usage:
|
|
595
|
+
|
|
596
|
+
applyDecs(
|
|
597
|
+
Class,
|
|
598
|
+
[
|
|
599
|
+
// member decorators
|
|
600
|
+
[
|
|
601
|
+
dec, // dec or array of decs
|
|
602
|
+
0, // kind of value being decorated
|
|
603
|
+
'prop', // name of public prop on class containing the value being decorated,
|
|
604
|
+
'#p', // the name of the private property (if is private, void 0 otherwise),
|
|
605
|
+
]
|
|
606
|
+
],
|
|
607
|
+
[
|
|
608
|
+
// class decorators
|
|
609
|
+
dec1, dec2
|
|
610
|
+
]
|
|
611
|
+
)
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
Fully transpiled example:
|
|
615
|
+
|
|
616
|
+
```js
|
|
617
|
+
@dec
|
|
618
|
+
class Class {
|
|
619
|
+
@dec
|
|
620
|
+
a = 123;
|
|
621
|
+
|
|
622
|
+
@dec
|
|
623
|
+
#a = 123;
|
|
624
|
+
|
|
625
|
+
@dec
|
|
626
|
+
@dec2
|
|
627
|
+
accessor b = 123;
|
|
628
|
+
|
|
629
|
+
@dec
|
|
630
|
+
accessor #b = 123;
|
|
631
|
+
|
|
632
|
+
@dec
|
|
633
|
+
c() { console.log('c'); }
|
|
634
|
+
|
|
635
|
+
@dec
|
|
636
|
+
#c() { console.log('privC'); }
|
|
637
|
+
|
|
638
|
+
@dec
|
|
639
|
+
get d() { console.log('d'); }
|
|
640
|
+
|
|
641
|
+
@dec
|
|
642
|
+
get #d() { console.log('privD'); }
|
|
643
|
+
|
|
644
|
+
@dec
|
|
645
|
+
set e(v) { console.log('e'); }
|
|
646
|
+
|
|
647
|
+
@dec
|
|
648
|
+
set #e(v) { console.log('privE'); }
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
// becomes
|
|
653
|
+
let initializeInstance;
|
|
654
|
+
let initializeClass;
|
|
655
|
+
|
|
656
|
+
let initA;
|
|
657
|
+
let initPrivA;
|
|
658
|
+
|
|
659
|
+
let initB;
|
|
660
|
+
let initPrivB, getPrivB, setPrivB;
|
|
661
|
+
|
|
662
|
+
let privC;
|
|
663
|
+
let privD;
|
|
664
|
+
let privE;
|
|
665
|
+
|
|
666
|
+
let Class;
|
|
667
|
+
class _Class {
|
|
668
|
+
static {
|
|
669
|
+
let ret = applyDecs(
|
|
670
|
+
this,
|
|
671
|
+
[
|
|
672
|
+
[dec, 0, 'a'],
|
|
673
|
+
[dec, 0, 'a', (i) => i.#a, (i, v) => i.#a = v],
|
|
674
|
+
[[dec, dec2], 1, 'b'],
|
|
675
|
+
[dec, 1, 'b', (i) => i.#privBData, (i, v) => i.#privBData = v],
|
|
676
|
+
[dec, 2, 'c'],
|
|
677
|
+
[dec, 2, 'c', () => console.log('privC')],
|
|
678
|
+
[dec, 3, 'd'],
|
|
679
|
+
[dec, 3, 'd', () => console.log('privD')],
|
|
680
|
+
[dec, 4, 'e'],
|
|
681
|
+
[dec, 4, 'e', () => console.log('privE')],
|
|
682
|
+
],
|
|
683
|
+
[
|
|
684
|
+
dec
|
|
685
|
+
]
|
|
686
|
+
)
|
|
687
|
+
|
|
688
|
+
initA = ret[0];
|
|
689
|
+
|
|
690
|
+
initPrivA = ret[1];
|
|
691
|
+
|
|
692
|
+
initB = ret[2];
|
|
693
|
+
|
|
694
|
+
initPrivB = ret[3];
|
|
695
|
+
getPrivB = ret[4];
|
|
696
|
+
setPrivB = ret[5];
|
|
697
|
+
|
|
698
|
+
privC = ret[6];
|
|
699
|
+
|
|
700
|
+
privD = ret[7];
|
|
701
|
+
|
|
702
|
+
privE = ret[8];
|
|
703
|
+
|
|
704
|
+
initializeInstance = ret[9];
|
|
705
|
+
|
|
706
|
+
Class = ret[10]
|
|
707
|
+
|
|
708
|
+
initializeClass = ret[11];
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
a = (initializeInstance(this), initA(this, 123));
|
|
712
|
+
|
|
713
|
+
#a = initPrivA(this, 123);
|
|
714
|
+
|
|
715
|
+
#bData = initB(this, 123);
|
|
716
|
+
get b() { return this.#bData }
|
|
717
|
+
set b(v) { this.#bData = v }
|
|
718
|
+
|
|
719
|
+
#privBData = initPrivB(this, 123);
|
|
720
|
+
get #b() { return getPrivB(this); }
|
|
721
|
+
set #b(v) { setPrivB(this, v); }
|
|
722
|
+
|
|
723
|
+
c() { console.log('c'); }
|
|
724
|
+
|
|
725
|
+
#c(...args) { return privC(this, ...args) }
|
|
726
|
+
|
|
727
|
+
get d() { console.log('d'); }
|
|
728
|
+
|
|
729
|
+
get #d() { return privD(this); }
|
|
730
|
+
|
|
731
|
+
set e(v) { console.log('e'); }
|
|
732
|
+
|
|
733
|
+
set #e(v) { privE(this, v); }
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
initializeClass(Class);
|
|
737
|
+
*/
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
export default function applyDecs(targetClass, memberDecs, classDecs) {
|
|
741
|
+
var ret = [];
|
|
742
|
+
var staticMetadataMap = {};
|
|
743
|
+
|
|
744
|
+
if (memberDecs) {
|
|
745
|
+
var protoMetadataMap = {};
|
|
746
|
+
applyMemberDecs(ret, targetClass, protoMetadataMap, staticMetadataMap, memberDecs);
|
|
747
|
+
convertMetadataMapToFinal(targetClass.prototype, protoMetadataMap);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
if (classDecs) {
|
|
751
|
+
applyClassDecs(ret, targetClass, staticMetadataMap, classDecs);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
convertMetadataMapToFinal(targetClass, staticMetadataMap);
|
|
755
|
+
return ret;
|
|
756
|
+
}
|