Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions addon/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ export default {
// addon. Anything not listed here may get optimized away.
addon.publicEntrypoints([
'index.js',
'helpers/**/*.js',
'services/**/*.js',
'helpers/page-title.js',
'test-support/index.js',
]),

// These are the modules that should get reexported into the traditional
// "app" tree. Things in here should also be in publicEntrypoints above, but
// not everything in publicEntrypoints necessarily needs to go here.
addon.appReexports(['helpers/**/*.js', 'services/**/*.js']),
addon.appReexports(['helpers/**/*.js']),

// This babel config should *not* apply presets or compile away ES modules.
// It exists only to provide development niceties for you, like automatic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { scheduleOnce } from '@ember/runloop';
import Service, { service } from '@ember/service';
import { service } from '@ember/service';
import { isEmpty } from '@ember/utils';
import { assert } from '@ember/debug';
import type ApplicationInstance from '@ember/application/instance';
import type RouterService from '@ember/routing/router-service';
import type Owner from '@ember/owner';
import { setOwner } from '@ember/owner';
import { associateDestroyableChild } from '@ember/destroyable';

import type {
FastBootDocument,
Expand Down Expand Up @@ -36,10 +38,9 @@ function hasPageTitleConfig(
const configKeys = ['separator', 'prepend', 'replace'] as const;

/**
@class page-title
@extends Ember.Service
@internal
*/
export default class PageTitleService extends Service {
export class PageTitleManager {
@service('router') declare router: RouterService;

// in fastboot context "document" is instance of
Expand All @@ -60,7 +61,9 @@ export default class PageTitleService extends Service {
};

constructor(owner: Owner) {
super(owner);
setOwner(this, owner);
associateDestroyableChild(this, owner);

this._validateExistingTitleElement();

if (hasResolveRegistration(owner)) {
Expand Down
7 changes: 4 additions & 3 deletions addon/src/helpers/page-title.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { service } from '@ember/service';
import Helper from '@ember/component/helper';
import { guidFor } from '@ember/object/internals';

import type Owner from '@ember/owner';
import type PageTitleService from '../services/page-title.ts';
import type PageTitleManager from './manager.ts';
import type { PageTitleToken } from '../private-types.ts';

export type PageTitleHelperOptions = Pick<
Expand Down Expand Up @@ -32,12 +31,14 @@ interface Signature {
* ```
*/
export default class PageTitle extends Helper<Signature> {
@service('page-title') declare tokens: PageTitleService;
declare tokens: PageTitleManager;

tokenId = guidFor(this);

constructor(owner: Owner) {
super(owner);

this.tokens = new PageTitleManager(owner);
this.tokens.push({ id: this.tokenId });
}

Expand Down
5 changes: 0 additions & 5 deletions addon/src/service-registry.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import type PageTitleService from './services/page-title.ts';
import type { FastBootDocument } from './private-types.ts';

export default interface ServiceRegistry {
/**
* The service for managing the title of the page.
*/
'page-title': PageTitleService;
/**
* ⚠️ This service is not provided by ember-page-title,
* but is needed by ember-page-title
Expand Down
Loading