Skip to content

Commit 3676088

Browse files
Merge pull request #21462 from emberjs/nvp/cleanup-3
Refactor so that small apps don't pull in the old renderer as well as some classic things
2 parents faeea2f + 16c8800 commit 3676088

16 files changed

Lines changed: 787 additions & 708 deletions

File tree

packages/@ember/-internals/glimmer/lib/base-renderer.ts

Lines changed: 667 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* The brand for the curly component manager lives in its own module so that
3+
* code which only needs to *detect* the curly manager (e.g. the resolver)
4+
* does not have to import the manager itself (and with it the classic
5+
* component machinery).
6+
*/
7+
export const CURLY_MANAGER_BRAND: unique symbol = Symbol('CURLY_MANAGER_BRAND');
8+
9+
export function isCurlyManager(manager: object): boolean {
10+
return (manager as any)[CURLY_MANAGER_BRAND] === true;
11+
}

packages/@ember/-internals/glimmer/lib/component-managers/curly.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import {
6060

6161
import ComponentStateBucket from '../utils/curly-component-state-bucket';
6262
import { processComponentArgs } from '../utils/process-args';
63+
import { CURLY_MANAGER_BRAND } from './curly-brand';
6364

6465
const COMPONENT_ARGS_MAP = new WeakMap<object, CapturedArguments['named']>();
6566

@@ -139,6 +140,8 @@ export default class CurlyComponentManager
139140
WithDynamicLayout<ComponentStateBucket, RuntimeResolver>,
140141
WithDynamicTagName<ComponentStateBucket>
141142
{
143+
readonly [CURLY_MANAGER_BRAND] = true;
144+
142145
protected templateFor(component: Component): CompilableProgram | null {
143146
let { layout, layoutName } = component;
144147
let owner = getOwner(component);
@@ -559,8 +562,6 @@ const CURLY_CAPABILITIES: InternalComponentCapabilities = {
559562
hasSubOwner: false,
560563
};
561564

562-
export const CURLY_COMPONENT_MANAGER = new CurlyComponentManager();
565+
export const CURLY_COMPONENT_MANAGER = /*@__PURE__*/ new CurlyComponentManager();
563566

564-
export function isCurlyManager(manager: object): boolean {
565-
return manager === CURLY_COMPONENT_MANAGER;
566-
}
567+
export { isCurlyManager } from './curly-brand';

packages/@ember/-internals/glimmer/lib/component-managers/mount.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class MountManager
166166
}
167167
}
168168

169-
const MOUNT_MANAGER = new MountManager();
169+
const MOUNT_MANAGER = /*@__PURE__*/ new MountManager();
170170

171171
export class MountDefinition implements ComponentDefinition {
172172
// handle is not used by this custom definition

packages/@ember/-internals/glimmer/lib/component-managers/outlet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const CAPABILITIES: InternalComponentCapabilities = {
6161
hasSubOwner: false,
6262
};
6363

64-
const CAPABILITIES_MASK = capabilityFlagsFrom(CAPABILITIES);
64+
const CAPABILITIES_MASK = /*@__PURE__*/ capabilityFlagsFrom(CAPABILITIES);
6565

6666
class OutletComponentManager
6767
implements
@@ -169,7 +169,7 @@ class OutletComponentManager
169169
}
170170
}
171171

172-
const OUTLET_MANAGER = new OutletComponentManager();
172+
const OUTLET_MANAGER = /*@__PURE__*/ new OutletComponentManager();
173173

174174
const OUTLET_COMPONENT_TEMPLATE = precompileTemplate(
175175
'<@Component @controller={{@controller}} @model={{@model}} />',

packages/@ember/-internals/glimmer/lib/component-managers/route-template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const CAPABILITIES: InternalComponentCapabilities = {
4646
hasSubOwner: false,
4747
};
4848

49-
const CAPABILITIES_MASK = capabilityFlagsFrom(CAPABILITIES);
49+
const CAPABILITIES_MASK = /*@__PURE__*/ capabilityFlagsFrom(CAPABILITIES);
5050

5151
class RouteTemplateManager
5252
implements
@@ -108,7 +108,7 @@ class RouteTemplateManager
108108
}
109109
}
110110

