Skip to content

Commit

Permalink
[FEATURE] Add remaining Ember modules
Browse files Browse the repository at this point in the history
Adds all of the remaining Ember modules so that we can remove the
API polyfill. Also updates the tests for re-exporting modules so they
are organized by exported module and also test re-exporting the external
module and not any internal one.
  • Loading branch information
Chris Garrett committed Mar 16, 2021
1 parent d414901 commit 49df5a1
Show file tree
Hide file tree
Showing 54 changed files with 629 additions and 206 deletions.
9 changes: 7 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ module.exports = {
}
}

if (optionalFeaturesMissing || optionalFeatures.isFeatureEnabled('jquery-integration')) {
this._jqueryIntegrationEnabled = optionalFeaturesMissing || optionalFeatures.isFeatureEnabled('jquery-integration');

if (this._jqueryIntegrationEnabled) {
this.ui.writeWarnLine(
'Setting the `jquery-integration` optional feature flag to `true`, or not providing a setting at all, has been deprecated. You must add the `@ember/optional-features` addon and set this feature to `false`. This warning will become an error in Ember 4.0.0.\n\nFor more information, see the deprecation guide: https://deprecations.emberjs.com/v3.x/#toc_optional-feature-jquery-integration'
);
Expand Down Expand Up @@ -218,7 +220,10 @@ module.exports = {
false
);

let exclude = isProduction ? ['ember-testing/**'] : [];
let exclude = [
isProduction ? 'ember-testing/**' : null,
!this._jqueryIntegrationEnabled ? 'jquery' : null,
].filter((value) => value !== null);

let emberFiles = new MergeTrees([new Funnel(packages, { exclude }), dependencies, headerFiles]);

Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/-internals/glimmer/lib/utils/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function escapeExpression(string: any): string {
@return {SafeString} A string that will not be HTML escaped by Handlebars.
@public
*/
export function htmlSafe(str: string) {
export function htmlSafe(str: string): SafeString {
if (str === null || str === undefined) {
str = '';
} else if (typeof str !== 'string') {
Expand Down
39 changes: 39 additions & 0 deletions packages/@ember/application/deprecations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
deprecate as _deprecate,
deprecateFunc as _deprecateFunc,
DeprecationOptions,
} from '@ember/debug';

export function deprecate(message: string, condition: boolean, options: DeprecationOptions): void {
deprecate(
"`import { deprecate } from '@ember/application/deprecations';` has been deprecated, please update to `import { deprecate } from '@ember/debug';`",
false,
{
id: 'old-deprecate-method-paths',
until: '4.0.0',
for: 'ember-source',
since: {
enabled: '3.0.0',
},
}
);

_deprecate(message, condition, options);
}

export function deprecateFunc(message: string, options: DeprecationOptions, func: Function): void {
deprecate(
"`import { deprecateFunc } from '@ember/application/deprecations';` has been deprecated, please update to `import { deprecateFunc } from '@ember/debug';`",
false,
{
id: 'old-deprecate-method-paths',
until: '4.0.0',
for: 'ember-source',
since: {
enabled: '3.0.0',
},
}
);

_deprecateFunc(message, options, func);
}
1 change: 1 addition & 0 deletions packages/@ember/application/namespace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Namespace as default } from '@ember/-internals/runtime';
1 change: 1 addition & 0 deletions packages/@ember/application/resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './globals-resolver';
2 changes: 2 additions & 0 deletions packages/@ember/array/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Array as default, isArray, A } from '@ember/-internals/runtime';
export { makeArray } from '@ember/-internals/utils';
1 change: 1 addition & 0 deletions packages/@ember/array/mutable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { MutableArray as default } from '@ember/-internals/runtime';
1 change: 1 addition & 0 deletions packages/@ember/array/proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ArrayProxy as default } from '@ember/-internals/runtime';
21 changes: 21 additions & 0 deletions packages/@ember/component/checkbox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { EMBER_MODERNIZED_BUILT_IN_COMPONENTS } from '@ember/canary-features';
import { deprecate } from '@ember/debug';

if (EMBER_MODERNIZED_BUILT_IN_COMPONENTS) {
deprecate(
`Using Ember.Checkbox or importing from 'Checkbox' has been deprecated, install the ` +
`\`ember-legacy-built-in-components\` addon and use \`import { Checkbox } from ` +
`'ember-legacy-built-in-components';\` instead`,
false,
{
id: 'ember.legacy-built-in-components',
until: '4.0.0',
for: 'ember-source',
since: {
// TODO: update this when enabling the feature
},
}
);
}

export { Checkbox as default } from '@ember/-internals/glimmer';
1 change: 1 addition & 0 deletions packages/@ember/component/helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Helper as default, helper } from '@ember/-internals/glimmer';
7 changes: 6 additions & 1 deletion packages/@ember/component/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export { Component } from '@ember/-internals/glimmer';
export { setComponentTemplate, getComponentTemplate } from '@glimmer/manager';
export { Component as default, Input } from '@ember/-internals/glimmer';
export {
componentCapabilities as capabilities,
setComponentManager,
} from '@ember/-internals/glimmer';
21 changes: 21 additions & 0 deletions packages/@ember/component/text-area.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { EMBER_MODERNIZED_BUILT_IN_COMPONENTS } from '@ember/canary-features';
import { deprecate } from '@ember/debug';

if (EMBER_MODERNIZED_BUILT_IN_COMPONENTS) {
deprecate(
`Using Ember.TextArea or importing from 'TextArea' has been deprecated, install the ` +
`\`ember-legacy-built-in-components\` addon and use \`import { TextArea } from ` +
`'ember-legacy-built-in-components';\` instead`,
false,
{
id: 'ember.legacy-built-in-components',
until: '4.0.0',
for: 'ember-source',
since: {
// TODO: update this when enabling the feature
},
}
);
}

export { TextArea as default } from '@ember/-internals/glimmer';
21 changes: 21 additions & 0 deletions packages/@ember/component/text-field.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { EMBER_MODERNIZED_BUILT_IN_COMPONENTS } from '@ember/canary-features';
import { deprecate } from '@ember/debug';

if (EMBER_MODERNIZED_BUILT_IN_COMPONENTS) {
deprecate(
`Using Ember.TextField or importing from 'TextField' has been deprecated, install the ` +
`\`ember-legacy-built-in-components\` addon and use \`import { TextField } from ` +
`'ember-legacy-built-in-components';\` instead`,
false,
{
id: 'ember.legacy-built-in-components',
until: '4.0.0',
for: 'ember-source',
since: {
// TODO: update this when enabling the feature
},
}
);
}

export { TextField as default } from '@ember/-internals/glimmer';
1 change: 1 addition & 0 deletions packages/@ember/debug/container-debug-adapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ContainerDebugAdapter as default } from '@ember/-internals/extension-support';
1 change: 1 addition & 0 deletions packages/@ember/debug/data-adapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DataAdapter as default } from '@ember/-internals/extension-support';
2 changes: 2 additions & 0 deletions packages/@ember/debug/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import _deprecate, { DeprecateFunc, DeprecationOptions } from './lib/deprecate';
import { isTesting } from './lib/testing';
import _warn, { WarnFunc } from './lib/warn';

export { inspect } from '@ember/-internals/utils';
export { registerHandler as registerWarnHandler } from './lib/warn';
export { registerHandler as registerDeprecationHandler } from './lib/deprecate';
export { isTesting, setTesting } from './lib/testing';
export { default as captureRenderTree } from './lib/capture-render-tree';
export { DeprecationOptions } from './lib/deprecate';

export type DebugFunctionType =
| 'assert'
Expand Down
1 change: 1 addition & 0 deletions packages/@ember/enumerable/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Enumerable as default } from '@ember/-internals/runtime';
4 changes: 2 additions & 2 deletions packages/@ember/helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,5 +304,5 @@
@public
*/

export { setHelperManager, helperCapabilities as capabilties } from '@glimmer/manager';
export { invokeHelper } from '@glimmer/runtime';
export { setHelperManager, helperCapabilities as capabilities } from '@glimmer/manager';
export { invokeHelper, hash, array, concat, get, on, fn } from '@glimmer/runtime';
3 changes: 2 additions & 1 deletion packages/@ember/modifier/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { setModifierManager, modifierCapabilities as capabilties } from '@glimmer/manager';
export { setModifierManager } from '@glimmer/manager';
export { modifierCapabilities as capabilities } from '@ember/-internals/glimmer';
3 changes: 3 additions & 0 deletions packages/@ember/object/computed.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export { ComputedProperty as default, expandProperties, alias } from '@ember/-internals/metal';

