-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Features & Fixes: DOM in core, less DOM writes, N Composition, (#450)
* Use N Flow * test: remove mjs from scripts * test: rename mjs files to js files for codesandbox compatibility * test: add js extension to package.json scripts * test: use `replace` instead of `replaceAll` for Node 14 compatibility * Update dependencies, include DOM for debugging * Update how default theme is applied * Apply default theme after reset * cleanup & composer update * Fix expect.js export * update dependencies, fs import * Update composition * Fix composer.inline reference * Fix issue with inline(css, classNames) * Update tests, inheritance * test: log composer to investigate "Can't find variable: inline" bug * test: only default to composition.type * Add #450 test * fix: additive default variants * fix: theme is object by default * test: update hash string mechanism to increase chances of unique hashes * test: and what of component styles? hash them out... all of them... * test: fix hashes * Remove unused dom.js * Update package.json * Delete deepMerge.js
- Loading branch information
1 parent
a3bd5b4
commit be2734e
Showing
36 changed files
with
844 additions
and
516 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import process from 'node:process' | ||
|
||
/** Root directory. */ | ||
export const rootUrl = new URL('../../', import.meta.url) | ||
|
||
/** Packages directory. */ | ||
export const packagesUrl = new URL('packages/', rootUrl) | ||
|
||
/** Core package directory. */ | ||
export const corePackageUrl = new URL('core/', packagesUrl) | ||
|
||
/** Core tests directory. */ | ||
export const coreTestsUrl = new URL('tests/', corePackageUrl) | ||
|
||
/** React package directory. */ | ||
export const reactPackageUrl = new URL('react/', packagesUrl) | ||
|
||
/** React tests directory. */ | ||
export const reactTestsUrl = new URL('tests/', reactPackageUrl) | ||
|
||
/** Current file href. */ | ||
export const argv1Url = new URL(process.argv[1], 'file:').href |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { deepEqual as toEqual, equal as toBe, notDeepEqual as toNotEqual, notEqual as toNotBe } from 'node:assert/strict' | ||
|
||
export default function expect(actual) { | ||
return { | ||
/** Tests for strict equality between the actual and expected parameters. */ | ||
toBe: toBe.bind(this, actual), | ||
/** Tests that the actual object is an instance of the expected class. */ | ||
toBeInstanceOf: toBeInstanceOf.bind(this, actual), | ||
/** Tests for deep equality between the actual and expected parameters. */ | ||
toEqual: toEqual.bind(this, actual), | ||
/** Tests that the actual function does throw when it is called. */ | ||
toThrow: toThrow.bind(this, actual), | ||
|
||
/** Tests for strict inequality between the actual and expected parameters. */ | ||
toNotBe: toNotBe.bind(this, actual), | ||
/** Tests that the actual object is not an instance of the expected class. */ | ||
toNotBeInstanceOf: toNotBeInstanceOf.bind(this, actual), | ||
/** Tests for deep inequality between the actual and expected parameters. */ | ||
toNotEqual: toNotEqual.bind(this, actual), | ||
/** Tests that the actual function does not throw when it is called. */ | ||
toNotThrow: toNotThrow.bind(this, actual), | ||
} | ||
} | ||
|
||
/** Tests that the actual object is an instance of the expected class. */ | ||
function toBeInstanceOf(actual, expected) { | ||
if (!(actual instanceof expected)) { | ||
throw new AssertionError({ | ||
message: 'Expected value to be instance:', | ||
operator: 'instanceOf', | ||
actual, | ||
expected, | ||
stackStartFn: toBeInstanceOf, | ||
}) | ||
} | ||
} | ||
|
||
/** Tests that the actual object is not an instance of the expected class. */ | ||
function toNotBeInstanceOf(actual, expected) { | ||
if (actual instanceof expected) { | ||
throw new AssertionError({ | ||
message: 'Expected value to be instance:', | ||
operator: 'instanceOf', | ||
actual, | ||
expected, | ||
stackStartFn: toNotBeInstanceOf, | ||
}) | ||
} | ||
} | ||
|
||
/** Tests that the actual function does throw when it is called. */ | ||
async function toThrow(actualFunction, expected) { | ||
let actual = undefined | ||
|
||
try { | ||
actual = await actualFunction() | ||
} catch (error) { | ||
// do nothing and continue | ||
return | ||
} | ||
|
||
throw new AssertionError({ | ||
message: 'Expected exception:', | ||
operator: 'throws', | ||
stackStartFn: toThrow, | ||
actual, | ||
expected, | ||
}) | ||
} | ||
|
||
/** Tests that the actual function does not throw when it is called. */ | ||
async function toNotThrow(actualFunction, expected) { | ||
let actual = undefined | ||
|
||
try { | ||
actual = await actualFunction() | ||
|
||
// do nothing and continue | ||
return | ||
} catch (error) { | ||
throw new AssertionError({ | ||
message: 'Unexpected exception:', | ||
operator: 'doesNotThrow', | ||
stackStartFn: toThrow, | ||
actual, | ||
expected, | ||
}) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
export default Object | ||
import { toPrimitive } from './Symbol.js' | ||
|
||
export const { assign, create, defineProperties, getOwnPropertyDescriptors } = Object | ||
|
||
export const define = (target, append) => defineProperties(target, getOwnPropertyDescriptors(append)) | ||
export const createComponent = (base, prop, props) => | ||
assign(defineProperties(base, getOwnPropertyDescriptors(props)), { | ||
[toPrimitive]() { | ||
return base[prop] | ||
}, | ||
toString() { | ||
return base[prop] | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const { ownKeys } = Reflect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { toPrimitive } from './Symbol.js' | ||
|
||
export default class StringArray extends Array { | ||
toString() { | ||
return this.join('') | ||
} | ||
|
||
get hasChanged() { | ||
const cssText = String(this) | ||
|
||
return () => cssText !== String(this) | ||
} | ||
} | ||
|
||
StringArray.prototype[toPrimitive] = StringArray.prototype.toString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { toPrimitive } from './Symbol.js' | ||
import { from } from './Array.js' | ||
|
||
export default class StringSet extends Set { | ||
toString() { | ||
return from(this).join('') | ||
} | ||
|
||
get hasChanged() { | ||
const { size } = this | ||
|
||
return () => size < this.size | ||
} | ||
} | ||
|
||
StringSet.prototype[toPrimitive] = StringSet.prototype.toString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const { toPrimitive } = Symbol | ||
|
||
export const $$composers = Symbol.for('sxs.composers') |
Oops, something went wrong.