111-
const ROUTE_TEMPLATE_MANAGER = new RouteTemplateManager();
111+
const ROUTE_TEMPLATE_MANAGER = /*@__PURE__*/ new RouteTemplateManager();
112112

113113
/**
114114
* This "upgrades" a route template into a invocable component. Conceptually
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* The brand for classic (class-based) helpers lives in its own module so that
3+
* code which only needs to *detect* classic helpers (e.g. the resolver) does
4+
* not have to import the classic `Helper` base class (and with it the classic
5+
* object model: `EmberObject`, `Mixin`, meta, etc.).
6+
*/
7+
export const IS_CLASSIC_HELPER: unique symbol = Symbol('IS_CLASSIC_HELPER');
8+
9+
export function isClassicHelper(obj: object): boolean {
10+
return (obj as any)[IS_CLASSIC_HELPER] === true;
11+
}

packages/@ember/-internals/glimmer/lib/helper.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import getDebugName from '@ember/-internals/utils/lib/get-debug-name';
1010
import { assert } from '@ember/debug';
1111
import { join } from '@ember/runloop';
1212
import type { Arguments, HelperManager } from '@glimmer/interfaces';
13-
import { getInternalHelperManager } from '@glimmer/manager/lib/internal/api';
1413
import { helperCapabilities } from '@glimmer/manager/lib/public/helper';
1514
import { setHelperManager } from '@glimmer/manager/lib/public/api';
1615
import type { DirtyableTag } from '@glimmer/interfaces';
1716
import { consumeTag } from '@glimmer/validator/lib/tracking';
1817
import { createTag, DIRTY_TAG as dirtyTag } from '@glimmer/validator/lib/validators';
18+
import { IS_CLASSIC_HELPER } from './helper-brand';
19+
20+
export { isClassicHelper } from './helper-brand';
1921

2022
const RECOMPUTE_TAG = Symbol('RECOMPUTE_TAG');
2123

@@ -44,8 +46,6 @@ export interface HelperInstance<S> {
4446
[RECOMPUTE_TAG]: DirtyableTag;
4547
}
4648

47-
const IS_CLASSIC_HELPER: unique symbol = Symbol('IS_CLASSIC_HELPER');
48-
4949
export interface SimpleHelper<S> {
5050
compute: (positional: Positional<S>, named: Named<S>) => Return<S>;
5151
}
@@ -60,15 +60,15 @@ declare const SIGNATURE: unique symbol;
6060
6161
```app/templates/application.gjs
6262
import Cost from '../components/cost';
63-
63+
6464
<template>
6565
<Cost @cents={{230}} />
6666
</template>
6767
```
6868
6969
```app/components/cost.gjs
7070
import formatCurrency from '../helpers/format-currency';
71-
71+
7272
<template>
7373
<div>{{formatCurrency @cents currency="$"}}</div>
7474
</template>
@@ -193,10 +193,6 @@ export default class Helper<S = unknown> extends FrameworkObject {
193193
}
194194
/* eslint-enable import/export */
195195

196-
export function isClassicHelper(obj: object): boolean {
197-
return (obj as any)[IS_CLASSIC_HELPER] === true;
198-
}
199-
200196
interface ClassicHelperStateBucket {
201197
instance: HelperInstance<unknown>;
202198
args: Arguments;
@@ -273,8 +269,6 @@ setHelperManager((owner: InternalOwner | undefined): ClassicHelperManager => {
273269
return new ClassicHelperManager(owner);
274270
}, Helper);
275271

276-
export const CLASSIC_HELPER_MANAGER = getInternalHelperManager(Helper);
277-
278272
///////////
279273

280274
class Wrapper<S = unknown> implements HelperFactory<SimpleHelper<S>> {

0 commit comments

Comments
 (0)