From 649124909c2c14a74c3f630d4c5174563d06fc73 Mon Sep 17 00:00:00 2001 From: Ruslan Lopatin Date: Mon, 12 Jul 2021 16:47:07 +0700 Subject: [PATCH] Move global context entries to dedicated libraries (#64) * Utilize global `NamespaceAliaser` * Utilize context entries defined in `@proc7ts/render-scheduler` * Utilize `DocumentRenderKit` defined in `@frontmeans/drek` * Upgrade deps * Upgrade deps * Upgrade deps * Wesib v2 * Wesib v2 --- package.json | 14 +++++------ src/fetch/http-fetch-agent.spec.ts | 2 +- src/fetch/http-fetch.ts | 4 ++-- src/fragment/fragment-render-ctl.spec.ts | 14 +++++++---- src/fragment/fragment-render-ctl.ts | 5 ++-- .../render-fragment.amendment.spec.ts | 24 +++++++++---------- src/shares/share-registry.impl.ts | 7 +++--- 7 files changed, 39 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index b6f21325..bc90fdfc 100644 --- a/package.json +++ b/package.json @@ -21,17 +21,17 @@ "exports": "./dist/wesib.generic.js", "peerDependencies": { "@proc7ts/fun-events": "^10.5.0", - "@wesib/wesib": "^2.0.0-dev.0" + "@wesib/wesib": "^2.0.0" }, "dependencies": { "@frontmeans/dom-events": "^1.2.0", "@frontmeans/dom-primitives": "^1.1.0", - "@frontmeans/drek": "^1.2.0", - "@frontmeans/namespace-aliaser": "^2.5.0", - "@frontmeans/render-scheduler": "^1.7.0", + "@frontmeans/drek": "^1.3.1", + "@frontmeans/namespace-aliaser": "^2.6.2", + "@frontmeans/render-scheduler": "^1.8.1", "@proc7ts/amend": "^1.0.0", - "@proc7ts/context-builder": "^7.0.0-dev.13", - "@proc7ts/context-values": "^7.0.0-dev.13", + "@proc7ts/context-builder": "^7.0.0", + "@proc7ts/context-values": "^7.0.0", "@proc7ts/primitives": "^3.0.2", "@proc7ts/supply": "^1.2.3" }, @@ -44,7 +44,7 @@ "@types/jsdom": "^16.2.13", "@typescript-eslint/eslint-plugin": "^4.28.2", "@typescript-eslint/parser": "^4.28.2", - "@wesib/wesib": "^2.0.0-dev.0", + "@wesib/wesib": "^2.0.0", "cross-fetch": "^3.1.4", "eslint": "^7.30.0", "eslint-plugin-jest": "^24.3.6", diff --git a/src/fetch/http-fetch-agent.spec.ts b/src/fetch/http-fetch-agent.spec.ts index 6dc22068..8d421388 100644 --- a/src/fetch/http-fetch-agent.spec.ts +++ b/src/fetch/http-fetch-agent.spec.ts @@ -89,7 +89,7 @@ describe('fetch', () => { expect(() => agent(mockFetch, request)).toThrow(new CxReferenceError( HttpFetchAgent, - 'The [HttpFetchAgent] is unavailable', + 'The [HttpFetchAgent] is no longer available', reason, )); expect(mockFetch).not.toHaveBeenCalled(); diff --git a/src/fetch/http-fetch.ts b/src/fetch/http-fetch.ts index 12c7fc78..353b124d 100644 --- a/src/fetch/http-fetch.ts +++ b/src/fetch/http-fetch.ts @@ -1,9 +1,9 @@ import { DomEventDispatcher } from '@frontmeans/dom-events'; +import { CxWindow } from '@frontmeans/render-scheduler'; import { CxEntry, cxRecent } from '@proc7ts/context-values'; import { EventEmitter, onceOn, OnEvent, onEventBy } from '@proc7ts/fun-events'; import { asis } from '@proc7ts/primitives'; import { Supply } from '@proc7ts/supply'; -import { BootstrapWindow } from '@wesib/wesib'; import { HttpFetchAgent } from './http-fetch-agent'; /** @@ -51,7 +51,7 @@ const HttpFetchAborted = {}; function HttpFetch$byDefault(target: CxEntry.Target): HttpFetch { - const window = target.get(BootstrapWindow); + const window = target.get(CxWindow); const agent = target.get(HttpFetchAgent); return (input, init) => agent(fetch, new Request(input, init)); diff --git a/src/fragment/fragment-render-ctl.spec.ts b/src/fragment/fragment-render-ctl.spec.ts index b490e902..8cf2b64c 100644 --- a/src/fragment/fragment-render-ctl.spec.ts +++ b/src/fragment/fragment-render-ctl.spec.ts @@ -1,11 +1,17 @@ import { nodeWindow } from '@frontmeans/dom-primitives'; import { drekContextOf } from '@frontmeans/drek'; -import { queuedRenderScheduler, RenderSchedule, RenderScheduleOptions } from '@frontmeans/render-scheduler'; +import { + PreRenderScheduler, + queuedRenderScheduler, + RenderSchedule, + RenderScheduleOptions, + RenderScheduler, +} from '@frontmeans/render-scheduler'; import { beforeEach, describe, expect, it, jest } from '@jest/globals'; import { cxConstAsset } from '@proc7ts/context-builder'; import { EventEmitter } from '@proc7ts/fun-events'; import { noop } from '@proc7ts/primitives'; -import { Component, ComponentContext, DefaultPreRenderScheduler, DefaultRenderScheduler } from '@wesib/wesib'; +import { Component, ComponentContext } from '@wesib/wesib'; import { testDefinition } from '@wesib/wesib/testing'; import { Mock } from 'jest-mock'; import { FragmentRenderCtl } from './fragment-render-ctl'; @@ -36,8 +42,8 @@ describe('fragment', () => { @Component({ feature: { setup(setup) { - setup.provide(cxConstAsset(DefaultRenderScheduler, mockRenderScheduler)); - setup.provide(cxConstAsset(DefaultPreRenderScheduler, mockPreRenderScheduler)); + setup.provide(cxConstAsset(RenderScheduler, mockRenderScheduler)); + setup.provide(cxConstAsset(PreRenderScheduler, mockPreRenderScheduler)); }, }, }) diff --git a/src/fragment/fragment-render-ctl.ts b/src/fragment/fragment-render-ctl.ts index 459801ab..96e93c32 100644 --- a/src/fragment/fragment-render-ctl.ts +++ b/src/fragment/fragment-render-ctl.ts @@ -1,8 +1,9 @@ import { drekAppender, drekCharger, DrekFragment, DrekTarget } from '@frontmeans/drek'; +import { PreRenderScheduler } from '@frontmeans/render-scheduler'; import { CxEntry, cxSingle } from '@proc7ts/context-values'; import { lazyValue, valueByRecipe } from '@proc7ts/primitives'; import { Supply } from '@proc7ts/supply'; -import { ComponentContext, ComponentRenderCtl, DefaultPreRenderScheduler } from '@wesib/wesib'; +import { ComponentContext, ComponentRenderCtl } from '@wesib/wesib'; import { FragmentRenderer, FragmentRendererExecution } from './fragment-renderer'; import { RenderFragmentDef } from './render-fragment-def'; @@ -60,7 +61,7 @@ class FragmentRenderCtl$ implements FragmentRenderCtl { const { target = RenderFragment$defaultTarget } = spec; const getTarget: () => DrekTarget = lazyValue(() => target(this._context)); const renderCtl = this._context.get(ComponentRenderCtl); - const scheduler = this._context.get(DefaultPreRenderScheduler); + const scheduler = this._context.get(PreRenderScheduler); const supply = new Supply(); const renderSupply = renderCtl.preRenderBy( preExec => { diff --git a/src/fragment/render-fragment.amendment.spec.ts b/src/fragment/render-fragment.amendment.spec.ts index 780d0c8c..04023e64 100644 --- a/src/fragment/render-fragment.amendment.spec.ts +++ b/src/fragment/render-fragment.amendment.spec.ts @@ -1,17 +1,17 @@ import { nodeWindow } from '@frontmeans/dom-primitives'; import { drekContextOf, drekReplacer } from '@frontmeans/drek'; -import { queuedRenderScheduler, RenderSchedule, RenderScheduleOptions } from '@frontmeans/render-scheduler'; +import { + PreRenderScheduler, + queuedRenderScheduler, + RenderSchedule, + RenderScheduleOptions, + RenderScheduler, +} from '@frontmeans/render-scheduler'; import { beforeEach, describe, expect, it, jest } from '@jest/globals'; import { cxConstAsset } from '@proc7ts/context-builder'; import { Class } from '@proc7ts/primitives'; import { Supply } from '@proc7ts/supply'; -import { - Component, - ComponentContext, - DefaultPreRenderScheduler, - DefaultRenderScheduler, - statePropertyPathTo, -} from '@wesib/wesib'; +import { Component, ComponentContext, statePropertyPathTo } from '@wesib/wesib'; import { testDefinition } from '@wesib/wesib/testing'; import { Mock } from 'jest-mock'; import { FragmentRendererExecution } from './fragment-renderer'; @@ -246,8 +246,8 @@ describe('fragment', () => { @Component({ feature: { setup(setup) { - setup.provide(cxConstAsset(DefaultRenderScheduler, mockRenderScheduler)); - setup.provide(cxConstAsset(DefaultPreRenderScheduler, mockPreRenderScheduler)); + setup.provide(cxConstAsset(RenderScheduler, mockRenderScheduler)); + setup.provide(cxConstAsset(PreRenderScheduler, mockPreRenderScheduler)); }, }, }) @@ -264,8 +264,8 @@ describe('fragment', () => { @Component({ feature: { setup(setup) { - setup.provide(cxConstAsset(DefaultRenderScheduler, mockRenderScheduler)); - setup.provide(cxConstAsset(DefaultPreRenderScheduler, mockPreRenderScheduler)); + setup.provide(cxConstAsset(RenderScheduler, mockRenderScheduler)); + setup.provide(cxConstAsset(PreRenderScheduler, mockPreRenderScheduler)); }, }, }) diff --git a/src/shares/share-registry.impl.ts b/src/shares/share-registry.impl.ts index d888cd39..7e0f1a62 100644 --- a/src/shares/share-registry.impl.ts +++ b/src/shares/share-registry.impl.ts @@ -1,12 +1,13 @@ +import { NamespaceAliaser } from '@frontmeans/namespace-aliaser'; import { CxEntry, cxEvaluated, cxScoped } from '@proc7ts/context-values'; import { trackValue, ValueTracker } from '@proc7ts/fun-events'; import { Supply } from '@proc7ts/supply'; -import { BootstrapContext, ComponentClass, DefaultNamespaceAliaser } from '@wesib/wesib'; +import { BootstrapContext, ComponentClass } from '@wesib/wesib'; import { Share } from './share'; const ShareRegistry$perContext: CxEntry.Definer = (/*#__PURE__*/ cxScoped( BootstrapContext, - cxEvaluated(target => new ShareRegistry(target.get(DefaultNamespaceAliaser))), + cxEvaluated(target => new ShareRegistry(target.get(NamespaceAliaser))), )); export class ShareRegistry { @@ -21,7 +22,7 @@ export class ShareRegistry { private readonly _sharers = new Map, ValueTracker>(); - constructor(readonly nsAlias: DefaultNamespaceAliaser) { + constructor(readonly nsAlias: NamespaceAliaser) { } addSharer(