Skip to content

add ember public api#2723

Draft
patricklx wants to merge 20 commits intoemberjs:mainfrom
patricklx:add-ember-public-api
Draft

add ember public api#2723
patricklx wants to merge 20 commits intoemberjs:mainfrom
patricklx:add-ember-public-api

Conversation

@patricklx
Copy link
Copy Markdown
Collaborator

Description

Screenshots

- Rewrite ember_debug/utils/ember.js to use new appLoader.loadCompatInspector() API
- Update ember-object-names.js to use getClassName() from new API
- Update type-check.js to use new type checking and computed property APIs
- Add comprehensive API analysis document with TypeScript definitions
- Hard cut to new API (no fallback to old internal modules)
- Replace instanceof checks with type checking functions
- Simplify tracking API usage
- Add missing exports to ember.js: GlimmerRuntime, GlimmerManager, GlimmerReference, GlimmerUtil, EmberDestroyable, RSVP, Application, Namespace
- Update object-inspector.js to use new tracking API (createPropertyTracker, hasPropertyChanged, getPropertyDependencies, getChangedDependencies, isTrackedProperty)
- Replace all instanceof checks with type checking functions (isEmberObject, isCoreObject, isObjectProxy, isArrayProxy, isService, isComponent, isGlimmerComponent)
- Remove old Glimmer tracking setup code (tagValue, tagValidate, track, tagForProperty, HAS_GLIMMER_TRACKING)
- Simplify getTrackedDependencies to use new API
- Build passes successfully
- Fix remaining instanceof ObjectProxy check in object-inspector.js
- Remove unused emberMeta import from type-check.js
- Fix prettier formatting issues
- All eslint checks now pass
@patricklx patricklx force-pushed the add-ember-public-api branch from 75f477f to 770e782 Compare February 26, 2026 16:04
- Replace direct __container__ access with emberInspectorAPI.owner.getContainerInstances()
- Replace all owner.lookup() and container.lookup() calls with emberInspectorAPI.owner.lookup()
- Replace route tree building (150+ lines) with emberInspectorAPI.router.buildRouteTree()
- Replace router internal access with emberInspectorAPI.router.getRouteHandler()
- Add comprehensive API stub in ember_debug/utils/ember-inspector-api.js
- Update EMBER_INSPECTOR_API_ANALYSIS.md with Owner/Container/Router APIs
- Add IMPLEMENTATION_COMPARISON.md showing 98% code reduction

Benefits:
- Zero direct private API access
- Zero version-specific code
- 180+ lines eliminated (98% reduction)
- Stable public API that won't break with Ember internals changes
@patricklx patricklx force-pushed the add-ember-public-api branch from 770e782 to 1fc3c91 Compare February 26, 2026 16:09
- Add computed.getComputedMetadata() API to replace direct access to desc._getter, desc._readOnly, desc._auto
- Add renderTree.getDebugRenderTree() API to replace direct access to _debugRenderTree
- Update object-inspector.js to use new computed metadata API
- Update render-tree.js to use new render tree API
- Update EMBER_INSPECTOR_API_ANALYSIS.md with new API definitions
- Add ComputedMetadata and DebugRenderTree interface definitions

This eliminates the remaining private property access in the implementation code.
The API stub still contains private access as it's the compatibility layer.
@patricklx patricklx force-pushed the add-ember-public-api branch from 9b372eb to 2ac9e8f Compare February 27, 2026 10:25
- Add computed.isMandatorySetter() API to replace string checking for 'You attempted to update'
- Update object-inspector.js to use new API instead of checking setter code
- Update EMBER_INSPECTOR_API_ANALYSIS.md with new API definition

This eliminates the last instance of checking internal implementation details via string matching.
@patricklx patricklx force-pushed the add-ember-public-api branch from 72ac286 to b29c19b Compare February 27, 2026 10:29
- Add computed.isCached() API to detect properties using @cached decorator
- Update EMBER_INSPECTOR_API_ANALYSIS.md with isCached documentation
- Implement stub in ember-inspector-api.js with heuristic detection
- @cached is from @glimmer/tracking and memoizes getter results

This provides a public API to identify cached properties without relying on internal implementation details.
@patricklx patricklx force-pushed the add-ember-public-api branch from 1c8d12f to 69c46b0 Compare February 27, 2026 10:33
- Remove unused imports from object-inspector.js
- Fix structural bug in ember-inspector-api.js (misplaced closing brace)
- Add eslint-disable directives for intentional private API usage in stub
- Add no-unused-vars exceptions for stub method parameters
- Add getApplication() and getOwnerFromApplication() to emberInspectorAPI.owner
- Replace local getApplication/getOwner functions in main.js with API calls
- Remove now-unused local helper functions
- Move Application/Namespace imports inside the stub (no longer passed as args)
- Simplify call site in main.js to emberInspectorAPI.owner.getApplication()
- Remove now-unused Application/Namespace imports from main.js
patricklx added a commit to patricklx/ember.js that referenced this pull request Feb 27, 2026
Implements the public inspector API as outlined in emberjs/ember-inspector#2723.
This provides a stable, high-level interface for the Ember Inspector to access
Ember internals without depending on private APIs.

The API includes:
- debug: captureRenderTree, inspect, registerDeprecationHandler
- environment: getEnv, VERSION
- instrumentation: subscribe, unsubscribe
- objectInternals: cacheFor, guidFor, meta, get, set
- owner: getOwner, lookup, factoryFor, hasRegistration, getContainerInstances
- libraries: getRegistry
- typeChecking: isEmberObject, isComponent, isGlimmerComponent, isService, etc.
- naming: getClassName (resolves Ember class/mixin names)
- tracking: createPropertyTracker, hasPropertyChanged, getPropertyDependencies, etc.
- computed: isComputed, getComputedMetadata, isMandatorySetter, isCached
- renderTree: getDebugRenderTree
- runloop: getBackburner, join, debounce, cancel
…ions

- Add new higher-level API methods to ember-inspector-api.js:
  - hasRegistration, getDataAdapter, getRouter, getController, getRoute, getInstance
- Remove _resolve method from data-debug.js
- Replace all emberInspectorAPI.owner.lookup calls with appropriate high-level methods
- Encapsulate all low-level owner access within ember-inspector-api.js only

This improves code maintainability and provides better abstraction for owner interactions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant