Skip to content

Commit

Permalink
feat: fast-element utilities, hooks, disposable, and binding observer…
Browse files Browse the repository at this point in the history
… improvements (#6030)

* chore: rebase to accept typescript and api-extractor updates

* feat: enable subscribing deeply to observables

* feat: introduce Disposable interface and use throughout fast-element

* test: add initial tests for makeObservable utility

* test: add initial tests for the watch utility

* feat: initial prototype of useState() and useEffect() hooks

* test: add tests for the useState() hook

* refactor: remove disconnect from BindingObserve and add  sync updates

* chore: fixing up file extension in tests and for disposable

* chore: various fixes for Node16 and package exports

* chore: update core web component library webpack and karma config

* Change files

* fix: temporary fix for site build

* chore: fix adaptive-ui build and test

* Change files

* Users/chhol/remove unnecessary site utilities (#6036)

* remove site util source directory and update website webpack loaders for assets

* fixing fast-foundation dependency version to install workspace version

* fixing test errors in fast-site-utilities

* removing eslint from site-utilties

* fixing path to spect files in adaptive-ui

* fixing color-explorer build

* remove babel-loader from website

Co-authored-by: nicholasrice <[email protected]>

* Change files

* chore: remove prettier from site-utilities

Co-authored-by: EisenbergEffect <[email protected]>
Co-authored-by: Chris Holt <[email protected]>
Co-authored-by: nicholasrice <[email protected]>
  • Loading branch information
4 people authored May 26, 2022
1 parent 4291216 commit e5b97ac
Show file tree
Hide file tree
Showing 179 changed files with 1,274 additions and 2,861 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: fix adaptive-ui build and test",
"packageName": "@microsoft/adaptive-ui",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "major",
"comment": "feat: add utilities and hooks, and change exports",
"packageName": "@microsoft/fast-element",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "major",
"comment": "fix: update to latest fast-element and change exports",
"packageName": "@microsoft/fast-foundation",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: various fixes for Node16 and package exports",
"packageName": "@microsoft/fast-react-wrapper",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "major",
"comment": "fix: update to latest fast-element utilities",
"packageName": "@microsoft/fast-router",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "chore: fix broken build",
"packageName": "@microsoft/fast-web-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
6 changes: 1 addition & 5 deletions packages/utilities/adaptive-ui/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"extends": ["@microsoft/eslint-config-fast-dna", "prettier"],
"rules": {
"@typescript-eslint/no-non-null-assertion": "off",
"import/extensions": [
"error",
"always"
]
"@typescript-eslint/no-non-null-assertion": "off"
}
}
2 changes: 1 addition & 1 deletion packages/utilities/adaptive-ui/.mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"colors": true,
"recursive": true,
"timeout": 5000,
"spec": "test/**/*.spec.js"
"spec": "dist/**/*.spec.js"
}
10 changes: 8 additions & 2 deletions packages/utilities/adaptive-ui/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../../api-extractor.json"
}
"extends": "../../../api-extractor.json",
"mainEntryPointFilePath": "./dist/dts/index.d.ts",
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "./dist/adaptive-ui.untrimmed.d.ts",
"betaTrimmedFilePath": "./dist/adaptive-ui.d.ts"
}
}
4 changes: 2 additions & 2 deletions packages/utilities/adaptive-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
},
"homepage": "https://fast.design",
"scripts": {
"build": "tsc -p ./tsconfig.build.json && yarn doc",
"build:tests": "tsc -p ./tsconfig.test.json",
"build": "tsc -p ./tsconfig.json && yarn doc",
"build:tests": "tsc -p ./tsconfig.json",
"clean:dist": "node ../../../build/clean.js dist",
"doc": "api-extractor run --local",
"doc:ci": "api-extractor run",
Expand Down
11 changes: 0 additions & 11 deletions packages/utilities/adaptive-ui/tsconfig.build.json

This file was deleted.

16 changes: 15 additions & 1 deletion packages/utilities/adaptive-ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"declarationDir": "dist/dts",
"outDir": "dist/esm",
"types": ["mocha"]
"experimentalDecorators": true,
"target": "es2015",
"module": "ESNext",
"moduleResolution": "Node16",
"importHelpers": true,
"jsx": "react",
"types": [
"mocha",
"webpack-env"
],
"lib": [
"DOM",
"ES2015"
]
},
"include": ["src"]
}
8 changes: 0 additions & 8 deletions packages/utilities/adaptive-ui/tsconfig.test.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/utilities/fast-react-wrapper/src/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { attr, customElement, DOM, FASTElement, html, nullableNumberConverter, observable, Updates } from '@microsoft/fast-element';
import React from "react";
import ReactDOM from "react-dom";
import { uniqueElementName } from '@microsoft/fast-foundation/testing.js';
import { uniqueElementName } from '@microsoft/fast-foundation/testing';
import { expect } from "chai";
import { DesignSystem, FoundationElement } from "@microsoft/fast-foundation";
import { provideReactWrapper } from './index.js';
Expand Down
7 changes: 2 additions & 5 deletions packages/utilities/fast-web-utilities/karma.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ module.exports = function (config: any) {
require("karma-chrome-launcher"),
require("karma-firefox-launcher"),
],
files: [`dist/__test__/${setup}.js`],
files: [`dist/__test__/${setup}.cjs`],
preprocessors: {
[`dist/__test__/${setup}.js`]: ["webpack", "sourcemap"],
[`dist/__test__/${setup}.cjs`]: ["webpack", "sourcemap"],
},
webpackMiddleware: {
// webpack-dev-middleware configuration
Expand All @@ -65,12 +65,9 @@ module.exports = function (config: any) {
hints: false,
},
optimization: {
namedModules: false,
namedChunks: false,
nodeEnv: false,
usedExports: true,
flagIncludedChunks: false,
occurrenceOrder: false,
sideEffects: true,
concatenateModules: true,
splitChunks: {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/fast-web-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"karma-mocha-reporter": "^2.2.5",
"karma-source-map-support": "^1.4.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.2",
"karma-webpack": "^5.0.0",
"mocha": "^7.1.2",
"prettier": "2.0.2",
"ts-loader": "^4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/fast-web-utilities/src/aria.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { Orientation } from "./aria";
import { Orientation } from "./aria.js";

describe("aria-orientation", () => {
it("should correctly return orientation values", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/fast-web-utilities/src/array.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { findLastIndex } from "./array";
import { findLastIndex } from "./array.js";

describe("findLastIndex", (): void => {
it("should return -1 when array is empty", (): void => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { classNames } from "./class-names";
import { classNames } from "./class-names.js";

describe("classNames", (): void => {
it("should return a string when invalid values are provided", (): void => {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/fast-web-utilities/src/dom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getDisplayedNodes,
isHTMLElement,
resetDocumentCache,
} from "./dom";
} from "./dom.js";

chai.use(spies);

Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/fast-web-utilities/src/html.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { convertStylePropertyPixelsToNumber, getClientRectWithMargin } from "./html";
import { convertStylePropertyPixelsToNumber, getClientRectWithMargin } from "./html.js";

describe("getClientRectWithMargin", () => {
const mockWidth: number = 120;
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/fast-web-utilities/src/numbers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { inRange, limit, wrapInBounds } from "./numbers";
import { inRange, limit, wrapInBounds } from "./numbers.js";

describe("wrapInBounds", () => {
it("should not throw if any parameters are null", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/fast-web-utilities/src/query.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { parseQueryStringParams } from "./query";
import { parseQueryStringParams } from "./query.js";

describe("parseQueryStringParams", (): void => {
it("basic query string", (): void => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "chai";
import { RtlScrollConverter } from "./rtl-scroll-converter";
import { Direction } from "./localization";
import { RtlScrollConverter } from "./rtl-scroll-converter.js";
import { Direction } from "./localization.js";

function getDummyDiv(): HTMLDivElement {
const dummy: HTMLDivElement = document.createElement("div");
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/fast-web-utilities/src/strings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
pascalCase,
spinalCase,
startsWith,
} from "./strings";
} from "./strings.js";

describe("format", (): void => {
it("should correctly manage undefined by returning an unformatted string", (): void => {
Expand Down
20 changes: 0 additions & 20 deletions packages/web-components/fast-element/.eslintrc.cjs

This file was deleted.

19 changes: 19 additions & 0 deletions packages/web-components/fast-element/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": ["@microsoft/eslint-config-fast-dna", "prettier"],
"rules": {
"max-classes-per-file": "off",
"no-case-declarations": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"{}": false,
"Function": false,
"Object": false
},
"extendDefaults": true
}
]
}
}
13 changes: 8 additions & 5 deletions packages/web-components/fast-element/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ export const BindingMode: Readonly<{
}>;

// @public
export interface BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier {
disconnect(): void;
export interface BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier, Disposable {
observe(source: TSource, context?: ExecutionContext<TParent>): TReturn;
records(): IterableIterator<ObservationRecord>;
setMode(isAsync: boolean): void;
}

// @public
Expand Down Expand Up @@ -301,6 +301,11 @@ export type DefaultTwoWayBindingOptions = DefaultBindingOptions & {
fromView?: (value: any) => any;
};

// @public
export interface Disposable {
dispose(): void;
}

// @public
export const DOM: Readonly<{
queueUpdate: (callable: Callable) => void;
Expand Down Expand Up @@ -826,7 +831,6 @@ export interface SubtreeDirectiveOptions<T = any> extends Omit<NodeBehaviorOptio

// @public
export interface SyntheticView<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>> extends View<TSource, TParent, TContext> {
dispose(): void;
readonly firstChild: Node;
insertBefore(node: Node): void;
readonly lastChild: Node;
Expand Down Expand Up @@ -928,10 +932,9 @@ export interface ValueConverter {
}

// @public
export interface View<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>> {
export interface View<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>> extends Disposable {
bind(source: TSource, context: TContext): void;
readonly context: TContext | null;
dispose(): void;
readonly source: TSource | null;
unbind(): void;
}
Expand Down
Loading

0 comments on commit e5b97ac

Please sign in to comment.