diff --git a/packages/preact/preact/src/frame.ts b/packages/preact/preact/src/frame.ts index f4bdf450..f5505172 100644 --- a/packages/preact/preact/src/frame.ts +++ b/packages/preact/preact/src/frame.ts @@ -52,7 +52,7 @@ export class ComponentFrame { ): FinalizedFormula { const frame = ComponentFrame.#frames.get(component); - verify( + verify?.( frame, isPresent, expected?.when("in Preact's _diff hook").as("a tracking frame"), @@ -101,7 +101,7 @@ export class ComponentFrame { } #end(subscription: (() => void) | undefined) { - verify( + verify?.( this.#active, isPresent, expected?.when("in preact's _diff hook").as("an active tracking frame"), diff --git a/packages/universal/collections/src/decorator.ts b/packages/universal/collections/src/decorator.ts index 755e9790..e17df8ca 100644 --- a/packages/universal/collections/src/decorator.ts +++ b/packages/universal/collections/src/decorator.ts @@ -10,7 +10,7 @@ export const cached = ( ): void => { const get = descriptor.get; - verify( + verify?.( get, isPresent, expected?.(`the target of @cached`) diff --git a/packages/universal/verify/index.ts b/packages/universal/verify/index.ts index 61324aca..268f5ade 100644 --- a/packages/universal/verify/index.ts +++ b/packages/universal/verify/index.ts @@ -26,7 +26,7 @@ export { export { type TypeOf } from "./src/assertions/types.js"; export { type Expectation, VerificationError } from "./src/verify.js"; -export const expected: typeof expectedDev = import.meta.env.DEV ? expectedDev : (noop as typeof expectedDev) +export const expected: typeof expectedDev = import.meta.env.DEV ? expectedDev : null as any export const hasType: typeof hasTypeDev = import.meta.env.DEV ? hasTypeDev : (noop as typeof hasTypeDev) export const isOneOf: typeof isOneOfDev = import.meta.env.DEV ? isOneOfDev : (noop as typeof isOneOfDev) diff --git a/packages/universal/verify/src/assertions/basic.ts b/packages/universal/verify/src/assertions/basic.ts index 20a93fe8..586e7f7b 100644 --- a/packages/universal/verify/src/assertions/basic.ts +++ b/packages/universal/verify/src/assertions/basic.ts @@ -8,8 +8,6 @@ export function isPresent(value: T): value is Exclude { return value !== null && value !== undefined; } -expected.associate(isPresent, expected.toBe("present")); - export function exhaustive(_value: never, type?: string): never { if (type) { throw Error(`unexpected types left in ${type}`); @@ -66,26 +64,12 @@ export function isObject(value: unknown): value is object { return typeof value === "object" && value !== null; } -expected.associate( - isObject, - expected - .toBe("an object") - .butGot((value) => (value === null ? "null" : typeof value)), -); - export function isWeakKey(value: unknown): value is Record { return ( (typeof value === "object" || typeof value === "function") && value !== null ); } -expected.associate( - isWeakKey, - expected - .toBe("an object or function") - .butGot((value) => (value === null ? "null" : typeof value)), -); - interface HasLength { (value: T[]): value is FixedArray; (value: T[] | readonly T[]): value is ReadonlyFixedArray; @@ -107,8 +91,6 @@ export const hasItems = isPresentArray; // return value.length > 0; // } -expected.associate(hasItems, expected.toHave(`at least one item`)); - export function isNullable( verifier: (value: In) => value is Out, ): (value: In | null) => value is Out | null { @@ -145,3 +127,22 @@ export function isNullable( return verify; } + + +if (import.meta.env.DEV) { + expected.associate(isPresent, expected.toBe("present")); + expected.associate(hasItems, expected.toHave(`at least one item`)); + expected.associate( + isWeakKey, + expected + .toBe("an object or function") + .butGot((value) => (value === null ? "null" : typeof value)), + ); + expected.associate( + isObject, + expected + .toBe("an object") + .butGot((value) => (value === null ? "null" : typeof value)), + ); + +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3e7769c6..5e8c480c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1786,6 +1786,9 @@ importers: rollup-plugin-copy: specifier: ^3.5.0 version: 3.5.0 + rollup-plugin-prettier: + specifier: ^4.1.1 + version: 4.1.1(prettier@3.1.1)(rollup@4.4.1) rollup-plugin-ts: specifier: ^3.4.5 version: 3.4.5(@swc/core@1.3.96)(@swc/helpers@0.5.3)(rollup@4.4.1)(typescript@5.3.3) @@ -4406,6 +4409,13 @@ packages: resolution: {integrity: sha512-219LSCO9HPcoXcRTC6DbCs0FRhZgBnEMzf16RRqkT40WbkKx3mOeQuz3e2XqbfhOz/AHfbru0kzB1n1RCAsIIg==} dev: false + /@types/prettier@3.0.0: + resolution: {integrity: sha512-mFMBfMOz8QxhYVbuINtswBp9VL2b4Y0QqYHwqLz3YbgtfAcat2Dl6Y1o4e22S/OVE6Ebl9m7wWiMT2lSbAs1wA==} + deprecated: This is a stub types definition. prettier provides its own type definitions, so you do not need this installed. + dependencies: + prettier: 3.1.1 + dev: false + /@types/prop-types@15.7.5: resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} dev: true @@ -5760,6 +5770,11 @@ packages: resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + /diff@5.1.0: + resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} + engines: {node: '>=0.3.1'} + dev: false + /dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -7996,10 +8011,26 @@ packages: resolution: {integrity: sha512-/u14pXGviLaweY5JI0IUzgzF2J6Ne8INyzAZjImcryjgkZ+ebruBxy2/JaOOkTqScddcYtakjhSaeemV8lR0tA==} dev: true + /lodash.hasin@4.5.2: + resolution: {integrity: sha512-AFAitwTSq1Ka/1J9uBaVxpLBP5OI3INQvkl4wKcgIYxoA0S3aqO1QWXHR9aCcOrWtPFqP7GzlFncZfe0Jz0kNw==} + dev: false + + /lodash.isempty@4.4.0: + resolution: {integrity: sha512-oKMuF3xEeqDltrGMfDxAPGIVMSSRv8tbRSODbrs4KGsRRLEhrW8N8Rd4DRgB2+621hY8A8XwwrTVhXWpxFvMzg==} + dev: false + + /lodash.isnil@4.0.0: + resolution: {integrity: sha512-up2Mzq3545mwVnMhTDMdfoG1OurpA/s5t88JmQX809eH3C8491iu2sfKhTfhQtKY78oPNhiaHJUpT/dUDAAtng==} + dev: false + /lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} dev: true + /lodash.omitby@4.6.0: + resolution: {integrity: sha512-5OrRcIVR75M288p4nbI2WLAf3ndw2GD9fyNv3Bc15+WCxJDdZ4lYndSxGd7hnG6PVjiJTeJE2dHEGhIuKGicIQ==} + dev: false + /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: true @@ -8947,7 +8978,6 @@ packages: resolution: {integrity: sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==} engines: {node: '>=14'} hasBin: true - dev: true /pretty-format@27.5.1: resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==} @@ -9330,6 +9360,24 @@ packages: is-plain-object: 3.0.1 dev: false + /rollup-plugin-prettier@4.1.1(prettier@3.1.1)(rollup@4.4.1): + resolution: {integrity: sha512-ugpi/EqW12yJa4NO3o4f/wt/YHwiQovVGC2jxZgxuKO9osjt4lVxVA427+itl87XmQc6089ZkpDc6OpaOZKWgQ==} + engines: {node: '>=6.0.0'} + peerDependencies: + prettier: ^1.0.0 || ^2.0.0 || ^3.0.0 + rollup: ^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0 + dependencies: + '@types/prettier': 3.0.0 + diff: 5.1.0 + lodash.hasin: 4.5.2 + lodash.isempty: 4.4.0 + lodash.isnil: 4.0.0 + lodash.omitby: 4.6.0 + magic-string: 0.30.5 + prettier: 3.1.1 + rollup: 4.4.1 + dev: false + /rollup-plugin-ts@3.4.5(@swc/core@1.3.96)(@swc/helpers@0.5.3)(rollup@4.4.1)(typescript@5.3.3): resolution: {integrity: sha512-9iCstRJpEZXSRQuXitlSZAzcGlrqTbJg1pE4CMbEi6xYldxVncdPyzA2I+j6vnh73wBymZckerS+Q/iEE/M3Ow==} engines: {node: '>=16.15.1', npm: '>=7.0.0', pnpm: '>=3.2.0', yarn: '>=1.13'} diff --git a/workspace/dev-compile/package.json b/workspace/dev-compile/package.json index 77ce5ff3..7903ccd9 100644 --- a/workspace/dev-compile/package.json +++ b/workspace/dev-compile/package.json @@ -26,6 +26,7 @@ "rollup": "^4.1.4", "rollup-plugin-copy": "^3.5.0", "rollup-plugin-ts": "^3.4.5", + "rollup-plugin-prettier": "^4.1.1", "typescript": "^5.2.2" }, "devDependencies": { diff --git a/workspace/dev-compile/src/rollup/rollup.ts b/workspace/dev-compile/src/rollup/rollup.ts index 74408b36..5357bc0e 100644 --- a/workspace/dev-compile/src/rollup/rollup.ts +++ b/workspace/dev-compile/src/rollup/rollup.ts @@ -11,6 +11,7 @@ import externals from "./plugins/external.js"; import importMeta from "./plugins/import-meta.js"; import typescript from "./plugins/typescript.js"; import type { RollupPlugin } from "./utils.js"; +import prettier from 'rollup-plugin-prettier'; const MODES = ["development", "production", undefined] as const; @@ -81,15 +82,16 @@ function compilePackage(pkg: PackageInfo, options: CompileOptions): RollupOption format: { comments: false }, - // prevent any compression compress: { dead_code: true, module: true, - keep_fargs: false, - passes: 5 + keep_fargs: false }, mangle: false, }), + prettier({ + parser: 'babel' + }) ] : []) ], }));