Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
Move global context entries to dedicated libraries (#64)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
surol authored Jul 12, 2021
1 parent dd3eb8f commit 6491249
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 31 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/fetch/http-fetch-agent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/fetch/http-fetch.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down Expand Up @@ -51,7 +51,7 @@ const HttpFetchAborted = {};

function HttpFetch$byDefault(target: CxEntry.Target<HttpFetch>): 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));
Expand Down
14 changes: 10 additions & 4 deletions src/fragment/fragment-render-ctl.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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));
},
},
})
Expand Down
5 changes: 3 additions & 2 deletions src/fragment/fragment-render-ctl.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 => {
Expand Down
24 changes: 12 additions & 12 deletions src/fragment/render-fragment.amendment.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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));
},
},
})
Expand All @@ -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));
},
},
})
Expand Down
7 changes: 4 additions & 3 deletions src/shares/share-registry.impl.ts
Original file line number Diff line number Diff line change
@@ -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<ShareRegistry> = (/*#__PURE__*/ cxScoped(
BootstrapContext,
cxEvaluated(target => new ShareRegistry(target.get(DefaultNamespaceAliaser))),
cxEvaluated(target => new ShareRegistry(target.get(NamespaceAliaser))),
));

export class ShareRegistry {
Expand All @@ -21,7 +22,7 @@ export class ShareRegistry {

private readonly _sharers = new Map<Share<unknown>, ValueTracker<Sharers>>();

constructor(readonly nsAlias: DefaultNamespaceAliaser) {
constructor(readonly nsAlias: NamespaceAliaser) {
}

addSharer(
Expand Down

0 comments on commit 6491249

Please sign in to comment.