ember-source 7.1.0-alpha.4 → 7.1.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-metadata.json +3 -3
- package/dist/dev/packages/@ember/-internals/container/index.js +4 -401
- package/dist/dev/packages/@ember/-internals/deprecations/index.js +1 -1
- package/dist/dev/packages/@ember/-internals/environment/index.js +3 -161
- package/dist/dev/packages/@ember/-internals/glimmer/index.js +14 -15
- package/dist/dev/packages/@ember/-internals/meta/lib/meta.js +0 -1
- package/dist/dev/packages/@ember/-internals/metal/index.js +18 -9
- package/dist/dev/packages/@ember/-internals/routing/index.js +1 -10
- package/dist/dev/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +10 -12
- package/dist/dev/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +1 -10
- package/dist/dev/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +3 -10
- package/dist/dev/packages/@ember/-internals/string/index.js +0 -1
- package/dist/dev/packages/@ember/-internals/utils/index.js +8 -3
- package/dist/dev/packages/@ember/-internals/views/lib/compat/fallback-view-registry.js +0 -1
- package/dist/dev/packages/@ember/-internals/views/lib/mixins/action_support.js +3 -12
- package/dist/dev/packages/@ember/-internals/views/lib/system/event_dispatcher.js +2 -11
- package/dist/dev/packages/@ember/-internals/views/lib/system/utils.js +1 -1
- package/dist/dev/packages/@ember/-internals/views/lib/views/core_view.js +1 -18
- package/dist/dev/packages/@ember/-internals/views/lib/views/states.js +1 -1
- package/dist/dev/packages/@ember/application/index.js +5 -28
- package/dist/dev/packages/@ember/application/instance.js +3 -22
- package/dist/dev/packages/@ember/application/namespace.js +4 -11
- package/dist/dev/packages/@ember/array/index.js +7 -15
- package/dist/dev/packages/@ember/array/proxy.js +10 -14
- package/dist/dev/packages/@ember/canary-features/index.js +1 -1
- package/dist/dev/packages/@ember/component/helper.js +1 -14
- package/dist/dev/packages/@ember/component/index.js +1355 -16
- package/dist/dev/packages/@ember/component/template-only.js +1 -9
- package/dist/dev/packages/@ember/controller/index.js +3 -19
- package/dist/dev/packages/@ember/debug/container-debug-adapter.js +0 -19
- package/dist/dev/packages/@ember/debug/data-adapter.js +4 -11
- package/dist/dev/packages/@ember/debug/index.js +1 -1
- package/dist/dev/packages/@ember/debug/lib/deprecate.js +1 -1
- package/dist/dev/packages/@ember/engine/index.js +3 -29
- package/dist/dev/packages/@ember/engine/instance.js +3 -8
- package/dist/dev/packages/@ember/helper/index.js +169 -21
- package/dist/dev/packages/@ember/instrumentation/index.js +1 -1
- package/dist/dev/packages/@ember/modifier/index.js +2 -16
- package/dist/dev/packages/@ember/modifier/on.js +1 -9
- package/dist/dev/packages/@ember/object/-internals.js +3 -11
- package/dist/dev/packages/@ember/object/compat.js +3 -10
- package/dist/dev/packages/@ember/object/computed.js +2 -12
- package/dist/dev/packages/@ember/object/core.js +10 -18
- package/dist/dev/packages/@ember/object/evented.js +2 -12
- package/dist/dev/packages/@ember/object/events.js +1 -11
- package/dist/dev/packages/@ember/object/index.js +10 -14
- package/dist/dev/packages/@ember/object/internals.js +1 -1
- package/dist/dev/packages/@ember/object/lib/computed/computed_macros.js +6 -23
- package/dist/dev/packages/@ember/object/lib/computed/reduce_computed_macros.js +3 -12
- package/dist/dev/packages/@ember/object/mixin.js +7 -10
- package/dist/dev/packages/@ember/object/observable.js +8 -12
- package/dist/dev/packages/@ember/object/observers.js +1 -11
- package/dist/dev/packages/@ember/object/promise-proxy-mixin.js +3 -13
- package/dist/dev/packages/@ember/object/proxy.js +0 -7
- package/dist/dev/packages/@ember/reactive/collections.js +589 -1
- package/dist/dev/packages/@ember/renderer/index.js +1 -14
- package/dist/dev/packages/@ember/routing/-internals.js +1 -10
- package/dist/dev/packages/@ember/routing/index.js +614 -14
- package/dist/dev/packages/@ember/routing/lib/generate_controller.js +2 -11
- package/dist/dev/packages/@ember/routing/lib/routing-service.js +7 -17
- package/dist/dev/packages/@ember/routing/lib/utils.js +2 -11
- package/dist/dev/packages/@ember/routing/route.js +12 -23
- package/dist/dev/packages/@ember/routing/router-service.js +8 -17
- package/dist/dev/packages/@ember/routing/router.js +5 -21
- package/dist/dev/packages/@ember/runloop/index.js +1 -10
- package/dist/dev/packages/@ember/service/index.js +1 -11
- package/dist/dev/packages/@ember/template/index.js +1 -14
- package/dist/dev/packages/@ember/template-compiler/lib/compile-options.js +12 -15
- package/dist/dev/packages/@ember/template-compiler/lib/dasherize-component-name.js +0 -1
- package/dist/dev/packages/@ember/template-compiler/lib/plugins/auto-import-builtins.js +13 -60
- package/dist/dev/packages/@ember/template-compiler/lib/plugins/index.js +1 -1
- package/dist/dev/packages/@ember/template-compiler/lib/plugins/transform-resolutions.js +1 -3
- package/dist/dev/packages/@ember/template-compiler/lib/template.js +2 -10
- package/dist/dev/packages/@ember/template-factory/index.js +1 -8
- package/dist/dev/packages/@ember/utils/lib/compare.js +0 -7
- package/dist/dev/packages/@ember/utils/lib/is_empty.js +1 -12
- package/dist/dev/packages/@glimmer/manager/index.js +4 -314
- package/dist/dev/packages/@glimmer/node/index.js +3 -11
- package/dist/dev/packages/@glimmer/opcode-compiler/index.js +5 -7
- package/dist/dev/packages/@glimmer/program/index.js +194 -3
- package/dist/dev/packages/@glimmer/reference/index.js +4 -5
- package/dist/dev/packages/@glimmer/runtime/index.js +17 -10
- package/dist/dev/packages/@glimmer/tracking/index.js +2 -11
- package/dist/dev/packages/@glimmer/tracking/primitives/cache/index.js +1 -11
- package/dist/dev/packages/@glimmer/util/index.js +1 -2
- package/dist/dev/packages/@glimmer/validator/index.js +4 -1253
- package/dist/dev/packages/@glimmer/vm/index.js +1 -1
- package/dist/dev/packages/@glimmer/wire-format/index.js +3 -65
- package/dist/dev/packages/ember/version.js +1 -1
- package/dist/dev/packages/ember-template-compiler/index.js +7 -7
- package/dist/dev/packages/shared-chunks/{alias-CSC0WIbj.js → alias-ZcMQckQV.js} +8 -4
- package/dist/dev/packages/shared-chunks/api-AYt3zE12.js +310 -0
- package/dist/dev/packages/shared-chunks/{api-BQMslHhq.js → api-WvJPuo9z.js} +4 -5
- package/dist/dev/packages/shared-chunks/{args-proxy-DgXMc9b5.js → args-proxy-BNLuRFlO.js} +2 -4
- package/dist/dev/packages/shared-chunks/{array-D8PfjQHi.js → array-Bh_kUjzy.js} +2 -1
- package/dist/dev/packages/shared-chunks/cache-B7dqAS38.js +596 -0
- package/dist/dev/packages/shared-chunks/{capabilities-O_xc7Yqk.js → capabilities-CZkuOqqC.js} +0 -5
- package/dist/dev/packages/shared-chunks/chain-tags-D6tuFUj_.js +190 -0
- package/dist/dev/packages/shared-chunks/{collections-D_nY_0UJ.js → collections-DPkjqeA3.js} +0 -1
- package/dist/dev/packages/shared-chunks/{compiler-D1leQ3Gl.js → compiler-CXB_8GdR.js} +7043 -234
- package/dist/dev/packages/shared-chunks/computed-CJnghmXC.js +980 -0
- package/dist/dev/packages/shared-chunks/container-BzzHmCNj.js +404 -0
- package/dist/dev/packages/shared-chunks/curly-CvC8E_4-.js +617 -0
- package/dist/dev/packages/shared-chunks/{fragment-Cc5k9Oy4.js → curried-BVwSNqpf.js} +5 -288
- package/dist/dev/packages/shared-chunks/decorator-B5Uh5NFI.js +135 -0
- package/dist/dev/packages/shared-chunks/element-C-QcIABg.js +109 -0
- package/dist/dev/packages/shared-chunks/element-builder-kHVx0F__.js +812 -0
- package/dist/dev/packages/shared-chunks/env-g-kaAFLN.js +161 -0
- package/dist/dev/packages/shared-chunks/events-6aFVjD4k.js +180 -0
- package/dist/dev/packages/shared-chunks/get-CpJjYeJO.js +138 -0
- package/dist/dev/packages/shared-chunks/get-debug-name-CSniHBsn.js +45 -0
- package/dist/dev/packages/shared-chunks/get_properties-CIm8IAtP.js +55 -0
- package/dist/dev/packages/shared-chunks/guid-Cbq2sNV_.js +123 -0
- package/dist/dev/packages/shared-chunks/hash-D3BENmhU.js +192 -0
- package/dist/dev/packages/shared-chunks/helper-DlC4YesW.js +314 -0
- package/dist/dev/packages/shared-chunks/index-CTxkmV78.js +2500 -0
- package/dist/dev/packages/shared-chunks/index-D-xTBV4B.js +220 -0
- package/dist/dev/packages/shared-chunks/{index-BUPd6pkm.js → index-DmGmwWPJ.js} +29 -29
- package/dist/dev/packages/shared-chunks/injected_property-B4T-FzZZ.js +70 -0
- package/dist/dev/packages/shared-chunks/intern-zquhAEIg.js +51 -0
- package/dist/dev/packages/shared-chunks/internal-CbQSKXEm.js +140 -0
- package/dist/dev/packages/shared-chunks/internal-helper-Dsl9_7H_.js +7 -0
- package/dist/dev/packages/shared-chunks/{neq-DujMPv1k.js → invoke-B6j6DdDz.js} +4 -32
- package/dist/{prod/packages/shared-chunks/is_proxy-Cr1qlMv_.js → dev/packages/shared-chunks/is_proxy-Bzg0d4m4.js} +1 -1
- package/dist/dev/packages/shared-chunks/libraries-CHBwbR72.js +79 -0
- package/dist/dev/packages/shared-chunks/mandatory-setter-BpbAMTzV.js +107 -0
- package/dist/dev/packages/shared-chunks/meta-BmRXesrk.js +46 -0
- package/dist/{prod/packages/shared-chunks/name-C68GLLO3.js → dev/packages/shared-chunks/name-Clp4Vsod.js} +1 -1
- package/dist/dev/packages/shared-chunks/{namespace_search-uT8odThF.js → namespace_search-BfvzEQzN.js} +1 -2
- package/dist/dev/packages/shared-chunks/normalize-CKySQVU7.js +84 -0
- package/dist/dev/packages/shared-chunks/observers-C2DurkLG.js +199 -0
- package/dist/dev/packages/shared-chunks/on-D8QwT-eN.js +253 -0
- package/dist/dev/packages/shared-chunks/opcode-metadata-9iSW5JGP.js +285 -0
- package/dist/dev/packages/shared-chunks/opcodes-CplRyHl_.js +50 -0
- package/dist/dev/packages/shared-chunks/or-DBU9Ge4r.js +118 -0
- package/dist/{prod/packages/shared-chunks/program-B7SJZ5NF.js → dev/packages/shared-chunks/program-DzAfcWFj.js} +1 -1
- package/dist/{prod/packages/shared-chunks/program-context-DFiwaPMR.js → dev/packages/shared-chunks/program-context-CqcQMsfa.js} +3 -3
- package/dist/dev/packages/shared-chunks/property_get-CIBS9umw.js +139 -0
- package/dist/dev/packages/shared-chunks/{property_set-DaoZXGM5.js → property_set-D3PKyisF.js} +4 -2
- package/dist/dev/packages/shared-chunks/props-fiqxqhAH.js +85 -0
- package/dist/dev/packages/shared-chunks/{reference-C3TKDRnP.js → reference-BoPB2LfI.js} +3 -4
- package/dist/dev/packages/shared-chunks/{registers-ylirb0dq.js → registers-DoamZwaG.js} +1 -1
- package/dist/{prod/packages/shared-chunks/rehydrate-builder-D3t52iGR.js → dev/packages/shared-chunks/rehydrate-builder-DdzXTaJk.js} +7 -4
- package/dist/dev/packages/shared-chunks/{render-DCchifOK.js → render-DDdabL30.js} +510 -15
- package/dist/{prod/packages/shared-chunks/serialize-builder-iXiRs1Pg.js → dev/packages/shared-chunks/serialize-builder-B3u9Wr3n.js} +2 -7
- package/dist/dev/packages/shared-chunks/set_properties-BghuuGJx.js +48 -0
- package/dist/dev/packages/shared-chunks/{setup-registry-DxchCIL2.js → setup-registry-XxD0xvgf.js} +34 -14
- package/dist/dev/packages/shared-chunks/spec-BXl1reqK.js +16 -0
- package/dist/dev/packages/shared-chunks/super-BBBjgF69.js +91 -0
- package/dist/dev/packages/shared-chunks/template-BRrQR6KS.js +16 -0
- package/dist/dev/packages/shared-chunks/template-only-Yluyu0DY.js +78 -0
- package/dist/dev/packages/shared-chunks/textarea-C0Us0PNJ.js +468 -0
- package/dist/dev/packages/shared-chunks/tracked-CKE4wnE6.js +148 -0
- package/dist/dev/packages/shared-chunks/tracked-data-CGnA4ytZ.js +31 -0
- package/dist/dev/packages/shared-chunks/transform-resolutions-h1ik8gqW.js +645 -0
- package/dist/dev/packages/shared-chunks/unique-id-A83bjEE-.js +32 -0
- package/dist/{prod/packages/shared-chunks/on-CersD7PL.js → dev/packages/shared-chunks/untouchable-this-cH6_N2LJ.js} +215 -1397
- package/dist/dev/packages/shared-chunks/well-known-_EVO9RaV.js +17 -0
- package/dist/prod/packages/@ember/-internals/container/index.js +5 -315
- package/dist/prod/packages/@ember/-internals/deprecations/index.js +1 -1
- package/dist/prod/packages/@ember/-internals/environment/index.js +3 -158
- package/dist/prod/packages/@ember/-internals/glimmer/index.js +14 -13
- package/dist/prod/packages/@ember/-internals/meta/lib/meta.js +1 -2
- package/dist/prod/packages/@ember/-internals/metal/index.js +19 -13
- package/dist/prod/packages/@ember/-internals/routing/index.js +2 -6
- package/dist/prod/packages/@ember/-internals/runtime/lib/ext/rsvp.js +1 -1
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +10 -10
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +2 -6
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +1 -1
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +3 -6
- package/dist/prod/packages/@ember/-internals/string/index.js +0 -2
- package/dist/prod/packages/@ember/-internals/utils/index.js +33 -30
- package/dist/prod/packages/@ember/-internals/views/lib/compat/fallback-view-registry.js +0 -2
- package/dist/prod/packages/@ember/-internals/views/lib/mixins/action_support.js +2 -6
- package/dist/prod/packages/@ember/-internals/views/lib/system/event_dispatcher.js +3 -7
- package/dist/prod/packages/@ember/-internals/views/lib/system/utils.js +2 -2
- package/dist/prod/packages/@ember/-internals/views/lib/views/core_view.js +1 -14
- package/dist/prod/packages/@ember/-internals/views/lib/views/states.js +1 -2
- package/dist/prod/packages/@ember/application/index.js +5 -24
- package/dist/prod/packages/@ember/application/instance.js +6 -18
- package/dist/prod/packages/@ember/application/namespace.js +5 -8
- package/dist/prod/packages/@ember/array/index.js +8 -12
- package/dist/prod/packages/@ember/array/proxy.js +10 -10
- package/dist/prod/packages/@ember/canary-features/index.js +1 -1
- package/dist/prod/packages/@ember/component/helper.js +1 -12
- package/dist/prod/packages/@ember/component/index.js +1292 -15
- package/dist/prod/packages/@ember/component/template-only.js +1 -6
- package/dist/prod/packages/@ember/controller/index.js +3 -16
- package/dist/prod/packages/@ember/debug/container-debug-adapter.js +1 -15
- package/dist/prod/packages/@ember/debug/data-adapter.js +5 -7
- package/dist/prod/packages/@ember/debug/index.js +1 -1
- package/dist/prod/packages/@ember/debug/lib/deprecate.js +1 -1
- package/dist/prod/packages/@ember/engine/index.js +4 -25
- package/dist/prod/packages/@ember/engine/instance.js +4 -9
- package/dist/prod/packages/@ember/helper/index.js +169 -19
- package/dist/prod/packages/@ember/instrumentation/index.js +1 -1
- package/dist/prod/packages/@ember/modifier/index.js +2 -14
- package/dist/prod/packages/@ember/modifier/on.js +1 -6
- package/dist/prod/packages/@ember/object/-internals.js +3 -6
- package/dist/prod/packages/@ember/object/compat.js +4 -7
- package/dist/prod/packages/@ember/object/computed.js +2 -8
- package/dist/prod/packages/@ember/object/core.js +9 -15
- package/dist/prod/packages/@ember/object/evented.js +2 -7
- package/dist/prod/packages/@ember/object/events.js +1 -6
- package/dist/prod/packages/@ember/object/index.js +10 -12
- package/dist/prod/packages/@ember/object/internals.js +3 -6
- package/dist/prod/packages/@ember/object/lib/computed/computed_macros.js +6 -20
- package/dist/prod/packages/@ember/object/lib/computed/reduce_computed_macros.js +3 -9
- package/dist/prod/packages/@ember/object/mixin.js +7 -9
- package/dist/prod/packages/@ember/object/observable.js +8 -9
- package/dist/prod/packages/@ember/object/observers.js +1 -6
- package/dist/prod/packages/@ember/object/promise-proxy-mixin.js +3 -9
- package/dist/prod/packages/@ember/object/proxy.js +0 -7
- package/dist/prod/packages/@ember/reactive/collections.js +589 -1
- package/dist/prod/packages/@ember/renderer/index.js +1 -12
- package/dist/prod/packages/@ember/routing/history-location.js +1 -1
- package/dist/prod/packages/@ember/routing/index.js +581 -12
- package/dist/prod/packages/@ember/routing/lib/dsl.js +1 -1
- package/dist/prod/packages/@ember/routing/lib/generate_controller.js +2 -6
- package/dist/prod/packages/@ember/routing/lib/routing-service.js +5 -14
- package/dist/prod/packages/@ember/routing/lib/utils.js +2 -6
- package/dist/prod/packages/@ember/routing/none-location.js +1 -1
- package/dist/prod/packages/@ember/routing/route.js +12 -21
- package/dist/prod/packages/@ember/routing/router-service.js +6 -14
- package/dist/prod/packages/@ember/routing/router.js +5 -17
- package/dist/prod/packages/@ember/runloop/index.js +2 -6
- package/dist/prod/packages/@ember/service/index.js +1 -7
- package/dist/prod/packages/@ember/template/index.js +1 -12
- package/dist/prod/packages/@ember/template-compiler/lib/compile-options.js +13 -14
- package/dist/prod/packages/@ember/template-compiler/lib/dasherize-component-name.js +0 -2
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-against-attrs.js +1 -1
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-against-named-outlets.js +1 -1
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-input-helper-without-block.js +1 -1
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-reserved-named-arguments.js +1 -1
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/auto-import-builtins.js +13 -60
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/index.js +1 -1
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-each-track-array.js +1 -1
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-in-element.js +1 -1
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-resolutions.js +127 -4
- package/dist/prod/packages/@ember/template-compiler/lib/template.js +2 -7
- package/dist/prod/packages/@ember/template-factory/index.js +1 -5
- package/dist/prod/packages/@ember/utils/lib/compare.js +1 -8
- package/dist/prod/packages/@ember/utils/lib/is_empty.js +1 -7
- package/dist/prod/packages/@glimmer/manager/index.js +4 -292
- package/dist/prod/packages/@glimmer/node/index.js +3 -8
- package/dist/prod/packages/@glimmer/opcode-compiler/index.js +5 -5
- package/dist/prod/packages/@glimmer/program/index.js +194 -3
- package/dist/prod/packages/@glimmer/reference/index.js +4 -4
- package/dist/prod/packages/@glimmer/runtime/index.js +16 -8
- package/dist/prod/packages/@glimmer/tracking/index.js +2 -7
- package/dist/prod/packages/@glimmer/tracking/primitives/cache/index.js +1 -6
- package/dist/prod/packages/@glimmer/util/index.js +2 -2
- package/dist/prod/packages/@glimmer/validator/index.js +5 -1016
- package/dist/prod/packages/@glimmer/vm/index.js +1 -1
- package/dist/prod/packages/@glimmer/wire-format/index.js +3 -65
- package/dist/prod/packages/ember/version.js +1 -1
- package/dist/prod/packages/ember-template-compiler/index.js +5 -7
- package/dist/prod/packages/shared-chunks/{alias-BLBQkche.js → alias-CLuFeKoV.js} +8 -6
- package/dist/prod/packages/shared-chunks/api-CM1trl_4.js +289 -0
- package/dist/prod/packages/shared-chunks/{api-B5UrgITK.js → api-zh_k31vb.js} +4 -5
- package/dist/prod/packages/shared-chunks/{args-proxy-Dl0A0YWI.js → args-proxy-BDXbXCF9.js} +2 -2
- package/dist/prod/packages/shared-chunks/{array-kVQfzrQn.js → array-DHdr4__s.js} +3 -3
- package/dist/prod/packages/shared-chunks/assert-CUCJBR2C.js +19 -0
- package/dist/prod/packages/shared-chunks/cache-BIlOoPA7.js +371 -0
- package/dist/prod/packages/shared-chunks/{capabilities-DXA-L0iT.js → capabilities-_5e35539.js} +0 -3
- package/dist/prod/packages/shared-chunks/chain-tags-BJqcuCM1.js +179 -0
- package/dist/prod/packages/shared-chunks/{compiler-Bbki2GT_.js → compiler-DjQtTQGk.js} +7045 -193
- package/dist/prod/packages/shared-chunks/{namespace_search-Dcdalhj6.js → computed-2Udcmflw.js} +109 -239
- package/dist/prod/packages/shared-chunks/container-D5NwW5Fd.js +316 -0
- package/dist/prod/packages/shared-chunks/curly-BsqvV8G0.js +546 -0
- package/dist/prod/packages/shared-chunks/{fragment-D7nBU9ae.js → curried-BVwSNqpf.js} +6 -303
- package/dist/prod/packages/shared-chunks/debug-render-tree-BLtnOSbb.js +2049 -0
- package/dist/prod/packages/shared-chunks/{decorator-BdDDBUd2.js → decorator-DBCISop4.js} +1 -1
- package/dist/prod/packages/shared-chunks/element-BjFr0tO0.js +101 -0
- package/dist/prod/packages/shared-chunks/{element-builder-CzXb9l1W.js → element-builder-BPjq0rxK.js} +109 -88
- package/dist/prod/packages/shared-chunks/env-DXxsTFkM.js +158 -0
- package/dist/prod/packages/shared-chunks/events-970OxD6Q.js +175 -0
- package/dist/prod/packages/shared-chunks/get-D5wxdTkY.js +138 -0
- package/dist/prod/packages/shared-chunks/get_properties-BcAC5sGx.js +55 -0
- package/dist/prod/packages/shared-chunks/guid-Cbq2sNV_.js +123 -0
- package/dist/prod/packages/shared-chunks/hash-DcUe-meU.js +192 -0
- package/dist/prod/packages/shared-chunks/helper-Da672z4a.js +299 -0
- package/dist/prod/packages/shared-chunks/{index-CjaDF9kC.js → index--2U-v2nf.js} +18 -10
- package/dist/prod/packages/shared-chunks/index-D-xTBV4B.js +220 -0
- package/dist/prod/packages/shared-chunks/index-D87qoERP.js +2322 -0
- package/dist/prod/packages/shared-chunks/{injected_property-CTVs5FPh.js → injected_property-D9B-fPiH.js} +3 -3
- package/dist/prod/packages/shared-chunks/intern-zquhAEIg.js +51 -0
- package/dist/prod/packages/shared-chunks/internal-DidurjJB.js +137 -0
- package/dist/prod/packages/shared-chunks/internal-helper-DIbr1RgC.js +7 -0
- package/dist/prod/packages/shared-chunks/{neq-BqdovTuC.js → invoke-Dr_CRwA_.js} +4 -24
- package/dist/{dev/packages/shared-chunks/is_proxy-B0smdQy8.js → prod/packages/shared-chunks/is_proxy-Bzg0d4m4.js} +1 -1
- package/dist/prod/packages/shared-chunks/libraries-DaXpIDYN.js +60 -0
- package/dist/prod/packages/shared-chunks/meta-B9mldqPL.js +36 -0
- package/dist/{dev/packages/shared-chunks/name-Z7dpqvzn.js → prod/packages/shared-chunks/name-Clp4Vsod.js} +1 -1
- package/dist/prod/packages/shared-chunks/namespace_search-BfvzEQzN.js +134 -0
- package/dist/prod/packages/shared-chunks/normalize-D9jDJVGg.js +84 -0
- package/dist/prod/packages/shared-chunks/observers-Co4JALkS.js +199 -0
- package/dist/prod/packages/shared-chunks/on-C3ZQiUUD.js +228 -0
- package/dist/prod/packages/shared-chunks/opcode-metadata-9iSW5JGP.js +285 -0
- package/dist/prod/packages/shared-chunks/opcodes-CplRyHl_.js +50 -0
- package/dist/prod/packages/shared-chunks/or-oTVMuHc8.js +91 -0
- package/dist/{dev/packages/shared-chunks/program-DfV0v8aa.js → prod/packages/shared-chunks/program-B7CWdS8W.js} +1 -2
- package/dist/{dev/packages/shared-chunks/program-context-sJz0oHOA.js → prod/packages/shared-chunks/program-context-CGMN-aQM.js} +3 -3
- package/dist/prod/packages/shared-chunks/property_get-hWJ0nGhW.js +122 -0
- package/dist/prod/packages/shared-chunks/{property_set-B2sZxeCw.js → property_set-Dj5-ScWk.js} +4 -5
- package/dist/prod/packages/shared-chunks/props-fiqxqhAH.js +85 -0
- package/dist/prod/packages/shared-chunks/{reference-BNqcwZWH.js → reference-BshxG6wn.js} +3 -3
- package/dist/prod/packages/shared-chunks/{registers-ylirb0dq.js → registers-DoamZwaG.js} +1 -1
- package/dist/{dev/packages/shared-chunks/rehydrate-builder-BRH0p0wA.js → prod/packages/shared-chunks/rehydrate-builder-BKg2X6Lo.js} +7 -7
- package/dist/prod/packages/shared-chunks/{render-D78XHdek.js → render-nx5-PsDW.js} +487 -12
- package/dist/{dev/packages/shared-chunks/serialize-builder-DiO7Ak9_.js → prod/packages/shared-chunks/serialize-builder-BGbC30SN.js} +2 -10
- package/dist/prod/packages/shared-chunks/set_properties-oPyURk67.js +48 -0
- package/dist/prod/packages/shared-chunks/{setup-registry-Cs-7NIJU.js → setup-registry-TiaKLj5k.js} +35 -13
- package/dist/prod/packages/shared-chunks/spec-BXl1reqK.js +16 -0
- package/dist/prod/packages/shared-chunks/super-BBBjgF69.js +91 -0
- package/dist/prod/packages/shared-chunks/template-BRrQR6KS.js +16 -0
- package/dist/prod/packages/shared-chunks/template-only-BtLl0uH0.js +78 -0
- package/dist/prod/packages/shared-chunks/textarea-CPKZ1c_O.js +455 -0
- package/dist/prod/packages/shared-chunks/{tracked-Cl5l4v8b.js → tracked-CffAABMz.js} +6 -4
- package/dist/prod/packages/shared-chunks/tracked-data-C83f5V5S.js +31 -0
- package/dist/prod/packages/shared-chunks/unique-id-CfHImDRV.js +32 -0
- package/dist/prod/packages/shared-chunks/well-known-_EVO9RaV.js +17 -0
- package/docs/data.json +1263 -1029
- package/package.json +1 -1
- package/types/stable/@ember/-internals/container/lib/registry.d.ts +1 -1
- package/types/stable/@ember/-internals/deprecations/index.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/index.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/curly.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/mount.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/outlet.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/route-template.d.ts +2 -2
- package/types/stable/@ember/-internals/glimmer/lib/component.d.ts +9 -7
- package/types/stable/@ember/-internals/glimmer/lib/components/abstract-input.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/dom.d.ts +6 -2
- package/types/stable/@ember/-internals/glimmer/lib/environment.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/helper.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/renderer.d.ts +3 -3
- package/types/stable/@ember/-internals/glimmer/lib/setup-registry.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/utils/bindings.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/utils/curly-component-state-bucket.d.ts +3 -2
- package/types/stable/@ember/-internals/glimmer/lib/utils/iterator.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/utils/managers.d.ts +2 -1
- package/types/stable/@ember/-internals/glimmer/lib/utils/serialization-first-node-helpers.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/utils/string.d.ts +1 -1
- package/types/stable/@ember/-internals/meta/lib/meta.d.ts +3 -2
- package/types/stable/@ember/-internals/metal/lib/cache.d.ts +1 -1
- package/types/stable/@ember/-internals/metal/lib/chain-tags.d.ts +3 -2
- package/types/stable/@ember/-internals/metal/lib/computed.d.ts +1 -1
- package/types/stable/@ember/-internals/metal/lib/decorator.d.ts +1 -1
- package/types/stable/@ember/-internals/metal/lib/deprecate_property.d.ts +1 -1
- package/types/stable/@ember/-internals/metal/lib/events.d.ts +1 -1
- package/types/stable/@ember/-internals/metal/lib/observer.d.ts +1 -1
- package/types/stable/@ember/-internals/metal/lib/properties.d.ts +1 -1
- package/types/stable/@ember/-internals/metal/lib/property_events.d.ts +1 -1
- package/types/stable/@ember/-internals/metal/lib/tags.d.ts +2 -1
- package/types/stable/@ember/-internals/runtime/lib/mixins/container_proxy.d.ts +1 -1
- package/types/stable/@ember/-internals/runtime/lib/mixins/registry_proxy.d.ts +1 -1
- package/types/stable/@ember/-internals/utils/lib/is_proxy.d.ts +1 -1
- package/types/stable/@ember/-internals/utils/lib/mandatory-setter.d.ts +1 -1
- package/types/stable/@ember/-internals/views/lib/system/utils.d.ts +1 -1
- package/types/stable/@ember/-internals/views/lib/views/core_view.d.ts +2 -2
- package/types/stable/@ember/-internals/views/lib/views/states.d.ts +1 -1
- package/types/stable/@ember/application/index.d.ts +5 -4
- package/types/stable/@ember/application/instance.d.ts +4 -3
- package/types/stable/@ember/application/namespace.d.ts +1 -1
- package/types/stable/@ember/array/proxy.d.ts +4 -3
- package/types/stable/@ember/component/helper.d.ts +1 -1
- package/types/stable/@ember/component/index.d.ts +6 -3
- package/types/stable/@ember/controller/index.d.ts +2 -2
- package/types/stable/@ember/debug/container-debug-adapter.d.ts +1 -1
- package/types/stable/@ember/engine/index.d.ts +3 -3
- package/types/stable/@ember/engine/instance.d.ts +4 -3
- package/types/stable/@ember/helper/index.d.ts +177 -5
- package/types/stable/@ember/modifier/index.d.ts +1 -1
- package/types/stable/@ember/object/-internals.d.ts +2 -2
- package/types/stable/@ember/object/compat.d.ts +2 -2
- package/types/stable/@ember/object/computed.d.ts +3 -1
- package/types/stable/@ember/object/evented.d.ts +1 -1
- package/types/stable/@ember/object/events.d.ts +1 -1
- package/types/stable/@ember/object/index.d.ts +8 -2
- package/types/stable/@ember/object/lib/computed/computed_macros.d.ts +1 -1
- package/types/stable/@ember/object/mixin.d.ts +1 -1
- package/types/stable/@ember/object/observers.d.ts +1 -1
- package/types/stable/@ember/object/proxy.d.ts +1 -1
- package/types/stable/@ember/reactive/collections.d.ts +6 -6
- package/types/stable/@ember/renderer/index.d.ts +2 -2
- package/types/stable/@ember/routing/index.d.ts +1 -1
- package/types/stable/@ember/routing/lib/controller_for.d.ts +2 -2
- package/types/stable/@ember/routing/route.d.ts +2 -2
- package/types/stable/@ember/routing/router.d.ts +2 -2
- package/types/stable/@ember/service/index.d.ts +1 -1
- package/types/stable/@ember/template/index.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/dasherize-component-name.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/assert-against-attrs.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/assert-against-named-outlets.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/assert-input-helper-without-block.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/assert-reserved-named-arguments.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/auto-import-builtins.d.ts +1 -4
- package/types/stable/@ember/template-compiler/lib/plugins/transform-action-syntax.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/transform-each-in-into-each.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/transform-each-track-array.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/transform-in-element.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/transform-resolutions.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/transform-wrap-mount-and-outlet.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/plugins/utils.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/system/calculate-location-display.d.ts +1 -1
- package/types/stable/@ember/template-compiler/lib/types.d.ts +2 -1
- package/types/stable/@ember/template-factory/index.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/builder/builder-interface.d.ts +2 -2
- package/types/stable/@glimmer/compiler/lib/builder/builder.d.ts +2 -2
- package/types/stable/@glimmer/compiler/lib/compiler.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/context.d.ts +2 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/index.d.ts +2 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/keywords/impl.d.ts +2 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/keywords/utils/curry.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/keywords/utils/dynamic-vars.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/keywords/utils/has-block.d.ts +2 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/keywords/utils/if-unless.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/keywords/utils/log.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/visitors/element/classified.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/visitors/element/component.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/visitors/element/simple-element.d.ts +2 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/visitors/expressions.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/visitors/statements.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/1-normalization/visitors/strict-mode.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/2-encoding/expressions.d.ts +1 -1
- package/types/stable/@glimmer/compiler/lib/passes/2-encoding/mir.d.ts +3 -1
- package/types/stable/@glimmer/compiler/lib/shared/result.d.ts +1 -1
- package/types/stable/@glimmer/manager/lib/public/component.d.ts +1 -1
- package/types/stable/@glimmer/manager/lib/util/args-proxy.d.ts +1 -1
- package/types/stable/@glimmer/manager/lib/util/capabilities.d.ts +1 -1
- package/types/stable/@glimmer/node/lib/node-dom-helper.d.ts +1 -1
- package/types/stable/@glimmer/opcode-compiler/lib/opcode-builder/helpers/components.d.ts +1 -1
- package/types/stable/@glimmer/runtime/index.d.ts +7 -4
- package/types/stable/@glimmer/runtime/lib/compiled/expressions/concat.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/compiled/opcodes/-debug-strip.d.ts +4 -3
- package/types/stable/@glimmer/runtime/lib/compiled/opcodes/component.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/compiled/opcodes/dom.d.ts +2 -2
- package/types/stable/@glimmer/runtime/lib/compiled/opcodes/vm.d.ts +2 -2
- package/types/stable/@glimmer/runtime/lib/component/template-only.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/curried-value.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/helpers/and.d.ts +3 -0
- package/types/stable/@glimmer/runtime/lib/helpers/gt.d.ts +8 -0
- package/types/stable/@glimmer/runtime/lib/helpers/gte.d.ts +8 -0
- package/types/stable/@glimmer/runtime/lib/helpers/invoke.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/helpers/lt.d.ts +8 -0
- package/types/stable/@glimmer/runtime/lib/helpers/lte.d.ts +8 -0
- package/types/stable/@glimmer/runtime/lib/helpers/not.d.ts +3 -0
- package/types/stable/@glimmer/runtime/lib/helpers/or.d.ts +3 -0
- package/types/stable/@glimmer/runtime/lib/opcodes.d.ts +2 -2
- package/types/stable/@glimmer/runtime/lib/references/class-list.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/references/curry-value.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/render.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/scope.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/vm/append.d.ts +3 -2
- package/types/stable/@glimmer/runtime/lib/vm/arguments.d.ts +2 -2
- package/types/stable/@glimmer/runtime/lib/vm/content/text.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/vm/element-builder.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/vm/low-level.d.ts +2 -1
- package/types/stable/@glimmer/runtime/lib/vm/rehydrate-builder.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/vm/update.d.ts +2 -1
- package/types/stable/@glimmer/syntax/lib/keywords.d.ts +2 -2
- package/types/stable/@glimmer/tracking/index.d.ts +2 -1
- package/types/stable/@glimmer/tracking/primitives/cache.d.ts +1 -1
- package/types/stable/index.d.ts +7 -0
- package/dist/dev/packages/shared-chunks/constants-BbdWMvgs.js +0 -213
- package/dist/dev/packages/shared-chunks/dynamic-CgX8M02_.js +0 -3823
- package/dist/dev/packages/shared-chunks/element-builder-BpJIoi99.js +0 -404
- package/dist/dev/packages/shared-chunks/index-RzG0Jvjx.js +0 -6306
- package/dist/dev/packages/shared-chunks/mandatory-setter-DHZe7-kW.js +0 -425
- package/dist/dev/packages/shared-chunks/observers-Bj9qLVau.js +0 -2062
- package/dist/dev/packages/shared-chunks/set_properties-kVGzZL_a.js +0 -100
- package/dist/dev/packages/shared-chunks/transform-resolutions-D-YtZ0_g.js +0 -7458
- package/dist/prod/packages/shared-chunks/constants-DThhT5fu.js +0 -210
- package/dist/prod/packages/shared-chunks/index-r-Dz_hzt.js +0 -5931
- package/dist/prod/packages/shared-chunks/observers-tZ2aOzr4.js +0 -714
- package/dist/prod/packages/shared-chunks/set_properties-C1T46IiN.js +0 -101
- package/dist/prod/packages/shared-chunks/super-Cm_a_cLQ.js +0 -275
- package/dist/prod/packages/shared-chunks/transform-resolutions-DR4GLmR2.js +0 -6936
- package/dist/prod/packages/shared-chunks/{collections-GpG8lT2g.js → collections-C3Y8z_9v.js} +9 -9
|
@@ -1,3823 +0,0 @@
|
|
|
1
|
-
import { r as VM_SYSCALL_SIZE, C as CURRIED_COMPONENT, s as VM_CHILD_SCOPE_OP, t as VM_POP_SCOPE_OP, u as VM_PUSH_DYNAMIC_SCOPE_OP, v as VM_POP_DYNAMIC_SCOPE_OP, w as VM_CONSTANT_OP, x as decodeHandle, y as VM_CONSTANT_REFERENCE_OP, z as VM_PRIMITIVE_OP, A as isHandle, B as decodeImmediate, D as VM_PRIMITIVE_REFERENCE_OP, E as VM_DUP_OP, F as VM_POP_OP, G as VM_LOAD_OP, H as VM_FETCH_OP, I as VM_BIND_DYNAMIC_SCOPE_OP, J as VM_ENTER_OP, K as VM_EXIT_OP, L as VM_PUSH_SYMBOL_TABLE_OP, M as VM_PUSH_BLOCK_SCOPE_OP, N as VM_COMPILE_BLOCK_OP, O as VM_INVOKE_YIELD_OP, P as VM_JUMP_IF_OP, Q as VM_JUMP_UNLESS_OP, R as VM_JUMP_EQ_OP, b as VM_ASSERT_SAME_OP, S as VM_TO_BOOLEAN_OP, T as VM_TEXT_OP, U as VM_COMMENT_OP, W as VM_OPEN_ELEMENT_OP, X as VM_OPEN_DYNAMIC_ELEMENT_OP, Y as VM_PUSH_REMOTE_ELEMENT_OP, Z as VM_POP_REMOTE_ELEMENT_OP, _ as VM_FLUSH_ELEMENT_OP, $ as VM_CLOSE_ELEMENT_OP, a0 as VM_MODIFIER_OP, a1 as VM_DYNAMIC_MODIFIER_OP, a2 as VM_STATIC_ATTR_OP, a3 as VM_DYNAMIC_ATTR_OP, a4 as CURRIED_MODIFIER, a5 as VM_PUSH_COMPONENT_DEFINITION_OP, a6 as VM_RESOLVE_DYNAMIC_COMPONENT_OP, f as VM_RESOLVE_CURRIED_COMPONENT_OP, g as VM_PUSH_DYNAMIC_COMPONENT_INSTANCE_OP, a7 as VM_PUSH_ARGS_OP, a8 as VM_PUSH_EMPTY_ARGS_OP, a9 as VM_CAPTURE_ARGS_OP, aa as VM_PREPARE_ARGS_OP, ab as VM_CREATE_COMPONENT_OP, ac as VM_REGISTER_COMPONENT_DESTRUCTOR_OP, ad as VM_BEGIN_COMPONENT_TRANSACTION_OP, ae as VM_PUT_COMPONENT_OPERATIONS_OP, af as VM_COMPONENT_ATTR_OP, ag as VM_STATIC_COMPONENT_ATTR_OP, ah as VM_DID_CREATE_ELEMENT_OP, ai as VM_GET_COMPONENT_SELF_OP, aj as VM_GET_COMPONENT_TAG_NAME_OP, ak as VM_GET_COMPONENT_LAYOUT_OP, V as VM_MAIN_OP, al as VM_POPULATE_LAYOUT_OP, am as VM_VIRTUAL_ROOT_SCOPE_OP, an as VM_SET_NAMED_VARIABLES_OP, ao as VM_SET_BLOCKS_OP, ap as VM_INVOKE_COMPONENT_LAYOUT_OP, aq as VM_DID_RENDER_LAYOUT_OP, ar as VM_COMMIT_COMPONENT_TRANSACTION_OP, as as VM_CURRY_OP, at as VM_DYNAMIC_HELPER_OP, au as CURRIED_HELPER, av as VM_HELPER_OP, aw as VM_GET_VARIABLE_OP, ax as VM_SET_VARIABLE_OP, ay as VM_SET_BLOCK_OP, az as VM_ROOT_SCOPE_OP, aA as VM_GET_PROPERTY_OP, aB as VM_GET_BLOCK_OP, aC as VM_SPREAD_BLOCK_OP, aD as VM_HAS_BLOCK_OP, aE as VM_HAS_BLOCK_PARAMS_OP, aF as VM_CONCAT_OP, aG as VM_IF_INLINE_OP, aH as VM_NOT_OP, aI as VM_GET_DYNAMIC_VAR_OP, aJ as VM_LOG_OP, a as VM_CONTENT_TYPE_OP, aK as VM_DYNAMIC_CONTENT_TYPE_OP, d as VM_APPEND_HTML_OP, h as VM_APPEND_SAFE_HTML_OP, e as VM_APPEND_TEXT_OP, i as VM_APPEND_DOCUMENT_FRAGMENT_OP, j as VM_APPEND_NODE_OP, aL as VM_DEBUGGER_OP, aM as VM_ENTER_LIST_OP, aN as VM_EXIT_LIST_OP, aO as VM_ITERATE_OP } from './fragment-Cc5k9Oy4.js';
|
|
2
|
-
import { d as debugToString } from './debug-to-string-CFb7h0lY.js';
|
|
3
|
-
import { u as unwrap, e as expect, a as isIndexable$1, S as StackImpl, d as dict, i as isDict } from './collections-D_nY_0UJ.js';
|
|
4
|
-
import { a as assign } from './object-utils-AijlD-JH.js';
|
|
5
|
-
import { toBool, debugAssert, setPath, getPath, warnIfStyleNotTrusted } from '../@glimmer/global-context/index.js';
|
|
6
|
-
import { CONSTANT_TAG, INITIAL, validateTag, consumeTag, valueForTag, beginTrackFrame, endTrackFrame, CURRENT_TAG, createUpdatableTag } from '../@glimmer/validator/index.js';
|
|
7
|
-
import { c as createComputeRef, v as valueForRef, a as createConstRef, d as createPrimitiveRef, i as isConstRef, U as UNDEFINED_REFERENCE, N as NULL_REFERENCE, T as TRUE_REFERENCE, F as FALSE_REFERENCE, R as REFERENCE, e as createDebugAliasRef, b as childRefFor, f as isInvokableRef, u as updateRef } from './reference-C3TKDRnP.js';
|
|
8
|
-
import { e as $v0, f as $t1, g as $t0, a as $pc, b as $ra, c as $fp, d as $sp, h as $s1, $ as $s0 } from './registers-ylirb0dq.js';
|
|
9
|
-
import { registerDestructor, destroy, associateDestroyableChild, _hasDestroyableChildren } from '../@glimmer/destroyable/index.js';
|
|
10
|
-
import { d as getInternalModifierManager, g as getInternalHelperManager, h as hasInternalComponentManager, f as hasInternalHelperManager, s as setInternalComponentManager, i as setInternalHelperManager, j as setInternalModifierManager } from './api-BQMslHhq.js';
|
|
11
|
-
import { m as managerHasCapability } from './capabilities-O_xc7Yqk.js';
|
|
12
|
-
import { ContentType } from '../@glimmer/vm/index.js';
|
|
13
|
-
import { createIteratorRef } from '../@glimmer/reference/index.js';
|
|
14
|
-
import { s as setLocalDebugType } from './debug-brand-B1TWjOCH.js';
|
|
15
|
-
import { b as EMPTY_STRING_ARRAY, e as enumerate, c as emptyArray } from './array-utils-CZQxrdD3.js';
|
|
16
|
-
import { a as assert } from './assert-CUCJBR2C.js';
|
|
17
|
-
import { a as unwrapTemplate } from './constants-BbdWMvgs.js';
|
|
18
|
-
import { I as InternalComponentCapabilities } from './flags-B9qxc-pB.js';
|
|
19
|
-
import { a as castToBrowser } from './simple-cast-DCvJLSin.js';
|
|
20
|
-
|
|
21
|
-
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
22
|
-
function buildUntouchableThis(source) {
|
|
23
|
-
let context = null;
|
|
24
|
-
{
|
|
25
|
-
let assertOnProperty = property => {
|
|
26
|
-
let access = typeof property === 'symbol' || typeof property === 'number' ? `[${String(property)}]` : `.${property}`;
|
|
27
|
-
throw new Error(`You accessed \`this${access}\` from a function passed to the ${source}, but the function itself was not bound to a valid \`this\` context. Consider updating to use a bound function (for instance, use an arrow function, \`() => {}\`).`);
|
|
28
|
-
};
|
|
29
|
-
context = new Proxy({}, {
|
|
30
|
-
get(_target, property) {
|
|
31
|
-
assertOnProperty(property);
|
|
32
|
-
},
|
|
33
|
-
set(_target, property) {
|
|
34
|
-
assertOnProperty(property);
|
|
35
|
-
return false;
|
|
36
|
-
},
|
|
37
|
-
has(_target, property) {
|
|
38
|
-
assertOnProperty(property);
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return context;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const ELEMENT_NODE = 1;
|
|
47
|
-
const TEXT_NODE = 3;
|
|
48
|
-
const COMMENT_NODE = 8;
|
|
49
|
-
const NS_MATHML = 'http://www.w3.org/1998/Math/MathML';
|
|
50
|
-
const NS_SVG = 'http://www.w3.org/2000/svg';
|
|
51
|
-
const INSERT_BEFORE_BEGIN = 'beforebegin';
|
|
52
|
-
const INSERT_BEFORE_END = 'beforeend';
|
|
53
|
-
|
|
54
|
-
function CheckInstanceof(Class) {
|
|
55
|
-
}
|
|
56
|
-
const CheckRegister = new class {
|
|
57
|
-
validate(value) {
|
|
58
|
-
switch (value) {
|
|
59
|
-
case $s0:
|
|
60
|
-
case $s1:
|
|
61
|
-
case $sp:
|
|
62
|
-
case $fp:
|
|
63
|
-
case $ra:
|
|
64
|
-
case $pc:
|
|
65
|
-
case $t0:
|
|
66
|
-
case $t1:
|
|
67
|
-
case $v0:
|
|
68
|
-
return true;
|
|
69
|
-
default:
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
expected() {
|
|
74
|
-
return `Register`;
|
|
75
|
-
}
|
|
76
|
-
}();
|
|
77
|
-
|
|
78
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
79
|
-
|
|
80
|
-
function check(value, checker, message) {
|
|
81
|
-
{
|
|
82
|
-
return value;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
class AppendOpcodes {
|
|
87
|
-
// This code is intentionally putting unsafe `null`s into the array that it
|
|
88
|
-
// will intentionally overwrite before anyone can see them.
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
90
|
-
evaluateOpcode = new Array(VM_SYSCALL_SIZE).fill(null);
|
|
91
|
-
constructor() {
|
|
92
|
-
}
|
|
93
|
-
add(name, evaluate, kind = 'syscall') {
|
|
94
|
-
this.evaluateOpcode[name] = {
|
|
95
|
-
syscall: kind !== 'machine',
|
|
96
|
-
evaluate
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
evaluate(vm, opcode, type) {
|
|
100
|
-
let operation = unwrap(this.evaluateOpcode[type]);
|
|
101
|
-
if (operation.syscall) {
|
|
102
|
-
(!(!opcode.isMachine) && assert(!opcode.isMachine, `BUG: Mismatch between operation.syscall (${operation.syscall}) and opcode.isMachine (${opcode.isMachine}) for ${opcode.type}`));
|
|
103
|
-
operation.evaluate(vm, opcode);
|
|
104
|
-
} else {
|
|
105
|
-
(!(opcode.isMachine) && assert(opcode.isMachine, `BUG: Mismatch between operation.syscall (${operation.syscall}) and opcode.isMachine (${opcode.isMachine}) for ${opcode.type}`));
|
|
106
|
-
operation.evaluate(vm.lowlevel, opcode);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function externs(vm) {
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
const APPEND_OPCODES = new AppendOpcodes();
|
|
114
|
-
|
|
115
|
-
const TYPE = Symbol('TYPE');
|
|
116
|
-
const INNER = Symbol('INNER');
|
|
117
|
-
const OWNER = Symbol('OWNER');
|
|
118
|
-
const ARGS = Symbol('ARGS');
|
|
119
|
-
const RESOLVED = Symbol('RESOLVED');
|
|
120
|
-
const CURRIED_VALUES = new WeakSet();
|
|
121
|
-
function isCurriedValue(value) {
|
|
122
|
-
return CURRIED_VALUES.has(value);
|
|
123
|
-
}
|
|
124
|
-
function isCurriedType(value, type) {
|
|
125
|
-
return isCurriedValue(value) && value[TYPE] === type;
|
|
126
|
-
}
|
|
127
|
-
class CurriedValue {
|
|
128
|
-
[TYPE];
|
|
129
|
-
[INNER];
|
|
130
|
-
[OWNER];
|
|
131
|
-
[ARGS];
|
|
132
|
-
[RESOLVED];
|
|
133
|
-
|
|
134
|
-
/** @internal */
|
|
135
|
-
constructor(type, inner, owner, args, resolved = false) {
|
|
136
|
-
CURRIED_VALUES.add(this);
|
|
137
|
-
this[TYPE] = type;
|
|
138
|
-
this[INNER] = inner;
|
|
139
|
-
this[OWNER] = owner;
|
|
140
|
-
this[ARGS] = args;
|
|
141
|
-
this[RESOLVED] = resolved;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function resolveCurriedValue(curriedValue) {
|
|
145
|
-
let currentWrapper = curriedValue;
|
|
146
|
-
let positional;
|
|
147
|
-
let named;
|
|
148
|
-
let definition, owner, resolved;
|
|
149
|
-
while (true) {
|
|
150
|
-
let {
|
|
151
|
-
[ARGS]: curriedArgs,
|
|
152
|
-
[INNER]: inner
|
|
153
|
-
} = currentWrapper;
|
|
154
|
-
if (curriedArgs !== null) {
|
|
155
|
-
let {
|
|
156
|
-
named: curriedNamed,
|
|
157
|
-
positional: curriedPositional
|
|
158
|
-
} = curriedArgs;
|
|
159
|
-
if (curriedPositional.length > 0) {
|
|
160
|
-
positional = positional === undefined ? curriedPositional : curriedPositional.concat(positional);
|
|
161
|
-
}
|
|
162
|
-
if (named === undefined) {
|
|
163
|
-
named = [];
|
|
164
|
-
}
|
|
165
|
-
named.unshift(curriedNamed);
|
|
166
|
-
}
|
|
167
|
-
if (!isCurriedValue(inner)) {
|
|
168
|
-
// Save off the owner that this helper was curried with. Later on,
|
|
169
|
-
// we'll fetch the value of this register and set it as the owner on the
|
|
170
|
-
// new root scope.
|
|
171
|
-
definition = inner;
|
|
172
|
-
owner = currentWrapper[OWNER];
|
|
173
|
-
resolved = currentWrapper[RESOLVED];
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
currentWrapper = inner;
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
definition,
|
|
180
|
-
owner,
|
|
181
|
-
resolved,
|
|
182
|
-
positional,
|
|
183
|
-
named
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function curry(type, spec, owner, args, resolved = false) {
|
|
187
|
-
return new CurriedValue(type, spec, owner, args, resolved);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function createCurryRef(type, inner, owner, args, resolver, isStrict) {
|
|
191
|
-
let lastValue, curriedDefinition;
|
|
192
|
-
return createComputeRef(() => {
|
|
193
|
-
let value = valueForRef(inner);
|
|
194
|
-
if (value === lastValue) {
|
|
195
|
-
return curriedDefinition;
|
|
196
|
-
}
|
|
197
|
-
if (isCurriedType(value, type)) {
|
|
198
|
-
curriedDefinition = args ? curry(type, value, owner, args) : args;
|
|
199
|
-
} else if (type === CURRIED_COMPONENT && typeof value === 'string' && value) {
|
|
200
|
-
// Only components should enter this path, as helpers and modifiers do not
|
|
201
|
-
// support string based resolution
|
|
202
|
-
|
|
203
|
-
{
|
|
204
|
-
if (isStrict) {
|
|
205
|
-
throw new Error(`Attempted to resolve a dynamic component with a string definition, \`${value}\` in a strict mode template. In strict mode, using strings to resolve component definitions is prohibited. You can instead import the component definition and use it directly.`);
|
|
206
|
-
}
|
|
207
|
-
let resolvedDefinition = expect(resolver).lookupComponent?.(value, owner) ?? null;
|
|
208
|
-
if (!resolvedDefinition) {
|
|
209
|
-
throw new Error(`Attempted to resolve \`${value}\`, which was expected to be a component, but nothing was found.`);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
curriedDefinition = curry(type, value, owner, args);
|
|
213
|
-
} else if (isIndexable$1(value)) {
|
|
214
|
-
curriedDefinition = curry(type, value, owner, args);
|
|
215
|
-
} else {
|
|
216
|
-
curriedDefinition = null;
|
|
217
|
-
}
|
|
218
|
-
lastValue = value;
|
|
219
|
-
return curriedDefinition;
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
class CursorImpl {
|
|
224
|
-
constructor(element, nextSibling) {
|
|
225
|
-
this.element = element;
|
|
226
|
-
this.nextSibling = nextSibling;
|
|
227
|
-
setLocalDebugType('cursor', this);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
class ConcreteBounds {
|
|
231
|
-
constructor(parentNode, first, last) {
|
|
232
|
-
this.parentNode = parentNode;
|
|
233
|
-
this.first = first;
|
|
234
|
-
this.last = last;
|
|
235
|
-
}
|
|
236
|
-
parentElement() {
|
|
237
|
-
return this.parentNode;
|
|
238
|
-
}
|
|
239
|
-
firstNode() {
|
|
240
|
-
return this.first;
|
|
241
|
-
}
|
|
242
|
-
lastNode() {
|
|
243
|
-
return this.last;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
function move(bounds, reference) {
|
|
247
|
-
let parent = bounds.parentElement();
|
|
248
|
-
let first = bounds.firstNode();
|
|
249
|
-
let last = bounds.lastNode();
|
|
250
|
-
let current = first;
|
|
251
|
-
while (true) {
|
|
252
|
-
let next = current.nextSibling;
|
|
253
|
-
parent.insertBefore(current, reference);
|
|
254
|
-
if (current === last) {
|
|
255
|
-
return next;
|
|
256
|
-
}
|
|
257
|
-
current = expect(next);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
function clear(bounds) {
|
|
261
|
-
let parent = bounds.parentElement();
|
|
262
|
-
let first = bounds.firstNode();
|
|
263
|
-
let last = bounds.lastNode();
|
|
264
|
-
let current = first;
|
|
265
|
-
while (true) {
|
|
266
|
-
let next = current.nextSibling;
|
|
267
|
-
parent.removeChild(current);
|
|
268
|
-
if (current === last) {
|
|
269
|
-
return next;
|
|
270
|
-
}
|
|
271
|
-
current = expect(next);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/** @internal */
|
|
276
|
-
function hasCustomDebugRenderTreeLifecycle(manager) {
|
|
277
|
-
return 'getDebugCustomRenderTree' in manager;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function resolveComponent(resolver, constants, name, owner) {
|
|
281
|
-
let definition = resolver?.lookupComponent?.(name, expect(owner)) ?? null;
|
|
282
|
-
if (!definition) {
|
|
283
|
-
throw new Error(`Attempted to resolve \`${name}\`, which was expected to be a component, but nothing was found.`);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
287
|
-
return constants.resolvedComponent(definition, name);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
let GUID = 0;
|
|
291
|
-
class Ref {
|
|
292
|
-
id = GUID++;
|
|
293
|
-
value;
|
|
294
|
-
constructor(value) {
|
|
295
|
-
this.value = value;
|
|
296
|
-
}
|
|
297
|
-
get() {
|
|
298
|
-
return this.value;
|
|
299
|
-
}
|
|
300
|
-
release() {
|
|
301
|
-
if (this.value === null) {
|
|
302
|
-
throw new Error('BUG: double release?');
|
|
303
|
-
}
|
|
304
|
-
this.value = null;
|
|
305
|
-
}
|
|
306
|
-
toString() {
|
|
307
|
-
let label = `Ref ${this.id}`;
|
|
308
|
-
if (this.value === null) {
|
|
309
|
-
return `${label} (released)`;
|
|
310
|
-
} else {
|
|
311
|
-
try {
|
|
312
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
313
|
-
return `${label}: ${this.value}`;
|
|
314
|
-
} catch {
|
|
315
|
-
return label;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
class DebugRenderTreeImpl {
|
|
321
|
-
stack = new StackImpl();
|
|
322
|
-
refs = new WeakMap();
|
|
323
|
-
roots = new Set();
|
|
324
|
-
nodes = new WeakMap();
|
|
325
|
-
begin() {
|
|
326
|
-
this.reset();
|
|
327
|
-
}
|
|
328
|
-
create(state, node) {
|
|
329
|
-
let internalNode = assign({}, node, {
|
|
330
|
-
bounds: null,
|
|
331
|
-
refs: new Set()
|
|
332
|
-
});
|
|
333
|
-
this.nodes.set(state, internalNode);
|
|
334
|
-
this.appendChild(internalNode, state);
|
|
335
|
-
this.enter(state);
|
|
336
|
-
}
|
|
337
|
-
update(state) {
|
|
338
|
-
this.enter(state);
|
|
339
|
-
}
|
|
340
|
-
didRender(state, bounds) {
|
|
341
|
-
if (this.stack.current !== state) {
|
|
342
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
343
|
-
throw new Error(`BUG: expecting ${this.stack.current}, got ${state}`);
|
|
344
|
-
}
|
|
345
|
-
this.nodeFor(state).bounds = bounds;
|
|
346
|
-
this.exit();
|
|
347
|
-
}
|
|
348
|
-
willDestroy(state) {
|
|
349
|
-
expect(this.refs.get(state)).release();
|
|
350
|
-
}
|
|
351
|
-
commit() {
|
|
352
|
-
this.reset();
|
|
353
|
-
}
|
|
354
|
-
capture() {
|
|
355
|
-
return this.captureRefs(this.roots);
|
|
356
|
-
}
|
|
357
|
-
reset() {
|
|
358
|
-
if (this.stack.size !== 0) {
|
|
359
|
-
// We probably encountered an error during the rendering loop. This will
|
|
360
|
-
// likely trigger undefined behavior and memory leaks as the error left
|
|
361
|
-
// things in an inconsistent state. It is recommended that the user
|
|
362
|
-
// refresh the page.
|
|
363
|
-
|
|
364
|
-
// TODO: We could warn here? But this happens all the time in our tests?
|
|
365
|
-
|
|
366
|
-
// Clean up the root reference to prevent errors from happening if we
|
|
367
|
-
// attempt to capture the render tree (Ember Inspector may do this)
|
|
368
|
-
let root = expect(this.stack.toArray()[0]);
|
|
369
|
-
let ref = this.refs.get(root);
|
|
370
|
-
if (ref !== undefined) {
|
|
371
|
-
this.roots.delete(ref);
|
|
372
|
-
}
|
|
373
|
-
while (!this.stack.isEmpty()) {
|
|
374
|
-
this.stack.pop();
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
enter(state) {
|
|
379
|
-
this.stack.push(state);
|
|
380
|
-
}
|
|
381
|
-
exit() {
|
|
382
|
-
if (this.stack.size === 0) {
|
|
383
|
-
throw new Error('BUG: unbalanced pop');
|
|
384
|
-
}
|
|
385
|
-
this.stack.pop();
|
|
386
|
-
}
|
|
387
|
-
nodeFor(state) {
|
|
388
|
-
return expect(this.nodes.get(state));
|
|
389
|
-
}
|
|
390
|
-
appendChild(node, state) {
|
|
391
|
-
if (this.refs.has(state)) {
|
|
392
|
-
throw new Error('BUG: child already appended');
|
|
393
|
-
}
|
|
394
|
-
let parent = this.stack.current;
|
|
395
|
-
let ref = new Ref(state);
|
|
396
|
-
this.refs.set(state, ref);
|
|
397
|
-
if (parent) {
|
|
398
|
-
let parentNode = this.nodeFor(parent);
|
|
399
|
-
parentNode.refs.add(ref);
|
|
400
|
-
node.parent = parentNode;
|
|
401
|
-
} else {
|
|
402
|
-
this.roots.add(ref);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
captureRefs(refs) {
|
|
406
|
-
let captured = [];
|
|
407
|
-
refs.forEach(ref => {
|
|
408
|
-
let state = ref.get();
|
|
409
|
-
if (state) {
|
|
410
|
-
captured.push(this.captureNode(`render-node:${ref.id}`, state));
|
|
411
|
-
} else {
|
|
412
|
-
refs.delete(ref);
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
return captured;
|
|
416
|
-
}
|
|
417
|
-
captureNode(id, state) {
|
|
418
|
-
let node = this.nodeFor(state);
|
|
419
|
-
let {
|
|
420
|
-
type,
|
|
421
|
-
name,
|
|
422
|
-
args,
|
|
423
|
-
instance,
|
|
424
|
-
refs
|
|
425
|
-
} = node;
|
|
426
|
-
let bounds = this.captureBounds(node);
|
|
427
|
-
let children = this.captureRefs(refs);
|
|
428
|
-
return {
|
|
429
|
-
id,
|
|
430
|
-
type,
|
|
431
|
-
name,
|
|
432
|
-
args: reifyArgsDebug(args),
|
|
433
|
-
instance,
|
|
434
|
-
bounds,
|
|
435
|
-
children
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
captureBounds(node) {
|
|
439
|
-
let bounds = expect(node.bounds);
|
|
440
|
-
let parentElement = bounds.parentElement();
|
|
441
|
-
let firstNode = bounds.firstNode();
|
|
442
|
-
let lastNode = bounds.lastNode();
|
|
443
|
-
return {
|
|
444
|
-
parentElement,
|
|
445
|
-
firstNode,
|
|
446
|
-
lastNode
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
function getDebugName(definition, manager = definition.manager) {
|
|
451
|
-
return definition.resolvedName ?? definition.debugName ?? manager.getDebugName(definition.state);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
function normalizeStringValue(value) {
|
|
455
|
-
if (isEmpty$1(value)) {
|
|
456
|
-
return '';
|
|
457
|
-
}
|
|
458
|
-
return String(value);
|
|
459
|
-
}
|
|
460
|
-
function shouldCoerce(value) {
|
|
461
|
-
return isString(value) || isEmpty$1(value) || typeof value === 'boolean' || typeof value === 'number';
|
|
462
|
-
}
|
|
463
|
-
function isEmpty$1(value) {
|
|
464
|
-
return value === null || value === undefined || typeof value.toString !== 'function';
|
|
465
|
-
}
|
|
466
|
-
function isIndexable(value) {
|
|
467
|
-
return value !== null && typeof value === 'object';
|
|
468
|
-
}
|
|
469
|
-
function isSafeString(value) {
|
|
470
|
-
return isIndexable(value) && typeof value['toHTML'] === 'function';
|
|
471
|
-
}
|
|
472
|
-
function isNode(value) {
|
|
473
|
-
return isIndexable(value) && typeof value['nodeType'] === 'number';
|
|
474
|
-
}
|
|
475
|
-
function isFragment(value) {
|
|
476
|
-
return isIndexable(value) && value['nodeType'] === 11;
|
|
477
|
-
}
|
|
478
|
-
function isString(value) {
|
|
479
|
-
return typeof value === 'string';
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
function createClassListRef(list) {
|
|
483
|
-
return createComputeRef(() => {
|
|
484
|
-
let ret = [];
|
|
485
|
-
for (const ref of list) {
|
|
486
|
-
let value = normalizeStringValue(typeof ref === 'string' ? ref : valueForRef(ref));
|
|
487
|
-
if (value) ret.push(value);
|
|
488
|
-
}
|
|
489
|
-
return ret.length === 0 ? null : ret.join(' ');
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
APPEND_OPCODES.add(VM_CHILD_SCOPE_OP, vm => vm.pushChildScope());
|
|
494
|
-
APPEND_OPCODES.add(VM_POP_SCOPE_OP, vm => vm.popScope());
|
|
495
|
-
APPEND_OPCODES.add(VM_PUSH_DYNAMIC_SCOPE_OP, vm => vm.pushDynamicScope());
|
|
496
|
-
APPEND_OPCODES.add(VM_POP_DYNAMIC_SCOPE_OP, vm => vm.popDynamicScope());
|
|
497
|
-
APPEND_OPCODES.add(VM_CONSTANT_OP, (vm, {
|
|
498
|
-
op1: other
|
|
499
|
-
}) => {
|
|
500
|
-
vm.stack.push(vm.constants.getValue(decodeHandle(other)));
|
|
501
|
-
});
|
|
502
|
-
APPEND_OPCODES.add(VM_CONSTANT_REFERENCE_OP, (vm, {
|
|
503
|
-
op1: other
|
|
504
|
-
}) => {
|
|
505
|
-
vm.stack.push(createConstRef(vm.constants.getValue(decodeHandle(other)), false));
|
|
506
|
-
});
|
|
507
|
-
APPEND_OPCODES.add(VM_PRIMITIVE_OP, (vm, {
|
|
508
|
-
op1: primitive
|
|
509
|
-
}) => {
|
|
510
|
-
let stack = vm.stack;
|
|
511
|
-
if (isHandle(primitive)) {
|
|
512
|
-
// it is a handle which does not already exist on the stack
|
|
513
|
-
let value = vm.constants.getValue(decodeHandle(primitive));
|
|
514
|
-
stack.push(value);
|
|
515
|
-
} else {
|
|
516
|
-
// is already an encoded immediate or primitive handle
|
|
517
|
-
stack.push(decodeImmediate(primitive));
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
APPEND_OPCODES.add(VM_PRIMITIVE_REFERENCE_OP, vm => {
|
|
521
|
-
let stack = vm.stack;
|
|
522
|
-
let value = check(stack.pop());
|
|
523
|
-
let ref;
|
|
524
|
-
if (value === undefined) {
|
|
525
|
-
ref = UNDEFINED_REFERENCE;
|
|
526
|
-
} else if (value === null) {
|
|
527
|
-
ref = NULL_REFERENCE;
|
|
528
|
-
} else if (value === true) {
|
|
529
|
-
ref = TRUE_REFERENCE;
|
|
530
|
-
} else if (value === false) {
|
|
531
|
-
ref = FALSE_REFERENCE;
|
|
532
|
-
} else {
|
|
533
|
-
ref = createPrimitiveRef(value);
|
|
534
|
-
}
|
|
535
|
-
stack.push(ref);
|
|
536
|
-
});
|
|
537
|
-
APPEND_OPCODES.add(VM_DUP_OP, (vm, {
|
|
538
|
-
op1: register,
|
|
539
|
-
op2: offset
|
|
540
|
-
}) => {
|
|
541
|
-
let position = check(vm.fetchValue(check(register, CheckRegister))) - offset;
|
|
542
|
-
vm.stack.dup(position);
|
|
543
|
-
});
|
|
544
|
-
APPEND_OPCODES.add(VM_POP_OP, (vm, {
|
|
545
|
-
op1: count
|
|
546
|
-
}) => {
|
|
547
|
-
vm.stack.pop(count);
|
|
548
|
-
});
|
|
549
|
-
APPEND_OPCODES.add(VM_LOAD_OP, (vm, {
|
|
550
|
-
op1: register
|
|
551
|
-
}) => {
|
|
552
|
-
vm.load(check(register));
|
|
553
|
-
});
|
|
554
|
-
APPEND_OPCODES.add(VM_FETCH_OP, (vm, {
|
|
555
|
-
op1: register
|
|
556
|
-
}) => {
|
|
557
|
-
vm.fetch(check(register));
|
|
558
|
-
});
|
|
559
|
-
APPEND_OPCODES.add(VM_BIND_DYNAMIC_SCOPE_OP, (vm, {
|
|
560
|
-
op1: _names
|
|
561
|
-
}) => {
|
|
562
|
-
let names = vm.constants.getArray(_names);
|
|
563
|
-
vm.bindDynamicScope(names);
|
|
564
|
-
});
|
|
565
|
-
APPEND_OPCODES.add(VM_ENTER_OP, (vm, {
|
|
566
|
-
op1: args
|
|
567
|
-
}) => {
|
|
568
|
-
vm.enter(args);
|
|
569
|
-
});
|
|
570
|
-
APPEND_OPCODES.add(VM_EXIT_OP, vm => {
|
|
571
|
-
vm.exit();
|
|
572
|
-
});
|
|
573
|
-
APPEND_OPCODES.add(VM_PUSH_SYMBOL_TABLE_OP, (vm, {
|
|
574
|
-
op1: _table
|
|
575
|
-
}) => {
|
|
576
|
-
let stack = vm.stack;
|
|
577
|
-
stack.push(vm.constants.getValue(_table));
|
|
578
|
-
});
|
|
579
|
-
APPEND_OPCODES.add(VM_PUSH_BLOCK_SCOPE_OP, vm => {
|
|
580
|
-
let stack = vm.stack;
|
|
581
|
-
stack.push(vm.scope());
|
|
582
|
-
});
|
|
583
|
-
APPEND_OPCODES.add(VM_COMPILE_BLOCK_OP, vm => {
|
|
584
|
-
let stack = vm.stack;
|
|
585
|
-
let block = stack.pop();
|
|
586
|
-
if (block) {
|
|
587
|
-
stack.push(vm.compile(block));
|
|
588
|
-
} else {
|
|
589
|
-
stack.push(null);
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
APPEND_OPCODES.add(VM_INVOKE_YIELD_OP, vm => {
|
|
593
|
-
let {
|
|
594
|
-
stack
|
|
595
|
-
} = vm;
|
|
596
|
-
let handle = check(stack.pop());
|
|
597
|
-
let scope = check(stack.pop());
|
|
598
|
-
let table = check(stack.pop());
|
|
599
|
-
let args = check(stack.pop());
|
|
600
|
-
if (table === null || handle === null) {
|
|
601
|
-
vm.lowlevel.pushFrame();
|
|
602
|
-
vm.pushScope(scope ?? vm.scope());
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
let invokingScope = expect(scope);
|
|
606
|
-
|
|
607
|
-
// If necessary, create a child scope
|
|
608
|
-
{
|
|
609
|
-
let locals = table.parameters;
|
|
610
|
-
let localsCount = locals.length;
|
|
611
|
-
if (localsCount > 0) {
|
|
612
|
-
invokingScope = invokingScope.child();
|
|
613
|
-
for (let i = 0; i < localsCount; i++) {
|
|
614
|
-
invokingScope.bindSymbol(unwrap(locals[i]), args.at(i));
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
vm.lowlevel.pushFrame();
|
|
619
|
-
vm.pushScope(invokingScope);
|
|
620
|
-
vm.call(handle);
|
|
621
|
-
});
|
|
622
|
-
APPEND_OPCODES.add(VM_JUMP_IF_OP, (vm, {
|
|
623
|
-
op1: target
|
|
624
|
-
}) => {
|
|
625
|
-
let reference = check(vm.stack.pop());
|
|
626
|
-
let value = Boolean(valueForRef(reference));
|
|
627
|
-
if (isConstRef(reference)) {
|
|
628
|
-
if (value) {
|
|
629
|
-
vm.lowlevel.goto(target);
|
|
630
|
-
}
|
|
631
|
-
} else {
|
|
632
|
-
if (value) {
|
|
633
|
-
vm.lowlevel.goto(target);
|
|
634
|
-
}
|
|
635
|
-
vm.updateWith(new Assert(reference));
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
APPEND_OPCODES.add(VM_JUMP_UNLESS_OP, (vm, {
|
|
639
|
-
op1: target
|
|
640
|
-
}) => {
|
|
641
|
-
let reference = check(vm.stack.pop());
|
|
642
|
-
let value = Boolean(valueForRef(reference));
|
|
643
|
-
if (isConstRef(reference)) {
|
|
644
|
-
if (!value) {
|
|
645
|
-
vm.lowlevel.goto(target);
|
|
646
|
-
}
|
|
647
|
-
} else {
|
|
648
|
-
if (!value) {
|
|
649
|
-
vm.lowlevel.goto(target);
|
|
650
|
-
}
|
|
651
|
-
vm.updateWith(new Assert(reference));
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
APPEND_OPCODES.add(VM_JUMP_EQ_OP, (vm, {
|
|
655
|
-
op1: target,
|
|
656
|
-
op2: comparison
|
|
657
|
-
}) => {
|
|
658
|
-
let other = check(vm.stack.peek());
|
|
659
|
-
if (other === comparison) {
|
|
660
|
-
vm.lowlevel.goto(target);
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
APPEND_OPCODES.add(VM_ASSERT_SAME_OP, vm => {
|
|
664
|
-
let reference = check(vm.stack.peek());
|
|
665
|
-
if (!isConstRef(reference)) {
|
|
666
|
-
vm.updateWith(new Assert(reference));
|
|
667
|
-
}
|
|
668
|
-
});
|
|
669
|
-
APPEND_OPCODES.add(VM_TO_BOOLEAN_OP, vm => {
|
|
670
|
-
let {
|
|
671
|
-
stack
|
|
672
|
-
} = vm;
|
|
673
|
-
let valueRef = check(stack.pop());
|
|
674
|
-
stack.push(createComputeRef(() => toBool(valueForRef(valueRef))));
|
|
675
|
-
});
|
|
676
|
-
class Assert {
|
|
677
|
-
last;
|
|
678
|
-
constructor(ref) {
|
|
679
|
-
this.ref = ref;
|
|
680
|
-
this.last = valueForRef(ref);
|
|
681
|
-
}
|
|
682
|
-
evaluate(vm) {
|
|
683
|
-
let {
|
|
684
|
-
last,
|
|
685
|
-
ref
|
|
686
|
-
} = this;
|
|
687
|
-
let current = valueForRef(ref);
|
|
688
|
-
if (last !== current) {
|
|
689
|
-
vm.throw();
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
class AssertFilter {
|
|
694
|
-
last;
|
|
695
|
-
constructor(ref, filter) {
|
|
696
|
-
this.ref = ref;
|
|
697
|
-
this.filter = filter;
|
|
698
|
-
this.last = filter(valueForRef(ref));
|
|
699
|
-
}
|
|
700
|
-
evaluate(vm) {
|
|
701
|
-
let {
|
|
702
|
-
last,
|
|
703
|
-
ref,
|
|
704
|
-
filter
|
|
705
|
-
} = this;
|
|
706
|
-
let current = filter(valueForRef(ref));
|
|
707
|
-
if (last !== current) {
|
|
708
|
-
vm.throw();
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
class JumpIfNotModifiedOpcode {
|
|
713
|
-
tag = CONSTANT_TAG;
|
|
714
|
-
lastRevision = INITIAL;
|
|
715
|
-
target;
|
|
716
|
-
finalize(tag, target) {
|
|
717
|
-
this.target = target;
|
|
718
|
-
this.didModify(tag);
|
|
719
|
-
}
|
|
720
|
-
evaluate(vm) {
|
|
721
|
-
let {
|
|
722
|
-
tag,
|
|
723
|
-
target,
|
|
724
|
-
lastRevision
|
|
725
|
-
} = this;
|
|
726
|
-
if (!vm.alwaysRevalidate && validateTag(tag, lastRevision)) {
|
|
727
|
-
consumeTag(tag);
|
|
728
|
-
vm.goto(expect(target));
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
didModify(tag) {
|
|
732
|
-
this.tag = tag;
|
|
733
|
-
this.lastRevision = valueForTag(this.tag);
|
|
734
|
-
consumeTag(tag);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
class BeginTrackFrameOpcode {
|
|
738
|
-
constructor(debugLabel) {
|
|
739
|
-
this.debugLabel = debugLabel;
|
|
740
|
-
}
|
|
741
|
-
evaluate() {
|
|
742
|
-
beginTrackFrame(this.debugLabel);
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
class EndTrackFrameOpcode {
|
|
746
|
-
constructor(target) {
|
|
747
|
-
this.target = target;
|
|
748
|
-
}
|
|
749
|
-
evaluate() {
|
|
750
|
-
let tag = endTrackFrame();
|
|
751
|
-
this.target.didModify(tag);
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
APPEND_OPCODES.add(VM_TEXT_OP, (vm, {
|
|
756
|
-
op1: text
|
|
757
|
-
}) => {
|
|
758
|
-
vm.tree().appendText(vm.constants.getValue(text));
|
|
759
|
-
});
|
|
760
|
-
APPEND_OPCODES.add(VM_COMMENT_OP, (vm, {
|
|
761
|
-
op1: text
|
|
762
|
-
}) => {
|
|
763
|
-
vm.tree().appendComment(vm.constants.getValue(text));
|
|
764
|
-
});
|
|
765
|
-
APPEND_OPCODES.add(VM_OPEN_ELEMENT_OP, (vm, {
|
|
766
|
-
op1: tag
|
|
767
|
-
}) => {
|
|
768
|
-
vm.tree().openElement(vm.constants.getValue(tag));
|
|
769
|
-
});
|
|
770
|
-
APPEND_OPCODES.add(VM_OPEN_DYNAMIC_ELEMENT_OP, vm => {
|
|
771
|
-
let tagName = check(valueForRef(check(vm.stack.pop(), CheckReference)));
|
|
772
|
-
vm.tree().openElement(tagName);
|
|
773
|
-
});
|
|
774
|
-
APPEND_OPCODES.add(VM_PUSH_REMOTE_ELEMENT_OP, vm => {
|
|
775
|
-
let elementRef = check(vm.stack.pop());
|
|
776
|
-
let insertBeforeRef = check(vm.stack.pop());
|
|
777
|
-
let guidRef = check(vm.stack.pop());
|
|
778
|
-
let element = check(valueForRef(elementRef));
|
|
779
|
-
let insertBefore = check(valueForRef(insertBeforeRef));
|
|
780
|
-
let guid = valueForRef(guidRef);
|
|
781
|
-
if (!isConstRef(elementRef)) {
|
|
782
|
-
vm.updateWith(new Assert(elementRef));
|
|
783
|
-
}
|
|
784
|
-
if (insertBefore !== undefined && !isConstRef(insertBeforeRef)) {
|
|
785
|
-
vm.updateWith(new Assert(insertBeforeRef));
|
|
786
|
-
}
|
|
787
|
-
let block = vm.tree().pushRemoteElement(element, guid, insertBefore);
|
|
788
|
-
vm.associateDestroyable(block);
|
|
789
|
-
if (vm.env.debugRenderTree !== undefined) {
|
|
790
|
-
// Note that there is nothing to update – when the args for an
|
|
791
|
-
// {{#in-element}} changes it gets torn down and a new one is
|
|
792
|
-
// re-created/rendered in its place (see the `Assert`s above)
|
|
793
|
-
let args = createCapturedArgs(insertBefore === undefined ? {} : {
|
|
794
|
-
insertBefore: insertBeforeRef
|
|
795
|
-
}, [elementRef]);
|
|
796
|
-
vm.env.debugRenderTree.create(block, {
|
|
797
|
-
type: 'keyword',
|
|
798
|
-
name: 'in-element',
|
|
799
|
-
args,
|
|
800
|
-
instance: null
|
|
801
|
-
});
|
|
802
|
-
registerDestructor(block, () => {
|
|
803
|
-
vm.env.debugRenderTree?.willDestroy(block);
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
APPEND_OPCODES.add(VM_POP_REMOTE_ELEMENT_OP, vm => {
|
|
808
|
-
let bounds = vm.tree().popRemoteElement();
|
|
809
|
-
if (vm.env.debugRenderTree !== undefined) {
|
|
810
|
-
// The RemoteBlock is also its bounds
|
|
811
|
-
vm.env.debugRenderTree.didRender(bounds, bounds);
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
APPEND_OPCODES.add(VM_FLUSH_ELEMENT_OP, vm => {
|
|
815
|
-
let operations = check(vm.fetchValue($t0));
|
|
816
|
-
let modifiers = null;
|
|
817
|
-
if (operations) {
|
|
818
|
-
modifiers = operations.flush(vm);
|
|
819
|
-
vm.loadValue($t0, null);
|
|
820
|
-
}
|
|
821
|
-
vm.tree().flushElement(modifiers);
|
|
822
|
-
});
|
|
823
|
-
APPEND_OPCODES.add(VM_CLOSE_ELEMENT_OP, vm => {
|
|
824
|
-
let modifiers = vm.tree().closeElement();
|
|
825
|
-
if (modifiers !== null) {
|
|
826
|
-
modifiers.forEach(modifier => {
|
|
827
|
-
vm.env.scheduleInstallModifier(modifier);
|
|
828
|
-
const d = modifier.manager.getDestroyable(modifier.state);
|
|
829
|
-
if (d !== null) {
|
|
830
|
-
vm.associateDestroyable(d);
|
|
831
|
-
}
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
});
|
|
835
|
-
APPEND_OPCODES.add(VM_MODIFIER_OP, (vm, {
|
|
836
|
-
op1: handle
|
|
837
|
-
}) => {
|
|
838
|
-
let args = check(vm.stack.pop());
|
|
839
|
-
if (!vm.env.isInteractive) {
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
let owner = vm.getOwner();
|
|
843
|
-
let definition = vm.constants.getValue(handle);
|
|
844
|
-
let {
|
|
845
|
-
manager
|
|
846
|
-
} = definition;
|
|
847
|
-
let {
|
|
848
|
-
constructing
|
|
849
|
-
} = vm.tree();
|
|
850
|
-
let capturedArgs = args.capture();
|
|
851
|
-
let state = manager.create(owner, expect(constructing), definition.state, capturedArgs);
|
|
852
|
-
let instance = {
|
|
853
|
-
manager,
|
|
854
|
-
state,
|
|
855
|
-
definition
|
|
856
|
-
};
|
|
857
|
-
let operations = expect(check(vm.fetchValue($t0)));
|
|
858
|
-
operations.addModifier(vm, instance, capturedArgs);
|
|
859
|
-
let tag = manager.getTag(state);
|
|
860
|
-
if (tag !== null) {
|
|
861
|
-
consumeTag(tag);
|
|
862
|
-
return vm.updateWith(new UpdateModifierOpcode(tag, instance));
|
|
863
|
-
}
|
|
864
|
-
});
|
|
865
|
-
APPEND_OPCODES.add(VM_DYNAMIC_MODIFIER_OP, vm => {
|
|
866
|
-
let {
|
|
867
|
-
stack
|
|
868
|
-
} = vm;
|
|
869
|
-
let ref = check(stack.pop());
|
|
870
|
-
let args = check(stack.pop());
|
|
871
|
-
if (!vm.env.isInteractive) {
|
|
872
|
-
return;
|
|
873
|
-
}
|
|
874
|
-
let capturedArgs = args.capture();
|
|
875
|
-
let {
|
|
876
|
-
positional: outerPositional,
|
|
877
|
-
named: outerNamed
|
|
878
|
-
} = capturedArgs;
|
|
879
|
-
let {
|
|
880
|
-
constructing
|
|
881
|
-
} = vm.tree();
|
|
882
|
-
let initialOwner = vm.getOwner();
|
|
883
|
-
let instanceRef = createComputeRef(() => {
|
|
884
|
-
let value = valueForRef(ref);
|
|
885
|
-
let owner;
|
|
886
|
-
if (!isIndexable$1(value)) {
|
|
887
|
-
return;
|
|
888
|
-
}
|
|
889
|
-
let hostDefinition;
|
|
890
|
-
if (isCurriedType(value, CURRIED_MODIFIER)) {
|
|
891
|
-
let {
|
|
892
|
-
definition: resolvedDefinition,
|
|
893
|
-
owner: curriedOwner,
|
|
894
|
-
positional,
|
|
895
|
-
named
|
|
896
|
-
} = resolveCurriedValue(value);
|
|
897
|
-
hostDefinition = resolvedDefinition;
|
|
898
|
-
owner = curriedOwner;
|
|
899
|
-
if (positional !== undefined) {
|
|
900
|
-
capturedArgs.positional = positional.concat(outerPositional);
|
|
901
|
-
}
|
|
902
|
-
if (named !== undefined) {
|
|
903
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
904
|
-
capturedArgs.named = Object.assign({}, ...named, outerNamed);
|
|
905
|
-
}
|
|
906
|
-
} else {
|
|
907
|
-
hostDefinition = value;
|
|
908
|
-
owner = initialOwner;
|
|
909
|
-
}
|
|
910
|
-
let manager = getInternalModifierManager(hostDefinition, true);
|
|
911
|
-
if (manager === null) {
|
|
912
|
-
{
|
|
913
|
-
throw new Error(`Expected a dynamic modifier definition, but received an object or function that did not have a modifier manager associated with it. The dynamic invocation was \`{{${ref.debugLabel}}}\`, and the incorrect definition is the value at the path \`${ref.debugLabel}\`, which was: ${debugToString?.(hostDefinition)}`);
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
let definition = {
|
|
917
|
-
resolvedName: null,
|
|
918
|
-
manager,
|
|
919
|
-
state: hostDefinition
|
|
920
|
-
};
|
|
921
|
-
let state = manager.create(owner, expect(constructing), definition.state, capturedArgs);
|
|
922
|
-
return {
|
|
923
|
-
manager,
|
|
924
|
-
state,
|
|
925
|
-
definition
|
|
926
|
-
};
|
|
927
|
-
});
|
|
928
|
-
let instance = valueForRef(instanceRef);
|
|
929
|
-
let tag = null;
|
|
930
|
-
if (instance !== undefined) {
|
|
931
|
-
let operations = expect(check(vm.fetchValue($t0)));
|
|
932
|
-
operations.addModifier(vm, instance, capturedArgs);
|
|
933
|
-
tag = instance.manager.getTag(instance.state);
|
|
934
|
-
if (tag !== null) {
|
|
935
|
-
consumeTag(tag);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
if (!isConstRef(ref) || tag) {
|
|
939
|
-
return vm.updateWith(new UpdateDynamicModifierOpcode(tag, instance, instanceRef));
|
|
940
|
-
}
|
|
941
|
-
});
|
|
942
|
-
class UpdateModifierOpcode {
|
|
943
|
-
lastUpdated;
|
|
944
|
-
constructor(tag, modifier) {
|
|
945
|
-
this.tag = tag;
|
|
946
|
-
this.modifier = modifier;
|
|
947
|
-
this.lastUpdated = valueForTag(tag);
|
|
948
|
-
}
|
|
949
|
-
evaluate(vm) {
|
|
950
|
-
let {
|
|
951
|
-
modifier,
|
|
952
|
-
tag,
|
|
953
|
-
lastUpdated
|
|
954
|
-
} = this;
|
|
955
|
-
consumeTag(tag);
|
|
956
|
-
if (!validateTag(tag, lastUpdated)) {
|
|
957
|
-
vm.env.scheduleUpdateModifier(modifier);
|
|
958
|
-
this.lastUpdated = valueForTag(tag);
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
class UpdateDynamicModifierOpcode {
|
|
963
|
-
lastUpdated;
|
|
964
|
-
constructor(tag, instance, instanceRef) {
|
|
965
|
-
this.tag = tag;
|
|
966
|
-
this.instance = instance;
|
|
967
|
-
this.instanceRef = instanceRef;
|
|
968
|
-
this.lastUpdated = valueForTag(tag ?? CURRENT_TAG);
|
|
969
|
-
}
|
|
970
|
-
evaluate(vm) {
|
|
971
|
-
let {
|
|
972
|
-
tag,
|
|
973
|
-
lastUpdated,
|
|
974
|
-
instance,
|
|
975
|
-
instanceRef
|
|
976
|
-
} = this;
|
|
977
|
-
let newInstance = valueForRef(instanceRef);
|
|
978
|
-
if (newInstance !== instance) {
|
|
979
|
-
if (instance !== undefined) {
|
|
980
|
-
let destroyable = instance.manager.getDestroyable(instance.state);
|
|
981
|
-
if (destroyable !== null) {
|
|
982
|
-
destroy(destroyable);
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
if (newInstance !== undefined) {
|
|
986
|
-
let {
|
|
987
|
-
manager,
|
|
988
|
-
state
|
|
989
|
-
} = newInstance;
|
|
990
|
-
let destroyable = manager.getDestroyable(state);
|
|
991
|
-
if (destroyable !== null) {
|
|
992
|
-
associateDestroyableChild(this, destroyable);
|
|
993
|
-
}
|
|
994
|
-
tag = manager.getTag(state);
|
|
995
|
-
if (tag !== null) {
|
|
996
|
-
this.lastUpdated = valueForTag(tag);
|
|
997
|
-
}
|
|
998
|
-
this.tag = tag;
|
|
999
|
-
vm.env.scheduleInstallModifier(newInstance);
|
|
1000
|
-
}
|
|
1001
|
-
this.instance = newInstance;
|
|
1002
|
-
} else if (tag !== null && !validateTag(tag, lastUpdated)) {
|
|
1003
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
1004
|
-
vm.env.scheduleUpdateModifier(instance);
|
|
1005
|
-
this.lastUpdated = valueForTag(tag);
|
|
1006
|
-
}
|
|
1007
|
-
if (tag !== null) {
|
|
1008
|
-
consumeTag(tag);
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
APPEND_OPCODES.add(VM_STATIC_ATTR_OP, (vm, {
|
|
1013
|
-
op1: _name,
|
|
1014
|
-
op2: _value,
|
|
1015
|
-
op3: _namespace
|
|
1016
|
-
}) => {
|
|
1017
|
-
let name = vm.constants.getValue(_name);
|
|
1018
|
-
let value = vm.constants.getValue(_value);
|
|
1019
|
-
let namespace = _namespace ? vm.constants.getValue(_namespace) : null;
|
|
1020
|
-
vm.tree().setStaticAttribute(name, value, namespace);
|
|
1021
|
-
});
|
|
1022
|
-
APPEND_OPCODES.add(VM_DYNAMIC_ATTR_OP, (vm, {
|
|
1023
|
-
op1: _name,
|
|
1024
|
-
op2: _trusting,
|
|
1025
|
-
op3: _namespace
|
|
1026
|
-
}) => {
|
|
1027
|
-
let name = vm.constants.getValue(_name);
|
|
1028
|
-
let trusting = vm.constants.getValue(_trusting);
|
|
1029
|
-
let reference = check(vm.stack.pop());
|
|
1030
|
-
let value = valueForRef(reference);
|
|
1031
|
-
let namespace = _namespace ? vm.constants.getValue(_namespace) : null;
|
|
1032
|
-
let attribute = vm.tree().setDynamicAttribute(name, value, trusting, namespace);
|
|
1033
|
-
if (!isConstRef(reference)) {
|
|
1034
|
-
vm.updateWith(new UpdateDynamicAttributeOpcode(reference, attribute, vm.env));
|
|
1035
|
-
}
|
|
1036
|
-
});
|
|
1037
|
-
class UpdateDynamicAttributeOpcode {
|
|
1038
|
-
updateRef;
|
|
1039
|
-
constructor(reference, attribute, env) {
|
|
1040
|
-
let initialized = false;
|
|
1041
|
-
this.updateRef = createComputeRef(() => {
|
|
1042
|
-
let value = valueForRef(reference);
|
|
1043
|
-
if (initialized) {
|
|
1044
|
-
attribute.update(value, env);
|
|
1045
|
-
} else {
|
|
1046
|
-
initialized = true;
|
|
1047
|
-
}
|
|
1048
|
-
});
|
|
1049
|
-
valueForRef(this.updateRef);
|
|
1050
|
-
}
|
|
1051
|
-
evaluate() {
|
|
1052
|
-
valueForRef(this.updateRef);
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
/**
|
|
1057
|
-
* The VM creates a new ComponentInstance data structure for every component
|
|
1058
|
-
* invocation it encounters.
|
|
1059
|
-
*
|
|
1060
|
-
* Similar to how a ComponentDefinition contains state about all components of a
|
|
1061
|
-
* particular type, a ComponentInstance contains state specific to a particular
|
|
1062
|
-
* instance of a component type. It also contains a pointer back to its
|
|
1063
|
-
* component type's ComponentDefinition.
|
|
1064
|
-
*/
|
|
1065
|
-
|
|
1066
|
-
APPEND_OPCODES.add(VM_PUSH_COMPONENT_DEFINITION_OP, (vm, {
|
|
1067
|
-
op1: handle
|
|
1068
|
-
}) => {
|
|
1069
|
-
let definition = vm.constants.getValue(handle);
|
|
1070
|
-
let {
|
|
1071
|
-
manager,
|
|
1072
|
-
capabilities
|
|
1073
|
-
} = definition;
|
|
1074
|
-
let instance = {
|
|
1075
|
-
definition,
|
|
1076
|
-
manager,
|
|
1077
|
-
capabilities,
|
|
1078
|
-
state: null,
|
|
1079
|
-
handle: null,
|
|
1080
|
-
table: null,
|
|
1081
|
-
lookup: null
|
|
1082
|
-
};
|
|
1083
|
-
vm.stack.push(instance);
|
|
1084
|
-
});
|
|
1085
|
-
APPEND_OPCODES.add(VM_RESOLVE_DYNAMIC_COMPONENT_OP, (vm, {
|
|
1086
|
-
op1: _isStrict
|
|
1087
|
-
}) => {
|
|
1088
|
-
let stack = vm.stack;
|
|
1089
|
-
let ref = check(stack.pop());
|
|
1090
|
-
let component = check(valueForRef(ref));
|
|
1091
|
-
let constants = vm.constants;
|
|
1092
|
-
let owner = vm.getOwner();
|
|
1093
|
-
let isStrict = constants.getValue(_isStrict);
|
|
1094
|
-
vm.loadValue($t1, null); // Clear the temp register
|
|
1095
|
-
|
|
1096
|
-
let definition;
|
|
1097
|
-
if (typeof component === 'string') {
|
|
1098
|
-
if (isStrict) {
|
|
1099
|
-
throw new Error(`Attempted to resolve a dynamic component with a string definition, \`${component}\` in a strict mode template. In strict mode, using strings to resolve component definitions is prohibited. You can instead import the component definition and use it directly.`);
|
|
1100
|
-
}
|
|
1101
|
-
let resolvedDefinition = resolveComponent(vm.context.resolver, constants, component, owner);
|
|
1102
|
-
definition = expect(resolvedDefinition);
|
|
1103
|
-
} else if (isCurriedValue(component)) {
|
|
1104
|
-
definition = component;
|
|
1105
|
-
} else {
|
|
1106
|
-
definition = constants.component(component, owner);
|
|
1107
|
-
}
|
|
1108
|
-
if (!isCurriedValue(definition) && !definition.resolvedName && !definition.debugName) {
|
|
1109
|
-
let debugLabel = ref.debugLabel;
|
|
1110
|
-
if (debugLabel) {
|
|
1111
|
-
definition.debugName = debugLabel;
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
stack.push(definition);
|
|
1115
|
-
});
|
|
1116
|
-
APPEND_OPCODES.add(VM_RESOLVE_CURRIED_COMPONENT_OP, vm => {
|
|
1117
|
-
let stack = vm.stack;
|
|
1118
|
-
let ref = check(stack.pop());
|
|
1119
|
-
let value = valueForRef(ref);
|
|
1120
|
-
let constants = vm.constants;
|
|
1121
|
-
let definition;
|
|
1122
|
-
if (!(typeof value === 'function' || typeof value === 'object' && value !== null)) {
|
|
1123
|
-
throw new Error(`Expected a component definition, but received ${value}. You may have accidentally done <${ref.debugLabel}>, where "${ref.debugLabel}" was a string instead of a curried component definition. You must either use the component definition directly, or use the {{component}} helper to create a curried component definition when invoking dynamically.`);
|
|
1124
|
-
}
|
|
1125
|
-
if (isCurriedValue(value)) {
|
|
1126
|
-
definition = value;
|
|
1127
|
-
} else {
|
|
1128
|
-
definition = constants.component(value, vm.getOwner(), true);
|
|
1129
|
-
if (definition === null) {
|
|
1130
|
-
throw new Error(`Expected a dynamic component definition, but received an object or function that did not have a component manager associated with it. The dynamic invocation was \`<${ref.debugLabel}>\` or \`{{${ref.debugLabel}}}\`, and the incorrect definition is the value at the path \`${ref.debugLabel}\`, which was: ${debugToString?.(value) ?? value}`);
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
if (definition && !isCurriedValue(definition) && !definition.resolvedName && !definition.debugName) {
|
|
1134
|
-
let debugLabel = ref.debugLabel;
|
|
1135
|
-
if (debugLabel) {
|
|
1136
|
-
definition.debugName = debugLabel;
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
stack.push(definition);
|
|
1140
|
-
});
|
|
1141
|
-
APPEND_OPCODES.add(VM_PUSH_DYNAMIC_COMPONENT_INSTANCE_OP, vm => {
|
|
1142
|
-
let {
|
|
1143
|
-
stack
|
|
1144
|
-
} = vm;
|
|
1145
|
-
let definition = stack.pop();
|
|
1146
|
-
let capabilities, manager;
|
|
1147
|
-
if (isCurriedValue(definition)) {
|
|
1148
|
-
manager = capabilities = null;
|
|
1149
|
-
} else {
|
|
1150
|
-
manager = definition.manager;
|
|
1151
|
-
capabilities = definition.capabilities;
|
|
1152
|
-
}
|
|
1153
|
-
stack.push({
|
|
1154
|
-
definition,
|
|
1155
|
-
capabilities,
|
|
1156
|
-
manager,
|
|
1157
|
-
state: null,
|
|
1158
|
-
handle: null,
|
|
1159
|
-
table: null
|
|
1160
|
-
});
|
|
1161
|
-
});
|
|
1162
|
-
APPEND_OPCODES.add(VM_PUSH_ARGS_OP, (vm, {
|
|
1163
|
-
op1: _names,
|
|
1164
|
-
op2: _blockNames,
|
|
1165
|
-
op3: flags
|
|
1166
|
-
}) => {
|
|
1167
|
-
let stack = vm.stack;
|
|
1168
|
-
let names = vm.constants.getArray(_names);
|
|
1169
|
-
let positionalCount = flags >> 4;
|
|
1170
|
-
let atNames = flags & 0b1000;
|
|
1171
|
-
let blockNames = flags & 0b0111 ? vm.constants.getArray(_blockNames) : EMPTY_STRING_ARRAY;
|
|
1172
|
-
vm.args.setup(stack, names, blockNames, positionalCount, !!atNames);
|
|
1173
|
-
stack.push(vm.args);
|
|
1174
|
-
});
|
|
1175
|
-
APPEND_OPCODES.add(VM_PUSH_EMPTY_ARGS_OP, vm => {
|
|
1176
|
-
let {
|
|
1177
|
-
stack
|
|
1178
|
-
} = vm;
|
|
1179
|
-
stack.push(vm.args.empty(stack));
|
|
1180
|
-
});
|
|
1181
|
-
APPEND_OPCODES.add(VM_CAPTURE_ARGS_OP, vm => {
|
|
1182
|
-
let stack = vm.stack;
|
|
1183
|
-
let args = check(stack.pop());
|
|
1184
|
-
let capturedArgs = args.capture();
|
|
1185
|
-
stack.push(capturedArgs);
|
|
1186
|
-
});
|
|
1187
|
-
APPEND_OPCODES.add(VM_PREPARE_ARGS_OP, (vm, {
|
|
1188
|
-
op1: register
|
|
1189
|
-
}) => {
|
|
1190
|
-
let stack = vm.stack;
|
|
1191
|
-
let instance = vm.fetchValue(check(register));
|
|
1192
|
-
let args = check(stack.pop());
|
|
1193
|
-
let {
|
|
1194
|
-
definition
|
|
1195
|
-
} = instance;
|
|
1196
|
-
if (isCurriedType(definition, CURRIED_COMPONENT)) {
|
|
1197
|
-
(!(!definition.manager) && assert(!definition.manager));
|
|
1198
|
-
let constants = vm.constants;
|
|
1199
|
-
let {
|
|
1200
|
-
definition: resolvedDefinition,
|
|
1201
|
-
owner,
|
|
1202
|
-
resolved,
|
|
1203
|
-
positional,
|
|
1204
|
-
named
|
|
1205
|
-
} = resolveCurriedValue(definition);
|
|
1206
|
-
if (resolved) {
|
|
1207
|
-
definition = resolvedDefinition;
|
|
1208
|
-
} else if (typeof resolvedDefinition === 'string') {
|
|
1209
|
-
let resolvedValue = vm.context.resolver?.lookupComponent?.(resolvedDefinition, owner) ?? null;
|
|
1210
|
-
definition = constants.resolvedComponent(expect(resolvedValue), resolvedDefinition);
|
|
1211
|
-
} else {
|
|
1212
|
-
definition = constants.component(resolvedDefinition, owner);
|
|
1213
|
-
}
|
|
1214
|
-
if (named !== undefined) {
|
|
1215
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
1216
|
-
args.named.merge(assign({}, ...named));
|
|
1217
|
-
}
|
|
1218
|
-
if (positional !== undefined) {
|
|
1219
|
-
args.realloc(positional.length);
|
|
1220
|
-
args.positional.prepend(positional);
|
|
1221
|
-
}
|
|
1222
|
-
let {
|
|
1223
|
-
manager
|
|
1224
|
-
} = definition;
|
|
1225
|
-
instance.definition = definition;
|
|
1226
|
-
instance.manager = manager;
|
|
1227
|
-
instance.capabilities = definition.capabilities;
|
|
1228
|
-
|
|
1229
|
-
// Save off the owner that this component was curried with. Later on,
|
|
1230
|
-
// we'll fetch the value of this register and set it as the owner on the
|
|
1231
|
-
// new root scope.
|
|
1232
|
-
vm.loadValue($t1, owner);
|
|
1233
|
-
}
|
|
1234
|
-
let {
|
|
1235
|
-
manager,
|
|
1236
|
-
state
|
|
1237
|
-
} = definition;
|
|
1238
|
-
let capabilities = instance.capabilities;
|
|
1239
|
-
if (!managerHasCapability(manager, capabilities, InternalComponentCapabilities.prepareArgs)) {
|
|
1240
|
-
stack.push(args);
|
|
1241
|
-
return;
|
|
1242
|
-
}
|
|
1243
|
-
let blocks = args.blocks.values;
|
|
1244
|
-
let blockNames = args.blocks.names;
|
|
1245
|
-
let preparedArgs = manager.prepareArgs(state, args);
|
|
1246
|
-
if (preparedArgs) {
|
|
1247
|
-
args.clear();
|
|
1248
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
1249
|
-
stack.push(blocks[i]);
|
|
1250
|
-
}
|
|
1251
|
-
let {
|
|
1252
|
-
positional,
|
|
1253
|
-
named
|
|
1254
|
-
} = preparedArgs;
|
|
1255
|
-
let positionalCount = positional.length;
|
|
1256
|
-
for (let i = 0; i < positionalCount; i++) {
|
|
1257
|
-
stack.push(positional[i]);
|
|
1258
|
-
}
|
|
1259
|
-
let names = Object.keys(named);
|
|
1260
|
-
for (let i = 0; i < names.length; i++) {
|
|
1261
|
-
stack.push(named[unwrap(names[i])]);
|
|
1262
|
-
}
|
|
1263
|
-
args.setup(stack, names, blockNames, positionalCount, false);
|
|
1264
|
-
}
|
|
1265
|
-
stack.push(args);
|
|
1266
|
-
});
|
|
1267
|
-
APPEND_OPCODES.add(VM_CREATE_COMPONENT_OP, (vm, {
|
|
1268
|
-
op1: flags
|
|
1269
|
-
}) => {
|
|
1270
|
-
let instance = check(vm.fetchValue($s0));
|
|
1271
|
-
let {
|
|
1272
|
-
definition,
|
|
1273
|
-
manager,
|
|
1274
|
-
capabilities
|
|
1275
|
-
} = instance;
|
|
1276
|
-
if (!managerHasCapability(manager, capabilities, InternalComponentCapabilities.createInstance)) {
|
|
1277
|
-
// TODO: Closure and Main components are always invoked dynamically, so this
|
|
1278
|
-
// opcode may run even if this capability is not enabled. In the future we
|
|
1279
|
-
// should handle this in a better way.
|
|
1280
|
-
return;
|
|
1281
|
-
}
|
|
1282
|
-
let dynamicScope = null;
|
|
1283
|
-
if (managerHasCapability(manager, capabilities, InternalComponentCapabilities.dynamicScope)) {
|
|
1284
|
-
dynamicScope = vm.dynamicScope();
|
|
1285
|
-
}
|
|
1286
|
-
let hasDefaultBlock = flags & 1;
|
|
1287
|
-
let args = null;
|
|
1288
|
-
if (managerHasCapability(manager, capabilities, InternalComponentCapabilities.createArgs)) {
|
|
1289
|
-
args = check(vm.stack.peek());
|
|
1290
|
-
}
|
|
1291
|
-
let self = null;
|
|
1292
|
-
if (managerHasCapability(manager, capabilities, InternalComponentCapabilities.createCaller)) {
|
|
1293
|
-
self = vm.getSelf();
|
|
1294
|
-
}
|
|
1295
|
-
let state = manager.create(vm.getOwner(), definition.state, args, vm.env, dynamicScope, self, !!hasDefaultBlock);
|
|
1296
|
-
|
|
1297
|
-
// We want to reuse the `state` POJO here, because we know that the opcodes
|
|
1298
|
-
// only transition at exactly one place.
|
|
1299
|
-
instance.state = state;
|
|
1300
|
-
if (managerHasCapability(manager, capabilities, InternalComponentCapabilities.updateHook)) {
|
|
1301
|
-
vm.updateWith(new UpdateComponentOpcode(state, manager, dynamicScope));
|
|
1302
|
-
}
|
|
1303
|
-
});
|
|
1304
|
-
APPEND_OPCODES.add(VM_REGISTER_COMPONENT_DESTRUCTOR_OP, (vm, {
|
|
1305
|
-
op1: register
|
|
1306
|
-
}) => {
|
|
1307
|
-
let {
|
|
1308
|
-
manager,
|
|
1309
|
-
state,
|
|
1310
|
-
capabilities
|
|
1311
|
-
} = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1312
|
-
let d = manager.getDestroyable(state);
|
|
1313
|
-
if (!managerHasCapability(manager, capabilities, InternalComponentCapabilities.willDestroy) && d !== null && "string" in d) {
|
|
1314
|
-
throw new Error('BUG: Destructor has willDestroy, but the willDestroy capability was not enabled for this component. Pre-destruction hooks must be explicitly opted into');
|
|
1315
|
-
}
|
|
1316
|
-
if (d) vm.associateDestroyable(d);
|
|
1317
|
-
});
|
|
1318
|
-
APPEND_OPCODES.add(VM_BEGIN_COMPONENT_TRANSACTION_OP, (vm, {
|
|
1319
|
-
op1: register
|
|
1320
|
-
}) => {
|
|
1321
|
-
let name;
|
|
1322
|
-
{
|
|
1323
|
-
let {
|
|
1324
|
-
definition,
|
|
1325
|
-
manager
|
|
1326
|
-
} = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1327
|
-
name = getDebugName(definition, manager);
|
|
1328
|
-
}
|
|
1329
|
-
vm.beginCacheGroup(name);
|
|
1330
|
-
vm.tree().pushAppendingBlock();
|
|
1331
|
-
});
|
|
1332
|
-
APPEND_OPCODES.add(VM_PUT_COMPONENT_OPERATIONS_OP, vm => {
|
|
1333
|
-
vm.loadValue($t0, new ComponentElementOperations());
|
|
1334
|
-
});
|
|
1335
|
-
APPEND_OPCODES.add(VM_COMPONENT_ATTR_OP, (vm, {
|
|
1336
|
-
op1: _name,
|
|
1337
|
-
op2: _trusting,
|
|
1338
|
-
op3: _namespace
|
|
1339
|
-
}) => {
|
|
1340
|
-
let name = vm.constants.getValue(_name);
|
|
1341
|
-
let trusting = vm.constants.getValue(_trusting);
|
|
1342
|
-
let reference = check(vm.stack.pop());
|
|
1343
|
-
let namespace = _namespace ? vm.constants.getValue(_namespace) : null;
|
|
1344
|
-
check(vm.fetchValue($t0), CheckInstanceof(ComponentElementOperations)).setAttribute(name, reference, trusting, namespace);
|
|
1345
|
-
});
|
|
1346
|
-
APPEND_OPCODES.add(VM_STATIC_COMPONENT_ATTR_OP, (vm, {
|
|
1347
|
-
op1: _name,
|
|
1348
|
-
op2: _value,
|
|
1349
|
-
op3: _namespace
|
|
1350
|
-
}) => {
|
|
1351
|
-
let name = vm.constants.getValue(_name);
|
|
1352
|
-
let value = vm.constants.getValue(_value);
|
|
1353
|
-
let namespace = _namespace ? vm.constants.getValue(_namespace) : null;
|
|
1354
|
-
check(vm.fetchValue($t0), CheckInstanceof(ComponentElementOperations)).setStaticAttribute(name, value, namespace);
|
|
1355
|
-
});
|
|
1356
|
-
class ComponentElementOperations {
|
|
1357
|
-
attributes = dict();
|
|
1358
|
-
classes = [];
|
|
1359
|
-
modifiers = [];
|
|
1360
|
-
setAttribute(name, value, trusting, namespace) {
|
|
1361
|
-
let deferred = {
|
|
1362
|
-
value,
|
|
1363
|
-
namespace,
|
|
1364
|
-
trusting
|
|
1365
|
-
};
|
|
1366
|
-
if (name === 'class') {
|
|
1367
|
-
this.classes.push(value);
|
|
1368
|
-
}
|
|
1369
|
-
this.attributes[name] = deferred;
|
|
1370
|
-
}
|
|
1371
|
-
setStaticAttribute(name, value, namespace) {
|
|
1372
|
-
let deferred = {
|
|
1373
|
-
value,
|
|
1374
|
-
namespace
|
|
1375
|
-
};
|
|
1376
|
-
if (name === 'class') {
|
|
1377
|
-
this.classes.push(value);
|
|
1378
|
-
}
|
|
1379
|
-
this.attributes[name] = deferred;
|
|
1380
|
-
}
|
|
1381
|
-
addModifier(vm, modifier, capturedArgs) {
|
|
1382
|
-
this.modifiers.push(modifier);
|
|
1383
|
-
if (vm.env.debugRenderTree !== undefined) {
|
|
1384
|
-
const {
|
|
1385
|
-
manager,
|
|
1386
|
-
definition,
|
|
1387
|
-
state
|
|
1388
|
-
} = modifier;
|
|
1389
|
-
|
|
1390
|
-
// TODO: we need a stable object for the debugRenderTree as the key, add support for
|
|
1391
|
-
// the case where the state is a primitive, or if in practice we always have/require
|
|
1392
|
-
// an object, then change the internal types to reflect that
|
|
1393
|
-
if (state === null || typeof state !== 'object' && typeof state !== 'function') {
|
|
1394
|
-
return;
|
|
1395
|
-
}
|
|
1396
|
-
let {
|
|
1397
|
-
element,
|
|
1398
|
-
constructing
|
|
1399
|
-
} = vm.tree();
|
|
1400
|
-
let name = definition.resolvedName ?? manager.getDebugName(definition.state);
|
|
1401
|
-
let instance = manager.getDebugInstance(state);
|
|
1402
|
-
let bounds = new ConcreteBounds(element, constructing, constructing);
|
|
1403
|
-
vm.env.debugRenderTree.create(state, {
|
|
1404
|
-
type: 'modifier',
|
|
1405
|
-
name,
|
|
1406
|
-
args: capturedArgs,
|
|
1407
|
-
instance
|
|
1408
|
-
});
|
|
1409
|
-
vm.env.debugRenderTree.didRender(state, bounds);
|
|
1410
|
-
|
|
1411
|
-
// For tearing down the debugRenderTree
|
|
1412
|
-
vm.associateDestroyable(state);
|
|
1413
|
-
vm.updateWith(new DebugRenderTreeUpdateOpcode(state));
|
|
1414
|
-
vm.updateWith(new DebugRenderTreeDidRenderOpcode(state, bounds));
|
|
1415
|
-
registerDestructor(state, () => {
|
|
1416
|
-
vm.env.debugRenderTree?.willDestroy(state);
|
|
1417
|
-
});
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
flush(vm) {
|
|
1421
|
-
let type;
|
|
1422
|
-
let attributes = this.attributes;
|
|
1423
|
-
for (let name in this.attributes) {
|
|
1424
|
-
if (name === 'type') {
|
|
1425
|
-
type = attributes[name];
|
|
1426
|
-
continue;
|
|
1427
|
-
}
|
|
1428
|
-
let attr = unwrap(this.attributes[name]);
|
|
1429
|
-
if (name === 'class') {
|
|
1430
|
-
setDeferredAttr(vm, 'class', mergeClasses(this.classes), attr.namespace, attr.trusting);
|
|
1431
|
-
} else {
|
|
1432
|
-
setDeferredAttr(vm, name, attr.value, attr.namespace, attr.trusting);
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
if (type !== undefined) {
|
|
1436
|
-
setDeferredAttr(vm, 'type', type.value, type.namespace, type.trusting);
|
|
1437
|
-
}
|
|
1438
|
-
return this.modifiers;
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
function mergeClasses(classes) {
|
|
1442
|
-
if (classes.length === 0) {
|
|
1443
|
-
return '';
|
|
1444
|
-
}
|
|
1445
|
-
if (classes.length === 1) {
|
|
1446
|
-
return unwrap(classes[0]);
|
|
1447
|
-
}
|
|
1448
|
-
if (allStringClasses(classes)) {
|
|
1449
|
-
return classes.join(' ');
|
|
1450
|
-
}
|
|
1451
|
-
return createClassListRef(classes);
|
|
1452
|
-
}
|
|
1453
|
-
function allStringClasses(classes) {
|
|
1454
|
-
return classes.every(c => typeof c === 'string');
|
|
1455
|
-
}
|
|
1456
|
-
function setDeferredAttr(vm, name, value, namespace, trusting = false) {
|
|
1457
|
-
if (typeof value === 'string') {
|
|
1458
|
-
vm.tree().setStaticAttribute(name, value, namespace);
|
|
1459
|
-
} else {
|
|
1460
|
-
let attribute = vm.tree().setDynamicAttribute(name, valueForRef(value), trusting, namespace);
|
|
1461
|
-
if (!isConstRef(value)) {
|
|
1462
|
-
vm.updateWith(new UpdateDynamicAttributeOpcode(value, attribute, vm.env));
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
APPEND_OPCODES.add(VM_DID_CREATE_ELEMENT_OP, (vm, {
|
|
1467
|
-
op1: register
|
|
1468
|
-
}) => {
|
|
1469
|
-
let {
|
|
1470
|
-
definition,
|
|
1471
|
-
state
|
|
1472
|
-
} = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1473
|
-
let {
|
|
1474
|
-
manager
|
|
1475
|
-
} = definition;
|
|
1476
|
-
let operations = check(vm.fetchValue($t0));
|
|
1477
|
-
manager.didCreateElement(state, expect(vm.tree().constructing), operations);
|
|
1478
|
-
});
|
|
1479
|
-
APPEND_OPCODES.add(VM_GET_COMPONENT_SELF_OP, (vm, {
|
|
1480
|
-
op1: register,
|
|
1481
|
-
op2: _names
|
|
1482
|
-
}) => {
|
|
1483
|
-
let instance = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1484
|
-
let {
|
|
1485
|
-
definition,
|
|
1486
|
-
state
|
|
1487
|
-
} = instance;
|
|
1488
|
-
let {
|
|
1489
|
-
manager
|
|
1490
|
-
} = definition;
|
|
1491
|
-
let selfRef = manager.getSelf(state);
|
|
1492
|
-
if (vm.env.debugRenderTree !== undefined) {
|
|
1493
|
-
let instance = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1494
|
-
let {
|
|
1495
|
-
definition,
|
|
1496
|
-
manager
|
|
1497
|
-
} = instance;
|
|
1498
|
-
let args;
|
|
1499
|
-
if (vm.stack.peek() === vm.args) {
|
|
1500
|
-
args = vm.args.capture();
|
|
1501
|
-
} else {
|
|
1502
|
-
let names = vm.constants.getArray(_names);
|
|
1503
|
-
vm.args.setup(vm.stack, names, [], 0, true);
|
|
1504
|
-
args = vm.args.capture();
|
|
1505
|
-
}
|
|
1506
|
-
let compilable = definition.compilable;
|
|
1507
|
-
if (compilable === null) {
|
|
1508
|
-
(!(managerHasCapability(manager, instance.capabilities, InternalComponentCapabilities.dynamicLayout)) && assert(managerHasCapability(manager, instance.capabilities, InternalComponentCapabilities.dynamicLayout)));
|
|
1509
|
-
let resolver = vm.context.resolver;
|
|
1510
|
-
compilable = resolver === null ? null : manager.getDynamicLayout(state, resolver);
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
// For tearing down the debugRenderTree
|
|
1514
|
-
vm.associateDestroyable(instance);
|
|
1515
|
-
if (hasCustomDebugRenderTreeLifecycle(manager)) {
|
|
1516
|
-
let nodes = manager.getDebugCustomRenderTree(instance.definition.state, instance.state, args);
|
|
1517
|
-
nodes.forEach(node => {
|
|
1518
|
-
let {
|
|
1519
|
-
bucket
|
|
1520
|
-
} = node;
|
|
1521
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
1522
|
-
vm.env.debugRenderTree.create(bucket, node);
|
|
1523
|
-
registerDestructor(instance, () => {
|
|
1524
|
-
vm.env.debugRenderTree?.willDestroy(bucket);
|
|
1525
|
-
});
|
|
1526
|
-
vm.updateWith(new DebugRenderTreeUpdateOpcode(bucket));
|
|
1527
|
-
});
|
|
1528
|
-
} else {
|
|
1529
|
-
let name = getDebugName(definition, manager);
|
|
1530
|
-
vm.env.debugRenderTree.create(instance, {
|
|
1531
|
-
type: 'component',
|
|
1532
|
-
name,
|
|
1533
|
-
args,
|
|
1534
|
-
instance: valueForRef(selfRef)
|
|
1535
|
-
});
|
|
1536
|
-
registerDestructor(instance, () => {
|
|
1537
|
-
vm.env.debugRenderTree?.willDestroy(instance);
|
|
1538
|
-
});
|
|
1539
|
-
vm.updateWith(new DebugRenderTreeUpdateOpcode(instance));
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
vm.stack.push(selfRef);
|
|
1543
|
-
});
|
|
1544
|
-
APPEND_OPCODES.add(VM_GET_COMPONENT_TAG_NAME_OP, (vm, {
|
|
1545
|
-
op1: register
|
|
1546
|
-
}) => {
|
|
1547
|
-
let {
|
|
1548
|
-
definition,
|
|
1549
|
-
state
|
|
1550
|
-
} = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1551
|
-
let {
|
|
1552
|
-
manager
|
|
1553
|
-
} = definition;
|
|
1554
|
-
let tagName = manager.getTagName(state);
|
|
1555
|
-
|
|
1556
|
-
// User provided value from JS, so we don't bother to encode
|
|
1557
|
-
vm.stack.push(tagName);
|
|
1558
|
-
});
|
|
1559
|
-
|
|
1560
|
-
// Dynamic Invocation Only
|
|
1561
|
-
APPEND_OPCODES.add(VM_GET_COMPONENT_LAYOUT_OP, (vm, {
|
|
1562
|
-
op1: register
|
|
1563
|
-
}) => {
|
|
1564
|
-
let instance = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1565
|
-
let {
|
|
1566
|
-
manager,
|
|
1567
|
-
definition
|
|
1568
|
-
} = instance;
|
|
1569
|
-
let {
|
|
1570
|
-
stack
|
|
1571
|
-
} = vm;
|
|
1572
|
-
let {
|
|
1573
|
-
compilable
|
|
1574
|
-
} = definition;
|
|
1575
|
-
if (compilable === null) {
|
|
1576
|
-
let {
|
|
1577
|
-
capabilities
|
|
1578
|
-
} = instance;
|
|
1579
|
-
(!(managerHasCapability(manager, capabilities, InternalComponentCapabilities.dynamicLayout)) && assert(managerHasCapability(manager, capabilities, InternalComponentCapabilities.dynamicLayout)));
|
|
1580
|
-
let resolver = vm.context.resolver;
|
|
1581
|
-
compilable = resolver === null ? null : manager.getDynamicLayout(instance.state, resolver);
|
|
1582
|
-
if (compilable === null) {
|
|
1583
|
-
if (managerHasCapability(manager, capabilities, InternalComponentCapabilities.wrapped)) {
|
|
1584
|
-
compilable = unwrapTemplate(vm.constants.defaultTemplate).asWrappedLayout();
|
|
1585
|
-
} else {
|
|
1586
|
-
compilable = unwrapTemplate(vm.constants.defaultTemplate).asLayout();
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
let handle = compilable.compile(vm.context);
|
|
1591
|
-
stack.push(compilable.symbolTable);
|
|
1592
|
-
stack.push(handle);
|
|
1593
|
-
});
|
|
1594
|
-
APPEND_OPCODES.add(VM_MAIN_OP, (vm, {
|
|
1595
|
-
op1: register
|
|
1596
|
-
}) => {
|
|
1597
|
-
let definition = check(vm.stack.pop());
|
|
1598
|
-
let invocation = check(vm.stack.pop());
|
|
1599
|
-
let {
|
|
1600
|
-
manager,
|
|
1601
|
-
capabilities
|
|
1602
|
-
} = definition;
|
|
1603
|
-
let state = {
|
|
1604
|
-
definition,
|
|
1605
|
-
manager,
|
|
1606
|
-
capabilities,
|
|
1607
|
-
state: null,
|
|
1608
|
-
handle: invocation.handle,
|
|
1609
|
-
table: invocation.symbolTable,
|
|
1610
|
-
lookup: null
|
|
1611
|
-
};
|
|
1612
|
-
vm.loadValue(check(register), state);
|
|
1613
|
-
});
|
|
1614
|
-
APPEND_OPCODES.add(VM_POPULATE_LAYOUT_OP, (vm, {
|
|
1615
|
-
op1: register
|
|
1616
|
-
}) => {
|
|
1617
|
-
let {
|
|
1618
|
-
stack
|
|
1619
|
-
} = vm;
|
|
1620
|
-
|
|
1621
|
-
// In import.meta.env.DEV handles could be ErrHandle objects
|
|
1622
|
-
let handle = check(stack.pop());
|
|
1623
|
-
let table = check(stack.pop());
|
|
1624
|
-
let state = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1625
|
-
state.handle = handle;
|
|
1626
|
-
state.table = table;
|
|
1627
|
-
});
|
|
1628
|
-
APPEND_OPCODES.add(VM_VIRTUAL_ROOT_SCOPE_OP, (vm, {
|
|
1629
|
-
op1: register
|
|
1630
|
-
}) => {
|
|
1631
|
-
let {
|
|
1632
|
-
table,
|
|
1633
|
-
manager,
|
|
1634
|
-
capabilities,
|
|
1635
|
-
state
|
|
1636
|
-
} = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1637
|
-
let owner;
|
|
1638
|
-
if (managerHasCapability(manager, capabilities, InternalComponentCapabilities.hasSubOwner)) {
|
|
1639
|
-
owner = manager.getOwner(state);
|
|
1640
|
-
vm.loadValue($t1, null); // Clear the temp register
|
|
1641
|
-
} else {
|
|
1642
|
-
// Check the temp register to see if an owner was resolved from currying
|
|
1643
|
-
owner = vm.fetchValue($t1);
|
|
1644
|
-
if (owner === null) {
|
|
1645
|
-
// If an owner wasn't found, default to using the current owner. This
|
|
1646
|
-
// will happen for normal dynamic component invocation,
|
|
1647
|
-
// e.g. <SomeClassicEmberComponent/>
|
|
1648
|
-
owner = vm.getOwner();
|
|
1649
|
-
} else {
|
|
1650
|
-
// Else the owner was found, so clear the temp register. This will happen
|
|
1651
|
-
// if we are loading a curried component, e.g. <@someCurriedComponent/>
|
|
1652
|
-
vm.loadValue($t1, null);
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
vm.pushRootScope(table.symbols.length + 1, owner);
|
|
1656
|
-
});
|
|
1657
|
-
APPEND_OPCODES.add(VM_SET_NAMED_VARIABLES_OP, (vm, {
|
|
1658
|
-
op1: register
|
|
1659
|
-
}) => {
|
|
1660
|
-
let state = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1661
|
-
let scope = vm.scope();
|
|
1662
|
-
let args = check(vm.stack.peek());
|
|
1663
|
-
let callerNames = args.named.atNames;
|
|
1664
|
-
for (let i = callerNames.length - 1; i >= 0; i--) {
|
|
1665
|
-
let atName = unwrap(callerNames[i]);
|
|
1666
|
-
let symbol = state.table.symbols.indexOf(atName);
|
|
1667
|
-
let value = args.named.get(atName, true);
|
|
1668
|
-
if (symbol !== -1) scope.bindSymbol(symbol + 1, value);
|
|
1669
|
-
if (state.lookup) state.lookup[atName] = value;
|
|
1670
|
-
}
|
|
1671
|
-
});
|
|
1672
|
-
function bindBlock(symbolName, blockName, state, blocks, vm) {
|
|
1673
|
-
let symbol = state.table.symbols.indexOf(symbolName);
|
|
1674
|
-
let block = blocks.get(blockName);
|
|
1675
|
-
if (symbol !== -1) vm.scope().bindBlock(symbol + 1, block);
|
|
1676
|
-
if (state.lookup) state.lookup[symbolName] = block;
|
|
1677
|
-
}
|
|
1678
|
-
APPEND_OPCODES.add(VM_SET_BLOCKS_OP, (vm, {
|
|
1679
|
-
op1: register
|
|
1680
|
-
}) => {
|
|
1681
|
-
let state = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1682
|
-
let {
|
|
1683
|
-
blocks
|
|
1684
|
-
} = check(vm.stack.peek());
|
|
1685
|
-
for (const [i] of enumerate(blocks.names)) {
|
|
1686
|
-
bindBlock(unwrap(blocks.symbolNames[i]), unwrap(blocks.names[i]), state, blocks, vm);
|
|
1687
|
-
}
|
|
1688
|
-
});
|
|
1689
|
-
|
|
1690
|
-
// Dynamic Invocation Only
|
|
1691
|
-
APPEND_OPCODES.add(VM_INVOKE_COMPONENT_LAYOUT_OP, (vm, {
|
|
1692
|
-
op1: register
|
|
1693
|
-
}) => {
|
|
1694
|
-
let state = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1695
|
-
vm.call(state.handle);
|
|
1696
|
-
});
|
|
1697
|
-
APPEND_OPCODES.add(VM_DID_RENDER_LAYOUT_OP, (vm, {
|
|
1698
|
-
op1: register
|
|
1699
|
-
}) => {
|
|
1700
|
-
let instance = check(vm.fetchValue(check(register, CheckRegister)));
|
|
1701
|
-
let {
|
|
1702
|
-
manager,
|
|
1703
|
-
state,
|
|
1704
|
-
capabilities
|
|
1705
|
-
} = instance;
|
|
1706
|
-
let bounds = vm.tree().popBlock();
|
|
1707
|
-
if (vm.env.debugRenderTree !== undefined) {
|
|
1708
|
-
if (hasCustomDebugRenderTreeLifecycle(manager)) {
|
|
1709
|
-
let nodes = manager.getDebugCustomRenderTree(instance.definition.state, state, EMPTY_ARGS);
|
|
1710
|
-
nodes.reverse().forEach(node => {
|
|
1711
|
-
let {
|
|
1712
|
-
bucket
|
|
1713
|
-
} = node;
|
|
1714
|
-
|
|
1715
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
1716
|
-
vm.env.debugRenderTree.didRender(bucket, bounds);
|
|
1717
|
-
vm.updateWith(new DebugRenderTreeDidRenderOpcode(bucket, bounds));
|
|
1718
|
-
});
|
|
1719
|
-
} else {
|
|
1720
|
-
vm.env.debugRenderTree.didRender(instance, bounds);
|
|
1721
|
-
vm.updateWith(new DebugRenderTreeDidRenderOpcode(instance, bounds));
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
if (managerHasCapability(manager, capabilities, InternalComponentCapabilities.createInstance)) {
|
|
1725
|
-
let mgr = check(manager);
|
|
1726
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call -- @fixme
|
|
1727
|
-
mgr.didRenderLayout(state, bounds);
|
|
1728
|
-
vm.env.didCreate(instance);
|
|
1729
|
-
vm.updateWith(new DidUpdateLayoutOpcode(instance, bounds));
|
|
1730
|
-
}
|
|
1731
|
-
});
|
|
1732
|
-
APPEND_OPCODES.add(VM_COMMIT_COMPONENT_TRANSACTION_OP, vm => {
|
|
1733
|
-
vm.commitCacheGroup();
|
|
1734
|
-
});
|
|
1735
|
-
class UpdateComponentOpcode {
|
|
1736
|
-
constructor(component, manager, dynamicScope) {
|
|
1737
|
-
this.component = component;
|
|
1738
|
-
this.manager = manager;
|
|
1739
|
-
this.dynamicScope = dynamicScope;
|
|
1740
|
-
}
|
|
1741
|
-
evaluate(_vm) {
|
|
1742
|
-
let {
|
|
1743
|
-
component,
|
|
1744
|
-
manager,
|
|
1745
|
-
dynamicScope
|
|
1746
|
-
} = this;
|
|
1747
|
-
manager.update(component, dynamicScope);
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
class DidUpdateLayoutOpcode {
|
|
1751
|
-
constructor(component, bounds) {
|
|
1752
|
-
this.component = component;
|
|
1753
|
-
this.bounds = bounds;
|
|
1754
|
-
}
|
|
1755
|
-
evaluate(vm) {
|
|
1756
|
-
let {
|
|
1757
|
-
component,
|
|
1758
|
-
bounds
|
|
1759
|
-
} = this;
|
|
1760
|
-
let {
|
|
1761
|
-
manager,
|
|
1762
|
-
state
|
|
1763
|
-
} = component;
|
|
1764
|
-
manager.didUpdateLayout(state, bounds);
|
|
1765
|
-
vm.env.didUpdate(component);
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
class DebugRenderTreeUpdateOpcode {
|
|
1769
|
-
constructor(bucket) {
|
|
1770
|
-
this.bucket = bucket;
|
|
1771
|
-
}
|
|
1772
|
-
evaluate(vm) {
|
|
1773
|
-
vm.env.debugRenderTree?.update(this.bucket);
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
class DebugRenderTreeDidRenderOpcode {
|
|
1777
|
-
constructor(bucket, bounds) {
|
|
1778
|
-
this.bucket = bucket;
|
|
1779
|
-
this.bounds = bounds;
|
|
1780
|
-
}
|
|
1781
|
-
evaluate(vm) {
|
|
1782
|
-
vm.env.debugRenderTree?.didRender(this.bucket, this.bounds);
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
class ReferenceChecker {
|
|
1787
|
-
validate(value) {
|
|
1788
|
-
return typeof value === 'object' && value !== null && REFERENCE in value;
|
|
1789
|
-
}
|
|
1790
|
-
expected() {
|
|
1791
|
-
return `Reference`;
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
const CheckReference = new ReferenceChecker();
|
|
1795
|
-
|
|
1796
|
-
/*
|
|
1797
|
-
The calling convention is:
|
|
1798
|
-
|
|
1799
|
-
* 0-N block arguments at the bottom
|
|
1800
|
-
* 0-N positional arguments next (left-to-right)
|
|
1801
|
-
* 0-N named arguments next
|
|
1802
|
-
*/
|
|
1803
|
-
|
|
1804
|
-
class VMArgumentsImpl {
|
|
1805
|
-
stack = null;
|
|
1806
|
-
positional = new PositionalArgumentsImpl();
|
|
1807
|
-
named = new NamedArgumentsImpl();
|
|
1808
|
-
blocks = new BlockArgumentsImpl();
|
|
1809
|
-
constructor() {
|
|
1810
|
-
setLocalDebugType('args', this);
|
|
1811
|
-
}
|
|
1812
|
-
empty(stack) {
|
|
1813
|
-
let base = stack.registers[$sp] + 1;
|
|
1814
|
-
this.named.empty(stack, base);
|
|
1815
|
-
this.positional.empty(stack, base);
|
|
1816
|
-
this.blocks.empty(stack, base);
|
|
1817
|
-
return this;
|
|
1818
|
-
}
|
|
1819
|
-
setup(stack, names, blockNames, positionalCount, atNames) {
|
|
1820
|
-
this.stack = stack;
|
|
1821
|
-
|
|
1822
|
-
/*
|
|
1823
|
-
| ... | blocks | positional | named |
|
|
1824
|
-
| ... | b0 b1 | p0 p1 p2 p3 | n0 n1 |
|
|
1825
|
-
index | ... | 4/5/6 7/8/9 | 10 11 12 13 | 14 15 |
|
|
1826
|
-
^ ^ ^ ^
|
|
1827
|
-
bbase pbase nbase sp
|
|
1828
|
-
*/
|
|
1829
|
-
|
|
1830
|
-
let named = this.named;
|
|
1831
|
-
let namedCount = names.length;
|
|
1832
|
-
let namedBase = stack.registers[$sp] - namedCount + 1;
|
|
1833
|
-
named.setup(stack, namedBase, namedCount, names, atNames);
|
|
1834
|
-
let positional = this.positional;
|
|
1835
|
-
let positionalBase = namedBase - positionalCount;
|
|
1836
|
-
positional.setup(stack, positionalBase, positionalCount);
|
|
1837
|
-
let blocks = this.blocks;
|
|
1838
|
-
let blocksCount = blockNames.length;
|
|
1839
|
-
let blocksBase = positionalBase - blocksCount * 3;
|
|
1840
|
-
blocks.setup(stack, blocksBase, blocksCount, blockNames);
|
|
1841
|
-
}
|
|
1842
|
-
get base() {
|
|
1843
|
-
return this.blocks.base;
|
|
1844
|
-
}
|
|
1845
|
-
get length() {
|
|
1846
|
-
return this.positional.length + this.named.length + this.blocks.length * 3;
|
|
1847
|
-
}
|
|
1848
|
-
at(pos) {
|
|
1849
|
-
return this.positional.at(pos);
|
|
1850
|
-
}
|
|
1851
|
-
realloc(offset) {
|
|
1852
|
-
let {
|
|
1853
|
-
stack
|
|
1854
|
-
} = this;
|
|
1855
|
-
if (offset > 0 && stack !== null) {
|
|
1856
|
-
let {
|
|
1857
|
-
positional,
|
|
1858
|
-
named
|
|
1859
|
-
} = this;
|
|
1860
|
-
let newBase = positional.base + offset;
|
|
1861
|
-
let length = positional.length + named.length;
|
|
1862
|
-
for (let i = length - 1; i >= 0; i--) {
|
|
1863
|
-
stack.copy(i + positional.base, i + newBase);
|
|
1864
|
-
}
|
|
1865
|
-
positional.base += offset;
|
|
1866
|
-
named.base += offset;
|
|
1867
|
-
stack.registers[$sp] += offset;
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1870
|
-
capture() {
|
|
1871
|
-
let positional = this.positional.length === 0 ? EMPTY_POSITIONAL : this.positional.capture();
|
|
1872
|
-
let named = this.named.length === 0 ? EMPTY_NAMED : this.named.capture();
|
|
1873
|
-
return {
|
|
1874
|
-
named,
|
|
1875
|
-
positional
|
|
1876
|
-
};
|
|
1877
|
-
}
|
|
1878
|
-
clear() {
|
|
1879
|
-
let {
|
|
1880
|
-
stack,
|
|
1881
|
-
length
|
|
1882
|
-
} = this;
|
|
1883
|
-
if (length > 0 && stack !== null) stack.pop(length);
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
const EMPTY_REFERENCES = emptyArray();
|
|
1887
|
-
class PositionalArgumentsImpl {
|
|
1888
|
-
base = 0;
|
|
1889
|
-
length = 0;
|
|
1890
|
-
stack = null;
|
|
1891
|
-
_references = null;
|
|
1892
|
-
constructor() {
|
|
1893
|
-
setLocalDebugType('args:positional', this);
|
|
1894
|
-
}
|
|
1895
|
-
empty(stack, base) {
|
|
1896
|
-
this.stack = stack;
|
|
1897
|
-
this.base = base;
|
|
1898
|
-
this.length = 0;
|
|
1899
|
-
this._references = EMPTY_REFERENCES;
|
|
1900
|
-
}
|
|
1901
|
-
setup(stack, base, length) {
|
|
1902
|
-
this.stack = stack;
|
|
1903
|
-
this.base = base;
|
|
1904
|
-
this.length = length;
|
|
1905
|
-
if (length === 0) {
|
|
1906
|
-
this._references = EMPTY_REFERENCES;
|
|
1907
|
-
} else {
|
|
1908
|
-
this._references = null;
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
at(position) {
|
|
1912
|
-
let {
|
|
1913
|
-
base,
|
|
1914
|
-
length,
|
|
1915
|
-
stack
|
|
1916
|
-
} = this;
|
|
1917
|
-
if (position < 0 || position >= length) {
|
|
1918
|
-
return UNDEFINED_REFERENCE;
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1921
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
1922
|
-
return check(stack.get(position, base));
|
|
1923
|
-
}
|
|
1924
|
-
capture() {
|
|
1925
|
-
return this.references;
|
|
1926
|
-
}
|
|
1927
|
-
prepend(other) {
|
|
1928
|
-
let additions = other.length;
|
|
1929
|
-
if (additions > 0) {
|
|
1930
|
-
let {
|
|
1931
|
-
base,
|
|
1932
|
-
length,
|
|
1933
|
-
stack
|
|
1934
|
-
} = this;
|
|
1935
|
-
this.base = base = base - additions;
|
|
1936
|
-
this.length = length + additions;
|
|
1937
|
-
for (let i = 0; i < additions; i++) {
|
|
1938
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
1939
|
-
stack.set(other[i], i, base);
|
|
1940
|
-
}
|
|
1941
|
-
this._references = null;
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
get references() {
|
|
1945
|
-
let references = this._references;
|
|
1946
|
-
if (!references) {
|
|
1947
|
-
let {
|
|
1948
|
-
stack,
|
|
1949
|
-
base,
|
|
1950
|
-
length
|
|
1951
|
-
} = this;
|
|
1952
|
-
|
|
1953
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
1954
|
-
references = this._references = stack.slice(base, base + length);
|
|
1955
|
-
}
|
|
1956
|
-
return references;
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
class NamedArgumentsImpl {
|
|
1960
|
-
base = 0;
|
|
1961
|
-
length = 0;
|
|
1962
|
-
_references = null;
|
|
1963
|
-
_names = EMPTY_STRING_ARRAY;
|
|
1964
|
-
_atNames = EMPTY_STRING_ARRAY;
|
|
1965
|
-
constructor() {
|
|
1966
|
-
setLocalDebugType('args:named', this);
|
|
1967
|
-
}
|
|
1968
|
-
empty(stack, base) {
|
|
1969
|
-
this.stack = stack;
|
|
1970
|
-
this.base = base;
|
|
1971
|
-
this.length = 0;
|
|
1972
|
-
this._references = EMPTY_REFERENCES;
|
|
1973
|
-
this._names = EMPTY_STRING_ARRAY;
|
|
1974
|
-
this._atNames = EMPTY_STRING_ARRAY;
|
|
1975
|
-
}
|
|
1976
|
-
setup(stack, base, length, names, atNames) {
|
|
1977
|
-
this.stack = stack;
|
|
1978
|
-
this.base = base;
|
|
1979
|
-
this.length = length;
|
|
1980
|
-
if (length === 0) {
|
|
1981
|
-
this._references = EMPTY_REFERENCES;
|
|
1982
|
-
this._names = EMPTY_STRING_ARRAY;
|
|
1983
|
-
this._atNames = EMPTY_STRING_ARRAY;
|
|
1984
|
-
} else {
|
|
1985
|
-
this._references = null;
|
|
1986
|
-
if (atNames) {
|
|
1987
|
-
this._names = null;
|
|
1988
|
-
this._atNames = names;
|
|
1989
|
-
} else {
|
|
1990
|
-
this._names = names;
|
|
1991
|
-
this._atNames = null;
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
get names() {
|
|
1996
|
-
let names = this._names;
|
|
1997
|
-
if (!names) {
|
|
1998
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
1999
|
-
names = this._names = this._atNames.map(this.toSyntheticName);
|
|
2000
|
-
}
|
|
2001
|
-
return names;
|
|
2002
|
-
}
|
|
2003
|
-
get atNames() {
|
|
2004
|
-
let atNames = this._atNames;
|
|
2005
|
-
if (!atNames) {
|
|
2006
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
2007
|
-
atNames = this._atNames = this._names.map(this.toAtName);
|
|
2008
|
-
}
|
|
2009
|
-
return atNames;
|
|
2010
|
-
}
|
|
2011
|
-
has(name) {
|
|
2012
|
-
return this.names.indexOf(name) !== -1;
|
|
2013
|
-
}
|
|
2014
|
-
get(name, atNames = false) {
|
|
2015
|
-
let {
|
|
2016
|
-
base,
|
|
2017
|
-
stack
|
|
2018
|
-
} = this;
|
|
2019
|
-
let names = atNames ? this.atNames : this.names;
|
|
2020
|
-
let idx = names.indexOf(name);
|
|
2021
|
-
if (idx === -1) {
|
|
2022
|
-
return UNDEFINED_REFERENCE;
|
|
2023
|
-
}
|
|
2024
|
-
let ref = stack.get(idx, base);
|
|
2025
|
-
{
|
|
2026
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
2027
|
-
return createDebugAliasRef(atNames ? name : `@${name}`, ref);
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
capture() {
|
|
2031
|
-
let {
|
|
2032
|
-
names,
|
|
2033
|
-
references
|
|
2034
|
-
} = this;
|
|
2035
|
-
let map = dict();
|
|
2036
|
-
for (const [i, name] of enumerate(names)) {
|
|
2037
|
-
{
|
|
2038
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
2039
|
-
map[name] = createDebugAliasRef(`@${name}`, unwrap(references[i]));
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
return map;
|
|
2043
|
-
}
|
|
2044
|
-
merge(other) {
|
|
2045
|
-
let keys = Object.keys(other);
|
|
2046
|
-
if (keys.length > 0) {
|
|
2047
|
-
let {
|
|
2048
|
-
names,
|
|
2049
|
-
length,
|
|
2050
|
-
stack
|
|
2051
|
-
} = this;
|
|
2052
|
-
let newNames = names.slice();
|
|
2053
|
-
for (const name of keys) {
|
|
2054
|
-
let idx = newNames.indexOf(name);
|
|
2055
|
-
if (idx === -1) {
|
|
2056
|
-
length = newNames.push(name);
|
|
2057
|
-
stack.push(other[name]);
|
|
2058
|
-
}
|
|
2059
|
-
}
|
|
2060
|
-
this.length = length;
|
|
2061
|
-
this._references = null;
|
|
2062
|
-
this._names = newNames;
|
|
2063
|
-
this._atNames = null;
|
|
2064
|
-
}
|
|
2065
|
-
}
|
|
2066
|
-
get references() {
|
|
2067
|
-
let references = this._references;
|
|
2068
|
-
if (!references) {
|
|
2069
|
-
let {
|
|
2070
|
-
base,
|
|
2071
|
-
length,
|
|
2072
|
-
stack
|
|
2073
|
-
} = this;
|
|
2074
|
-
references = this._references = stack.slice(base, base + length);
|
|
2075
|
-
}
|
|
2076
|
-
return references;
|
|
2077
|
-
}
|
|
2078
|
-
toSyntheticName(name) {
|
|
2079
|
-
return name.slice(1);
|
|
2080
|
-
}
|
|
2081
|
-
toAtName(name) {
|
|
2082
|
-
return `@${name}`;
|
|
2083
|
-
}
|
|
2084
|
-
}
|
|
2085
|
-
function toSymbolName(name) {
|
|
2086
|
-
return `&${name}`;
|
|
2087
|
-
}
|
|
2088
|
-
const EMPTY_BLOCK_VALUES = emptyArray();
|
|
2089
|
-
class BlockArgumentsImpl {
|
|
2090
|
-
internalValues = null;
|
|
2091
|
-
_symbolNames = null;
|
|
2092
|
-
internalTag = null;
|
|
2093
|
-
names = EMPTY_STRING_ARRAY;
|
|
2094
|
-
length = 0;
|
|
2095
|
-
base = 0;
|
|
2096
|
-
constructor() {
|
|
2097
|
-
setLocalDebugType('args:blocks', this);
|
|
2098
|
-
}
|
|
2099
|
-
empty(stack, base) {
|
|
2100
|
-
this.stack = stack;
|
|
2101
|
-
this.names = EMPTY_STRING_ARRAY;
|
|
2102
|
-
this.base = base;
|
|
2103
|
-
this.length = 0;
|
|
2104
|
-
this._symbolNames = null;
|
|
2105
|
-
this.internalTag = CONSTANT_TAG;
|
|
2106
|
-
this.internalValues = EMPTY_BLOCK_VALUES;
|
|
2107
|
-
}
|
|
2108
|
-
setup(stack, base, length, names) {
|
|
2109
|
-
this.stack = stack;
|
|
2110
|
-
this.names = names;
|
|
2111
|
-
this.base = base;
|
|
2112
|
-
this.length = length;
|
|
2113
|
-
this._symbolNames = null;
|
|
2114
|
-
if (length === 0) {
|
|
2115
|
-
this.internalTag = CONSTANT_TAG;
|
|
2116
|
-
this.internalValues = EMPTY_BLOCK_VALUES;
|
|
2117
|
-
} else {
|
|
2118
|
-
this.internalTag = null;
|
|
2119
|
-
this.internalValues = null;
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
get values() {
|
|
2123
|
-
let values = this.internalValues;
|
|
2124
|
-
if (!values) {
|
|
2125
|
-
let {
|
|
2126
|
-
base,
|
|
2127
|
-
length,
|
|
2128
|
-
stack
|
|
2129
|
-
} = this;
|
|
2130
|
-
values = this.internalValues = stack.slice(base, base + length * 3);
|
|
2131
|
-
}
|
|
2132
|
-
return values;
|
|
2133
|
-
}
|
|
2134
|
-
has(name) {
|
|
2135
|
-
return this.names.indexOf(name) !== -1;
|
|
2136
|
-
}
|
|
2137
|
-
get(name) {
|
|
2138
|
-
let idx = this.names.indexOf(name);
|
|
2139
|
-
if (idx === -1) {
|
|
2140
|
-
return null;
|
|
2141
|
-
}
|
|
2142
|
-
let {
|
|
2143
|
-
base,
|
|
2144
|
-
stack
|
|
2145
|
-
} = this;
|
|
2146
|
-
let table = check(stack.get(idx * 3, base));
|
|
2147
|
-
let scope = check(stack.get(idx * 3 + 1, base));
|
|
2148
|
-
let handle = check(stack.get(idx * 3 + 2, base));
|
|
2149
|
-
return handle === null ? null : [handle, scope, table];
|
|
2150
|
-
}
|
|
2151
|
-
capture() {
|
|
2152
|
-
return new CapturedBlockArgumentsImpl(this.names, this.values);
|
|
2153
|
-
}
|
|
2154
|
-
get symbolNames() {
|
|
2155
|
-
let symbolNames = this._symbolNames;
|
|
2156
|
-
if (symbolNames === null) {
|
|
2157
|
-
symbolNames = this._symbolNames = this.names.map(toSymbolName);
|
|
2158
|
-
}
|
|
2159
|
-
return symbolNames;
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
class CapturedBlockArgumentsImpl {
|
|
2163
|
-
length;
|
|
2164
|
-
constructor(names, values) {
|
|
2165
|
-
this.names = names;
|
|
2166
|
-
this.values = values;
|
|
2167
|
-
this.length = names.length;
|
|
2168
|
-
}
|
|
2169
|
-
has(name) {
|
|
2170
|
-
return this.names.indexOf(name) !== -1;
|
|
2171
|
-
}
|
|
2172
|
-
get(name) {
|
|
2173
|
-
let idx = this.names.indexOf(name);
|
|
2174
|
-
if (idx === -1) return null;
|
|
2175
|
-
return [this.values[idx * 3 + 2], this.values[idx * 3 + 1], this.values[idx * 3]];
|
|
2176
|
-
}
|
|
2177
|
-
}
|
|
2178
|
-
function createCapturedArgs(named, positional) {
|
|
2179
|
-
return {
|
|
2180
|
-
named,
|
|
2181
|
-
positional
|
|
2182
|
-
};
|
|
2183
|
-
}
|
|
2184
|
-
function reifyNamed(named) {
|
|
2185
|
-
let reified = dict();
|
|
2186
|
-
for (const [key, value] of Object.entries(named)) {
|
|
2187
|
-
reified[key] = valueForRef(value);
|
|
2188
|
-
}
|
|
2189
|
-
return reified;
|
|
2190
|
-
}
|
|
2191
|
-
function reifyPositional(positional) {
|
|
2192
|
-
return positional.map(valueForRef);
|
|
2193
|
-
}
|
|
2194
|
-
function reifyArgs(args) {
|
|
2195
|
-
return {
|
|
2196
|
-
named: reifyNamed(args.named),
|
|
2197
|
-
positional: reifyPositional(args.positional)
|
|
2198
|
-
};
|
|
2199
|
-
}
|
|
2200
|
-
const ARGUMENT_ERROR = Symbol('ARGUMENT_ERROR');
|
|
2201
|
-
function isArgumentError(arg) {
|
|
2202
|
-
return arg !== null && typeof arg === 'object' && arg[ARGUMENT_ERROR];
|
|
2203
|
-
}
|
|
2204
|
-
|
|
2205
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2206
|
-
function ArgumentErrorImpl(error) {
|
|
2207
|
-
return {
|
|
2208
|
-
[ARGUMENT_ERROR]: true,
|
|
2209
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
2210
|
-
error
|
|
2211
|
-
};
|
|
2212
|
-
}
|
|
2213
|
-
function reifyNamedDebug(named) {
|
|
2214
|
-
let reified = dict();
|
|
2215
|
-
for (const [key, value] of Object.entries(named)) {
|
|
2216
|
-
try {
|
|
2217
|
-
reified[key] = valueForRef(value);
|
|
2218
|
-
} catch (e) {
|
|
2219
|
-
reified[key] = ArgumentErrorImpl(e);
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
return reified;
|
|
2223
|
-
}
|
|
2224
|
-
function reifyPositionalDebug(positional) {
|
|
2225
|
-
return positional.map(p => {
|
|
2226
|
-
try {
|
|
2227
|
-
return valueForRef(p);
|
|
2228
|
-
} catch (e) {
|
|
2229
|
-
return ArgumentErrorImpl(e);
|
|
2230
|
-
}
|
|
2231
|
-
});
|
|
2232
|
-
}
|
|
2233
|
-
function reifyArgsDebug(args) {
|
|
2234
|
-
let named = reifyNamedDebug(args.named);
|
|
2235
|
-
let positional = reifyPositionalDebug(args.positional);
|
|
2236
|
-
return {
|
|
2237
|
-
named,
|
|
2238
|
-
positional
|
|
2239
|
-
};
|
|
2240
|
-
}
|
|
2241
|
-
const EMPTY_NAMED = Object.freeze(Object.create(null));
|
|
2242
|
-
const EMPTY_POSITIONAL = EMPTY_REFERENCES;
|
|
2243
|
-
const EMPTY_ARGS = createCapturedArgs(EMPTY_NAMED, EMPTY_POSITIONAL);
|
|
2244
|
-
|
|
2245
|
-
function createConcatRef(partsRefs) {
|
|
2246
|
-
return createComputeRef(() => {
|
|
2247
|
-
const parts = [];
|
|
2248
|
-
for (const ref of partsRefs) {
|
|
2249
|
-
const value = valueForRef(ref);
|
|
2250
|
-
if (value !== null && value !== undefined) {
|
|
2251
|
-
parts.push(castToString(value));
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
if (parts.length > 0) {
|
|
2255
|
-
return parts.join('');
|
|
2256
|
-
}
|
|
2257
|
-
return null;
|
|
2258
|
-
});
|
|
2259
|
-
}
|
|
2260
|
-
function castToString(value) {
|
|
2261
|
-
if (typeof value === 'string') {
|
|
2262
|
-
return value;
|
|
2263
|
-
} else if (typeof value.toString !== 'function') {
|
|
2264
|
-
return '';
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2267
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- @fixme
|
|
2268
|
-
return String(value);
|
|
2269
|
-
}
|
|
2270
|
-
|
|
2271
|
-
APPEND_OPCODES.add(VM_CURRY_OP, (vm, {
|
|
2272
|
-
op1: type,
|
|
2273
|
-
op2: _isStrict
|
|
2274
|
-
}) => {
|
|
2275
|
-
let stack = vm.stack;
|
|
2276
|
-
let definition = check(stack.pop());
|
|
2277
|
-
let capturedArgs = check(stack.pop());
|
|
2278
|
-
let owner = vm.getOwner();
|
|
2279
|
-
let resolver = vm.context.resolver;
|
|
2280
|
-
let isStrict = false;
|
|
2281
|
-
{
|
|
2282
|
-
// strict check only happens in import.meta.env.DEV builds, no reason to load it otherwise
|
|
2283
|
-
isStrict = vm.constants.getValue(decodeHandle(_isStrict));
|
|
2284
|
-
}
|
|
2285
|
-
vm.loadValue($v0, createCurryRef(type, definition, owner, capturedArgs, resolver, isStrict));
|
|
2286
|
-
});
|
|
2287
|
-
APPEND_OPCODES.add(VM_DYNAMIC_HELPER_OP, vm => {
|
|
2288
|
-
let stack = vm.stack;
|
|
2289
|
-
let ref = check(stack.pop());
|
|
2290
|
-
let args = check(stack.pop()).capture();
|
|
2291
|
-
let helperRef;
|
|
2292
|
-
let initialOwner = vm.getOwner();
|
|
2293
|
-
let helperInstanceRef = createComputeRef(() => {
|
|
2294
|
-
if (helperRef !== undefined) {
|
|
2295
|
-
destroy(helperRef);
|
|
2296
|
-
}
|
|
2297
|
-
let definition = valueForRef(ref);
|
|
2298
|
-
if (isCurriedType(definition, CURRIED_HELPER)) {
|
|
2299
|
-
let {
|
|
2300
|
-
definition: resolvedDef,
|
|
2301
|
-
owner,
|
|
2302
|
-
positional,
|
|
2303
|
-
named
|
|
2304
|
-
} = resolveCurriedValue(definition);
|
|
2305
|
-
let helper = resolveHelper(resolvedDef, ref);
|
|
2306
|
-
if (named !== undefined) {
|
|
2307
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
2308
|
-
args.named = assign({}, ...named, args.named);
|
|
2309
|
-
}
|
|
2310
|
-
if (positional !== undefined) {
|
|
2311
|
-
args.positional = positional.concat(args.positional);
|
|
2312
|
-
}
|
|
2313
|
-
helperRef = helper(args, owner);
|
|
2314
|
-
associateDestroyableChild(helperInstanceRef, helperRef);
|
|
2315
|
-
} else if (isIndexable$1(definition)) {
|
|
2316
|
-
let helper = resolveHelper(definition, ref);
|
|
2317
|
-
helperRef = helper(args, initialOwner);
|
|
2318
|
-
if (_hasDestroyableChildren(helperRef)) {
|
|
2319
|
-
associateDestroyableChild(helperInstanceRef, helperRef);
|
|
2320
|
-
}
|
|
2321
|
-
} else {
|
|
2322
|
-
helperRef = UNDEFINED_REFERENCE;
|
|
2323
|
-
}
|
|
2324
|
-
});
|
|
2325
|
-
let helperValueRef = createComputeRef(() => {
|
|
2326
|
-
valueForRef(helperInstanceRef);
|
|
2327
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
2328
|
-
return valueForRef(helperRef);
|
|
2329
|
-
});
|
|
2330
|
-
vm.associateDestroyable(helperInstanceRef);
|
|
2331
|
-
vm.loadValue($v0, helperValueRef);
|
|
2332
|
-
});
|
|
2333
|
-
function resolveHelper(definition, ref) {
|
|
2334
|
-
let managerOrHelper = getInternalHelperManager(definition, true);
|
|
2335
|
-
let helper;
|
|
2336
|
-
if (managerOrHelper === null) {
|
|
2337
|
-
helper = null;
|
|
2338
|
-
} else {
|
|
2339
|
-
helper = typeof managerOrHelper === 'function' ? managerOrHelper : managerOrHelper.getHelper(definition);
|
|
2340
|
-
}
|
|
2341
|
-
debugAssert(helper !== null, () => `Expected a dynamic helper definition, but received an object or function that did not have a helper manager associated with it. The dynamic invocation was \`{{${ref.debugLabel}}}\` or \`(${ref.debugLabel})\`, and the incorrect definition is the value at the path \`${ref.debugLabel}\`, which was: ${debugToString?.(definition)}`);
|
|
2342
|
-
return helper;
|
|
2343
|
-
}
|
|
2344
|
-
APPEND_OPCODES.add(VM_HELPER_OP, (vm, {
|
|
2345
|
-
op1: handle
|
|
2346
|
-
}) => {
|
|
2347
|
-
let stack = vm.stack;
|
|
2348
|
-
let helper = check(vm.constants.getValue(handle));
|
|
2349
|
-
let args = check(stack.pop());
|
|
2350
|
-
let value = helper(args.capture(), vm.getOwner(), vm.dynamicScope());
|
|
2351
|
-
if (_hasDestroyableChildren(value)) {
|
|
2352
|
-
vm.associateDestroyable(value);
|
|
2353
|
-
}
|
|
2354
|
-
vm.loadValue($v0, value);
|
|
2355
|
-
});
|
|
2356
|
-
APPEND_OPCODES.add(VM_GET_VARIABLE_OP, (vm, {
|
|
2357
|
-
op1: symbol
|
|
2358
|
-
}) => {
|
|
2359
|
-
let expr = vm.referenceForSymbol(symbol);
|
|
2360
|
-
vm.stack.push(expr);
|
|
2361
|
-
});
|
|
2362
|
-
APPEND_OPCODES.add(VM_SET_VARIABLE_OP, (vm, {
|
|
2363
|
-
op1: symbol
|
|
2364
|
-
}) => {
|
|
2365
|
-
let expr = check(vm.stack.pop());
|
|
2366
|
-
vm.scope().bindSymbol(symbol, expr);
|
|
2367
|
-
});
|
|
2368
|
-
APPEND_OPCODES.add(VM_SET_BLOCK_OP, (vm, {
|
|
2369
|
-
op1: symbol
|
|
2370
|
-
}) => {
|
|
2371
|
-
let handle = check(vm.stack.pop());
|
|
2372
|
-
let scope = check(vm.stack.pop());
|
|
2373
|
-
let table = check(vm.stack.pop());
|
|
2374
|
-
vm.scope().bindBlock(symbol, [handle, scope, table]);
|
|
2375
|
-
});
|
|
2376
|
-
APPEND_OPCODES.add(VM_ROOT_SCOPE_OP, (vm, {
|
|
2377
|
-
op1: size
|
|
2378
|
-
}) => {
|
|
2379
|
-
vm.pushRootScope(size, vm.getOwner());
|
|
2380
|
-
});
|
|
2381
|
-
APPEND_OPCODES.add(VM_GET_PROPERTY_OP, (vm, {
|
|
2382
|
-
op1: _key
|
|
2383
|
-
}) => {
|
|
2384
|
-
let key = vm.constants.getValue(_key);
|
|
2385
|
-
let expr = check(vm.stack.pop());
|
|
2386
|
-
vm.stack.push(childRefFor(expr, key));
|
|
2387
|
-
});
|
|
2388
|
-
APPEND_OPCODES.add(VM_GET_BLOCK_OP, (vm, {
|
|
2389
|
-
op1: _block
|
|
2390
|
-
}) => {
|
|
2391
|
-
let {
|
|
2392
|
-
stack
|
|
2393
|
-
} = vm;
|
|
2394
|
-
let block = vm.scope().getBlock(_block);
|
|
2395
|
-
stack.push(block);
|
|
2396
|
-
});
|
|
2397
|
-
APPEND_OPCODES.add(VM_SPREAD_BLOCK_OP, vm => {
|
|
2398
|
-
let {
|
|
2399
|
-
stack
|
|
2400
|
-
} = vm;
|
|
2401
|
-
let block = check(stack.pop());
|
|
2402
|
-
if (block && !isUndefinedReference(block)) {
|
|
2403
|
-
let [handleOrCompilable, scope, table] = block;
|
|
2404
|
-
stack.push(table);
|
|
2405
|
-
stack.push(scope);
|
|
2406
|
-
stack.push(handleOrCompilable);
|
|
2407
|
-
} else {
|
|
2408
|
-
stack.push(null);
|
|
2409
|
-
stack.push(null);
|
|
2410
|
-
stack.push(null);
|
|
2411
|
-
}
|
|
2412
|
-
});
|
|
2413
|
-
function isUndefinedReference(input) {
|
|
2414
|
-
return input === UNDEFINED_REFERENCE;
|
|
2415
|
-
}
|
|
2416
|
-
APPEND_OPCODES.add(VM_HAS_BLOCK_OP, vm => {
|
|
2417
|
-
let {
|
|
2418
|
-
stack
|
|
2419
|
-
} = vm;
|
|
2420
|
-
let block = check(stack.pop());
|
|
2421
|
-
if (block && !isUndefinedReference(block)) {
|
|
2422
|
-
stack.push(TRUE_REFERENCE);
|
|
2423
|
-
} else {
|
|
2424
|
-
stack.push(FALSE_REFERENCE);
|
|
2425
|
-
}
|
|
2426
|
-
});
|
|
2427
|
-
APPEND_OPCODES.add(VM_HAS_BLOCK_PARAMS_OP, vm => {
|
|
2428
|
-
// FIXME(mmun): should only need to push the symbol table
|
|
2429
|
-
vm.stack.pop();
|
|
2430
|
-
vm.stack.pop();
|
|
2431
|
-
let table = check(vm.stack.pop());
|
|
2432
|
-
let hasBlockParams = table && table.parameters.length;
|
|
2433
|
-
vm.stack.push(hasBlockParams ? TRUE_REFERENCE : FALSE_REFERENCE);
|
|
2434
|
-
});
|
|
2435
|
-
APPEND_OPCODES.add(VM_CONCAT_OP, (vm, {
|
|
2436
|
-
op1: count
|
|
2437
|
-
}) => {
|
|
2438
|
-
let out = new Array(count);
|
|
2439
|
-
for (let i = count; i > 0; i--) {
|
|
2440
|
-
let offset = i - 1;
|
|
2441
|
-
out[offset] = check(vm.stack.pop());
|
|
2442
|
-
}
|
|
2443
|
-
vm.stack.push(createConcatRef(out));
|
|
2444
|
-
});
|
|
2445
|
-
APPEND_OPCODES.add(VM_IF_INLINE_OP, vm => {
|
|
2446
|
-
let condition = check(vm.stack.pop());
|
|
2447
|
-
let truthy = check(vm.stack.pop());
|
|
2448
|
-
let falsy = check(vm.stack.pop());
|
|
2449
|
-
vm.stack.push(createComputeRef(() => {
|
|
2450
|
-
if (toBool(valueForRef(condition))) {
|
|
2451
|
-
return valueForRef(truthy);
|
|
2452
|
-
} else {
|
|
2453
|
-
return valueForRef(falsy);
|
|
2454
|
-
}
|
|
2455
|
-
}));
|
|
2456
|
-
});
|
|
2457
|
-
APPEND_OPCODES.add(VM_NOT_OP, vm => {
|
|
2458
|
-
let ref = check(vm.stack.pop());
|
|
2459
|
-
vm.stack.push(createComputeRef(() => {
|
|
2460
|
-
return !toBool(valueForRef(ref));
|
|
2461
|
-
}));
|
|
2462
|
-
});
|
|
2463
|
-
APPEND_OPCODES.add(VM_GET_DYNAMIC_VAR_OP, vm => {
|
|
2464
|
-
let scope = vm.dynamicScope();
|
|
2465
|
-
let stack = vm.stack;
|
|
2466
|
-
let nameRef = check(stack.pop());
|
|
2467
|
-
stack.push(createComputeRef(() => {
|
|
2468
|
-
let name = String(valueForRef(nameRef));
|
|
2469
|
-
return valueForRef(scope.get(name));
|
|
2470
|
-
}));
|
|
2471
|
-
});
|
|
2472
|
-
APPEND_OPCODES.add(VM_LOG_OP, vm => {
|
|
2473
|
-
let {
|
|
2474
|
-
positional
|
|
2475
|
-
} = check(vm.stack.pop()).capture();
|
|
2476
|
-
vm.loadValue($v0, createComputeRef(() => {
|
|
2477
|
-
// eslint-disable-next-line no-console
|
|
2478
|
-
console.log(...reifyPositional(positional));
|
|
2479
|
-
}));
|
|
2480
|
-
});
|
|
2481
|
-
|
|
2482
|
-
class DynamicTextContent {
|
|
2483
|
-
constructor(node, reference, lastValue) {
|
|
2484
|
-
this.node = node;
|
|
2485
|
-
this.reference = reference;
|
|
2486
|
-
this.lastValue = lastValue;
|
|
2487
|
-
}
|
|
2488
|
-
evaluate() {
|
|
2489
|
-
let value = valueForRef(this.reference);
|
|
2490
|
-
let {
|
|
2491
|
-
lastValue
|
|
2492
|
-
} = this;
|
|
2493
|
-
if (value === lastValue) return;
|
|
2494
|
-
let normalized;
|
|
2495
|
-
if (isEmpty$1(value)) {
|
|
2496
|
-
normalized = '';
|
|
2497
|
-
} else if (isString(value)) {
|
|
2498
|
-
normalized = value;
|
|
2499
|
-
} else {
|
|
2500
|
-
normalized = String(value);
|
|
2501
|
-
}
|
|
2502
|
-
if (normalized !== lastValue) {
|
|
2503
|
-
let textNode = this.node;
|
|
2504
|
-
textNode.nodeValue = this.lastValue = normalized;
|
|
2505
|
-
}
|
|
2506
|
-
}
|
|
2507
|
-
}
|
|
2508
|
-
|
|
2509
|
-
function toContentType(value) {
|
|
2510
|
-
if (shouldCoerce(value)) {
|
|
2511
|
-
return ContentType.String;
|
|
2512
|
-
} else if (isCurriedType(value, CURRIED_COMPONENT) || hasInternalComponentManager(value)) {
|
|
2513
|
-
return ContentType.Component;
|
|
2514
|
-
} else if (isCurriedType(value, CURRIED_HELPER) || hasInternalHelperManager(value)) {
|
|
2515
|
-
return ContentType.Helper;
|
|
2516
|
-
} else if (isSafeString(value)) {
|
|
2517
|
-
return ContentType.SafeString;
|
|
2518
|
-
} else if (isFragment(value)) {
|
|
2519
|
-
return ContentType.Fragment;
|
|
2520
|
-
} else if (isNode(value)) {
|
|
2521
|
-
return ContentType.Node;
|
|
2522
|
-
} else {
|
|
2523
|
-
return ContentType.String;
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
function toDynamicContentType(value) {
|
|
2527
|
-
if (!isIndexable$1(value)) {
|
|
2528
|
-
return ContentType.String;
|
|
2529
|
-
}
|
|
2530
|
-
if (isCurriedType(value, CURRIED_COMPONENT) || hasInternalComponentManager(value)) {
|
|
2531
|
-
return ContentType.Component;
|
|
2532
|
-
} else {
|
|
2533
|
-
if (!isCurriedType(value, CURRIED_HELPER) && !hasInternalHelperManager(value)) {
|
|
2534
|
-
throw new Error(
|
|
2535
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- @fixme
|
|
2536
|
-
`Attempted use a dynamic value as a component or helper, but that value did not have an associated component or helper manager. The value was: ${value}`);
|
|
2537
|
-
}
|
|
2538
|
-
return ContentType.Helper;
|
|
2539
|
-
}
|
|
2540
|
-
}
|
|
2541
|
-
APPEND_OPCODES.add(VM_CONTENT_TYPE_OP, vm => {
|
|
2542
|
-
let reference = check(vm.stack.peek());
|
|
2543
|
-
vm.stack.push(toContentType(valueForRef(reference)));
|
|
2544
|
-
if (!isConstRef(reference)) {
|
|
2545
|
-
vm.updateWith(new AssertFilter(reference, toContentType));
|
|
2546
|
-
}
|
|
2547
|
-
});
|
|
2548
|
-
APPEND_OPCODES.add(VM_DYNAMIC_CONTENT_TYPE_OP, vm => {
|
|
2549
|
-
let reference = check(vm.stack.peek());
|
|
2550
|
-
vm.stack.push(toDynamicContentType(valueForRef(reference)));
|
|
2551
|
-
if (!isConstRef(reference)) {
|
|
2552
|
-
vm.updateWith(new AssertFilter(reference, toDynamicContentType));
|
|
2553
|
-
}
|
|
2554
|
-
});
|
|
2555
|
-
APPEND_OPCODES.add(VM_APPEND_HTML_OP, vm => {
|
|
2556
|
-
let reference = check(vm.stack.pop());
|
|
2557
|
-
let rawValue = valueForRef(reference);
|
|
2558
|
-
let value = isEmpty$1(rawValue) ? '' : String(rawValue);
|
|
2559
|
-
vm.tree().appendDynamicHTML(value);
|
|
2560
|
-
});
|
|
2561
|
-
APPEND_OPCODES.add(VM_APPEND_SAFE_HTML_OP, vm => {
|
|
2562
|
-
let reference = check(vm.stack.pop());
|
|
2563
|
-
let rawValue = check(valueForRef(reference)).toHTML();
|
|
2564
|
-
let value = isEmpty$1(rawValue) ? '' : check(rawValue);
|
|
2565
|
-
vm.tree().appendDynamicHTML(value);
|
|
2566
|
-
});
|
|
2567
|
-
APPEND_OPCODES.add(VM_APPEND_TEXT_OP, vm => {
|
|
2568
|
-
let reference = check(vm.stack.pop());
|
|
2569
|
-
let rawValue = valueForRef(reference);
|
|
2570
|
-
let value = isEmpty$1(rawValue) ? '' : String(rawValue);
|
|
2571
|
-
let node = vm.tree().appendDynamicText(value);
|
|
2572
|
-
if (!isConstRef(reference)) {
|
|
2573
|
-
vm.updateWith(new DynamicTextContent(node, reference, value));
|
|
2574
|
-
}
|
|
2575
|
-
});
|
|
2576
|
-
APPEND_OPCODES.add(VM_APPEND_DOCUMENT_FRAGMENT_OP, vm => {
|
|
2577
|
-
let reference = check(vm.stack.pop());
|
|
2578
|
-
let value = check(valueForRef(reference));
|
|
2579
|
-
vm.tree().appendDynamicFragment(value);
|
|
2580
|
-
});
|
|
2581
|
-
APPEND_OPCODES.add(VM_APPEND_NODE_OP, vm => {
|
|
2582
|
-
let reference = check(vm.stack.pop());
|
|
2583
|
-
let value = check(valueForRef(reference));
|
|
2584
|
-
vm.tree().appendDynamicNode(value);
|
|
2585
|
-
});
|
|
2586
|
-
|
|
2587
|
-
// Allow the contents of `debugCallback` without extra annotations
|
|
2588
|
-
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
2589
|
-
|
|
2590
|
-
function debugCallback(context, get) {
|
|
2591
|
-
// eslint-disable-next-line no-console
|
|
2592
|
-
console.info('Use `context`, and `get(<path>)` to debug this template.');
|
|
2593
|
-
|
|
2594
|
-
// for example...
|
|
2595
|
-
context === get('this');
|
|
2596
|
-
|
|
2597
|
-
// eslint-disable-next-line no-debugger
|
|
2598
|
-
debugger;
|
|
2599
|
-
}
|
|
2600
|
-
let callback = debugCallback;
|
|
2601
|
-
|
|
2602
|
-
// For testing purposes
|
|
2603
|
-
function setDebuggerCallback(cb) {
|
|
2604
|
-
callback = cb;
|
|
2605
|
-
}
|
|
2606
|
-
function resetDebuggerCallback() {
|
|
2607
|
-
callback = debugCallback;
|
|
2608
|
-
}
|
|
2609
|
-
class ScopeInspector {
|
|
2610
|
-
#symbols;
|
|
2611
|
-
constructor(scope, symbols) {
|
|
2612
|
-
this.scope = scope;
|
|
2613
|
-
this.#symbols = symbols;
|
|
2614
|
-
}
|
|
2615
|
-
get(path) {
|
|
2616
|
-
let {
|
|
2617
|
-
scope
|
|
2618
|
-
} = this;
|
|
2619
|
-
let symbols = this.#symbols;
|
|
2620
|
-
let parts = path.split('.');
|
|
2621
|
-
let [head, ...tail] = path.split('.');
|
|
2622
|
-
let ref;
|
|
2623
|
-
if (head === 'this') {
|
|
2624
|
-
ref = scope.getSelf();
|
|
2625
|
-
} else if (symbols.locals[head]) {
|
|
2626
|
-
ref = unwrap(scope.getSymbol(symbols.locals[head]));
|
|
2627
|
-
} else {
|
|
2628
|
-
ref = this.scope.getSelf();
|
|
2629
|
-
tail = parts;
|
|
2630
|
-
}
|
|
2631
|
-
return tail.reduce((r, part) => childRefFor(r, part), ref);
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
APPEND_OPCODES.add(VM_DEBUGGER_OP, (vm, {
|
|
2635
|
-
op1: _debugInfo
|
|
2636
|
-
}) => {
|
|
2637
|
-
let debuggerInfo = vm.constants.getValue(decodeHandle(_debugInfo));
|
|
2638
|
-
let inspector = new ScopeInspector(vm.scope(), debuggerInfo);
|
|
2639
|
-
callback(valueForRef(vm.getSelf()), path => valueForRef(inspector.get(path)));
|
|
2640
|
-
});
|
|
2641
|
-
|
|
2642
|
-
APPEND_OPCODES.add(VM_ENTER_LIST_OP, (vm, {
|
|
2643
|
-
op1: relativeStart,
|
|
2644
|
-
op2: elseTarget
|
|
2645
|
-
}) => {
|
|
2646
|
-
let stack = vm.stack;
|
|
2647
|
-
let listRef = check(stack.pop());
|
|
2648
|
-
let keyRef = check(stack.pop());
|
|
2649
|
-
let keyValue = valueForRef(keyRef);
|
|
2650
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- @fixme
|
|
2651
|
-
let key = keyValue === null ? '@identity' : String(keyValue);
|
|
2652
|
-
let iteratorRef = createIteratorRef(listRef, key);
|
|
2653
|
-
let iterator = valueForRef(iteratorRef);
|
|
2654
|
-
vm.updateWith(new AssertFilter(iteratorRef, iterator => iterator.isEmpty()));
|
|
2655
|
-
if (iterator.isEmpty()) {
|
|
2656
|
-
// TODO: Fix this offset, should be accurate
|
|
2657
|
-
vm.lowlevel.goto(elseTarget + 1);
|
|
2658
|
-
} else {
|
|
2659
|
-
vm.enterList(iteratorRef, relativeStart);
|
|
2660
|
-
vm.stack.push(iterator);
|
|
2661
|
-
}
|
|
2662
|
-
});
|
|
2663
|
-
APPEND_OPCODES.add(VM_EXIT_LIST_OP, vm => {
|
|
2664
|
-
vm.exitList();
|
|
2665
|
-
});
|
|
2666
|
-
APPEND_OPCODES.add(VM_ITERATE_OP, (vm, {
|
|
2667
|
-
op1: breaks
|
|
2668
|
-
}) => {
|
|
2669
|
-
let stack = vm.stack;
|
|
2670
|
-
let iterator = check(stack.peek());
|
|
2671
|
-
let item = iterator.next();
|
|
2672
|
-
if (item !== null) {
|
|
2673
|
-
vm.registerItem(vm.enterItem(item));
|
|
2674
|
-
} else {
|
|
2675
|
-
vm.lowlevel.goto(breaks);
|
|
2676
|
-
}
|
|
2677
|
-
});
|
|
2678
|
-
|
|
2679
|
-
const CAPABILITIES = {
|
|
2680
|
-
dynamicLayout: false,
|
|
2681
|
-
dynamicTag: false,
|
|
2682
|
-
prepareArgs: false,
|
|
2683
|
-
createArgs: false,
|
|
2684
|
-
attributeHook: false,
|
|
2685
|
-
elementHook: false,
|
|
2686
|
-
createCaller: false,
|
|
2687
|
-
dynamicScope: false,
|
|
2688
|
-
updateHook: false,
|
|
2689
|
-
createInstance: false,
|
|
2690
|
-
wrapped: false,
|
|
2691
|
-
willDestroy: false,
|
|
2692
|
-
hasSubOwner: false
|
|
2693
|
-
};
|
|
2694
|
-
class TemplateOnlyComponentManager {
|
|
2695
|
-
getCapabilities() {
|
|
2696
|
-
return CAPABILITIES;
|
|
2697
|
-
}
|
|
2698
|
-
getDebugName({
|
|
2699
|
-
name
|
|
2700
|
-
}) {
|
|
2701
|
-
return name;
|
|
2702
|
-
}
|
|
2703
|
-
getSelf() {
|
|
2704
|
-
return NULL_REFERENCE;
|
|
2705
|
-
}
|
|
2706
|
-
getDestroyable() {
|
|
2707
|
-
return null;
|
|
2708
|
-
}
|
|
2709
|
-
}
|
|
2710
|
-
const TEMPLATE_ONLY_COMPONENT_MANAGER = new TemplateOnlyComponentManager();
|
|
2711
|
-
|
|
2712
|
-
// This is only exported for types, don't use this class directly
|
|
2713
|
-
class TemplateOnlyComponentDefinition {
|
|
2714
|
-
constructor(moduleName = '@glimmer/component/template-only', name = '(unknown template-only component)') {
|
|
2715
|
-
this.moduleName = moduleName;
|
|
2716
|
-
this.name = name;
|
|
2717
|
-
}
|
|
2718
|
-
toString() {
|
|
2719
|
-
return this.moduleName;
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
setInternalComponentManager(TEMPLATE_ONLY_COMPONENT_MANAGER, TemplateOnlyComponentDefinition.prototype);
|
|
2723
|
-
|
|
2724
|
-
/**
|
|
2725
|
-
This utility function is used to declare a given component has no backing class. When the rendering engine detects this it
|
|
2726
|
-
is able to perform a number of optimizations. Templates that are associated with `templateOnly()` will be rendered _as is_
|
|
2727
|
-
without adding a wrapping `<div>` (or any of the other element customization behaviors of [@ember/component](/ember/release/classes/Component)).
|
|
2728
|
-
Specifically, this means that the template will be rendered as "outer HTML".
|
|
2729
|
-
|
|
2730
|
-
In general, this method will be used by build time tooling and would not be directly written in an application. However,
|
|
2731
|
-
at times it may be useful to use directly to leverage the "outer HTML" semantics mentioned above. For example, if an addon would like
|
|
2732
|
-
to use these semantics for its templates but cannot be certain it will only be consumed by applications that have enabled the
|
|
2733
|
-
`template-only-glimmer-components` optional feature.
|
|
2734
|
-
|
|
2735
|
-
@example
|
|
2736
|
-
|
|
2737
|
-
```js
|
|
2738
|
-
import { templateOnlyComponent } from '@glimmer/runtime';
|
|
2739
|
-
|
|
2740
|
-
export default templateOnlyComponent();
|
|
2741
|
-
```
|
|
2742
|
-
|
|
2743
|
-
@public
|
|
2744
|
-
@method templateOnly
|
|
2745
|
-
@param {String} moduleName the module name that the template only component represents, this will be used for debugging purposes
|
|
2746
|
-
@category EMBER_GLIMMER_SET_COMPONENT_TEMPLATE
|
|
2747
|
-
*/
|
|
2748
|
-
|
|
2749
|
-
function templateOnlyComponent(moduleName, name) {
|
|
2750
|
-
return new TemplateOnlyComponentDefinition(moduleName, name);
|
|
2751
|
-
}
|
|
2752
|
-
|
|
2753
|
-
// http://www.w3.org/TR/html/syntax.html#html-integration-point
|
|
2754
|
-
const SVG_INTEGRATION_POINTS = {
|
|
2755
|
-
foreignObject: 1,
|
|
2756
|
-
desc: 1,
|
|
2757
|
-
title: 1
|
|
2758
|
-
};
|
|
2759
|
-
|
|
2760
|
-
// http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes
|
|
2761
|
-
// TODO: Adjust SVG attributes
|
|
2762
|
-
|
|
2763
|
-
// http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign
|
|
2764
|
-
// TODO: Adjust SVG elements
|
|
2765
|
-
|
|
2766
|
-
// http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign
|
|
2767
|
-
const BLACKLIST_TABLE = Object.create(null);
|
|
2768
|
-
class DOMOperations {
|
|
2769
|
-
// Set by this.setupUselessElement() in constructor
|
|
2770
|
-
|
|
2771
|
-
constructor(document) {
|
|
2772
|
-
this.document = document;
|
|
2773
|
-
this.setupUselessElement();
|
|
2774
|
-
}
|
|
2775
|
-
|
|
2776
|
-
// split into separate method so that NodeDOMTreeConstruction
|
|
2777
|
-
// can override it.
|
|
2778
|
-
setupUselessElement() {
|
|
2779
|
-
this.uselessElement = this.document.createElement('div');
|
|
2780
|
-
}
|
|
2781
|
-
createElement(tag, context) {
|
|
2782
|
-
let isElementInSVGNamespace, isHTMLIntegrationPoint, isElementInMathMlNamespace, ns;
|
|
2783
|
-
if (context) {
|
|
2784
|
-
isElementInSVGNamespace = context.namespaceURI === NS_SVG || tag === 'svg';
|
|
2785
|
-
isElementInMathMlNamespace = context.namespaceURI === NS_MATHML || tag === 'math';
|
|
2786
|
-
isHTMLIntegrationPoint = !!SVG_INTEGRATION_POINTS[context.tagName];
|
|
2787
|
-
} else {
|
|
2788
|
-
isElementInSVGNamespace = tag === 'svg';
|
|
2789
|
-
isElementInMathMlNamespace = tag === 'math';
|
|
2790
|
-
isHTMLIntegrationPoint = false;
|
|
2791
|
-
}
|
|
2792
|
-
if ((isElementInMathMlNamespace || isElementInSVGNamespace) && !isHTMLIntegrationPoint) {
|
|
2793
|
-
// FIXME: This does not properly handle <font> with color, face, or
|
|
2794
|
-
// size attributes, which is also disallowed by the spec. We should fix
|
|
2795
|
-
// this.
|
|
2796
|
-
if (BLACKLIST_TABLE[tag]) {
|
|
2797
|
-
throw new Error(`Cannot create a ${tag} inside an SVG context`);
|
|
2798
|
-
}
|
|
2799
|
-
if (isElementInMathMlNamespace) {
|
|
2800
|
-
ns = NS_MATHML;
|
|
2801
|
-
} else {
|
|
2802
|
-
ns = NS_SVG;
|
|
2803
|
-
}
|
|
2804
|
-
return this.document.createElementNS(ns, tag);
|
|
2805
|
-
} else {
|
|
2806
|
-
return this.document.createElement(tag);
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2809
|
-
insertBefore(parent, node, reference) {
|
|
2810
|
-
parent.insertBefore(node, reference);
|
|
2811
|
-
}
|
|
2812
|
-
insertHTMLBefore(parent, nextSibling, html) {
|
|
2813
|
-
if (html === '') {
|
|
2814
|
-
const comment = this.createComment('');
|
|
2815
|
-
parent.insertBefore(comment, nextSibling);
|
|
2816
|
-
return new ConcreteBounds(parent, comment, comment);
|
|
2817
|
-
}
|
|
2818
|
-
const prev = nextSibling ? nextSibling.previousSibling : parent.lastChild;
|
|
2819
|
-
let last;
|
|
2820
|
-
if (nextSibling === null) {
|
|
2821
|
-
parent.insertAdjacentHTML(INSERT_BEFORE_END, html);
|
|
2822
|
-
last = expect(parent.lastChild);
|
|
2823
|
-
} else if (nextSibling instanceof HTMLElement) {
|
|
2824
|
-
nextSibling.insertAdjacentHTML('beforebegin', html);
|
|
2825
|
-
last = expect(nextSibling.previousSibling);
|
|
2826
|
-
} else {
|
|
2827
|
-
// Non-element nodes do not support insertAdjacentHTML, so add an
|
|
2828
|
-
// element and call it on that element. Then remove the element.
|
|
2829
|
-
const {
|
|
2830
|
-
uselessElement
|
|
2831
|
-
} = this;
|
|
2832
|
-
parent.insertBefore(uselessElement, nextSibling);
|
|
2833
|
-
uselessElement.insertAdjacentHTML(INSERT_BEFORE_BEGIN, html);
|
|
2834
|
-
last = expect(uselessElement.previousSibling);
|
|
2835
|
-
parent.removeChild(uselessElement);
|
|
2836
|
-
}
|
|
2837
|
-
const first = expect(prev ? prev.nextSibling : parent.firstChild);
|
|
2838
|
-
return new ConcreteBounds(parent, first, last);
|
|
2839
|
-
}
|
|
2840
|
-
createTextNode(text) {
|
|
2841
|
-
return this.document.createTextNode(text);
|
|
2842
|
-
}
|
|
2843
|
-
createComment(data) {
|
|
2844
|
-
return this.document.createComment(data);
|
|
2845
|
-
}
|
|
2846
|
-
}
|
|
2847
|
-
|
|
2848
|
-
['b', 'big', 'blockquote', 'body', 'br', 'center', 'code', 'dd', 'div', 'dl', 'dt', 'em', 'embed', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'i', 'img', 'li', 'listing', 'main', 'meta', 'nobr', 'ol', 'p', 'pre', 'ruby', 's', 'small', 'span', 'strong', 'strike', 'sub', 'sup', 'table', 'tt', 'u', 'ul', 'var'].forEach(tag => BLACKLIST_TABLE[tag] = 1);
|
|
2849
|
-
const WHITESPACE = /[\t\n\v\f\r \xa0\u{1680}\u{180e}\u{2000}-\u{200a}\u{2028}\u{2029}\u{202f}\u{205f}\u{3000}\u{feff}]/u;
|
|
2850
|
-
function isWhitespace(string) {
|
|
2851
|
-
return WHITESPACE.test(string);
|
|
2852
|
-
}
|
|
2853
|
-
class DOMChangesImpl extends DOMOperations {
|
|
2854
|
-
namespace;
|
|
2855
|
-
constructor(document) {
|
|
2856
|
-
super(document);
|
|
2857
|
-
this.document = document;
|
|
2858
|
-
this.namespace = null;
|
|
2859
|
-
}
|
|
2860
|
-
setAttribute(element, name, value) {
|
|
2861
|
-
element.setAttribute(name, value);
|
|
2862
|
-
}
|
|
2863
|
-
removeAttribute(element, name) {
|
|
2864
|
-
element.removeAttribute(name);
|
|
2865
|
-
}
|
|
2866
|
-
insertAfter(element, node, reference) {
|
|
2867
|
-
this.insertBefore(element, node, reference.nextSibling);
|
|
2868
|
-
}
|
|
2869
|
-
}
|
|
2870
|
-
const DOMChanges = DOMChangesImpl;
|
|
2871
|
-
|
|
2872
|
-
/*
|
|
2873
|
-
* @method normalizeProperty
|
|
2874
|
-
* @param element {HTMLElement}
|
|
2875
|
-
* @param slotName {String}
|
|
2876
|
-
* @returns {Object} { name, type }
|
|
2877
|
-
*/
|
|
2878
|
-
function normalizeProperty(element, slotName) {
|
|
2879
|
-
let type, normalized;
|
|
2880
|
-
if (slotName in element) {
|
|
2881
|
-
normalized = slotName;
|
|
2882
|
-
type = 'prop';
|
|
2883
|
-
} else {
|
|
2884
|
-
let lower = slotName.toLowerCase();
|
|
2885
|
-
if (lower in element) {
|
|
2886
|
-
type = 'prop';
|
|
2887
|
-
normalized = lower;
|
|
2888
|
-
} else {
|
|
2889
|
-
type = 'attr';
|
|
2890
|
-
normalized = slotName;
|
|
2891
|
-
}
|
|
2892
|
-
}
|
|
2893
|
-
if (type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName, normalized))) {
|
|
2894
|
-
type = 'attr';
|
|
2895
|
-
}
|
|
2896
|
-
return {
|
|
2897
|
-
normalized,
|
|
2898
|
-
type
|
|
2899
|
-
};
|
|
2900
|
-
}
|
|
2901
|
-
|
|
2902
|
-
// Properties that MUST be set as attributes because the DOM properties
|
|
2903
|
-
// are read-only or have type mismatches with the HTML attributes.
|
|
2904
|
-
//
|
|
2905
|
-
// element.form is a read-only DOM property on all form-associated elements
|
|
2906
|
-
// that returns the owning HTMLFormElement (or null). The HTML `form` attribute
|
|
2907
|
-
// (set via setAttribute) associates the element with a form by ID.
|
|
2908
|
-
// See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/form
|
|
2909
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/form
|
|
2910
|
-
const ATTR_OVERRIDES = {
|
|
2911
|
-
INPUT: {
|
|
2912
|
-
form: true,
|
|
2913
|
-
// HTMLElement.autocorrect is a boolean DOM property, but the HTML attribute
|
|
2914
|
-
// uses "on"/"off" strings. Setting `element.autocorrect = "off"` coerces to
|
|
2915
|
-
// `true` (truthy string). Must use setAttribute for correct "on"/"off" behavior.
|
|
2916
|
-
// See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/autocorrect
|
|
2917
|
-
autocorrect: true,
|
|
2918
|
-
// HTMLInputElement.list is a read-only DOM property that returns the associated
|
|
2919
|
-
// HTMLDataListElement (or null). Must use setAttribute to set the datalist ID.
|
|
2920
|
-
// See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/list
|
|
2921
|
-
list: true
|
|
2922
|
-
},
|
|
2923
|
-
SELECT: {
|
|
2924
|
-
form: true
|
|
2925
|
-
},
|
|
2926
|
-
OPTION: {
|
|
2927
|
-
form: true
|
|
2928
|
-
},
|
|
2929
|
-
TEXTAREA: {
|
|
2930
|
-
form: true
|
|
2931
|
-
},
|
|
2932
|
-
LABEL: {
|
|
2933
|
-
form: true
|
|
2934
|
-
},
|
|
2935
|
-
FIELDSET: {
|
|
2936
|
-
form: true
|
|
2937
|
-
},
|
|
2938
|
-
LEGEND: {
|
|
2939
|
-
form: true
|
|
2940
|
-
},
|
|
2941
|
-
OBJECT: {
|
|
2942
|
-
form: true
|
|
2943
|
-
},
|
|
2944
|
-
OUTPUT: {
|
|
2945
|
-
form: true
|
|
2946
|
-
},
|
|
2947
|
-
BUTTON: {
|
|
2948
|
-
form: true
|
|
2949
|
-
}
|
|
2950
|
-
};
|
|
2951
|
-
function preferAttr(tagName, propName) {
|
|
2952
|
-
let tag = ATTR_OVERRIDES[tagName.toUpperCase()];
|
|
2953
|
-
return !!(tag && tag[propName.toLowerCase()]);
|
|
2954
|
-
}
|
|
2955
|
-
|
|
2956
|
-
function internalHelper(helper) {
|
|
2957
|
-
return setInternalHelperManager(helper, {});
|
|
2958
|
-
}
|
|
2959
|
-
|
|
2960
|
-
/**
|
|
2961
|
-
Use the `{{array}}` helper to create an array to pass as an option to your
|
|
2962
|
-
components.
|
|
2963
|
-
|
|
2964
|
-
```handlebars
|
|
2965
|
-
<MyComponent @people={{array
|
|
2966
|
-
'Tom Dale'
|
|
2967
|
-
'Yehuda Katz'
|
|
2968
|
-
this.myOtherPerson}}
|
|
2969
|
-
/>
|
|
2970
|
-
```
|
|
2971
|
-
or
|
|
2972
|
-
```handlebars
|
|
2973
|
-
{{my-component people=(array
|
|
2974
|
-
'Tom Dale'
|
|
2975
|
-
'Yehuda Katz'
|
|
2976
|
-
this.myOtherPerson)
|
|
2977
|
-
}}
|
|
2978
|
-
```
|
|
2979
|
-
|
|
2980
|
-
Would result in an object such as:
|
|
2981
|
-
|
|
2982
|
-
```js
|
|
2983
|
-
['Tom Dale', 'Yehuda Katz', this.get('myOtherPerson')]
|
|
2984
|
-
```
|
|
2985
|
-
|
|
2986
|
-
Where the 3rd item in the array is bound to updates of the `myOtherPerson` property.
|
|
2987
|
-
|
|
2988
|
-
@method array
|
|
2989
|
-
@param {Array} options
|
|
2990
|
-
@return {Array} Array
|
|
2991
|
-
@public
|
|
2992
|
-
*/
|
|
2993
|
-
|
|
2994
|
-
const array = internalHelper(({
|
|
2995
|
-
positional
|
|
2996
|
-
}) => {
|
|
2997
|
-
return createComputeRef(() => reifyPositional(positional), null, 'array');
|
|
2998
|
-
});
|
|
2999
|
-
|
|
3000
|
-
const isEmpty = value => {
|
|
3001
|
-
return value === null || value === undefined || typeof value.toString !== 'function';
|
|
3002
|
-
};
|
|
3003
|
-
const normalizeTextValue = value => {
|
|
3004
|
-
if (isEmpty(value)) {
|
|
3005
|
-
return '';
|
|
3006
|
-
}
|
|
3007
|
-
return String(value);
|
|
3008
|
-
};
|
|
3009
|
-
|
|
3010
|
-
/**
|
|
3011
|
-
Concatenates the given arguments into a string.
|
|
3012
|
-
|
|
3013
|
-
Example:
|
|
3014
|
-
|
|
3015
|
-
```handlebars
|
|
3016
|
-
{{some-component name=(concat firstName " " lastName)}}
|
|
3017
|
-
|
|
3018
|
-
{{! would pass name="<first name value> <last name value>" to the component}}
|
|
3019
|
-
```
|
|
3020
|
-
|
|
3021
|
-
or for angle bracket invocation, you actually don't need concat at all.
|
|
3022
|
-
|
|
3023
|
-
```handlebars
|
|
3024
|
-
<SomeComponent @name="{{firstName}} {{lastName}}" />
|
|
3025
|
-
```
|
|
3026
|
-
|
|
3027
|
-
@public
|
|
3028
|
-
@method concat
|
|
3029
|
-
*/
|
|
3030
|
-
const concat = internalHelper(({
|
|
3031
|
-
positional
|
|
3032
|
-
}) => {
|
|
3033
|
-
return createComputeRef(() => reifyPositional(positional).map(normalizeTextValue).join(''), null, 'concat');
|
|
3034
|
-
});
|
|
3035
|
-
|
|
3036
|
-
const context = buildUntouchableThis('`fn` helper');
|
|
3037
|
-
|
|
3038
|
-
/**
|
|
3039
|
-
The `fn` helper allows you to ensure a function that you are passing off
|
|
3040
|
-
to another component, helper, or modifier has access to arguments that are
|
|
3041
|
-
available in the template.
|
|
3042
|
-
|
|
3043
|
-
For example, if you have an `each` helper looping over a number of items, you
|
|
3044
|
-
may need to pass a function that expects to receive the item as an argument
|
|
3045
|
-
to a component invoked within the loop. Here's how you could use the `fn`
|
|
3046
|
-
helper to pass both the function and its arguments together:
|
|
3047
|
-
|
|
3048
|
-
```app/templates/components/items-listing.hbs
|
|
3049
|
-
{{#each @items as |item|}}
|
|
3050
|
-
<DisplayItem @item=item @select={{fn this.handleSelected item}} />
|
|
3051
|
-
{{/each}}
|
|
3052
|
-
```
|
|
3053
|
-
|
|
3054
|
-
```app/components/items-list.js
|
|
3055
|
-
import Component from '@glimmer/component';
|
|
3056
|
-
import { action } from '@ember/object';
|
|
3057
|
-
|
|
3058
|
-
export default class ItemsList extends Component {
|
|
3059
|
-
handleSelected = (item) => {
|
|
3060
|
-
// ...snip...
|
|
3061
|
-
}
|
|
3062
|
-
}
|
|
3063
|
-
```
|
|
3064
|
-
|
|
3065
|
-
In this case the `display-item` component will receive a normal function
|
|
3066
|
-
that it can invoke. When it invokes the function, the `handleSelected`
|
|
3067
|
-
function will receive the `item` and any arguments passed, thanks to the
|
|
3068
|
-
`fn` helper.
|
|
3069
|
-
|
|
3070
|
-
Let's take look at what that means in a couple circumstances:
|
|
3071
|
-
|
|
3072
|
-
- When invoked as `this.args.select()` the `handleSelected` function will
|
|
3073
|
-
receive the `item` from the loop as its first and only argument.
|
|
3074
|
-
- When invoked as `this.args.select('foo')` the `handleSelected` function
|
|
3075
|
-
will receive the `item` from the loop as its first argument and the
|
|
3076
|
-
string `'foo'` as its second argument.
|
|
3077
|
-
|
|
3078
|
-
In the example above, we used an arrow function to ensure that
|
|
3079
|
-
`handleSelected` is properly bound to the `items-list`, but let's explore what
|
|
3080
|
-
happens if we left out the arrow function:
|
|
3081
|
-
|
|
3082
|
-
```app/components/items-list.js
|
|
3083
|
-
import Component from '@glimmer/component';
|
|
3084
|
-
|
|
3085
|
-
export default class ItemsList extends Component {
|
|
3086
|
-
handleSelected(item) {
|
|
3087
|
-
// ...snip...
|
|
3088
|
-
}
|
|
3089
|
-
}
|
|
3090
|
-
```
|
|
3091
|
-
|
|
3092
|
-
In this example, when `handleSelected` is invoked inside the `display-item`
|
|
3093
|
-
component, it will **not** have access to the component instance. In other
|
|
3094
|
-
words, it will have no `this` context, so please make sure your functions
|
|
3095
|
-
are bound (via an arrow function or other means) before passing into `fn`!
|
|
3096
|
-
|
|
3097
|
-
See also [partial application](https://en.wikipedia.org/wiki/Partial_application).
|
|
3098
|
-
|
|
3099
|
-
@method fn
|
|
3100
|
-
@public
|
|
3101
|
-
*/
|
|
3102
|
-
const fn = internalHelper(({
|
|
3103
|
-
positional
|
|
3104
|
-
}) => {
|
|
3105
|
-
let callbackRef = check(positional[0]);
|
|
3106
|
-
return createComputeRef(() => {
|
|
3107
|
-
return (...invocationArgs) => {
|
|
3108
|
-
let [fn, ...args] = reifyPositional(positional);
|
|
3109
|
-
assertCallbackIsFn(callbackRef);
|
|
3110
|
-
if (isInvokableRef(callbackRef)) {
|
|
3111
|
-
let value = args.length > 0 ? args[0] : invocationArgs[0];
|
|
3112
|
-
return void updateRef(callbackRef, value);
|
|
3113
|
-
} else {
|
|
3114
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return -- @fixme
|
|
3115
|
-
return fn.call(context, ...args, ...invocationArgs);
|
|
3116
|
-
}
|
|
3117
|
-
};
|
|
3118
|
-
}, null, 'fn');
|
|
3119
|
-
});
|
|
3120
|
-
function assertCallbackIsFn(callbackRef) {
|
|
3121
|
-
if (!(callbackRef && (isInvokableRef(callbackRef) || typeof valueForRef(callbackRef) === 'function'))) {
|
|
3122
|
-
throw new Error(`You must pass a function as the \`fn\` helper's first argument, you passed ${callbackRef ? valueForRef(callbackRef) : callbackRef}. While rendering:\n\n${callbackRef?.debugLabel}`);
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
|
|
3126
|
-
/**
|
|
3127
|
-
Dynamically look up a property on an object. The second argument to `{{get}}`
|
|
3128
|
-
should have a string value, although it can be bound.
|
|
3129
|
-
|
|
3130
|
-
For example, these two usages are equivalent:
|
|
3131
|
-
|
|
3132
|
-
```app/components/developer-detail.js
|
|
3133
|
-
import Component from '@glimmer/component';
|
|
3134
|
-
import { tracked } from '@glimmer/tracking';
|
|
3135
|
-
|
|
3136
|
-
export default class extends Component {
|
|
3137
|
-
@tracked developer = {
|
|
3138
|
-
name: "Sandi Metz",
|
|
3139
|
-
language: "Ruby"
|
|
3140
|
-
}
|
|
3141
|
-
}
|
|
3142
|
-
```
|
|
3143
|
-
|
|
3144
|
-
```handlebars
|
|
3145
|
-
{{this.developer.name}}
|
|
3146
|
-
{{get this.developer "name"}}
|
|
3147
|
-
```
|
|
3148
|
-
|
|
3149
|
-
If there were several facts about a person, the `{{get}}` helper can dynamically
|
|
3150
|
-
pick one:
|
|
3151
|
-
|
|
3152
|
-
```app/templates/application.hbs
|
|
3153
|
-
<DeveloperDetail @factName="language" />
|
|
3154
|
-
```
|
|
3155
|
-
|
|
3156
|
-
```handlebars
|
|
3157
|
-
{{get this.developer @factName}}
|
|
3158
|
-
```
|
|
3159
|
-
|
|
3160
|
-
For a more complex example, this template would allow the user to switch
|
|
3161
|
-
between showing the user's height and weight with a click:
|
|
3162
|
-
|
|
3163
|
-
```app/components/developer-detail.js
|
|
3164
|
-
import Component from '@glimmer/component';
|
|
3165
|
-
import { tracked } from '@glimmer/tracking';
|
|
3166
|
-
|
|
3167
|
-
export default class extends Component {
|
|
3168
|
-
@tracked developer = {
|
|
3169
|
-
name: "Sandi Metz",
|
|
3170
|
-
language: "Ruby"
|
|
3171
|
-
}
|
|
3172
|
-
|
|
3173
|
-
@tracked currentFact = 'name'
|
|
3174
|
-
|
|
3175
|
-
showFact = (fact) => {
|
|
3176
|
-
this.currentFact = fact;
|
|
3177
|
-
}
|
|
3178
|
-
}
|
|
3179
|
-
```
|
|
3180
|
-
|
|
3181
|
-
```app/components/developer-detail.js
|
|
3182
|
-
{{get this.developer this.currentFact}}
|
|
3183
|
-
|
|
3184
|
-
<button {{on 'click' (fn this.showFact "name")}}>Show name</button>
|
|
3185
|
-
<button {{on 'click' (fn this.showFact "language")}}>Show language</button>
|
|
3186
|
-
```
|
|
3187
|
-
|
|
3188
|
-
The `{{get}}` helper can also respect mutable values itself. For example:
|
|
3189
|
-
|
|
3190
|
-
```app/components/developer-detail.js
|
|
3191
|
-
<Input @value={{mut (get this.person this.currentFact)}} />
|
|
3192
|
-
|
|
3193
|
-
<button {{on 'click' (fn this.showFact "name")}}>Show name</button>
|
|
3194
|
-
<button {{on 'click' (fn this.showFact "language")}}>Show language</button>
|
|
3195
|
-
```
|
|
3196
|
-
|
|
3197
|
-
Would allow the user to swap what fact is being displayed, and also edit
|
|
3198
|
-
that fact via a two-way mutable binding.
|
|
3199
|
-
|
|
3200
|
-
@public
|
|
3201
|
-
@method get
|
|
3202
|
-
*/
|
|
3203
|
-
const get = internalHelper(({
|
|
3204
|
-
positional
|
|
3205
|
-
}) => {
|
|
3206
|
-
let sourceRef = positional[0] ?? UNDEFINED_REFERENCE;
|
|
3207
|
-
let pathRef = positional[1] ?? UNDEFINED_REFERENCE;
|
|
3208
|
-
return createComputeRef(() => {
|
|
3209
|
-
let source = valueForRef(sourceRef);
|
|
3210
|
-
if (isDict(source)) {
|
|
3211
|
-
return getPath(source, String(valueForRef(pathRef)));
|
|
3212
|
-
}
|
|
3213
|
-
}, value => {
|
|
3214
|
-
let source = valueForRef(sourceRef);
|
|
3215
|
-
if (isDict(source)) {
|
|
3216
|
-
return setPath(source, String(valueForRef(pathRef)), value);
|
|
3217
|
-
}
|
|
3218
|
-
}, 'get');
|
|
3219
|
-
});
|
|
3220
|
-
|
|
3221
|
-
/**
|
|
3222
|
-
Use the `{{hash}}` helper to create a hash to pass as an option to your
|
|
3223
|
-
components. This is specially useful for contextual components where you can
|
|
3224
|
-
just yield a hash:
|
|
3225
|
-
|
|
3226
|
-
```handlebars
|
|
3227
|
-
{{yield (hash
|
|
3228
|
-
name='Sarah'
|
|
3229
|
-
title=office
|
|
3230
|
-
)}}
|
|
3231
|
-
```
|
|
3232
|
-
|
|
3233
|
-
Would result in an object such as:
|
|
3234
|
-
|
|
3235
|
-
```js
|
|
3236
|
-
{ name: 'Sarah', title: this.get('office') }
|
|
3237
|
-
```
|
|
3238
|
-
|
|
3239
|
-
Where the `title` is bound to updates of the `office` property.
|
|
3240
|
-
|
|
3241
|
-
Note that the hash is an empty object with no prototype chain, therefore
|
|
3242
|
-
common methods like `toString` are not available in the resulting hash.
|
|
3243
|
-
If you need to use such a method, you can use the `call` or `apply`
|
|
3244
|
-
approach:
|
|
3245
|
-
|
|
3246
|
-
```js
|
|
3247
|
-
function toString(obj) {
|
|
3248
|
-
return Object.prototype.toString.apply(obj);
|
|
3249
|
-
}
|
|
3250
|
-
```
|
|
3251
|
-
|
|
3252
|
-
@method hash
|
|
3253
|
-
@param {Object} options
|
|
3254
|
-
@return {Object} Hash
|
|
3255
|
-
@public
|
|
3256
|
-
*/
|
|
3257
|
-
const hash = internalHelper(({
|
|
3258
|
-
named
|
|
3259
|
-
}) => {
|
|
3260
|
-
let ref = createComputeRef(() => {
|
|
3261
|
-
return reifyNamed(named);
|
|
3262
|
-
}, null, 'hash');
|
|
3263
|
-
|
|
3264
|
-
// Setup the children so that templates can bypass getting the value of
|
|
3265
|
-
// the reference and treat children lazily
|
|
3266
|
-
let children = new Map();
|
|
3267
|
-
for (let name in named) {
|
|
3268
|
-
children.set(name, named[name]);
|
|
3269
|
-
}
|
|
3270
|
-
ref.children = children;
|
|
3271
|
-
return ref;
|
|
3272
|
-
});
|
|
3273
|
-
|
|
3274
|
-
const untouchableContext = buildUntouchableThis('`on` modifier');
|
|
3275
|
-
class OnModifierState {
|
|
3276
|
-
tag = createUpdatableTag();
|
|
3277
|
-
element;
|
|
3278
|
-
args;
|
|
3279
|
-
listener = null;
|
|
3280
|
-
constructor(element, args) {
|
|
3281
|
-
this.element = element;
|
|
3282
|
-
this.args = args;
|
|
3283
|
-
registerDestructor(this, () => {
|
|
3284
|
-
let {
|
|
3285
|
-
element,
|
|
3286
|
-
listener
|
|
3287
|
-
} = this;
|
|
3288
|
-
if (listener) {
|
|
3289
|
-
let {
|
|
3290
|
-
eventName,
|
|
3291
|
-
callback,
|
|
3292
|
-
options
|
|
3293
|
-
} = listener;
|
|
3294
|
-
removeEventListener(element, eventName, callback, options);
|
|
3295
|
-
}
|
|
3296
|
-
});
|
|
3297
|
-
}
|
|
3298
|
-
|
|
3299
|
-
// Update this.listener if needed
|
|
3300
|
-
updateListener() {
|
|
3301
|
-
let {
|
|
3302
|
-
element,
|
|
3303
|
-
args,
|
|
3304
|
-
listener
|
|
3305
|
-
} = this;
|
|
3306
|
-
let selector;
|
|
3307
|
-
{
|
|
3308
|
-
const el = this.element;
|
|
3309
|
-
selector = el.tagName.toLowerCase() + (el.id ? `#${el.id}` : '') + Array.from(el.classList).map(c => `.${c}`).join('');
|
|
3310
|
-
}
|
|
3311
|
-
let arg0 = args.positional[0];
|
|
3312
|
-
let eventName = check(arg0 ? valueForRef(arg0) : undefined);
|
|
3313
|
-
if (!eventName) {
|
|
3314
|
-
throw new Error(`You must pass a valid DOM event name as the first argument to the \`on\` modifier on ${selector}`);
|
|
3315
|
-
}
|
|
3316
|
-
let arg1 = args.positional[1];
|
|
3317
|
-
let userProvidedCallback = check(arg1 ? valueForRef(arg1) : undefined);
|
|
3318
|
-
if (typeof userProvidedCallback !== 'function') {
|
|
3319
|
-
throw new Error(`You must pass a function as the second argument to the \`on\` modifier; you passed ${userProvidedCallback === null ? 'null' : typeof userProvidedCallback}. While rendering:\n\n${args.positional[1]?.debugLabel ?? '(unknown)'} on ${selector}`);
|
|
3320
|
-
}
|
|
3321
|
-
if (args.positional.length !== 2) {
|
|
3322
|
-
throw new Error(`You can only pass two positional arguments (event name and callback) to the \`on\` modifier, but you provided ${args.positional.length}. Consider using the \`fn\` helper to provide additional arguments to the \`on\` callback on ${selector}`);
|
|
3323
|
-
}
|
|
3324
|
-
let once = undefined;
|
|
3325
|
-
let passive = undefined;
|
|
3326
|
-
let capture = undefined;
|
|
3327
|
-
{
|
|
3328
|
-
let {
|
|
3329
|
-
once: _once,
|
|
3330
|
-
passive: _passive,
|
|
3331
|
-
capture: _capture,
|
|
3332
|
-
...extra
|
|
3333
|
-
} = reifyNamed(args.named);
|
|
3334
|
-
once = check(_once);
|
|
3335
|
-
passive = check(_passive);
|
|
3336
|
-
capture = check(_capture);
|
|
3337
|
-
if (Object.keys(extra).length > 0) {
|
|
3338
|
-
throw new Error(`You can only \`once\`, \`passive\` or \`capture\` named arguments to the \`on\` modifier, but you provided ${Object.keys(extra).join(', ')} on ${selector}`);
|
|
3339
|
-
}
|
|
3340
|
-
}
|
|
3341
|
-
let shouldUpdate = false;
|
|
3342
|
-
if (listener === null) {
|
|
3343
|
-
shouldUpdate = true;
|
|
3344
|
-
} else {
|
|
3345
|
-
shouldUpdate = eventName !== listener.eventName || userProvidedCallback !== listener.userProvidedCallback || once !== listener.once || passive !== listener.passive || capture !== listener.capture;
|
|
3346
|
-
}
|
|
3347
|
-
let options = undefined;
|
|
3348
|
-
|
|
3349
|
-
// we want to handle both `true` and `false` because both have a meaning:
|
|
3350
|
-
// https://bugs.chromium.org/p/chromium/issues/detail?id=770208
|
|
3351
|
-
if (shouldUpdate) {
|
|
3352
|
-
if (once !== undefined || passive !== undefined || capture !== undefined) {
|
|
3353
|
-
options = {
|
|
3354
|
-
once,
|
|
3355
|
-
passive,
|
|
3356
|
-
capture
|
|
3357
|
-
};
|
|
3358
|
-
}
|
|
3359
|
-
}
|
|
3360
|
-
if (shouldUpdate) {
|
|
3361
|
-
let callback = userProvidedCallback;
|
|
3362
|
-
{
|
|
3363
|
-
callback = userProvidedCallback.bind(untouchableContext);
|
|
3364
|
-
if (passive) {
|
|
3365
|
-
let _callback = callback;
|
|
3366
|
-
callback = event => {
|
|
3367
|
-
event.preventDefault = () => {
|
|
3368
|
-
throw new Error(`You marked this listener as 'passive', meaning that you must not call 'event.preventDefault()': \n\n${userProvidedCallback.name || `{anonymous function}`}`);
|
|
3369
|
-
};
|
|
3370
|
-
return _callback(event);
|
|
3371
|
-
};
|
|
3372
|
-
}
|
|
3373
|
-
}
|
|
3374
|
-
this.listener = {
|
|
3375
|
-
eventName,
|
|
3376
|
-
callback,
|
|
3377
|
-
userProvidedCallback,
|
|
3378
|
-
once,
|
|
3379
|
-
passive,
|
|
3380
|
-
capture,
|
|
3381
|
-
options
|
|
3382
|
-
};
|
|
3383
|
-
if (listener) {
|
|
3384
|
-
removeEventListener(element, listener.eventName, listener.callback, listener.options);
|
|
3385
|
-
}
|
|
3386
|
-
addEventListener(element, eventName, callback, options);
|
|
3387
|
-
}
|
|
3388
|
-
}
|
|
3389
|
-
}
|
|
3390
|
-
let adds = 0;
|
|
3391
|
-
let removes = 0;
|
|
3392
|
-
function removeEventListener(element, eventName, callback, options) {
|
|
3393
|
-
removes++;
|
|
3394
|
-
element.removeEventListener(eventName, callback, options);
|
|
3395
|
-
}
|
|
3396
|
-
function addEventListener(element, eventName, callback, options) {
|
|
3397
|
-
adds++;
|
|
3398
|
-
element.addEventListener(eventName, callback, options);
|
|
3399
|
-
}
|
|
3400
|
-
|
|
3401
|
-
/**
|
|
3402
|
-
The `{{on}}` modifier lets you easily add event listeners (it uses
|
|
3403
|
-
[EventTarget.addEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener)
|
|
3404
|
-
internally).
|
|
3405
|
-
|
|
3406
|
-
For example, if you'd like to run a function on your component when a `<button>`
|
|
3407
|
-
in the components template is clicked you might do something like:
|
|
3408
|
-
|
|
3409
|
-
```app/components/like-post.hbs
|
|
3410
|
-
<button {{on 'click' this.saveLike}}>Like this post!</button>
|
|
3411
|
-
```
|
|
3412
|
-
|
|
3413
|
-
```app/components/like-post.js
|
|
3414
|
-
import Component from '@glimmer/component';
|
|
3415
|
-
import { action } from '@ember/object';
|
|
3416
|
-
|
|
3417
|
-
export default class LikePostComponent extends Component {
|
|
3418
|
-
saveLike = () => {
|
|
3419
|
-
// someone likes your post!
|
|
3420
|
-
// better send a request off to your server...
|
|
3421
|
-
}
|
|
3422
|
-
}
|
|
3423
|
-
```
|
|
3424
|
-
|
|
3425
|
-
### Arguments
|
|
3426
|
-
|
|
3427
|
-
`{{on}}` accepts two positional arguments, and a few named arguments.
|
|
3428
|
-
|
|
3429
|
-
The positional arguments are:
|
|
3430
|
-
|
|
3431
|
-
- `event` -- the name to use when calling `addEventListener`
|
|
3432
|
-
- `callback` -- the function to be passed to `addEventListener`
|
|
3433
|
-
|
|
3434
|
-
The named arguments are:
|
|
3435
|
-
|
|
3436
|
-
- capture -- a `true` value indicates that events of this type will be dispatched
|
|
3437
|
-
to the registered listener before being dispatched to any EventTarget beneath it
|
|
3438
|
-
in the DOM tree.
|
|
3439
|
-
- once -- indicates that the listener should be invoked at most once after being
|
|
3440
|
-
added. If true, the listener would be automatically removed when invoked.
|
|
3441
|
-
- passive -- if `true`, indicates that the function specified by listener will never
|
|
3442
|
-
call preventDefault(). If a passive listener does call preventDefault(), the user
|
|
3443
|
-
agent will do nothing other than generate a console warning. See
|
|
3444
|
-
[Improving scrolling performance with passive listeners](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Improving_scrolling_performance_with_passive_listeners)
|
|
3445
|
-
to learn more.
|
|
3446
|
-
|
|
3447
|
-
The callback function passed to `{{on}}` will receive any arguments that are passed
|
|
3448
|
-
to the event handler. Most commonly this would be the `event` itself.
|
|
3449
|
-
|
|
3450
|
-
If you would like to pass additional arguments to the function you should use
|
|
3451
|
-
the `{{fn}}` helper.
|
|
3452
|
-
|
|
3453
|
-
For example, in our example case above if you'd like to pass in the post that
|
|
3454
|
-
was being liked when the button is clicked you could do something like:
|
|
3455
|
-
|
|
3456
|
-
```app/components/like-post.hbs
|
|
3457
|
-
<button {{on 'click' (fn this.saveLike @post)}}>Like this post!</button>
|
|
3458
|
-
```
|
|
3459
|
-
|
|
3460
|
-
In this case, the `saveLike` function will receive two arguments: the click event
|
|
3461
|
-
and the value of `@post`.
|
|
3462
|
-
|
|
3463
|
-
### Function Context
|
|
3464
|
-
|
|
3465
|
-
In the example above, we used an arrow function to ensure that `likePost` is
|
|
3466
|
-
properly bound to the `items-list`, but let's explore what happens if we
|
|
3467
|
-
left out the arrow function:
|
|
3468
|
-
|
|
3469
|
-
```app/components/like-post.js
|
|
3470
|
-
import Component from '@glimmer/component';
|
|
3471
|
-
|
|
3472
|
-
export default class LikePostComponent extends Component {
|
|
3473
|
-
saveLike() {
|
|
3474
|
-
// ...snip...
|
|
3475
|
-
}
|
|
3476
|
-
}
|
|
3477
|
-
```
|
|
3478
|
-
|
|
3479
|
-
In this example, when the button is clicked `saveLike` will be invoked,
|
|
3480
|
-
it will **not** have access to the component instance. In other
|
|
3481
|
-
words, it will have no `this` context, so please make sure your functions
|
|
3482
|
-
are bound (via an arrow function or other means) before passing into `on`!
|
|
3483
|
-
|
|
3484
|
-
@method on
|
|
3485
|
-
@public
|
|
3486
|
-
*/
|
|
3487
|
-
class OnModifierManager {
|
|
3488
|
-
getDebugName() {
|
|
3489
|
-
return 'on';
|
|
3490
|
-
}
|
|
3491
|
-
getDebugInstance() {
|
|
3492
|
-
return null;
|
|
3493
|
-
}
|
|
3494
|
-
get counters() {
|
|
3495
|
-
return {
|
|
3496
|
-
adds,
|
|
3497
|
-
removes
|
|
3498
|
-
};
|
|
3499
|
-
}
|
|
3500
|
-
create(_owner, element, _state, args) {
|
|
3501
|
-
return new OnModifierState(element, args);
|
|
3502
|
-
}
|
|
3503
|
-
getTag({
|
|
3504
|
-
tag
|
|
3505
|
-
}) {
|
|
3506
|
-
return tag;
|
|
3507
|
-
}
|
|
3508
|
-
install(state) {
|
|
3509
|
-
state.updateListener();
|
|
3510
|
-
}
|
|
3511
|
-
update(state) {
|
|
3512
|
-
state.updateListener();
|
|
3513
|
-
}
|
|
3514
|
-
getDestroyable(state) {
|
|
3515
|
-
return state;
|
|
3516
|
-
}
|
|
3517
|
-
}
|
|
3518
|
-
const on = setInternalModifierManager(new OnModifierManager(), {});
|
|
3519
|
-
|
|
3520
|
-
const badProtocols = ['javascript:', 'vbscript:'];
|
|
3521
|
-
const badTags = ['A', 'BODY', 'LINK', 'IMG', 'IFRAME', 'BASE', 'FORM'];
|
|
3522
|
-
const badTagsForDataURI = ['EMBED'];
|
|
3523
|
-
const badAttributes = ['href', 'src', 'background', 'action'];
|
|
3524
|
-
const badAttributesForDataURI = ['src'];
|
|
3525
|
-
function has(array, item) {
|
|
3526
|
-
return array.indexOf(item) !== -1;
|
|
3527
|
-
}
|
|
3528
|
-
function checkURI(tagName, attribute) {
|
|
3529
|
-
return (tagName === null || has(badTags, tagName)) && has(badAttributes, attribute);
|
|
3530
|
-
}
|
|
3531
|
-
function checkDataURI(tagName, attribute) {
|
|
3532
|
-
if (tagName === null) return false;
|
|
3533
|
-
return has(badTagsForDataURI, tagName) && has(badAttributesForDataURI, attribute);
|
|
3534
|
-
}
|
|
3535
|
-
function requiresSanitization(tagName, attribute) {
|
|
3536
|
-
return checkURI(tagName, attribute) || checkDataURI(tagName, attribute);
|
|
3537
|
-
}
|
|
3538
|
-
function findProtocolForURL() {
|
|
3539
|
-
const weirdURL = URL;
|
|
3540
|
-
if (typeof weirdURL === 'object' && weirdURL !== null &&
|
|
3541
|
-
// this is super annoying, TS thinks that URL **must** be a function so `URL.parse` check
|
|
3542
|
-
// thinks it is `never` without this `as unknown as any`
|
|
3543
|
-
|
|
3544
|
-
typeof weirdURL.parse === 'function') {
|
|
3545
|
-
// In Ember-land the `fastboot` package sets the `URL` global to `require('url')`
|
|
3546
|
-
// ultimately, this should be changed (so that we can either rely on the natural `URL` global
|
|
3547
|
-
// that exists) but for now we have to detect the specific `FastBoot` case first
|
|
3548
|
-
//
|
|
3549
|
-
// a future version of `fastboot` will detect if this legacy URL setup is required (by
|
|
3550
|
-
// inspecting Ember version) and if new enough, it will avoid shadowing the `URL` global
|
|
3551
|
-
// constructor with `require('url')`.
|
|
3552
|
-
let nodeURL = weirdURL;
|
|
3553
|
-
return url => {
|
|
3554
|
-
let protocol = null;
|
|
3555
|
-
if (typeof url === 'string') {
|
|
3556
|
-
protocol = nodeURL.parse(url).protocol;
|
|
3557
|
-
}
|
|
3558
|
-
return protocol === null ? ':' : protocol;
|
|
3559
|
-
};
|
|
3560
|
-
} else if (typeof weirdURL === 'function') {
|
|
3561
|
-
return _url => {
|
|
3562
|
-
try {
|
|
3563
|
-
let url = new weirdURL(_url);
|
|
3564
|
-
return url.protocol;
|
|
3565
|
-
} catch {
|
|
3566
|
-
// any non-fully qualified url string will trigger an error (because there is no
|
|
3567
|
-
// baseURI that we can provide; in that case we **know** that the protocol is
|
|
3568
|
-
// "safe" because it isn't specifically one of the `badProtocols` listed above
|
|
3569
|
-
// (and those protocols can never be the default baseURI)
|
|
3570
|
-
return ':';
|
|
3571
|
-
}
|
|
3572
|
-
};
|
|
3573
|
-
} else {
|
|
3574
|
-
throw new Error(`@glimmer/runtime needs a valid "globalThis.URL"`);
|
|
3575
|
-
}
|
|
3576
|
-
}
|
|
3577
|
-
let _protocolForUrlImplementation;
|
|
3578
|
-
function protocolForUrl(url) {
|
|
3579
|
-
if (!_protocolForUrlImplementation) {
|
|
3580
|
-
_protocolForUrlImplementation = findProtocolForURL();
|
|
3581
|
-
}
|
|
3582
|
-
return _protocolForUrlImplementation(url);
|
|
3583
|
-
}
|
|
3584
|
-
function sanitizeAttributeValue(element, attribute, value) {
|
|
3585
|
-
if (value === null || value === undefined) {
|
|
3586
|
-
return value;
|
|
3587
|
-
}
|
|
3588
|
-
if (isSafeString(value)) {
|
|
3589
|
-
return value.toHTML();
|
|
3590
|
-
}
|
|
3591
|
-
const tagName = element.tagName.toUpperCase();
|
|
3592
|
-
let str = normalizeStringValue(value);
|
|
3593
|
-
if (checkURI(tagName, attribute)) {
|
|
3594
|
-
let protocol = protocolForUrl(str);
|
|
3595
|
-
if (has(badProtocols, protocol)) {
|
|
3596
|
-
return `unsafe:${str}`;
|
|
3597
|
-
}
|
|
3598
|
-
}
|
|
3599
|
-
if (checkDataURI(tagName, attribute)) {
|
|
3600
|
-
return `unsafe:${str}`;
|
|
3601
|
-
}
|
|
3602
|
-
return str;
|
|
3603
|
-
}
|
|
3604
|
-
|
|
3605
|
-
function dynamicAttribute(element, attr, namespace, isTrusting = false) {
|
|
3606
|
-
const {
|
|
3607
|
-
tagName,
|
|
3608
|
-
namespaceURI
|
|
3609
|
-
} = element;
|
|
3610
|
-
const attribute = {
|
|
3611
|
-
element,
|
|
3612
|
-
name: attr,
|
|
3613
|
-
namespace
|
|
3614
|
-
};
|
|
3615
|
-
if (attr === 'style' && !isTrusting) {
|
|
3616
|
-
return new DebugStyleAttributeManager(attribute);
|
|
3617
|
-
}
|
|
3618
|
-
if (namespaceURI === NS_SVG) {
|
|
3619
|
-
return buildDynamicAttribute(tagName, attr, attribute);
|
|
3620
|
-
}
|
|
3621
|
-
const {
|
|
3622
|
-
type,
|
|
3623
|
-
normalized
|
|
3624
|
-
} = normalizeProperty(element, attr);
|
|
3625
|
-
if (type === 'attr') {
|
|
3626
|
-
return buildDynamicAttribute(tagName, normalized, attribute);
|
|
3627
|
-
} else {
|
|
3628
|
-
return buildDynamicProperty(tagName, normalized, attribute);
|
|
3629
|
-
}
|
|
3630
|
-
}
|
|
3631
|
-
function buildDynamicAttribute(tagName, name, attribute) {
|
|
3632
|
-
if (requiresSanitization(tagName, name)) {
|
|
3633
|
-
return new SafeDynamicAttribute(attribute);
|
|
3634
|
-
} else {
|
|
3635
|
-
return new SimpleDynamicAttribute(attribute);
|
|
3636
|
-
}
|
|
3637
|
-
}
|
|
3638
|
-
function buildDynamicProperty(tagName, name, attribute) {
|
|
3639
|
-
if (requiresSanitization(tagName, name)) {
|
|
3640
|
-
return new SafeDynamicProperty(name, attribute);
|
|
3641
|
-
}
|
|
3642
|
-
if (isUserInputValue(tagName, name)) {
|
|
3643
|
-
return new InputValueDynamicAttribute(name, attribute);
|
|
3644
|
-
}
|
|
3645
|
-
if (isOptionSelected(tagName, name)) {
|
|
3646
|
-
return new OptionSelectedDynamicAttribute(name, attribute);
|
|
3647
|
-
}
|
|
3648
|
-
return new DefaultDynamicProperty(name, attribute);
|
|
3649
|
-
}
|
|
3650
|
-
class DynamicAttribute {
|
|
3651
|
-
constructor(attribute) {
|
|
3652
|
-
this.attribute = attribute;
|
|
3653
|
-
}
|
|
3654
|
-
}
|
|
3655
|
-
class SimpleDynamicAttribute extends DynamicAttribute {
|
|
3656
|
-
set(dom, value, _env) {
|
|
3657
|
-
const normalizedValue = normalizeValue(value);
|
|
3658
|
-
if (normalizedValue !== null) {
|
|
3659
|
-
const {
|
|
3660
|
-
name,
|
|
3661
|
-
namespace
|
|
3662
|
-
} = this.attribute;
|
|
3663
|
-
dom.__setAttribute(name, normalizedValue, namespace);
|
|
3664
|
-
}
|
|
3665
|
-
}
|
|
3666
|
-
update(value, _env) {
|
|
3667
|
-
const normalizedValue = normalizeValue(value);
|
|
3668
|
-
const {
|
|
3669
|
-
element,
|
|
3670
|
-
name
|
|
3671
|
-
} = this.attribute;
|
|
3672
|
-
if (normalizedValue === null) {
|
|
3673
|
-
element.removeAttribute(name);
|
|
3674
|
-
} else {
|
|
3675
|
-
element.setAttribute(name, normalizedValue);
|
|
3676
|
-
}
|
|
3677
|
-
}
|
|
3678
|
-
}
|
|
3679
|
-
class DefaultDynamicProperty extends DynamicAttribute {
|
|
3680
|
-
constructor(normalizedName, attribute) {
|
|
3681
|
-
super(attribute);
|
|
3682
|
-
this.normalizedName = normalizedName;
|
|
3683
|
-
}
|
|
3684
|
-
value;
|
|
3685
|
-
set(dom, value, _env) {
|
|
3686
|
-
if (value !== null && value !== undefined) {
|
|
3687
|
-
this.value = value;
|
|
3688
|
-
dom.__setProperty(this.normalizedName, value);
|
|
3689
|
-
}
|
|
3690
|
-
}
|
|
3691
|
-
update(value, _env) {
|
|
3692
|
-
const {
|
|
3693
|
-
element
|
|
3694
|
-
} = this.attribute;
|
|
3695
|
-
if (this.value !== value) {
|
|
3696
|
-
element[this.normalizedName] = this.value = value;
|
|
3697
|
-
if (value === null || value === undefined) {
|
|
3698
|
-
this.removeAttribute();
|
|
3699
|
-
}
|
|
3700
|
-
}
|
|
3701
|
-
}
|
|
3702
|
-
removeAttribute() {
|
|
3703
|
-
// TODO this sucks but to preserve properties first and to meet current
|
|
3704
|
-
// semantics we must do this.
|
|
3705
|
-
const {
|
|
3706
|
-
element,
|
|
3707
|
-
namespace
|
|
3708
|
-
} = this.attribute;
|
|
3709
|
-
if (namespace) {
|
|
3710
|
-
element.removeAttributeNS(namespace, this.normalizedName);
|
|
3711
|
-
} else {
|
|
3712
|
-
element.removeAttribute(this.normalizedName);
|
|
3713
|
-
}
|
|
3714
|
-
}
|
|
3715
|
-
}
|
|
3716
|
-
class SafeDynamicProperty extends DefaultDynamicProperty {
|
|
3717
|
-
set(dom, value, env) {
|
|
3718
|
-
const {
|
|
3719
|
-
element,
|
|
3720
|
-
name
|
|
3721
|
-
} = this.attribute;
|
|
3722
|
-
const sanitized = sanitizeAttributeValue(element, name, value);
|
|
3723
|
-
super.set(dom, sanitized, env);
|
|
3724
|
-
}
|
|
3725
|
-
update(value, env) {
|
|
3726
|
-
const {
|
|
3727
|
-
element,
|
|
3728
|
-
name
|
|
3729
|
-
} = this.attribute;
|
|
3730
|
-
const sanitized = sanitizeAttributeValue(element, name, value);
|
|
3731
|
-
super.update(sanitized, env);
|
|
3732
|
-
}
|
|
3733
|
-
}
|
|
3734
|
-
class SafeDynamicAttribute extends SimpleDynamicAttribute {
|
|
3735
|
-
set(dom, value, env) {
|
|
3736
|
-
const {
|
|
3737
|
-
element,
|
|
3738
|
-
name
|
|
3739
|
-
} = this.attribute;
|
|
3740
|
-
const sanitized = sanitizeAttributeValue(element, name, value);
|
|
3741
|
-
super.set(dom, sanitized, env);
|
|
3742
|
-
}
|
|
3743
|
-
update(value, env) {
|
|
3744
|
-
const {
|
|
3745
|
-
element,
|
|
3746
|
-
name
|
|
3747
|
-
} = this.attribute;
|
|
3748
|
-
const sanitized = sanitizeAttributeValue(element, name, value);
|
|
3749
|
-
super.update(sanitized, env);
|
|
3750
|
-
}
|
|
3751
|
-
}
|
|
3752
|
-
class InputValueDynamicAttribute extends DefaultDynamicProperty {
|
|
3753
|
-
set(dom, value) {
|
|
3754
|
-
const normalized = normalizeStringValue(value);
|
|
3755
|
-
dom.__setProperty('value', normalized);
|
|
3756
|
-
|
|
3757
|
-
// GH#19219: Browsers don't reflect `input.value = ''` as a value attribute when
|
|
3758
|
-
// type is later changed to "radio"/"checkbox". Explicitly set the attribute for <input>.
|
|
3759
|
-
// Not needed for <textarea> (no value attribute).
|
|
3760
|
-
if (value === '' && this.attribute.element.tagName === 'INPUT') {
|
|
3761
|
-
dom.__setAttribute('value', '', null);
|
|
3762
|
-
}
|
|
3763
|
-
}
|
|
3764
|
-
update(value) {
|
|
3765
|
-
const input = castToBrowser(this.attribute.element);
|
|
3766
|
-
const currentValue = input.value;
|
|
3767
|
-
const normalizedValue = normalizeStringValue(value);
|
|
3768
|
-
if (currentValue !== normalizedValue) {
|
|
3769
|
-
input.value = normalizedValue;
|
|
3770
|
-
}
|
|
3771
|
-
}
|
|
3772
|
-
}
|
|
3773
|
-
class OptionSelectedDynamicAttribute extends DefaultDynamicProperty {
|
|
3774
|
-
set(dom, value) {
|
|
3775
|
-
if (value !== null && value !== undefined && value !== false) {
|
|
3776
|
-
dom.__setProperty('selected', true);
|
|
3777
|
-
}
|
|
3778
|
-
}
|
|
3779
|
-
update(value) {
|
|
3780
|
-
const option = castToBrowser(this.attribute.element);
|
|
3781
|
-
if (value) {
|
|
3782
|
-
option.selected = true;
|
|
3783
|
-
} else {
|
|
3784
|
-
option.selected = false;
|
|
3785
|
-
}
|
|
3786
|
-
}
|
|
3787
|
-
}
|
|
3788
|
-
function isOptionSelected(tagName, attribute) {
|
|
3789
|
-
return tagName === 'OPTION' && attribute === 'selected';
|
|
3790
|
-
}
|
|
3791
|
-
function isUserInputValue(tagName, attribute) {
|
|
3792
|
-
return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value';
|
|
3793
|
-
}
|
|
3794
|
-
function normalizeValue(value) {
|
|
3795
|
-
if (value === false || value === undefined || value === null || typeof value.toString === 'undefined') {
|
|
3796
|
-
return null;
|
|
3797
|
-
}
|
|
3798
|
-
if (value === true) {
|
|
3799
|
-
return '';
|
|
3800
|
-
}
|
|
3801
|
-
// onclick function etc in SSR
|
|
3802
|
-
if (typeof value === 'function') {
|
|
3803
|
-
return null;
|
|
3804
|
-
}
|
|
3805
|
-
|
|
3806
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- @fixme
|
|
3807
|
-
return String(value);
|
|
3808
|
-
}
|
|
3809
|
-
let DebugStyleAttributeManager;
|
|
3810
|
-
{
|
|
3811
|
-
DebugStyleAttributeManager = class extends SimpleDynamicAttribute {
|
|
3812
|
-
set(dom, value, env) {
|
|
3813
|
-
warnIfStyleNotTrusted(value);
|
|
3814
|
-
super.set(dom, value, env);
|
|
3815
|
-
}
|
|
3816
|
-
update(value, env) {
|
|
3817
|
-
warnIfStyleNotTrusted(value);
|
|
3818
|
-
super.update(value, env);
|
|
3819
|
-
}
|
|
3820
|
-
};
|
|
3821
|
-
}
|
|
3822
|
-
|
|
3823
|
-
export { COMMENT_NODE as A, TEXT_NODE as B, ConcreteBounds as C, DOMChanges as D, EMPTY_ARGS as E, ELEMENT_NODE as F, DOMOperations as G, DebugRenderTreeImpl as H, isArgumentError as I, APPEND_OPCODES as J, move as K, externs as L, JumpIfNotModifiedOpcode as M, NS_SVG as N, BeginTrackFrameOpcode as O, EndTrackFrameOpcode as P, SimpleDynamicAttribute as S, TEMPLATE_ONLY_COMPONENT_MANAGER as T, VMArgumentsImpl as V, CurriedValue as a, CursorImpl as b, DynamicAttribute as c, EMPTY_NAMED as d, EMPTY_POSITIONAL as e, DOMChangesImpl as f, TemplateOnlyComponentDefinition as g, TemplateOnlyComponentManager as h, array as i, clear as j, concat as k, createCapturedArgs as l, curry as m, dynamicAttribute as n, fn as o, get as p, hash as q, isWhitespace as r, normalizeProperty as s, on as t, reifyArgs as u, reifyNamed as v, reifyPositional as w, resetDebuggerCallback as x, setDebuggerCallback as y, templateOnlyComponent as z };
|