export {
empty,
notEmpty,
Expand All @@ -11,6 +13,7 @@ export {
lt,
lte,
oneWay,
oneWay as reads,
readOnly,
deprecatingAlias,
and,
Expand Down
1 change: 1 addition & 0 deletions packages/@ember/object/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { CoreObject as default } from '@ember/-internals/runtime';
2 changes: 2 additions & 0 deletions packages/@ember/object/evented.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Evented as default } from '@ember/-internals/runtime';
export { on } from '@ember/-internals/metal';
1 change: 1 addition & 0 deletions packages/@ember/object/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { addListener, removeListener, sendEvent } from '@ember/-internals/metal';
16 changes: 16 additions & 0 deletions packages/@ember/object/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ import { assert } from '@ember/debug';
import { assign } from '@ember/polyfills';
import { isElementDescriptor, setClassicDecorator } from '@ember/-internals/metal';

export { Object as default } from '@ember/-internals/runtime';

export {
notifyPropertyChange,
defineProperty,
get,
set,
getProperties,
setProperties,
getWithDefault,
observer,
computed,
trySet,
aliasMethod,
} from '@ember/-internals/metal';

/**
Decorator that turns the target function into an Action which can be accessed
directly by reference.
Expand Down
3 changes: 3 additions & 0 deletions packages/@ember/object/internals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { getCachedValueFor as cacheFor } from '@ember/-internals/metal';
export { copy } from '@ember/-internals/runtime';
export { guidFor } from '@ember/-internals/utils';
1 change: 1 addition & 0 deletions packages/@ember/object/mixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Mixin as default } from '@ember/-internals/metal';
1 change: 1 addition & 0 deletions packages/@ember/object/observable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Observable as default } from '@ember/-internals/runtime';
1 change: 1 addition & 0 deletions packages/@ember/object/observers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { addObserver, removeObserver } from '@ember/-internals/metal';
1 change: 1 addition & 0 deletions packages/@ember/object/promise-proxy-mixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { PromiseProxyMixin as default } from '@ember/-internals/runtime';
1 change: 1 addition & 0 deletions packages/@ember/object/proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ObjectProxy as default } from '@ember/-internals/runtime';
2 changes: 2 additions & 0 deletions packages/@ember/polyfills/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ let merge = MERGE ? deprecatedMerge : undefined;
// Export `assignPolyfill` for testing
export { default as assign, assign as assignPolyfill } from './lib/assign';
export { merge };

export const hasPropertyAccessors = true;
1 change: 1 addition & 0 deletions packages/@ember/routing/auto-location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { AutoLocation as default } from '@ember/-internals/routing';
1 change: 1 addition & 0 deletions packages/@ember/routing/hash-location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { HashLocation as default } from '@ember/-internals/routing';
1 change: 1 addition & 0 deletions packages/@ember/routing/history-location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { HistoryLocation as default } from '@ember/-internals/routing';
1 change: 1 addition & 0 deletions packages/@ember/routing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { LinkComponent as LinkTo } from '@ember/-internals/glimmer';
21 changes: 21 additions & 0 deletions packages/@ember/routing/link-component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { EMBER_MODERNIZED_BUILT_IN_COMPONENTS } from '@ember/canary-features';
import { deprecate } from '@ember/debug';

if (EMBER_MODERNIZED_BUILT_IN_COMPONENTS) {
deprecate(
`Using Ember.LinkComponent or importing from 'LinkComponent' has been deprecated, install the ` +
`\`ember-legacy-built-in-components\` addon and use \`import { LinkComponent } from ` +
`'ember-legacy-built-in-components';\` instead`,
false,
{
id: 'ember.legacy-built-in-components',
until: '4.0.0',
for: 'ember-source',
since: {
// TODO: update this when enabling the feature
},
}
);
}

export { LinkComponent as default } from '@ember/-internals/glimmer';
1 change: 1 addition & 0 deletions packages/@ember/routing/location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Location as default } from '@ember/-internals/routing';
1 change: 1 addition & 0 deletions packages/@ember/routing/none-location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { NoneLocation as default } from '@ember/-internals/routing';
1 change: 1 addition & 0 deletions packages/@ember/routing/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Route as default } from '@ember/-internals/routing';
1 change: 1 addition & 0 deletions packages/@ember/routing/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Router as default } from '@ember/-internals/routing';
35 changes: 35 additions & 0 deletions packages/@ember/string/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import { Cache } from '@ember/-internals/utils';
import { deprecate } from '@ember/debug';
import { getString } from './lib/string_registry';

import {
htmlSafe as internalHtmlSafe,
isHTMLSafe as internalIsHtmlSafe,
SafeString,
} from '@ember/-internals/glimmer';

const STRING_DASHERIZE_REGEXP = /[ _]/g;

const STRING_DASHERIZE_CACHE = new Cache<string, string>(1000, (key) =>
Expand Down Expand Up @@ -294,6 +300,35 @@ export function capitalize(str: string): string {
return CAPITALIZE_CACHE.get(str);
}

function deprecateImportFromString(
name: string,
message = `Importing ${name} from '@ember/string' is deprecated. Please import ${name} from '@ember/template' instead.`
) {
// Disabling this deprecation due to unintended errors in 3.25
// See https://github.com/emberjs/ember.js/issues/19393 fo more information.
deprecate(message, true, {
id: 'ember-string.htmlsafe-ishtmlsafe',
for: 'ember-source',
since: {
enabled: '3.25',
},
until: '4.0.0',
url: 'https://deprecations.emberjs.com/v3.x/#toc_ember-string-htmlsafe-ishtmlsafe',
});
}

export function htmlSafe(str: string): SafeString {
deprecateImportFromString('htmlSafe');

return internalHtmlSafe(str);
}

export function isHTMLSafe(str: any | null | undefined): str is SafeString {
deprecateImportFromString('isHTMLSafe');

return internalIsHtmlSafe(str);
}

if (ENV.EXTEND_PROTOTYPES.String) {
let deprecateEmberStringPrototypeExtension = function (
name: string,
Expand Down
13 changes: 13 additions & 0 deletions packages/@ember/template-compilation/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { DEBUG } from '@glimmer/env';

export { compile as compileTemplate } from 'ember-template-compiler';

export let precompileTemplate;

if (DEBUG) {
precompileTemplate = () => {
throw new Error(
'Attempted to call `precompileTemplate` at runtime, but this API is meant to be used at compile time. You should use `compileTemplate` instead.'
);
};
}
1 change: 1 addition & 0 deletions packages/@ember/template-factory/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { templateFactory as createTemplateFactory } from '@glimmer/opcode-compiler';
1 change: 1 addition & 0 deletions packages/@ember/template/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { htmlSafe, isHTMLSafe } from '@ember/-internals/glimmer';
3 changes: 3 additions & 0 deletions packages/@ember/test/adapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Test } from 'ember-testing';

export default Test.Adapter;
11 changes: 11 additions & 0 deletions packages/@ember/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Test } from 'ember-testing';

const {
registerAsyncHelper,
registerHelper,
registerWaiter,
unregisterHelper,
unregisterWaiter,
} = Test;

export { registerAsyncHelper, registerHelper, registerWaiter, unregisterHelper, unregisterWaiter };
3 changes: 3 additions & 0 deletions packages/@ember/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { isNone, isBlank, isEmpty, isPresent } from '@ember/-internals/metal';
export { tryInvoke } from '@ember/-internals/utils';
export { compare, isEqual, typeOf } from '@ember/-internals/runtime';
1 change: 1 addition & 0 deletions packages/@ember/version/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as VERSION } from 'ember/version';
1 change: 1 addition & 0 deletions packages/@glimmer/tracking/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { tracked } from '@ember/-internals/metal';
1 change: 1 addition & 0 deletions packages/@glimmer/tracking/primitives/cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { createCache, getValue, isConst } from '@ember/-internals/metal';
1 change: 0 additions & 1 deletion packages/ember/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ Object.defineProperty(Ember.run, 'currentRunLoop', {

// ****@ember/-internals/metal****

// Using _globalsComputed here so that mutating the function is only available
// in globals builds
const computed = metal._globalsComputed;
Ember.computed = computed;
Expand Down
Loading

0 comments on commit 49df5a1

Please sign in to comment.